conformtools 0.6.11 → 0.6.13
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 -1
- package/dist/{account-IUWNSDG5.js → account-F54SG45Q.js} +1 -1
- package/dist/agent-hook-setup-RTQT5JEN.js +3 -0
- package/dist/{analysis-engine-M7W32RRC.js → analysis-engine-UWIK7AYB.js} +1 -1
- package/dist/{bridge-SV7PCLQY.js → bridge-PWYOJ7E7.js} +1 -1
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-2WBGXD27.js → chunk-4BTTR6U3.js} +2 -2
- package/dist/{chunk-NSQP6CTA.js → chunk-4VFDGL4E.js} +1 -1
- package/dist/{chunk-THVX57I3.js → chunk-6WLSIH2N.js} +1 -1
- package/dist/{chunk-DGXZB7MO.js → chunk-7W5AFZYX.js} +1 -1
- package/dist/chunk-B54TEGMG.js +5 -0
- package/dist/chunk-BTS3DFPD.js +7 -0
- package/dist/chunk-BYMCZJBQ.js +3 -0
- package/dist/{chunk-64X5DLH5.js → chunk-EP4L2BWV.js} +1 -1
- package/dist/chunk-ERUN634Q.js +6 -0
- package/dist/{chunk-6HZP2OJA.js → chunk-G3HBKJ5L.js} +1 -1
- package/dist/{chunk-IK6RKNS5.js → chunk-H4BU5WA6.js} +1 -1
- package/dist/{chunk-XIAG7ACN.js → chunk-I2Y2P5NH.js} +2 -2
- package/dist/{chunk-2CY2OOOJ.js → chunk-J43UCJ6G.js} +1 -1
- package/dist/chunk-L3HRAIDR.js +8 -0
- package/dist/chunk-LKQTE6T5.js +158 -0
- package/dist/chunk-LRGA6QJQ.js +514 -0
- package/dist/{chunk-JXTRQ3UG.js → chunk-LZRCXSUJ.js} +1 -1
- package/dist/chunk-NZLL44HU.js +3 -0
- package/dist/chunk-OD445COC.js +7 -0
- package/dist/chunk-XI6XF7FQ.js +3 -0
- package/dist/{chunk-6VP6G7CY.js → chunk-Y455Y6V4.js} +4 -4
- package/dist/{claude-setup-REU4AOKX.js → claude-setup-NGZ5NDYH.js} +1 -1
- package/dist/cli.js +9 -9
- package/dist/engine-6ACEWA4S.js +5 -0
- package/dist/framing-P5RGN5V3.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-B2TLLEMI.js → h264-JI62TU4W.js} +1 -1
- package/dist/{h264-mxf-3GED5PBT.js → h264-mxf-J2QPZO4U.js} +1 -1
- package/dist/hook.js +3 -0
- package/dist/host-relink-76CFY32O.js +10 -0
- package/dist/hosted-L26AGRIY.js +3 -0
- package/dist/hosts-TBHEPV6A.js +3 -0
- package/dist/http.js +3 -3
- package/dist/{inspect-RJFJQSHZ.js → inspect-U656APGR.js} +2 -2
- package/dist/{isobmff-C5A2EFKH.js → isobmff-UISATYUR.js} +1 -1
- package/dist/{mc-video-ARKIHPA7.js → mc-video-LSTKUKNL.js} +1 -1
- package/dist/mcp.js +8 -7
- package/dist/{media-22VAJIVT.js → media-XBNKYKB7.js} +1 -1
- package/dist/mxf-ZL57VJ3C.js +3 -0
- package/dist/{ops-BCTGDBXT.js → ops-ZQEQXW2N.js} +1 -1
- package/dist/probe-ZDX6XNRF.js +3 -0
- package/dist/{r3d-FX7V4BIE.js → r3d-R4TLYJVE.js} +1 -1
- package/dist/resolve-bridge.py +31 -2
- package/dist/{sequence-patch-CN4VC5W3.js → sequence-patch-C2QRIT5V.js} +1 -1
- package/dist/store-JNWELX35.js +3 -0
- package/dist/timeline-JONFBIA3.js +3 -0
- package/package.json +5 -5
- package/dist/chunk-2QT5MMBP.js +0 -499
- package/dist/chunk-5YWO2LBG.js +0 -3
- package/dist/chunk-6NLB5TZ2.js +0 -7
- package/dist/chunk-G3SZDPDS.js +0 -3
- package/dist/chunk-RKIRHMON.js +0 -5
- package/dist/chunk-ROPKSAFP.js +0 -6
- package/dist/chunk-S6KP52OG.js +0 -8
- package/dist/chunk-VE423Z2L.js +0 -132
- package/dist/chunk-XF3YMBI7.js +0 -3
- package/dist/engine-274GQLUB.js +0 -5
- package/dist/framing-ZTMYZR2S.js +0 -3
- package/dist/host-relink-FHNXXMHW.js +0 -10
- package/dist/hosted-BWAYLJXR.js +0 -3
- package/dist/hosts-Y6HGDRLM.js +0 -3
- package/dist/mxf-CQSI6H5T.js +0 -3
- package/dist/probe-72QZKMCC.js +0 -3
- package/dist/store-H676BOKI.js +0 -3
- package/dist/timeline-5TGA5HBY.js +0 -3
- /package/dist/{still-WUCFH2WX.js → still-4UR35GZH.js} +0 -0
package/dist/chunk-2QT5MMBP.js
DELETED
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{c as zg,d as Gg,e as Kg}from"./chunk-XF3YMBI7.js";import{a as Vg}from"./chunk-RKIRHMON.js";import{a as Dg,b as jg,c as Zs,d as Bg,e as qg,j as un}from"./chunk-XIAG7ACN.js";import{a as xa,b as Lg,c as Ng}from"./chunk-2CY2OOOJ.js";import{d as Ug,e as Hg,f as Wg}from"./chunk-ROPKSAFP.js";import{$ as mh,$a as q1,$b as Ys,Aa as Dh,Ab as Vc,Ac as kg,Ba as jh,Bb as Vs,Bc as ru,Ca as Bh,Cb as Js,Cc as _g,Da as aa,Db as vo,Dc as vg,Ea as qh,Eb as Z1,Ec as Tg,Fa as Uh,Fb as eg,Fc as xg,G as f,Ga as Hh,Gb as tg,Gc as Sg,H as Pf,Ha as go,Hb as ng,Hc as ou,I as Lc,Ia as Wh,Ib as Jc,J as th,Ja as Qt,Jb as wa,K as Nc,Ka as zh,Kb as rg,L as Bt,La as Uc,Lb as og,M as es,Ma as Gh,Mb as sg,Mc as $g,N as Dc,Na as Kh,Nb as ig,O as oa,Oa as Vh,Ob as Xs,Oc as Rg,P as oh,Pa as Jh,Pb as Qs,Pc as Cg,Q as sh,Qa as Xh,Qb as ag,Qc as Eg,R as ih,Ra as la,Rc as Ag,S as ah,Sa as Yh,Sc as Ig,T as lh,Ta as Zh,Tc as Mg,U as ch,Ua as e1,Uc as Pg,V as uh,Va as Un,Vc as Ta,W as dh,Wc as Og,X as jc,Xa as N1,Xb as Xc,Y as Bc,Ya as D1,Yb as Qc,Z as ph,Za as j1,Zb as lg,_ as sa,_a as B1,_b as cg,aa as fh,ab as U1,ba as hh,bb as _o,bc as ug,ca as qc,cb as Kc,cc as dg,da as gh,db as ya,dc as pg,ea as bh,eb as H1,ec as Yc,fa as ia,fb as W1,fc as Zc,ga as yh,gc as eu,ha as wh,hc as tu,ia as kh,ja as _h,ka as vh,la as Th,lc as mg,ma as xh,mc as ka,na as Sh,nc as nu,oa as $h,oc as _a,pa as Rh,pc as fg,qa as Ch,ra as Eh,rc as ts,sa as Ah,sb as G1,sc as Tr,ta as Ih,tb as K1,tc as hg,ua as Mh,ub as V1,uc as gg,va as Ph,wa as Fh,wb as J1,wc as bg,xa as Oh,xb as X1,xc as yg,ya as Lh,yb as Q1,yc as va,za as Nh,zb as Y1,zc as wg}from"./chunk-VE423Z2L.js";import{a as wo,b as ko,c as Gs,d as Gc,f as fa,g as Ks,i as ha,k as mt,l as M1,m as P1,p as ga,s as F1,t as ba,u as O1,v as L1}from"./chunk-6VP6G7CY.js";import{a as jr,b as Yn,c as I1}from"./chunk-PFZVET7S.js";import{e as z1}from"./chunk-LVGGCRDW.js";import{a as Af,c as If,e as Mf}from"./chunk-IK6RKNS5.js";import{c as Qh}from"./chunk-JV7TZDKJ.js";import{b as R1,e as C1,f as ma}from"./chunk-6V4OEOOX.js";import{b as S1,c as $1}from"./chunk-RGMTLNMF.js";import{M as t1,S as ca}from"./chunk-C2ESM27Z.js";import{a as v1,b as T1,d as x1,e as pa}from"./chunk-XDI6CPPV.js";import{d as E1,e as A1,f as bo,i as yo}from"./chunk-JXTRQ3UG.js";import{c as Jg,d as su,e as iu,f as au,g as Xg,h as Qg,i as Yg,k as Zg,m as eb,n as tb}from"./chunk-2WBGXD27.js";import{l as Fg}from"./chunk-N34DQ6MH.js";import{a as nh,b as He,d as jt,e as rh,f as ur}from"./chunk-NU3X7P4N.js";import{A as l1,E as c1,Ea as w1,F as u1,Fa as k1,G as Wc,Ha as _1,Ia as Dr,L as d1,N as p1,P as m1,Q as f1,S as h1,T as g1,V as zc,c as ua,d as n1,f as r1,h as o1,i as da,l as s1,m as i1,ma as b1,v as Hc,z as a1,za as y1}from"./chunk-DPA26AOI.js";import{A as qn,B as bt,C as Xt,D as Zf,E as ra,F as eh,a as Ws,b as Bf,c as qf,d as Uf,e as Ic,f as _r,g as Hf,h as vr,i as Wf,j as zf,k as Gf,l as Mc,m as Kf,n as Pc,o as Vf,p as Jt,q as zs,r as Fc,s as Jf,t as Xf,u as Oc,v as Qf,w as ho,x as Yf}from"./chunk-S6KP52OG.js";import{a as Of,e as Lf,f as Ac,j as Nf,l as Df,m as jf}from"./chunk-6NLB5TZ2.js";import{b as na,c as Wt,d as Ff}from"./chunk-64X5DLH5.js";import{a as L,b as X,c as _t,d as J}from"./chunk-PHAMF4JF.js";import{$ as B,A as Ke,B as Vt,D as Zo,E as fo,F as Ht,H as ea,J as Dt,K as Rt,L as Cc,N as lr,O as Rf,P as cr,Q as Cf,V as Ec,W as Ef,X as ta,Y as ie,Z as xn,_ as Qn,b as en,c as $c,g as ln,i as Rc,j as Tf,k as xf,m as Xe,n as Nr,o as Nt,q as Sf,r as mo,s as At,t as nt,u as Fn,v as $f,w as tn,x as et,y as cn,z as Ve}from"./chunk-G3SZDPDS.js";import{c as Ce,f as _S}from"./chunk-PSANHDZM.js";var nn=Ce(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var ry;(function(e){e[e.NONE=0]="NONE";let n=1;e[e._abstract=n]="_abstract";let r=n+1;e[e._accessor=r]="_accessor";let o=r+1;e[e._as=o]="_as";let s=o+1;e[e._assert=s]="_assert";let i=s+1;e[e._asserts=i]="_asserts";let a=i+1;e[e._async=a]="_async";let l=a+1;e[e._await=l]="_await";let c=l+1;e[e._checks=c]="_checks";let u=c+1;e[e._constructor=u]="_constructor";let p=u+1;e[e._declare=p]="_declare";let d=p+1;e[e._enum=d]="_enum";let m=d+1;e[e._exports=m]="_exports";let h=m+1;e[e._from=h]="_from";let g=h+1;e[e._get=g]="_get";let y=g+1;e[e._global=y]="_global";let k=y+1;e[e._implements=k]="_implements";let b=k+1;e[e._infer=b]="_infer";let w=b+1;e[e._interface=w]="_interface";let _=w+1;e[e._is=_]="_is";let v=_+1;e[e._keyof=v]="_keyof";let R=v+1;e[e._mixins=R]="_mixins";let S=R+1;e[e._module=S]="_module";let T=S+1;e[e._namespace=T]="_namespace";let x=T+1;e[e._of=x]="_of";let $=x+1;e[e._opaque=$]="_opaque";let U=$+1;e[e._out=U]="_out";let E=U+1;e[e._override=E]="_override";let z=E+1;e[e._private=z]="_private";let G=z+1;e[e._protected=G]="_protected";let D=G+1;e[e._proto=D]="_proto";let te=D+1;e[e._public=te]="_public";let we=te+1;e[e._readonly=we]="_readonly";let ge=we+1;e[e._require=ge]="_require";let ve=ge+1;e[e._satisfies=ve]="_satisfies";let oe=ve+1;e[e._set=oe]="_set";let P=oe+1;e[e._static=P]="_static";let M=P+1;e[e._symbol=M]="_symbol";let O=M+1;e[e._type=O]="_type";let V=O+1;e[e._unique=V]="_unique";let fe=V+1;e[e._using=fe]="_using"})(ry||(Ru.ContextualKeyword=ry={}))});var tt=Ce(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});var ae;(function(e){e[e.PRECEDENCE_MASK=15]="PRECEDENCE_MASK";let n=16;e[e.IS_KEYWORD=n]="IS_KEYWORD";let r=32;e[e.IS_ASSIGN=r]="IS_ASSIGN";let o=64;e[e.IS_RIGHT_ASSOCIATIVE=o]="IS_RIGHT_ASSOCIATIVE";let s=128;e[e.IS_PREFIX=s]="IS_PREFIX";let i=256;e[e.IS_POSTFIX=i]="IS_POSTFIX";let a=512;e[e.IS_EXPRESSION_START=a]="IS_EXPRESSION_START";let l=512;e[e.num=l]="num";let c=1536;e[e.bigint=c]="bigint";let u=2560;e[e.decimal=u]="decimal";let p=3584;e[e.regexp=p]="regexp";let d=4608;e[e.string=d]="string";let m=5632;e[e.name=m]="name";let h=6144;e[e.eof=h]="eof";let g=7680;e[e.bracketL=g]="bracketL";let y=8192;e[e.bracketR=y]="bracketR";let k=9728;e[e.braceL=k]="braceL";let b=10752;e[e.braceBarL=b]="braceBarL";let w=11264;e[e.braceR=w]="braceR";let _=12288;e[e.braceBarR=_]="braceBarR";let v=13824;e[e.parenL=v]="parenL";let R=14336;e[e.parenR=R]="parenR";let S=15360;e[e.comma=S]="comma";let T=16384;e[e.semi=T]="semi";let x=17408;e[e.colon=x]="colon";let $=18432;e[e.doubleColon=$]="doubleColon";let U=19456;e[e.dot=U]="dot";let E=20480;e[e.question=E]="question";let z=21504;e[e.questionDot=z]="questionDot";let G=22528;e[e.arrow=G]="arrow";let D=23552;e[e.template=D]="template";let te=24576;e[e.ellipsis=te]="ellipsis";let we=25600;e[e.backQuote=we]="backQuote";let ge=27136;e[e.dollarBraceL=ge]="dollarBraceL";let ve=27648;e[e.at=ve]="at";let oe=29184;e[e.hash=oe]="hash";let P=29728;e[e.eq=P]="eq";let M=30752;e[e.assign=M]="assign";let O=32640;e[e.preIncDec=O]="preIncDec";let V=33664;e[e.postIncDec=V]="postIncDec";let fe=34432;e[e.bang=fe]="bang";let xe=35456;e[e.tilde=xe]="tilde";let Oe=35841;e[e.pipeline=Oe]="pipeline";let De=36866;e[e.nullishCoalescing=De]="nullishCoalescing";let ze=37890;e[e.logicalOR=ze]="logicalOR";let Q=38915;e[e.logicalAND=Q]="logicalAND";let me=39940;e[e.bitwiseOR=me]="bitwiseOR";let be=40965;e[e.bitwiseXOR=be]="bitwiseXOR";let Ie=41990;e[e.bitwiseAND=Ie]="bitwiseAND";let ye=43015;e[e.equality=ye]="equality";let Le=44040;e[e.lessThan=Le]="lessThan";let re=45064;e[e.greaterThan=re]="greaterThan";let se=46088;e[e.relationalOrEqual=se]="relationalOrEqual";let le=47113;e[e.bitShiftL=le]="bitShiftL";let _e=48137;e[e.bitShiftR=_e]="bitShiftR";let Me=49802;e[e.plus=Me]="plus";let Pe=50826;e[e.minus=Pe]="minus";let Ge=51723;e[e.modulo=Ge]="modulo";let dt=52235;e[e.star=dt]="star";let Ft=53259;e[e.slash=Ft]="slash";let bn=54348;e[e.exponent=bn]="exponent";let En=55296;e[e.jsxName=En]="jsxName";let An=56320;e[e.jsxText=An]="jsxText";let ir=57344;e[e.jsxEmptyText=ir]="jsxEmptyText";let In=58880;e[e.jsxTagStart=In]="jsxTagStart";let Mn=59392;e[e.jsxTagEnd=Mn]="jsxTagEnd";let yn=60928;e[e.typeParameterStart=yn]="typeParameterStart";let Jn=61440;e[e.nonNullAssertion=Jn]="nonNullAssertion";let Us=62480;e[e._break=Us]="_break";let Ko=63504;e[e._case=Ko]="_case";let H=64528;e[e._catch=H]="_catch";let ce=65552;e[e._continue=ce]="_continue";let de=66576;e[e._debugger=de]="_debugger";let ke=67600;e[e._default=ke]="_default";let Ne=68624;e[e._do=Ne]="_do";let Ee=69648;e[e._else=Ee]="_else";let Qe=70672;e[e._finally=Qe]="_finally";let gt=71696;e[e._for=gt]="_for";let Je=73232;e[e._function=Je]="_function";let Et=73744;e[e._if=Et]="_if";let Ot=74768;e[e._return=Ot]="_return";let Lt=75792;e[e._switch=Lt]="_switch";let rn=77456;e[e._throw=rn]="_throw";let sn=77840;e[e._try=sn]="_try";let vn=78864;e[e._var=vn]="_var";let Tn=79888;e[e._let=Tn]="_let";let Pn=80912;e[e._const=Pn]="_const";let ar=81936;e[e._while=ar]="_while";let co=82960;e[e._with=co]="_with";let an=84496;e[e._new=an]="_new";let uo=85520;e[e._this=uo]="_this";let Vo=86544;e[e._super=Vo]="_super";let Hs=87568;e[e._class=Hs]="_class";let Jo=88080;e[e._extends=Jo]="_extends";let po=89104;e[e._export=po]="_export";let Xn=90640;e[e._import=Xn]="_import";let Lr=91664;e[e._yield=Lr]="_yield";let Xo=92688;e[e._null=Xo]="_null";let Qo=93712;e[e._true=Qo]="_true";let Yo=94736;e[e._false=Yo]="_false";let vc=95256;e[e._in=vc]="_in";let Tc=96280;e[e._instanceof=Tc]="_instanceof";let xc=97936;e[e._typeof=xc]="_typeof";let Sc=98960;e[e._void=Sc]="_void";let sS=99984;e[e._delete=sS]="_delete";let iS=100880;e[e._async=iS]="_async";let aS=101904;e[e._get=aS]="_get";let lS=102928;e[e._set=lS]="_set";let cS=103952;e[e._declare=cS]="_declare";let uS=104976;e[e._readonly=uS]="_readonly";let dS=106e3;e[e._abstract=dS]="_abstract";let pS=107024;e[e._static=pS]="_static";let mS=107536;e[e._public=mS]="_public";let fS=108560;e[e._private=fS]="_private";let hS=109584;e[e._protected=hS]="_protected";let gS=110608;e[e._override=gS]="_override";let bS=112144;e[e._as=bS]="_as";let yS=113168;e[e._enum=yS]="_enum";let wS=114192;e[e._type=wS]="_type";let kS=115216;e[e._implements=kS]="_implements"})(ae||(ja.TokenType=ae={}));function A$(e){switch(e){case ae.num:return"num";case ae.bigint:return"bigint";case ae.decimal:return"decimal";case ae.regexp:return"regexp";case ae.string:return"string";case ae.name:return"name";case ae.eof:return"eof";case ae.bracketL:return"[";case ae.bracketR:return"]";case ae.braceL:return"{";case ae.braceBarL:return"{|";case ae.braceR:return"}";case ae.braceBarR:return"|}";case ae.parenL:return"(";case ae.parenR:return")";case ae.comma:return",";case ae.semi:return";";case ae.colon:return":";case ae.doubleColon:return"::";case ae.dot:return".";case ae.question:return"?";case ae.questionDot:return"?.";case ae.arrow:return"=>";case ae.template:return"template";case ae.ellipsis:return"...";case ae.backQuote:return"`";case ae.dollarBraceL:return"${";case ae.at:return"@";case ae.hash:return"#";case ae.eq:return"=";case ae.assign:return"_=";case ae.preIncDec:return"++/--";case ae.postIncDec:return"++/--";case ae.bang:return"!";case ae.tilde:return"~";case ae.pipeline:return"|>";case ae.nullishCoalescing:return"??";case ae.logicalOR:return"||";case ae.logicalAND:return"&&";case ae.bitwiseOR:return"|";case ae.bitwiseXOR:return"^";case ae.bitwiseAND:return"&";case ae.equality:return"==/!=";case ae.lessThan:return"<";case ae.greaterThan:return">";case ae.relationalOrEqual:return"<=/>=";case ae.bitShiftL:return"<<";case ae.bitShiftR:return">>/>>>";case ae.plus:return"+";case ae.minus:return"-";case ae.modulo:return"%";case ae.star:return"*";case ae.slash:return"/";case ae.exponent:return"**";case ae.jsxName:return"jsxName";case ae.jsxText:return"jsxText";case ae.jsxEmptyText:return"jsxEmptyText";case ae.jsxTagStart:return"jsxTagStart";case ae.jsxTagEnd:return"jsxTagEnd";case ae.typeParameterStart:return"typeParameterStart";case ae.nonNullAssertion:return"nonNullAssertion";case ae._break:return"break";case ae._case:return"case";case ae._catch:return"catch";case ae._continue:return"continue";case ae._debugger:return"debugger";case ae._default:return"default";case ae._do:return"do";case ae._else:return"else";case ae._finally:return"finally";case ae._for:return"for";case ae._function:return"function";case ae._if:return"if";case ae._return:return"return";case ae._switch:return"switch";case ae._throw:return"throw";case ae._try:return"try";case ae._var:return"var";case ae._let:return"let";case ae._const:return"const";case ae._while:return"while";case ae._with:return"with";case ae._new:return"new";case ae._this:return"this";case ae._super:return"super";case ae._class:return"class";case ae._extends:return"extends";case ae._export:return"export";case ae._import:return"import";case ae._yield:return"yield";case ae._null:return"null";case ae._true:return"true";case ae._false:return"false";case ae._in:return"in";case ae._instanceof:return"instanceof";case ae._typeof:return"typeof";case ae._void:return"void";case ae._delete:return"delete";case ae._async:return"async";case ae._get:return"get";case ae._set:return"set";case ae._declare:return"declare";case ae._readonly:return"readonly";case ae._abstract:return"abstract";case ae._static:return"static";case ae._public:return"public";case ae._private:return"private";case ae._protected:return"protected";case ae._override:return"override";case ae._as:return"as";case ae._enum:return"enum";case ae._type:return"type";case ae._implements:return"implements";default:return""}}ja.formatTokenType=A$});var qa=Ce(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});var I$=nn(),M$=tt(),Cu=class{constructor(t,n,r){this.startTokenIndex=t,this.endTokenIndex=n,this.isFunctionScope=r}};ci.Scope=Cu;var Ba=class{constructor(t,n,r,o,s,i,a,l,c,u,p,d,m){this.potentialArrowAt=t,this.noAnonFunctionType=n,this.inDisallowConditionalTypesContext=r,this.tokensLength=o,this.scopesLength=s,this.pos=i,this.type=a,this.contextualKeyword=l,this.start=c,this.end=u,this.isType=p,this.scopeDepth=d,this.error=m}};ci.StateSnapshot=Ba;var Eu=class e{constructor(){e.prototype.__init.call(this),e.prototype.__init2.call(this),e.prototype.__init3.call(this),e.prototype.__init4.call(this),e.prototype.__init5.call(this),e.prototype.__init6.call(this),e.prototype.__init7.call(this),e.prototype.__init8.call(this),e.prototype.__init9.call(this),e.prototype.__init10.call(this),e.prototype.__init11.call(this),e.prototype.__init12.call(this),e.prototype.__init13.call(this)}__init(){this.potentialArrowAt=-1}__init2(){this.noAnonFunctionType=!1}__init3(){this.inDisallowConditionalTypesContext=!1}__init4(){this.tokens=[]}__init5(){this.scopes=[]}__init6(){this.pos=0}__init7(){this.type=M$.TokenType.eof}__init8(){this.contextualKeyword=I$.ContextualKeyword.NONE}__init9(){this.start=0}__init10(){this.end=0}__init11(){this.isType=!1}__init12(){this.scopeDepth=0}__init13(){this.error=null}snapshot(){return new Ba(this.potentialArrowAt,this.noAnonFunctionType,this.inDisallowConditionalTypesContext,this.tokens.length,this.scopes.length,this.pos,this.type,this.contextualKeyword,this.start,this.end,this.isType,this.scopeDepth,this.error)}restoreFromSnapshot(t){this.potentialArrowAt=t.potentialArrowAt,this.noAnonFunctionType=t.noAnonFunctionType,this.inDisallowConditionalTypesContext=t.inDisallowConditionalTypesContext,this.tokens.length=t.tokensLength,this.scopes.length=t.scopesLength,this.pos=t.pos,this.type=t.type,this.contextualKeyword=t.contextualKeyword,this.start=t.start,this.end=t.end,this.isType=t.isType,this.scopeDepth=t.scopeDepth,this.error=t.error}};ci.default=Eu});var On=Ce(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});var Ur;(function(e){e[e.backSpace=8]="backSpace";let n=10;e[e.lineFeed=n]="lineFeed";let r=9;e[e.tab=r]="tab";let o=13;e[e.carriageReturn=o]="carriageReturn";let s=14;e[e.shiftOut=s]="shiftOut";let i=32;e[e.space=i]="space";let a=33;e[e.exclamationMark=a]="exclamationMark";let l=34;e[e.quotationMark=l]="quotationMark";let c=35;e[e.numberSign=c]="numberSign";let u=36;e[e.dollarSign=u]="dollarSign";let p=37;e[e.percentSign=p]="percentSign";let d=38;e[e.ampersand=d]="ampersand";let m=39;e[e.apostrophe=m]="apostrophe";let h=40;e[e.leftParenthesis=h]="leftParenthesis";let g=41;e[e.rightParenthesis=g]="rightParenthesis";let y=42;e[e.asterisk=y]="asterisk";let k=43;e[e.plusSign=k]="plusSign";let b=44;e[e.comma=b]="comma";let w=45;e[e.dash=w]="dash";let _=46;e[e.dot=_]="dot";let v=47;e[e.slash=v]="slash";let R=48;e[e.digit0=R]="digit0";let S=49;e[e.digit1=S]="digit1";let T=50;e[e.digit2=T]="digit2";let x=51;e[e.digit3=x]="digit3";let $=52;e[e.digit4=$]="digit4";let U=53;e[e.digit5=U]="digit5";let E=54;e[e.digit6=E]="digit6";let z=55;e[e.digit7=z]="digit7";let G=56;e[e.digit8=G]="digit8";let D=57;e[e.digit9=D]="digit9";let te=58;e[e.colon=te]="colon";let we=59;e[e.semicolon=we]="semicolon";let ge=60;e[e.lessThan=ge]="lessThan";let ve=61;e[e.equalsTo=ve]="equalsTo";let oe=62;e[e.greaterThan=oe]="greaterThan";let P=63;e[e.questionMark=P]="questionMark";let M=64;e[e.atSign=M]="atSign";let O=65;e[e.uppercaseA=O]="uppercaseA";let V=66;e[e.uppercaseB=V]="uppercaseB";let fe=67;e[e.uppercaseC=fe]="uppercaseC";let xe=68;e[e.uppercaseD=xe]="uppercaseD";let Oe=69;e[e.uppercaseE=Oe]="uppercaseE";let De=70;e[e.uppercaseF=De]="uppercaseF";let ze=71;e[e.uppercaseG=ze]="uppercaseG";let Q=72;e[e.uppercaseH=Q]="uppercaseH";let me=73;e[e.uppercaseI=me]="uppercaseI";let be=74;e[e.uppercaseJ=be]="uppercaseJ";let Ie=75;e[e.uppercaseK=Ie]="uppercaseK";let ye=76;e[e.uppercaseL=ye]="uppercaseL";let Le=77;e[e.uppercaseM=Le]="uppercaseM";let re=78;e[e.uppercaseN=re]="uppercaseN";let se=79;e[e.uppercaseO=se]="uppercaseO";let le=80;e[e.uppercaseP=le]="uppercaseP";let _e=81;e[e.uppercaseQ=_e]="uppercaseQ";let Me=82;e[e.uppercaseR=Me]="uppercaseR";let Pe=83;e[e.uppercaseS=Pe]="uppercaseS";let Ge=84;e[e.uppercaseT=Ge]="uppercaseT";let dt=85;e[e.uppercaseU=dt]="uppercaseU";let Ft=86;e[e.uppercaseV=Ft]="uppercaseV";let bn=87;e[e.uppercaseW=bn]="uppercaseW";let En=88;e[e.uppercaseX=En]="uppercaseX";let An=89;e[e.uppercaseY=An]="uppercaseY";let ir=90;e[e.uppercaseZ=ir]="uppercaseZ";let In=91;e[e.leftSquareBracket=In]="leftSquareBracket";let Mn=92;e[e.backslash=Mn]="backslash";let yn=93;e[e.rightSquareBracket=yn]="rightSquareBracket";let Jn=94;e[e.caret=Jn]="caret";let Us=95;e[e.underscore=Us]="underscore";let Ko=96;e[e.graveAccent=Ko]="graveAccent";let H=97;e[e.lowercaseA=H]="lowercaseA";let ce=98;e[e.lowercaseB=ce]="lowercaseB";let de=99;e[e.lowercaseC=de]="lowercaseC";let ke=100;e[e.lowercaseD=ke]="lowercaseD";let Ne=101;e[e.lowercaseE=Ne]="lowercaseE";let Ee=102;e[e.lowercaseF=Ee]="lowercaseF";let Qe=103;e[e.lowercaseG=Qe]="lowercaseG";let gt=104;e[e.lowercaseH=gt]="lowercaseH";let Je=105;e[e.lowercaseI=Je]="lowercaseI";let Et=106;e[e.lowercaseJ=Et]="lowercaseJ";let Ot=107;e[e.lowercaseK=Ot]="lowercaseK";let Lt=108;e[e.lowercaseL=Lt]="lowercaseL";let rn=109;e[e.lowercaseM=rn]="lowercaseM";let sn=110;e[e.lowercaseN=sn]="lowercaseN";let vn=111;e[e.lowercaseO=vn]="lowercaseO";let Tn=112;e[e.lowercaseP=Tn]="lowercaseP";let Pn=113;e[e.lowercaseQ=Pn]="lowercaseQ";let ar=114;e[e.lowercaseR=ar]="lowercaseR";let co=115;e[e.lowercaseS=co]="lowercaseS";let an=116;e[e.lowercaseT=an]="lowercaseT";let uo=117;e[e.lowercaseU=uo]="lowercaseU";let Vo=118;e[e.lowercaseV=Vo]="lowercaseV";let Hs=119;e[e.lowercaseW=Hs]="lowercaseW";let Jo=120;e[e.lowercaseX=Jo]="lowercaseX";let po=121;e[e.lowercaseY=po]="lowercaseY";let Xn=122;e[e.lowercaseZ=Xn]="lowercaseZ";let Lr=123;e[e.leftCurlyBrace=Lr]="leftCurlyBrace";let Xo=124;e[e.verticalBar=Xo]="verticalBar";let Qo=125;e[e.rightCurlyBrace=Qo]="rightCurlyBrace";let Yo=126;e[e.tilde=Yo]="tilde";let vc=160;e[e.nonBreakingSpace=vc]="nonBreakingSpace";let Tc=5760;e[e.oghamSpaceMark=Tc]="oghamSpaceMark";let xc=8232;e[e.lineSeparator=xc]="lineSeparator";let Sc=8233;e[e.paragraphSeparator=Sc]="paragraphSeparator"})(Ur||(Ua.charCodes=Ur={}));function P$(e){return e>=Ur.digit0&&e<=Ur.digit9||e>=Ur.lowercaseA&&e<=Ur.lowercaseF||e>=Ur.uppercaseA&&e<=Ur.uppercaseF}Ua.isDigit=P$});var Ln=Ce(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});function F$(e){return e&&e.__esModule?e:{default:e}}var O$=qa(),L$=F$(O$),N$=On();zt.isJSXEnabled;zt.isTypeScriptEnabled;zt.isFlowEnabled;zt.state;zt.input;zt.nextContextId;function D$(){return zt.nextContextId++}zt.getNextContextId=D$;function j$(e){if("pos"in e){let t=oy(e.pos);e.message+=` (${t.line}:${t.column})`,e.loc=t}return e}zt.augmentError=j$;var Ha=class{constructor(t,n){this.line=t,this.column=n}};zt.Loc=Ha;function oy(e){let t=1,n=1;for(let r=0;r<e;r++)zt.input.charCodeAt(r)===N$.charCodes.lineFeed?(t++,n=1):n++;return new Ha(t,n)}zt.locationForIndex=oy;function B$(e,t,n,r){zt.input=e,zt.state=new L$.default,zt.nextContextId=1,zt.isJSXEnabled=t,zt.isTypeScriptEnabled=n,zt.isFlowEnabled=r}zt.initParser=B$});var Wr=Ce(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});var Hr=Yt(),Ro=tt(),Wa=On(),Nn=Ln();function q$(e){return Nn.state.contextualKeyword===e}Dn.isContextual=q$;function U$(e){let t=Hr.lookaheadTypeAndKeyword.call(void 0);return t.type===Ro.TokenType.name&&t.contextualKeyword===e}Dn.isLookaheadContextual=U$;function sy(e){return Nn.state.contextualKeyword===e&&Hr.eat.call(void 0,Ro.TokenType.name)}Dn.eatContextual=sy;function H$(e){sy(e)||za()}Dn.expectContextual=H$;function iy(){return Hr.match.call(void 0,Ro.TokenType.eof)||Hr.match.call(void 0,Ro.TokenType.braceR)||ay()}Dn.canInsertSemicolon=iy;function ay(){let e=Nn.state.tokens[Nn.state.tokens.length-1],t=e?e.end:0;for(let n=t;n<Nn.state.start;n++){let r=Nn.input.charCodeAt(n);if(r===Wa.charCodes.lineFeed||r===Wa.charCodes.carriageReturn||r===8232||r===8233)return!0}return!1}Dn.hasPrecedingLineBreak=ay;function W$(){let e=Hr.nextTokenStart.call(void 0);for(let t=Nn.state.end;t<e;t++){let n=Nn.input.charCodeAt(t);if(n===Wa.charCodes.lineFeed||n===Wa.charCodes.carriageReturn||n===8232||n===8233)return!0}return!1}Dn.hasFollowingLineBreak=W$;function ly(){return Hr.eat.call(void 0,Ro.TokenType.semi)||iy()}Dn.isLineTerminator=ly;function z$(){ly()||za('Unexpected token, expected ";"')}Dn.semicolon=z$;function G$(e){Hr.eat.call(void 0,e)||za(`Unexpected token, expected "${Ro.formatTokenType.call(void 0,e)}"`)}Dn.expect=G$;function za(e="Unexpected token",t=Nn.state.start){if(Nn.state.error)return;let n=new SyntaxError(e);n.pos=t,Nn.state.error=n,Nn.state.pos=Nn.input.length,Hr.finishToken.call(void 0,Ro.TokenType.eof)}Dn.unexpected=za});var Iu=Ce(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});var Au=On(),K$=[9,11,12,Au.charCodes.space,Au.charCodes.nonBreakingSpace,Au.charCodes.oghamSpaceMark,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];Co.WHITESPACE_CHARS=K$;var V$=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;Co.skipWhiteSpace=V$;var J$=new Uint8Array(65536);Co.IS_WHITESPACE=J$;for(let e of Co.WHITESPACE_CHARS)Co.IS_WHITESPACE[e]=1});var ls=Ce(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});var cy=On(),X$=Iu();function Q$(e){if(e<48)return e===36;if(e<58)return!0;if(e<65)return!1;if(e<91)return!0;if(e<97)return e===95;if(e<123)return!0;if(e<128)return!1;throw new Error("Should not be called with non-ASCII char code.")}var Y$=new Uint8Array(65536);er.IS_IDENTIFIER_CHAR=Y$;for(let e=0;e<128;e++)er.IS_IDENTIFIER_CHAR[e]=Q$(e)?1:0;for(let e=128;e<65536;e++)er.IS_IDENTIFIER_CHAR[e]=1;for(let e of X$.WHITESPACE_CHARS)er.IS_IDENTIFIER_CHAR[e]=0;er.IS_IDENTIFIER_CHAR[8232]=0;er.IS_IDENTIFIER_CHAR[8233]=0;var Z$=er.IS_IDENTIFIER_CHAR.slice();er.IS_IDENTIFIER_START=Z$;for(let e=cy.charCodes.digit0;e<=cy.charCodes.digit9;e++)er.IS_IDENTIFIER_START[e]=0});var uy=Ce(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var Ye=nn(),rt=tt(),eR=new Int32Array([-1,27,783,918,1755,2376,2862,3483,-1,3699,-1,4617,4752,4833,5130,5508,5940,-1,6480,6939,7749,8181,8451,8613,-1,8829,-1,-1,-1,54,243,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,432,-1,-1,-1,675,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,81,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,108,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,135,-1,-1,-1,-1,-1,-1,-1,-1,-1,162,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,189,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,216,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._abstract<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,270,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,297,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,324,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,351,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,378,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,405,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._accessor<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._as<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,459,-1,-1,-1,-1,-1,594,-1,-1,-1,-1,-1,-1,486,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,513,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,540,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._assert<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,567,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._asserts<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,621,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,648,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._async<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,702,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,729,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,756,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._await<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,810,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,837,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,864,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,891,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._break<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,945,-1,-1,-1,-1,-1,-1,1107,-1,-1,-1,1242,-1,-1,1350,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,972,1026,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,999,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._case<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1053,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1080,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._catch<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1134,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1161,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1188,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1215,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._checks<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1269,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1296,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1323,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._class<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1377,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1404,1620,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1431,-1,-1,-1,-1,-1,-1,(rt.TokenType._const<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1458,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1485,-1,-1,-1,-1,-1,-1,-1,-1,1512,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1539,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1566,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1593,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._constructor<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1647,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1674,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1701,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1728,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._continue<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1782,-1,-1,-1,-1,-1,-1,-1,-1,-1,2349,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1809,1971,-1,-1,2106,-1,-1,-1,-1,-1,2241,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1836,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1863,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1890,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1917,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1944,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._debugger<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1998,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2025,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2052,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2079,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._declare<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2133,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2160,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2187,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2214,-1,-1,-1,-1,-1,-1,(rt.TokenType._default<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2268,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2295,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2322,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._delete<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._do<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2403,-1,2484,-1,-1,-1,-1,-1,-1,-1,-1,-1,2565,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2430,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2457,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._else<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2511,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2538,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._enum<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2592,-1,-1,-1,2727,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2619,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2646,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2673,-1,-1,-1,-1,-1,-1,(rt.TokenType._export<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2700,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._exports<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2754,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2781,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2808,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2835,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._extends<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2889,-1,-1,-1,-1,-1,-1,-1,2997,-1,-1,-1,-1,-1,3159,-1,-1,3213,-1,-1,3294,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2916,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2943,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2970,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._false<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3024,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3051,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3078,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3105,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3132,-1,(rt.TokenType._finally<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3186,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._for<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3240,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3267,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._from<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3321,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3348,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3375,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3402,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3429,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3456,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._function<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3510,-1,-1,-1,-1,-1,-1,3564,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3537,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._get<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3591,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3618,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3645,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3672,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._global<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3726,-1,-1,-1,-1,-1,-1,3753,4077,-1,-1,-1,-1,4590,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._if<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3780,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3807,-1,-1,3996,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3834,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3861,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3888,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3915,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3942,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3969,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._implements<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4023,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4050,-1,-1,-1,-1,-1,-1,(rt.TokenType._import<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._in<<1)+1,-1,-1,-1,-1,-1,4104,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4185,4401,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4131,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4158,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._infer<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4212,-1,-1,-1,-1,-1,-1,-1,4239,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4266,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4293,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4320,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4347,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4374,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._instanceof<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4428,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4455,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4482,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4509,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4536,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4563,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._interface<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._is<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4644,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4671,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4698,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4725,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._keyof<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4779,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4806,-1,-1,-1,-1,-1,-1,(rt.TokenType._let<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4860,-1,-1,-1,-1,-1,4995,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4887,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4914,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4941,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4968,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._mixins<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5022,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5049,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5076,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5103,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._module<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5157,-1,-1,-1,5373,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5427,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5184,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5211,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5238,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5265,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5292,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5319,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5346,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._namespace<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5400,-1,-1,-1,(rt.TokenType._new<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5454,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5481,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._null<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5535,-1,-1,-1,-1,-1,-1,-1,-1,-1,5562,-1,-1,-1,-1,5697,5751,-1,-1,-1,-1,Ye.ContextualKeyword._of<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5589,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5616,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5643,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5670,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._opaque<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5724,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._out<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5778,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5805,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5832,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5859,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5886,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5913,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._override<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5967,-1,-1,6345,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5994,-1,-1,-1,-1,-1,6129,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6021,-1,-1,-1,-1,-1,6048,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6075,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6102,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._private<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6156,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6183,-1,-1,-1,-1,-1,-1,-1,-1,-1,6318,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6210,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6237,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6264,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6291,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._protected<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._proto<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6372,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6399,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6426,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6453,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._public<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6507,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6534,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6696,-1,-1,6831,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6561,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6588,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6615,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6642,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6669,-1,Ye.ContextualKeyword._readonly<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6723,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6750,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6777,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6804,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._require<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6858,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6885,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6912,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._return<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6966,-1,-1,-1,7182,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7236,7371,-1,7479,-1,7614,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6993,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7020,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7047,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7074,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7101,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7128,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7155,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._satisfies<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7209,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._set<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7263,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7290,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7317,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._static<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7398,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7425,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7452,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._super<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7506,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7533,-1,-1,-1,-1,-1,-1,-1,-1,-1,7560,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7587,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._switch<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7641,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7668,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7695,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7722,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._symbol<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7776,-1,-1,-1,-1,-1,-1,-1,-1,-1,7938,-1,-1,-1,-1,-1,-1,8046,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7803,-1,-1,-1,-1,-1,-1,-1,-1,7857,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7830,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._this<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7884,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7911,-1,-1,-1,(rt.TokenType._throw<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7965,-1,-1,-1,8019,-1,-1,-1,-1,-1,-1,7992,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._true<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._try<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8073,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8100,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._type<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8127,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8154,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._typeof<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8208,-1,-1,-1,-1,8343,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8235,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8262,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8289,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8316,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._unique<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8370,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8397,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8424,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,Ye.ContextualKeyword._using<<1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8478,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8532,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8505,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._var<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8559,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8586,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._void<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8640,8748,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8667,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8694,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8721,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._while<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8775,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8802,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._with<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8856,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8883,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8910,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8937,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,(rt.TokenType._yield<<1)+1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);Mu.READ_WORD_TREE=eR});var fy=Ce(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var tr=Ln(),zr=On(),dy=ls(),Pu=Yt(),py=uy(),my=tt();function tR(){let e=0,t=0,n=tr.state.pos;for(;n<tr.input.length&&(t=tr.input.charCodeAt(n),!(t<zr.charCodes.lowercaseA||t>zr.charCodes.lowercaseZ));){let o=py.READ_WORD_TREE[e+(t-zr.charCodes.lowercaseA)+1];if(o===-1)break;e=o,n++}let r=py.READ_WORD_TREE[e];if(r>-1&&!dy.IS_IDENTIFIER_CHAR[t]){tr.state.pos=n,r&1?Pu.finishToken.call(void 0,r>>>1):Pu.finishToken.call(void 0,my.TokenType.name,r>>>1);return}for(;n<tr.input.length;){let o=tr.input.charCodeAt(n);if(dy.IS_IDENTIFIER_CHAR[o])n++;else if(o===zr.charCodes.backslash){if(n+=2,tr.input.charCodeAt(n)===zr.charCodes.leftCurlyBrace){for(;n<tr.input.length&&tr.input.charCodeAt(n)!==zr.charCodes.rightCurlyBrace;)n++;n++}}else if(o===zr.charCodes.atSign&&tr.input.charCodeAt(n+1)===zr.charCodes.atSign)n+=2;else break}tr.state.pos=n,Pu.finishToken.call(void 0,my.TokenType.name)}Fu.default=tR});var Yt=Ce(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});function nR(e){return e&&e.__esModule?e:{default:e}}var F=Ln(),cs=Wr(),Y=On(),gy=ls(),Lu=Iu(),rR=nn(),oR=fy(),sR=nR(oR),Se=tt(),Mt;(function(e){e[e.Access=0]="Access";let n=1;e[e.ExportAccess=n]="ExportAccess";let r=n+1;e[e.TopLevelDeclaration=r]="TopLevelDeclaration";let o=r+1;e[e.FunctionScopedDeclaration=o]="FunctionScopedDeclaration";let s=o+1;e[e.BlockScopedDeclaration=s]="BlockScopedDeclaration";let i=s+1;e[e.ObjectShorthandTopLevelDeclaration=i]="ObjectShorthandTopLevelDeclaration";let a=i+1;e[e.ObjectShorthandFunctionScopedDeclaration=a]="ObjectShorthandFunctionScopedDeclaration";let l=a+1;e[e.ObjectShorthandBlockScopedDeclaration=l]="ObjectShorthandBlockScopedDeclaration";let c=l+1;e[e.ObjectShorthand=c]="ObjectShorthand";let u=c+1;e[e.ImportDeclaration=u]="ImportDeclaration";let p=u+1;e[e.ObjectKey=p]="ObjectKey";let d=p+1;e[e.ImportAccess=d]="ImportAccess"})(Mt||(ht.IdentifierRole=Mt={}));var hy;(function(e){e[e.NoChildren=0]="NoChildren";let n=1;e[e.OneChild=n]="OneChild";let r=n+1;e[e.StaticChildren=r]="StaticChildren";let o=r+1;e[e.KeyAfterPropSpread=o]="KeyAfterPropSpread"})(hy||(ht.JSXRole=hy={}));function iR(e){let t=e.identifierRole;return t===Mt.TopLevelDeclaration||t===Mt.FunctionScopedDeclaration||t===Mt.BlockScopedDeclaration||t===Mt.ObjectShorthandTopLevelDeclaration||t===Mt.ObjectShorthandFunctionScopedDeclaration||t===Mt.ObjectShorthandBlockScopedDeclaration}ht.isDeclaration=iR;function aR(e){let t=e.identifierRole;return t===Mt.FunctionScopedDeclaration||t===Mt.BlockScopedDeclaration||t===Mt.ObjectShorthandFunctionScopedDeclaration||t===Mt.ObjectShorthandBlockScopedDeclaration}ht.isNonTopLevelDeclaration=aR;function lR(e){let t=e.identifierRole;return t===Mt.TopLevelDeclaration||t===Mt.ObjectShorthandTopLevelDeclaration||t===Mt.ImportDeclaration}ht.isTopLevelDeclaration=lR;function cR(e){let t=e.identifierRole;return t===Mt.TopLevelDeclaration||t===Mt.BlockScopedDeclaration||t===Mt.ObjectShorthandTopLevelDeclaration||t===Mt.ObjectShorthandBlockScopedDeclaration}ht.isBlockScopedDeclaration=cR;function uR(e){let t=e.identifierRole;return t===Mt.FunctionScopedDeclaration||t===Mt.ObjectShorthandFunctionScopedDeclaration}ht.isFunctionScopedDeclaration=uR;function dR(e){return e.identifierRole===Mt.ObjectShorthandTopLevelDeclaration||e.identifierRole===Mt.ObjectShorthandBlockScopedDeclaration||e.identifierRole===Mt.ObjectShorthandFunctionScopedDeclaration}ht.isObjectShorthandDeclaration=dR;var ui=class{constructor(){this.type=F.state.type,this.contextualKeyword=F.state.contextualKeyword,this.start=F.state.start,this.end=F.state.end,this.scopeDepth=F.state.scopeDepth,this.isType=F.state.isType,this.identifierRole=null,this.jsxRole=null,this.shadowsGlobal=!1,this.isAsyncOperation=!1,this.contextId=null,this.rhsEndIndex=null,this.isExpression=!1,this.numNullishCoalesceStarts=0,this.numNullishCoalesceEnds=0,this.isOptionalChainStart=!1,this.isOptionalChainEnd=!1,this.subscriptStartIndex=null,this.nullishStartIndex=null}};ht.Token=ui;function Ka(){F.state.tokens.push(new ui),ky()}ht.next=Ka;function pR(){F.state.tokens.push(new ui),F.state.start=F.state.pos,OR()}ht.nextTemplateToken=pR;function mR(){F.state.type===Se.TokenType.assign&&--F.state.pos,MR()}ht.retokenizeSlashAsRegex=mR;function fR(e){for(let n=F.state.tokens.length-e;n<F.state.tokens.length;n++)F.state.tokens[n].isType=!0;let t=F.state.isType;return F.state.isType=!0,t}ht.pushTypeContext=fR;function hR(e){F.state.isType=e}ht.popTypeContext=hR;function by(e){return Nu(e)?(Ka(),!0):!1}ht.eat=by;function gR(e){let t=F.state.isType;F.state.isType=!0,by(e),F.state.isType=t}ht.eatTypeToken=gR;function Nu(e){return F.state.type===e}ht.match=Nu;function bR(){let e=F.state.snapshot();Ka();let t=F.state.type;return F.state.restoreFromSnapshot(e),t}ht.lookaheadType=bR;var Ga=class{constructor(t,n){this.type=t,this.contextualKeyword=n}};ht.TypeAndKeyword=Ga;function yR(){let e=F.state.snapshot();Ka();let t=F.state.type,n=F.state.contextualKeyword;return F.state.restoreFromSnapshot(e),new Ga(t,n)}ht.lookaheadTypeAndKeyword=yR;function yy(){return wy(F.state.pos)}ht.nextTokenStart=yy;function wy(e){Lu.skipWhiteSpace.lastIndex=e;let t=Lu.skipWhiteSpace.exec(F.input);return e+t[0].length}ht.nextTokenStartSince=wy;function wR(){return F.input.charCodeAt(yy())}ht.lookaheadCharCode=wR;function ky(){if(vy(),F.state.start=F.state.pos,F.state.pos>=F.input.length){let e=F.state.tokens;e.length>=2&&e[e.length-1].start>=F.input.length&&e[e.length-2].start>=F.input.length&&cs.unexpected.call(void 0,"Unexpectedly reached the end of input."),yt(Se.TokenType.eof);return}kR(F.input.charCodeAt(F.state.pos))}ht.nextToken=ky;function kR(e){gy.IS_IDENTIFIER_START[e]||e===Y.charCodes.backslash||e===Y.charCodes.atSign&&F.input.charCodeAt(F.state.pos+1)===Y.charCodes.atSign?sR.default.call(void 0):xy(e)}function _R(){for(;F.input.charCodeAt(F.state.pos)!==Y.charCodes.asterisk||F.input.charCodeAt(F.state.pos+1)!==Y.charCodes.slash;)if(F.state.pos++,F.state.pos>F.input.length){cs.unexpected.call(void 0,"Unterminated comment",F.state.pos-2);return}F.state.pos+=2}function _y(e){let t=F.input.charCodeAt(F.state.pos+=e);if(F.state.pos<F.input.length)for(;t!==Y.charCodes.lineFeed&&t!==Y.charCodes.carriageReturn&&t!==Y.charCodes.lineSeparator&&t!==Y.charCodes.paragraphSeparator&&++F.state.pos<F.input.length;)t=F.input.charCodeAt(F.state.pos)}ht.skipLineComment=_y;function vy(){for(;F.state.pos<F.input.length;){let e=F.input.charCodeAt(F.state.pos);switch(e){case Y.charCodes.carriageReturn:F.input.charCodeAt(F.state.pos+1)===Y.charCodes.lineFeed&&++F.state.pos;case Y.charCodes.lineFeed:case Y.charCodes.lineSeparator:case Y.charCodes.paragraphSeparator:++F.state.pos;break;case Y.charCodes.slash:switch(F.input.charCodeAt(F.state.pos+1)){case Y.charCodes.asterisk:F.state.pos+=2,_R();break;case Y.charCodes.slash:_y(2);break;default:return}break;default:if(Lu.IS_WHITESPACE[e])++F.state.pos;else return}}}ht.skipSpace=vy;function yt(e,t=rR.ContextualKeyword.NONE){F.state.end=F.state.pos,F.state.type=e,F.state.contextualKeyword=t}ht.finishToken=yt;function vR(){let e=F.input.charCodeAt(F.state.pos+1);if(e>=Y.charCodes.digit0&&e<=Y.charCodes.digit9){Sy(!0);return}e===Y.charCodes.dot&&F.input.charCodeAt(F.state.pos+2)===Y.charCodes.dot?(F.state.pos+=3,yt(Se.TokenType.ellipsis)):(++F.state.pos,yt(Se.TokenType.dot))}function TR(){F.input.charCodeAt(F.state.pos+1)===Y.charCodes.equalsTo?ft(Se.TokenType.assign,2):ft(Se.TokenType.slash,1)}function xR(e){let t=e===Y.charCodes.asterisk?Se.TokenType.star:Se.TokenType.modulo,n=1,r=F.input.charCodeAt(F.state.pos+1);e===Y.charCodes.asterisk&&r===Y.charCodes.asterisk&&(n++,r=F.input.charCodeAt(F.state.pos+2),t=Se.TokenType.exponent),r===Y.charCodes.equalsTo&&F.input.charCodeAt(F.state.pos+2)!==Y.charCodes.greaterThan&&(n++,t=Se.TokenType.assign),ft(t,n)}function SR(e){let t=F.input.charCodeAt(F.state.pos+1);if(t===e){F.input.charCodeAt(F.state.pos+2)===Y.charCodes.equalsTo?ft(Se.TokenType.assign,3):ft(e===Y.charCodes.verticalBar?Se.TokenType.logicalOR:Se.TokenType.logicalAND,2);return}if(e===Y.charCodes.verticalBar){if(t===Y.charCodes.greaterThan){ft(Se.TokenType.pipeline,2);return}else if(t===Y.charCodes.rightCurlyBrace&&F.isFlowEnabled){ft(Se.TokenType.braceBarR,2);return}}if(t===Y.charCodes.equalsTo){ft(Se.TokenType.assign,2);return}ft(e===Y.charCodes.verticalBar?Se.TokenType.bitwiseOR:Se.TokenType.bitwiseAND,1)}function $R(){F.input.charCodeAt(F.state.pos+1)===Y.charCodes.equalsTo?ft(Se.TokenType.assign,2):ft(Se.TokenType.bitwiseXOR,1)}function RR(e){let t=F.input.charCodeAt(F.state.pos+1);if(t===e){ft(Se.TokenType.preIncDec,2);return}t===Y.charCodes.equalsTo?ft(Se.TokenType.assign,2):e===Y.charCodes.plusSign?ft(Se.TokenType.plus,1):ft(Se.TokenType.minus,1)}function CR(){let e=F.input.charCodeAt(F.state.pos+1);if(e===Y.charCodes.lessThan){if(F.input.charCodeAt(F.state.pos+2)===Y.charCodes.equalsTo){ft(Se.TokenType.assign,3);return}F.state.isType?ft(Se.TokenType.lessThan,1):ft(Se.TokenType.bitShiftL,2);return}e===Y.charCodes.equalsTo?ft(Se.TokenType.relationalOrEqual,2):ft(Se.TokenType.lessThan,1)}function Ty(){if(F.state.isType){ft(Se.TokenType.greaterThan,1);return}let e=F.input.charCodeAt(F.state.pos+1);if(e===Y.charCodes.greaterThan){let t=F.input.charCodeAt(F.state.pos+2)===Y.charCodes.greaterThan?3:2;if(F.input.charCodeAt(F.state.pos+t)===Y.charCodes.equalsTo){ft(Se.TokenType.assign,t+1);return}ft(Se.TokenType.bitShiftR,t);return}e===Y.charCodes.equalsTo?ft(Se.TokenType.relationalOrEqual,2):ft(Se.TokenType.greaterThan,1)}function ER(){F.state.type===Se.TokenType.greaterThan&&(F.state.pos-=1,Ty())}ht.rescan_gt=ER;function AR(e){let t=F.input.charCodeAt(F.state.pos+1);if(t===Y.charCodes.equalsTo){ft(Se.TokenType.equality,F.input.charCodeAt(F.state.pos+2)===Y.charCodes.equalsTo?3:2);return}if(e===Y.charCodes.equalsTo&&t===Y.charCodes.greaterThan){F.state.pos+=2,yt(Se.TokenType.arrow);return}ft(e===Y.charCodes.equalsTo?Se.TokenType.eq:Se.TokenType.bang,1)}function IR(){let e=F.input.charCodeAt(F.state.pos+1),t=F.input.charCodeAt(F.state.pos+2);e===Y.charCodes.questionMark&&!(F.isFlowEnabled&&F.state.isType)?t===Y.charCodes.equalsTo?ft(Se.TokenType.assign,3):ft(Se.TokenType.nullishCoalescing,2):e===Y.charCodes.dot&&!(t>=Y.charCodes.digit0&&t<=Y.charCodes.digit9)?(F.state.pos+=2,yt(Se.TokenType.questionDot)):(++F.state.pos,yt(Se.TokenType.question))}function xy(e){switch(e){case Y.charCodes.numberSign:++F.state.pos,yt(Se.TokenType.hash);return;case Y.charCodes.dot:vR();return;case Y.charCodes.leftParenthesis:++F.state.pos,yt(Se.TokenType.parenL);return;case Y.charCodes.rightParenthesis:++F.state.pos,yt(Se.TokenType.parenR);return;case Y.charCodes.semicolon:++F.state.pos,yt(Se.TokenType.semi);return;case Y.charCodes.comma:++F.state.pos,yt(Se.TokenType.comma);return;case Y.charCodes.leftSquareBracket:++F.state.pos,yt(Se.TokenType.bracketL);return;case Y.charCodes.rightSquareBracket:++F.state.pos,yt(Se.TokenType.bracketR);return;case Y.charCodes.leftCurlyBrace:F.isFlowEnabled&&F.input.charCodeAt(F.state.pos+1)===Y.charCodes.verticalBar?ft(Se.TokenType.braceBarL,2):(++F.state.pos,yt(Se.TokenType.braceL));return;case Y.charCodes.rightCurlyBrace:++F.state.pos,yt(Se.TokenType.braceR);return;case Y.charCodes.colon:F.input.charCodeAt(F.state.pos+1)===Y.charCodes.colon?ft(Se.TokenType.doubleColon,2):(++F.state.pos,yt(Se.TokenType.colon));return;case Y.charCodes.questionMark:IR();return;case Y.charCodes.atSign:++F.state.pos,yt(Se.TokenType.at);return;case Y.charCodes.graveAccent:++F.state.pos,yt(Se.TokenType.backQuote);return;case Y.charCodes.digit0:{let t=F.input.charCodeAt(F.state.pos+1);if(t===Y.charCodes.lowercaseX||t===Y.charCodes.uppercaseX||t===Y.charCodes.lowercaseO||t===Y.charCodes.uppercaseO||t===Y.charCodes.lowercaseB||t===Y.charCodes.uppercaseB){PR();return}}case Y.charCodes.digit1:case Y.charCodes.digit2:case Y.charCodes.digit3:case Y.charCodes.digit4:case Y.charCodes.digit5:case Y.charCodes.digit6:case Y.charCodes.digit7:case Y.charCodes.digit8:case Y.charCodes.digit9:Sy(!1);return;case Y.charCodes.quotationMark:case Y.charCodes.apostrophe:FR(e);return;case Y.charCodes.slash:TR();return;case Y.charCodes.percentSign:case Y.charCodes.asterisk:xR(e);return;case Y.charCodes.verticalBar:case Y.charCodes.ampersand:SR(e);return;case Y.charCodes.caret:$R();return;case Y.charCodes.plusSign:case Y.charCodes.dash:RR(e);return;case Y.charCodes.lessThan:CR();return;case Y.charCodes.greaterThan:Ty();return;case Y.charCodes.equalsTo:case Y.charCodes.exclamationMark:AR(e);return;case Y.charCodes.tilde:ft(Se.TokenType.tilde,1);return;default:break}cs.unexpected.call(void 0,`Unexpected character '${String.fromCharCode(e)}'`,F.state.pos)}ht.getTokenFromCode=xy;function ft(e,t){F.state.pos+=t,yt(e)}function MR(){let e=F.state.pos,t=!1,n=!1;for(;;){if(F.state.pos>=F.input.length){cs.unexpected.call(void 0,"Unterminated regular expression",e);return}let r=F.input.charCodeAt(F.state.pos);if(t)t=!1;else{if(r===Y.charCodes.leftSquareBracket)n=!0;else if(r===Y.charCodes.rightSquareBracket&&n)n=!1;else if(r===Y.charCodes.slash&&!n)break;t=r===Y.charCodes.backslash}++F.state.pos}++F.state.pos,$y(),yt(Se.TokenType.regexp)}function Ou(){for(;;){let e=F.input.charCodeAt(F.state.pos);if(e>=Y.charCodes.digit0&&e<=Y.charCodes.digit9||e===Y.charCodes.underscore)F.state.pos++;else break}}function PR(){for(F.state.pos+=2;;){let t=F.input.charCodeAt(F.state.pos);if(t>=Y.charCodes.digit0&&t<=Y.charCodes.digit9||t>=Y.charCodes.lowercaseA&&t<=Y.charCodes.lowercaseF||t>=Y.charCodes.uppercaseA&&t<=Y.charCodes.uppercaseF||t===Y.charCodes.underscore)F.state.pos++;else break}F.input.charCodeAt(F.state.pos)===Y.charCodes.lowercaseN?(++F.state.pos,yt(Se.TokenType.bigint)):yt(Se.TokenType.num)}function Sy(e){let t=!1,n=!1;e||Ou();let r=F.input.charCodeAt(F.state.pos);if(r===Y.charCodes.dot&&(++F.state.pos,Ou(),r=F.input.charCodeAt(F.state.pos)),(r===Y.charCodes.uppercaseE||r===Y.charCodes.lowercaseE)&&(r=F.input.charCodeAt(++F.state.pos),(r===Y.charCodes.plusSign||r===Y.charCodes.dash)&&++F.state.pos,Ou(),r=F.input.charCodeAt(F.state.pos)),r===Y.charCodes.lowercaseN?(++F.state.pos,t=!0):r===Y.charCodes.lowercaseM&&(++F.state.pos,n=!0),t){yt(Se.TokenType.bigint);return}if(n){yt(Se.TokenType.decimal);return}yt(Se.TokenType.num)}function FR(e){for(F.state.pos++;;){if(F.state.pos>=F.input.length){cs.unexpected.call(void 0,"Unterminated string constant");return}let t=F.input.charCodeAt(F.state.pos);if(t===Y.charCodes.backslash)F.state.pos++;else if(t===e)break;F.state.pos++}F.state.pos++,yt(Se.TokenType.string)}function OR(){for(;;){if(F.state.pos>=F.input.length){cs.unexpected.call(void 0,"Unterminated template");return}let e=F.input.charCodeAt(F.state.pos);if(e===Y.charCodes.graveAccent||e===Y.charCodes.dollarSign&&F.input.charCodeAt(F.state.pos+1)===Y.charCodes.leftCurlyBrace){if(F.state.pos===F.state.start&&Nu(Se.TokenType.template))if(e===Y.charCodes.dollarSign){F.state.pos+=2,yt(Se.TokenType.dollarBraceL);return}else{++F.state.pos,yt(Se.TokenType.backQuote);return}yt(Se.TokenType.template);return}e===Y.charCodes.backslash&&F.state.pos++,F.state.pos++}}function $y(){for(;F.state.pos<F.input.length;){let e=F.input.charCodeAt(F.state.pos);if(gy.IS_IDENTIFIER_CHAR[e])F.state.pos++;else if(e===Y.charCodes.backslash){if(F.state.pos+=2,F.input.charCodeAt(F.state.pos)===Y.charCodes.leftCurlyBrace){for(;F.state.pos<F.input.length&&F.input.charCodeAt(F.state.pos)!==Y.charCodes.rightCurlyBrace;)F.state.pos++;F.state.pos++}}else break}}ht.skipWord=$y});var di=Ce(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var Ry=tt();function LR(e,t=e.currentIndex()){let n=t+1;if(Va(e,n)){let r=e.identifierNameAtIndex(t);return{isType:!1,leftName:r,rightName:r,endIndex:n}}if(n++,Va(e,n))return{isType:!0,leftName:null,rightName:null,endIndex:n};if(n++,Va(e,n))return{isType:!1,leftName:e.identifierNameAtIndex(t),rightName:e.identifierNameAtIndex(t+2),endIndex:n};if(n++,Va(e,n))return{isType:!0,leftName:null,rightName:null,endIndex:n};throw new Error(`Unexpected import/export specifier at ${t}`)}Du.default=LR;function Va(e,t){let n=e.tokens[t];return n.type===Ry.TokenType.braceR||n.type===Ry.TokenType.comma}});var Cy=Ce(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});ju.default=new Map([["quot",'"'],["amp","&"],["apos","'"],["lt","<"],["gt",">"],["nbsp","\xA0"],["iexcl","\xA1"],["cent","\xA2"],["pound","\xA3"],["curren","\xA4"],["yen","\xA5"],["brvbar","\xA6"],["sect","\xA7"],["uml","\xA8"],["copy","\xA9"],["ordf","\xAA"],["laquo","\xAB"],["not","\xAC"],["shy","\xAD"],["reg","\xAE"],["macr","\xAF"],["deg","\xB0"],["plusmn","\xB1"],["sup2","\xB2"],["sup3","\xB3"],["acute","\xB4"],["micro","\xB5"],["para","\xB6"],["middot","\xB7"],["cedil","\xB8"],["sup1","\xB9"],["ordm","\xBA"],["raquo","\xBB"],["frac14","\xBC"],["frac12","\xBD"],["frac34","\xBE"],["iquest","\xBF"],["Agrave","\xC0"],["Aacute","\xC1"],["Acirc","\xC2"],["Atilde","\xC3"],["Auml","\xC4"],["Aring","\xC5"],["AElig","\xC6"],["Ccedil","\xC7"],["Egrave","\xC8"],["Eacute","\xC9"],["Ecirc","\xCA"],["Euml","\xCB"],["Igrave","\xCC"],["Iacute","\xCD"],["Icirc","\xCE"],["Iuml","\xCF"],["ETH","\xD0"],["Ntilde","\xD1"],["Ograve","\xD2"],["Oacute","\xD3"],["Ocirc","\xD4"],["Otilde","\xD5"],["Ouml","\xD6"],["times","\xD7"],["Oslash","\xD8"],["Ugrave","\xD9"],["Uacute","\xDA"],["Ucirc","\xDB"],["Uuml","\xDC"],["Yacute","\xDD"],["THORN","\xDE"],["szlig","\xDF"],["agrave","\xE0"],["aacute","\xE1"],["acirc","\xE2"],["atilde","\xE3"],["auml","\xE4"],["aring","\xE5"],["aelig","\xE6"],["ccedil","\xE7"],["egrave","\xE8"],["eacute","\xE9"],["ecirc","\xEA"],["euml","\xEB"],["igrave","\xEC"],["iacute","\xED"],["icirc","\xEE"],["iuml","\xEF"],["eth","\xF0"],["ntilde","\xF1"],["ograve","\xF2"],["oacute","\xF3"],["ocirc","\xF4"],["otilde","\xF5"],["ouml","\xF6"],["divide","\xF7"],["oslash","\xF8"],["ugrave","\xF9"],["uacute","\xFA"],["ucirc","\xFB"],["uuml","\xFC"],["yacute","\xFD"],["thorn","\xFE"],["yuml","\xFF"],["OElig","\u0152"],["oelig","\u0153"],["Scaron","\u0160"],["scaron","\u0161"],["Yuml","\u0178"],["fnof","\u0192"],["circ","\u02C6"],["tilde","\u02DC"],["Alpha","\u0391"],["Beta","\u0392"],["Gamma","\u0393"],["Delta","\u0394"],["Epsilon","\u0395"],["Zeta","\u0396"],["Eta","\u0397"],["Theta","\u0398"],["Iota","\u0399"],["Kappa","\u039A"],["Lambda","\u039B"],["Mu","\u039C"],["Nu","\u039D"],["Xi","\u039E"],["Omicron","\u039F"],["Pi","\u03A0"],["Rho","\u03A1"],["Sigma","\u03A3"],["Tau","\u03A4"],["Upsilon","\u03A5"],["Phi","\u03A6"],["Chi","\u03A7"],["Psi","\u03A8"],["Omega","\u03A9"],["alpha","\u03B1"],["beta","\u03B2"],["gamma","\u03B3"],["delta","\u03B4"],["epsilon","\u03B5"],["zeta","\u03B6"],["eta","\u03B7"],["theta","\u03B8"],["iota","\u03B9"],["kappa","\u03BA"],["lambda","\u03BB"],["mu","\u03BC"],["nu","\u03BD"],["xi","\u03BE"],["omicron","\u03BF"],["pi","\u03C0"],["rho","\u03C1"],["sigmaf","\u03C2"],["sigma","\u03C3"],["tau","\u03C4"],["upsilon","\u03C5"],["phi","\u03C6"],["chi","\u03C7"],["psi","\u03C8"],["omega","\u03C9"],["thetasym","\u03D1"],["upsih","\u03D2"],["piv","\u03D6"],["ensp","\u2002"],["emsp","\u2003"],["thinsp","\u2009"],["zwnj","\u200C"],["zwj","\u200D"],["lrm","\u200E"],["rlm","\u200F"],["ndash","\u2013"],["mdash","\u2014"],["lsquo","\u2018"],["rsquo","\u2019"],["sbquo","\u201A"],["ldquo","\u201C"],["rdquo","\u201D"],["bdquo","\u201E"],["dagger","\u2020"],["Dagger","\u2021"],["bull","\u2022"],["hellip","\u2026"],["permil","\u2030"],["prime","\u2032"],["Prime","\u2033"],["lsaquo","\u2039"],["rsaquo","\u203A"],["oline","\u203E"],["frasl","\u2044"],["euro","\u20AC"],["image","\u2111"],["weierp","\u2118"],["real","\u211C"],["trade","\u2122"],["alefsym","\u2135"],["larr","\u2190"],["uarr","\u2191"],["rarr","\u2192"],["darr","\u2193"],["harr","\u2194"],["crarr","\u21B5"],["lArr","\u21D0"],["uArr","\u21D1"],["rArr","\u21D2"],["dArr","\u21D3"],["hArr","\u21D4"],["forall","\u2200"],["part","\u2202"],["exist","\u2203"],["empty","\u2205"],["nabla","\u2207"],["isin","\u2208"],["notin","\u2209"],["ni","\u220B"],["prod","\u220F"],["sum","\u2211"],["minus","\u2212"],["lowast","\u2217"],["radic","\u221A"],["prop","\u221D"],["infin","\u221E"],["ang","\u2220"],["and","\u2227"],["or","\u2228"],["cap","\u2229"],["cup","\u222A"],["int","\u222B"],["there4","\u2234"],["sim","\u223C"],["cong","\u2245"],["asymp","\u2248"],["ne","\u2260"],["equiv","\u2261"],["le","\u2264"],["ge","\u2265"],["sub","\u2282"],["sup","\u2283"],["nsub","\u2284"],["sube","\u2286"],["supe","\u2287"],["oplus","\u2295"],["otimes","\u2297"],["perp","\u22A5"],["sdot","\u22C5"],["lceil","\u2308"],["rceil","\u2309"],["lfloor","\u230A"],["rfloor","\u230B"],["lang","\u2329"],["rang","\u232A"],["loz","\u25CA"],["spades","\u2660"],["clubs","\u2663"],["hearts","\u2665"],["diams","\u2666"]])});var qu=Ce(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});function NR(e){let[t,n]=Ey(e.jsxPragma||"React.createElement"),[r,o]=Ey(e.jsxFragmentPragma||"React.Fragment");return{base:t,suffix:n,fragmentBase:r,fragmentSuffix:o}}Bu.default=NR;function Ey(e){let t=e.indexOf(".");return t===-1&&(t=e.length),[e.slice(0,t),e.slice(t)]}});var Hn=Ce(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var Uu=class{getPrefixCode(){return""}getHoistedCode(){return""}getSuffixCode(){return""}};Hu.default=Uu});var Gu=Ce(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});function zu(e){return e&&e.__esModule?e:{default:e}}var DR=Cy(),jR=zu(DR),Ja=Yt(),lt=tt(),pr=On(),BR=qu(),qR=zu(BR),UR=Hn(),HR=zu(UR),Wu=class e extends HR.default{__init(){this.lastLineNumber=1}__init2(){this.lastIndex=0}__init3(){this.filenameVarName=null}__init4(){this.esmAutomaticImportNameResolutions={}}__init5(){this.cjsAutomaticModuleNameResolutions={}}constructor(t,n,r,o,s){super(),this.rootTransformer=t,this.tokens=n,this.importProcessor=r,this.nameManager=o,this.options=s,e.prototype.__init.call(this),e.prototype.__init2.call(this),e.prototype.__init3.call(this),e.prototype.__init4.call(this),e.prototype.__init5.call(this),this.jsxPragmaInfo=qR.default.call(void 0,s),this.isAutomaticRuntime=s.jsxRuntime==="automatic",this.jsxImportSource=s.jsxImportSource||"react"}process(){return this.tokens.matches1(lt.TokenType.jsxTagStart)?(this.processJSXTag(),!0):!1}getPrefixCode(){let t="";if(this.filenameVarName&&(t+=`const ${this.filenameVarName} = ${JSON.stringify(this.options.filePath||"")};`),this.isAutomaticRuntime)if(this.importProcessor)for(let[n,r]of Object.entries(this.cjsAutomaticModuleNameResolutions))t+=`var ${r} = require("${n}");`;else{let{createElement:n,...r}=this.esmAutomaticImportNameResolutions;n&&(t+=`import {createElement as ${n}} from "${this.jsxImportSource}";`);let o=Object.entries(r).map(([s,i])=>`${s} as ${i}`).join(", ");if(o){let s=this.jsxImportSource+(this.options.production?"/jsx-runtime":"/jsx-dev-runtime");t+=`import {${o}} from "${s}";`}}return t}processJSXTag(){let{jsxRole:t,start:n}=this.tokens.currentToken(),r=this.options.production?null:this.getElementLocationCode(n);this.isAutomaticRuntime&&t!==Ja.JSXRole.KeyAfterPropSpread?this.transformTagToJSXFunc(r,t):this.transformTagToCreateElement(r)}getElementLocationCode(t){return`lineNumber: ${this.getLineNumberForIndex(t)}`}getLineNumberForIndex(t){let n=this.tokens.code;for(;this.lastIndex<t&&this.lastIndex<n.length;)n[this.lastIndex]===`
|
|
4
|
-
`&&this.lastLineNumber++,this.lastIndex++;return this.lastLineNumber}transformTagToJSXFunc(t,n){let r=n===Ja.JSXRole.StaticChildren;this.tokens.replaceToken(this.getJSXFuncInvocationCode(r));let o=null;if(this.tokens.matches1(lt.TokenType.jsxTagEnd))this.tokens.replaceToken(`${this.getFragmentCode()}, {`),this.processAutomaticChildrenAndEndProps(n);else{if(this.processTagIntro(),this.tokens.appendCode(", {"),o=this.processProps(!0),this.tokens.matches2(lt.TokenType.slash,lt.TokenType.jsxTagEnd))this.tokens.appendCode("}");else if(this.tokens.matches1(lt.TokenType.jsxTagEnd))this.tokens.removeToken(),this.processAutomaticChildrenAndEndProps(n);else throw new Error("Expected either /> or > at the end of the tag.");o&&this.tokens.appendCode(`, ${o}`)}for(this.options.production||(o===null&&this.tokens.appendCode(", void 0"),this.tokens.appendCode(`, ${r}, ${this.getDevSource(t)}, this`)),this.tokens.removeInitialToken();!this.tokens.matches1(lt.TokenType.jsxTagEnd);)this.tokens.removeToken();this.tokens.replaceToken(")")}transformTagToCreateElement(t){if(this.tokens.replaceToken(this.getCreateElementInvocationCode()),this.tokens.matches1(lt.TokenType.jsxTagEnd))this.tokens.replaceToken(`${this.getFragmentCode()}, null`),this.processChildren(!0);else if(this.processTagIntro(),this.processPropsObjectWithDevInfo(t),!this.tokens.matches2(lt.TokenType.slash,lt.TokenType.jsxTagEnd))if(this.tokens.matches1(lt.TokenType.jsxTagEnd))this.tokens.removeToken(),this.processChildren(!0);else throw new Error("Expected either /> or > at the end of the tag.");for(this.tokens.removeInitialToken();!this.tokens.matches1(lt.TokenType.jsxTagEnd);)this.tokens.removeToken();this.tokens.replaceToken(")")}getJSXFuncInvocationCode(t){return this.options.production?t?this.claimAutoImportedFuncInvocation("jsxs","/jsx-runtime"):this.claimAutoImportedFuncInvocation("jsx","/jsx-runtime"):this.claimAutoImportedFuncInvocation("jsxDEV","/jsx-dev-runtime")}getCreateElementInvocationCode(){if(this.isAutomaticRuntime)return this.claimAutoImportedFuncInvocation("createElement","");{let{jsxPragmaInfo:t}=this;return`${this.importProcessor&&this.importProcessor.getIdentifierReplacement(t.base)||t.base}${t.suffix}(`}}getFragmentCode(){if(this.isAutomaticRuntime)return this.claimAutoImportedName("Fragment",this.options.production?"/jsx-runtime":"/jsx-dev-runtime");{let{jsxPragmaInfo:t}=this;return(this.importProcessor&&this.importProcessor.getIdentifierReplacement(t.fragmentBase)||t.fragmentBase)+t.fragmentSuffix}}claimAutoImportedFuncInvocation(t,n){let r=this.claimAutoImportedName(t,n);return this.importProcessor?`${r}.call(void 0, `:`${r}(`}claimAutoImportedName(t,n){if(this.importProcessor){let r=this.jsxImportSource+n;return this.cjsAutomaticModuleNameResolutions[r]||(this.cjsAutomaticModuleNameResolutions[r]=this.importProcessor.getFreeIdentifierForPath(r)),`${this.cjsAutomaticModuleNameResolutions[r]}.${t}`}else return this.esmAutomaticImportNameResolutions[t]||(this.esmAutomaticImportNameResolutions[t]=this.nameManager.claimFreeName(`_${t}`)),this.esmAutomaticImportNameResolutions[t]}processTagIntro(){let t=this.tokens.currentIndex()+1;for(;this.tokens.tokens[t].isType||!this.tokens.matches2AtIndex(t-1,lt.TokenType.jsxName,lt.TokenType.jsxName)&&!this.tokens.matches2AtIndex(t-1,lt.TokenType.greaterThan,lt.TokenType.jsxName)&&!this.tokens.matches1AtIndex(t,lt.TokenType.braceL)&&!this.tokens.matches1AtIndex(t,lt.TokenType.jsxTagEnd)&&!this.tokens.matches2AtIndex(t,lt.TokenType.slash,lt.TokenType.jsxTagEnd);)t++;if(t===this.tokens.currentIndex()+1){let n=this.tokens.identifierName();Iy(n)&&this.tokens.replaceToken(`'${n}'`)}for(;this.tokens.currentIndex()<t;)this.rootTransformer.processToken()}processPropsObjectWithDevInfo(t){let n=this.options.production?"":`__self: this, __source: ${this.getDevSource(t)}`;if(!this.tokens.matches1(lt.TokenType.jsxName)&&!this.tokens.matches1(lt.TokenType.braceL)){n?this.tokens.appendCode(`, {${n}}`):this.tokens.appendCode(", null");return}this.tokens.appendCode(", {"),this.processProps(!1),n?this.tokens.appendCode(` ${n}}`):this.tokens.appendCode("}")}processProps(t){let n=null;for(;;){if(this.tokens.matches2(lt.TokenType.jsxName,lt.TokenType.eq)){let r=this.tokens.identifierName();if(t&&r==="key"){n!==null&&this.tokens.appendCode(n.replace(/[^\n]/g,"")),this.tokens.removeToken(),this.tokens.removeToken();let o=this.tokens.snapshot();this.processPropValue(),n=this.tokens.dangerouslyGetAndRemoveCodeSinceSnapshot(o);continue}else this.processPropName(r),this.tokens.replaceToken(": "),this.processPropValue()}else if(this.tokens.matches1(lt.TokenType.jsxName)){let r=this.tokens.identifierName();this.processPropName(r),this.tokens.appendCode(": true")}else if(this.tokens.matches1(lt.TokenType.braceL))this.tokens.replaceToken(""),this.rootTransformer.processBalancedCode(),this.tokens.replaceToken("");else break;this.tokens.appendCode(",")}return n}processPropName(t){t.includes("-")?this.tokens.replaceToken(`'${t}'`):this.tokens.copyToken()}processPropValue(){this.tokens.matches1(lt.TokenType.braceL)?(this.tokens.replaceToken(""),this.rootTransformer.processBalancedCode(),this.tokens.replaceToken("")):this.tokens.matches1(lt.TokenType.jsxTagStart)?this.processJSXTag():this.processStringPropValue()}processStringPropValue(){let t=this.tokens.currentToken(),n=this.tokens.code.slice(t.start+1,t.end-1),r=Ay(n),o=zR(n);this.tokens.replaceToken(o+r)}processAutomaticChildrenAndEndProps(t){t===Ja.JSXRole.StaticChildren?(this.tokens.appendCode(" children: ["),this.processChildren(!1),this.tokens.appendCode("]}")):(t===Ja.JSXRole.OneChild&&this.tokens.appendCode(" children: "),this.processChildren(!1),this.tokens.appendCode("}"))}processChildren(t){let n=t;for(;;){if(this.tokens.matches2(lt.TokenType.jsxTagStart,lt.TokenType.slash))return;let r=!1;if(this.tokens.matches1(lt.TokenType.braceL))this.tokens.matches2(lt.TokenType.braceL,lt.TokenType.braceR)?(this.tokens.replaceToken(""),this.tokens.replaceToken("")):(this.tokens.replaceToken(n?", ":""),this.rootTransformer.processBalancedCode(),this.tokens.replaceToken(""),r=!0);else if(this.tokens.matches1(lt.TokenType.jsxTagStart))this.tokens.appendCode(n?", ":""),this.processJSXTag(),r=!0;else if(this.tokens.matches1(lt.TokenType.jsxText)||this.tokens.matches1(lt.TokenType.jsxEmptyText))r=this.processChildTextElement(n);else throw new Error("Unexpected token when processing JSX children.");r&&(n=!0)}}processChildTextElement(t){let n=this.tokens.currentToken(),r=this.tokens.code.slice(n.start,n.end),o=Ay(r),s=WR(r);return s==='""'?(this.tokens.replaceToken(o),!1):(this.tokens.replaceToken(`${t?", ":""}${s}${o}`),!0)}getDevSource(t){return`{fileName: ${this.getFilenameVarName()}, ${t}}`}getFilenameVarName(){return this.filenameVarName||(this.filenameVarName=this.nameManager.claimFreeName("_jsxFileName")),this.filenameVarName}};Xa.default=Wu;function Iy(e){let t=e.charCodeAt(0);return t>=pr.charCodes.lowercaseA&&t<=pr.charCodes.lowercaseZ}Xa.startsWithLowerCase=Iy;function WR(e){let t="",n="",r=!1,o=!1;for(let s=0;s<e.length;s++){let i=e[s];if(i===" "||i===" "||i==="\r")r||(n+=i);else if(i===`
|
|
5
|
-
`)n="",r=!0;else{if(o&&r&&(t+=" "),t+=n,n="",i==="&"){let{entity:a,newI:l}=My(e,s+1);s=l-1,t+=a}else t+=i;o=!0,r=!1}}return r||(t+=n),JSON.stringify(t)}function Ay(e){let t=0,n=0;for(let r of e)r===`
|
|
6
|
-
`?(t++,n=0):r===" "&&n++;return`
|
|
7
|
-
`.repeat(t)+" ".repeat(n)}function zR(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r===`
|
|
8
|
-
`)if(/\s/.test(e[n+1]))for(t+=" ";n<e.length&&/\s/.test(e[n+1]);)n++;else t+=`
|
|
9
|
-
`;else if(r==="&"){let{entity:o,newI:s}=My(e,n+1);t+=o,n=s-1}else t+=r}return JSON.stringify(t)}function My(e,t){let n="",r=0,o,s=t;if(e[s]==="#"){let i=10;s++;let a;if(e[s]==="x")for(i=16,s++,a=s;s<e.length&&KR(e.charCodeAt(s));)s++;else for(a=s;s<e.length&&GR(e.charCodeAt(s));)s++;if(e[s]===";"){let l=e.slice(a,s);l&&(s++,o=String.fromCodePoint(parseInt(l,i)))}}else for(;s<e.length&&r++<10;){let i=e[s];if(s++,i===";"){o=jR.default.get(n);break}n+=i}return o?{entity:o,newI:s}:{entity:"&",newI:t}}function GR(e){return e>=pr.charCodes.digit0&&e<=pr.charCodes.digit9}function KR(e){return e>=pr.charCodes.digit0&&e<=pr.charCodes.digit9||e>=pr.charCodes.lowercaseA&&e<=pr.charCodes.lowercaseF||e>=pr.charCodes.uppercaseA&&e<=pr.charCodes.uppercaseF}});var Vu=Ce(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});function VR(e){return e&&e.__esModule?e:{default:e}}var Qa=Yt(),us=tt(),JR=Gu(),XR=qu(),QR=VR(XR);function YR(e,t){let n=QR.default.call(void 0,t),r=new Set;for(let o=0;o<e.tokens.length;o++){let s=e.tokens[o];if(s.type===us.TokenType.name&&!s.isType&&(s.identifierRole===Qa.IdentifierRole.Access||s.identifierRole===Qa.IdentifierRole.ObjectShorthand||s.identifierRole===Qa.IdentifierRole.ExportAccess)&&!s.shadowsGlobal&&r.add(e.identifierNameForToken(s)),s.type===us.TokenType.jsxTagStart&&r.add(n.base),s.type===us.TokenType.jsxTagStart&&o+1<e.tokens.length&&e.tokens[o+1].type===us.TokenType.jsxTagEnd&&(r.add(n.base),r.add(n.fragmentBase)),s.type===us.TokenType.jsxName&&s.identifierRole===Qa.IdentifierRole.Access){let i=e.identifierNameForToken(s);(!JR.startsWithLowerCase.call(void 0,i)||e.tokens[o+1].type===us.TokenType.dot)&&r.add(e.identifierNameForToken(s))}}return r}Ku.getNonTypeIdentifiers=YR});var Py=Ce(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});function ZR(e){return e&&e.__esModule?e:{default:e}}var eC=Yt(),Ya=nn(),qe=tt(),tC=di(),nC=ZR(tC),rC=Vu(),Ju=class e{__init(){this.nonTypeIdentifiers=new Set}__init2(){this.importInfoByPath=new Map}__init3(){this.importsToReplace=new Map}__init4(){this.identifierReplacements=new Map}__init5(){this.exportBindingsByLocalName=new Map}constructor(t,n,r,o,s,i,a){this.nameManager=t,this.tokens=n,this.enableLegacyTypeScriptModuleInterop=r,this.options=o,this.isTypeScriptTransformEnabled=s,this.keepUnusedImports=i,this.helperManager=a,e.prototype.__init.call(this),e.prototype.__init2.call(this),e.prototype.__init3.call(this),e.prototype.__init4.call(this),e.prototype.__init5.call(this)}preprocessTokens(){for(let t=0;t<this.tokens.tokens.length;t++)this.tokens.matches1AtIndex(t,qe.TokenType._import)&&!this.tokens.matches3AtIndex(t,qe.TokenType._import,qe.TokenType.name,qe.TokenType.eq)&&this.preprocessImportAtIndex(t),this.tokens.matches1AtIndex(t,qe.TokenType._export)&&!this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType.eq)&&this.preprocessExportAtIndex(t);this.generateImportReplacements()}pruneTypeOnlyImports(){this.nonTypeIdentifiers=rC.getNonTypeIdentifiers.call(void 0,this.tokens,this.options);for(let[t,n]of this.importInfoByPath.entries()){if(n.hasBareImport||n.hasStarExport||n.exportStarNames.length>0||n.namedExports.length>0)continue;[...n.defaultNames,...n.wildcardNames,...n.namedImports.map(({localName:o})=>o)].every(o=>this.shouldAutomaticallyElideImportedName(o))&&this.importsToReplace.set(t,"")}}shouldAutomaticallyElideImportedName(t){return this.isTypeScriptTransformEnabled&&!this.keepUnusedImports&&!this.nonTypeIdentifiers.has(t)}generateImportReplacements(){for(let[t,n]of this.importInfoByPath.entries()){let{defaultNames:r,wildcardNames:o,namedImports:s,namedExports:i,exportStarNames:a,hasStarExport:l}=n;if(r.length===0&&o.length===0&&s.length===0&&i.length===0&&a.length===0&&!l){this.importsToReplace.set(t,`require('${t}');`);continue}let c=this.getFreeIdentifierForPath(t),u;this.enableLegacyTypeScriptModuleInterop?u=c:u=o.length>0?o[0]:this.getFreeIdentifierForPath(t);let p=`var ${c} = require('${t}');`;if(o.length>0)for(let d of o){let m=this.enableLegacyTypeScriptModuleInterop?c:`${this.helperManager.getHelperName("interopRequireWildcard")}(${c})`;p+=` var ${d} = ${m};`}else a.length>0&&u!==c?p+=` var ${u} = ${this.helperManager.getHelperName("interopRequireWildcard")}(${c});`:r.length>0&&u!==c&&(p+=` var ${u} = ${this.helperManager.getHelperName("interopRequireDefault")}(${c});`);for(let{importedName:d,localName:m}of i)p+=` ${this.helperManager.getHelperName("createNamedExportFrom")}(${c}, '${m}', '${d}');`;for(let d of a)p+=` exports.${d} = ${u};`;l&&(p+=` ${this.helperManager.getHelperName("createStarExport")}(${c});`),this.importsToReplace.set(t,p);for(let d of r)this.identifierReplacements.set(d,`${u}.default`);for(let{importedName:d,localName:m}of s)this.identifierReplacements.set(m,`${c}.${d}`)}}getFreeIdentifierForPath(t){let n=t.split("/"),o=n[n.length-1].replace(/\W/g,"");return this.nameManager.claimFreeName(`_${o}`)}preprocessImportAtIndex(t){let n=[],r=[],o=[];if(t++,(this.tokens.matchesContextualAtIndex(t,Ya.ContextualKeyword._type)||this.tokens.matches1AtIndex(t,qe.TokenType._typeof))&&!this.tokens.matches1AtIndex(t+1,qe.TokenType.comma)&&!this.tokens.matchesContextualAtIndex(t+1,Ya.ContextualKeyword._from)||this.tokens.matches1AtIndex(t,qe.TokenType.parenL))return;if(this.tokens.matches1AtIndex(t,qe.TokenType.name)&&(n.push(this.tokens.identifierNameAtIndex(t)),t++,this.tokens.matches1AtIndex(t,qe.TokenType.comma)&&t++),this.tokens.matches1AtIndex(t,qe.TokenType.star)&&(t+=2,r.push(this.tokens.identifierNameAtIndex(t)),t++),this.tokens.matches1AtIndex(t,qe.TokenType.braceL)){let a=this.getNamedImports(t+1);t=a.newIndex;for(let l of a.namedImports)l.importedName==="default"?n.push(l.localName):o.push(l)}if(this.tokens.matchesContextualAtIndex(t,Ya.ContextualKeyword._from)&&t++,!this.tokens.matches1AtIndex(t,qe.TokenType.string))throw new Error("Expected string token at the end of import statement.");let s=this.tokens.stringValueAtIndex(t),i=this.getImportInfo(s);i.defaultNames.push(...n),i.wildcardNames.push(...r),i.namedImports.push(...o),n.length===0&&r.length===0&&o.length===0&&(i.hasBareImport=!0)}preprocessExportAtIndex(t){if(this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType._var)||this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType._let)||this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType._const))this.preprocessVarExportAtIndex(t);else if(this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType._function)||this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType._class)){let n=this.tokens.identifierNameAtIndex(t+2);this.addExportBinding(n,n)}else if(this.tokens.matches3AtIndex(t,qe.TokenType._export,qe.TokenType.name,qe.TokenType._function)){let n=this.tokens.identifierNameAtIndex(t+3);this.addExportBinding(n,n)}else this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType.braceL)?this.preprocessNamedExportAtIndex(t):this.tokens.matches2AtIndex(t,qe.TokenType._export,qe.TokenType.star)&&this.preprocessExportStarAtIndex(t)}preprocessVarExportAtIndex(t){let n=0;for(let r=t+2;;r++)if(this.tokens.matches1AtIndex(r,qe.TokenType.braceL)||this.tokens.matches1AtIndex(r,qe.TokenType.dollarBraceL)||this.tokens.matches1AtIndex(r,qe.TokenType.bracketL))n++;else if(this.tokens.matches1AtIndex(r,qe.TokenType.braceR)||this.tokens.matches1AtIndex(r,qe.TokenType.bracketR))n--;else{if(n===0&&!this.tokens.matches1AtIndex(r,qe.TokenType.name))break;if(this.tokens.matches1AtIndex(1,qe.TokenType.eq)){let o=this.tokens.currentToken().rhsEndIndex;if(o==null)throw new Error("Expected = token with an end index.");r=o-1}else{let o=this.tokens.tokens[r];if(eC.isDeclaration.call(void 0,o)){let s=this.tokens.identifierNameAtIndex(r);this.identifierReplacements.set(s,`exports.${s}`)}}}}preprocessNamedExportAtIndex(t){t+=2;let{newIndex:n,namedImports:r}=this.getNamedImports(t);if(t=n,this.tokens.matchesContextualAtIndex(t,Ya.ContextualKeyword._from))t++;else{for(let{importedName:i,localName:a}of r)this.addExportBinding(i,a);return}if(!this.tokens.matches1AtIndex(t,qe.TokenType.string))throw new Error("Expected string token at the end of import statement.");let o=this.tokens.stringValueAtIndex(t);this.getImportInfo(o).namedExports.push(...r)}preprocessExportStarAtIndex(t){let n=null;if(this.tokens.matches3AtIndex(t,qe.TokenType._export,qe.TokenType.star,qe.TokenType._as)?(t+=3,n=this.tokens.identifierNameAtIndex(t),t+=2):t+=3,!this.tokens.matches1AtIndex(t,qe.TokenType.string))throw new Error("Expected string token at the end of star export statement.");let r=this.tokens.stringValueAtIndex(t),o=this.getImportInfo(r);n!==null?o.exportStarNames.push(n):o.hasStarExport=!0}getNamedImports(t){let n=[];for(;;){if(this.tokens.matches1AtIndex(t,qe.TokenType.braceR)){t++;break}let r=nC.default.call(void 0,this.tokens,t);if(t=r.endIndex,r.isType||n.push({importedName:r.leftName,localName:r.rightName}),this.tokens.matches2AtIndex(t,qe.TokenType.comma,qe.TokenType.braceR)){t+=2;break}else if(this.tokens.matches1AtIndex(t,qe.TokenType.braceR)){t++;break}else if(this.tokens.matches1AtIndex(t,qe.TokenType.comma))t++;else throw new Error(`Unexpected token: ${JSON.stringify(this.tokens.tokens[t])}`)}return{newIndex:t,namedImports:n}}getImportInfo(t){let n=this.importInfoByPath.get(t);if(n)return n;let r={defaultNames:[],wildcardNames:[],namedImports:[],namedExports:[],hasBareImport:!1,exportStarNames:[],hasStarExport:!1};return this.importInfoByPath.set(t,r),r}addExportBinding(t,n){this.exportBindingsByLocalName.has(t)||this.exportBindingsByLocalName.set(t,[]),this.exportBindingsByLocalName.get(t).push(n)}claimImportCode(t){let n=this.importsToReplace.get(t);return this.importsToReplace.set(t,""),n||""}getIdentifierReplacement(t){return this.identifierReplacements.get(t)||null}resolveExportBinding(t){let n=this.exportBindingsByLocalName.get(t);return!n||n.length===0?null:n.map(r=>`exports.${r}`).join(" = ")}getGlobalNames(){return new Set([...this.identifierReplacements.keys(),...this.exportBindingsByLocalName.keys()])}};Xu.default=Ju});var Yu=Ce((Qu,pi)=>{(function(e,t){if(typeof Qu=="object"&&typeof pi<"u")t(pi),pi.exports=n(pi);else if(typeof define=="function"&&define.amd)define(["module"],function(r){t.apply(this,arguments),r.exports=n(r)});else{let r={exports:{}};t(r),e=typeof globalThis<"u"?globalThis:e||self,e.sourcemapCodec=n(r)}function n(r){return"default"in r.exports?r.exports.default:r.exports}})(Qu,(function(e){"use strict";var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(P,M)=>{for(var O in M)t(P,O,{get:M[O],enumerable:!0})},i=(P,M,O,V)=>{if(M&&typeof M=="object"||typeof M=="function")for(let fe of r(M))!o.call(P,fe)&&fe!==O&&t(P,fe,{get:()=>M[fe],enumerable:!(V=n(M,fe))||V.enumerable});return P},a=P=>i(t({},"__esModule",{value:!0}),P),l={};s(l,{decode:()=>we,decodeGeneratedRanges:()=>U,decodeOriginalScopes:()=>T,decodeRangeMappings:()=>D,encode:()=>oe,encodeGeneratedRanges:()=>E,encodeOriginalScopes:()=>x,encodeRangeMappings:()=>te}),e.exports=a(l);var c=44,u=59,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=new Uint8Array(64),m=new Uint8Array(128);for(let P=0;P<p.length;P++){let M=p.charCodeAt(P);d[P]=M,m[M]=P}function h(P){let M=0,O=0,V=0;do{let fe=P.next();V=m[fe],M|=(V&31)<<O,O+=5}while(V&32);return M}function g(P){return P&1?-2147483648|-(P>>>1):P>>>1}function y(P,M){do{let O=M&31;M>>>=5,M>0&&(O|=32),P.write(d[O])}while(M>0)}function k(P){return P<0?-P<<1|1:P<<1}function b(P,M){return P.pos>=M?!1:P.peek()!==c}var w=1024*16,_=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(P){return Buffer.from(P.buffer,P.byteOffset,P.byteLength).toString()}}:{decode(P){let M="";for(let O=0;O<P.length;O++)M+=String.fromCharCode(P[O]);return M}},v=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(w)}write(P){let{buffer:M}=this;M[this.pos++]=P,this.pos===w&&(this.out+=_.decode(M),this.pos=0)}flush(){let{buffer:P,out:M,pos:O}=this;return O>0?M+_.decode(P.subarray(0,O)):M}},R=class{constructor(P){this.pos=0,this.buffer=P}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(P){let{buffer:M,pos:O}=this,V=M.indexOf(P,O);return V===-1?M.length:V}},S=[];function T(P){let{length:M}=P,O=new R(P),V=[],fe=[],xe=0;for(;O.pos<M;O.pos++){xe+=g(h(O));let Oe=g(h(O));if(!b(O,M)){let Ie=fe.pop();Ie[2]=xe,Ie[3]=Oe;continue}let De=g(h(O)),me=g(h(O))&1?[xe,Oe,0,0,De,g(h(O))]:[xe,Oe,0,0,De],be=S;if(b(O,M)){be=[];do{let Ie=g(h(O));be.push(Ie)}while(b(O,M))}me.vars=be,V.push(me),fe.push(me)}return V}function x(P){let M=new v;for(let O=0;O<P.length;)O=$(P,O,M,[0]);return M.flush()}function $(P,M,O,V){let fe=P[M],{0:xe,1:Oe,2:De,3:ze,4:Q,vars:me}=fe;M>0&&O.write(c),y(O,k(xe-V[0])),V[0]=xe,y(O,k(Oe)),y(O,k(Q));let be=fe.length===6?1:0;y(O,k(be)),fe.length===6&&y(O,k(fe[5]));for(let Ie of me)y(O,k(Ie));for(M++;M<P.length;){let Ie=P[M],{0:ye,1:Le}=Ie;if(ye>De||ye===De&&Le>=ze)break;M=$(P,M,O,V)}return O.write(c),y(O,k(De-V[0])),V[0]=De,y(O,k(ze)),M}function U(P){let{length:M}=P,O=new R(P),V=[],fe=[],xe=0,Oe=0,De=0,ze=0,Q=0,me=0,be=0,Ie=0;do{let ye=O.indexOf(";"),Le=0;for(;O.pos<ye;O.pos++){if(Le+=g(h(O)),!b(O,ye)){let dt=fe.pop();dt[2]=xe,dt[3]=Le;continue}let re=g(h(O)),se=re&1,le=re&2,_e=re&4,Me=null,Pe=S,Ge;if(se){let dt=Oe+g(h(O));De=g(h(O))+(Oe===dt?De:0),Oe=dt,Ge=[xe,Le,0,0,dt,De]}else Ge=[xe,Le,0,0];if(Ge.isScope=!!_e,le){let dt=ze,Ft=Q;ze+=g(h(O));let bn=dt===ze;Q=(bn?Q:0)+g(h(O)),me=(bn&&Ft===Q?me:0)+g(h(O)),Me=[ze,Q,me]}if(Ge.callsite=Me,b(O,ye)){Pe=[];do{be=xe,Ie=Le;let dt=g(h(O)),Ft;if(dt<-1){Ft=[[g(h(O))]];for(let bn=-1;bn>dt;bn--){let En=be;be+=g(h(O)),Ie=(be===En?Ie:0)+g(h(O));let An=g(h(O));Ft.push([An,be,Ie])}}else Ft=[[dt]];Pe.push(Ft)}while(b(O,ye))}Ge.bindings=Pe,V.push(Ge),fe.push(Ge)}xe++,O.pos=ye+1}while(O.pos<M);return V}function E(P){if(P.length===0)return"";let M=new v;for(let O=0;O<P.length;)O=z(P,O,M,[0,0,0,0,0,0,0]);return M.flush()}function z(P,M,O,V){let fe=P[M],{0:xe,1:Oe,2:De,3:ze,isScope:Q,callsite:me,bindings:be}=fe;V[0]<xe?(G(O,V[0],xe),V[0]=xe,V[1]=0):M>0&&O.write(c),y(O,k(fe[1]-V[1])),V[1]=fe[1];let Ie=(fe.length===6?1:0)|(me?2:0)|(Q?4:0);if(y(O,k(Ie)),fe.length===6){let{4:ye,5:Le}=fe;ye!==V[2]&&(V[3]=0),y(O,k(ye-V[2])),V[2]=ye,y(O,k(Le-V[3])),V[3]=Le}if(me){let{0:ye,1:Le,2:re}=fe.callsite;ye!==V[4]?(V[5]=0,V[6]=0):Le!==V[5]&&(V[6]=0),y(O,k(ye-V[4])),V[4]=ye,y(O,k(Le-V[5])),V[5]=Le,y(O,k(re-V[6])),V[6]=re}if(be)for(let ye of be){ye.length>1&&y(O,k(-ye.length));let Le=ye[0][0];y(O,k(Le));let re=xe,se=Oe;for(let le=1;le<ye.length;le++){let _e=ye[le];y(O,k(_e[1]-re)),re=_e[1],y(O,k(_e[2]-se)),se=_e[2],y(O,k(_e[0]))}}for(M++;M<P.length;){let ye=P[M],{0:Le,1:re}=ye;if(Le>De||Le===De&&re>=ze)break;M=z(P,M,O,V)}return V[0]<De?(G(O,V[0],De),V[0]=De,V[1]=0):O.write(c),y(O,k(ze-V[1])),V[1]=ze,M}function G(P,M,O){do P.write(u);while(++M<O)}function D(P){let{length:M}=P,O=new R(P),V=[];do{let fe=O.indexOf(";"),xe=[],Oe=0;for(;O.pos<fe;)Oe+=h(O),xe.push(Oe);V.push(xe),O.pos=fe+1}while(O.pos<=M);return V}function te(P){if(P.length===0)return"";let M=new v;for(let O=0;O<P.length;O++){let V=P[O];O>0&&M.write(u);let fe=0;for(let xe=0;xe<V.length;xe++){let Oe=V[xe];y(M,Oe-fe),fe=Oe}}return M.flush()}function we(P){let{length:M}=P,O=new R(P),V=[],fe=0,xe=0,Oe=0,De=0,ze=0;do{let Q=O.indexOf(";"),me=[],be=!0,Ie=0;for(fe=0;O.pos<Q;){let ye;fe+=g(h(O)),fe<Ie&&(be=!1),Ie=fe,b(O,Q)?(xe+=g(h(O)),Oe+=g(h(O)),De+=g(h(O)),b(O,Q)?(ze+=g(h(O)),ye=[fe,xe,Oe,De,ze]):ye=[fe,xe,Oe,De]):ye=[fe],me.push(ye),O.pos++}be||ge(me),V.push(me),O.pos=Q+1}while(O.pos<=M);return V}function ge(P){P.sort(ve)}function ve(P,M){return P[0]-M[0]}function oe(P){let M=new v,O=0,V=0,fe=0,xe=0;for(let Oe=0;Oe<P.length;Oe++){let De=P[Oe];if(Oe>0&&M.write(u),De.length===0)continue;let ze=0;for(let Q=0;Q<De.length;Q++){let me=De[Q];Q>0&&M.write(c),y(M,k(me[0]-ze)),ze=me[0],me.length!==1&&(y(M,k(me[1]-O)),y(M,k(me[2]-V)),y(M,k(me[3]-fe)),O=me[1],V=me[2],fe=me[3],me.length!==4&&(y(M,k(me[4]-xe)),xe=me[4]))}}return M.flush()}}))});var Fy=Ce((Zu,ed)=>{(function(e,t){typeof Zu=="object"&&typeof ed<"u"?ed.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.resolveURI=t())})(Zu,(function(){"use strict";let e=/^[\w+.-]+:\/\//,t=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,n=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function r(y){return e.test(y)}function o(y){return y.startsWith("//")}function s(y){return y.startsWith("/")}function i(y){return y.startsWith("file:")}function a(y){return/^[.?#]/.test(y)}function l(y){let k=t.exec(y);return u(k[1],k[2]||"",k[3],k[4]||"",k[5]||"/",k[6]||"",k[7]||"")}function c(y){let k=n.exec(y),b=k[2];return u("file:","",k[1]||"","",s(b)?b:"/"+b,k[3]||"",k[4]||"")}function u(y,k,b,w,_,v,R){return{scheme:y,user:k,host:b,port:w,path:_,query:v,hash:R,type:7}}function p(y){if(o(y)){let b=l("http:"+y);return b.scheme="",b.type=6,b}if(s(y)){let b=l("http://foo.com"+y);return b.scheme="",b.host="",b.type=5,b}if(i(y))return c(y);if(r(y))return l(y);let k=l("http://foo.com/"+y);return k.scheme="",k.host="",k.type=y?y.startsWith("?")?3:y.startsWith("#")?2:4:1,k}function d(y){if(y.endsWith("/.."))return y;let k=y.lastIndexOf("/");return y.slice(0,k+1)}function m(y,k){h(k,k.type),y.path==="/"?y.path=k.path:y.path=d(k.path)+y.path}function h(y,k){let b=k<=4,w=y.path.split("/"),_=1,v=0,R=!1;for(let T=1;T<w.length;T++){let x=w[T];if(!x){R=!0;continue}if(R=!1,x!=="."){if(x===".."){v?(R=!0,v--,_--):b&&(w[_++]=x);continue}w[_++]=x,v++}}let S="";for(let T=1;T<_;T++)S+="/"+w[T];(!S||R&&!S.endsWith("/.."))&&(S+="/"),y.path=S}function g(y,k){if(!y&&!k)return"";let b=p(y),w=b.type;if(k&&w!==7){let v=p(k),R=v.type;switch(w){case 1:b.hash=v.hash;case 2:b.query=v.query;case 3:case 4:m(b,v);case 5:b.user=v.user,b.host=v.host,b.port=v.port;case 6:b.scheme=v.scheme}R>w&&(w=R)}h(b,w);let _=b.query+b.hash;switch(w){case 2:case 3:return _;case 4:{let v=b.path.slice(1);return v?a(k||y)&&!a(v)?"./"+v+_:v+_:_||"."}case 5:return b.path+_;default:return b.scheme+"//"+b.user+b.host+b.port+b.path+_}}return g}))});var Oy=Ce((td,mi)=>{(function(e,t){if(typeof td=="object"&&typeof mi<"u")t(mi,Fy(),Yu()),mi.exports=n(mi);else if(typeof define=="function"&&define.amd)define(["module","@jridgewell/resolve-uri","@jridgewell/sourcemap-codec"],function(r){t.apply(this,arguments),r.exports=n(r)});else{let r={exports:{}};t(r,e.resolveURI,e.sourcemapCodec),e=typeof globalThis<"u"?globalThis:e||self,e.traceMapping=n(r)}function n(r){return"default"in r.exports?r.exports.default:r.exports}})(td,(function(e,t,n){"use strict";var r=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,c=(H,ce)=>function(){return ce||(0,H[i(H)[0]])((ce={exports:{}}).exports,ce),ce.exports},u=(H,ce)=>{for(var de in ce)o(H,de,{get:ce[de],enumerable:!0})},p=(H,ce,de,ke)=>{if(ce&&typeof ce=="object"||typeof ce=="function")for(let Ne of i(ce))!l.call(H,Ne)&&Ne!==de&&o(H,Ne,{get:()=>ce[Ne],enumerable:!(ke=s(ce,Ne))||ke.enumerable});return H},d=(H,ce,de)=>(de=H!=null?r(a(H)):{},p(ce||!H||!H.__esModule?o(de,"default",{value:H,enumerable:!0}):de,H)),m=H=>p(o({},"__esModule",{value:!0}),H),h=c({"umd:@jridgewell/sourcemap-codec"(H,ce){ce.exports=n}}),g=c({"umd:@jridgewell/resolve-uri"(H,ce){ce.exports=t}}),y={};u(y,{AnyMap:()=>fe,FlattenMap:()=>fe,GREATEST_LOWER_BOUND:()=>Ie,LEAST_UPPER_BOUND:()=>be,TraceMap:()=>ye,allGeneratedPositionsFor:()=>Pe,decodedMap:()=>An,decodedMappings:()=>se,eachMapping:()=>Ge,encodedMap:()=>ir,encodedMappings:()=>re,generatedPositionFor:()=>Me,isIgnored:()=>bn,originalPositionFor:()=>_e,presortedDecodedMap:()=>En,sourceContentFor:()=>Ft,traceSegment:()=>le}),e.exports=m(y);var k=d(h()),b=d(g());function w(H){if(!H)return"";let ce=H.lastIndexOf("/");return H.slice(0,ce+1)}function _(H,ce){let de=w(H),ke=ce?ce+"/":"";return Ne=>(0,b.default)(ke+(Ne||""),de)}var v=0,R=1,S=2,T=3,x=4,$=1,U=2;function E(H,ce){let de=z(H,0);if(de===H.length)return H;ce||(H=H.slice());for(let ke=de;ke<H.length;ke=z(H,ke+1))H[ke]=D(H[ke],ce);return H}function z(H,ce){for(let de=ce;de<H.length;de++)if(!G(H[de]))return de;return H.length}function G(H){for(let ce=1;ce<H.length;ce++)if(H[ce][v]<H[ce-1][v])return!1;return!0}function D(H,ce){return ce||(H=H.slice()),H.sort(te)}function te(H,ce){return H[v]-ce[v]}function we(H,ce){let de=ce.map(()=>[]);for(let ke=0;ke<H.length;ke++){let Ne=H[ke];for(let Ee=0;Ee<Ne.length;Ee++){let Qe=Ne[Ee];if(Qe.length===1)continue;let gt=Qe[R],Je=Qe[S],Et=Qe[T],Ot=de[gt];(Ot[Je]||(Ot[Je]=[])).push([Et,ke,Qe[v]])}}for(let ke=0;ke<de.length;ke++){let Ne=de[ke];for(let Ee=0;Ee<Ne.length;Ee++){let Qe=Ne[Ee];Qe&&Qe.sort(te)}}return de}var ge=!1;function ve(H,ce,de,ke){for(;de<=ke;){let Ne=de+(ke-de>>1),Ee=H[Ne][v]-ce;if(Ee===0)return ge=!0,Ne;Ee<0?de=Ne+1:ke=Ne-1}return ge=!1,de-1}function oe(H,ce,de){for(let ke=de+1;ke<H.length&&H[ke][v]===ce;de=ke++);return de}function P(H,ce,de){for(let ke=de-1;ke>=0&&H[ke][v]===ce;de=ke--);return de}function M(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function O(H,ce,de,ke){let{lastKey:Ne,lastNeedle:Ee,lastIndex:Qe}=de,gt=0,Je=H.length-1;if(ke===Ne){if(ce===Ee)return ge=Qe!==-1&&H[Qe][v]===ce,Qe;ce>=Ee?gt=Qe===-1?0:Qe:Je=Qe}return de.lastKey=ke,de.lastNeedle=ce,de.lastIndex=ve(H,ce,gt,Je)}function V(H){return typeof H=="string"?JSON.parse(H):H}var fe=function(H,ce){let de=V(H);if(!("sections"in de))return new ye(de,ce);let ke=[],Ne=[],Ee=[],Qe=[],gt=[];xe(de,ce,ke,Ne,Ee,Qe,gt,0,0,1/0,1/0);let Je={version:3,file:de.file,names:Qe,sources:Ne,sourcesContent:Ee,mappings:ke,ignoreList:gt};return En(Je)};function xe(H,ce,de,ke,Ne,Ee,Qe,gt,Je,Et,Ot){let{sections:Lt}=H;for(let rn=0;rn<Lt.length;rn++){let{map:sn,offset:vn}=Lt[rn],Tn=Et,Pn=Ot;if(rn+1<Lt.length){let ar=Lt[rn+1].offset;Tn=Math.min(Et,gt+ar.line),Tn===Et?Pn=Math.min(Ot,Je+ar.column):Tn<Et&&(Pn=Je+ar.column)}Oe(sn,ce,de,ke,Ne,Ee,Qe,gt+vn.line,Je+vn.column,Tn,Pn)}}function Oe(H,ce,de,ke,Ne,Ee,Qe,gt,Je,Et,Ot){let Lt=V(H);if("sections"in Lt)return xe(...arguments);let rn=new ye(Lt,ce),sn=ke.length,vn=Ee.length,Tn=se(rn),{resolvedSources:Pn,sourcesContent:ar,ignoreList:co}=rn;if(De(ke,Pn),De(Ee,rn.names),ar)De(Ne,ar);else for(let an=0;an<Pn.length;an++)Ne.push(null);if(co)for(let an=0;an<co.length;an++)Qe.push(co[an]+sn);for(let an=0;an<Tn.length;an++){let uo=gt+an;if(uo>Et)return;let Vo=ze(de,uo),Hs=an===0?Je:0,Jo=Tn[an];for(let po=0;po<Jo.length;po++){let Xn=Jo[po],Lr=Hs+Xn[v];if(uo===Et&&Lr>=Ot)return;if(Xn.length===1){Vo.push([Lr]);continue}let Xo=sn+Xn[R],Qo=Xn[S],Yo=Xn[T];Vo.push(Xn.length===4?[Lr,Xo,Qo,Yo]:[Lr,Xo,Qo,Yo,vn+Xn[x]])}}}function De(H,ce){for(let de=0;de<ce.length;de++)H.push(ce[de])}function ze(H,ce){for(let de=H.length;de<=ce;de++)H[de]=[];return H[ce]}var Q="`line` must be greater than 0 (lines start at line 1)",me="`column` must be greater than or equal to 0 (columns start at column 0)",be=-1,Ie=1,ye=class{constructor(H,ce){let de=typeof H=="string";if(!de&&H._decodedMemo)return H;let ke=V(H),{version:Ne,file:Ee,names:Qe,sourceRoot:gt,sources:Je,sourcesContent:Et}=ke;this.version=Ne,this.file=Ee,this.names=Qe||[],this.sourceRoot=gt,this.sources=Je,this.sourcesContent=Et,this.ignoreList=ke.ignoreList||ke.x_google_ignoreList||void 0;let Ot=_(ce,gt);this.resolvedSources=Je.map(Ot);let{mappings:Lt}=ke;if(typeof Lt=="string")this._encoded=Lt,this._decoded=void 0;else if(Array.isArray(Lt))this._encoded=void 0,this._decoded=E(Lt,de);else throw ke.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(ke)}`);this._decodedMemo=M(),this._bySources=void 0,this._bySourceMemos=void 0}};function Le(H){return H}function re(H){var ce,de;return(de=(ce=H)._encoded)!=null?de:ce._encoded=(0,k.encode)(H._decoded)}function se(H){var ce;return(ce=H)._decoded||(ce._decoded=(0,k.decode)(H._encoded))}function le(H,ce,de){let ke=se(H);if(ce>=ke.length)return null;let Ne=ke[ce],Ee=Jn(Ne,H._decodedMemo,ce,de,Ie);return Ee===-1?null:Ne[Ee]}function _e(H,ce){let{line:de,column:ke,bias:Ne}=ce;if(de--,de<0)throw new Error(Q);if(ke<0)throw new Error(me);let Ee=se(H);if(de>=Ee.length)return Mn(null,null,null,null);let Qe=Ee[de],gt=Jn(Qe,H._decodedMemo,de,ke,Ne||Ie);if(gt===-1)return Mn(null,null,null,null);let Je=Qe[gt];if(Je.length===1)return Mn(null,null,null,null);let{names:Et,resolvedSources:Ot}=H;return Mn(Ot[Je[R]],Je[S]+1,Je[T],Je.length===5?Et[Je[x]]:null)}function Me(H,ce){let{source:de,line:ke,column:Ne,bias:Ee}=ce;return Ko(H,de,ke,Ne,Ee||Ie,!1)}function Pe(H,ce){let{source:de,line:ke,column:Ne,bias:Ee}=ce;return Ko(H,de,ke,Ne,Ee||be,!0)}function Ge(H,ce){let de=se(H),{names:ke,resolvedSources:Ne}=H;for(let Ee=0;Ee<de.length;Ee++){let Qe=de[Ee];for(let gt=0;gt<Qe.length;gt++){let Je=Qe[gt],Et=Ee+1,Ot=Je[0],Lt=null,rn=null,sn=null,vn=null;Je.length!==1&&(Lt=Ne[Je[1]],rn=Je[2]+1,sn=Je[3]),Je.length===5&&(vn=ke[Je[4]]),ce({generatedLine:Et,generatedColumn:Ot,source:Lt,originalLine:rn,originalColumn:sn,name:vn})}}}function dt(H,ce){let{sources:de,resolvedSources:ke}=H,Ne=de.indexOf(ce);return Ne===-1&&(Ne=ke.indexOf(ce)),Ne}function Ft(H,ce){let{sourcesContent:de}=H;if(de==null)return null;let ke=dt(H,ce);return ke===-1?null:de[ke]}function bn(H,ce){let{ignoreList:de}=H;if(de==null)return!1;let ke=dt(H,ce);return ke===-1?!1:de.includes(ke)}function En(H,ce){let de=new ye(In(H,[]),ce);return de._decoded=H.mappings,de}function An(H){return In(H,se(H))}function ir(H){return In(H,re(H))}function In(H,ce){return{version:H.version,file:H.file,names:H.names,sourceRoot:H.sourceRoot,sources:H.sources,sourcesContent:H.sourcesContent,mappings:ce,ignoreList:H.ignoreList||H.x_google_ignoreList}}function Mn(H,ce,de,ke){return{source:H,line:ce,column:de,name:ke}}function yn(H,ce){return{line:H,column:ce}}function Jn(H,ce,de,ke,Ne){let Ee=O(H,ke,ce,de);return ge?Ee=(Ne===be?oe:P)(H,ke,Ee):Ne===be&&Ee++,Ee===-1||Ee===H.length?-1:Ee}function Us(H,ce,de,ke,Ne){let Ee=Jn(H,ce,de,ke,Ie);if(!ge&&Ne===be&&Ee++,Ee===-1||Ee===H.length)return[];let Qe=ge?ke:H[Ee][v];ge||(Ee=P(H,Qe,Ee));let gt=oe(H,Qe,Ee),Je=[];for(;Ee<=gt;Ee++){let Et=H[Ee];Je.push(yn(Et[$]+1,Et[U]))}return Je}function Ko(H,ce,de,ke,Ne,Ee){var Qe,gt;if(de--,de<0)throw new Error(Q);if(ke<0)throw new Error(me);let{sources:Je,resolvedSources:Et}=H,Ot=Je.indexOf(ce);if(Ot===-1&&(Ot=Et.indexOf(ce)),Ot===-1)return Ee?[]:yn(null,null);let Lt=(Qe=H)._bySourceMemos||(Qe._bySourceMemos=Je.map(M)),sn=((gt=H)._bySources||(gt._bySources=we(se(H),Lt)))[Ot][de];if(sn==null)return Ee?[]:yn(null,null);let vn=Lt[Ot];if(Ee)return Us(sn,vn,de,ke,Ne);let Tn=Jn(sn,vn,de,ke,Ne);if(Tn===-1)return yn(null,null);let Pn=sn[Tn];return yn(Pn[$]+1,Pn[U])}}))});var Ly=Ce((nd,fi)=>{(function(e,t){if(typeof nd=="object"&&typeof fi<"u")t(fi,Yu(),Oy()),fi.exports=n(fi);else if(typeof define=="function"&&define.amd)define(["module","@jridgewell/sourcemap-codec","@jridgewell/trace-mapping"],function(r){t.apply(this,arguments),r.exports=n(r)});else{let r={exports:{}};t(r,e.sourcemapCodec,e.traceMapping),e=typeof globalThis<"u"?globalThis:e||self,e.genMapping=n(r)}function n(r){return"default"in r.exports?r.exports.default:r.exports}})(nd,(function(e,t,n){"use strict";var r=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,c=(re,se)=>function(){return se||(0,re[i(re)[0]])((se={exports:{}}).exports,se),se.exports},u=(re,se)=>{for(var le in se)o(re,le,{get:se[le],enumerable:!0})},p=(re,se,le,_e)=>{if(se&&typeof se=="object"||typeof se=="function")for(let Me of i(se))!l.call(re,Me)&&Me!==le&&o(re,Me,{get:()=>se[Me],enumerable:!(_e=s(se,Me))||_e.enumerable});return re},d=(re,se,le)=>(le=re!=null?r(a(re)):{},p(se||!re||!re.__esModule?o(le,"default",{value:re,enumerable:!0}):le,re)),m=re=>p(o({},"__esModule",{value:!0}),re),h=c({"umd:@jridgewell/sourcemap-codec"(re,se){se.exports=t}}),g=c({"umd:@jridgewell/trace-mapping"(re,se){se.exports=n}}),y={};u(y,{GenMapping:()=>G,addMapping:()=>we,addSegment:()=>te,allMappings:()=>fe,fromMap:()=>V,maybeAddMapping:()=>ve,maybeAddSegment:()=>ge,setIgnore:()=>P,setSourceContent:()=>oe,toDecodedMap:()=>M,toEncodedMap:()=>O}),e.exports=m(y);var k=class{constructor(){this._indexes={__proto__:null},this.array=[]}};function b(re){return re}function w(re,se){return re._indexes[se]}function _(re,se){let le=w(re,se);if(le!==void 0)return le;let{array:_e,_indexes:Me}=re,Pe=_e.push(se);return Me[se]=Pe-1}function v(re,se){let le=w(re,se);if(le===void 0)return;let{array:_e,_indexes:Me}=re;for(let Pe=le+1;Pe<_e.length;Pe++){let Ge=_e[Pe];_e[Pe-1]=Ge,Me[Ge]--}Me[se]=void 0,_e.pop()}var R=d(h()),S=d(g()),T=0,x=1,$=2,U=3,E=4,z=-1,G=class{constructor({file:re,sourceRoot:se}={}){this._names=new k,this._sources=new k,this._sourcesContent=[],this._mappings=[],this.file=re,this.sourceRoot=se,this._ignoreList=new k}};function D(re){return re}function te(re,se,le,_e,Me,Pe,Ge,dt){return xe(!1,re,se,le,_e,Me,Pe,Ge,dt)}function we(re,se){return Le(!1,re,se)}var ge=(re,se,le,_e,Me,Pe,Ge,dt)=>xe(!0,re,se,le,_e,Me,Pe,Ge,dt),ve=(re,se)=>Le(!0,re,se);function oe(re,se,le){let{_sources:_e,_sourcesContent:Me}=re,Pe=_(_e,se);Me[Pe]=le}function P(re,se,le=!0){let{_sources:_e,_sourcesContent:Me,_ignoreList:Pe}=re,Ge=_(_e,se);Ge===Me.length&&(Me[Ge]=null),le?_(Pe,Ge):v(Pe,Ge)}function M(re){let{_mappings:se,_sources:le,_sourcesContent:_e,_names:Me,_ignoreList:Pe}=re;return me(se),{version:3,file:re.file||void 0,names:Me.array,sourceRoot:re.sourceRoot||void 0,sources:le.array,sourcesContent:_e,mappings:se,ignoreList:Pe.array}}function O(re){let se=M(re);return Object.assign({},se,{mappings:(0,R.encode)(se.mappings)})}function V(re){let se=new S.TraceMap(re),le=new G({file:se.file,sourceRoot:se.sourceRoot});return be(le._names,se.names),be(le._sources,se.sources),le._sourcesContent=se.sourcesContent||se.sources.map(()=>null),le._mappings=(0,S.decodedMappings)(se),se.ignoreList&&be(le._ignoreList,se.ignoreList),le}function fe(re){let se=[],{_mappings:le,_sources:_e,_names:Me}=re;for(let Pe=0;Pe<le.length;Pe++){let Ge=le[Pe];for(let dt=0;dt<Ge.length;dt++){let Ft=Ge[dt],bn={line:Pe+1,column:Ft[T]},En,An,ir;Ft.length!==1&&(En=_e.array[Ft[x]],An={line:Ft[$]+1,column:Ft[U]},Ft.length===5&&(ir=Me.array[Ft[E]])),se.push({generated:bn,source:En,original:An,name:ir})}}return se}function xe(re,se,le,_e,Me,Pe,Ge,dt,Ft){let{_mappings:bn,_sources:En,_sourcesContent:An,_names:ir}=se,In=De(bn,le),Mn=ze(In,_e);if(!Me)return re&&Ie(In,Mn)?void 0:Q(In,Mn,[_e]);let yn=_(En,Me),Jn=dt?_(ir,dt):z;if(yn===An.length&&(An[yn]=Ft??null),!(re&&ye(In,Mn,yn,Pe,Ge,Jn)))return Q(In,Mn,dt?[_e,yn,Pe,Ge,Jn]:[_e,yn,Pe,Ge])}function Oe(re){}function De(re,se){for(let le=re.length;le<=se;le++)re[le]=[];return re[se]}function ze(re,se){let le=re.length;for(let _e=le-1;_e>=0;le=_e--){let Me=re[_e];if(se>=Me[T])break}return le}function Q(re,se,le){for(let _e=re.length;_e>se;_e--)re[_e]=re[_e-1];re[se]=le}function me(re){let{length:se}=re,le=se;for(let _e=le-1;_e>=0&&!(re[_e].length>0);le=_e,_e--);le<se&&(re.length=le)}function be(re,se){for(let le=0;le<se.length;le++)_(re,se[le])}function Ie(re,se){return se===0?!0:re[se-1].length===1}function ye(re,se,le,_e,Me,Pe){if(se===0)return!1;let Ge=re[se-1];return Ge.length===1?!1:le===Ge[x]&&_e===Ge[$]&&Me===Ge[U]&&Pe===(Ge.length===5?Ge[E]:z)}function Le(re,se,le){let{generated:_e,source:Me,original:Pe,name:Ge,content:dt}=le;return Me?xe(re,se,_e.line-1,_e.column,Me,Pe.line-1,Pe.column,Ge,dt):xe(re,se,_e.line-1,_e.column,null,null,null,null,null)}}))});var Dy=Ce(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});var hi=Ly(),Ny=On();function oC({code:e,mappings:t},n,r,o,s){let i=sC(o,s),a=new hi.GenMapping({file:r.compiledFilename}),l=0,c=t[0];for(;c===void 0&&l<t.length-1;)l++,c=t[l];let u=0,p=0;c!==p&&hi.maybeAddSegment.call(void 0,a,u,0,n,u,0);for(let g=0;g<e.length;g++){if(g===c){let y=c-p,k=i[l];for(hi.maybeAddSegment.call(void 0,a,u,y,n,u,k);(c===g||c===void 0)&&l<t.length-1;)l++,c=t[l]}e.charCodeAt(g)===Ny.charCodes.lineFeed&&(u++,p=g+1,c!==p&&hi.maybeAddSegment.call(void 0,a,u,0,n,u,0))}let{sourceRoot:d,sourcesContent:m,...h}=hi.toEncodedMap.call(void 0,a);return h}rd.default=oC;function sC(e,t){let n=new Array(t.length),r=0,o=t[r].start,s=0;for(let i=0;i<e.length;i++)i===o&&(n[r]=o-s,r++,o=t[r].start),e.charCodeAt(i)===Ny.charCodes.lineFeed&&(s=i+1);return n}});var jy=Ce(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});var iC={require:`
|
|
10
|
-
import {createRequire as CREATE_REQUIRE_NAME} from "module";
|
|
11
|
-
const require = CREATE_REQUIRE_NAME(import.meta.url);
|
|
12
|
-
`,interopRequireWildcard:`
|
|
13
|
-
function interopRequireWildcard(obj) {
|
|
14
|
-
if (obj && obj.__esModule) {
|
|
15
|
-
return obj;
|
|
16
|
-
} else {
|
|
17
|
-
var newObj = {};
|
|
18
|
-
if (obj != null) {
|
|
19
|
-
for (var key in obj) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
21
|
-
newObj[key] = obj[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
newObj.default = obj;
|
|
26
|
-
return newObj;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`,interopRequireDefault:`
|
|
30
|
-
function interopRequireDefault(obj) {
|
|
31
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
32
|
-
}
|
|
33
|
-
`,createNamedExportFrom:`
|
|
34
|
-
function createNamedExportFrom(obj, localName, importedName) {
|
|
35
|
-
Object.defineProperty(exports, localName, {enumerable: true, configurable: true, get: () => obj[importedName]});
|
|
36
|
-
}
|
|
37
|
-
`,createStarExport:`
|
|
38
|
-
function createStarExport(obj) {
|
|
39
|
-
Object.keys(obj)
|
|
40
|
-
.filter((key) => key !== "default" && key !== "__esModule")
|
|
41
|
-
.forEach((key) => {
|
|
42
|
-
if (exports.hasOwnProperty(key)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
`,nullishCoalesce:`
|
|
49
|
-
function nullishCoalesce(lhs, rhsFn) {
|
|
50
|
-
if (lhs != null) {
|
|
51
|
-
return lhs;
|
|
52
|
-
} else {
|
|
53
|
-
return rhsFn();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
`,asyncNullishCoalesce:`
|
|
57
|
-
async function asyncNullishCoalesce(lhs, rhsFn) {
|
|
58
|
-
if (lhs != null) {
|
|
59
|
-
return lhs;
|
|
60
|
-
} else {
|
|
61
|
-
return await rhsFn();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`,optionalChain:`
|
|
65
|
-
function optionalChain(ops) {
|
|
66
|
-
let lastAccessLHS = undefined;
|
|
67
|
-
let value = ops[0];
|
|
68
|
-
let i = 1;
|
|
69
|
-
while (i < ops.length) {
|
|
70
|
-
const op = ops[i];
|
|
71
|
-
const fn = ops[i + 1];
|
|
72
|
-
i += 2;
|
|
73
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
77
|
-
lastAccessLHS = value;
|
|
78
|
-
value = fn(value);
|
|
79
|
-
} else if (op === 'call' || op === 'optionalCall') {
|
|
80
|
-
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
81
|
-
lastAccessLHS = undefined;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
`,asyncOptionalChain:`
|
|
87
|
-
async function asyncOptionalChain(ops) {
|
|
88
|
-
let lastAccessLHS = undefined;
|
|
89
|
-
let value = ops[0];
|
|
90
|
-
let i = 1;
|
|
91
|
-
while (i < ops.length) {
|
|
92
|
-
const op = ops[i];
|
|
93
|
-
const fn = ops[i + 1];
|
|
94
|
-
i += 2;
|
|
95
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
99
|
-
lastAccessLHS = value;
|
|
100
|
-
value = await fn(value);
|
|
101
|
-
} else if (op === 'call' || op === 'optionalCall') {
|
|
102
|
-
value = await fn((...args) => value.call(lastAccessLHS, ...args));
|
|
103
|
-
lastAccessLHS = undefined;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
`,optionalChainDelete:`
|
|
109
|
-
function optionalChainDelete(ops) {
|
|
110
|
-
const result = OPTIONAL_CHAIN_NAME(ops);
|
|
111
|
-
return result == null ? true : result;
|
|
112
|
-
}
|
|
113
|
-
`,asyncOptionalChainDelete:`
|
|
114
|
-
async function asyncOptionalChainDelete(ops) {
|
|
115
|
-
const result = await ASYNC_OPTIONAL_CHAIN_NAME(ops);
|
|
116
|
-
return result == null ? true : result;
|
|
117
|
-
}
|
|
118
|
-
`},od=class e{__init(){this.helperNames={}}__init2(){this.createRequireName=null}constructor(t){this.nameManager=t,e.prototype.__init.call(this),e.prototype.__init2.call(this)}getHelperName(t){let n=this.helperNames[t];return n||(n=this.nameManager.claimFreeName(`_${t}`),this.helperNames[t]=n,n)}emitHelpers(){let t="";this.helperNames.optionalChainDelete&&this.getHelperName("optionalChain"),this.helperNames.asyncOptionalChainDelete&&this.getHelperName("asyncOptionalChain");for(let[n,r]of Object.entries(iC)){let o=this.helperNames[n],s=r;n==="optionalChainDelete"?s=s.replace("OPTIONAL_CHAIN_NAME",this.helperNames.optionalChain):n==="asyncOptionalChainDelete"?s=s.replace("ASYNC_OPTIONAL_CHAIN_NAME",this.helperNames.asyncOptionalChain):n==="require"&&(this.createRequireName===null&&(this.createRequireName=this.nameManager.claimFreeName("_createRequire")),s=s.replace(/CREATE_REQUIRE_NAME/g,this.createRequireName)),o&&(t+=" ",t+=s.replace(n,o).replace(/\s+/g," ").trim())}return t}};sd.HelperManager=od});var Uy=Ce(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});var id=Yt(),Za=tt();function aC(e,t,n){qy(e,n)&&lC(e,t,n)}el.default=aC;function qy(e,t){for(let n of e.tokens)if(n.type===Za.TokenType.name&&!n.isType&&id.isNonTopLevelDeclaration.call(void 0,n)&&t.has(e.identifierNameForToken(n)))return!0;return!1}el.hasShadowedGlobals=qy;function lC(e,t,n){let r=[],o=t.length-1;for(let s=e.tokens.length-1;;s--){for(;r.length>0&&r[r.length-1].startTokenIndex===s+1;)r.pop();for(;o>=0&&t[o].endTokenIndex===s+1;)r.push(t[o]),o--;if(s<0)break;let i=e.tokens[s],a=e.identifierNameForToken(i);if(r.length>1&&!i.isType&&i.type===Za.TokenType.name&&n.has(a)){if(id.isBlockScopedDeclaration.call(void 0,i))By(r[r.length-1],e,a);else if(id.isFunctionScopedDeclaration.call(void 0,i)){let l=r.length-1;for(;l>0&&!r[l].isFunctionScope;)l--;if(l<0)throw new Error("Did not find parent function scope.");By(r[l],e,a)}}}if(r.length>0)throw new Error("Expected empty scope stack after processing file.")}function By(e,t,n){for(let r=e.startTokenIndex;r<e.endTokenIndex;r++){let o=t.tokens[r];(o.type===Za.TokenType.name||o.type===Za.TokenType.jsxName)&&t.identifierNameForToken(o)===n&&(o.shadowsGlobal=!0)}}});var Hy=Ce(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});var cC=tt();function uC(e,t){let n=[];for(let r of t)r.type===cC.TokenType.name&&n.push(e.slice(r.start,r.end));return n}ad.default=uC});var Wy=Ce(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:!0});function dC(e){return e&&e.__esModule?e:{default:e}}var pC=Hy(),mC=dC(pC),ld=class e{__init(){this.usedNames=new Set}constructor(t,n){e.prototype.__init.call(this),this.usedNames=new Set(mC.default.call(void 0,t,n))}claimFreeName(t){let n=this.findFreeName(t);return this.usedNames.add(n),n}findFreeName(t){if(!this.usedNames.has(t))return t;let n=2;for(;this.usedNames.has(t+String(n));)n++;return t+String(n)}};cd.default=ld});var tl=Ce(mr=>{"use strict";var fC=mr&&mr.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)o.hasOwnProperty(s)&&(r[s]=o[s])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(mr,"__esModule",{value:!0});mr.DetailContext=mr.NoopContext=mr.VError=void 0;var zy=(function(e){fC(t,e);function t(n,r){var o=e.call(this,r)||this;return o.path=n,Object.setPrototypeOf(o,t.prototype),o}return t})(Error);mr.VError=zy;var hC=(function(){function e(){}return e.prototype.fail=function(t,n,r){return!1},e.prototype.unionResolver=function(){return this},e.prototype.createContext=function(){return this},e.prototype.resolveUnion=function(t){},e})();mr.NoopContext=hC;var Gy=(function(){function e(){this._propNames=[""],this._messages=[null],this._score=0}return e.prototype.fail=function(t,n,r){return this._propNames.push(t),this._messages.push(n),this._score+=r,!1},e.prototype.unionResolver=function(){return new gC},e.prototype.resolveUnion=function(t){for(var n,r,o=t,s=null,i=0,a=o.contexts;i<a.length;i++){var l=a[i];(!s||l._score>=s._score)&&(s=l)}s&&s._score>0&&((n=this._propNames).push.apply(n,s._propNames),(r=this._messages).push.apply(r,s._messages))},e.prototype.getError=function(t){for(var n=[],r=this._propNames.length-1;r>=0;r--){var o=this._propNames[r];t+=typeof o=="number"?"["+o+"]":o?"."+o:"";var s=this._messages[r];s&&n.push(t+" "+s)}return new zy(t,n.join("; "))},e.prototype.getErrorDetail=function(t){for(var n=[],r=this._propNames.length-1;r>=0;r--){var o=this._propNames[r];t+=typeof o=="number"?"["+o+"]":o?"."+o:"";var s=this._messages[r];s&&n.push({path:t,message:s})}for(var i=null,r=n.length-1;r>=0;r--)i&&(n[r].nested=[i]),i=n[r];return i},e})();mr.DetailContext=Gy;var gC=(function(){function e(){this.contexts=[]}return e.prototype.createContext=function(){var t=new Gy;return this.contexts.push(t),t},e})()});var bd=Ce(Ae=>{"use strict";var jn=Ae&&Ae.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)o.hasOwnProperty(s)&&(r[s]=o[s])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(Ae,"__esModule",{value:!0});Ae.basicTypes=Ae.BasicType=Ae.TParamList=Ae.TParam=Ae.param=Ae.TFunc=Ae.func=Ae.TProp=Ae.TOptional=Ae.opt=Ae.TIface=Ae.iface=Ae.TEnumLiteral=Ae.enumlit=Ae.TEnumType=Ae.enumtype=Ae.TIntersection=Ae.intersection=Ae.TUnion=Ae.union=Ae.TTuple=Ae.tuple=Ae.TArray=Ae.array=Ae.TLiteral=Ae.lit=Ae.TName=Ae.name=Ae.TType=void 0;var Jy=tl(),Sn=(function(){function e(){}return e})();Ae.TType=Sn;function Gr(e){return typeof e=="string"?Xy(e):e}function pd(e,t){var n=e[t];if(!n)throw new Error("Unknown type "+t);return n}function Xy(e){return new md(e)}Ae.name=Xy;var md=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.name=n,r._failMsg="is not a "+n,r}return t.prototype.getChecker=function(n,r,o){var s=this,i=pd(n,this.name),a=i.getChecker(n,r,o);return i instanceof dn||i instanceof t?a:function(l,c){return a(l,c)?!0:c.fail(null,s._failMsg,0)}},t})(Sn);Ae.TName=md;function bC(e){return new fd(e)}Ae.lit=bC;var fd=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.value=n,r.name=JSON.stringify(n),r._failMsg="is not "+r.name,r}return t.prototype.getChecker=function(n,r){var o=this;return function(s,i){return s===o.value?!0:i.fail(null,o._failMsg,-1)}},t})(Sn);Ae.TLiteral=fd;function yC(e){return new Qy(Gr(e))}Ae.array=yC;var Qy=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.ttype=n,r}return t.prototype.getChecker=function(n,r){var o=this.ttype.getChecker(n,r);return function(s,i){if(!Array.isArray(s))return i.fail(null,"is not an array",0);for(var a=0;a<s.length;a++){var l=o(s[a],i);if(!l)return i.fail(a,null,1)}return!0}},t})(Sn);Ae.TArray=Qy;function wC(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return new Yy(e.map(function(n){return Gr(n)}))}Ae.tuple=wC;var Yy=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.ttypes=n,r}return t.prototype.getChecker=function(n,r){var o=this.ttypes.map(function(i){return i.getChecker(n,r)}),s=function(i,a){if(!Array.isArray(i))return a.fail(null,"is not an array",0);for(var l=0;l<o.length;l++){var c=o[l](i[l],a);if(!c)return a.fail(l,null,1)}return!0};return r?function(i,a){return s(i,a)?i.length<=o.length?!0:a.fail(o.length,"is extraneous",2):!1}:s},t})(Sn);Ae.TTuple=Yy;function kC(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return new Zy(e.map(function(n){return Gr(n)}))}Ae.union=kC;var Zy=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;r.ttypes=n;var o=n.map(function(i){return i instanceof md||i instanceof fd?i.name:null}).filter(function(i){return i}),s=n.length-o.length;return o.length?(s>0&&o.push(s+" more"),r._failMsg="is none of "+o.join(", ")):r._failMsg="is none of "+s+" types",r}return t.prototype.getChecker=function(n,r){var o=this,s=this.ttypes.map(function(i){return i.getChecker(n,r)});return function(i,a){for(var l=a.unionResolver(),c=0;c<s.length;c++){var u=s[c](i,l.createContext());if(u)return!0}return a.resolveUnion(l),a.fail(null,o._failMsg,0)}},t})(Sn);Ae.TUnion=Zy;function _C(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return new e0(e.map(function(n){return Gr(n)}))}Ae.intersection=_C;var e0=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.ttypes=n,r}return t.prototype.getChecker=function(n,r){var o=new Set,s=this.ttypes.map(function(i){return i.getChecker(n,r,o)});return function(i,a){var l=s.every(function(c){return c(i,a)});return l?!0:a.fail(null,null,0)}},t})(Sn);Ae.TIntersection=e0;function vC(e){return new hd(e)}Ae.enumtype=vC;var hd=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.members=n,r.validValues=new Set,r._failMsg="is not a valid enum value",r.validValues=new Set(Object.keys(n).map(function(o){return n[o]})),r}return t.prototype.getChecker=function(n,r){var o=this;return function(s,i){return o.validValues.has(s)?!0:i.fail(null,o._failMsg,0)}},t})(Sn);Ae.TEnumType=hd;function TC(e,t){return new t0(e,t)}Ae.enumlit=TC;var t0=(function(e){jn(t,e);function t(n,r){var o=e.call(this)||this;return o.enumName=n,o.prop=r,o._failMsg="is not "+n+"."+r,o}return t.prototype.getChecker=function(n,r){var o=this,s=pd(n,this.enumName);if(!(s instanceof hd))throw new Error("Type "+this.enumName+" used in enumlit is not an enum type");var i=s.members[this.prop];if(!s.members.hasOwnProperty(this.prop))throw new Error("Unknown value "+this.enumName+"."+this.prop+" used in enumlit");return function(a,l){return a===i?!0:l.fail(null,o._failMsg,-1)}},t})(Sn);Ae.TEnumLiteral=t0;function xC(e){return Object.keys(e).map(function(t){return SC(t,e[t])})}function SC(e,t){return t instanceof gd?new dd(e,t.ttype,!0):new dd(e,Gr(t),!1)}function $C(e,t){return new n0(e,xC(t))}Ae.iface=$C;var n0=(function(e){jn(t,e);function t(n,r){var o=e.call(this)||this;return o.bases=n,o.props=r,o.propSet=new Set(r.map(function(s){return s.name})),o}return t.prototype.getChecker=function(n,r,o){var s=this,i=this.bases.map(function(d){return pd(n,d).getChecker(n,r)}),a=this.props.map(function(d){return d.ttype.getChecker(n,r)}),l=new Jy.NoopContext,c=this.props.map(function(d,m){return!d.isOpt&&!a[m](void 0,l)}),u=function(d,m){if(typeof d!="object"||d===null)return m.fail(null,"is not an object",0);for(var h=0;h<i.length;h++)if(!i[h](d,m))return!1;for(var h=0;h<a.length;h++){var g=s.props[h].name,y=d[g];if(y===void 0){if(c[h])return m.fail(g,"is missing",1)}else{var k=a[h](y,m);if(!k)return m.fail(g,null,1)}}return!0};if(!r)return u;var p=this.propSet;return o&&(this.propSet.forEach(function(d){return o.add(d)}),p=o),function(d,m){if(!u(d,m))return!1;for(var h in d)if(!p.has(h))return m.fail(h,"is extraneous",2);return!0}},t})(Sn);Ae.TIface=n0;function RC(e){return new gd(Gr(e))}Ae.opt=RC;var gd=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.ttype=n,r}return t.prototype.getChecker=function(n,r){var o=this.ttype.getChecker(n,r);return function(s,i){return s===void 0||o(s,i)}},t})(Sn);Ae.TOptional=gd;var dd=(function(){function e(t,n,r){this.name=t,this.ttype=n,this.isOpt=r}return e})();Ae.TProp=dd;function CC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return new r0(new s0(t),Gr(e))}Ae.func=CC;var r0=(function(e){jn(t,e);function t(n,r){var o=e.call(this)||this;return o.paramList=n,o.result=r,o}return t.prototype.getChecker=function(n,r){return function(o,s){return typeof o=="function"?!0:s.fail(null,"is not a function",0)}},t})(Sn);Ae.TFunc=r0;function EC(e,t,n){return new o0(e,Gr(t),!!n)}Ae.param=EC;var o0=(function(){function e(t,n,r){this.name=t,this.ttype=n,this.isOpt=r}return e})();Ae.TParam=o0;var s0=(function(e){jn(t,e);function t(n){var r=e.call(this)||this;return r.params=n,r}return t.prototype.getChecker=function(n,r){var o=this,s=this.params.map(function(c){return c.ttype.getChecker(n,r)}),i=new Jy.NoopContext,a=this.params.map(function(c,u){return!c.isOpt&&!s[u](void 0,i)}),l=function(c,u){if(!Array.isArray(c))return u.fail(null,"is not an array",0);for(var p=0;p<s.length;p++){var d=o.params[p];if(c[p]===void 0){if(a[p])return u.fail(d.name,"is missing",1)}else{var m=s[p](c[p],u);if(!m)return u.fail(d.name,null,1)}}return!0};return r?function(c,u){return l(c,u)?c.length<=s.length?!0:u.fail(s.length,"is extraneous",2):!1}:l},t})(Sn);Ae.TParamList=s0;var dn=(function(e){jn(t,e);function t(n,r){var o=e.call(this)||this;return o.validator=n,o.message=r,o}return t.prototype.getChecker=function(n,r){var o=this;return function(s,i){return o.validator(s)?!0:i.fail(null,o.message,0)}},t})(Sn);Ae.BasicType=dn;Ae.basicTypes={any:new dn(function(e){return!0},"is invalid"),number:new dn(function(e){return typeof e=="number"},"is not a number"),object:new dn(function(e){return typeof e=="object"&&e},"is not an object"),boolean:new dn(function(e){return typeof e=="boolean"},"is not a boolean"),string:new dn(function(e){return typeof e=="string"},"is not a string"),symbol:new dn(function(e){return typeof e=="symbol"},"is not a symbol"),void:new dn(function(e){return e==null},"is not void"),undefined:new dn(function(e){return e===void 0},"is not undefined"),null:new dn(function(e){return e===null},"is not null"),never:new dn(function(e){return!1},"is unexpected"),Date:new dn(Ky("[object Date]"),"is not a Date"),RegExp:new dn(Ky("[object RegExp]"),"is not a RegExp")};var AC=Object.prototype.toString;function Ky(e){return function(t){return typeof t=="object"&&t&&AC.call(t)===e}}typeof Buffer<"u"&&(Ae.basicTypes.Buffer=new dn(function(e){return Buffer.isBuffer(e)},"is not a Buffer"));var IC=function(e){Ae.basicTypes[e.name]=new dn(function(t){return t instanceof e},"is not a "+e.name)};for(nl=0,ud=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,ArrayBuffer];nl<ud.length;nl++)Vy=ud[nl],IC(Vy);var Vy,nl,ud});var yd=Ce(ot=>{"use strict";var MC=ot&&ot.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,a=s.length;i<a;i++,o++)r[o]=s[i];return r};Object.defineProperty(ot,"__esModule",{value:!0});ot.Checker=ot.createCheckers=void 0;var gi=bd(),ds=tl(),Tt=bd();Object.defineProperty(ot,"TArray",{enumerable:!0,get:function(){return Tt.TArray}});Object.defineProperty(ot,"TEnumType",{enumerable:!0,get:function(){return Tt.TEnumType}});Object.defineProperty(ot,"TEnumLiteral",{enumerable:!0,get:function(){return Tt.TEnumLiteral}});Object.defineProperty(ot,"TFunc",{enumerable:!0,get:function(){return Tt.TFunc}});Object.defineProperty(ot,"TIface",{enumerable:!0,get:function(){return Tt.TIface}});Object.defineProperty(ot,"TLiteral",{enumerable:!0,get:function(){return Tt.TLiteral}});Object.defineProperty(ot,"TName",{enumerable:!0,get:function(){return Tt.TName}});Object.defineProperty(ot,"TOptional",{enumerable:!0,get:function(){return Tt.TOptional}});Object.defineProperty(ot,"TParam",{enumerable:!0,get:function(){return Tt.TParam}});Object.defineProperty(ot,"TParamList",{enumerable:!0,get:function(){return Tt.TParamList}});Object.defineProperty(ot,"TProp",{enumerable:!0,get:function(){return Tt.TProp}});Object.defineProperty(ot,"TTuple",{enumerable:!0,get:function(){return Tt.TTuple}});Object.defineProperty(ot,"TType",{enumerable:!0,get:function(){return Tt.TType}});Object.defineProperty(ot,"TUnion",{enumerable:!0,get:function(){return Tt.TUnion}});Object.defineProperty(ot,"TIntersection",{enumerable:!0,get:function(){return Tt.TIntersection}});Object.defineProperty(ot,"array",{enumerable:!0,get:function(){return Tt.array}});Object.defineProperty(ot,"enumlit",{enumerable:!0,get:function(){return Tt.enumlit}});Object.defineProperty(ot,"enumtype",{enumerable:!0,get:function(){return Tt.enumtype}});Object.defineProperty(ot,"func",{enumerable:!0,get:function(){return Tt.func}});Object.defineProperty(ot,"iface",{enumerable:!0,get:function(){return Tt.iface}});Object.defineProperty(ot,"lit",{enumerable:!0,get:function(){return Tt.lit}});Object.defineProperty(ot,"name",{enumerable:!0,get:function(){return Tt.name}});Object.defineProperty(ot,"opt",{enumerable:!0,get:function(){return Tt.opt}});Object.defineProperty(ot,"param",{enumerable:!0,get:function(){return Tt.param}});Object.defineProperty(ot,"tuple",{enumerable:!0,get:function(){return Tt.tuple}});Object.defineProperty(ot,"union",{enumerable:!0,get:function(){return Tt.union}});Object.defineProperty(ot,"intersection",{enumerable:!0,get:function(){return Tt.intersection}});Object.defineProperty(ot,"BasicType",{enumerable:!0,get:function(){return Tt.BasicType}});var PC=tl();Object.defineProperty(ot,"VError",{enumerable:!0,get:function(){return PC.VError}});function FC(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=Object.assign.apply(Object,MC([{},gi.basicTypes],e)),r={},o=0,s=e;o<s.length;o++)for(var i=s[o],a=0,l=Object.keys(i);a<l.length;a++){var c=l[a];r[c]=new i0(n,i[c])}return r}ot.createCheckers=FC;var i0=(function(){function e(t,n,r){if(r===void 0&&(r="value"),this.suite=t,this.ttype=n,this._path=r,this.props=new Map,n instanceof gi.TIface)for(var o=0,s=n.props;o<s.length;o++){var i=s[o];this.props.set(i.name,i.ttype)}this.checkerPlain=this.ttype.getChecker(t,!1),this.checkerStrict=this.ttype.getChecker(t,!0)}return e.prototype.setReportedPath=function(t){this._path=t},e.prototype.check=function(t){return this._doCheck(this.checkerPlain,t)},e.prototype.test=function(t){return this.checkerPlain(t,new ds.NoopContext)},e.prototype.validate=function(t){return this._doValidate(this.checkerPlain,t)},e.prototype.strictCheck=function(t){return this._doCheck(this.checkerStrict,t)},e.prototype.strictTest=function(t){return this.checkerStrict(t,new ds.NoopContext)},e.prototype.strictValidate=function(t){return this._doValidate(this.checkerStrict,t)},e.prototype.getProp=function(t){var n=this.props.get(t);if(!n)throw new Error("Type has no property "+t);return new e(this.suite,n,this._path+"."+t)},e.prototype.methodArgs=function(t){var n=this._getMethod(t);return new e(this.suite,n.paramList)},e.prototype.methodResult=function(t){var n=this._getMethod(t);return new e(this.suite,n.result)},e.prototype.getArgs=function(){if(!(this.ttype instanceof gi.TFunc))throw new Error("getArgs() applied to non-function");return new e(this.suite,this.ttype.paramList)},e.prototype.getResult=function(){if(!(this.ttype instanceof gi.TFunc))throw new Error("getResult() applied to non-function");return new e(this.suite,this.ttype.result)},e.prototype.getType=function(){return this.ttype},e.prototype._doCheck=function(t,n){var r=new ds.NoopContext;if(!t(n,r)){var o=new ds.DetailContext;throw t(n,o),o.getError(this._path)}},e.prototype._doValidate=function(t,n){var r=new ds.NoopContext;if(t(n,r))return null;var o=new ds.DetailContext;return t(n,o),o.getErrorDetail(this._path)},e.prototype._getMethod=function(t){var n=this.props.get(t);if(!n)throw new Error("Type has no property "+t);if(!(n instanceof gi.TFunc))throw new Error("Property "+t+" is not a method");return n},e})();ot.Checker=i0});var a0=Ce(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});function OC(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}var LC=yd(),St=OC(LC),NC=St.union(St.lit("jsx"),St.lit("typescript"),St.lit("flow"),St.lit("imports"),St.lit("react-hot-loader"),St.lit("jest"));xr.Transform=NC;var DC=St.iface([],{compiledFilename:"string"});xr.SourceMapOptions=DC;var jC=St.iface([],{transforms:St.array("Transform"),disableESTransforms:St.opt("boolean"),jsxRuntime:St.opt(St.union(St.lit("classic"),St.lit("automatic"),St.lit("preserve"))),production:St.opt("boolean"),jsxImportSource:St.opt("string"),jsxPragma:St.opt("string"),jsxFragmentPragma:St.opt("string"),keepUnusedImports:St.opt("boolean"),preserveDynamicImport:St.opt("boolean"),injectCreateRequireForImportRequire:St.opt("boolean"),enableLegacyTypeScriptModuleInterop:St.opt("boolean"),enableLegacyBabel5ModuleInterop:St.opt("boolean"),sourceMapOptions:St.opt("SourceMapOptions"),filePath:St.opt("string")});xr.Options=jC;var BC={Transform:xr.Transform,SourceMapOptions:xr.SourceMapOptions,Options:xr.Options};xr.default=BC});var l0=Ce(wd=>{"use strict";Object.defineProperty(wd,"__esModule",{value:!0});function qC(e){return e&&e.__esModule?e:{default:e}}var UC=yd(),HC=a0(),WC=qC(HC),{Options:zC}=UC.createCheckers.call(void 0,WC.default);function GC(e){zC.strictCheck(e)}wd.validateOptions=GC});var rl=Ce(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});var KC=wi(),c0=ps(),pn=Yt(),bi=nn(),Wn=tt(),Zt=Ln(),yi=Eo(),kd=Wr();function VC(){pn.next.call(void 0),yi.parseMaybeAssign.call(void 0,!1)}fr.parseSpread=VC;function u0(e){pn.next.call(void 0),vd(e)}fr.parseRest=u0;function d0(e){yi.parseIdentifier.call(void 0),p0(e)}fr.parseBindingIdentifier=d0;function JC(){yi.parseIdentifier.call(void 0),Zt.state.tokens[Zt.state.tokens.length-1].identifierRole=pn.IdentifierRole.ImportDeclaration}fr.parseImportedIdentifier=JC;function p0(e){let t;Zt.state.scopeDepth===0?t=pn.IdentifierRole.TopLevelDeclaration:e?t=pn.IdentifierRole.BlockScopedDeclaration:t=pn.IdentifierRole.FunctionScopedDeclaration,Zt.state.tokens[Zt.state.tokens.length-1].identifierRole=t}fr.markPriorBindingIdentifier=p0;function vd(e){switch(Zt.state.type){case Wn.TokenType._this:{let t=pn.pushTypeContext.call(void 0,0);pn.next.call(void 0),pn.popTypeContext.call(void 0,t);return}case Wn.TokenType._yield:case Wn.TokenType.name:{Zt.state.type=Wn.TokenType.name,d0(e);return}case Wn.TokenType.bracketL:{pn.next.call(void 0),m0(Wn.TokenType.bracketR,e,!0);return}case Wn.TokenType.braceL:yi.parseObj.call(void 0,!0,e);return;default:kd.unexpected.call(void 0)}}fr.parseBindingAtom=vd;function m0(e,t,n=!1,r=!1,o=0){let s=!0,i=!1,a=Zt.state.tokens.length;for(;!pn.eat.call(void 0,e)&&!Zt.state.error;)if(s?s=!1:(kd.expect.call(void 0,Wn.TokenType.comma),Zt.state.tokens[Zt.state.tokens.length-1].contextId=o,!i&&Zt.state.tokens[a].isType&&(Zt.state.tokens[Zt.state.tokens.length-1].isType=!0,i=!0)),!(n&&pn.match.call(void 0,Wn.TokenType.comma))){if(pn.eat.call(void 0,e))break;if(pn.match.call(void 0,Wn.TokenType.ellipsis)){u0(t),f0(),pn.eat.call(void 0,Wn.TokenType.comma),kd.expect.call(void 0,e);break}else XC(r,t)}}fr.parseBindingList=m0;function XC(e,t){e&&c0.tsParseModifiers.call(void 0,[bi.ContextualKeyword._public,bi.ContextualKeyword._protected,bi.ContextualKeyword._private,bi.ContextualKeyword._readonly,bi.ContextualKeyword._override]),_d(t),f0(),_d(t,!0)}function f0(){Zt.isFlowEnabled?KC.flowParseAssignableListItemTypes.call(void 0):Zt.isTypeScriptEnabled&&c0.tsParseAssignableListItemTypes.call(void 0)}function _d(e,t=!1){if(t||vd(e),!pn.eat.call(void 0,Wn.TokenType.eq))return;let n=Zt.state.tokens.length-1;yi.parseMaybeAssign.call(void 0),Zt.state.tokens[n].rhsEndIndex=Zt.state.tokens.length}fr.parseMaybeDefault=_d});var ps=Ce(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});var A=Yt(),Re=nn(),C=tt(),j=Ln(),Ze=Eo(),fs=rl(),hr=xi(),pe=Wr(),QC=Pd();function xd(){return A.match.call(void 0,C.TokenType.name)}function YC(){return A.match.call(void 0,C.TokenType.name)||!!(j.state.type&C.TokenType.IS_KEYWORD)||A.match.call(void 0,C.TokenType.string)||A.match.call(void 0,C.TokenType.num)||A.match.call(void 0,C.TokenType.bigint)||A.match.call(void 0,C.TokenType.decimal)}function w0(){let e=j.state.snapshot();return A.next.call(void 0),(A.match.call(void 0,C.TokenType.bracketL)||A.match.call(void 0,C.TokenType.braceL)||A.match.call(void 0,C.TokenType.star)||A.match.call(void 0,C.TokenType.ellipsis)||A.match.call(void 0,C.TokenType.hash)||YC())&&!pe.hasPrecedingLineBreak.call(void 0)?!0:(j.state.restoreFromSnapshot(e),!1)}function k0(e){for(;Cd(e)!==null;);}ct.tsParseModifiers=k0;function Cd(e){if(!A.match.call(void 0,C.TokenType.name))return null;let t=j.state.contextualKeyword;if(e.indexOf(t)!==-1&&w0()){switch(t){case Re.ContextualKeyword._readonly:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._readonly;break;case Re.ContextualKeyword._abstract:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._abstract;break;case Re.ContextualKeyword._static:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._static;break;case Re.ContextualKeyword._public:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._public;break;case Re.ContextualKeyword._private:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._private;break;case Re.ContextualKeyword._protected:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._protected;break;case Re.ContextualKeyword._override:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._override;break;case Re.ContextualKeyword._declare:j.state.tokens[j.state.tokens.length-1].type=C.TokenType._declare;break;default:break}return t}return null}ct.tsParseModifier=Cd;function _i(){for(Ze.parseIdentifier.call(void 0);A.eat.call(void 0,C.TokenType.dot);)Ze.parseIdentifier.call(void 0)}function ZC(){_i(),!pe.hasPrecedingLineBreak.call(void 0)&&A.match.call(void 0,C.TokenType.lessThan)&&gs()}function eE(){A.next.call(void 0),Ti()}function tE(){A.next.call(void 0)}function nE(){pe.expect.call(void 0,C.TokenType._typeof),A.match.call(void 0,C.TokenType._import)?_0():_i(),!pe.hasPrecedingLineBreak.call(void 0)&&A.match.call(void 0,C.TokenType.lessThan)&&gs()}function _0(){pe.expect.call(void 0,C.TokenType._import),pe.expect.call(void 0,C.TokenType.parenL),pe.expect.call(void 0,C.TokenType.string),pe.expect.call(void 0,C.TokenType.parenR),A.eat.call(void 0,C.TokenType.dot)&&_i(),A.match.call(void 0,C.TokenType.lessThan)&&gs()}function rE(){A.eat.call(void 0,C.TokenType._const);let e=A.eat.call(void 0,C.TokenType._in),t=pe.eatContextual.call(void 0,Re.ContextualKeyword._out);A.eat.call(void 0,C.TokenType._const),(e||t)&&!A.match.call(void 0,C.TokenType.name)?j.state.tokens[j.state.tokens.length-1].type=C.TokenType.name:Ze.parseIdentifier.call(void 0),A.eat.call(void 0,C.TokenType._extends)&&Pt(),A.eat.call(void 0,C.TokenType.eq)&&Pt()}function hs(){A.match.call(void 0,C.TokenType.lessThan)&&sl()}ct.tsTryParseTypeParameters=hs;function sl(){let e=A.pushTypeContext.call(void 0,0);for(A.match.call(void 0,C.TokenType.lessThan)||A.match.call(void 0,C.TokenType.typeParameterStart)?A.next.call(void 0):pe.unexpected.call(void 0);!A.eat.call(void 0,C.TokenType.greaterThan)&&!j.state.error;)rE(),A.eat.call(void 0,C.TokenType.comma);A.popTypeContext.call(void 0,e)}function Ed(e){let t=e===C.TokenType.arrow;hs(),pe.expect.call(void 0,C.TokenType.parenL),j.state.scopeDepth++,oE(!1),j.state.scopeDepth--,(t||A.match.call(void 0,e))&&ki(e)}function oE(e){fs.parseBindingList.call(void 0,C.TokenType.parenR,e)}function ol(){A.eat.call(void 0,C.TokenType.comma)||pe.semicolon.call(void 0)}function h0(){Ed(C.TokenType.colon),ol()}function sE(){let e=j.state.snapshot();A.next.call(void 0);let t=A.eat.call(void 0,C.TokenType.name)&&A.match.call(void 0,C.TokenType.colon);return j.state.restoreFromSnapshot(e),t}function v0(){if(!(A.match.call(void 0,C.TokenType.bracketL)&&sE()))return!1;let e=A.pushTypeContext.call(void 0,0);return pe.expect.call(void 0,C.TokenType.bracketL),Ze.parseIdentifier.call(void 0),Ti(),pe.expect.call(void 0,C.TokenType.bracketR),vi(),ol(),A.popTypeContext.call(void 0,e),!0}function g0(e){A.eat.call(void 0,C.TokenType.question),!e&&(A.match.call(void 0,C.TokenType.parenL)||A.match.call(void 0,C.TokenType.lessThan))?(Ed(C.TokenType.colon),ol()):(vi(),ol())}function iE(){if(A.match.call(void 0,C.TokenType.parenL)||A.match.call(void 0,C.TokenType.lessThan)){h0();return}if(A.match.call(void 0,C.TokenType._new)){A.next.call(void 0),A.match.call(void 0,C.TokenType.parenL)||A.match.call(void 0,C.TokenType.lessThan)?h0():g0(!1);return}let e=!!Cd([Re.ContextualKeyword._readonly]);v0()||((pe.isContextual.call(void 0,Re.ContextualKeyword._get)||pe.isContextual.call(void 0,Re.ContextualKeyword._set))&&w0(),Ze.parsePropertyName.call(void 0,-1),g0(e))}function aE(){T0()}function T0(){for(pe.expect.call(void 0,C.TokenType.braceL);!A.eat.call(void 0,C.TokenType.braceR)&&!j.state.error;)iE()}function lE(){let e=j.state.snapshot(),t=cE();return j.state.restoreFromSnapshot(e),t}function cE(){return A.next.call(void 0),A.eat.call(void 0,C.TokenType.plus)||A.eat.call(void 0,C.TokenType.minus)?pe.isContextual.call(void 0,Re.ContextualKeyword._readonly):(pe.isContextual.call(void 0,Re.ContextualKeyword._readonly)&&A.next.call(void 0),!A.match.call(void 0,C.TokenType.bracketL)||(A.next.call(void 0),!xd())?!1:(A.next.call(void 0),A.match.call(void 0,C.TokenType._in)))}function uE(){Ze.parseIdentifier.call(void 0),pe.expect.call(void 0,C.TokenType._in),Pt()}function dE(){pe.expect.call(void 0,C.TokenType.braceL),A.match.call(void 0,C.TokenType.plus)||A.match.call(void 0,C.TokenType.minus)?(A.next.call(void 0),pe.expectContextual.call(void 0,Re.ContextualKeyword._readonly)):pe.eatContextual.call(void 0,Re.ContextualKeyword._readonly),pe.expect.call(void 0,C.TokenType.bracketL),uE(),pe.eatContextual.call(void 0,Re.ContextualKeyword._as)&&Pt(),pe.expect.call(void 0,C.TokenType.bracketR),A.match.call(void 0,C.TokenType.plus)||A.match.call(void 0,C.TokenType.minus)?(A.next.call(void 0),pe.expect.call(void 0,C.TokenType.question)):A.eat.call(void 0,C.TokenType.question),SE(),pe.semicolon.call(void 0),pe.expect.call(void 0,C.TokenType.braceR)}function pE(){for(pe.expect.call(void 0,C.TokenType.bracketL);!A.eat.call(void 0,C.TokenType.bracketR)&&!j.state.error;)mE(),A.eat.call(void 0,C.TokenType.comma)}function mE(){A.eat.call(void 0,C.TokenType.ellipsis)?Pt():(Pt(),A.eat.call(void 0,C.TokenType.question)),A.eat.call(void 0,C.TokenType.colon)&&Pt()}function fE(){pe.expect.call(void 0,C.TokenType.parenL),Pt(),pe.expect.call(void 0,C.TokenType.parenR)}function hE(){for(A.nextTemplateToken.call(void 0),A.nextTemplateToken.call(void 0);!A.match.call(void 0,C.TokenType.backQuote)&&!j.state.error;)pe.expect.call(void 0,C.TokenType.dollarBraceL),Pt(),A.nextTemplateToken.call(void 0),A.nextTemplateToken.call(void 0);A.next.call(void 0)}var Kr;(function(e){e[e.TSFunctionType=0]="TSFunctionType";let n=1;e[e.TSConstructorType=n]="TSConstructorType";let r=n+1;e[e.TSAbstractConstructorType=r]="TSAbstractConstructorType"})(Kr||(Kr={}));function Td(e){e===Kr.TSAbstractConstructorType&&pe.expectContextual.call(void 0,Re.ContextualKeyword._abstract),(e===Kr.TSConstructorType||e===Kr.TSAbstractConstructorType)&&pe.expect.call(void 0,C.TokenType._new);let t=j.state.inDisallowConditionalTypesContext;j.state.inDisallowConditionalTypesContext=!1,Ed(C.TokenType.arrow),j.state.inDisallowConditionalTypesContext=t}function gE(){switch(j.state.type){case C.TokenType.name:ZC();return;case C.TokenType._void:case C.TokenType._null:A.next.call(void 0);return;case C.TokenType.string:case C.TokenType.num:case C.TokenType.bigint:case C.TokenType.decimal:case C.TokenType._true:case C.TokenType._false:Ze.parseLiteral.call(void 0);return;case C.TokenType.minus:A.next.call(void 0),Ze.parseLiteral.call(void 0);return;case C.TokenType._this:{tE(),pe.isContextual.call(void 0,Re.ContextualKeyword._is)&&!pe.hasPrecedingLineBreak.call(void 0)&&eE();return}case C.TokenType._typeof:nE();return;case C.TokenType._import:_0();return;case C.TokenType.braceL:lE()?dE():aE();return;case C.TokenType.bracketL:pE();return;case C.TokenType.parenL:fE();return;case C.TokenType.backQuote:hE();return;default:if(j.state.type&C.TokenType.IS_KEYWORD){A.next.call(void 0),j.state.tokens[j.state.tokens.length-1].type=C.TokenType.name;return}break}pe.unexpected.call(void 0)}function bE(){for(gE();!pe.hasPrecedingLineBreak.call(void 0)&&A.eat.call(void 0,C.TokenType.bracketL);)A.eat.call(void 0,C.TokenType.bracketR)||(Pt(),pe.expect.call(void 0,C.TokenType.bracketR))}function yE(){if(pe.expectContextual.call(void 0,Re.ContextualKeyword._infer),Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType._extends)){let e=j.state.snapshot();pe.expect.call(void 0,C.TokenType._extends);let t=j.state.inDisallowConditionalTypesContext;j.state.inDisallowConditionalTypesContext=!0,Pt(),j.state.inDisallowConditionalTypesContext=t,(j.state.error||!j.state.inDisallowConditionalTypesContext&&A.match.call(void 0,C.TokenType.question))&&j.state.restoreFromSnapshot(e)}}function Sd(){if(pe.isContextual.call(void 0,Re.ContextualKeyword._keyof)||pe.isContextual.call(void 0,Re.ContextualKeyword._unique)||pe.isContextual.call(void 0,Re.ContextualKeyword._readonly))A.next.call(void 0),Sd();else if(pe.isContextual.call(void 0,Re.ContextualKeyword._infer))yE();else{let e=j.state.inDisallowConditionalTypesContext;j.state.inDisallowConditionalTypesContext=!1,bE(),j.state.inDisallowConditionalTypesContext=e}}function b0(){if(A.eat.call(void 0,C.TokenType.bitwiseAND),Sd(),A.match.call(void 0,C.TokenType.bitwiseAND))for(;A.eat.call(void 0,C.TokenType.bitwiseAND);)Sd()}function wE(){if(A.eat.call(void 0,C.TokenType.bitwiseOR),b0(),A.match.call(void 0,C.TokenType.bitwiseOR))for(;A.eat.call(void 0,C.TokenType.bitwiseOR);)b0()}function kE(){return A.match.call(void 0,C.TokenType.lessThan)?!0:A.match.call(void 0,C.TokenType.parenL)&&vE()}function _E(){if(A.match.call(void 0,C.TokenType.name)||A.match.call(void 0,C.TokenType._this))return A.next.call(void 0),!0;if(A.match.call(void 0,C.TokenType.braceL)||A.match.call(void 0,C.TokenType.bracketL)){let e=1;for(A.next.call(void 0);e>0&&!j.state.error;)A.match.call(void 0,C.TokenType.braceL)||A.match.call(void 0,C.TokenType.bracketL)?e++:(A.match.call(void 0,C.TokenType.braceR)||A.match.call(void 0,C.TokenType.bracketR))&&e--,A.next.call(void 0);return!0}return!1}function vE(){let e=j.state.snapshot(),t=TE();return j.state.restoreFromSnapshot(e),t}function TE(){return A.next.call(void 0),!!(A.match.call(void 0,C.TokenType.parenR)||A.match.call(void 0,C.TokenType.ellipsis)||_E()&&(A.match.call(void 0,C.TokenType.colon)||A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.question)||A.match.call(void 0,C.TokenType.eq)||A.match.call(void 0,C.TokenType.parenR)&&(A.next.call(void 0),A.match.call(void 0,C.TokenType.arrow))))}function ki(e){let t=A.pushTypeContext.call(void 0,0);pe.expect.call(void 0,e),$E()||Pt(),A.popTypeContext.call(void 0,t)}function xE(){A.match.call(void 0,C.TokenType.colon)&&ki(C.TokenType.colon)}function vi(){A.match.call(void 0,C.TokenType.colon)&&Ti()}ct.tsTryParseTypeAnnotation=vi;function SE(){A.eat.call(void 0,C.TokenType.colon)&&Pt()}function $E(){let e=j.state.snapshot();return pe.isContextual.call(void 0,Re.ContextualKeyword._asserts)?(A.next.call(void 0),pe.eatContextual.call(void 0,Re.ContextualKeyword._is)?(Pt(),!0):xd()||A.match.call(void 0,C.TokenType._this)?(A.next.call(void 0),pe.eatContextual.call(void 0,Re.ContextualKeyword._is)&&Pt(),!0):(j.state.restoreFromSnapshot(e),!1)):xd()||A.match.call(void 0,C.TokenType._this)?(A.next.call(void 0),pe.isContextual.call(void 0,Re.ContextualKeyword._is)&&!pe.hasPrecedingLineBreak.call(void 0)?(A.next.call(void 0),Pt(),!0):(j.state.restoreFromSnapshot(e),!1)):!1}function Ti(){let e=A.pushTypeContext.call(void 0,0);pe.expect.call(void 0,C.TokenType.colon),Pt(),A.popTypeContext.call(void 0,e)}ct.tsParseTypeAnnotation=Ti;function Pt(){if($d(),j.state.inDisallowConditionalTypesContext||pe.hasPrecedingLineBreak.call(void 0)||!A.eat.call(void 0,C.TokenType._extends))return;let e=j.state.inDisallowConditionalTypesContext;j.state.inDisallowConditionalTypesContext=!0,$d(),j.state.inDisallowConditionalTypesContext=e,pe.expect.call(void 0,C.TokenType.question),Pt(),pe.expect.call(void 0,C.TokenType.colon),Pt()}ct.tsParseType=Pt;function RE(){return pe.isContextual.call(void 0,Re.ContextualKeyword._abstract)&&A.lookaheadType.call(void 0)===C.TokenType._new}function $d(){if(kE()){Td(Kr.TSFunctionType);return}if(A.match.call(void 0,C.TokenType._new)){Td(Kr.TSConstructorType);return}else if(RE()){Td(Kr.TSAbstractConstructorType);return}wE()}ct.tsParseNonConditionalType=$d;function CE(){let e=A.pushTypeContext.call(void 0,1);Pt(),pe.expect.call(void 0,C.TokenType.greaterThan),A.popTypeContext.call(void 0,e),Ze.parseMaybeUnary.call(void 0)}ct.tsParseTypeAssertion=CE;function EE(){if(A.eat.call(void 0,C.TokenType.jsxTagStart)){j.state.tokens[j.state.tokens.length-1].type=C.TokenType.typeParameterStart;let e=A.pushTypeContext.call(void 0,1);for(;!A.match.call(void 0,C.TokenType.greaterThan)&&!j.state.error;)Pt(),A.eat.call(void 0,C.TokenType.comma);QC.nextJSXTagToken.call(void 0),A.popTypeContext.call(void 0,e)}}ct.tsTryParseJSXTypeArgument=EE;function x0(){for(;!A.match.call(void 0,C.TokenType.braceL)&&!j.state.error;)AE(),A.eat.call(void 0,C.TokenType.comma)}function AE(){_i(),A.match.call(void 0,C.TokenType.lessThan)&&gs()}function IE(){fs.parseBindingIdentifier.call(void 0,!1),hs(),A.eat.call(void 0,C.TokenType._extends)&&x0(),T0()}function ME(){fs.parseBindingIdentifier.call(void 0,!1),hs(),pe.expect.call(void 0,C.TokenType.eq),Pt(),pe.semicolon.call(void 0)}function PE(){if(A.match.call(void 0,C.TokenType.string)?Ze.parseLiteral.call(void 0):Ze.parseIdentifier.call(void 0),A.eat.call(void 0,C.TokenType.eq)){let e=j.state.tokens.length-1;Ze.parseMaybeAssign.call(void 0),j.state.tokens[e].rhsEndIndex=j.state.tokens.length}}function Ad(){for(fs.parseBindingIdentifier.call(void 0,!1),pe.expect.call(void 0,C.TokenType.braceL);!A.eat.call(void 0,C.TokenType.braceR)&&!j.state.error;)PE(),A.eat.call(void 0,C.TokenType.comma)}function Id(){pe.expect.call(void 0,C.TokenType.braceL),hr.parseBlockBody.call(void 0,C.TokenType.braceR)}function Rd(){fs.parseBindingIdentifier.call(void 0,!1),A.eat.call(void 0,C.TokenType.dot)?Rd():Id()}function S0(){pe.isContextual.call(void 0,Re.ContextualKeyword._global)?Ze.parseIdentifier.call(void 0):A.match.call(void 0,C.TokenType.string)?Ze.parseExprAtom.call(void 0):pe.unexpected.call(void 0),A.match.call(void 0,C.TokenType.braceL)?Id():pe.semicolon.call(void 0)}function $0(){fs.parseImportedIdentifier.call(void 0),pe.expect.call(void 0,C.TokenType.eq),OE(),pe.semicolon.call(void 0)}ct.tsParseImportEqualsDeclaration=$0;function FE(){return pe.isContextual.call(void 0,Re.ContextualKeyword._require)&&A.lookaheadType.call(void 0)===C.TokenType.parenL}function OE(){FE()?LE():_i()}function LE(){pe.expectContextual.call(void 0,Re.ContextualKeyword._require),pe.expect.call(void 0,C.TokenType.parenL),A.match.call(void 0,C.TokenType.string)||pe.unexpected.call(void 0),Ze.parseLiteral.call(void 0),pe.expect.call(void 0,C.TokenType.parenR)}function NE(){if(pe.isLineTerminator.call(void 0))return!1;switch(j.state.type){case C.TokenType._function:{let e=A.pushTypeContext.call(void 0,1);A.next.call(void 0);let t=j.state.start;return hr.parseFunction.call(void 0,t,!0),A.popTypeContext.call(void 0,e),!0}case C.TokenType._class:{let e=A.pushTypeContext.call(void 0,1);return hr.parseClass.call(void 0,!0,!1),A.popTypeContext.call(void 0,e),!0}case C.TokenType._const:if(A.match.call(void 0,C.TokenType._const)&&pe.isLookaheadContextual.call(void 0,Re.ContextualKeyword._enum)){let e=A.pushTypeContext.call(void 0,1);return pe.expect.call(void 0,C.TokenType._const),pe.expectContextual.call(void 0,Re.ContextualKeyword._enum),j.state.tokens[j.state.tokens.length-1].type=C.TokenType._enum,Ad(),A.popTypeContext.call(void 0,e),!0}case C.TokenType._var:case C.TokenType._let:{let e=A.pushTypeContext.call(void 0,1);return hr.parseVarStatement.call(void 0,j.state.type!==C.TokenType._var),A.popTypeContext.call(void 0,e),!0}case C.TokenType.name:{let e=A.pushTypeContext.call(void 0,1),t=j.state.contextualKeyword,n=!1;return t===Re.ContextualKeyword._global?(S0(),n=!0):n=il(t,!0),A.popTypeContext.call(void 0,e),n}default:return!1}}function y0(){return il(j.state.contextualKeyword,!0)}function DE(e){switch(e){case Re.ContextualKeyword._declare:{let t=j.state.tokens.length-1;if(NE())return j.state.tokens[t].type=C.TokenType._declare,!0;break}case Re.ContextualKeyword._global:if(A.match.call(void 0,C.TokenType.braceL))return Id(),!0;break;default:return il(e,!1)}return!1}function il(e,t){switch(e){case Re.ContextualKeyword._abstract:if(ms(t)&&A.match.call(void 0,C.TokenType._class))return j.state.tokens[j.state.tokens.length-1].type=C.TokenType._abstract,hr.parseClass.call(void 0,!0,!1),!0;break;case Re.ContextualKeyword._enum:if(ms(t)&&A.match.call(void 0,C.TokenType.name))return j.state.tokens[j.state.tokens.length-1].type=C.TokenType._enum,Ad(),!0;break;case Re.ContextualKeyword._interface:if(ms(t)&&A.match.call(void 0,C.TokenType.name)){let n=A.pushTypeContext.call(void 0,t?2:1);return IE(),A.popTypeContext.call(void 0,n),!0}break;case Re.ContextualKeyword._module:if(ms(t)){if(A.match.call(void 0,C.TokenType.string)){let n=A.pushTypeContext.call(void 0,t?2:1);return S0(),A.popTypeContext.call(void 0,n),!0}else if(A.match.call(void 0,C.TokenType.name)){let n=A.pushTypeContext.call(void 0,t?2:1);return Rd(),A.popTypeContext.call(void 0,n),!0}}break;case Re.ContextualKeyword._namespace:if(ms(t)&&A.match.call(void 0,C.TokenType.name)){let n=A.pushTypeContext.call(void 0,t?2:1);return Rd(),A.popTypeContext.call(void 0,n),!0}break;case Re.ContextualKeyword._type:if(ms(t)&&A.match.call(void 0,C.TokenType.name)){let n=A.pushTypeContext.call(void 0,t?2:1);return ME(),A.popTypeContext.call(void 0,n),!0}break;default:break}return!1}function ms(e){return e?(A.next.call(void 0),!0):!pe.isLineTerminator.call(void 0)}function jE(){let e=j.state.snapshot();return sl(),hr.parseFunctionParams.call(void 0),xE(),pe.expect.call(void 0,C.TokenType.arrow),j.state.error?(j.state.restoreFromSnapshot(e),!1):(Ze.parseFunctionBody.call(void 0,!0),!0)}function Md(){j.state.type===C.TokenType.bitShiftL&&(j.state.pos-=1,A.finishToken.call(void 0,C.TokenType.lessThan)),gs()}function gs(){let e=A.pushTypeContext.call(void 0,0);for(pe.expect.call(void 0,C.TokenType.lessThan);!A.match.call(void 0,C.TokenType.greaterThan)&&!j.state.error;)Pt(),A.eat.call(void 0,C.TokenType.comma);e?(pe.expect.call(void 0,C.TokenType.greaterThan),A.popTypeContext.call(void 0,e)):(A.popTypeContext.call(void 0,e),A.rescan_gt.call(void 0),pe.expect.call(void 0,C.TokenType.greaterThan),j.state.tokens[j.state.tokens.length-1].isType=!0)}function BE(){if(A.match.call(void 0,C.TokenType.name))switch(j.state.contextualKeyword){case Re.ContextualKeyword._abstract:case Re.ContextualKeyword._declare:case Re.ContextualKeyword._enum:case Re.ContextualKeyword._interface:case Re.ContextualKeyword._module:case Re.ContextualKeyword._namespace:case Re.ContextualKeyword._type:return!0;default:break}return!1}ct.tsIsDeclarationStart=BE;function qE(e,t){if(A.match.call(void 0,C.TokenType.colon)&&ki(C.TokenType.colon),!A.match.call(void 0,C.TokenType.braceL)&&pe.isLineTerminator.call(void 0)){let n=j.state.tokens.length-1;for(;n>=0&&(j.state.tokens[n].start>=e||j.state.tokens[n].type===C.TokenType._default||j.state.tokens[n].type===C.TokenType._export);)j.state.tokens[n].isType=!0,n--;return}Ze.parseFunctionBody.call(void 0,!1,t)}ct.tsParseFunctionBodyAndFinish=qE;function UE(e,t,n){if(!pe.hasPrecedingLineBreak.call(void 0)&&A.eat.call(void 0,C.TokenType.bang)){j.state.tokens[j.state.tokens.length-1].type=C.TokenType.nonNullAssertion;return}if(A.match.call(void 0,C.TokenType.lessThan)||A.match.call(void 0,C.TokenType.bitShiftL)){let r=j.state.snapshot();if(!t&&Ze.atPossibleAsync.call(void 0)&&jE())return;if(Md(),!t&&A.eat.call(void 0,C.TokenType.parenL)?(j.state.tokens[j.state.tokens.length-1].subscriptStartIndex=e,Ze.parseCallExpressionArguments.call(void 0)):A.match.call(void 0,C.TokenType.backQuote)?Ze.parseTemplate.call(void 0):(j.state.type===C.TokenType.greaterThan||j.state.type!==C.TokenType.parenL&&j.state.type&C.TokenType.IS_EXPRESSION_START&&!pe.hasPrecedingLineBreak.call(void 0))&&pe.unexpected.call(void 0),j.state.error)j.state.restoreFromSnapshot(r);else return}else!t&&A.match.call(void 0,C.TokenType.questionDot)&&A.lookaheadType.call(void 0)===C.TokenType.lessThan&&(A.next.call(void 0),j.state.tokens[e].isOptionalChainStart=!0,j.state.tokens[j.state.tokens.length-1].subscriptStartIndex=e,gs(),pe.expect.call(void 0,C.TokenType.parenL),Ze.parseCallExpressionArguments.call(void 0));Ze.baseParseSubscript.call(void 0,e,t,n)}ct.tsParseSubscript=UE;function HE(){if(A.eat.call(void 0,C.TokenType._import))return pe.isContextual.call(void 0,Re.ContextualKeyword._type)&&A.lookaheadType.call(void 0)!==C.TokenType.eq&&pe.expectContextual.call(void 0,Re.ContextualKeyword._type),$0(),!0;if(A.eat.call(void 0,C.TokenType.eq))return Ze.parseExpression.call(void 0),pe.semicolon.call(void 0),!0;if(pe.eatContextual.call(void 0,Re.ContextualKeyword._as))return pe.expectContextual.call(void 0,Re.ContextualKeyword._namespace),Ze.parseIdentifier.call(void 0),pe.semicolon.call(void 0),!0;if(pe.isContextual.call(void 0,Re.ContextualKeyword._type)){let e=A.lookaheadType.call(void 0);(e===C.TokenType.braceL||e===C.TokenType.star)&&A.next.call(void 0)}return!1}ct.tsTryParseExport=HE;function WE(){if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ImportDeclaration;return}if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ImportDeclaration,j.state.tokens[j.state.tokens.length-2].isType=!0,j.state.tokens[j.state.tokens.length-1].isType=!0;return}if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-3].identifierRole=A.IdentifierRole.ImportAccess,j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ImportDeclaration;return}Ze.parseIdentifier.call(void 0),j.state.tokens[j.state.tokens.length-3].identifierRole=A.IdentifierRole.ImportAccess,j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ImportDeclaration,j.state.tokens[j.state.tokens.length-4].isType=!0,j.state.tokens[j.state.tokens.length-3].isType=!0,j.state.tokens[j.state.tokens.length-2].isType=!0,j.state.tokens[j.state.tokens.length-1].isType=!0}ct.tsParseImportSpecifier=WE;function zE(){if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ExportAccess;return}if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-1].identifierRole=A.IdentifierRole.ExportAccess,j.state.tokens[j.state.tokens.length-2].isType=!0,j.state.tokens[j.state.tokens.length-1].isType=!0;return}if(Ze.parseIdentifier.call(void 0),A.match.call(void 0,C.TokenType.comma)||A.match.call(void 0,C.TokenType.braceR)){j.state.tokens[j.state.tokens.length-3].identifierRole=A.IdentifierRole.ExportAccess;return}Ze.parseIdentifier.call(void 0),j.state.tokens[j.state.tokens.length-3].identifierRole=A.IdentifierRole.ExportAccess,j.state.tokens[j.state.tokens.length-4].isType=!0,j.state.tokens[j.state.tokens.length-3].isType=!0,j.state.tokens[j.state.tokens.length-2].isType=!0,j.state.tokens[j.state.tokens.length-1].isType=!0}ct.tsParseExportSpecifier=zE;function GE(){if(pe.isContextual.call(void 0,Re.ContextualKeyword._abstract)&&A.lookaheadType.call(void 0)===C.TokenType._class)return j.state.type=C.TokenType._abstract,A.next.call(void 0),hr.parseClass.call(void 0,!0,!0),!0;if(pe.isContextual.call(void 0,Re.ContextualKeyword._interface)){let e=A.pushTypeContext.call(void 0,2);return il(Re.ContextualKeyword._interface,!0),A.popTypeContext.call(void 0,e),!0}return!1}ct.tsTryParseExportDefaultExpression=GE;function KE(){if(j.state.type===C.TokenType._const){let e=A.lookaheadTypeAndKeyword.call(void 0);if(e.type===C.TokenType.name&&e.contextualKeyword===Re.ContextualKeyword._enum)return pe.expect.call(void 0,C.TokenType._const),pe.expectContextual.call(void 0,Re.ContextualKeyword._enum),j.state.tokens[j.state.tokens.length-1].type=C.TokenType._enum,Ad(),!0}return!1}ct.tsTryParseStatementContent=KE;function VE(e){let t=j.state.tokens.length;k0([Re.ContextualKeyword._abstract,Re.ContextualKeyword._readonly,Re.ContextualKeyword._declare,Re.ContextualKeyword._static,Re.ContextualKeyword._override]);let n=j.state.tokens.length;if(v0()){let o=e?t-1:t;for(let s=o;s<n;s++)j.state.tokens[s].isType=!0;return!0}return!1}ct.tsTryParseClassMemberWithIsStatic=VE;function JE(e){DE(e)||pe.semicolon.call(void 0)}ct.tsParseIdentifierStatement=JE;function XE(){let e=pe.eatContextual.call(void 0,Re.ContextualKeyword._declare);e&&(j.state.tokens[j.state.tokens.length-1].type=C.TokenType._declare);let t=!1;if(A.match.call(void 0,C.TokenType.name))if(e){let n=A.pushTypeContext.call(void 0,2);t=y0(),A.popTypeContext.call(void 0,n)}else t=y0();if(!t)if(e){let n=A.pushTypeContext.call(void 0,2);hr.parseStatement.call(void 0,!0),A.popTypeContext.call(void 0,n)}else hr.parseStatement.call(void 0,!0)}ct.tsParseExportDeclaration=XE;function QE(e){if(e&&(A.match.call(void 0,C.TokenType.lessThan)||A.match.call(void 0,C.TokenType.bitShiftL))&&Md(),pe.eatContextual.call(void 0,Re.ContextualKeyword._implements)){j.state.tokens[j.state.tokens.length-1].type=C.TokenType._implements;let t=A.pushTypeContext.call(void 0,1);x0(),A.popTypeContext.call(void 0,t)}}ct.tsAfterParseClassSuper=QE;function YE(){hs()}ct.tsStartParseObjPropValue=YE;function ZE(){hs()}ct.tsStartParseFunctionParams=ZE;function eA(){let e=A.pushTypeContext.call(void 0,0);pe.hasPrecedingLineBreak.call(void 0)||A.eat.call(void 0,C.TokenType.bang),vi(),A.popTypeContext.call(void 0,e)}ct.tsAfterParseVarHead=eA;function tA(){A.match.call(void 0,C.TokenType.colon)&&Ti()}ct.tsStartParseAsyncArrowFromCallExpression=tA;function nA(e,t){return j.isJSXEnabled?R0(e,t):C0(e,t)}ct.tsParseMaybeAssign=nA;function R0(e,t){if(!A.match.call(void 0,C.TokenType.lessThan))return Ze.baseParseMaybeAssign.call(void 0,e,t);let n=j.state.snapshot(),r=Ze.baseParseMaybeAssign.call(void 0,e,t);if(j.state.error)j.state.restoreFromSnapshot(n);else return r;return j.state.type=C.TokenType.typeParameterStart,sl(),r=Ze.baseParseMaybeAssign.call(void 0,e,t),r||pe.unexpected.call(void 0),r}ct.tsParseMaybeAssignWithJSX=R0;function C0(e,t){if(!A.match.call(void 0,C.TokenType.lessThan))return Ze.baseParseMaybeAssign.call(void 0,e,t);let n=j.state.snapshot();sl();let r=Ze.baseParseMaybeAssign.call(void 0,e,t);if(r||pe.unexpected.call(void 0),j.state.error)j.state.restoreFromSnapshot(n);else return r;return Ze.baseParseMaybeAssign.call(void 0,e,t)}ct.tsParseMaybeAssignWithoutJSX=C0;function rA(){if(A.match.call(void 0,C.TokenType.colon)){let e=j.state.snapshot();ki(C.TokenType.colon),pe.canInsertSemicolon.call(void 0)&&pe.unexpected.call(void 0),A.match.call(void 0,C.TokenType.arrow)||pe.unexpected.call(void 0),j.state.error&&j.state.restoreFromSnapshot(e)}return A.eat.call(void 0,C.TokenType.arrow)}ct.tsParseArrow=rA;function oA(){let e=A.pushTypeContext.call(void 0,0);A.eat.call(void 0,C.TokenType.question),vi(),A.popTypeContext.call(void 0,e)}ct.tsParseAssignableListItemTypes=oA;function sA(){(A.match.call(void 0,C.TokenType.lessThan)||A.match.call(void 0,C.TokenType.bitShiftL))&&Md(),hr.baseParseMaybeDecoratorArguments.call(void 0)}ct.tsParseMaybeDecoratorArguments=sA});var Pd=Ce(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var st=Yt(),pt=tt(),je=Ln(),al=Eo(),Vr=Wr(),qt=On(),E0=ls(),iA=ps();function aA(){let e=!1,t=!1;for(;;){if(je.state.pos>=je.input.length){Vr.unexpected.call(void 0,"Unterminated JSX contents");return}let n=je.input.charCodeAt(je.state.pos);if(n===qt.charCodes.lessThan||n===qt.charCodes.leftCurlyBrace){if(je.state.pos===je.state.start){if(n===qt.charCodes.lessThan){je.state.pos++,st.finishToken.call(void 0,pt.TokenType.jsxTagStart);return}st.getTokenFromCode.call(void 0,n);return}e&&!t?st.finishToken.call(void 0,pt.TokenType.jsxEmptyText):st.finishToken.call(void 0,pt.TokenType.jsxText);return}n===qt.charCodes.lineFeed?e=!0:n!==qt.charCodes.space&&n!==qt.charCodes.carriageReturn&&n!==qt.charCodes.tab&&(t=!0),je.state.pos++}}function lA(e){for(je.state.pos++;;){if(je.state.pos>=je.input.length){Vr.unexpected.call(void 0,"Unterminated string constant");return}if(je.input.charCodeAt(je.state.pos)===e){je.state.pos++;break}je.state.pos++}st.finishToken.call(void 0,pt.TokenType.string)}function cA(){let e;do{if(je.state.pos>je.input.length){Vr.unexpected.call(void 0,"Unexpectedly reached the end of input.");return}e=je.input.charCodeAt(++je.state.pos)}while(E0.IS_IDENTIFIER_CHAR[e]||e===qt.charCodes.dash);st.finishToken.call(void 0,pt.TokenType.jsxName)}function Fd(){zn()}function A0(e){if(Fd(),!st.eat.call(void 0,pt.TokenType.colon)){je.state.tokens[je.state.tokens.length-1].identifierRole=e;return}Fd()}function I0(){let e=je.state.tokens.length;A0(st.IdentifierRole.Access);let t=!1;for(;st.match.call(void 0,pt.TokenType.dot);)t=!0,zn(),Fd();if(!t){let n=je.state.tokens[e],r=je.input.charCodeAt(n.start);r>=qt.charCodes.lowercaseA&&r<=qt.charCodes.lowercaseZ&&(n.identifierRole=null)}}function uA(){switch(je.state.type){case pt.TokenType.braceL:st.next.call(void 0),al.parseExpression.call(void 0),zn();return;case pt.TokenType.jsxTagStart:P0(),zn();return;case pt.TokenType.string:zn();return;default:Vr.unexpected.call(void 0,"JSX value should be either an expression or a quoted JSX text")}}function dA(){Vr.expect.call(void 0,pt.TokenType.ellipsis),al.parseExpression.call(void 0)}function pA(e){if(st.match.call(void 0,pt.TokenType.jsxTagEnd))return!1;I0(),je.isTypeScriptEnabled&&iA.tsTryParseJSXTypeArgument.call(void 0);let t=!1;for(;!st.match.call(void 0,pt.TokenType.slash)&&!st.match.call(void 0,pt.TokenType.jsxTagEnd)&&!je.state.error;){if(st.eat.call(void 0,pt.TokenType.braceL)){t=!0,Vr.expect.call(void 0,pt.TokenType.ellipsis),al.parseMaybeAssign.call(void 0),zn();continue}t&&je.state.end-je.state.start===3&&je.input.charCodeAt(je.state.start)===qt.charCodes.lowercaseK&&je.input.charCodeAt(je.state.start+1)===qt.charCodes.lowercaseE&&je.input.charCodeAt(je.state.start+2)===qt.charCodes.lowercaseY&&(je.state.tokens[e].jsxRole=st.JSXRole.KeyAfterPropSpread),A0(st.IdentifierRole.ObjectKey),st.match.call(void 0,pt.TokenType.eq)&&(zn(),uA())}let n=st.match.call(void 0,pt.TokenType.slash);return n&&zn(),n}function mA(){st.match.call(void 0,pt.TokenType.jsxTagEnd)||I0()}function M0(){let e=je.state.tokens.length-1;je.state.tokens[e].jsxRole=st.JSXRole.NoChildren;let t=0;if(!pA(e))for(bs();;)switch(je.state.type){case pt.TokenType.jsxTagStart:if(zn(),st.match.call(void 0,pt.TokenType.slash)){zn(),mA(),je.state.tokens[e].jsxRole!==st.JSXRole.KeyAfterPropSpread&&(t===1?je.state.tokens[e].jsxRole=st.JSXRole.OneChild:t>1&&(je.state.tokens[e].jsxRole=st.JSXRole.StaticChildren));return}t++,M0(),bs();break;case pt.TokenType.jsxText:t++,bs();break;case pt.TokenType.jsxEmptyText:bs();break;case pt.TokenType.braceL:st.next.call(void 0),st.match.call(void 0,pt.TokenType.ellipsis)?(dA(),bs(),t+=2):(st.match.call(void 0,pt.TokenType.braceR)||(t++,al.parseExpression.call(void 0)),bs());break;default:Vr.unexpected.call(void 0);return}}function P0(){zn(),M0()}ll.jsxParseElement=P0;function zn(){je.state.tokens.push(new st.Token),st.skipSpace.call(void 0),je.state.start=je.state.pos;let e=je.input.charCodeAt(je.state.pos);if(E0.IS_IDENTIFIER_START[e])cA();else if(e===qt.charCodes.quotationMark||e===qt.charCodes.apostrophe)lA(e);else switch(++je.state.pos,e){case qt.charCodes.greaterThan:st.finishToken.call(void 0,pt.TokenType.jsxTagEnd);break;case qt.charCodes.lessThan:st.finishToken.call(void 0,pt.TokenType.jsxTagStart);break;case qt.charCodes.slash:st.finishToken.call(void 0,pt.TokenType.slash);break;case qt.charCodes.equalsTo:st.finishToken.call(void 0,pt.TokenType.eq);break;case qt.charCodes.leftCurlyBrace:st.finishToken.call(void 0,pt.TokenType.braceL);break;case qt.charCodes.dot:st.finishToken.call(void 0,pt.TokenType.dot);break;case qt.charCodes.colon:st.finishToken.call(void 0,pt.TokenType.colon);break;default:Vr.unexpected.call(void 0)}}ll.nextJSXTagToken=zn;function bs(){je.state.tokens.push(new st.Token),je.state.start=je.state.pos,aA()}});var O0=Ce(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var cl=Yt(),ys=tt(),F0=Ln(),fA=Eo(),hA=wi(),gA=ps();function bA(e){if(cl.match.call(void 0,ys.TokenType.question)){let t=cl.lookaheadType.call(void 0);if(t===ys.TokenType.colon||t===ys.TokenType.comma||t===ys.TokenType.parenR)return}fA.baseParseConditional.call(void 0,e)}ul.typedParseConditional=bA;function yA(){cl.eatTypeToken.call(void 0,ys.TokenType.question),cl.match.call(void 0,ys.TokenType.colon)&&(F0.isTypeScriptEnabled?gA.tsParseTypeAnnotation.call(void 0):F0.isFlowEnabled&&hA.flowParseTypeAnnotation.call(void 0))}ul.typedParseParenItem=yA});var Eo=Ce(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});var Rr=wi(),wA=Pd(),L0=O0(),Xr=ps(),ue=Yt(),Sr=nn(),N0=qa(),Z=tt(),D0=On(),kA=ls(),ee=Ln(),Jr=rl(),nr=xi(),it=Wr(),ml=class{constructor(t){this.stop=t}};Ct.StopState=ml;function Si(e=!1){if(Gn(e),ue.match.call(void 0,Z.TokenType.comma))for(;ue.eat.call(void 0,Z.TokenType.comma);)Gn(e)}Ct.parseExpression=Si;function Gn(e=!1,t=!1){return ee.isTypeScriptEnabled?Xr.tsParseMaybeAssign.call(void 0,e,t):ee.isFlowEnabled?Rr.flowParseMaybeAssign.call(void 0,e,t):j0(e,t)}Ct.parseMaybeAssign=Gn;function j0(e,t){if(ue.match.call(void 0,Z.TokenType._yield))return NA(),!1;(ue.match.call(void 0,Z.TokenType.parenL)||ue.match.call(void 0,Z.TokenType.name)||ue.match.call(void 0,Z.TokenType._yield))&&(ee.state.potentialArrowAt=ee.state.start);let n=_A(e);return t&&jd(),ee.state.type&Z.TokenType.IS_ASSIGN?(ue.next.call(void 0),Gn(e),!1):n}Ct.baseParseMaybeAssign=j0;function _A(e){return TA(e)?!0:(vA(e),!1)}function vA(e){ee.isTypeScriptEnabled||ee.isFlowEnabled?L0.typedParseConditional.call(void 0,e):B0(e)}function B0(e){ue.eat.call(void 0,Z.TokenType.question)&&(Gn(),it.expect.call(void 0,Z.TokenType.colon),Gn(e))}Ct.baseParseConditional=B0;function TA(e){let t=ee.state.tokens.length;return Ri()?!0:(dl(t,-1,e),!1)}function dl(e,t,n){if(ee.isTypeScriptEnabled&&(Z.TokenType._in&Z.TokenType.PRECEDENCE_MASK)>t&&!it.hasPrecedingLineBreak.call(void 0)&&(it.eatContextual.call(void 0,Sr.ContextualKeyword._as)||it.eatContextual.call(void 0,Sr.ContextualKeyword._satisfies))){let o=ue.pushTypeContext.call(void 0,1);Xr.tsParseType.call(void 0),ue.popTypeContext.call(void 0,o),ue.rescan_gt.call(void 0),dl(e,t,n);return}let r=ee.state.type&Z.TokenType.PRECEDENCE_MASK;if(r>0&&(!n||!ue.match.call(void 0,Z.TokenType._in))&&r>t){let o=ee.state.type;ue.next.call(void 0),o===Z.TokenType.nullishCoalescing&&(ee.state.tokens[ee.state.tokens.length-1].nullishStartIndex=e);let s=ee.state.tokens.length;Ri(),dl(s,o&Z.TokenType.IS_RIGHT_ASSOCIATIVE?r-1:r,n),o===Z.TokenType.nullishCoalescing&&(ee.state.tokens[e].numNullishCoalesceStarts++,ee.state.tokens[ee.state.tokens.length-1].numNullishCoalesceEnds++),dl(e,t,n)}}function Ri(){if(ee.isTypeScriptEnabled&&!ee.isJSXEnabled&&ue.eat.call(void 0,Z.TokenType.lessThan))return Xr.tsParseTypeAssertion.call(void 0),!1;if(it.isContextual.call(void 0,Sr.ContextualKeyword._module)&&ue.lookaheadCharCode.call(void 0)===D0.charCodes.leftCurlyBrace&&!it.hasFollowingLineBreak.call(void 0))return DA(),!1;if(ee.state.type&Z.TokenType.IS_PREFIX)return ue.next.call(void 0),Ri(),!1;if(q0())return!0;for(;ee.state.type&Z.TokenType.IS_POSTFIX&&!it.canInsertSemicolon.call(void 0);)ee.state.type===Z.TokenType.preIncDec&&(ee.state.type=Z.TokenType.postIncDec),ue.next.call(void 0);return!1}Ct.parseMaybeUnary=Ri;function q0(){let e=ee.state.tokens.length;return gl()?!0:(Nd(e),ee.state.tokens.length>e&&ee.state.tokens[e].isOptionalChainStart&&(ee.state.tokens[ee.state.tokens.length-1].isOptionalChainEnd=!0),!1)}Ct.parseExprSubscripts=q0;function Nd(e,t=!1){ee.isFlowEnabled?Rr.flowParseSubscripts.call(void 0,e,t):U0(e,t)}function U0(e,t=!1){let n=new ml(!1);do xA(e,t,n);while(!n.stop&&!ee.state.error)}Ct.baseParseSubscripts=U0;function xA(e,t,n){ee.isTypeScriptEnabled?Xr.tsParseSubscript.call(void 0,e,t,n):ee.isFlowEnabled?Rr.flowParseSubscript.call(void 0,e,t,n):H0(e,t,n)}function H0(e,t,n){if(!t&&ue.eat.call(void 0,Z.TokenType.doubleColon))Dd(),n.stop=!0,Nd(e,t);else if(ue.match.call(void 0,Z.TokenType.questionDot)){if(ee.state.tokens[e].isOptionalChainStart=!0,t&&ue.lookaheadType.call(void 0)===Z.TokenType.parenL){n.stop=!0;return}ue.next.call(void 0),ee.state.tokens[ee.state.tokens.length-1].subscriptStartIndex=e,ue.eat.call(void 0,Z.TokenType.bracketL)?(Si(),it.expect.call(void 0,Z.TokenType.bracketR)):ue.eat.call(void 0,Z.TokenType.parenL)?pl():fl()}else if(ue.eat.call(void 0,Z.TokenType.dot))ee.state.tokens[ee.state.tokens.length-1].subscriptStartIndex=e,fl();else if(ue.eat.call(void 0,Z.TokenType.bracketL))ee.state.tokens[ee.state.tokens.length-1].subscriptStartIndex=e,Si(),it.expect.call(void 0,Z.TokenType.bracketR);else if(!t&&ue.match.call(void 0,Z.TokenType.parenL))if(W0()){let r=ee.state.snapshot(),o=ee.state.tokens.length;ue.next.call(void 0),ee.state.tokens[ee.state.tokens.length-1].subscriptStartIndex=e;let s=ee.getNextContextId.call(void 0);ee.state.tokens[ee.state.tokens.length-1].contextId=s,pl(),ee.state.tokens[ee.state.tokens.length-1].contextId=s,SA()&&(ee.state.restoreFromSnapshot(r),n.stop=!0,ee.state.scopeDepth++,nr.parseFunctionParams.call(void 0),$A(o))}else{ue.next.call(void 0),ee.state.tokens[ee.state.tokens.length-1].subscriptStartIndex=e;let r=ee.getNextContextId.call(void 0);ee.state.tokens[ee.state.tokens.length-1].contextId=r,pl(),ee.state.tokens[ee.state.tokens.length-1].contextId=r}else ue.match.call(void 0,Z.TokenType.backQuote)?Bd():n.stop=!0}Ct.baseParseSubscript=H0;function W0(){return ee.state.tokens[ee.state.tokens.length-1].contextualKeyword===Sr.ContextualKeyword._async&&!it.canInsertSemicolon.call(void 0)}Ct.atPossibleAsync=W0;function pl(){let e=!0;for(;!ue.eat.call(void 0,Z.TokenType.parenR)&&!ee.state.error;){if(e)e=!1;else if(it.expect.call(void 0,Z.TokenType.comma),ue.eat.call(void 0,Z.TokenType.parenR))break;X0(!1)}}Ct.parseCallExpressionArguments=pl;function SA(){return ue.match.call(void 0,Z.TokenType.colon)||ue.match.call(void 0,Z.TokenType.arrow)}function $A(e){ee.isTypeScriptEnabled?Xr.tsStartParseAsyncArrowFromCallExpression.call(void 0):ee.isFlowEnabled&&Rr.flowStartParseAsyncArrowFromCallExpression.call(void 0),it.expect.call(void 0,Z.TokenType.arrow),$i(e)}function Dd(){let e=ee.state.tokens.length;gl(),Nd(e,!0)}function gl(){if(ue.eat.call(void 0,Z.TokenType.modulo))return $r(),!1;if(ue.match.call(void 0,Z.TokenType.jsxText)||ue.match.call(void 0,Z.TokenType.jsxEmptyText))return z0(),!1;if(ue.match.call(void 0,Z.TokenType.lessThan)&&ee.isJSXEnabled)return ee.state.type=Z.TokenType.jsxTagStart,wA.jsxParseElement.call(void 0),ue.next.call(void 0),!1;let e=ee.state.potentialArrowAt===ee.state.start;switch(ee.state.type){case Z.TokenType.slash:case Z.TokenType.assign:ue.retokenizeSlashAsRegex.call(void 0);case Z.TokenType._super:case Z.TokenType._this:case Z.TokenType.regexp:case Z.TokenType.num:case Z.TokenType.bigint:case Z.TokenType.decimal:case Z.TokenType.string:case Z.TokenType._null:case Z.TokenType._true:case Z.TokenType._false:return ue.next.call(void 0),!1;case Z.TokenType._import:return ue.next.call(void 0),ue.match.call(void 0,Z.TokenType.dot)&&(ee.state.tokens[ee.state.tokens.length-1].type=Z.TokenType.name,ue.next.call(void 0),$r()),!1;case Z.TokenType.name:{let t=ee.state.tokens.length,n=ee.state.start,r=ee.state.contextualKeyword;return $r(),r===Sr.ContextualKeyword._await?(LA(),!1):r===Sr.ContextualKeyword._async&&ue.match.call(void 0,Z.TokenType._function)&&!it.canInsertSemicolon.call(void 0)?(ue.next.call(void 0),nr.parseFunction.call(void 0,n,!1),!1):e&&r===Sr.ContextualKeyword._async&&!it.canInsertSemicolon.call(void 0)&&ue.match.call(void 0,Z.TokenType.name)?(ee.state.scopeDepth++,Jr.parseBindingIdentifier.call(void 0,!1),it.expect.call(void 0,Z.TokenType.arrow),$i(t),!0):ue.match.call(void 0,Z.TokenType._do)&&!it.canInsertSemicolon.call(void 0)?(ue.next.call(void 0),nr.parseBlock.call(void 0),!1):e&&!it.canInsertSemicolon.call(void 0)&&ue.match.call(void 0,Z.TokenType.arrow)?(ee.state.scopeDepth++,Jr.markPriorBindingIdentifier.call(void 0,!1),it.expect.call(void 0,Z.TokenType.arrow),$i(t),!0):(ee.state.tokens[ee.state.tokens.length-1].identifierRole=ue.IdentifierRole.Access,!1)}case Z.TokenType._do:return ue.next.call(void 0),nr.parseBlock.call(void 0),!1;case Z.TokenType.parenL:return G0(e);case Z.TokenType.bracketL:return ue.next.call(void 0),J0(Z.TokenType.bracketR,!0),!1;case Z.TokenType.braceL:return K0(!1,!1),!1;case Z.TokenType._function:return RA(),!1;case Z.TokenType.at:nr.parseDecorators.call(void 0);case Z.TokenType._class:return nr.parseClass.call(void 0,!1),!1;case Z.TokenType._new:return AA(),!1;case Z.TokenType.backQuote:return Bd(),!1;case Z.TokenType.doubleColon:return ue.next.call(void 0),Dd(),!1;case Z.TokenType.hash:{let t=ue.lookaheadCharCode.call(void 0);return kA.IS_IDENTIFIER_START[t]||t===D0.charCodes.backslash?fl():ue.next.call(void 0),!1}default:return it.unexpected.call(void 0),!1}}Ct.parseExprAtom=gl;function fl(){ue.eat.call(void 0,Z.TokenType.hash),$r()}function RA(){let e=ee.state.start;$r(),ue.eat.call(void 0,Z.TokenType.dot)&&$r(),nr.parseFunction.call(void 0,e,!1)}function z0(){ue.next.call(void 0)}Ct.parseLiteral=z0;function CA(){it.expect.call(void 0,Z.TokenType.parenL),Si(),it.expect.call(void 0,Z.TokenType.parenR)}Ct.parseParenExpression=CA;function G0(e){let t=ee.state.snapshot(),n=ee.state.tokens.length;it.expect.call(void 0,Z.TokenType.parenL);let r=!0;for(;!ue.match.call(void 0,Z.TokenType.parenR)&&!ee.state.error;){if(r)r=!1;else if(it.expect.call(void 0,Z.TokenType.comma),ue.match.call(void 0,Z.TokenType.parenR))break;if(ue.match.call(void 0,Z.TokenType.ellipsis)){Jr.parseRest.call(void 0,!1),jd();break}else Gn(!1,!0)}return it.expect.call(void 0,Z.TokenType.parenR),e&&EA()&&Od()?(ee.state.restoreFromSnapshot(t),ee.state.scopeDepth++,nr.parseFunctionParams.call(void 0),Od(),$i(n),ee.state.error?(ee.state.restoreFromSnapshot(t),G0(!1),!1):!0):!1}function EA(){return ue.match.call(void 0,Z.TokenType.colon)||!it.canInsertSemicolon.call(void 0)}function Od(){return ee.isTypeScriptEnabled?Xr.tsParseArrow.call(void 0):ee.isFlowEnabled?Rr.flowParseArrow.call(void 0):ue.eat.call(void 0,Z.TokenType.arrow)}Ct.parseArrow=Od;function jd(){(ee.isTypeScriptEnabled||ee.isFlowEnabled)&&L0.typedParseParenItem.call(void 0)}function AA(){if(it.expect.call(void 0,Z.TokenType._new),ue.eat.call(void 0,Z.TokenType.dot)){$r();return}IA(),ee.isFlowEnabled&&Rr.flowStartParseNewArguments.call(void 0),ue.eat.call(void 0,Z.TokenType.parenL)&&J0(Z.TokenType.parenR)}function IA(){Dd(),ue.eat.call(void 0,Z.TokenType.questionDot)}function Bd(){for(ue.nextTemplateToken.call(void 0),ue.nextTemplateToken.call(void 0);!ue.match.call(void 0,Z.TokenType.backQuote)&&!ee.state.error;)it.expect.call(void 0,Z.TokenType.dollarBraceL),Si(),ue.nextTemplateToken.call(void 0),ue.nextTemplateToken.call(void 0);ue.next.call(void 0)}Ct.parseTemplate=Bd;function K0(e,t){let n=ee.getNextContextId.call(void 0),r=!0;for(ue.next.call(void 0),ee.state.tokens[ee.state.tokens.length-1].contextId=n;!ue.eat.call(void 0,Z.TokenType.braceR)&&!ee.state.error;){if(r)r=!1;else if(it.expect.call(void 0,Z.TokenType.comma),ue.eat.call(void 0,Z.TokenType.braceR))break;let o=!1;if(ue.match.call(void 0,Z.TokenType.ellipsis)){let s=ee.state.tokens.length;if(Jr.parseSpread.call(void 0),e&&(ee.state.tokens.length===s+2&&Jr.markPriorBindingIdentifier.call(void 0,t),ue.eat.call(void 0,Z.TokenType.braceR)))break;continue}e||(o=ue.eat.call(void 0,Z.TokenType.star)),!e&&it.isContextual.call(void 0,Sr.ContextualKeyword._async)?(o&&it.unexpected.call(void 0),$r(),ue.match.call(void 0,Z.TokenType.colon)||ue.match.call(void 0,Z.TokenType.parenL)||ue.match.call(void 0,Z.TokenType.braceR)||ue.match.call(void 0,Z.TokenType.eq)||ue.match.call(void 0,Z.TokenType.comma)||(ue.match.call(void 0,Z.TokenType.star)&&(ue.next.call(void 0),o=!0),hl(n))):hl(n),OA(e,t,n)}ee.state.tokens[ee.state.tokens.length-1].contextId=n}Ct.parseObj=K0;function MA(e){return!e&&(ue.match.call(void 0,Z.TokenType.string)||ue.match.call(void 0,Z.TokenType.num)||ue.match.call(void 0,Z.TokenType.bracketL)||ue.match.call(void 0,Z.TokenType.name)||!!(ee.state.type&Z.TokenType.IS_KEYWORD))}function PA(e,t){let n=ee.state.start;return ue.match.call(void 0,Z.TokenType.parenL)?(e&&it.unexpected.call(void 0),Ld(n,!1),!0):MA(e)?(hl(t),Ld(n,!1),!0):!1}function FA(e,t){if(ue.eat.call(void 0,Z.TokenType.colon)){e?Jr.parseMaybeDefault.call(void 0,t):Gn(!1);return}let n;e?ee.state.scopeDepth===0?n=ue.IdentifierRole.ObjectShorthandTopLevelDeclaration:t?n=ue.IdentifierRole.ObjectShorthandBlockScopedDeclaration:n=ue.IdentifierRole.ObjectShorthandFunctionScopedDeclaration:n=ue.IdentifierRole.ObjectShorthand,ee.state.tokens[ee.state.tokens.length-1].identifierRole=n,Jr.parseMaybeDefault.call(void 0,t,!0)}function OA(e,t,n){ee.isTypeScriptEnabled?Xr.tsStartParseObjPropValue.call(void 0):ee.isFlowEnabled&&Rr.flowStartParseObjPropValue.call(void 0),PA(e,n)||FA(e,t)}function hl(e){ee.isFlowEnabled&&Rr.flowParseVariance.call(void 0),ue.eat.call(void 0,Z.TokenType.bracketL)?(ee.state.tokens[ee.state.tokens.length-1].contextId=e,Gn(),it.expect.call(void 0,Z.TokenType.bracketR),ee.state.tokens[ee.state.tokens.length-1].contextId=e):(ue.match.call(void 0,Z.TokenType.num)||ue.match.call(void 0,Z.TokenType.string)||ue.match.call(void 0,Z.TokenType.bigint)||ue.match.call(void 0,Z.TokenType.decimal)?gl():fl(),ee.state.tokens[ee.state.tokens.length-1].identifierRole=ue.IdentifierRole.ObjectKey,ee.state.tokens[ee.state.tokens.length-1].contextId=e)}Ct.parsePropertyName=hl;function Ld(e,t){let n=ee.getNextContextId.call(void 0);ee.state.scopeDepth++;let r=ee.state.tokens.length,o=t;nr.parseFunctionParams.call(void 0,o,n),V0(e,n);let s=ee.state.tokens.length;ee.state.scopes.push(new N0.Scope(r,s,!0)),ee.state.scopeDepth--}Ct.parseMethod=Ld;function $i(e){qd(!0);let t=ee.state.tokens.length;ee.state.scopes.push(new N0.Scope(e,t,!0)),ee.state.scopeDepth--}Ct.parseArrowExpression=$i;function V0(e,t=0){ee.isTypeScriptEnabled?Xr.tsParseFunctionBodyAndFinish.call(void 0,e,t):ee.isFlowEnabled?Rr.flowParseFunctionBodyAndFinish.call(void 0,t):qd(!1,t)}Ct.parseFunctionBodyAndFinish=V0;function qd(e,t=0){e&&!ue.match.call(void 0,Z.TokenType.braceL)?Gn():nr.parseBlock.call(void 0,!0,t)}Ct.parseFunctionBody=qd;function J0(e,t=!1){let n=!0;for(;!ue.eat.call(void 0,e)&&!ee.state.error;){if(n)n=!1;else if(it.expect.call(void 0,Z.TokenType.comma),ue.eat.call(void 0,e))break;X0(t)}}function X0(e){e&&ue.match.call(void 0,Z.TokenType.comma)||(ue.match.call(void 0,Z.TokenType.ellipsis)?(Jr.parseSpread.call(void 0),jd()):ue.match.call(void 0,Z.TokenType.question)?ue.next.call(void 0):Gn(!1,!0))}function $r(){ue.next.call(void 0),ee.state.tokens[ee.state.tokens.length-1].type=Z.TokenType.name}Ct.parseIdentifier=$r;function LA(){Ri()}function NA(){ue.next.call(void 0),!ue.match.call(void 0,Z.TokenType.semi)&&!it.canInsertSemicolon.call(void 0)&&(ue.eat.call(void 0,Z.TokenType.star),Gn())}function DA(){it.expectContextual.call(void 0,Sr.ContextualKeyword._module),it.expect.call(void 0,Z.TokenType.braceL),nr.parseBlockBody.call(void 0,Z.TokenType.braceR)}});var wi=Ce($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});var N=Yt(),Ue=nn(),I=tt(),Fe=Ln(),wt=Eo(),Qr=xi(),he=Wr();function jA(e){return(e.type===I.TokenType.name||!!(e.type&I.TokenType.IS_KEYWORD))&&e.contextualKeyword!==Ue.ContextualKeyword._from}function gr(e){let t=N.pushTypeContext.call(void 0,0);he.expect.call(void 0,e||I.TokenType.colon),$n(),N.popTypeContext.call(void 0,t)}function Q0(){he.expect.call(void 0,I.TokenType.modulo),he.expectContextual.call(void 0,Ue.ContextualKeyword._checks),N.eat.call(void 0,I.TokenType.parenL)&&(wt.parseExpression.call(void 0),he.expect.call(void 0,I.TokenType.parenR))}function Wd(){let e=N.pushTypeContext.call(void 0,0);he.expect.call(void 0,I.TokenType.colon),N.match.call(void 0,I.TokenType.modulo)?Q0():($n(),N.match.call(void 0,I.TokenType.modulo)&&Q0()),N.popTypeContext.call(void 0,e)}function BA(){N.next.call(void 0),zd(!0)}function qA(){N.next.call(void 0),wt.parseIdentifier.call(void 0),N.match.call(void 0,I.TokenType.lessThan)&&br(),he.expect.call(void 0,I.TokenType.parenL),Hd(),he.expect.call(void 0,I.TokenType.parenR),Wd(),he.semicolon.call(void 0)}function Ud(){N.match.call(void 0,I.TokenType._class)?BA():N.match.call(void 0,I.TokenType._function)?qA():N.match.call(void 0,I.TokenType._var)?UA():he.eatContextual.call(void 0,Ue.ContextualKeyword._module)?N.eat.call(void 0,I.TokenType.dot)?zA():HA():he.isContextual.call(void 0,Ue.ContextualKeyword._type)?GA():he.isContextual.call(void 0,Ue.ContextualKeyword._opaque)?KA():he.isContextual.call(void 0,Ue.ContextualKeyword._interface)?VA():N.match.call(void 0,I.TokenType._export)?WA():he.unexpected.call(void 0)}function UA(){N.next.call(void 0),rw(),he.semicolon.call(void 0)}function HA(){for(N.match.call(void 0,I.TokenType.string)?wt.parseExprAtom.call(void 0):wt.parseIdentifier.call(void 0),he.expect.call(void 0,I.TokenType.braceL);!N.match.call(void 0,I.TokenType.braceR)&&!Fe.state.error;)N.match.call(void 0,I.TokenType._import)?(N.next.call(void 0),Qr.parseImport.call(void 0)):he.unexpected.call(void 0);he.expect.call(void 0,I.TokenType.braceR)}function WA(){he.expect.call(void 0,I.TokenType._export),N.eat.call(void 0,I.TokenType._default)?N.match.call(void 0,I.TokenType._function)||N.match.call(void 0,I.TokenType._class)?Ud():($n(),he.semicolon.call(void 0)):N.match.call(void 0,I.TokenType._var)||N.match.call(void 0,I.TokenType._function)||N.match.call(void 0,I.TokenType._class)||he.isContextual.call(void 0,Ue.ContextualKeyword._opaque)?Ud():N.match.call(void 0,I.TokenType.star)||N.match.call(void 0,I.TokenType.braceL)||he.isContextual.call(void 0,Ue.ContextualKeyword._interface)||he.isContextual.call(void 0,Ue.ContextualKeyword._type)||he.isContextual.call(void 0,Ue.ContextualKeyword._opaque)?Qr.parseExport.call(void 0):he.unexpected.call(void 0)}function zA(){he.expectContextual.call(void 0,Ue.ContextualKeyword._exports),ws(),he.semicolon.call(void 0)}function GA(){N.next.call(void 0),Kd()}function KA(){N.next.call(void 0),Vd(!0)}function VA(){N.next.call(void 0),zd()}function zd(e=!1){if(kl(),N.match.call(void 0,I.TokenType.lessThan)&&br(),N.eat.call(void 0,I.TokenType._extends))do bl();while(!e&&N.eat.call(void 0,I.TokenType.comma));if(he.isContextual.call(void 0,Ue.ContextualKeyword._mixins)){N.next.call(void 0);do bl();while(N.eat.call(void 0,I.TokenType.comma))}if(he.isContextual.call(void 0,Ue.ContextualKeyword._implements)){N.next.call(void 0);do bl();while(N.eat.call(void 0,I.TokenType.comma))}yl(e,!1,e)}function bl(){ew(!1),N.match.call(void 0,I.TokenType.lessThan)&&Ao()}function Gd(){zd()}function kl(){wt.parseIdentifier.call(void 0)}function Kd(){kl(),N.match.call(void 0,I.TokenType.lessThan)&&br(),gr(I.TokenType.eq),he.semicolon.call(void 0)}function Vd(e){he.expectContextual.call(void 0,Ue.ContextualKeyword._type),kl(),N.match.call(void 0,I.TokenType.lessThan)&&br(),N.match.call(void 0,I.TokenType.colon)&&gr(I.TokenType.colon),e||gr(I.TokenType.eq),he.semicolon.call(void 0)}function JA(){Qd(),rw(),N.eat.call(void 0,I.TokenType.eq)&&$n()}function br(){let e=N.pushTypeContext.call(void 0,0);N.match.call(void 0,I.TokenType.lessThan)||N.match.call(void 0,I.TokenType.typeParameterStart)?N.next.call(void 0):he.unexpected.call(void 0);do JA(),N.match.call(void 0,I.TokenType.greaterThan)||he.expect.call(void 0,I.TokenType.comma);while(!N.match.call(void 0,I.TokenType.greaterThan)&&!Fe.state.error);he.expect.call(void 0,I.TokenType.greaterThan),N.popTypeContext.call(void 0,e)}$t.flowParseTypeParameterDeclaration=br;function Ao(){let e=N.pushTypeContext.call(void 0,0);for(he.expect.call(void 0,I.TokenType.lessThan);!N.match.call(void 0,I.TokenType.greaterThan)&&!Fe.state.error;)$n(),N.match.call(void 0,I.TokenType.greaterThan)||he.expect.call(void 0,I.TokenType.comma);he.expect.call(void 0,I.TokenType.greaterThan),N.popTypeContext.call(void 0,e)}function XA(){if(he.expectContextual.call(void 0,Ue.ContextualKeyword._interface),N.eat.call(void 0,I.TokenType._extends))do bl();while(N.eat.call(void 0,I.TokenType.comma));yl(!1,!1,!1)}function Jd(){N.match.call(void 0,I.TokenType.num)||N.match.call(void 0,I.TokenType.string)?wt.parseExprAtom.call(void 0):wt.parseIdentifier.call(void 0)}function QA(){N.lookaheadType.call(void 0)===I.TokenType.colon?(Jd(),gr()):$n(),he.expect.call(void 0,I.TokenType.bracketR),gr()}function YA(){Jd(),he.expect.call(void 0,I.TokenType.bracketR),he.expect.call(void 0,I.TokenType.bracketR),N.match.call(void 0,I.TokenType.lessThan)||N.match.call(void 0,I.TokenType.parenL)?Xd():(N.eat.call(void 0,I.TokenType.question),gr())}function Xd(){for(N.match.call(void 0,I.TokenType.lessThan)&&br(),he.expect.call(void 0,I.TokenType.parenL);!N.match.call(void 0,I.TokenType.parenR)&&!N.match.call(void 0,I.TokenType.ellipsis)&&!Fe.state.error;)wl(),N.match.call(void 0,I.TokenType.parenR)||he.expect.call(void 0,I.TokenType.comma);N.eat.call(void 0,I.TokenType.ellipsis)&&wl(),he.expect.call(void 0,I.TokenType.parenR),gr()}function ZA(){Xd()}function yl(e,t,n){let r;for(t&&N.match.call(void 0,I.TokenType.braceBarL)?(he.expect.call(void 0,I.TokenType.braceBarL),r=I.TokenType.braceBarR):(he.expect.call(void 0,I.TokenType.braceL),r=I.TokenType.braceR);!N.match.call(void 0,r)&&!Fe.state.error;){if(n&&he.isContextual.call(void 0,Ue.ContextualKeyword._proto)){let o=N.lookaheadType.call(void 0);o!==I.TokenType.colon&&o!==I.TokenType.question&&(N.next.call(void 0),e=!1)}if(e&&he.isContextual.call(void 0,Ue.ContextualKeyword._static)){let o=N.lookaheadType.call(void 0);o!==I.TokenType.colon&&o!==I.TokenType.question&&N.next.call(void 0)}if(Qd(),N.eat.call(void 0,I.TokenType.bracketL))N.eat.call(void 0,I.TokenType.bracketL)?YA():QA();else if(N.match.call(void 0,I.TokenType.parenL)||N.match.call(void 0,I.TokenType.lessThan))ZA();else{if(he.isContextual.call(void 0,Ue.ContextualKeyword._get)||he.isContextual.call(void 0,Ue.ContextualKeyword._set)){let o=N.lookaheadType.call(void 0);(o===I.TokenType.name||o===I.TokenType.string||o===I.TokenType.num)&&N.next.call(void 0)}eI()}tI()}he.expect.call(void 0,r)}function eI(){if(N.match.call(void 0,I.TokenType.ellipsis)){if(he.expect.call(void 0,I.TokenType.ellipsis),N.eat.call(void 0,I.TokenType.comma)||N.eat.call(void 0,I.TokenType.semi),N.match.call(void 0,I.TokenType.braceR))return;$n()}else Jd(),N.match.call(void 0,I.TokenType.lessThan)||N.match.call(void 0,I.TokenType.parenL)?Xd():(N.eat.call(void 0,I.TokenType.question),gr())}function tI(){!N.eat.call(void 0,I.TokenType.semi)&&!N.eat.call(void 0,I.TokenType.comma)&&!N.match.call(void 0,I.TokenType.braceR)&&!N.match.call(void 0,I.TokenType.braceBarR)&&he.unexpected.call(void 0)}function ew(e){for(e||wt.parseIdentifier.call(void 0);N.eat.call(void 0,I.TokenType.dot);)wt.parseIdentifier.call(void 0)}function nI(){ew(!0),N.match.call(void 0,I.TokenType.lessThan)&&Ao()}function rI(){he.expect.call(void 0,I.TokenType._typeof),tw()}function oI(){for(he.expect.call(void 0,I.TokenType.bracketL);Fe.state.pos<Fe.input.length&&!N.match.call(void 0,I.TokenType.bracketR)&&($n(),!N.match.call(void 0,I.TokenType.bracketR));)he.expect.call(void 0,I.TokenType.comma);he.expect.call(void 0,I.TokenType.bracketR)}function wl(){let e=N.lookaheadType.call(void 0);e===I.TokenType.colon||e===I.TokenType.question?(wt.parseIdentifier.call(void 0),N.eat.call(void 0,I.TokenType.question),gr()):$n()}function Hd(){for(;!N.match.call(void 0,I.TokenType.parenR)&&!N.match.call(void 0,I.TokenType.ellipsis)&&!Fe.state.error;)wl(),N.match.call(void 0,I.TokenType.parenR)||he.expect.call(void 0,I.TokenType.comma);N.eat.call(void 0,I.TokenType.ellipsis)&&wl()}function tw(){let e=!1,t=Fe.state.noAnonFunctionType;switch(Fe.state.type){case I.TokenType.name:{if(he.isContextual.call(void 0,Ue.ContextualKeyword._interface)){XA();return}wt.parseIdentifier.call(void 0),nI();return}case I.TokenType.braceL:yl(!1,!1,!1);return;case I.TokenType.braceBarL:yl(!1,!0,!1);return;case I.TokenType.bracketL:oI();return;case I.TokenType.lessThan:br(),he.expect.call(void 0,I.TokenType.parenL),Hd(),he.expect.call(void 0,I.TokenType.parenR),he.expect.call(void 0,I.TokenType.arrow),$n();return;case I.TokenType.parenL:if(N.next.call(void 0),!N.match.call(void 0,I.TokenType.parenR)&&!N.match.call(void 0,I.TokenType.ellipsis))if(N.match.call(void 0,I.TokenType.name)){let n=N.lookaheadType.call(void 0);e=n!==I.TokenType.question&&n!==I.TokenType.colon}else e=!0;if(e)if(Fe.state.noAnonFunctionType=!1,$n(),Fe.state.noAnonFunctionType=t,Fe.state.noAnonFunctionType||!(N.match.call(void 0,I.TokenType.comma)||N.match.call(void 0,I.TokenType.parenR)&&N.lookaheadType.call(void 0)===I.TokenType.arrow)){he.expect.call(void 0,I.TokenType.parenR);return}else N.eat.call(void 0,I.TokenType.comma);Hd(),he.expect.call(void 0,I.TokenType.parenR),he.expect.call(void 0,I.TokenType.arrow),$n();return;case I.TokenType.minus:N.next.call(void 0),wt.parseLiteral.call(void 0);return;case I.TokenType.string:case I.TokenType.num:case I.TokenType._true:case I.TokenType._false:case I.TokenType._null:case I.TokenType._this:case I.TokenType._void:case I.TokenType.star:N.next.call(void 0);return;default:if(Fe.state.type===I.TokenType._typeof){rI();return}else if(Fe.state.type&I.TokenType.IS_KEYWORD){N.next.call(void 0),Fe.state.tokens[Fe.state.tokens.length-1].type=I.TokenType.name;return}}he.unexpected.call(void 0)}function sI(){for(tw();!he.canInsertSemicolon.call(void 0)&&(N.match.call(void 0,I.TokenType.bracketL)||N.match.call(void 0,I.TokenType.questionDot));)N.eat.call(void 0,I.TokenType.questionDot),he.expect.call(void 0,I.TokenType.bracketL),N.eat.call(void 0,I.TokenType.bracketR)||($n(),he.expect.call(void 0,I.TokenType.bracketR))}function nw(){N.eat.call(void 0,I.TokenType.question)?nw():sI()}function Y0(){nw(),!Fe.state.noAnonFunctionType&&N.eat.call(void 0,I.TokenType.arrow)&&$n()}function Z0(){for(N.eat.call(void 0,I.TokenType.bitwiseAND),Y0();N.eat.call(void 0,I.TokenType.bitwiseAND);)Y0()}function iI(){for(N.eat.call(void 0,I.TokenType.bitwiseOR),Z0();N.eat.call(void 0,I.TokenType.bitwiseOR);)Z0()}function $n(){iI()}function ws(){gr()}$t.flowParseTypeAnnotation=ws;function rw(){wt.parseIdentifier.call(void 0),N.match.call(void 0,I.TokenType.colon)&&ws()}function Qd(){(N.match.call(void 0,I.TokenType.plus)||N.match.call(void 0,I.TokenType.minus))&&(N.next.call(void 0),Fe.state.tokens[Fe.state.tokens.length-1].isType=!0)}$t.flowParseVariance=Qd;function aI(e){N.match.call(void 0,I.TokenType.colon)&&Wd(),wt.parseFunctionBody.call(void 0,!1,e)}$t.flowParseFunctionBodyAndFinish=aI;function lI(e,t,n){if(N.match.call(void 0,I.TokenType.questionDot)&&N.lookaheadType.call(void 0)===I.TokenType.lessThan){if(t){n.stop=!0;return}N.next.call(void 0),Ao(),he.expect.call(void 0,I.TokenType.parenL),wt.parseCallExpressionArguments.call(void 0);return}else if(!t&&N.match.call(void 0,I.TokenType.lessThan)){let r=Fe.state.snapshot();if(Ao(),he.expect.call(void 0,I.TokenType.parenL),wt.parseCallExpressionArguments.call(void 0),Fe.state.error)Fe.state.restoreFromSnapshot(r);else return}wt.baseParseSubscript.call(void 0,e,t,n)}$t.flowParseSubscript=lI;function cI(){if(N.match.call(void 0,I.TokenType.lessThan)){let e=Fe.state.snapshot();Ao(),Fe.state.error&&Fe.state.restoreFromSnapshot(e)}}$t.flowStartParseNewArguments=cI;function uI(){if(N.match.call(void 0,I.TokenType.name)&&Fe.state.contextualKeyword===Ue.ContextualKeyword._interface){let e=N.pushTypeContext.call(void 0,0);return N.next.call(void 0),Gd(),N.popTypeContext.call(void 0,e),!0}else if(he.isContextual.call(void 0,Ue.ContextualKeyword._enum))return ow(),!0;return!1}$t.flowTryParseStatement=uI;function dI(){return he.isContextual.call(void 0,Ue.ContextualKeyword._enum)?(ow(),!0):!1}$t.flowTryParseExportDefaultExpression=dI;function pI(e){if(e===Ue.ContextualKeyword._declare){if(N.match.call(void 0,I.TokenType._class)||N.match.call(void 0,I.TokenType.name)||N.match.call(void 0,I.TokenType._function)||N.match.call(void 0,I.TokenType._var)||N.match.call(void 0,I.TokenType._export)){let t=N.pushTypeContext.call(void 0,1);Ud(),N.popTypeContext.call(void 0,t)}}else if(N.match.call(void 0,I.TokenType.name)){if(e===Ue.ContextualKeyword._interface){let t=N.pushTypeContext.call(void 0,1);Gd(),N.popTypeContext.call(void 0,t)}else if(e===Ue.ContextualKeyword._type){let t=N.pushTypeContext.call(void 0,1);Kd(),N.popTypeContext.call(void 0,t)}else if(e===Ue.ContextualKeyword._opaque){let t=N.pushTypeContext.call(void 0,1);Vd(!1),N.popTypeContext.call(void 0,t)}}he.semicolon.call(void 0)}$t.flowParseIdentifierStatement=pI;function mI(){return he.isContextual.call(void 0,Ue.ContextualKeyword._type)||he.isContextual.call(void 0,Ue.ContextualKeyword._interface)||he.isContextual.call(void 0,Ue.ContextualKeyword._opaque)||he.isContextual.call(void 0,Ue.ContextualKeyword._enum)}$t.flowShouldParseExportDeclaration=mI;function fI(){return N.match.call(void 0,I.TokenType.name)&&(Fe.state.contextualKeyword===Ue.ContextualKeyword._type||Fe.state.contextualKeyword===Ue.ContextualKeyword._interface||Fe.state.contextualKeyword===Ue.ContextualKeyword._opaque||Fe.state.contextualKeyword===Ue.ContextualKeyword._enum)}$t.flowShouldDisallowExportDefaultSpecifier=fI;function hI(){if(he.isContextual.call(void 0,Ue.ContextualKeyword._type)){let e=N.pushTypeContext.call(void 0,1);N.next.call(void 0),N.match.call(void 0,I.TokenType.braceL)?(Qr.parseExportSpecifiers.call(void 0),Qr.parseExportFrom.call(void 0)):Kd(),N.popTypeContext.call(void 0,e)}else if(he.isContextual.call(void 0,Ue.ContextualKeyword._opaque)){let e=N.pushTypeContext.call(void 0,1);N.next.call(void 0),Vd(!1),N.popTypeContext.call(void 0,e)}else if(he.isContextual.call(void 0,Ue.ContextualKeyword._interface)){let e=N.pushTypeContext.call(void 0,1);N.next.call(void 0),Gd(),N.popTypeContext.call(void 0,e)}else Qr.parseStatement.call(void 0,!0)}$t.flowParseExportDeclaration=hI;function gI(){return N.match.call(void 0,I.TokenType.star)||he.isContextual.call(void 0,Ue.ContextualKeyword._type)&&N.lookaheadType.call(void 0)===I.TokenType.star}$t.flowShouldParseExportStar=gI;function bI(){if(he.eatContextual.call(void 0,Ue.ContextualKeyword._type)){let e=N.pushTypeContext.call(void 0,2);Qr.baseParseExportStar.call(void 0),N.popTypeContext.call(void 0,e)}else Qr.baseParseExportStar.call(void 0)}$t.flowParseExportStar=bI;function yI(e){if(e&&N.match.call(void 0,I.TokenType.lessThan)&&Ao(),he.isContextual.call(void 0,Ue.ContextualKeyword._implements)){let t=N.pushTypeContext.call(void 0,0);N.next.call(void 0),Fe.state.tokens[Fe.state.tokens.length-1].type=I.TokenType._implements;do kl(),N.match.call(void 0,I.TokenType.lessThan)&&Ao();while(N.eat.call(void 0,I.TokenType.comma));N.popTypeContext.call(void 0,t)}}$t.flowAfterParseClassSuper=yI;function wI(){N.match.call(void 0,I.TokenType.lessThan)&&(br(),N.match.call(void 0,I.TokenType.parenL)||he.unexpected.call(void 0))}$t.flowStartParseObjPropValue=wI;function kI(){let e=N.pushTypeContext.call(void 0,0);N.eat.call(void 0,I.TokenType.question),N.match.call(void 0,I.TokenType.colon)&&ws(),N.popTypeContext.call(void 0,e)}$t.flowParseAssignableListItemTypes=kI;function _I(){if(N.match.call(void 0,I.TokenType._typeof)||he.isContextual.call(void 0,Ue.ContextualKeyword._type)){let e=N.lookaheadTypeAndKeyword.call(void 0);(jA(e)||e.type===I.TokenType.braceL||e.type===I.TokenType.star)&&N.next.call(void 0)}}$t.flowStartParseImportSpecifiers=_I;function vI(){let e=Fe.state.contextualKeyword===Ue.ContextualKeyword._type||Fe.state.type===I.TokenType._typeof;e?N.next.call(void 0):wt.parseIdentifier.call(void 0),he.isContextual.call(void 0,Ue.ContextualKeyword._as)&&!he.isLookaheadContextual.call(void 0,Ue.ContextualKeyword._as)?(wt.parseIdentifier.call(void 0),e&&!N.match.call(void 0,I.TokenType.name)&&!(Fe.state.type&I.TokenType.IS_KEYWORD)||wt.parseIdentifier.call(void 0)):(e&&(N.match.call(void 0,I.TokenType.name)||Fe.state.type&I.TokenType.IS_KEYWORD)&&wt.parseIdentifier.call(void 0),he.eatContextual.call(void 0,Ue.ContextualKeyword._as)&&wt.parseIdentifier.call(void 0))}$t.flowParseImportSpecifier=vI;function TI(){if(N.match.call(void 0,I.TokenType.lessThan)){let e=N.pushTypeContext.call(void 0,0);br(),N.popTypeContext.call(void 0,e)}}$t.flowStartParseFunctionParams=TI;function xI(){N.match.call(void 0,I.TokenType.colon)&&ws()}$t.flowAfterParseVarHead=xI;function SI(){if(N.match.call(void 0,I.TokenType.colon)){let e=Fe.state.noAnonFunctionType;Fe.state.noAnonFunctionType=!0,ws(),Fe.state.noAnonFunctionType=e}}$t.flowStartParseAsyncArrowFromCallExpression=SI;function $I(e,t){if(N.match.call(void 0,I.TokenType.lessThan)){let n=Fe.state.snapshot(),r=wt.baseParseMaybeAssign.call(void 0,e,t);if(Fe.state.error)Fe.state.restoreFromSnapshot(n),Fe.state.type=I.TokenType.typeParameterStart;else return r;let o=N.pushTypeContext.call(void 0,0);if(br(),N.popTypeContext.call(void 0,o),r=wt.baseParseMaybeAssign.call(void 0,e,t),r)return!0;he.unexpected.call(void 0)}return wt.baseParseMaybeAssign.call(void 0,e,t)}$t.flowParseMaybeAssign=$I;function RI(){if(N.match.call(void 0,I.TokenType.colon)){let e=N.pushTypeContext.call(void 0,0),t=Fe.state.snapshot(),n=Fe.state.noAnonFunctionType;Fe.state.noAnonFunctionType=!0,Wd(),Fe.state.noAnonFunctionType=n,he.canInsertSemicolon.call(void 0)&&he.unexpected.call(void 0),N.match.call(void 0,I.TokenType.arrow)||he.unexpected.call(void 0),Fe.state.error&&Fe.state.restoreFromSnapshot(t),N.popTypeContext.call(void 0,e)}return N.eat.call(void 0,I.TokenType.arrow)}$t.flowParseArrow=RI;function CI(e,t=!1){if(Fe.state.tokens[Fe.state.tokens.length-1].contextualKeyword===Ue.ContextualKeyword._async&&N.match.call(void 0,I.TokenType.lessThan)){let n=Fe.state.snapshot();if(EI()&&!Fe.state.error)return;Fe.state.restoreFromSnapshot(n)}wt.baseParseSubscripts.call(void 0,e,t)}$t.flowParseSubscripts=CI;function EI(){Fe.state.scopeDepth++;let e=Fe.state.tokens.length;return Qr.parseFunctionParams.call(void 0),wt.parseArrow.call(void 0)?(wt.parseArrowExpression.call(void 0,e),!0):!1}function ow(){he.expectContextual.call(void 0,Ue.ContextualKeyword._enum),Fe.state.tokens[Fe.state.tokens.length-1].type=I.TokenType._enum,wt.parseIdentifier.call(void 0),AI()}function AI(){he.eatContextual.call(void 0,Ue.ContextualKeyword._of)&&N.next.call(void 0),he.expect.call(void 0,I.TokenType.braceL),II(),he.expect.call(void 0,I.TokenType.braceR)}function II(){for(;!N.match.call(void 0,I.TokenType.braceR)&&!Fe.state.error&&!N.eat.call(void 0,I.TokenType.ellipsis);)MI(),N.match.call(void 0,I.TokenType.braceR)||he.expect.call(void 0,I.TokenType.comma)}function MI(){wt.parseIdentifier.call(void 0),N.eat.call(void 0,I.TokenType.eq)&&N.next.call(void 0)}});var xi=Ce(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});var PI=rp(),mn=wi(),Gt=ps(),ne=Yt(),We=nn(),Yr=qa(),K=tt(),sw=On(),q=Ln(),ut=Eo(),Zr=rl(),Te=Wr();function FI(){if(tp(K.TokenType.eof),q.state.scopes.push(new Yr.Scope(0,q.state.tokens.length,!0)),q.state.scopeDepth!==0)throw new Error(`Invalid scope depth at end of file: ${q.state.scopeDepth}`);return new PI.File(q.state.tokens,q.state.scopes)}Kt.parseTopLevel=FI;function rr(e){q.isFlowEnabled&&mn.flowTryParseStatement.call(void 0)||(ne.match.call(void 0,K.TokenType.at)&&ep(),OI(e))}Kt.parseStatement=rr;function OI(e){if(q.isTypeScriptEnabled&&Gt.tsTryParseStatementContent.call(void 0))return;let t=q.state.type;switch(t){case K.TokenType._break:case K.TokenType._continue:NI();return;case K.TokenType._debugger:DI();return;case K.TokenType._do:jI();return;case K.TokenType._for:BI();return;case K.TokenType._function:if(ne.lookaheadType.call(void 0)===K.TokenType.dot)break;e||Te.unexpected.call(void 0),HI();return;case K.TokenType._class:e||Te.unexpected.call(void 0),vl(!0);return;case K.TokenType._if:WI();return;case K.TokenType._return:zI();return;case K.TokenType._switch:GI();return;case K.TokenType._throw:KI();return;case K.TokenType._try:JI();return;case K.TokenType._let:case K.TokenType._const:e||Te.unexpected.call(void 0);case K.TokenType._var:_l(t!==K.TokenType._var);return;case K.TokenType._while:XI();return;case K.TokenType.braceL:_s();return;case K.TokenType.semi:QI();return;case K.TokenType._export:case K.TokenType._import:{let o=ne.lookaheadType.call(void 0);if(o===K.TokenType.parenL||o===K.TokenType.dot)break;ne.next.call(void 0),t===K.TokenType._import?yw():hw();return}case K.TokenType.name:if(q.state.contextualKeyword===We.ContextualKeyword._async){let o=q.state.start,s=q.state.snapshot();if(ne.next.call(void 0),ne.match.call(void 0,K.TokenType._function)&&!Te.canInsertSemicolon.call(void 0)){Te.expect.call(void 0,K.TokenType._function),Ai(o,!0);return}else q.state.restoreFromSnapshot(s)}else if(q.state.contextualKeyword===We.ContextualKeyword._using&&!Te.hasFollowingLineBreak.call(void 0)&&ne.lookaheadType.call(void 0)===K.TokenType.name){_l(!0);return}else if(lw()){Te.expectContextual.call(void 0,We.ContextualKeyword._await),_l(!0);return}default:break}let n=q.state.tokens.length;ut.parseExpression.call(void 0);let r=null;if(q.state.tokens.length===n+1){let o=q.state.tokens[q.state.tokens.length-1];o.type===K.TokenType.name&&(r=o.contextualKeyword)}if(r==null){Te.semicolon.call(void 0);return}ne.eat.call(void 0,K.TokenType.colon)?YI():ZI(r)}function lw(){if(!Te.isContextual.call(void 0,We.ContextualKeyword._await))return!1;let e=q.state.snapshot();return ne.next.call(void 0),!Te.isContextual.call(void 0,We.ContextualKeyword._using)||Te.hasPrecedingLineBreak.call(void 0)||(ne.next.call(void 0),!ne.match.call(void 0,K.TokenType.name)||Te.hasPrecedingLineBreak.call(void 0))?(q.state.restoreFromSnapshot(e),!1):(q.state.restoreFromSnapshot(e),!0)}function ep(){for(;ne.match.call(void 0,K.TokenType.at);)cw()}Kt.parseDecorators=ep;function cw(){if(ne.next.call(void 0),ne.eat.call(void 0,K.TokenType.parenL))ut.parseExpression.call(void 0),Te.expect.call(void 0,K.TokenType.parenR);else{for(ut.parseIdentifier.call(void 0);ne.eat.call(void 0,K.TokenType.dot);)ut.parseIdentifier.call(void 0);LI()}}function LI(){q.isTypeScriptEnabled?Gt.tsParseMaybeDecoratorArguments.call(void 0):uw()}function uw(){ne.eat.call(void 0,K.TokenType.parenL)&&ut.parseCallExpressionArguments.call(void 0)}Kt.baseParseMaybeDecoratorArguments=uw;function NI(){ne.next.call(void 0),Te.isLineTerminator.call(void 0)||(ut.parseIdentifier.call(void 0),Te.semicolon.call(void 0))}function DI(){ne.next.call(void 0),Te.semicolon.call(void 0)}function jI(){ne.next.call(void 0),rr(!1),Te.expect.call(void 0,K.TokenType._while),ut.parseParenExpression.call(void 0),ne.eat.call(void 0,K.TokenType.semi)}function BI(){q.state.scopeDepth++;let e=q.state.tokens.length;UI();let t=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(e,t,!1)),q.state.scopeDepth--}function qI(){return!(!Te.isContextual.call(void 0,We.ContextualKeyword._using)||Te.isLookaheadContextual.call(void 0,We.ContextualKeyword._of))}function UI(){ne.next.call(void 0);let e=!1;if(Te.isContextual.call(void 0,We.ContextualKeyword._await)&&(e=!0,ne.next.call(void 0)),Te.expect.call(void 0,K.TokenType.parenL),ne.match.call(void 0,K.TokenType.semi)){e&&Te.unexpected.call(void 0),Yd();return}let t=lw();if(t||ne.match.call(void 0,K.TokenType._var)||ne.match.call(void 0,K.TokenType._let)||ne.match.call(void 0,K.TokenType._const)||qI()){if(t&&Te.expectContextual.call(void 0,We.ContextualKeyword._await),ne.next.call(void 0),dw(!0,q.state.type!==K.TokenType._var),ne.match.call(void 0,K.TokenType._in)||Te.isContextual.call(void 0,We.ContextualKeyword._of)){iw(e);return}Yd();return}if(ut.parseExpression.call(void 0,!0),ne.match.call(void 0,K.TokenType._in)||Te.isContextual.call(void 0,We.ContextualKeyword._of)){iw(e);return}e&&Te.unexpected.call(void 0),Yd()}function HI(){let e=q.state.start;ne.next.call(void 0),Ai(e,!0)}function WI(){ne.next.call(void 0),ut.parseParenExpression.call(void 0),rr(!1),ne.eat.call(void 0,K.TokenType._else)&&rr(!1)}function zI(){ne.next.call(void 0),Te.isLineTerminator.call(void 0)||(ut.parseExpression.call(void 0),Te.semicolon.call(void 0))}function GI(){ne.next.call(void 0),ut.parseParenExpression.call(void 0),q.state.scopeDepth++;let e=q.state.tokens.length;for(Te.expect.call(void 0,K.TokenType.braceL);!ne.match.call(void 0,K.TokenType.braceR)&&!q.state.error;)if(ne.match.call(void 0,K.TokenType._case)||ne.match.call(void 0,K.TokenType._default)){let n=ne.match.call(void 0,K.TokenType._case);ne.next.call(void 0),n&&ut.parseExpression.call(void 0),Te.expect.call(void 0,K.TokenType.colon)}else rr(!0);ne.next.call(void 0);let t=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(e,t,!1)),q.state.scopeDepth--}function KI(){ne.next.call(void 0),ut.parseExpression.call(void 0),Te.semicolon.call(void 0)}function VI(){Zr.parseBindingAtom.call(void 0,!0),q.isTypeScriptEnabled&&Gt.tsTryParseTypeAnnotation.call(void 0)}function JI(){if(ne.next.call(void 0),_s(),ne.match.call(void 0,K.TokenType._catch)){ne.next.call(void 0);let e=null;if(ne.match.call(void 0,K.TokenType.parenL)&&(q.state.scopeDepth++,e=q.state.tokens.length,Te.expect.call(void 0,K.TokenType.parenL),VI(),Te.expect.call(void 0,K.TokenType.parenR)),_s(),e!=null){let t=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(e,t,!1)),q.state.scopeDepth--}}ne.eat.call(void 0,K.TokenType._finally)&&_s()}function _l(e){ne.next.call(void 0),dw(!1,e),Te.semicolon.call(void 0)}Kt.parseVarStatement=_l;function XI(){ne.next.call(void 0),ut.parseParenExpression.call(void 0),rr(!1)}function QI(){ne.next.call(void 0)}function YI(){rr(!0)}function ZI(e){q.isTypeScriptEnabled?Gt.tsParseIdentifierStatement.call(void 0,e):q.isFlowEnabled?mn.flowParseIdentifierStatement.call(void 0,e):Te.semicolon.call(void 0)}function _s(e=!1,t=0){let n=q.state.tokens.length;q.state.scopeDepth++,Te.expect.call(void 0,K.TokenType.braceL),t&&(q.state.tokens[q.state.tokens.length-1].contextId=t),tp(K.TokenType.braceR),t&&(q.state.tokens[q.state.tokens.length-1].contextId=t);let r=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(n,r,e)),q.state.scopeDepth--}Kt.parseBlock=_s;function tp(e){for(;!ne.eat.call(void 0,e)&&!q.state.error;)rr(!0)}Kt.parseBlockBody=tp;function Yd(){Te.expect.call(void 0,K.TokenType.semi),ne.match.call(void 0,K.TokenType.semi)||ut.parseExpression.call(void 0),Te.expect.call(void 0,K.TokenType.semi),ne.match.call(void 0,K.TokenType.parenR)||ut.parseExpression.call(void 0),Te.expect.call(void 0,K.TokenType.parenR),rr(!1)}function iw(e){e?Te.eatContextual.call(void 0,We.ContextualKeyword._of):ne.next.call(void 0),ut.parseExpression.call(void 0),Te.expect.call(void 0,K.TokenType.parenR),rr(!1)}function dw(e,t){for(;;){if(eM(t),ne.eat.call(void 0,K.TokenType.eq)){let n=q.state.tokens.length-1;ut.parseMaybeAssign.call(void 0,e),q.state.tokens[n].rhsEndIndex=q.state.tokens.length}if(!ne.eat.call(void 0,K.TokenType.comma))break}}function eM(e){Zr.parseBindingAtom.call(void 0,e),q.isTypeScriptEnabled?Gt.tsAfterParseVarHead.call(void 0):q.isFlowEnabled&&mn.flowAfterParseVarHead.call(void 0)}function Ai(e,t,n=!1){ne.match.call(void 0,K.TokenType.star)&&ne.next.call(void 0),t&&!n&&!ne.match.call(void 0,K.TokenType.name)&&!ne.match.call(void 0,K.TokenType._yield)&&Te.unexpected.call(void 0);let r=null;ne.match.call(void 0,K.TokenType.name)&&(t||(r=q.state.tokens.length,q.state.scopeDepth++),Zr.parseBindingIdentifier.call(void 0,!1));let o=q.state.tokens.length;q.state.scopeDepth++,pw(),ut.parseFunctionBodyAndFinish.call(void 0,e);let s=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(o,s,!0)),q.state.scopeDepth--,r!==null&&(q.state.scopes.push(new Yr.Scope(r,s,!0)),q.state.scopeDepth--)}Kt.parseFunction=Ai;function pw(e=!1,t=0){q.isTypeScriptEnabled?Gt.tsStartParseFunctionParams.call(void 0):q.isFlowEnabled&&mn.flowStartParseFunctionParams.call(void 0),Te.expect.call(void 0,K.TokenType.parenL),t&&(q.state.tokens[q.state.tokens.length-1].contextId=t),Zr.parseBindingList.call(void 0,K.TokenType.parenR,!1,!1,e,t),t&&(q.state.tokens[q.state.tokens.length-1].contextId=t)}Kt.parseFunctionParams=pw;function vl(e,t=!1){let n=q.getNextContextId.call(void 0);ne.next.call(void 0),q.state.tokens[q.state.tokens.length-1].contextId=n,q.state.tokens[q.state.tokens.length-1].isExpression=!e;let r=null;e||(r=q.state.tokens.length,q.state.scopeDepth++),oM(e,t),sM();let o=q.state.tokens.length;if(tM(n),!q.state.error&&(q.state.tokens[o].contextId=n,q.state.tokens[q.state.tokens.length-1].contextId=n,r!==null)){let s=q.state.tokens.length;q.state.scopes.push(new Yr.Scope(r,s,!1)),q.state.scopeDepth--}}Kt.parseClass=vl;function mw(){return ne.match.call(void 0,K.TokenType.eq)||ne.match.call(void 0,K.TokenType.semi)||ne.match.call(void 0,K.TokenType.braceR)||ne.match.call(void 0,K.TokenType.bang)||ne.match.call(void 0,K.TokenType.colon)}function fw(){return ne.match.call(void 0,K.TokenType.parenL)||ne.match.call(void 0,K.TokenType.lessThan)}function tM(e){for(Te.expect.call(void 0,K.TokenType.braceL);!ne.eat.call(void 0,K.TokenType.braceR)&&!q.state.error;){if(ne.eat.call(void 0,K.TokenType.semi))continue;if(ne.match.call(void 0,K.TokenType.at)){cw();continue}let t=q.state.start;nM(t,e)}}function nM(e,t){q.isTypeScriptEnabled&&Gt.tsParseModifiers.call(void 0,[We.ContextualKeyword._declare,We.ContextualKeyword._public,We.ContextualKeyword._protected,We.ContextualKeyword._private,We.ContextualKeyword._override]);let n=!1;if(ne.match.call(void 0,K.TokenType.name)&&q.state.contextualKeyword===We.ContextualKeyword._static){if(ut.parseIdentifier.call(void 0),fw()){Ci(e,!1);return}else if(mw()){Ei();return}if(q.state.tokens[q.state.tokens.length-1].type=K.TokenType._static,n=!0,ne.match.call(void 0,K.TokenType.braceL)){q.state.tokens[q.state.tokens.length-1].contextId=t,_s();return}}rM(e,n,t)}function rM(e,t,n){if(q.isTypeScriptEnabled&&Gt.tsTryParseClassMemberWithIsStatic.call(void 0,t))return;if(ne.eat.call(void 0,K.TokenType.star)){ks(n),Ci(e,!1);return}ks(n);let r=!1,o=q.state.tokens[q.state.tokens.length-1];o.contextualKeyword===We.ContextualKeyword._constructor&&(r=!0),Zd(),fw()?Ci(e,r):mw()?Ei():o.contextualKeyword===We.ContextualKeyword._async&&!Te.isLineTerminator.call(void 0)?(q.state.tokens[q.state.tokens.length-1].type=K.TokenType._async,ne.match.call(void 0,K.TokenType.star)&&ne.next.call(void 0),ks(n),Zd(),Ci(e,!1)):(o.contextualKeyword===We.ContextualKeyword._get||o.contextualKeyword===We.ContextualKeyword._set)&&!(Te.isLineTerminator.call(void 0)&&ne.match.call(void 0,K.TokenType.star))?(o.contextualKeyword===We.ContextualKeyword._get?q.state.tokens[q.state.tokens.length-1].type=K.TokenType._get:q.state.tokens[q.state.tokens.length-1].type=K.TokenType._set,ks(n),Ci(e,!1)):o.contextualKeyword===We.ContextualKeyword._accessor&&!Te.isLineTerminator.call(void 0)?(ks(n),Ei()):Te.isLineTerminator.call(void 0)?Ei():Te.unexpected.call(void 0)}function Ci(e,t){q.isTypeScriptEnabled?Gt.tsTryParseTypeParameters.call(void 0):q.isFlowEnabled&&ne.match.call(void 0,K.TokenType.lessThan)&&mn.flowParseTypeParameterDeclaration.call(void 0),ut.parseMethod.call(void 0,e,t)}function ks(e){ut.parsePropertyName.call(void 0,e)}Kt.parseClassPropertyName=ks;function Zd(){if(q.isTypeScriptEnabled){let e=ne.pushTypeContext.call(void 0,0);ne.eat.call(void 0,K.TokenType.question),ne.popTypeContext.call(void 0,e)}}Kt.parsePostMemberNameModifiers=Zd;function Ei(){if(q.isTypeScriptEnabled?(ne.eatTypeToken.call(void 0,K.TokenType.bang),Gt.tsTryParseTypeAnnotation.call(void 0)):q.isFlowEnabled&&ne.match.call(void 0,K.TokenType.colon)&&mn.flowParseTypeAnnotation.call(void 0),ne.match.call(void 0,K.TokenType.eq)){let e=q.state.tokens.length;ne.next.call(void 0),ut.parseMaybeAssign.call(void 0),q.state.tokens[e].rhsEndIndex=q.state.tokens.length}Te.semicolon.call(void 0)}Kt.parseClassProperty=Ei;function oM(e,t=!1){q.isTypeScriptEnabled&&(!e||t)&&Te.isContextual.call(void 0,We.ContextualKeyword._implements)||(ne.match.call(void 0,K.TokenType.name)&&Zr.parseBindingIdentifier.call(void 0,!0),q.isTypeScriptEnabled?Gt.tsTryParseTypeParameters.call(void 0):q.isFlowEnabled&&ne.match.call(void 0,K.TokenType.lessThan)&&mn.flowParseTypeParameterDeclaration.call(void 0))}function sM(){let e=!1;ne.eat.call(void 0,K.TokenType._extends)?(ut.parseExprSubscripts.call(void 0),e=!0):e=!1,q.isTypeScriptEnabled?Gt.tsAfterParseClassSuper.call(void 0,e):q.isFlowEnabled&&mn.flowAfterParseClassSuper.call(void 0,e)}function hw(){let e=q.state.tokens.length-1;q.isTypeScriptEnabled&&Gt.tsTryParseExport.call(void 0)||(cM()?uM():lM()?(ut.parseIdentifier.call(void 0),ne.match.call(void 0,K.TokenType.comma)&&ne.lookaheadType.call(void 0)===K.TokenType.star?(Te.expect.call(void 0,K.TokenType.comma),Te.expect.call(void 0,K.TokenType.star),Te.expectContextual.call(void 0,We.ContextualKeyword._as),ut.parseIdentifier.call(void 0)):gw(),Ii()):ne.eat.call(void 0,K.TokenType._default)?iM():pM()?aM():(np(),Ii()),q.state.tokens[e].rhsEndIndex=q.state.tokens.length)}Kt.parseExport=hw;function iM(){if(q.isTypeScriptEnabled&&Gt.tsTryParseExportDefaultExpression.call(void 0)||q.isFlowEnabled&&mn.flowTryParseExportDefaultExpression.call(void 0))return;let e=q.state.start;ne.eat.call(void 0,K.TokenType._function)?Ai(e,!0,!0):Te.isContextual.call(void 0,We.ContextualKeyword._async)&&ne.lookaheadType.call(void 0)===K.TokenType._function?(Te.eatContextual.call(void 0,We.ContextualKeyword._async),ne.eat.call(void 0,K.TokenType._function),Ai(e,!0,!0)):ne.match.call(void 0,K.TokenType._class)?vl(!0,!0):ne.match.call(void 0,K.TokenType.at)?(ep(),vl(!0,!0)):(ut.parseMaybeAssign.call(void 0),Te.semicolon.call(void 0))}function aM(){q.isTypeScriptEnabled?Gt.tsParseExportDeclaration.call(void 0):q.isFlowEnabled?mn.flowParseExportDeclaration.call(void 0):rr(!0)}function lM(){if(q.isTypeScriptEnabled&&Gt.tsIsDeclarationStart.call(void 0))return!1;if(q.isFlowEnabled&&mn.flowShouldDisallowExportDefaultSpecifier.call(void 0))return!1;if(ne.match.call(void 0,K.TokenType.name))return q.state.contextualKeyword!==We.ContextualKeyword._async;if(!ne.match.call(void 0,K.TokenType._default))return!1;let e=ne.nextTokenStart.call(void 0),t=ne.lookaheadTypeAndKeyword.call(void 0),n=t.type===K.TokenType.name&&t.contextualKeyword===We.ContextualKeyword._from;if(t.type===K.TokenType.comma)return!0;if(n){let r=q.input.charCodeAt(ne.nextTokenStartSince.call(void 0,e+4));return r===sw.charCodes.quotationMark||r===sw.charCodes.apostrophe}return!1}function gw(){ne.eat.call(void 0,K.TokenType.comma)&&np()}function Ii(){Te.eatContextual.call(void 0,We.ContextualKeyword._from)&&(ut.parseExprAtom.call(void 0),ww()),Te.semicolon.call(void 0)}Kt.parseExportFrom=Ii;function cM(){return q.isFlowEnabled?mn.flowShouldParseExportStar.call(void 0):ne.match.call(void 0,K.TokenType.star)}function uM(){q.isFlowEnabled?mn.flowParseExportStar.call(void 0):bw()}function bw(){Te.expect.call(void 0,K.TokenType.star),Te.isContextual.call(void 0,We.ContextualKeyword._as)?dM():Ii()}Kt.baseParseExportStar=bw;function dM(){ne.next.call(void 0),q.state.tokens[q.state.tokens.length-1].type=K.TokenType._as,ut.parseIdentifier.call(void 0),gw(),Ii()}function pM(){return q.isTypeScriptEnabled&&Gt.tsIsDeclarationStart.call(void 0)||q.isFlowEnabled&&mn.flowShouldParseExportDeclaration.call(void 0)||q.state.type===K.TokenType._var||q.state.type===K.TokenType._const||q.state.type===K.TokenType._let||q.state.type===K.TokenType._function||q.state.type===K.TokenType._class||Te.isContextual.call(void 0,We.ContextualKeyword._async)||ne.match.call(void 0,K.TokenType.at)}function np(){let e=!0;for(Te.expect.call(void 0,K.TokenType.braceL);!ne.eat.call(void 0,K.TokenType.braceR)&&!q.state.error;){if(e)e=!1;else if(Te.expect.call(void 0,K.TokenType.comma),ne.eat.call(void 0,K.TokenType.braceR))break;mM()}}Kt.parseExportSpecifiers=np;function mM(){if(q.isTypeScriptEnabled){Gt.tsParseExportSpecifier.call(void 0);return}ut.parseIdentifier.call(void 0),q.state.tokens[q.state.tokens.length-1].identifierRole=ne.IdentifierRole.ExportAccess,Te.eatContextual.call(void 0,We.ContextualKeyword._as)&&ut.parseIdentifier.call(void 0)}function fM(){let e=q.state.snapshot();return Te.expectContextual.call(void 0,We.ContextualKeyword._module),Te.eatContextual.call(void 0,We.ContextualKeyword._from)?Te.isContextual.call(void 0,We.ContextualKeyword._from)?(q.state.restoreFromSnapshot(e),!0):(q.state.restoreFromSnapshot(e),!1):ne.match.call(void 0,K.TokenType.comma)?(q.state.restoreFromSnapshot(e),!1):(q.state.restoreFromSnapshot(e),!0)}function hM(){Te.isContextual.call(void 0,We.ContextualKeyword._module)&&fM()&&ne.next.call(void 0)}function yw(){if(q.isTypeScriptEnabled&&ne.match.call(void 0,K.TokenType.name)&&ne.lookaheadType.call(void 0)===K.TokenType.eq){Gt.tsParseImportEqualsDeclaration.call(void 0);return}if(q.isTypeScriptEnabled&&Te.isContextual.call(void 0,We.ContextualKeyword._type)){let e=ne.lookaheadTypeAndKeyword.call(void 0);if(e.type===K.TokenType.name&&e.contextualKeyword!==We.ContextualKeyword._from){if(Te.expectContextual.call(void 0,We.ContextualKeyword._type),ne.lookaheadType.call(void 0)===K.TokenType.eq){Gt.tsParseImportEqualsDeclaration.call(void 0);return}}else(e.type===K.TokenType.star||e.type===K.TokenType.braceL)&&Te.expectContextual.call(void 0,We.ContextualKeyword._type)}ne.match.call(void 0,K.TokenType.string)||(hM(),bM(),Te.expectContextual.call(void 0,We.ContextualKeyword._from)),ut.parseExprAtom.call(void 0),ww(),Te.semicolon.call(void 0)}Kt.parseImport=yw;function gM(){return ne.match.call(void 0,K.TokenType.name)}function aw(){Zr.parseImportedIdentifier.call(void 0)}function bM(){q.isFlowEnabled&&mn.flowStartParseImportSpecifiers.call(void 0);let e=!0;if(!(gM()&&(aw(),!ne.eat.call(void 0,K.TokenType.comma)))){if(ne.match.call(void 0,K.TokenType.star)){ne.next.call(void 0),Te.expectContextual.call(void 0,We.ContextualKeyword._as),aw();return}for(Te.expect.call(void 0,K.TokenType.braceL);!ne.eat.call(void 0,K.TokenType.braceR)&&!q.state.error;){if(e)e=!1;else if(ne.eat.call(void 0,K.TokenType.colon)&&Te.unexpected.call(void 0,"ES2015 named imports do not destructure. Use another statement for destructuring after the import."),Te.expect.call(void 0,K.TokenType.comma),ne.eat.call(void 0,K.TokenType.braceR))break;yM()}}}function yM(){if(q.isTypeScriptEnabled){Gt.tsParseImportSpecifier.call(void 0);return}if(q.isFlowEnabled){mn.flowParseImportSpecifier.call(void 0);return}Zr.parseImportedIdentifier.call(void 0),Te.isContextual.call(void 0,We.ContextualKeyword._as)&&(q.state.tokens[q.state.tokens.length-1].identifierRole=ne.IdentifierRole.ImportAccess,ne.next.call(void 0),Zr.parseImportedIdentifier.call(void 0))}function ww(){(ne.match.call(void 0,K.TokenType._with)||Te.isContextual.call(void 0,We.ContextualKeyword._assert)&&!Te.hasPrecedingLineBreak.call(void 0))&&(ne.next.call(void 0),ut.parseObj.call(void 0,!1,!1))}});var vw=Ce(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});var kw=Yt(),_w=On(),op=Ln(),wM=xi();function kM(){return op.state.pos===0&&op.input.charCodeAt(0)===_w.charCodes.numberSign&&op.input.charCodeAt(1)===_w.charCodes.exclamationMark&&kw.skipLineComment.call(void 0,2),kw.nextToken.call(void 0),wM.parseTopLevel.call(void 0)}sp.parseFile=kM});var rp=Ce(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});var Tl=Ln(),_M=vw(),ip=class{constructor(t,n){this.tokens=t,this.scopes=n}};xl.File=ip;function vM(e,t,n,r){if(r&&n)throw new Error("Cannot combine flow and typescript plugins.");Tl.initParser.call(void 0,e,t,n,r);let o=_M.parseFile.call(void 0);if(Tl.state.error)throw Tl.augmentError.call(void 0,Tl.state.error);return o}xl.parse=vM});var Tw=Ce(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});var TM=nn();function xM(e){let t=e.currentIndex(),n=0,r=e.currentToken();do{let o=e.tokens[t];if(o.isOptionalChainStart&&n++,o.isOptionalChainEnd&&n--,n+=o.numNullishCoalesceStarts,n-=o.numNullishCoalesceEnds,o.contextualKeyword===TM.ContextualKeyword._await&&o.identifierRole==null&&o.scopeDepth===r.scopeDepth)return!0;t+=1}while(n>0&&t<e.tokens.length);return!1}ap.default=xM});var xw=Ce(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});function SM(e){return e&&e.__esModule?e:{default:e}}var Sl=tt(),$M=Tw(),RM=SM($M),lp=class e{__init(){this.resultCode=""}__init2(){this.resultMappings=new Array(this.tokens.length)}__init3(){this.tokenIndex=0}constructor(t,n,r,o,s){this.code=t,this.tokens=n,this.isFlowEnabled=r,this.disableESTransforms=o,this.helperManager=s,e.prototype.__init.call(this),e.prototype.__init2.call(this),e.prototype.__init3.call(this)}snapshot(){return{resultCode:this.resultCode,tokenIndex:this.tokenIndex}}restoreToSnapshot(t){this.resultCode=t.resultCode,this.tokenIndex=t.tokenIndex}dangerouslyGetAndRemoveCodeSinceSnapshot(t){let n=this.resultCode.slice(t.resultCode.length);return this.resultCode=t.resultCode,n}reset(){this.resultCode="",this.resultMappings=new Array(this.tokens.length),this.tokenIndex=0}matchesContextualAtIndex(t,n){return this.matches1AtIndex(t,Sl.TokenType.name)&&this.tokens[t].contextualKeyword===n}identifierNameAtIndex(t){return this.identifierNameForToken(this.tokens[t])}identifierNameAtRelativeIndex(t){return this.identifierNameForToken(this.tokenAtRelativeIndex(t))}identifierName(){return this.identifierNameForToken(this.currentToken())}identifierNameForToken(t){return this.code.slice(t.start,t.end)}rawCodeForToken(t){return this.code.slice(t.start,t.end)}stringValueAtIndex(t){return this.stringValueForToken(this.tokens[t])}stringValue(){return this.stringValueForToken(this.currentToken())}stringValueForToken(t){return this.code.slice(t.start+1,t.end-1)}matches1AtIndex(t,n){return this.tokens[t].type===n}matches2AtIndex(t,n,r){return this.tokens[t].type===n&&this.tokens[t+1].type===r}matches3AtIndex(t,n,r,o){return this.tokens[t].type===n&&this.tokens[t+1].type===r&&this.tokens[t+2].type===o}matches1(t){return this.tokens[this.tokenIndex].type===t}matches2(t,n){return this.tokens[this.tokenIndex].type===t&&this.tokens[this.tokenIndex+1].type===n}matches3(t,n,r){return this.tokens[this.tokenIndex].type===t&&this.tokens[this.tokenIndex+1].type===n&&this.tokens[this.tokenIndex+2].type===r}matches4(t,n,r,o){return this.tokens[this.tokenIndex].type===t&&this.tokens[this.tokenIndex+1].type===n&&this.tokens[this.tokenIndex+2].type===r&&this.tokens[this.tokenIndex+3].type===o}matches5(t,n,r,o,s){return this.tokens[this.tokenIndex].type===t&&this.tokens[this.tokenIndex+1].type===n&&this.tokens[this.tokenIndex+2].type===r&&this.tokens[this.tokenIndex+3].type===o&&this.tokens[this.tokenIndex+4].type===s}matchesContextual(t){return this.matchesContextualAtIndex(this.tokenIndex,t)}matchesContextIdAndLabel(t,n){return this.matches1(t)&&this.currentToken().contextId===n}previousWhitespaceAndComments(){let t=this.code.slice(this.tokenIndex>0?this.tokens[this.tokenIndex-1].end:0,this.tokenIndex<this.tokens.length?this.tokens[this.tokenIndex].start:this.code.length);return this.isFlowEnabled&&(t=t.replace(/@flow/g,"")),t}replaceToken(t){this.resultCode+=this.previousWhitespaceAndComments(),this.appendTokenPrefix(),this.resultMappings[this.tokenIndex]=this.resultCode.length,this.resultCode+=t,this.appendTokenSuffix(),this.tokenIndex++}replaceTokenTrimmingLeftWhitespace(t){this.resultCode+=this.previousWhitespaceAndComments().replace(/[^\r\n]/g,""),this.appendTokenPrefix(),this.resultMappings[this.tokenIndex]=this.resultCode.length,this.resultCode+=t,this.appendTokenSuffix(),this.tokenIndex++}removeInitialToken(){this.replaceToken("")}removeToken(){this.replaceTokenTrimmingLeftWhitespace("")}removeBalancedCode(){let t=0;for(;!this.isAtEnd();){if(this.matches1(Sl.TokenType.braceL))t++;else if(this.matches1(Sl.TokenType.braceR)){if(t===0)return;t--}this.removeToken()}}copyExpectedToken(t){if(this.tokens[this.tokenIndex].type!==t)throw new Error(`Expected token ${t}`);this.copyToken()}copyToken(){this.resultCode+=this.previousWhitespaceAndComments(),this.appendTokenPrefix(),this.resultMappings[this.tokenIndex]=this.resultCode.length,this.resultCode+=this.code.slice(this.tokens[this.tokenIndex].start,this.tokens[this.tokenIndex].end),this.appendTokenSuffix(),this.tokenIndex++}copyTokenWithPrefix(t){this.resultCode+=this.previousWhitespaceAndComments(),this.appendTokenPrefix(),this.resultCode+=t,this.resultMappings[this.tokenIndex]=this.resultCode.length,this.resultCode+=this.code.slice(this.tokens[this.tokenIndex].start,this.tokens[this.tokenIndex].end),this.appendTokenSuffix(),this.tokenIndex++}appendTokenPrefix(){let t=this.currentToken();if((t.numNullishCoalesceStarts||t.isOptionalChainStart)&&(t.isAsyncOperation=RM.default.call(void 0,this)),!this.disableESTransforms){if(t.numNullishCoalesceStarts)for(let n=0;n<t.numNullishCoalesceStarts;n++)t.isAsyncOperation?(this.resultCode+="await ",this.resultCode+=this.helperManager.getHelperName("asyncNullishCoalesce")):this.resultCode+=this.helperManager.getHelperName("nullishCoalesce"),this.resultCode+="(";t.isOptionalChainStart&&(t.isAsyncOperation&&(this.resultCode+="await "),this.tokenIndex>0&&this.tokenAtRelativeIndex(-1).type===Sl.TokenType._delete?t.isAsyncOperation?this.resultCode+=this.helperManager.getHelperName("asyncOptionalChainDelete"):this.resultCode+=this.helperManager.getHelperName("optionalChainDelete"):t.isAsyncOperation?this.resultCode+=this.helperManager.getHelperName("asyncOptionalChain"):this.resultCode+=this.helperManager.getHelperName("optionalChain"),this.resultCode+="([")}}appendTokenSuffix(){let t=this.currentToken();if(t.isOptionalChainEnd&&!this.disableESTransforms&&(this.resultCode+="])"),t.numNullishCoalesceEnds&&!this.disableESTransforms)for(let n=0;n<t.numNullishCoalesceEnds;n++)this.resultCode+="))"}appendCode(t){this.resultCode+=t}currentToken(){return this.tokens[this.tokenIndex]}currentTokenCode(){let t=this.currentToken();return this.code.slice(t.start,t.end)}tokenAtRelativeIndex(t){return this.tokens[this.tokenIndex+t]}currentIndex(){return this.tokenIndex}nextToken(){if(this.tokenIndex===this.tokens.length)throw new Error("Unexpectedly reached end of input.");this.tokenIndex++}previousToken(){this.tokenIndex--}finish(){if(this.tokenIndex!==this.tokens.length)throw new Error("Tried to finish processing tokens before reaching the end.");return this.resultCode+=this.previousWhitespaceAndComments(),{code:this.resultCode,mappings:this.resultMappings}}isAtEnd(){return this.tokenIndex===this.tokens.length}};cp.default=lp});var Rw=Ce(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var Sw=nn(),at=tt();function CM(e,t,n,r){let o=t.snapshot(),s=EM(t),i=[],a=[],l=[],c=null,u=[],p=[],d=t.currentToken().contextId;if(d==null)throw new Error("Expected non-null class context ID on class open-brace.");for(t.nextToken();!t.matchesContextIdAndLabel(at.TokenType.braceR,d);)if(t.matchesContextual(Sw.ContextualKeyword._constructor)&&!t.currentToken().isType)({constructorInitializerStatements:i,constructorInsertPos:c}=$w(t));else if(t.matches1(at.TokenType.semi))r||p.push({start:t.currentIndex(),end:t.currentIndex()+1}),t.nextToken();else if(t.currentToken().isType)t.nextToken();else{let m=t.currentIndex(),h=!1,g=!1,y=!1;for(;$l(t.currentToken());)t.matches1(at.TokenType._static)&&(h=!0),t.matches1(at.TokenType.hash)&&(g=!0),(t.matches1(at.TokenType._declare)||t.matches1(at.TokenType._abstract))&&(y=!0),t.nextToken();if(h&&t.matches1(at.TokenType.braceL)){up(t,d);continue}if(g){up(t,d);continue}if(t.matchesContextual(Sw.ContextualKeyword._constructor)&&!t.currentToken().isType){({constructorInitializerStatements:i,constructorInsertPos:c}=$w(t));continue}let k=t.currentIndex();if(AM(t),t.matches1(at.TokenType.lessThan)||t.matches1(at.TokenType.parenL)){up(t,d);continue}for(;t.currentToken().isType;)t.nextToken();if(t.matches1(at.TokenType.eq)){let b=t.currentIndex(),w=t.currentToken().rhsEndIndex;if(w==null)throw new Error("Expected rhsEndIndex on class field assignment.");for(t.nextToken();t.currentIndex()<w;)e.processToken();let _;h?(_=n.claimFreeName("__initStatic"),l.push(_)):(_=n.claimFreeName("__init"),a.push(_)),u.push({initializerName:_,equalsIndex:b,start:k,end:t.currentIndex()})}else(!r||y)&&p.push({start:m,end:t.currentIndex()})}return t.restoreToSnapshot(o),r?{headerInfo:s,constructorInitializerStatements:i,instanceInitializerNames:[],staticInitializerNames:[],constructorInsertPos:c,fields:[],rangesToRemove:p}:{headerInfo:s,constructorInitializerStatements:i,instanceInitializerNames:a,staticInitializerNames:l,constructorInsertPos:c,fields:u,rangesToRemove:p}}dp.default=CM;function up(e,t){for(e.nextToken();e.currentToken().contextId!==t;)e.nextToken();for(;$l(e.tokenAtRelativeIndex(-1));)e.previousToken()}function EM(e){let t=e.currentToken(),n=t.contextId;if(n==null)throw new Error("Expected context ID on class token.");let r=t.isExpression;if(r==null)throw new Error("Expected isExpression on class token.");let o=null,s=!1;for(e.nextToken(),e.matches1(at.TokenType.name)&&(o=e.identifierName());!e.matchesContextIdAndLabel(at.TokenType.braceL,n);)e.matches1(at.TokenType._extends)&&!e.currentToken().isType&&(s=!0),e.nextToken();return{isExpression:r,className:o,hasSuperclass:s}}function $w(e){let t=[];e.nextToken();let n=e.currentToken().contextId;if(n==null)throw new Error("Expected context ID on open-paren starting constructor params.");for(;!e.matchesContextIdAndLabel(at.TokenType.parenR,n);)if(e.currentToken().contextId===n){if(e.nextToken(),$l(e.currentToken())){for(e.nextToken();$l(e.currentToken());)e.nextToken();let s=e.currentToken();if(s.type!==at.TokenType.name)throw new Error("Expected identifier after access modifiers in constructor arg.");let i=e.identifierNameForToken(s);t.push(`this.${i} = ${i}`)}}else e.nextToken();for(e.nextToken();e.currentToken().isType;)e.nextToken();let r=e.currentIndex(),o=!1;for(;!e.matchesContextIdAndLabel(at.TokenType.braceR,n);){if(!o&&e.matches2(at.TokenType._super,at.TokenType.parenL)){e.nextToken();let s=e.currentToken().contextId;if(s==null)throw new Error("Expected a context ID on the super call");for(;!e.matchesContextIdAndLabel(at.TokenType.parenR,s);)e.nextToken();r=e.currentIndex(),o=!0}e.nextToken()}return e.nextToken(),{constructorInitializerStatements:t,constructorInsertPos:r}}function $l(e){return[at.TokenType._async,at.TokenType._get,at.TokenType._set,at.TokenType.plus,at.TokenType.minus,at.TokenType._readonly,at.TokenType._static,at.TokenType._public,at.TokenType._private,at.TokenType._protected,at.TokenType._override,at.TokenType._abstract,at.TokenType.star,at.TokenType._declare,at.TokenType.hash].includes(e.type)}function AM(e){if(e.matches1(at.TokenType.bracketL)){let n=e.currentToken().contextId;if(n==null)throw new Error("Expected class context ID on computed name open bracket.");for(;!e.matchesContextIdAndLabel(at.TokenType.bracketR,n);)e.nextToken();e.nextToken()}else e.nextToken()}});var mp=Ce(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var Cw=tt();function IM(e){if(e.removeInitialToken(),e.removeToken(),e.removeToken(),e.removeToken(),e.matches1(Cw.TokenType.parenL))e.removeToken(),e.removeToken(),e.removeToken();else for(;e.matches1(Cw.TokenType.dot);)e.removeToken(),e.removeToken()}pp.default=IM});var fp=Ce(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});var MM=Yt(),PM=tt(),FM={typeDeclarations:new Set,valueDeclarations:new Set};Rl.EMPTY_DECLARATION_INFO=FM;function OM(e){let t=new Set,n=new Set;for(let r=0;r<e.tokens.length;r++){let o=e.tokens[r];o.type===PM.TokenType.name&&MM.isTopLevelDeclaration.call(void 0,o)&&(o.isType?t.add(e.identifierNameForToken(o)):n.add(e.identifierNameForToken(o)))}return{typeDeclarations:t,valueDeclarations:n}}Rl.default=OM});var gp=Ce(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});var LM=nn(),Ew=tt();function NM(e){let t=e.currentIndex();for(;!e.matches1AtIndex(t,Ew.TokenType.braceR);)t++;return e.matchesContextualAtIndex(t+1,LM.ContextualKeyword._from)&&e.matches1AtIndex(t+2,Ew.TokenType.string)}hp.default=NM});var yp=Ce(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});var DM=nn(),Cl=tt();function jM(e){(e.matches2(Cl.TokenType._with,Cl.TokenType.braceL)||e.matches2(Cl.TokenType.name,Cl.TokenType.braceL)&&e.matchesContextual(DM.ContextualKeyword._assert))&&(e.removeToken(),e.removeToken(),e.removeBalancedCode(),e.removeToken())}bp.removeMaybeImportAttributes=jM});var kp=Ce(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var Aw=tt();function BM(e,t,n,r){if(!e||t)return!1;let o=n.currentToken();if(o.rhsEndIndex==null)throw new Error("Expected non-null rhsEndIndex on export token.");let s=o.rhsEndIndex-n.currentIndex();if(s!==3&&!(s===4&&n.matches1AtIndex(o.rhsEndIndex-1,Aw.TokenType.semi)))return!1;let i=n.tokenAtRelativeIndex(2);if(i.type!==Aw.TokenType.name)return!1;let a=n.identifierNameForToken(i);return r.typeDeclarations.has(a)&&!r.valueDeclarations.has(a)}wp.default=BM});var Mw=Ce(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});function vs(e){return e&&e.__esModule?e:{default:e}}var El=Yt(),Io=nn(),W=tt(),qM=mp(),UM=vs(qM),Iw=fp(),HM=vs(Iw),WM=di(),zM=vs(WM),GM=gp(),KM=vs(GM),Al=yp(),VM=kp(),JM=vs(VM),XM=Hn(),QM=vs(XM),_p=class e extends QM.default{__init(){this.hadExport=!1}__init2(){this.hadNamedExport=!1}__init3(){this.hadDefaultExport=!1}constructor(t,n,r,o,s,i,a,l,c,u,p,d){super(),this.rootTransformer=t,this.tokens=n,this.importProcessor=r,this.nameManager=o,this.helperManager=s,this.reactHotLoaderTransformer=i,this.enableLegacyBabel5ModuleInterop=a,this.enableLegacyTypeScriptModuleInterop=l,this.isTypeScriptTransformEnabled=c,this.isFlowTransformEnabled=u,this.preserveDynamicImport=p,this.keepUnusedImports=d,e.prototype.__init.call(this),e.prototype.__init2.call(this),e.prototype.__init3.call(this),this.declarationInfo=c?HM.default.call(void 0,n):Iw.EMPTY_DECLARATION_INFO}getPrefixCode(){let t="";return this.hadExport&&(t+='Object.defineProperty(exports, "__esModule", {value: true});'),t}getSuffixCode(){return this.enableLegacyBabel5ModuleInterop&&this.hadDefaultExport&&!this.hadNamedExport?`
|
|
119
|
-
module.exports = exports.default;
|
|
120
|
-
`:""}process(){return this.tokens.matches3(W.TokenType._import,W.TokenType.name,W.TokenType.eq)?this.processImportEquals():this.tokens.matches1(W.TokenType._import)?(this.processImport(),!0):this.tokens.matches2(W.TokenType._export,W.TokenType.eq)?(this.tokens.replaceToken("module.exports"),!0):this.tokens.matches1(W.TokenType._export)&&!this.tokens.currentToken().isType?(this.hadExport=!0,this.processExport()):this.tokens.matches2(W.TokenType.name,W.TokenType.postIncDec)&&this.processPostIncDec()?!0:this.tokens.matches1(W.TokenType.name)||this.tokens.matches1(W.TokenType.jsxName)?this.processIdentifier():this.tokens.matches1(W.TokenType.eq)?this.processAssignment():this.tokens.matches1(W.TokenType.assign)?this.processComplexAssignment():this.tokens.matches1(W.TokenType.preIncDec)?this.processPreIncDec():!1}processImportEquals(){let t=this.tokens.identifierNameAtIndex(this.tokens.currentIndex()+1);return this.importProcessor.shouldAutomaticallyElideImportedName(t)?UM.default.call(void 0,this.tokens):this.tokens.replaceToken("const"),!0}processImport(){if(this.tokens.matches2(W.TokenType._import,W.TokenType.parenL)){if(this.preserveDynamicImport){this.tokens.copyToken();return}let n=this.enableLegacyTypeScriptModuleInterop?"":`${this.helperManager.getHelperName("interopRequireWildcard")}(`;this.tokens.replaceToken(`Promise.resolve().then(() => ${n}require`);let r=this.tokens.currentToken().contextId;if(r==null)throw new Error("Expected context ID on dynamic import invocation.");for(this.tokens.copyToken();!this.tokens.matchesContextIdAndLabel(W.TokenType.parenR,r);)this.rootTransformer.processToken();this.tokens.replaceToken(n?")))":"))");return}if(this.removeImportAndDetectIfShouldElide())this.tokens.removeToken();else{let n=this.tokens.stringValue();this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(n)),this.tokens.appendCode(this.importProcessor.claimImportCode(n))}Al.removeMaybeImportAttributes.call(void 0,this.tokens),this.tokens.matches1(W.TokenType.semi)&&this.tokens.removeToken()}removeImportAndDetectIfShouldElide(){if(this.tokens.removeInitialToken(),this.tokens.matchesContextual(Io.ContextualKeyword._type)&&!this.tokens.matches1AtIndex(this.tokens.currentIndex()+1,W.TokenType.comma)&&!this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+1,Io.ContextualKeyword._from))return this.removeRemainingImport(),!0;if(this.tokens.matches1(W.TokenType.name)||this.tokens.matches1(W.TokenType.star))return this.removeRemainingImport(),!1;if(this.tokens.matches1(W.TokenType.string))return!1;let t=!1,n=!1;for(;!this.tokens.matches1(W.TokenType.string);)(!t&&this.tokens.matches1(W.TokenType.braceL)||this.tokens.matches1(W.TokenType.comma))&&(this.tokens.removeToken(),this.tokens.matches1(W.TokenType.braceR)||(n=!0),(this.tokens.matches2(W.TokenType.name,W.TokenType.comma)||this.tokens.matches2(W.TokenType.name,W.TokenType.braceR)||this.tokens.matches4(W.TokenType.name,W.TokenType.name,W.TokenType.name,W.TokenType.comma)||this.tokens.matches4(W.TokenType.name,W.TokenType.name,W.TokenType.name,W.TokenType.braceR))&&(t=!0)),this.tokens.removeToken();return this.keepUnusedImports?!1:this.isTypeScriptTransformEnabled?!t:this.isFlowTransformEnabled?n&&!t:!1}removeRemainingImport(){for(;!this.tokens.matches1(W.TokenType.string);)this.tokens.removeToken()}processIdentifier(){let t=this.tokens.currentToken();if(t.shadowsGlobal)return!1;if(t.identifierRole===El.IdentifierRole.ObjectShorthand)return this.processObjectShorthand();if(t.identifierRole!==El.IdentifierRole.Access)return!1;let n=this.importProcessor.getIdentifierReplacement(this.tokens.identifierNameForToken(t));if(!n)return!1;let r=this.tokens.currentIndex()+1;for(;r<this.tokens.tokens.length&&this.tokens.tokens[r].type===W.TokenType.parenR;)r++;return this.tokens.tokens[r].type===W.TokenType.parenL?this.tokens.tokenAtRelativeIndex(1).type===W.TokenType.parenL&&this.tokens.tokenAtRelativeIndex(-1).type!==W.TokenType._new?(this.tokens.replaceToken(`${n}.call(void 0, `),this.tokens.removeToken(),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(W.TokenType.parenR)):this.tokens.replaceToken(`(0, ${n})`):this.tokens.replaceToken(n),!0}processObjectShorthand(){let t=this.tokens.identifierName(),n=this.importProcessor.getIdentifierReplacement(t);return n?(this.tokens.replaceToken(`${t}: ${n}`),!0):!1}processExport(){if(this.tokens.matches2(W.TokenType._export,W.TokenType._enum)||this.tokens.matches3(W.TokenType._export,W.TokenType._const,W.TokenType._enum))return this.hadNamedExport=!0,!1;if(this.tokens.matches2(W.TokenType._export,W.TokenType._default))return this.tokens.matches3(W.TokenType._export,W.TokenType._default,W.TokenType._enum)?(this.hadDefaultExport=!0,!1):(this.processExportDefault(),!0);if(this.tokens.matches2(W.TokenType._export,W.TokenType.braceL))return this.processExportBindings(),!0;if(this.tokens.matches2(W.TokenType._export,W.TokenType.name)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+1,Io.ContextualKeyword._type)){if(this.tokens.removeInitialToken(),this.tokens.removeToken(),this.tokens.matches1(W.TokenType.braceL)){for(;!this.tokens.matches1(W.TokenType.braceR);)this.tokens.removeToken();this.tokens.removeToken()}else this.tokens.removeToken(),this.tokens.matches1(W.TokenType._as)&&(this.tokens.removeToken(),this.tokens.removeToken());return this.tokens.matchesContextual(Io.ContextualKeyword._from)&&this.tokens.matches1AtIndex(this.tokens.currentIndex()+1,W.TokenType.string)&&(this.tokens.removeToken(),this.tokens.removeToken(),Al.removeMaybeImportAttributes.call(void 0,this.tokens)),!0}if(this.hadNamedExport=!0,this.tokens.matches2(W.TokenType._export,W.TokenType._var)||this.tokens.matches2(W.TokenType._export,W.TokenType._let)||this.tokens.matches2(W.TokenType._export,W.TokenType._const))return this.processExportVar(),!0;if(this.tokens.matches2(W.TokenType._export,W.TokenType._function)||this.tokens.matches3(W.TokenType._export,W.TokenType.name,W.TokenType._function))return this.processExportFunction(),!0;if(this.tokens.matches2(W.TokenType._export,W.TokenType._class)||this.tokens.matches3(W.TokenType._export,W.TokenType._abstract,W.TokenType._class)||this.tokens.matches2(W.TokenType._export,W.TokenType.at))return this.processExportClass(),!0;if(this.tokens.matches2(W.TokenType._export,W.TokenType.star))return this.processExportStar(),!0;throw new Error("Unrecognized export syntax.")}processAssignment(){let t=this.tokens.currentIndex(),n=this.tokens.tokens[t-1];if(n.isType||n.type!==W.TokenType.name||n.shadowsGlobal||t>=2&&this.tokens.matches1AtIndex(t-2,W.TokenType.dot)||t>=2&&[W.TokenType._var,W.TokenType._let,W.TokenType._const].includes(this.tokens.tokens[t-2].type))return!1;let r=this.importProcessor.resolveExportBinding(this.tokens.identifierNameForToken(n));return r?(this.tokens.copyToken(),this.tokens.appendCode(` ${r} =`),!0):!1}processComplexAssignment(){let t=this.tokens.currentIndex(),n=this.tokens.tokens[t-1];if(n.type!==W.TokenType.name||n.shadowsGlobal||t>=2&&this.tokens.matches1AtIndex(t-2,W.TokenType.dot))return!1;let r=this.importProcessor.resolveExportBinding(this.tokens.identifierNameForToken(n));return r?(this.tokens.appendCode(` = ${r}`),this.tokens.copyToken(),!0):!1}processPreIncDec(){let t=this.tokens.currentIndex(),n=this.tokens.tokens[t+1];if(n.type!==W.TokenType.name||n.shadowsGlobal||t+2<this.tokens.tokens.length&&(this.tokens.matches1AtIndex(t+2,W.TokenType.dot)||this.tokens.matches1AtIndex(t+2,W.TokenType.bracketL)||this.tokens.matches1AtIndex(t+2,W.TokenType.parenL)))return!1;let r=this.tokens.identifierNameForToken(n),o=this.importProcessor.resolveExportBinding(r);return o?(this.tokens.appendCode(`${o} = `),this.tokens.copyToken(),!0):!1}processPostIncDec(){let t=this.tokens.currentIndex(),n=this.tokens.tokens[t],r=this.tokens.tokens[t+1];if(n.type!==W.TokenType.name||n.shadowsGlobal||t>=1&&this.tokens.matches1AtIndex(t-1,W.TokenType.dot))return!1;let o=this.tokens.identifierNameForToken(n),s=this.importProcessor.resolveExportBinding(o);if(!s)return!1;let i=this.tokens.rawCodeForToken(r),a=this.importProcessor.getIdentifierReplacement(o)||o;if(i==="++")this.tokens.replaceToken(`(${a} = ${s} = ${a} + 1, ${a} - 1)`);else if(i==="--")this.tokens.replaceToken(`(${a} = ${s} = ${a} - 1, ${a} + 1)`);else throw new Error(`Unexpected operator: ${i}`);return this.tokens.removeToken(),!0}processExportDefault(){let t=!0;if(this.tokens.matches4(W.TokenType._export,W.TokenType._default,W.TokenType._function,W.TokenType.name)||this.tokens.matches5(W.TokenType._export,W.TokenType._default,W.TokenType.name,W.TokenType._function,W.TokenType.name)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+2,Io.ContextualKeyword._async)){this.tokens.removeInitialToken(),this.tokens.removeToken();let n=this.processNamedFunction();this.tokens.appendCode(` exports.default = ${n};`)}else if(this.tokens.matches4(W.TokenType._export,W.TokenType._default,W.TokenType._class,W.TokenType.name)||this.tokens.matches5(W.TokenType._export,W.TokenType._default,W.TokenType._abstract,W.TokenType._class,W.TokenType.name)||this.tokens.matches3(W.TokenType._export,W.TokenType._default,W.TokenType.at)){this.tokens.removeInitialToken(),this.tokens.removeToken(),this.copyDecorators(),this.tokens.matches1(W.TokenType._abstract)&&this.tokens.removeToken();let n=this.rootTransformer.processNamedClass();this.tokens.appendCode(` exports.default = ${n};`)}else if(JM.default.call(void 0,this.isTypeScriptTransformEnabled,this.keepUnusedImports,this.tokens,this.declarationInfo))t=!1,this.tokens.removeInitialToken(),this.tokens.removeToken(),this.tokens.removeToken();else if(this.reactHotLoaderTransformer){let n=this.nameManager.claimFreeName("_default");this.tokens.replaceToken(`let ${n}; exports.`),this.tokens.copyToken(),this.tokens.appendCode(` = ${n} =`),this.reactHotLoaderTransformer.setExtractedDefaultExportName(n)}else this.tokens.replaceToken("exports."),this.tokens.copyToken(),this.tokens.appendCode(" =");t&&(this.hadDefaultExport=!0)}copyDecorators(){for(;this.tokens.matches1(W.TokenType.at);)if(this.tokens.copyToken(),this.tokens.matches1(W.TokenType.parenL))this.tokens.copyExpectedToken(W.TokenType.parenL),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(W.TokenType.parenR);else{for(this.tokens.copyExpectedToken(W.TokenType.name);this.tokens.matches1(W.TokenType.dot);)this.tokens.copyExpectedToken(W.TokenType.dot),this.tokens.copyExpectedToken(W.TokenType.name);this.tokens.matches1(W.TokenType.parenL)&&(this.tokens.copyExpectedToken(W.TokenType.parenL),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(W.TokenType.parenR))}}processExportVar(){this.isSimpleExportVar()?this.processSimpleExportVar():this.processComplexExportVar()}isSimpleExportVar(){let t=this.tokens.currentIndex();if(t++,t++,!this.tokens.matches1AtIndex(t,W.TokenType.name))return!1;for(t++;t<this.tokens.tokens.length&&this.tokens.tokens[t].isType;)t++;return!!this.tokens.matches1AtIndex(t,W.TokenType.eq)}processSimpleExportVar(){this.tokens.removeInitialToken(),this.tokens.copyToken();let t=this.tokens.identifierName();for(;!this.tokens.matches1(W.TokenType.eq);)this.rootTransformer.processToken();let n=this.tokens.currentToken().rhsEndIndex;if(n==null)throw new Error("Expected = token with an end index.");for(;this.tokens.currentIndex()<n;)this.rootTransformer.processToken();this.tokens.appendCode(`; exports.${t} = ${t}`)}processComplexExportVar(){this.tokens.removeInitialToken(),this.tokens.removeToken();let t=this.tokens.matches1(W.TokenType.braceL);t&&this.tokens.appendCode("(");let n=0;for(;;)if(this.tokens.matches1(W.TokenType.braceL)||this.tokens.matches1(W.TokenType.dollarBraceL)||this.tokens.matches1(W.TokenType.bracketL))n++,this.tokens.copyToken();else if(this.tokens.matches1(W.TokenType.braceR)||this.tokens.matches1(W.TokenType.bracketR))n--,this.tokens.copyToken();else{if(n===0&&!this.tokens.matches1(W.TokenType.name)&&!this.tokens.currentToken().isType)break;if(this.tokens.matches1(W.TokenType.eq)){let r=this.tokens.currentToken().rhsEndIndex;if(r==null)throw new Error("Expected = token with an end index.");for(;this.tokens.currentIndex()<r;)this.rootTransformer.processToken()}else{let r=this.tokens.currentToken();if(El.isDeclaration.call(void 0,r)){let o=this.tokens.identifierName(),s=this.importProcessor.getIdentifierReplacement(o);if(s===null)throw new Error(`Expected a replacement for ${o} in \`export var\` syntax.`);El.isObjectShorthandDeclaration.call(void 0,r)&&(s=`${o}: ${s}`),this.tokens.replaceToken(s)}else this.rootTransformer.processToken()}}if(t){let r=this.tokens.currentToken().rhsEndIndex;if(r==null)throw new Error("Expected = token with an end index.");for(;this.tokens.currentIndex()<r;)this.rootTransformer.processToken();this.tokens.appendCode(")")}}processExportFunction(){this.tokens.replaceToken("");let t=this.processNamedFunction();this.tokens.appendCode(` exports.${t} = ${t};`)}processNamedFunction(){if(this.tokens.matches1(W.TokenType._function))this.tokens.copyToken();else if(this.tokens.matches2(W.TokenType.name,W.TokenType._function)){if(!this.tokens.matchesContextual(Io.ContextualKeyword._async))throw new Error("Expected async keyword in function export.");this.tokens.copyToken(),this.tokens.copyToken()}if(this.tokens.matches1(W.TokenType.star)&&this.tokens.copyToken(),!this.tokens.matches1(W.TokenType.name))throw new Error("Expected identifier for exported function name.");let t=this.tokens.identifierName();if(this.tokens.copyToken(),this.tokens.currentToken().isType)for(this.tokens.removeInitialToken();this.tokens.currentToken().isType;)this.tokens.removeToken();return this.tokens.copyExpectedToken(W.TokenType.parenL),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(W.TokenType.parenR),this.rootTransformer.processPossibleTypeRange(),this.tokens.copyExpectedToken(W.TokenType.braceL),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(W.TokenType.braceR),t}processExportClass(){this.tokens.removeInitialToken(),this.copyDecorators(),this.tokens.matches1(W.TokenType._abstract)&&this.tokens.removeToken();let t=this.rootTransformer.processNamedClass();this.tokens.appendCode(` exports.${t} = ${t};`)}processExportBindings(){this.tokens.removeInitialToken(),this.tokens.removeToken();let t=KM.default.call(void 0,this.tokens),n=[];for(;;){if(this.tokens.matches1(W.TokenType.braceR)){this.tokens.removeToken();break}let r=zM.default.call(void 0,this.tokens);for(;this.tokens.currentIndex()<r.endIndex;)this.tokens.removeToken();if(!(r.isType||!t&&this.shouldElideExportedIdentifier(r.leftName))){let s=r.rightName;s==="default"?this.hadDefaultExport=!0:this.hadNamedExport=!0;let i=r.leftName,a=this.importProcessor.getIdentifierReplacement(i);n.push(`exports.${s} = ${a||i};`)}if(this.tokens.matches1(W.TokenType.braceR)){this.tokens.removeToken();break}if(this.tokens.matches2(W.TokenType.comma,W.TokenType.braceR)){this.tokens.removeToken(),this.tokens.removeToken();break}else if(this.tokens.matches1(W.TokenType.comma))this.tokens.removeToken();else throw new Error(`Unexpected token: ${JSON.stringify(this.tokens.currentToken())}`)}if(this.tokens.matchesContextual(Io.ContextualKeyword._from)){this.tokens.removeToken();let r=this.tokens.stringValue();this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(r)),Al.removeMaybeImportAttributes.call(void 0,this.tokens)}else this.tokens.appendCode(n.join(" "));this.tokens.matches1(W.TokenType.semi)&&this.tokens.removeToken()}processExportStar(){for(this.tokens.removeInitialToken();!this.tokens.matches1(W.TokenType.string);)this.tokens.removeToken();let t=this.tokens.stringValue();this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(t)),Al.removeMaybeImportAttributes.call(void 0,this.tokens),this.tokens.matches1(W.TokenType.semi)&&this.tokens.removeToken()}shouldElideExportedIdentifier(t){return this.isTypeScriptTransformEnabled&&!this.keepUnusedImports&&!this.declarationInfo.valueDeclarations.has(t)}};vp.default=_p});var Ow=Ce(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});function Ts(e){return e&&e.__esModule?e:{default:e}}var Cr=nn(),$e=tt(),YM=mp(),ZM=Ts(YM),Fw=fp(),eP=Ts(Fw),tP=di(),Pw=Ts(tP),nP=Vu(),rP=gp(),oP=Ts(rP),Tp=yp(),sP=kp(),iP=Ts(sP),aP=Hn(),lP=Ts(aP),xp=class extends lP.default{constructor(t,n,r,o,s,i,a,l){super(),this.tokens=t,this.nameManager=n,this.helperManager=r,this.reactHotLoaderTransformer=o,this.isTypeScriptTransformEnabled=s,this.isFlowTransformEnabled=i,this.keepUnusedImports=a,this.nonTypeIdentifiers=s&&!a?nP.getNonTypeIdentifiers.call(void 0,t,l):new Set,this.declarationInfo=s&&!a?eP.default.call(void 0,t):Fw.EMPTY_DECLARATION_INFO,this.injectCreateRequireForImportRequire=!!l.injectCreateRequireForImportRequire}process(){if(this.tokens.matches3($e.TokenType._import,$e.TokenType.name,$e.TokenType.eq))return this.processImportEquals();if(this.tokens.matches4($e.TokenType._import,$e.TokenType.name,$e.TokenType.name,$e.TokenType.eq)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+1,Cr.ContextualKeyword._type)){this.tokens.removeInitialToken();for(let t=0;t<7;t++)this.tokens.removeToken();return!0}if(this.tokens.matches2($e.TokenType._export,$e.TokenType.eq))return this.tokens.replaceToken("module.exports"),!0;if(this.tokens.matches5($e.TokenType._export,$e.TokenType._import,$e.TokenType.name,$e.TokenType.name,$e.TokenType.eq)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+2,Cr.ContextualKeyword._type)){this.tokens.removeInitialToken();for(let t=0;t<8;t++)this.tokens.removeToken();return!0}if(this.tokens.matches1($e.TokenType._import))return this.processImport();if(this.tokens.matches2($e.TokenType._export,$e.TokenType._default))return this.processExportDefault();if(this.tokens.matches2($e.TokenType._export,$e.TokenType.braceL))return this.processNamedExports();if(this.tokens.matches2($e.TokenType._export,$e.TokenType.name)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+1,Cr.ContextualKeyword._type)){if(this.tokens.removeInitialToken(),this.tokens.removeToken(),this.tokens.matches1($e.TokenType.braceL)){for(;!this.tokens.matches1($e.TokenType.braceR);)this.tokens.removeToken();this.tokens.removeToken()}else this.tokens.removeToken(),this.tokens.matches1($e.TokenType._as)&&(this.tokens.removeToken(),this.tokens.removeToken());return this.tokens.matchesContextual(Cr.ContextualKeyword._from)&&this.tokens.matches1AtIndex(this.tokens.currentIndex()+1,$e.TokenType.string)&&(this.tokens.removeToken(),this.tokens.removeToken(),Tp.removeMaybeImportAttributes.call(void 0,this.tokens)),!0}return!1}processImportEquals(){let t=this.tokens.identifierNameAtIndex(this.tokens.currentIndex()+1);return this.shouldAutomaticallyElideImportedName(t)?ZM.default.call(void 0,this.tokens):this.injectCreateRequireForImportRequire?(this.tokens.replaceToken("const"),this.tokens.copyToken(),this.tokens.copyToken(),this.tokens.replaceToken(this.helperManager.getHelperName("require"))):this.tokens.replaceToken("const"),!0}processImport(){if(this.tokens.matches2($e.TokenType._import,$e.TokenType.parenL))return!1;let t=this.tokens.snapshot();if(this.removeImportTypeBindings()){for(this.tokens.restoreToSnapshot(t);!this.tokens.matches1($e.TokenType.string);)this.tokens.removeToken();this.tokens.removeToken(),Tp.removeMaybeImportAttributes.call(void 0,this.tokens),this.tokens.matches1($e.TokenType.semi)&&this.tokens.removeToken()}return!0}removeImportTypeBindings(){if(this.tokens.copyExpectedToken($e.TokenType._import),this.tokens.matchesContextual(Cr.ContextualKeyword._type)&&!this.tokens.matches1AtIndex(this.tokens.currentIndex()+1,$e.TokenType.comma)&&!this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+1,Cr.ContextualKeyword._from))return!0;if(this.tokens.matches1($e.TokenType.string))return this.tokens.copyToken(),!1;this.tokens.matchesContextual(Cr.ContextualKeyword._module)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+2,Cr.ContextualKeyword._from)&&this.tokens.copyToken();let t=!1,n=!1,r=!1;if(this.tokens.matches1($e.TokenType.name)&&(this.shouldAutomaticallyElideImportedName(this.tokens.identifierName())?(this.tokens.removeToken(),this.tokens.matches1($e.TokenType.comma)&&this.tokens.removeToken()):(t=!0,this.tokens.copyToken(),this.tokens.matches1($e.TokenType.comma)&&(r=!0,this.tokens.removeToken()))),this.tokens.matches1($e.TokenType.star))this.shouldAutomaticallyElideImportedName(this.tokens.identifierNameAtRelativeIndex(2))?(this.tokens.removeToken(),this.tokens.removeToken(),this.tokens.removeToken()):(r&&this.tokens.appendCode(","),t=!0,this.tokens.copyExpectedToken($e.TokenType.star),this.tokens.copyExpectedToken($e.TokenType.name),this.tokens.copyExpectedToken($e.TokenType.name));else if(this.tokens.matches1($e.TokenType.braceL)){for(r&&this.tokens.appendCode(","),this.tokens.copyToken();!this.tokens.matches1($e.TokenType.braceR);){n=!0;let o=Pw.default.call(void 0,this.tokens);if(o.isType||this.shouldAutomaticallyElideImportedName(o.rightName)){for(;this.tokens.currentIndex()<o.endIndex;)this.tokens.removeToken();this.tokens.matches1($e.TokenType.comma)&&this.tokens.removeToken()}else{for(t=!0;this.tokens.currentIndex()<o.endIndex;)this.tokens.copyToken();this.tokens.matches1($e.TokenType.comma)&&this.tokens.copyToken()}}this.tokens.copyExpectedToken($e.TokenType.braceR)}return this.keepUnusedImports?!1:this.isTypeScriptTransformEnabled?!t:this.isFlowTransformEnabled?n&&!t:!1}shouldAutomaticallyElideImportedName(t){return this.isTypeScriptTransformEnabled&&!this.keepUnusedImports&&!this.nonTypeIdentifiers.has(t)}processExportDefault(){if(iP.default.call(void 0,this.isTypeScriptTransformEnabled,this.keepUnusedImports,this.tokens,this.declarationInfo))return this.tokens.removeInitialToken(),this.tokens.removeToken(),this.tokens.removeToken(),!0;if(!(this.tokens.matches4($e.TokenType._export,$e.TokenType._default,$e.TokenType._function,$e.TokenType.name)||this.tokens.matches5($e.TokenType._export,$e.TokenType._default,$e.TokenType.name,$e.TokenType._function,$e.TokenType.name)&&this.tokens.matchesContextualAtIndex(this.tokens.currentIndex()+2,Cr.ContextualKeyword._async)||this.tokens.matches4($e.TokenType._export,$e.TokenType._default,$e.TokenType._class,$e.TokenType.name)||this.tokens.matches5($e.TokenType._export,$e.TokenType._default,$e.TokenType._abstract,$e.TokenType._class,$e.TokenType.name))&&this.reactHotLoaderTransformer){let n=this.nameManager.claimFreeName("_default");return this.tokens.replaceToken(`let ${n}; export`),this.tokens.copyToken(),this.tokens.appendCode(` ${n} =`),this.reactHotLoaderTransformer.setExtractedDefaultExportName(n),!0}return!1}processNamedExports(){if(!this.isTypeScriptTransformEnabled)return!1;this.tokens.copyExpectedToken($e.TokenType._export),this.tokens.copyExpectedToken($e.TokenType.braceL);let t=oP.default.call(void 0,this.tokens),n=!1;for(;!this.tokens.matches1($e.TokenType.braceR);){let r=Pw.default.call(void 0,this.tokens);if(r.isType||!t&&this.shouldElideExportedName(r.leftName)){for(;this.tokens.currentIndex()<r.endIndex;)this.tokens.removeToken();this.tokens.matches1($e.TokenType.comma)&&this.tokens.removeToken()}else{for(n=!0;this.tokens.currentIndex()<r.endIndex;)this.tokens.copyToken();this.tokens.matches1($e.TokenType.comma)&&this.tokens.copyToken()}}return this.tokens.copyExpectedToken($e.TokenType.braceR),!this.keepUnusedImports&&t&&!n&&(this.tokens.removeToken(),this.tokens.removeToken(),Tp.removeMaybeImportAttributes.call(void 0,this.tokens)),!0}shouldElideExportedName(t){return this.isTypeScriptTransformEnabled&&!this.keepUnusedImports&&this.declarationInfo.typeDeclarations.has(t)&&!this.declarationInfo.valueDeclarations.has(t)}};Sp.default=xp});var Nw=Ce(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});function cP(e){return e&&e.__esModule?e:{default:e}}var Lw=nn(),Bn=tt(),uP=Hn(),dP=cP(uP),$p=class extends dP.default{constructor(t,n,r){super(),this.rootTransformer=t,this.tokens=n,this.isImportsTransformEnabled=r}process(){return this.rootTransformer.processPossibleArrowParamEnd()||this.rootTransformer.processPossibleAsyncArrowWithTypeParams()||this.rootTransformer.processPossibleTypeRange()?!0:this.tokens.matches1(Bn.TokenType._enum)?(this.processEnum(),!0):this.tokens.matches2(Bn.TokenType._export,Bn.TokenType._enum)?(this.processNamedExportEnum(),!0):this.tokens.matches3(Bn.TokenType._export,Bn.TokenType._default,Bn.TokenType._enum)?(this.processDefaultExportEnum(),!0):!1}processNamedExportEnum(){if(this.isImportsTransformEnabled){this.tokens.removeInitialToken();let t=this.tokens.identifierNameAtRelativeIndex(1);this.processEnum(),this.tokens.appendCode(` exports.${t} = ${t};`)}else this.tokens.copyToken(),this.processEnum()}processDefaultExportEnum(){this.tokens.removeInitialToken(),this.tokens.removeToken();let t=this.tokens.identifierNameAtRelativeIndex(1);this.processEnum(),this.isImportsTransformEnabled?this.tokens.appendCode(` exports.default = ${t};`):this.tokens.appendCode(` export default ${t};`)}processEnum(){this.tokens.replaceToken("const"),this.tokens.copyExpectedToken(Bn.TokenType.name);let t=!1;this.tokens.matchesContextual(Lw.ContextualKeyword._of)&&(this.tokens.removeToken(),t=this.tokens.matchesContextual(Lw.ContextualKeyword._symbol),this.tokens.removeToken());let n=this.tokens.matches3(Bn.TokenType.braceL,Bn.TokenType.name,Bn.TokenType.eq);this.tokens.appendCode(' = require("flow-enums-runtime")');let r=!t&&!n;for(this.tokens.replaceTokenTrimmingLeftWhitespace(r?".Mirrored([":"({");!this.tokens.matches1(Bn.TokenType.braceR);){if(this.tokens.matches1(Bn.TokenType.ellipsis)){this.tokens.removeToken();break}this.processEnumElement(t,n),this.tokens.matches1(Bn.TokenType.comma)&&this.tokens.copyToken()}this.tokens.replaceToken(r?"]);":"});")}processEnumElement(t,n){if(t){let r=this.tokens.identifierName();this.tokens.copyToken(),this.tokens.appendCode(`: Symbol("${r}")`)}else n?(this.tokens.copyToken(),this.tokens.replaceTokenTrimmingLeftWhitespace(":"),this.tokens.copyToken()):this.tokens.replaceToken(`"${this.tokens.identifierName()}"`)}};Rp.default=$p});var Dw=Ce(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});function pP(e){return e&&e.__esModule?e:{default:e}}function mP(e){let t,n=e[0],r=1;for(;r<e.length;){let o=e[r],s=e[r+1];if(r+=2,(o==="optionalAccess"||o==="optionalCall")&&n==null)return;o==="access"||o==="optionalAccess"?(t=n,n=s(n)):(o==="call"||o==="optionalCall")&&(n=s((...i)=>n.call(t,...i)),t=void 0)}return n}var Er=tt(),fP=Hn(),hP=pP(fP),Il="jest",gP=["mock","unmock","enableAutomock","disableAutomock"],Cp=class e extends hP.default{__init(){this.hoistedFunctionNames=[]}constructor(t,n,r,o){super(),this.rootTransformer=t,this.tokens=n,this.nameManager=r,this.importProcessor=o,e.prototype.__init.call(this)}process(){return this.tokens.currentToken().scopeDepth===0&&this.tokens.matches4(Er.TokenType.name,Er.TokenType.dot,Er.TokenType.name,Er.TokenType.parenL)&&this.tokens.identifierName()===Il?mP([this,"access",t=>t.importProcessor,"optionalAccess",t=>t.getGlobalNames,"call",t=>t(),"optionalAccess",t=>t.has,"call",t=>t(Il)])?!1:this.extractHoistedCalls():!1}getHoistedCode(){return this.hoistedFunctionNames.length>0?this.hoistedFunctionNames.map(t=>`${t}();`).join(""):""}extractHoistedCalls(){this.tokens.removeToken();let t=!1;for(;this.tokens.matches3(Er.TokenType.dot,Er.TokenType.name,Er.TokenType.parenL);){let n=this.tokens.identifierNameAtIndex(this.tokens.currentIndex()+1);if(gP.includes(n)){let o=this.nameManager.claimFreeName("__jestHoist");this.hoistedFunctionNames.push(o),this.tokens.replaceToken(`function ${o}(){${Il}.`),this.tokens.copyToken(),this.tokens.copyToken(),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(Er.TokenType.parenR),this.tokens.appendCode(";}"),t=!1}else t?this.tokens.copyToken():this.tokens.replaceToken(`${Il}.`),this.tokens.copyToken(),this.tokens.copyToken(),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(Er.TokenType.parenR),t=!0}return!0}};Ep.default=Cp});var jw=Ce(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});function bP(e){return e&&e.__esModule?e:{default:e}}var yP=tt(),wP=Hn(),kP=bP(wP),Ap=class extends kP.default{constructor(t){super(),this.tokens=t}process(){if(this.tokens.matches1(yP.TokenType.num)){let t=this.tokens.currentTokenCode();if(t.includes("_"))return this.tokens.replaceToken(t.replace(/_/g,"")),!0}return!1}};Ip.default=Ap});var qw=Ce(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});function _P(e){return e&&e.__esModule?e:{default:e}}var Bw=tt(),vP=Hn(),TP=_P(vP),Mp=class extends TP.default{constructor(t,n){super(),this.tokens=t,this.nameManager=n}process(){return this.tokens.matches2(Bw.TokenType._catch,Bw.TokenType.braceL)?(this.tokens.copyToken(),this.tokens.appendCode(` (${this.nameManager.claimFreeName("e")})`),!0):!1}};Pp.default=Mp});var Uw=Ce(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});function xP(e){return e&&e.__esModule?e:{default:e}}var kn=tt(),SP=Hn(),$P=xP(SP),Fp=class extends $P.default{constructor(t,n){super(),this.tokens=t,this.nameManager=n}process(){if(this.tokens.matches1(kn.TokenType.nullishCoalescing)){let r=this.tokens.currentToken();return this.tokens.tokens[r.nullishStartIndex].isAsyncOperation?this.tokens.replaceTokenTrimmingLeftWhitespace(", async () => ("):this.tokens.replaceTokenTrimmingLeftWhitespace(", () => ("),!0}if(this.tokens.matches1(kn.TokenType._delete)&&this.tokens.tokenAtRelativeIndex(1).isOptionalChainStart)return this.tokens.removeInitialToken(),!0;let n=this.tokens.currentToken().subscriptStartIndex;if(n!=null&&this.tokens.tokens[n].isOptionalChainStart&&this.tokens.tokenAtRelativeIndex(-1).type!==kn.TokenType._super){let r=this.nameManager.claimFreeName("_"),o;if(n>0&&this.tokens.matches1AtIndex(n-1,kn.TokenType._delete)&&this.isLastSubscriptInChain()?o=`${r} => delete ${r}`:o=`${r} => ${r}`,this.tokens.tokens[n].isAsyncOperation&&(o=`async ${o}`),this.tokens.matches2(kn.TokenType.questionDot,kn.TokenType.parenL)||this.tokens.matches2(kn.TokenType.questionDot,kn.TokenType.lessThan))this.justSkippedSuper()&&this.tokens.appendCode(".bind(this)"),this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'optionalCall', ${o}`);else if(this.tokens.matches2(kn.TokenType.questionDot,kn.TokenType.bracketL))this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'optionalAccess', ${o}`);else if(this.tokens.matches1(kn.TokenType.questionDot))this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'optionalAccess', ${o}.`);else if(this.tokens.matches1(kn.TokenType.dot))this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'access', ${o}.`);else if(this.tokens.matches1(kn.TokenType.bracketL))this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'access', ${o}[`);else if(this.tokens.matches1(kn.TokenType.parenL))this.justSkippedSuper()&&this.tokens.appendCode(".bind(this)"),this.tokens.replaceTokenTrimmingLeftWhitespace(`, 'call', ${o}(`);else throw new Error("Unexpected subscript operator in optional chain.");return!0}return!1}isLastSubscriptInChain(){let t=0;for(let n=this.tokens.currentIndex()+1;;n++){if(n>=this.tokens.tokens.length)throw new Error("Reached the end of the code while finding the end of the access chain.");if(this.tokens.tokens[n].isOptionalChainStart?t++:this.tokens.tokens[n].isOptionalChainEnd&&t--,t<0)return!0;if(t===0&&this.tokens.tokens[n].subscriptStartIndex!=null)return!1}}justSkippedSuper(){let t=0,n=this.tokens.currentIndex()-1;for(;;){if(n<0)throw new Error("Reached the start of the code while finding the start of the access chain.");if(this.tokens.tokens[n].isOptionalChainStart?t--:this.tokens.tokens[n].isOptionalChainEnd&&t++,t<0)return!1;if(t===0&&this.tokens.tokens[n].subscriptStartIndex!=null)return this.tokens.tokens[n-1].type===kn.TokenType._super;n--}}};Op.default=Fp});var Ww=Ce(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});function RP(e){return e&&e.__esModule?e:{default:e}}var Hw=Yt(),on=tt(),CP=Hn(),EP=RP(CP),Lp=class extends EP.default{constructor(t,n,r,o){super(),this.rootTransformer=t,this.tokens=n,this.importProcessor=r,this.options=o}process(){let t=this.tokens.currentIndex();if(this.tokens.identifierName()==="createReactClass"){let n=this.importProcessor&&this.importProcessor.getIdentifierReplacement("createReactClass");return n?this.tokens.replaceToken(`(0, ${n})`):this.tokens.copyToken(),this.tryProcessCreateClassCall(t),!0}if(this.tokens.matches3(on.TokenType.name,on.TokenType.dot,on.TokenType.name)&&this.tokens.identifierName()==="React"&&this.tokens.identifierNameAtIndex(this.tokens.currentIndex()+2)==="createClass"){let n=this.importProcessor&&this.importProcessor.getIdentifierReplacement("React")||"React";return n?(this.tokens.replaceToken(n),this.tokens.copyToken(),this.tokens.copyToken()):(this.tokens.copyToken(),this.tokens.copyToken(),this.tokens.copyToken()),this.tryProcessCreateClassCall(t),!0}return!1}tryProcessCreateClassCall(t){let n=this.findDisplayName(t);n&&this.classNeedsDisplayName()&&(this.tokens.copyExpectedToken(on.TokenType.parenL),this.tokens.copyExpectedToken(on.TokenType.braceL),this.tokens.appendCode(`displayName: '${n}',`),this.rootTransformer.processBalancedCode(),this.tokens.copyExpectedToken(on.TokenType.braceR),this.tokens.copyExpectedToken(on.TokenType.parenR))}findDisplayName(t){return t<2?null:this.tokens.matches2AtIndex(t-2,on.TokenType.name,on.TokenType.eq)?this.tokens.identifierNameAtIndex(t-2):t>=2&&this.tokens.tokens[t-2].identifierRole===Hw.IdentifierRole.ObjectKey?this.tokens.identifierNameAtIndex(t-2):this.tokens.matches2AtIndex(t-2,on.TokenType._export,on.TokenType._default)?this.getDisplayNameFromFilename():null}getDisplayNameFromFilename(){let n=(this.options.filePath||"unknown").split("/"),r=n[n.length-1],o=r.lastIndexOf("."),s=o===-1?r:r.slice(0,o);return s==="index"&&n[n.length-2]?n[n.length-2]:s}classNeedsDisplayName(){let t=this.tokens.currentIndex();if(!this.tokens.matches2(on.TokenType.parenL,on.TokenType.braceL))return!1;let n=t+1,r=this.tokens.tokens[n].contextId;if(r==null)throw new Error("Expected non-null context ID on object open-brace.");for(;t<this.tokens.tokens.length;t++){let o=this.tokens.tokens[t];if(o.type===on.TokenType.braceR&&o.contextId===r){t++;break}if(this.tokens.identifierNameAtIndex(t)==="displayName"&&this.tokens.tokens[t].identifierRole===Hw.IdentifierRole.ObjectKey&&o.contextId===r)return!1}if(t===this.tokens.tokens.length)throw new Error("Unexpected end of input when processing React class.");return this.tokens.matches1AtIndex(t,on.TokenType.parenR)||this.tokens.matches2AtIndex(t,on.TokenType.comma,on.TokenType.parenR)}};Np.default=Lp});var Gw=Ce(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});function AP(e){return e&&e.__esModule?e:{default:e}}var zw=Yt(),IP=Hn(),MP=AP(IP),Dp=class e extends MP.default{__init(){this.extractedDefaultExportName=null}constructor(t,n){super(),this.tokens=t,this.filePath=n,e.prototype.__init.call(this)}setExtractedDefaultExportName(t){this.extractedDefaultExportName=t}getPrefixCode(){return`
|
|
121
|
-
(function () {
|
|
122
|
-
var enterModule = require('react-hot-loader').enterModule;
|
|
123
|
-
enterModule && enterModule(module);
|
|
124
|
-
})();`.replace(/\s+/g," ").trim()}getSuffixCode(){let t=new Set;for(let r of this.tokens.tokens)!r.isType&&zw.isTopLevelDeclaration.call(void 0,r)&&r.identifierRole!==zw.IdentifierRole.ImportDeclaration&&t.add(this.tokens.identifierNameForToken(r));let n=Array.from(t).map(r=>({variableName:r,uniqueLocalName:r}));return this.extractedDefaultExportName&&n.push({variableName:this.extractedDefaultExportName,uniqueLocalName:"default"}),`
|
|
125
|
-
;(function () {
|
|
126
|
-
var reactHotLoader = require('react-hot-loader').default;
|
|
127
|
-
var leaveModule = require('react-hot-loader').leaveModule;
|
|
128
|
-
if (!reactHotLoader) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
${n.map(({variableName:r,uniqueLocalName:o})=>` reactHotLoader.register(${r}, "${o}", ${JSON.stringify(this.filePath||"")});`).join(`
|
|
132
|
-
`)}
|
|
133
|
-
leaveModule(module);
|
|
134
|
-
})();`}process(){return!1}};jp.default=Dp});var Vw=Ce(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});var Kw=ls(),PP=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","implements","interface","let","package","private","protected","public","static","await","false","null","true"]);function FP(e){if(e.length===0||!Kw.IS_IDENTIFIER_START[e.charCodeAt(0)])return!1;for(let t=1;t<e.length;t++)if(!Kw.IS_IDENTIFIER_CHAR[e.charCodeAt(t)])return!1;return!PP.has(e)}Bp.default=FP});var Qw=Ce(Up=>{"use strict";Object.defineProperty(Up,"__esModule",{value:!0});function Xw(e){return e&&e.__esModule?e:{default:e}}var kt=tt(),OP=Vw(),Jw=Xw(OP),LP=Hn(),NP=Xw(LP),qp=class extends NP.default{constructor(t,n,r){super(),this.rootTransformer=t,this.tokens=n,this.isImportsTransformEnabled=r}process(){return this.rootTransformer.processPossibleArrowParamEnd()||this.rootTransformer.processPossibleAsyncArrowWithTypeParams()||this.rootTransformer.processPossibleTypeRange()?!0:this.tokens.matches1(kt.TokenType._public)||this.tokens.matches1(kt.TokenType._protected)||this.tokens.matches1(kt.TokenType._private)||this.tokens.matches1(kt.TokenType._abstract)||this.tokens.matches1(kt.TokenType._readonly)||this.tokens.matches1(kt.TokenType._override)||this.tokens.matches1(kt.TokenType.nonNullAssertion)?(this.tokens.removeInitialToken(),!0):this.tokens.matches1(kt.TokenType._enum)||this.tokens.matches2(kt.TokenType._const,kt.TokenType._enum)?(this.processEnum(),!0):this.tokens.matches2(kt.TokenType._export,kt.TokenType._enum)||this.tokens.matches3(kt.TokenType._export,kt.TokenType._const,kt.TokenType._enum)?(this.processEnum(!0),!0):!1}processEnum(t=!1){for(this.tokens.removeInitialToken();this.tokens.matches1(kt.TokenType._const)||this.tokens.matches1(kt.TokenType._enum);)this.tokens.removeToken();let n=this.tokens.identifierName();this.tokens.removeToken(),t&&!this.isImportsTransformEnabled&&this.tokens.appendCode("export "),this.tokens.appendCode(`var ${n}; (function (${n})`),this.tokens.copyExpectedToken(kt.TokenType.braceL),this.processEnumBody(n),this.tokens.copyExpectedToken(kt.TokenType.braceR),t&&this.isImportsTransformEnabled?this.tokens.appendCode(`)(${n} || (exports.${n} = ${n} = {}));`):this.tokens.appendCode(`)(${n} || (${n} = {}));`)}processEnumBody(t){let n=null;for(;!this.tokens.matches1(kt.TokenType.braceR);){let{nameStringCode:r,variableName:o}=this.extractEnumKeyInfo(this.tokens.currentToken());this.tokens.removeInitialToken(),this.tokens.matches3(kt.TokenType.eq,kt.TokenType.string,kt.TokenType.comma)||this.tokens.matches3(kt.TokenType.eq,kt.TokenType.string,kt.TokenType.braceR)?this.processStringLiteralEnumMember(t,r,o):this.tokens.matches1(kt.TokenType.eq)?this.processExplicitValueEnumMember(t,r,o):this.processImplicitValueEnumMember(t,r,o,n),this.tokens.matches1(kt.TokenType.comma)&&this.tokens.removeToken(),o!=null?n=o:n=`${t}[${r}]`}}extractEnumKeyInfo(t){if(t.type===kt.TokenType.name){let n=this.tokens.identifierNameForToken(t);return{nameStringCode:`"${n}"`,variableName:Jw.default.call(void 0,n)?n:null}}else if(t.type===kt.TokenType.string){let n=this.tokens.stringValueForToken(t);return{nameStringCode:this.tokens.code.slice(t.start,t.end),variableName:Jw.default.call(void 0,n)?n:null}}else throw new Error("Expected name or string at beginning of enum element.")}processStringLiteralEnumMember(t,n,r){r!=null?(this.tokens.appendCode(`const ${r}`),this.tokens.copyToken(),this.tokens.copyToken(),this.tokens.appendCode(`; ${t}[${n}] = ${r};`)):(this.tokens.appendCode(`${t}[${n}]`),this.tokens.copyToken(),this.tokens.copyToken(),this.tokens.appendCode(";"))}processExplicitValueEnumMember(t,n,r){let o=this.tokens.currentToken().rhsEndIndex;if(o==null)throw new Error("Expected rhsEndIndex on enum assign.");if(r!=null){for(this.tokens.appendCode(`const ${r}`),this.tokens.copyToken();this.tokens.currentIndex()<o;)this.rootTransformer.processToken();this.tokens.appendCode(`; ${t}[${t}[${n}] = ${r}] = ${n};`)}else{for(this.tokens.appendCode(`${t}[${t}[${n}]`),this.tokens.copyToken();this.tokens.currentIndex()<o;)this.rootTransformer.processToken();this.tokens.appendCode(`] = ${n};`)}}processImplicitValueEnumMember(t,n,r,o){let s=o!=null?`${o} + 1`:"0";r!=null&&(this.tokens.appendCode(`const ${r} = ${s}; `),s=r),this.tokens.appendCode(`${t}[${t}[${n}] = ${s}] = ${n};`)}};Up.default=qp});var Yw=Ce(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});function Kn(e){return e&&e.__esModule?e:{default:e}}var DP=nn(),Ut=tt(),jP=Rw(),BP=Kn(jP),qP=Mw(),UP=Kn(qP),HP=Ow(),WP=Kn(HP),zP=Nw(),GP=Kn(zP),KP=Dw(),VP=Kn(KP),JP=Gu(),XP=Kn(JP),QP=jw(),YP=Kn(QP),ZP=qw(),e2=Kn(ZP),t2=Uw(),n2=Kn(t2),r2=Ww(),o2=Kn(r2),s2=Gw(),i2=Kn(s2),a2=Qw(),l2=Kn(a2),Hp=class e{__init(){this.transformers=[]}__init2(){this.generatedVariables=[]}constructor(t,n,r,o){e.prototype.__init.call(this),e.prototype.__init2.call(this),this.nameManager=t.nameManager,this.helperManager=t.helperManager;let{tokenProcessor:s,importProcessor:i}=t;this.tokens=s,this.isImportsTransformEnabled=n.includes("imports"),this.isReactHotLoaderTransformEnabled=n.includes("react-hot-loader"),this.disableESTransforms=!!o.disableESTransforms,o.disableESTransforms||(this.transformers.push(new n2.default(s,this.nameManager)),this.transformers.push(new YP.default(s)),this.transformers.push(new e2.default(s,this.nameManager))),n.includes("jsx")&&(o.jsxRuntime!=="preserve"&&this.transformers.push(new XP.default(this,s,i,this.nameManager,o)),this.transformers.push(new o2.default(this,s,i,o)));let a=null;if(n.includes("react-hot-loader")){if(!o.filePath)throw new Error("filePath is required when using the react-hot-loader transform.");a=new i2.default(s,o.filePath),this.transformers.push(a)}if(n.includes("imports")){if(i===null)throw new Error("Expected non-null importProcessor with imports transform enabled.");this.transformers.push(new UP.default(this,s,i,this.nameManager,this.helperManager,a,r,!!o.enableLegacyTypeScriptModuleInterop,n.includes("typescript"),n.includes("flow"),!!o.preserveDynamicImport,!!o.keepUnusedImports))}else this.transformers.push(new WP.default(s,this.nameManager,this.helperManager,a,n.includes("typescript"),n.includes("flow"),!!o.keepUnusedImports,o));n.includes("flow")&&this.transformers.push(new GP.default(this,s,n.includes("imports"))),n.includes("typescript")&&this.transformers.push(new l2.default(this,s,n.includes("imports"))),n.includes("jest")&&this.transformers.push(new VP.default(this,s,this.nameManager,i))}transform(){this.tokens.reset(),this.processBalancedCode();let n=this.isImportsTransformEnabled?'"use strict";':"";for(let i of this.transformers)n+=i.getPrefixCode();n+=this.helperManager.emitHelpers(),n+=this.generatedVariables.map(i=>` var ${i};`).join("");for(let i of this.transformers)n+=i.getHoistedCode();let r="";for(let i of this.transformers)r+=i.getSuffixCode();let o=this.tokens.finish(),{code:s}=o;if(s.startsWith("#!")){let i=s.indexOf(`
|
|
135
|
-
`);return i===-1&&(i=s.length,s+=`
|
|
136
|
-
`),{code:s.slice(0,i+1)+n+s.slice(i+1)+r,mappings:this.shiftMappings(o.mappings,n.length)}}else return{code:n+s+r,mappings:this.shiftMappings(o.mappings,n.length)}}processBalancedCode(){let t=0,n=0;for(;!this.tokens.isAtEnd();){if(this.tokens.matches1(Ut.TokenType.braceL)||this.tokens.matches1(Ut.TokenType.dollarBraceL))t++;else if(this.tokens.matches1(Ut.TokenType.braceR)){if(t===0)return;t--}if(this.tokens.matches1(Ut.TokenType.parenL))n++;else if(this.tokens.matches1(Ut.TokenType.parenR)){if(n===0)return;n--}this.processToken()}}processToken(){if(this.tokens.matches1(Ut.TokenType._class)){this.processClass();return}for(let t of this.transformers)if(t.process())return;this.tokens.copyToken()}processNamedClass(){if(!this.tokens.matches2(Ut.TokenType._class,Ut.TokenType.name))throw new Error("Expected identifier for exported class name.");let t=this.tokens.identifierNameAtIndex(this.tokens.currentIndex()+1);return this.processClass(),t}processClass(){let t=BP.default.call(void 0,this,this.tokens,this.nameManager,this.disableESTransforms),n=(t.headerInfo.isExpression||!t.headerInfo.className)&&t.staticInitializerNames.length+t.instanceInitializerNames.length>0,r=t.headerInfo.className;n&&(r=this.nameManager.claimFreeName("_class"),this.generatedVariables.push(r),this.tokens.appendCode(` (${r} =`));let s=this.tokens.currentToken().contextId;if(s==null)throw new Error("Expected class to have a context ID.");for(this.tokens.copyExpectedToken(Ut.TokenType._class);!this.tokens.matchesContextIdAndLabel(Ut.TokenType.braceL,s);)this.processToken();this.processClassBody(t,r);let i=t.staticInitializerNames.map(a=>`${r}.${a}()`);n?this.tokens.appendCode(`, ${i.map(a=>`${a}, `).join("")}${r})`):t.staticInitializerNames.length>0&&this.tokens.appendCode(` ${i.map(a=>`${a};`).join(" ")}`)}processClassBody(t,n){let{headerInfo:r,constructorInsertPos:o,constructorInitializerStatements:s,fields:i,instanceInitializerNames:a,rangesToRemove:l}=t,c=0,u=0,p=this.tokens.currentToken().contextId;if(p==null)throw new Error("Expected non-null context ID on class.");this.tokens.copyExpectedToken(Ut.TokenType.braceL),this.isReactHotLoaderTransformEnabled&&this.tokens.appendCode("__reactstandin__regenerateByEval(key, code) {this[key] = eval(code);}");let d=s.length+a.length>0;if(o===null&&d){let m=this.makeConstructorInitCode(s,a,n);if(r.hasSuperclass){let h=this.nameManager.claimFreeName("args");this.tokens.appendCode(`constructor(...${h}) { super(...${h}); ${m}; }`)}else this.tokens.appendCode(`constructor() { ${m}; }`)}for(;!this.tokens.matchesContextIdAndLabel(Ut.TokenType.braceR,p);)if(c<i.length&&this.tokens.currentIndex()===i[c].start){let m=!1;for(this.tokens.matches1(Ut.TokenType.bracketL)?this.tokens.copyTokenWithPrefix(`${i[c].initializerName}() {this`):this.tokens.matches1(Ut.TokenType.string)||this.tokens.matches1(Ut.TokenType.num)?(this.tokens.copyTokenWithPrefix(`${i[c].initializerName}() {this[`),m=!0):this.tokens.copyTokenWithPrefix(`${i[c].initializerName}() {this.`);this.tokens.currentIndex()<i[c].end;)m&&this.tokens.currentIndex()===i[c].equalsIndex&&this.tokens.appendCode("]"),this.processToken();this.tokens.appendCode("}"),c++}else if(u<l.length&&this.tokens.currentIndex()>=l[u].start){for(this.tokens.currentIndex()<l[u].end&&this.tokens.removeInitialToken();this.tokens.currentIndex()<l[u].end;)this.tokens.removeToken();u++}else this.tokens.currentIndex()===o?(this.tokens.copyToken(),d&&this.tokens.appendCode(`;${this.makeConstructorInitCode(s,a,n)};`),this.processToken()):this.processToken();this.tokens.copyExpectedToken(Ut.TokenType.braceR)}makeConstructorInitCode(t,n,r){return[...t,...n.map(o=>`${r}.prototype.${o}.call(this)`)].join(";")}processPossibleArrowParamEnd(){if(this.tokens.matches2(Ut.TokenType.parenR,Ut.TokenType.colon)&&this.tokens.tokenAtRelativeIndex(1).isType){let t=this.tokens.currentIndex()+1;for(;this.tokens.tokens[t].isType;)t++;if(this.tokens.matches1AtIndex(t,Ut.TokenType.arrow)){for(this.tokens.removeInitialToken();this.tokens.currentIndex()<t;)this.tokens.removeToken();return this.tokens.replaceTokenTrimmingLeftWhitespace(") =>"),!0}}return!1}processPossibleAsyncArrowWithTypeParams(){if(!this.tokens.matchesContextual(DP.ContextualKeyword._async)&&!this.tokens.matches1(Ut.TokenType._async))return!1;let t=this.tokens.tokenAtRelativeIndex(1);if(t.type!==Ut.TokenType.lessThan||!t.isType)return!1;let n=this.tokens.currentIndex()+1;for(;this.tokens.tokens[n].isType;)n++;if(this.tokens.matches1AtIndex(n,Ut.TokenType.parenL)){for(this.tokens.replaceToken("async ("),this.tokens.removeInitialToken();this.tokens.currentIndex()<n;)this.tokens.removeToken();return this.tokens.removeToken(),this.processBalancedCode(),this.processToken(),!0}return!1}processPossibleTypeRange(){if(this.tokens.currentToken().isType){for(this.tokens.removeInitialToken();this.tokens.currentToken().isType;)this.tokens.removeToken();return!0}return!1}shiftMappings(t,n){for(let r=0;r<t.length;r++){let o=t[r];o!==void 0&&(t[r]=o+n)}return t}};Wp.default=Hp});var tk=Ce(Mi=>{"use strict";Mi.__esModule=!0;Mi.LinesAndColumns=void 0;var Ml=`
|
|
137
|
-
`,Zw="\r",ek=(function(){function e(t){this.string=t;for(var n=[0],r=0;r<t.length;)switch(t[r]){case Ml:r+=Ml.length,n.push(r);break;case Zw:r+=Zw.length,t[r]===Ml&&(r+=Ml.length),n.push(r);break;default:r++;break}this.offsets=n}return e.prototype.locationForIndex=function(t){if(t<0||t>this.string.length)return null;for(var n=0,r=this.offsets;r[n+1]<=t;)n++;var o=t-r[n];return{line:n,column:o}},e.prototype.indexForLocation=function(t){var n=t.line,r=t.column;return n<0||n>=this.offsets.length||r<0||r>this.lengthOfLine(n)?null:this.offsets[n]+r},e.prototype.lengthOfLine=function(t){var n=this.offsets[t],r=t===this.offsets.length-1?this.string.length:this.offsets[t+1];return r-n},e})();Mi.LinesAndColumns=ek;Mi.default=ek});var nk=Ce(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});function c2(e){return e&&e.__esModule?e:{default:e}}var u2=tk(),d2=c2(u2),p2=tt();function m2(e,t){if(t.length===0)return"";let n=Object.keys(t[0]).filter(d=>d!=="type"&&d!=="value"&&d!=="start"&&d!=="end"&&d!=="loc"),r=Object.keys(t[0].type).filter(d=>d!=="label"&&d!=="keyword"),o=["Location","Label","Raw",...n,...r],s=new d2.default(e),i=[o,...t.map(l)],a=o.map(()=>0);for(let d of i)for(let m=0;m<d.length;m++)a[m]=Math.max(a[m],d[m].length);return i.map(d=>d.map((m,h)=>m.padEnd(a[h])).join(" ")).join(`
|
|
138
|
-
`);function l(d){let m=e.slice(d.start,d.end);return[u(d.start,d.end),p2.formatTokenType.call(void 0,d.type),f2(String(m),14),...n.map(h=>c(d[h],h)),...r.map(h=>c(d.type[h],h))]}function c(d,m){return d===!0?m:d===!1||d===null?"":String(d)}function u(d,m){return`${p(d)}-${p(m)}`}function p(d){let m=s.locationForIndex(d);return m?`${m.line+1}:${m.column+1}`:"Unknown"}}zp.default=m2;function f2(e,t){return e.length>t?`${e.slice(0,t-3)}...`:e}});var rk=Ce(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});function h2(e){return e&&e.__esModule?e:{default:e}}var Rn=tt(),g2=di(),b2=h2(g2);function y2(e){let t=new Set;for(let n=0;n<e.tokens.length;n++)e.matches1AtIndex(n,Rn.TokenType._import)&&!e.matches3AtIndex(n,Rn.TokenType._import,Rn.TokenType.name,Rn.TokenType.eq)&&w2(e,n,t);return t}Gp.default=y2;function w2(e,t,n){t++,!e.matches1AtIndex(t,Rn.TokenType.parenL)&&(e.matches1AtIndex(t,Rn.TokenType.name)&&(n.add(e.identifierNameAtIndex(t)),t++,e.matches1AtIndex(t,Rn.TokenType.comma)&&t++),e.matches1AtIndex(t,Rn.TokenType.star)&&(t+=2,n.add(e.identifierNameAtIndex(t)),t++),e.matches1AtIndex(t,Rn.TokenType.braceL)&&(t++,k2(e,t,n)))}function k2(e,t,n){for(;;){if(e.matches1AtIndex(t,Rn.TokenType.braceR))return;let r=b2.default.call(void 0,e,t);if(t=r.endIndex,r.isType||n.add(r.rightName),e.matches2AtIndex(t,Rn.TokenType.comma,Rn.TokenType.braceR))return;if(e.matches1AtIndex(t,Rn.TokenType.braceR))return;if(e.matches1AtIndex(t,Rn.TokenType.comma))t++;else throw new Error(`Unexpected token: ${JSON.stringify(e.tokens[t])}`)}}});var ik=Ce(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});function eo(e){return e&&e.__esModule?e:{default:e}}var _2=Py(),v2=eo(_2),T2=Dy(),x2=eo(T2),S2=jy(),$2=Uy(),ok=eo($2),R2=Wy(),C2=eo(R2),E2=l0(),A2=rp(),I2=xw(),M2=eo(I2),P2=Yw(),F2=eo(P2),O2=nk(),L2=eo(O2),N2=rk(),D2=eo(N2);function j2(){return"3.35.1"}Pi.getVersion=j2;function B2(e,t){E2.validateOptions.call(void 0,t);try{let n=sk(e,t),o=new F2.default(n,t.transforms,!!t.enableLegacyBabel5ModuleInterop,t).transform(),s={code:o.code};if(t.sourceMapOptions){if(!t.filePath)throw new Error("filePath must be specified when generating a source map.");s={...s,sourceMap:x2.default.call(void 0,o,t.filePath,t.sourceMapOptions,e,n.tokenProcessor.tokens)}}return s}catch(n){throw t.filePath&&(n.message=`Error transforming ${t.filePath}: ${n.message}`),n}}Pi.transform=B2;function q2(e,t){let n=sk(e,t).tokenProcessor.tokens;return L2.default.call(void 0,e,n)}Pi.getFormattedTokens=q2;function sk(e,t){let n=t.transforms.includes("jsx"),r=t.transforms.includes("typescript"),o=t.transforms.includes("flow"),s=t.disableESTransforms===!0,i=A2.parse.call(void 0,e,n,r,o),a=i.tokens,l=i.scopes,c=new C2.default(e,a),u=new S2.HelperManager(c),p=new M2.default(e,a,o,s,u),d=!!t.enableLegacyTypeScriptModuleInterop,m=null;return t.transforms.includes("imports")?(m=new v2.default(c,p,d,t,t.transforms.includes("typescript"),!!t.keepUnusedImports,u),m.preprocessTokens(),ok.default.call(void 0,p,l,m.getGlobalNames()),t.transforms.includes("typescript")&&!t.keepUnusedImports&&m.pruneTypeOnlyImports()):t.transforms.includes("typescript")&&!t.keepUnusedImports&&ok.default.call(void 0,p,l,D2.default.call(void 0,p)),{tokenProcessor:p,scopes:l,nameManager:c,importProcessor:m,helperManager:u}}});var vS=Xe(),To=B(vS,"jobs"),ei=new Map;function TS(){let e=new Uint8Array(4);return crypto.getRandomValues(e),"job-"+Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}async function Sa(e){try{await Ke(To),await Ve(B(To,`${e.id}.json`),JSON.stringify(e));let{result:t,...n}=e;await Ve(B(To,".current"),JSON.stringify(n))}catch{}}function ti(e,t){let n=new AbortController,r=new Date().toISOString(),o={id:TS(),verb:e,status:"running",started_at:r,updated_at:r,phase:"starting",done:0,total:0},s=0,a=t((l,c,u)=>{o.done=l,o.total=c,o.phase=u,o.updated_at=new Date().toISOString();let p=Date.now();p-s>2e3&&(s=p,Sa(o))},n.signal).then(l=>(o.status=l.isError?"failed":"done",o.result=l,o.error=l.isError?l.content[0]?.text:void 0,o.finished_at=new Date().toISOString(),Sa(o),l),l=>{o.status=n.signal.aborted?"cancelled":"failed",o.error=l instanceof Error?l.message:String(l),o.finished_at=new Date().toISOString(),Sa(o);let c={content:[{type:"text",text:`error: ${o.error}`}],isError:!0,structuredContent:{ok:!1,code:o.status==="cancelled"?"cancelled":"engine",message:o.error}};return o.result=c,c});return ei.set(o.id,{rec:o,ctrl:n,promise:a}),Sa(o),o}function lu(e){return ei.get(e)?.promise??null}async function nb(e){let t=ei.get(e);if(t)return t.rec;try{return JSON.parse(await et(B(To,`${e}.json`)))}catch{return null}}function cu(e){let t=ei.get(e);return!t||t.rec.status!=="running"?!1:(t.ctrl.abort(),!0)}async function rb(){let e=new Map;try{await Ke(To);for await(let t of Rt(To))if(t.name.endsWith(".json"))try{let n=JSON.parse(await et(B(To,t.name)));e.set(n.id,n)}catch{}}catch{}for(let t of ei.values())e.set(t.rec.id,t.rec);return[...e.values()].sort((t,n)=>n.started_at.localeCompare(t.started_at)).slice(0,50)}function uu(e){let t=e.total?` ${Math.round(100*e.done/e.total)}%`:"";return`${e.id} ${e.verb} ${e.status} \u2014 ${e.phase}${t} (started ${e.started_at}${e.finished_at?`, finished ${e.finished_at}`:""})${e.error?`
|
|
139
|
-
${e.error}`:""}`}var xS=new Set(["timeline_read","timeline_write","timeline_relink","timeline_edit","timeline_author","timeline_generate","timeline_autoconform","timeline_inspect","timeline_diff","timeline_align","session_export","host_open","host_render","host_apply","media_probe","media_consolidate","media_deliver","media_trim","media_fix","media_dcp","media_dcp_patch","media_patch","media_sync","media_cuts","gfx_make","color_match","p2p_send","delivery_fetch","project_link","qc_compare","qc_media","qc_deliverable","qc_blanking","render_gate","naming"]),SS=300,ob=/^[A-Za-z0-9_-]{1,64}$/,sb=e=>B(Xe(),"projects",e,"activity.jsonl");function $S(e,t,n){if(!xS.has(e))return null;let r=t.ops;if(e==="host_apply"&&(!r?.length||r.every(u=>u.op==="playhead"))||e==="delivery_fetch"&&t.as==="list")return null;let o=n.content.map(u=>u.text).join(`
|
|
140
|
-
`),s=o.split(`
|
|
141
|
-
`).find(u=>u.trim()&&!/^\s*(session_id|source|job_id)\s*[:=]/.test(u))??"",i=["path","out_path","out_dir","from"].map(u=>t[u]).find(u=>typeof u=="string"&&u.includes("/")&&u.length<1024),a=i&&!s.includes(ie(i))?` (${ie(i)})`:"",l=s.replace(/^error\s*/i,"").trim();for(let u of["path","out_path","out_dir","media_root"].map(p=>t[p]))typeof u=="string"&&u.includes("/")&&(l=l.split(`${xn(u)}/`).join(""));l=l.split(`${Nr()}/`).join("~/"),l=l.replace(/^\[\w+\]:\s*/,"").replace(/\s+as job-[0-9a-f]+/g,"").replace(/\s+—\s+(job_cancel|job_status|poll|mount it|use mount)\b.*$/,"");let c=n.structuredContent?.session_id??t.session_id??o.match(/session_id[:=]\s*([0-9a-f]{8})\b/)?.[1];return{at:new Date().toISOString(),verb:e,ok:!n.isError,line:`${l}${a}`.slice(0,SS),...typeof c=="string"?{session_id:c}:{}}}async function du(e,t,n){try{let r=$S(e,t,n);if(!r)return;let o=(await ho())?.id??Xf;if(!ob.test(o))return;await Ke(B(Xe(),"projects",o)),await Ve(sb(o),`${JSON.stringify(r)}
|
|
142
|
-
`,{append:!0})}catch{}}async function EN(e,t){if(!ob.test(e))return[];let n="";try{n=await et(sb(e))}catch{return[]}let r=[];for(let o of n.split(`
|
|
143
|
-
`))if(o)try{let s=JSON.parse(o);(!t||s.at>t)&&r.push(s)}catch{}return r}var ni=new Set;function xo(e){for(let t of ni)try{t(e)}catch{ni.delete(t)}}function RS(e){return ni.add(e),()=>ni.delete(e)}var ib=null,IN=e=>{ib={...e,at:new Date().toISOString()}},ab=()=>ib,ri=()=>ni.size;function MN(){let e=new TextEncoder,t,n;return new ReadableStream({start(r){r.enqueue(e.encode(`: hello
|
|
144
|
-
|
|
145
|
-
`)),t=RS(o=>r.enqueue(e.encode(`data: ${JSON.stringify(o)}
|
|
146
|
-
|
|
147
|
-
`))),n=setInterval(()=>{try{r.enqueue(e.encode(`: .
|
|
148
|
-
|
|
149
|
-
`))}catch{t?.(),clearInterval(n)}},2e4)},cancel(){t?.(),clearInterval(n)}})}var pu=["text","number","bool","choice","color","marker_color","file","files","folder","rename_steps","track","tracks","timeline","timelines","projects","render_preset","node","source","data"];var oi=e=>typeof e=="string"&&/^\$[A-Za-z_]/.test(e);var CS=f.object({id:f.string().regex(/^[a-z][a-z0-9_]*$/),label:f.string(),type:f.enum(pu),choices:f.array(f.tuple([f.string(),f.string()])).optional().describe("choice: [value, label] pairs"),default:f.unknown().optional(),not:f.string().optional(),optional:f.boolean().optional(),placeholder:f.string().optional(),when:f.object({input:f.string(),is:f.array(f.string())}).optional(),hidden:f.boolean().optional()}),ES=f.object({id:f.string().regex(/^[a-z][a-z0-9_]*$/),use:f.string().describe("a block: verb.<verb>, resolve.pull, resolve.apply, rows.filter, review, plan.*"),args:f.record(f.unknown()).default({}),when:f.string().optional(),label:f.string().optional(),at:f.tuple([f.number(),f.number()]).optional()}),AS=["knobs","viewer","rows","result","compare","graphics","running"],cb=f.lazy(()=>f.union([f.object({split:f.enum(["row","col"]),panes:f.array(cb).min(1),size:f.number().positive().max(1).optional()}),f.object({pane:f.enum(AS),show:f.union([f.string(),f.array(f.string())]).optional(),title:f.string().optional(),size:f.number().positive().max(1).optional()})])),si=f.object({id:f.string().regex(/^[a-z][a-z0-9_-]{0,63}$/),name:f.string().min(1),group:f.string().default("Mine"),about:f.string().default(""),aka:f.array(f.string()).optional(),app:f.boolean().optional(),part:f.boolean().optional(),legacy:f.string().optional(),host:f.enum(Qt).optional(),pinned:f.boolean().optional(),output:f.enum(["timeline"]).optional(),playbook:f.string().optional(),preview:f.boolean().optional(),inputs:f.array(CS).default([]),nodes:f.array(ES).min(1),view:cb.optional()}),$a=()=>B(Xe(),"tools"),mu=e=>B($a(),`${e}.json`);async function ns(){let e=new Map;try{for await(let o of Rt($a()))if(o.name.endsWith(".json"))try{let s=si.parse(JSON.parse(await et(B($a(),o.name))));e.set(s.id,s)}catch{}}catch{}let t=[...Ta,...Og(ss)],n=new Set(t.map(o=>o.id)),r=new Set((await rs()).hidden);return[...t.map(o=>e.has(o.id)?{...e.get(o.id),template:!1,shipped:!0}:{...si.parse(o),template:!0,shipped:!0}),...[...e.values()].filter(o=>!n.has(o.id)).map(o=>({...o,template:!1,shipped:!1}))].map(o=>({...o,hidden:r.has(o.id)}))}var IS=new Set(["rename_steps","files","tracks","timelines"]),ub=e=>Object.fromEntries(e.inputs.map(t=>[t.id,t.default??(t.type==="bool"?!1:IS.has(t.type)?[]:"")]));async function Br(e){let t=(await ns()).find(n=>n.id===e);if(!t)throw new L("not_found",`no tool '${e}' (tool action=list)`);return t}function MS(e){let t=[],n=new Set(e.inputs.map(s=>s.id)),r=(s,i,a)=>{if(oi(s))for(let l of s.split("|").map(c=>c.trim())){if(/[[\]]/.test(l)){t.push(`${i}: '${l}' indexes a list; pass the whole list, or use a block that takes one (timeline.read_many)`);continue}let c=/^\$([a-z][a-z0-9_]*)(?:\.([A-Za-z0-9_.]+))?(?:=.*|!=.*)?$/.exec(l.replace(/(!=|=).*$/,""));if(!c){t.push(`${i}: '${l}' is not a reference ($in.x, $node, $node.field)`);continue}if(c[1]==="in"){let u=(c[2]??"").split(".")[0];n.has(u)||t.push(`${i}: no input '${u}'`)}else a.has(c[1])||t.push(`${i}: '$${c[1]}' is not an earlier node`)}else Array.isArray(s)?s.forEach(l=>r(l,i,a)):s&&typeof s=="object"&&Object.values(s).forEach(l=>r(l,i,a))},o=new Set;for(let s of e.nodes)r(s.args,s.id,o),s.when&&r(s.when,s.id,o),o.add(s.id);for(let s of e.inputs)s.when&&!n.has(s.when.input)&&t.push(`input ${s.id}: shown when '${s.when.input}', which is not an input`);return t}async function fu(e,t){let n=si.safeParse(e);if(!n.success)throw new L("invalid_args",`not a tool: ${n.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`).join("; ")}`);let r=n.data,o=new Set;for(let i of r.nodes){if(o.has(i.id))throw new L("invalid_args",`two nodes are called '${i.id}'`);if(o.add(i.id),!t(i.use))throw new L("invalid_args",`node '${i.id}' uses '${i.use}', which is not a block (tool action=blocks)`)}let s=MS(r);if(s.length)throw new L("invalid_args",`the wiring is off: ${s.join("; ")}`);return await Ke($a()),await Ve(mu(r.id),JSON.stringify(r,null,2)),r}async function db(e){if(!/^[a-z][a-z0-9_-]{0,63}$/.test(e))return!1;try{await et(mu(e))}catch{return!1}return await Vt(mu(e)),!0}var Ra=f.object({hidden:f.array(f.string()).default([]),favourites:f.array(f.string()).nullable().default(null)}),pb=()=>B(Xe(),"tool-layout.json");async function rs(){try{return Ra.parse(JSON.parse(await et(pb())))}catch{return Ra.parse({})}}async function Ca(e){let t=Ra.partial().safeParse(e);if(!t.success)throw new L("invalid_args",`not a layout: ${t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join("; ")}`);let n=Ra.parse({...await rs(),...Object.fromEntries(Object.entries(t.data).filter(([,r])=>r!==void 0))});return await Ke(Xe()),await Ve(pb(),JSON.stringify(n,null,2)),n}async function Ea(e){let t=await rs();!t.favourites||t.favourites.includes(e)||await Ca({favourites:[...t.favourites,e]})}var lb=f.union([f.object({host:f.enum(Qt)}),f.object({session_id:f.string(),name:f.string().optional()}),f.object({path:f.string()})]),Aa=f.object({open:f.array(f.string()).default([]),source:lb.nullable().default(null),sources:f.record(lb).default({}),settings:f.record(f.record(f.unknown())).default({})}),mb=e=>B(Xe(),"projects",e.replace(/[^\w-]/g,"_"),"workspace.json");async function Ia(e){try{return Aa.parse(JSON.parse(await et(mb(e))))}catch{return null}}async function os(e,t){let n=Aa.safeParse(t);if(!n.success)throw new L("invalid_args",`not a workspace: ${n.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join("; ")}`);return await Ke(B(Xe(),"projects",e.replace(/[^\w-]/g,"_"))),await Ve(mb(e),JSON.stringify(n.data,null,2)),xo({type:"workspace",project:e,workspace:n.data}),n.data}var fb=1;async function hb(e,t){if(!e.length)throw new L("invalid_args","export needs the tool ids");let n=await ns(),r=e.map(s=>{let i=n.find(p=>p.id===s);if(!i)throw new L("not_found",`no tool '${s}'`);let{template:a,shipped:l,hidden:c,...u}=i;return u}),o=/\.json$/i.test(t)?t:`${t}.json`;return await Ve(o,JSON.stringify({conformtools_tools:fb,tools:r},null,2)),{path:o,tools:r.map(s=>s.id)}}async function gb(e,t){let n;try{n=JSON.parse(await et(e))}catch(i){throw new L("invalid_args",`not a recipe file: ${i.message}`)}let r=n,o=Array.isArray(r.tools)?r.tools:[n];if(typeof r.conformtools_tools=="number"&&r.conformtools_tools>fb)throw new L("invalid_args","this recipe file is from a newer conform.tools: update the app");let s=[];for(let i of o)s.push(await fu(i,t));return s}var Ma=[["open","Open"],["fixed","Fixed"],["intent","Artistic intent"],["best_available","Best available"],["wont_fix","Won't fix"],["not_issue","Not an issue"]],vt=e=>String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function bb(e,t){let n=t.filter(l=>!l.decision),r=t.filter(l=>l.decision),o=e.verdict??(n.some(l=>/fail/i.test(l.severity??""))?"FAIL":n.length?"CHECK":"PASS"),s=new Map;for(let l of n)s.set(l.kind||"finding",(s.get(l.kind||"finding")??0)+1);let i=(e.when??new Date).toISOString().replace("T"," ").slice(0,16),a=o==="PASS"?"#1f8a4c":o==="FAIL"?"#c0392b":"#b7791f";return`<!doctype html>
|
|
150
|
-
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
151
|
-
<title>QC \xB7 ${vt(e.subject)}</title>
|
|
152
|
-
<style>
|
|
153
|
-
body { font: 14px/1.45 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; color: #1b1b1b; margin: 32px; }
|
|
154
|
-
h1 { font-size: 20px; margin: 0 0 4px; } .meta { color: #666; margin-bottom: 18px; }
|
|
155
|
-
.verdict { display: inline-block; padding: 3px 10px; border-radius: 4px; color: #fff; background: ${a}; font-weight: 600; }
|
|
156
|
-
table { border-collapse: collapse; width: 100%; margin-top: 14px; } th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
|
|
157
|
-
th { font-weight: 600; background: #f6f6f6; } td.tc { font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
|
|
158
|
-
.sev-FAIL { color: #c0392b; font-weight: 600; } .sev-WARN, .sev-CHECK { color: #b7791f; }
|
|
159
|
-
.counts span { margin-right: 14px; } td.ev img { width: 192px; border-radius: 3px; display: block; } @media print { body { margin: 12mm; } }
|
|
160
|
-
</style></head><body>
|
|
161
|
-
<h1>${vt(e.subject)}</h1>
|
|
162
|
-
<div class="meta">Checked against <b>${vt(e.spec)}</b> \xB7 ${vt(i)}${e.by?` \xB7 ${vt(e.by)}`:""}</div>
|
|
163
|
-
<p><span class="verdict">${vt(o)}</span> ${n.length} finding${n.length===1?"":"s"}</p>
|
|
164
|
-
${s.size?`<p class="counts">${[...s].map(([l,c])=>`<span>${vt(l)}: <b>${c}</b></span>`).join("")}</p>`:""}
|
|
165
|
-
${e.summary?`<pre style="white-space:pre-wrap;color:#444">${vt(e.summary)}</pre>`:""}
|
|
166
|
-
${n.length?`<table><thead><tr><th>#</th><th>In</th><th>Out</th><th>Finding</th><th></th><th>Clip</th><th>Measured</th>${n.some(l=>l.evidence)?"<th>Frame</th>":""}</tr></thead><tbody>
|
|
167
|
-
${n.map((l,c)=>`<tr><td>${c+1}</td><td class="tc">${vt(l.tc)}</td><td class="tc">${vt(l.out)}</td><td>${vt(l.kind)}</td><td class="sev-${vt((l.severity??"").toUpperCase())}">${vt(l.severity)}</td><td>${vt(l.clip)}</td><td>${vt(l.detail)}</td>${n.some(u=>u.evidence)?`<td class="ev">${l.evidence?.startsWith("data:image/")?`<img alt="" src="${vt(l.evidence)}">`:""}</td>`:""}</tr>`).join(`
|
|
168
|
-
`)}
|
|
169
|
-
</tbody></table>`:"<p>Nothing found.</p>"}
|
|
170
|
-
${r.length?`<h2 style="font-size:16px;margin-top:28px">Reviewed (${r.length}, not counted)</h2>
|
|
171
|
-
<table><thead><tr><th>In</th><th>Out</th><th>Finding</th><th>Clip</th><th>Measured</th><th>Decision</th></tr></thead><tbody>
|
|
172
|
-
${r.map(l=>`<tr><td class="tc">${vt(l.tc)}</td><td class="tc">${vt(l.out)}</td><td>${vt(l.kind)}</td><td>${vt(l.clip)}</td><td>${vt(l.detail)}</td><td><b>${vt(l.decision)}</b></td></tr>`).join(`
|
|
173
|
-
`)}
|
|
174
|
-
</tbody></table>`:""}
|
|
175
|
-
<p class="meta" style="margin-top:24px">conform.tools</p>
|
|
176
|
-
</body></html>
|
|
177
|
-
`}function yb(e,t,n,r="",o=new Date){let s=o.toISOString().replace("T"," ").slice(0,16),i=t.filter(([a])=>n.some(l=>l[a]!==""&&l[a]!=null&&l[a]!==!1));return`<!doctype html>
|
|
178
|
-
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
179
|
-
<title>${vt(e)}</title>
|
|
180
|
-
<style>
|
|
181
|
-
body { font: 14px/1.45 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; color: #1b1b1b; margin: 32px; }
|
|
182
|
-
h1 { font-size: 20px; margin: 0 0 4px; } .meta { color: #666; margin-bottom: 18px; }
|
|
183
|
-
table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
|
|
184
|
-
th { font-weight: 600; background: #f6f6f6; } @media print { body { margin: 12mm; } }
|
|
185
|
-
</style></head><body>
|
|
186
|
-
<h1>${vt(e)}</h1>
|
|
187
|
-
<div class="meta">${vt(s)} \xB7 ${n.length} row${n.length===1?"":"s"}${r?` \xB7 ${vt(r)}`:""}</div>
|
|
188
|
-
${n.length?`<table><thead><tr>${i.map(([,a])=>`<th>${vt(a)}</th>`).join("")}</tr></thead><tbody>
|
|
189
|
-
${n.map(a=>`<tr>${i.map(([l])=>`<td>${vt(a[l])}</td>`).join("")}</tr>`).join(`
|
|
190
|
-
`)}
|
|
191
|
-
</tbody></table>`:"<p>Nothing.</p>"}
|
|
192
|
-
<p class="meta" style="margin-top:24px">conform.tools</p>
|
|
193
|
-
</body></html>
|
|
194
|
-
`}var wb=(e,t)=>`${e}::${t}`,hu=()=>B(Xe(),"qc-decisions.json");async function kb(){return await nt(hu())?JSON.parse(await et(hu())):{}}async function _b(e,t){return(await kb())[wb(e,t)]??{}}async function vb(e,t,n,r,o){let s=await kb(),i=wb(e,t),a={...s[i]};r==="open"?delete a[n]:a[n]={status:r,...o?{note:o}:{},at:new Date().toISOString()},s[i]=a,await Ke(Xe()),await Ve(hu(),JSON.stringify(s,null,1))}var Pa=e=>e?`${Ma.find(([t])=>t===e.status)?.[1]??e.status}${e.note?`: ${e.note}`:""}`:"";var So={soft:2,blocky:2,burn_in:3,text:1,low_resolution:2,path:2,codec:2},PS=/proxy|offline|_prx|prx_|lowres|dailies/i,FS=/H\.?264|AVC|Proxy|DNxHD\s*36|DNxHR\s*LB|\bLT\b/i,OS=4,LS=2;function xb(e,t){let n=new Map;for(let u of e)n.set(u.track,[...n.get(u.track)??[],{...u,transition:!1}]);for(let u of n.values()){u.sort((d,m)=>d.start-m.start);let p=u.filter(d=>d.mpi_id);for(let d of u)d.transition=!d.mpi_id&&p.some(m=>m.start<d.end&&m.end>d.start)}let r=[...n].sort((u,p)=>u[0]-p[0]).map(([,u])=>u),o=r.flat().filter(u=>u.transition).map(u=>[u.start,u.end]),s=u=>{for(let p of[...r].reverse())for(let d of p){if(d.start>u)break;if(d.track_enabled!==!1&&d.enabled!==!1&&!d.transition&&d.start<=u&&u<d.end)return d}},i=(u,p=0)=>o.some(([d,m])=>d-p<=u&&u<=m+p),a=new Set;for(let u of r.flat())u.track_enabled!==!1&&u.enabled!==!1&&!u.transition&&(a.add(u.start),a.add(u.end));let l=u=>u?u.id??`${u.track}:${u.start}`:null,c=[...a].sort((u,p)=>u-p).filter(u=>u>t&&l(s(u-1))!==l(s(u)));return{topmost:s,inTransition:i,edits:c}}var Fa=e=>e?{clip:e.name,track:e.track}:{clip:""};function Sb(e,t,n,r,o,s=1){let i=n.edits.filter(m=>o==null||m<o),a=new Set(i),l=e.slice(1).map(m=>r+m.pts),c=new Set(t.flatMap(m=>[m.start_frame,m.end_frame+1])),u=[],p=new Set,d=(m,h,g,y,k=n.topmost(g),b=g)=>({kind:m,severity:h,start_frame:g,end_frame:b,detail:y,...Fa(k)});for(let m of l){let h;for(let y=0;y<=s&&h==null;y++)h=a.has(m-y)?m-y:a.has(m+y)?m+y:void 0;if(h!=null){p.add(h);continue}let g=[s+1,s+2].find(y=>a.has(m-y)||a.has(m+y));n.inTransition(m,s)||u.push(g!=null?d("boundary_without_edit","error",m,`Picture cut ${g} frame(s) from the nearest edit - off-by-one conform`):d("boundary_without_edit","warn",m,"Picture cut inside the clip with no edit here - flash frame, baked-in cut, or a source with its own edit"))}for(let m of i){if(p.has(m)||Array.from({length:2*s+1},(y,k)=>m+k-s).some(y=>c.has(y)))continue;let h=n.topmost(m-1),g=n.topmost(m);n.inTransition(m,s)?u.push(d("dissolve","info",m,"Dissolve across the edit - no cut expected",g)):h?.mpi_id&&h.mpi_id===g?.mpi_id?u.push(d("edit_without_boundary","info",m,"Edit between two pieces of the same source with no visible cut (split clip)",g)):u.push(d("edit_without_boundary","warn",m,"Edit here but the picture does not change - same media or a continuous shot across the cut",g))}for(let m of t){let h=n.topmost(m.start_frame);u.push(h?d("black_without_gap","error",m.start_frame,"Black frames on the clip - missing media or a black source",h,m.end_frame):d("gap","info",m.start_frame,"Black frames where the timeline has no clip (gap)",void 0,m.end_frame))}return u}var NS=e=>{let t=/(\d+)\s*[xX×]\s*(\d+)/.exec(e??"");return t?[Number(t[1]),Number(t[2])]:[0,0]},Tb=(e,t,n)=>(e.pts??0)<=n&&(e.pts_end??e.pts??0)>=t,$b=(e,t,n)=>t.topmost(n+Math.floor((e.pts+e.pts_end)/2));function Rb(e,t,n,r,o,s){let i=t.filter(l=>l.kind==="burn_in_tc"),a=t.filter(l=>l.kind==="text_present");return e.flatMap(l=>{let c=new Set(l.flags??[]),u=$b(l,n,r),p=[];if(!u)return[];let d=0,m=(y,k)=>{d+=y,p.push(k)};c.has("soft")&&m(So.soft,"effective resolution far below the other shots (soft / upscaled)"),c.has("blocky")&&m(So.blocky,"compression blockiness"),i.some(y=>Tb(y,l.pts,l.pts_end))&&m(So.burn_in,"burn-in timecode / running counter"),a.some(y=>Tb(y,l.pts,l.pts_end))&&m(So.text,"text-like graphics in the picture");let[h,g]=NS(u?.resolution);return h&&g&&o&&s&&(h<.75*o||g<.75*s)&&m(So.low_resolution,`source is ${h}x${g} against a ${o}x${s} timeline`),u?.path&&PS.test(u.path)&&m(So.path,"offline / proxy path"),u?.codec&&FS.test(u.codec)&&m(So.codec,`offline-class codec (${u.codec})`),d<LS?[]:[{kind:"proxy_leak",severity:d>=OS?"error":"warn",start_frame:r+l.pts,end_frame:r+l.pts_end,detail:p.join("; "),...Fa(u)}]})}function Cb(e,t,n){return e.flatMap(r=>{let o=new Set(r.flags??[]),s=$b(r,t,n),i=[];if(!s)return i;let a={start_frame:n+r.pts,end_frame:n+r.pts_end,...Fa(s)};if(o.has("log_look")){let l=s?.luts??[],c=s?.nodes??0,u=(s?.labels??[]).some(d=>/color space|cst/i.test(d)),p=(r.p01??0)>=.08&&(r.p99??1)<=.7&&(r.contrast??1)<=.12;!l.length&&!u&&c<=1?i.push({...a,kind:"ungraded_shot",severity:p?"error":"warn",detail:`Looks ungraded / log (no LUT, no CST, ${c} node${c===1?"":"s"} on the clip${p?"":"; low-contrast look, verify"})`}):i.push({...a,kind:"log_despite_lut",severity:"info",detail:"Looks log despite a LUT / CST in the node graph - check the input color space"})}return i})}function Eb(e,t,n){return e.filter(r=>r.kind==="text_present").map(r=>{let o=n+(r.pts??0);return{kind:"text_in_textless",severity:"error",start_frame:o,end_frame:n+(r.pts_end??r.pts??0),detail:`Text in the picture: ${r.detail??""}`,...Fa(t.topmost(o))}})}function Ab(e,t,n,r,o,s){let i=[],a=e?.pop_pts??-1,l=(u,p,d,m=n)=>({kind:u,severity:p,start_frame:m,end_frame:m,clip:"",detail:d});if(o!=null&&a>=0&&r>0){let u=Math.round(o*r-a);Math.abs(u)>1&&i.push(l("pop_out_of_sync","warn",`Audio 2-pop is ${u>0?"+":""}${u} frame(s) from the picture pop`,n+a))}t&&(t.status==="fail"||t.status==="warn")&&i.push(l("leader_expectation",t.status==="fail"?"error":"warn",String(t.measured?.note??"").trim()||"Leader does not match the spec's expectations"));let c=u=>s?.[`expect_${u}`]!=null&&s[`expect_${u}`]!=="";return e&&!e.slate_present&&!c("slate")&&i.push(l("no_slate","warn","No slate detected in the head - the receiving side cannot identify this master from the picture alone")),i}var DS="ConformTools:blanking:error",jS="ConformTools:blanking:black",BS="ConformTools:blanking:check";function qS(e,t,n){return e*175e4*(t*n/(1920*1080))}async function Ib(e,t){let n=-1;for(let r=Date.now()+t;Date.now()<r;){if(await nt(e)){let o=(await At(e)).size;if(o>0&&o===n)return!0;n=o}await new Promise(o=>setTimeout(o,500))}return n>0}async function gu(e,t,n,r){let o=new Promise(s=>r?.addEventListener("abort",()=>s(),{once:!0}));for(;t.state==="queued"||t.state==="rendering";){if(n?.(t.percent,100,"rendering"),await Promise.race([o.then(()=>!0),new Promise(i=>setTimeout(()=>i(!1),1e3))]))return await e.renderCancel(t.job_id);t=await e.renderStatus(t.job_id)}return t}async function Mb(e,t,n,r,o,s={}){let i=[],a=await(s.status??xa)();if(a.readiness!=="ready")if(a.readiness==="unknown")i.push("Resolve's log does not say whether it loaded the renderplugin; trying anyway");else throw new Error(`renderplugin ${a.readiness}: ${a.next}`);let l=async($,U)=>{let E=await t($,U,6e4);if(!E.ok)throw new Error(`resolve: ${E.detail||E.why}`);return E};r?.(0,100,"preparing");let c=await l("renderplugin_preset",{preset_path:await Lg()});c.imported&&i.push(`imported the conform.tools render preset into this Resolve database${c.replaced?" (replaced a stale one)":""}`);let u=await l("clips",{timeline:n.timeline,...n.conform||n.textless?{conform:!0,grades:!!n.conform}:{}}),p=n.range?.in??u.start_frame,d=n.range?n.range.out-n.range.in+1:u.end_frame-u.start_frame,m=B(Xe(),"renderplugin",`${u.timeline.replace(/[^\w.-]+/g,"_")}_${Date.now()}`);await Ke(m);let h=qS(d,u.width,u.height)*1.15+5e9,g=await ea(m);if(!n.ignore_space&&g!==null&&g<h)throw await Ht(m),new Error(`not enough space for the throwaway render: about ${(h/1e9).toFixed(1)} GB needed, ${(g/1e9).toFixed(1)} GB free on the volume holding ${Xe()}. Free space, set CONFORM_MCP_HOME to a bigger volume, or pass ignore_space.`);await Ve(B(m,"qc_scan.json"),JSON.stringify({tl:u,args:{...n,ignore_space:void 0},first:p,frames:d}));let y=await e.renderStart({timeline:u.timeline,target_dir:m,name:"conform.tools",range:n.range,audio:n.audio??!0,renderplugin:n.checks?"checks"in n.checks?n.checks:{checks:n.checks}:{}});if(y=await gu(e,y,r,o),y.state!=="complete")throw await Ht(m),new Error(`the renderplugin render ${y.state}${y.error?`: ${y.error}`:""}`);r?.(100,100,"reading the report");let k=B(m,"qc_report.json");if(!await Ib(k,3e4))throw new Error("the render finished but wrote no qc_report.json: the preset is not selecting the renderplugin codec, or Resolve has not loaded the renderplugin (restart Resolve)");let{report:b,...w}=await Ob(m,u,n,p,d,i),{fps:_,blanking:v,black:R,findings:S}=w,T;if(n.markers??!0){let $=G=>He(G,_),U=(G,D="")=>{if(n.marker_scope!=="clips"||D.startsWith("conform.")||D.startsWith("leader.")||D.startsWith("audio."))return{};let te=u.clips.filter(we=>we.start<=G&&G<we.end&&we.enabled!==!1).sort((we,ge)=>ge.track-we.track)[0];return te?{clip:{track:te.track,start:te.start-u.start_frame}}:{}},E=[...v.map(G=>({frame:G.start_frame-u.start_frame,duration:G.duration_frames,color:"Red",tag:DS,name:"conform.tools blanking",...U(G.start_frame),note:`Zone: ${G.zones.join(", ")} | max ${Math.max(G.measured.bt,G.measured.bb,G.measured.bl,G.measured.br)}px | ${G.frame_count} frame(s) | frames ${G.start_frame}-${G.end_frame} @ ${$(G.start_frame)}`})),...R.map(G=>({frame:G.start_frame-u.start_frame,duration:G.duration_frames,color:"Yellow",tag:jS,name:"conform.tools black frames",...U(G.start_frame),note:`${G.frames} black frame(s) @ ${$(G.start_frame)}`})),...S.map(G=>({frame:G.start_frame-u.start_frame,duration:Math.max(1,G.end_frame-G.start_frame+1),color:G.severity==="fail"?"Red":"Cream",tag:BS,...U(G.start_frame,G.check),name:`conform.tools ${G.label}`,note:`${G.severity.toUpperCase()} ${G.detail}${G.clip?` | ${G.clip}`:""} @ ${$(G.start_frame)}`}))],z=await l("markers",{timeline:u.timeline,tag:"ConformTools:blanking",place:E,reconcile:!0});T={placed:Number(z.placed),skipped:z.skipped,resolved:Number(z.resolved??0)}}let x;for await(let $ of Rt(m))!$.isFile||$.name.startsWith("qc_")||(n.keep_render?(x??=[]).push(B(m,$.name)):await Ht(B(m,$.name)));return{...w,markers:T,...x?{render_kept:x}:{}}}async function Pb(){let e=B(Xe(),"renderplugin"),t=[];if(!await nt(e))return[];for await(let n of Rt(e)){if(!n.isDirectory)continue;let r=B(e,n.name);await nt(B(r,"qc_scan.json"))&&await nt(B(r,"qc_report.json"))&&t.push({path:r,at:Number(/_(\d+)$/.exec(n.name)?.[1]??0)})}return t.sort((n,r)=>r.at-n.at).map(n=>n.path)}async function Fb(e){let t=JSON.parse(await et(B(e,"qc_scan.json"))),{report:n,...r}=await Ob(e,t.tl,{...t.args,markers:!1},t.first,t.frames,[`reopened the scan in ${e} (no render)`]);return r}async function Ob(e,t,n,r,o,s){let i=B(e,"qc_report.json"),a=JSON.parse(await et(i)),l=a.width||t.width,c=a.height||t.height,u=a.fps_num&&a.fps_den?a.fps_num/a.fps_den:Number(t.fps)||24,p=Gh(n.strictness,n.overrides),d=a.frame_stats??[],m=Kh(d,t.clips,r,l,c,{...p,expected_aspect_ratio:n.expected_aspect}),h=d.some(E=>(E.avg_luma??0)>1.5)?1:255,g=Jh(d.filter(E=>(E.avg_luma??255)*h<p.black_threshold).map(E=>({frame:r+E.pts,avg:(E.avg_luma??0)*h})),p.gap_frames),y=(a.checks??[]).filter(E=>E.status==="fail"||E.status==="warn").map(E=>({id:E.id,label:E.label??E.id,status:E.status,ranges:E.ranges?.length??0})),k=new Set(["video.blanking","video.black_frame"]),b=(a.checks??[]).filter(E=>(E.status==="fail"||E.status==="warn")&&!k.has(E.id)).flatMap(E=>(E.ranges??[]).flatMap(z=>{let G=r+Number(z.pts??0),D=Math.max(G,r+Number(z.pts_end??z.pts??0)),te=t.clips.filter(we=>we.start<=D&&G<we.end).sort((we,ge)=>ge.track-we.track);return t.clips.length&&!te.length?[]:[{check:E.id,label:E.label??E.id,severity:z.severity||E.status,start_frame:G,end_frame:D,clip:te[0]?.name??"",detail:String(z.detail??"")}]}));if(n.conform||n.textless){let E=xb(t.clips,t.start_frame),z=a.shots??[],G=(a.checks??[]).flatMap(ge=>ge.ranges??[]),D=r+o,te={boundary_without_edit:"Cut with no edit",edit_without_boundary:"Edit with no cut",black_without_gap:"Black on a clip",proxy_leak:"Proxy leak",ungraded_shot:"Ungraded shot",text_in_textless:"Text in a textless master"},we=[...n.conform?[...Sb(z,g,E,r,D),...Rb(z,G,E,r,l,c),...Cb(z,E,r)]:[],...n.textless?Eb(G,E,r):[]].filter(ge=>ge.severity!=="info");b.push(...we.map(ge=>({check:`conform.${ge.kind}`,label:te[ge.kind]??ge.kind,severity:ge.severity==="error"?"fail":"warn",start_frame:ge.start_frame,end_frame:ge.end_frame,clip:ge.clip,detail:ge.detail})));for(let[ge,ve]of Object.entries(Object.groupBy(we,oe=>oe.kind)))y.push({id:`conform.${ge}`,label:te[ge]??ge,status:ve.some(oe=>oe.severity==="error")?"fail":"warn",ranges:ve.length})}let w,_=B(e,"qc_audio.json");if((n.audio??!0)&&await Ib(_,8e3)){let E=JSON.parse(await et(_));w={integrated_lufs:E.integrated_lufs,true_peak_dbtp:E.true_peak_dbtp,issues:E.issues?.length??0,...E.pops?.length?{pop_sec:Number(E.pops[0])}:{}}}let v=n.checks&&"checks"in n.checks?n.checks.checks:n.checks,R=Ab(a.leader,(a.checks??[]).find(E=>E.id==="video.leader"),r,u,w?.pop_sec,v?.["video.leader"]).filter(E=>E.severity!=="info");if(b.push(...R.map(E=>({check:`leader.${E.kind}`,label:E.kind==="no_slate"?"No slate":E.kind==="pop_out_of_sync"?"2-pop out of sync":"Leader",severity:E.severity==="error"?"fail":"warn",start_frame:E.start_frame,end_frame:E.end_frame,clip:"",detail:E.detail}))),n.only?.length){let E=new Set(n.only);E.has("video.blanking")||m.splice(0),E.has("video.black_frame")||g.splice(0),b.splice(0,b.length,...b.filter(z=>E.has(z.check))),y.splice(0,y.length,...y.filter(z=>E.has(z.id)))}let S=[...(a.checks??[]).flatMap(E=>(E.ranges??[]).map(z=>({id:E.id,a:r+Number(z.pts??0),b:r+Number(z.pts_end??z.pts??0),uri:z.evidence}))),...(a.shots??[]).map(E=>({id:"shot",a:r+E.pts,b:r+E.pts_end,uri:E.evidence}))].filter(E=>E.uri?.startsWith("data:image/")),T=new Map,x=async(E,z)=>{let G=S.find(D=>(!E||E.includes(D.id))&&D.a<=z&&z<=D.b);if(G){if(!T.has(G.uri)){let D=B(e,"qc_evidence",`${T.size+1}.jpg`);await Ke(B(e,"qc_evidence")),await cn(D,Uint8Array.from(atob(G.uri.slice(G.uri.indexOf(",")+1)),te=>te.charCodeAt(0))),T.set(G.uri,D)}return T.get(G.uri)}};for(let E of b){let z=E.check.startsWith("conform.")||E.check.startsWith("leader.")?["shot"]:[E.check];E.evidence=await x(z,E.start_frame)??await x(null,E.start_frame)}let $={blanking:[],black:[],black_clip:[]};for(let E of g)$.black_clip.push(t.clips.filter(z=>z.start<=E.start_frame&&E.start_frame<z.end).sort((z,G)=>G.track-z.track)[0]?.name??"");for(let E of m)$.blanking.push(await x(["video.blanking"],E.start_frame));for(let E of g)$.black.push(await x(["video.black_frame"],E.start_frame));let U=Vh(m).length;return m.length&&s.push(`${m.length} blanking finding(s) on ${U} clip(s)`),{project:t.project,timeline:t.timeline,frames:o,raster:{width:l,height:c},fps:u,strictness:p,blanking:m,black:g,checks:y,findings:b,evidence:$,audio:w,report_dir:e,notes:s,report:a}}function Lb(e){let t=o=>He(o,e.fps),n=e.blanking.length+e.black.length+e.checks.filter(o=>o.status==="fail").length,r=[`renderplugin scan of ${e.timeline}: ${n?`${n} finding(s)`:"clean"} over ${e.frames} frames (${e.raster.width}x${e.raster.height}, ${e.strictness.preset} strictness)`];for(let o of e.blanking){let s=Math.max(o.measured.bt,o.measured.bb,o.measured.bl,o.measured.br);r.push(` blanking ${t(o.start_frame)}\u2013${t(o.end_frame)} ${o.clip.name} (V${o.clip.track}) ${o.zones.join("/")} ${s}px, ${o.frame_count} frame(s)`)}for(let o of e.black)r.push(` black ${t(o.start_frame)}\u2013${t(o.end_frame)} ${o.frames} frame(s)`);for(let o of e.checks)r.push(` ${o.status.padEnd(9)} ${o.label}${o.ranges?` (${o.ranges} range(s))`:""}`);return e.audio&&r.push(` audio ${e.audio.integrated_lufs??"?"} LUFS integrated, ${e.audio.true_peak_dbtp??"?"} dBTP true peak, ${e.audio.issues} issue(s)`),e.markers&&r.push(`markers: ${e.markers.placed} placed on the timeline${e.markers.resolved?`, ${e.markers.resolved} from an earlier scan now green RESOLVED`:""}${e.markers.skipped.length?`, ${e.markers.skipped.length} refused by Resolve`:""}`),r.push(...e.notes.map(o=>`note: ${o}`),`report: ${e.report_dir}`),e.render_kept&&r.push(`render kept: ${e.render_kept.join(", ")}`),r.join(`
|
|
195
|
-
`)}import{gunzipSync as US}from"node:zlib";function Db(e,t){if(!t.tracks?.length)return;let n=e.timelines.find(r=>r.name===t.timeline)??e.timelines[0];if(n)for(let r of["video","audio"]){let o=n.tracks.filter(s=>(s.kind??"").toLowerCase()===r).sort((s,i)=>(s.track_index??0)-(i.track_index??0));for(let s of t.tracks.filter(i=>i.kind===r)){let i=o[s.index-1];i&&(typeof s.enabled=="boolean"&&(i.enabled=s.enabled),s.name&&!/^(Video|Audio) \d+$/.test(s.name)&&(i.name=s.name))}}}async function HS(){return(await lr("ps",["-axo","pid=,args="])).stdout.split(`
|
|
196
|
-
`).map(t=>t.trim()).filter(Boolean).map(t=>{let n=t.indexOf(" ");return{pid:Number(t.slice(0,n)),args:t.slice(n+1)}})}async function WS(){let e=`ObjC.import("CoreGraphics");
|
|
197
|
-
const a = $.CGWindowListCopyWindowInfo($.kCGWindowListOptionAll, 0);
|
|
198
|
-
const arr = ObjC.deepUnwrap(ObjC.castRefToObject(a)) || [];
|
|
199
|
-
JSON.stringify(arr.filter(w => w.kCGWindowName).map(w => ({ pid: w.kCGWindowOwnerPID, owner: w.kCGWindowOwnerName, title: w.kCGWindowName })));`;if(ln()!=="darwin")return[];let t=await lr("osascript",["-l","JavaScript","-e",e]);try{return JSON.parse(t.stdout.trim())}catch{return[]}}async function Oa(e){return(await lr("lsof",["-p",String(e),"-Fn"])).stdout.split(`
|
|
200
|
-
`).filter(n=>n.startsWith("n/")).map(n=>n.slice(1))}var bu=e=>new Date(e).toISOString();async function zS(e,t){let n=e.find(o=>/DaVinci Resolve\.app\/Contents\/MacOS\/Resolve(\s|$)|\\Resolve\.exe\b/.test(o.args)),r={host:"resolve",running:!!n,pid:n?.pid,notes:[]};return n?await GS(r,t):r}async function GS(e,t){let n=B(t,`resolve_current_${Date.now()}.drt`),r=await Zs("current",{},6e4),o;r.why!=="bridge"&&(o=r,r.ok&&r.timeline&&(o.exported=(await Zs("export",{out_path:n},6e4)).ok));let s=o?.db,i=s?.DbType?`the ${s.DbType==="Disk"?"local":s.DbType} project library${s.DbName?` "${s.DbName}"`:""}${s.IpAddress?` on ${s.IpAddress}`:""}`:"its project library";if(!o)return e.notes.push(`Resolve holds ${i}, and its scripting door could not be reached (${r.detail??"no answer"}). Export the timeline as a .drt from Resolve (File > Export > Timeline) and read that file.`),e;if(!o.ok){let l=o.why==="no_project"?"no project is open (only the Project Manager)":o.why==="no_connection"?"Resolve refused the local scripting connection (Preferences > System > General > External scripting using: Local)":`the Resolve scripting module is not installed (${o.detail??""})`;return e.notes.push(`Resolve holds ${i}; ${l}. Or export the timeline as a .drt from Resolve (File > Export > Timeline) and read that file.`),e}if(e.project=o.project,e.timelines=o.timelines,!o.timeline)return e.notes.push("no timeline is open in the viewer"),e;if(e.timeline=o.timeline,r.ok&&(e.tracks=r.tracks),!o.exported||!await nt(n))return e.notes.push(`Resolve holds ${i}; it named the open timeline but its .drt export failed. Export it from Resolve (File > Export > Timeline) and read that file.`),e;let a=B(t,`${Nb(o.project??"resolve")}__${Nb(o.timeline)}.drt`);return await fo(n,a),e.read={path:a,format:"drt"},e.notes.push(`project in ${i}: the timeline was exported by Resolve itself (its own .drt of the current state, including unsaved edits)`),e}async function KS(e,t){let n=e.find(u=>/Adobe Premiere Pro( \d{4})?\.app\/Contents\/MacOS\/Adobe Premiere Pro|\\Adobe Premiere Pro\.exe\b/.test(u.args)),r={host:"premiere",running:!!n,pid:n?.pid,notes:[]};if(!n)return r;let s=t.find(u=>u.pid===n.pid&&/\.prproj/i.test(u.title))?.title?.replace(/\s*\*\s*$/,"").replace(/^.*?((?:\/|[A-Za-z]:[\\/]|\\\\).*\.prproj).*$/i,"$1");if(!s){if(t.some(u=>u.pid===n.pid&&u.title))return r.notes.push("Premiere is running with no project window (home screen)."),r;if(s=await VS(),!s)return r.notes.push("Premiere's window titles are hidden from this app (macOS: give it Screen Recording in System Settings \u203A Privacy & Security) and Premiere's recent-projects list names no project."),r;r.notes.push("window titles are hidden from this app (macOS Screen Recording permission), so the project is taken from Premiere's recent-projects list: the last one it opened, not confirmed open")}if(!await nt(s))return r.notes.push(`window title names ${s} but it is not on disk`),r;r.project_path=s,r.project=ie(s).replace(/\.prproj$/i,""),r.read={path:s,format:"prproj"},await nt(s.replace(/\.prproj$/i,".prlock"))&&r.notes.push("lock file present beside the project (project locking is on)");let i=await tn(s),a=new TextDecoder().decode(i[0]===31&&i[1]===139?US(i):i),l=[...a.matchAll(/<MZ\.PrefixKey\.OpenSequenceGuidList\.(\d+)>([0-9a-f-]{36})</g)].map(u=>({idx:Number(u[1]),uid:u[2]})).sort((u,p)=>u.idx-p.idx),c=u=>{let p=a.indexOf(`<Sequence ObjectUID="${u}"`);if(p<0)return null;let d=/<Name>([^<]*)<\/Name>/.exec(a.slice(p,p+2e4));return d?d[1]:null};return r.timelines=l.map(u=>c(u.uid)).filter(u=>!!u),r.timelines.length&&(r.timeline=r.timelines[0]),r.notes.push("last saved state of the project file (Premiere has no outside door to unsaved edits; the panel has)"),r.notes.push(r.timelines.length?"sequences open in the Timeline panel at the last save, in panel order; the first is taken as the active one":"the project file records no open sequences"),r}async function VS(){let e=B(Nr(),"Documents","Adobe","Premiere Pro"),t;try{for await(let r of Rt(e))if(!(!r.isDirectory||!/^\d+\.\d+$/.test(r.name)))for await(let o of Rt(B(e,r.name))){if(!o.isDirectory||!o.name.startsWith("Profile-"))continue;let s=B(e,r.name,o.name,"Adobe Premiere Pro Prefs"),i=(await At(s).catch(()=>null))?.mtimeMs??0;i&&(!t||i>t.at)&&(t={at:i,path:s})}}catch{return}return t?/<BE\.Prefs\.MRU\.Document\.0>([^<]+\.prproj)</i.exec(await et(t.path).catch(()=>""))?.[1]:void 0}async function JS(e,t,n){let r=e.find(d=>/AvidMediaComposer\.app\/Contents\/MacOS\/AvidMediaComposer(\s|$)|\\AvidMediaComposer\.exe\b/.test(d.args)),o={host:"avid",running:!!r,pid:r?.pid,notes:[]};if(!r)return o;let s=t.find(d=>d.pid===r.pid&&/Media Composer/.test(d.title))?.title??"",i=/Media Composer[^-]*-\s*([^-]+?)\s*(?:-|$)/.exec(s)?.[1]?.trim(),a=(await Oa(r.pid)).find(d=>/\.avp$/i.test(d))??(ln()==="win32"&&i?await XS(i):void 0);if(!a)return o.notes.push(i?`project "${i}" per the window title, but ${ln()==="win32"?"its .avp is not in Media Composer's project folders":"no .avp is held open"}`:"no project open"),o.project=i,o;o.project_path=a,o.project=ie(a).replace(/\.avp$/i,"");let l=xn(a),c=[];for await(let d of Rt(l))if(d.isFile&&/\.avb$/i.test(d.name)&&!d.name.startsWith("_")){let m=await At(B(l,d.name));c.push({path:B(l,d.name),modified_at:bu(m.mtimeMs)})}c.sort((d,m)=>m.modified_at.localeCompare(d.modified_at)),o.bins=c;let u=c[0];if(n){for(let d of c.slice(0,12))if(await n(d.path,"avb")){u=d;break}}u&&(o.read={path:u.path,format:"avb"}),o.notes.push("Media Composer keeps the sequence loaded in the Timeline only in memory; bins are the saved state. The newest-modified bin holding a sequence is offered; pass another bin path to timeline_read to choose.");let p=B("/Users/Shared/AvidMediaComposer/Avid Attic",o.project,"Bins");if(await nt(p)){let d=null;for await(let m of Rt(p)){if(!m.isDirectory)continue;let h=await At(B(p,m.name));(!d||h.mtimeMs>d.m)&&(d={name:m.name,m:h.mtimeMs})}d&&o.notes.push(`Attic: last bin autosaved while open was "${d.name.replace(/\.[^.]*$/,"")}" at ${bu(d.m)}`)}return o}async function XS(e){let t=B(en("PUBLIC")??"C:\\Users\\Public","Documents","Avid Media Composer");for(let n of["Shared Avid Projects","Avid Projects"]){let r=B(t,n,e,`${e}.avp`);if(await nt(r))return r}}async function QS(e){let t=e.find(l=>/\/flame\.app\/Contents\/MacOS\/flame(\s|$)/.test(l.args)||/\/flame_\d{4}\/bin\/flame(\s|$)/.test(l.args)),n={host:"flame",running:!!t,pid:t?.pid,notes:[]};if(!t)return n;let r=/\s-J\s+(\S+)/.exec(t.args)?.[1],o=/\s-W\s+(\S+)/.exec(t.args)?.[1]??"Workspace";if(!r)return n.notes.push("Flame is running but its command line names no project (-J)"),n;n.project=r;let s=["/opt/Autodesk/project","/private/var/opt/Autodesk/flame/projects","/var/opt/Autodesk/flame/projects"],i=null;for(let l of s){let c=B(l,r,"catalog",`${o}.wksp`);if(await nt(c)){i=c;break}}if(!i)return n.notes.push(`no catalog folder for project ${r} / workspace ${o} under ${s.join(", ")}`),n;n.project_path=i;let a=null;for await(let l of Rt(i))if(l.isFile&&/^\.#workspace\.\d+\.wks$/.test(l.name)){let c=await At(B(i,l.name));(!a||c.mtimeMs>a.m)&&(a={path:B(i,l.name),m:c.mtimeMs})}return a?(n.read={path:a.path,format:"flame"},n.notes.push(`live workspace file, written by Flame at ${bu(a.m)}; holds the desktop's reels and sequences. Which sequence sits in the Timeline is not yet decoded \u2014 every sequence on the desktop is returned.`),n):(n.notes.push("no workspace file in the catalog"),n)}var YS=/(?:[\/\\]Nuke\d+\.\d+(?:v\d+)?(?:\.exe)?(?:\s.*)?\s--(?:studio|hiero)\b|(?:NukeStudio|Hiero)[^/]*\.app\/Contents\/MacOS\/)/i;async function ZS(e,t){let n=e.find(s=>YS.test(s.args)),r={host:"nuke",running:!!n,pid:n?.pid,notes:[]};if(!n)return r;let o=(await Oa(n.pid)).find(s=>/\.hrox$/i.test(s))??t.filter(s=>s.pid===n.pid).map(s=>/(\/\S.*?\.hrox)\b/i.exec(s.title)?.[1]).find(Boolean);return o&&(r.project_path=o,r.project=ie(o).replace(/\.hrox$/i,"")),r.notes.push("Nuke Studio's timelines are read through the conform.tools panel: host_export host=nuke (host_setup host=nuke installs it)"),r}async function e$(e){let t=e.find(c=>/Final Cut Pro\.app\/Contents\/MacOS\/Final Cut Pro(\s|$)/.test(c.args)),n={host:"fcp",running:!!t,pid:t?.pid,notes:[]};if(!t)return n;let r=[...new Set((await Oa(t.pid)).map(c=>/^(.*?\.fcpbundle)(\/|$)/.exec(c)?.[1]).filter(c=>!!c))];if(!r.length)return n.notes.push("Final Cut is running with no library open"),n;n.timelines=[];let o=new Map;for(let c of r)for await(let u of Rt(c))if(!(!u.isDirectory||/\.(localized)$/.test(u.name)||u.name.startsWith("_")))for await(let p of Rt(B(c,u.name)))p.isDirectory&&!/^(Original Media|Render Files|Analysis Files|Transcoded Media|Shared Items)$/.test(p.name)&&await nt(B(c,u.name,p.name,"CurrentVersion.fcpevent"))&&o.set(p.name,{library:c,event:u.name});let s=await lr("osascript",["-e",'tell application "System Events" to tell process "Final Cut Pro" to get value of every static text of group 1 of group 4 of splitter group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of window 2']),i=s.success?s.stdout.trim().split(", ").find(c=>o.has(c)):void 0;if(!i){let c=await lr("osascript",["-e",'tell application "System Events" to tell process "Final Cut Pro" to get entire contents of window 2']);for(let u of c.stdout.matchAll(/static text ([^,]+?) of group/g))if(o.has(u[1])){i=u[1];break}}let a=i?o.get(i):void 0;n.project=a?ie(a.library).replace(/\.fcpbundle$/,""):r.length===1?ie(r[0]).replace(/\.fcpbundle$/,""):void 0,n.project_path=a?.library??(r.length===1?r[0]:void 0),n.timeline=i,n.timelines=[...o.keys()],n.notes.push(`${r.length} librar${r.length===1?"y":"ies"} open: ${r.map(c=>ie(c)).join(" | ")}`),i&&a?n.notes.push(`project "${i}" is in event "${a.event}" of ${ie(a.library)}`):n.notes.push("could not read the Timeline title (no project loaded, or the accessibility layout differs)");let l=i&&a?B(a.library,a.event,i,"CurrentVersion.fcpevent"):void 0;return l&&await nt(l)?(n.read={path:l,format:"fcpevent"},n.notes.push("read from the project's own store in the library (Final Cut saves it as you edit; read from a copy, the library is never written)")):i&&n.notes.push(`no project store found for "${i}"${l?` at ${l}`:""}`),n}function t$(e){let t=e.find(r=>/\/Baselight[^/]*\.app\/Contents\/MacOS\/|\/usr\/fl\/baselight[^ ]*\/bin\/baselight\b/i.test(r.args)),n={host:"baselight",running:!!t,pid:t?.pid,notes:[]};return t&&n.notes.push("the open scene is not read here (it lives in Baselight's scene database): host_export host=baselight reads it through FLAPI"),n}async function n$(e,t){let n=e.find(s=>/Pro Tools\.app\/Contents\/MacOS\/Pro Tools(\s|$)/.test(s.args)),r={host:"protools",running:!!n,pid:n?.pid,notes:[]};if(!n)return r;let o=(await Oa(n.pid)).find(s=>/\.ptx$/i.test(s));if(r.project=t.find(s=>s.pid===n.pid&&/^Edit: /.test(s.title))?.title.slice(6).trim()||void 0,!o){let s=await new qg().current();s&&(r.project=s.project,o=s.project_path||void 0)}return!o||!await nt(o)?(r.notes.push(r.project?`session "${r.project}" has no saved .ptx found`:"no session open (or Pro Tools' scripting door did not answer)"),r):(r.project_path=o,r.project??=ie(o).replace(/\.ptx$/i,""),r.timeline=r.project,r.timelines=[r.project],r.read={path:o,format:"ptx"},r.notes.push("the session file as last saved; edits since the last save are not in it"),r)}var Nb=e=>e.replace(/[^\w.-]+/g,"_").slice(0,80);function r$(e=ln()){return e==="darwin"||e==="linux"||e==="win32"?null:`host_current is not available on ${e} yet: it reads the process table and open files (ps, lsof), which this OS does not have. Export the timeline from the host and use timeline_read.`}async function jb(e,t,n){let r=r$();if(r)throw new L("unsupported",r);let o=e?.length?e:[...Qt],s=t??await Dt("conform-host-"),i=ln()==="win32"?await Rf():null,a=i??await HS(),l=i?i.filter(u=>u.title):o.some(u=>u==="premiere"||u==="avid"||u==="protools"||u==="nuke")?await WS():[],c=[];for(let u of o)try{u==="resolve"?c.push(await zS(a,s)):u==="premiere"?c.push(await KS(a,l)):u==="avid"?c.push(await JS(a,l,n)):u==="flame"?c.push(await QS(a)):u==="baselight"?c.push(t$(a)):u==="protools"?c.push(await n$(a,l)):u==="nuke"?c.push(await ZS(a,l)):c.push(await e$(a))}catch(p){c.push({host:u,running:!0,notes:[`failed: ${p instanceof Error?p.message:String(p)}`]})}return c}function yu(e){return e.map(t=>`${t.kind[0].toUpperCase()}${t.index}${t.name&&!/^(Video|Audio|Subtitle) \d+$/.test(t.name)?` ${t.name}`:""}${t.enabled===!1?" (off)":""}${t.locked?" (locked)":""}`).join(" | ")}function Bb(e){let t=[`${e.host}: ${e.running?`running (pid ${e.pid})`:"not running"}`];e.project&&t.push(` project: ${e.project}${e.project_path?` [${e.project_path}]`:""}`),e.timeline&&t.push(` open timeline: ${e.timeline}`),e.timelines?.length&&t.push(` timelines: ${e.timelines.join(" | ")}`),e.tracks?.length&&t.push(` tracks: ${yu(e.tracks)}`),e.bins?.length&&t.push(` bins (newest first): ${e.bins.slice(0,8).map(n=>ie(n.path)).join(" | ")}${e.bins.length>8?` \u2026 +${e.bins.length-8}`:""}`),e.read&&t.push(` read as: ${e.read.format} ${e.read.path}`);for(let n of e.notes)t.push(` note: ${n}`);return t.join(`
|
|
201
|
-
`)}var Hb={"YYYY-MM-DD":e=>`${e.Y}-${e.M}-${e.D}`,YYYYMMDD:e=>`${e.Y}${e.M}${e.D}`,YYMMDD:e=>`${e.y}${e.M}${e.D}`,"YYYY-MM-DD_HHMM":e=>`${e.Y}-${e.M}-${e.D}_${e.h}${e.m}`,YYYYMMDD_HHMMSS:e=>`${e.Y}${e.M}${e.D}_${e.h}${e.m}${e.s}`,HHMMSS:e=>`${e.h}${e.m}${e.s}`};function o$(e,t){let n=r=>String(r).padStart(2,"0");return Hb[e]({Y:String(t.getFullYear()),y:n(t.getFullYear()%100),M:n(t.getMonth()+1),D:n(t.getDate()),h:n(t.getHours()),m:n(t.getMinutes()),s:n(t.getSeconds())})}var Na="[\\p{L}\\p{N}]",s$=`(?<!${Na})`,i$=`(?!${Na})`,qb=new RegExp(`${Na}+(?:'${Na}+)*`,"gu"),wu=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a$=e=>Array.from(e,t=>t==="*"?".*":t==="?"?".":wu(t)).join(""),Ub=e=>(...t)=>{let n=t.slice(0,t.findIndex(r=>typeof r=="number"));return e.replace(/[$\\](\d+)|\\\\/g,(r,o)=>o===void 0?"\\":String(n[Number(o)]??""))};function La(e,t,n=!1){try{return new RegExp(e,(t?"g":"gi")+(n?"u":""))}catch(r){throw new Error(`Invalid regex: ${r.message}`)}}var qr=e=>Array.from(e);function l$(e,t){switch(t){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();case"title":return e.replace(qb,n=>qr(n)[0].toUpperCase()+qr(n).slice(1).join("").toLowerCase());case"capitalize":return e.replace(qb,n=>qr(n)[0].toUpperCase()+qr(n).slice(1).join(""));case"sentence":{let n=e.length-e.trimStart().length,r=qr(e.slice(n));return r.length?e.slice(0,n)+r[0].toUpperCase()+r.slice(1).join("").toLowerCase():e}}throw new Error(`Unknown case mode: ${t}`)}function c$(e,t,n,r=new Date){switch(t.type){case"find_replace":{if(!t.find)return e;let o=t.regex?t.find:t.wildcard?a$(t.find):wu(t.find),s=t.whole_word?La(s$+o+i$,!!t.case_sensitive,!0):La(o,!!t.case_sensitive),i=t.replace??"";return e.replace(s,t.regex?Ub(i):()=>i)}case"regex_replace":return t.pattern?e.replace(La(t.pattern,t.case_sensitive??!0),Ub(t.replacement??"")):e;case"add_prefix":return(t.text??"")+e;case"add_suffix":return e+(t.text??"");case"insert":{if(!t.text)return e;let o=qr(e),s=Math.max(0,Math.min(t.position??0,o.length)),i=t.from_end?o.length-s:s;return o.slice(0,i).join("")+t.text+o.slice(i).join("")}case"remove_text":return t.text?e.replace(La(wu(t.text),!!t.case_sensitive),""):e;case"remove_chars":{let o=t.count??0;if(o<=0)return e;let s=qr(e),i=s.length,a=t.mode??"from_end",l;if(a==="from_start")l=s.slice(o);else if(a==="from_end")l=s.slice(0,Math.max(0,i-o));else if(a==="from_position"){let c=t.position??0,u=Math.min(c>=0?c:Math.max(0,i+c),i);l=[...s.slice(0,u),...s.slice(u+o)]}else throw new Error(`Unknown remove mode: ${a}`);if(i&&!l.length)throw new Error(`Removing ${o} character(s) would leave an empty name`);return l.join("")}case"trim_whitespace":return e.replace(/\s+/gu," ").trim();case"change_case":return l$(e,t.mode);case"substring":{let o=qr(e),s=t.start??0,i=t.length??0,a=s>=0?s:Math.max(0,o.length+s);return(i<=0?o.slice(a):o.slice(a,a+i)).join("")}case"sequential_numbering":{let o=String((t.start??1)+n*(t.increment||1)).padStart(Math.max(1,t.pad??3),"0"),s=t.separator??"_";return t.position==="prefix"?o+s+e:e+s+o}case"add_date":{let o=t.format??"YYYY-MM-DD";if(!(o in Hb))throw new Error(`Unknown date format: ${o}`);let s=t.separator??"_",i=o$(o,r);return t.position==="prefix"?i+s+e:e+s+i}}throw new Error(`Unknown rule type: ${t.type}`)}var u$=/^(.*?)([._-]?)(\d+)(\.[^.]+)$/u;function ku(e,t,n={}){let r=t.filter(i=>i.enabled!==!1),o=e.map((i,a)=>{let l=n.sequence?u$.exec(i):null;if(n.sequence&&!l)return{old:i,new:i,dupe:!1};let c=l?l[1]:i;try{for(let u of r)c=c$(c,u,a,n.now)}catch(u){return{old:i,new:i,dupe:!1,error:u.message}}return i&&!c?{old:i,new:i,dupe:!1,error:"The steps leave an empty name"}:{old:i,new:l?c+l[2]+l[3]+l[4]:c,dupe:!1}}),s=new Map;for(let i of o)s.set(i.new,(s.get(i.new)??new Set).add(i.old));for(let i of o)i.new!==i.old&&s.get(i.new).size>1&&(i.dupe=!0);return o}function Wb(e,t){let n=o=>/^(.*?)([._])(\d+)(\.[A-Za-z0-9]+)$/.exec(o),r=new Map;for(let o of e){let s=n(o);if(s){let i=`${s[1]}${s[2]}|${s[4]}`;r.set(i,Math.min(r.get(i)??1/0,Number(s[3])))}}return e.map(o=>{let s=n(o);if(!s)return o;let i=`${s[1]}${s[2]}|${s[4]}`,a=Number(s[3]),l=t.start!=null?t.start+(a-r.get(i)):a+(t.offset??0);return l<0?o:`${s[1]}${s[2]}${String(l).padStart(s[3].length,"0")}${s[4]}`})}async function zb(e,t){let n={project:e.project??"",timeline:e.timeline},r=await _b(n.project,n.timeline),o=Ch(e),s=o.rows.map(a=>{let l=r[String(a.key)];return{...a,id:t?`${n.timeline}:${a.id}`:a.id,scope:n,...l?{closed:!0}:{},cells:{...a.cells,timeline:n.timeline,decision:Pa(l)}}}),i=s.filter(a=>a.closed).length;return{rows:s,text:`${t?`${n.timeline}: `:""}${o.text}${i?`
|
|
202
|
-
${i} finding(s) reviewed earlier (not counted)`:""}`}}async function ii(e,t=new Map){return await Promise.all(e.map(async n=>{let r=String(n.cells.target_url??"");if(Number(n.cells["available_range.dur"])>0||!r)return n;t.has(r)||t.set(r,$o("media_probe",{path:r}).then(s=>{let i=s?.structuredContent?.available_range;return i?{start:i.start.value,dur:i.duration.value,rate:i.start.rate}:null},()=>null));let o=await t.get(r);return o?{...n,cells:{...n.cells,"available_range.start":o.start,"available_range.dur":o.dur,"available_range.rate":o.rate}}:n}))}async function d$(e,t=new Map){let n=await bt(e),r=n.session.media_references??[],o=r.map((a,l)=>({id:String(l),cells:{target_url:a.target_url??"","available_range.dur":a.available_range?.duration?.value??0}})),s=await ii(o,t),i=0;s.forEach((a,l)=>{let c=r[l],u=Number(a.cells["available_range.dur"]);if(u>0&&!(Number(c.available_range?.duration?.value)>0)){let p=Number(a.cells["available_range.rate"])||c.source_fps||24;c.available_range={start:{value:Number(a.cells["available_range.start"]),rate:p},duration:{value:u,rate:p}},i++}}),i&&await Xt(n,`media lengths probed for ${i} file(s)`)}async function Gb(e){return{...e,media:await ii(e.media)}}async function Be(e,t,n={}){t=p$(e,t);let r=wn(e),o=r?f.object(r.inputSchema).safeParse(t):null;o?.success&&(t=o.data);let s=await $o(e,t,{signal:n.signal,progress:n.progress}),i=s.content.map(l=>l.text).join(`
|
|
203
|
-
`);if(s.isError)throw new L(s.structuredContent?.code??"engine",i.replace(/^error \[\w+\]: /,""));let a=s.structuredContent?.session_id??i.match(/session_id[:=]\s*([0-9a-f]{8})\b/)?.[1]??t.session_id;return{...s.structuredContent??{},...a?{session_id:a}:{},ok:!0,text:i}}function p$(e,t){let n=wn(e)?.inputSchema??{},r=o=>o instanceof f.ZodOptional||o instanceof f.ZodDefault||o instanceof f.ZodNullable?r(o._def.innerType):o;return Object.fromEntries(Object.entries(t).flatMap(([o,s])=>{if(s===""||s===null||Array.isArray(s)&&!s.length)return[];let i=n[o]?r(n[o]):void 0;return typeof s=="string"&&i instanceof f.ZodNumber&&s.trim()!==""&&Number.isFinite(Number(s))?[[o,Number(s)]]:typeof s=="string"&&i instanceof f.ZodUnion&&i._def.options.some(a=>a instanceof f.ZodNumber)&&/^\d+(\.\d+)?$/.test(s)?[[o,Number(s)]]:[[o,s]]}))}var Kb=(e,t)=>Be(e,t).catch(n=>({ok:!1,text:n.message})),m$={items:"items",apply:"apply",pool:"project"};function dr(e){return Qt.filter(t=>{let n=un(t);if(n.wired===!1)return!1;if(e==="qc")return t==="resolve";if(t==="protools"&&(e==="open"||e==="render"))return!1;let r=m$[e];return!r||typeof n[r]=="function"})}var Zn={host:{type:"string",about:`the host: ${Qt.join(" | ")} (default resolve)`}},It=e=>String(e.host||"resolve"),is=new Map,f$=4e3;function h$(e,t){let n=`${e}\0${t??""}`,r=is.get(n);if(r&&Date.now()-r.at<f$)return r.live;let o=lh(Kb,t,e);return is.set(n,{at:Date.now(),live:o}),o.catch(()=>is.delete(n)),o}var Vb={clip_color:"Clip color",flags:"Flags",enabled:"Enable / disable",name:"Clip name",properties:"Properties (sizing, crop, opacity, retime)",metadata:"Media pool metadata",copy_grade:"Copy grade",copy_properties:"Copy properties",version:"Color version",color_group:"Color group",cache:"Render cache",fades:"Fades",normalize_audio:"Normalize audio",output_blanking:"Output blanking",drx:"Apply a .drx still",lut:"LUT on a node",marker_add:"Add marker",marker_update:"Change marker",marker_delete:"Delete marker",playhead:"Move the playhead",timeline_duplicate:"Duplicate the timeline",goto:"Go to",pool_rename:"Rename pool clip",pool_move:"Move pool clips",pool_delete:"Delete pool clips",pool_import:"Import into the pool",track_delete:"Delete a track",timeline_rename:"Rename timeline"};function g$(e,t){let{rows:n,...r}=t;return Array.isArray(n)?e.startsWith("pool_")?n.length?[{op:e,clips:n.map(o=>o.id),...r}]:[]:n.flatMap(o=>{let s="cells"in o?ah(o):typeof o.track=="number"?{kind:o.kind??"video",track:o.track,start:Number(o.start)}:null;if(s)return[{op:e,item:s,...r}];let i="cells"in o?Number(o.cells.frame):NaN;return Number.isFinite(i)?[{op:e,frame:i,...r}]:[]}):[{op:e,...r}]}async function b$(e,t,n,r,o){return await Be("host_render",{host:e,...t?{timeline:t}:{},...n},{signal:r.signal,progress:(i,a,l)=>r.progress?.(i,a,`${o} \xB7 ${l}`)}).catch(i=>({ok:!1,text:i.message}))}var ai={"source.file":{label:"Timeline file",group:"Sources",effect:!1,about:"Read a timeline file from any host (.drt .aaf .avb .prproj .fcpxml .xml .otio .edl, a Flame archive) into a session; `engine` local (this machine) or hosted.",params:{path:{type:"string",required:!0,about:"the timeline file"},engine:{type:"string"}},run:(e,t)=>Be("timeline_read",e,t)},"source.session":{label:"Project timeline",group:"Sources",effect:!1,about:"A timeline already in the project (a session read earlier, from Exchange, the chat, a pull).",params:{session_id:{type:"string",required:!0}},run:async e=>{let t=await bt(String(e.session_id));return{ok:!0,text:`${t.source_path.split(/[\\/]/).pop()} (${e.session_id})`,session_id:e.session_id,source_path:t.source_path}}},"transfer.inbox":{label:"Inbox",group:"Transfers",effect:!1,about:"What clients sent into the project through its links (bucket sends) and who is sharing live peer to peer: rows {from, label, sender, when, size, status}, for transfer.receive.",params:{project_id:{type:"string",required:!0}},run:async e=>{let t=await Be("project",{action:"show",project_id:e.project_id}),n=r=>r>=1e9?`${(r/1e9).toFixed(1)} GB`:`${(r/1e6).toFixed(1)} MB`;return[...(t.links??[]).filter(r=>r.peer).map(r=>({id:`live:${r.id}`,from:r.peer.ticket,cells:{label:`${r.label??"A client"} (live)`,sender:"",when:"now",size:"",status:"sharing",from:"peer to peer"}})),...(t.sessions??[]).map(r=>({id:r.id,from:`bucket:${r.id}`,cells:{label:r.label||"Send",sender:r.sender_email??"",when:r.created_at.slice(0,16).replace("T"," "),size:n(r.total_bytes),status:r.status,from:`bucket:${r.id}`}}))]}},"transfer.receive":{label:"Receive",group:"Transfers",effect:!0,about:"Open deliveries \u2014 `from` (a peer-to-peer ticket, bucket:<id>, a .iso path) or inbox rows \u2014 as = list | mount (live, sparse) | trims (cut the media into out_path) | iso (fetch the .iso into out_path).",params:{from:{type:"string"},rows:{type:"array"},as:{type:"string"},out_path:{type:"string"}},run:async(e,t)=>{let n=e.rows?e.rows.map(s=>s.from).filter(Boolean):e.from?[String(e.from)]:[];if(!n.length)throw new L("invalid_args","nothing to receive: wire an inbox, or give from");let r=[],o={};for(let[s,i]of n.entries()){let a=String(e.as??"list"),l=a==="iso"&&e.out_path&&!/\.iso$/i.test(String(e.out_path))?`${String(e.out_path).replace(/[\\/]$/,"")}/${i.replace(/^bucket:/,"").replace(/[^\w.-]+/g,"_").slice(0,40)}.iso`:e.out_path;t.progress?.(s,n.length,`${s+1}/${n.length}`),o=await Be("delivery_fetch",{from:i,as:a,...l?{out_path:l}:{}},t),r.push(String(o.text).split(`
|
|
204
|
-
`)[0])}return{...o,ok:!0,text:r.join(`
|
|
205
|
-
`)}}},"transfer.deliver":{label:"Deliver",group:"Transfers",effect:!0,about:"A timeline with its media, trimmed with handles, as a package: destination folder | iso | bucket (your bucket, recipients emailed) | p2p (served from this machine: a ticket to hand over).",params:{session_id:{type:"string",required:!0},destination:{type:"string",required:!0},handles:{type:"number"},out_path:{type:"string"},recipients:{type:"array"}},run:(e,t)=>Be("media_deliver",e,t)},"transfer.share":{label:"Share peer to peer",group:"Transfers",effect:!0,about:"Serve a file or folder on this machine peer to peer (encrypted, nothing uploaded) until stopped: answers the ticket the recipient opens.",params:{path:{type:"string",required:!0}},run:(e,t)=>Be("p2p_send",e,t)},"transfer.link":{label:"Client link",group:"Transfers",effect:!0,about:"A link a client sends into this project with (a small app named for you: their cut's media, trimmed, lands in the inbox).",params:{project_id:{type:"string",required:!0},label:{type:"string"},recipient_email:{type:"string"}},run:e=>Be("project_link",{action:"create",...e})},"ui.graphics":{label:"Graphics",group:"Make",effect:!1,about:"Lower thirds, locators, legal lines and end crawls designed over the timeline wired in (the designer opens in the knobs, the graphic draws on the viewer); its Render makes ProRes 4444 with alpha for every aspect and position.",params:{session_id:{type:"string"}},run:async e=>({ok:!0,text:"graphics",...e.session_id?{session_id:e.session_id}:{}})},"gfx.place":{label:"Graphics onto the timeline",group:"Make",effect:!0,hosts:["resolve"],about:"Lay a graphics package (gfx_make's answer) on a new track of the timeline read: one graphic after another from frame `at`, each in the position given (default the package's first) and the format that fits the timeline.",params:{package:{type:"object",required:!0,about:"gfx_make's answer"},from:{type:"object",about:"the timeline read (host.read)"},at:{type:"number",about:"the frame the first graphic starts on (default 0)"},position:{type:"string",about:"an anchor (bottom-left\u2026) or a list (its first); default the package's first"}},run:async(e,t)=>{let n=e.from??{},r=n.session_id?(await bt(String(n.session_id)).catch(()=>null))?.session.timelines.find(i=>i.kind!=="compound"):void 0,o=Array.isArray(e.position)?e.position[0]:e.position,s=x$(e.package,r?.resolution_w??void 0,r?.resolution_h??void 0,o,Number(e.at??0));if(!s.paths.length)throw new L("not_found","the package has no file for that position and format");return Be("host_apply",{host:"resolve",...n.timeline?{timeline:n.timeline}:{},ops:[{op:"pool_import",paths:s.paths,folder:s.folder,at:s.at}]},t)}},"host.read":{label:"Host: the open timeline",group:"Hosts",effect:!1,hosts:dr("read"),about:"Read the timeline open in the host (or `timeline`): clips, markers and media as rows, a session for the timeline blocks, and on Resolve the live items (clip color, flags, versions, groups) and tracks. `from` = a timeline wired in instead (another read, a file, any node with a session): the same rows from it.",params:{...Zn,timeline:{type:"string",about:"a timeline by name; default the open one"},from:{type:"object",about:"a timeline wired in (a read, a file source, any node with a session_id)"}},run:async e=>{let t=e.from,n=t&&Array.isArray(t.clips)&&Array.isArray(t.items)?t:t?.session_id?await ch(Kb,String(t.session_id),{timeline:String(t.source_path??"").split(/[\\/]/).pop()}):await h$(It(e),e.timeline);for(let r of n.markers){r.cells.on=r.cells.item_id?"clip":"timeline";let o=Number(r.cells.frame),s=Math.max(1,Number(r.cells.frames??1));n.playhead!=null&&n.playhead>=o&&n.playhead<o+s&&(r.cells.at="playhead")}return uh(n)}},"host.apply":{label:"Host: apply edits",group:"Hosts",effect:!0,hosts:dr("apply"),about:"Carry out a batch of edits in the host, each read back; one undo for the batch.",params:{...Zn,ops:{type:"array",required:!0},timeline:{type:"string"},source:{type:"object",about:"the read the edits are for: one from a file cannot be applied (write it instead)"}},run:async e=>{let t=e.source;if(t&&t.clips&&!t.host)throw new L("refused","this timeline came from a file, not a running host: its edits cannot be applied live (write it for a host instead)");let n=(e.ops??[]).flat().filter(Boolean);if(!n.length)return{ok:!0,text:"nothing to change",applied:0};let r=await Be("host_apply",{host:t?.host??It(e),timeline:e.timeline,ops:n});return is.clear(),r}},"host.export_many":{label:"Host: read several timelines",group:"Hosts",effect:!1,hosts:dr("read"),about:"Export timelines of the open project by name (none = the open one), or every timeline in a media pool `bin` (Resolve; `subfolders` too): the first as session_id, the rest as sources for timeline.all_clips / timeline.join.",params:{...Zn,timelines:{type:"array"},bin:{type:"string",about:"Resolve: every timeline in this media pool folder (0.9.5 All Clips' source)"},subfolders:{type:"boolean"}},run:async e=>{let t=(e.timelines??[]).map(String).filter(s=>s.trim()),n=String(e.bin??"").replace(/^\/+|\/+$/g,"");if(n){if(It(e)!=="resolve")throw new L("unsupported",`${It(e)}: a bin of timelines is Resolve only (name the timelines)`);let s=(await Be("host_project",{host:"resolve",clips:!0})).pool;if(t=[...t,...sa(s).filter(i=>i.type?.toLowerCase()==="timeline"&&(i.folder===n||e.subfolders!==!1&&i.folder.startsWith(`${n}/`))).map(i=>i.name)],!t.length)throw new L("not_found",`no timelines in the bin ${n}`)}let r=[],o=[];for(let s of t.length?t:[void 0]){let i=await Be("host_export",{host:It(e),...s?{timeline:s}:{}});r.push(String(i.session_id)),o.push(String(i.timeline??s??""))}return{ok:!0,text:`read ${r.length} timeline(s)`,session_id:r[0],sources:r.slice(1),sessions:r,timelines:o,first:{host:It(e),timeline:o[0]}}}},"host.open":{label:"Host: open as a new timeline",group:"Hosts",effect:!0,hosts:dr("open"),about:"Bring a session's timeline(s) into the host as NEW timelines linked to the clips already in the project (nothing open is edited). timeline_ids = several (all_clips per resolution).",params:{...Zn,session_id:{type:"string",required:!0},timeline_id:{type:"string"},timeline_ids:{type:"array"},name:{type:"string"},like:{type:"object",about:"the read the new timeline derives from: when it is this host's live timeline, the new one takes its settings, verified (Resolve)"}},run:async e=>{let t=e.timeline_ids?.length?e.timeline_ids:[e.timeline_id],n=e.like,r=n?.host===It(e)&&It(e)==="resolve"&&n.timeline?n.timeline:void 0,o=[],s={},i=[];for(let a of t)if(s=await Be("host_open",{host:It(e),session_id:e.session_id,...a?{timeline_id:a}:{},...e.name?{name:e.name}:{},link_existing:!0,...r?{settings_from:r}:{}}),o.push(String(s.text).split(`
|
|
206
|
-
`)[0]),It(e)==="resolve"&&s.timeline){let l=await bt(String(e.session_id)),u=((l.session.timelines.find(m=>m.id===a)??l.session.timelines.find(m=>m.kind!=="compound"))?.tracks??[]).filter(m=>m.kind==="Video").flatMap((m,h)=>m.items.filter(g=>g.kind==="clip"&&g.enabled!==!1).map(g=>`V${h+1}:${Math.round(g.timeline_range.start.value)}:${Math.round(g.timeline_range.duration.value)}`)),p=new Set(((await Be("host_items",{timeline:s.timeline,kind:"video"})).items??[]).map(m=>`V${m.track}:${m.start}:${m.end-m.start}`)),d=u.filter(m=>!p.has(m));d.length?(i.push(...d.map(m=>`${s.timeline} ${m}`)),o.push(`${d.length} of ${u.length} clip(s) did not land as built (track:start:length): ${d.slice(0,8).join(", ")}${d.length>8?" \u2026":""}`)):o.push(`all ${u.length} clip(s) landed as built`)}return is.clear(),{...s,ok:!0,text:o.join(`
|
|
207
|
-
`),...i.length?{not_landed:i}:{}}}},"host.render":{label:"Host: render jobs",group:"Hosts",effect:!0,hosts:dr("render"),about:"Render each job {name, in, out, target_dir, preset?} from `timeline` with the host's own renderer, one after another (only these jobs are queued; the artist's queue and Deliver settings stay). jobs may be review rows carrying `job`.",params:{...Zn,timeline:{type:"string"},jobs:{type:"array",required:!0},queue:{type:"boolean",about:"Resolve: leave the jobs in the render queue for the artist (nothing rendered)"}},run:async(e,t)=>{let n=(e.jobs??[]).map(s=>({...s.job??s,...e.queue===!0?{queue:!0}:{}})),r=[];for(let[s,{name:i,in:a,out:l,...c}]of n.entries()){if(t.signal?.aborted){r.push("stopped");break}t.progress?.(s,n.length,`${s+1}/${n.length} ${i}`);let u=await b$(It(e),e.timeline,{name:i,range:{in:a,out:l},...c},t,`${s+1}/${n.length} ${i}`);r.push(`${i}: ${u.ok?e.queue===!0?"queued":"rendered":String(u.text).split(`
|
|
208
|
-
`)[0]}`)}let o=s=>s.endsWith("rendered")||s.endsWith("queued");return{ok:r.every(o),text:r.join(`
|
|
209
|
-
`)||"nothing to render",rendered:r.filter(o).length}}},"host.pool":{label:"Host: media pool clips",group:"Hosts",effect:!1,hosts:dr("pool"),about:"Every clip in the project's media pool with its file, bin, start TC and how many timelines use it; unused=true keeps the ones no timeline uses (outside `skip_folder`). Rows {name, folder, start_tc, file, drive}.",params:{...Zn,unused:{type:"boolean"},skip_folder:{type:"string"}},run:async(e,t)=>{let n=await Be("host_project",{host:It(e),clips:!0,used:!!e.unused}),r=n.pool;if(!e.unused)return sa(r).map(s=>({id:s.id,cells:{...s,drive:mh(s.file)}}));let o=n.used;if(!o){let s=new Set,i=n.timelines??[];for(let[a,l]of i.entries()){t.progress?.(a,i.length,`reading ${l}`);for(let c of(await Be("host_items",{host:It(e),timeline:l})).items??[])c.media_id&&s.add(c.media_id)}o=[...s]}return fh(r,String(e.skip_folder??""),new Set(o))}},"host.timelines":{label:"Host: the project's timelines",group:"Hosts",effect:!1,hosts:dr("pool"),about:"Every timeline in the open project, by name (rows), for a review or a filter.",params:{...Zn},run:async e=>((await Be("host_project",{host:It(e)})).timelines??[]).map(t=>({id:t,cells:{name:t}}))},"host.qc":{label:"Render plugin: finishing QC",group:"Render plugin",effect:!0,hosts:dr("qc"),about:"Render the timeline through the conform.tools render plugin, which measures EVERY frame after the grade: black edges per range with the clip and edge, black frames, clipping, freeze/flash, dead pixels, leader/slate, loudness. `pack` = a delivery spec (its check config: Netflix, Apple, Amazon, EBU R128, BBC/DPP, ATSC A/85, conform packs). Findings go on the timeline as tagged markers (markers=true). Rows for a table, and the scan.",params:{timeline:{type:"string"},timelines:{type:"array",about:"a batch: each timeline scanned in turn, its rows named (0.9.5 Master QC batch)"},strictness:{type:"string"},expected_aspect:{type:"number"},markers:{type:"boolean"},audio:{type:"boolean"},pack:{type:"string",about:`a spec pack: ${Xh.map(e=>e.id).join(" | ")}`},only:{type:"array",about:'keep (mark and list) only these findings by check id (the proxy_leak pack keeps ["conform.proxy_leak"] by itself)'},marker_scope:{type:"timeline|clips",about:"markers on the timeline, or picture findings on their clip"}},run:async(e,t)=>{let{pack:n,timelines:r,...o}=e,s=la(n?String(n):void 0);if(n&&!s)throw new L("invalid_args",`no spec pack ${n}`);let i=s?.checks??{},a=!s||i["video.shots"]?.enabled!==!1,l=!!i["video.text"]?.fail_on_text;s?.id==="proxy_leak"&&Object.assign(o,{only:o.only??["conform.proxy_leak"],audio:!1});let c=Array.isArray(r)&&r.length?r:[o.timeline],u=[],p=[],d=[];for(let m of c){let h=await Be("host_render",{host:"resolve",renderplugin:!0,...o,...m?{timeline:m}:{},...s?{checks:{id:s.id,color_space:s.color_space,checks:s.checks}}:{},conform:a,textless:l},t),g=await zb(h,c.length>1);u.push(...g.rows),d.push(h),p.push(g.text)}return{rows:u,text:p.join(`
|
|
210
|
-
|
|
211
|
-
`),scan:d.length===1?d[0]:{timeline:`${c.length} timelines`,scans:d},ok:!0}}},"qc.reopen":{label:"An earlier QC scan",group:"Render plugin",effect:!1,about:"A Finishing QC scan read again from the folder it kept (0.9.5 Master QC's Reports): every finding, frame and decision, nothing rendered, no Resolve needed. `folder`: a scan folder; the newest scan when omitted.",params:{folder:{type:"string",about:"a scan folder (the newest when omitted)"}},run:async e=>{let t=e.folder?Nt(String(e.folder)):(await Pb())[0];if(!t)throw new L("not_found","no earlier scan is kept on this machine: run Finishing QC on a timeline first");let n=await Fb(t);return{...await zb(n,!1),scan:n,ok:!0}}},"qc.report":{label:"QC report (HTML)",group:"Checks",effect:!0,about:"The findings as one self-contained HTML page (the spec, the verdict, counts, every finding with its timecodes) saved into `folder` as <subject>_QC.html.",params:{rows:{type:"array"},text:{type:"string"},subject:{type:"string"},pack:{type:"string"},folder:{type:"string",required:!0},verdict:{type:"string",about:"the check's own verdict (default: from the rows)"}},run:async e=>{let t=String(e.subject||"master").split(/[\\/]/).pop(),n=e.rows??[],r=new Set(n.map(i=>i.cells.timeline)).size>1,o=await Promise.all(n.map(async i=>({...i.cells,...r?{clip:`${i.cells.timeline} \xB7 ${i.cells.clip??""}`}:{},...i.evidence?{evidence:`data:image/jpeg;base64,${ta(await tn(i.evidence).catch(()=>new Uint8Array))}`}:{}}))),s=B(Nt(String(e.folder)),`${t.replace(/\.[^.]+$/,"").replace(/[^\w.-]+/g,"_")}_QC.html`);return await Ke(Nt(String(e.folder))),await Ve(s,bb({subject:t,spec:la(e.pack?String(e.pack):"conform_default")?.label??"no spec",summary:e.text?String(e.text):void 0,...e.verdict?{verdict:String(e.verdict)}:{}},o)),{ok:!0,text:`report: ${s}`,path:s}}},"rows.html":{label:"Save the rows as a page (HTML)",group:"Checks",effect:!0,about:"Any tool's rows (a review or a table) as one self-contained HTML page \u2014 the title, a summary, the columns as shown \u2014 saved into `folder` as <title>.html (0.9.5's per-tool reports).",params:{rows:{type:"array"},columns:{type:"array",required:!0},title:{type:"string",required:!0},text:{type:"string"},folder:{type:"string",required:!0}},run:async e=>{let t=String(e.title),n=Nt(String(e.folder)),r=B(n,`${t.replace(/[^\w.-]+/g,"_")}.html`);return await Ke(n),await Ve(r,yb(t,e.columns,(e.rows??[]).map(o=>o.cells),e.text?String(e.text).split(`
|
|
212
|
-
`)[0]:"")),{ok:!0,text:`report: ${r}`,path:r}}},"qc.master_file":{label:"QC a rendered master",group:"Checks",effect:!1,about:"A rendered master from any host, every frame measured by the analysis engine (black, freeze, flash, duplicates, blanking on each edge, dead / stuck / hot pixels; each audio track's loudness, true peak, clipping, dropouts, silence, phase) and held to a spec pack's loudness and true peak: rows for a table, at the file's own timecode.",params:{path:{type:"string",required:!0},pack:{type:"string"}},run:async(e,t)=>{let n=String(e.path),r=la(e.pack?String(e.pack):"conform_default"),o=await Be("qc_media",{path:n},t),s=o.fps||24,i=p=>He(o.startFrame+p,s,o.dropFrame),a=[],l=(p,d,m,h,g)=>a.push({id:String(a.length),cells:{tc:p==null?"":i(p),out:d==null?"":i(d),kind:m,severity:h.toUpperCase(),detail:g}});for(let p of o.temporal.findings.filter(d=>d.severity!=="info"))l(p.start,p.end,p.check,p.severity,p.detail);for(let p of["top","bottom","left","right"])for(let d of o.edges[p]??[])l(d.start,d.end,`blanking ${p}`,"fail",`${d.thickness} px`);for(let p of o.pixels.defects)l(null,null,`${p.kind} pixel`,"fail",`at ${p.x},${p.y}, value ${p.value}`);for(let p of o.audio??[])for(let d of p.findings)l(d.start!=null?Math.floor(d.start*s):null,null,d.check,d.severity,`track ${p.track}${d.channel?` ch ${d.channel}`:""}: ${d.detail}`);let c=await Be("qc_deliverable",{path:n,name:!1,...r?.audio?{loudness_lufs:r.audio.lufs,loudness_tolerance:r.audio.tolerance,true_peak:r.audio.true_peak}:{}},t);for(let p of c.rows.filter(d=>d.outcome!=="PASS"&&d.outcome!=="INFO"))l(null,null,p.check,p.outcome,[p.expected&&`expected ${p.expected}`,p.measured&&`measured ${p.measured}`,p.note].filter(Boolean).join("; "));let u=o.verdict==="FAIL"||c.verdict==="FAIL"?"FAIL":o.verdict==="CHECK"?"CHECK":"PASS";return{ok:!0,verdict:u,rows:a,text:`${n.split(/[\\/]/).pop()}: ${u} against ${r?.label??"no spec"} \u2014 ${a.length} finding(s)
|
|
213
|
-
${String(o.text??"")}
|
|
214
|
-
${String(c.text??"")}`}}},"files.move":{label:"Move the files on disk",group:"Media",effect:!0,about:"The kept rows' files (`field`, default file) into `destination` (media_move: writability checked, clashes numbered, missing files named); its undo_id puts them back.",params:{rows:{type:"array",required:!0},destination:{type:"string",required:!0},field:{type:"string"}},run:async(e,t)=>{let n=(e.rows??[]).map(r=>String(r.cells[String(e.field??"file")]??"")).filter(Boolean);return n.length?Be("media_move",{paths:n,destination:e.destination},t):{ok:!0,text:"no files to move"}}},"files.rename_plan":{label:"Plan file renames",group:"Planners",effect:!1,about:"Every file in `folder` (image sequences frame by frame) through the rename steps on the name part, then the frame numbers offset or shifted to start at a number (0.9.5 Image Sequence Renamer); rows {where, old, new, dupe, error, hold} for every file (`hold`: not renamed \u2014 a DUPE, or unchanged), each with its from / to path.",params:{folder:{type:"string",required:!0},steps:{type:"array"},only:{type:"string"},offset:{type:"number"},start_at:{type:"number"}},run:async e=>{let t=Nt(String(e.folder)),n=[];for await(let d of Rt(t))d.isFile&&!d.name.startsWith(".")&&n.push(d.name);n.sort();let r=e.only?new RegExp(String(e.only)):null,o=n.filter(d=>!r||r.test(d)),s=ku(o,e.steps??[],{sequence:!0}),i=e.offset!=null&&e.offset!==""?Number(e.offset):void 0,a=e.start_at!=null&&e.start_at!==""?Number(e.start_at):void 0,l=i!=null||a!=null?Wb(s.map(d=>d.new),{offset:i,start:a}):s.map(d=>d.new),c=new Set(o.filter((d,m)=>l[m]!==d)),u=new Set(n.filter(d=>!c.has(d))),p=new Set;return o.map((d,m)=>{let h=l[m],g=s[m].dupe||p.has(h)||h!==d&&u.has(h);return p.add(h),{id:d,from:B(t,d),to:B(t,h),cells:{where:t.split(/[\\/]/).pop(),old:d,new:h,dupe:g?"DUPE":"",error:s[m].error??"",hold:g||h===d?"1":""}}})}},"files.patch_plan":{label:"Plan a sequence patch",group:"Planners",effect:!1,about:"Every frame of the patch folders beside an image sequence's folder (0.9.5 Image Sequence Patcher), one row each: the frame, its folder, and whether the sequence has that frame to replace.",params:{sequence:{type:"string",required:!0}},run:async(e,t)=>((await Be("media_patch_sequence",{sequence:e.sequence,mode:"plan"},t)).rows??[]).map(r=>({id:`${r.folder}/${r.file}`,cells:{frame:r.file,folder:r.folder,status:r.replaces?"replaces":"not in the sequence",cant:!r.replaces}}))},"files.patch":{label:"Patch the frames in",group:"Media",effect:!0,about:"The kept patch frames into the sequence (media_patch_sequence apply): originals to <sequence>_originalframes, the patch folders filed under zAPPLIED_PATCHES; its undo_id puts it all back.",params:{sequence:{type:"string",required:!0},rows:{type:"array",required:!0}},run:async(e,t)=>{let n=(e.rows??[]).filter(r=>!r.cells.cant).map(r=>r.id);return n.length?Be("media_patch_sequence",{sequence:e.sequence,mode:"apply",only:n},t):{ok:!0,text:"no frames to patch"}}},"files.sort_plan":{label:"Plan the filing",group:"Planners",effect:!1,about:"Where every file of `folder` goes by the recipe (media_sort plan): one row each \u2014 file, rule, project, where it goes, and its status (ready, renamed, conflict, in place, unmatched, invalid); only ready / renamed rows can be applied.",params:{folder:{type:"string",required:!0},recipe:{type:"string"},recursive:{type:"boolean"},destination_root:{type:"string"},operation:{type:"move|copy"}},run:async(e,t)=>((await Be("media_sort",{folder:e.folder,recipe:e.recipe||"mixes-splits",mode:"plan",recursive:!!e.recursive,...e.destination_root?{destination_root:e.destination_root}:{},...e.operation?{operation:e.operation}:{}},t)).files??[]).map(r=>({id:r.source_path,cells:{file:r.name,rule:r.rule_name??"",project:r.project,to:[r.dest_rel,r.dest_name!==r.name?r.dest_name:""].filter(Boolean).join("/"),status:r.status.replace("_"," "),why:r.reason??"",cant:!(r.status==="ready"||r.status==="renamed")}}))},"files.sort":{label:"File them",group:"Media",effect:!0,about:"The kept rows filed by the recipe (media_sort apply, re-planned from disk: nothing overwritten); its undo_id puts every file back.",params:{folder:{type:"string",required:!0},recipe:{type:"string"},recursive:{type:"boolean"},destination_root:{type:"string"},operation:{type:"move|copy"},rows:{type:"array",required:!0}},run:async(e,t)=>{let n=(e.rows??[]).filter(r=>!r.cells.cant).map(r=>r.id);return n.length?Be("media_sort",{folder:e.folder,recipe:e.recipe||"mixes-splits",mode:"apply",recursive:!!e.recursive,only:n,...e.destination_root?{destination_root:e.destination_root}:{},...e.operation?{operation:e.operation}:{}},t):{ok:!0,text:"nothing to file"}}},"files.odd_plan":{label:"Find odd-sized stills",group:"Planners",effect:!1,about:"Every still of `folder` whose width or height is odd (or larger than `max`), one row each with the size it would become (media_odd_images plan).",params:{folder:{type:"string",required:!0},max:{type:"number"}},run:async(e,t)=>((await Be("media_odd_images",{folder:e.folder,mode:"plan",...Number(e.max)>0?{max:Number(e.max)}:{}},t)).files??[]).filter(r=>r.status!=="skipped").map(r=>({id:r.path,cells:{file:r.path.split(/[\\/]/).pop(),now:r.original??"",becomes:r.new??"",why:r.why??"",cant:r.status!=="fixed"}}))},"files.odd_fix":{label:"Make them even",group:"Media",effect:!0,about:"The kept stills rewritten at even sizes (media_odd_images apply: originals to 'zORIGINAL IMAGES'); its undo_id puts every original back.",params:{rows:{type:"array",required:!0},max:{type:"number"}},run:async(e,t)=>{let n=(e.rows??[]).filter(o=>!o.cells.cant).map(o=>o.id);if(!n.length)return{ok:!0,text:"nothing to fix",paths:[]};let r=await Be("media_odd_images",{files:n,mode:"apply",...Number(e.max)>0?{max:Number(e.max)}:{}},t);return{...r,paths:(r.files??[]).filter(o=>o.status==="fixed").map(o=>o.path)}}},"files.rename":{label:"Rename the files on disk",group:"Media",effect:!0,about:"The kept rows' files renamed (media_move renames: collision-safe, refused whole when a target is a file outside the batch); its undo_id puts every name back.",params:{rows:{type:"array",required:!0}},run:async(e,t)=>{let n=(e.rows??[]).filter(r=>r.from&&r.to&&!r.cells.dupe).map(r=>({from:r.from,to:r.to}));return n.length?Be("media_move",{renames:n},t):{ok:!0,text:"nothing to rename"}}},"rows.times":{label:"Times on the timeline",group:"Logic",effect:!1,fresh:!0,about:"Rows at regular times on a read timeline: one every `seconds` (or `frames`), from `from` to `to` seconds (default the whole timeline). Each row has frame (from the head) and tc; an edit block given these rows acts on the timeline at that frame (edit.marker_add: a marker every N seconds).",params:{live:{type:"object",required:!0},seconds:{type:"number"},frames:{type:"number"},from:{type:"number"},to:{type:"number"}},run:async e=>{let t=e.live,n=Number(t.fps??24),r=Math.round(Number(e.frames??0)||Number(e.seconds??1)*n);if(!(r>0))throw new L("invalid_args","times need seconds or frames above 0");let o=e.to!=null&&e.to!==""?Math.round(Number(e.to)*n):Number(t.frames??0),s=[];for(let i=Math.round(Number(e.from??0)*n);i<o&&s.length<1e4;i+=r)s.push({id:`t${i}`,cells:{frame:i,tc:He(i+Number(t.start_frame??0),n,!1)}});return s}},"rows.filter":{label:"Filter rows",group:"Logic",effect:!1,about:'Keep the rows where every condition holds: [field, op, value] (field "a|b": either field), op = | != | contains | starts | !starts (a comma list: any of them) | in | empty | set | < | <= | > | >= (numbers: frames, speed %, duration). A track cell ("V2") matches a track number (2), so a track input filters directly. A condition whose value is unset is skipped (an optional filter left blank).',params:{rows:{type:"array",required:!0},where:{type:"array"}},run:async e=>{let t=(e.where??[]).filter(([,r,o])=>r==="empty"||r==="set"||o!=null&&o!==""),n=(r,o)=>r.cells[o];return(e.rows??[]).filter(r=>t.every(([o,s,i])=>String(o).split("|").some(a=>{let l=n(r,a),c=String(l??"").toLowerCase(),u=String(i??"").toLowerCase(),p=()=>c===u||/^[va]\d+$/.test(c)&&/^\d+$/.test(u)&&c.slice(1)===u,d=h=>typeof h=="number"?h:parseFloat(String(h??"").replace(/[^0-9.+-]/g,"")),m=()=>{let h=d(l),g=d(i);return Number.isFinite(h)&&Number.isFinite(g)?h-g:NaN};switch(s){case"=":return typeof i=="boolean"?!!l===i:p();case"!=":return!p();case"<":return m()<0;case"<=":return m()<=0;case">":return m()>0;case">=":return m()>=0;case"contains":return c.includes(u);case"starts":return u.split(",").map(h=>h.trim()).filter(Boolean).some(h=>c.startsWith(h));case"!starts":return!u.split(",").map(h=>h.trim()).filter(Boolean).some(h=>c.startsWith(h));case"in":return Array.isArray(i)&&i.map(h=>String(h).toLowerCase()).includes(c);case"empty":return!c;case"set":return!!c;default:return!0}})))}},review:{label:"Review",group:"Logic",effect:!1,about:"Show the rows (with `columns`) and wait: the artist unticks what to leave out and applies. Its output is the rows kept.",params:{rows:{type:"array",required:!0},columns:{type:"array",about:"[cell key, label] pairs"},skip:{type:"string",about:"a cell that marks rows that cannot be applied (e.g. dupe)"}},run:async()=>{throw new L("internal","review is the runner's")}},"ops.collect":{label:"Collect edits",group:"Logic",effect:!1,about:"The edits a planner put on each row (`field`, default op) as one batch for host.apply.",params:{rows:{type:"array",required:!0},field:{type:"string"}},run:async e=>(e.rows??[]).map(t=>t[String(e.field??"op")]).filter(Boolean)},"plan.marker_ops":{label:"Plan marker edits",group:"Planners",effect:!1,about:"Existing marker rows \u2192 edits: action = recolor | swap (color \u2194 text, over `all`) | rename | note | keyword | prefix | suffix | replace (text \u2192 with, any case) | duration (frames) | delete | to_clip / copy_to_clip (onto the clip under it: `track`, else the topmost) | to_timeline / copy_to_timeline | swap_places (timeline \u2194 clip); `field` = name | note | keyword for rename / prefix / suffix / replace, `separator` for prefix / suffix. It changes markers that are there; to ADD markers use edit.marker_add (one per row: clip rows mark each clip, rows.times rows mark those times).",params:{live:{type:"object",required:!0},rows:{type:"array",required:!0},action:{type:"recolor|swap|rename|note|keyword|prefix|suffix|replace|duration|delete|to_clip|to_timeline|copy_to_clip|copy_to_timeline|swap_places",required:!0},color:{type:"string"},text:{type:"string"},with:{type:"string"},field:{type:"name|note|keyword"},separator:{type:"string"},track:{type:"number"},frames:{type:"number"},all:{type:"array",about:"swap: the markers it swaps across (default every marker of the timeline); the color filter does not narrow a swap"}},run:async e=>{let t=e.live,n=e.action,r=Number(e.track)||void 0;return dh(t,n==="swap"?e.all??t.markers:e.rows,n,String(e.color??"Green"),String(e.text??(n==="swap"?"Red":"")),{field:e.field||"name",separator:e.separator==null?"":String(e.separator),with:String(e.with??""),track:r,frames:Number(e.frames)||void 0})}},"rename.subjects":{label:"What to rename",group:"Planners",effect:!1,about:"The names to rename and how each is renamed in the host: target = clips (timeline video clips) | timelines | pool (media pool clips, `folder` to narrow; Resolve).",params:{...Zn,live:{type:"object",required:!0},target:{type:"string",required:!0},folder:{type:"string"},subfolders:{type:"boolean",about:"pool: the folder's subfolders too (default true)"},only:{type:"string",about:"a regex (any case): only the names it finds; numbering counts these"}},run:async e=>{let t=null;try{t=e.only?new RegExp(String(e.only),"i"):null}catch(r){throw new L("invalid_args",`the filter is not a valid pattern: ${r.message}`)}let n=await T$(e);return t?n.filter(r=>t.test(r.name)):n}},"plan.rename":{label:"Plan renames",group:"Planners",effect:!1,about:"Run the rename steps over every subject's name; rows {id, where, old, new, dupe, error, hold, op} for every subject (as 0.9.5's preview: the whole list, the new name beside each) \u2014 `hold` marks a row that is not applied (a DUPE, or a name the steps leave as it is).",params:{subjects:{type:"array",required:!0},steps:{type:"array",required:!0}},run:async e=>{let t=e.subjects??[],n=ku(t.map(r=>r.name),e.steps??[]);return t.map((r,o)=>({id:r.id,cells:{where:r.where,old:n[o].old,new:n[o].new,dupe:n[o].dupe?"DUPE":"",error:n[o].error??"",hold:n[o].dupe||n[o].new===n[o].old?"1":""},op:{...r.op,name:n[o].new}}))}},table:{label:"Show a table",group:"Logic",effect:!1,about:"End a tool with a table of rows (with `columns`) and a summary `text`: findings to read, not to apply. A row's `tc` cell moves the host's playhead when clicked.",params:{rows:{type:"array",required:!0},columns:{type:"array"},text:{type:"string"}},run:async e=>({ok:!0,text:String(e.text??`${(e.rows??[]).length} row(s)`),table:{rows:e.rows??[],columns:e.columns??[]}})},"plan.clips":{label:"Clips as rows",group:"Planners",effect:!1,about:"The read timeline's clips as rows with what the host holds live on each (color, flags, on, version, group, nodes, keywords); `query` narrows them with the Edit Index grammar (is:offline \xB7 speed!=100 \xB7 track:V2 \xB7 name:/^A0\\d+/).",params:{live:{type:"object",required:!0},query:{type:"string"}},run:async e=>{let t=e.live,n=String(e.query??"").trim();if(!n)return Bc(t);let r=await Be("timeline_query",{session_id:t.session_id,table:"clips",query:n,limit:5e3,columns:["#"]});return Bc(t,new Set((r.rows??[]).map(o=>o.id)))}},"plan.index_ops":{label:"Plan clip edits",group:"Planners",effect:!1,about:`Clip rows \u2192 one edit each: action = ${jc.map(([e])=>e).join(" | ")}; color (clip color), marker_color (flags, markers), text.`,params:{live:{type:"object",required:!0},rows:{type:"array",required:!0},action:{type:jc.map(([e])=>e).join("|"),required:!0},color:{type:"string"},marker_color:{type:"string"},text:{type:"string"}},run:async e=>{let t=String(e.action),n=String(t==="color"?e.color??"":e.marker_color??"Blue");return ph(e.live,e.rows??[],t,n,String(e.text??""))}},"plan.pool_ops":{label:"Plan pool moves",group:"Planners",effect:!1,about:"Pool clip rows \u2192 one batch: action = move (into `folder`, made if missing) | remove (out of the pool; files on disk stay; cannot be undone).",params:{rows:{type:"array",required:!0},action:{type:"move|remove"},folder:{type:"string"}},run:async e=>hh(e.rows??[],String(e.action??"move"),String(e.folder??""))},"plan.copy_pairs":{label:"Pair clips by overlap",group:"Planners",effect:!1,about:"Every clip on track `to` paired with the clip on track `from` it overlaps most (rows; a clip with nothing over it is a row too).",params:{live:{type:"object",required:!0},from:{type:"number",required:!0},to:{type:"number",required:!0}},run:async e=>gh(e.live,Number(e.from),Number(e.to))},"plan.copy_ops":{label:"Plan copies",group:"Planners",effect:!1,about:"Paired rows \u2192 copy_grade / copy_properties / clip color / flags / clip markers / color group / keywords edits for what is switched on (grade, sizing, crop, composite, clip_color, flags, markers, group, keywords); unpaired rows get a `miss_color` marker.",params:{rows:{type:"array",required:!0},grade:{type:"boolean"},sizing:{type:"boolean"},crop:{type:"boolean"},composite:{type:"boolean"},clip_color:{type:"boolean"},flags:{type:"boolean"},markers:{type:"boolean"},versions:{type:"boolean"},group:{type:"boolean"},keywords:{type:"boolean"},miss_color:{type:"string"},live:{type:"object",about:"the read (clip markers need it)"}},run:async e=>bh(e.rows??[],new Set(qc.map(([t])=>t).filter(t=>e[t])),String(e.miss_color??""),e.live)},"plan.grade_trace":{label:"Trace earlier grades",group:"Planners",effect:!1,about:"Score every clip of the read timeline against the clips of earlier `timelines` and of other `projects` (source TC overlap, reel, file name, path, duration): rows with the best match and up to top_n alternatives.",params:{...Zn,live:{type:"object",required:!0},timelines:{type:"array"},projects:{type:"array",about:"other projects of the library to search (Resolve opens each, then yours again)"},top_n:{type:"number"},min_score:{type:"number"},floor:{type:"number"},tracks:{type:"string",about:'only these video tracks of the read, e.g. "1, 3" (default all)'},clip_color:{type:"boolean",about:"read the earlier clips' clip color (to copy it with the grade)"},flags:{type:"boolean",about:"and their flags"}},run:async(e,t)=>{let n=e.live,r=[],o=new Map,s=String(e.tracks??"").split(",").map(c=>Number(c.trim().replace(/^v/i,""))).filter(c=>c>0),i=(e.timelines??[]).filter(c=>c&&c!==n.timeline),a=(e.projects??[]).filter(Boolean);if(!i.length&&!a.length)throw new L("invalid_args","choose the earlier timelines (or other projects) to trace from");for(let[c,u]of a.entries()){t.progress?.(c,a.length,`reading the project ${u}`);let p=await Be("host_project",{host:"resolve",project:u,export_dir:await Dt("conform-trace-")});for(let d of p.exported??[]){let m=await Be("timeline_read",{path:d.path}),[h,g]=await Promise.all([Be("timeline_query",{session_id:m.session_id,table:"clips",limit:5e3,columns:["track","track_no","name","timeline_range.start","reel_name","media_reference_id"]}),Be("timeline_query",{session_id:m.session_id,table:"media",limit:5e3,columns:["name","target_url","available_range.start","available_range.dur"]})]);r.push(...ia(d.timeline,h.rows,await ii(g.rows,o)).map(y=>({...y,project:u})))}}for(let[c,u]of i.entries()){t.progress?.(c,i.length,`reading ${u}`);let p=await Be("host_export",{host:It(e),timeline:u}),[d,m]=await Promise.all([Be("timeline_query",{session_id:p.session_id,table:"clips",limit:5e3,columns:["track","track_no","name","timeline_range.start","reel_name","media_reference_id"]}),Be("timeline_query",{session_id:p.session_id,table:"media",limit:5e3,columns:["name","target_url","available_range.start","available_range.dur"]})]),h=It(e)==="resolve"&&(e.clip_color||e.flags)?(await Be("host_items",{timeline:u,kind:"video"})).items??[]:[];r.push(...ia(u,d.rows,await ii(m.rows,o),h))}let l=ia(n.timeline,n.clips,await ii(n.media,o),n.items).filter(c=>!s.length||s.includes(c.track));if(It(e)==="resolve"){let c=sa((await Be("host_project",{host:"resolve",clips:!0}).catch(()=>({pool:{folders:[]}}))).pool),u=new Map(c.filter(p=>p.camera).map(p=>[p.file,p.camera]));for(let p of[...l,...r])p.file_path&&u.has(p.file_path)&&(p.camera_roll=u.get(p.file_path))}return yh(l,r,{topN:Number(e.top_n??3),minScore:Number(e.min_score??60),floor:Number(e.floor??60)})}},"plan.grade_trace_ops":{label:"Plan traced grades",group:"Planners",effect:!1,about:"Traced rows \u2192 copy_grade from the best match (only_trusted: trusted matches only), or with variants the top matches as named local versions; unmatched rows get a `mark_color` marker.",params:{rows:{type:"array",required:!0},variants:{type:"boolean"},only_trusted:{type:"boolean"},mark_color:{type:"string"},prefix:{type:"string",about:"variants' name prefix (default trace)"},unsure_only:{type:"boolean",about:"variants only where the match is not trusted"},sizing:{type:"boolean"},crop:{type:"boolean"},composite:{type:"boolean"},clip_color:{type:"boolean"},flags:{type:"boolean"},live:{type:"object",about:"the read: its earlier tracer markers are cleared when `clear`"},clear:{type:"boolean"}},run:async(e,t)=>{let n=wh(e.rows??[],{variants:!!e.variants,onlyTrusted:e.only_trusted!==!1,markColor:String(e.mark_color??""),prefix:e.prefix?String(e.prefix):void 0,unsureOnly:e.unsure_only===!0,keys:qc.filter(([o])=>["sizing","crop","composite"].includes(o)&&e[o]===!0).flatMap(([,,o])=>o),clear:e.clear===!0?e.live?.markers:void 0,color:e.clip_color===!0,flags:e.flags===!0}),r=n.filter(o=>o.from_project);for(let[o,s]of[...new Set(r.map(i=>String(i.from_project)))].entries()){t.progress?.(o,0,`grabbing grades in ${s}`);let i=r.filter(c=>c.from_project===s),a=i.map((c,u)=>({key:u,timeline:c.from_timeline,...c.item})),l=(await Be("host_project",{host:"resolve",project:s,grades:a,grades_dir:await Dt("conform-trace-")})).grades??{};i.forEach((c,u)=>{let p=l[u],{from_project:d,from_timeline:m,...h}=c;Object.keys(c).forEach(g=>delete c[g]),Object.assign(c,typeof p=="string"?{...h,item:h.to[0],drx:p}:{op:"skip",why:`${s}: ${p?.error??"no grade"}`})})}return n.filter(o=>o.op!=="skip")}},"align.against":{label:"Align a build to B, track by track",group:"Planners",effect:!1,about:"Reconform's Match Sizing: every one of B's video tracks that is on laid onto the build's read as its own reference track (stack_track), then each of the build's tracks aligned against B's track of the same number \u2014 both decoded from the files (media-core), B's own reframe composed in. One answer {rows, ops} for plan.align_rows / plan.align_ops.",params:{session_id:{type:"string",required:!0},timeline:{type:"string",required:!0},b_session_id:{type:"string",required:!0},b_timeline:{type:"string",required:!0}},run:async(e,t)=>{let n=(await bt(String(e.b_session_id))).session,r=n.timelines.find(l=>l.name===e.b_timeline)??n.timelines.find(l=>l.kind==="primary");if(!r)throw new L("not_found",`no timeline ${e.b_timeline} in B's read`);let o=r.tracks.filter(l=>l.kind==="Video").sort((l,c)=>l.track_index-c.track_index),s=new Map;for(let[l,c]of o.entries()){if(c.enabled===!1)continue;let u=await Be("timeline_edit",{session_id:e.session_id,kind:"stack_track",args:{timeline_id:e.timeline,from:r.name,from_track:l+1,sources:[e.b_session_id]}},t);u.meta?.track&&s.set(l+1,u.meta.track)}let i=[],a=[];for(let[l,c]of s){let u=await Be("timeline_align",{session_id:e.session_id,reference_track:c,tracks:[l],markers:!1},t);i.push(...u.rows??[]),a.push(...u.ops??[])}return{ok:!0,rows:i,ops:a,sizing_target:"edit",text:`${i.length} clip(s) measured against B, track by track`}}},"plan.align_rows":{label:"Align results as rows",group:"Planners",effect:!1,about:"timeline_align's answer as rows: record TC, track, clip, verdict, confidence, the host sizing (rows not aligned cannot be applied: cell `cant`).",params:{result:{type:"object",required:!0}},run:async e=>kh(e.result?.rows??[],e.result?.sizing_target)},"plan.align_ops":{label:"Plan sizing",group:"Planners",effect:!1,about:"The sizing edits of the kept aligned rows, and timeline_align's markers when `markers`.",params:{result:{type:"object",required:!0},rows:{type:"array",required:!0},markers:{type:"boolean"}},run:async e=>_h(e.result?.ops??[],e.rows??[],e.markers!==!1)},"plan.blanking_rows":{label:"Blanking findings as rows",group:"Planners",effect:!1,about:"qc_blanking's findings as rows: record TC, frames, track, clip, black per edge, the zoom that fills.",params:{result:{type:"object",required:!0},live:{type:"object",about:"the read: its playhead marks the finding under it (at=playhead) and the next one (at=next)"}},run:async e=>vh(e.result?.findings??[],e.live?.playhead)},"plan.blanking_ops":{label:"Plan blanking fixes",group:"Planners",effect:!1,about:"The kept findings' markers, and the zoom fix of each clip they sit on when `fixes`.",params:{result:{type:"object",required:!0},rows:{type:"array",required:!0},live:{type:"object",required:!0},fixes:{type:"boolean"},clear:{type:"boolean",about:"take an earlier run's blanking markers off first"},which:{type:"string",about:"a one-finding run (playhead / next) never clears the others' markers"}},run:async e=>Th(e.result?.ops??[],e.rows??[],e.live,e.fixes!==!1,e.clear===!0&&!e.which)},"plan.vfx_dropin":{label:"Match comps to plates",group:"Planners",effect:!1,about:"Every finished comp in `folder` (movies, and image sequences by their first frame) probed and matched to a plate of the read (0.9.5 Drop in VFX): by the shot id in its name \u2014 the VFX shot markers, the plates' names \u2014 then by source timecode and reel; each row ready (with where its frames go), ambiguous, retimed or unmatched, and why.",params:{live:{type:"object",required:!0},folder:{type:"string",required:!0}},run:async e=>{let t=Nt(String(e.folder)),n=new Set,r=[];for await(let s of Rt(t)){if(!s.isFile||s.name.startsWith("."))continue;let i=/^(.*?)[._](\d{3,8})\.(exr|dpx|tiff?|png|jpe?g)$/i.exec(s.name),a=i?`${i[1]}|${i[3]}`:s.name;!/\.(mov|mxf|mp4|m4v|exr|dpx|tiff?|png|jpe?g)$/i.test(s.name)||n.has(a)||(n.add(a),r.push(B(t,s.name)))}r.sort();let o=(await Promise.all(r.map(async s=>{let i=await $o("media_probe",{path:s}),a=i.structuredContent;return i.isError||!a?null:{path:s,name:s.split(/[\\/]/).pop(),frames:Number(a.available_range?.duration.value??0),fps:Number(a.source_fps??24),start_tc:a.source_timecode??void 0,reel:a.reel_name??void 0,...a.source_resolution_w?{raster:[a.source_resolution_w,a.source_resolution_h]}:{}}}))).filter(s=>s!==null);return jh(await Gb(e.live),o)}},"plan.vfx_dropin_ops":{label:"Drop the comps in",group:"Planners",effect:!1,about:"The kept ready rows as one drop_in: the comps into the pool's VFX bin, onto a new top track over their plates (the plate's sizing when the rasters agree), the plates switched off when asked.",params:{rows:{type:"array",required:!0},name:{type:"string"},disable_plates:{type:"boolean"}},run:async e=>Bh(e.rows??[],{name:e.name?String(e.name):void 0,disable_plates:e.disable_plates===!0})},"plan.history":{label:"A's program as a history track",group:"Planners",effect:!1,about:"The op that cuts A's program (the topmost enabled clip at every span, its source window) onto a new, switched-off video track of the target (0.9.5 Reconformer's V1 HISTORY).",params:{a:{type:"object",required:!0},name:{type:"string"}},run:async e=>{let t=Dh(e.a);return t.length?[{op:"history_track",name:String(e.name||"V1 HISTORY"),pieces:t}]:[]}},"plan.edit_changes":{label:"The change list by the edit",group:"Planners",effect:!1,about:"A (the old cut) and B (the new one), both reads: each B clip paired with the A clip holding the most of the same source frames, and what happened \u2014 moved, trimmed / extended at either end, slipped, split, joined, retimed, reframed; inserted / deleted for the unpaired. Rows carry their marker (on B, a deletion on A).",params:{a:{type:"object",required:!0},b:{type:"object",required:!0}},run:async e=>Lh(e.a,e.b)},"verify.pictures":{label:"Check the picture (decode both sides)",group:"Checks",effect:!1,about:"For every change row pairing an A clip with a B clip, both sides' source frame at the middle of what they share decoded straight from the files (media-core, no render, no app) and compared by the analysis engine's picture distance (it survives a regrade, a burn-in, a rescale; another shot does not): `picture` says same / DIFFERS, with the A/B frame beside it. `which`: loose (just the pairs made by name, default) or all.",params:{rows:{type:"array",required:!0},which:{type:"loose|all"}},run:async e=>{let t=e.rows??[],n=[];for(let r of t){if(!r.pair||e.which!=="all"&&!r.cells.paired){n.push(r);continue}try{let o=await _o({path:r.pair.a.path,frame:r.pair.a.frame,b:r.pair.b.path,width:320}),s=o.diff?.[0];n.push({...r,evidence:o.out_path,cells:{...r.cells,picture:s?s.same?"same":`DIFFERS (${s.distance})`:"not decoded"}})}catch(o){n.push({...r,cells:{...r.cells,picture:`not decoded: ${o.message.slice(0,80)}`}})}}return n}},"plan.edit_change_ops":{label:"Markers for the changes",group:"Planners",effect:!1,about:"The kept change rows' markers for one side: B (the changes) or A (the deletions).",params:{rows:{type:"array",required:!0},side:{type:"A|B",required:!0},live:{type:"object",about:"that side's read: its own markers' frames are left alone"}},run:async e=>Nh(e.rows??[],e.side==="A"?"A":"B",e.live)},"plan.reconform":{label:"Cut changes as rows",group:"Planners",effect:!1,about:"timeline_diff's ranges as rows (record in/out, change, both sides), each carrying the marker for A at its first frame (start_frame = A's timeline start).",params:{diff:{type:"object",required:!0},start_frame:{type:"number"}},run:async e=>xh(e.diff?.ranges??[],Number(e.start_frame??0))},"plan.carry_rows":{label:"Pair the new cut with the color cut",group:"Planners",effect:!1,about:"Every video clip of B (a read) paired with the clip of A (a read) holding the most of the same source frames of the same media: the clip whose grade it takes. New material is a row with no source.",params:{a:{type:"object",required:!0},b:{type:"object",required:!0}},run:async e=>{let t=e.a,n=e.b;if(!n?.items?.length)throw new L("invalid_args","B has to be a timeline in this project to build the reconform on (import the new cut into Resolve first)");return Sh(t,n)}},"plan.carry_ops":{label:"Plan the carry",group:"Planners",effect:!1,about:"Kept carry rows \u2192 edits on B's copy, each source read in A: grade (a remote one selected, a local one copied onto a local version), sizing, crop, composite, clip color, clip markers (what is switched on; flags are the media's, so B has A's); new material gets a `miss_color` marker.",params:{rows:{type:"array",required:!0},a:{type:"object",required:!0},grade:{type:"boolean"},sizing:{type:"boolean"},crop:{type:"boolean"},composite:{type:"boolean"},clip_color:{type:"boolean"},markers:{type:"boolean"},speed:{type:"boolean"},fades:{type:"boolean"},miss_color:{type:"string"},a_sizing:{type:"array",about:"of the clips whose sizing differs, the ones that take A's (kept rows of the sizing review); the others keep B's"}},run:async e=>{let t=e.rows??[],n=e.a_sizing,r=n?new Set(t.filter(o=>o.cells.sizing_differs&&!n.some(s=>s.id===o.id)).map(o=>o.id)):void 0;return Rh(t,new Set($h.map(([o])=>o).filter(o=>e[o])),e.a,String(e.miss_color??""),r)}},"host.duplicate":{label:"Host: duplicate a timeline",group:"Hosts",effect:!0,hosts:["resolve"],about:"A copy of `timeline` under `name` (made unique: never over another timeline), opened. Answers `timeline`: its name, for the next host.apply.",params:{...Zn,timeline:{type:"string",required:!0},name:{type:"string"}},run:async e=>{let t=await Be("host_apply",{host:It(e),timeline:e.timeline,ops:[{op:"timeline_duplicate",name:e.name||`${e.timeline}_RECONFORMED`}]}),n=t.results?.[0]?.name;if(!n)throw new L("engine",`Resolve did not duplicate ${e.timeline}: ${String(t.text).split(`
|
|
215
|
-
`)[0]}`);return is.clear(),{ok:!0,text:`made ${n}`,timeline:n}}},"plan.vfx_pulls":{label:"Plan VFX pulls",group:"Planners",effect:!1,about:"Markers of `color` \u2192 numbered shots (prefix, increment, digits) with their plates (the clips under each marker; hero = lowest | highest track) and the reference_track clip; rows per pull, and the string-out with handles and a gap between shots.",params:{live:{type:"object",required:!0},color:{type:"string"},prefix:{type:"string"},increment:{type:"number"},digits:{type:"number"},handles:{type:"number"},gap:{type:"number"},start_frame:{type:"number"},hero:{type:"string"},reference_track:{type:"number"},skip_disabled:{type:"boolean"},naming:{type:"plates|scene_take|clip"},folder:{type:"string",about:"the shot folder: {prefix} {shot} {number} {scene} {take}"},names:{type:"string",about:`the artist's own pull names: "VFX_0010_PLATE01=SMOKE_0010, \u2026"`}},run:async e=>Eh(await Gb(e.live),{...e.names?{names:String(e.names)}:{},naming:["scene_take","clip"].includes(String(e.naming))?e.naming:"plates",folder:e.folder?String(e.folder):void 0,color:String(e.color??"Blue"),prefix:String(e.prefix??"VFX"),increment:Number(e.increment??10),digits:Number(e.digits??4),handles:Number(e.handles??8),gap:Number(e.gap??24),startFrame:Number(e.start_frame??1001),hero:e.hero==="highest"?"highest":"lowest",referenceTrack:Number(e.reference_track)||void 0,skipDisabled:e.skip_disabled!==!1})},"plan.output_blanking":{label:"Output blanking for the aspect",group:"Planners",effect:!1,about:"The timeline's output blanking (Resolve 21.1+) that shows `aspect` in the checked raster: even bars, top and bottom or left and right; nothing when it is already set so.",params:{aspect:{type:"string",required:!0},check:{type:"object",required:!0,about:"qc_blanking's result (its raster)"},live:{type:"object"}},run:async e=>{let t=Ag(e.aspect),[n,r]=e.check.raster;if(t==null)return[];let o=Ig(t,n,r),s=e.live?.output_blanking;return s&&["top","bottom","left","right"].every(i=>s[i]===o[i])?[]:[{op:"timeline_output_blanking",...o}]}},"plan.vfx_next_marker":{label:"The next VFX marker",group:"Planners",effect:!1,about:"A marker at the read's playhead named for the next shot number on the grid (after every shot the plan holds): prefix_NNNN, in `color`.",params:{live:{type:"object",required:!0},plan:{type:"object",required:!0},color:{type:"string"},prefix:{type:"string"},digits:{type:"number"},increment:{type:"number"}},run:async e=>{let t=e.live,n=Number(e.increment??10)||10;if(t.playhead==null)throw new L("unsupported","the host did not say where its playhead is (Resolve does)");let r=t.markers.find(i=>!i.cells.item_id&&Number(i.cells.frame)===t.playhead);if(r)throw new L("usage",`a marker is already at the playhead ("${r.cells.name??""}"); move the playhead`);let o=Math.max(0,...(e.plan.shots??[]).map(i=>i.number)),s=Math.floor(o/n)*n+n;return[{op:"marker_add",frame:t.playhead,color:String(e.color??"Blue"),name:`${e.prefix??"VFX"}_${String(s).padStart(Number(e.digits??4),"0")}`,note:"conform.tools VFX Pulls"}]}},"plan.vfx_names":{label:"Plan shot names",group:"Planners",effect:!1,about:"The shot names onto their markers, for the shots with a kept pull.",params:{plan:{type:"object",required:!0},rows:{type:"array",required:!0}},run:async e=>Ah(e.plan,e.rows??[])},"vfx.stringout":{label:"Build the VFX string-out",group:"Planners",effect:!0,hosts:dr("open"),about:"The kept pulls end to end (handles, a gap between shots) as a new timeline <name>_VFX_STRINGOUT in the host, linked to the clips already there; its name and start frame for host.render.",params:{...Zn,live:{type:"object",required:!0},plan:{type:"object",required:!0},rows:{type:"array",required:!0}},run:async e=>{let t=e.live,n=Ih(e.plan,e.rows??[]);if(!n.length)throw new L("invalid_args","no kept pull has linked media");let o=(await bt(t.session_id)).session.timelines?.find(u=>u.kind!=="compound"),s=await Be("timeline_author",{name:`${t.timeline}_VFX_STRINGOUT`,fps_num:o?.fps_num??24,fps_den:o?.fps_den??1,width:o?.resolution_w??1920,height:o?.resolution_h??1080,shots:n.map(u=>({path:u.media,source_in:u.src_in,duration:u.src_out-u.src_in,at:u.rec_in,track:1}))});await Be("timeline_edit",{session_id:s.session_id,kind:"add_markers",args:{markers:n.map(u=>({time:u.rec_in,duration:Math.max(1,u.src_out-u.src_in),name:"conform.tools VFX Pulls",color:u.role==="REFERENCE"?"Purple":"Blue",note:`${u.name} \xB7 Folder: ${u.shot}${u.role==="REFERENCE"?" \xB7 Reference":""}`}))}});let i=It(e)==="resolve"&&t.host==="resolve"&&t.timeline?t.timeline:void 0,a=await Be("host_open",{host:It(e),session_id:s.session_id,link_existing:!0,...i?{settings_from:i}:{}}),l=String(a.timeline),c=It(e)==="resolve"?Number((await Be("host_items",{timeline:l,kind:"video",track:1})).start_frame??0):0;return{ok:!0,text:String(a.text).split(`
|
|
216
|
-
`)[0],timeline:l,start_frame:c}}},"plan.vfx_renders":{label:"Plan pull renders",group:"Planners",effect:!1,about:"One render job per kept pull from the built string-out (its timeline start), into root/<shot>/, plates and reference each with their preset.",params:{plan:{type:"object",required:!0},rows:{type:"array",required:!0},start_frame:{type:"number"},root:{type:"string",required:!0},plate_preset:{type:"string"},reference_preset:{type:"string"}},run:async e=>{if(e.start_frame===void 0)throw new L("invalid_args","build the string-out first (switch on Build)");return Ph(e.plan,e.rows??[],Number(e.start_frame),String(e.root),String(e.plate_preset??""),String(e.reference_preset??""))}},"plan.vfx_cut_renders":{label:"Plan pull renders off the cut",group:"Planners",effect:!1,about:"One render job per kept pull straight off the cut (no string-out): a plate with only its track on, a reference with every track; record span \xB1 handles; into root/<shot>/.",params:{plan:{type:"object",required:!0},rows:{type:"array",required:!0},live:{type:"object",required:!0},handles:{type:"number"},root:{type:"string",required:!0},plate_preset:{type:"string"},reference_preset:{type:"string"}},run:async e=>Mh(e.plan,e.rows??[],e.live,Number(e.handles??8),String(e.root),String(e.plate_preset??""),String(e.reference_preset??""))},"plan.marker_renders":{label:"Plan marker renders",group:"Planners",effect:!1,about:`One render job per marker of \`color\` (scope all | duration | frame), named by a delivery convention (naming: ${Fh.map(([e])=>e).join(" | ")}; fields {show, season, episode, film, reel, version, artist \u2026}), with handles, into the convention's folder under root. Rows carry the job; a name two jobs share is marked dupe.`,params:{live:{type:"object",required:!0},color:{type:"string"},scope:{type:"string"},naming:{type:"string"},handles:{type:"number"},fields:{type:"object"},root:{type:"string",required:!0},preset:{type:"string"},folder:{type:"string",about:"a folder template instead of the convention's"},template:{type:"string",about:"a name pattern instead of the convention's: {MARKER} {TL_TC} {SRC_TC} {N} {show} {episode} \u2026"},case:{type:"none|uppercase|lowercase"}},run:async e=>Oh(e.live,{...e.folder?{folder:String(e.folder)}:{},...e.template?{template:String(e.template)}:{},...e.case?{case:String(e.case)}:{},color:String(e.color??"Blue"),scope:["all","duration","frame"].includes(String(e.scope))?e.scope:"all",naming:String(e.naming??"conformtools"),handles:Number(e.handles??0),fields:Object.fromEntries(Object.entries(e.fields??{}).filter(([,t])=>t!==void 0&&t!=="").map(([t,n])=>[t,String(n)])),root:String(e.root??""),preset:e.preset?String(e.preset):void 0})}};for(let[e,t]of Object.entries(Vb))ai[`edit.${e}`]={label:`Edit: ${t}`,group:"Host edits",effect:!1,hosts:dr("apply").filter(n=>zh(n,e)),about:`One '${e}' edit per row (clip rows or live items), with the other args as its fields (host_apply's '${e}'); feed the result to host.apply.`,params:{rows:{type:"array",about:"the items to edit; leave out for a one-off edit"}},run:async n=>g$(e,n)};var y$={"resolve.pull":"host.read","resolve.apply":"host.apply",...Object.fromEntries(Object.keys(Vb).map(e=>[`resolve.${e}`,`edit.${e}`]))},w$={join:"Join timelines end to end",remove_audio:"Remove audio",stringout:"String-out with handles",add_handles:"Add handles (new timeline)",all_clips:"All clips (new timeline)",reformat:"Change the raster",timeline_rate:"Change the frame rate",add_markers:"Add markers",add_track:"Add a track",delete_track:"Delete a track",add_clip:"Cut a media file in",transform:"Transform a clip",trim:"Trim a clip",slip:"Slip a clip",delete:"Delete a clip",move_clip:"Move a clip",new_timeline:"New empty timeline",carry:"Carry a finished cut's sizing / crop / opacity / effects onto a new cut"},k$=new Set(["add_handles","all_clips","stringout"]);for(let[e,t]of Object.entries(w$))ai[`timeline.${e}`]={label:`Timeline: ${t}`,group:"Timeline",effect:!1,about:`timeline_edit '${e}' on the session (frame-accurate, on the IR, no host needed): its args as this block's; \`sources\` = other sessions whose timelines take part (join several reads).`,params:{session_id:{type:"string",required:!0},sources:{type:"array"}},run:async(n,r)=>{let{session_id:o,...s}=n;if(k$.has(e)){let c=new Map;for(let u of[o,...n.sources??[]])u&&await d$(String(u),c)}let i=await Be("timeline_edit",{session_id:o,kind:e,args:s},r),a=i.meta??{},l=typeof a.timeline_id=="string"?[a.timeline_id]:(a.timelines??[]).map(c=>c.id);return{...i,session_id:o,...l.length?{timeline_id:l[0],timeline_ids:l}:{}}}};ai["timeline.read_many"]={label:"Read timelines",group:"Timeline",effect:!1,about:"Read several timeline files (any host): the first as session_id, the rest as sources for timeline.join and the other timeline blocks.",params:{paths:{type:"array",required:!0},engine:{type:"string"}},run:async(e,t)=>{let n=(e.paths??[]).map(o=>String(o).trim()).filter(Boolean);if(!n.length)throw new L("invalid_args","no timeline files");let r=[];for(let o of n)r.push(String((await Be("timeline_read",{path:o,...e.engine?{engine:e.engine}:{}},t)).session_id));return{ok:!0,text:`read ${r.length} timeline file(s)`,session_id:r[0],sources:r.slice(1),sessions:r}}};var _$=new Set(["timeline_align","timeline_diff"]);function Jb(e){let t=e.startsWith("verb.")?wn(e.slice(5)):void 0;if(!t)return null;let n=Pf(f.object(t.inputSchema));return{label:t.title??t.name,group:"conform.tools",about:String(t.description??"").split(". ")[0],effect:!li.has(t.name)&&!_$.has(t.name),params:Object.fromEntries(Object.entries(n.properties??{}).map(([r,o])=>[r,{type:o.enum?o.enum.join("|"):o.type,about:o.description,required:n.required?.includes(r)}])),run:(r,o)=>Be(t.name,r,o)}}var _u=e=>ai[y$[e]??e]??Jb(e),vu=e=>!!_u(e);function Xb(){let e=ss.filter(t=>!["tool","account_login","account_logout","report","job"].includes(t.name)).map(t=>({use:`verb.${t.name}`,...Jb(`verb.${t.name}`)}));return[...Object.entries(ai).map(([t,n])=>({use:t,...n})),...e].map(({run:t,...n})=>n)}var v$=e=>Fg[e]?.slug??e;async function T$(e){let t=e.live;if(e.target==="clips")return t.items.filter(s=>s.kind==="video").sort((s,i)=>s.start-i.start||s.track-i.track).map(s=>({id:s.id,name:s.name,where:`V${s.track}`,op:{op:"name",item:{track:s.track,start:s.start}}}));if(e.target==="pool"&&It(e)!=="resolve")throw new L("unsupported",`${It(e)}: renaming media pool clips is Resolve only (rename the timeline clips or the timelines)`);let n=await Be("host_project",{host:It(e),clips:e.target==="pool"});if(e.target==="timelines"){let s=new Map;return(n.timelines??[]).map(i=>{let a=s.get(i)??0;return s.set(i,a+1),{id:a?`${i}#${a+1}`:i,name:i,where:"timeline",op:{op:"timeline_rename",timeline:i,...a?{nth:a}:{}}}})}let r=s=>[...s.clip_list??[],...(s.folders??[]).flatMap(r)],o=String(e.folder??"");return r(n.pool).filter(s=>s.type?.toLowerCase()!=="timeline"&&(!o||s.folder===o||e.subfolders!==!1&&s.folder.startsWith(`${o}/`))).map(s=>({id:s.id,name:s.name,where:s.folder||"Master",op:{op:"pool_rename",clip:s.id}}))}function x$(e,t,n,r,o=0){let s=e.graphics.flatMap(m=>m.files),i=r?v$(r):s[0]?.position,a=[...new Map(s.map(m=>[m.format,m.width/m.height])).entries()],l=t&&n?t/n:16/9,c=a.sort((m,h)=>Math.abs(Math.log(m[1]/l))-Math.abs(Math.log(h[1]/l)))[0]?.[0],u=e.graphics.map(m=>m.files.find(h=>h.position===i&&h.format===c)??m.files.find(h=>h.format===c)).filter(m=>!!m),p=o,d=u.map(m=>{let h=p;return p+=m.frames,h});return{paths:u.map(m=>m.path),at:d,folder:`Graphics/${e.out_dir.split(/[\\/]/).pop()}`}}var as=()=>B(Xe(),"move-undo");async function S$(e,t){let n=Qn(t),r=t.slice(0,t.length-n.length);for(let o=0;;o++){let s=B(e,o?`${r} (${o})${n}`:t);if(!await nt(s))return s}}async function Qb(e,t){try{await fo(e,t);return}catch(n){if(!/EXDEV|cross-device/i.test(String(n.message??n)))throw n}if(await Zo(e,t),(await At(t)).size!==(await At(e)).size)throw await Vt(t),new Error("the copy's size differs; the original was kept");await Vt(e)}async function Yb(e,t,n){if(!await nt(t)||!(await At(t)).isDirectory)throw new L("invalid_args",`not a folder: ${t}`);let r=B(t,".conform-tools-write-check.tmp");try{await Ve(r,"ok"),await Vt(r)}catch(s){throw new L("refused",`cannot write to ${t}: ${s.message}`)}let o={moved:[],skipped:[],failed:[]};for(let[s,i]of[...new Set(e)].entries()){if(n?.(s,e.length,ie(i)),!await nt(i)){o.skipped.push(i);continue}try{let a=await S$(t,ie(i));await Qb(i,a),o.moved.push({source:i,destination:a})}catch(a){o.failed.push({path:i,error:a.message})}}return o.moved.length&&(o.undo_id=`files-${Date.now().toString(36)}`,await Ke(as()),await Ve(B(as(),`${o.undo_id}.json`),JSON.stringify(o.moved))),o}async function Tu(e){let t={moved:[],skipped:[],failed:[]},n=e.filter(l=>l.from!==l.to),r=new Set(n.map(l=>l.from)),o=new Set;for(let l of n){if(o.has(l.to))throw new L("refused",`two files would be named ${ie(l.to)}`);if(o.add(l.to),!r.has(l.to)&&await nt(l.to))throw new L("refused",`${ie(l.to)} already exists and is not being renamed: nothing moved`)}let s=[];for(let l of n)await nt(l.from)?s.push(l):t.skipped.push(l.from);let i=`.ct-rename-${Date.now().toString(36)}`,a=[];for(let l of s){let c=`${l.from}${i}`;try{await fo(l.from,c),a.push({...l,tmp:c})}catch(u){t.failed.push({path:l.from,error:u.message})}}for(let l of a)try{await fo(l.tmp,l.to),t.moved.push({source:l.from,destination:l.to})}catch(c){await fo(l.tmp,l.from).catch(()=>{}),t.failed.push({path:l.from,error:c.message})}return t.moved.length&&(t.undo_id=`files-${Date.now().toString(36)}`,await Ke(as()),await Ve(B(as(),`${t.undo_id}.json`),JSON.stringify({rename:!0,moves:t.moved}))),t}async function Zb(e){let t=B(as(),`${e.replace(/[^\w-]/g,"")}.json`);if(!await nt(t))throw new L("not_found",`no file moves recorded as ${e}`);let n=JSON.parse(await et(t));if(!Array.isArray(n)&&"odd"in n){let{analysisOp:i}=await import("./analysis-engine-M7W32RRC.js"),a=await i({op:"odd_undo",fixed:n.fixed});return a.errors?.length||await Vt(t),{restored:a.restored??0,failed:(a.errors??[]).map(l=>({path:"",error:l}))}}if(!Array.isArray(n)&&"sort"in n){let{analysisOp:i}=await import("./analysis-engine-M7W32RRC.js"),a=await i({op:"sort_undo",request:n});return a.errors?.length||await Vt(t),{restored:a.restored??0,failed:(a.errors??[]).map(l=>({path:"",error:l}))}}if(!Array.isArray(n)&&"patch"in n){let{undoPatch:i}=await import("./sequence-patch-CN4VC5W3.js"),a=await i(n);return a.failed.length||await Vt(t),a}if(!Array.isArray(n)){let i=await Tu(n.moves.map(a=>({from:a.destination,to:a.source})));return i.undo_id&&await Vt(B(as(),`${i.undo_id}.json`)),i.failed.length||await Vt(t),{restored:i.moved.length,failed:i.failed}}let r=n,o=0,s=[];for(let i of r)try{if(await nt(i.source))throw new Error("a file is at the original path again; left where it is");await Ke(i.source.replace(/[\\/][^\\/]*$/,"")),await Qb(i.destination,i.source),o++}catch(a){s.push({path:i.destination,error:a.message})}return s.length||await Vt(t),{restored:o,failed:s}}var $$=e=>e.length>4?e.replace(/(ings?|ers?|ed|es|s)$/,"").replace(/e$/,""):e,xu=e=>e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(" ").filter(Boolean).map($$);var R$=new Set(xu("a an the and or but to of in on at by for from with into onto as is are be been do does make made can could please me my i we our you your it its this that these those them they there here what which how when where all every each any some one just only also then than so not no up out over use using want need get got let tell show give know see look help like have has did done go going would should will file files folder clip clips timeline timelines thing things way").concat(["{","}"]));function Su(e){return[...new Set(xu(e.replace(/\{[^{}]*\}/g," ")).filter(t=>t.length>1&&!R$.has(t)))]}var Da=(e,t)=>e===t||e.length>=4&&t.length>=4&&(e.startsWith(t)||t.startsWith(e)),C$=.4;function ey(e,t,n=5){let r=Su(e);if(!r.length)return[];let o=t.map(l=>({d:l,head:Su(`${l.id.replace(/[_-]/g," ")} ${l.title} ${(l.aka??[]).join(" ")}`),body:Su(l.text)})),s=l=>Math.log(1+o.length/(1+o.filter(c=>c.head.some(u=>Da(l,u))||c.body.some(u=>Da(l,u))).length)),i=r.map(s),a=i.reduce((l,c)=>l+c,0);return o.map(({d:l,head:c,body:u})=>{let p=r.reduce((d,m,h)=>d+i[h]*(c.some(g=>Da(m,g))?1:u.some(g=>Da(m,g))?.6:0),0);return{id:l.id,title:l.title,score:Math.round(p/a*100)/100}}).filter(l=>l.score>=C$).sort((l,c)=>c.score-l.score||l.id.localeCompare(c.id)).slice(0,n)}async function ty(e){let t=$u(await e),[n,r,{QuickJSWASMModule:o}]=await Promise.all([t.importModuleLoader().then($u),t.importFFI(),import("./module-ES6BEMUI-L6VQ7K3J.js").then($u)]),s=await n();s.type="sync";let i=new r(s);return new o(s,i)}function $u(e){return e&&"default"in e&&e.default?e.default&&"default"in e.default&&e.default.default?e.default.default:e.default:e}var E$={type:"sync",importFFI:()=>import("./ffi-7KTOX2T4.js").then(e=>e.QuickJSFFI),importModuleLoader:()=>import("./emscripten-module-Q67P5WYC-HW3D2R5O.js").then(e=>e.default)},ny=E$;var lk=_S(ik(),1);var U2=256*2**20,H2=3e4,Kp=200,W2,ak="async function __main() {",z2='const ct = new Proxy({}, { get: (_, name) => typeof name !== "string" || name === "then" ? undefined : (args = {}) => __call(name, JSON.stringify(args ?? {})).then(JSON.parse, (e) => { const o = JSON.parse(e); const x = new Error(o.message); x.code = o.code; x.verb = name; throw x; }) });';function G2(e){try{return(0,lk.transform)(`${ak}${e}
|
|
217
|
-
}`,{transforms:["typescript"],disableESTransforms:!0}).code}catch(t){throw new L("invalid_args",`the script does not parse: ${t.message.replace(/\((\d+):(\d+)\)/,(n,r,o)=>`(line ${r}, column ${r==="1"?Number(o)-ak.length:o})`)}`)}}async function ck(e,t,{signal:n,onCall:r,cpuMs:o=H2}={}){let s=G2(e),a=(await(W2??=ty(ny))).newRuntime();a.setMemoryLimit(U2),a.setMaxStackSize(2**20);let l=performance.now();a.setInterruptHandler(()=>n?.aborted||performance.now()-l>o);let c=a.newContext(),u=[],p=[],d=!0,m=()=>{d&&(l=performance.now(),a.executePendingJobs())},h=new Set;try{let g=c.newObject();for(let v of["log","info","warn","error"])c.newFunction(v,(...R)=>{u.length<Kp?u.push(R.map(S=>{let T=c.dump(S);return typeof T=="string"?T:JSON.stringify(T)}).join(" ")):u.length===Kp&&u.push(`\u2026 (console lines after ${Kp} dropped)`)}).consume(R=>c.setProp(g,v,R));c.setProp(c.global,"console",g),g.dispose(),c.newFunction("__call",(v,R)=>{let S=c.newPromise();h.add(S);let T=c.getString(v),x=c.getString(R);return p.push(T),r?.(p.length,T),Promise.resolve().then(()=>t(T,JSON.parse(x))).then($=>{d&&S.alive&&c.newString(JSON.stringify($??null)).consume(U=>S.resolve(U))},$=>{let U=$ instanceof L?$:new L("engine",$ instanceof Error?$.message:String($));d&&S.alive&&c.newString(JSON.stringify({code:U.code,message:U.message})).consume(E=>S.reject(E))}).finally(()=>{h.delete(S),S.alive&&S.dispose(),m()}),S.handle}).consume(v=>c.setProp(c.global,"__call",v));let y=c.evalCode(`${z2} ${s}
|
|
218
|
-
__main();`,"script"),k=c.unwrapResult(y),b=c.resolvePromise(k);k.dispose(),m();let w=new Promise((v,R)=>{n?.aborted&&R(new L("cancelled","script cancelled")),n?.addEventListener("abort",()=>R(new L("cancelled","script cancelled")),{once:!0})}),_=await Promise.race([b,w]);if(_.error){let v=_.error.consume(S=>c.dump(S));if(typeof v=="object"&&v?.message==="interrupted"&&n?.aborted)throw new L("cancelled","script cancelled");if(typeof v=="object"&&v?.message==="interrupted")throw new L("refused",`the script computed for over ${o/1e3} s without calling a verb (a loop that never ends?) and was stopped`);let R=typeof v=="object"?v.verb?`ct.${v.verb}: ${v.message}`:`${v.name??"Error"}: ${v.message}${v.stack?`
|
|
219
|
-
${v.stack.replace(/^/gm," ").trimEnd()}`:""}`:String(v);throw new L(typeof v=="object"&&v.code?v.code:"engine",`the script stopped after ${p.length} call${p.length===1?"":"s"}: ${R}${u.length?`
|
|
220
|
-
console:
|
|
221
|
-
${u.join(`
|
|
222
|
-
`)}`:""}`,{calls:p})}return{value:_.value.consume(v=>c.dump(v)),logs:u,calls:p}}finally{d=!1;for(let g of h)g.alive&&g.dispose();c.dispose(),a.dispose()}}function uk(e){let t=e._def;if(t.typeName)return t.typeName;let n=typeof t.type=="string"?t.type:"";return n==="pipe"?"ZodPipeline":`Zod${n.charAt(0).toUpperCase()}${n.slice(1)}`}function Vn(e){let t=e._def;switch(uk(e)){case"ZodString":return"string";case"ZodNumber":return"number";case"ZodBoolean":return"boolean";case"ZodLiteral":return(t.values??[t.value]).map(n=>JSON.stringify(n)).join(" | ");case"ZodEnum":return Object.values(t.entries??t.values).map(n=>JSON.stringify(n)).join(" | ");case"ZodNativeEnum":return Object.values(t.values).map(n=>JSON.stringify(n)).join(" | ");case"ZodArray":{let n=Vn(t.element??t.type);return/[ |]/.test(n)?`(${n})[]`:`${n}[]`}case"ZodTuple":return`[${t.items.map(Vn).join(", ")}]`;case"ZodObject":return mk(e.shape);case"ZodRecord":return`Record<string, ${Vn(t.valueType)}>`;case"ZodUnion":case"ZodDiscriminatedUnion":return t.options.map(Vn).join(" | ");case"ZodIntersection":return`${Vn(t.left)} & ${Vn(t.right)}`;case"ZodOptional":case"ZodDefault":case"ZodCatch":case"ZodReadonly":return Vn(t.innerType);case"ZodNullable":return`${Vn(t.innerType)} | null`;case"ZodEffects":return Vn(t.schema);case"ZodPipeline":return Vn(t.in);case"ZodLazy":return Vn(t.getter());default:return"unknown"}}var dk=e=>e.isOptional()||uk(e)==="ZodDefault",pk=(e,t)=>e?`${t}/** ${e.replace(/\*\//g,"*\\/").replace(/\s*\n\s*/g," ")} */
|
|
223
|
-
`:"";function mk(e,t=" "){let n=Object.keys(e);return n.length?`{
|
|
224
|
-
${n.map(r=>`${pk(e[r].description,t)}${t}${/^[A-Za-z_$][\w$]*$/.test(r)?r:JSON.stringify(r)}${dk(e[r])?"?":""}: ${Vn(e[r])};`).join(`
|
|
225
|
-
`)}
|
|
226
|
-
${t.slice(2)}}`:"{}"}function fk(e,t={}){return["/** Every verb's answer: its structured fields plus `text`, the same answer as the tool gives. A failed verb throws an Error with `code` and `verb`. */","type Answer = { ok: boolean; text: string; [field: string]: any };",`declare const ct: {
|
|
227
|
-
${e.map(r=>`${pk(r.description," ")} ${r.name}(args${Object.values(r.inputSchema).every(dk)?"?":""}: ${mk(r.inputSchema," ")}): Promise<${t[r.name]?`Answer & ${t[r.name]}`:"Answer"}>;`).join(`
|
|
228
|
-
`)}
|
|
229
|
-
};`].join(`
|
|
230
|
-
`)}function Pl(e,t=0){if(e==null)return"null";if(Array.isArray(e))return{arr:e.slice(0,50).map(r=>Pl(r,t)).reduce(Fi,"null")};if(typeof e!="object")return typeof e;if(t>=3)return"object";let n=Object.keys(e).filter(r=>r!=="text");return n.length>40||n.some(r=>!/^[a-z][a-z0-9_]*$/i.test(r))?"Record<string, any>":{obj:Object.fromEntries(n.map(r=>[r,Pl(e[r],t+1)]))}}function Fi(e,t){if(e==="null")return t;if(t==="null"||e===t)return e;if(typeof e=="object"&&typeof t=="object"){if("arr"in e&&"arr"in t)return{arr:Fi(e.arr,t.arr)};if("obj"in e&&"obj"in t){let n={...e.obj};for(let[r,o]of Object.entries(t.obj))n[r]=r in n?Fi(n[r],o):o;return{obj:n}}}return"any"}function Oi(e){if(typeof e=="string")return e;if("arr"in e){let n=Oi(e.arr);return/^[\w<>, ]+$|^\{.*\}$/.test(n)?`${n}[]`:`(${n})[]`}let t=Object.keys(e.obj);return t.length?`{ ${t.map(n=>`${n}: ${Oi(e.obj[n])}`).join("; ")} }`:"{}"}var xs=e=>Object.fromEntries(Object.entries(e.out).flatMap(([t,n])=>{let r=n?.session_id;return typeof r=="string"?[[t,r]]:[]})),Ss=new Map,K2=50,hk=(e,t)=>t.reduce((n,r)=>n?.[r],e);function Ar(e,t){if(oi(e)){for(let n of e.split("|")){let[r,...o]=n.trim().slice(1).split("."),s=hk(r==="in"?t.in:t.out[r],o);if(s!=null&&s!=="")return s}return}return Array.isArray(e)?e.map(n=>Ar(n,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,Ar(r,t)])):e}function bk(e,t){if(!e)return!0;if(e.includes(" & "))return e.split(" & ").every(o=>bk(o,t));let n=/^(.*?)(!=|=)(.*)$/.exec(e);if(!n){let o=Ar(e,t);return o!==void 0&&o!==!1}let r=String(Ar(n[1].trim(),t)??"");return n[2]==="="?r===n[3].trim():r!==n[3].trim()}function V2(e,t){let n=new Map(e.nodes.map(i=>[i.id,i])),r=new Set,o=(i,a)=>{if(oi(i))for(let l of i.split("|")){let c=l.trim().slice(1).split(/[.=!]/)[0];c&&c!=="in"&&a.push(c)}else Array.isArray(i)?i.forEach(l=>o(l,a)):i&&typeof i=="object"&&Object.values(i).forEach(l=>o(l,a));return a},s=i=>{if(r.has(i)||!n.has(i))return;r.add(i);let a=n.get(i);for(let l of o(a.when,o(a.args,[])))s(l)};return s(t),r}async function Mo(e,t,n={}){let r,o=0,s,i;if(n.resume){let h=Ss.get(n.resume.run_id);if(!h)throw new L("not_found","that run is no longer waiting (run the tool again)");Ss.delete(n.resume.run_id),{spec:e,ctx:r,at:o}=h,n.resume.inputs&&(r={...r,in:{...r.in,...n.resume.inputs}}),s=h.only?new Set(h.only):void 0;let g=e.nodes[o];if(h.inner){let y=await Mo({},{},{...n,resume:n.resume&&{run_id:h.inner.run_id,keep:n.resume.keep,...n.resume.inputs?{inputs:Ar(g.args,r)}:{}},until:void 0});if(y.state==="review")return gk(y,{spec:e,ctx:r,at:o,only:h.only,inner:{run_id:y.run_id,node:g.id}});if(y.state==="ready")return{state:"ready",node:g.id,label:y.label};if(!y.ok)return y;i=r.out[g.id]=y.output}else{let y=Ar(g.args.rows,r)??[],k=new Set(n.resume.keep),b=g.args.skip;i=r.out[g.id]=y.filter(w=>k.has(w.id)&&!(b&&w.cells[b]))}o++}else{let h=Object.fromEntries(e.inputs.map(g=>[g.id,t[g.id]??g.default]));for(let g of e.inputs)g.when&&!g.when.is.includes(String(h[g.when.input]??""))&&delete h[g.id];if(r={in:{...Object.fromEntries(Object.entries(t).filter(([g])=>g in h||!e.inputs.some(y=>y.id===g))),...h},out:{}},n.until){if(!e.nodes.some(g=>g.id===n.until))throw new L("not_found",`no node '${n.until}'`);s=V2(e,n.until)}}let a=[];for(;o<e.nodes.length;o++){let h=e.nodes[o];if(s&&!s.has(h.id)||!bk(h.when,r))continue;if(h.use.startsWith("tool.")){if(!n.tool)throw new L("invalid_args",`node '${h.id}': tools inside tools need the tool table`);let k=await n.tool(h.use.slice(5)),b=await Mo(k,Ar(h.args,r),{...n,until:void 0,resume:void 0});if(b.state==="review")return gk(b,{spec:e,ctx:r,at:o,only:s&&[...s],inner:{run_id:b.run_id,node:h.id}});if(b.state==="ready")return{state:"ready",node:h.id,label:`${k.name}: ${b.label}`,sessions:{...xs(r),...b.sessions}};if(!b.ok)return{...b,text:`${h.label??k.name}: ${b.text}`};i=r.out[h.id]=b.output??{ok:!0,text:b.text},a.push(b.text);continue}let g=_u(h.use);if(!g)throw new L("invalid_args",`node '${h.id}': no block '${h.use}'`);let y=h.label??g.label;if(h.use==="review"){let k=Ar(h.args.rows,r)??[],b=crypto.randomUUID();return yk(b,{spec:e,ctx:r,at:o,only:s&&[...s]}),{state:"review",run_id:b,node:h.id,label:y,rows:k,columns:h.args.columns??[],skip:h.args.skip,sessions:xs(r)}}if(n.preview&&g.effect)return{state:"ready",node:h.id,label:y,sessions:xs(r)};try{i=r.out[h.id]=await g.run(Ar(h.args,r),{signal:n.signal,progress:n.progress});let k=i?.text;g.effect&&typeof k=="string"&&a.push(k)}catch(k){return{state:"done",ok:!1,text:`${y}: ${k.message}`,node:h.id,sessions:xs(r)}}}let l=i&&typeof i=="object"&&!Array.isArray(i)?i:{},c=typeof l.text=="string"?l.text:Array.isArray(i)?`${i.length} result(s)`:i===void 0?"done":JSON.stringify(i).slice(0,2e3),u=a.length?a.join(`
|
|
231
|
-
`):c,p=Object.values(r.out).map(h=>h?.undo_id).filter(h=>typeof h=="string"),d=p.length?p.join("+"):void 0,m=Object.values(r.out).find(h=>typeof h?.clips=="object");return{state:"done",ok:l.ok!==!1,text:u,...d?{undo_id:d}:{},...typeof m?.timeline=="string"?{timeline:m.timeline}:{},...l.table?{table:l.table}:{},output:i,sessions:xs(r)}}function yk(e,t){for(Ss.set(e,{...t,at:t.at});Ss.size>K2;)Ss.delete(Ss.keys().next().value)}function gk(e,t){let n=crypto.randomUUID();return yk(n,t),{...e,run_id:n,sessions:{...xs(t.ctx),...e.sessions}}}var Po=new Map,J2=100,Vp=()=>new Date().toISOString();function Li(e){for(e.updated=Vp(),Po.set(e.id,e);Po.size>J2;)Po.delete(Po.keys().next().value);return xo({type:"run",run:e}),e}function Fl(e,t){return e.state=t,e.status=t.state==="review"?"review":t.state==="ready"||t.ok?"done":"failed",Li(e)}function Fo(e,t){return[...Po.values()].filter(n=>n.project===e&&(!t||n.tool===t)).reverse()}function Ni(e){return Po.get(e)??[...Po.values()].find(t=>t.state?.state==="review"&&t.state.run_id===e)}async function wk(e,t,n,r={}){if(r?.until||r?.preview&&n.by==="app")return{state:await Mo(e,t,r)};let o=Li({id:crypto.randomUUID(),tool:e.id,name:e.name,project:n.project,by:n.by,inputs:t,status:"running",started:Vp(),updated:Vp()});try{let s=await Mo(e,t,r);return{run:Fl(o,s),state:s}}catch(s){throw Fl(o,{state:"done",ok:!1,text:s.message}),s}}function X2(e,t,n,r){if(n)return n;let o=new Set(r?.map(s=>(typeof s=="number"||/^\d+$/.test(String(s)))&&!e.some(i=>i.id===String(s))?e[Number(s)-1]?.id:String(s)));return e.filter(s=>!(t&&s.cells[t])&&!o.has(s.id)).map(s=>s.id)}async function kk(e,t,n={}){let r=t.id?Ni(t.id):Fo(e,t.tool).find(i=>i.status==="review");if(!r){if(t.id)return{state:await Mo({},{},{...n,resume:{run_id:t.id,keep:t.keep??[],inputs:t.inputs}})};throw new L("not_found",t.tool?`nothing from ${t.tool} is waiting for an OK`:"nothing is waiting for an OK in this job")}if(r.state?.state!=="review")throw new L("invalid_args",`${r.name} is not waiting for an OK (it is ${r.status})`);let o=r.state,s=X2(o.rows,o.skip,t.keep,t.drop);r.status="running",Li(r);try{let i=await Mo({},{},{...n,resume:{run_id:o.run_id,keep:s,inputs:t.inputs}});return{run:Fl(r,i),state:i}}catch(i){throw Fl(r,{state:"done",ok:!1,text:i.message}),i}}function _k(e,t){let n=t.id?Ni(t.id):Fo(e,t.tool).find(r=>r.status==="review");if(!n||n.status!=="review")throw new L("not_found","nothing is waiting for an OK");return n.status="dropped",Li(n)}async function vk(e,t,n){let r=a=>a.status==="done"&&a.state?.state==="done"&&!!a.state.undo_id,o=t.id?Ni(t.id):Fo(e,t.tool).find(r);if(!o||!r(o))throw new L("not_found",o?`${o.name}'s run left nothing to undo`:"nothing in this job to undo");let s=o.state,i=await n(s.undo_id,s.timeline);if(!i.ok)throw new L("engine",i.text);return o.status="undone",o.undone=i.text,Li(o)}function Jp(e,t=25){let n=e.state,r=`${e.name} (${e.tool}) \xB7 run ${e.id} \xB7 ${e.status} \xB7 by ${e.by}`;if(e.status==="review"&&n?.state==="review"){let o=n.columns.length?n.columns.map(([i])=>i):[...new Set(n.rows.slice(0,20).flatMap(i=>Object.keys(i.cells)))].slice(0,6),s=n.rows.slice(0,t).map((i,a)=>` ${a+1}. [${i.id}] ${o.map(l=>`${l}: ${String(i.cells[l]??"")}`).join(" \xB7 ")}${n.skip&&i.cells[n.skip]?" (skipped)":""}`);return[`${r} \u2014 ${n.label}: ${n.rows.length} row(s) waiting for an OK`,...s,...n.rows.length>t?[` \u2026 ${n.rows.length-t} more`]:[]].join(`
|
|
232
|
-
`)}return n?.state==="done"?`${r} \u2014 ${e.undone?`undone: ${e.undone}`:n.text.split(`
|
|
233
|
-
`)[0]}${n.undo_id&&e.status==="done"?" (can undo)":""}`:r}function Tk(e){let t=e.state,n=t?.state==="review"?t:t?.state==="done"?t.table:void 0;if(!n)return null;let r=n.columns.length?n.columns:[...new Set(n.rows.flatMap(o=>Object.keys(o.cells)))].map(o=>[o,o]);return oa(r.filter(([o])=>o!=="__keep").map(([o,s])=>({header:s||o,value:i=>{let a=i.cells[o];return a==null?"":typeof a=="object"?JSON.stringify(a):String(a)}})),n.rows)}function Q2(e){let t=e?.duration?.value,n=e?.duration?.rate;if(!t||!n)return"n/a";let r=o=>String(o).padStart(2,"0");if(n>=1e3){let o=t/n,s=Math.round((o-Math.floor(o))*1e3);return`${r(Math.floor(o/3600))}:${r(Math.floor(o/60)%60)}:${r(Math.floor(o)%60)}.${String(s).padStart(3,"0")}`}return He(Math.max(0,t),n)}function xk(e){for(let t of e?.streams??[])if(t.kind==="video"&&t.bit_depth!=null)return t.bit_depth;return null}var Xp=[{label:"Start TC",criterion:"timecode",standing:!0,get:e=>e?.source_timecode||"00:00:00:00",has:e=>!!e?.source_timecode},{label:"Reel",criterion:"reelName",get:e=>e?.reel_name||"n/a",has:e=>!!e?.reel_name},{label:"Duration",criterion:"totalDuration",get:e=>Q2(e?.available_range?.duration?.value?e.available_range:e?.declared_duration?{duration:e.declared_duration}:null),has:e=>(e?.available_range?.duration?.value??0)>0||(e?.declared_duration?.value??0)>0},{label:"Resolution",criterion:"resolution",get:e=>e?.source_resolution_w&&e?.source_resolution_h?`${e.source_resolution_w}\xD7${e.source_resolution_h}`:"n/a",has:e=>!!(e?.source_resolution_w&&e?.source_resolution_h)},{label:"Bit depth",criterion:"bitDepth",get:e=>{let t=xk(e);return t!=null?`${t}-bit`:"n/a"},has:e=>xk(e)!=null},{label:"Frame rate",criterion:"frameRate",standing:!0,get:e=>e?.source_fps!=null?Nc(e.source_fps):"n/a",has:e=>e?.source_fps!=null},{label:"Format",criterion:"fileFormat",get:e=>e?.container||"n/a",has:e=>!!e?.container},{label:"Codec",criterion:"codec",get:e=>e?.codec||"n/a",has:e=>!!e?.codec}],Sk=Xp.map(e=>e.label);var $k=["#","name","track","timeline","kind","item_index","enabled","timeline_range.start","timeline_range.dur","source_range.start","source_range.dur","media_reference_id","source_element_id","reel_name","source_timecode","nested_timeline_id","is_nested","is_multicam","is_reinterpreted","speed","speed_ramped","speed_reverse","scale","scale_x","scale_y","position_x","position_y","rotation","anchor_x","anchor_y","crop_left","crop_right","crop_top","crop_bottom","opacity","blend_mode","keyframes","effects",...Sk];function Y2(e){if(!e||typeof e!="object")return!1;let t=e,n=t.start,r=t.duration;return!!n&&!!r&&typeof n.value=="number"&&typeof r.value=="number"}function Ck(e,t,n){for(let[r,o]of Object.entries(t)){let s=e?`${e}.${r}`:r;if(o==null)n[s]=null;else if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")n[s]=o;else if(Y2(o))n[`${s}.start`]=Math.round(o.start.value),n[`${s}.dur`]=Math.round(o.duration.value);else if(Array.isArray(o))n[s]=o.length?`[${o.length}]`:null;else if(typeof o=="object"){let i=JSON.stringify(o);n[s]=i==="{}"?null:i}}}function Ek(e){let t=[],n=new Set,r=[],o=a=>{n.has(a)||(n.add(a),r.push(a))},s=0;for(let a of es(e))for(let l of a.tracks??[])for(let c of l.items??[]){if(c.kind==="gap")continue;let u={};u["#"]=++s,u.timeline=a.name,u.timeline_fps=Bt(a),u.track=Un(l,a.tracks??[]),Ck("",c,u);let p=(c.effects??[]).map(m=>m.name||m.plugin_name||m.kind||"").filter(Boolean);u.effect_names=p.length?p.join(", "):null,u.source_fps_n=Dc(e,c)?.source_fps??null;let d=Dc(e,c);for(let m of Xp){let h=d?m.get(d):null;u[m.label]=h==="n/a"?null:h}u.binding_state=d?d.binding_state??"unbound":null;for(let m of Object.keys(u))o(m);t.push({id:c.id,item:c,cells:u})}return{columns:[...$k,...r.filter(a=>!$k.includes(a))],rows:t}}var Rk=["name","binding_state","usage","origin","content_kind","kind","target_url","local_path","reel_name","reel_sources","source_timecode","available_range.start","available_range.dur","source_resolution_w","source_resolution_h","source_pixel_aspect","source_fps","container","codec","size_bytes","bitrate_bps","streams","display_name","file_modified_at","keykode","vendor_metadata","bundle","recipe","raw_extraction","metadata"];function Ak(e){let t=[],n=new Set,r=[],o=i=>{n.has(i)||(n.add(i),r.push(i))};for(let i of e){let a={};a.name=i.name,a.origin=i.origin,i.ref&&Ck("",i.ref,a),i.extra&&Object.assign(a,i.extra);for(let l of Object.keys(a))o(l);t.push({id:i.id,name:i.name,ref:i.ref,origin:i.origin,cells:a})}return{columns:[...Rk,...r.filter(i=>!Rk.includes(i))],rows:t}}var Z2={name:"Name",origin:"Origin",usage:"Usage",id:"ID",binding_state:"State",content_kind:"Kind",target_url:"Path",reel_name:"Reel",source_timecode:"Start TC",source_resolution_w:"Source W",source_resolution_h:"Source H",source_pixel_aspect:"PAR",source_fps:"FPS",size_bytes:"Size",codec:"Codec",container:"Format",declared_duration:"Declared",available_range:"Range",source_facts_origin:"Facts",coverage_reason:"Coverage",display_name:"Display name"};function Ol(e){let t=Z2[e];return t||e.split(".").map(n=>n.replace(/_/g," ").replace(/^./,r=>r.toUpperCase())).join(" \xB7 ")}var eF=/^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/,Oo="[-+]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][-+]?\\d+)?";function Lo(e){let t=e.trim();if(!eF.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}function tF(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string")return null;let t=Lo(e);if(t!==null)return t;let n=e.trim().match(new RegExp(`^(${Oo})\\s*[a-zA-Z%\xB0\xD7]*$`));if(!n)return null;let r=Number(n[1]);return Number.isFinite(r)?r:null}function Ik(e){let t=e.trim(),n=t.indexOf(".");if(n===-1||/[eE]/.test(t))return 1e-4;let r=t.length-n-1;return Math.max(1e-4,.5*Math.pow(10,-(r+1)))}function $s(e){let t=e.trim();if(!t||t.includes("...."))return null;let r=t.match(new RegExp(`^between\\s+(${Oo})\\s+and\\s+(${Oo})$`,"i"))??t.match(new RegExp(`^(${Oo})\\s*(?:\\.\\.\\.?|,,|\\s+to\\s+|-)\\s*(${Oo})$`,"i"));if(r){let a=Lo(r[1]),l=Lo(r[2]);return a===null||l===null?null:{op:"range",value:Math.min(a,l),high:Math.max(a,l)}}let o=t.match(new RegExp(`^(?:in\\s+)?(${Oo}(?:\\s*[,|]\\s*${Oo})+)$`,"i"));if(o){let a=o[1].split(/\s*[,|]\s*/).map(Lo);if(a.some(c=>c===null))return null;let l=a;return{op:"in",value:l[0],values:l,tolerance:1e-4}}let s=t.match(/^(>=|<=|!=|==|=|>|<)\s*(.+)$/);if(s){let a=Lo(s[2]);return a===null?null:{op:s[1]==="=="?"=":s[1],value:a,tolerance:Ik(s[2])}}let i=Lo(t);return i!==null?{op:"=",value:i,tolerance:Ik(t)}:null}function nF(e){let t=e.trim();if(!t)return null;let n=$s(t);if(n)return[n];let r=t.split(/(?:\s*(?:,|&|\band\b)\s*|\s+)(?=(?:>=|<=|!=|==|=|>|<))/i).map(s=>s.trim().replace(/(?:\s*(?:,|&|\band))+$/i,"").trim()).filter(Boolean);if(r.length<2)return null;let o=r.map($s);return o.some(s=>s===null)?null:o}function rF(e,t,n){if(!Number.isFinite(e))return!1;let r=n??t.tolerance??1e-6;switch(t.op){case"=":return Math.abs(e-t.value)<=r;case"!=":return Math.abs(e-t.value)>r;case">":return e>t.value;case"<":return e<t.value;case">=":return e>=t.value-r;case"<=":return e<=t.value+r;case"range":return e>=t.value-r&&e<=(t.high??t.value)+r;case"in":return(t.values??[t.value]).some(o=>Math.abs(e-o)<=r);default:return!1}}function Qp(e,t=0){if(t>4||e===null||e===void 0)return[];let n=tF(e);return n!==null?[n]:Array.isArray(e)?e.flatMap(r=>Qp(r,t+1)):typeof e=="object"?Object.values(e).flatMap(r=>Qp(r,t+1)):[]}function Rs(e,t,n="="){let r=nF(t);if(!r)return!1;let o=Qp(e);if(o.length===0)return!1;let s=Lo(t)!==null,i=r.map(a=>s&&n!=="="?{...a,op:n}:a);return o.some(a=>i.every(l=>rF(a,l)))}var Mk="Key > value \xB7 Key = value \xB7 Key ~ text \xB7 Key (exists)",Pk=">1.2 \xB7 <0.5 \xB7 =62.5 \xB7 !=0 \xB7 1..2 \xB7 61-64 \xB7 >61 <64 \xB7 in 5,6,8";var oF=/^is:(.*)$/,sF=/^([A-Za-z_][\w. -]*?)\s*(>=|<=|!=|=|>|<|:)\s*(.*)$/s,iF=/^"([^"]+)"\s*(>=|<=|!=|=|>|<|:)\s*(.*)$/s,Fk=/^\/(.*)\/([a-z]*)$/s,Yp=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function Nl(e){return e.match(/[^\s"]*(?::|=)in\s+[^\s"]+|(?:[^\s"]+|"[^"]*")+/gi)??[]}function Nk(e){return/^".*"$/s.test(e)?e.slice(1,-1):null}function Ok(e,t){let n=Yp(t);if(!n)return[];let r=Object.keys(e.cells),o=r.filter(i=>Yp(i)===n);return(o.length?o:r.filter(i=>Yp(i).includes(n))).map(i=>e.cells[i])}var aF=e=>e==null?null:String(e);function Ll(e,t,n){let r=aF(e),o=Nk(n.trim());if(o!=null)return r==null?!1:t==="="?r.toLowerCase()===o.toLowerCase():t==="!="?r.toLowerCase()!==o.toLowerCase():r.toLowerCase().includes(o.toLowerCase());let s=n.trim(),i=/^in\s+(.+)$/is.exec(s);if(i&&(t===":"||t==="="))return i[1].split(/\s*[,|]\s*/).some(l=>l!==""&&Ll(e,"=",l));if(!s)return r!=null&&r!==""&&r!=="n/a";if(s.includes("|")&&!Fk.test(s))return s.split("|").some(l=>l.trim()&&Ll(e,t,l));let a=Fk.exec(s);if(a){if(r==null)return!1;try{return new RegExp(a[1],a[2]||"i").test(r)}catch{return!1}}if(t===":"){let l=$s(s);return l&&!/^[-+]?[\d.]+$/.test(s)?Rs(e,s):l!=null&&Rs(e,s)||r!=null&&r.toLowerCase().includes(s.toLowerCase())}if($s(s)&&t!=="="&&t!=="!=")return Rs(e,t+s);if(t==="="||t==="!="){let l=$s(s)?Rs(e,s):r!=null&&r.toLowerCase()===s.toLowerCase();return t==="="?l:!l}return Rs(e,t+s)}function Zp(e,t,n){let r=iF.exec(t);if(r){let a=Ok(e,r[1]);return a.length>0&&a.some(l=>Ll(l,r[2],r[3]))}let o=Nk(t);if(o!=null)return Lk(e,o);let s=oF.exec(t);if(s){let a=n[s[1].toLowerCase()];return a?a(e):!1}let i=sF.exec(t.replace(/^"([^"]+)"(?=\s*(?:[<>!=:]))/,(a,l)=>l));if(i){let a=Ok(e,i[1]);return a.length?a.some(l=>Ll(l,i[2],i[3])):!1}return t.includes("|")?t.split("|").some(a=>a.trim()&&Zp(e,a.trim(),n)):Lk(e,t)}function Lk(e,t){let n=t.toLowerCase();return Object.values(e.cells).some(r=>r!=null&&String(r).toLowerCase().includes(n))}function em(e,t,n={}){let r=t.trim();if(!r)return!0;let o=r.split(/\s+OR\s+/);if(o.length>1)return o.some(i=>em(e,i,n));let s=Object.fromEntries(Object.entries(n).map(([i,a])=>[i.toLowerCase(),a]));return Nl(r).every(i=>{let a=i.startsWith("-")||i.startsWith("!"),l=a?i.slice(1):i;if(!l)return Zp(e,i,s);let c=Zp(e,l,s);return a?!c:c})}function Dk(e){return Object.keys(e).sort()}var jk={offline:e=>e.cells.binding_state!=null&&e.cells.binding_state!=="linked",rate_mismatch:e=>{let t=Number(e.cells.source_fps_n),n=Number(e.cells.timeline_fps);return e.cells.source_fps_n!=null&&t>0&&n>0&&Math.abs(t-n)>.001},stabilized:e=>/stabiliz/i.test(String(e.cells.effect_names??"")),effects:e=>!!e.cells.effect_names,retimed:e=>e.cells.speed_ramped===!0||e.cells.speed_reverse===!0||e.cells.speed!=null&&Math.abs(Number(e.cells.speed)-100)>1e-6,nested:e=>e.cells.kind==="nested"||e.cells.is_nested===!0,multicam:e=>e.cells.is_multicam===!0},Bk={unused:e=>Number(e.cells.usage??0)===0,offline:e=>e.cells.binding_state!=="linked",linked:e=>e.cells.binding_state==="linked"};function qk(e){let t=new Map;for(let n of e?.timelines??[])for(let r of n?.tracks??[])for(let o of r?.items??[]){let s=o?.media_reference_id;!s||o.kind==="gap"||t.set(s,(t.get(s)??0)+1)}return t}function lF(e){return(typeof e.display_name=="string"?e.display_name:"")||e.target_url&&e.target_url.split(/[\\/]/).pop()||e.id}function Uk(e,t={}){let n=qk(e),r=t.idPrefix??"mr:";return(e?.media_references??[]).flatMap(o=>{let s=lF(o);return t.skip?.(s)?[]:[{id:`${r}${o.id}`,name:s,ref:o,origin:"from timeline",extra:{usage:n.get(o.id)??0}}]})}function Hk(e,t){let n=e.map(r=>({header:Ol(r),value:o=>{let s=o.cells[r];return s==null?"":typeof s=="boolean"?s?"true":"false":s}}));return oa(n,[...t])}function Wk(e,t,n=new Date){let r=n.toISOString().slice(0,16).replace(/[-:T]/g,""),o=s=>s.replace(/[^a-zA-Z0-9_-]/g,"_");return`${r}_${o(e)}_${o(t)}.csv`}var zk=["clips","media","markers"],cF={clips:["#","timeline","track","name","timeline_range.start","timeline_range.dur","rec_in_tc","rec_out_tc","source_range.start","reel_name","speed","binding_state"],media:["name","binding_state","usage","codec","source_resolution_w","source_resolution_h","source_fps","source_timecode","target_url"],markers:["timeline","tc","color","name","note","duration","clip"]},tm=`Terms are separated by spaces and ALL must match; a leading - negates a term; OR (capitals, its own word) = either side (reel:A001 OR speed!=100). text = in any column; field:text = in that column (field:/regex/, field:"two words", field:a|b; a field name with a space is quoted: "Frame rate":!=24); numbers: ${Pk} (e.g. speed!=100, crop:1..2, track:in V5,V6 \u2014 whole-cell membership); field: alone = has a value; clips: overlaps:A..B = clips whose RECORD range touches A..B inclusive (record TC like 01:00:10:00, or timeline frames; overlaps:A alone = clips under that frame) \u2014 unlike timeline_range.start:A..B, which only asks where a clip starts. is:<lens> = a named question (clips: is:offline, is:visible = the topmost enabled picture somewhere, what actually plays, is:rate_mismatch, is:stabilized, is:effects, is:retimed, is:nested, is:multicam; media: is:unused, is:offline, is:linked; markers: is:<color>, is:duration). An unknown field or lens matches nothing.`,uF=/^([-!]?)overlaps?:(.+)$/i;function dF(e){let t=[];return{rest:Nl(e).filter(r=>{let o=uF.exec(r);if(!o)return!0;let[s,i=s]=o[2].split(/\.\.\.?|-(?=\d)/);return t.push(a=>{if(!a.item||!a.tl)return!1;let l=Bt(a.tl),c=He(a.tl.start_frame??0,l,!!a.tl.is_drop_frame),u,p;try{u=ur(s,l,c),p=ur(i,l,c)}catch{return!1}u>p&&([u,p]=[p,u]);let d=a.item.timeline_range.start.value,m=d+a.item.timeline_range.duration.value,h=d<=p&&m>u;return o[1]?!h:h}),!1}).join(" "),tests:t}}function pF(e){let t=s=>[s.timeline_range.start.value,s.timeline_range.start.value+s.timeline_range.duration.value],n=(e.tracks??[]).filter(s=>s.kind==="Video"&&s.enabled!==!1).sort((s,i)=>i.track_index-s.track_index).map(s=>s.items.filter(i=>i.enabled!==!1&&(i.kind==="clip"||i.kind==="nested")&&!i.title)),r=[...new Set(n.flat().flatMap(s=>t(s)))].sort((s,i)=>s-i),o=new Set;for(let s=0;s+1<r.length;s++){let i=r[s];for(let a of n){let l=a.find(c=>t(c)[0]<=i&&i<t(c)[1]);if(l){o.add(l.id);break}}}return o}var mF=/^([-!]?)is:visible$/i;function fF(e){let t=new Map,n=[];return{rest:Nl(e).filter(o=>{let s=mF.exec(o);return s?(n.push(i=>{if(!i.tl)return!1;t.has(i.tl)||t.set(i.tl,pF(i.tl));let a=t.get(i.tl).has(i.id);return s[1]?!a:a}),!1):!0}).join(" "),tests:n}}function hF(e,t,n){let r=e,o=es(r).filter(i=>!n||i.id===n);if(n&&!o.length){let i=es(r).map(a=>`${a.id} "${a.name}"`).join(", ");throw new L("not_found",`no timeline ${n} in this session (timelines: ${i||"none"})`)}if(t==="clips"){let i=new Set(o.map(p=>p.id)),a=new Map;for(let p of e.timelines){if(!i.has(p.id))continue;let d=Bt(p),m=h=>He(h+(p.start_frame??0),d,!!p.is_drop_frame);for(let h of p.tracks??[])for(let g of h.items??[]){let y=g.timeline_range.start.value,k=y+g.timeline_range.duration.value,b=Un({...h,name:null},p.tracks??[]);a.set(g.id,{tl:p,cells:{track_no:b,track_name:h.name??null,track_enabled:h.enabled!==!1,rec_in_tc:m(y),rec_out_tc:m(k)}})}}let l=Ek(r),c=l.rows.filter(p=>a.has(p.id)).map(p=>({...p,tl:a.get(p.id).tl,cells:{...p.cells,...a.get(p.id).cells}})),u=[...l.columns];return u.splice(u.indexOf("track")+1,0,"track_no","track_name","track_enabled"),u.splice(u.indexOf("timeline_range.dur")+1,0,"rec_in_tc","rec_out_tc"),{rows:c,columns:u,lenses:jk}}if(t==="media"){let i=Ak(Uk(r));return{rows:i.rows,columns:i.columns,lenses:Bk}}return{rows:o.flatMap(i=>oh(i,r).map(a=>({...a,id:`${i.id}:${a.id}`,cells:{timeline:i.name,...a.cells}}))),columns:["timeline","tc","frame","color","name","note","duration","frames","clip","item_id"],lenses:sh}}function gF(e,t,n){if(!e?.length)return cF[t].filter(i=>n.includes(i));let r=i=>i.toLowerCase().replace(/[^a-z0-9]/g,""),o=[],s=[];for(let i of e){let a=n.find(l=>l===i)??n.find(l=>r(l)===r(i)||r(Ol(l))===r(i));a?o.push(a):s.push(i)}if(s.length)throw new L("invalid_args",`unknown column${s.length>1?"s":""} ${s.join(", ")} for ${t} (columns: ${n.slice(0,60).join(", ")}${n.length>60?", \u2026":""})`,{available:n});return o}function Gk(e,t){let{rows:n,columns:r,lenses:o}=hF(e,t.table,t.timeline_id),s=gF(t.columns,t.table,r),i=fF(t.query?.trim()??""),{rest:a,tests:l}=dF(i.rest),c=[...i.tests,...l],u=n.filter(d=>c.every(m=>m(d))&&(!a||em(d,a,o))),p={table:t.table,columns:s,available:r,lenses:Dk(o),total:n.length,matched:u.length,fps:(()=>{let d=es(e).find(m=>!t.timeline_id||m.id===t.timeline_id);return d?Bt(d):void 0})(),rows:u.map(d=>({id:d.id,cells:Object.fromEntries(s.map(m=>[m,d.cells[m]??null]))}))};return t.csv&&(p.csv=t.table==="markers"&&!t.columns?.length?ih(u):Hk(s,u)),p}async function Kk(e,t,n){let r=e.table==="clips"?"Edit_Index":e.table==="media"?"Media":"Markers",o=await $f(t)?B(t,Wk(n,r)):t;return await Ve(o,e.csv??""),o}function Vk(e,t,n){let r=`${e.table}: ${e.matched} of ${e.total} row${e.total===1?"":"s"}${t?` match "${t}"`:""}`;if(!e.matched)return`${r}
|
|
234
|
-
lenses: ${e.lenses.map(p=>`is:${p}`).join(" ")||"(none)"}
|
|
235
|
-
columns: ${e.available.slice(0,40).join(", ")}${e.available.length>40?", \u2026":""}
|
|
236
|
-
grammar: ${tm}
|
|
237
|
-
field queries: ${Mk}`;let o=e.rows.slice(0,n),s=p=>(p==null?"":String(p)).replace(/\s+/g," ").slice(0,60),i=e.columns.map(p=>Math.min(60,Math.max(p.length,...o.map(d=>s(d.cells[p]).length)))),a=p=>p.map((d,m)=>d.padEnd(i[m])).join(" ").trimEnd(),l=[a(e.columns),...o.map(p=>a(e.columns.map(d=>s(p.cells[d]))))],c=e.matched>o.length?`TRUNCATED: showing ${o.length} of ${e.matched} matching rows \u2014 NOT the full list. Pass limit=${Math.min(e.matched,5e3)}, narrow the query, or out_path for the full CSV.
|
|
238
|
-
`:"",u=c?`
|
|
239
|
-
\u2026 ${e.matched-o.length} more not shown (see TRUNCATED above)`:"";return`${c}${r}
|
|
240
|
-
${l.join(`
|
|
241
|
-
`)}${u}`}var bF=/^0[1-4]_[A-Z_]+\//;function rm(e,t){let n=nm(e.target_url);if(!n)return"";let r=e.role==="reference"?"03_REFERENCES":"02_MEDIA";if(t&&e.target_url){let o=wF(e.target_url),s=o?o.replace(bF,""):n;return`${r}/${s}`}return`${r}/${n}`}function om(e,t,n){return{entries:yF(e,t,n).entries.map(s=>{if(s.inlineBytes)return{path:s.path,bytes:s.inlineBytes};if(s.sourceBasename)return{path:s.path,sourceBasename:s.sourceBasename};throw new Error(`folder-layout entry missing both inlineBytes and sourceBasename: ${s.path}`)})}}function yF(e,t,n){let r=[],o=new Map,s=new Set;for(let l of n.sourceFiles??[]){let c=Cs(`01_PROJECT_FILES/source/${l.name}`,s);r.push({path:c,section:"project-source",inlineBytes:l.data})}let i=new Set,a=(e.media_references??[]).filter(l=>{if(!l.target_url)return!1;let c=nm(l.target_url);if(!(c.length>0&&t.has(c)))return!1;let u=`${c.toLowerCase()}\0${l.role??""}`;return i.has(u)?!1:(i.add(u),!0)});for(let l of a){let c=nm(l.target_url);if(l.bundle&&l.bundle.files.length>0){for(let p of l.bundle.files){if(!t.has(p.basename))continue;let d=Cs(`02_MEDIA/${p.rel_path}`,s);r.push({path:d,section:"media",sourceBasename:p.basename}),o.set(p.basename,d)}continue}let u=Cs(rm(l,n.preserveStructure===!0),s);r.push({path:u,section:l.role==="reference"?"reference":"media",sourceBasename:c}),l.role!=="reference"&&o.set(c,u)}for(let l of n.exchangeFiles??[]){let c=l.text?Jk(l.bytes,o,n.volumeName):l.bytes,u=Cs(`01_PROJECT_FILES/converted/${l.filename}`,s);r.push({path:u,section:"project-converted",inlineBytes:c})}if(n.timelineFile){let l=n.timelineFile,c=Jk(l.bytes,o,n.volumeName);if(l.isConversion){let u=Cs(`01_PROJECT_FILES/converted/${l.filename}`,s);r.push({path:u,section:"project-converted",inlineBytes:c})}else{let u=l.filename.includes(".")?l.filename.slice(l.filename.lastIndexOf(".")):"",d=`${l.filename.includes(".")?l.filename.slice(0,l.filename.lastIndexOf(".")):l.filename}_relinked${u}`,m=Cs(`01_PROJECT_FILES/source/${d}`,s);r.push({path:m,section:"project-source",inlineBytes:c})}}return{entries:r,basenameToIsoPath:o}}function Jk(e,t,n){let r;try{r=new TextDecoder("utf-8",{fatal:!1}).decode(e)}catch{return e}for(let[o,s]of t){let i=`/Volumes/${n}/${s}`,a=kF(o);r=r.replace(new RegExp(`(<pathurl>)[^<]*${a}(</pathurl>)`,"g"),`$1file://localhost${i}$2`).replace(new RegExp(`("target_url"\\s*:\\s*")[^"]*${a}"`,"g"),`$1${i}"`).replace(new RegExp(`(src="file://)[^"]*${a}"`,"g"),`$1localhost${i}"`)}return new TextEncoder().encode(r)}function nm(e){return e?e.split(/[/\\]/).pop()??"":""}function wF(e){if(e)try{return decodeURIComponent(e.replace(/^file:\/\//,"").replace(/^\//,"").replace(/^Volumes\//,""))||void 0}catch{return}}function Cs(e,t){if(!t.has(e))return t.add(e),e;let n=e.lastIndexOf("."),r=n>0?e.slice(0,n):e,o=n>0?e.slice(n):"",s=2,i=`${r}_${s}${o}`;for(;t.has(i);)s++,i=`${r}_${s}${o}`;return t.add(i),i}function kF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xk(e){return $1(e)}function Qk(e,t){let n=Math.max(0,Math.floor(e.handles??0)),r=e.frame_in-n,o=e.frame_out+n,s=Math.max(0,r),i=t!==void 0?Math.min(t,o):o;return{frame_in:s,frame_out:i,handles_applied_in:e.frame_in-s,handles_applied_out:i-e.frame_out,handles_requested:n}}function No(e,t){if(t.format==="iso")return vF(e,t);if(t.format==="folder")return _F(e,t);throw new Error(`deriveLayout: unsupported format "${t.format}"`)}function _F(e,t){let n=Yk(e),r=[],o=new Set,s=new Set,i=0;for(let a of n){let l=sm(a);if(!l)continue;s.add(l);let c=TF(a,l,t);o.add(c);let u=Zk(a.id??l,t),p=e_(e,a,u,t.handles??0);r.push({dest_file:c,dest_offset:0,length:p,source:{kind:"file",basename:l,offset:0}}),i+=p}return{regions:r,total_bytes:i,dest_files:Array.from(o),source_basenames:Array.from(s)}}function vF(e,t){if(!t.volume_name)throw new Error("deriveLayout(iso): intent.volume_name is required");let n=Yk(e),r=`${t.volume_name}.iso`,o=[],s=new Set,i=0;for(let a of n){let l=sm(a);if(!l)continue;s.add(l);let c=Zk(a.id??l,t),u=e_(e,a,c,t.handles??0);o.push({dest_file:r,dest_offset:i,length:u,source:{kind:"file",basename:l,offset:0}}),i+=u}return{regions:o,total_bytes:i,dest_files:[r],source_basenames:Array.from(s)}}function Yk(e){let t=e.media_references;return Array.isArray(t)?t.filter(n=>n.carry_whole===!0||!(n.binding_state&&n.binding_state!=="linked")):[]}function sm(e){if(!e.target_url)return null;let t=e.target_url.split(/[\\/]/).pop();return t&&t.length>0?t:null}function TF(e,t,n){let r=n.per_file_overrides?.[e.id]?.rel_path;if(r)return r;switch(n.folder_layout??"flat"){case"flat":return t;case"by-camera":{let o=e.reel_name;return o?`${o}/${t}`:t}case"media-organized":{let o=xF(e);return o?`${o}/${t}`:t}case"canonical-i2o":return rm(e,!1)}}function xF(e){if(Qh(e))return"Stills";switch(e.content_kind){case"still":return"Stills";case"audio":return"Audio";case"video":case"video_audio":return"Footage";case"compound":return"Compounds";default:return null}}function Zk(e,t){return t.per_file_overrides?.[e]?.mode??t.per_file_mode}function e_(e,t,n,r){let o=t.size_bytes??0;if(o===0)return 0;let s=sm(t);if(!s||!Xk(s)||n.mode==="sparse"&&n.populate.full===!0)return o;let i=t.available_range?.duration?.value??0;if(i<=0)return o;let a=SF(e,t.id);if(a.length===0)return o;let l=a.map(d=>{let m=Qk({frame_in:d.start,frame_out:d.end,handles:r},i);return{start:m.frame_in,end:m.frame_out}});l.sort((d,m)=>d.start-m.start);let c=[{...l[0]}];for(let d=1;d<l.length;d++){let m=l[d],h=c[c.length-1];m.start<=h.end?h.end=Math.max(h.end,m.end):c.push({...m})}let u=0;for(let d of c){let m=Math.max(0,d.start),h=Math.min(i,d.end);h>m&&(u+=h-m)}let p=Math.min(1,u/i);return Math.round(p*o)}function SF(e,t){let n=[],r=e?.timelines??[];for(let o of r)for(let s of o.tracks??[])for(let i of s.items??[]){if(i.media_reference_id!==t||!i.source_range)continue;let a=i.source_range.start.value,l=i.source_range.duration.value;l>0&&n.push({start:a,end:a+l})}return n}function t_(e,t){let n=$F(e),r=n>=0?e.slice(0,n+1):"",o=n>=0?e.slice(n+1):e,s=o.lastIndexOf(".");return s<=0?r+o+t:r+o.slice(0,s)+t+o.slice(s)}function $F(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("\\");return t>n?t:n}async function n_(e){try{return await e()}catch(t){let n=E1(t);throw n?new A1(n):t}}async function Dl(e){let t=S1(e);if(!t||!t.trimSupported)return null;let n=t.flavor,r=o=>ma(n,[R1(e,o)]);return{byteSourceFromFile:RF,async prepareWrite(o,s,i){let l=(await n_(()=>yo(r(o),{verb:"sparsify",selection:{items:s,handles:i}})))[0];return{fileSize:l.fileSize,structuralRanges:l.structuralRanges,essenceRanges:l.essenceRanges,trimInputs:l.trimInputs??[],wholeFileFallback:l.wholeFileFallback}},async planTrim(o,s,i){let a=await n_(()=>yo(r(o),{verb:"trim",selection:{items:s,handles:i}}));if(n==="r3d")throw new Error(`planTrim(${e}): R3D must route through the R3D compact pass (r3d-trim-pass.ts), not the per-file path`);return a}}}async function RF(e){return{fileSize:e.size,async read(t,n){let r=Math.min(t+n,e.size),o=e.slice(t,r);return new Uint8Array(await o.arrayBuffer())}}}function CF(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function Di(e,t="i2o",n,r,o=Ws){await Ic();let s;try{s=Bf(JSON.stringify(e),t,r?JSON.stringify(r):"",o)}catch(a){let l="";try{l=qf()}catch{}throw l?new Error(`udf_build_layout failed: ${l} (raw: ${a instanceof Error?a.message:String(a)})`):a instanceof Error?a:new Error(`udf_build_layout failed: ${String(a)}`)}let i=JSON.parse(s);return{totalBytes:i.totalBytes,totalSectors:i.totalSectors,structuralRegions:i.structuralRegions.map(a=>({sectorStart:a.sectorStart,sectorCount:a.sectorCount,data:CF(a.dataB64)})),fileDataRegions:i.fileDataRegions}}async function o_(e){await Ic();let t=32*2048,n=16*2048,r;if(e instanceof Uint8Array){if(e.length<t+n)return null;r=e.subarray(t,t+n)}else{if(e.size<t+n)return null;r=new Uint8Array(await e.slice(t,t+n).arrayBuffer())}let o=Uf(r);if(!o)return null;try{return JSON.parse(o)}catch{return null}}function EF(e){return e.speed!=null&&e.speed!==100||e.speed_reverse||e.speed_ramped?!0:(e.keyframes??[]).some(t=>t.parameter_path==="speed")}function AF(e,t){let n=e.timelines??[];if(t)return n.filter(s=>s.name===t);let r=new Set;for(let s of n)for(let i of s.tracks??[])for(let a of i.items??[])a.nested_timeline_id&&r.add(a.nested_timeline_id);let o=n.filter(s=>!r.has(s.id));return o.length?o:n}function IF(e,t,n){let r=new Map((e.timelines??[]).map(s=>[s.id,s])),o=(s,i,a,l)=>{if(!(!s||a>8))for(let c of s.tracks??[])for(let u of c.items??[]){let p=a===0?u:l??u,d=Math.round(u.timeline_range?.start?.value??0),m=d+Math.round(u.timeline_range?.duration?.value??0),h=i?i.map(([y,k])=>[Math.max(d,y),Math.min(m,k)]).filter(([y,k])=>k>y):[[d,m]];if(h.length===0)continue;let g=EF(u);if(u.nested_timeline_id){let y=r.get(u.nested_timeline_id),k=Math.round(u.source_range?.start?.value??0),b=(s.fps_num??0)/Math.max(s.fps_den??1,1),w=y?(y.fps_num??0)/Math.max(y.fps_den??1,1):b,_=b>0&&w>0?w/b:1,v=h.map(([R,S])=>[Math.floor((k+(R-d))*_),Math.floor((k+(S-d))*_)]);o(y,v,a+1,p)}else if(u.media_reference_id){let y=Math.round(u.source_range?.start?.value??0),k=Math.round(u.source_range?.duration?.value??0);if(g){n({item:u,root:p,tl_id:s.id,depth:a,has_speed:!0,tl_in:d,src_in:y,a:d,b:d+k,reached_in:y,reached_out:y+k});continue}for(let[b,w]of h)n({item:u,root:p,tl_id:s.id,depth:a,has_speed:!1,tl_in:d,src_in:y,a:b,b:w,reached_in:y+(b-d),reached_out:y+(w-d)})}}};for(let s of AF(e,t.rootTimelineName))o(s,null,0,null)}function s_(e,t={}){let n=new Map;return IF(e,t,r=>{let o=r.item.media_reference_id,s={clip_src_in:r.src_in,reached_in:r.reached_in,reached_out:r.reached_out,has_speed:r.has_speed},i=n.get(o);i?i.push(s):n.set(o,[s])}),n}var yr=2048;function jl(e,t,n){console.error(`[planIsoRegions] DROPPING "${t}" \u2014 ${n}. NOT shipping it whole: that would deliver the entire file to carry a few seconds of it.`),e.push({basename:t,reason:n})}async function i_(e){if(e.perFile.mode==="trim")throw new Error("planIsoRegions: ISO + trim is not supported. Use folder collection for compact trim output, or ISO sparse-segments for the canonical cloud / P2P shape (recipient can derive folder-of-trims at download time per project_upload_once_choose_at_download).");let t=e.perFile.populate,{ranges:n,dropped:r}=await MF(e),o=[],s=[];for(let k of e.entries){if("bytes"in k){o.push({path:k.path,totalSize:k.bytes.length,keptRanges:[{offset:0,length:k.bytes.length}],inlineBytes:k.bytes});continue}let b=e.files.get(k.sourceBasename);if(!b)continue;let w=()=>({path:k.path,sourceBasename:k.sourceBasename,totalSize:b.size,keptRanges:[{offset:0,length:b.size}],file:b}),_=await Dl(k.sourceBasename);if(!_||t.full){o.push(w());continue}if(Yn(k.sourceBasename)){if(r.has(k.sourceBasename)){jl(s,k.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}let x=n.get(k.sourceBasename);if(x&&(x.structuralRanges.length>0||x.essenceRanges.length>0)){let $=[...x.structuralRanges];t.segments&&$.push(...x.essenceRanges),o.push({path:k.path,sourceBasename:k.sourceBasename,totalSize:b.size,keptRanges:$,prep:{fileSize:b.size,structuralRanges:x.structuralRanges,essenceRanges:x.essenceRanges,trimInputs:[]},file:b})}else jl(s,k.sourceBasename,"R3D part has no planned sparse ranges");continue}let v=l_(e.session,k.sourceBasename),R=await _.byteSourceFromFile(b),S;try{S=await _.prepareWrite(R,v,e.handles)}catch(x){let $=bo(x);if($){console.warn(`[planIsoRegions] coverage miss detail for "${k.sourceBasename}":`,$),jl(s,k.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}jl(s,k.sourceBasename,x instanceof Error?x.message:String(x));continue}let T=[...S.structuralRanges];t.segments&&T.push(...S.essenceRanges),o.push({path:k.path,sourceBasename:k.sourceBasename,totalSize:b.size,keptRanges:T,prep:S,source:R,file:b})}let i=o.map(k=>{let b=k.prep?PF(k.keptRanges,k.totalSize):void 0,w=e.pinSectorByPath?.get(k.path);return{name:k.path,totalSize:k.totalSize,...b?{dataExtents:b}:{},...w!==void 0?{fixedPartSector:w}:{}}}),a=await Di(i,e.volumeName,{},e.iuvd,e.buildTimestamp),l=new Map;for(let k of a.fileDataRegions)l.has(k.name)||l.set(k.name,{byteOffset:k.sectorStart*yr,partSector:k.sectorStart-257});let c=`${e.volumeName}.iso`,u=[],p=new Set;for(let k of a.structuralRegions)k.data.length!==0&&u.push({dest_file:c,dest_offset:k.sectorStart*yr,length:k.data.length,source:{kind:"inline",bytes:k.data}});let d=new Map;for(let k of o)d.set(k.path,k);let m=new Map,h=new Map;for(let k of a.fileDataRegions){let b=d.get(k.name);if(!b)continue;let w=!!b.file&&!b.inlineBytes&&(!b.prep||b.prep.wholeFileFallback===!0);if(h.has(b.path)||h.set(b.path,w),b.inlineBytes){let S=b.inlineBytes.subarray(k.sourceOffset,k.sourceOffset+k.sourceLength);u.push({dest_file:c,dest_offset:k.sectorStart*yr,length:S.length,source:{kind:"inline",bytes:S}}),m.set(b.path,(m.get(b.path)??0)+S.length);continue}if(!b.file){h.set(b.path,!0);continue}if(!b.prep){p.add(b.sourceBasename??b.file.name),u.push({dest_file:c,dest_offset:k.sectorStart*yr,length:k.sourceLength,source:{kind:"file",basename:b.sourceBasename??b.file.name,offset:k.sourceOffset}}),m.set(b.path,(m.get(b.path)??0)+k.sourceLength);continue}let _=b.sourceBasename??b.file.name;p.add(_);let v=k.sourceOffset,R=k.sourceOffset+k.sourceLength;for(let S of b.keptRanges){let T=Math.max(S.offset,v),x=Math.min(S.offset+S.length,R);if(x<=T)continue;let $=x-T;u.push({dest_file:c,dest_offset:k.sectorStart*yr+(T-v),length:$,source:{kind:"file",basename:_,offset:T}}),m.set(b.path,(m.get(b.path)??0)+$)}}u.sort((k,b)=>k.dest_offset-b.dest_offset);let g=o.map(k=>({path:k.path,bytesWritten:m.get(k.path)??0,fellBack:h.get(k.path)??!1})),y=0;for(let k of u)y+=k.length;return{layout:{regions:u,total_bytes:y,dest_files:[c],source_basenames:Array.from(p),image_total_bytes:a.totalBytes,file_extents:o.map(k=>{let b=a.fileDataRegions.filter(_=>_.name===k.path).map(_=>({at:_.sectorStart*yr,from:_.sourceOffset,len:_.sourceLength})),w=u.filter(_=>_.source.kind!=="zero"&&b.some(v=>_.dest_offset>=v.at&&_.dest_offset<v.at+v.len)).map(_=>({at:_.dest_offset,len:_.length}));return{path:k.path,size:k.totalSize,extents:b,data:w}})},isoPositions:l,totalBytes:a.totalBytes,perFileSummary:g,untrimmable:s}}async function a_(e,t,n,r={}){let{layout:o,totalBytes:s}=e;if(o.dest_files.length!==1)throw new Error(`executeIsoPlan: expected single dest_file, got ${o.dest_files.length}`);let i=0;for(let l of o.regions)l.source.kind!=="zero"&&(i+=l.length);await n.reserveSize(s);let a=0;try{for(let l of o.regions){if(r.signal?.aborted)throw new DOMException("Aborted","AbortError");if(l.length!==0){switch(l.source.kind){case"inline":{await n.writeAt(l.dest_offset,l.source.bytes),a+=l.source.bytes.length;break}case"file":{let c=t.get(l.source.basename);if(!c)throw new Error(`executeIsoPlan: file not in files map: "${l.source.basename}"`);let u=16*1024*1024,p=0;for(;p<l.length;){let d=Math.min(u,l.length-p),m=c.slice(l.source.offset+p,l.source.offset+p+d),h=new Uint8Array(await m.arrayBuffer());await n.writeAt(l.dest_offset+p,h),p+=d,a+=d,r.onProgress?.({bytesWritten:a,totalBytes:i,currentFile:l.source.basename})}continue}case"zero":break;case"pack":throw new Error("executeIsoPlan: `pack` regions require the CAS executor, not a local-file build")}r.onProgress?.({bytesWritten:a,totalBytes:i})}}await n.close()}catch(l){throw await n.abort?.(l),l}return{bytesWritten:a}}async function MF(e){let t=new Map,n=new Set,r=e.session.media_references??[],o=[],s=new Set;for(let l of r){if(l.bundle?.kind!=="rdc")continue;let c=l.bundle,u=c.files.filter(d=>d.role==="anchor"||d.role==="part").slice().sort((d,m)=>(d.part_number??0)-(m.part_number??0)).map(d=>({filename:d.basename,file:e.files.get(d.basename)})).filter(d=>!!d.file);if(u.length===0)continue;let p=(l.target_url??"").split(/[/\\]/).pop()||u[0].filename;o.push({label:c.folder,anchorBasename:p,parts:u});for(let d of u)s.add(d.filename)}for(let l of r){if(l.bundle?.kind==="rdc")continue;let c=(l.target_url??"").split(/[/\\]/).pop()??"";if(!Yn(c)||s.has(c))continue;let u=I1(c,e.files.keys()).map(p=>({filename:p,file:e.files.get(p)})).filter(p=>!!p.file);if(u.length!==0){o.push({label:c,anchorBasename:c,parts:u});for(let p of u)s.add(p.filename)}}if(o.length===0)return{ranges:t,dropped:n};let{mediaOp:i}=await import("./ops-BCTGDBXT.js"),{sourceFromFiles:a}=await import("./source-QGWWLMME.js");for(let l of o){let{label:c,anchorBasename:u,parts:p}=l,d=l_(e.session,u);try{let m=a(p.map(g=>g.file)),h=await i(m,{verb:"sparsify",selection:{items:d,handles:e.handles}});for(let g of h)t.set(g.filename,{structuralRanges:g.structuralRanges,essenceRanges:g.essenceRanges})}catch(m){let h=bo(m);if(h){for(let g of p)n.add(g.filename);console.warn(`[planIsoRegions] DROPPING R3D clip "${c}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,h);continue}console.warn(`[planIsoRegions] R3D spanned prep failed for "${c}":`,m)}}return{ranges:t,dropped:n}}function l_(e,t){let n=new Set,r=t.toLowerCase();for(let u of e.media_references??[]){if(!u.target_url)continue;(u.target_url.split(/[/\\]/).pop()??"").toLowerCase()===r&&n.add(u.id)}let o=[],s=!1;for(let u of e.timelines??[])for(let p of u.tracks??[])for(let d of p.items??[])d.media_reference_id&&n.has(d.media_reference_id)&&o.push(d),d.nested_timeline_id&&(s=!0);if(!s||o.length===0)return o;let i=s_(e),a=[...n].flatMap(u=>i.get(u)??[]);if(a.length===0)return o;let l=o[0],c=l.source_range?.start?.rate??l.source_range?.duration?.rate??1;return a.map(u=>({...l,kind:"clip",source_range:{start:{value:u.reached_in,rate:c},duration:{value:u.reached_out-u.reached_in,rate:c}}}))}function PF(e,t){if(e.length===0)return e;let n=e.map(o=>{let s=Math.floor(o.offset/yr)*yr,i=Math.min(Math.ceil((o.offset+o.length)/yr)*yr,t);return{offset:s,length:Math.max(0,i-s)}}).filter(o=>o.length>0);n.sort((o,s)=>o.offset-s.offset);let r=[];for(let o of n){let s=r[r.length-1];s&&o.offset<=s.offset+s.length?s.length=Math.max(s.length,o.offset+o.length-s.offset):r.push({...o})}return r}async function Es(e,t,n,r,o){if(r.format==="iso"){if(!o)throw new Error("refineLayoutForTrim(iso): isoOptions is required (entries, pinSectorByPath, iuvd come from buildI2oFolderLayout in the wizard).");if(!r.volume_name)throw new Error("refineLayoutForTrim(iso): intent.volume_name is required");let c=LF(r,n),u=await i_({session:n,files:t,handles:r.handles??0,perFile:c,volumeName:r.volume_name,entries:o.entries,pinSectorByPath:o.pinSectorByPath,iuvd:o.iuvd,buildTimestamp:o.buildTimestamp});return u.untrimmable.length>0?{...u.layout,untrimmable:u.untrimmable}:u.layout}if(r.per_file_mode.mode!=="trim")return e;let s=am(n),i=lm(n),a=new Map;for(let c of e.regions){let u=a.get(c.dest_file);u?u.push(c):a.set(c.dest_file,[c])}let l=[];for(let[c,u]of a){let p=u.length===1?u[0]:null;if(!p||p.source.kind!=="file"){l.push(...u);continue}let d=p.source.basename,m=t.get(d);if(!m){l.push(p);continue}let h=i.get(d),g=h?s.get(h.id)??[]:[],y=await FF({destFile:c,basename:d,file:m,ref:h,items:g,handles:r.handles??0});y!=="coverage-miss"&&(y?l.push(...y):l.push({dest_file:c,dest_offset:0,length:m.size,source:{kind:"file",basename:d,offset:0}}))}return OF(l)}async function FF(e){if(e.items.length===0)return null;let t=await Dl(e.basename);if(!t||!t.planTrim)return null;let n;try{let o=await t.byteSourceFromFile(e.file);n=await t.planTrim(o,e.items,e.handles)}catch(o){let s=bo(o);return s?(console.warn(`[refineLayoutForTrim] DROPPING "${e.basename}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,s),"coverage-miss"):null}if(n.length===0)return null;if(n.length===1)return ji(n[0],e.destFile,e.basename);let r=Math.max(3,String(n.length).length);return n.flatMap((o,s)=>ji(o,t_(e.destFile,`_S${String(s+1).padStart(r,"0")}`),e.basename))}function ji(e,t,n){let r=[],o=e.dest_header_bytes_base64?im(e.dest_header_bytes_base64):null;o&&o.length>0&&r.push({dest_file:t,dest_offset:0,length:o.length,source:{kind:"inline",bytes:o}});for(let s of e.src_byte_ranges)s.length<=0||r.push({dest_file:t,dest_offset:s.write_to_dest_offset,length:s.length,source:{kind:"file",basename:s.src_file_name??n,offset:s.offset}});if(e.dest_footer_bytes_base64&&e.dest_footer_offset!=null){let s=im(e.dest_footer_bytes_base64);s.length>0&&r.push({dest_file:t,dest_offset:e.dest_footer_offset,length:s.length,source:{kind:"inline",bytes:s}})}if(e.dest_patches)for(let s of e.dest_patches){let i=im(s.bytes_base64);i.length!==0&&r.push({dest_file:t,dest_offset:s.offset,length:i.length,source:{kind:"inline",bytes:i}})}return r.sort((s,i)=>s.dest_offset-i.dest_offset),r}function am(e){let t=new Map,n=e?.timelines??[];for(let r of n)for(let o of r.tracks??[])for(let s of o.items??[]){if(!s?.media_reference_id)continue;let i=t.get(s.media_reference_id);i?i.push(s):t.set(s.media_reference_id,[s])}return t}function c_(e,t,n){let r=t?.source_timecode?jt(t.source_timecode,n):null;return r==null?e:e.map(o=>{let s=o?.raw_extraction;if(s?.sourceConformedToMedia)return o;let i=s?.alternateFrame;if(i==null||!o.source_range)return o;let a=i-r;return a===0?o:{...o,source_range:{...o.source_range,start:{...o.source_range.start,value:o.source_range.start.value+a}}}})}function lm(e){let t=new Map,n=e?.media_references??[];for(let r of n){if(!r.target_url)continue;let o=r.target_url.split(/[\\/]/).pop();o&&o.length>0&&t.set(o,r)}return t}function OF(e){let t=new Set,n=new Set,r=0;for(let o of e)t.add(o.dest_file),o.source.kind==="file"&&n.add(o.source.basename),r+=o.length;return{regions:e,total_bytes:r,dest_files:Array.from(t),source_basenames:Array.from(n)}}function im(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function LF(e,t){return e.per_file_mode.mode==="trim"?{mode:"trim"}:{mode:"sparse",populate:{structural:!0,segments:e.per_file_mode.populate.segments,full:e.per_file_mode.populate.full}}}var As=class{constructor(t){this.opts=t}async execute(){let{layout:t,sink:n}=this.opts,r=t.total_bytes,o=NF(t.regions),s=Math.max(1,this.opts.concurrency??1),i=0,a=0,l=[],c,u=async(p,d)=>{this.opts.signal?.throwIfAborted(),d.sort((y,k)=>y.dest_offset-k.dest_offset);let m=DF(d),h=await n.openFile(p,m),g=0;try{for(let y of d){this.opts.signal?.throwIfAborted(),c=p,this.opts.onProgress?.({bytesWritten:i,totalBytes:r,currentFile:c});let k=0,b=await this.writeRegion(y,h,w=>{a+=w-k,k=w,this.opts.onProgress?.({bytesWritten:a,totalBytes:r,currentFile:c})});g+=b,i+=b}await h.close()}catch(y){throw await h.abort?.(y),y}return{path:p,bytesWritten:g}};if(s===1)for(let[p,d]of o)l.push(await u(p,d));else{let p=Array.from(o.entries()),d=0,m=[];for(let h=0;h<Math.min(s,p.length);h++)m.push((async()=>{for(;d<p.length;){let g=d++;if(g>=p.length)break;let[y,k]=p[g],b=await u(y,k);l.push(b)}})());await Promise.all(m)}return await n.closeCollection(),this.opts.onProgress?.({bytesWritten:i,totalBytes:r}),{bytesWritten:i,perFile:l}}async writeRegion(t,n,r){if(t.length===0)return 0;switch(t.source.kind){case"inline":return await n.writeAt(t.dest_offset,t.source.bytes),r?.(t.source.bytes.length),t.source.bytes.length;case"file":{let o=this.opts.files.get(t.source.basename);if(!o)throw new Error(`LocalDirectoryExecutor: file not found in files map: "${t.source.basename}"`);let s=16*1024*1024,i=t.source.offset,a=0;for(;a<t.length;){let l=Math.min(s,t.length-a),c=o.slice(i+a,i+a+l),u=new Uint8Array(await c.arrayBuffer());await n.writeAt(t.dest_offset+a,u),a+=l,r?.(a)}return t.length}case"zero":return 0;case"pack":throw new Error("LocalDirectoryExecutor: `pack` regions require the CAS executor, not a local-file executor")}}};function NF(e){let t=new Map;for(let n of e){let r=t.get(n.dest_file);r?r.push(n):t.set(n.dest_file,[n])}return t}function DF(e){let t=0;for(let n of e){let r=n.dest_offset+n.length;r>t&&(t=r)}return t}var Bl=class{constructor(t){this.opts=t}async execute(){return a_({layout:this.opts.layout,totalBytes:this.opts.totalBytes},this.opts.files,this.opts.sink,{onProgress:this.opts.onProgress,signal:this.opts.signal})}};import{mkdir as jF,open as u_}from"node:fs/promises";import{dirname as BF,join as qF}from"node:path";function d_(e){let t=!1;return{async reserveSize(n){await e.truncate(n)},async writeAt(n,r){if(t)throw new Error("nodeFileStream: closed");let o=Buffer.from(r.buffer,r.byteOffset,r.byteLength);await e.write(o,0,r.byteLength,n)},async close(){t||(t=!0,await e.close())},async abort(n){if(!t){t=!0;try{await e.close()}catch{}}}}}async function p_(e){let t=await u_(e,"w");return d_(t)}function ql(e){return{async openFile(t,n){let r=qF(e,t);await jF(BF(r),{recursive:!0});let o=await u_(r,"w"),s=d_(o);return await s.reserveSize(n),s},async closeCollection(){}}}async function um(e){let t=cm(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}function cm(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(cm).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(o=>`${JSON.stringify(o)}:${cm(t[o])}`).join(",")}}`}var HF="i2o-2026-05-08",WF=1;function m_(e){let t=e?.created_at?Date.parse(e.created_at):NaN;return Number.isFinite(t)?t:Ws}async function f_(e){let[t,n]=await Promise.all([um(e.session),um(e.layoutIntent)]);return{payload:{v:1,conform_tools_version:HF,session_sha256:t,delivery_intent_sha256:n,layout_fn_version:WF,written_at:e.writtenAt??new Date(Ws).toISOString(),...e.sessionIdHint?{session_id_hint:e.sessionIdHint}:{}},session_sha256:t,delivery_intent_sha256:n}}function Ul(e){return e.map((t,n)=>({partNumber:t.output_part_number??n+1,clipNumber:t.output_clip_number,clipCount:t.output_clip_count,plan:t}))}function zF(e,t,n,r=""){let o=jr(t),s=o?o.clipBase:t.replace(/\.R3D$/i,""),i=`${s}_${String(n).padStart(3,"0")}.R3D`,a=e.split("/");return a.pop(),a.length&&/\.rdc$/i.test(a[a.length-1])&&a.pop(),[...a,`${s}${r}.RDC`,i].join("/")}function GF(e){let t=e.clipCount??1;if(t<=1)return"";let n=Math.max(3,String(t).length);return`_S${String(e.clipNumber??1).padStart(n,"0")}`}function KF(e){let t=new Map;for(let n of e){let r=jr(n.basename),o=r?r.clipBase:n.basename,s=t.get(o);s?s.push(n):t.set(o,[n])}for(let n of t.values())n.sort((r,o)=>(jr(r.basename)?.partNumber??0)-(jr(o.basename)?.partNumber??0));return[...t.values()]}async function Hl(e){let t=[],n=new Map,r=[],o=0;for(let s of KF(e.parts)){let i=s[0];if(new Set(s.map(l=>l.basename)).size!==s.length){let l=jr(i.basename),c=l?l.clipBase:i.basename.replace(/\.R3D$/i,""),u={reason:"duplicate .R3D part filenames in one send (same clip name in two .RDC folders \u2014 e.g. re-sending two _S### islands of one source); byte-identical routing would be ambiguous"};console.warn(`[r3d-trim-pass] DROPPING R3D clip "${c}" fail-closed:`,u.reason),r.push({clipBase:c,parts:s.map(p=>p.basename),reason:u});continue}let a;try{a=await e.planClip(s)}catch(l){let c=bo(l);if(!c)throw l;let u=jr(i.basename),p=u?u.clipBase:i.basename.replace(/\.R3D$/i,"");console.warn(`[r3d-trim-pass] DROPPING R3D clip "${p}" fail-closed \u2014 delivery coverage miss (cut not within the file's real frames); NOT whole-filing:`,c),r.push({clipBase:p,parts:s.map(d=>d.basename),reason:c});continue}for(let l of s)n.set(l.basename,l.file);for(let l of a){let c=zF(i.destPathHint,i.basename,l.partNumber,GF(l));t.push(...ji(l.plan,c,i.basename)),o+=l.plan.src_byte_ranges.reduce((u,p)=>u+p.length,0)}}return{regions:t,filesByBasename:n,bytes:o,dropped:r}}function h_(e){switch(e){case"trim":return{mode:"trim"};case"skeleton":return{mode:"sparse",populate:{structural:!0}};case"sparse":return{mode:"sparse",populate:{structural:!0,segments:!0}};case"full":return{mode:"sparse",populate:{structural:!0,full:!0}}}}var VF=2048,to=".conform",g_=`${to}/delivery.json`;function b_(e,t){let n=new Set;for(let s of e.timelines)for(let i of s.tracks)for(let a of i.items)a.media_reference_id&&n.add(a.media_reference_id);let r=(e.media_references??[]).filter(s=>n.has(s.id)).map(s=>{let{local_path:i,target_url:a,...l}=s;return{...l,target_url:a&&a.split(/[\\/]/).pop()}}),o={v:1,timelines:e.timelines,media_references:r,handles:t};return new TextEncoder().encode(JSON.stringify(o))}var Wl=class{constructor(t,n,r,o){this.img=t;this.info=n;this.f=r;this.name=o;this.size=r.totalSize}slice(t=0,n=this.size){let r=Math.max(0,Math.min(t,this.size)),o=Math.max(r,Math.min(n,this.size)),{img:s,info:i,f:a}=this;return{size:o-r,async arrayBuffer(){let l=new Uint8Array(o-r);for(let c of vr(a)){let u=Math.max(r,c.offset),p=Math.min(o,c.offset+c.length);p>u&&l.set(await s.read((i.partitionStartSector+c.imageSector)*VF+(u-c.offset),p-u),u-r)}return l.buffer}}}async arrayBuffer(){return this.slice().arrayBuffer()}dataRanges(){return vr(this.f).map(({offset:t,length:n})=>({offset:t,length:n}))}},Do=e=>e.split("/").pop()||e,dm=e=>e.startsWith("02_MEDIA/")||e.startsWith("03_PROXIES/");async function pm(e){let t=await _r(e);return{image:e.size(),recipes:t.files.filter(n=>n.name.startsWith(`${to}/`)).length,files:t.files.filter(n=>!n.name.startsWith(`${to}/`)&&n.name!==".i2o-manifest.json").map(n=>({name:n.name,size:n.totalSize,recorded:vr(n).reduce((r,o)=>r+o.length,0)}))}}async function y_(e,t){let n=t.files.filter(i=>i.name.startsWith(`${to}/delivery`)&&i.name.endsWith(".json"));if(!n.length)return null;let r=[],o=new Map,s=0;for(let i of n){let a=JSON.parse(new TextDecoder().decode(await new Wl(e,t,i,i.name).arrayBuffer()));r.push(...a.timelines);for(let l of a.media_references)l.id&&o.set(l.id,l);s=Math.max(s,a.handles??0)}return{session:{timelines:r,media_references:[...o.values()]},handles:s}}async function w_(e,t){let n=await y_(e,t);return n?{timelines:n.session.timelines,media:n.session.media_references??[],handles:n.handles}:{timelines:[],media:[],handles:0}}async function mm(e,t,n={}){let r=await _r(e),o=b=>!n.only?.length||n.only.some(w=>b.includes(w)),s=await y_(e,r),i=new Map,a=new Map,l=[];for(let b of r.files){if(b.name.startsWith(`${to}/`)||b.name===".i2o-manifest.json"||!o(b.name))continue;let w=new Wl(e,r,b,Do(b.name));dm(b.name)&&Yn(Do(b.name))?l.push({udfPath:b.name,basename:Do(b.name),file:w}):dm(b.name)&&s?i.set(Do(b.name),w):a.set(b.name,w)}n.onProgress?.(0,0,"planning trims");let c=[],u={regions:[],total_bytes:0,dest_files:[],source_basenames:[]};if(s&&i.size){let b={format:"folder",folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:s.handles},w={...s.session,media_references:(s.session.media_references??[]).filter(_=>i.has(Do(_.target_url??""))).map(_=>({..._,binding_state:"linked"}))};u=await Es(No(w,b),i,w,b);for(let _ of u.untrimmable??[])c.push(`${_.basename}: ${_.reason}`)}else if(!s)for(let b of a.keys())dm(b)&&c.push(`${Do(b)}: no recipe in this .iso \u2014 written as stored`);let p=await Hl({parts:l.map(b=>({basename:b.basename,destPathHint:b.udfPath,file:b.file,dataRanges:b.file.dataRanges()})),planClip:async b=>{let w=ma("r3d",b.map(_=>({filename:_.basename,fileSize:_.file.size,dataRanges:_.dataRanges??[],read:(v,R)=>_.file.slice(v,v+R).arrayBuffer().then(S=>new Uint8Array(S))})));return Ul(await yo(w,{verb:"trim",selection:{items:[],handles:0}}))}}),d=new Set([...u.dest_files,...p.regions.map(b=>b.dest_file)]),m=[];for(let[b,w]of a)d.has(b)||m.push({dest_file:b,dest_offset:0,length:w.size,source:{kind:"file",basename:b,offset:0}});for(let[b,w]of i){let _=r.files.find(v=>Do(v.name)===b).name;!u.dest_files.includes(_)&&!u.regions.some(v=>v.source.kind==="file"&&v.source.basename===b)&&(m.push({dest_file:_,dest_offset:0,length:w.size,source:{kind:"file",basename:_,offset:0}}),a.set(_,w),c.push(`${b}: not in the recipe's cut \u2014 written as stored`))}let h=[...u.regions,...p.regions,...m],g={regions:h,total_bytes:h.reduce((b,w)=>b+w.length,0),dest_files:[...new Set(h.map(b=>b.dest_file))],source_basenames:[]},y=new Map([...i,...a,...p.filesByBasename]);await Ke(t);let k=await new As({layout:g,files:y,sink:ql(t),signal:n.signal,concurrency:4,onProgress:b=>n.onProgress?.(b.bytesWritten,b.totalBytes,"writing trims")}).execute();return{files:g.dest_files.length,bytes:k.bytesWritten,untrimmed:c}}import{open as fm}from"node:fs/promises";import{createServer as JF}from"node:http";function k_(e,t=8*1024*1024,n=32){let r=new Map,o=(s,i)=>{let a=`${s}@${i}`,l=r.get(a);if(l)return r.delete(a),r.set(a,l),l;if(l=e(s,i*t,t).catch(c=>{throw r.delete(a),c}),r.set(a,l),r.size>n){let c=r.keys().next().value;c!==void 0&&r.delete(c)}return l};return async(s,i,a)=>{let l=Math.floor(i/t),c=Math.floor((i+a-1)/t);if(l===c){let m=await o(s,l),h=i-l*t;return m.subarray(h,Math.min(h+a,m.length))}let u=await Promise.all(Array.from({length:c-l+1},(m,h)=>o(s,l+h))),p=new Uint8Array(a),d=0;for(let m=0;m<u.length;m++){let h=u[m],g=(l+m)*t,y=Math.max(0,i-g),k=Math.min(h.length,i+a-g);k>y&&(p.set(h.subarray(y,k),d),d+=k-y)}return d===a?p:p.subarray(0,d)}}async function jo(e,t=!1){let n=await fm(e,t?"r+":"r"),r=(await n.stat()).size;return{read:async(o,s)=>{let i=new Uint8Array(s),{bytesRead:a}=await n.read(i,0,s,o);return a===s?i:i.subarray(0,a)},write:async(o,s)=>{await n.write(s,0,s.length,o),r=Math.max(r,o+s.length)},getSize:async()=>r,setSize:async o=>{await n.truncate(o),r=o},size:()=>r,close:()=>n.close()}}var XF=4<<20;async function hm(e,t=fetch){let n=await e(),r=async(a,l)=>{for(let c=0;;c++){let u=await t(n,{headers:{range:`bytes=${a}-${a+l-1}`}});if(u.status===403&&c===0){await u.body?.cancel(),n=await e();continue}if(u.status===416)return await u.body?.cancel(),new Uint8Array(0);if(!u.ok)throw new Error(`reading the .iso: ${u.status} ${(await u.text()).slice(0,200)}`);if(u.status===200&&a>0)throw new Error("the bucket ignored the byte range (no ranged GET)");return new Uint8Array(await u.arrayBuffer())}},o=await t(n,{headers:{range:"bytes=0-0"}});await o.body?.cancel();let s=Number(/\/(\d+)$/.exec(o.headers.get("content-range")??"")?.[1]??o.headers.get("content-length"));if(!o.ok||!Number.isFinite(s))throw new Error(`reading the .iso: ${o.status}`);let i=k_((a,l,c)=>r(l,Math.min(c,s-l)),1<<20,64);return{read:(a,l)=>{let c=Math.max(0,Math.min(l,s-a));return c?c<XF?i("iso",a,c):r(a,c):Promise.resolve(new Uint8Array(0))},write:()=>Promise.reject(new Error("a bucket .iso is read-only here (add_to patches an overlay)")),getSize:async()=>s,size:()=>s,close:async()=>{}}}function QF(e){let t=[];for(let n of[...e].sort((r,o)=>r.offset-o.offset)){let r=t[t.length-1];r&&n.offset<=r.offset+r.length?r.length=Math.max(r.length,n.offset+n.length-r.offset):t.push({...n})}return t}async function __(e,t){let n=await fm(t,"w+"),r=[],o=e.size();return{read:async(i,a)=>{a=Math.max(0,Math.min(a,o-i));let l=new Uint8Array(a),c=Math.max(0,Math.min(a,e.size()-i));c>0&&l.set(await e.read(i,c),0);for(let u of r){let p=Math.max(u.offset,i),d=Math.min(u.offset+u.length,i+a);d>p&&await n.read(l,p-i,d-p,p)}return l},write:async(i,a)=>{await n.write(a,0,a.length,i),r=QF([...r,{offset:i,length:a.length}]),o=Math.max(o,i+a.length)},getSize:async()=>o,setSize:async i=>{o=i},size:()=>o,writes:()=>r,scratch:t,close:()=>n.close()}}async function v_(e){let t=JF((n,r)=>void(async()=>{let o=e.size(),s=/bytes=(\d+)-(\d*)/.exec(n.headers.range??""),i=s?Number(s[1]):0,a=s&&s[2]?Math.min(Number(s[2])+1,o):o;if(r.writeHead(s?206:200,{"Accept-Ranges":"bytes","Content-Length":a-i,...s?{"Content-Range":`bytes ${i}-${a-1}/${o}`}:{}}),n.method==="HEAD")return r.end();for(let l=i;l<a;l+=8388608)r.write(await e.read(l,Math.min(8388608,a-l)));r.end()})().catch(()=>{r.headersSent||r.writeHead(503),r.end()}));return await new Promise(n=>t.listen(0,"127.0.0.1",n)),{url:`http://127.0.0.1:${t.address().port}/disk.iso`,close:()=>new Promise(n=>t.close(()=>n()))}}async function T_(e){if(ln()!=="darwin")throw new Error("a live mount needs macOS (hdiutil attaches the image over HTTP); fetch the .iso or its trims elsewhere");let{execFile:t}=await import("node:child_process"),n=await new Promise((o,s)=>t("/usr/bin/hdiutil",["attach",e,"-readonly","-noverify","-noautoopen"],(i,a,l)=>i?s(new Error(l||i.message)):o(a))),r=n.trim().split(`
|
|
242
|
-
`).map(o=>o.split(" ").pop().trim()).filter(o=>o.startsWith("/")).pop();if(!r)throw new Error(`hdiutil attached nothing: ${n}`);return{mountpoint:r,detach:()=>new Promise(o=>t("/usr/bin/hdiutil",["detach",r,"-force"],()=>o()))}}async function x_(e,t,n,r,o=32<<20){let s=await fm(t,"w"),i=e.size(),a=0,l=0;try{await s.truncate(i),await Promise.all(Array.from({length:4},async()=>{for(;a<i;){r?.throwIfAborted();let c=a;a+=o;let u=await e.read(c,Math.min(o,i-c));await s.write(u,0,u.length,c),l+=u.length,n?.(l,i)}}))}finally{await s.close()}return i}var Bo=class e extends File{#e;constructor(t,n,r){super([],n),this.path=t,this.#e=r}get size(){return this.#e}static async open(t,n=ie(t)){return new e(t,n,(await At(t)).size)}slice(t=0,n=this.size){let r=Math.max(0,t),o=Math.min(this.size,n),s=this.path;return{size:o-r,async arrayBuffer(){let i=await Cc(s);try{let a=await i.readAt(r,o-r);return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}finally{await i.close()}}}}arrayBuffer(){return this.slice().arrayBuffer()}stream(){let t=this;return new ReadableStream({async start(n){n.enqueue(new Uint8Array(await t.arrayBuffer())),n.close()}})}text(){return this.arrayBuffer().then(t=>new TextDecoder().decode(t))}static async openClip(t){let n=Yn(ie(t))?await Ks(t):[t];return n.length<2?e.open(t):new gm(t,await Promise.all(n.map(async r=>({path:r,name:ie(r),size:(await At(r)).size}))))}},gm=class extends Bo{constructor(t,n){super(t,ie(t),n.reduce((o,s)=>o+s.size,0)),this.parts=n;let r=0;this.bases=n.map(o=>(r+=o.size)-o.size)}slice(t=0,n=this.size){let r=Math.max(0,t),o=Math.min(this.size,n),s=this;return{size:Math.max(0,o-r),async arrayBuffer(){let i=new Uint8Array(Math.max(0,o-r));for(let a=0;a<s.parts.length;a++){let l=Math.max(r,s.bases[a]),c=Math.min(o,s.bases[a]+s.parts[a].size);if(l>=c)continue;let u=await Cc(s.parts[a].path);try{i.set(await u.readAt(l-s.bases[a],c-l),l-r)}finally{await u.close()}}return i.buffer}}}};async function S_(e,t){let n=new Map,r=[],o=new Set;for(let s of e.timelines)for(let i of s.tracks)for(let a of i.items)a.media_reference_id&&o.add(a.media_reference_id);for(let s of e.media_references??[]){if(!o.has(s.id))continue;let i=s.local_path??s.target_url;if(!i){r.push(`${s.id}: no path`);continue}if(t.only_linked&&s.binding_state!=="linked"){r.push(`${s.id} ${ie(i)}: not linked (run timeline_relink, or only_linked=false)`);continue}if(!await nt(i)){r.push(`${s.id} ${i}: not on this machine`);continue}if(!fa.has(Qn(i).toLowerCase())){r.push(`${s.id} ${ie(i)}: unsupported container`);continue}for(let a of await Ks(i))n.set(ie(a),await Bo.open(a))}return{files:n,skipped:r}}var YF=new Set(["resolve-xmeml","flame-fcpxml","resolve-otio","premiere-otio"]);async function $_(e,t,n){let r=await nt(t)?[{name:ie(t),data:await tn(t)}]:[],o=[],s=[];for(let a of n){let l=kg(a),c=await J1(l,e),u=typeof c.body=="string"?new TextEncoder().encode(c.body):c.body;if(l==="finalcut-fcpxmld"){for(let[p,d]of Object.entries(ca(u)))p.endsWith("/")||o.push({filename:p,bytes:d,text:!0});for(let p of c.issues??[])s.push(`${l}: ${p.message}`);continue}o.push({filename:c.filenameSuggestion,bytes:u,text:YF.has(l)});for(let p of c.issues??[])s.push(`${l}: ${p.message}`)}return{timelineFile:o.length?{bytes:o[0].bytes,filename:o[0].filename,isConversion:!0}:void 0,sourceFiles:r,exchangeFiles:o.slice(1),issues:s}}function ZF(e,t){let n=t.filter(r=>r.bytes).map(r=>({dest_file:r.path,dest_offset:0,length:r.bytes.length,source:{kind:"inline",bytes:r.bytes}}));return n.length?{...e,regions:[...e.regions,...n],dest_files:[...new Set([...e.dest_files,...n.map(r=>r.dest_file)])],total_bytes:e.total_bytes+n.reduce((r,o)=>r+o.length,0)}:e}var R_=(e,t,n,r)=>["deliver",...t.length?["untrimmable"]:[],...n.length?["skipped"]:[],...e.length?["capability"]:[],...r?[]:["iso_unverified"]];async function C_(e,t,n){let{files:r,skipped:o}=await S_(e,{only_linked:n.only_linked});if(!r.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${o.length?`:
|
|
243
|
-
- ${o.join(`
|
|
244
|
-
- `)}`:""}`);let s=n.volume_name??ie(n.out_path),i=await $_(e,t,n.timeline_formats),{entries:a}=om(e,r,{volumeName:s,preserveStructure:n.preserve_structure,timelineFile:i.timelineFile,sourceFiles:i.sourceFiles,exchangeFiles:i.exchangeFiles,handles:n.handles}),l={format:"folder",volume_name:s,folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:n.handles},c=No(e,l),u=[...r.keys()].filter(Yn),p=u.length?{...e,media_references:(e.media_references??[]).filter(b=>!Yn(ie(b.target_url??"")))}:e,d=await Es(c,r,p,l),m=[];if(u.length){let b=new Map;for(let T of c.regions){let x=ie(T.dest_file);Yn(x)&&b.set(x,T.dest_file)}let w=am(e),_=lm(e),v=await Hl({parts:u.map(T=>({basename:T,destPathHint:b.get(T)??`02_MEDIA/${T}`,file:r.get(T)})),planClip:async T=>{let x=_.get(T[0].basename),$=c_(x?w.get(x.id)??[]:[],x,x?.source_fps??24),U=await yo(C1(T.map(E=>E.file)),{verb:"trim",selection:{items:$,handles:n.handles}});return Ul(U)}});m=v.dropped??[];let S=[...d.regions.filter(T=>!Yn(ie(T.dest_file))),...v.regions];d={...d,regions:S,total_bytes:S.reduce((T,x)=>T+x.length,0),dest_files:[...new Set(S.map(T=>T.dest_file))],source_basenames:[...new Set(S.map(T=>T.source.kind==="file"?T.source.basename:"").filter(Boolean))]}}d=ZF(d,a);let h=d.regions.filter(b=>b.source.kind!=="file"||r.has(b.source.basename));d={...d,regions:h,dest_files:[...new Set(h.map(b=>b.dest_file))],total_bytes:h.reduce((b,w)=>b+w.length,0)},await Ke(n.out_path);let g=await new As({layout:d,files:r,sink:ql(n.out_path)}).execute(),y=[...d.untrimmable??[],...m],k=[...r.values()].reduce((b,w)=>b+w.size,0);return{text:[`delivered ${d.dest_files.length} file(s), ${(g.bytesWritten/1e6).toFixed(1)} MB (sources ${(k/1e6).toFixed(1)} MB) \u2192 ${n.out_path}`,...d.dest_files.map(b=>`- ${b}`),...i.issues.length?["timeline capability issues:",...i.issues.map(b=>` - ${b}`)]:[],...y.length?["not shipped (could not be trimmed \u2014 never shipped whole):",...y.map(b=>` - ${b.basename}: ${b.reason}`)]:[],...o.length?["skipped:",...o.map(b=>` - ${b}`)]:[]].join(`
|
|
245
|
-
`),files:d.dest_files.length,bytes:g.bytesWritten,keys:R_(i.issues,y,o,!0)}}async function E_(e,t,n){let{files:r,skipped:o}=await S_(e,{only_linked:n.only_linked});if(!r.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${o.length?`:
|
|
246
|
-
- ${o.join(`
|
|
247
|
-
- `)}`:""}`);let s=n.out_path.toLowerCase().endsWith(".iso")?n.out_path:B(n.out_path,`${n.volume_name??ie(t,Qn(t))}.iso`),i=n.volume_name??ie(s,".iso"),a=await $_(e,t,n.timeline_formats),l=om(e,r,{volumeName:i,preserveStructure:n.preserve_structure,timelineFile:a.timelineFile,sourceFiles:a.sourceFiles,exchangeFiles:a.exchangeFiles,handles:n.handles}),{pinSectorByPath:c}=l,u=[...l.entries,{path:g_,bytes:b_(e,n.handles)}],p={format:"iso",volume_name:i,per_file_mode:h_("sparse"),handles:n.handles},d=m_(e),{payload:m}=await f_({session:e,layoutIntent:p,writtenAt:new Date(d).toISOString()}),h=await Es(No(e,p),r,e,p,{entries:u,pinSectorByPath:c,iuvd:m,buildTimestamp:d}),g=h.image_total_bytes??h.total_bytes;await Ke(xn(s));let y=await new Bl({layout:h,files:r,totalBytes:g,sink:await p_(s)}).execute(),k=await o_(await Bo.open(s)).catch(()=>null),b=h.untrimmable??[],w=[...r.values()].reduce((_,v)=>_+v.size,0);return{text:[`wrote ${s}: ${(g/1e6).toFixed(1)} MB image, ${(y.bytesWritten/1e6).toFixed(1)} MB real data (sources ${(w/1e6).toFixed(1)} MB), volume "${i}"${k?", IUVD verified":", IUVD readback FAILED"}`,...[...new Set(h.dest_files)].map(_=>`- ${_}`),...a.issues.length?["timeline capability issues:",...a.issues.map(_=>` - ${_}`)]:[],...b.length?["not shipped (could not be planned \u2014 never shipped whole):",...b.map(_=>` - ${_.basename}: ${_.reason}`)]:[],...o.length?["skipped:",...o.map(_=>` - ${_}`)]:[]].join(`
|
|
248
|
-
`),path:s,bytes:g,keys:R_(a.issues,b,o,!!k)}}function eO(e,t){let n=[];for(let r of e){let o=[r];for(let s of t)o=o.flatMap(i=>{let a=Math.max(i.offset,s.offset),l=Math.min(i.offset+i.length,s.offset+s.length);return l<=a?[i]:[{offset:i.offset,length:a-i.offset},{offset:l,length:i.offset+i.length-l}].filter(c=>c.length>0)});n.push(...o)}return n}async function bm(e,t){let n=typeof t=="string"?await jo(t):t,r=typeof e=="string"?await jo(e,!0):e;try{let o=await _r(n),s=await _r(r),i=2048,a=o.partitionStartSector,l=(m,h)=>{let g=new Uint8Array(h.length);return Promise.all(vr(m).map(async y=>{let k=Math.max(y.offset,h.offset),b=Math.min(y.offset+y.length,h.offset+h.length);b<=k||g.set(await n.read((a+y.imageSector)*i+(k-y.offset),b-k),k-h.offset)})).then(()=>g)},c=0,u=0,p=[],d=[];for(let m of o.files){let h=vr(m).map(({offset:x,length:$})=>({offset:x,length:$})),g=m.name.lastIndexOf("."),y=g>m.name.lastIndexOf("/")?m.name.slice(0,g):m.name,k=y===m.name?"":m.name.slice(g),b=s.files.filter(x=>x.name===m.name||x.name.startsWith(`${y}_v`)&&x.name.endsWith(k)&&/^\d+$/.test(x.name.slice(y.length+2,x.name.length-k.length))),w=async x=>{if(x.totalSize!==m.totalSize)return!1;for(let $ of vr(x))for(let U of h){let E=Math.max($.offset,U.offset),z=Math.min($.offset+$.length,U.offset+U.length);if(z<=E)continue;let G=await l(m,{offset:E,length:z-E}),D=await r.read((s.partitionStartSector+$.imageSector)*i+(E-$.offset),z-E);if(G.some((te,we)=>te!==D[we]))return!1}return!0},_;for(let x of b)if(await w(x)){_=x;break}let v=_?.name??m.name;if(!_&&b.length){let x=2;for(;s.files.some($=>$.name===`${y}_v${x}${k}`);)x++;v=`${y}_v${x}${k}`,d.push(v)}if(!_){try{s=await zf(r,s,v,m.totalSize)}catch(x){if(v.startsWith(".conform/"))continue;throw x}d.includes(v)||p.push(v)}let R=s.files.find(x=>x.name===v),S=eO(h,vr(R).map(({offset:x,length:$})=>({offset:x,length:$}))),T=Hf(R).flatMap(x=>S.map($=>{let U=Math.max(x.offset,$.offset),E=Math.min(x.offset+x.length,$.offset+$.length);return{offset:U,length:E-U}})).filter(x=>x.length>0);for(let x of T)s=await Wf(r,s,v,x.offset,await l(m,x)),c++,u+=x.length}return{filled:c,added:p,versioned:d,bytes:u}}finally{typeof t=="string"&&await n.close(),typeof e=="string"&&await r.close()}}var zl=32,A_=8,DB=(()=>{let e=new Float64Array(A_*zl);for(let t=0;t<A_;t++)for(let n=0;n<zl;n++)e[t*zl+n]=Math.cos((2*n+1)*t*Math.PI/(2*zl));return e})();function tO(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,Math.imul(e,16843009)>>>24}var xt=64,I_=(()=>{let e=new Float64Array(16*xt);for(let t=0;t<16;t++)for(let n=0;n<xt;n++)e[t*xt+n]=Math.cos(Math.PI*(t+1)*(2*n+1)/(2*xt));return e})();function Gl(e,t){let n=0;for(let r=0;r<8;r++)n+=tO((e.bits[r]^t.bits[r])>>>0);return n}var ym=72;function M_(e,t,n){let r=new Float64Array(xt*xt),o=t/xt,s=n/xt;for(let m=0;m<xt;m++)for(let h=0;h<xt;h++){let g=0,y=0,k=h*o|0,b=(h+1)*o|0,w=m*s|0,_=(m+1)*s|0;for(let v=w;v<_;v++){let R=v*t;for(let S=k;S<b;S++)g+=e[R+S],y++}r[m*xt+h]=y?g/y:0}let i=new Float64Array(16*xt);for(let m=0;m<16;m++)for(let h=0;h<xt;h++){let g=0;for(let y=0;y<xt;y++)g+=I_[m*xt+y]*r[y*xt+h];i[m*xt+h]=g}let a=new Float64Array(256);for(let m=0;m<16;m++)for(let h=0;h<16;h++){let g=0;for(let y=0;y<xt;y++)g+=i[m*xt+y]*I_[h*xt+y];a[m*16+h]=g}let l=Array.from(a).sort((m,h)=>m-h),c=(l[127]+l[128])/2,u=new Uint32Array(8);for(let m=0;m<256;m++)a[m]>c&&(u[m>>5]|=1<<(m&31));let p=0;for(let m=0;m<xt;m++)for(let h=0;h<xt-1;h++)p+=Math.abs(r[m*xt+h+1]-r[m*xt+h]);let d=0;for(let m=0;m<xt*xt;m++)d+=r[m];return{bits:u,quality:p,meanY:d/(xt*xt)}}function P_(e){let t={aSource:0,hole:0};for(let n of e)n.kind==="hole"?t.hole+=n.count:t.aSource+=n.count;return t}function wm(e,t="AX"){return e.replace(/\.[^.]+$/,"").replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,8)||t}function F_(e,t,n){let r=n?.title??"QC RECONFORM",o=wm(n?.aReel??"AX"),s=(n?.aReel??"").replace(/[\r\n]+/g," ").trim(),i=t.fps??24,a=nh(i,t.dropFrame)?"DROP FRAME":"NON-DROP FRAME",l=He(0,i,t.dropFrame),c=[`TITLE: ${r}`,`FCM: ${a}`],u=0;for(let p of e){u++;let d=String(u).padStart(3,"0");if(p.kind==="hole"){let m=He(p.count,i,t.dropFrame);c.push(`${d} ${"BL".padEnd(8)} V C ${l} ${m} ${p.recordInTc} ${p.recordOutTc}`),c.push(`* NEW MATERIAL (${p.count} frames)`)}else{if(c.push(`${d} ${o.padEnd(8)} V C ${p.aInTc} ${p.aOutTc} ${p.recordInTc} ${p.recordOutTc}`),s&&c.push(`* FROM CLIP NAME: ${s}`),p.motion&&!p.motion.ramp){let m=i*p.motion.percent/100,h=`${m<0?"-":""}${Math.abs(m).toFixed(1).padStart(5,"0")}`;c.push(`M2 ${o.padEnd(8)} ${h.padStart(6)} ${p.motion.entryTc}`),p.motion.percent<0&&c.push(`* REVERSE \u2014 PLAYS DOWN FROM ${p.motion.entryTc}`),p.motion.percent===0&&c.push(`* FREEZE FRAME AT ${p.motion.entryTc}`)}p.motion?.ramp&&c.push("* SPEED RAMP \u2014 NOT EXPRESSIBLE IN CMX3600; THE SESSION CARRIES THE CURVE"),p.unreproducible&&(c.push(`* CHECK BY EYE \u2014 ${p.unreproducible.note.toUpperCase()}`),p.motion||c.push("* THIS EVENT MAY NOT REBUILD THE CUT (HOLD / REVERSE / RETIME NOT EXPRESSIBLE)"))}}return c.join(`\r
|
|
249
|
-
`)+`\r
|
|
250
|
-
`}function nO(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function O_(e){let t=e.some(r=>r.motion),n=[["#","kind","rec_in","rec_out","A_in","A_out","frames",...t?["speed"]:[]]];for(let r of e)n.push([String(r.index),r.kind==="hole"?"HOLE":"A-SOURCE",r.recordInTc,r.recordOutTc,r.aInTc??"",r.aOutTc??"",String(r.count),...t?[r.motion?r.motion.ramp?"ramp":`${r.motion.percent.toFixed(1)}%`:""]:[]]);return n.map(r=>r.map(nO).join(",")).join(`\r
|
|
251
|
-
`)+`\r
|
|
252
|
-
`}var km=["only_in_a","only_in_b","different_file","same_name_different_clip","source_tc"],rO=e=>e.replace(/^file:\/\//,"").split(/[\\/]/).pop()??e;function Kl(e,t){let n=e.timelines??[],r=t?n.find(o=>o.id===t):n.find(o=>o.kind==="primary"&&o.tracks?.some(s=>s.items?.length))??n[0];if(!r)throw new L("not_found",t?`no timeline ${t} (timelines: ${n.map(o=>`${o.id} "${o.name}"`).join(", ")})`:"the session has no timeline");return r}function Is(e,t){let n=e.start_frame??0,r=[];for(let i of t)if(i.enabled!==!1)for(let a of i.items){if(a.kind!=="clip"||a.enabled===!1||!a.timeline_range.duration.value)continue;let l=n+a.timeline_range.start.value;r.push({s:l,e:l+a.timeline_range.duration.value,it:a,track:Un(i,e.tracks),z:i.track_index??0})}let o=[...new Set(r.flatMap(i=>[i.s,i.e]))].sort((i,a)=>i-a),s=[];for(let i=0;i+1<o.length;i++){let[a,l]=[o[i],o[i+1]],c;for(let u of r)u.s<=a&&u.e>=l&&(!c||u.z>=c.z)&&(c=u);c&&s.push({s:a,e:l,it:c.it,track:c.track})}return s}function L_(e,t,n,r){let o=e.it,s=o.media_reference_id?r.get(o.media_reference_id):void 0,i=s?.local_path??s?.target_url??null,a=o.source_range?.start.rate||Bt(n),l=s?.source_fps||a,c=s?.source_timecode?jt(s.source_timecode,l)??0:0,u=(n.start_frame??0)+o.timeline_range.start.value,p=(o.speed??100)/100*(o.speed_reverse?-1:1),d=(o.source_range?.start.value??0)+(t-u)*p*a/Bt(n),m=Math.round(c+d*l/a);return{item_id:o.id,track:e.track,file:i?rO(i):o.name??"(unnamed)",path:i,reel:s?.reel_name??o.reel_name??null,file_tc:s?.source_timecode??null,file_frames:s?.available_range?.duration?.value??s?.declared_duration?.value??null,src_tc:He(m,l,!!s?.source_timecode?.includes(";")),src_frame:m,rate:l}}function oO(e,t){if(!e&&!t)return null;if(!t)return{kind:"only_in_a",note:"A has picture here, B has none"};if(!e)return{kind:"only_in_b",note:"B has picture here, A has none (missing from A)"};let n=e.file.toLowerCase(),r=t.file.toLowerCase();if(n!==r)return{kind:"different_file",note:`${e.reel&&t.reel&&e.reel===t.reel?"same reel, ":""}different file; source TC ${e.src_tc} vs ${t.src_tc}${Math.abs(e.src_frame-t.src_frame)>1440?" (different TC base: temp vs master?)":""}`};if(e.file_tc&&t.file_tc&&e.file_tc!==t.file_tc||e.file_frames!=null&&t.file_frames!=null&&e.file_frames!==t.file_frames)return{kind:"same_name_different_clip",note:`same name, different clip: file TC ${e.file_tc??"?"} vs ${t.file_tc??"?"}, ${e.file_frames??"?"} vs ${t.file_frames??"?"} fr${e.path!==t.path?" (different folders)":""}`};let o=t.src_frame-e.src_frame;return o?{kind:"source_tc",note:`same file, source ${o>0?"+":""}${o} fr (A ${e.src_tc}, B ${t.src_tc})`}:null}function D_(e,t,n={}){let r=Kl(e,n.a_timeline_id),o=Kl(t,n.b_timeline_id),s=Bt(r),i=Bt(o);if(Math.abs(s-i)>.001)throw new L("invalid_args",`the timelines run at different rates (${s} vs ${i} fps); record TC cannot be aligned frame for frame`);let a=new Map((e.media_references??[]).map(m=>[m.id,m])),l=new Map((t.media_references??[]).map(m=>[m.id,m])),c=m=>m.tracks.filter(h=>h.kind==="Video"),u=[];if(n.by_track){let m=new Set([...c(r).map(h=>Un(h,r.tracks)),...c(o).map(h=>Un(h,o.tracks))]);for(let h of m)u.push({name:h,a:c(r).filter(g=>Un(g,r.tracks)===h),b:c(o).filter(g=>Un(g,o.tracks)===h)})}else u.push({name:"top",a:c(r),b:c(o)});let p=m=>He(m,s,!!r.is_drop_frame),d=[];for(let m of u){let h=Is(r,m.a),g=Is(o,m.b),y=[...new Set([...h,...g].flatMap(b=>[b.s,b.e]))].sort((b,w)=>b-w),k=(b,w)=>b.find(_=>_.s<=w&&_.e>w);for(let b=0;b+1<y.length;b++){let[w,_]=[y[b],y[b+1]],v=k(h,w),R=k(g,w),S=v?L_(v,w,r,a):null,T=R?L_(R,w,o,l):null,x=oO(S,T);if(!x)continue;let $=d[d.length-1];if($&&$.lane===m.name&&$.rec_out===w&&$.kind===x.kind&&$.a?.item_id===S?.item_id&&$.b?.item_id===T?.item_id){$.rec_out=_,$.rec_out_tc=p(_),$.frames=_-$.rec_in;continue}d.push({lane:m.name,kind:x.kind,rec_in:w,rec_out:_,rec_in_tc:p(w),rec_out_tc:p(_),frames:_-w,a:S,b:T,note:x.note})}}return{ranges:d,ta:r,tb:o,lanes:u.map(m=>m.name)}}var N_=e=>e?`${e.file} @ ${e.src_tc} [${e.track} ${e.item_id}]`:"(nothing)";function j_(e,t,n,r){let o=km.map(c=>[c,e.ranges.filter(u=>u.kind===c).length]).filter(([,c])=>c),s=e.ranges.length?`${e.ranges.length} record range${e.ranges.length===1?"":"s"} differ in source between A and B (${o.map(([c,u])=>`${u} ${c}`).join(", ")})`:`no source differences: A and B show the same source on every record frame (${e.lanes.join(", ")})`,i=e.ranges.slice(0,r),a=e.ranges.length>i.length?`TRUNCATED: showing ${i.length} of ${e.ranges.length} ranges \u2014 NOT the full list. Pass limit=${e.ranges.length}, or csv_path for all.
|
|
253
|
-
`:"",l=i.map(c=>`- ${c.lane==="top"?"":`${c.lane} `}${c.rec_in_tc}\u2013${c.rec_out_tc} (${c.frames} fr) ${c.kind}: A ${N_(c.a)} | B ${N_(c.b)} \u2014 ${c.note}`);return`${a}${s}
|
|
254
|
-
A: ${t} "${e.ta.name}"
|
|
255
|
-
B: ${n} "${e.tb.name}"
|
|
256
|
-
compared: ${e.lanes[0]==="top"?"topmost enabled video clip per record frame":`per video track (${e.lanes.join(", ")})`}; record TC from each timeline's start TC; out exclusive${l.length?`
|
|
257
|
-
${l.join(`
|
|
258
|
-
`)}`:""}`}var sO=e=>{let t=e==null?"":String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t};function B_(e){let t=["lane","kind","rec_in_tc","rec_out_tc","frames","a_file","a_src_tc","a_file_tc","a_track","a_item","a_path","b_file","b_src_tc","b_file_tc","b_track","b_item","b_path","note"],n=e.map(r=>[r.lane,r.kind,r.rec_in_tc,r.rec_out_tc,r.frames,r.a?.file,r.a?.src_tc,r.a?.file_tc,r.a?.track,r.a?.item_id,r.a?.path,r.b?.file,r.b?.src_tc,r.b?.file_tc,r.b?.track,r.b?.item_id,r.b?.path,r.note]);return[t,...n].map(r=>r.map(sO).join(",")).join(`
|
|
259
|
-
`)+`
|
|
260
|
-
`}function q_(e,t){let n=Bt(e.tb),r=!!e.tb.is_drop_frame,o=i=>He(i,n,r),s=[`TITLE: ${t}`,`FCM: ${r?"DROP FRAME":"NON-DROP FRAME"}`];return e.ranges.forEach((i,a)=>{let l=String(a+1).padStart(3,"0");if(!i.b){s.push(`${l} ${"BL".padEnd(8)} V C ${o(0)} ${o(i.frames)} ${i.rec_in_tc} ${i.rec_out_tc}`,`* ${i.kind.toUpperCase()}: B HAS NO PICTURE HERE`);return}s.push(`${l} ${wm(i.b.reel??i.b.file).padEnd(8)} V C ${i.b.src_tc} ${He(i.b.src_frame+Math.round(i.frames*i.b.rate/n),i.b.rate,i.b.src_tc.includes(";"))} ${i.rec_in_tc} ${i.rec_out_tc}`,`* FROM CLIP NAME: ${i.b.file}`,`* ${i.kind.toUpperCase()}: ${i.note.toUpperCase()}`)}),s.join(`\r
|
|
261
|
-
`)+`\r
|
|
262
|
-
`}function U_(e,t){let n=structuredClone(e),r=n.timelines.find(s=>s.id===t.tb.id);n.timelines=[r];let o=new Set(t.ranges.map(s=>s.b?.item_id).filter(Boolean));for(let s of r.tracks)s.items=s.kind==="Video"?s.items.filter(i=>o.has(i.id)):[];return r.name=`${r.name} \u2014 source diff`,n}var iO="klein4b-q8",aO="https://pub-ed884bfa772244d89e9b6178f3b8ec9a.r2.dev/klein4b-q8/v2/manifest.json",lO=["transformer.safetensors","vae.safetensors","balance.safetensors","exposure.safetensors","exposure_s1.safetensors","exposure_s2.safetensors","yunet.safetensors","loma_b.safetensors","eomt_l_ade.safetensors","det_10g.onnx","w600k_r50.onnx","face_parsing.onnx"],vm={"darwin-arm64":["media-gen","mlx.metallib"],"linux-x64":["media-gen","libmlx.so","libmlxc.so"],"linux-arm64":["media-gen","libmlx.so","libmlxc.so"],"win32-x64":["media-gen.exe","mlx.dll","mlxc.dll"]},Bi=()=>`${ln()}-${Rc()}`;function cO(e,t){return e.files.filter(n=>!n.platform||n.platform===t)}var uO=["loma_b.safetensors","eomt_l_ade.safetensors","det_10g.onnx","w600k_r50.onnx","face_parsing.onnx"];async function H_(e){for(let t of uO)if(!await Fn(B(e.model,t)))return!1;return!0}var dO=["exposure.safetensors","exposure_s1.safetensors","exposure_s2.safetensors"];async function W_(e){for(let t of dO)if(!await Fn(B(e.model,t)))return!1;return!0}var pO=16e9,Vl=()=>B(Xe(),"models",iO);function qi(){return vm[Bi()]?$c()<pO?`the local AI color model needs 16 GB of memory (this machine has ${Math.round($c()/1e9)} GB)`:null:`the local AI color model runs on Apple Silicon Macs, Linux and Windows (x64), not ${ln()}/${Rc()}`}async function Ir(){let e=en("CONFORM_AI_MODEL")??Vl(),t=en("CONFORM_MEDIA_GEN")??B(Vl(),vm[Bi()]?.[0]??"media-gen"),n={runner:t,model:e,preset:B(e,"balance.safetensors")};for(let r of[t,n.preset,B(e,"transformer.safetensors"),B(e,"vae.safetensors")])if(!await Fn(r))return null;return n}async function Jl(e={}){let t=qi();if(t)throw new Error(t);let n=e.manifestUrl??en("CONFORM_AI_PACK_URL")??aO;if(!n)throw new Error("the AI color model has not been published yet (no pack manifest URL)");let r=await fetch(n);if(!r.ok)throw new Error(`could not read the AI pack manifest (${r.status})`);let o=await r.json(),s=Vl();await Ke(s);let i=vm[Bi()]??[],a=cO(o,Bi());if(!i.every(c=>a.some(u=>u.name===c)))throw new Error(`the published AI pack has no runner for ${Bi()} yet`);for(let c of a){if(!lO.includes(c.name)&&!i.includes(c.name))throw new Error(`unexpected file in the AI pack: ${c.name}`);let u=B(s,c.name);if(await Fn(u)&&await Ec(u)===c.sha256)continue;let p=0;await Ef(new URL(c.url,n).href,u,(m,h)=>{let g=Math.floor(100*m/(h||c.bytes));g>=p+5&&(p=g,e.onProgress?.(`${c.name} ${g}% of ${(c.bytes/1e9).toFixed(2)} GB`))});let d=await Ec(u);if(d!==c.sha256)throw await Vt(u),new Error(`${c.name} failed its checksum (got ${d}); deleted, run again to re-download`);c.name==="media-gen"&&await cr("chmod",["+x",u],()=>{})}let l=await Ir();if(!l)throw new Error("the AI pack downloaded but is incomplete");return l}async function z_(e,t,n={}){let r=new Uint8Array(t.w*t.h*3);for(let l=0;l<r.length;l++)r[l]=Math.max(0,Math.min(255,Math.round(t.data[l]*255)));let o=await Dt("conform-ai-"),s=B(o,"in.rgb");await cn(s,r);let i=[],a=Date.now();try{let l=await cr(e.runner,["balance","--input-rgb",`${s}:${t.w}x${t.h}`,"--raw","u8","--model",e.model,"--preset",e.preset,"--edge",String(n.edge??512),"--seed",String(n.seed??376436993),"--steps",String(n.steps??3),"--sampler","sdcpp"],g=>i.push(g));if(l.code!==0&&/non-empty mlx_stream/.test(l.stderr))throw new Error(`the AI color model's GPU kernels (mlx.metallib) did not load on this macOS; delete ${Vl()} and run color_match reference "ai" again to fetch the current pack`);if(l.code!==0)throw new Error(`the AI color model failed (exit ${l.code}): ${l.stderr.trim().slice(-400)}`);let c=l.stderr.match(/ (\d+)x(\d+) [\d.]+s/);if(!c)throw new Error(`the AI color model gave no output size: ${l.stderr.trim().slice(-200)}`);let[u,p]=[Number(c[1]),Number(c[2])],d=new Uint8Array(i.reduce((g,y)=>g+y.length,0)),m=0;for(let g of i)d.set(g,m),m+=g.length;if(d.length!==u*p*3)throw new Error(`the AI color model returned ${d.length} bytes for ${u}x${p}`);let h=new Float32Array(d.length);for(let g=0;g<d.length;g++)h[g]=d[g]/255;return{data:h,w:u,h:p,ms:Date.now()-a}}finally{await Vt(o).catch(()=>{})}}var _m=[.2126,.7152,.0722];function G_(e,t,n=2){let r=(u,p)=>_m[0]*Math.max(0,Math.min(1,u[p]))**2.4+_m[1]*Math.max(0,Math.min(1,u[p+1]))**2.4+_m[2]*Math.max(0,Math.min(1,u[p+2]))**2.4,o=[];for(let u=0;u<e.data.length;u+=3){let p=r(e.data,u);p>1e-5&&Math.max(e.data[u],e.data[u+1],e.data[u+2])<.99&&o.push(Math.log2(Math.max(r(t.data,u),1e-9)/Math.max(p,1e-9)))}if(o.length<64)return{image:t,askedStops:0,appliedStops:0};o.sort((u,p)=>u-p);let s=o.length,i=s%2?o[s-1>>1]:(o[s/2-1]+o[s/2])/2;if(Math.abs(i)<.01)return{image:t,askedStops:i,appliedStops:i};let a=i*Math.exp(-Math.abs(i)/n),l=2**(a-i),c=new Float32Array(t.data.length);for(let u=0;u<c.length;u++)c[u]=Math.min(1,(Math.max(0,Math.min(1,t.data[u]))**2.4*l)**(1/2.4));return{image:{data:c,w:t.w,h:t.h},askedStops:i,appliedStops:a}}async function K_(e,t,n,r){let o=await Dt("conform-serve-"),s="",i="",a=[],l=Cf(e.runner,["serve"],m=>{s+=new TextDecoder().decode(m);for(let h=s.indexOf(`
|
|
263
|
-
`);h>=0;h=s.indexOf(`
|
|
264
|
-
`)){let g=s.slice(0,h);s=s.slice(h+1),a.shift()?.(g)}},m=>{i=(i+m).slice(-4e3),n?.(m)});l.hold(!0);let c=!1;l.exited.then(()=>{c=!0;for(let m of a.splice(0))m(JSON.stringify({error:`media-gen serve exited: ${i.trim().slice(-400)}`}))});let u=async m=>{if(c)throw new Error(`media-gen serve is not running: ${i.trim().slice(-400)}`);let h=new Promise(y=>a.push(y));await l.write(new TextEncoder().encode(JSON.stringify(m)+`
|
|
265
|
-
`));let g=JSON.parse(await h);if(g.error)throw new Error(String(g.error));return g},p=r?{preset:B(e.model,"exposure.safetensors"),view_lut:r,loras:{s1:B(e.model,"exposure_s1.safetensors"),s2:B(e.model,"exposure_s2.safetensors")}}:{preset:e.preset};await u({cmd:"open",model:e.model,consist:t,...p});let d=0;return{async balance(m,h={}){let g=new Uint8Array(m.w*m.h*3);for(let S=0;S<g.length;S++)g[S]=Math.max(0,Math.min(255,Math.round(m.data[S]*255)));let[y,k]=[B(o,`in${d}.rgb`),B(o,`out${d++}.rgb`)];await cn(y,g);let b=await u({cmd:"balance",rgb:y,w:m.w,h:m.h,edge:h.edge??512,seed:h.seed??376436993,steps:h.steps??3,out:k}),w=await tn(k);await Vt(y).catch(()=>{}),await Vt(k).catch(()=>{});let[_,v]=[Number(b.w),Number(b.h)];if(w.length!==_*v*3)throw new Error(`the AI color model returned ${w.length} bytes for ${_}x${v}`);let R=new Float32Array(w.length);for(let S=0;S<w.length;S++)R[S]=w[S]/255;return{data:R,w:_,h:v,ms:Number(b.ms)}},async step1(m){let h=await u({cmd:"step1",frame:m});return{values:h.values,stage1:h.stage1,ms:Number(h.ms)}},async shot(m){return Number((await u({cmd:"shot",shot:m})).ms??0)},async finish(){return await u({cmd:"finish"})},close(){l.hold(!1),l.close(),Ht(o).catch(()=>{})}}}function mO(e,t){let n=(e.keyframes??[]).filter(i=>i.parameter_path==="speed"&&typeof i.time?.value=="number"&&typeof i.value=="number").map(i=>({x:i.time.value,y:i.value,t:Array.isArray(i.raw_extraction?.drtNativeTangent)?i.raw_extraction.drtNativeTangent:null,pre:!!i.raw_extraction?.speedPreRoll,g0:Array.isArray(i.raw_extraction?.speedGraphPoint)&&Math.abs(i.raw_extraction.speedGraphPoint[0])<1e-9})).sort((i,a)=>i.x-a.x);if(n.length<2)return null;let r=(n.find(i=>i.g0)??n.find(i=>!i.pre)??n[0]).x,o=(i,a)=>{let l=n[i].t;if(l&&l.length>=4){if(a==="in"&&l[0])return l[1]/l[0];if(a==="out"&&l[2])return l[3]/l[2]}let c=a==="out"?Math.min(i+1,n.length-1):Math.max(i-1,0),u=Math.min(i,c),p=Math.max(i,c);return n[p].x>n[u].x?(n[p].y-n[u].y)/(n[p].x-n[u].x):0},s=i=>{let a=n.length-1;if(i<=n[0].x)return n[0].y+(i-n[0].x)*o(0,"out");if(i>=n[a].x)return n[a].y+(i-n[a].x)*o(a,"in");for(let l=0;l<a;l++){let c=n[l],u=n[l+1];if(i>u.x)continue;let p=u.x-c.x;if(p<=0)return u.y;let d=(i-c.x)/p,m=d*d,h=m*d;return(2*h-3*m+1)*c.y+(h-2*m+d)*p*o(l,"out")+(-2*h+3*m)*u.y+(h-m)*p*o(l+1,"in")}return n[a].y};{let i=n[0].x-1,a=n[n.length-1].x+1;for(let l=0;l<80;l++){let c=(i+a)/2;s(c)<t?i=c:a=c}Math.abs(s(a)-t)<1e-4&&(r=a)}return i=>s(r+i)}function V_(e,t,n,r=0,o=0){let s=e.source_range.start.rate||n,i=t?.source_fps||s,a=Math.round(e.timeline_range.duration.value),l=mO(e,e.source_range.start.value/s),c=e.source_range.start.value*(i/s),u=i/n*((e.speed??100)/100)*(e.speed_reverse?-1:1),p=[];for(let d=-r;d<a+o;d++)p.push(l?l(d/n)*i:c+d*u);return p}var Ms=e=>"a"in e;async function fO(){let e=[en("CONFORM_MEDIA_GEN"),mo(new URL("../../rust/target/release/media-gen",import.meta.url)),(await Ir())?.runner],t=en("CONFORM_RIFE_WEIGHTS")??B(Xe(),"models","rife","rife_v4.22_lite.safetensors"),n;for(let r of e)if(r&&await Fn(r)){n=r;break}if(!n)throw new Error("the interpolation model's runner (media-gen) is not installed (Apple Silicon; cargo build --release -p media-gen)");if(!await Fn(t))throw new Error(`RIFE's weights are not installed at ${t} (scripts/rife/oracle.py --out writes them)`);return{runner:n,weights:t}}async function J_(e){if(e.kind==="retime"&&(e.speed??100)<=0&&!e.ramp?.length)throw new Error("retime: speed must be above 0 (a reverse or a freeze is an edit, not a fix)");let t=async g=>(await mt(g)).available_range?.duration.value||void 0,n=await Wt({op:"fix",kind:e.kind,path:e.path,frames:await t(e.path),includeFreezes:!!e.include_freezes,plate:e.plate,plateStart:e.plate_start??0,plateFrames:e.plate_frames,mask:e.mask,plateCount:e.plate?await t(e.plate):void 0,srcIn:e.src_in??0,outFrames:e.frames,speed:e.speed!=null?e.speed/100:void 0,ramp:e.ramp?.map(([g,y])=>[g,y/100])}),r=n.out,o=n.between,s={kind:e.kind,status:"planned",frames_in:n.frames,frames_out:r.length,between:o,found:n.found},i=n.found;if(e.kind==="cadence"&&i.repace?.detected&&!e.force)return{...s,status:"refused: re-pace detected"};if(e.plan_only)return s;if(!(o>0||r.length!==s.frames_in||r.some((g,y)=>!Ms(g)&&g.f!==y)))return{...s,status:"nothing to fix"};let l=e.out_path??e.path.replace(/(\.[^./]+)?$/,`_${e.kind}.mov`),c=async(g,y)=>{let k=await mt(g),b=k.source_timecode?jt(k.source_timecode,k.source_fps??k.available_range?.duration.rate??24):null;return{tc:b!=null?b+y:-1,df:!!k.source_timecode?.includes(";")}},u=e.kind==="cadence"?await c(e.plate,i.plate.start):await c(e.path,Ms(r[0])?r[0].a:r[0].f),[p,d]=String(n.rate??"24/1").split("/").map(Number),m=await Q_(e.path,r,l,p,d||1,u),h=e.kind==="cadence"?await Wt({op:"cadence_check",out:l,plate:e.plate,plateStart:i.plate.start,plateFrames:i.plate.frames}).then(g=>({motion_flags:g.motion_flags})):await Wt({op:"fix",kind:"duplicates",path:l,frames:r.length}).then(g=>({repeats_left:g.between}));return{...s,status:"fixed",wrote:l,between_output_frames:m,check:h}}async function X_(e,t){let n=e.timelines.find(c=>c.kind==="primary")??e.timelines[0];if(!n)throw new Error("the session has no timeline");let r=Bt(n),o=Math.max(0,Math.floor(t.handles??12)),s=t.out_dir??B(Xe(),"renders",t.session_id);t.plan_only||await Ke(s);let i=[],a=e.media_references??[],l=!1;for(let c of n.tracks.filter(u=>u.kind==="Video"))for(let u of c.items){if(u.kind!=="clip"||u.enabled===!1||!u.source_range||t.item_ids&&!t.item_ids.includes(u.id))continue;let p=u.speed??100,d=!!u.speed_ramped;if(!d&&Math.abs(p-100)<1e-6)continue;let m=u.name??u.id,h=d?"ramp":`${+p.toFixed(2)} %`;if(u.speed_reverse||!d&&p<=0){i.push({item:u.id,name:m,speed:h,skipped:"a reverse or a freeze is an edit, not a retime to smooth"});continue}let g=a.find($=>$.id===u.media_reference_id),y=g?.local_path??g?.target_url?.replace(/^file:\/\//,"");if(!g||!y||!await Fn(y)){i.push({item:u.id,name:m,speed:h,skipped:"its media isn't linked on this machine (timeline_relink first)"});continue}let k=(await mt(y)).available_range?.duration.value??0,b=V_(u,g,r,o,o),w=o;for(;w>0&&(b[0]<0||b[0]>k-1);)b=b.slice(1),w--;for(;b.length>Math.round(u.timeline_range.duration.value)+w&&(b[b.length-1]<0||b[b.length-1]>k-1);)b=b.slice(0,-1);let _=await Wt({op:"fix",kind:"retime",path:y,frames:k||void 0,positions:b}),v=_.out;if(t.plan_only){i.push({item:u.id,name:m,speed:h,frames:v.length,between:_.between});continue}let R=Math.round(u.timeline_range.start.value),S=(n.start_frame??0)+R-w,T=B(s,`${ie(y).replace(/\.[^.]+$/,"")}_flow_${He(S,r,!!n.is_drop_frame).replace(/[:;]/g,"")}.mov`);await Q_(y,v,T,n.fps_num,n.fps_den||1,{tc:S,df:!!n.is_drop_frame});let x=await mt(T);x.id=`flow-${u.id}`,e.media_references=[...a.filter($=>$.id!==x.id),x],u.media_reference_id=x.id,u.source_range={start:{value:w,rate:r},duration:{value:Math.round(u.timeline_range.duration.value),rate:r}},u.speed=100,u.speed_ramped=!1,u.speed_reverse=!1,u.keyframes=(u.keyframes??[]).filter($=>$.parameter_path!=="speed"),l=!0,i.push({item:u.id,name:m,speed:h,wrote:T,frames:v.length,between:_.between})}return{session:e,items:i,changed:l}}async function Q_(e,t,n,r,o,s){let i=await Dt("conform-fix-");try{let a=S=>`${S.a}_${S.b}_${S.t}`,l=new Map;for(let S of t.filter(Ms)){let T=l.get(`${S.a}_${S.b}`)??{a:S.a,b:S.b,t:[]};T.t.includes(S.t)||T.t.push(S.t),l.set(`${S.a}_${S.b}`,T)}let c=new Set([...l.values()].flatMap(S=>[S.a,S.b])),u=0,p=0,d=S=>{let T=new Uint8Array(S.length/4*3);for(let x=0,$=0;x<S.length;x+=4,$+=3)T[$]=S[x],T[$+1]=S[x+1],T[$+2]=S[x+2];return T};if(c.size){let S=[];await Gc(e,U=>{u=U.w,p=U.h},(U,E)=>{c.has(U)&&S.push(cn(B(i,`${U}.bgr`),d(E)))}),await Promise.all(S);let T=[...l.values()].map(U=>({a:B(i,`${U.a}.bgr`),b:B(i,`${U.b}.bgr`),t:U.t,out:U.t.map(E=>B(i,`${a({a:U.a,b:U.b,t:E})}.mid.bgr`))}));await Ve(B(i,"jobs.json"),JSON.stringify({w:u,h:p,pairs:T}));let x=await fO(),$=await lr(x.runner,["rife","--weights",x.weights,"--jobs",B(i,"jobs.json")]);if(!$.success)throw new Error(`the interpolation model (RIFE on media-gen) failed: ${$.stderr.trim().split(`
|
|
266
|
-
`).slice(-4).join(" | ")}`)}await Dr();let m=(S,T)=>{let x=new Uint8Array(u*p*4);for(let $=0,U=0;U<x.length;$+=T,U+=4)x[U]=S[$+2],x[U+1]=S[$+1],x[U+2]=S[$],x[U+3]=255;return x},h=new Map;for(let S of t.filter(Ms))h.has(a(S))||h.set(a(S),zc(m(await tn(B(i,`${a(S)}.mid.bgr`)),3),u,p));let g=new Map;t.forEach((S,T)=>{Ms(S)||g.set(S.f,T)});let y=new Map,k=[],b=[],w=0,_=S=>{for(;w<t.length;){let T=t[w];if(Ms(T))b.push(k.length),k.push(h.get(a(T)));else{if(T.f>S||!y.has(T.f))break;k.push(y.get(T.f)),g.get(T.f)===w&&y.delete(T.f)}w++}};if(await Gc(e,S=>{u=S.w,p=S.h},(S,T)=>{g.has(S)&&y.set(S,zc(m(T,4),u,p)),_(S)}),w<t.length)throw new Error(`the source stopped decoding at output frame ${w} of ${t.length}`);let v=new Uint8Array(k.reduce((S,T)=>S+T.length,0)),R=0;for(let S of k)v.set(S,R),R+=S.length;return await cn(n,b1(v,Uint32Array.from(k.map(S=>S.length)),u,p,r,o,"apch",!1,BigInt(s.tc),s.df,1,1)),b}finally{await Ht(i).catch(()=>{})}}function Y_(e){let n=[`${e.status}: ${e.kind} \u2014 ${e.frames_in} source frames \u2192 ${e.frames_out} out, ${e.between} remade between frames`];if(e.kind==="duplicates"){let r=e.found;n.push(r.length?`found (${r.length}): ${r.map(o=>`${o.check} ${o.start}\u2013${o.end}`).join(", ")}`:"found: no repeated frames QC calls a defect")}if(e.kind==="cadence"){let r=e.found;n.push(`held frames cut (${r.held_frames.length}): ${r.held_frames.join(", ")||"none"}`),r.real_pauses_kept.length&&n.push(`kept as real pauses (the plate pauses too): ${r.real_pauses_kept.join(", ")}`),n.push(`skipped source frames: ${r.gaps.map(o=>`after render ${o.after_render_frame} \u2192 plate ${o.plate_frames.join("/")}`).join("; ")||"none"}`),r.repace.detected&&n.push(`RE-PACE: render frames ${r.repace.runs.fast.map(([o,s])=>`${o}\u2013${s}`).join(", ")} race ahead of the plate. ${r.repace.note}`)}return e.wrote&&n.push(`wrote ${e.wrote}; between frames at output ${e.between_output_frames?.join(", ")||"none"}`),e.check&&n.push(`check: ${JSON.stringify(e.check)}`),n.join(`
|
|
267
|
-
`)}async function no(e){let t=await ko();if(!t)throw new L("unsupported","media_patch needs the native engine (conformtools-decode), which is not installed here. From a source checkout build it once: cd rust && cargo build --release -p media-native --bin conformtools-decode (or set CONFORM_NATIVE_DECODE to the binary); the npm package ships it.");let n=await lr(t,["patch",JSON.stringify(e)]);if(n.code!==0){let r=Gs(n.stderr),o=/not supported|does not match|refus|outside|disagrees|no timecode|timecode mismatch|exists/.test(r);throw new L(o?"refused":"engine",r)}return JSON.parse(n.stdout.trim().split(`
|
|
268
|
-
`).pop())}var $m=()=>B(Xe(),"patches.jsonl"),Xl=e=>`${(e/1e9).toFixed(e<1e10?2:1)} GB`;function hO(e,t){return[`layout: ${e.top_level.map(n=>n.type).join(" ")} (index at the ${e.moov_at}), ${Xl(e.master_bytes)}`,` in_place grows the file by ${Xl(e.in_place_grows_by)}; new needs ${Xl(e.new_needs_free)} free${t!=null?` (${Xl(t)} free here${t<e.new_needs_free?": NOT enough for new, in_place only if the user asks to modify the master":""})`:""}`,` chunk offsets after the write: ${e.chunk_offsets_after}; bitrate box (btrt): ${e.btrt?"present, refreshed":"none"}`,` changes: ${e.changes}`].join(`
|
|
269
|
-
`)}async function gO(e){if(e.in==null||e.out==null)throw new L("invalid_args","plan needs in and out (the fixed range on the master, frames or TC)");let t=await mt(e.path),n=t.source_fps??t.streams?.find(c=>c.kind==="video")?.rate??0,r=t.source_timecode??null,o=ur(e.in,n,r),s=ur(e.out,n,r);if(o<0||s<o)throw new L("invalid_args","in/out must be inside the master, in before out");let i=await no({mode:"plan",master:e.path,master_in:o,frames:s-o+1}),a=c=>He((i.master_tc_start_frame??0)+c,n),l=i.frames-(s-o+1);return{text:[`${i.codec}: render master frames ${i.span[0]}\u2013${i.span[1]} (${i.frames} frames, ${a(i.span[0])}\u2013${a(i.span[1])}) for the fix at ${o}\u2013${s}${l?` (+${l} to whole GOPs)`:""}`,`GOP ${i.gop??"?"}${i.fixed_gop?" (fixed)":" (varies)"}, ${i.b_frames?"B-frames":"no B-frames"}${i.open_gop_after?"; the GOP after the fix is open, so it is included":""}`,i.swappable?`then: ${i.render}`:`the master's GOP at ${a(i.span[0])} is open: a swap there needs a re-encode across the seam; ask before rendering`].join(`
|
|
270
|
-
`),data:{...i,fixed:[o,s],tc_in:a(i.span[0]),tc_out:a(i.span[1])}}}async function bO(){try{return(await et($m())).split(`
|
|
271
|
-
`).filter(Boolean).map(e=>JSON.parse(e))}catch{return[]}}var Tm=e=>`${((Number(e)||0)/1e6).toFixed(1)} MB`;async function Rm(e,t){let n=e.mode??"new";if(n==="undo")return yO(e.path);if(e.patches?.length){if(n!=="in_place"&&n!=="check")throw new L("invalid_args","patches (several at once) is for mode in_place or check; one patch per new/section file");if(e.patch||e.in!=null||e.out!=null||e.patch_in!=null)throw new L("invalid_args","with patches, each is placed by its own TC: leave patch/in/out/patch_in out");let h=[];for(let[k,b]of e.patches.entries())t?.(k,e.patches.length,`check ${ie(b)}`),h.push(await no({mode:"check",master:e.path,patch:b}));let g=h.map(k=>[k.master_in,k.master_in+k.frames-1]).sort((k,b)=>k[0]-b[0]);for(let k=1;k<g.length;k++)if(g[k][0]<=g[k-1][1])throw new L("refused",`patches overlap at master frames ${g[k][0]}\u2013${g[k-1][1]}; nothing written`);if(n==="check")return{text:`all ${h.length} patches fit: ${h.map(k=>`${k.frames} frames at ${k.master_in}`).join(", ")}
|
|
272
|
-
nothing written (mode=check)`,data:{plans:h}};let y=[];for(let[k,b]of e.patches.entries())t?.(k,e.patches.length,`patch ${k+1}/${e.patches.length}: ${ie(b)}`),y.push(await Rm({path:e.path,patch:b,mode:n,verify:e.verify}));return t?.(e.patches.length,e.patches.length,"done"),{text:y.map(k=>k.text).join(`
|
|
273
|
-
|
|
274
|
-
`),data:{mode:n,path:e.path,patches:y.map(k=>k.data)}}}if(n==="plan")return gO(e);if(!e.patch)throw new L("invalid_args","patch (the render of the fixed range, with record TC) is required");let r,o;if(e.in!=null||e.out!=null){let h=await mt(e.path),g=h.source_fps??h.streams?.find(k=>k.kind==="video")?.rate??0,y=h.source_timecode??null;if(e.in!=null&&(r=ur(e.in,g,y)),e.out!=null){if(r==null)throw new L("invalid_args","out needs in");if(o=ur(e.out,g,y)-r+1,o<1)throw new L("invalid_args","out is before in")}if(r!=null&&r<0)throw new L("invalid_args",`in is before the master's start TC (${y})`)}let s=await no({mode:"check",master:e.path,patch:e.patch,master_in:r,frames:o,patch_in:e.patch_in}),i=`${s.master_in}\u2013${s.master_in+s.frames-1}`,a=Qn(e.path),l=ie(e.path,a),c=async h=>{let g=e.out_path??B(xn(e.path),h);try{(await At(g)).isDirectory&&(g=B(g,h))}catch{}if(await nt(g))throw new L("refused",`${g} already exists; not overwriting (pass another out_path)`);return g},u=`${s.frames} frame${s.frames===1?"":"s"} of ${s.codec} cut in by timecode at master frames ${i} (patch frames ${s.patch_in}\u2013${s.patch_in+s.frames-1})`;if(n==="check"){let h=s.layout,g=await ea(xn(e.path)).catch(()=>null);return{text:`patch fits: ${u}, no re-encode
|
|
275
|
-
${h?hO(h,g)+`
|
|
276
|
-
`:""}nothing written (mode=check)`,data:{...s,free_bytes:g}}}let p={patch_in:s.patch_in,frames:s.frames};if(n==="section"){let h=await c(`${l}_patch_${i.replace("\u2013","-")}${a}`),g=await Dt("conform-patch-");try{let y=B(g,`range${a}`);await ga({path:e.path,in:s.master_in,out:s.master_in+s.frames-1,out_path:y});let k=await no({mode:"new",master:y,patch:e.patch,out_path:h,...p}),b=await mt(h);return{text:`wrote section ${h}: ${u}, with the master's TC and audio, no re-encode
|
|
277
|
-
verified: ${xm(k)}; start TC ${b.source_timecode??"none"}`,data:{...p,master_in:s.master_in,mode:n,path:h,start_tc:b.source_timecode??null,verify:k.verify,cost:k.cost}}}finally{await Ht(g)}}if(n==="in_place"){t?.(0,1,`write + verify ${ie(e.patch)}`);let h=await no({mode:"in_place",master:e.path,patch:e.patch,...p,verify:e.verify??"index"}),g={...h.undo,patch:e.patch,at:new Date().toISOString()};await Ke(Xe()),await Ve($m(),JSON.stringify(g)+`
|
|
278
|
-
`,{append:!0});let y=h.cost??{};return{text:`patched ${ie(e.path)} in place: ${u}, no re-encode
|
|
279
|
-
verified: ${xm(h)}
|
|
280
|
-
cost: the file grew ${Tm(y.grew_bytes)}; ${Tm(y.dead_bytes)} stay as dead bytes (the replaced frames + old index, kept so undo works); the patched span now sits at the end of the file, away from its audio (mode=new rewrites the file contiguously)${y.btrt_refreshed?"; bitrate box refreshed":""}
|
|
281
|
-
undo: media_patch mode=undo path=${e.path} restores the original byte for byte`,data:{...p,master_in:s.master_in,mode:n,path:e.path,verify:h.verify,cost:h.cost,undo:g}}}let d=await c(`${l}_patched${a}`),m=await no({mode:"new",master:e.path,patch:e.patch,out_path:d,...p});return{text:`wrote ${d}: ${ie(e.path)} with ${u}, no re-encode
|
|
282
|
-
verified: ${xm(m)}
|
|
283
|
-
rewritten contiguously in the master's interleave order (${Tm(m.cost?.bytes)}); the master was not touched`,data:{...p,master_in:s.master_in,mode:n,path:d,verify:m.verify,cost:m.cost}}}function xm(e){let t=e.verify??{},n=t.other_tracks_check==="index"?`${t.other_tracks} other tracks (audio/TC) untouched: every sample at its original offset and size, and the write never reached them (verify=full re-reads and hashes them)`:`${t.other_tracks} other tracks (audio/TC) hash-identical`;return`${t.frames} frames, the master's TC track unchanged, ${t.patched_frames_identical} frames at the patch's TC byte-identical to the patch (ends decode to the patch's pixels), frames either side are the master's (${(t.splice??[]).filter(r=>!r.is.startsWith("patch")).map(r=>r.frame).join(", ")||"none: the span is the whole file"}), ${n}`}async function yO(e){let t=await bO(),n=(await At(e)).size,r=t.findLastIndex(s=>s.path===e&&s.size_after===n);if(r<0){let s=t.some(i=>i.path===e);throw new L(s?"refused":"not_found",s?`${ie(e)} changed since its last in-place patch (size ${n}); nothing undone`:`no in-place patch of ${ie(e)} on record`)}let o=t[r];return await no({mode:"undo",record:o}),t.splice(r,1),await Ve($m(),t.map(s=>JSON.stringify(s)+`
|
|
284
|
-
`).join("")),{text:`undid the in-place patch of ${ie(e)} (master frames ${o.master_in}\u2013${o.master_in+o.frames-1}): the file is byte-identical to before it`,data:{mode:"undo",path:e,undone:o}}}var wO={rec709:1,bt709:1,rec2020:9,bt2020:9,"dci-p3":11,p3dci:11,p3d65:12,"display-p3":12},kO={rec709:1,bt709:1,g24:1,bt1886:1,pq:16,st2084:16,g26:17,st428:17,hlg:18},_O={rec709:1,bt709:1,rec2020:9,bt2020:9};function Sm(e,t,n){if(typeof t=="number")return t;let r=n[t.toLowerCase().replace(/[\s_.]/g,"")];if(r==null)throw new L("invalid_args",`unknown ${e} '${t}' (use ${Object.keys(n).join(", ")} or an H.273 code)`);return r}async function Z_(e){if(!e.out_path&&!e.in_place)throw new L("invalid_args","give out_path (a retagged copy) or in_place=true (only when the user asks to change this file itself)");let t=e.out_path;t&&await At(t).then(i=>i.isDirectory).catch(()=>!1)&&(t=B(t,ie(e.path)));let n=[Sm("primaries",e.primaries,wO),Sm("transfer",e.transfer,kO),Sm("matrix",e.matrix,_O)],r=await no({mode:"retag",master:e.path,out_path:t,in_place:e.in_place??!1,primaries:n[0],transfer:n[1],matrix:n[2]}),o=r.retag,s=o.frames_before.map(i=>`${i.tags.join("/")} \xD7${i.frames}`).join(", ");return{text:`retagged ${r.path} (${r.codec}, no re-encode)
|
|
285
|
-
colr ${o.colr.kind}: ${o.colr.before.join("/")} \u2192 ${o.colr.after.join("/")} (primaries/transfer/matrix)
|
|
286
|
-
frame headers: ${o.frames} frames, ${s} \u2192 ${o.colr.after.join("/")}
|
|
287
|
-
read back: all match`,data:r}}async function Cm(e,t,n,r){let o=await ko();if(!o)throw new L("unsupported",`media_${e==="dcp"?"dcp":"dcp_kdm"} needs the native engine (conformtools-decode), which is not installed here. From a source checkout: cd rust && cargo build --release -p media-native --bin conformtools-decode (or set CONFORM_NATIVE_DECODE); the npm package ships it.`);let s="",i="",a=new TextDecoder,l=await cr(o,[e,JSON.stringify(t)],c=>{s+=a.decode(c,{stream:!0});let u=s.split(`
|
|
288
|
-
`);s=u.pop();for(let p of u){if(!p.trim())continue;let d=p.startsWith('{"progress"')?JSON.parse(p).progress:null;d?n?.(d[0],d[1],"encoding"):i=p}},{signal:r});if(s.trim()&&(i=s),l.code!==0){let c=Gs(l.stderr);throw new L(/exists|is required|not ProRes|integer rate|mix is|Hz|not integer PCM|unknown|encrypted|no key|do not fit|fps|not a date|must be after|signing identity|CPL|VF|subtitles/.test(c)?"refused":"engine",c)}return i}async function ev(e,t,n){let r={...e,path:void 0,movie:e.path,out_dir:e.out_dir??xn(e.path)};return JSON.parse(await Cm("dcp",r,t,n))}async function tv(e){return JSON.parse(await Cm("kdm",e))}function Em(e){let t=r=>`${(r/1e6).toFixed(1)} MB`,n=[`wrote ${e.path}`];if(e.source_dcp)n.push(`from ${e.source_dcp.path}${e.source_dcp.encrypted?" (encrypted)":""}: ${e.frames} frames @ ${e.fps} fps, ${e.reels} reel(s)`),e.patch&&n.push(`patched frames ${e.patch.at}\u2013${e.patch.at+e.patch.count-1} from ${e.patch.movie} (its frames ${e.patch.from}\u2013${e.patch.from+e.patch.count-1}); every other codestream re-wrapped byte-for-byte`),e.carried_reels?.length&&n.push(`reel(s) ${e.carried_reels.join(", ")} carried unchanged`),e.sound_replaced&&n.push("sound replaced from the new mix");else if(e.source&&e.container&&e.audio){let[r,o]=e.container.picture,s=r!==e.container.width||o!==e.container.height?` (picture ${r}x${o}, rest black)`:"";n.push(`${e.frames} frames @ ${e.fps} fps, ${e.container.width}x${e.container.height}${s} from ${e.source.codec} ${e.source.width}x${e.source.height}`,`sound: ${e.audio.channels} ch ${e.audio.rate/1e3} kHz 24-bit (mix was ${e.audio.bits_in}-bit)`),e.reclock&&n.push(`reclocked ${e.reclock.from_fps.toFixed(3)} \u2192 ${e.reclock.to_fps} frame-for-frame; sound ${e.reclock.audio}`)}return n.push(...e.assets.map(r=>` ${r.file} ${t(r.size)} sha1 ${r.hash}`)),e.encrypted?(n.push(`CPL ${e.cpl}; ENCRYPTED (AES-128 + HMAC), CPL/PKL signed by ${e.signer?.subject}`,`content key: ${e.keys} \u2014 the ONLY copy. Keep it with the job; without it this DCP can never play or get a KDM. Do not ship it with the DCP.`),e.signer?.created&&n.push(`new facility signing identity created at ${e.signer.path} (back it up; KDMs are signed with it)`),n.push("next: media_dcp_kdm with keys + the venue's projector certificate")):n.push(`CPL ${e.cpl}; unencrypted OV, unsigned`),n.push(e.valid?`validation: PASS${e.findings.length?` with ${e.findings.length} note(s)`:""}`:"validation: FAIL",...e.findings.map(r=>` ${r.severity} ${r.code}: ${r.message}`)),n.join(`
|
|
289
|
-
`)}function nv(e){return[`wrote ${e.path}`,`${e.title} (CPL ${e.cpl_id}), ${e.keys} key(s)`,`for ${e.recipient.cn} (${e.recipient.o}, thumbprint ${e.recipient.thumbprint})`,`plays ${e.not_valid_before} \u2192 ${e.not_valid_after} (UTC); signature self-checked`].join(`
|
|
290
|
-
`)}async function rv(e,t,n){if(e.patches?.length||e.mode==="vf"||e.mode==="check"||e.reel!==void 0||typeof e.at=="string"||e.start_tc!==void 0)throw new L("refused","an encrypted patch takes one fix: path + at (a composition frame number), as a new OV; patches=, mode=vf/check, reel= and timecode placement need an unencrypted source");if(!e.title)throw new L("refused","title is required for an encrypted patch (the new package's ContentTitleText)");let{dcp:r,keys:o,encrypt:s,path:i,at:a,color:l,from:c,count:u,wav:p,title:d,out_dir:m,issuer:h}=e,g={dcp:r,keys:o,encrypt:s,movie:i,at:a,color:l,from:c,count:u,wav:p,title:d,issuer:h,out_dir:m??xn(r.replace(/\/+$/,""))};return JSON.parse(await Cm("dcp",g,t,n))}async function ov(e,t,n){let r=await ko();if(!r)throw new L("unsupported","media_dcp_patch needs the native engine (conformtools-decode), which is not installed here. From a source checkout: cd rust && cargo build --release -p media-native --bin conformtools-decode (or set CONFORM_NATIVE_DECODE); the npm package ships it.");let{path:o,at:s,reel:i,color:a,from:l,count:c,patches:u,...p}=e,d=u?.length?u:o?[{path:o,at:s,reel:i,color:a,from:l,count:c}]:[];if(!d.length)throw new L("refused","give the fix as path= (with at=), or several as patches=[{path, at}, \u2026]");let m="",h="",g=new TextDecoder,y=await cr(r,["dcp-patch",JSON.stringify({...p,patches:d})],k=>{m+=g.decode(k,{stream:!0});let b=m.split(`
|
|
291
|
-
`);m=b.pop();for(let w of b){if(!w.trim())continue;let _=w.startsWith('{"progress"')?JSON.parse(w).progress:null;_?t?.(_[0],_[1],"encoding the fix"):h=w}},{signal:n});if(m.trim()&&(h=m),y.code!==0){let k=Gs(y.stderr);throw new L(/did not verify/.test(k)?"engine":"refused",k)}return JSON.parse(h)}function sv(e){let t=r=>`${(r/1e6).toFixed(1)} MB`,n=e.mode==="check"?[`check: ${e.ok?"OK":"REFUSED"}, nothing written (would write ${e.would_write}, ${e.package})`]:[`wrote ${e.path} (${e.package}${e.package==="VF"?": plays only with the OV ingested":""})`];n.push(`${e.frames} frames @ ${e.fps} fps, ${e.reels} reel(s); re-wrapped: reel ${e.rewrap_reels.join(", ")||"none"}`);for(let r of e.patches)n.push(` ${r.essence} ${r.frames} frame(s) at ${r.at} (${r.tc}, reel ${r.reel} frame ${r.reel_frame}) from ${r.source} ${r.path?.split("/").pop()??""}`);e.encoded_frames&&n.push(`encoded ${e.encoded_frames} frame(s) of the fix to DCI J2K`);for(let r of e.assets??[])n.push(` ${r.file} ${t(r.size)} ${r.carried?"carried (same bytes)":"new"} sha1 ${r.hash}`);for(let r of e.verify??[])n.push(`${r.code==="VERIFY_OK"?"verified":r.code}: ${r.message}`);return e.decoded_frames&&n.push(`decoded: ${e.decoded_frames} patch and seam frame(s) decode cleanly (our J2K decoder)`),e.valid!==void 0&&n.push(e.valid?`validation: PASS${e.hashes_checked?" (every hash recomputed)":""}${e.findings.length?` with ${e.findings.length} warning(s)`:""}`:"validation: FAIL"),n.push(...e.findings.map(r=>` ${r.severity} ${r.code}: ${r.message}`)),n.join(`
|
|
292
|
-
`)}function Ql(e,t){let n=[...e].sort((r,o)=>r[0]-o[0]);if(t<=n[0][0])return n[0][1];for(let r=1;r<n.length;r++)if(t<=n[r][0])return n[r-1][1]+(n[r][1]-n[r-1][1])*(t-n[r-1][0])/Math.max(1e-9,n[r][0]-n[r-1][0]);return n[n.length-1][1]}function Ui(e,t,n,r,o,s,i=0){let a=e.map(([y,k])=>[y,k*o/r]),l=[0,...a.map(y=>y[0]).filter(y=>y>1e-9&&y<t-1e-9),t].filter((y,k,b)=>b.indexOf(y)===k).sort((y,k)=>y-k),c=l.map(y=>Ql(a,y)/100),u=n/o,p=l.map(y=>u+y/r),d=[u];for(let y=1;y<l.length;y++)d.push(d[y-1]+(c[y-1]+c[y])*.5*(l[y]-l[y-1])/o);let m=y=>c[y]*r/o,h=[],g=(y,k,b)=>h.push({id:`${s}-${h.length}`,parameter_path:"speed",time:{value:y,rate:r},value:k,interp:"bezier",tangent_in:null,tangent_out:null,order_index:h.length,raw_extraction:b});if(u>1e-9){let y=u/3;g(0,0,{drtNativeTangent:[0,0,y,y,0,0],speedPreRoll:!0})}for(let y=0;y<l.length;y++){let k=[0,0,0,0,0,0];if(y>0){let w=(p[y]-p[y-1])/3;k[0]=-w,k[1]=-m(y)*w}else if(u>1e-9){let w=u/3;k[0]=-w,k[1]=-w}if(y+1<l.length){let w=(p[y+1]-p[y])/3;k[2]=w,k[3]=m(y)*w}let b=a.find(w=>Math.abs(w[0]-l[y])<1e-9);g(p[y],d[y],b?{drtNativeTangent:k,speedGraphPoint:[l[y],b[1]]}:{drtNativeTangent:k,speedGraphPoint:[l[y],c[y]*100],speedGraphSynth:!0})}return{keyframes:h,sourceFrames:(d[d.length-1]-u)*o}}var Hi=class{constructor(t,n,r=100){this.channels=t;this.sampleRate=n;this.hz=r;this.counted=0;this.binSamples=Math.max(1,Math.round(n/r)),this.sums=new Float64Array(t),this.bins=Array.from({length:t},()=>[])}push(t){let n=this.channels,r=Math.floor(t.length/n);for(let o=0;o<r;o++){let s=o*n;for(let i=0;i<n;i++){let a=t[s+i];this.sums[i]+=a*a}++this.counted===this.binSamples&&this.flush()}}flush(){for(let t=0;t<this.channels;t++)this.bins[t].push(Math.sqrt(this.sums[t]/this.counted)),this.sums[t]=0;this.counted=0}finish(){return this.counted>0&&this.flush(),this.bins.map(t=>Float32Array.from(t))}};var P6=typeof process<"u"&&!!process.env?.CONFORM_PROFILE;function Wi(e,t,n,r){if(!n||!r||!(e>0)||!(t>0))return{w:e,h:t};let o=Math.min(e/n,t/r);return{w:n*o,h:r*o}}var K6=180/Math.PI;var zi=(e,t)=>`conform-${e}-${t}`,TO=4,xO="1",SO=.025,$O=.005,RO=.5,CO=.001,EO=.5,AO=.05;function IO(e,t,n){let r=e.measuredBy==="sizing";if(e.flipH||e.flipV)return!1;let o=r?CO:SO,s=r?AO:RO,i=(a,l)=>!l||(r?Math.abs(a)<EO:Math.abs(a/l)<$O);return Math.abs(e.scaleX-1)<o&&Math.abs(e.scaleY-1)<o&&Math.abs(e.rotationDeg)<s&&i(e.dxCenter,t)&&i(e.dyCenter,n)&&!e.perspective}function MO(e,t,n,r){e.scale=t.scale*100,Math.abs(t.scaleX-t.scaleY)>.001&&(e.scale_x=t.scaleX*100,e.scale_y=t.scaleY*100),n>0&&(e.position_x=t.dxCenter/n),r>0&&(e.position_y=t.dyCenter/r),Math.abs(t.rotationDeg)>.001&&(e.rotation=t.rotationDeg);let o=e;t.flipH&&(o.flip_horizontal=!0),t.flipV&&(o.flip_vertical=!0)}function PO(e,t,n,r,o,s,i){let a=[],l=n.srcStart??0,c=0;for(let u of t.keyframes){let p=u.refFrame-n.refStart,d=n.srcEnd!=null&&n.refEnd>n.refStart?(n.srcEnd-l)/(n.refEnd-n.refStart):r/(o||r),h={value:l+p*d,rate:r},g=(y,k)=>{a.push({id:`${e}-kf-${c++}`,parameter_path:y,time:h,value:k})};g("scale",u.reframe.scale*100),s>0&&g("position.x",u.reframe.dxCenter/s),i>0&&g("position.y",u.reframe.dyCenter/i),Math.abs(u.reframe.rotationDeg)>.001&&g("rotation",u.reframe.rotationDeg)}return a}function iv(e,t={}){let n=[],r=e.refFps??24,o=th(r)??{num:24,den:1},s=new Map(e.clips.map(w=>[w.label,w])),i=new Set(e.timeline.filter(w=>w.kind!=="gap"&&w.clipLabel).map(w=>w.clipLabel)),a=[],l=new Map;for(let w of e.clips){if(!i.has(w.label))continue;let _=zi("media",w.clipIndex);l.set(w.label,_);let v=w.srcFps??r;a.push({id:_,kind:"external",content_kind:"video",target_url:w.label,display_name:w.label.replace(/\.[^.]+$/,""),source_fps:v,source_timecode:He(w.srcStartFrame,v,w.srcDropFrame??!1),available_range:{start:{value:0,rate:v},duration:{value:w.srcFrames,rate:v}},source_resolution_w:w.srcW??null,source_resolution_h:w.srcH??null,reel_name:null,raw_extraction:{},metadata:{codec:w.codec}}),w.srcFps&&e.refFps&&Math.abs(w.srcFps-e.refFps)>.01&&n.push({kind:"rate",message:`${w.label} is ${w.srcFps.toFixed(3)} fps against a ${e.refFps.toFixed(3)} fps reference. The cut is written at the reference rate with source ranges in the clip's own rate, but the MATCH was made frame-index to frame-index \u2014 check this clip's in-points before trusting them.`});for(let R of w.warnings)n.push({kind:"rate",message:`${w.label}: ${R}`})}let c=[],u=0,p=0,d=0,m=0,h=0,g=[];for(let w of e.timeline){if(w.kind==="gap"||!w.clipLabel||w.srcStart==null||w.srcStart>=0){g.push(w);continue}let _=s.get(w.clipLabel),v=w.srcEnd!=null&&w.refEnd>w.refStart?(w.srcEnd-w.srcStart)/(w.refEnd-w.refStart):(_?.srcFps??r)/(r||1),R=v>0?Math.ceil(-w.srcStart/v-1e-9):w.refEnd-w.refStart+1;if(R>w.refEnd-w.refStart){g.push({...w,kind:"gap",clipLabel:void 0});continue}n.push({kind:"source-range",refStart:w.refStart,refEnd:w.refStart+R-1,message:`${w.clipLabel}: placed from source frame ${w.srcStart}, before the clip's first frame \u2014 the first ${R} frame(s) are left empty and the clip starts at frame 0. Usually a speed or frame-rate conform (e.g. 25 fps played frame-for-frame); check the shot's timing.`}),g.push({kind:"gap",refStart:w.refStart,refEnd:w.refStart+R-1}),g.push({...w,refStart:w.refStart+R,srcStart:w.srcStart+R*v})}for(let w of g){let _=w.refEnd-w.refStart+1;if(w.kind==="gap"||!w.clipLabel){p+=_,n.push({kind:"gap",refStart:w.refStart,refEnd:w.refEnd,message:`${_} frame(s) with no matching source \u2014 left empty on the timeline.`+(w.nothingSimilar!=null?` Nothing in the media you supplied resembles these frames (best similarity ${w.nothingSimilar.toFixed(2)}) \u2014 stock, graphics, or media that was not in the bucket.`:"")+(w.unconfirmed?` Best guess: ${w.unconfirmed.clipLabel} from source frame ${w.unconfirmed.srcFrame}, but the picture did not confirm it (${w.unconfirmed.why??"often graphics or stock that resembles a camera shot"}) \u2014 check it by eye if a shot is expected here.`:"")});continue}w.kind==="composite"&&n.push({kind:"composite",refStart:w.refStart,refEnd:w.refEnd,message:`split-screen / composite of ${w.regions?.length??0} sources \u2014 emitted as the first region only; rebuild the layout by hand.`});let v=s.get(w.clipLabel),R=l.get(w.clipLabel);if(!v||!R)continue;let S=v.srcFps??r,T=w.speed&&(w.speed.kind==="retime"||w.speed.kind==="reverse")?w.speed.percent/100:1,x=(r>0?_*(S/r):_)*T,$=w.speed?.kind==="reverse"?Math.min(w.srcStart??0,w.srcEnd??w.srcStart??0):w.srcStart??0;w.takeRival&&n.push({kind:"contested",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel} or ${w.takeRival.clipLabel}? Two takes of one setup explain this shot almost equally (shot-sizing agreement ${w.takeRival.winnerAgreement.toFixed(2)} vs ${w.takeRival.agreement.toFixed(2)}). Conformed from ${w.clipLabel} \u2014 check the take against the offline.`}),w.contest?.settledBy==="label"&&n.push({kind:"contested",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel} and ${w.contest.rivals.map(G=>G.clipLabel).join(", ")} explain these frames equally well (tied at ${w.contest.winnerScore?.toFixed(1)??"\u2014"} bits). Conformed from ${w.clipLabel} because it sorts first by name \u2014 verify the source timecode.`});let U=zi("item",h),E={id:U,kind:"clip",item_index:h++,name:w.clipLabel,enabled:!0,timeline_range:{start:{value:w.refStart,rate:r},duration:{value:_,rate:r}},source_range:{start:{value:$,rate:S},duration:{value:x,rate:S}},media_reference_id:R,raw_extraction:{},metadata:{}},z=w.track;if(z&&z.kind!=="unresolved"&&z.keyframes.length>0&&!(z.kind==="static"&&IO(z.keyframes[z.keyframes.length>>1].reframe,e.refW,e.refH))){let G=z.keyframes[z.keyframes.length>>1],D=Wi(e.refW,e.refH,v.srcW,v.srcH);MO(E,G.reframe,D.w,D.h),d++,z.kind==="animated"&&(m++,E.keyframes=PO(U,{keyframes:z.keyframes},w,S,r,D.w,D.h),n.push({kind:"reframe",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel}: animated reframe (${z.keyframes.length} keys: ${z.label}) \u2014 measured, not declared; check the move against the reference.`}))}else z?.kind==="unresolved"&&n.push({kind:"unresolved",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel}: placed, but its reframe could not be recovered${z.label&&!z.label.startsWith("unresolved")?` (${z.label})`:""} \u2014 the clip is full-frame on the timeline and may need resizing.`});if(w.ramp&&w.ramp.length>=2){let G=Ui(w.ramp,_,$,r,S,`${U}-spd`);E.source_range={start:E.source_range.start,duration:{value:Math.max(1,Math.ceil(G.sourceFrames)+1),rate:S}},E.speed_ramped=!0,E.speed=Math.round(100*G.sourceFrames/_*(r/S)*100)/100;let D=E.keyframes??[];E.keyframes=[...D,...G.keyframes.map((te,we)=>({...te,order_index:D.length+we}))],n.push({kind:"retime",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel}: SPEED RAMP read from the picture \u2014 ${w.ramp.map(([te,we])=>`${we.toFixed(0)}%@${Math.round(te)}`).join(" \u2192 ")}. Check the ramp against the reference.`})}w.speed&&w.speed.kind!=="normal"&&(E.speed=w.speed.percent,E.speed_ramped=!1,w.speed.kind==="reverse"&&(E.speed_reverse=!0),n.push({kind:"retime",refStart:w.refStart,refEnd:w.refEnd,message:w.speed.kind==="freeze"?`${w.clipLabel}: FREEZE FRAME \u2014 the source holds on one frame across ${_} reference frame(s). Emitted at 0% speed; a host may want an explicit freeze instead.`:w.speed.kind==="reverse"?`${w.clipLabel}: REVERSE at ${w.speed.percent.toFixed(1)}% \u2014 the source runs backwards across ${_} reference frame(s), read from the picture. Check the direction and speed against the reference.`:w.speed.basis==="frame-for-frame"?`${w.clipLabel}: plays FRAME FOR FRAME \u2014 one source frame per record frame, ${w.speed.percent.toFixed(1)}% of real time \u2014 measured from the picture at ${w.speed.samples} points. Usually the edit's rate-conform setting, not a retime.`:w.speed.basis==="convention"?`${w.clipLabel}: emitted at ${w.speed.percent.toFixed(1)}% to match the cut's other shots at this frame rate \u2014 this shot's own picture could not tell real time from frame-for-frame. Check its motion against the reference.`:`${w.clipLabel}: retimed to ${w.speed.percent.toFixed(1)}% (fitted over ${w.speed.samples} runs, residual ${w.speed.residual.toFixed(1)} frames). A speed RAMP would not fit one slope \u2014 check it if the residual is high.`})),w.inPointAmbiguity!=null&&w.inPointAmbiguity>=TO?n.push({kind:"ambiguous",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel}: in-point uncertain \u2014 ${w.inPointAmbiguity} source frames match this shot equally well (the picture barely changes), so its source timecode may be out by up to \xB1${Math.ceil(w.inPointAmbiguity/2)} frames. Check it against the offline.`}):w.inPointUnconfirmed&&n.push({kind:"ambiguous",refStart:w.refStart,refEnd:w.refEnd,message:`${w.clipLabel}: in-point not confirmed \u2014 ${w.takeRival?"and the take itself is contested (see the red marker); ":"the take is right, but "}nothing in the shot (motion, difference mode) pinned the exact frame, so its source timecode may be off. Check it against the offline.`}),c.push(E),u++}let y={id:zi("track",1),kind:"Video",track_index:1,name:"V1",enabled:!0,items:c,source_element_id:null,raw_extraction:{},metadata:{}},k={id:zi("timeline",1),name:t.name??t.referenceName??"Auto-Conform",kind:"primary",timeline_index:0,fps_num:o.num,fps_den:o.den,resolution_w:e.refW||null,resolution_h:e.refH||null,start_frame:e.refStartFrame,is_drop_frame:e.refDropFrame,duration_frames:e.refFrames,tracks:[y],markers:[],source_element_id:null,raw_extraction:{},metadata:{}};return{session:{projects:[{id:zi("project",1),user_id:"",created_at:"",source_format:"auto-conform",source_filename:t.referenceName??null,source_file_sha256:null,source_file_bytes:null,parser_name:"conform-session",parser_version:xO,status:"ready",error_message:null,metadata:{}}],timelines:[k],media_references:a,source_format:"auto-conform",source_filename:t.referenceName??null},issues:n,stats:{placed:u,gapFrames:p,reframed:d,animated:m}}}var FO={gap:"Green",unresolved:"Red",contested:"Red",composite:"Yellow",rate:"Yellow",reframe:"Yellow",retime:"Yellow",ambiguous:"Yellow","source-range":"Yellow",vfx:"Cyan"},OO={gap:"NO SOURCE",unresolved:"REFRAME UNRESOLVED",contested:"CONTESTED SOURCE",composite:"COMPOSITE",rate:"RATE",reframe:"REFRAME",retime:"RETIME",ambiguous:"IN-POINT UNCERTAIN","source-range":"SOURCE RANGE",vfx:"VFX / CLEANUP"};function LO(e,t){return e.map((n,r)=>{let o=n.refStart??0,s=n.refEnd!=null&&n.refStart!=null?n.refEnd-n.refStart+1:1;return{id:`conform-marker-${r}`,name:OO[n.kind]??n.kind.toUpperCase(),color:FO[n.kind]??"Yellow",kind:null,note:n.message,time:{value:o,rate:t},duration:{value:Math.max(1,s),rate:t},item_id:null,raw_extraction:{},source_element_id:null,metadata:{}}})}function av(e,t){let n=(e.timelines??[])[0];if(!n||t.length===0)return e;let r=Bt(n);return{...e,timelines:[{...n,markers:[...n.markers??[],...LO(t,r)]},...(e.timelines??[]).slice(1)]}}var NO=.02,Im=100,DO="the lowest enabled video track is read as the picture spine; anything on the tracks above it (titles, graphics, split-screens) is not hinted and falls to the pixel search";function lv(e){return e&&e.split(/[\\/]/).pop()||null}function Mr(e,t){if(!e||!Number.isFinite(e.value))return 0;let n=e.rate&&Number.isFinite(e.rate)&&e.rate>0?e.rate:t;return Math.round(e.value*(t/n))}function cv(e){let t=e,n=(r,o)=>r!=null&&Number.isFinite(r)&&Math.abs(r-o)>1e-6;return n(t.scale,Im)||n(t.scale_x,Im)||n(t.scale_y,Im)||n(t.position_x,0)||n(t.position_y,0)||n(t.rotation,0)}var jO=3;function BO(e){let t=e;return(t.scale??100)>=100&&Math.abs(t.position_x??0)<1&&Math.abs(t.position_y??0)<1&&(t.opacity??100)>=100&&!(t.crop_left||t.crop_right||t.crop_top||t.crop_bottom)}function qO(e){let n=(e.tracks??[]).filter(r=>r.kind==="Video"&&r.enabled!==!1).sort((r,o)=>r.track_index-o.track_index).filter(r=>(r.items??[]).some(o=>o.kind==="clip"));return{track:n[0]??null,extraVideo:Math.max(0,n.length-1)}}function UO(e,t,n){return!n||n<=0||!e.length?0:Math.min(...e.map(o=>Mr(o.timeline_range?.start,t)))>=n-1?n:0}function uv(e,t,n={}){let r=[],o=(e.timelines??[]).filter(v=>v.kind!=="compound"),s=(t?o.find(v=>v.name===t):null)??o[0]??(e.timelines??[])[0];if(!s)return{timelineName:"",timelineId:null,startOffset:0,fps:0,frames:0,shots:[],cuts:[],warnings:["no timeline in this file"]};o.length>1&&r.push(`this file holds ${o.length} sequences \u2014 hinting from "${s.name}". If that is not the cut you rendered, the claims below will disagree with the picture everywhere.`);let i=Bt(s),{track:a,extraVideo:l}=qO(s);if(!a)return{timelineName:s.name,timelineId:s.id??null,startOffset:0,fps:i,frames:s.duration_frames??0,shots:[],cuts:[],warnings:[...r,"no video track with clips \u2014 nothing to hint from"]};let c=n.allTracks?(s.tracks??[]).filter(v=>v.kind==="Video"&&v.enabled!==!1):[a];l>0&&r.push(n.allTracks?`${l} video track(s) above the spine \u2014 their clips are hinted too, each checked against the picture like any other claim.`:`${l} video track(s) above the spine \u2014 ${DO}.`);let u=c.flatMap(v=>v.items??[]).sort((v,R)=>Mr(v.timeline_range?.start,i)-Mr(R.timeline_range?.start,i)),p=UO(u,i,s.start_frame??0);p>0&&r.push(`item times carry the timeline's start timecode (${p} frames); removed so they line up with a render that begins at its first frame.`);let d=new Map((e.media_references??[]).map(v=>[v.id,v])),m=new Map;for(let v of c)for(let R of v.items??[])m.set(R,v.track_index);let h=[];for(let v of c)for(let R of v.items??[]){if(R.enabled===!1||R.kind!=="clip"||!BO(R))continue;let S=R.media_reference_id?d.get(R.media_reference_id):void 0;if(S?.content_kind==="still"||/\.(png|webp|tiff?|psd|exr|dpx|gif|jpe?g)$/i.test(S?.target_url??S?.display_name??""))continue;let T=Mr(R.timeline_range?.start,i)-p,x=Mr(R.timeline_range?.duration,i);x>0&&h.push({track:v.track_index,lo:T,hi:T+x-1})}let g=(v,R,S)=>{let T=[[v,R]];for(let x of h)x.track<=S||(T=T.flatMap(([$,U])=>{if(x.hi<$||x.lo>U)return[[$,U]];let E=[];return x.lo>$&&E.push([$,x.lo-1]),x.hi<U&&E.push([x.hi+1,U]),E}));return T.filter(([x,$])=>$-x+1>=jO)},y=[],k=0,b=0,w=0,_=0;for(let v of u){if(v.enabled===!1){b++;continue}if(v.kind==="nested"||v.nested_timeline_id){k++;continue}if(v.kind!=="clip"){w++;continue}let R=Mr(v.timeline_range?.start,i)-p,S=Mr(v.timeline_range?.duration,i);if(S<=0){w++;continue}let T=v.media_reference_id?d.get(v.media_reference_id):void 0,x=lv(T?.local_path)??lv(T?.target_url)??T?.display_name??null,$=v.name??null,U=v.reel_name??T?.reel_name??null;if(!x&&!$&&!U){_++;continue}let E=v.source_range?.start?.rate||i,z=Mr(v.source_range?.start,E),G=Mr(v.source_range?.duration,E),D=S>0&&G>0?G/S:1,te=Math.abs(D-1)>NO?D:null,we=m.get(v)??0,ge=T?.source_timecode?rh(T.source_timecode,E):null;for(let[ve,oe]of g(R,R+S-1,we)){let P=Math.round((ve-R)*D);y.push({index:y.length,itemId:v.id??null,refStart:ve,refEnd:oe,clipName:$,reelName:U,sourceFilename:x,srcStart:z+P,srcTimecode:ge?ge.frames+z+P:null,srcRate:E,srcDropFrame:ge?.drop??!1,declaredReframe:cv(v),declaredTransform:cv(v)?{scale:v.scale,scale_x:v.scale_x,scale_y:v.scale_y,position_x:v.position_x,position_y:v.position_y,rotation:v.rotation}:null,declaredSpeed:te})}}return k&&r.push(`${k} nested/compound clip(s) not expanded \u2014 their shots fall to the pixel search rather than being hinted from the wrapper's own range, which would be wrong.`),b&&r.push(`${b} disabled clip(s) ignored.`),w&&r.push(`${w} non-clip item(s) (transitions, gaps) ignored.`),_&&r.push(`${_} clip(s) name no source at all \u2014 no file, no reel, no clip name. Nothing to bind them to, so they go to the pixel search.`),{timelineName:s.name,timelineId:s.id??null,startOffset:p,fps:i,frames:s.duration_frames??(y.length?y[y.length-1].refEnd+1:0),shots:y,cuts:[...new Set(y.slice(1).map(v=>v.refStart))].sort((v,R)=>v-R),warnings:r}}var S5=8*1024*1024;var XO=new Set(["mov","mp4","m4v","r3d","mxf","braw","ari","arx","arri","crm"]),Mm=e=>e.split(".").pop()?.toLowerCase()??"",Pm=e=>XO.has(Mm(e)),dv=new Set(["mov","mp4","m4v"]),Yl=e=>(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"").toUpperCase();function pv(e,t){let n=new Set(e.map(t).filter(i=>!dv.has(Mm(i))).map(Yl)),r=new Set(e.map(t).map(Yl)),o=[],s=[];for(let i of e){let a=t(i),l=/^(.*)_TRIM_\d+-\d+$/.exec(Yl(a))?.[1];(dv.has(Mm(a))&&n.has(Yl(a))||l!=null&&r.has(l)?s:o).push(i)}return{kept:o,proxies:s}}var Zl="autoconform",QO=new Set(["ambiguous","speed_unobservable"]),mv=["kind","clipLabel","srcStart","srcEnd","track","speed"],fv=(e,t)=>e.refStart<=t&&t<=e.refEnd;function Ps(e){return e.report.timeline.flatMap(t=>{let n={ref_start:t.refStart,ref_end:t.refEnd};if(t.kind==="gap"&&t.unconfirmed)return[{...n,kind:"gap_guess",clip:t.unconfirmed.clipLabel,src_frame:Math.round(t.unconfirmed.srcFrame),why:t.unconfirmed.why??"the picture did not confirm it"}];if(t.kind==="gap"||!t.clipLabel||t.srcStart==null)return[];if(e.alignIssues.some(s=>s.kind==="reviewed"&&s.refStart===t.refStart))return[];let o=e.alignIssues.find(s=>QO.has(s.kind)&&fv(t,s.refStart))?.message??(t.takeRival?`another take (${t.takeRival.clipLabel}) explains it nearly as well`:null);return o?[{...n,kind:"doubtful",clip:t.clipLabel,src_frame:Math.round(t.srcStart),why:o}]:[]})}async function YO(e,t,n){let r=e.pool.find(c=>ie(c)===t.clip);if(!r)throw new L("not_found",`${t.clip} is not in the pool this conform ran on`);let o=Math.max(1,Math.floor((t.ref_end-t.ref_start)/4)),s=t.ref_start+2*o,i=n.unconfirmed?.placed??n,a=i.srcEnd!=null&&i.srcStart!=null&&t.ref_end>t.ref_start?(i.srcEnd-i.srcStart)/(t.ref_end-t.ref_start):1;return(await _o({path:e.reference,frame:s,around:2*o,step:o,b:r,b_frame:Math.max(0,Math.round(t.src_frame+(s-t.ref_start)*a)),width:192})).out_path}function ZO(e,t,n){let r=Ps(e),o=[];for(let s of[...t,...n]){let i=t.includes(s)?"gap_guess":"doubtful";if(!r.some(a=>a.ref_start===s&&a.kind===i))throw new L("invalid_args",`${s} is not a ${i==="gap_guess"?"gap with a guess (accept)":"doubtful shot (reject)"}; review shots: ${r.map(a=>`${a.ref_start} ${a.kind}`).join(", ")||"none"}`)}for(let s of e.report.timeline)if(t.includes(s.refStart)&&s.unconfirmed){let i=s.unconfirmed;Object.assign(s,i.placed??{kind:"static",clipLabel:i.clipLabel,srcStart:i.srcFrame,srcEnd:i.srcFrame+(s.refEnd-s.refStart)}),delete s.unconfirmed,e.alignIssues.push({kind:"reviewed",refStart:s.refStart,refEnd:s.refEnd,message:`${i.clipLabel} from source frame ${Math.round(i.srcFrame)}: the engine could not confirm it; placed on review from the contact sheet; check the in-point.`}),o.push(`accepted ${s.refStart}-${s.refEnd} ${i.clipLabel}@${Math.round(i.srcFrame)}`)}else if(n.includes(s.refStart)&&s.clipLabel&&s.srcStart!=null){let i=Object.fromEntries(mv.map(a=>[a,s[a]]));s.unconfirmed={clipLabel:s.clipLabel,srcFrame:s.srcStart,why:"rejected on review",placed:i};for(let a of mv)a!=="kind"&&delete s[a];s.kind="gap",e.alignIssues=e.alignIssues.filter(a=>!fv(s,a.refStart)),o.push(`rejected ${s.refStart}-${s.refEnd} ${i.clipLabel}@${Math.round(i.srcStart)}`)}return o}async function hv(e){let t=await eh(e.session_id,Zl);if(!t)throw new L("not_found",`session ${e.session_id} was not made by timeline_autoconform (0.6.4 or later), so there is nothing to review`);let n=[];if(e.accept?.length||e.reject?.length){n=ZO(t,e.accept??[],e.reject??[]);let l=await bt(e.session_id);l.session=Fm(t).session,await ra(e.session_id,Zl,t),await Xt(l,`autoconform review: ${n.join("; ")}`)}let r=Ps(t),o=e.offset??0,s=r.slice(o,o+(e.limit??4)),i=new Map(t.report.timeline.map(l=>[l.refStart,l])),a=[];for(let l of s)try{l.sheet=await YO(t,l,i.get(l.ref_start)),a.push({data:ta(await tn(l.sheet)),mimeType:"image/png"})}catch(c){l.why+=` (no contact sheet: ${c instanceof Error?c.message:c})`}return{settled:n,shots:r.length,from:o,review:s,images:a}}function gv(e){return[...e.settled,e.shots?`${e.shots} shot(s) to review${e.review.length?`; showing ${e.from+1}\u2013${e.from+e.review.length}`:""}`:"nothing left to review",...e.review.map(t=>`- ${t.ref_start}-${t.ref_end} ${t.kind==="gap_guess"?"GAP, guess":"PLACED, doubtful"}: ${t.clip} from source frame ${t.src_frame}: ${t.why}${t.sheet?`
|
|
293
|
-
image ${e.review.filter(n=>n.sheet).indexOf(t)+1}: ${t.sheet} (top row = reference, bottom = ${t.clip})`:""}`),...e.review.length?["Look at each sheet. Same shot, same moment? gap_guess \u2192 accept=[ref_start]; doubtful and clearly another shot or moment \u2192 reject=[ref_start]. Only decide when sure; otherwise leave it and tell the artist which shots to check (identical-looking takes of one setup are theirs to call)."]:[]].join(`
|
|
294
|
-
`)}async function Om(e,t=4e3){let n=[],r=new Set;async function o(i){let a=await Ks(i).catch(()=>[i]);r.has(a[0])||(a.forEach(l=>r.add(l)),n.push(a[0]))}async function s(i,a){if(!(a>10||n.length>=t))for await(let l of Rt(i)){if(l.name.startsWith("."))continue;let c=B(i,l.name);if(l.isDirectory?await s(c,a+1):l.isFile&&Pm(l.name)&&await o(c),n.length>=t)return}}for(let i of e)if((await At(i)).isDirectory)await s(i,0);else if(Pm(ie(i)))await o(i);else throw new Error(`not a conformable media file: ${i}`);return pv(n,i=>i).kept}async function ec(e){let t=await Om(e.pool);if(!t.length)throw new Error("pool is empty \u2014 no mov/mp4/r3d/mxf/braw/ari/crm files found");let n=[...t].sort((l,c)=>ie(l).localeCompare(ie(c))),r=e.hints?(await X1(e.hints))?.session??e.hints:void 0,o=r?uv(r,void 0,{allTracks:!0}).shots:[],s=performance.now(),i=l=>console.error(`[time] ${l} ${((performance.now()-s)/1e3).toFixed(1)} s`),a=await na({reference:e.reference,clips:n,lite:!0,display:!!e.display_transform});try{let l=await a.ask({op:"autoconform",claims:o,referenceAudio:e.reference_audio??e.reference,sizing:e.sizing!==!1,trust:!!e.trust},(g,y,k)=>{e.signal?.throwIfAborted(),e.onProgress?.(g,y,k==="index"?`index: ${g} of ${y} clips`:k)});if(!l.ok)throw new Error(`analysis engine: ${l.why??l.miss}`);for(let g of l.laps)i(`engine: ${g}`);en("CONFORM_DEBUG_NOMINATIONS")&&l.soundLog.length&&console.error(`[sound] ${l.soundLog.join(" | ")}`);let c=l.report,u={...c,clips:c.clips.map(g=>({clipIndex:g.clip,label:g.label,shots:[],coverage:0,srcFps:g.srcFps,srcStartFrame:g.srcStartFrame,srcFrames:g.srcFrames,srcW:g.srcW,srcH:g.srcH,codec:g.codec,warnings:[]}))},p={reference:e.reference,name:e.name??`${ie(e.reference)} auto conform`,pool:n,rotated:l.rotated,alignIssues:l.issues,report:u},{session:d,issues:m,stats:h}=Fm(p);return{session:d,report:u,rebuild:p,issues:m,stats:h,pool:n,unreadable:l.unreadable}}finally{a.close()}}function Fm(e){let{report:t}=e,n=new Set(e.rotated),r=iv(t,{name:e.name,referenceName:ie(e.reference)});for(let i of r.session.timelines[0]?.tracks[0]?.items??[]){let a=Math.round(i.timeline_range?.start.value??-1);n.has(a)&&!t.timeline.find(l=>l.refStart===a)?.track&&(i.rotation=180)}r.issues.push(...e.alignIssues);let o=av(r.session,r.issues),s=new Map(e.pool.map(i=>[ie(i),i]));for(let i of o.media_references??[]){let a=s.get(ie(i.target_url??""))??s.get(i.reel_name??"");a&&(i.target_url=a,i.local_path=a)}return{session:o,issues:r.issues,stats:r.stats}}function bv(e){let t=new Set(e.issues.map(n=>n.kind));return(e.report.timeline??[]).some(n=>n.kind==="gap")&&t.add("gap"),e.unreadable?.length&&t.add("unreadable"),Ps(e.rebuild).length&&t.add("review"),t}function yv(e){let t=e.report,n=t.timeline??[],r={};for(let i of n)r[i.kind??"?"]=(r[i.kind??"?"]??0)+1;let o=e.issues,s={};for(let i of o)s[i.kind]=(s[i.kind]??0)+1;return[`reference ${t.refFrames??"?"} frames @ ${t.refFps??"?"} fps; pool ${e.pool.length} clip(s)${t.triage?` (examined ${t.triage.examined??"?"}, skipped ${t.triage.skipped??0})`:""}`,...e.unreadable?.length?[`unreadable pool files (left out): ${e.unreadable.length} \u2014 ${e.unreadable.slice(0,5).map(i=>`${ie(i.path)}: ${i.error.slice(0,80)}`).join("; ")}${e.unreadable.length>5?"; \u2026":""}`]:[],`timeline segments: ${Object.entries(r).map(([i,a])=>`${a} ${i}`).join(", ")}`,`stats: ${JSON.stringify(e.stats)}`,`issues: ${o.length?Object.entries(s).map(([i,a])=>`${a} ${i}`).join(", "):"none"}`,...o.slice(0,25).map(i=>`- [${i.kind}] ${i.message??i.note??""}${i.refStart!=null?` @ ${i.refStart}${i.refEnd!=null?`\u2013${i.refEnd}`:""}`:""}`)].join(`
|
|
295
|
-
`)}var Ki=["plain","short","jump","lookalike","punch_in","turned","animated","offrate","retime","ramp","pip","gap","lower_third","locator","title","frankenbite"],Fs={plain:{plain:1},hard:{plain:2,short:3,jump:2,lookalike:3,punch_in:2,turned:1,animated:1,offrate:1,gap:1},all:{plain:2,short:3,jump:2,lookalike:3,punch_in:2,turned:1,animated:1,offrate:1,retime:1,ramp:1,pip:1,gap:1,lower_third:1,locator:1,title:1},speed:{plain:1,offrate:3,retime:3,ramp:3},sound:{plain:2,short:1,jump:2,lookalike:3,punch_in:1,frankenbite:2},graphics:{plain:1,lower_third:3,locator:3,title:2}},Lm=new Set(["lower_third","locator","title"]),wv=["MARIA ALVAREZ","DR. JAMES OKAFOR","SARAH CHEN","TOM WHITFIELD","ANA LUCIA REYES","MARCUS BELL"],kv=["Small Business Owner","Emergency Physician","City Council Member","Rancher, 4th Generation","Teacher","Veteran, U.S. Army"],_v=["AUSTIN, TEXAS","LOCKHART, TX","SAN MARCOS","CALDWELL COUNTY","HOUSTON, TEXAS","WEST TEXAS"],vv=["STRONGER TOGETHER","THE ROAD AHEAD","PLANNING AHEAD","RIGHT HERE AT HOME","VOTE NOVEMBER 5"];var e3=(e,t)=>e.path<t.path?-1:e.path>t.path?1:0;function t3(e){let t=[],n=[],r=new Map;for(let{path:o,ref:s}of[...e].sort(e3)){let i=s.available_range?.duration?.value??0,a=s.available_range?.duration?.rate||s.source_fps||0;if(!a||i<a*5||!s.source_resolution_w){n.push({path:o,reason:"too short or no picture"});continue}let l=o.slice(0,o.lastIndexOf("/")),c=r.get(l)??0;r.set(l,c+1);let u=Yh(s);t.push({path:o,dir:l,idx:c,frames:i,rate:a,w:s.source_resolution_w,h:s.source_resolution_h??0,sound:u})}return{clips:t,skipped:n}}function n3(e){let t=e>>>0,n=()=>{t=t+1831565813>>>0;let r=t;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296};return{next:n,int:(r,o)=>r+Math.floor(n()*(o-r+1)),pick:r=>r[Math.floor(n()*r.length)],range:(r,o)=>r+n()*(o-r)}}function Tv(e){let t=typeof e=="object"&&e!==null?e:Fs[e??"hard"];if(!t)throw new Error(`unknown mix '${e}' (presets: ${Object.keys(Fs).join(", ")})`);return t}function tc(e){let t=Tv(e),n=Ki.filter(r=>(t[r]??0)>0);if(!n.length)throw new Error("the mix weights no class");return n}function r3(e,t){let n=n3(e.seed),r=e.fps_num??24e3,o=e.fps_den??1001,s=e.width??1920,i=e.height??1080,a=r/o,l=Tv(e.mix),c=tc(e.mix),u=c.reduce((T,x)=>T+l[x],0),p=()=>{let T=n.next()*u;for(let x of c)if((T-=l[x])<0)return x;return c[c.length-1]};if(!t.length)throw new Error("no usable clips");let d=t.filter(T=>Math.abs(T.rate-a)>.01),m=[],h=e.shots??24,g=0,y=null,k=0,b=(T,x,$)=>Math.max(1,Math.round(x*(T.rate/a)*($/100))),w=T=>Math.ceil(T.rate*Math.min(12,Math.max(2,.15*T.frames/T.rate))),_=(T,x,$)=>(e.avoid??[]).some(U=>U.path===T&&x<U.to&&x+$>U.from),v=(T,x)=>{let $=w(T),U=T.frames-Math.ceil(T.rate)-x;if(U<=$)return-1;for(let E=0;E<24;E++){let z=n.int($,U);if(!_(T.path,z,x))return z}return-1},R=(T,x,$)=>{let U=0;for(let E=0;E<x;E++)U+=Ql($,E+.5)/100;return Math.max(1,Math.ceil(U*(T.rate/a))+1)},S=[];for(let T=0;T<h;T++){let x=p(),$=[x];x==="gap"&&(g+=n.int(6,48));let U=x==="short"||x!=="plain"&&x!=="ramp"&&!Lm.has(x)&&n.next()<.2;U&&x!=="short"&&$.push("short");let E=x==="ramp"?n.int(60,144):Lm.has(x)?n.int(48,120):U?n.int(4,23):x==="plain"?n.int(24,120):24+Math.floor(n.next()**2*96),z,G=n.pick(t),D=100,te=-1,we={};if(x==="jump"&&y){G=y.clip;let M=y.srcOut+n.int(6,120);M+b(G,E,100)<G.frames-G.rate&&!_(G.path,M,b(G,E,100))&&(te=M)}else if(x==="lookalike"&&y){let M=t.filter(O=>O.dir===y.clip.dir&&O!==y.clip).sort((O,V)=>Math.abs(O.idx-y.clip.idx)-Math.abs(V.idx-y.clip.idx));M.length&&(G=M[Math.min(M.length-1,n.int(0,2))])}else if(x==="offrate"&&d.length)G=n.pick(d),D=n.next()<.6?Math.round(a/G.rate*1e4)/100:100;else if(x==="retime")D=n.pick([25,50,150,200]);else if(x==="ramp"){let M=Math.round(E*n.range(.2,.4)),O=Math.round(E*n.range(.6,.8));z=n.pick([[[M,100],[O,40]],[[M,40],[O,100]],[[M,100],[O,200]],[[M,200],[O,100]],[[0,100],[M,100],[Math.round((M+O)/2),30],[O,100]]])}x==="jump"&&te<0&&($[0]="plain"),x==="lookalike"&&(!y||G.dir!==y.clip.dir)&&($[0]="plain"),x==="offrate"&&D===100&&Math.abs(G.rate-a)<.01&&($[0]="plain");let ge=z?R(G,E,z):b(G,E,D);if(te<0&&(te=v(G,ge)),te<0){if(++k>h*50)throw new Error("the clips are too short for this mix");T--;continue}let ve=M=>(M/100-1)/2*.8;if(x==="punch_in"){let M=Math.round(n.range(110,200));Object.assign(we,{scale:M,position_x:Math.round(n.range(-1,1)*ve(M)*s),position_y:Math.round(n.range(-1,1)*ve(M)*i)})}else if(x==="turned")if(n.next()<.35)Object.assign(we,n.next()<.7?{flip_h:!0}:{flip_v:!0});else{let M=Math.round(n.range(1,6)*10)/10*(n.next()<.5?-1:1);Object.assign(we,{rotation:M,scale:Math.round(100+Math.abs(M)*4)})}else if(x==="animated")if(n.next()<.5)Object.assign(we,{scale:100,scale_end:Math.round(n.range(115,150))});else{let M=Math.round(n.range(125,150)),O=ve(M)*s;Object.assign(we,{scale:M,position_x:Math.round(-O),position_x_end:Math.round(O)})}let oe=e.audio&&G.sound&&D===100&&!z&&Math.abs(G.rate-a)<.01,P;if(x==="frankenbite")if(!oe)$[0]="plain";else{let M=t.filter(fe=>fe.dir===G.dir&&fe!==G&&fe.sound&&Math.abs(fe.rate-a)<.01),O=M.length&&n.next()<.6?n.pick(M):G,V=v(O,ge);V>=0&&(O!==G||Math.abs(V-te)>48)?P={path:O.path,source_in:V}:$[0]="plain"}if(m.push({path:G.path,source_in:te,duration:E,at:g,track:1,...D!==100?{speed:D}:{},...z?{ramp:z}:{},...oe?{audio:!0}:{},...P?{audio_from:P}:{},...we,classes:$,record_in:g,record_out:g+E}),Lm.has(x)){let M=g+Math.floor(E*n.range(0,.2)),O=g+E-Math.floor(E*n.range(0,.15)),V=n.int(0,wv.length-1),fe=x==="lower_third"?`${wv[V]}
|
|
296
|
-
${kv[n.int(0,kv.length-1)]}`:x==="locator"?_v[n.int(0,_v.length-1)]:vv[n.int(0,vv.length-1)];S.push({kind:x,text:fe,at:M,duration:Math.max(12,O-M),track:3})}if(x==="pip"&&E>=12){let M=n.pick(t),O=Math.max(8,Math.floor(E*n.range(.5,1))),V=v(M,b(M,O,100));if(V>=0){let fe=Math.round(n.range(25,45)),xe=(1-fe/100)/2*.85,Oe=g+Math.floor((E-O)*n.next());m.push({path:M.path,source_in:V,duration:O,at:Oe,track:2,scale:fe,position_x:Math.round((n.next()<.5?-1:1)*xe*s),position_y:Math.round((n.next()<.5?-1:1)*xe*i),classes:["pip"],record_in:Oe,record_out:Oe+O})}}y={clip:G,srcOut:te+ge},g+=E}return{shots:m,titles:S}}function Gi(e,t,n){let r=e1(t);if(!r)throw new Error(`unknown operation '${t}'; known: ${Object.keys(Zh).join(", ")}`);return r(e,n)}function Nm(e,t){let n={projects:[],timelines:[],media_references:[]},r="author-tl";Gi(n,"new_timeline",{timeline_id:r,name:e.name,fps_num:e.fps_num,fps_den:e.fps_den,resolution_w:e.width,resolution_h:e.height,start_frame:e.start_frame,is_drop_frame:e.drop_frame});let o=n.timelines.find(c=>c.id===r),s=e.fps_num/e.fps_den,i=()=>o.tracks.filter(c=>c.kind==="Video"),a=new Map,l=[];for(let[c,u]of e.shots.entries()){let p=Math.max(1,u.track??1);for(;i().length<p;)Gi(n,"add_track",{timeline_id:r,kind:"Video"});let d=i()[p-1],m=a.get(u.path);m||a.set(u.path,m=t(u.path));let h=m.available_range,g=h?.duration?.rate||m.source_fps||s,y=h?.duration?.value??1/0,k=u.speed??100,b=u.ramp?Ui(u.ramp,u.duration,u.source_in,s,g,"spd"):null,w=b?Math.max(1,Math.ceil(b.sourceFrames)+1):Math.max(1,Math.round(u.duration*(g/s)*(k/100)));if(u.source_in<0||u.source_in+w>y)throw new Error(`shot ${c+1} (${m.id}): source ${u.source_in}+${w} is outside the clip (0\u2013${y-1})`);let _=Gi(n,"add_clip",{timeline_id:r,media_reference_id:m.id,media_reference:m,source_start:(h?.start?.value??0)+u.source_in,source_duration:u.duration,at_frame:u.at,track_id:d.id,without_audio:!u.audio}),v=_.meta?.item_id,R=d.items.find(E=>E.id===v);if(!R)throw new Error(`shot ${c+1}: ${_.summary}`);R.source_range={start:R.source_range.start,duration:{value:w,rate:g}};let S=_.meta?.audio_item_id;if(S&&u.audio_from){let E=o.tracks.flatMap(G=>G.items).find(G=>G.id===S),z=a.get(u.audio_from.path);if(z||a.set(u.audio_from.path,z=t(u.audio_from.path)),E){n.media_references.some(D=>D.id===z.id)||n.media_references.push(z),E.media_reference_id=z.id,E.name=z.id;let G=z.available_range?.duration?.rate||z.source_fps||s;E.source_range={start:{value:(z.available_range?.start?.value??0)+u.audio_from.source_in,rate:G},duration:{value:u.duration*(G/s),rate:G}}}}b?(R.speed_ramped=!0,R.speed=Math.round(100*b.sourceFrames/u.duration*(s/g)*100)/100):k!==100&&(R.speed=k);let T=Wi(e.width,e.height,m.source_resolution_w,m.source_resolution_h);(u.scale!=null||u.position_x!=null||u.position_y!=null||u.rotation!=null)&&Gi(n,"transform",{timeline_id:r,item_id:R.id,...u.scale!=null?{scale:u.scale}:{},...u.position_x!=null?{position_x:u.position_x/T.w}:{},...u.position_y!=null?{position_y:u.position_y/T.h}:{},...u.rotation!=null?{rotation:u.rotation}:{}});let x=[["scale",u.scale??100,u.scale_end,E=>E],["position.x",u.position_x??0,u.position_x_end,E=>E/T.w],["position.y",u.position_y??0,u.position_y_end,E=>E/T.h],["rotation",u.rotation??0,u.rotation_end,E=>E]],$=[];for(let[E,z,G,D]of x)if(G!=null)for(let[te,we]of[[0,z],[w-1,G]])$.push({id:`${R.id}-kf-${$.length}`,parameter_path:E,time:{value:R.source_range.start.value+te,rate:g},value:D(we),interp:"linear",order_index:$.length,raw_extraction:{}});if(b)for(let E of b.keyframes)$.push({...E,id:`${R.id}-${E.id}`,order_index:$.length});$.length&&(R.keyframes=$);let U=R;u.flip_h&&(U.flip_horizontal=!0),u.flip_v&&(U.flip_vertical=!0),l.push(`${c+1}. V${p} @${R.timeline_range.start.value} ${u.duration}f ${m.id} src+${u.source_in}${k!==100?` ${k}%`:""}${u.scale!=null?` scale ${u.scale}`:""}${u.rotation?` rot ${u.rotation}`:""}${u.flip_h?" flipH":""}${u.flip_v?" flipV":""}${u.audio?u.audio_from?` sound from ${u.audio_from.path.split("/").pop()}+${u.audio_from.source_in}`:" +sound":""}${b?` ramp ${u.ramp.map(([E,z])=>`${z}%@${E}`).join("\u2192")}`:""}${$.length&&!b?` animated (${$.length/2} params)`:""}`)}for(let[c,u]of(e.titles??[]).entries()){for(;i().length<u.track;)Gi(n,"add_track",{timeline_id:r,kind:"Video"});let p=i()[u.track-1],d=e.height/1080,m={font:"Arial",raster_w:e.width,raster_h:e.height,color:"#FFFFFF",opacity:1,shadow_color:"#000000",shadow_opacity:.6,shadow_dx:2*d,shadow_dy:2*d,shadow_blur:4*d,source_tool:"Resolve Text+"},h=u.kind==="lower_third"?{font_style:"Bold",size:52*d,align:"left",anchor_x:.08,anchor_y:.8,anchor_ref:"baseline"}:u.kind==="locator"?{font_style:"Regular",size:40*d,align:"left",anchor_x:.06,anchor_y:.1,anchor_ref:"baseline",tracking:.08}:{font_style:"Bold",size:110*d,align:"center",anchor_x:.5,anchor_y:.5,anchor_ref:"center"};p.items.push({id:`${r}-title-${c}`,kind:"clip",item_index:p.items.length,name:u.text.split(`
|
|
297
|
-
`)[0],enabled:!0,timeline_range:{start:{value:u.at,rate:s},duration:{value:u.duration,rate:s}},title:{text:u.text,...m,...h}}),l.push(`T${c+1}. V${u.track} @${u.at} ${u.duration}f ${u.kind} "${u.text.replace(`
|
|
298
|
-
`," / ")}"`)}return{session:n,summary:l}}function xv(e,t){tc(e.mix);let{clips:n,skipped:r}=t3(t);if(!n.length)throw new Error(`no usable clips (${r.length} skipped)`);let{shots:o,titles:s}=r3(e,n),i=e.fps_num??24e3,a=e.fps_den??1001,l=e.width??1920,c=e.height??1080,u=new Map(t.map(h=>[h.path,h.ref])),p=e.name??`generated ${e.seed}`,{session:d,summary:m}=Nm({name:p,fps_num:i,fps_den:a,width:l,height:c,shots:o.map(({classes:h,record_in:g,record_out:y,...k})=>k),titles:s},h=>u.get(h));return{session:d,summary:m,shots:o,titles:s,pool:{used:n.length,skipped:r}}}async function Vi(e){if(e.start_tc){let r=jt(e.start_tc,e.fps_num/e.fps_den);if(r==null)throw new Error(`start_tc: cannot parse '${e.start_tc}' (HH:MM:SS:FF, ';' before FF for drop frame)`);e={...e,start_frame:r,drop_frame:e.drop_frame??e.start_tc.includes(";")}}let t=new Map;for(let r of e.shots)if(!t.has(r.path))try{t.set(r.path,await mt(r.path))}catch(o){t.set(r.path,o instanceof Error?o:new Error(String(o)))}let n=new Set;for(let r of t.values()){if(r instanceof Error)continue;let o=r.id,s=2;for(;n.has(o);)o=`${r.id} (${s++})`;n.add(r.id=o)}return Nm(e,r=>{let o=t.get(r);if(o instanceof Error)throw o;return o})}async function Sv(e,t,n){let r=await na({reference:e,clips:[]});try{let o=await r.ask(t,n);if(!o.ok)throw new Error(`${ie(e)}: ${o.why??"the analysis engine could not read it"}`);return o}finally{r.close()}}var $v=e=>t=>He(e.startFrame+t,e.fps||24,e.dropFrame);async function Rv(e,t,n){let r=await Sv(e,{op:"cuts"},n),o=$v(r),s=r.fps||24,[i,a]=Math.abs(s-Math.round(s))>.01?[Math.round(s*1001/1e3)*1e3,1001]:[Math.round(s),1],{session:l}=await Vi({name:t??`${ie(e)} cuts`,fps_num:i,fps_den:a,width:r.w||1920,height:r.h||1080,start_tc:He(r.startFrame,s,r.dropFrame),shots:r.shots.map(([u,p])=>({path:e,source_in:u,duration:p-u+1,at:u}))}),c=[`${ie(e)}: ${r.frames} frames @ ${s.toFixed(3)} fps \u2014 ${r.shots.length} shot(s), ${r.cuts.length} cut(s)${r.flat.length?`, ${r.flat.length} black run(s)`:""}`,...r.shots.slice(0,200).map(([u,p],d)=>`${String(d+1).padStart(4)} ${o(u)} \u2013 ${o(p)} (${p-u+1} fr)${r.flat.some(([m,h])=>m<=u&&h>=p)?" black":""}`),...r.shots.length>200?[`\u2026 ${r.shots.length-200} more`]:[]];return{session:l,text:c.join(`
|
|
299
|
-
`),data:{frames:r.frames,fps:s,cuts:r.cuts,shots:r.shots,black:r.flat,cutsTc:r.cuts.map(o)}}}async function Cv(e,t={},n){let r=await Sv(e,{op:"qc",edgesEvery:t.edges_every??1},n),o=$v(r),s=(w,_)=>w===_?o(w):`${o(w)} \u2013 ${o(_)}`,i=r.temporal.findings.filter(w=>w.severity==="fail"),a=r.temporal.findings.filter(w=>w.severity==="warn"),[l,c]=r.matteRaster??[0,0],u=r.matte,p=r.format,d=["top","bottom","left","right"].flatMap(w=>r.edges[w].map(_=>({e:w,..._}))),m=r.audio??[],h=m.flatMap(w=>w.findings.map(_=>({track:w.track,..._}))),g=i.length||d.length||r.pixels.defects.length||h.some(w=>w.severity==="fail")?"FAIL":a.length||h.length?"CHECK":"PASS",y=[`${ie(e)}: ${g} \u2014 ${r.frames} frames, ${r.w}\xD7${r.h} @ ${(r.fps||0).toFixed(3)} fps`,`frames: ${i.length} fail, ${a.length} to check (motion p50 ${r.temporal.stats.motionP50}, p90 ${r.temporal.stats.motionP90})`,...r.temporal.findings.filter(w=>w.severity!=="info").map(w=>` ${w.severity.toUpperCase().padEnd(4)} ${w.check.padEnd(9)} ${s(w.start,w.end)} ${w.detail}`),...u&&p?[`picture: ${u.h<c?"letterbox":"pillarbox"} ${p} \u2014 active ${u.w}\xD7${u.h} of ${l}\xD7${c} (the format: edges are checked past it)`]:[],`edges${r.edgesEvery>1?` (every ${r.edgesEvery}th frame)`:""}: ${d.length?`worst top ${r.edges.worst.top}, bottom ${r.edges.worst.bottom}, left ${r.edges.worst.left}, right ${r.edges.worst.right} px${p?" past the picture":""}`:"clean"}`,...d.slice(0,40).map(w=>` FAIL ${w.e.padEnd(6)} ${w.thickness} px ${s(w.start,w.end)}`),...r.cardFrames?.length?[` INFO picture on black (a card, logo or graphic) on ${r.cardFrames.length} frame(s) checked, first ${o(r.cardFrames[0])}: not blanking`]:[],...r.edges.cornerFrames.length?[` CHECK black corners on ${r.edges.cornerFrames.length} frame(s), first ${o(r.edges.cornerFrames[0])}`]:[],`pixels: ${r.pixels.measurable?r.pixels.defects.length?`${r.pixels.defects.length} defect(s)`:"clean":"not measurable (the picture barely moves across the frames sampled)"} (${r.pixels.frames} frames)`,...r.pixels.defects.map(w=>` FAIL ${w.kind.padEnd(4)} pixel at ${w.x},${w.y}${w.pixels>1?` (${w.pixels} px)`:""}, value ${w.value}, ${w.contrast>0?"+":""}${w.contrast} vs its neighbours`),`sound: ${m.length?m.map(w=>`track ${w.track} ${w.channels}ch ${w.lufs??"\u2014"} LUFS ${w.truePeak??"\u2014"} dBTP`).join("; "):"no audio track"}`,...h.slice(0,40).map(w=>` ${w.severity.toUpperCase().padEnd(4)} ${w.check.padEnd(14)} track ${w.track}${w.channel?` ch ${w.channel}`:""}${w.start!=null?` at ${o(Math.floor(w.start*(r.fps||24)))}`:""} ${w.detail}`)],k=r.temporal.findings.filter(w=>w.check==="duplicate"||w.check==="retime"),b=k.length?[{verb:"media_fix",args:{kind:"duplicates",path:e},why:`${k.length} repeated-frame finding(s): remade as the motion between their neighbours`}]:[];return b.length&&y.push(`fix: media_fix kind=duplicates \u2014 ${b[0].why} (plan_only first)`),{verdict:g,text:y.join(`
|
|
300
|
-
`),data:{verdict:g,...r,fixes:b}}}async function o3(e){let t=[];async function n(r,o){if(!(await At(r)).isDirectory){if(/\.wav$/i.test(r))t.push(r);else throw new Error(`not a WAV: ${r}`);return}if(!(o>10))for await(let i of Rt(r))!i.name.startsWith(".")&&(i.isDirectory||/\.wav$/i.test(i.name))&&await n(B(r,i.name),o+1)}for(let r of e)await n(r,0);return t.sort((r,o)=>ie(r).localeCompare(ie(o)))}async function Ev(e,t){let n=(await Om(e.picture)).sort((w,_)=>ie(w).localeCompare(ie(_))),r=await o3(e.sound);if(!n.length)throw new Error("no picture files found");if(!r.length)throw new Error("no recorder WAVs found");let o=await Wt({op:"sync",picture:n,sound:r},t),s=o.synced,i=await Promise.all(n.map(w=>mt(w))),a=w=>w.available_range?.duration.rate||24,l=a(i[0]),c=w=>(w.source_timecode?jt(w.source_timecode,a(w)):null)??0,u=n.map((w,_)=>_).sort((w,_)=>c(i[w])-c(i[_])||ie(n[w]).localeCompare(ie(n[_]))),[p,d]=Math.abs(l-Math.round(l))>.01?[Math.round(l*1001/1e3)*1e3,1001]:[Math.round(l),1],m=0,h=u.map(w=>{let _=Math.round(i[w].available_range?.duration.value??0),v={path:n[w],source_in:0,duration:_,at:m};return m+=_,v}),{session:g}=await Vi({name:e.name??`${ie(r[0])} dailies`,fps_num:p,fps_den:d,width:i[0].source_resolution_w||1920,height:i[0].source_resolution_h||1080,shots:h});s3(g,s,u,h,r,await Promise.all(r.map(w=>mt(w))),l);let y=w=>He(w,l,!1),k=(w,_)=>{let v=o.sound[w];return v.start!=null?y(Math.round((v.start+_)*l)):`+${_.toFixed(3)} s`},b=[`${n.length} picture file(s), ${r.length} recorder file(s): ${s.filter(w=>w.by==="sound").length} synced by sound, ${s.filter(w=>w.by==="timecode").length} by timecode only, ${s.filter(w=>w.by==="none").length} not found`,...u.map(w=>{let _=s[w];return` ${ie(n[w]).padEnd(32)} ${_.sound==null?"\u2014".padEnd(24):ie(r[_.sound]).padEnd(24)} ${_.by.padEnd(8)} ${_.offset==null?"":`at ${k(_.sound,_.offset)}`}${_.tcOffFrames!=null?` TC ${_.tcOffFrames>=0?"+":""}${_.tcOffFrames} fr`:""}${_.note?` \u2014 ${_.note}`:""}`})];return{session:g,text:b.join(`
|
|
301
|
-
`),data:{picture:n.map((w,_)=>({path:w,...s[_],sound:s[_].sound==null?null:r[s[_].sound]}))}}}function s3(e,t,n,r,o,s,i){let a=e.timelines[0],l=d=>d.streams?.find(m=>m.kind==="audio")?.channels??1,c=Math.max(1,...t.filter(d=>d.sound!=null).map(d=>l(s[d.sound]))),u=new Map;for(let[d,m]of s.entries())e.media_references?.some(h=>h.id===m.id)||e.media_references?.push(m),u.set(d,m.id);let p=d=>({value:d,rate:i});for(let d=0;d<c;d++){let m=[];n.forEach((h,g)=>{let y=t[h],k=r[g];y.sound==null||y.offset==null||d>=l(s[y.sound])||m.push({id:`sync-a${d+1}-${g+1}`,kind:"clip",item_index:m.length,name:ie(o[y.sound]),enabled:!0,timeline_range:{start:p(k.at),duration:p(k.duration)},source_range:{start:p(y.offset*i),duration:p(k.duration)},media_reference_id:u.get(y.sound),channel_map:{routing:{[d]:0}}})}),a.tracks.push({id:`sync-a${d+1}`,kind:"Audio",track_index:d,name:`A${d+1}`,enabled:!0,items:m,audio_channel_count:1})}}var i3=2.5;async function a3(e,t){let n=t.map(s=>{let i=Math.max(1,Math.round(s.duration*((s.speed??100)/100)));return{s,need:i,frames:[s.source_in,s.source_in+(i>>1),s.source_in+i-1]}}),r=await e.ask({op:"detail",frames:n.flatMap(s=>s.frames.map(i=>[s.s.path,i]))});if(!r.ok)throw new Error(`the analysis engine could not read the planned shots: ${r.why}`);let o=r.detail;return n.flatMap((s,i)=>o.slice(3*i,3*i+3).filter(a=>a!=null&&a<i3).length>=2?[{path:s.s.path,from:s.s.source_in-24,to:s.s.source_in+s.need+24}]:[])}var l3=/\.(mov|mxf|mp4|m4v|mts|braw|r3d|ari)$/i,c3=/prox(y|ies)|^cache$/i;async function Av(e,t,n=!0){if((await Deno.stat(e)).isFile){l3.test(e)&&!e.split("/").pop().startsWith("._")&&t.push(e);return}if(!(!n&&c3.test(e.split("/").pop())))for await(let o of Deno.readDir(e))o.name.startsWith(".")||await Av(`${e}/${o.name}`,t,!1)}async function Iv(e){tc(e.mix);let t=[];for(let c of e.media)await Av(c,t);if(t.sort(),!t.length)throw new Error("no video files under the media given");let n=[],r=new Map;for(let c of t)try{n.push({path:c,ref:await mt(c)})}catch(u){r.set(c,u instanceof Error?u.message:String(u))}let o=[...e.avoid??[]],s,i=e.look===!1?null:await Ff();try{for(let c=0;c<(e.look===!1?1:5);c++){try{s=xv({...e,avoid:o},n)}catch(p){throw p instanceof Error&&p.message.startsWith("no usable clips")?new Error(`no usable clips (${t.length} skipped)`):p}if(e.look===!1)break;let u=await a3(i,s.shots);if(!u.length)break;o.push(...u)}}finally{i?.close()}if(!s)throw new Error("no cut");let a=new Map([...r,...s.pool.skipped.map(c=>[c.path,c.reason])]),l=t.filter(c=>a.has(c)).map(c=>`${c} (${a.get(c)})`);return{session:s.session,summary:s.summary,shots:s.shots,titles:s.titles,pool:{used:s.pool.used,skipped:l}}}async function Mv(e){let t=await ec({reference:e.b,pool:[e.a],name:`${ie(e.b)} rebuilt from ${ie(e.a)}`,onProgress:e.onProgress,signal:e.signal}),n=t.report,r=n.clips[0],o={fps:n.refFps,frames:n.refFrames,startFrame:n.refStartFrame,dropFrame:n.refDropFrame,w:n.refW,h:n.refH,label:""},s=r?{fps:r.srcFps??n.refFps,frames:r.srcFrames,startFrame:r.srcStartFrame,dropFrame:n.refDropFrame,w:r.srcW,h:r.srcH,label:r.codec}:{...o,frames:0},i=m=>s.fps?He(s.startFrame+m,s.fps,s.dropFrame):"",a=m=>o.fps?He(o.startFrame+m,o.fps,o.dropFrame):"",l=t.issues,c=[],u=(m,h)=>{let g=c[c.length-1];g?.kind==="hole"&&g.recordOut===m?(g.count+=h-m,g.recordOut=h,g.recordOutTc=a(h)):c.push({index:0,kind:"hole",count:h-m,recordIn:m,recordOut:h,recordInTc:a(m),recordOutTc:a(h)})},p=0;for(let m of[...n.timeline].sort((h,g)=>h.refStart-g.refStart)){m.refStart>p&&u(p,m.refStart);let h=m.refEnd-m.refStart+1;if(!m.clipLabel||m.srcStart==null){u(m.refStart,m.refEnd+1),p=m.refEnd+1;continue}let g=m.speed?.slope??1,y=m.ramp?null:Array.from({length:h},(v,R)=>m.srcStart+Math.floor(R*g+.001)),k=y?Math.min(...y):m.srcStart,b=y?Math.max(...y):m.srcStart+h-1,w={index:0,kind:"a-source",count:h,recordIn:m.refStart,recordOut:m.refEnd+1,recordInTc:a(m.refStart),recordOutTc:a(m.refEnd+1),aIn:k,aOut:b+1,aInTc:i(k),aOutTc:i(b+1)};m.ramp?w.motion={percent:100,ramp:!0,entry:m.srcStart,entryTc:i(m.srcStart)}:m.speed&&m.speed.kind!=="normal"&&(w.motion={percent:m.speed.kind==="freeze"?0:(m.speed.kind==="reverse"?-1:1)*m.speed.percent,entry:m.srcStart,entryTc:i(m.srcStart)});let _=l.find(v=>v.refStart<=m.refEnd&&v.refEnd>=m.refStart&&v.kind!=="retime");_&&(w.unreproducible={checked:0,failed:0,note:_.message}),c.push(w),p=m.refEnd+1}p<o.frames&&u(p,o.frames),c.forEach((m,h)=>m.index=h+1);let d={...o,codec:"",kind:"unknown"};return{a:s,b:o,events:c,summary:P_(c),check:c.filter(m=>m.unreproducible),edl:F_(c,d,{title:`${ie(e.b)} FROM ${ie(e.a)}`.toUpperCase().slice(0,70),aReel:ie(e.a)}),csv:O_(c),session:t.session,stats:t.stats}}function Pv(e,t){let n=(s,i)=>`${ie(i)}: ${s.label?`${s.label} `:""}${s.w}x${s.h} @ ${s.fps?.toFixed(3)??"?"} fps, ${s.frames} frames`,r=e.summary.hole===0&&e.events.length===1&&!e.events[0].motion&&e.events[0].aIn===0&&e.events[0].count===e.a.frames,o=s=>s.motion?s.motion.ramp?" SPEED RAMP":s.motion.percent===0?" FREEZE":s.motion.percent<0?` REVERSE ${-s.motion.percent.toFixed(1)}%`:` SPEED ${s.motion.percent.toFixed(1)}%`:"";return[`A (old) ${n(e.a,t.a)}`,`B (new) ${n(e.b,t.b)}`,r?"B is A, picture for picture (one event covers the whole cut).":`B rebuilt from A in ${e.events.length} event(s): ${e.events.filter(s=>s.kind!=="hole").length} from A (${e.summary.aSource} frames), ${e.events.filter(s=>s.kind==="hole").length} hole(s) of new material (${e.summary.hole} frames)`,"",...e.events.map(s=>`${String(s.index).padStart(4)} ${s.recordInTc}\u2013${s.recordOutTc} ${s.kind==="hole"?`NEW MATERIAL (${s.count} fr)`:`A ${s.aInTc}\u2013${s.aOutTc} (${s.count} fr)${o(s)}`}${s.unreproducible?` CHECK: ${s.unreproducible.note}`:""}`)].join(`
|
|
302
|
-
`)}import{basename as Ho}from"node:path";var Fv=48e3*30;function Dm(e){return(t,n)=>e.slice(t,t+n).arrayBuffer().then(r=>new Uint8Array(r))}var u3=async e=>{let t=globalThis.OfflineAudioContext;if(!t)return null;let r=await new t(1,1,48e3).decodeAudioData(await e.arrayBuffer()),o=new Float32Array(r.length);for(let s=0;s<r.numberOfChannels;s++){let i=r.getChannelData(s);for(let a=0;a<i.length;a++)o[a]+=i[a]/r.numberOfChannels}return{sampleRate:r.sampleRate,channels:1,chunks:(async function*(){yield o})()}},d3=u3;async function p3(e){let t=await d3(e).catch(()=>null);if(!t)return null;let n=new Hi(t.channels,t.sampleRate,100),r=0;for await(let o of t.chunks)n.push(o),r+=o.length/t.channels;return r?{sampleRate:t.sampleRate,channels:t.channels,sampleFrames:r,durationSec:r/t.sampleRate,envelopes:n.finish(),codec:"platform"}:null}async function Ov(e){await Dr();let t=Dm(e),n=await ua(t,e.size),r=JSON.parse(n);if(!r||r.aac)return p3(e);let o=r.sample_rate??0,s=r.channels??0,i=r.sample_frames??0;if(!o||!s||!i)return null;let a=new Hi(s,o,100);for(let l=0;l<i;l+=Fv){let c=Math.min(Fv,i-l),u=await da(t,e.size,l,c);if(!u||u.length<12)break;let p=new DataView(u.buffer,u.byteOffset,u.byteLength),d=p.getUint32(8,!0),m=p.getUint32(4,!0);if(!d||!m)break;let h=u.byteOffset+12,g=h%4===0?new Float32Array(u.buffer,h,d*m):new Float32Array(u.slice(12).buffer,0,d*m);a.push(g)}return{sampleRate:o,channels:s,sampleFrames:i,durationSec:i/o,envelopes:a.finish(),codec:r.codec}}function m3(e){let t=1681.974450955533,n=3.999843853973347,r=.7071752369554196,o=Math.tan(Math.PI*t/e),s=Math.pow(10,n/20),i=Math.pow(s,.4996667741545416),a=1+o/r+o*o,l={b0:(s+i*o/r+o*o)/a,b1:2*(o*o-s)/a,b2:(s-i*o/r+o*o)/a,a1:2*(o*o-1)/a,a2:(1-o/r+o*o)/a},c=38.13547087602444,u=.5003270373238773,p=Math.tan(Math.PI*c/e),d=1+p/u+p*p,m={b0:1,b1:-2,b2:1,a1:2*(p*p-1)/d,a2:(1-p/u+p*p)/d};return{shelf:l,highpass:m}}function f3(e){switch(e){case 1:return[1];case 2:return[1,1];case 6:return[1,1,1,0,1.41,1.41];case 8:return[1,1,1,0,1.41,1.41,1.41,1.41];default:return new Array(e).fill(1)}}var h3=-.691,g3=-70,b3=10,y3=.4,w3=.75;var rc=class{constructor(t,n){this.channels=t;this.sampleRate=n;this.blockFilled=0;this.historyAt=0;this.sinceLastBlock=0;this.totalSamples=0;this.blockPower=[];let r=m3(n);this.shelf=r.shelf,this.highpass=r.highpass,this.weights=f3(t),this.state=Array.from({length:t},()=>({s1:[0,0,0,0],s2:[0,0,0,0]})),this.blockSize=Math.round(y3*n),this.hop=Math.max(1,Math.round(this.blockSize*(1-w3))),this.blockSums=new Array(t).fill(0),this.history=Array.from({length:t},()=>new Float32Array(this.blockSize))}step(t,n,r){let o=t.b0*r+t.b1*n[0]+t.b2*n[1]-t.a1*n[2]-t.a2*n[3];return n[1]=n[0],n[0]=r,n[3]=n[2],n[2]=o,o}push(t){let n=Math.floor(t.length/this.channels);for(let r=0;r<n;r++){for(let o=0;o<this.channels;o++){let s=this.state[o],i=this.step(this.highpass,s.s2,this.step(this.shelf,s.s1,t[r*this.channels+o])),a=i*i;this.blockSums[o]+=a-this.history[o][this.historyAt],this.history[o][this.historyAt]=a}if(this.historyAt=(this.historyAt+1)%this.blockSize,this.totalSamples++,this.blockFilled<this.blockSize&&this.blockFilled++,this.blockFilled>=this.blockSize&&(this.sinceLastBlock++,this.sinceLastBlock>=this.hop||this.blockPower.length===0)){this.sinceLastBlock=0;let o=0;for(let s=0;s<this.channels;s++){let i=this.weights[s]??1;i!==0&&(o+=i*(this.blockSums[s]/this.blockSize))}this.blockPower.push(o)}}}finish(){return k3(this.blockPower)}get samplesSeen(){return this.totalSamples}};function k3(e){let t=a=>a>0?h3+10*Math.log10(a):-1/0,n=e.filter(a=>t(a)>g3);if(n.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let r=n.reduce((a,l)=>a+l,0)/n.length,o=t(r)-b3,s=n.filter(a=>t(a)>o);if(s.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let i=s.reduce((a,l)=>a+l,0)/s.length;return{integratedLufs:t(i),gatedBlocks:s.length,totalBlocks:e.length}}var _3=4,nc=32;function v3(e=_3,t=nc){let n=[],r=t/2;for(let o=0;o<e;o++){let s=new Float32Array(t),i=0;for(let a=0;a<t;a++){let l=a-r+1-o/e,c=l===0?1:Math.sin(Math.PI*l)/(Math.PI*l),u=.42-.5*Math.cos(2*Math.PI*a/(t-1))+.08*Math.cos(4*Math.PI*a/(t-1));s[a]=c*u,i+=s[a]}if(i!==0)for(let a=0;a<t;a++)s[a]/=i;n.push(s)}return n}var Lv=1024;var oc=class{constructor(t){this.channelCount=t;this.base=0;this.next=0;this.peak=0;this.phases=v3(),this.half=nc/2;let n=1;for(let r=1;r<this.phases.length;r++){let o=0;for(let s=0;s<nc;s++)o+=Math.abs(this.phases[r][s]);o>n&&(n=o)}this.l1=n,this.buffers=Array.from({length:t},()=>new Float32Array(0))}push(t){let n=Math.floor(t.length/this.channelCount);if(n<=0)return;for(let o=0;o<this.channelCount;o++){let s=this.buffers[o],i=new Float32Array(s.length+n);i.set(s,0);for(let a=0;a<n;a++){let l=t[a*this.channelCount+o];i[s.length+a]=l;let c=l<0?-l:l;c>this.peak&&(this.peak=c)}this.buffers[o]=i}let r=this.base+this.buffers[0].length;this.evaluate(r-this.half,!1),this.trim()}finish(){let t=this.base+this.buffers[0].length;return this.evaluate(t,!0),this.peak>0?20*Math.log10(this.peak):-1/0}evaluate(t,n){if(!(t<=this.next)){for(let r=0;r<this.channelCount;r++){let o=this.buffers[r],s=this.base,i=this.base+o.length;for(let a=this.next;a<t;a+=Lv){let l=Math.min(a+Lv,t),c=Math.max(s,a-this.half),u=Math.min(i,l+this.half),p=0;for(let d=c;d<u;d++){let m=o[d-s]<0?-o[d-s]:o[d-s];m>p&&(p=m)}if(!(p*this.l1<=this.peak))for(let d=a;d<l;d++)for(let m=1;m<this.phases.length;m++){let h=this.phases[m],g=0;for(let k=0;k<nc;k++){let b=d+k-this.half+1;b>=s&&b<i&&(g+=o[b-s]*h[k])}let y=g<0?-g:g;y>this.peak&&(this.peak=y)}}}this.next=t,n&&(this.next=Math.max(this.next,this.base+this.buffers[0].length))}}trim(){let t=Math.max(this.base,this.next-this.half+1),n=t-this.base;if(!(n<=0)){for(let r=0;r<this.channelCount;r++)this.buffers[r]=this.buffers[r].slice(n);this.base=t}}};var T3={fps:24,minTonality:.7,minIsolationDb:20,maxFrameMultiple:3};function x3(e,t,n,r,o){let s=Math.round(n*r/o),i=2*Math.PI*s/n,a=2*Math.cos(i),l=0,c=0;for(let u=0;u<n;u++){let p=e[t+u]+a*l-c;c=l,l=p}return Math.sqrt(l*l+c*c-a*l*c)/(n/2)}function S3(e,t,n){let r=0;for(let o=0;o<n;o++){let s=e[t+o];r+=s*s}return Math.sqrt(r/n)}var sc=e=>e>0?20*Math.log10(e):-1/0;function Nv(e,t,n={}){let r={...T3,...n};if(t<=0||e.length===0)return null;let o=1e3/r.fps,s=Math.max(64,Math.round(20/1e3*t)),i=Math.max(1,Math.round(s/2)),a=Math.min(e.length,Math.round(12*t));if(a<s*4)return null;let l=[],c=[];for(let g=0;g+s<=a;g+=i){let y=S3(e,g,s);l.push(y),c.push(y>1e-6?Math.min(1,x3(e,g,s,1e3,t)/(y*Math.SQRT2)):0)}if(l.length<4)return null;let u=[...l].sort((g,y)=>g-y),p=u[Math.floor(u.length/2)],d=g=>c[g]>=r.minTonality&&sc(l[g])-sc(Math.max(p,1e-9))>=r.minIsolationDb,m=null,h=0;for(;h<l.length;){if(!d(h)){h++;continue}let g=h;for(;g+1<l.length&&d(g+1);)g++;let y=g-h+1,k=((y-1)*i+s)*1e3/t;if(k<=o*r.maxFrameMultiple){let b=(h*i+(g*i+s))/2,w=Math.max(...l.slice(h,g+1)),_=c.slice(h,g+1).reduce((R,S)=>R+S,0)/y,v={atSeconds:b/t,durationMs:k,tonality:_,isolationDb:sc(w)-sc(Math.max(p,1e-9))};(!m||v.isolationDb>m.isolationDb)&&(m=v)}h=g+1}return m}function Dv(e,t){if(t<=1)return e;let n=Math.floor(e.length/t),r=new Float32Array(n);for(let o=0;o<n;o++){let s=0;for(let i=0;i<t;i++)s+=e[o*t+i];r[o]=s/t}return r}var jv=1<<18;async function Bv(e,t={}){await Dr();let n=Dm(e),r=await ua(n,e.size),o=JSON.parse(r);if(!o||o.aac)return{loudness:null,twoPop:null,truePeakDb:null};let s=o.sample_rate??0,i=o.channels??0,a=o.sample_frames??0;if(!s||!i||!a)return{loudness:null,twoPop:null,truePeakDb:null};let l=new rc(i,s),c=new oc(i),u=Math.min(a,Math.round(12*s)),p=new Float32Array(u*i),d=0;for(let y=0;y<a;y+=jv){if(t.signal?.aborted)return{loudness:null,twoPop:null,truePeakDb:null};let k=Math.min(jv,a-y),b=await da(n,e.size,y,k);if(!b||b.length<12)break;let w=new DataView(b.buffer,b.byteOffset,b.byteLength),_=w.getUint32(8,!0),v=w.getUint32(4,!0);if(!_||!v)break;let R=b.byteOffset+12,S=R%4===0?new Float32Array(b.buffer,R,_*v):new Float32Array(b.slice(12).buffer,0,_*v);if(l.push(S),c.push(S),d<p.length){let T=Math.min(S.length,p.length-d);p.set(S.subarray(0,T),d),d+=T}t.onProgress?.(Math.min(y+k,a),a)}let m=l.finish(),h=d>0?Nv(Dv(p.subarray(0,d),i),s,{fps:t.fps&&t.fps>0?t.fps:void 0}):null,g=c.finish();return{loudness:m.integratedLufs===null?null:m,twoPop:h,truePeakDb:Number.isFinite(g)?g:null}}var R3={apco:"ProRes 422 Proxy",apcs:"ProRes 422 LT",apcn:"ProRes 422",apch:"ProRes 422 HQ",ap4h:"ProRes 4444",ap4x:"ProRes 4444 XQ",aprn:"ProRes RAW",aprh:"ProRes RAW HQ"};function qv(e){let t=(e??"").toLowerCase().trim(),n=v1(t);return{family:n,label:R3[t]??n??t,bitDepth:T1(t),chroma:x1(t)}}function jm(e){return e.toLowerCase().replace(/\b(apple|avid|sony|panasonic)\b/g,"").replace(/[\s_-]+/g,"")}function Uv(e,t){let n=jm(e),r=jm(t.label);return!n||!r?!1:r===n||r.startsWith(n)?!0:t.family!=null&&jm(t.family)===n}var Tq={"23.98":24e3/1001,"23.976":24e3/1001,"29.97":3e4/1001,"59.94":6e4/1001,"47.95":48e3/1001,"119.88":12e4/1001};function Hv(e,t,n,r=255){let o=e instanceof Int32Array?-13110.4:r*.1,s=Math.floor(n*.45),i=Math.floor(t*.45),a=m=>{let h=0,g=m*t;for(let y=0;y<t;y++)e[g+y]<=o&&h++;return h>=t*.95},l=m=>{let h=0;for(let g=0;g<n;g++)e[g*t+m]<=o&&h++;return h>=n*.95},c=0;for(;c<s&&a(c);)c++;let u=0;for(;u<s&&a(n-1-u);)u++;let p=0;for(;p<i&&l(p);)p++;let d=0;for(;d<i&&l(t-1-d);)d++;return{top:c,bottom:u,left:p,right:d}}function Wv(e,t,n){if(e.length===0)return null;let r=(c,u)=>{let p=Math.floor(u*.02),d=e.filter(m=>m[c]>p);return d.length<e.length*.8?0:Math.min(...d.map(m=>m[c]))},o=r("top",n),s=r("bottom",n),i=r("left",t),a=r("right",t);if(o+s+i+a===0)return null;let l={x:i,y:o,w:t-i-a,h:n-o-s};return l.w<t*.3||l.h<n*.3?null:l}function zv(e,t=16){if(e<=0)return[];let n=Math.min(t,e);if(n===1)return[e>>1];let r=[];for(let o=0;o<n;o++)r.push(Math.min(e-1,Math.floor((o+.5)*e/n)));return[...new Set(r)]}function Gv(e,t,n){if(!e)return null;let r=Math.round(e.y),o=Math.round(n-e.h-e.y),s=Math.round(e.x),i=Math.round(t-e.w-e.x),a=[];return(r||o)&&a.push(`letterboxed ${r===o?`${r} px top and bottom`:`${r} px top, ${o} px bottom`}`),(s||i)&&a.push(`pillarboxed ${s===i?`${s} px each side`:`${s} px left, ${i} px right`}`),a.length?a.join(", "):null}function C3(e){let t=new DataView(e.buffer,e.byteOffset,8);return{w:t.getUint32(0,!0),h:t.getUint32(4,!0)}}function Bm(e){let t=c1(e),{w:n,h:r}=C3(t),o=new Int32Array(n*r),s=new DataView(t.buffer,t.byteOffset+8,n*r*4);for(let i=0;i<n*r;i++)o[i]=s.getInt32(i*4,!0);return{y:o,w:n,h:r}}function qo(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0,!0),r=t.getUint32(4,!0),o=n*r;if(e.byteLength<8+o*4)throw new Error(`decoded frame short: ${e.byteLength} B for ${n}x${r}`);let s=new Uint8Array(o);for(let i=0,a=8;i<o;i++,a+=4)s[i]=54*e[a]+183*e[a+1]+19*e[a+2]+128>>8;return{y:s,w:n,h:r}}function Uo(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0,!0),o=n.getUint32(4,!0),s=r*o;if(e.byteLength<8+s*2)throw new Error(`decoded luma short: ${e.byteLength} B for ${r}x${o}`);let i=new Uint16Array(s);for(let a=0,l=8;a<s;a++,l+=2)i[a]=n.getUint16(l,!0);return{y:i,w:r,h:o,peak:t}}function Qv(e,t){switch(t.codec){case"prores":return Uo(Hc(e),1023);case"r3d":return Uo(u1(e),255);case"arriraw":return Uo(r1(e,t.w,t.h),255);case"xocn":return Uo(f1(e),255);case"vc3":return Uo(d1(e),255);case"braw":return Uo(s1(e),4095);case"proresraw":return Uo(a1(e),255)}}var Kv={gpu:0,wasm:0};var qm=null;function E3(){return qm||(qm=!_1||typeof navigator>"u"||!("gpu"in navigator)?Promise.resolve(null):import("./prores-RIG37OIH.js").catch(()=>null)),qm}function A3(e,t,n,r){if(r===t&&e.length===t*n)return e;let o=new Uint16Array(t*n);for(let s=0;s<n;s++)o.set(e.subarray(s*r,s*r+t),s*t);return o}async function I3(e){try{let t=await E3();if(!t||!await t.proresGpuAvailable())return null;let n=await t.decodeProResFrameGpu(e);return n?{y:A3(n.y,n.width,n.height,n.strideY),w:n.width,h:n.height,peak:1023}:null}catch{return null}}async function M3(e,t){if(t.codec==="prores"){let n=await I3(e);if(n)return Kv.gpu++,n;Kv.wasm++}return Qv(e,t)}function Yv(e){let t=e.y.length,n=new Uint8Array(t);if(e.peak===255){for(let o=0;o<t;o++)n[o]=e.y[o]>255?255:e.y[o];return n}let r=255/e.peak;for(let o=0;o<t;o++){let s=Math.round(e.y[o]*r);n[o]=s>255?255:s}return n}function P3(e,t,n="coarse"){if(n==="exact"){let r=Qv(e,t);return{y:Yv(r),w:r.w,h:r.h}}if(n==="index"&&t.codec==="prores"){let r=Bm(e),o=e.length>20?e[18]<<8|e[19]:0,s=o>0?Math.min(r.h,Math.max(1,Math.round(o/8))):r.h,i=new Uint8Array(r.w*s);for(let a=0;a<i.length;a++)i[a]=Math.max(0,Math.min(255,Math.round(r.y[a]/128+128)));return{y:i,w:r.w,h:s}}if(n==="index"&&t.codec==="r3d")return qo(Wc(e,0));if(n==="index"&&t.codec==="xocn"){let r=m1(e),o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=o.getUint32(0,!0),i=o.getUint32(4,!0);return{y:r.subarray(8,8+s*i),w:s,h:i}}switch(t.codec){case"prores":{let r=Bm(e);return{y:r.y,w:r.w,h:r.h}}case"r3d":return qo(Wc(e,t.subbands));case"arriraw":return qo(o1(e,t.w,t.h,t.scale));case"xocn":return qo(t.display==="rec709"?g1(e):h1(e,t.scale));case"vc3":return qo(p1(e,t.scale));case"braw":return qo(i1(e,t.scale));case"proresraw":return qo(l1(e,t.scale))}}var Vv=512*1024,Jv=160*1024,Xv=16*1024;async function Zv(e,t,n,r,o="coarse"){let s=async i=>new Uint8Array(await e.slice(t,t+i).arrayBuffer());if(o==="index"&&r?.codec==="xocn"&&n>Jv){let i=await s(Jv),a=w1(i.subarray(0,128));if(a>0&&a<=n)return a<=i.length?i.subarray(0,a):await s(a)}if(o!=="exact"&&r?.codec==="r3d"&&n>Xv){let i=await s(Xv),a=y1(i,n,o==="index"?0:Math.min(3,r.subbands)),l=new Uint8Array(n);if(l.set(i),!a.length)return l.set(new Uint8Array(await e.slice(t+i.length,t+n).arrayBuffer()),i.length),l;let c=a[0];await Promise.all(Array.from({length:c},async(u,p)=>{let d=a[1+2*p],m=d+a[2+2*p];d<i.length&&(d=i.length),d<m&&l.set(new Uint8Array(await e.slice(t+d,t+m).arrayBuffer()),d)}));for(let u=1+2*c;u<a.length;u++){let p=a[u];l[p]=255,l[p+1]=144,l[p+2]=0,l[p+3]=10,l[p+12]=255,l[p+13]=147}return l}if(o!=="exact"&&r?.codec==="xocn"&&n>Vv){let i=await s(Vv),a=k1(i.subarray(0,128));if(a>0&&a<=n)return a<=i.length?i.subarray(0,a):await s(a)}return await s(n)}async function eT(e,t,n="coarse"){if(n!=="exact")return P3(e,t,n);let r=await M3(e,t);return{y:Yv(r),w:r.w,h:r.h}}async function F3(e,t,n,r,o,s){let i=await eT(e,t,n),a={idx:o,ok:!0,w:i.w,h:i.h,black:rT(i.y)};if(r.diff&&s&&(a.diff=oT(s.y,i.y)),r.hash){let l=M_(i.y,i.w,i.h);a.bits=Array.from(l.bits),a.q=l.quality,a.my=l.meanY??0}return r.bars&&(a.bars=Hv(i.y,i.w,i.h)),{result:a,plane:i}}var tT=e=>({idx:e,ok:!1,w:0,h:0,black:!1});async function O3(e,t,n,r,o,s,i){let a=[],l=null;for(let c=0;c<t.length;c++){let u=t[c],p=c<n,d;try{let m=await Zv(e,u.offset,u.size,r,o),h=await F3(m,r,o,s,u.idx,l);l=h.plane,d=h.result}catch{d=tT(u.idx)}p||a.push(d),i?.(p?null:d)}return a}function L3(e,t){let n=[],r=Math.min(t,e.length);if(r===0)return n;let o=Math.ceil(e.length/r);for(let s=0;s<e.length;s+=o){let i=e.slice(s,s+o);s===0?n.push({jobs:i,primers:0}):n.push({jobs:[e[s-1],...i],primers:1})}return n}async function nT(e,t,n,r,o,s={}){let{signal:i,onProgress:a}=s;if(t.length===0)return[];let l=t.length,c=0,u=()=>a?.(++c,l);if(typeof Worker>"u")return await O3(e,t,0,n,r,o,g=>{if(i?.aborted)throw new DOMException("aborted","AbortError");g&&u()});let p=Math.max(1,Math.min(navigator.hardwareConcurrency||4,16,t.length)),d=o.diff?L3(t,p):Array.from({length:p},(h,g)=>({jobs:t.filter((y,k)=>k%p===g),primers:0})),m=new Map;return await new Promise((h,g)=>{let y=d.filter(_=>_.jobs.length>0).length;if(y===0){h();return}let k=[],b=()=>{for(let _ of k)_.terminate();i?.removeEventListener("abort",w)};function w(){b(),g(new DOMException("aborted","AbortError"))}if(i?.aborted){w();return}i?.addEventListener("abort",w,{once:!0});for(let _ of d){if(_.jobs.length===0)continue;let v=new Worker(new URL("./workers/picture-worker.ts",import.meta.url),{type:"module"});k.push(v),v.onmessage=S=>{let T=S.data;if(T.progress)for(let x=0;x<T.progress;x++)u();if(T.results){for(let x of T.results)m.set(x.idx,x);--y===0&&(b(),h())}},v.onerror=S=>{b(),g(new Error(`picture worker error: ${S.message}`))};let R={file:e,jobs:_.jobs,primers:_.primers,spec:n,tier:r,want:o};v.postMessage(R)}}),t.map(h=>m.get(h.idx)??tT(h.idx))}var N3=16,D3=.075,j3=.12;function rT(e){let t=0,n=0;for(let r=0;r<e.length;r++){let o=e[r];t+=o,o>n&&(n=o)}return t/e.length<=255*D3&&n<=255*j3}function oT(e,t){let n=Math.min(e.length,t.length);if(n===0)return 0;let r=0;for(let o=0;o<n;o++)r+=Math.abs(e[o]-t[o]);return r/n}var B3=1.5,q3=1,U3=30;function H3(e,t){let n=[];for(let r of t){let o=e.frames[r];o&&n.push({idx:r,offset:o.offset,size:o.size})}return n}async function ic(e,t,n,r,o,s){if(!t.spec)return null;try{return await nT(e,H3(t,n),t.spec,r,o,{signal:s.signal,onProgress:s.onProgress})}catch(i){if(i instanceof DOMException&&i.name==="AbortError")return null;throw i}}async function sT(e,t,n={}){let r;try{r=t??await wo(e)}catch{return null}if(!r.spec||r.frames.length===0)return null;let o=zv(r.frames.length,N3),s=await ic(e,r,o,"exact",{bars:!0},n);if(!s)return null;let i=s.filter(b=>b.ok&&b.bars);if(i.length===0)return null;let{w:a,h:l}=i[0],c=Wv(i.map(b=>b.bars),a,l),u=r.h>0&&l>0?r.h/l:1,p=r.w>0&&a>0?r.w/a:1,d=c?{x:Math.round(c.x*p),y:Math.round(c.y*u),w:Math.round(c.w*p),h:Math.round(c.h*u)}:null,m=d?Gv(d,Math.round(a*p),Math.round(l*u)):null,h=Math.max(1,Math.round(u)),g=h>1?` (\xB1${h} px, measured at 1/${h} scale)`:"",y=`across ${i.length} sampled frame${i.length===1?"":"s"}`;return c==null||c.x===0&&c.y===0&&c.w===a&&c.h===l?{hasBlanking:!1,note:`none found ${y}`}:{hasBlanking:!0,note:`${m??"bars detected"}${g} ${y}`}}async function iT(e,t,n,r={}){let o;try{o=n??await wo(e)}catch{return null}if(!o.spec||o.frames.length===0)return null;let s=o.frames.length,i=Math.min(t,s),a=Math.max(i,s-t);if(a<=i)return null;let l=[];for(let h=i;h<a;h++)l.push(h);let c=await ic(e,o,l,"exact",{},r);if(!c)return null;let u=[],p=0;for(let h of c)h.ok&&(p++,h.black&&u.push(h.idx));if(p===0)return null;let d=`${p} of ${a-i} interior frames`;if(u.length===0)return{hasBlackFrames:!1,note:`none found in ${d}`};let m=u.slice(0,5).join(", ");return{hasBlackFrames:!0,note:`${u.length} black frame${u.length===1?"":"s"} at ${m}${u.length>5?", \u2026":""} (${d})`}}function Um(e,t){let n=e/t,r=Math.floor(n/60);return`${r}:${(n-r*60).toFixed(2).padStart(5,"0")}`}async function aT(e,t,n={}){let r;try{r=t??await wo(e)}catch{return null}if(!r.spec||r.frames.length===0)return null;let o=r.fps&&r.fps>0?r.fps:24,s=Math.min(r.frames.length,Math.round(o*U3)),i=[];for(let p=0;p<s;p++)i.push(p);let a=await ic(e,r,i,"exact",{diff:!0},n);if(!a)return null;let l=[],c=[],u=0;for(let p=0;p<a.length;p++){let d=a[p];if(!d.ok){l.push(l[p-1]??!1),c.push(!1);continue}u++,l.push(d.black),c.push(d.diff==null?!1:d.diff>B3)}return u===0?null:W3(l,c,o)}function W3(e,t,n){let r=e.length,o=Math.max(2,Math.round(n*q3)),s=0;for(;s<r&&e[s];)s++;let i=s,a=-1,l=-1;for(;s<r;){if(e[s]){s++;continue}let p=s,d=s+1;for(;d<r&&!e[d]&&!t[d];)d++;if(d-p>=o){a=p,l=d;break}s=Math.max(d,s+1)}let c=null;for(let p=l>=0?l:i;p<r;p++)if(!e[p]){c=p;break}let u=[];return i>0&&u.push(`${(i/n).toFixed(2)} s black at head`),a>=0?u.push(`a static card ${Um(a,n)}\u2013${Um(l,n)} (${((l-a)/n).toFixed(2)} s)`):u.push(`no static card in the first ${(r/n).toFixed(0)} s`),c!=null&&u.push(`picture from ${Um(c,n)}`),{hasSlate:a>=0,programmeStart:c,note:u.join(", ")}}var z3=1200,G3=.5,K3=.6,V3=.7,J3=3;function X3(e,t,n){let r=e.length;for(let o=n;o<r;o++){if(!e[o]||t[o])continue;let s=0,i=0;for(let a=o;a<r;a++)t[a]||(s++,e[a]&&i++);if(s>=3&&i>=s*V3)return o}return-1}async function lT(e,t,n={}){let r;try{r=t??await wo(e)}catch{return null}if(!r.spec||r.frames.length===0)return null;let o=r.fps&&r.fps>0?r.fps:24,s=r.frames.length,i=Math.max(1,Math.round(o*G3),Math.ceil(s/z3)),a=[];for(let b=0;b<s;b+=i)a.push(b);let l=await ic(e,r,a,"coarse",{hash:!0},n);if(!l)return null;let c=[],u=[],p=[];for(let b of l)!b.ok||!b.bits||(c.push(b.idx),u.push({bits:Uint32Array.from(b.bits),quality:b.q??0,meanY:b.my}),p.push(b.black));let d=u.length,m=`sampled every ${(i/o).toFixed(2)} s`;if(d<8)return null;let h=Math.floor(d*K3);if(h<2)return null;let g=new Array(d).fill(!1);for(let b=h;b<d;b++)if(!p[b]){for(let w=0;w<h;w++)if(Gl(u[b],u[w])<=ym){g[b]=!0;break}}let y=X3(g,p,h);if(y<0)return{hasTextlessTail:!1,note:`no repeated material at the tail (${m})`};let k=(c[d-1]-c[y])/o;return k<J3?{hasTextlessTail:!1,note:`only ${k.toFixed(1)} s of repeated material at the tail, too short to be textless (${m})`}:{hasTextlessTail:!0,note:`${k.toFixed(1)} s from ${(c[y]/o/60).toFixed(0)}:${(c[y]/o%60).toFixed(2).padStart(5,"0")} repeats earlier picture (${m})`}}function Q3(e){let t=e.toLowerCase().match(/\.([a-z0-9]{2,4})$/);return t?t[1]:void 0}function Y3(e){if(e===1)return"mono";if(e===2)return"stereo";if(e===6)return"5.1"}async function cT(e,t={}){let n={name:e.name,sizeBytes:e.size,wrapper:Q3(e.name)},r;try{let o=await wo(e);r=o,n.width=o.w||void 0,n.height=o.h||void 0,n.fps=o.fps??void 0,n.durationFrames=o.frames.length||void 0;let s=o.index?.codec,i=qv(s??o.label);n.codec=s?i.label:o.label,n.bitDepth=i.bitDepth??void 0,n.chroma=i.chroma??void 0,o.fps&&Number.isFinite(o.startFrame)&&(n.startTimecode=He(o.startFrame,o.fps,o.dropFrame))}catch{}if(t.audio!==!1){try{let o=await Ov(e);o&&(n.audioChannels=o.channels,n.audioSampleRate=o.sampleRate,n.audioLayout=Y3(o.channels))}catch{}if(t.loudness!==!1)try{let o=await Bv(e,{signal:t.signal,fps:n.fps});o.loudness?.integratedLufs!=null&&(n.loudnessLufs=o.loudness.integratedLufs),o.truePeakDb!=null&&(n.truePeakDb=o.truePeakDb),n.hasTwoPop=o.twoPop!==null}catch{}}if(t.picture?.blanking){let o=await sT(e,r,{signal:t.signal});o&&(n.hasBlanking=o.hasBlanking,n.blankingNote=o.note)}if(t.picture?.headStructure){let o=await aT(e,r,{signal:t.signal});o&&(n.hasSlate=o.hasSlate,n.slateNote=o.note)}if(t.picture?.textlessTail){let o=await lT(e,r,{signal:t.signal});o&&(n.hasTextlessTail=o.hasTextlessTail,n.textlessNote=o.note)}if(t.picture?.blackFrames){let o=n.fps&&n.fps>0?Math.round(n.fps):24,s=await iT(e,o,r,{signal:t.signal});s&&(n.hasBlackFrames=s.hasBlackFrames,n.blackFramesNote=s.note)}return n}function Os(e,t,n,r,o,s){let i=fn(e,t,n,r,(a,l)=>a===l,o);return s&&i.outcome!=="unstated"?{...i,note:s}:i}function Hm(e,t){let n=t.plusMinus??0;return Math.abs(e-t.target)<=n+1e-9}function Z3(e){return e.plusMinus?`${e.target} \xB1${e.plusMinus}`:String(e.target)}function fn(e,t,n,r,o,s){if(n==null)return{field:e,label:t,outcome:"unstated"};let i=s.required(n.value);return r==null||typeof r=="number"&&!Number.isFinite(r)?{field:e,label:t,outcome:"unmeasurable",required:i,note:"not reported by the probe"}:{field:e,label:t,outcome:o(n.value,r)?"pass":"fail",required:i,measured:s.measured(r)}}var Ji={required:e=>e,measured:e=>e},Ls={required:e=>String(e),measured:e=>String(e)},Wm={required:Z3,measured:e=>String(e)};function uT(e,t){let n=e.video??{},r=e.audio??{},o=e.content??{};return[fn("video.codec","Codec",n.codec,t.codec,(s,i)=>Uv(s,{family:null,label:i}),Ji),fn("video.wrapper","Wrapper",n.wrapper,t.wrapper,(s,i)=>s.toLowerCase()===i.toLowerCase(),Ji),fn("video.width","Width",n.width,t.width,(s,i)=>s===i,Ls),fn("video.height","Height",n.height,t.height,(s,i)=>s===i,Ls),fn("video.fps","Frame rate",n.fps,t.fps,(s,i)=>Hm(i,s),Wm),fn("video.durationFrames","Duration (frames)",n.durationFrames,t.durationFrames,(s,i)=>Hm(i,s),Wm),fn("video.startTimecode","Start timecode",n.startTimecode,t.startTimecode,(s,i)=>s===i,Ji),fn("video.par","Pixel aspect ratio",n.par,t.par,(s,i)=>Math.abs(s-i)<=.005,Ls),fn("video.bitDepth","Bit depth",n.bitDepth,t.bitDepth,(s,i)=>s===i,Ls),fn("video.chroma","Chroma",n.chroma,t.chroma,(s,i)=>pa(s)===pa(i),Ji),fn("audio.channels","Audio channels",r.channels,t.audioChannels,(s,i)=>s===i,Ls),fn("audio.layout","Audio layout",r.layout,t.audioLayout,(s,i)=>s.toLowerCase()===i.toLowerCase(),Ji),fn("audio.sampleRate","Sample rate",r.sampleRate,t.audioSampleRate,(s,i)=>s===i,Ls),fn("audio.loudnessLufs","Loudness (LUFS)",r.loudnessLufs,t.loudnessLufs,(s,i)=>Hm(i,s),Wm),fn("audio.truePeakDb","True peak (dBTP)",r.truePeakDb,t.truePeakDb,(s,i)=>i<=s+1e-9,{required:s=>`\u2264 ${s}`,measured:s=>s.toFixed(2)}),Os("content.twoPop","2-pop",o.twoPop,t.hasTwoPop,{required:s=>s?"present":"absent",measured:s=>s?"present":"absent"}),Os("content.slate","Slate",o.slate,t.hasSlate,{required:s=>s?"present":"absent",measured:s=>s?"present":"absent"},t.slateNote),Os("content.textlessAtTail","Textless at tail",o.textlessAtTail,t.hasTextlessTail,{required:s=>s?"present":"absent",measured:s=>s?"present":"absent"},t.textlessNote),Os("content.noBlanking","Free of blanking",o.noBlanking,t.hasBlanking==null?void 0:!t.hasBlanking,{required:s=>s?"no blanking":"blanking allowed",measured:s=>s?"none found":"blanking found"},t.blankingNote),Os("content.noBlackFrames","Free of black frames",o.noBlackFrames,t.hasBlackFrames==null?void 0:!t.hasBlackFrames,{required:s=>s?"no black frames":"black frames allowed",measured:s=>s?"none found":"black frames found"},t.blackFramesNote),Os("content.matchesMaster","Matches approved master",o.matchesMaster,t.matchesMaster,{required:s=>s?"must match":"need not match",measured:s=>s?"matches":"differs"})]}async function dT(e){let n=(await Wt({op:"audio",path:e}).catch(()=>null))?.tracks??[];if(n.length===1){let o=(await mt(e).catch(()=>null))?.streams?.filter(s=>s.kind==="audio").reduce((s,i)=>s+(i.channels??0),0)??0;o>n[0].channels&&(n[0].channels=o)}return n.map(r=>({track:r.track,channels:r.channels,rate:r.rate,lufs:r.lufs,peak_db:r.truePeak,findings:r.findings}))}var oo=e=>e==null?"\u2014":`${e.toFixed(1)}`;function eL(e,t){if(!t.length)return[];let n=[],r=new Set;for(let o of e){if(o.lufs==null)continue;let s=t.map((l,c)=>({x:l,i:c,d:l.lufs==null?1/0:o.lufs-l.lufs})).sort((l,c)=>Math.abs(l.d)-Math.abs(c.d)),i=s.find(l=>Math.abs(l.d)<=.5&&l.x.channels===o.channels)??s.find(l=>Math.abs(l.d)<=.5),a=s.find(l=>l.d>=5&&l.d<=7);i&&r.add(i.i),n.push(i?{check:`Track ${o.track} vs mix`,outcome:i.x.channels===o.channels?"pass":"warn",measured:`= ${i.x.file} (${i.x.channels}ch, ${oo(i.x.lufs)} LUFS, \u0394 ${i.d.toFixed(1)} LU)`,note:i.x.channels!==o.channels?"loudness matches but the channel count differs (downmix or wrong bus)":void 0}:{check:`Track ${o.track} vs mix`,outcome:"fail",measured:`${oo(o.lufs)} LUFS`,note:a?`\u2248 +6 LU over ${a.x.file}: summed twice (two buses into one output, or a doubled track)`:`no mix file within 0.5 LU (nearest ${s[0]?.x.file??"\u2014"}: ${oo(s[0]?.x.lufs??null)} LUFS)`})}return t.forEach((o,s)=>{r.has(s)||n.push({check:`Mix ${o.file}`,outcome:"warn",measured:`${o.channels}ch, ${oo(o.lufs)} LUFS`,note:"no output track carries this mix (missing bus?)"})}),n}var ro=e=>({value:e,source:"operator"});async function pT(e){let t=await Bo.open(e.path),n=await cT(t,{loudness:!1}),r=e.fps??n.fps??24,o=b=>b==null?null:typeof b=="number"?b:jt(b,r),s=o(e.mark_in),i=o(e.mark_out),a=await vo(),l=s!=null?He(s,r):e.start_tc??a.conventions?.program_start,c=e.end_on_picture??a.conventions?.end_on_picture,u=e.frames??(s!=null&&i!=null?i-s+1:void 0),p={label:Ho(e.path),video:{...e.codec?{codec:ro(e.codec)}:{},...e.width?{width:ro(e.width)}:{},...e.height?{height:ro(e.height)}:{},...e.fps?{fps:ro({target:e.fps,plusMinus:.001})}:{},...e.bit_depth?{bitDepth:ro(e.bit_depth)}:{},...e.chroma?{chroma:ro(e.chroma)}:{},...l?{startTimecode:ro(l)}:{},...u?{durationFrames:ro({target:u})}:{}}},d=uT(p,n).filter(b=>b.outcome!=="unstated").map(b=>({check:b.label,outcome:b.outcome==="pass"||b.outcome==="fail"?b.outcome:"unchecked",expected:b.required,measured:b.measured,note:b.note}));if(l||d.push({check:"Start timecode",outcome:"unchecked",measured:n.startTimecode,note:"no start TC stated and none in the artist's profile: confirm it (artist_profile action=remember convention program_start)"}),d.push({check:"Picture",outcome:"pass",measured:[n.codec,n.width&&`${n.width}x${n.height}`,n.fps&&`${+n.fps.toFixed(3)} fps`,n.bitDepth&&`${n.bitDepth}-bit`,n.chroma].filter(Boolean).join(", ")}),e.name!==!1)try{let b=wa(a,Ho(e.path),{probe:await mt(e.path)}),w=b.issues.filter(v=>v.level==="error"),_=b.issues.filter(v=>v.level==="warn");d.push({check:"Name",outcome:w.length?"fail":_.length?"warn":"pass",measured:Ho(e.path),note:b.issues.map(v=>`${v.element}: ${v.message}`).join("; ")||void 0})}catch(b){d.push({check:"Name",outcome:"unchecked",note:String(b.message??b)})}try{let b=await Wt({op:"ends",path:e.path,cap:Math.round(5*r),frames:n.durationFrames||void 0}),[w,_,v,R]=[b.first,b.last,b.head,b.tail],S=T=>T>=Math.round(5*r)?"5 s or more":`${T} frame(s)`;d.push({check:"First frame",outcome:w==null?"unchecked":w?"warn":"pass",measured:w==null?void 0:w?`black (${S(v)})`:"picture"}),d.push({check:"Last frame",outcome:_==null?"unchecked":_?c?"fail":"warn":"pass",measured:_==null?void 0:_?`black (last ${S(R)})`:"picture",note:_?c?"the job ends on picture: Mark Out past the end card, or a gap at the tail":"black tail: confirm the delivery spec pads with black":void 0})}catch{d.push({check:"First/last frame",outcome:"unchecked"})}let m=await dT(e.path),h=m.reduce((b,w)=>b+w.channels,0);e.channels!=null&&d.push({check:"Audio channels",outcome:h===e.channels?"pass":"fail",expected:String(e.channels),measured:`${h} (${m.map(b=>`track ${b.track}: ${b.channels}ch`).join(", ")||"no audio"})`});for(let b of m){let w=e.loudness_lufs==null||b.lufs==null?null:Math.abs(b.lufs-e.loudness_lufs)<=(e.loudness_tolerance??1),_=e.true_peak==null||b.peak_db==null?null:b.peak_db<=e.true_peak;d.push({check:`Audio track ${b.track}`,outcome:w===!1||_===!1?"fail":b.lufs==null?"unchecked":"pass",expected:[e.loudness_lufs!=null&&`${e.loudness_lufs} LUFS \xB1${e.loudness_tolerance??1}`,e.true_peak!=null&&`\u2264 ${e.true_peak} dBTP`].filter(Boolean).join(", ")||void 0,measured:`${b.channels}ch${b.rate?` ${b.rate/1e3} kHz`:""}, ${oo(b.lufs)} LUFS, ${oo(b.peak_db)} dBTP`})}for(let b of m)for(let w of b.findings)d.push({check:`Audio track ${b.track} ${w.check}`,outcome:w.severity==="fail"?"fail":"warn",measured:`${w.channel?`ch ${w.channel} `:""}${w.start!=null?`at ${w.start.toFixed(3)} s: `:""}${w.detail}`});let g=m.find(b=>b.channels===2)??m[0],y=a.conventions?.theatrical_tag;if(y&&g?.lufs!=null&&e.name!==!1){let b=new RegExp(`[_\\-. ]${y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}([_\\-. ]|$)`,"i").test(Ho(e.path));b&&g.lufs>-20&&d.push({check:`${y} tag`,outcome:"warn",measured:`${oo(g.lufs)} LUFS on track ${g.track}`,note:`tagged ${y} (theatrical) but measures at a web/nearfield level`}),!b&&g.lufs<-27&&d.push({check:`${y} tag`,outcome:"warn",measured:`${oo(g.lufs)} LUFS on track ${g.track}`,note:`measures at a theatrical level: add _${y} to the audio config? ask`})}m.length||d.push({check:"Audio",outcome:e.channels===0?"pass":e.channels||e.mix?.length?"fail":"warn",measured:"no audio tracks"});let k=[];for(let b of e.mix??[]){let w=await dT(b);w.length||d.push({check:`Mix ${Ho(b)}`,outcome:"unchecked",measured:"no audio read from this file"});for(let{findings:_,...v}of w)k.push({...v,file:Ho(b)})}if(d.push(...eL(m,k)),e.ref)try{let b=await ya({a:e.path,b:e.ref,b_in:e.ref_in??n.startTimecode??l}),w=b.overall;d.push({check:"Picture vs REF",outcome:w.verdict==="exact"?"pass":w.verdict==="unverifiable"?"warn":"fail",measured:w.verdict==="offset"?`offset ${w.offset>0?"+":""}${w.offset} frame(s)`:w.verdict,expected:`exact at ${b.b_tc}`,note:[...b.shots.filter(_=>_.verdict!=="exact").slice(0,5).map(_=>`shot ${_.a_tc}: ${_.verdict}${_.offset?` ${_.offset>0?"+":""}${_.offset}`:""}`),...b.flash].join("; ")||void 0})}catch(b){d.push({check:"Picture vs REF",outcome:"unchecked",note:String(b.message??b)})}return{file:Ho(e.path),verdict:d.some(b=>b.outcome==="fail")?"FAIL":"PASS",rows:d,tracks:m,mix:k}}function mT(e){let t={pass:"PASS",fail:"FAIL",warn:"WARN",unchecked:"----"};return[`${e.verdict}: ${e.file}`,...e.rows.map(n=>` ${t[n.outcome]} ${n.check}: ${n.measured??"could not measure"}${n.expected?` (expected ${n.expected})`:""}${n.note?` \u2014 ${n.note}`:""}`)].join(`
|
|
303
|
-
`)}import{basename as fT}from"node:path";async function tL(e,t){let r=(await mt(e).catch(()=>null))?.vendor_metadata?.bext,o=await Wt({op:"mix",path:e,fps:t}).catch(()=>null);if(!o)return null;let[s,i,a,l,c]=[o.rate,o.channels,o.samples,o.lastSound,o.pop],u=M1(r?.time_reference??0,r?.sample_rate||s,a,t),p=jt(u.tc,t)??0,d=m=>p+Math.floor(m*u.frames/Math.max(a,1));return{file:fT(e),channels:i,start:p,end:p+u.frames,last_sound:l<0?p:d(l)+1,pop:c?d(c.atSeconds*s):null}}function nL(e){let t=e.toUpperCase().split(/[_.]/),n=[];for(let o of t)o==="5-1"?n.push({label:"5.1",channels:6}):o==="7-1"?n.push({label:"7.1",channels:8}):o==="STEREO"||o==="LORO"?n.push({label:o==="LORO"?"LoRo":"stereo",channels:2}):o==="MONO"&&n.push({label:"mono",channels:1});let r=t.map(o=>/^(\d+)CH$/.exec(o)).find(Boolean);return{total:r?Number(r[1]):null,parts:n}}async function hT(e,t){let n=Kl(e,t.timeline_id),r=Bt(n),o=!!n.is_drop_frame,s=v=>He(v,r,o),i=n.tracks.filter(v=>v.kind==="Video"),a=Is(n,i),l=[];if(!a.length)throw new Error("the timeline has no enabled video");let c=a[0].s,u=a[a.length-1].e,p=[];for(let v of t.mix??[]){let R=await tL(v,r);R?p.push(R):l.push({check:`Mix ${fT(v)}`,outcome:"unchecked",measured:"no audio read from this file"})}let d=p[0],m=t.program_start??(await vo()).conventions?.program_start,h=m?jt(m,r):null,g=d?.pop!=null?d.pop+Math.round(2*r):null,y=g??(h!=null&&h>=c-Math.round(10*r)?h:c);d&&l.push(d.pop!=null?{check:"2-pop",outcome:h==null||g===h?"pass":"warn",measured:`${s(d.pop)} in ${d.file} \u2192 program starts ${s(g)}`,note:h!=null&&g!==h?`the stated start is ${s(h)}`:void 0}:{check:"2-pop",outcome:"warn",measured:`none found in the first 15 s of ${d.file}`,note:`program start taken as ${s(y)}`});let k=d?d.last_sound:u;if(d){let v=u-d.last_sound;l.push({check:"Picture end vs mix end",outcome:v===0?"pass":"fail",measured:`picture ends ${s(u-1)} (last frame), sound ends ${s(d.last_sound-1)}`,note:v===0?void 0:v<0?`picture stops ${-v} frame(s) before the mix: ${-v} frame(s) of black under sound. EDIT ERROR: extend the last shot/card, or ask`:`picture runs ${v} frame(s) past the mix: picture with no sound at the end. EDIT ERROR: ask before trimming`});for(let R of p.slice(1))R.last_sound!==d.last_sound&&l.push({check:`Mix ${R.file} end`,outcome:"warn",measured:`sound ends ${s(R.last_sound-1)}`,note:`${d.file} ends ${s(d.last_sound-1)}`});d.start>y&&l.push({check:"Mix start",outcome:"fail",measured:`${d.file} starts ${s(d.start)}`,note:`after the program start ${s(y)}: no sound under the first frames`})}c>y&&l.push({check:"Picture start",outcome:"fail",measured:`first picture ${s(c)}`,note:`${c-y} frame(s) of black after the program start ${s(y)}`});let b=a.find(v=>v.s<=k-1&&v.e>=k);l.push({check:"Last program frame",outcome:b?"pass":"fail",measured:b?`${s(k-1)}: ${b.it.name??"clip"} (${b.track})`:`${s(k-1)}: no picture`,note:b?"confirm it is the end card, not black inside the clip":"the program ends on a gap"});let w=[],_=y;for(let v of a)if(!(v.e<=y)){if(v.s>=k)break;v.s>_&&w.push([_,Math.min(v.s,k)]),_=Math.max(_,v.e)}_<Math.min(k,u)&&w.push([_,Math.min(k,u)]),l.push(w.length?{check:"Gaps in the program",outcome:"warn",measured:w.map(([v,R])=>`${s(v)}\u2013${s(R-1)} (${R-v} fr)`).join(", "),note:"black in the render: check each against the REF (intentional or an edit error)"}:{check:"Gaps in the program",outcome:"pass",measured:"none"});for(let v of i){if(v.enabled===!1)continue;let R=v.items.filter(T=>T.kind==="clip"&&T.enabled!==!1).map(T=>(n.start_frame??0)+T.timeline_range.start.value+T.timeline_range.duration.value),S=Math.max(...R,-1/0);S>Math.min(k,u)-Math.round(r)&&S<Math.min(k,u)&&l.push({check:`Track ${Un(v,n.tracks)}`,outcome:"warn",measured:`ends ${Math.min(k,u)-S} frame(s) before the picture ends`,note:"an effect/adjustment layer should cover the whole program"})}if(t.name){let v=nL(t.name),R=v.parts.reduce((S,T)=>S+T.channels,0);if(v.total!=null&&v.parts.length&&R!==v.total)l.push({check:"Name audio",outcome:"fail",measured:t.name,note:`${v.total}CH but ${v.parts.map(S=>S.label).join(" + ")} = ${R} channels`});else if(v.parts.length&&p.length){let S=[...p],T=v.parts.filter(x=>{let $=S.findIndex(U=>U.channels===x.channels);return $<0?!0:(S.splice($,1),!1)});l.push({check:"Name audio vs mix",outcome:T.length?"fail":"pass",measured:`${v.parts.map(x=>`${x.label} (${x.channels}ch)`).join(" + ")} = ${R}ch`,note:T.length?`no ${T.map(x=>`${x.channels}ch mix for ${x.label}`).join(", ")} among ${p.map(x=>`${x.file} (${x.channels}ch)`).join(", ")}`:"route each to an output track in this order (host_render audio_tracks), then qc_deliverable the render"})}}return{verdict:l.some(v=>v.outcome==="fail"||v.outcome==="unchecked"&&v.check.startsWith("Mix "))?"STOP":"READY",rows:l,mark_in:s(y),mark_out:s(k-1),program:[y,k],mix:p}}function gT(e){let t={pass:"PASS",fail:"FAIL",warn:"WARN",unchecked:"----"};return[`${e.verdict==="READY"?"READY to render":"STOP: fix before rendering"} \u2014 Mark In ${e.mark_in}, Mark Out ${e.mark_out} (inclusive, ${e.program[1]-e.program[0]} frames)`,...e.rows.map(n=>` ${t[n.outcome]} ${n.check}: ${n.measured??"could not measure"}${n.note?` \u2014 ${n.note}`:""}`)].join(`
|
|
304
|
-
`)}import{basename as bT}from"node:path";async function yT(e,t=16){let n=await mt(e),r=n.streams?.find(_=>_.kind==="video"),o=r?.width??0,s=r?.height??0,i=n.available_range?.duration.value??0;if(!o||!s)throw new Error(`${bT(e)}: no raster in the probe`);let a=await Wt({op:"aspect",path:e,samples:t,frames:i||void 0}),l=a.w,c=a.h,u=a.active??{x:0,y:0,w:l,h:c},p=o/l,d=s/c,m={x:Math.round(u.x*p),y:Math.round(u.y*d),w:Math.round(u.w*p),h:Math.round(u.h*d)},h=m.h<s-2,g=m.w<o-2,y=h&&g?"windowbox":h?"letterbox":g?"pillarbox":"none",k=m.w/m.h,b=_=>2*Math.round(_/2),w=y==="pillarbox"?`${b(s*k)}x${s}`:`${o}x${b(o/k)}`;return{file:bT(e),width:o,height:s,frames_sampled:a.sampled,active:m,boxing:y,aspect:+k.toFixed(4),aspect_name:a.name??k.toFixed(2),oar_raster:y==="none"?`${o}x${s}`:w}}function wT(e){return`${e.boxing==="none"?`${e.file}: full ${e.width}x${e.height} raster is picture \u2192 OAR ${e.aspect_name}, no boxing`:`${e.file}: ${e.boxing}: active picture ${e.active.w}x${e.active.h} at (${e.active.x},${e.active.y}) inside ${e.width}x${e.height} \u2192 OAR ${e.aspect_name}; OAR raster ${e.oar_raster}`}
|
|
305
|
-
(${e.frames_sampled} frames sampled across the clip; a bar counts only when \u226580% of them carry it)`}var xT=/lower ?thirds?|\bLTs?\b|titles?|subtitles?|\bsubs\b|captions?|graphics?|\bgfx\b|\btext\b|supers?/i,_n=e=>[e.timeline_range.start.value,e.timeline_range.start.value+e.timeline_range.duration.value],kT=e=>xT.test(e.name??"")||e.items.some(t=>t.kind!=="gap")&&e.items.every(t=>t.kind==="gap"||!!t.title),Xi=e=>e.enabled!==!1&&(e.kind==="clip"||e.kind==="nested"),_T=e=>`V${e.track_index}${e.name?` "${e.name}"`:""}`,rL=/\b(TEXTED|TEXTLESS|MASTER|MEZZ(ANINE)?)(\b|_)/i,vT=300,oL=60;function ST(e,t,n={}){let r=e.timelines.filter(D=>D.kind!=="compound"),o=n.timeline_id?r.find(D=>D.id===n.timeline_id):r.find(D=>D.tracks.some(te=>te.kind==="Video"&&te.items.length));if(!o)throw new L("not_found",n.timeline_id?`no timeline ${n.timeline_id} in this session`:"the session has no timeline with video");if(!t.length)throw new L("invalid_args","changes is empty: give clip ids or record ranges");let s=Bt(o),i=o.start_frame??0,a=!!o.is_drop_frame,l=D=>He(D+i,s,a),c=[],u=o.tracks.filter(D=>D.kind==="Video"&&D.enabled!==!1).sort((D,te)=>te.track_index-D.track_index),p=new Set,d=(D,te)=>u.some(we=>we.track_index<D.track_index&&we.items.some(ge=>Xi(ge)&&_n(ge)[0]<_n(te)[1]&&_n(ge)[1]>_n(te)[0]));for(let D of u)for(let te of D.items)!Xi(te)||te.title||(rL.test(te.name??"")||te.timeline_range.duration.value>=vT*s&&d(D,te))&&p.add(te);p.size&&c.push(`baked picture (a laid-back master, or a clip of ${vT/60} min or more) left out of the cut points, the edits under it decide: ${[...p].map(D=>`"${D.name??D.id}" ${l(_n(D)[0])}\u2013${l(_n(D)[1]-1)}`).join(", ")}`);let m=D=>Xi(D)&&!p.has(D),h=u.filter(kT),g=u.filter(D=>!kT(D));for(let D of o.tracks)D.kind==="Video"&&D.enabled===!1&&xT.test(D.name??"")&&D.items.some(Xi)&&c.push(`${_T(D)} is a graphics track but disabled: left out of TEXTED too; enable it if the master carries it`);let y=Math.max(0,...u.flatMap(D=>D.items.filter(Xi).map(te=>_n(te)[1]))),k=new Set([0,y]);for(let D of g)for(let te of D.items)m(te)&&_n(te).forEach(we=>k.add(we));let b=[...k].filter(D=>D>=0&&D<=y).sort((D,te)=>D-te),w=[];for(let D=0;D+1<b.length;D++){let[te,we]=[b[D],b[D+1]],ge={start:te,end:we,item:null,track:null};for(let oe of g){let P=oe.items.find(M=>m(M)&&_n(M)[0]<=te&&_n(M)[1]>=we);if(P){ge={start:te,end:we,item:P,track:oe};break}}let ve=w[w.length-1];ve&&ve.item===ge.item?ve.end=we:w.push(ge)}let _=[...h.flatMap(D=>D.items.filter(m).map(_n)),...u.flatMap(D=>D.items.filter(te=>te.kind==="transition").map(_n))],v=new Set([0,y,...w.map(D=>D.start)].filter(D=>!_.some(([te,we])=>te<D&&D<we))),R=D=>Math.max(...[...v].filter(te=>te<=D)),S=D=>Math.min(...[...v].filter(te=>te>=D)),T=D=>w.find(te=>te.start<=D&&D<te.end),x=new Map(o.tracks.flatMap(D=>D.items.map(te=>[te.id,te]))),$=D=>{if(typeof D=="number")return D-i;let te=jt(D,s);if(te==null){if(/^\d+$/.test(D))return Number(D)-i;throw new L("invalid_args",`cannot read '${D}' as a record timecode`)}return te-i},U=t.map(D=>{if(typeof D=="string"){let ge=x.get(D);if(!ge)throw new L("not_found",`no clip ${D} on ${o.name} (item ids come from timeline_query)`);return[..._n(ge)]}let[te,we]=[$(D.in),$(D.out)+1];if(we<=te)throw new L("invalid_args",`range ${D.in}..${D.out} is empty or backwards`);return[te,we]}).sort((D,te)=>D[0]-te[0]);for(let[D,te]of U)if(D<0||te>y)throw new L("invalid_args",`change ${l(D)}\u2013${l(te-1)} is outside the timeline (${l(0)}\u2013${l(y-1)})`);let E=[];for(let[D,te]of U){let we=D>0?T(D-1):void 0,ge=te<y?T(te):void 0,ve=R(we?.item?we.start:D),oe=S(ge?.item?ge.end:te),P=E[E.length-1];P&&ve<=P.tail?(P.tail=Math.max(P.tail,oe),P.changes.push([D,te])):E.push({head:ve,tail:oe,changes:[[D,te]]})}let z=D=>D.item?D.item.name??D.item.reel_name??D.item.id:"(black)",G=E.map((D,te)=>{let we=w.filter(V=>V.end>D.head&&V.start<D.tail),ge=V=>D.changes.some(([fe,xe])=>V.end>fe&&V.start<xe),ve=we.findIndex(ge),oe=we.length-1-[...we].reverse().findIndex(ge),P=we.map((V,fe)=>({role:ge(V)?"changed":fe===ve-1?"before":fe===oe+1?"after":"inside",name:z(V),track:V.track?_T(V.track):"-",rec_in_tc:l(V.start),frames:V.end-V.start})),M=h.filter(V=>V.items.some(fe=>m(fe)&&_n(fe)[1]>D.head&&_n(fe)[0]<D.tail)),O=[];for(let V of P)(V.role==="before"||V.role==="after")&&V.frames>oL*s&&O.push(`the ${V.role} clip "${V.name}" runs ${Math.round(V.frames/s)} s: check it is a real shot, not baked picture`);return P.some(V=>V.role==="before")||O.push("no clip before the change (timeline head or black): starts on the change"),P.some(V=>V.role==="after")||O.push("no clip after the change (timeline tail or black): ends on the change"),M.length||O.push("no graphics in range: one render serves TEXTED and TEXTLESS"),{nn:(n.first_patch??1)+te,range:{in:D.head+i,out:D.tail-1+i},frames:D.tail-D.head,rec_in_tc:l(D.head),rec_out_tc:l(D.tail-1),start_tc:l(D.head),versions:M.length?["TEXTED","TEXTLESS"]:["TEXTED"],textless_exclude_tracks:M.map(V=>({index:V.track_index,name:V.name??null})),audio:!1,neighbours:P,notes:O}});return{timeline:o.name,fps:s,start_tc:l(0),patches:G,warnings:c}}function $T(e){let t=`${e.patches.length} patch${e.patches.length===1?"":"es"} on ${e.timeline}: `+e.patches.map(r=>`PATCH${String(r.nn).padStart(2,"0")} ${r.rec_in_tc}\u2013${r.rec_out_tc} (${r.frames} fr, ${r.versions.join("+")})`).join("; "),n=e.patches.flatMap(r=>[`PATCH${String(r.nn).padStart(2,"0")}: record ${r.rec_in_tc}\u2013${r.rec_out_tc} inclusive, ${r.frames} frames; host_render range {in:${r.range.in}, out:${r.range.out}}; file TC ${r.start_tc}; picture only`,...r.neighbours.map(o=>` ${o.role.padEnd(7)} ${o.rec_in_tc} ${String(o.frames).padStart(5)} fr ${o.track} ${o.name}`),r.textless_exclude_tracks.length?` TEXTLESS: leave out ${r.textless_exclude_tracks.map(o=>`V${o.index}${o.name?` "${o.name}"`:""}`).join(", ")}`:"",...r.notes.map(o=>` note: ${o}`)].filter(Boolean));return[t,...n,...e.warnings.map(r=>`warning: ${r}`)].join(`
|
|
306
|
-
`)}function TT(e){let t=e.streams?.find(r=>r.kind==="video"),n=t?.codec_specific??{};return{codec:t?.codec,fourcc:n.fourcc,profile:n.profile,pixel_format:n.pixel_format,bit_depth:t?.bit_depth,raster:t?.width?`${t.width}x${t.height}`:void 0,fps:Math.round((e.source_fps??t?.rate??0)*1e3)/1e3,colour:n.colr?`${n.colr.primaries}/${n.colr.transfer}/${n.colr.matrix}`:void 0}}async function zm(e,t,n){return(await Wt({op:"hashes",path:e,from:t,count:n})).hashes.map(o=>o??void 0)}async function sL(e){let t=Math.max(2,Math.round(e.fps*2)),n=[];for(let[r,o]of[["head",e.offset],["tail",e.offset+e.frames]]){let s=Math.max(0,o-t),i=Math.min(e.mframes,o+t),a=i-s;if(a<=0)continue;let l=await zm(e.master,s,a),c=Math.max(s,e.offset),u=Math.min(i,e.offset+e.frames),p=u>c?await zm(e.patch,c-e.offset,u-c):[],d=e.original?await zm(e.original,s,a):null,m=0,h=0,g=0,y=0;l.forEach((b,w)=>{let _=s+w;_>=c&&_<u?(h++,(!b||b!==p[_-c])&&m++):d&&(y++,(!b||b!==d[w])&&g++)});let k=l.filter(b=>!b).length;n.push({seam:r,tc:He(e.master_tc+o,e.fps),frames:[s,i-1],inside:h?m?`${m}/${h} frames differ from the patch`:`${h} frames = the patch`:"\u2014",outside:d?g?`${g}/${y} frames differ from the original`:`${y} frames = the original`:"no original given (pass original= a backup to prove the neighbours)",undecoded:k,ok:!m&&!g&&!k})}return n}async function RT(e,t){let[n,r]=await Promise.all([mt(e.patch),mt(e.master)]),o=TT(n),s=TT(r),i=Object.keys(o).map(_=>({field:_,patch:o[_],master:s[_],ok:o[_]===s[_]})),a=n.available_range?.duration.value??n.declared_duration?.value??0,l=r.available_range?.duration.value??r.declared_duration?.value??0,c=o.fps||s.fps,u=[];e.expected_frames!=null&&u.push({what:"frames",ok:a===e.expected_frames,detail:`${a} frames, expected ${e.expected_frames}`});let p=n.source_timecode??null,d=r.source_timecode??null;e.expected_tc&&u.push({what:"start TC",ok:p!=null&&jt(p,c)===jt(e.expected_tc,c),detail:`starts ${p??"with no TC"}, expected ${e.expected_tc}`});let m=n.streams?.filter(_=>_.kind==="audio").length??0;u.push({what:"picture only",ok:m===0,detail:m?`${m} audio track(s)`:"no audio"});let h=null,g=[],y=[],k=p?jt(p,c):null,b=d?jt(d,c):null;if(k==null||b==null)u.push({what:"position in master",ok:!1,detail:"no start TC on the patch or the master: cannot place it"});else if(k-b<0||k-b+a>l)u.push({what:"position in master",ok:!1,detail:`${p} + ${a} fr is outside the master (${d}, ${l} fr)`});else{h=k-b,u.push({what:"position in master",ok:!0,detail:`master frames ${h}\u2013${h+a-1}`});let _=await Wt({op:"patch",patch:e.patch,master:e.master,offset:h,frames:a,tolerance:e.tolerance??10},t);for(let R of _.mismatches)g.push({...R,tc:He((k??0)+R.frame,c)});for(let R of _.shotChanges)y.push(He((k??0)+R,c));let v=_.undecoded;v&&u.push({what:"decode",ok:!1,detail:`${v} patch frame(s) did not decode`}),u.push({what:"picture vs master",ok:!g.length,detail:g.length?`${g.length}/${a} frames differ (first ${g[0].tc})`:`all ${a} frames match at the same TC`})}let w;if(h!=null)try{w=await sL({master:e.master,patch:e.patch,original:e.original,offset:h,frames:a,mframes:l,fps:c,master_tc:b??0});let _=w.filter(R=>!R.ok);w.length&&w.every(R=>/^(\d+)\/\1 frames differ from the patch$/.test(R.inside)&&!R.undecoded)?(u.push({what:"seam decode",ok:!0,detail:"not spliced yet: the master still has its own frames in the span; run patch_verify again after media_patch"}),w=void 0):u.push({what:"seam decode",ok:!_.length,detail:_.length?_.map(R=>`${R.seam} ${R.tc}: ${[R.inside,R.outside,R.undecoded?`${R.undecoded} undecoded`:""].filter(Boolean).join("; ")}`).join(" | "):`${w.length} seam(s): every frame decodes and matches${e.original?"":" the patch (neighbours unchecked: no original)"}`})}catch(_){if(!/not installed|missing/.test(String(_)))throw _}return{ok:i.every(_=>_.ok)&&u.every(_=>_.ok),spec:i,frames:a,start_tc:p,master_offset:h,checks:u,mismatches:g,shot_changes:y,seams:w}}function CT(e,t){let n=[...e.spec.filter(r=>!r.ok).map(r=>r.field),...e.checks.filter(r=>!r.ok).map(r=>r.what)];return[`${e.ok?"PASS":"FAIL"}: ${ie(t.patch)} vs ${ie(t.master)}${n.length?` (${n.join(", ")})`:""}`,...e.spec.map(r=>` ${r.ok?"ok ":"DIFF"} ${r.field}: ${r.patch??"-"}${r.ok?"":` (master ${r.master??"-"})`}`),...e.checks.map(r=>` ${r.ok?"ok ":"FAIL"} ${r.what}: ${r.detail}`),...e.mismatches.slice(0,40).map(r=>` frame ${r.frame} @ ${r.tc}: mean diff ${r.mean}, max ${r.max}`),e.mismatches.length>40?` \u2026 ${e.mismatches.length-40} more`:"",e.shot_changes.length?` shot changes in the patch at ${e.shot_changes.join(", ")}`:"",...(e.seams??[]).map(r=>` seam ${r.seam} ${r.tc} (master frames ${r.frames[0]}\u2013${r.frames[1]}): ${r.ok?"ok":"FAIL"} \u2014 inside: ${r.inside}; outside: ${r.outside}${r.undecoded?`; ${r.undecoded} undecoded`:""}`)].filter(Boolean).join(`
|
|
307
|
-
`)}import{createHash as iL}from"node:crypto";var Qi=e=>mo(new URL(e,import.meta.url)),Wo=e=>/^__version__\s*=\s*["']([^"']+)["']/m.exec(e)?.[1]??"";async function Gm(e,t=""){let n={};for await(let r of Rt(e))r.name==="__pycache__"||/\.py[co]$/.test(r.name)||(r.isDirectory?Object.assign(n,await Gm(B(e,r.name),`${t}${r.name}/`)):r.isFile&&(n[`${t}${r.name}`]=B(e,r.name)));return n}async function ET(){let e=Qi("./peer-kit/ctpeer/"),t=[];for await(let s of Rt(e))s.isFile&&s.name.endsWith(".py")&&t.push(s.name);t.sort();let n={},r=iL("sha256");for(let s of t)n[s]=await tn(B(e,s)),r.update(s),r.update(n[s]);let o={ctpeer_version:Wo(new TextDecoder().decode(n["__init__.py"])),ctpeer_sha256:r.digest("hex")};return n["VENDORED.json"]=new TextEncoder().encode(JSON.stringify(o,null,2)),n}var ac="conformtools_flame_hook.py",lc="conformtools_flame.zip";function AT(e=ln()){return e==="darwin"?B(Nr(),"Library","Preferences","Autodesk","flame","python"):B(Nr(),"flame","python")}async function aL(e=AT()){let t=Qi("./flame/hook/"),n={};for(let[r,o]of Object.entries(await Gm(B(t,"conformtools_flame"))))n[`conformtools_flame/${r}`]=await tn(o);for(let[r,o]of Object.entries(await ET()))n[`ctpeer/${r}`]=o;return await Ke(e),await Zo(B(t,ac),B(e,ac)),await cn(B(e,lc),t1(n)),{version:Wo(await et(B(t,"conformtools_flame","__init__.py"))),dest:e,files:[B(e,ac),B(e,lc)]}}async function lL(e=AT()){if(!await nt(B(e,ac))||!await nt(B(e,lc)))return{installed:!1,dest:e};let t=ca(await tn(B(e,lc)),{filter:n=>n.name==="conformtools_flame/__init__.py"})["conformtools_flame/__init__.py"];return{installed:!0,dest:e,...t?{version:Wo(new TextDecoder().decode(t))}:{}}}async function cL(){return Wo(await et(Qi("./flame/hook/conformtools_flame/__init__.py")))}var IT=()=>B(Nr(),".nuke");async function uL(e=IT()){let t=Qi("./nuke/panel/python/"),n=B(e,"Python");await Ke(B(n,"Startup")),await Zo(B(t,"Startup","conformtools_nuke_startup.py"),B(n,"Startup","conformtools_nuke_startup.py"));for(let r of["conformtools_nuke","ctpeer"])await Ht(B(n,r));for(let[r,o]of Object.entries(await Gm(B(t,"conformtools_nuke"))))await Ke(B(n,"conformtools_nuke",...r.split("/").slice(0,-1))),await Zo(o,B(n,"conformtools_nuke",r));await Ke(B(n,"ctpeer"));for(let[r,o]of Object.entries(await ET()))await cn(B(n,"ctpeer",r),o);return{version:Wo(await et(B(t,"conformtools_nuke","__init__.py"))),dest:e,files:[B(n,"Startup","conformtools_nuke_startup.py"),B(n,"conformtools_nuke"),B(n,"ctpeer")]}}async function dL(e=IT()){let t=B(e,"Python");if(!await nt(B(t,"Startup","conformtools_nuke_startup.py")))return{installed:!1,dest:e};let n=B(t,"conformtools_nuke","__init__.py");return{installed:!0,dest:e,...await nt(n)?{version:Wo(await et(n))}:{}}}async function pL(){return Wo(await et(Qi("./nuke/panel/python/conformtools_nuke/__init__.py")))}var Km={flame:{install:()=>aL(),installed:()=>lL(),version:cL,what:"hook",next:"In Flame: Flame menu > Python > Rescan Python Hooks (or restart Flame), then Flame menu > CONFORM.TOOLS > Connect to CONFORM.TOOLS."},nuke:{install:()=>uL(),installed:()=>dL(),version:pL,what:"panel",next:"Restart Nuke Studio / Hiero, then CONFORM.TOOLS > Connect (Window > CONFORM.TOOLS shows its panel)."}};function Vm(e,t,n){let r=t*n,o=new Float32Array(r*3);for(let s=0;s<r;s++)o[s*3]=e[s*4]/255,o[s*3+1]=e[s*4+1]/255,o[s*3+2]=e[s*4+2]/255;return{data:o,w:t,h:n}}function Pr(e){return e<0?0:e>1?1:e}var Jm="srgb";function MT(e){Jm=e}function Fr(e){return Jm==="g24"?Math.pow(Math.max(e,0),2.4):e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Xm(e){return Jm==="g24"?Math.pow(Math.max(e,0),1/2.4):e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055}function cc(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));if(n>=1)return e;let r=Math.max(1,Math.round(e.w*n)),o=Math.max(1,Math.round(e.h*n)),s=new Float32Array(r*o*3),i=e.w/r,a=e.h/o;for(let l=0;l<o;l++){let c=Math.floor(l*a),u=Math.min(e.h,Math.max(c+1,Math.floor((l+1)*a)));for(let p=0;p<r;p++){let d=Math.floor(p*i),m=Math.min(e.w,Math.max(d+1,Math.floor((p+1)*i))),h=0,g=0,y=0,k=0;for(let w=c;w<u;w++)for(let _=d;_<m;_++){let v=(w*e.w+_)*3;h+=e.data[v],g+=e.data[v+1],y+=e.data[v+2],k++}let b=(l*r+p)*3;s[b]=h/k,s[b+1]=g/k,s[b+2]=y/k}}return{data:s,w:r,h:o}}function hn(e,t){let n=new Float64Array(9);for(let r=0;r<3;r++)for(let o=0;o<3;o++){let s=0;for(let i=0;i<3;i++)s+=e[r*3+i]*t[i*3+o];n[r*3+o]=s}return n}function Zm(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let r=0;r<3;r++)t[n*3+r]=e[r*3+n];return t}function uc(e){let t=new Float64Array(9);return t[0]=e[0],t[4]=e[1],t[8]=e[2],t}function ef(e){let t=Float64Array.from(e),n=new Float64Array([1,0,0,0,1,0,0,0,1]);for(let i=0;i<24;i++){let a=0;for(let[l,c]of[[0,1],[0,2],[1,2]])a+=t[l*3+c]**2;if(a<1e-30)break;for(let[l,c]of[[0,1],[0,2],[1,2]]){let u=t[l*3+c];if(Math.abs(u)<1e-300)continue;let p=(t[c*3+c]-t[l*3+l])/(2*u),d=Math.sign(p||1)/(Math.abs(p)+Math.sqrt(p*p+1)),m=1/Math.sqrt(d*d+1),h=d*m;for(let g=0;g<3;g++){let y=t[g*3+l],k=t[g*3+c];t[g*3+l]=m*y-h*k,t[g*3+c]=h*y+m*k}for(let g=0;g<3;g++){let y=t[l*3+g],k=t[c*3+g];t[l*3+g]=m*y-h*k,t[c*3+g]=h*y+m*k}for(let g=0;g<3;g++){let y=n[g*3+l],k=n[g*3+c];n[g*3+l]=m*y-h*k,n[g*3+c]=h*y+m*k}}}let r=[0,1,2].sort((i,a)=>t[i*3+i]-t[a*3+a]),o=new Float64Array(3),s=new Float64Array(9);return r.forEach((i,a)=>{o[a]=t[i*3+i];for(let l=0;l<3;l++)s[l*3+a]=n[l*3+i]}),{values:o,vectors:s}}function PT(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let r=0;r<=n;r++){let o=e[n*3+r];for(let s=0;s<r;s++)o-=t[n*3+s]*t[r*3+s];if(n===r){if(o<=0)return null;t[n*3+r]=Math.sqrt(o)}else t[n*3+r]=o/t[r*3+r]}return t}function mL(e){let t=new Float64Array(9);for(let n=0;n<3;n++){t[n*3+n]=1/e[n*3+n];for(let r=0;r<n;r++){let o=0;for(let s=r;s<n;s++)o+=e[n*3+s]*t[s*3+r];t[n*3+r]=-o/e[n*3+n]}}return t}function Qm(e){let{values:t,vectors:n}=ef(e),r=1e-12*Math.max(...Array.from(t).map(Math.abs),1e-30),o=new Float64Array(3);for(let s=0;s<3;s++)o[s]=Math.abs(t[s])>r?1/t[s]:0;return hn(hn(n,uc(o)),Zm(n))}function fL(e){let{values:t,vectors:n}=ef(e),r=new Float64Array(3);for(let o=0;o<3;o++)r[o]=Math.sqrt(Math.max(t[o],0));return hn(hn(n,uc(r)),Zm(n))}function FT(e){let t=e.w*e.h,n=new Float64Array(3);for(let s=0;s<t;s++)for(let i=0;i<3;i++)n[i]+=e.data[s*3+i];for(let s=0;s<3;s++)n[s]/=t;let r=new Float64Array(9);for(let s=0;s<t;s++){let i=e.data[s*3]-n[0],a=e.data[s*3+1]-n[1],l=e.data[s*3+2]-n[2];r[0]+=i*i,r[1]+=i*a,r[2]+=i*l,r[4]+=a*a,r[5]+=a*l,r[8]+=l*l}let o=Math.max(1,t-1);for(let s of[0,1,2,4,5,8])r[s]/=o;return r[3]=r[1],r[6]=r[2],r[7]=r[5],{mean:n,cov:r}}function hL(e,t,n,r){let o=e.w*e.h,s=new Float32Array(o*3);for(let i=0;i<o;i++){let a=e.data[i*3]-n[0],l=e.data[i*3+1]-n[1],c=e.data[i*3+2]-n[2];s[i*3]=t[0]*a+t[1]*l+t[2]*c+r[0],s[i*3+1]=t[3]*a+t[4]*l+t[5]*c+r[1],s[i*3+2]=t[6]*a+t[7]*l+t[8]*c+r[2]}return{data:s,w:e.w,h:e.h}}function gL(e,t){let{values:n,vectors:r}=ef(e),o=new Float64Array(3),s=new Float64Array(3);for(let p=0;p<3;p++){let d=Math.max(n[p],0);o[p]=Math.sqrt(d),s[p]=o[p]>1e-12?1/o[p]:0}let i=uc(o),a=uc(s),l=Zm(r),c=hn(hn(hn(hn(i,l),t),r),i),u=fL(c);return hn(hn(hn(hn(r,a),u),a),l)}function bL(e,t){let r=Float64Array.from(e),o=Float64Array.from(t);for(let a of[0,4,8])r[a]+=1e-5,o[a]+=1e-5;let s=PT(r),i=PT(o);if(!s||!i){let a=new Float64Array(9);for(let l=0;l<3;l++){let c=Math.sqrt(Math.max(e[l*3+l],0)),u=Math.sqrt(Math.max(t[l*3+l],0));a[l*3+l]=c>1e-12?u/c:1}return a}return hn(i,mL(s))}function yL(e,t,n,r){let o=Qm(n.cov),s=Qm(r.cov),i=e.w*e.h,a=new Float64Array(9);for(let c=0;c<i;c++){let u=t.data[c*3]-r.mean[0],p=t.data[c*3+1]-r.mean[1],d=t.data[c*3+2]-r.mean[2],m=e.data[c*3]-n.mean[0],h=e.data[c*3+1]-n.mean[1],g=e.data[c*3+2]-n.mean[2];a[0]+=u*m,a[1]+=u*h,a[2]+=u*g,a[3]+=p*m,a[4]+=p*h,a[5]+=p*g,a[6]+=d*m,a[7]+=d*h,a[8]+=d*g}let l=Math.max(1,i-1);for(let c=0;c<9;c++)a[c]/=l;return hn(hn(Qm(s),s),hn(a,o))}var or=4096;function Ym(e,t){let n=e.w*e.h,r=t.w*t.h,o=i=>Math.min(or-1,Math.max(0,Math.round(Pr(i)*(or-1)))),s=[];for(let i=0;i<3;i++){let a=new Float64Array(or),l=new Float64Array(or);for(let h=0;h<n;h++)a[o(e.data[h*3+i])]++;for(let h=0;h<r;h++)l[o(t.data[h*3+i])]++;let c=0;for(let h=0;h<or;h++)c+=a[h],a[h]=c/n;let u=[],p=[];c=0;for(let h=0;h<or;h++)l[h]!==0&&(c+=l[h],u.push(h/(or-1)),p.push(c/r));let d=new Float32Array(or),m=0;for(let h=0;h<or;h++){let g=a[h];for(;m<p.length-1&&p[m]<g;)m++;if(m===0||p[m]<=g)d[h]=u[m]??0;else{let y=p[m-1],k=p[m],b=k>y?(g-y)/(k-y):0;d[h]=u[m-1]+(u[m]-u[m-1])*b}}s.push(d)}return s}var Ns=1/Math.sqrt(3),Ds=1/Math.sqrt(6),dc=1/Math.sqrt(2),D7=[Ns,Ns,Ns,Ds,Ds,-2*Ds,dc,-dc,0],j7=[Ns,Ds,dc,Ns,Ds,-dc,Ns,-2*Ds,0];function pc(e,t,n="mvgd"){let r=e.w*e.h,o=y=>Math.min(or-1,Math.max(0,Math.round(Pr(y)*(or-1)))),s=(y,k)=>{let b=new Float32Array(r*3);for(let w=0;w<3;w++){let _=k[w];for(let v=0;v<r;v++)b[v*3+w]=_[o(y.data[v*3+w])]}return{data:b,w:y.w,h:y.h}},i=Ym(e,t),a=s(e,i),l=FT(a),c=FT(t),u;if(n==="mkl")u=gL(l.cov,c.cov);else if(n==="coral")u=bL(l.cov,c.cov);else if(n==="adain"){let y=new Float64Array(9);for(let k=0;k<3;k++){let b=Math.sqrt(Math.max(l.cov[k*3+k],0)),w=Math.sqrt(Math.max(c.cov[k*3+k],0));y[k*3+k]=b>1e-12?w/b:1}u=y}else u=yL(a,t,l,c);let p=hL(a,u,l.mean,c.mean),d={data:Float32Array.from(p.data,Pr),w:e.w,h:e.h},m=Ym(d,t),h=s(d,m),g=[c.mean[0]-(u[0]*l.mean[0]+u[1]*l.mean[1]+u[2]*l.mean[2]),c.mean[1]-(u[3]*l.mean[0]+u[4]*l.mean[1]+u[5]*l.mean[2]),c.mean[2]-(u[6]*l.mean[0]+u[7]*l.mean[1]+u[8]*l.mean[2])];return{hm1:i,matrix:Array.from(u),offset:g,mid:d,hm2:m,image:h}}function LT(e,t,n=1){let r=e.w*e.h,o=new Float32Array(r*3),s=[Math.pow(t[0],n),Math.pow(t[1],n),Math.pow(t[2],n)];for(let i=0;i<r;i++)for(let a=0;a<3;a++){let l=Fr(Math.min(1,Math.max(0,e.data[i*3+a])))*s[a];o[i*3+a]=Xm(l<0?0:l>1?1:l)}return{data:o,w:e.w,h:e.h}}function OT(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[1/Math.sqrt(3),1/Math.sqrt(3),1/Math.sqrt(3)]}function NT(e,t){let n=OT(e),r=OT(t),o=n[0]*r[0]+n[1]*r[1]+n[2]*r[2],s=[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]],i=Math.hypot(s[0],s[1],s[2]);return Math.atan2(i,o)*180/Math.PI}var mc={note:"Measured from DaVinci Resolve Studio 21 EXR renders of a 16-bit ramp chart (drt-color-re/render_grade.py batch 5, 2026-08-11). Absolute per-amplitude deltas vs the neutral render; regenerate with gen_wheel_basis.py.",x:[0,.033351,.066701,.100052,.133403,.166754,.200104,.233455,.266806,.300156,.333507,.366858,.400208,.433559,.46691,.500261,.533611,.566962,.600313,.633663,.667014,.700365,.733715,.767066,.800417,.833768,.867118,.900469,.93382,.96717,1],controls:{shadow:{amps:[-.4,-.2,-.1,.05,.1,.2,.3,.4],curves:{"-0.40":[-.4,-.361005,-.320961,-.28089,-.240827,-.200775,-.160651,-.119559,-.084823,-.054151,-.028079,-.007759,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.20":[-.2,-.180746,-.160725,-.140689,-.120659,-.100632,-.08057,-.060049,-.042665,-.027551,-.014705,-.004394,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.10":[-.1,-.090617,-.080607,-.070588,-.060574,-.05056,-.040529,-.030279,-.021573,-.014076,-.007709,-.002511,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.05":[.01665,.014519,.01285,.011184,.009514,.007848,.006178,.004433,.003088,.001785,631e-6,-218e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.10":[.0333,.029526,.02619,.022856,.019518,.016185,.012843,.009357,.006657,.004041,.00172,24e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.20":[.0666,.059539,.052869,.046199,.039526,.032859,.026174,.019208,.013791,.008561,.003926,527e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.30":[.0999,.089552,.079548,.069542,.059534,.049533,.039505,.029067,.020915,.013093,.006169,.001059,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.40":[.1332,.119565,.106227,.092886,.079542,.066207,.052837,.038936,.028026,.017634,.008453,.001622,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6]}},midtone:{amps:[-.4,-.2,-.1,.1,.2,.4],curves:{"-0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-451e-6,263e-6,-.003632,-.010819,-.020501,-.032238,-.047185,-.059943,-.066296,-.060685,-.040876,-.017385,-303e-6,-447e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-466e-6,-57e-6,-.002523,-.007541,-.014006,-.020949,-.027712,-.032192,-.033342,-.029182,-.019455,-.008585,-391e-6,-467e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-476e-6,-266e-6,-.001602,-.004451,-.00808,-.011811,-.014895,-.016618,-.016765,-.014464,-.00969,-.004462,-438e-6,-478e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-509e-6,-938e-6,.001249,.004662,.008518,.012261,.014922,.015752,.01505,.012601,.007936,.002742,-514e-6,-496e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-53e-5,-.001381,.00303,.010093,.018105,.0258,.030902,.031857,.029403,.023831,.014993,.005523,-542e-6,-502e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-571e-6,-.002236,.006718,.021856,.039117,.055211,.063967,.062345,.052975,.039586,.02427,.009349,-592e-6,-514e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6]}},highlight:{amps:[-.4,-.2,-.1,.1,.2,.4],curves:{"-0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-49e-6,-.001378,-.005676,-.012124,-.02034,-.033741,-.0471,-.060436,-.073779,-.087121,-.100459,-.1138,-.127144,-.14048,-.153821,-.167165,-.180293],"-0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-285e-6,-921e-6,-.003101,-.006371,-.010411,-.017115,-.023794,-.030461,-.037134,-.043804,-.050474,-.057144,-.063817,-.070484,-.077154,-.083827,-.090391],"-0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-392e-6,-703e-6,-.001797,-.003442,-.005449,-.008802,-.012141,-.015474,-.018812,-.022146,-.025482,-.028816,-.032154,-.035487,-.038821,-.042159,-.04544],"+0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-913e-6,207e-6,.002501,.005682,.010558,.017987,.025407,.032818,.040228,.047642,.055048,.062463,.069872,.077283,.084698,.092108,.099403],"+0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-.001308,875e-6,.005478,.011902,.021601,.036463,.051302,.066123,.080944,.095772,.110587,.125414,.140236,.155056,.169883,.184705,.199294],"+0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-.002028,.002127,.011361,.024415,.043682,.073414,.103093,.132732,.162378,.192031,.221663,.251316,.280962,.310601,.340254,.3699,.399077]}}},contrast:{cs:[.5,.8,1.25,1.5,1.8],curves:{"0.50":[.2175,.200578,.183907,.167229,.15055,.13388,.117203,.100531,.083854,.067175,.050505,.033828,.017148,479e-6,-.016201,-.032878,-.049548,-.066227,-.082897,-.099576,-.116253,-.132923,-.149602,-.16628,-.182951,-.199629,-.216308,-.232978,-.249655,-.266334,-.282745],"0.80":[.087,.079939,.073269,.066599,.059926,.053259,.046589,.039919,.033249,.026576,.019909,.013239,.006566,-101e-6,-.006775,-.013445,-.020112,-.026785,-.033452,-.040125,-.046795,-.053462,-.060135,-.066805,-.073475,-.080145,-.086818,-.093485,-.100155,-.106828,-.113392],"1.25":[0,-.010727,-.021735,-.032532,-.042279,-.050126,-.055135,-.056541,-.054061,-.047509,-.037623,-.025716,-.013116,-.001136,.010563,.023076,.035617,.047411,.057676,.06563,.070555,.072344,.071151,.067141,.060599,.052178,.042386,.031729,.020695,.009783,-345e-6],"1.50":[0,-.021136,-.043244,-.065419,-.086537,-.105469,-.121116,-.131949,-.135345,-.128698,-.109132,-.077071,-.039172,-.002436,.033276,.07165,.108539,.139821,.161382,.172335,.174591,.16969,.159165,.144656,.12727,.107658,.086487,.064431,.042132,.020262,-196e-6],"1.80":[0,-.030247,-.061752,-.093815,-.125632,-.1564,-.185357,-.21169,-.23463,-.254734,-.26386,-.247374,-.163569,-.008383,.14496,.280152,.328288,.341546,.334832,.316817,.295588,.272004,.245823,.217525,.18759,.15646,.124616,.09254,.060672,.029492,-59e-6]}},pivot_probes:{pivot02_c15:[0,.011586,.023617,.041223,.072432,.128713,.199237,.267856,.339119,.410913,.481153,.547825,.60882,.662121,.707868,.747147,.780708,.809347,.833813,.8549,.873465,.889957,.904721,.918081,.93036,.941903,.953031,.964073,.975367,.987238,.999804],pivot08_c15:[0,.012599,.024474,.035774,.04682,.057941,.069476,.081743,.095087,.109829,.126295,.144829,.165876,.190289,.218866,.252371,.29155,.337202,.39039,.451293,.517901,.588105,.659892,.731177,.799843,.87034,.927,.958466,.976191,.988267,.999805],pivot02_c07:[.06,.083008,.106345,.129696,.153044,.176383,.199734,.223071,.246421,.269769,.293109,.316459,.339807,.363147,.386494,.409845,.433184,.456532,.479872,.50322,.52657,.54991,.573258,.596608,.619945,.643295,.666643,.689983,.713333,.736681,.759657],pivot08_c07:[.24,.263008,.286345,.309696,.333044,.356383,.379734,.403071,.426421,.449769,.473109,.496459,.519807,.543146,.566494,.589845,.613184,.636532,.659872,.68322,.70657,.72991,.753258,.776608,.799945,.823295,.846643,.869983,.893333,.916681,.939657]}};var sr=.435;var UT={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:1,pivot:sr};function js(e){if(!e)return!0;let t=n=>n.every(r=>Math.abs(r)<1e-9);return t(e.shadow)&&t(e.midtone)&&t(e.highlight)&&Math.abs(e.contrast-1)<1e-9}var gn=mc.x,so=gn.length;function nf(e){let t=mc.controls[e],n=[],r=[];for(let s of t.amps)n.push(s),r.push(t.curves[`${s>=0?"+":""}${s.toFixed(2)}`]);let o=n.findIndex(s=>s>0);return o<0&&(o=n.length),n.splice(o,0,0),r.splice(o,0,new Array(so).fill(0)),{amps:n,curves:r}}var kL=nf("shadow"),_L=nf("midtone"),vL=nf("highlight");function zo(e,t){if(t<=gn[0])return e[0];let n=so-1;if(t>=gn[n])return e[n];let r=0,o=n;for(;o-r>1;){let i=r+o>>1;gn[i]<=t?r=i:o=i}let s=(t-gn[r])/(gn[o]-gn[r]);return e[r]+(e[o]-e[r])*s}function tf(e,t,n){if(t===0)return 0;let{amps:r,curves:o}=e,s=r.length-1;if(t<=r[0])return zo(o[0],n)*(t/r[0]);if(t>=r[s])return zo(o[s],n)*(t/r[s]);let i=0,a=s;for(;a-i>1;){let c=i+a>>1;r[c]<=t?i=c:a=c}let l=(t-r[i])/(r[a]-r[i]);return zo(o[i],n)+(zo(o[a],n)-zo(o[i],n))*l}var fc=(()=>{let e=mc.contrast,t=e.cs.filter(n=>n>1).map(n=>({c:n,y:e.curves[n.toFixed(2)].map((r,o)=>gn[o]+r)}));return t.unshift({c:1,y:[...gn]}),t})();function DT(e,t){if(t<=e[0])return gn[0];let n=so-1;if(t>=e[n])return gn[n];let r=0,o=n;for(;o-r>1;){let i=r+o>>1;e[i]<=t?r=i:o=i}let s=(t-e[r])/(e[o]-e[r]);return gn[r]+(gn[o]-gn[r])*s}function TL(e,t){let n=0;for(;n<fc.length-2&&fc[n+1].c<=e;)n++;let r=fc[n],o=fc[n+1],s=(e-r.c)/(o.c-r.c),i=sr,a=new Array(so);for(let u=0;u<so;u++){let p=gn[u],d=0,m=1;for(let h=0;h<30;h++){let g=(d+m)/2;DT(r.y,g)*(1-s)+DT(o.y,g)*s<p?d=g:m=g}a[u]=(d+m)/2}let l=a;if(Math.abs(t-i)>1e-6){l=new Array(so);for(let u=0;u<so;u++){let p=gn[u],d=p<t?i*(p/t):i+(1-i)*((p-t)/(1-t)),m=zo(a,d);l[u]=m<i?t*(m/i):t+(1-t)*((m-i)/(1-i))}}let c=0;for(let u=0;u<so;u++){let p=l[u]<c?c:l[u];l[u]=p<0?0:p>1?1:p,c=l[u]}return l}var jT=NaN,BT=NaN,qT=null;function xL(e,t,n){return t<1?n+t*(e-n):((t!==jT||n!==BT)&&(qT=TL(t,n),jT=t,BT=n),zo(qT,e))}function io(e,t,n){let r=e+tf(kL,t.shadow[n],e)+tf(_L,t.midtone[n],e)+tf(vL,t.highlight[n],e);return t.contrast!==1&&(r=xL(r,t.contrast,t.pivot)),r}var HT=[.2126,.7152,.0722];function WT(e,t){let n=t.wheels??UT,r=rf({...t,wheels:void 0,saturation:void 0,mixer:void 0}),o=!js(t.wheels),s=e.w*e.h,i=new Float32Array(s*3),a=(c,u)=>{let p=c*r.slope[u]+r.offset[u],d=r.power[u];return d!==1&&(p=p<0?-Math.pow(-p,d):Math.pow(p,d)),o?io(p,n,u):p};if(s*3>=32768){let u=new Float32Array(12288);for(let p=0;p<3;p++)for(let d=0;d<4096;d++)u[p*4096+d]=a(d/4095,p);for(let p=0;p<s;p++)for(let d=0;d<3;d++){let m=e.data[p*3+d];if(m>=0&&m<=1){let h=m*4095,g=h|0,y=h-g,k=u[d*4096+g];i[p*3+d]=y>0?k+(u[d*4096+g+1]-k)*y:k}else i[p*3+d]=a(m,d)}}else for(let c=0;c<s;c++)for(let u=0;u<3;u++)i[c*3+u]=a(e.data[c*3+u],u);let l=t.saturation??1;if(l!==1)for(let c=0;c<s;c++){let u=.21*i[c*3]+.7*i[c*3+1]+.09*i[c*3+2];for(let p=0;p<3;p++)i[c*3+p]=u+(i[c*3+p]-u)*l}if(!Bs(t.mixer)){let c=hc(t.mixer);for(let u=0;u<s;u++){let p=i[u*3],d=i[u*3+1],m=i[u*3+2];i[u*3]=c[0]*p+c[1]*d+c[2]*m,i[u*3+1]=c[3]*p+c[4]*d+c[5]*m,i[u*3+2]=c[6]*p+c[7]*d+c[8]*m}}return{data:i,w:e.w,h:e.h}}function Bs(e){if(!e)return!0;let t=[1,0,0,0,1,0,0,0,1];return e.every((n,r)=>Math.abs(n-t[r])<1e-9)}function hc(e){let t=e.slice();for(let n=0;n<3;n++){let r=-HT[n];for(let o=0;o<3;o++)r+=HT[o]*e[o*3+n];for(let o=0;o<3;o++)t[o*3+n]-=r}return t}function zT(e,t){if(!js(t.wheels)||t.saturation!==void 0&&t.saturation!==1||!Bs(t.mixer)){let c=WT(e,t);for(let u=0;u<c.data.length;u++)c.data[u]=Pr(c.data[u]);return c}let n=t.blackPointOffset,r=Math.pow(2,t.exposureStops),o=[t.wbGain[0]*r,t.wbGain[1]*r,t.wbGain[2]*r],s=e.w*e.h,i=new Float32Array(s*3);for(let c=0;c<s;c++)i[c*3]=Pr(e.data[c*3]+n[0]),i[c*3+1]=Pr(e.data[c*3+1]+n[1]),i[c*3+2]=Pr(e.data[c*3+2]+n[2]);let a=LT({data:i,w:e.w,h:e.h},o,1),l=t.power;if(!l||l[0]===1&&l[1]===1&&l[2]===1)return a;for(let c=0;c<s;c++)for(let u=0;u<3;u++){let p=a.data[c*3+u];a.data[c*3+u]=p<=0?0:Math.pow(p,l[u])}return a}function rf(e){let t=Math.pow(2,e.exposureStops),n=e.wbGain.map(i=>Math.pow(i*t,1/2.4)),r=e.blackPointOffset.map((i,a)=>i*n[a]),o=e.power??[1,1,1],s={slope:n,offset:r,power:o};return js(e.wheels)||(s.wheels=e.wheels),e.saturation!==void 0&&Math.abs(e.saturation-1)>1e-6&&(s.saturation=e.saturation),Bs(e.mixer)||(s.mixer=e.mixer),s}function GT(e,t,n){return .2126*e+.7152*t+.0722*n}function SL(e,t){let n=e.length;if(n===0)return 0;if(n===1)return e[0];let r=Math.min(n-1,Math.max(0,t*(n-1))),o=Math.floor(r),s=Math.min(n-1,o+1),i=r-o;return e[o]+i*(e[s]-e[o])}function KT(e,t,n=4,r=6e4){let o=e.w*e.h,s=Math.max(1,Math.floor(o/r)),i=new Float32Array(Math.ceil(o/s)),a=0;for(let c=0;c<o;c+=s){let u=Fr(Math.max(0,Math.min(1,e.data[c*3]))),p=Fr(Math.max(0,Math.min(1,e.data[c*3+1]))),d=Fr(Math.max(0,Math.min(1,e.data[c*3+2]))),m=GT(u,p,d);if(m<=1e-5||Math.max(u,p,d)>=.99)continue;let h=Fr(Math.max(0,Math.min(1,t.data[c*3]))),g=Fr(Math.max(0,Math.min(1,t.data[c*3+1]))),y=Fr(Math.max(0,Math.min(1,t.data[c*3+2]))),k=GT(h,g,y)/m;!Number.isFinite(k)||k<=0||(i[a++]=Math.max(-n,Math.min(n,Math.log2(k))))}if(a===0)return 0;let l=i.subarray(0,a);return l.sort(),SL(l,.5)}function $L(e,t,n,r,o,s,i){let l=new Float64Array(1024),c=new Float64Array(1024),u=new Float64Array(1024),p=0;for(let $=0;$<n;$+=r){let U=e[$*3+o],E=t[$*3+o];if(!(U>.004&&U<.996)||!(E>5e-4&&E<.9995))continue;let z=U*1023+.5|0,G=s?s[$]:1;l[z]+=U*G,c[z]+=E*G,u[z]+=G,p++}let d=[],m=[],h=[];for(let $=0;$<1024;$++)u[$]!==0&&(d.push(l[$]/u[$]),m.push(c[$]/u[$]),h.push(u[$]));let g=d.length;if(p<32||g<8)return{slope:1,offset:0,power:1,residual:0,samples:p};let y=0;for(let $=0;$<g;$++)y+=h[$];let k=($,U,E)=>{let z=0;for(let G=0;G<g;G++){let D=d[G]*$+U,te=D<=0?0:Math.pow(D,E);z+=h[G]*Math.abs((te>1?1:te)-m[G])}return z/y},b=$=>{let U=0,E=0,z=0,G=0,D=0;for(let ve=0;ve<g;ve++){let oe=$===1?m[ve]:Math.pow(Math.max(m[ve],1e-9),1/$),P=h[ve];U+=P,E+=P*d[ve],z+=P*d[ve]*d[ve],G+=P*oe,D+=P*d[ve]*oe}let te=U*z-E*E;if(Math.abs(te)<1e-12)return null;let we=(U*D-E*G)/te,ge=(z*G-E*D)/te;for(let ve=0;ve<3;ve++){let oe=0,P=0,M=0,O=0,V=0;for(let xe=0;xe<g;xe++){let Oe=d[xe]*we+ge;if(Oe<=1e-9)continue;let De=Math.pow(Oe,$),ze=(De>1?1:De)-m[xe],Q=$*Math.pow(Oe,$-1),me=Q*d[xe],be=h[xe];oe+=be*me*me,P+=be*me*Q,M+=be*Q*Q,O+=be*me*ze,V+=be*Q*ze}let fe=oe*M-P*P;if(!(Math.abs(fe)>1e-12))break;if(we-=(M*O-P*V)/fe,ge-=(oe*V-P*O)/fe,ge>0&&(ge=0),!(we>.02&&we<200)||!Number.isFinite(ge))return null}return!(we>.02&&we<200)||!Number.isFinite(ge)||ge>0?null:{s:we,o:ge}},w=i?Math.min(Math.max(1,i[0]),i[1]):1,_=b(w),v=_?{slope:_.s,offset:_.o,power:w,residual:k(_.s,_.o,w),samples:p}:{slope:1,offset:0,power:1,residual:k(1,0,1),samples:p},R=.02,S=160,T=Math.log(i?i[0]:.1),x=Math.log(i?i[1]:5);for(let $=0;$<S;$++){let U=Math.exp(T+(x-T)*$/(S-1)),E=b(U);if(!E)continue;let z=k(E.s,E.o,U);z<v.residual*(1-R)&&(v={slope:E.s,offset:E.o,power:U,residual:z,samples:p})}return v}function gc(e,t,n=4e4,r,o){if(e.w!==t.w||e.h!==t.h)throw new Error(`fitShotAnalysis: size mismatch \u2014 ${e.w}x${e.h} vs ${t.w}x${t.h}`);let s=e.w*e.h;if(r&&r.length!==s)throw new Error(`fitShotAnalysis: weights length ${r.length} != ${s} pixels`);let i=Math.max(1,Math.floor(s/n)),a=[1,1,1],l=[0,0,0],c=[1,1,1],u=[0,0,0],p=0;for(let y=0;y<3;y++){let k=$L(e.data,t.data,s,i,y,r,o?.[y]);a[y]=k.slope,l[y]=k.offset,c[y]=k.power,u[y]=k.residual,p=Math.max(p,k.samples)}let d=a.map(y=>Math.pow(y,2.4)),m=[d[0]/d[1],1,d[2]/d[1]],h=Math.log2(d[1]);return{analysis:{blackPointOffset:[l[0]/a[0],l[1]/a[1],l[2]/a[2]],wbGain:m,exposureStops:h,power:c,castDeg:NT(m,[1,1,1])},lumaStops:KT(e,t),slope:a,offset:l,power:c,residual:u,maxResidual:Math.max(u[0],u[1],u[2]),samples:p}}function VT(e,t,n,r=2e4,o,s){let i=e.w*e.h;if(o&&o.length!==i)throw new Error(`fitLogWheels: weights length ${o.length} != ${i} pixels`);let a=Math.max(1,Math.floor(i/r)),l=1024,c=[[],[],[]],u=[[],[],[]],p=[[],[],[]];for(let T=0;T<3;T++){let x=new Float64Array(l),$=new Float64Array(l),U=new Float64Array(l);for(let E=0;E<i;E+=a){let z=e.data[E*3+T];if(!(z>.002&&z<.998))continue;let G=z*(l-1)+.5|0,D=o?o[E]:1;x[G]+=z*D,$[G]+=t.data[E*3+T]*D,U[G]+=D}for(let E=0;E<l;E++)U[E]!==0&&(c[T].push(x[E]/U[E]),u[T].push($[E]/U[E]),p[T].push(U[E]))}let d=(T,x)=>x?Math.min(x[1],Math.max(x[0],T)):T,m={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:d(1,s?.contrast),pivot:d(sr,s?.pivot)},h=n.wbGain,g=Math.pow(2,n.exposureStops),y=[0,1,2].map(T=>Math.pow(h[T]*g,1/2.4)),k=n.blackPointOffset,b=n.power??[1,1,1],w=[[],[],[]];for(let T=0;T<3;T++)for(let x=0;x<c[T].length;x++){let $=(c[T][x]+k[T])*y[T];b[T]!==1&&($=$<0?-Math.pow(-$,b[T]):Math.pow($,b[T])),w[T].push($)}let _=0;for(let T=0;T<3;T++)for(let x of p[T])_+=x;let v=()=>{let T=0;for(let x=0;x<3;x++)for(let $=0;$<w[x].length;$++){let U=io(w[x][$],m,x);T+=p[x][$]*Math.abs((U<0?0:U>1?1:U)-u[x][$])}return _?T/_:0},R=(T,x,$)=>{let U=.6180339887,E=x,z=$,G=z-U*(z-E),D=E+U*(z-E);T(G);let te=v();T(D);let we=v(),ge=te,ve=we;for(let P=0;P<18&&z-E>1e-4;P++)ge<ve?(z=D,D=G,ve=ge,G=z-U*(z-E),T(G),ge=v()):(E=G,G=D,ge=ve,D=E+U*(z-E),T(D),ve=v());let oe=ge<ve?G:D;T(oe)},S=v();for(let T=0;T<3;T++){R($=>{m.contrast=$},Math.max(.4,s?.contrast[0]??.4),Math.min(2.2,s?.contrast[1]??2.2)),R($=>{m.pivot=$},Math.max(.15,s?.pivot[0]??.15),Math.min(.85,s?.pivot[1]??.85));for(let $=0;$<3;$++)R(U=>{m.shadow[$]=U},-.4,.4),R(U=>{m.midtone[$]=U},-.4,.4),R(U=>{m.highlight[$]=U},-.4,.4);let x=v();if(S-x<1e-5)break;S=x}return Math.abs(m.contrast-1)<1e-4&&(m.contrast=1,m.pivot=sr),{wheels:m,residual:v()}}var Cn=e=>e<0?0:e>1?1:e;function XT(e){let t=e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]);return[(e[4]*e[8]-e[5]*e[7])/t,(e[2]*e[7]-e[1]*e[8])/t,(e[1]*e[5]-e[2]*e[4])/t,(e[5]*e[6]-e[3]*e[8])/t,(e[0]*e[8]-e[2]*e[6])/t,(e[2]*e[3]-e[0]*e[5])/t,(e[3]*e[7]-e[4]*e[6])/t,(e[1]*e[6]-e[0]*e[7])/t,(e[0]*e[4]-e[1]*e[3])/t]}function RL(e,t){let n=e.w*e.h,r=new Float32Array(n*3);for(let o=0;o<3;o++){let s=t[o],i=s.length-1;for(let a=0;a<n;a++){let l=Math.min(i,Math.max(0,Math.round(Cn(e.data[a*3+o])*i)));r[a*3+o]=s[l]}}return{data:r,w:e.w,h:e.h}}function JT(e,t,n=1){let r=0,o=0;for(let s=0;s<e.w*e.h;s+=n){for(let i=0;i<3;i++)r+=Math.abs(Cn(e.data[s*3+i])-Cn(t.data[s*3+i]));o+=3}return r/o}var cU=.8/255;function QT(e,t,n,r){let o=n??pc(e,t,r?.inner??"mvgd"),s=r?.tone1Contrast??null,i=r?.enableTone2??!0,a=r?.trimContrast??null,l=o.matrix,c=$=>({data:Float32Array.from($.data,Cn),w:$.w,h:$.h}),u=RL(e,o.hm1),p=sf(e,u),d=o.offset,m=XT(l),h=[m[0]*d[0]+m[1]*d[1]+m[2]*d[2],m[3]*d[0]+m[4]*d[1]+m[5]*d[2],m[6]*d[0]+m[7]*d[1]+m[8]*d[2]],g=e.w*e.h,y=new Float32Array(g*3);for(let $=0;$<g;$++){let U=p.out.data[$*3],E=p.out.data[$*3+1],z=p.out.data[$*3+2];y[$*3]=Cn(l[0]*U+l[1]*E+l[2]*z+d[0]),y[$*3+1]=Cn(l[3]*U+l[4]*E+l[5]*z+d[1]),y[$*3+2]=Cn(l[6]*U+l[7]*E+l[8]*z+d[2])}let k={data:y,w:e.w,h:e.h},b=sf(k,o.image);if(s==null&&i&&a==null){let $=JT(c(b.out),o.image);return{tone1:p.tone,offset:h,matrix:l,tone2:b.tone,tone2Enabled:!0,trim:null,residual:$}}let w=s==null?p.tone:{...p.tone,contrast:s,pivot:p.tone.pivot??.435},_=a==null?null:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1],contrast:a,pivot:.435},v=of(e,w),R=new Float32Array(g*3);for(let $=0;$<g;$++){let U=v.data[$*3],E=v.data[$*3+1],z=v.data[$*3+2];R[$*3]=Cn(l[0]*U+l[1]*E+l[2]*z+d[0]),R[$*3+1]=Cn(l[3]*U+l[4]*E+l[5]*z+d[1]),R[$*3+2]=Cn(l[6]*U+l[7]*E+l[8]*z+d[2])}let S={data:R,w:e.w,h:e.h},T=i?of(S,b.tone):S;_&&(T=of(T,_));let x=JT(T,o.image);return{tone1:w,offset:h,matrix:l,tone2:b.tone,tone2Enabled:i,trim:_,residual:x}}function of(e,t){let r=t.shadow||t.midtone||t.highlight||t.contrast!==void 0&&Math.abs(t.contrast-1)>1e-9?{shadow:t.shadow??[0,0,0],midtone:t.midtone??[0,0,0],highlight:t.highlight??[0,0,0],contrast:t.contrast??1,pivot:t.pivot??.435}:null,o=new Float32Array(3*4096);for(let i=0;i<3;i++){let a=t.power?.[i]??1;for(let l=0;l<4096;l++){let c=l/4095*t.slope[i]+t.offset[i];a!==1&&(c=c<0?-Math.pow(-c,a):Math.pow(c,a)),r&&(c=io(c,r,i)),o[i*4096+l]=Cn(c)}}let s=new Float32Array(e.data.length);for(let i=0;i<e.w*e.h;i++)for(let a=0;a<3;a++)s[i*3+a]=o[a*4096+Math.min(4095,Math.max(0,Math.round(Cn(e.data[i*3+a])*4095)))];return{data:s,w:e.w,h:e.h}}function sf(e,t,n){let r=gc(e,t,void 0,n),o=r.analysis,s=VT(e,t,o,void 0,n);s.residual<r.maxResidual&&(o={...o,wheels:s.wheels});let i=zT(e,o),a={data:Float32Array.from(i.data,Cn),w:e.w,h:e.h},l=rf(o);return{tone:{slope:l.slope,offset:l.offset,power:l.power,...l.wheels?{shadow:l.wheels.shadow,midtone:l.wheels.midtone,highlight:l.wheels.highlight,contrast:l.wheels.contrast,pivot:l.wheels.pivot}:{}},out:a}}function af(e,t,n=16){let{w:r,h:o}=e,s=(a,l)=>.2126*a[l*3]+.7152*a[l*3+1]+.0722*a[l*3+2],i=new Float32Array(r*o);for(let a=0;a<o;a+=n)for(let l=0;l<r;l+=n){let c=0,u=0,p=0,d=0,m=0,h=0,g=Math.min(o,a+n),y=Math.min(r,l+n);for(let v=a;v<g;v++)for(let R=l;R<y;R++){let S=v*r+R,T=s(e.data,S),x=s(t.data,S);c++,u+=T,p+=x,d+=T*T,m+=x*x,h+=T*x}let k=d/c-(u/c)**2,b=m/c-(p/c)**2,w=2e-5,_=k<w&&b<w?1:k<w||b<w?.1:Math.min(1,Math.max(0,((h/c-u/c*(p/c))/Math.sqrt(k*b)-.2)/.6));for(let v=a;v<g;v++)for(let R=l;R<y;R++){let S=v*r+R,T=Math.max(e.data[S*3],e.data[S*3+1],e.data[S*3+2])>.99||Math.max(t.data[S*3],t.data[S*3+1],t.data[S*3+2])>.99;i[S]=T?0:_}}return i}function CL(e,t){let n=[0,1,2,3].map(r=>[e[r*4],e[r*4+1],e[r*4+2],e[r*4+3],t[r]]);for(let r=0;r<4;r++){let o=r;for(let s=r+1;s<4;s++)Math.abs(n[s][r])>Math.abs(n[o][r])&&(o=s);if([n[r],n[o]]=[n[o],n[r]],Math.abs(n[r][r])<1e-12)return r<3?[r===0?1:0,r===1?1:0,r===2?1:0,0]:[0,0,0,0];for(let s=0;s<4;s++)if(s!==r){let i=n[s][r]/n[r][r];for(let a=r;a<5;a++)n[s][a]-=i*n[r][a]}}return n.map((r,o)=>r[4]/r[o])}var EL=0;function YT(e,t,n){if(e.w!==t.w||e.h!==t.h)throw new Error(`pixelFitStages: size mismatch ${e.w}x${e.h} vs ${t.w}x${t.h}`);let r=e.w*e.h,o=n?.weights??af(e,t),s=new Float64Array(16),i=new Float64Array(12),a=0;for(let R=0;R<r;R++){let S=o[R];if(!S)continue;a+=S;let T=[e.data[R*3],e.data[R*3+1],e.data[R*3+2],1];for(let x=0;x<4;x++){for(let $=0;$<4;$++)s[x*4+$]+=S*T[x]*T[$];for(let $=0;$<3;$++)i[x*3+$]+=S*T[x]*t.data[R*3+$]}}let l=(n?.ridge??EL)*a;for(let R=0;R<3;R++)s[R*4+R]+=l,i[R*3+R]+=l;let c=[0,1,2].map(R=>CL(s,[0,1,2,3].map(S=>i[S*3+R]))),u=c.flatMap(R=>R.slice(0,3)),p=c.map(R=>R[3]),d=XT(u),m=[d[0]*p[0]+d[1]*p[1]+d[2]*p[2],d[3]*p[0]+d[4]*p[1]+d[5]*p[2],d[6]*p[0]+d[7]*p[1]+d[8]*p[2]],h=new Float32Array(r*3);for(let R=0;R<r;R++){let S=e.data[R*3],T=e.data[R*3+1],x=e.data[R*3+2];for(let $=0;$<3;$++)h[R*3+$]=Cn(u[$*3]*S+u[$*3+1]*T+u[$*3+2]*x+p[$])}let g={data:h,w:e.w,h:e.h},y=R=>{let S=0,T=0;for(let x=0;x<r;x++){let $=o[x];$&&(S+=$*(Math.abs(R.data[x*3]-t.data[x*3])+Math.abs(R.data[x*3+1]-t.data[x*3+1])+Math.abs(R.data[x*3+2]-t.data[x*3+2])),T+=3*$)}return T?S/T:0},k=sf(g,t,o),b=y(g),w=y(k.out),_=w<b-.5/255;return{tone1:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},offset:m,matrix:u,tone2:k.tone,tone2Enabled:_,trim:null,residual:_?w:b,trustedShare:a/r}}function ZT(e){let{wheels:t,...n}=e;return{...n,...t?{shadow:t.shadow,midtone:t.midtone,highlight:t.highlight,contrast:t.contrast,pivot:t.pivot}:{}}}function ex(e){if(e.mixerLumaLock!==!1||Bs(e.mixer))return!1;let t=(s,i)=>Math.abs(s-i)<1e-9,n=e.power??[1,1,1],r=e.curves,o=!!r&&[r.r,r.g,r.b].some(s=>s&&s.length>=2);return[0,1,2].every(s=>t(n[s],1))&&tx(e)===null&&!o}function AL(e,t){if(t<=e[0][0])return e[0][1];let n=e[e.length-1];if(t>=n[0])return n[1];let r=0,o=e.length-1;for(;o-r>1;){let c=r+o>>1;e[c][0]<=t?r=c:o=c}let[s,i]=e[r],[a,l]=e[o];return a>s?i+(l-i)*(t-s)/(a-s):i}var Or=[.21,.7,.09];function tx(e){if(!e.shadow&&!e.midtone&&!e.highlight&&e.contrast===void 0)return null;let t=r=>[r?.[0]??0,r?.[1]??0,r?.[2]??0],n={shadow:t(e.shadow),midtone:t(e.midtone),highlight:t(e.highlight),contrast:e.contrast??1,pivot:e.pivot??sr};return js(n)?null:n}function nx(e,t){if(ex(e))return i=>i;let n=tx(e),r=e.power??[1,1,1],o=[e.curves?.r,e.curves?.g,e.curves?.b].map(i=>i&&i.length>=2?i:null),s=i=>i<0?0:i>1?1:i;return(i,a)=>{let l=i*e.slope[a]+e.offset[a],c=r[a];c!==1&&(l=l<0?-Math.pow(-l,c):Math.pow(l,c)),n&&(l=io(l,n,a));let u=o[a];return u&&(l=AL(u,s(l))),t?s(l):l}}function rx(e){let t=e.saturation??1,n=Math.abs(t-1)>1e-9,r=!Bs(e.mixer),o=ex(e);if(!n&&!r&&!o)return null;let s=[t+(1-t)*Or[0],(1-t)*Or[1],(1-t)*Or[2],(1-t)*Or[0],t+(1-t)*Or[1],(1-t)*Or[2],(1-t)*Or[0],(1-t)*Or[1],t+(1-t)*Or[2]];if(r){let a=e.mixerLumaLock===!1?e.mixer:hc(e.mixer),l=new Array(9);for(let c=0;c<3;c++)for(let u=0;u<3;u++)l[c*3+u]=a[c*3]*s[u]+a[c*3+1]*s[3+u]+a[c*3+2]*s[6+u];s=l}let i=[0,0,0];if(o){let a=e.slope,l=e.offset;for(let c=0;c<3;c++){i[c]=s[c*3]*l[0]+s[c*3+1]*l[1]+s[c*3+2]*l[2];for(let u=0;u<3;u++)s[c*3+u]*=a[u]}}return{m:s,add:i}}var Yi=-1,ao=-1,sx=!1,cf=.35,IL=[.25,-.5,Math.log(.25)],ML=[4,.5,Math.log(4)],wr=-1;function lf(e){let t={slope:[e[0],e[1],e[2]],offset:[e[3],e[4],e[5]],power:[Math.exp(e[6]),Math.exp(e[7]),Math.exp(e[8])],contrast:e[9],pivot:Yi>=0?e[Yi]:sr,saturation:e[10]};if(wr>=0&&(t.master={slope:e[wr],offset:e[wr+1],power:Math.exp(e[wr+2])}),ao>=0){let n=e.slice(ao,ao+6);t.mixer=[1,n[0],n[1],n[2],1,n[3],n[4],n[5],1],sx&&(t.mixerLumaLock=!1)}return e.length-(Yi>=0?1:0)-(ao>=0?6:0)-(wr>=0?3:0)>11&&(t.shadow=[e[11],e[12],e[13]],t.midtone=[e[14],e[15],e[16]],t.highlight=[e[17],e[18],e[19]]),t}var PL=[.25,.25,.25,-.5,-.5,-.5,Math.log(.25),Math.log(.25),Math.log(.25),.5,0,...Array(9).fill(-.3)],FL=[4,4,4,.5,.5,.5,Math.log(4),Math.log(4),Math.log(4),2,2,...Array(9).fill(.3)],OL=e=>e.map((t,n)=>n===Yi?Math.min(.9,Math.max(.1,t)):wr>=0&&n>=wr?Math.min(ML[n-wr],Math.max(IL[n-wr],t)):ao>=0&&n>=ao&&n<ao+6?Math.min(cf,Math.max(-cf,t)):Math.min(FL[n],Math.max(PL[n],t))),bc=(e,t)=>t===1?e:e<0?-Math.pow(-e,t):Math.pow(e,t);function ox(e,t,n,r){let o=e.master,s=o?{...e,slope:[1,1,1],offset:[0,0,0],power:[1,1,1]}:{...e},i=nx(s,!1),a=rx(s);for(let l=0;l<t.length;l+=3){let c,u,p;if(o){let d=t[l],m=t[l+1],h=t[l+2],g=bc(d*e.slope[0]+e.offset[0],e.power[0]),y=bc(m*e.slope[1]+e.offset[1],e.power[1]),k=bc(h*e.slope[2]+e.offset[2],e.power[2]),b=.2126*g+.7152*y+.0722*k,w=.2126*d+.7152*m+.0722*h,_=bc(w*o.slope+o.offset,o.power);c=i(g-b+_,0),u=i(y-b+_,1),p=i(k-b+_,2)}else c=i(t[l],0),u=i(t[l+1],1),p=i(t[l+2],2);if(a){let d=a.m,m=a.add,h=d[0]*c+d[1]*u+d[2]*p+m[0],g=d[3]*c+d[4]*u+d[5]*p+m[1],y=d[6]*c+d[7]*u+d[8]*p+m[2];c=h,u=g,p=y}n[l]=c,n[l+1]=u,n[l+2]=p}r?.(n);for(let l=0;l<n.length;l++)n[l]=n[l]<0?0:n[l]>1?1:n[l]}function LL(e,t,n){let r=e.slice(),o=t.slice();for(let i=0;i<n;i++){let a=i;for(let c=i+1;c<n;c++)Math.abs(r[c*n+i])>Math.abs(r[a*n+i])&&(a=c);if(a!==i){for(let c=0;c<n;c++)[r[i*n+c],r[a*n+c]]=[r[a*n+c],r[i*n+c]];[o[i],o[a]]=[o[a],o[i]]}let l=r[i*n+i]||1e-12;for(let c=i+1;c<n;c++){let u=r[c*n+i]/l;if(u){for(let p=i;p<n;p++)r[c*n+p]-=u*r[i*n+p];o[c]-=u*o[i]}}}let s=new Array(n).fill(0);for(let i=n-1;i>=0;i--){let a=o[i];for(let l=i+1;l<n;l++)a-=r[i*n+l]*s[l];s[i]=a/(r[i*n+i]||1e-12)}return s}function uf(e,t,n={}){if(n.matchChroma&&n.matchStats===void 0&&(n={...n,matchStats:1}),e.w!==t.w||e.h!==t.h)throw new Error(`fitPrimaries: size mismatch ${e.w}x${e.h} vs ${t.w}x${t.h}`);let r=e.w*e.h,o=n.samples??6e3;if(n.skinBoost&&n.skinBoost>1){let Q=n.weights??new Float32Array(r).fill(1),me=new Float32Array(r);for(let be=0;be<r;be++){if(me[be]=Q[be],!Q[be])continue;let Ie=t.data[be*3]*255,ye=t.data[be*3+1]*255,Le=t.data[be*3+2]*255,re=.299*Ie+.587*ye+.114*Le,se=128-.168736*Ie-.331264*ye+.5*Le,le=128+.5*Ie-.418688*ye-.081312*Le;(n.skinRegion===void 0||n.skinRegion!==null&&n.skinRegion[be]>1)&&se>=77&&se<=127&&le>=133&&le<=173&&re>40&&re<235&&(me[be]=Q[be]*n.skinBoost)}n={...n,weights:me}}let s=[];for(let Q=0;Q<r;Q++)(!n.weights||n.weights[Q]>0)&&s.push(Q);let i=[],a=Math.max(1,s.length/o);for(let Q=0;Q<s.length&&i.length<o;Q+=a)i.push(s[Math.floor(Q)]);let l=i.length,c=new Float64Array(l*3),u=new Float64Array(l*3),p=new Float64Array(l);i.forEach((Q,me)=>{for(let be=0;be<3;be++)c[me*3+be]=e.data[Q*3+be],u[me*3+be]=t.data[Q*3+be];p[me]=Math.sqrt(n.weights?n.weights[Q]:1)});let d=(n.wheels?20:11)+(n.freePivot?1:0)+(n.mixer||n.mixerRaw?6:0)+(n.lumMix100?3:0),m=[1,1,1,0,0,0,0,0,0,1,1,...n.wheels?Array(9).fill(0):[],...n.freePivot?[sr]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[]];wr=n.lumMix100?d-3:-1,n.lumMix100&&(m=[...m,1,0,0]),ao=n.mixer||n.mixerRaw?d-6-(n.lumMix100?3:0):-1,sx=!!n.mixerRaw,cf=n.mixerRaw?1.5:.35,Yi=n.freePivot?d-1-(n.mixer||n.mixerRaw?6:0)-(n.lumMix100?3:0):-1;let h=[.2126,.7152,.0722],g=n.keepTone;g&&(m=[...g.slope,...g.offset,...g.power.map(Math.log),g.contrast,g.saturation,...m.slice(11)]);let y=Q=>{if(n.balanceOnly&&(Q[7]=Q[6],Q[8]=Q[6]),g){let me=h[0]*Q[0]+h[1]*Q[1]+h[2]*Q[2],be=h[0]*g.slope[0]+h[1]*g.slope[1]+h[2]*g.slope[2];for(let Le=0;Le<3;Le++)Q[Le]*=be/me;let Ie=h[0]*Q[3]+h[1]*Q[4]+h[2]*Q[5],ye=h[0]*g.offset[0]+h[1]*g.offset[1]+h[2]*g.offset[2];for(let Le=3;Le<6;Le++)Q[Le]+=ye-Ie}return Q};if(n.lumMix100){let Q=y;y=me=>{Q(me);let be=h[0]*me[0]+h[1]*me[1]+h[2]*me[2];for(let ye=0;ye<3;ye++)me[ye]/=be;let Ie=h[0]*me[3]+h[1]*me[4]+h[2]*me[5];for(let ye=3;ye<6;ye++)me[ye]-=Ie;return me[6]=me[7]=me[8]=0,me}}let k=new Set([...n.balanceOnly?[7,8]:[],...g?[6,7,8,9]:[],...n.lumMix100?[6,7,8]:[],...n.noContrastSat?[9,10]:[]]),b=[1,1,1,0,0,0,0,0,0,1,1,...n.wheels?Array(9).fill(0):[],...n.freePivot?[sr]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[],...n.lumMix100?[1,0,0]:[]],w=[6,7,8,9],_=0;for(let Q=0;Q<l;Q++)_+=p[Q]*p[Q];let v=Math.sqrt((n.prior??0)*_),R=[.02,.1,.25,.5,.75,.9,.98],S=Q=>{let me=new Float64Array(l),be=0,Ie=0;for(let le=0;le<l;le++){let _e=Q[le*3],Me=Q[le*3+1],Pe=Q[le*3+2],Ge=p[le]*p[le];Ie+=Ge,be+=Ge*(Math.max(_e,Me,Pe)-Math.min(_e,Me,Pe)),me[le]=.2126*_e+.7152*Me+.0722*Pe}let ye=new Float64Array(9),Le=[0,0,0];U.forEach((le,_e)=>{for(let Me of le){for(let Pe=0;Pe<3;Pe++)ye[_e*3+Pe]+=Q[Me*3+Pe];Le[_e]++}});let re=new Float64Array(6),se=[0,0];return G.forEach((le,_e)=>{for(let Me of le){for(let Pe=0;Pe<3;Pe++)re[_e*3+Pe]+=Q[Me*3+Pe];se[_e]++}}),me.sort(),[...R.map(le=>me[Math.floor(le*(l-1))]),be/Ie,...Array.from(ye,(le,_e)=>Le[_e/3|0]?le/Le[_e/3|0]:0),...[0,1].flatMap(()=>Array.from(re,(le,_e)=>se[_e/3|0]?le/se[_e/3|0]:0))]},T=[];for(let Q=0;Q<l;Q++){let me=u[Q*3],be=u[Q*3+1],Ie=u[Q*3+2],ye=.2126*me+.7152*be+.0722*Ie;Math.max(me,be,Ie)-Math.min(me,be,Ie)<.06&&ye>.04&&ye<.96&&T.push(Q)}let x=Q=>.2126*u[Q*3]+.7152*u[Q*3+1]+.0722*u[Q*3+2];T.sort((Q,me)=>x(Q)-x(me));let $=Math.floor(T.length/3),U=$>=20?[T.slice(0,$),T.slice($,2*$),T.slice(2*$)]:[[],[],[]],E=[];for(let Q=0;Q<l;Q++){let me=u[Q*3]*255,be=u[Q*3+1]*255,Ie=u[Q*3+2]*255,ye=.299*me+.587*be+.114*Ie,Le=128-.168736*me-.331264*be+.5*Ie,re=128+.5*me-.418688*be-.081312*Ie;Le>=77&&Le<=127&&re>=133&&re<=173&&ye>40&&ye<235&&E.push(Q)}E.sort((Q,me)=>x(Q)-x(me));let z=Math.floor(E.length/2),G=z>=15?[E.slice(0,z),E.slice(z)]:[[],[]],D=S(u),te=n.matchStats?D.length:0,we=Math.sqrt((n.matchStats??0)*_*3/Math.max(1,te)),ge=l*3+te+w.length,ve=new Float64Array(l*3),oe=Q=>{ox(lf(Q),c,ve,n.post);let me=new Float64Array(ge);for(let be=0;be<l*3;be++)me[be]=(ve[be]-u[be])*p[be/3|0];if(te){let be=S(ve);for(let Ie=0;Ie<te;Ie++)me[l*3+Ie]=we*(be[Ie]-D[Ie])}return w.forEach((be,Ie)=>{me[l*3+te+Ie]=v*(Q[be]-b[be])}),me},P=Q=>{let me=0;for(let be of Q)me+=be*be;return me},M=oe(m),O=P(M),V=.001,fe=0,xe=n.iterations??80,Oe=new Float64Array(ge*d);for(;fe<xe;fe++){for(let ye=0;ye<d;ye++){if(k.has(ye)){for(let le=0;le<ge;le++)Oe[le*d+ye]=0;continue}let Le=1e-4,re=m.slice();re[ye]+=Le,y(re);let se=oe(re);for(let le=0;le<ge;le++)Oe[le*d+ye]=(se[le]-M[le])/Le}let Q=new Array(d*d).fill(0),me=new Array(d).fill(0);for(let ye=0;ye<ge;ye++){let Le=M[ye];for(let re=0;re<d;re++){let se=Oe[ye*d+re];if(se){me[re]+=se*Le;for(let le=re;le<d;le++)Q[re*d+le]+=se*Oe[ye*d+le]}}}for(let ye of k)Q[ye*d+ye]+=1;for(let ye=0;ye<d;ye++)for(let Le=0;Le<ye;Le++)Q[ye*d+Le]=Q[Le*d+ye];let be=!1,Ie=!1;for(let ye=0;ye<8;ye++){let Le=Q.slice();for(let Me=0;Me<d;Me++)Le[Me*d+Me]*=1+V;let re=LL(Le,me.map(Me=>-Me),d),se=y(OL(m.map((Me,Pe)=>k.has(Pe)?Me:Me+re[Pe]))),le=oe(se),_e=P(le);if(_e<O){Ie=(O-_e)/Math.max(O,1e-12)<1e-7,m=se,O=_e,M=le,V=Math.max(V/3,1e-7),be=!0;break}V*=4}if(!be||Ie)break}ox(lf(m),c,ve,n.post);let De=0,ze=0;for(let Q=0;Q<l*3;Q++){let me=p[Q/3|0]**2;De+=me*Math.abs(ve[Q]-u[Q]),ze+=me}return{cdl:lf(m),residual:ze?De/ze:0,iterations:fe}}var NL="yunet.safetensors";async function ix(e){let t=await Ir(),n=t&&B(t.model,NL);if(!t||!n||!await Fn(n))return[];let r=new Uint8Array(e.w*e.h*3);for(let s=0;s<r.length;s++)r[s]=Math.max(0,Math.min(255,Math.round(e.data[s]*255)));let o=await Dt("conform-faces-");try{let s=B(o,"in.rgb");await cn(s,r);let i=[],a=await cr(t.runner,["faces","--weights",n,"--input-rgb",`${s}:${e.w}x${e.h}`],c=>i.push(c));if(a.code!==0)throw new Error(`face detection failed (exit ${a.code}): ${a.stderr.trim().slice(-300)}`);return JSON.parse(new TextDecoder().decode(DL(i)).trim()).faces.map(c=>({x0:Math.max(0,c.x/e.w),y0:Math.max(0,c.y/e.h),x1:Math.min(1,(c.x+c.w)/e.w),y1:Math.min(1,(c.y+c.h)/e.h),score:c.score}))}finally{await Vt(o).catch(()=>{})}}function DL(e){let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function ax(e,t,n=8){let r=t.filter(i=>i.x1>i.x0&&i.y1>i.y0&&i.score>0);if(r.length===0)return null;let o=e.w*e.h,s=new Float32Array(o).fill(1);for(let i of r){let a=(i.x0+i.x1)/2*e.w,l=(i.y0+i.y1)/2*e.h,c=Math.max(1,(i.x1-i.x0)/2*e.w),u=Math.max(1,(i.y1-i.y0)/2*e.h),p=Math.max(0,Math.floor(a-2.5*c)),d=Math.min(e.w,Math.ceil(a+2.5*c)),m=Math.max(0,Math.floor(l-2.5*u)),h=Math.min(e.h,Math.ceil(l+2.5*u));for(let g=m;g<h;g++){let y=(g-l)/u;for(let k=p;k<d;k++){let b=(k-a)/c,w=b*b+y*y,_=1+(n-1)*i.score*Math.exp(-w/(2*.45)),v=g*e.w+k;_>s[v]&&(s[v]=_)}}}return s}var lx=()=>({slope:[1,1,1],offset:[0,0,0],power:[1,1,1]});function df(e,t){let n=yc(t),r="engine"in e&&e.engine==="ai"?e:null,o=r?r.transferred?"AI Color Transfer":"AI Auto Balance":"Auto Balance",s={source:r?r.transferred?"ai_color_transfer_v1":"ai_balance_v1":"auto_balance_v1",castDeg:e.analysis.castDeg,exposureStops:e.analysis.exposureStops,wbGain:e.analysis.wbGain,blackPointOffset:e.analysis.blackPointOffset,framesUsed:e.framesUsed,transfer:e.transfer,...r?{seed:r.seed,prompt:r.prompt,fitResidual:r.fitResidual,inferenceMs:r.inferenceMs,matchMethod:r.matchMethod,gradeStyle:r.gradeStyle,usesLogWheels:e.cdl.wheels!==void 0,usesSaturation:e.cdl.saturation!==void 0,facesDetected:r.facesDetected,skinWeighted:r.skinWeighted}:{}};if(r?.fold){let a=r.fold;return[{id:n[0],kind:"cdl",label:`${o} \xB7 tone 1`,enabled:!0,cdl:{...a.tone1},meta:s},{id:n[1],kind:"cdl",label:`${o} \xB7 match matrix`,enabled:!0,cdl:{...lx(),offset:a.offset,mixer:a.matrix,mixerLumaLock:!1},meta:{source:s.source,part:"2/4"}},{id:n[2],kind:"cdl",label:`${o} \xB7 tone 2`,enabled:a.tone2Enabled??!0,cdl:{...a.tone2},meta:{source:s.source,part:"3/4"}},...a.trim?[{id:n[3],kind:"cdl",label:`${o} \xB7 trim`,enabled:!0,cdl:{...lx(),contrast:a.trim.contrast,pivot:a.trim.pivot},meta:{source:s.source,part:"4/4"}}]:[]]}let i=ZT(e.cdl);return[{id:n[0],kind:"cdl",label:o,enabled:!0,cdl:i,meta:s}]}function yc(e){let t=e?`@${e}`:"";return[`auto-balance${t}`,`auto-balance${t}-2`,`auto-balance${t}-3`,`auto-balance${t}-4`]}function cx(e,t,n,r){let o=df(e,r),s=new Set(o.map(a=>a.id)),i=r?[...yc(r),...yc()]:yc();return[...o.map(a=>({timeline_id:t,item_id:n,entry:a})),...i.filter(a=>!s.has(a)).map(a=>({timeline_id:t,item_id:n,remove_id:a}))]}var ux={inputColorSpace:"REC709_COLORSPACE",inputGamma:"TWOPOINTFOUR_GAMMA",outputColorSpace:"REC709_COLORSPACE",outputGamma:"TWOPOINTFOUR_GAMMA"};function dx(e){let t=String(e.outputGamma??ux.outputGamma);return t==="TWOPOINTFOUR_GAMMA"||t==="REC709_GAMMA"?"g24":t==="SRGB_GAMMA"?"srgb":null}function pf(e){let t=n=>String(e[n]??ux[n]).replace(/_(COLORSPACE|GAMMA)$/,"");return`${t("inputColorSpace")}/${t("inputGamma")} \u2192 ${t("outputColorSpace")}/${t("outputGamma")}`}async function qs(e,t){await Dr();let n=Float32Array.from(e.data);return n1(JSON.stringify(t),n),{data:n,w:e.w,h:e.h}}var hx=["primaries","pixel","hm-mkl-hm","hm-coral-hm","hm-adain-hm","hm-mvgd-hm"],px=1024;async function jL(e){let t=await B1(e);return Vm(t.rgba,t.width,t.height)}async function BL(e,t){let n=await mt(e),r=n.streams?.find(u=>u.kind==="video"),o=(r?.codec??"").toLowerCase(),s=n.source_fps??r?.rate??24,i=n.available_range?.duration?.value??0;if(["r3d","braw","crm","canon","arriraw","ari","xocn","prores_raw","prores raw","aprn","aprh"].some(u=>o.includes(u)))throw new Error(`${ie(e)} is camera-native raw (${o}): the engine decodes it as log, so a display-referred match would be wrong \u2014 match on a proxy or a rendered frame`);let l=t==null?Math.floor(i/2):ur(t,s,n.source_timecode??null);if(i&&(l<0||l>=i))throw new Error(`frame ${l} is outside ${ie(e)} (0\u2013${i-1})`);let c=await ha(e,l,o);return{image:Vm(c.rgba,c.width,c.height),frame:l,codec:o,transfer:"g24",fps:s}}async function mx(e,t){let n=Qn(e).toLowerCase();if(N1.has(n)||D1.has(n))return{image:await jL(e),frame:0,codec:"still",transfer:"srgb",fps:0};if(fa.has(n))return BL(e,t);throw new Error(`unsupported file for color match: ${ie(e)}`)}async function gx(e){let t=Date.now(),n=e.reference==="ai",r=e.method??(n?"primaries":"hm-mkl-hm"),o=r.split("-")[1],s=await mx(e.source,e.frame);if(e.cst){let _=dx(e.cst);if(!_)throw new Error(`the clip's Color Space Transform (${pf(e.cst)}) does not end on a display; balance needs Rec.709/sRGB out`);s.image=await qs(s.image,e.cst),s.transfer=_}let i,a=n?await(async()=>{let _=qi();if(_)throw new Error(_);let v=await Ir();if(!v&&!e.download)throw new Error("the local AI color model is not installed yet: run again with download: true to fetch it once (~4.3 GB, stays on this machine)");v??=await Jl({onProgress:e.onProgress});let R=await z_(v,cc(s.image,1024)),S=G_(fx(s.image,R.w,R.h),R);return i={ms:R.ms,askedStops:S.askedStops,appliedStops:S.appliedStops},{image:S.image,frame:0,codec:"ai",transfer:s.transfer,fps:0}})():await mx(e.reference,e.reference_frame),l=e.transfer??s.transfer;MT(l);let c=cc(s.image,px),u=cc(a.image,px);(o==="mvgd"||r==="pixel"||r==="primaries")&&(u.w!==c.w||u.h!==c.h)&&(u=fx(u,c.w,c.h));let p,d,m,h,g=0,y=0;if(r==="primaries"){let _=af(c,u),v=0;for(let $ of _)v+=$;let R,S=e.skinBoost??3;if(S>1){let $=await ix(u);g=$.length,R=ax(u,$);let U=$.reduce((E,z)=>E+Math.max(0,z.x1-z.x0)*Math.max(0,z.y1-z.y0)*z.score,0);y=Math.min(1,U/.05)}let T={weights:_,balanceOnly:!0,mixerRaw:e.mixer===!0};h=uf(c,u,T);let x=1+(S-1)*y;R&&x>1.05&&(h=uf(c,u,{...T,skinBoost:x,skinRegion:R,keepTone:h.cdl})),d=u,m=v/_.length}else if(r==="pixel"){let _=YT(c,u);p=_,d=u,m=_.trustedShare}else{let _=pc(c,u,o);p=QT(c,u,_,{tone1Contrast:null,enableTone2:!1,trimContrast:null}),d=_.image}let k=gc(c,d),b={itemId:e.item_id??"color-match",averaged:c,balanced:d,report:{},analysis:k.analysis,cdl:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},framesUsed:[s.frame],issues:[],transfer:l,sourceW:s.image.w,sourceH:s.image.h,totalMs:Date.now()-t,engine:"ai",transferred:!0,reference:u,seed:n?376436993:0,prompt:n?"balance (FLUX.2 klein, local)":"",matchMethod:r,fitResidual:h?.residual??p.residual,lumaStops:k.lumaStops,inferenceMs:i?.ms??0,facesDetected:g,skinWeighted:g>0,gradeStyle:h?"primaries":"fold",fold:p};if(h){let _=h.cdl;b.cdl={slope:_.slope,offset:_.offset,power:_.power,saturation:_.saturation,..._.mixer?{mixer:_.mixer,mixerLumaLock:_.mixerLumaLock}:{},wheels:{shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:_.contrast,pivot:_.pivot}}}let w=df(b);return{run:b,entries:w,method:r,transfer:l,source:{path:e.source,frame:s.frame,codec:s.codec,w:s.image.w,h:s.image.h},reference:{path:n?"FLUX.2 klein (local)":e.reference,w:a.image.w,h:a.image.h},residual:h?.residual??p.residual,lumaStops:k.lumaStops,ai:i,trustedShare:m,cst:e.cst?pf(e.cst):void 0}}function bx(e,t,n){return cx(e.run,t,n)}function yx(e,t){for(let n of e.timelines)for(let r of n.tracks)for(let o of r.items){if(o.id!==t)continue;return(o.effects??[]).find(i=>i.kind==="color_space_transform")?.parameters}}function wx(e,t){let n=[];for(let r of e.timelines)for(let o of r.tracks)for(let s of o.items)(s.id===t||s.name===t)&&n.push({timelineId:r.id??"",itemId:s.id,name:s.name??""});return n.length===1?n[0]:n.length>1?n.find(o=>o.itemId===t)??n[0]:null}var lo=e=>(Math.round(e*1e3)/1e3).toString(),Go=e=>e?`[${e.map(lo).join(", ")}]`:"\u2014";function kx(e){let t=[`source ${ie(e.source.path)} frame ${e.source.frame} (${e.source.codec}, ${e.source.w}x${e.source.h}, ${e.cst?`after the clip's CST ${e.cst}, `:""}${e.transfer}) \u2192 reference ${ie(e.reference.path)} (${e.reference.w}x${e.reference.h})`,`method ${e.method}; fit residual ${lo(e.residual)} (mean |chain \u2212 match|, 0\u20131 codes); luma ${e.lumaStops>=0?"+":""}${lo(e.lumaStops)} stops`,...e.ai?[`AI balance: FLUX.2 klein on this machine in ${(e.ai.ms/1e3).toFixed(1)} s; exposure held (model asked ${e.ai.askedStops>=0?"+":""}${lo(e.ai.askedStops)} stops, applied ${e.ai.appliedStops>=0?"+":""}${lo(e.ai.appliedStops)})`]:[],...e.method==="primaries"?[(n=>n.facesDetected?`skin: ${n.facesDetected} face${n.facesDetected>1?"s":""} found \u2014 skin protected (color only, contrast kept)`:"skin: no faces in the frame \u2014 plain balance")(e.run)]:[],"grade (Resolve node order \u2014 timeline_write resolve-drt emits them as corrector nodes):"];for(let n of e.entries){let r=n.cdl??{},o=n.enabled===!1?" (bypassed)":"",s=[r.slope?`slope ${Go(r.slope)}`:"",r.offset?`offset ${Go(r.offset)}`:"",r.power?`power ${Go(r.power)}`:"",r.mixer?`mixer ${Go(r.mixer)}`:"",r.saturation!=null?`sat ${lo(r.saturation)}`:"",r.contrast!=null?`contrast ${lo(r.contrast)} @ pivot ${lo(r.pivot??.435)}`:"",r.shadow?`wheels lift ${Go(r.shadow)} gamma ${Go(r.midtone)} gain ${Go(r.highlight)}`:""].filter(Boolean);t.push(`- ${n.label??n.id}${o}: ${s.join("; ")}`)}return t.join(`
|
|
308
|
-
`)}function fx(e,t,n){let r=new Float32Array(t*n*3);for(let o=0;o<n;o++){let s=Math.min(e.h-1,Math.floor((o+.5)*e.h/n));for(let i=0;i<t;i++){let a=Math.min(e.w-1,Math.floor((i+.5)*e.w/t)),l=(s*e.w+a)*3,c=(o*t+i)*3;r[c]=e.data[l],r[c+1]=e.data[l+1],r[c+2]=e.data[l+2]}}return{data:r,w:t,h:n}}var mf=960,qL=187.5/1023,_x={lift:100663320,gain:100663325,gamma:100663330,offset:100663421,contrast:2248147137,pivot:2248147136,shadow:2248147138,temp:2248147221,tint:2248147222};function vx(e){let t=[];for(let n of["lift","gain","gamma","offset","shadow"])e[n].forEach((r,o)=>t.push([_x[n]+o,r]));for(let n of["contrast","pivot","temp","tint"])t.push([_x[n],e[n]]);return t.sort((n,r)=>n[0]-r[0])}function Sx(e,t=`(3, ${e.h}, ${e.w})`){let n=`{'descr': '<f4', 'fortran_order': False, 'shape': ${t}, }`;for(;(10+n.length+1)%64;)n+=" ";n+=`
|
|
309
|
-
`;let r=e.w*e.h,o=new Uint8Array(10+n.length+12*r);o.set([147,78,85,77,80,89,1,0,n.length&255,n.length>>8]),o.set(new TextEncoder().encode(n),10);let s=new Float32Array(3*r);for(let i=0;i<r;i++)for(let a=0;a<3;a++)s[a*r+i]=e.data[i*3+a];return o.set(new Uint8Array(s.buffer),10+n.length),o}function UL(e,t=33){let n=new Float32Array(t*t*t*3);for(let r=0;r<t*t*t;r++)[Math.floor(r/(t*t)),Math.floor(r/t)%t,r%t].forEach((o,s)=>n[r*3+s]=-.15+1.5*o/(t-1));return Sx(qs({data:n,w:t*t*t,h:1},e),`(3, ${t}, ${t}, ${t})`)}var HL=["H","Q1","M","Q3","T"],wc=["clip","group_pre","group_post","adjustment_clips","timeline","output"],WL=`How do you build your grade? (color_prep look_levels=[...] lut_dirs=[...])
|
|
310
|
-
look_levels: where your look lives, any of: clip (nodes after your balance node in this tree), group_pre, group_post, adjustment_clips, timeline, output (an output LUT in project settings)
|
|
311
|
-
lut_dirs: the folders your LUTs and DCTLs live in (so I can read your DCTLs and find your LUTs; anything encrypted I bake through Resolve in a scratch project)`;async function $x(e,t,n,r,o,s){let i=await z1(await et(e));if(!i.ok)throw new L("invalid_args",`${ie(e)}: ${i.why}`);let a=i.nodes.map(m=>` node ${m.id}${m.label?` "${m.label}"`:""}${m.cst?` (Color Space Transform: ${m.cst_params?.inputColorSpace??"?"}/${m.cst_params?.inputGamma??"?"} -> ${m.cst_params?.outputColorSpace??"?"}/${m.cst_params?.outputGamma??"?"})`:""}`).join(`
|
|
312
|
-
`);if(t==null||n==null&&!s||!r?.length)return{ask:`${ie(e)} has ${i.nodes.length} nodes:
|
|
313
|
-
${a}
|
|
314
|
-
Which node is the BALANCE node, and which is the input Color Space Transform? (color_prep tree=\u2026 balance_node=<id> cst_node=<id>; if their input CST is not in this tree \u2014 in a group pre-clip grade or color management \u2014 give working="<SPACE>_COLORSPACE/<CURVE>_GAMMA" for the space this tree works in instead of cst_node)
|
|
315
|
-
${WL}`};if(!i.nodes.find(m=>m.id===t))throw new L("invalid_args",`${ie(e)} has no node ${t}:
|
|
316
|
-
${a}`);let c;if(n!=null){let m=i.nodes.find(h=>h.id===n);if(!m?.cst)throw new L("invalid_args",`node ${n} is not a Color Space Transform node:
|
|
317
|
-
${a}`);if(c=m.cst_params??{},!c.outputColorSpace||!c.outputGamma)throw new L("invalid_args",`node ${n}'s CST does not say its output (working) space; set it in Resolve and export the still again`)}else{let[m,h]=s.split("/").map(g=>g.trim());if(!m?.endsWith("_COLORSPACE")||!h?.endsWith("_GAMMA"))throw new L("invalid_args",`working '${s}': give <SPACE>_COLORSPACE/<CURVE>_GAMMA (Resolve CST names, e.g. DWG_COLORSPACE/DAV_INTER_OETF_GAMMA)`);c={outputColorSpace:m,outputGamma:h}}let u=r.filter(m=>!wc.includes(m));if(u.length)throw new L("invalid_args",`look_levels ${u.join(", ")}: use ${wc.join(", ")}`);let p={name:ie(e),body_hex:i.body_hex,nodes:i.nodes,balance_node:t,...n!=null?{cst_node:n}:{},working:{space:String(c.outputColorSpace),gamma:String(c.outputGamma)},look_levels:r,lut_dirs:o},d=await Js();return await eg({...d,color_tree:p}),{tree:p}}async function Rx(){return(await Js()).color_tree??null}async function Cx(e){let t=await ko();if(!t)throw new L("unsupported","the native decoder (conformtools-decode) is not installed");let n=[],r=await cr(t,e,i=>n.push(i)),o=new Uint8Array(n.reduce((i,a)=>i+a.length,0)),s=0;for(let i of n)o.set(i,s),s+=i.length;return{out:o,...r}}async function Tx(e){let t=await Cx(["colour",e]).catch(n=>({code:1,out:new Uint8Array,stderr:String(n?.message??n)}));return t.code!==0?{kind:"unknown",evidence:`could not read it (${t.stderr.trim().slice(0,200)})`,confident:!1}:JSON.parse(new TextDecoder().decode(t.out))}function xx(e,t){let n=e?.find(i=>t.some(a=>a.toLowerCase().includes(i.match.toLowerCase())));if(!n)return null;let r=n.as.trim();if(/^(graphic|none|skip)$/i.test(r))return{kind:"graphic",evidence:`you said: ${r}`,confident:!0};if(/^rec\.?709$/i.test(r))return{kind:"display",color_space:"REC709_COLORSPACE",gamma:"TWOPOINTFOUR_GAMMA",evidence:"you said: Rec.709",confident:!0};let[o,s]=r.split("/").map(i=>i.trim());if(!o?.endsWith("_COLORSPACE")||!s?.endsWith("_GAMMA"))throw new L("invalid_args",`color answer '${r}' for '${n.match}': give graphic, rec709, or <SPACE>_COLORSPACE/<CURVE>_GAMMA (Resolve CST names)`);return{kind:/709|SRGB|2020/.test(s)||s==="TWOPOINTFOUR_GAMMA"?"display":"log",color_space:o,gamma:s,evidence:`you said: ${r}`,confident:!0}}function zL(e,t){let n=t.tracks.filter(u=>u.kind==="Video"),r=Is(t,n),o=new Map(e.media_references.map(u=>[u.id,u])),s=t.fps_den?t.fps_num/t.fps_den:t.fps_num,i=new Map;for(let u of r){let p=u.it,d=p.media_reference_id?o.get(p.media_reference_id):void 0,m=d?.local_path??d?.target_url?.replace(/^file:\/\//,"");if(!m||!p.source_range)continue;let h=(t.start_frame??0)+p.timeline_range.start.value,g=i.get(p.id);if(g){g.rec1=Math.max(g.rec1,u.e);continue}let y=d.source_timecode,k=y?y.split(/[:;]/).map(Number).reduce((b,w,_)=>_<3?b*60+w:b*Math.round(s)+w,0):0;i.set(p.id,{item:p,path:m,name:p.name??ie(m),colour:{kind:"unknown",evidence:"",confident:!1},rec0:u.s,rec1:u.e,src0:p.source_range.start.value+(u.s-h),camFrame:k+p.source_range.start.value,fps:s})}let a=[...i.values()].sort((u,p)=>u.rec0-p.rec0),l=new Set(a.map(u=>u.item.id)),c=n.flatMap(u=>u.items).filter(u=>u.kind==="clip"&&!l.has(u.id)&&u.media_reference_id);return{shots:a,hidden:c}}function GL(e,t){let n=e.start_frame??0,r=e.tracks.flatMap(a=>a.items).filter(a=>a.kind==="transition").map(a=>({s:n+a.timeline_range.start.value,e:n+a.timeline_range.start.value+a.timeline_range.duration.value})),o=a=>r.some(l=>a>=l.s-1&&a<=l.e),s=0,i=t.rec1-t.rec0-1;for(;s<i&&o(t.rec0+s);)s++;for(;i>s&&o(t.rec0+i);)i--;return HL.map((a,l)=>({key:a,src:t.src0+Math.round(s+(i-s)*l/4)}))}async function KL(e,t,n){let r={outputColorSpace:n.space,outputGamma:n.gamma,doFwdOOTF:0},o="";if(/\.mxf$/i.test(e.path)){let s=await Cx(["logframe",e.path,String(t),String(mf)]);if(s.code!==0&&/not an X-OCN/.test(s.stderr)&&(o="h264"),s.code===0){let i=s.out.indexOf(10),a=JSON.parse(new TextDecoder().decode(s.out.subarray(0,i))),l=new Float32Array(s.out.slice(i+1).buffer);return qs({data:l,w:a.w,h:a.h},{inputColorSpace:a.color_space,inputGamma:a.gamma,...r,doInvOOTF:0})}}if(e.colour.kind==="log"&&/\.(r3d|braw|ari|arx|crm)$/i.test(e.path))return null;try{let s=await ha(e.path,t,o,mf),i=new Float32Array(s.width*s.height*3);for(let l=0,c=0;l<i.length;l+=3,c+=4)i[l]=s.rgba[c]/255,i[l+1]=s.rgba[c+1]/255,i[l+2]=s.rgba[c+2]/255;let a=VL({data:i,w:s.width,h:s.height},mf);return qs(a,{inputColorSpace:e.colour.color_space,inputGamma:e.colour.gamma,...r,doInvOOTF:e.colour.kind==="display"?1:0})}catch{return null}}function VL(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));if(n>=1)return e;let r=Math.round(e.w*n),o=Math.round(e.h*n),s=new Float32Array(r*o*3);for(let i=0;i<o;i++){let a=Math.floor(i*e.h/o),l=Math.max(a+1,Math.floor((i+1)*e.h/o));for(let c=0;c<r;c++){let u=Math.floor(c*e.w/r),p=Math.max(u+1,Math.floor((c+1)*e.w/r));for(let d=0;d<3;d++){let m=0;for(let h=a;h<l;h++)for(let g=u;g<p;g++)m+=e.data[(h*e.w+g)*3+d];s[(i*r+c)*3+d]=m/((l-a)*(p-u))}}}return{data:s,w:r,h:o}}var JL=e=>({inputColorSpace:e.space,inputGamma:e.gamma,outputColorSpace:"REC709_COLORSPACE",outputGamma:"TWOPOINTFOUR_GAMMA",doFwdOOTF:1,doInvOOTF:0});async function Ex(e,t){let n=t.progress??(()=>{}),r=e.timelines.find(g=>!t.timeline||g.id===t.timeline||g.name===t.timeline)??e.timelines[0];if(!r)throw new L("not_found","no timeline in this session");let{shots:o,hidden:s}=zL(e,r),i=new Map;for(let g of o)n(`reading color metadata: ${g.name}`),g.colour=xx(t.answers,[g.name,ie(g.path)])??i.get(g.path)??await Tx(g.path),i.set(g.path,g.colour);let a=o.filter(g=>g.colour.kind==="unknown"||!g.colour.confident);if(a.length){let g=new Map;for(let k of a){let b=k.path.split("/").slice(-3,-1).join("/");g.set(b,[...g.get(b)??[],k])}return{text:`Before I build the color prep I need to know what these clips are (nothing is written until then):
|
|
318
|
-
${[...g.entries()].map(([k,b])=>` ${k}: ${b.length} clip(s), e.g. ${b[0].name} \u2014 ${b[0].colour.evidence}${b[0].colour.color_space?` (tags say ${b[0].colour.color_space}/${b[0].colour.gamma})`:""}`).join(`
|
|
319
|
-
`)}
|
|
320
|
-
Answer with answers=[{match:"<part of the file or folder name>", as:"rec709" | "graphic" | "<SPACE>_COLORSPACE/<CURVE>_GAMMA"}].`,data:{questions:a.map(k=>({item:k.item.id,name:k.name,path:k.path,...k.colour}))},ops:[]}}let l=o.filter(g=>g.colour.kind!=="graphic"),c=[];if(t.balance!==!1&&l.length){let g=qi();if(g)throw new L("unsupported",`${g}; run with balance=false for the tree and CSTs only`);let y=await Ir(),k=y&&await H_(y)&&await W_(y);if(!k&&!t.download)throw new L("refused",y?"the balance needs the AI pack's new models (step 1's exposure LoRAs, step 2's shot-to-shot models; up to ~2.8 GB): ask the user, then download=true; or balance=false for the tree and CSTs only":"the balance needs the local AI pack (one-time download, ~4.4 GB): ask the user, then download=true; or balance=false for the tree and CSTs only");let b=k?y:await Jl({onProgress:n}),w=await Dt("conform-prep-"),_=t.tree.working.space==="DWG_COLORSPACE"&&t.tree.working.gamma==="DAV_INTER_OETF_GAMMA";_||c.push(`shot-to-shot consistency skipped: it measures in DaVinci Wide Gamut / Intermediate and your tree works in ${t.tree.working.space}/${t.tree.working.gamma}; step 1 (the AI balance) only`);let v=_&&l.length>1?{look_tree:{body_hex:t.tree.body_hex,balance_node:t.tree.balance_node,lut_roots:t.tree.lut_dirs??[],dctl_roots:t.tree.lut_dirs??[]},loma:B(b.model,"loma_b.safetensors"),eomt:B(b.model,"eomt_l_ade.safetensors"),face_models:b.model}:null,R=JL(t.tree.working),S=B(w,"view_lut.npy");await cn(S,UL(R));let T=await K_(b,v,void 0,S),x=0,$=!!v;try{let U=ve=>KL(ve,GL(r,ve).find(oe=>oe.key==="M").src,t.tree.working),z=l.slice(0,3).map(U),G=async ve=>{let oe;try{oe=await ve.ai}catch(M){c.push(`${ve.s.name}: the AI balance failed, CST set, no balance: ${M.message.slice(0,200)}`);return}let P=ve.s;if(P.knobs=oe.values,P.raw=vx(P.knobs),P.step1=P.offset=P.knobs.offset.map(M=>M*qL),$){let M=oe.ms;D.push(T.shot({id:P.item.id,take:P.path,family:P.colour.color_space??"unknown",date:"",tod:P.camFrame/P.fps,frame:P.npy,base:P.knobs}).then(O=>{x++,en("CONFORM_PREP_TIMING")&&console.error(`prep-timing klein_ms ${M} shot_ms ${O} ${P.name}`)}).catch(O=>{$&&c.push(`shot-to-shot consistency failed, step 1 only: ${O.message.slice(0,300)}`),$=!1}))}},D=[],te=null,we=en("CONFORM_PREP_TIMING")?(ve,oe)=>console.error(`prep-timing ${ve} ${Math.round(performance.now()-oe)}`):()=>{};for(let[ve,oe]of l.entries()){n(`balance ${ve+1}/${l.length}: ${oe.name}`);let P=performance.now(),M=await z.shift();if(we("decode_wait",P),P=performance.now(),ve+3<l.length&&z.push(U(l[ve+3])),!M){c.push(`${oe.name}: could not decode to its log here (raw developer missing); CST set, no balance`);continue}oe.npy=B(w,`${oe.item.id}.npy`),await cn(oe.npy,Sx(M));let O={s:oe,ai:T.step1(oe.npy)};O.ai.catch(()=>{}),we("npy_view",P),P=performance.now(),te&&await G(te),we("finish_prev",P),te=O}te&&await G(te),await Promise.all(D);let ge=l.filter(ve=>ve.step1&&ve.npy);if($&&x>1){n(`shot-to-shot consistency (V7-1): matching and deciding over ${x} shots`);try{let ve=await T.finish();for(let P of ge){let M=ve.shots[P.item.id];M?.moved&&M.values&&(P.raw=vx(M.values),P.moved=!0)}c.push(`shot-to-shot consistency (V7-1): ${ge.filter(P=>P.moved).length} of ${ge.length} shots nudged (${ve.moves.length} moves, ${ve.reverted.length} undone by the no-harm check), fitted through your tree's look after the balance node`);let oe=(t.tree.look_levels??[]).filter(P=>P!=="clip");oe.length&&c.push(`your look also lives in ${oe.join(", ")}: not evaluated yet (that needs the project export, .drp/.drt); the fit sees only the clip tree's part`),c.push(...ve.notes.slice(0,20))}catch(ve){c.push(`shot-to-shot consistency failed, step 1 only: ${ve.message.slice(0,300)}`)}}}finally{T.close(),await Ht(w).catch(()=>{})}}let u=[],p=(g,y,k)=>({timeline_id:r.id,item_id:g.item.id,entry:{id:"color-prep",kind:"tree",label:"Color prep",enabled:!0,meta:{tree:t.tree.body_hex,balance_node:t.tree.balance_node,...t.tree.cst_node!=null?{cst_node:t.tree.cst_node,cst:{inputColorSpace:g.colour.color_space,inputGamma:g.colour.gamma,doInvOOTF:g.colour.kind==="display"?1:0}}:{},...k?{raw:k}:y?{printer:y}:{}}}});for(let g of o)u.push(g.colour.kind==="graphic"?{timeline_id:r.id,item_id:g.item.id,remove_id:"color-prep"}:p(g,g.offset,g.raw));for(let g of s){let y=(r.start_frame??0)+g.timeline_range.start.value+g.timeline_range.duration.value/2,k=o.find(v=>v.rec0<=y&&y<v.rec1),b=e.media_references.find(v=>v.id===g.media_reference_id),w=b?.local_path??b?.target_url?.replace(/^file:\/\//,"")??"",_=xx(t.answers,[g.name??"",ie(w)])??i.get(w)??(w?await Tx(w):null);!_||_.kind==="graphic"||_.kind==="unknown"||!_.confident||u.push(p({item:g,colour:_},k?.offset,k?.raw))}let d=g=>o.filter(y=>y.colour.kind===g).length,m=[...new Set(l.map(g=>`${g.colour.color_space}/${g.colour.gamma}`))];return{text:[`color prep on ${r.name}: your tree "${t.tree.name}" (balance node ${t.tree.balance_node}, ${t.tree.cst_node!=null?`CST node ${t.tree.cst_node}`:"input CST outside the tree: not written, yours stays"}, working ${t.tree.working.space}/${t.tree.working.gamma})`,`${d("log")} log, ${d("display")} Rec.709-type, ${d("graphic")} graphics/stills left ungraded`,`input CSTs: ${m.join(", ")||"none"}`,...t.balance===!1?["balance: skipped (balance=false)"]:c,"nothing written yet: timeline_write target=resolve-drt writes the .drt (a separate file; the user's project is untouched)"].join(`
|
|
321
|
-
`),data:{shots:o.map(g=>({item:g.item.id,name:g.name,colour:g.colour,offset:g.offset,consistency:g.moved?g.raw:void 0}))},ops:u}}import{execFile as Fx,execFileSync as Ox,spawn as XL}from"node:child_process";import{createServer as QL}from"node:http";import{open as YL,readdir as ZL,stat as Lx}from"node:fs/promises";import{basename as Nx,join as eN,relative as tN}from"node:path";var Zi=2048,nN=4<<20,Ax=6e4,bf=e=>e?e.direct?`direct (${e.addr}, ${e.rtt_ms} ms)`:`through a relay (${e.addr.replace(/^Relay\((.*)\)$/,"$1")}, ${e.rtt_ms} ms): slower`:"connecting";async function rN(){let e=ln()==="win32"?"i2o-transfer.exe":"i2o-transfer",t=[en("CONFORM_P2P"),Tf(e),mo(new URL(`./${e}`,import.meta.url)),mo(new URL(`../../native-host/i2o-transfer/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await Fn(n))return n;return null}var oN=e=>Buffer.from(JSON.stringify(e)).toString("base64url");function kr(e){let t=JSON.parse(Buffer.from(e.trim(),"base64url").toString());if(t.v!==1||!t.node_id||!Array.isArray(t.files))throw new Error("not a conform.tools peer-to-peer ticket");return t}async function Dx(e,t){let n=await rN();if(!n)throw new Error(xf("the peer-to-peer engine (i2o-transfer)"));let r=XL(n,[],{stdio:["pipe","pipe","pipe"]}),o="";r.stdout.on("data",i=>{o+=i.toString();for(let a;(a=o.indexOf(`
|
|
322
|
-
`))>=0;){let l=o.slice(0,a).trim();if(o=o.slice(a+1),l)try{t(JSON.parse(l))}catch{}}}),r.stderr.on("data",()=>{});let s=i=>r.stdin.write(JSON.stringify(i)+`
|
|
323
|
-
`);return s(e),{child:r,send:s,stop:()=>r.kill()}}async function jx(e){return(await Lx(e)).isDirectory()?(await ZL(e,{recursive:!0,withFileTypes:!0})).filter(n=>n.isFile()&&!n.name.startsWith(".")).map(n=>eN(n.parentPath,n.name)).sort().map(n=>({path:n,name:tN(e,n).split("\\").join("/")})):[{path:e,name:Nx(e)}]}async function yf(e,t={}){let n=d=>Promise.all(d.map(m=>typeof m=="string"?{path:m,name:Nx(m)}:m).map(async m=>({...m,size:(await Lx(m.path)).size}))),r=await n(e),o=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("hex"),s=!1,i,a,l=new Promise(d=>{a=d}),c=async()=>{let d,m,h=new Promise((b,w)=>{d=b,m=w}),g=await Dx({type:"start-sender",files:r,secret_key:o},b=>{b.type==="endpoint-ready"?d(oN({v:1,node_id:String(b.node_id),relay_url:b.relay_url??null,addrs:b.addrs??[],files:r.map(({name:w,size:_})=>({name:w,size:_})),...r.length===1&&/\.iso$/i.test(r[0].name)?{iso:!0}:{},...t.label?{label:t.label}:{}})):b.type==="path"?t.onPath?.(b):b.type==="error"&&!String(b.error).startsWith("[debug]")&&m(new Error(String(b.error)))});i=g;let y=!1;g.child.on("exit",b=>{if(s)return a();if(!y)return m(new Error(`peer-to-peer sender exited (${b}) before its endpoint was ready`));c().catch(()=>a())});let k=await h;return y=!0,k};return{ticket:await c(),stop:()=>{s=!0,i?.stop()},closed:l,add:async d=>{let m=(await n(d)).filter(h=>!r.some(g=>g.name===h.name));return m.length?(r.push(...m),i?.send({type:"add-sender-files",files:m}),m.length):0}}}var ff=257,sN=4096,iN=2e4,Ix=e=>{let t=[];for(let n of[...e].sort((r,o)=>r[0]-o[0])){let r=t[t.length-1];r&&n[0]<=r[1]?r[1]=Math.max(r[1],n[1]):t.push([n[0],n[1]])}return t},Mx=(e,t,n)=>{let r=[],o=e;for(let[s,i]of n)if(!(i<=o)){if(s>=t)break;s>o&&r.push([o,s]),o=Math.max(o,i)}return o<t&&r.push([o,t]),r};async function wf(e,t,n={}){let r=kr(e),o=n.volume??"CONFORM_P2P",s=r.files.map(oe=>({name:oe.name,size:oe.size})),i=await YL(t,"w+"),a=[],l=[],c=[],u=0,p=0,d=async oe=>{for(let M of oe)c[M]=u,u+=Math.ceil(s[M].size/Zi);let P;try{P=await Di(s.map((M,O)=>({name:M.name,totalSize:M.size,fixedPartSector:c[O]})),o)}catch(M){throw new Error(`can't add ${oe.length} more file(s) to this mount: ${M.message}. Mount it again to see them`)}(await i.stat()).size<P.totalBytes&&await i.truncate(P.totalBytes);for(let M of P.structuralRegions)await i.write(M.data,0,M.data.length,M.sectorStart*Zi);for(let M of oe)a[M]=(ff+c[M])*Zi;l.push({regions:P.structuralRegions,totalBytes:P.totalBytes,files:s.length})};if(r.iso)await i.truncate(s[0].size),a.push(0),l.push({regions:[],totalBytes:s[0].size,files:1});else{let oe=await Di(s.map(M=>({name:M.name,totalSize:M.size})),o);u=2*(Math.min(oe.totalSectors-1,...oe.fileDataRegions.map(M=>M.sectorStart))-ff)+sN,p=(ff+u)*Zi,await d(s.map((M,O)=>O))}let m=()=>s.reduce((oe,P)=>oe+P.size,0),h=oe=>[a[oe],a[oe]+s[oe].size],g=[],y=(oe,P,M=s.length)=>{let O=0;for(let V=0;V<M;V++){let[fe,xe]=h(V),Oe=Math.max(fe,oe),De=Math.min(xe,P);if(De>Oe)for(let[ze,Q]of Mx(Oe,De,g))O+=Q-ze}return O},k=[],b=0,w,_=new Promise((oe,P)=>{w=M=>M?P(M):oe()});m()===0&&w();let v=(oe,P)=>{g=Ix([...g,[oe,P]]),b=m()-y(0,1/0),n.onProgress?.(b,m());for(let M of[...k])y(M.a,M.b,M.n)||(k.splice(k.indexOf(M),1),M.ready());b>=m()&&w()},R=!1,S,T=null,x=[],$=(oe,P)=>{if(!S)return;let M=Date.now();x=x.filter(([,,O])=>M-O<iN);for(let[O,V]of Mx(oe,P,Ix([...g,...x.map(([fe,xe])=>[fe,xe])])))S.send({type:"need-bytes",offset:O,length:V-O}),x.push([O,V,M])},U=(oe,P,M=s.length)=>y(oe,P,M)?new Promise((O,V)=>{let fe={a:oe,b:P,n:M,ready:()=>{clearTimeout(xe),O()}},xe=setTimeout(()=>{k.splice(k.indexOf(fe),1),V(new Error(`bytes ${oe}-${P} didn't arrive in ${Ax/1e3} s`))},Ax);k.push(fe);for(let Oe=0;Oe<M;Oe++){let[De,ze]=h(Oe),Q=Math.max(De,oe),me=Math.min(ze,Math.max(P,oe+nN));me>Q&&$(Q,me)}}):Promise.resolve(),E=QL((oe,P)=>void z(oe,P).catch(()=>{P.headersSent||(P.statusCode=503),P.end()})),z=async(oe,P)=>{if(R)return P.writeHead(503).end();let M=new URL(oe.url??"/","http://x");if(oe.method==="POST"){let De=Number(M.searchParams.get("offset")),ze=[];for await(let me of oe)ze.push(me);let Q=Buffer.concat(ze);return await i.write(Q,0,Q.length,De),v(De,De+Q.length),P.end("ok")}let O=l[Number(/^\/disk(?:_v(\d+))?\.iso$/.exec(M.pathname)?.[1]??(M.pathname==="/disk.iso"?1:0))-1];if(!O)return P.writeHead(404).end();let V=/bytes=(\d+)-(\d*)/.exec(oe.headers.range??""),fe=V?Number(V[1]):0,xe=V&&V[2]?Math.min(Number(V[2])+1,O.totalBytes):O.totalBytes;if(oe.method==="GET"&&await U(fe,xe,O.files),P.writeHead(V?206:200,{"Accept-Ranges":"bytes","Content-Length":xe-fe,...V?{"Content-Range":`bytes ${fe}-${xe-1}/${O.totalBytes}`}:{}}),oe.method==="HEAD")return P.end();let Oe=Buffer.alloc(xe-fe);await i.read(Oe,0,Oe.length,fe),fe<p&&Oe.fill(0,0,Math.min(xe,p)-fe);for(let De of O.regions){let ze=De.sectorStart*Zi,Q=Math.max(fe,ze),me=Math.min(xe,ze+De.data.length);me>Q&&Oe.set(De.data.subarray(Q-ze,me-ze),Q-fe)}P.end(Oe)};await new Promise(oe=>E.listen(0,"127.0.0.1",oe));let G=E.address().port,D=Promise.resolve(),te=oe=>{r.iso||oe.length<=s.length||s.some((P,M)=>oe[M]?.name!==P.name)||(D=D.then(async()=>{let P=s.length;if(oe.length<=P)return;s.push(...oe.slice(P).map(O=>({name:O.name,size:O.size})));let M=s.map((O,V)=>V).slice(P);await d(M),S.send({type:"update-file-offsets",fileOffsets:a,fileSizes:s.map(O=>O.size),senderMapping:s.map((O,V)=>V<P?-2:-3)}),n.onGrow?.(l.length,M)}).catch(P=>{we=P.message}))},we=null;S=await Dx({type:"start-receiver",http_port:G,iso_path:t,file_offsets:a,peer_node_id:r.node_id,peer_relay_url:r.relay_url,peer_addrs:r.addrs},oe=>{oe.type==="path"?T=oe:oe.type==="manifest"?te(oe.files):oe.type==="error"&&!String(oe.error).startsWith("[debug]")&&w(new Error(String(oe.error)))}),S.send({type:"volume-mounted"}),S.child.on("exit",oe=>{!R&&b<m()&&w(new Error(`peer-to-peer receiver exited (${oe}) with ${b} of ${m()} bytes`))});let ge=async()=>{if(R=!0,S&&S.child.exitCode===null){let oe=new Promise(P=>S.child.once("exit",()=>P()));S.send({type:"cancel"}),await Promise.race([oe,new Promise(P=>setTimeout(P,2e3))]),S.stop()}E.close(),await i.close()};_.catch(()=>{});let ve=`http://127.0.0.1:${G}`;return{t:r,files:s,offsets:a,done:_,close:ge,daemon:S,ensure:U,fh:i,ask:$,url:(oe=1)=>`${ve}/${oe===1?"disk":`disk_v${oe}`}.iso`,get version(){return l.length},get size(){return l[l.length-1].totalBytes},get total(){return m()},get have(){return b},get path(){return T},get grewError(){return we}}}async function Bx(e,t,n={}){let r=n.chunk??8388608,o,s=i=>{let[a,l]=[o.offsets[i],o.files[i]];for(let c=0;c<l.size;c+=r)o.ask(a+c,a+Math.min(c+r,l.size))};o=await wf(e,t,{onProgress:n.onProgress,onGrow:(i,a)=>{o&&a.forEach(s)}}),n.signal?.addEventListener("abort",()=>void o.close());try{return o.files.forEach((i,a)=>s(a)),await o.done,{path:t,bytes:o.have,files:o.files.length}}finally{await o.close()}}var hf=(e,t)=>new Promise((n,r)=>Fx(e,t,(o,s,i)=>o?r(new Error(String(i||o.message).trim())):n(String(s)))),gf=e=>new Promise(t=>Fx("/usr/bin/hdiutil",["detach",e,"-force"],t)),kc=new Map,Px=!1;function aN(e,t){if(kc.set(e,t),!Px){Px=!0,process.on("exit",()=>{for(let n of kc.values())for(let r of[...n].reverse())try{Ox("/usr/bin/hdiutil",["detach",r,"-force"],{stdio:"ignore",timeout:5e3})}catch{}});for(let n of["SIGINT","SIGTERM","SIGHUP"])process.once(n,()=>process.exit(128+{SIGHUP:1,SIGINT:2,SIGTERM:15}[n]))}}async function lN(){let e;try{e=JSON.parse(Ox("/bin/sh",["-c","/usr/bin/hdiutil info -plist | /usr/bin/plutil -convert json -o - -"],{encoding:"utf8",timeout:1e4}))}catch{return[]}let t=new Set([...kc.values()].flat()),n=[];for(let r of e.images??[]){let o=r["image-path"]??"";if(!/^http:\/\/127\.0\.0\.1:\d+\/disk(_v\d+)?\.iso$/.test(o))continue;let s=r["system-entities"]??[],i=s.find(c=>c["mount-point"])?.["mount-point"],a=s[0]?.["dev-entry"];!a||t.has(a)||await fetch(o,{method:"HEAD",signal:AbortSignal.timeout(1500)}).then(()=>!0,()=>!1)||(await gf(a),n.push(i??a))}return n}var cN=e=>e.normalize("NFKD").replace(/[^A-Za-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"CONFORM_P2P";async function qx(e,t,n={}){if(ln()!=="darwin")throw new Error("live mount needs macOS (hdiutil attaches the image over HTTP); use p2p_receive elsewhere");await lN();let r=0,o="",s=null,i,a=[],l=new Promise(h=>{i=h}),c=async h=>{if(h<=r)return;let g=/\/dev\/disk\d+/.exec(await hf("/usr/bin/hdiutil",["attach",u.url(h),"-nomount","-readonly","-noverify","-noautoopen"]))?.[0];if(!g)throw new Error("hdiutil attached nothing");try{await hf("/sbin/mount",["-t","udf","-r","-o","nobrowse",g,o])}catch(y){throw await gf(g),y}a.push(g)},u=await wf(e,t,{volume:cN(n.volume??"CONFORM_P2P"),onGrow:h=>{l=l.then(()=>c(h)).catch(g=>{s=`files added, but not shown: ${g.message}`})}});try{r=u.version;let h=await hf("/usr/bin/hdiutil",["attach",u.url(r),"-readonly","-noverify","-noautoopen"]);o=h.trim().split(`
|
|
324
|
-
`).map(y=>y.split(" ").pop().trim()).filter(y=>y.startsWith("/")).pop()??"";let g=/\/dev\/disk\d+/.exec(h)?.[0];if(!o||!g)throw new Error(`hdiutil attached nothing: ${h}`);a.push(g)}catch(h){throw await u.close(),h}aN(o,a),i();let d={at:Date.now(),have:u.have},m=0;return{mountpoint:o,path:t,status:()=>{let h=Date.now();return h-d.at>=1e3&&(m=(u.have-d.have)/((h-d.at)/1e3),d={at:h,have:u.have}),{path:u.path,files:u.files.length,fetched:u.have,total:u.total,rate:m,error:u.grewError??s}},stop:async()=>{await l.catch(()=>{});for(let h of[...a].reverse())await gf(h);kc.delete(o),await u.close()}}}async function Ux(e,t){if(!kr(e).iso)throw new Error("this ticket serves files, not a delivery .iso \u2014 use mount, or receive it whole");let n=await wf(e,t),r=n.size;return{read:async(o,s)=>{let i=Math.max(0,Math.min(s,r-o));await n.ensure(o,o+i);let a=new Uint8Array(i);return await n.fh.read(a,0,i,o),a},write:()=>Promise.reject(new Error("a peer's .iso is read-only")),getSize:async()=>r,size:()=>r,close:()=>n.close()}}var uN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function kf(e){let t=e.trim();if(t.startsWith("bucket:"))return{kind:"bucket",session_id:t.slice(7)};if(uN.test(t))return{kind:"bucket",session_id:t};if(/\.iso$/i.test(t)||t.includes("/")||t.includes("\\"))return{kind:"file",path:Nt(t)};try{return kr(t),{kind:"peer",ticket:t}}catch{}throw new Error(`"${e.slice(0,40)}\u2026" is not a .iso path, a bucket delivery (bucket:<id>) or a p2p_send ticket`)}async function _f(e){let{files:t}=await Jt("v1-sessions",`/v1/sessions/${e}/files`),n=t.find(r=>r.chunks?._format==="iso"&&r.chunks.b2FileName);if(!n)throw new Error(`delivery ${e} has no .iso in its bucket`);return n}async function _c(e,t){if(e.kind==="file")return Object.assign(await jo(e.path),{name:ie(e.path)});if(e.kind==="peer"){let o=kr(e.ticket);return Object.assign(await Ux(e.ticket,B(t,o.files[0]?.name??"peer.iso")),{name:o.files[0]?.name??"peer.iso"})}let n=await _f(e.session_id),r=zs(e.session_id);return Object.assign(await hm(()=>r.readUrl(n.chunks.b2FileName)),{name:n.file_name})}async function dN(){let{storage:e}=await Jt("v1-me","/v1/me/storage");if(!e)throw new Error("your org has no bucket set up \u2014 the org owner adds one on conform.tools (Settings \u2192 Storage) or PUT /v1/me/storage");return e}var Hx=()=>B(Xe(),"bucket-index");async function pN(e,t,n=50){let{sessions:r}=await Jt("v1-sessions",`/v1/sessions?limit=${n}`),o=[];await Ke(Hx());let s=r.filter(i=>i.id!==t);return await Promise.all(Array.from({length:6},async()=>{for(let i=s.shift();i;i=s.shift())try{let l=(await _f(i.id)).chunks;if(!l.blocksKey||l.bucket!==e)continue;let c=B(Hx(),`${i.id}-${l.isoSize}.json`),u;try{u=JSON.parse(await et(c))}catch{let p=await zs(i.id).readUrl(l.blocksKey),d=await fetch(p);if(!d.ok)continue;u=await d.json(),await Ve(c,JSON.stringify(u))}u.size===l.isoSize&&o.push({key:l.b2FileName,index:u})}catch{}})),o}async function Wx(e,t,n){let r=await Jt("v1-sessions",`/v1/sessions/${e}/storage/upload-url`,{body:{key:t,content_type:"application/json",content_length:n.length}}),o=await fetch(r.upload_url,{method:r.method,headers:r.headers,body:n});if(!o.ok)throw new Error(`saving ${t}: ${o.status} ${(await o.text()).slice(0,200)}`)}async function zx(e,t,n){let r=await w_(t,n);r.timelines.length&&await Jt("v1-sessions",`/v1/sessions/${e}/contents`,{body:{projects:[],timelines:r.timelines,media:r.media,delivery_intent:{format:"folder",folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:r.handles}}})}async function Gx(e,t={}){let n=await dN(),r=await jo(e),o=Jf(e);try{let s=await _r(r),i=ie(e);t.onProgress?.(0,r.size(),"indexing the image");let a=0,l=await Pc(r,s,r.size(),b=>t.onProgress?.(a+=b,r.size(),"indexing the image")),{session:c}=await Jt("v1-sessions","/v1/sessions",{body:{destination:"b2",storage:"org",status:"ready",label:t.label??i.replace(/\.iso$/i,""),...t.recipients?.length?{recipient_emails:t.recipients}:{}}}),u=c.id,p=`sessions/${u}/${i}`,d=t.dedupe===!1?[]:await pN(n.bucket,u),m=Vf(l,d),h=Mc(r.size(),m),g=(t.bucket??zs)(u),y=await Fc(g,p,h,o.read,{onProgress:(b,w)=>t.onProgress?.(b,w,"uploading"),signal:t.signal}),k=`${p}.blocks.json`;return await Wx(u,k,new TextEncoder().encode(JSON.stringify(l))),await Jt("v1-sessions",`/v1/sessions/${u}/files`,{body:{files:[{file_name:i,file_size:r.size(),status:"completed",chunks:{_format:"iso",b2FileName:p,isoSize:r.size(),blocksKey:k,bucket:n.bucket,files:s.files.filter(b=>!b.name.startsWith(`${to}/`)).map(b=>({name:b.name,size:b.totalSize}))}}]}}),await zx(u,r,s),await Jt("v1-sessions",`/v1/sessions/${u}`,{method:"PATCH",body:{status:"completed"}}),{session_id:u,key:p,image:r.size(),uploaded:y.uploaded,copied:y.copied,reused_from:new Set(m.map(b=>b.key)).size}}finally{await o.close(),await r.close()}}async function Kx(e,t,n={}){if(e.kind==="peer")throw new Error("a peer's delivery is read-only \u2014 add_to a .iso on disk or a bucket delivery");if(e.kind==="file"){let u=await bm(e.path,t),p=await jo(e.path),d=p.size();return await p.close(),{...u,image:d}}let r=e.session_id,o=await _f(r),s=o.chunks.b2FileName,i=(n.bucket??zs)(r),a=await hm(()=>i.readUrl(s)),l=await Dt("conform-grow-"),c=await __(a,B(l,"overlay"));try{n.onProgress?.(0,0,"patching");let u=await bm(c,t);if(!c.writes().length)return{...u,uploaded:0,copied:0,image:a.size()};let p=Mc(c.size(),Kf(s,a.size(),c.size(),c.writes())),d=await Fc(i,s,p,c.read,{onProgress:(w,_)=>n.onProgress?.(w,_,"writing back"),signal:n.signal}),m=await _r(c),h=o.chunks.blocksKey?await fetch(await i.readUrl(o.chunks.blocksKey)).then(w=>w.ok?w.json():null).catch(()=>null):null,g=new Map((h?.blocks??[]).map(w=>[`${w[1]}:${w[2]}`,w])),y=(w,_)=>c.writes().some(v=>v.offset<w+_&&v.offset+v.length>w),{blocks:k}=await Pc(c,m,c.size(),void 0,(w,_)=>y(w,_)?void 0:g.get(`${w}:${_}`)),b={v:1,block:Gf,size:c.size(),blocks:k};return o.chunks.blocksKey&&await Wx(r,o.chunks.blocksKey,new TextEncoder().encode(JSON.stringify(b))),await Jt("v1-sessions",`/v1/sessions/${r}/files/${o.id}`,{method:"PATCH",body:{bytes_uploaded:c.size(),chunks:{...o.chunks,isoSize:c.size(),files:m.files.filter(w=>!w.name.startsWith(`${to}/`)).map(w=>({name:w.name,size:w.totalSize}))}}}),await zx(r,c,m),{...u,uploaded:d.uploaded,copied:d.copied,image:c.size()}}finally{await c.close(),await Ht(l)}}async function Vx(e,t){if(e.kind==="peer"){let o=kr(e.ticket),s=await qx(e.ticket,B(t,o.iso?ie(o.files[0].name):"shared.iso"),{volume:o.label});return{mountpoint:s.mountpoint,stop:s.stop,status:s.status}}let n=await _c(e,t),r=await v_(n);try{let o=await T_(r.url);return{mountpoint:o.mountpoint,stop:async()=>{await o.detach(),await r.close(),await n.close()}}}catch(o){throw await r.close(),await n.close(),o}}async function Jx(e,t,n,r,o){if(await Ke(xn(t)),e.kind==="peer")return(await Bx(e.ticket,t,{onProgress:(i,a)=>r?.(i,a,"receiving"),signal:o})).bytes;let s=await _c(e,n);try{return await x_(s,t,(i,a)=>r?.(i,a,"downloading"),o)}finally{await s.close()}}var Xx={resolve:["resolve-drt","drt"],premiere:["premiere-prproj","prproj"],avid:["avid-avb","avb"],flame:["flame-fcpxml","fcpxml"],nuke:["resolve-xmeml","xml"]},Qx=["summary","flags","link"],mN=[{name:"account_login",title:"Sign in to conform.tools",description:"Sign in with the Google account you use on conform.tools. Opens the browser to the sign-in page and waits (up to 5 minutes) until it completes, then reports the plan. Needed once per machine; every other verb except timeline_routes and the account verbs requires a signed-in account with an active trial or subscription.",inputSchema:{},run:async()=>{let e="",t=await Df({onUrl:(n,r)=>{e=r?"":n,r||console.error(`open this URL to sign in: ${n}`)}});return X(`signed in
|
|
325
|
-
${Ac(t)}${e?`
|
|
326
|
-
(sign-in URL: ${e})`:""}
|
|
327
|
-
${await Yc()}`,{account:t})}},{name:"account_status",title:"Account and plan",description:"The running conformtools version (and whether a newer one is on npm), who is signed in on this machine, and whether the account's trial or subscription is active (checked live against conform.tools, with a 72-hour offline grace).",inputSchema:{},run:async()=>{let[e,t]=await Promise.all([Lf({force:!0}),If()]);return X(`${await Mf()}
|
|
328
|
-
${Ac(e)}
|
|
329
|
-
${await Yc()}`,{account:e,version:Af,latest_version:t})}},{name:"account_logout",title:"Sign out",description:"Forget this machine's conform.tools sign-in.",inputSchema:{},run:async()=>(await jf(),X(`signed out (${Of().env})`,{signed_in:!1}))},{name:"account_telemetry",title:"Outcome telemetry on / off",description:"Turn the optional outcome telemetry on or off, or show its state (action=status, the default). It is ON unless the user turns it off. It records, per tool run, the tool name, ok or the error code, duration, package version, engine mode, counts (numbers only), the names of the arguments given and the call's place in the conversation (a random run id + number), and per rejected call the tool name and the names of the failing arguments; never paths, file or clip names, timeline contents, project notes, prompts or media. Only change it when the user asks. Same as `conformtools telemetry on|off|status`.",inputSchema:{action:f.enum(["on","off","status"]).default("status")},run:async({action:e})=>((e==="on"||e==="off")&&await dg(e==="on"),X(await pg(),{telemetry:await ug()}))},{name:"conform_learn",title:"Load the conform.tools playbook for a task",description:`Call this FIRST, before any conform, timeline conversion, relink, verification or delivery task, and follow what it returns: the conform.tools playbook for the task (the order a conform artist works in, what to check, how to tell the user). task = conform (a turnover, timeline conversion, relink, online/offline conform, "is this conform right?") | autoconform (rebuild an edit from a reference render + source media) | deliver (consolidate, media manage, package or QC a turnover for the next facility) | deliverables (render and QC a finished program's deliverables: the usual set, naming, pre-render gate, audio routing, sign-off) | troubleshoot (a conformtools result looks wrong) | patch (fix a show already delivered: temps left in, replace with masters, insert timelines, patch renders and their QC). hosts = the editing systems involved, which adds their notes. Once per task per conversation is enough. Needs a signed-in account (account_login).`,inputSchema:{task:f.enum(Xc).describe(Xc.join(" | ")),hosts:f.array(f.enum(Qc)).max(Qc.length).optional().describe("The editing systems involved, source and target")},run:async({task:e,hosts:t})=>{try{let n=await cg(e,t??[]);return X(n.text)}catch(n){return J(new L("refused",`the playbook could not be loaded: ${n instanceof Error?n.message:String(n)}. Carry on with the tools; their descriptions still apply.`))}}},{name:"report_note",hidden:!0,title:"Send a playbook note or suggestion",description:`Send the conform.tools team a lesson, workflow rule or suggestion when nothing broke: something the playbooks should teach ("a patch runs from the whole clip before to the whole clip after", "this facility files patch renders in 200 - FINISH/<date>", "never match archival by file name alone") or an idea for the tools. File names at most, never full paths or values from the user's media. Tell the user you sent it.`,inputSchema:{note:f.string().min(3).describe(`One line: the lesson or suggestion (max ${Vs.summary} chars; longer is cut)`),detail:f.string().optional().describe(`Why, when it applies, what went wrong without it (max ${Vs.what_happened} chars; longer is cut)`),topic:f.enum(["playbook","suggestion"]).default("playbook").describe("playbook = how the work should be done; suggestion = an idea for conformtools"),session_id:f.string().optional(),verb:f.string().optional().describe("The tool it is about, if any")},run:async({note:e,detail:t,topic:n,...r})=>{try{let o={...r,summary:`[${n??"playbook"}] ${e}`,...t?{what_happened:t}:{}};return tu(await eu(await Zc(o)),o)}catch(o){return J(o)}}},{name:"report",title:"Send conform.tools a lesson or suggestion",description:`Send the conform.tools team a lesson, workflow rule or suggestion when nothing broke ("a patch runs from the whole clip before to the whole clip after", "never match archival by file name alone"); tell the user it was sent and give the report id. Problems need no report: a failed or wrong result is recorded with the run itself. Never sends media, file contents or timeline files; file names at most, never full paths or values from the user's media.`,inputSchema:{summary:f.string().min(3).describe(`One line: the lesson or suggestion (max ${Vs.summary} chars; longer is cut)`),detail:f.string().optional().describe(`Why, when it applies (max ${Vs.what_happened} chars)`),topic:f.enum(["playbook","suggestion"]).optional().describe("playbook = how the work should be done (default); suggestion = an idea for the product"),session_id:f.string().optional(),verb:f.string().optional().describe("The tool it is about, e.g. timeline_write")},run:async({summary:e,detail:t,topic:n,...r})=>{try{let o={...r,summary:`[${n??"playbook"}] ${e}`,...t?{what_happened:t}:{}};return tu(await eu(await Zc(o)),o)}catch(o){return J(o)}}},{name:"find_verb",title:"Find the tool for a request",description:"Call this FIRST whenever no conformtools tool obviously fits what the user asked: it answers with the tools and artist recipes that do it, best first, or says nothing does it yet. That answer is how conform.tools learns what to build next, so call it before any workaround (ffmpeg, ffprobe, a script, another tool, manual steps in a host), and before telling the user conformtools cannot do something. asked = the request in one line, every show, person, clip, reel, scene and path written as a {placeholder}.",inputSchema:{asked:f.string().min(3).max(Vc).describe('The request in one line, names as {placeholders}: "check every clip in {folder} for variable frame rate"')},run:async({asked:e})=>{let t=await ns().catch(()=>[]),n=ey(e,[...ss.filter(r=>!hN.test(r.name)).map(r=>({id:r.name,title:r.title,text:[r.description,...Object.values(r.inputSchema).map(o=>o.description??"")].join(" ")})),...t.filter(r=>r.group!=="API"&&!r.part).map(r=>({id:`tool:${r.id}`,title:r.name,text:r.about,aka:r.aka}))]);return n.length?X(`These fit, best first (tool:<id> = an artist recipe: run it with tool_run id=<id>):
|
|
330
|
-
`+n.map(r=>`- ${r.id} \u2014 ${r.title} (${Math.round(r.score*100)}%)`).join(`
|
|
331
|
-
`)+`
|
|
332
|
-
If none of them does what was asked, say so to the user rather than forcing one.`,{hits:n.map(r=>r.id)}):X("Nothing in conformtools does this yet. That is now recorded for the conform.tools team; tell the user plainly, then help another way if you can.",{hits:[]})}},Yx("script_run"),Yx("script_read"),{name:"timeline_read",protectedStages:["canonicalize"],title:"Read a timeline file",description:"Read an editorial timeline file (Avid AAF/AVB bin, Premiere .prproj, Resolve .drt, Final Cut .fcpxml/.fcpxmld or a project's own CurrentVersion.fcpevent inside a library, FCP7 XML, OTIO, Flame archive) into a session on this machine. Nothing is uploaded. Returns a session_id to pass to the other timeline_* tools, plus a summary (rates, raster, tracks, clip counts, media link state, conform flags). Call this first for any request that mentions a cut, sequence, bin, timeline or conform.",inputSchema:{engine:f.enum(["local","hosted"]).optional().describe("Where the conversion runs: local = this machine, offline, nothing uploaded; hosted = conform.tools (the website's engine). Default: local when this build has it"),path:f.string().describe("Absolute path to the timeline file (or .fcpxmld bundle directory)"),format:f.enum(fg).optional().describe("Override format detection (needed for Flame archives, which have no fixed extension)")},run:async({path:e,format:t})=>{try{let{session:n,format:r,sourcePath:o,notes:s}=await ts(e,t),i=await qn(n,o??e,r);return X(`session_id: ${i.id}
|
|
333
|
-
source: ${e} (${r})
|
|
334
|
-
${(s??[]).map(a=>`note: ${a}
|
|
335
|
-
`).join("")}${await Tr(n)}`,{session_id:i.id,format:r,...s?.length?{notes:s}:{}})}catch(n){return J(n)}}},{name:"host_current",protectedStages:["canonicalize"],title:"What is open in Resolve / Premiere / Media Composer / Flame / Nuke Studio / Final Cut",description:`Find the project and timeline each editing host on this machine has open right now \u2014 no host API, no export dialog \u2014 and read it into a session as if its file had been given to timeline_read. Resolve (Studio): the timeline in the viewer, exported by Resolve itself as its own .drt (its project database is never read). Premiere: the project window's .prproj and the sequences open in its Timeline panel (last save). Media Composer: the open project's bins (newest first; the loaded sequence is not on disk). Flame: the running project/workspace's live workspace file (every sequence on the desktop). Nuke Studio / Hiero: running, and its .hrox when the OS shows it (timelines come through its panel: host_current via=export). Final Cut: the project in the Timeline, decoded from its own store in the open library (CurrentVersion.fcpevent \u2192 FCPXML; effects, titles and the like come back as conform flags). via=export (or a timeline / out_path) asks the running host to export a timeline itself through its scripting door (read-only on the project) and reads that: Resolve any timeline of the open project by name as its own .drt; Baselight a scene (default the open one, or "host:job:scene") through FLAPI; Premiere, Media Composer, Flame, Nuke Studio through the conform.tools plugin (host_setup says how to install it). Use it when the open timeline is not readable from disk (a PostgreSQL project library, a timeline never saved) or to pick one by name; the reply carries project, timeline, path and session_id. Use when asked 'what do I have open', 'grab my current timeline', 'the sequence I'm working on', or to act on the open cut.`,inputSchema:{host:f.enum(Qt).optional().describe("One host; omit for all"),read:f.boolean().default(!0).describe("Also read the open timeline into a session (session_id in the reply)"),via:f.enum(["disk","export"]).default("disk").describe("disk: what the host has on disk, no host API; export: the running host exports the timeline itself (needs host)"),timeline:f.string().optional().describe("Timeline name to export (implies via=export); default the open one"),out_path:f.string().optional().describe("via=export: where to write the file; a temp file when omitted")},run:async({host:e,read:t,via:n,timeline:r,out_path:o})=>{if(n==="export"||r||o)return e?wn("host_export").run({host:e,timeline:r,out_path:o,read:t}):J(new L("invalid_args","via=export needs host"));try{let i=await jb(e?[e]:void 0,void 0,t?async(c,u)=>{try{let{session:p}=await ts(c,u);return p.timelines.some(d=>d.tracks?.some(m=>m.items?.length))}catch{return!1}}:void 0),a=[],l=[];for(let c of i){let u=Bb(c),p={...c};if(l.push(p),t&&c.read)try{let{session:d,format:m,sourcePath:h,notes:g}=await ts(c.read.path,c.read.format);Db(d,c);let y=await qn(d,h??c.read.path,m);p.session_id=y.id,u+=`${(g??[]).map(k=>`
|
|
336
|
-
note: ${k}`).join("")}
|
|
337
|
-
session_id: ${y.id}
|
|
338
|
-
${(await Tr(d)).replace(/^/gm," ")}`}catch(d){u+=`
|
|
339
|
-
read failed: ${d instanceof Error?d.message:String(d)}`}a.push(u)}return X(a.join(`
|
|
340
|
-
|
|
341
|
-
`),{hosts:l})}catch(s){return J(s)}}},{name:"host_export",hidden:!0,protectedStages:["canonicalize"],title:"Export a timeline from the running host",description:`Ask the running host to export a timeline in its own format, through its scripting door (read-only on the project), and read it into a session. Resolve: any timeline of the open project by name (default: the one in the viewer) as Resolve's own .drt. Baselight: a scene (default: the one open in the app; or "host:job:scene") read shot by shot through FLAPI into an OTIO. Premiere, Media Composer, Flame, Nuke Studio: through the conform.tools plugin in the host (host_setup says how to install it), as OTIO (Premiere / Media Composer: the host's own export; Flame / Nuke: the timeline as the plugin reads it). Use when host_current cannot read the open timeline from disk (a PostgreSQL project library, a timeline never saved), or to pick a timeline by name.`,inputSchema:{host:f.enum(Qt).describe("The host to export from"),timeline:f.string().optional().describe("Timeline name; the open one when omitted"),out_path:f.string().optional().describe("Where to write the file; a temp file when omitted"),read:f.boolean().default(!0).describe("Also read it into a session (session_id in the reply)")},run:async({host:e,timeline:t,out_path:n,read:r})=>{try{if(e==="premiere"&&!n&&r!==!1){let{premiereSession:l}=await import("./host-relink-FHNXXMHW.js"),c=un("premiere"),u=await l(c,t).catch(p=>{if(p.code==="panel_old")return null;throw p});if(u){let p=await qn(u.session,u.path,/\.otio$/i.test(u.path)?"otio":"prproj"),d=await c.current(),m=u.session.timelines[0]?.name??t??d.timeline;return X([`read ${d.project} / ${m} from ${u.from}`,...u.lossy?[`\u26A0 ${u.lossy}`]:[],`session_id: ${p.id}`,await Tr(u.session)].join(`
|
|
342
|
-
`),{path:u.path,format:/\.otio$/i.test(u.path)?"otio":"prproj",project:d.project,timeline:m,session_id:p.id,from:u.from})}}let o=n??B(await Dt("conform-export-"),`${(t??"current").replace(/[^\w.-]+/g,"_")}.${e==="resolve"?"drt":"otio"}`),s=await un(e).export({timeline:t,out_path:o}),i=[`exported ${s.project} / ${s.timeline} \u2192 ${s.path} (${s.format})`,...(s.notes??[]).map(l=>`\u26A0 ${l}`)].join(`
|
|
343
|
-
`),a={...s};if(r!==!1){let{session:l,format:c}=await ts(s.path,s.format);e==="resolve"&&await(await import("./host-relink-FHNXXMHW.js")).withOfflineReference(un("resolve"),l).catch(()=>0),e==="premiere"&&await(await import("./host-relink-FHNXXMHW.js")).withPremiereTimecodes(un("premiere"),l).catch(()=>0);let u=await qn(l,s.path,c);i+=`
|
|
344
|
-
session_id: ${u.id}
|
|
345
|
-
${await Tr(l)}`,a.session_id=u.id}return X(i,a)}catch(o){return J(new L("refused",o instanceof Error?o.message:String(o)))}}},{name:"host_open",protectedStages:["write"],title:"Open a timeline file in the running host",description:`Import a timeline file into the running host as a NEW timeline (never overwrites one; a taken name gets a number). Resolve: into the open project's conform.tools media pool folder (into=current, the default), or into our scratch project (into=scratch: the user's project is saved first, then reopened). Baselight: a NEW scene in the open scene's job (into=current) or our job conform_tools (into=scratch), V1 built shot by shot from the file's media paths, saved; the scene in the app is never touched. folder (Resolve): the media pool folder to land it in, by path under Master, e.g. "000 - TIMELINES/20261006" (learn the project's layout with host_project first); a missing folder is refused unless create_folder=true. link_existing=true links the timeline to clips already in the media pool (no duplicate clips; Resolve importSourceClips off): the way to bring an insert/update timeline into a project that has the media. The user's timeline, folder and page are put back afterwards unless stay=true. Use after timeline_write to land a conversion in the host, or to bring a turnover in for checking. Premiere, Media Composer, Flame, Nuke Studio: through the host's conform.tools plugin, into the open project (Flame: the CONFORM.TOOLS reel group on the desktop, segments relinked to media on disk). session_id (+ timeline_id) opens a session's timeline directly \u2014 the push half of a Resolve tool: host_current via=export \u2192 timeline_edit add_handles / all_clips \u2192 host_open session_id timeline_id link_existing=true.`,inputSchema:{host:f.enum(Qt).describe("The host to open it in"),path:f.string().optional().describe("The timeline file (Resolve: .drt, .xml, .fcpxml, .aaf, .edl, .otio); or give session_id"),session_id:f.string().optional().describe("Open a timeline of this session instead of a file (written here first in the host's own format: .drt Resolve, .prproj Premiere, .avb Media Composer, .fcpxml Flame, FCP7 .xml Nuke Studio)"),timeline_id:f.string().optional().describe("With session_id: which timeline (e.g. the one timeline_edit just built); default the session's first"),name:f.string().optional().describe("Timeline name; the file name (or the session timeline's name) when omitted"),into:f.enum(["current","scratch"]).default("current").describe("current: the open project; scratch: our own project"),media_dirs:f.array(f.string()).optional().describe("Folders to link media from while importing"),stay:f.boolean().default(!1).describe("Leave the host showing the imported timeline"),folder:f.string().optional().describe('Resolve: media pool folder path to import into, e.g. "000 - TIMELINES/20261006" (default: conform.tools)'),create_folder:f.boolean().default(!1).describe("Create the folder (and its parents) when missing"),link_existing:f.boolean().default(!1).describe("Link to clips already in the media pool instead of importing new ones"),settings_from:f.string().optional().describe("Resolve: a timeline whose settings the new one takes (resolution, rate, color science and spaces, data levels, monitoring), verified; if a critical one does not take, the new timeline is deleted and the open refused")},run:async({host:e,path:t,session_id:n,timeline_id:r,name:o,into:s,media_dirs:i,stay:a,folder:l,create_folder:c,link_existing:u,settings_from:p})=>{try{if(n){let h=await bt(n),g=h.session.timelines.find(_=>_.id===r)??h.session.timelines.find(_=>_.kind!=="compound");if(!g)return J(new L("not_found",`no timeline ${r??""} in session ${n}`));let y={...h.session,timelines:h.session.timelines.filter(_=>_.id===g.id||_.kind==="compound")},[k,b]=Xx[e]??Xx.resolve;t=(await ru(y,k,B(await Dt("conform-open-"),`${g.name.replace(/[^\w.-]+/g,"_")}.${b}`),h.source_path)).path,o??=g.name}if(!t)return J(new L("invalid_args","host_open needs path or session_id"));let d=await un(e).open({path:t,name:o,into:s,media_dirs:i,stay:a,folder:l,create_folder:c,link_existing:u,...p?{settings_from:p}:{}}),m=[`opened in ${e}: ${d.project} / ${d.timeline}${d.folder?` (media pool: ${d.folder})`:""}`,d.restored?"the user's timeline, folder and page were put back":"left showing the imported timeline",...u?["linked to clips already in the media pool (no new clips imported)"]:[],...d.settings?[`timeline settings from ${p}: ${d.settings}, verified`]:[],...d.notes];return X(m.join(`
|
|
346
|
-
`),{...d})}catch(d){return J(new L("refused",d instanceof Error?d.message:String(d)))}}},{name:"host_render",long:!0,title:"Render a timeline in the running host (optionally through the renderplugin)",description:`Render a timeline (or a frame range of it) with the host's own renderer and wait for the files. Only OUR job is queued and started; the user's render queue is never run, their Deliver settings are restored as soon as our job is queued, and their timeline and page come back when it finishes. Refuses while the host is already rendering. Resolve: preset = a render preset saved in Resolve (default: the project's current render settings); range = absolute timeline frames, inclusive; name = the output file name. Baselight: timeline = a scene (default: the one open in the app), preset = a deliverable defined in the scene (default: ProRes 422 HQ of the working space), queued on the local render queue as "conform.tools <name>". Premiere: preset = the path of a Media Encoder .epr. Flame (through its conform.tools hook): preset = one of Flame's export presets by name (required), range as Resolve's; Flame renders in the foreground and a running export cannot be cancelled from here. Picture only unless audio=true. audio_tracks (Resolve) = the Deliver page's audio output routing by timeline track, which its API cannot set: [1, 2] = A1 (5.1) on ch1-6 + A2 (stereo) on ch7-8 (an 8CH_5-1_STEREO deliverable), [2] = stereo only; set it whenever a name promises a channel layout. disable_tracks = video tracks to leave out of this render, by name (every track so named, e.g. ["Lower Thirds"] for a TEXTLESS version) or "V7": Resolve's API has no per-job track selection, so they are switched off on the Edit page (read back) for our job and switched back on when it ends. Resolve names the queued job itself ("Job N"); its API cannot. renderplugin=true (Resolve): render through the conform.tools renderplugin instead, which measures EVERY frame after grading and compositing, and return findings: black edges (blanking) per range with the clip and edge, black frames, failed/warned checks (clipping, freeze/flash, dead pixels, leader/slate), audio loudness and peak; markers go on the timeline (ours, tagged; a re-run replaces them, nobody else's are touched). The throwaway render is deleted unless keep_render. strictness: strict (1 px, 1 frame; default) | standard | relaxed. expected_aspect: the delivered ratio when bars are part of the deliverable (2.39 in UHD, 1.85 in DCI). Use for finishing QC ('check this timeline for black edges', 'QC the master before it goes'). Long: pass background=true for a job id, then job action=status.`,inputSchema:{host:f.enum(Qt).describe("The host to render in"),timeline:f.string().optional().describe("Timeline name; the open one when omitted"),target_dir:f.string().optional().describe("Folder for the render (required unless renderplugin=true); created if missing"),name:f.string().optional().describe("Output name without extension; the timeline name when omitted"),preset:f.string().optional().describe("A render preset saved in the host"),range:f.object({in:f.number().int(),out:f.number().int()}).optional().describe("Frame range, absolute timeline frames, inclusive"),audio:f.boolean().optional().describe("Render audio with the picture (default: off = picture only; on for renderplugin)"),disable_tracks:f.array(f.string()).optional().describe('Video tracks to leave out of this render, by name or "V7" (e.g. ["Lower Thirds"] for TEXTLESS)'),audio_tracks:f.array(f.number().int().positive()).optional().describe("Resolve: audio output n = timeline track audio_tracks[n], e.g. [1, 2] = 5.1 (A1) on ch1-6 + stereo (A2) on ch7-8; [2] = stereo only. Implies audio"),renderplugin:f.boolean().default(!1).describe("Resolve: render through the conform.tools renderplugin and return QC findings"),strictness:f.enum(Object.keys(Uc)).optional().describe("renderplugin: strict (default) | standard | relaxed"),expected_aspect:f.number().positive().optional().describe("renderplugin: delivered aspect ratio when bars are expected, e.g. 2.39"),markers:f.boolean().default(!0).describe("renderplugin: place markers on the findings"),keep_render:f.boolean().default(!1).describe("renderplugin: keep the throwaway ProRes render"),ignore_space:f.boolean().default(!1).describe("renderplugin: skip the free-space check"),conform:f.boolean().optional().describe("renderplugin: the render against the timeline too \u2014 picture cuts with no edit (off-by-one conform, flash frames), edits with no cut, black on a clip, proxy leak, ungraded (log) shots, grade outliers"),textless:f.boolean().optional().describe("renderplugin: a textless master \u2014 any text in the picture fails"),marker_scope:f.enum(["timeline","clips"]).optional().describe("renderplugin: markers on the timeline (default) or, for picture findings, on the topmost video clip under them (they travel with the clip)"),only:f.array(f.string()).optional().describe('renderplugin: keep (mark and return) only these findings by check id, e.g. ["conform.proxy_leak"]'),queue:f.boolean().default(!1).describe("Resolve: add the job to the render queue for the artist and stop there (nothing rendered)"),checks:f.record(f.unknown()).optional().describe("renderplugin: the check config \u2014 a spec pack's {id, color_space, checks} or its bare `checks` map (api/core/qc/spec-packs.ts); every check at its defaults when omitted")},run:async({host:e,timeline:t,target_dir:n,name:r,preset:o,range:s,audio:i,disable_tracks:a,audio_tracks:l,renderplugin:c,strictness:u,expected_aspect:p,markers:d,keep_render:m,ignore_space:h,queue:g,checks:y,conform:k,textless:b,only:w,marker_scope:_,__progress:v,__signal:R})=>{let S=un(e);try{if(c){if(e!=="resolve")return J(new L("unsupported","the renderplugin is a DaVinci Resolve plugin"));let $=await Mb(S,Zs,{timeline:t,range:s,strictness:u,expected_aspect:p,markers:d,keep_render:m,ignore_space:h,audio:i,conform:k,textless:b,only:w,marker_scope:_,...y?{checks:y}:{}},v,R);return X(Lb($),{...$})}if(!n)return J(new L("invalid_args","target_dir is required (unless renderplugin=true)"));if(l?.length&&e!=="resolve")return J(new L("unsupported","audio_tracks (output routing) is for DaVinci Resolve"));if(g&&e!=="resolve")return J(new L("unsupported","queue (leave the job in the render queue) is for DaVinci Resolve"));let T=await S.renderStart({timeline:t,target_dir:n,name:r,preset:o,range:s,audio:(i??!1)||!!l?.length,...a?.length?{disable_tracks:a}:{},...l?.length?{audio_tracks:l}:{},...g?{queue:g}:{}});if(g)return X(`queued in ${e}: ${r??t??"the timeline"} \u2192 ${n} (render queue job ${T.job_id}; nothing rendered \u2014 start it on the Deliver page)
|
|
347
|
-
the user's render settings, timeline and page were put back`,{host_render_job:T.job_id,queued:!0});if(T=await gu(S,T,v,R),T.state!=="complete")return J(new L(T.state==="cancelled"?"cancelled":"engine",`render ${T.state}${T.error?`: ${T.error}`:""}${T.notes?.length?`; ${T.notes.join("; ")}`:""}`));let x=T.outputs?.length?T.outputs:await Bg(n,r??t??"");return X([`rendered in ${e} \u2192 ${x.join(", ")||n}${i||l?.length?"":" (picture only)"}`,...a?.length?[`without video tracks: ${a.join(", ")}`]:[],...l?.length?[`audio outputs: ${l.map(($,U)=>`${U+1} = timeline track ${$}`).join(", ")} \u2014 probe the file to confirm the channel layout`]:[],"the user's render settings, timeline and page were put back",`${e} render queue job ${T.job_id} (the host's own id, kept in its queue \u2014 not a conform.tools job id)`,...T.notes??[]].join(`
|
|
348
|
-
`),{host_render_job:T.job_id,outputs:x,...T.notes?{notes:T.notes}:{}})}catch(T){return J(new L("refused",T instanceof Error?T.message:String(T)))}}},{name:"host_preset",title:"Read or author host render presets (incl. audio output routing)",description:"Resolve render presets. action=list: every preset (or names) with its container, codec, raster, audio codec and the Deliver page's audio OUTPUT routing (Timeline Track n / Bus n per output) \u2014 the routing the scripting API cannot read. action=author: save a NEW preset = base (a preset, or the Deliver page's current settings) with audio output n fed by timeline track audio_tracks[n] ([1, 2] = 5.1 on A1 \u2192 ch1-6 + stereo on A2 \u2192 ch7-8; [2] = stereo only). Never replaces a preset; names without dots. The user's Deliver settings and page are put back. Prove a new preset with a short test render (host_render range of ~11 frames) and media_probe the channels before the full render.",inputSchema:{host:f.enum(Qt).default("resolve").describe("The host"),action:f.enum(["list","author"]).default("list"),names:f.array(f.string()).optional().describe("list: only these presets"),name:f.string().optional().describe("author: the new preset's name (no dots), e.g. PR4444_8CH_5-1_STEREO"),base:f.string().optional().describe("author: the preset to start from; the Deliver page's current settings when omitted"),audio_tracks:f.array(f.number().int().positive()).optional().describe("author: timeline track per audio output, e.g. [1, 2]")},run:async({host:e,action:t,names:n,name:r,base:o,audio_tracks:s})=>{try{let i=un(e??"resolve");if(!i.presets||!i.presetAuthor)return J(new L("unsupported",`${i.host}: host_preset is for DaVinci Resolve`));let a=c=>c.error?`${c.name}: ${c.error}`:`${c.name}: ${c.format??"?"} ${c.codec??"?"} ${c.width??"?"}x${c.height??"?"}; audio ${c.audio==="true"?`${c.audio_codec??"on"} \u2192 ${c.audio_outputs?.length?c.audio_outputs.map((u,p)=>`out ${p+1} = ${u}`).join(", "):"default routing"}`:"off"}`;if(t==="author"){if(!r||!s?.length)return J(new L("invalid_args","author needs name and audio_tracks"));let c=await i.presetAuthor({name:r,...o?{base:o}:{},audio_tracks:s});return X(`saved render preset "${c.preset}"${c.summary?`
|
|
349
|
-
${a({...c.summary,name:c.preset})}`:""}
|
|
350
|
-
prove it: host_render a ~11-frame range with this preset, then media_probe the channels`,c)}let l=await i.presets({...n?.length?{names:n}:{}});return X([`${l.presets.length} render preset(s) in "${l.project}":`,...l.presets.map(a)].join(`
|
|
351
|
-
`),l)}catch(i){return J(new L("refused",i instanceof Error?i.message:String(i)))}}},{name:"host_project",title:"Learn the open host project: media pool, render queue, tracks",description:"Read-only look at the project open in the running host, to learn its conventions before acting. Resolve: the media pool folder tree with clip counts (clips=true lists every clip with its file, start TC and usage); find = file paths or name fragments to look up project-wide ('is this file already in the project? where?'); the render queue with each job's name, timeline, output folder/file, status, mark in/out and the settings Resolve reports; and every track of a timeline (default: the open one) with its name and enabled/locked state. Use before host_open (which folder) and host_render (which tracks are Lower Thirds, which job made the deliverable).",inputSchema:{host:f.enum(Qt).default("resolve").describe("The host"),timeline:f.string().optional().describe("Timeline whose tracks to list; the open one when omitted"),clips:f.boolean().default(!1).describe("List every clip in every folder (large projects: long)"),find:f.array(f.string()).optional().describe("File paths or name fragments to look up in the media pool"),used:f.boolean().default(!1).describe("Resolve: also the ids of every media pool clip any timeline holds (`used`), read from the timelines themselves"),project:f.string().optional().describe("Resolve: read another project of the library instead (it is opened, then the open one again)"),export_dir:f.string().optional().describe("Resolve: also write every timeline of the project as .drt into this folder (`exported`)"),grades:f.array(f.object({key:f.union([f.string(),f.number()]),timeline:f.string(),track:f.number(),start:f.number()})).optional().describe("Resolve: these clips' grades as gallery-still .drx files into grades_dir (`grades`: key \u2192 path), for a copy into another project"),grades_dir:f.string().optional()},run:async({host:e,timeline:t,clips:n,find:r,used:o,project:s,export_dir:i,grades:a,grades_dir:l})=>{try{let c=un(e??"resolve");if(!c.project)return J(new L("unsupported",`${c.host}: host_project is not available for this host yet`));let u=await c.project({timeline:t,clips:n,find:r,...o?{used:o}:{},...s?{project:s}:{},...i?{export_dir:i}:{},...a?.length?{grades:a,grades_dir:l}:{}}),p=0,d=0,m=[],h=(y,k)=>{k&&(p++,m.push(`${" ".repeat(k)}${y.path.split("/").pop()} (${y.clips} clip${y.clips===1?"":"s"})`)),d+=y.clips;for(let b of y.clip_list??[])m.push(`${" ".repeat(k+1)}- ${b.name} ${b.file}${b.start_tc?` TC ${b.start_tc}`:""}${b.usage?` used ${b.usage}x`:""}`);for(let b of y.folders)h(b,k+1)};h(u.pool,0);let g=[`${e??"resolve"} project "${u.project}": ${p} media pool folders, ${d} clips; ${u.jobs.length} render job(s)${u.timeline?`; timeline "${u.timeline}" has ${u.tracks.length} tracks`:""}`];g.push("media pool:",...m.length?m:[" (no folders)"]);for(let[y,k]of Object.entries(u.found??{}))g.push(k.length?`find "${y}": ${k.map(b=>`${b.folder||"Master"}/${b.name} (${b.file||"no file"}${b.usage?`, used ${b.usage}x`:""})`).join("; ")}`:`find "${y}": not in the project`);u.jobs.length&&g.push("render queue:");for(let y of u.jobs){let k=y.MarkIn!=null?` frames ${y.MarkIn}-${y.MarkOut}`:"";g.push(` ${y.RenderJobName??y.JobId} [${y.JobStatus||"?"}] "${y.TimelineName??""}" \u2192 ${Sf(String(y.TargetDir??""),String(y.OutputFilename??""))}${k}${y.VideoCodec?` ${y.VideoFormat??""} ${y.VideoCodec}`:""}${y.PresetName?` preset ${y.PresetName}`:""}`)}return u.tracks?.length&&g.push(`tracks: ${yu(u.tracks)}`),X(g.join(`
|
|
352
|
-
`),u)}catch(c){return J(new L("refused",c instanceof Error?c.message:String(c)))}}},{name:"host_items",title:"Live clip attributes in the host (color, flags, versions, groups)",description:"Resolve: per item of a timeline (default the open one) what its timeline file does not carry: clip color, flags, enabled, the loaded grade version, color group, node count, keywords, and its unique id. Items are addressed like timeline_query rows: kind + 1-based track + start (record frames from the timeline start), so the two join. Also the project's color groups and node-stack layer count. Read-only.",inputSchema:{host:f.enum(Qt).default("resolve").describe("The host (each says when it cannot do this yet)"),timeline:f.string().optional().describe("Timeline by name; the open one when omitted"),kind:f.enum(["video","audio"]).optional(),track:f.number().int().positive().optional(),selected:f.boolean().optional().describe("only the clips selected in the host's timeline right now: {selected: [{kind, track, start, id, name}]}")},run:async({host:e,timeline:t,kind:n,track:r,selected:o})=>{try{let s=un(e??"resolve");if(!s.items)return J(new L("unsupported",`${s.host}: host_items is not available for this host yet`));if(o){let l=await s.items({timeline:t,selected:!0});return X(`"${l.timeline}": ${l.selected.length} clip(s) selected`,l)}let i=await s.items({timeline:t,kind:n,track:r}),a=l=>i.items.filter(c=>c[l]&&(!Array.isArray(c[l])||c[l].length)).length;return X(`"${i.timeline}": ${i.items.length} items; ${a("color")} with a clip color, ${a("flags")} flagged, ${i.items.filter(l=>!l.enabled).length} disabled; color groups: ${i.color_groups.join(", ")||"none"}`,i)}catch(s){return J(new L("refused",s instanceof Error?s.message:String(s)))}}},{name:"host_apply",title:"Change clips in the open host timeline (color, flags, markers, grades, names)",description:"Resolve: carry out live edits on a timeline (default the open one), in order, each read back. Items are addressed {kind?, track, start} (a timeline_query row's track number and record start frame from the timeline start) or {id} (host_items). Ops: marker_add|marker_update|marker_delete {item?, frame, color?, name?, note?, duration?, data?, to_frame?} (no item = a timeline marker; frame from the timeline start, or from the clip's start for a clip marker); clip_color {item, color|''}; flags {item, add?:[color], clear?:color|'All'}; enabled {item, on}; name {item, name}; properties {item, set:{Pan, Tilt, ZoomX, ZoomY, RotationAngle, FlipX, CropLeft\u2026, Opacity, CompositeMode, RetimeProcess\u2026}}; metadata {item, set:{Keywords, Comments, Scene\u2026}} (the clip's media pool item); copy_grade {item, to:[item], from_timeline?} (verified by node count; from_timeline = the source item is in that timeline); copy_properties {item, to:[item], keys:[Pan, ZoomX, CropLeft, Opacity\u2026]} (the source's values as Resolve holds them); version {item, add|load|delete, type?:'local'|'remote'}; color_group {item, group|''}; cache {item, color?:bool, fusion?:'Auto'|'On'|'Off'}; fades {item, set}; output_blanking {item, set}; drx {item, path, graph?, mode?} (apply a .drx still); edit_keys {item, keys:[{t, transform, shape?}]} (timeline_align sizing_target edit, a move: Resolve cannot keyframe the Edit page from a script, so after every other op the moving clips are keyed on a copy, '<timeline> ALIGNED' \u2014 Resolve's own .drt of the timeline with only those clips' Transform keyed on Resolve's Edit-page law, every grade and setting as it was, linked to the same pool clips; the timeline itself is not changed); grade_sizing {item, target:'input'|'node', zoom, height?, rotation (degrees clockwise), pan, tilt (fractions of the timeline width / height, tilt up), flip_x?, flip_y?} (Color-page Input Sizing or node Sizing as timeline_align answers it, ADDED to the clip's grade as it stands on a new local version 'conform.tools aligned' (the colorist's version untouched; a grade that cannot be read is refused, never replaced); a clip on a remote version is moved onto its local one first; undo resets the grade and loads the remote version back); node_structure {item, node_structure: a .drx path} (that node tree onto the clip on a new local version 'conform.tools aligned', the colorist's own version untouched; undo goes back); lut {item, graph?, node, path}; playhead {tc} (move the playhead to a record timecode); pool_rename {clip:id, name}; pool_move {clips:[id], folder, create?}; pool_delete {clips:[id]}; pool_import {paths:[file], folder:'A/B', at?:[frame]} (import files into that pool folder, made if missing; at = lay each on one new top video track at that frame from the timeline start; undo removes the track and what it added); track_delete {kind, index}; timeline_rename {timeline?, nth?, guid?, name} (nth = which of the sequences sharing that name, from 0; guid = exactly one: Premiere, where names repeat); timeline_duplicate {timeline?, name} (a copy under a name no timeline has, made the open one; answers its name); goto {timeline?, frame} (open that timeline with the playhead on frame, from its start). The reply has one result per op and an undo_id: host_apply {undo: undo_id} puts back everything that batch changed (pool_delete, copy_grade and drx cannot be undone). Changes the user's project: only when asked.",inputSchema:{host:f.enum(Qt).default("resolve").describe("The host (each says when it cannot do this yet)"),timeline:f.string().optional().describe("Timeline by name; the open one when omitted"),ops:f.array(f.object({op:f.string()}).passthrough()).optional().describe("The edits, in order (see description)"),undo:f.string().optional().describe("An undo_id from an earlier host_apply: put that batch back")},protectedStages:["canonicalize","write"],run:async({host:e,timeline:t,ops:n,undo:r})=>{try{let o=un(e??"resolve");if(!o.apply)return J(new L("unsupported",`${o.host}: host_apply is not available for this host yet`));let s=B(Xe(),"host-undo"),i=n;if(r){let p=JSON.parse(await et(B(s,`${r.replace(/[^\w-]/g,"")}.json`)));i=p.ops,t=p.timeline}if(!i?.length)return J(new L("usage","host_apply needs ops (or undo)"));let a=await o.apply({timeline:t,ops:i}),l;a.undo.length&&(l=`${Date.now().toString(36)}-${crypto.randomUUID().slice(0,6)}`,await Ke(s),await Ve(B(s,`${l}.json`),JSON.stringify({timeline:a.timeline,project:a.project,ops:a.undo})));let c=a.results.map((p,d)=>({...p,i:d})).filter(p=>!p.ok),u=[`${r?"undid":"applied"} ${a.applied}/${a.results.length} on "${a.timeline}" (${a.project})${l?`; undo_id: ${l}`:""}`];for(let p of c.slice(0,20))u.push(` #${p.i+1} ${p.op}: ${p.detail??(p.refused?`refused ${p.refused.join(", ")}`:"Resolve refused")}`);return c.length>20&&u.push(` \u2026and ${c.length-20} more`),X(u.join(`
|
|
353
|
-
`),{...a,undo:void 0,undo_id:l})}catch(o){return J(new L("refused",o instanceof Error?o.message:String(o)))}}},{name:"host_edit",title:"Edit the open Premiere sequence into a new one (resize, un-nest, frame rate, handles\u2026)",description:"Premiere: read the open sequence (the saved .prproj when it matches the live one \u2014 every effect, retime and nest \u2014 else Premiere's OTIO export with its timecodes), run timeline_edit operations on it, and import the result as a NEW sequence written by the conform.tools .prproj writer. The open sequence never changes. ops: [{kind, args}] in order, kinds as timeline_edit (timeline_id defaults to the sequence), plus unnest. Common jobs: resize without moving a pixel: {kind:'reformat', args:{resolution_w:3840, resolution_h:2160}} (HD \u2194 UHD: every clip keeps its framing; an aspect change needs fit:'fit'|'fill'|'stretch'); un-nest: {kind:'unnest'} (every nested sequence expanded into the cut with the nest's transform, opacity and speed composed onto its clips; multicam clips read as their active angle; adjustment layers kept); conform the rate: {kind:'timeline_rate', args:{fps_num, fps_den}}; a handles / all-clips / string-out version: add_handles {handles}, all_clips {}, stringout {}. name: the new sequence's name (default <sequence>_<KIND>). The reply lists what the writer could not carry.",inputSchema:{host:f.enum(["premiere"]).default("premiere"),timeline:f.string().optional().describe("Sequence by name; the active one when omitted"),ops:f.array(f.object({kind:f.string(),args:f.object({}).passthrough().optional()})).min(1),name:f.string().optional()},run:async({timeline:e,ops:t,name:n})=>{try{let{hostEdit:r}=await import("./host-relink-FHNXXMHW.js"),o=await r(un("premiere"),{timeline:e,ops:t,name:n});return X(o.text,o.data)}catch(r){return J(new L("refused",r instanceof Error?r.message:String(r)))}}},{name:"host_relink",title:"Conform into the open Premiere sequence (proxies \u2192 online, cut in returns)",description:"Premiere: link the open sequence's media with conform.tools' matcher (Conform Connect: reel, timecode containment, loose proxy names, picture when asked) instead of Premiere's Link Media, then hand the result to Premiere. The sequence is read from the saved .prproj when it matches the live one (every effect and retime), else Premiere's XML export. modes: replace = repoint every proxy project clip at its online file (every use follows; not in Premiere's undo, the reply says how to put it back); hires = attach the online file as full-res behind each proxy (Premiere's Toggle Proxies switches between them); proxy = the other way: the project is on the online media and each clip gets its proxy from the folder attached (matched by name + timecode, not by Premiere's Attach Proxies); cut_in = cut each matched return (VFX / color returns trimmed with handles, matched by reel + timecode) in over its clip on the track above (track, default the top + 1), video only, the clip's sizing carried, originals left underneath \u2014 one \u2318Z in Premiere; new_version = a NEW sequence written by the conform.tools .prproj writer from the relinked cut and imported (nothing in the open sequence changes). dry_run=true lists what would link to what. criteria / tolerances as timeline_relink (default: loose names for replace/hires, reel + timecode for cut_in). Changes the user's project: only when asked.",inputSchema:{host:f.enum(["premiere"]).default("premiere"),media_root:f.string().describe("The folder with the online media / returns"),mode:f.enum(["replace","hires","proxy","cut_in","new_version"]).default("new_version"),timeline:f.string().optional().describe("Sequence by name; the active one when omitted"),track:f.number().int().positive().optional().describe("cut_in: the video track to cut onto (default above the top track)"),name:f.string().optional().describe("new_version: the new sequence's name (default <sequence>_CONFORMED)"),dry_run:f.boolean().default(!1),criteria:f.object({}).passthrough().optional().describe("as timeline_relink criteria"),tolerances:f.object({}).passthrough().optional().describe("as timeline_relink tolerances")},run:async({media_root:e,mode:t,timeline:n,track:r,name:o,dry_run:s,criteria:i,tolerances:a})=>{try{let{hostRelink:l}=await import("./host-relink-FHNXXMHW.js"),c=await l(un("premiere"),{media_root:e,mode:t,timeline:n,track:r,name:o,dry_run:s,criteria:i,tolerances:a});return X(c.text,c.data)}catch(l){return J(new L("refused",l instanceof Error?l.message:String(l)))}}},{name:"host_setup",title:"Host readiness, and installing the renderplugin",description:"What works with each editing host on this machine and what to do about what doesn't (Resolve: Studio, external scripting, an open project; the conform.tools renderplugin installed and loaded). action=install_renderplugin downloads the published renderplugin for this platform, verifies its checksum before writing anything, and installs it into Resolve's system I/O plugin folder (the OS asks for an administrator password). Resolve must be restarted afterwards. action=install_probe installs ColorMatchProbe, the OFX plugin the app ships (Apple silicon Macs): it lets conform.tools read the Color page's selected clips and node (administrator password, then restart Resolve). action=install_panel installs the host's conform.tools plugin: Premiere's UXP panel with Adobe's own installer (the user then opens Window > UXP Plugins > conform.tools once); Flame's Python hook into this user's hook folder (then Rescan Python Hooks); the Nuke Studio / Hiero panel into ~/.nuke (then restart it). Never with sudo. Only install when the user asks.",inputSchema:{host:f.enum(Qt).default("resolve").describe("The host"),action:f.enum(["status","install_renderplugin","install_panel","install_probe"]).default("status")},run:async({host:e,action:t})=>{try{let n=e??"resolve";if((t??"status")==="install_panel"){if(n==="flame"||n==="nuke"){let a=Km[n],l=await a.install();return X([`conform.tools ${a.what} ${l.version} installed in ${l.dest}`,a.next].join(`
|
|
354
|
-
`),{...l})}if(n!=="premiere")return J(new L("unsupported","install_panel installs the conform.tools plugin for Premiere Pro, Flame or Nuke Studio (Media Composer's panel: mcp/hosts/avid/panel)"));let i=await Wg();return X([`conform.tools panel ${i.version} installed for Premiere Pro (Adobe's installer: ${i.output.split(`
|
|
355
|
-
`).pop()})`,"In Premiere: Window > UXP Plugins > conform.tools (restart Premiere first if it was running). It connects by itself from then on."].join(`
|
|
356
|
-
`),{...i})}if(t==="install_probe"){if(n!=="resolve")return J(new L("unsupported","the probe is a DaVinci Resolve plugin"));let{installProbe:i}=await import("./probe-72QZKMCC.js"),a=await i();return X([`ColorMatchProbe installed at ${a.path} (with administrator approval)`,"Restart Resolve: it loads OFX plugins at launch."].join(`
|
|
357
|
-
`),{...a})}if((t??"status")==="install_renderplugin"){if(n!=="resolve")return J(new L("unsupported","the renderplugin is a DaVinci Resolve plugin"));let i=await Ng();return X([`renderplugin ${i.version} installed at ${i.path}${i.elevated?" (with administrator approval)":""}`,"Restart Resolve: it loads I/O plugins only at launch.",...i.notes].join(`
|
|
358
|
-
`),{...i})}let r=await un(n).support(),o=[`${n}:`,...Object.entries(r).map(([i,a])=>` ${i}: ${a.ok?"ready":`no: ${a.reason}${a.setup?` (${a.setup})`:""}`}`)],s={host:n,support:r};if(n==="premiere"){let i=await Hg();o.push(` panel: ${i.installed?`installed${i.version?` (${i.version})`:""}`:`not installed (this release ships ${await Ug()}; host_setup host=premiere action=install_panel)`}`),s.panel={installed:i.installed,version:i.version}}if(n==="flame"||n==="nuke"){let i=Km[n],a=await i.installed();o.push(` ${i.what}: ${a.installed?`installed in ${a.dest}${a.version?` (${a.version})`:""}`:`not installed (this release ships ${await i.version()}; host_setup host=${n} action=install_panel)`}`),s.panel={installed:a.installed,version:a.version}}if(n==="resolve"){let i=await xa();o.push(` renderplugin: ${i.readiness}${i.version?` (${i.version})`:""}: ${i.next}`),s.renderplugin=i;let{probeStatus:a}=await import("./probe-72QZKMCC.js"),l=await a();o.push(` probe: ${l.next}`),s.probe=l}return X(o.join(`
|
|
359
|
-
`),s)}catch(n){return J(new L("refused",n instanceof Error?n.message:String(n)))}}},{name:"timeline_inspect",hidden:!0,title:"Inspect a session",description:"Look inside a read timeline. detail=summary (default) gives rates/tracks/counts; clips lists every item per track with record and source timecodes, media link state, speed, effects and conform flags; media lists every media reference with path, reel, timecode, raster, fps and whether it is linked; flags lists only the conform flags (things the reader could not carry 1:1); link is the Conform Connect view: which match criteria are usable for this timeline (populated on the references), what is unresolved and why, and the remembered media locations. Use clips to find item_id values for timeline_edit.",inputSchema:{session_id:f.string(),detail:f.enum(["summary","clips","media","flags","link"]).default("summary"),timeline_id:f.string().optional().describe("Limit clips listing to one timeline")},run:async({session_id:e,detail:t,timeline_id:n})=>{try{let r=await bt(e);switch(t){case"clips":return _t(hg(r.session,n));case"media":return _t(gg(r.session));case"flags":return _t(bg(r.session));case"link":return _t(await Tg(r.session));default:return _t(`${await Tr(r.session)}
|
|
360
|
-
history: ${r.history.length?r.history.join(" \u2192 "):"(unedited)"}`)}}catch(r){return J(r)}}},{name:"timeline_query",title:"Query clips, media or markers (Edit Index)",description:`Search a read timeline the way the app's tables do \u2014 the Edit Index +, Unused Media and Marker Utility tools without a host app. table=clips: one row per clip with every IR field (record/source frames, reel, speed, transform, crop, opacity, media columns, link state), plus rec_in_tc / rec_out_tc (record timecode from the timeline's start TC and rate; out is exclusive), track_name (the lane's own name, if any) and track_enabled. table=media: one row per media reference with its usage count (how many clips use it) and link state \u2014 query "is:unused" lists media no cut uses. table=markers: every marker with record TC, color, name, note, duration and the clip under it \u2014 "is:red" lists red markers. query grammar: ${tm} The reply shows at most limit rows (default 50); when more match it starts with TRUNCATED and truncated=true \u2014 never treat that list as complete. columns picks what to show (keys or the app's labels; the reply lists every available column). out_path writes the matched rows as CSV (a file, or a folder for a stamped name; markers use the Resolve suite's marker CSV). table=summary: rates, tracks, counts and the edit history; flags: only the conform flags (what the reader could not carry 1:1); link: which match criteria are usable for this timeline. Read-only: to change what it finds use timeline_edit with the item_ids in the rows.`,inputSchema:{session_id:f.string(),table:f.enum([...zk,...Qx]).default("clips"),query:f.string().optional().describe(`Filter, e.g. 'is:offline', 'speed!=100 track:V1', 'track:in V5,V6', 'overlaps:01:00:10:00..01:00:12:00', 'is:unused', 'is:rate_mismatch', '"Frame rate":23.976', 'is:red note:vfx'. Omit for every row.`),timeline_id:f.string().optional().describe("Only this timeline (clips, markers); default every primary timeline"),columns:f.array(f.string()).optional().describe("Columns to return, by key or label; default the table's working set"),limit:f.number().int().min(1).max(5e3).default(50).describe("Rows in the reply (the CSV always has every match)"),out_path:f.string().optional().describe("Write the matched rows as CSV to this file or folder")},run:async({session_id:e,table:t,query:n,timeline_id:r,columns:o,limit:s,out_path:i})=>{if(Qx.includes(t))return wn("timeline_inspect").run({session_id:e,detail:t,timeline_id:r});try{let a=await bt(e),l=Gk(a.session,{table:t,query:n,timeline_id:r,columns:o,csv:!!i}),c=a.session.timelines.find(m=>m.id===r)?.name??a.source_path.split(/[\\/]/).pop()??"session",u=i?await Kk(l,i,c):null,{csv:p,...d}=l;return X(`${Vk(l,n??"",s)}${u?`
|
|
361
|
-
wrote ${u} (${l.matched} rows)`:""}`,{...d,rows:d.rows.slice(0,s),truncated:l.matched>s,csv_path:u})}catch(a){return J(a)}}},{name:"timeline_edit",title:"Edit a session",description:`Apply one editing operation to the session in place (frame-accurate, on the IR, no host app needed). Operations and their args:
|
|
362
|
-
- slip {timeline_id,item_id,delta_frames}: move the source window, keep the record position
|
|
363
|
-
- trim {timeline_id,item_id,edge:'in'|'out',delta_frames,ripple?}: move one edge (+ lengthens the clip at out / shortens at in)
|
|
364
|
-
- delete {timeline_id,item_id or item_ids:[\u2026],ripple?}: one clip or many in one call (every black spacer at once); ripple closes the gaps
|
|
365
|
-
- move_clip {timeline_id,item_id,to_track_id?,to_frame?}
|
|
366
|
-
- transform {timeline_id,item_id,scale?,opacity?,position_x?,position_y?,rotation?,crop_*?}
|
|
367
|
-
- reformat {timeline_id?,resolution_w,resolution_h,fit?}: change the sequence raster
|
|
368
|
-
- stack_track {timeline_id,from,from_track?,name?}: another timeline's video track (with \`sources\`, another session's) laid onto this one as a new, switched-off top video track at the same record frames \u2014 a reference to align against (timeline_align reference_track)
|
|
369
|
-
- timeline_rate {timeline_id,fps_num,fps_den}
|
|
370
|
-
- add_markers {timeline_id?,markers:[{name?,note?,color?,time,duration?,item_id?}]}: time/duration in timeline frames (from the timeline start) or {value,rate}; duration defaults to 1 frame; the reply says why any marker was dropped
|
|
371
|
-
- stringout {extent?,handles?,name_prefix?}: build a string-out (every used source range, in order) with handles
|
|
372
|
-
- add_clip {timeline_id,path,source_start?,source_duration?,at_frame?,track_id?,fit?,without_audio?}: cut a media file in (probed here; its audio comes with it). source_start/source_duration in source frames (default the whole file); at_frame = timeline frame for the head, OVERWRITING what is there (default: append to the track); track_id default the last video track (an audio-only file goes to the last audio track)
|
|
373
|
-
- add_track {timeline_id,kind?:'Video'|'Audio'}: an empty track on top (video) or bottom (audio); reply carries its track_id
|
|
374
|
-
- add_handles {timeline_id?,handles,name?}: a NEW timeline, every video clip end to end with \xB1handles frames per side clamped to the media (negative trims each end); stills skipped and listed; named {TL}_{N}FR_HANDLES / {TL}_TRIM_{N}FR
|
|
375
|
-
- all_clips {timeline_ids?,handles?,name?,include_disabled?,include_image_sequences?(true),include_stills?,include_offline?(true),include_references?,reference_pattern?('_REF|_REFERENCE| REF'),mark_duplicates?(true),reduce_duplicates?,per_resolution?,stack?,order?:'timeline'|'source_tc'}: a NEW timeline of every piece of footage used across the timelines, overlapping uses of one clip merged; stack=V1 one uncut piece per shot with takes above; duplicates = the same shot under two clips (marked; reduce rebuilds from the copy holding every frame)
|
|
376
|
-
- relink, new_timeline, delete_track, node_sizing, finish_op (advanced)
|
|
377
|
-
args.sources [session_id\u2026]: also run over those sessions' timelines (one host_current via=export per Resolve timeline \u2192 all_clips over several); their ids become '<session_id>/<id>'; only the timelines the op builds are added here, the sources stay untouched.
|
|
378
|
-
Get item_id / timeline_id from timeline_query. Frame deltas are in timeline frames.`,inputSchema:{session_id:f.string(),kind:f.enum(yg),args:f.object({}).passthrough().describe("Arguments for the operation, see description")},run:async({session_id:e,kind:t,args:n})=>{try{let r=await bt(e);t==="add_clip"&&(n=await yN(r.session,n));let o=Array.isArray(n.sources)?n.sources.map(String).filter(i=>i!==e):[],s=o.length?wg(r.session,await Promise.all(o.map(async i=>({id:i,session:(await bt(i)).session}))),t,n):va(r.session,t,n);return await Xt(r,`${t} ${JSON.stringify(n)}`),X(`${s.summary}${s.meta?`
|
|
379
|
-
${JSON.stringify(s.meta,null,1).slice(0,4e3)}`:""}`,{summary:s.summary,meta:s.meta??null})}catch(r){return J(r)}}},{name:"timeline_author",title:"Author a timeline from media",description:"Build a NEW timeline from media files and a shot list, on this machine, with the app's own editing operations (no host app). Each shot: path, source_in (first source frame, 0 = the file's first frame), duration (timeline frames), and optionally at (timeline frame; default append), track (1-based video track; created as needed), scale (percent), position_x/position_y (frame pixels from centre), rotation (degrees clockwise), flip_h/flip_v (mirror), scale_end/position_x_end/position_y_end/rotation_end (animate linearly to these by the shot's last frame), speed (percent of real time; a 29.97 clip played frame for frame in a 23.976 timeline is 80). Returns a session_id for timeline_write / timeline_query. Use to make a test cut whose answer is known exactly (write it, render it in the host, then auto conform the render against the media).",inputSchema:{name:f.string().describe("Timeline name"),fps_num:f.number().int().positive().describe("Timeline rate numerator, e.g. 24000"),fps_den:f.number().int().positive().describe("Timeline rate denominator, e.g. 1001"),width:f.number().int().positive(),height:f.number().int().positive(),start_tc:f.string().optional().describe("Timeline start timecode, e.g. \"00:59:52:00\" (';' before the frames = drop frame); default 00:00:00:00. Shot `at` stays frames from the timeline start"),shots:f.array(f.object({path:f.string(),source_in:f.number().int().nonnegative(),duration:f.number().int().positive(),at:f.number().int().nonnegative().optional(),track:f.number().int().positive().optional(),scale:f.number().positive().optional(),position_x:f.number().optional(),position_y:f.number().optional(),rotation:f.number().optional(),flip_h:f.boolean().optional(),flip_v:f.boolean().optional(),scale_end:f.number().positive().optional(),position_x_end:f.number().optional(),position_y_end:f.number().optional(),rotation_end:f.number().optional(),speed:f.number().positive().optional()})).min(1)},run:async e=>{try{let{session:t,summary:n}=await Vi(e),r=await qn(t,B(Xe(),"authored",`${e.name}.authored`),"authored");return X(`session_id: ${r.id}
|
|
380
|
-
${n.join(`
|
|
381
|
-
`)}
|
|
382
|
-
${await Tr(t)}`,{session_id:r.id})}catch(t){return J(t)}}},{name:"timeline_generate",repoOnly:!0,title:"Generate a test cut from a bucket",description:"Make a NEW timeline from a bucket of media: a seeded random edit with a chosen mix of hard cases, laid in by timeline_author, so its answer is known exactly. Same media + seed + mix = the same cut. Every shot is tagged with the classes it tests: "+Ki.join(", ")+". mix: a preset ("+Object.keys(Fs).join(", ")+"; default hard) or weights per class. Returns a session_id for timeline_write and the shot list with record ranges and classes. Use to test auto conform, compare or any matcher: generate, write, render in the host (optionally grade it), auto conform the render, score per class.",inputSchema:{media:f.array(f.string()).min(1).describe("Media files or folders (walked; folders named *proxy*/*proxies* or cache skipped)"),seed:f.number().int().describe("Random seed"),shots:f.number().int().positive().max(500).optional().describe("V1 shots (default 24)"),audio:f.boolean().optional().describe("Lay sync sound in under normal-speed shots whose clips have it (needed for frankenbite)"),look:f.boolean().optional().describe("Look at each planned shot and re-plan around flat picture \u2014 empty backdrops, grey cards (default true)"),mix:f.union([f.enum(Object.keys(Fs)),f.record(f.enum(Ki),f.number().nonnegative())]).optional(),name:f.string().optional(),fps_num:f.number().int().positive().optional().describe("Default 24000"),fps_den:f.number().int().positive().optional().describe("Default 1001"),width:f.number().int().positive().optional().describe("Default 1920"),height:f.number().int().positive().optional().describe("Default 1080")},run:async e=>{try{let t=await Iv(e),n=e.name??`generated ${e.seed}`,r=await qn(t.session,B(Xe(),"authored",`${n}.authored`),"authored"),o=new Map;for(let i of t.shots)for(let a of i.classes)o.set(a,(o.get(a)??0)+1);let s=[`session_id: ${r.id}`,`${t.shots.length} shots from ${t.pool.used} clips: ${[...o].map(([i,a])=>`${a} ${i}`).join(", ")}`,...t.pool.skipped.length?[`skipped ${t.pool.skipped.length}: ${t.pool.skipped.slice(0,5).join("; ")}`]:[],await Tr(t.session)];return X(s.join(`
|
|
383
|
-
`),{session_id:r.id,shots:t.shots,titles:t.titles,skipped:t.pool.skipped})}catch(t){return J(t)}}},{name:"timeline_relink",title:"Link / relink media (Conform Connect)",description:`The app's Conform Connect link wizard, as one call, on the same matcher and coverage law. Finds the media for the session's unbound references under a folder on this machine and repoints them.
|
|
384
|
-
gather: 'walk' (default) scans the folder recursively (name-first pre-filter, cap 2000) and matches by the criteria; 'path' is strict link \u2014 each reference must exist at its recorded relative path under the folder, no scan.
|
|
385
|
-
criteria (all optional; default = file_name on, tight): file_name + file_name_mode tight|loose (loose strips _Sxxx, _vN and proxy words like proxy/prx/offline/h264/prores and accepts \u22650.6 similarity), reel_name, total_duration, resolution, bit_depth, file_format, codec, media_umid, extensions, picture (the analysis engine compares the reference's own file with each candidate at the same TC; needs the reference readable). Enabled criteria are strict AND. Timecode containment (the file must hold the cut) and fps are ALWAYS enforced. For renamed media use reel_name=true, file_name=false. For proxy\u2192OCF use file_name_mode loose and leave resolution/codec off.
|
|
386
|
-
tolerances: timecode_tolerance_frames (1), duration_tolerance_seconds (0.1), min_name_similarity (0.6), fps_tolerance (0.005).
|
|
387
|
-
scope: ref_ids limits to a zone; lane video|audio|both limits by track usage; reset=true re-points already-linked refs in scope (they are unbound first).
|
|
388
|
-
dry_run=true proposes without changing anything: per reference matched/ambiguous/unmatched, the chosen file, confidence, reasons, refusals with the coverage reason, and alternatives; compare=true adds the per-criterion project-vs-media table. accept=[{ref_id,candidate_id}] commits only those rows (ids from a dry run) \u2014 the manual pick. Without accept, every matched row is applied. media_root omitted \u2192 the remembered locations are tried; remember=true saves this folder. Ends with the link summary and what is still unresolved, with the reason.`,inputSchema:{session_id:f.string(),media_root:f.string().optional().describe("Folder to link from; omit to use remembered locations"),gather:f.enum(["walk","path"]).default("walk"),criteria:f.object({file_name:f.boolean().optional(),file_name_mode:f.enum(["tight","loose"]).optional(),reel_name:f.boolean().optional(),total_duration:f.boolean().optional(),resolution:f.boolean().optional(),bit_depth:f.boolean().optional(),file_format:f.boolean().optional(),codec:f.boolean().optional(),media_umid:f.boolean().optional(),extensions:f.array(f.string()).optional().describe("Only consider these extensions, e.g. ['mxf','mov']"),picture:f.boolean().optional().describe("Also match by picture where the reference's own file is readable (proxy \u2192 OCF): each candidate must show the same frames at the same TC; picks the one right file among ambiguous candidates, refuses a name match that shows another picture or a TC slip")}).optional(),tolerances:f.object({timecode_tolerance_frames:f.number().optional(),duration_tolerance_seconds:f.number().optional(),min_name_similarity:f.number().optional(),fps_tolerance:f.number().optional(),aspect_tolerance:f.number().optional()}).optional(),ref_ids:f.array(f.string()).optional().describe("Only these references (a zone)"),lane:f.enum(["video","audio","both"]).default("both"),reset:f.boolean().default(!1).describe("Re-point refs in scope even if already linked"),dry_run:f.boolean().default(!1).describe("Propose only; change nothing"),compare:f.boolean().default(!1).describe("With dry_run: show the per-criterion comparison for each matched row"),accept:f.array(f.object({ref_id:f.string(),candidate_id:f.string()})).optional().describe("Commit only these rows (from a dry run)"),cap:f.number().int().min(1).max(2e4).default(2e3),remember:f.boolean().default(!1)},run:async e=>{try{let t=await bt(e.session_id),n=await Vg(t.session,e);return n.changed&&(t.session=n.session,await Xt(t,n.note)),_t(n.text)}catch(t){return J(t)}}},{name:"timeline_write",protectedStages:["write"],title:"Write a timeline for a host",description:"Write the session for a host, on this machine. Prefer a DESTINATION (the host the user is going to): resolve, premiere, avid, flame, finalcut, baselight, protools \u2014 it writes the host's native file AND its fallback (e.g. resolve = .drt + XML for Resolve; avid = .avb + AAF) into one folder named for the host, with a README saying which to open first. Single formats still work as targets: resolve-drt (DaVinci Resolve timeline, preferred for Resolve), premiere-prproj, avid-avb (Media Composer bin), avid-aaf, flame-archive, baselight-blscene, finalcut-fcpxmld, resolve-xmeml, flame-fcpxml. Short aliases drt/prproj/avb/aaf/xmeml/fcpxml work (OTIO is read, not written). Returns the written path and the capability issues: what this target host cannot carry from the source (nests flattened, effects dropped, etc.) \u2014 always relay those to the user. A conversion on conform.tools keeps the original timeline file with it, as on the website, so the result is checked (never media; off with account_telemetry).",inputSchema:{engine:f.enum(["local","hosted"]).optional().describe("Where the conversion runs: local = this machine, offline, nothing uploaded; hosted = conform.tools (the website's engine). Default: local when this build has it"),session_id:f.string(),target:f.string().describe("A destination (resolve, premiere, avid, flame, finalcut, baselight, protools) or a single target format, e.g. resolve-drt, or an alias like drt"),out_path:f.string().optional().describe("Output file path, or a directory (file name is derived; a destination writes a host-named folder inside it). Defaults next to the source file."),timeline_id:f.string().optional().describe("Write only this timeline (e.g. the one timeline_edit add_handles / all_clips just built); default the session's timelines as read")},run:async({session_id:e,target:t,out_path:n,timeline_id:r})=>{try{let o=await bt(e);if(r&&!o.session.timelines.some(c=>c.id===r))return J(new L("not_found",`no timeline ${r} in session ${e} (${o.session.timelines.map(c=>`${c.id} "${c.name}"`).join(", ")})`));let s=r?{...o.session,timelines:o.session.timelines.filter(c=>c.id===r||c.kind==="compound")}:o.session;if(Wh(t)){let c=await _g(s,t,n,o.source_path);await Xt(o,`write ${t} \u2192 ${c.folder}`);let u=c.files.map(p=>`${p.path} (${p.bytes} bytes, ${p.target})`+(p.issues.length?`
|
|
389
|
-
issues (${p.issues.length}):
|
|
390
|
-
${p.issues.map(d=>` - [${d.severity??"info"}] ${d.code?`${d.code}: `:""}${d.message}`).join(`
|
|
391
|
-
`)}`:`
|
|
392
|
-
no capability issues`));return _t(`wrote ${c.folder}/ \u2014 README.txt says which to open first
|
|
393
|
-
${u.join(`
|
|
394
|
-
`)}${c.pending?`
|
|
395
|
-
${c.pending} is not included yet (writer pending its host's import law)`:""}`)}let i=await ru(s,t,n,o.source_path);await Xt(o,`write ${t} \u2192 ${i.path}`);let a=i.issues.length?`
|
|
396
|
-
issues (${i.issues.length}):
|
|
397
|
-
${i.issues.map(c=>`- [${c.severity??"info"}] ${c.code?`${c.code}: `:""}${c.message}`).join(`
|
|
398
|
-
`)}`:`
|
|
399
|
-
no capability issues`,l=await Ys("conform-artist",["write"]);return _t(`wrote ${i.path} (${i.bytes} bytes)${a}${l?`
|
|
400
|
-
|
|
401
|
-
Reading this write (conform.tools playbook):
|
|
402
|
-
${l}`:""}`)}catch(o){return J(o)}}},{name:"timeline_routes",title:"Supported formats and operations",description:"List what can be read, what can be written (first-class vs beta), aliases, and the editing operations. Use when asked 'can you convert X to Y' or what the tool supports.",inputSchema:{},run:()=>_t(vg())},{name:"timeline_sessions",title:"List sessions",description:"List sessions read earlier (id, source file, format, when, edit history). Sessions persist across restarts.",inputSchema:{},run:async()=>{let e=await Zf();return _t(e.length?e.map(t=>`${t.id} ${t.source_path} (${t.source_format}) updated ${t.updated_at}${t.history.length?` \u2014 ${t.history.length} edits`:""}`).join(`
|
|
403
|
-
`):"(no sessions)")}},{name:"session_export",title:"Export Session IR",description:"Write the session's IR JSON (the engine's canonical timeline representation) to a file, for tooling, diffing or archiving.",inputSchema:{session_id:f.string(),out_path:f.string()},run:async({session_id:e,out_path:t})=>{try{let n=await bt(e);return await Ve(t,JSON.stringify(n.session,null,1)),_t(`wrote ${t}`)}catch(n){return J(n)}}},{name:"media_probe",title:"Probe a media file",description:"Read a media file's facts on this machine (never uploads): container, codec, raster, frame rate, start timecode, frame count, duration, audio, reel. Supports mov/mp4/m4v (ProRes, DNx, H.264/HEVC\u2026), braw, crm, mxf (ARRI/Sony/DNx), wav, RED .R3D (spanned clips: any part or the .RDC folder), stills (exr/dpx/tiff/jpg/png/dng/cr3: raster; an EXR's own framesPerSecond + timeCode from its header; a numbered frame's whole sequence from its folder \u2014 first/last, length, gaps, start TC). Use before media_trim to know the file's start timecode and length. A WAV has no frame rate: pass fps (the project's) for its BWF start TC and length in frames; without it both 23.976 and 24 are shown.",inputSchema:{path:f.string(),fps:f.number().positive().optional().describe("audio-only files: the video rate to count the BWF timecode and length at (23.976, 24, 25, 29.97\u2026)")},run:async({path:e,fps:t})=>{try{if(j1(e)){let r=await q1(e);return X(U1(r),{...r})}let n=await mt(e);return X(P1(n,t),{...n})}catch(n){return J(n)}}},{name:"timeline_diff",protectedStages:["canonicalize"],title:"Source diff of two cuts (online vs editorial)",description:"Compare WHERE THE PICTURE COMES FROM in two cuts aligned by record TC: A = the online/colour timeline, B = the newest editorial turnover (each a session_id or a timeline file). Per record frame it takes the topmost enabled video clip (by_track=true: each video track by name, V1 vs V1\u2026) and reports the record ranges whose source differs: only_in_a / only_in_b (missing or extra clips), different_file (another file or reel \u2014 temp vs master; a different TC base is called out), same_name_different_clip (same file name but a different start TC or length: dated batch folders reuse names, never trust the name alone), source_tc (same file, slipped N frames). Starts with the count per kind; every range lists both sides' file, source TC, track and item id. csv_path / edl_path write every range (the EDL carries B's sources: what to drop into A); session=true makes a new session of B's clips under those ranges only (an insert timeline for timeline_write). Read-only on both cuts.",inputSchema:{a_session_id:f.string().optional().describe("A (online/colour) as a session"),a:f.string().optional().describe("A as a timeline file, instead of a_session_id"),b_session_id:f.string().optional().describe("B (editorial turnover) as a session"),b:f.string().optional().describe("B as a timeline file, instead of b_session_id"),a_timeline_id:f.string().optional(),b_timeline_id:f.string().optional(),by_track:f.boolean().default(!1).describe("Compare each video track by name instead of the topmost picture"),limit:f.number().int().min(1).max(5e3).default(100).describe("Ranges in the reply (files always have all)"),csv_path:f.string().optional(),edl_path:f.string().optional(),session:f.boolean().default(!1).describe("Also create a session of B's differing clips (insert timeline)")},run:async({a_session_id:e,a:t,b_session_id:n,b:r,a_timeline_id:o,b_timeline_id:s,by_track:i,limit:a=100,csv_path:l,edl_path:c,session:u})=>{try{let p=async(b,w,_)=>{if(b){let v=await bt(b);return{session:v.session,name:`session ${b} (${ie(v.source_path)})`}}if(w)return{session:(await ts(w)).session,name:ie(w)};throw new L("invalid_args",`give ${_}_session_id or ${_} (a timeline file)`)},d=await p(e,t,"a"),m=await p(n,r,"b"),h=D_(d.session,m.session,{a_timeline_id:o,b_timeline_id:s,by_track:i}),g=[];l&&(await Ve(l,B_(h.ranges)),g.push(`CSV: ${l} (${h.ranges.length} ranges)`)),c&&(await Ve(c,q_(h,`${h.tb.name} SOURCE DIFF`)),g.push(`EDL: ${c} (B sources)`));let y;if(u&&h.ranges.length){let b=await qn(U_(m.session,h),B(Xe(),"authored",`${h.tb.name} source diff.authored`),"diff");y=b.id,g.push(`session_id: ${b.id} (B's clips under the differing ranges; timeline_write it)`)}let k=Object.fromEntries(km.map(b=>[b,h.ranges.filter(w=>w.kind===b).length]));return X([j_(h,d.name,m.name,a),...g].join(`
|
|
404
|
-
`),{counts:k,total:h.ranges.length,ranges:h.ranges.slice(0,a),truncated:h.ranges.length>a,session_id:y,csv_path:l,edl_path:c})}catch(p){return J(p)}}},{name:"media_aspect",title:"Active picture and OAR of a movie",description:"Find a movie's active picture (letterbox / pillarbox / windowbox) and the original aspect ratio it implies, snapped to the standard ratios (1.33, 1.78, 1.85, 1.90, 2.00, 2.39 \u2026), with the OAR raster (full width, even height). 16 frames across the clip; a bar counts only when \u226580% of them carry it, so fades and black leaders don't invent one. Use on the screener / editorial REF to decide OAR deliverables vs a 16x9 container, and on a render to confirm it.",inputSchema:{path:f.string(),samples:f.number().int().min(4).max(64).optional().describe("Frames sampled (default 16)")},run:async({path:e,samples:t})=>{try{let n=await yT(e,t);return X(wT(n),{...n})}catch(n){return J(n)}}},{name:"media_find",title:"Find media by name or ID on a volume",description:"Search a folder or volume (read-only walk) for media whose name holds a name or ID fragment, and probe each match so temp and master can be told apart: codec, raster, rate, start\u2013end TC, frames, duration. Matching ignores case, spaces/underscores/dots and doubled extensions (`X.mov.mov`, `X.mov_001.mov`); when the whole fragment is not found, a file that holds every digit-bearing token of it matches as an id match (a misspelt word around the ID). Files with the same name in different folders are called out: dated batch folders reuse names for DIFFERENT clips, so match by TC + duration, never by name alone. Bounded by max_depth, max_entries and time_limit_s; when a bound stops it the reply starts with TRUNCATED.",inputSchema:{path:f.string().describe("Folder or volume to search"),query:f.string().min(2).describe("Name or ID fragment, e.g. 'XD32995' or 'XD32995_0158_0221_MultiClip.mov'"),max_depth:f.number().int().min(0).max(30).default(10),max_entries:f.number().int().min(1).max(2e6).default(2e5).describe("Directory entries to visit before stopping"),time_limit_s:f.number().min(1).max(600).default(60),probe:f.boolean().default(!0).describe("Probe each match (codec, raster, rate, TC, length)"),limit:f.number().int().min(1).max(5e3).default(100)},run:async({path:e,query:t,max_depth:n,max_entries:r,time_limit_s:o,probe:s,limit:i})=>{try{let a=await F1(e,t,{max_depth:n??10,max_entries:r??2e5,time_limit_s:o??60,probe:s??!0});return i??=100,X(O1(a,e,t,i),{scanned:a.scanned,truncated:a.truncated,total:a.hits.length,hits:a.hits.slice(0,i).map(l=>({path:l.path,match:l.match,size:l.size,facts:l.facts?ba(l.facts):null,source_timecode:l.facts?.source_timecode??null,frames:l.facts?.available_range?.duration?.value??l.facts?.declared_duration?.value??null,error:l.error}))})}catch(a){return J(a)}}},{name:"media_coverage",title:"Does a file cover these TC ranges (and how much handle)?",description:"Check that a media file holds the source ranges a cut needs, and how much handle it has: per range covered, or NOT covered and short by N frames at head/tail, plus the head/tail handle in frames. ranges: [{in, out, label?}] as absolute source timecode (the file's own TC, e.g. 23:59:12:10; out exclusive, as an EDL reads; TC wraps at midnight) or file-local frame numbers. Or session_id + item_ids: the clips' used source ranges (from their own media's TC), checked against path, or against each clip's own file when path is omitted. A master with a different TC base than the temp the cut was made on will show NOT covered: that is the answer (the client's clip-TC list is then the mapping). handles: also flag ranges with less than this many frames each side.",inputSchema:{path:f.string().optional().describe("The media file to check (required with ranges)"),ranges:f.array(f.object({in:f.union([f.string(),f.number().int()]),out:f.union([f.string(),f.number().int()]),label:f.string().optional()})).optional(),session_id:f.string().optional(),item_ids:f.array(f.string()).optional().describe("Clip item ids (timeline_query / timeline_query)"),handles:f.number().int().min(0).default(0).describe("Required handle per side, frames")},run:async({path:e,ranges:t,session_id:n,item_ids:r,handles:o})=>{try{let s=new Map,i=[];if(t?.length){if(!e)throw new L("invalid_args","path is required with ranges");s.set(e,[...t])}if(n){if(!r?.length)throw new L("invalid_args","item_ids is required with session_id");let d=(await bt(n)).session,m=new Map((d.media_references??[]).map(g=>[g.id,g])),h=new Map(d.timelines.flatMap(g=>g.tracks.flatMap(y=>y.items)).map(g=>[g.id,g]));for(let g of r){let y=h.get(g);if(!y?.source_range){i.push(`${g}: no such clip with a source range`);continue}let k=y.media_reference_id?m.get(y.media_reference_id):void 0,b=(k?.local_path??k?.target_url??"").replace(/^file:\/\//,""),w=e??b;if(!w){i.push(`${g}: the clip has no media path; pass path`);continue}let _=y.source_range.start.rate||k?.source_fps||24,v=k?.source_fps||_,R=y.source_range.start.value*v/_,S=y.source_range.duration.value*v/_,T=k?.source_timecode?jt(k.source_timecode,v):null,x=Math.round(v)*86400,$=!!k?.source_timecode?.includes(";"),U=E=>T==null?Math.round(E):He(Math.round(T+E)%x,v,$);(s.get(w)??s.set(w,[]).get(w)).push({label:`${g} ${y.name??""}`.trim(),in:U(R),out:U(R+S)})}}if(!s.size)throw new L("invalid_args",i.length?i.join("; "):"give path + ranges, or session_id + item_ids");let a=[],l=[],c=0,u=0;for(let[d,m]of s){let h=await L1(d,m,o);l.push({path:d,facts:ba(h.facts),rows:h.rows}),a.push(`${d}
|
|
405
|
-
${ba(h.facts)}`,...h.rows.map(g=>` - ${g.label}: ${g.in_tc}\u2013${g.out_tc} (${g.frames} fr) ${g.note}`)),c+=h.rows.filter(g=>!g.covered).length,u+=h.rows.length}let p=c?`${c} of ${u} range${u===1?"":"s"} NOT covered`:`all ${u} range${u===1?"":"s"} covered`;return X([p,...a,...i.map(d=>`skipped ${d}`)].join(`
|
|
406
|
-
`),{covered:u-c,not_covered:c,files:l,skipped:i})}catch(s){return J(s)}}},{name:"media_sort",title:"File a folder of deliverables by a recipe",description:`0.9.5's Output Sorter: every file of \`folder\` filed into folders by a recipe \u2014 ordered rules (first match wins: a whole keyword, contains, starts / ends with, an extension, a regex with {1}\u2026{9}, any), a project name read from the file name ({PROJECT}), destination templates ({PROJECT} {RULE} {KEYWORD} {EXT} {YYYY} {MM} {DD} \u2026). Nothing is ever overwritten (a taken name is skipped, or kept under a free name), a destination never leaves its root, apply re-plans from disk, every run is undoable (undo=<undo_id>, or media_move undo=\u2026). recipe: a built-in (${Lc.map(e=>e.id).join(", ")}), or a recipe object / a .json file of one. mode plan shows where every file goes; apply files them (all, or \`only\`: source paths).`,inputSchema:{folder:f.string().describe("The folder of files to sort"),recipe:f.union([f.string(),f.record(f.unknown())]).default("mixes-splits").describe("A built-in recipe id, a recipe object, or a path to a recipe .json"),mode:f.enum(["plan","apply"]).default("plan"),recursive:f.boolean().optional().describe("Into subfolders too"),destination_root:f.string().optional().describe("File into this folder instead of inside `folder`"),operation:f.enum(["move","copy"]).optional().describe("Override the recipe's (copy keeps the originals)"),only:f.array(f.string()).optional().describe("apply: just these source paths")},run:async({folder:e,recipe:t,mode:n,recursive:r,destination_root:o,operation:s,only:i})=>{try{let a=typeof t=="string"?Lc.find(d=>d.id===t)?.recipe??JSON.parse(await et(Nt(t))):t,l={directories:[Nt(e)],recursive:!!r,include_hidden:!1,destination_root:o?Nt(o):"",recipe:{...a,...s?{operation:s}:{}},only:i??[]};if(n==="plan"){let d=await Wt({op:"sort_plan",request:l});if(d.ok===!1)return J(new L("invalid_args",String(d.why)));let m=d.counts;return X(`${d.scanned} file(s): ${Object.entries(m).map(([h,g])=>`${g} ${h}`).join(", ")}${d.warnings.length?`
|
|
407
|
-
${d.warnings.join(`
|
|
408
|
-
`)}`:""}`,{...d})}let c=await Wt({op:"sort_apply",request:l});if(c.ok===!1)return J(new L("refused",String(c.why)));let u=c.moved,p=u.length?`files-${Date.now().toString(36)}`:void 0;return p&&(await Ke(B(Xe(),"move-undo")),await Ve(B(Xe(),"move-undo",`${p}.json`),JSON.stringify({sort:!0,moved:u,created_dirs:c.created_dirs}))),X([`filed ${u.length} file(s)${Number(c.skipped)?`, ${c.skipped} left where they were`:""}`,...c.errors.map(d=>`not filed: ${d}`),...p?[`undo_id: ${p} (media_move undo=\u2026 puts them back)`]:[]].join(`
|
|
409
|
-
`),{...c,...p?{undo_id:p}:{},ok:!c.errors.length})}catch(a){return J(a)}}},{name:"media_odd_images",title:"Make odd-sized stills even",description:"0.9.5's Odd Image Size Fixer: every still in `folder` (or `files`) whose width or height is odd \u2014 most codecs and some hosts refuse it, Resolve draws a black line \u2014 rewritten in its own format at even dimensions (the last row / column cropped; with max, scaled to fit first), ICC profile and EXIF kept. The original is copied first to 'zORIGINAL IMAGES' beside it (the first original is never overwritten). mode plan lists what would change; apply rewrites; undo=<undo_id> (or media_move undo=\u2026) puts every original back. PNG, JPEG, TIFF, WebP, GIF, BMP.",inputSchema:{folder:f.string().optional().describe("A folder of stills"),files:f.array(f.string()).optional().describe("\u2026or these files"),max:f.number().int().positive().optional().describe("Also scale anything larger to fit this many pixels"),mode:f.enum(["plan","apply"]).default("plan")},run:async({folder:e,files:t,max:n,mode:r})=>{try{let o=(t??[]).map(u=>Nt(u));if(e){let u=Nt(e);for await(let p of Deno.readDir(u))p.isFile&&!p.name.startsWith(".")&&o.push(B(u,p.name))}if(o=[...new Set(o)].sort(),!o.length)return J(new L("invalid_args","media_odd_images needs a folder or files"));let i=(await Wt({op:"odd_fix",files:o,...n?{max:n}:{},dry_run:r==="plan"})).files,a=i.filter(u=>u.status==="fixed"),l=i.filter(u=>u.status==="error"),c;return r==="apply"&&a.length&&(c=`files-${Date.now().toString(36)}`,await Ke(B(Xe(),"move-undo")),await Ve(B(Xe(),"move-undo",`${c}.json`),JSON.stringify({odd:!0,fixed:a.map(u=>[u.path,u.backup])}))),X([`${r==="plan"?"would make":"made"} ${a.length} of ${o.length} still(s) even${a.length?`: ${a.slice(0,8).map(u=>`${ie(u.path)} ${u.original}\u2192${u.new}`).join(", ")}${a.length>8?" \u2026":""}`:""}`,...l.map(u=>`not done: ${ie(u.path)} \u2014 ${u.why}`),...c?[`undo_id: ${c} (media_move undo=\u2026 puts the originals back)`]:[]].join(`
|
|
410
|
-
`),{files:i,...c?{undo_id:c}:{},ok:!l.length})}catch(o){return J(o)}}},{name:"media_patch_sequence",title:"Patch frames into an image sequence",description:`0.9.5's Image Sequence Patcher: the folders beside the sequence's folder with "patch" in their name hold fixed frames; each replaces the sequence's frame of the same name. The original goes to <sequence>_originalframes (numbered when that frame is backed up already), the patch is COPIED in (a failed copy puts the original straight back), the used patch folders are filed under zAPPLIED_PATCHES. mode plan lists every patch frame and whether the sequence has it; apply patches (all, or \`only\`: "folder/file" keys); undo=<undo_id> (or media_move undo=\u2026) puts everything back.`,inputSchema:{sequence:f.string().describe("The image sequence's folder (or a frame in it)"),folders:f.array(f.string()).optional().describe(`The patch folders (names beside the sequence's folder); default every one with "patch" in its name`),mode:f.enum(["plan","apply"]).default("plan"),only:f.array(f.string()).optional().describe('apply: just these "folder/file" keys')},run:async({sequence:e,folders:t,mode:n,only:r})=>{try{let o=Nt(e);await At(o).then(a=>a.isDirectory,()=>!1)||(o=o.replace(/[\\/][^\\/]+$/,""));let s=t?.length?t:await zg(o);if(!s.length)return J(new L("not_found",`no patch folder beside ${ie(o)} (a folder next to it with "patch" in its name)`));if(n==="plan"){let a=await Gg(o,s);return X(`${a.length} patch frame(s) in ${s.join(", ")}; ${a.filter(l=>!l.replaces).length} not in the sequence`,{sequence:o,folders:s,rows:a})}let i=await Kg(o,s,r?.length?new Set(r):void 0);return X([`patched ${i.patched} frame(s) into ${ie(o)}; originals in ${ie(o)}_originalframes, patch folders filed under zAPPLIED_PATCHES`,...i.errors.map(a=>`not patched: ${a}`),...i.undo_id?[`undo_id: ${i.undo_id} (media_move undo=\u2026 puts it all back)`]:[]].join(`
|
|
411
|
-
`),{...i,ok:!i.errors.length})}catch(o){return J(o)}}},{name:"media_move",title:"Move media files into a folder (and back)",description:"Move files into a folder on disk (Unused Media's 'move the files'): the destination is proved writable first; a missing file is skipped and named; a name already taken gets ' (1)'; across volumes it copies, checks the size and deletes. Every move is recorded: undo=<undo_id> puts each file back (never over a file that has appeared at the old path). Media pool clips are not relinked: move only media no timeline uses.",inputSchema:{paths:f.array(f.string()).optional().describe("The files to move"),destination:f.string().optional().describe("The folder they go into"),undo:f.string().optional().describe("Put back the files a move recorded (its undo_id)"),renames:f.array(f.object({from:f.string(),to:f.string()})).optional().describe("Rename files in place instead (Image Sequence Renamer): collision-safe (frames may shift onto each other's numbers), refused before anything moves when a target is a file outside the batch; undoable")},run:async({paths:e,destination:t,undo:n,renames:r,__progress:o})=>{try{if(r?.length){let i=await Tu(r.map(a=>({from:Nt(a.from),to:Nt(a.to)})));return X([`renamed ${i.moved.length} file(s)`,...i.skipped.length?[`${i.skipped.length} missing, skipped`]:[],...i.failed.map(a=>`failed: ${ie(a.path)} \u2014 ${a.error}`),...i.undo_id?[`undo_id: ${i.undo_id} (media_move undo=\u2026 puts the names back)`]:[]].join(`
|
|
412
|
-
`),{...i})}if(n){let i=await Zb(n);return X(`put back ${i.restored} file(s)${i.failed.length?`; ${i.failed.length} not: ${i.failed.map(a=>`${ie(a.path)} (${a.error})`).join("; ")}`:""}`,{...i,ok:!i.failed.length})}if(!e?.length||!t)return J(new L("invalid_args","media_move needs paths and destination (or undo)"));let s=await Yb(e,Nt(t),o);return X([`moved ${s.moved.length} file(s) to ${t}`,...s.skipped.length?[`${s.skipped.length} offline / missing, skipped: ${s.skipped.map(i=>ie(i)).join(", ")}`]:[],...s.failed.map(i=>`failed: ${ie(i.path)} \u2014 ${i.error}`),...s.undo_id?[`undo_id: ${s.undo_id} (media_move undo=\u2026 puts them back)`]:[]].join(`
|
|
413
|
-
`),{...s})}catch(s){return J(s)}}},{name:"media_trim",title:"Trim a media file",description:"Cut a shorter file out of a source WITHOUT re-encoding (byte-exact essence copy, index rebuilt; source timecode is preserved so the trim relinks in any host). in/out are frame indexes (0 = first frame) or timecodes relative to the file's start TC; out is the LAST frame included unless out_exclusive=true. handles adds frames on both sides (clamped to the file). Supports mov/mp4/m4v (ProRes, DNx, H.264/HEVC \u2014 long-GOP snaps to keyframes), braw, crm, mxf, wav, and RED .R3D (spanned .RDC clips: pass any part or the folder; output is a new .RDC). Returns the new path(s) and the frames written.",inputSchema:{path:f.string(),in:f.union([f.string(),f.number().int()]).describe("First frame: frame index or timecode like 01:00:10:00"),out:f.union([f.string(),f.number().int()]).describe("Last frame (inclusive) or timecode; set out_exclusive for an edit-style out point"),out_exclusive:f.boolean().optional(),handles:f.number().int().min(0).optional().describe("Extra frames on each side"),out_path:f.string().optional().describe("Output file or directory; default is next to the source as <name>_trim_<in>-<out>.<ext>")},run:async e=>{try{let t=await ga(e),n=t.facts.streams?.find(r=>r.kind==="video");return _t(`${t.outputs.map(r=>`wrote ${r.path} (${(r.bytes/1e6).toFixed(1)} MB${r.part?`, part ${r.part}`:""})`).join(`
|
|
414
|
-
`)}
|
|
415
|
-
frames ${t.first_frame}\u2013${t.last_frame} (${t.frames} frames)${t.asked?` \u2014 snapped to keyframes (asked ${t.asked.first_frame}\u2013${t.asked.last_frame})`:""}
|
|
416
|
-
source: ${n?.codec??"?"} ${n?.width??"?"}x${n?.height??"?"} @ ${t.fps} fps, start TC ${t.facts.source_timecode??"none"}`)}catch(t){return J(t)}}},{name:"media_patch",long:!0,title:"Patch frames into a master",description:"Cut a fixed range of frames into a finished master BY TIMECODE, WITHOUT re-encoding (the Resolve 'bypass re-encode' fix, for ProRes and DNxHD/HR .mov). patch = a render of the fixed range in the master's exact spec with record TC: codec/profile, raster, rate, alpha/depth and color tags are checked first, the patch lands at (patch start TC \u2212 master start TC) and needs a TC track at the master's TC rate and DF/NDF; a mismatch, a patch without TC or a range outside the master is refused and nothing is written. in/out on the master (frames or timecodes, like media_trim; out inclusive) only cross-check that placement or pick part of the patch: an in= that disagrees with the TC is refused. Patch frames may be bigger or smaller than the ones they replace. mode new (default): a new file beside the master (<name>_patched), rewritten contiguously in the master's interleave order; the master untouched. mode section: a new file of just the patched range with the master's TC and audio. mode in_place: ONLY when the user asks to modify the master itself \u2014 the patch frames are appended and the index rewritten (the file grows by the patch, the replaced frames stay as dead bytes, the patched span loses interleave locality), the old index kept so mode=undo restores the file byte for byte. mode check: the spec + TC check, nothing written. mode plan (H.264/HEVC, BEFORE rendering a patch; needs in/out, no patch): the whole-GOP span of the master to render (keyframe at/before in \u2192 frame before the next keyframe after out; an open GOP after it included), its TCs, the GOP length and B-frames. Every write is verified (frame count, the master's TC track unchanged, frames at the patch's TC byte-identical to the patch and decoding to its pixels, the frames either side the master's, audio and untouched frames identical) and rolled back if it fails. in_place proves audio/TC untouched from the index by default (every sample at its original offset and size, the write append-only), so a feature master patches in about a minute; verify=full re-reads and hashes them (minutes a pass over a share). patches=[\u2026] puts several into one master in one call (all checked first; overlap refused). Long: background=true for a job id with progress. H.264/HEVC (long-GOP): a patch that replaces whole closed GOPs encoded like the master's (span from a master keyframe to the frame before the next, identical avcC/hvcC, keyframes and B-frame offsets) cuts in with no re-encode; anything else is refused, naming the GOP span to render.",inputSchema:{path:f.string().describe("The master .mov"),patch:f.string().optional().describe("The render of the fixed range (not needed for mode=undo)"),mode:f.enum(["new","section","in_place","check","undo","plan"]).optional().describe("Default new; in_place only when asked to modify the master itself; plan before rendering a long-GOP patch"),in:f.union([f.string(),f.number().int()]).optional().describe("Cross-check: the master frame (index or timecode) to start at; must agree with the patch's TC"),out:f.union([f.string(),f.number().int()]).optional().describe("Last master frame to replace (inclusive); default: to the end of the patch"),patch_in:f.number().int().min(0).optional().describe("First patch frame to use (default: the one at in= by TC, else 0)"),out_path:f.string().optional().describe("Output file or folder for mode new/section; never overwritten"),patches:f.array(f.string()).optional().describe("in_place/check: several patch renders into this master in one call, each placed by its own TC (instead of patch)"),verify:f.enum(["index","full"]).optional().describe("in_place: index (default) proves audio/TC untouched from the index; full re-reads and hashes them")},run:async({__progress:e,__signal:t,...n})=>{try{let r=await Rm(n,e);return X(r.text,r.data)}catch(r){return J(r)}}},{name:"media_retag",title:"Retag a file's color (no re-encode)",description:"Change what a ProRes .mov SAYS its color is (primaries / transfer / matrix), WITHOUT converting a pixel: the video colr atom (nclc/nclx) and every ProRes frame header are rewritten in place (same size, nothing moves) and read back. Use it for 'the same file tagged Rec.709' or to fix a mis-tagged render. Names: rec709, p3d65, dci-p3, rec2020 (primaries); rec709/g24, g26, pq, hlg (transfer); rec709, rec2020 (matrix); or ITU-T H.273 codes. out_path (file or folder) = a retagged copy, never overwriting (name it with the artist's naming: the color/gamma fields change); in_place=true only when the user asks to change the file itself. The file's hash changes, so a checksum manifest that went out with it is stale. Refused: H.264/HEVC (the tags live in the SPS, a re-encode) and files without a colr atom.",inputSchema:{path:f.string().describe("The ProRes .mov to retag"),primaries:f.union([f.string(),f.number().int().min(0).max(255)]).describe("rec709 | p3d65 | dci-p3 | rec2020 | H.273 code"),transfer:f.union([f.string(),f.number().int().min(0).max(255)]).describe("rec709 (=g24) | g26 | pq | hlg | H.273 code"),matrix:f.union([f.string(),f.number().int().min(0).max(255)]).describe("rec709 | rec2020 | H.273 code"),out_path:f.string().optional().describe("A retagged copy (file or folder); never overwritten"),in_place:f.boolean().optional().describe("Retag this file itself (only when the user asks)")},run:async e=>{try{let t=await Z_(e);return X(t.text,t.data)}catch(t){return J(t)}}},{name:"media_dcp",long:!0,title:"Make a DCP from a master",description:`Build a SMPTE OV DCP folder from a finished ProRes master and its mix WAV, natively on this machine (the same DCI J2K encoder, MXF writers and validator as conform.tools/dcp); to change frames of a finished DCP use media_dcp_patch. The master is fitted into the DCI container keeping its aspect (flat 1.85 up to 1.9:1, scope above; container= to force; 16:9 lands pillarboxed in flat, a 2.39 OAR master fills scope), rest black. color = what the master IS (rec709 = BT.1886 2.4, srgb, p3d65): ask if the master's tags or the artist's profile don't say. The rate is the master's own (24/25/30/48/50/60 in 2K, 24/25/30 in 4K). A 23.976/29.97 master needs reclock=true: frame-for-frame at 24/30, sound sped up 0.1% with no pitch correction (Resolve's method; the mix is the master-rate mix). Ask before reclocking. The WAV (48/96 kHz integer PCM, any channel count, 5.1 = 6 ch in SMPTE order) must end with the picture: a mix longer or a frame+ shorter is refused (run render_gate first). Prove a new master with from/count (~48 frames) first.
|
|
417
|
-
encrypt=true: SMPTE 429-6 AES-128 + HMAC, CPL/PKL signed with the facility identity (~/.conform-mcp/dcp/signer.pem, created on first use with issuer as the organisation). The content key is written ONLY to <out_dir>/<title>_KEYS/keys.json: tell the user it is the only copy, never ship it inside the DCP. Then media_dcp_kdm per venue.
|
|
418
|
-
title = ContentTitleText and folder name, DCNC form (naming / artist's profile; a new version gets a new date/version). Lands in out_dir/<title> (default beside the master), never overwritten, then validated (DCI raster, J2K rate caps, hashes, CPL/PKL/ASSETMAP, signatures) with PASS/FAIL. Refused up front if the volume lacks room for the worst case (250 Mb/s + sound). Speed \u2248 40+ fps 2K, \u2248 15 fps 4K encoded on an M-series Mac: a feature runs a long time, so background=true.`,inputSchema:{path:f.string().describe("The ProRes master .mov"),wav:f.string().describe("The program's mix WAV (5.1 = 6 channels L R C LFE Ls Rs)"),title:f.string().describe("ContentTitleText / folder name, DCNC form e.g. FILM_FTR-1_F_EN-XX_51_2K_20261009_TBD_SMPTE_OV"),color:f.enum(go(aa)).describe("The master's color encoding"),out_dir:f.string().optional().describe("Folder the DCP folder is created in (default: beside the master)"),container:f.enum(go(qh)).optional().describe("DCI container; default from the master's aspect"),resolution:f.enum(go(Uh)).optional().describe("Default 2k"),kind:f.string().optional().describe(`CPL ContentKind: ${go(Hh).join(", ")}\u2026 (default feature)`),issuer:f.string().optional().describe("Issuer, and the organisation of a newly created signing identity"),encrypt:f.boolean().optional().describe("Encrypt + sign the package (fresh content key, written to keys.json beside it)"),reclock:f.boolean().optional().describe("23.976 \u2192 24 (29.97 \u2192 30): picture frame-for-frame, sound +0.1% varispeed"),from:f.number().int().min(0).optional().describe("First master frame (test builds)"),count:f.number().int().min(1).optional().describe("Frames to build (test builds); default to the end")},run:async({__progress:e,__signal:t,...n})=>{try{let r=await ev(n,e,t);return X(Em(r),r)}catch(r){return J(r)}}},{name:"media_dcp_patch",long:!0,title:"Patch frames into a DCP",description:"Overwrite frames of a finished SMPTE DCP with a fix (a VFX shot, a title, a bad frame, a sound pop) without rebuilding the package. The fix (path) is: a ProRes .mov render of just the fixed range (encoded here with the media_dcp DCI J2K encoder, fitted into the DCP's own container at its rate; color = what the render IS), .j2c codestreams (one file, or a folder of them, sorted by name), a picture track .mxf (another DCP's), a .wav (same channels and rate as the DCP's sound) or a sound track .mxf. at = the first composition frame it replaces: a frame number or HH:MM:SS:FF counted from the composition's first frame; reel=N makes at relative to reel N; a .mov with a TC track can be placed by its own TC with start_tc= (the DCP's first frame, e.g. 01:00:00:00). Length never changes (overwrite, not insert), so sound, subtitles and reel lengths stay where they were. Before anything is written every patch frame is checked against the reel it lands in (raster, components, 2K/4K profile; a different COD is a warning), against the DCI 250 Mb/s per-frame cap, and for range/overlap/channel layout; a refusal writes nothing. Only the reels a patch touches are re-wrapped (new track files with new asset UUIDs: changed bytes never keep the old id); untouched reels are carried as the same files (hard-linked on the same volume: instant for a feature) or, mode=vf, referenced from the OV (the VF carries only the re-wrapped reels: send it to venues and labs that hold the OV; it plays nowhere else). mode=ov (default) is a self-contained new OV. mode=check: placement, which reels re-wrap and every check, nothing written (a .mov fix: one frame is encoded to check it). The output is proven before it is reported: patch frames, the 2 frames either side of every seam and each reel's head/tail byte-identical to their source, every other edit unit by length, then the validator; verify=full also recomputes every hash. Lands in out_dir/<title> (default: beside the DCP; title default = the source's DCNC name with OV/VF set), never overwritten. Name a new version in the DCNC title (FTR-2) when the client tracks versions. Encrypted DCPs and Interop packages are refused. ENCRYPTED: an encrypted source needs keys (its keys.json from media_dcp encrypt=true); encrypt=true writes the result encrypted with a fresh key (+ signed, keys.json beside it). Without path it only re-packages: encrypt=true encrypts an OV, keys alone makes a decrypted copy. An encrypted patch is one fix (path + at as a frame number) into a new OV; wav= replaces the whole mix there.",inputSchema:{dcp:f.string().describe("The DCP folder (the one with ASSETMAP.xml)"),path:f.string().optional().describe("The fix: .mov (ProRes), .j2c or a folder of .j2c, .mxf, .wav"),at:f.union([f.number().int().min(0),f.string()]).optional().describe("First composition frame replaced: frame number or HH:MM:SS:FF from the composition start"),reel:f.number().int().min(1).optional().describe("Make at relative to this reel (1-based)"),color:f.enum(go(aa)).optional().describe("A .mov fix: its color encoding (required for .mov)"),from:f.number().int().min(0).optional().describe("First frame of the fix to use (default 0)"),count:f.number().int().min(1).optional().describe("Frames of the fix to use (default: all of it)"),patches:f.array(f.object({path:f.string(),at:f.union([f.number().int().min(0),f.string()]).optional(),reel:f.number().int().min(1).optional(),color:f.enum(go(aa)).optional(),from:f.number().int().min(0).optional(),count:f.number().int().min(1).optional()})).optional().describe("Several fixes in one pass (instead of path/at); overlap refused"),mode:f.enum(["ov","vf","check"]).optional().describe("ov (default): a new self-contained OV; vf: only what changed, referencing the OV; check: nothing written"),package:f.enum(["ov","vf"]).optional().describe("mode=check: check as this package type"),title:f.string().optional().describe("ContentTitleText / folder name (default: the source's, OV/VF set)"),out_dir:f.string().optional().describe("Folder the new package is created in (default: beside the DCP)"),cpl:f.string().optional().describe("Which CPL, when the package has several (file name, title or uuid)"),start_tc:f.union([f.number().int().min(0),f.string()]).optional().describe("The composition's first frame as TC, to place a .mov fix by its own timecode"),issuer:f.string().optional(),keys:f.string().optional().describe("keys.json of an encrypted source DCP"),encrypt:f.boolean().optional().describe("Encrypt + sign the new package (fresh content key)"),wav:f.string().optional().describe("Encrypted patch only: a new mix WAV replacing the whole sound"),verify:f.enum(["quick","full"]).optional().describe("full: also recompute every asset hash (reads the whole package)")},run:async({__progress:e,__signal:t,...n})=>{try{let r=n;if(r.keys||r.encrypt){let s=await rv(r,e,t);return X(Em(s),s)}let o=await ov(r,e,t);return X(sv(o),o)}catch(r){return J(r)}}},{name:"media_dcp_kdm",title:"Make a KDM for a DCP",description:"Write a KDM (SMPTE 430-1) that lets ONE projector/media block play an encrypted DCP made by media_dcp, for a window. keys = that DCP's keys.json; recipient = the venue's server/projector certificate .pem (they send it; a chain file is fine, the device leaf is picked). from/to are UTC dates (YYYY-MM-DD; to is inclusive to 23:59:59) or full YYYY-MM-DDThh:mm:ss: confirm the screening dates with the user, and allow for the venue's time zone. Signed with the same facility identity as the DCP, self-verified. Written beside keys.json as <title>_KDM_<recipient>_<from>_<to>.xml, never overwritten. The KDM is safe to email; keys.json is not.",inputSchema:{keys:f.string().describe("The encrypted DCP's keys.json"),recipient:f.string().describe("The projector/server certificate (.pem) from the venue"),from:f.string().optional().describe("First day it plays, UTC (default now)"),to:f.string().describe("Last day it plays, UTC"),out_dir:f.string().optional().describe("Default: beside keys.json")},run:async e=>{try{let t=await tv(e);return X(nv(t),t)}catch(t){return J(t)}}},{name:"gfx_make",long:!0,title:"Make a graphics package",description:`Design a graphic ONCE and get it for every deliverable: lower thirds, locators (location IDs), legal lines and end crawls, rendered on this machine as ProRes 4444 + alpha (the matte Resolve, Premiere, Avid and FCP read) for every aspect ratio and position. The reformat is automatic and art-directed, not a stretch: type is sized on the short edge so it is physically the same in every format, each graphic stays pinned to its anchor inside action-safe (9:16 also keeps clear of the platform caption band and right rail), and text re-wraps to each format's width with the plate growing to fit. Formats default to all of ${su.join(", ")} (or name a raster like 1280x720); resolution uhd doubles every raster. Positions: a lower third fans to bottom-left/bottom/bottom-right by default, a locator to top-left/top-right; any of ${iu.join(", ")} or all \u2014 each enters from its own side. End crawls are full frame. Content: one graphic (name+title \xB7 location+sub \xB7 text \xB7 credits) or many (items=[{\u2026}] or csv_path, one package per item). End crawl credits use the paste dialect: '# Section', 'Role | Name', '> wrapped paragraph', '@image logo.png' or '@image sag.png | dga.png 18' (a row of logos, images_dir), blank = gap; or credits_path (.txt) / csv_path (a credits sheet: section, role, name columns). Look: a preset (${au.join(", ")}), an object of {family, accent, primary, secondary, plate (${Xg.join("|")}), style (${Qg.join("|")}), stagger, ease, radiusLu, padLu, uppercase, tracking}, or look_path (a .look.json from conform.tools/gfx or an earlier package) \u2014 the same look keeps every type on-brand. Fonts: family = a shipped face (${Yg.join(", ")}), any installed family by name (gfx_fonts lists them), or a font file/folder; fonts= adds files (e.g. the bold) under their own family names. An unknown family is refused, never substituted. Every run writes <base>/preview.png (every format \xD7 position at the hold, true relative sizes) and <base>/still.png (the design full size): run preview_only=true first, LOOK at them, adjust, then render. Output: out_dir/<base>/<position>/<format>_<w>x<h>.mov, manifest.json and look.json (reuse with look_path). background_color=#rrggbb makes opaque ProRes 422 HQ instead (named _on_rrggbb). lottie=true also writes <base>.lottie (editable in Resolve/web; outlines for shipped and supplied fonts). options passes generator settings (lower third: center, nameLu, titleLu, maxWidthLu\u2026 \xB7 legal: sizeLu, minLu, sizeHpct, scrim, align \xB7 crawl: lineLu, colGapLu, gutterFrac). Held frames are encoded once, so a 21-file lower-third package takes seconds.`,inputSchema:{type:f.enum(Object.keys(Jg)),name:f.string().optional().describe("lower_third: the name line"),title:f.string().optional().describe("lower_third: the title line"),location:f.string().optional().describe("locator: the location line"),sub:f.string().optional().describe("locator: the second line (time, date, INT./EXT.)"),text:f.string().optional().describe("legal: the disclaimer paragraph"),credits:f.string().optional().describe("end_crawl: credits in the paste dialect"),items:f.array(f.record(f.string())).optional().describe("Many graphics of this type, e.g. [{name, title}, \u2026]; one package each"),csv_path:f.string().optional().describe("A CSV of items (name,title \xB7 location,sub \xB7 text) or, for end_crawl, a credits sheet"),credits_path:f.string().optional().describe("end_crawl: a .txt (paste dialect) or .csv credits file"),images_dir:f.string().optional().describe("end_crawl: folder the @image names are in (default: the credits file's folder)"),look:f.union([f.string(),f.record(f.unknown())]).optional().describe(`A preset (${au.join(", ")}) or look fields`),look_path:f.string().optional().describe("A .look.json (conform.tools/gfx, or an earlier package's look.json)"),family:f.string().optional().describe("Typeface: shipped id, installed family name, or a font file/folder"),fonts:f.array(f.string()).optional().describe("Font files or folders to make available (each under its own family name)"),formats:f.array(f.string()).optional().describe(`Default all: ${su.join(", ")}; or a raster like 1280x720`),positions:f.array(f.string()).optional().describe(`Anchors (${iu.join(", ")}) or ["all"]; default per type`),resolution:f.enum(["hd","uhd"]).optional().describe("hd (16:9 = 1920\xD71080, default) or uhd (\xD72)"),fps:f.number().positive().optional().describe("Default 23.976"),duration:f.number().positive().max(600).optional().describe("Seconds (default: lower third 6, locator 5, legal 6, crawl 12)"),start_tc:f.string().optional().describe("Start timecode (default 00:00:00:00)"),background_color:f.string().optional().describe("#rrggbb: opaque ProRes 422 HQ on this color instead of 4444 + alpha"),options:f.record(f.unknown()).optional().describe("Generator settings beyond the look"),lottie:f.boolean().optional().describe("Also write an editable .lottie per graphic"),preview_only:f.boolean().optional().describe("Only the preview sheet + still; render nothing"),out_dir:f.string().optional().describe("Package folder (default <MCP home>/gfx/<type>_<time>)")},run:async({__progress:e,__signal:t,...n})=>{try{let r=await eb(n,e,t);return X(tb(r),r)}catch(r){return J(r)}}},{name:"gfx_fonts",title:"List typefaces for graphics",description:"The typefaces gfx_make can set: the shipped faces (by id; OFL, embeddable in a .lottie) and every family installed on this machine with its weights. query filters by name. A face not listed can still be used by passing its font file or folder to gfx_make.",inputSchema:{query:f.string().optional().describe("Part of a family name, e.g. 'helv'")},run:async({query:e})=>{try{let t=await Zg(e),n=[`shipped: ${t.shipped.map(r=>`${r.id} (${r.label}, ${r.weights.join("/")})`).join(" \xB7 ")}`,`installed${e?` matching '${e}'`:""} (${t.installed.length}): ${t.installed.slice(0,200).map(r=>`${r.family}${r.weights.length>1?` [${r.weights.join("/")}]`:""}`).join(" \xB7 ")}${t.installed.length>200?" \u2026(query= to narrow)":""}`].join(`
|
|
419
|
-
`);return X(n,t)}catch(t){return J(t)}}},{name:"media_fix",long:!0,repoOnly:!0,title:"Fix frames: duplicates, cadence, retime",description:"Remake the frames a picture got wrong, as new media (ProRes 422 HQ at the source's timecode, so it relinks like the original). One plan, one executor: the analysis engine decides each output frame \u2014 a source frame as it is, or a frame BETWEEN two (RIFE v4.22.lite) \u2014 and the result is checked. Kinds: duplicates \u2014 the frames QC (qc_media) calls repeated: a double frame, a hang, slow motion by repeating frames; each repeat becomes the motion between the frames around it, the frame count kept (include_freezes: also a freeze continuing from motion \u2014 off by default, a freeze may be the edit's). cadence \u2014 an AI render (e.g. Seedance video_edit) against the plate it was made from: held frames cut, skipped plate frames put back, the output at the plate's count and rate; a render the AI RE-PACED is reported and not repaired unless force=true (filling it would cut real frames). retime \u2014 a constant speed (percent, 100 = real time) or a ramp ([frame, percent] keys) from src_in for `frames` output frames: optical-flow slow motion and speed changes better than a host's frame blend; or with session_id, every retimed clip of the timeline (its own speed or speed ramp, handles each side) rendered at the timeline's rate and record TC and the item relinked to it at 100 %. plan_only reports the plan without writing. The plan, the check, the decode and the encode are the engine and media-core; the between frames are RIFE on MLX (media-gen, Apple Silicon, its weights in models/rife/ of the MCP home); a plan with none (holds cut only) needs neither.",inputSchema:{kind:f.enum(["duplicates","cadence","retime"]),path:f.string().optional().describe("The clip to fix (cadence: the AI render); omit for a timeline retime"),session_id:f.string().optional().describe("retime: every retimed clip of this session's timeline (or item_ids) rendered with optical flow and relinked, played 1:1"),item_ids:f.array(f.string()).optional().describe("retime with session_id: only these items"),handles:f.number().int().min(0).max(240).optional().describe("retime with session_id: frames rendered each side of the used range (default 12)"),out_dir:f.string().optional().describe("retime with session_id: where the renders go (default <MCP home>/renders/<session id>)"),out_path:f.string().optional().describe("Output .mov; default <path>_<kind>.mov beside it"),plan_only:f.boolean().optional(),include_freezes:f.boolean().optional().describe("duplicates: also remake freezes continuing from motion"),plate:f.string().optional().describe("cadence: the source plate the AI was given"),plate_start:f.number().int().min(0).optional().describe("cadence: first plate frame the AI was given (default 0)"),plate_frames:f.number().int().min(2).optional().describe("cadence: plate frames the AI was given (default: to the end)"),mask:f.tuple([f.number(),f.number(),f.number(),f.number()]).optional().describe("cadence: x0,y0,x1,y1 fractions, an area the AI changed on purpose, left out of the alignment"),force:f.boolean().optional().describe("cadence: repair even when a re-pace is detected"),src_in:f.number().min(0).optional().describe("retime: source in-point (frame, default 0)"),frames:f.number().int().min(1).optional().describe("retime: output frames (default: the source's count)"),speed:f.number().positive().optional().describe("retime: constant speed in percent (50 = half speed)"),ramp:f.array(f.tuple([f.number(),f.number()])).optional().describe("retime: speed ramp keys [output frame, percent]")},run:async e=>{try{if(e.session_id){if(e.kind!=="retime")throw new Error("session_id is for kind=retime (a timeline's retimed clips)");let n=await bt(e.session_id),r=await X_(n.session,{session_id:e.session_id,item_ids:e.item_ids,handles:e.handles,out_dir:e.out_dir,plan_only:e.plan_only});r.changed&&(n.session=r.session,await Xt(n,`media_fix retime: ${r.items.filter(s=>s.wrote).length} clip(s) rendered with optical flow and relinked`));let o=[`${r.items.filter(s=>s.wrote).length} of ${r.items.length} retimed clip(s) ${e.plan_only?"planned":"rendered with optical flow and relinked (played 1:1)"}`,...r.items.map(s=>` ${s.name} (${s.speed}): ${s.skipped??`${s.frames} frames, ${s.between} remade${s.wrote?` \u2192 ${s.wrote}`:""}`}`)].join(`
|
|
420
|
-
`);return X(o,{session_id:e.session_id,items:r.items})}if(!e.path)throw new Error("path is required (or session_id with kind=retime)");let t=await J_(e);return X(Y_(t),{...t})}catch(t){return J(t)}}},{name:"media_consolidate",long:!0,title:"Consolidate media for a timeline",description:"Timeline-driven trim: for every source file the cut uses, write a byte-exact trim of just the used frames plus handles into out_dir (no re-encode; ProRes/DNx/H.264 mov, mxf, wav, RED .R3D). This is the conform 'consolidate' / 'media manage' step. By default only linked references are trimmed (run timeline_relink first so paths are verified); set only_linked=false to trim whatever paths exist on disk. With relink=true (default) the session is repointed at the trims, so a following timeline_write links to the consolidated media. Reports each output and everything skipped, with the reason.",inputSchema:{session_id:f.string(),out_dir:f.string().describe("Folder for the trimmed media"),handles:f.number().int().min(0).default(24).describe("Frames of handle on each side of every used range"),relink:f.boolean().default(!0).describe("Repoint the session at the trims"),only_linked:f.boolean().default(!0)},run:async({session_id:e,out_dir:t,handles:n,relink:r,only_linked:o})=>{try{let s=await bt(e),i=await xg(s.session,t,n,{relink:r,only_linked:o});return await Xt(s,`consolidate \u2192 ${t} (${i.outputs.length} files, ${n} handles)`),_t(i.text)}catch(s){return J(s)}}},{name:"color_prep",long:!0,title:"Prep a conform for color: the colorist's node tree, input CSTs and a first balance",description:"The color prep step of a conform, onto the session's timeline (timeline_read the prproj/drt/xml first). Every shot gets the colorist's OWN node tree, the input Color Space Transform for what it was shot in, and a first balance in their balance node; timeline_write target=resolve-drt then writes it as a separate .drt (their project is never touched). TREE: tree = a gallery still or PowerGrade (.drx) of their tree, exported from Resolve's gallery. The first time, call with tree only: it lists the nodes and you ASK the user which is the balance node and which the input CST (never pick from labels), AND how they build their grade \u2014 where their look lives (look_levels: clip / group_pre / group_post / adjustment_clips / timeline / output; colorists differ: groups or not, timeline grade, adjustment clips) and where their LUTs/DCTLs live (lut_dirs) \u2014 then call again with balance_node + cst_node + look_levels (+ lut_dirs); all of it is remembered in the artist profile, so later preps need no tree. CSTs: read per clip from the camera's own metadata (Sony X-OCN/XAVC, ARRI, RED; MOV color tags): camera log \u2192 its space into the tree's working space; Rec.709 video \u2192 Rec.709 with inverse OOTF; graphics, stills and alpha \u2192 no tree, no grade. A clip that cannot be identified, or is identified only by container tags (camera files often tag log as Rec.709), is returned as a QUESTION and nothing is written: ask the user, then pass answers=[{match, as}]. BALANCE (default on; Apple Silicon, local AI pack, download=true the first time after asking): step 1 = the local AI balance per shot read as an Offset (exposure + white balance); step 2 = group consistency V7-1 (only obvious cast / contrast mismatches between shots that share surfaces or the same person are nudged, never exposure, a no-harm check on nearby cuts; DaVinci Wide Gamut / Intermediate trees), the moved shots' balance node refitted (primaries only, Lum Mix 100). The result lists how many shots were nudged. balance=false = tree and CSTs only. Long: background=true for a job id.",inputSchema:{session_id:f.string().describe("The conform's session (timeline_read of their timeline)"),timeline:f.string().optional().describe("Timeline id or name (default: the first)"),tree:f.string().optional().describe("Path to a .drx (gallery still / PowerGrade) of the colorist's node tree; omit to use the remembered one"),balance_node:f.number().int().optional().describe("With tree: the node id the USER says is their balance node"),cst_node:f.number().int().optional().describe("With tree: the node id the USER says is their input Color Space Transform"),look_levels:f.array(f.enum(wc)).optional().describe("With tree: where the USER says their look lives (any combination)"),lut_dirs:f.array(f.string()).optional().describe("With tree: the folders the USER keeps their LUTs and DCTLs in"),working:f.string().optional().describe("With tree, instead of cst_node when the USER says their input CST is not in this tree (group pre-clip / color management): the space the tree works in, <SPACE>_COLORSPACE/<CURVE>_GAMMA"),answers:f.array(f.object({match:f.string(),as:f.string()})).optional().describe(`The user's answers to the color questions: match = part of the file/folder/clip name; as = "rec709" | "graphic" | "<SPACE>_COLORSPACE/<CURVE>_GAMMA"`),balance:f.boolean().optional().describe("Balance the shots (default true); false = tree and CSTs only"),download:f.boolean().optional().describe("Allow the one-time AI pack download (ask the user first)")},run:async({session_id:e,timeline:t,tree:n,balance_node:r,cst_node:o,look_levels:s,lut_dirs:i,working:a,answers:l,balance:c,download:u,__progress:p})=>{try{let d=await bt(e),m;if(n){let g=await $x(n,r,o,s,i,a);if(g.ask)return X(g.ask,{needs:"node choice"});m=g.tree}else m=await Rx();if(!m)return X("I need the colorist's node tree once: export a still of it from Resolve's gallery (right-click the still > Export, .drx) or a PowerGrade, and give me the path (tree=\u2026).",{needs:"tree"});let h=await Ex(d.session,{timeline:t,tree:m,answers:l,balance:c,download:u,progress:g=>p?.(0,0,g)});if(!h.ops.length)return X(h.text,h.data);for(let g of h.ops)va(d.session,"finish_op",g);return await Xt(d,`color_prep: ${m.name}, ${h.ops.length} clips`),X(h.text,{...h.data,session_id:e})}catch(d){return J(d)}}},{name:"color_match",title:"Match a shot's color to a reference image",description:`Conform Connect's auto color, headless: solve the grade that moves a SOURCE frame onto a REFERENCE image (an AI-generated still, a client frame grab, a graded still \u2014 png/jpg/tiff/exr/dpx decoded by our own engine, or a frame of another clip). The same histogram + covariance match and fold fit the Lab runs; the result is Resolve corrector nodes (tone 1, match matrix, tone 2 bypassed) as finish entries. Default method hm-mkl-hm works against ANY reference; hm-mvgd-hm is the Lab's default and needs a pixel-aligned pair (the same frame recolored, e.g. an AI color transfer output). With session_id + item the grade is installed on that clip, so timeline_write resolve-drt then carries it as live nodes on Resolve's color page. reference "ai" balances the frame with the local model (color from the model, exposure mostly held, as on conform.tools) and fits it from the pixel pairs (method pixel); the first use needs download: true. With session_id + item, a Color Space Transform on the clip's color page (read from the .drt) runs first \u2014 our own CST, exact to Resolve's \u2014 so the balance and the fit happen after it, and the written .drt keeps that CST node in front of the new nodes. Camera-native raw sources are refused (they decode as log); match on a proxy or a rendered frame.`,inputSchema:{source:f.string().describe("Media file (ProRes/DNx/MXF) or a still to grade"),frame:f.union([f.number().int(),f.string()]).optional().describe("Frame index or timecode of the source frame (default: the middle of the file)"),reference:f.string().describe('The look to match: a still image, a media file (+reference_frame), or "ai" \u2014 a first-pass balance by FLUX.2 klein running on THIS machine (Apple Silicon, 16 GB+; nothing is uploaded)'),reference_frame:f.union([f.number().int(),f.string()]).optional(),method:f.enum(hx).optional().describe('default hm-mkl-hm; for reference "ai" the default is primaries: ONE corrector node of gain/lift per channel, one gamma, contrast and saturation, skin protected on faces'),mixer:f.boolean().optional().describe("method primaries: also use the RGB Mixer (default false: a plain balance of gain/lift/gamma/contrast/saturation)"),skin_protect:f.number().min(1).max(20).optional().describe("method primaries: skin protection strength, default 3 (1 = off). Only inside detected faces, scaled by how much of the frame they fill; it moves color only and keeps the balance's contrast"),transfer:f.enum(["srgb","g24"]).optional().describe("Override the source's encoding (default: g24 for video, srgb for stills)"),session_id:f.string().optional().describe("Install the grade on a clip of this session"),item:f.string().optional().describe("The clip to grade: item id or unique clip name (with session_id)"),download:f.boolean().optional().describe('reference "ai" only: allow the one-time model download (~4.3 GB into ~/.conform-mcp/models). Ask the user first.')},run:async({source:e,frame:t,reference:n,reference_frame:r,method:o,transfer:s,session_id:i,item:a,download:l,mixer:c,skin_protect:u})=>{try{let p=i?await bt(i):null;if(p&&!a)throw new L("invalid_args","item is required with session_id");let d=p&&a?wx(p.session,a):null;if(p&&!d)throw new L("not_found",`no clip '${a}' in session ${i} (timeline_query lists ids and names)`);let m=d?yx(p.session,d.itemId):void 0,h=await gx({source:e,frame:t,reference:n,reference_frame:r,method:o,transfer:s,item_id:a,download:l,cst:m,mixer:c,skinBoost:u}),g={method:h.method,transfer:h.transfer,residual:h.residual,luma_stops:h.lumaStops,source:h.source,reference:h.reference,entries:h.entries,...h.cst?{cst:h.cst}:{}},y="";if(p&&d){let k=bx(h,d.timelineId,d.itemId);for(let b of k)va(p.session,"finish_op",b);await Xt(p,`color_match ${ie(n)} \u2192 ${d.name||d.itemId} (${h.method})`),g.session_id=i,g.item_id=d.itemId,y=`
|
|
421
|
-
installed on ${d.name||d.itemId} in session ${i}: timeline_write target=resolve-drt writes it as corrector nodes`}return X(kx(h)+y,g)}catch(p){return J(p)}}},{name:"p2p_send",title:"Send files or a package peer to peer (Iroh)",description:"Serve a file, or a folder such as a media_deliver package, straight from this machine to one recipient over Iroh (encrypted QUIC, direct or relayed): no upload, no bucket. Returns a ticket for the recipient to pass to p2p_receive, and a job_id: the files are served until job action=cancel. The recipient only ever pulls the bytes it asks for (seek+response), so nothing is pushed.",inputSchema:{path:f.string().describe("A file, or a folder to send with its layout (e.g. a media_deliver folder package)")},run:async({path:e})=>{try{let t=await jx(e);if(!t.length)return J(new L("not_found",`nothing to send in ${e}`));let n=await yf(t),r=ti("p2p_send",async(s,i)=>(await new Promise(a=>{i.addEventListener("abort",()=>a()),n.closed.then(a)}),n.stop(),_t("stopped serving"))),o=kr(n.ticket).files.length;return X(`serving ${o} file(s) as ${r.id} \u2014 job action=cancel job_id=${r.id} to stop
|
|
422
|
-
ticket (give this to the recipient): ${n.ticket}`,{ticket:n.ticket,job_id:r.id,files:o})}catch(t){return J(t)}}},{name:"account_bucket",title:"Your bucket: where client sends and deliveries land",description:"Connect your own S3-compatible bucket (AWS S3, Cloudflare R2, Backblaze B2, Wasabi, MinIO) to your conform.tools account. Projects then default to it: what clients send through a project_link, and media_deliver destination=bucket, land there. action=show \xB7 set (endpoint https://\u2026, bucket, access_key_id, region?, secret_access_key \u2014 or leave it out and set CONFORM_BUCKET_SECRET in the MCP's environment so the secret never passes through the chat) \xB7 forget. set tests the bucket first (write, ranged server-side copy, read back, delete) and saves only if every step works. The secret is kept server-side (Vault), never shown again.",inputSchema:{action:f.enum(["show","set","forget"]).default("show"),endpoint:f.string().optional().describe("set: e.g. https://<account>.r2.cloudflarestorage.com, https://s3.us-west-2.amazonaws.com"),bucket:f.string().optional(),region:f.string().optional().describe("set: default auto"),access_key_id:f.string().optional(),secret_access_key:f.string().optional().describe("set: or CONFORM_BUCKET_SECRET in the environment")},run:async({action:e,endpoint:t,bucket:n,region:r,access_key_id:o,secret_access_key:s})=>{try{let i=c=>c?`your bucket: ${c.bucket} at ${c.endpoint} (key ${c.access_key_id}${c.verified_at?`, checked ${c.verified_at.slice(0,10)}`:""})`:"no bucket connected \u2014 account_bucket action=set endpoint=\u2026 bucket=\u2026 access_key_id=\u2026";if(e==="show"){let{storage:c}=await Jt("v1-me","/v1/me/storage");return X(i(c),{storage:c})}if(e==="forget")return await Jt("v1-me","/v1/me/storage",{method:"DELETE"}),_t("bucket forgotten; new projects use conform.tools storage");let a=s??en("CONFORM_BUCKET_SECRET");if(!t||!n||!o||!a)return J(new L("invalid_args","set needs endpoint, bucket, access_key_id and secret_access_key (or CONFORM_BUCKET_SECRET)"));let{storage:l}=await Jt("v1-me","/v1/me/storage",{method:"PUT",body:{endpoint:t,bucket:n,region:r,access_key_id:o,secret_access_key:a}});return X(`${i(l)} \u2014 tested and saved; new projects send into it`,{storage:l})}catch(i){return J(i)}}},{name:"project",title:"Projects: the job you are working on, its shared context, and what clients send into it",description:`A project is one job ("PRIMROSE \xB7 Ep 104") on conform.tools, shared by everyone in the org: its context (the standing notes \u2014 client, deliverables, naming, handles, specs, decisions \u2014 that everyone, and Claude over the MCP, works from), its sessions, and what clients send through its links (project_link), in conform.tools storage or the org's own bucket (storage='org'), trimmed to their cut + the project's handles. Starting work on a job: action=open first (project_id from list) \u2014 its context comes back, and every session you make from then on joins the project. When you learn something about the job, add it with action=context text=\u2026 (the whole notes, edited: read them first). action=open (project_id) \xB7 context (project_id? default the open one; text? saves the whole notes over the version read, else reads them) \xB7 attach (project_id?, session_id: one of the org's conform.tools sessions, e.g. an older send, joins it) \xB7 create (name, client_name?, handles?, storage?) \xB7 list \xB7 incoming (every client app sharing LIVE right now, on any project \u2014 mount one with delivery_fetch) \xB7 show (project_id: its links, every send newest first, and any client app sharing LIVE peer to peer) \xB7 archive (project_id: its links stop working).`,inputSchema:{action:f.enum(["open","context","attach","create","list","incoming","show","archive"]),project_id:f.string().optional().describe("default for context/attach: the open project"),text:f.string().max(2e5).optional().describe("context: the project's whole notes (markdown) to save; omit to read them"),session_id:f.string().optional().describe("attach: a conform.tools session id"),name:f.string().optional().describe("create: the job's name"),client_name:f.string().optional(),handles:f.number().int().min(0).max(240).optional().describe("create: trim handles in frames for what clients send (default 24)"),storage:f.enum(["conform","org"]).optional().describe("create: the org's own bucket (default when account_bucket has one) or conform.tools storage")},run:async({action:e,project_id:t,name:n,client_name:r,handles:o,storage:s,text:i,session_id:a})=>{try{let l=(d,m={})=>Jt("v1-projects",d,m),c=d=>[d.updated_by?`saved by ${d.updated_by} ${String(d.updated_at).slice(0,16).replace("T"," ")}`:"",d.pending?"saved on this machine only; it goes up when conform.tools is reachable":d.offline?"offline: this machine's copy":""].filter(Boolean).join(" \xB7 ");if(e==="open"){if(!t)return J(new L("invalid_args","open needs project_id (project action=list)"));let{project:d}=await l(`/v1/projects/${t}`);await Yf({id:d.id,name:d.name});let m=await Oc(d.id);return X([`open: ${d.name}${d.client_name?` \xB7 ${d.client_name}`:""} \u2014 ${d.handles}-frame handles; sessions you make now join it`,m.text.trim()?`context (${c(m)||"shared with the project"}):
|
|
423
|
-
${m.text.trim()}`:"context: none yet \u2014 when you learn the spec (deliverables, naming, handles, client), save it with project action=context text=\u2026"].join(`
|
|
424
|
-
`),{project:d,context:m})}if(e==="context"||e==="attach"){let d=t??(await ho())?.id;if(!d)return J(new L("invalid_args",`${e} needs project_id, or a project opened with project action=open`));if(e==="attach")return a?(await l(`/v1/projects/${d}/sessions`,{method:"PUT",body:{session_id:a}}),_t(`session ${a} joined project ${d}`)):J(new L("invalid_args","attach needs session_id"));let m=i===void 0?await Oc(d):await Qf(d,i);return X(i===void 0?m.text.trim()?`${m.text.trim()}
|
|
425
|
-
|
|
426
|
-
(${c(m)||"shared with the project"})`:"no context yet for this project":`saved the project's context (${m.text.length} characters)${m.pending?": on this machine only, it goes up when conform.tools is reachable":""}`,{context:m})}let u=d=>`${(Number(d||0)/1e6).toFixed(1)} MB`;if(e==="create"){if(!n)return J(new L("invalid_args","create needs name"));let d=s??((await Jt("v1-me","/v1/me/storage").catch(()=>({storage:null}))).storage?"org":"conform"),{project:m}=await l("/v1/projects",{body:{name:n,client_name:r,handles:o,storage:d}});return X(`project ${m.name} (${m.id}) \u2014 ${m.handles}-frame handles, ${m.storage==="org"?"your bucket":"conform.tools storage"}
|
|
427
|
-
next: project_link project_id=${m.id} for a link to send your client`,{project:m})}if(e==="list"){let[{projects:d},m]=await Promise.all([l("/v1/projects"),ho()]);return X(d.length?d.map(h=>`- ${h.name}${h.client_name?` (${h.client_name})`:""} \xB7 ${h.id}${h.id===m?.id?" \xB7 OPEN":""}${h.live?.length?` \xB7 LIVE: ${h.live.length} sharing now (project action=incoming)`:""}`).join(`
|
|
428
|
-
`):"no projects yet \u2014 project action=create name=\u2026",{projects:d,open:m})}if(e==="incoming"){let{projects:d}=await l("/v1/projects"),m=d.flatMap(h=>(h.live??[]).map(g=>({project:h.name,project_id:h.id,...g})));return X(m.length?m.map(h=>`- ${h.project}${h.label?` \xB7 ${h.label}`:""} \xB7 sharing since ${String(h.seen_at).slice(11,16)} \u2192 delivery_fetch from=${h.ticket} as=mount (or as=trims / as=iso)`).join(`
|
|
429
|
-
`):'nobody is sharing right now \u2014 a client presses "Let <you> connect" in their Send app (project_link makes one)',{live:m})}if(!t)return J(new L("invalid_args",`${e} needs project_id`));if(e==="archive")return await l(`/v1/projects/${t}`,{method:"PATCH",body:{archived:!0}}),_t(`archived ${t}; its links no longer work`);let p=await l(`/v1/projects/${t}`);return X([`${p.project.name}${p.project.client_name?` \xB7 ${p.project.client_name}`:""} \u2014 ${p.project.handles}-frame handles, ${p.project.storage==="org"?"your bucket":"conform.tools storage"}`,`links (${p.links.length}):`,...p.links.flatMap(d=>[` - ${d.label??"(no label)"} ${d.url} ${d.alive?`\xB7 expires ${d.expires_at?.slice(0,10)??"never"}`:"\xB7 OFF"}${d.last_used_at?` \xB7 last used ${d.last_used_at.slice(0,16)}`:""}`,...d.peer?[` LIVE: their app is sharing its cut from their machine \u2192 delivery_fetch from=${d.peer.ticket} as=mount (or as=trims / as=iso)`]:[]]),`sends (${p.sessions.length}):`,...p.sessions.map(d=>` - ${d.created_at.slice(0,16)} ${d.label??""} ${d.sender_email??""} ${d.status} ${u(d.total_bytes)} \u2192 delivery_fetch from=bucket:${d.id}`)].join(`
|
|
430
|
-
`),p)}catch(l){return J(l)}}},{name:"project_link",title:"A link for your client to send footage into a project",description:`Make a link for one client and one project. Send it to them: it downloads a small app named for you and the project ("Send to Stefan"); they double-click it, drop their Premiere/Avid/Resolve/Final Cut project on it, and it finds their media by the project's own paths, trims to the cut + handles and sends it into the project \u2014 no account, no folders to point at. Or, instead of Send, they press "Let <you> connect": the app serves the same trimmed cut from their machine peer to peer (nothing uploaded) and project action=show gives the ticket to mount it (delivery_fetch from=<ticket> as=mount \u2014 opening a clip fetches only what is read). action=create (project_id, label? e.g. 'Jen at Northlight', recipient_email?, expires_in_days? default 30, null = never) \xB7 revoke (project_id, link_id). Sends show up in project action=show.`,inputSchema:{action:f.enum(["create","revoke"]).default("create"),project_id:f.string(),link_id:f.string().optional(),label:f.string().optional(),recipient_email:f.string().optional(),expires_in_days:f.number().int().min(1).max(365).nullable().optional()},run:async({action:e,project_id:t,link_id:n,label:r,recipient_email:o,expires_in_days:s})=>{try{if(e==="revoke")return n?(await Jt("v1-projects",`/v1/projects/${t}/links/${n}`,{method:"DELETE"}),_t(`link ${n} turned off`)):J(new L("invalid_args","revoke needs link_id"));let{link:i}=await Jt("v1-projects",`/v1/projects/${t}/links`,{body:{label:r,recipient_email:o,expires_in_days:s}});return X(`send this to your client: ${i.url}
|
|
431
|
-
(expires ${i.expires_at?.slice(0,10)??"never"}; project_link action=revoke link_id=${i.id} turns it off)`,{link:i})}catch(i){return J(i)}}},{name:"team",title:"Team: the org's seats and who is in it",description:"The org you belong to on conform.tools: everyone in it shares its projects (and their context) and rides on the owner's plan. action=list (members, seats used of the plan's cap, pending invites) \xB7 invite (email: they get an email to join; owner only, within the seat cap) \xB7 revoke (invite_id: a pending invite) \xB7 remove (profile_id: a member leaves the org; owner only).",inputSchema:{action:f.enum(["list","invite","revoke","remove"]),email:f.string().optional().describe("invite: who to invite"),invite_id:f.string().optional().describe("revoke: from action=list"),profile_id:f.string().optional().describe("remove: the member, from action=list")},run:async({action:e,email:t,invite_id:n,profile_id:r})=>{try{let o=(l,c={})=>Jt("v1-orgs",l,c);if(e==="invite")return t?(await o("/v1/orgs/me/invites",{body:{email:t}}),_t(`invited ${t}: they get an email to join your team`)):J(new L("invalid_args","invite needs email"));if(e==="revoke")return n?(await o(`/v1/orgs/me/invites/${n}`,{method:"DELETE"}),_t(`invite ${n} revoked`)):J(new L("invalid_args","revoke needs invite_id (team action=list)"));if(e==="remove")return r?(await o(`/v1/orgs/me/members/${r}`,{method:"DELETE"}),_t(`removed ${r} from the team`)):J(new L("invalid_args","remove needs profile_id (team action=list)"));let s=await o("/v1/orgs/me"),i=s.seatCap>=999?"unlimited":String(s.seatCap),a=s.members.map(l=>({profile_id:l.profile?.id,name:l.profile?.full_name??null,email:l.profile?.email??null,role:l.role}));return X([`${s.org?.name??"your team"} \u2014 ${s.seatsUsed} of ${i} seats${s.isOwner?" (you own it)":""}`,...a.map(l=>`- ${l.name??l.email} <${l.email}> ${l.role} \xB7 ${l.profile_id}`),...(s.pendingInvites??[]).map(l=>`- invited ${l.email} (until ${String(l.expires_at).slice(0,10)}) \xB7 invite ${l.id}`)].join(`
|
|
432
|
-
`),{org:s.org,is_owner:s.isOwner,seat_cap:s.seatCap,seats_used:s.seatsUsed,members:a,invites:s.pendingInvites??[]})}catch(o){return J(o)}}},{name:"delivery_fetch",long:!0,title:"Open a delivery: list it, fetch the .iso, cut trims from it, or mount it live",description:`A delivery is one .iso (media_deliver writes it). This reads one WHEREVER it is \u2014 from=a .iso path on this machine, a bucket delivery (bucket:<session id>, from media_deliver destination=bucket), or a peer's p2p_send ticket \u2014 the same way:
|
|
433
|
-
as=list: what it holds (files, sizes, how much of each is real bytes). as=iso: the whole image to out_path. as=trims: a folder at out_path in the delivery's own layout, each clip cut to the edit's frames + handles from the recipe the .iso carries; only reads the bytes the trims need (only=['A001C003'] or ['01_PROJECT_FILES'] keeps matching paths). as=mount (macOS): mount it now; from a bucket or a peer, opening a clip fetches only what is read; returns a job_id that keeps it mounted until job action=cancel. From a peer it says the path: direct (tens of MB/s on a good line) or through a relay when the two networks can't reach each other (a few MB/s: fine to browse and check shots, slow to play back hi-res); job action=status shows it live.
|
|
434
|
-
A peer's machine must stay on and serving. Long: background=true for a job id.`,inputSchema:{from:f.string().describe("A .iso path, bucket:<session id> (or the bare id), or a p2p_send ticket"),as:f.enum(["list","iso","trims","mount"]).default("list"),out_path:f.string().optional().describe("as=iso: the .iso to write; as=trims: the folder to write into"),only:f.array(f.string()).optional().describe("as=trims: keep only paths containing one of these"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status, cancel with job action=cancel")},run:async({from:e,as:t,out_path:n,only:r,__progress:o,__signal:s})=>{let i=await Dt("conform-fetch-");try{let a=kf(e);if(t==="mount"){let c=await Vx(a,i),u=ti("delivery_fetch",async(d,m)=>{let h=c.status&&setInterval(()=>{let g=c.status();d(g.fetched,g.total,`${g.files} files \xB7 ${bf(g.path)} \xB7 ${(g.rate/1e6).toFixed(1)} MB/s${g.error?` \xB7 ${g.error}`:""}`)},2e3);return await new Promise(g=>m.addEventListener("abort",()=>g())),h&&clearInterval(h),await c.stop(),await Ht(i),_t(`unmounted ${c.mountpoint}`)});c.status&&await new Promise(d=>setTimeout(d,3e3));let p=c.status?.();return X(`mounted at ${c.mountpoint}${a.kind==="file"?"":" \u2014 clips fetch as they are read; files the sender adds while sharing appear in it"}`+(p?`
|
|
435
|
-
path: ${bf(p.path)} (job action=status job_id=${u.id} shows it live, with MB/s)`:"")+`
|
|
436
|
-
job_cancel ${u.id} to unmount`,{mountpoint:c.mountpoint,job_id:u.id,...p?{path:p.path}:{}})}if(t==="iso"){if(!n)return J(new L("invalid_args","as=iso needs out_path (the .iso to write)"));if(a.kind==="file")return J(new L("invalid_args","that .iso is already on this machine"));let c=await Jx(a,n,i,o,s);return X(`fetched ${(c/1e6).toFixed(1)} MB \u2192 ${n}`,{path:n,bytes:c})}if(t==="list"&&a.kind==="peer"&&!kr(a.ticket).iso){let c=kr(a.ticket),u=p=>`${(p/1e6).toFixed(1)} MB`;return X([`${c.label??"shared files"}: ${c.files.length} file(s), ${u(c.files.reduce((p,d)=>p+d.size,0))} \u2014 mount it, or as=iso to receive it whole`,...c.files.map(p=>`- ${p.name} ${u(p.size)}`)].join(`
|
|
437
|
-
`),{files:c.files,name:c.label??"shared files"})}let l=await _c(a,i);try{if(t==="list"){let u=await pm(l),p=d=>`${(d/1e6).toFixed(1)} MB`;return X([`${l.name}: ${u.files.length} file(s), ${p(u.image)} image${u.recipes?`, ${u.recipes} edit(s) in it (trims available)`:" (no recipe: trims come out as stored)"}`,...u.files.map(d=>`- ${d.name} ${p(d.size)}${d.recorded<d.size?` (${p(d.recorded)} real \u2014 the cut's frames)`:""}`)].join(`
|
|
438
|
-
`),{...u,name:l.name})}if(!n)return J(new L("invalid_args","as=trims needs out_path (the folder to write into)"));let c=await mm(l,n,{only:r,onProgress:o,signal:s});return X([`wrote ${c.files} file(s), ${(c.bytes/1e6).toFixed(1)} MB of trims \u2192 ${n}`,...c.untrimmed.length?["not trimmed (written as stored):",...c.untrimmed.map(u=>` - ${u}`)]:[]].join(`
|
|
439
|
-
`),c)}finally{await l.close()}}catch(a){return J(a)}finally{t!=="mount"&&await Ht(i)}}},{name:"media_deliver",protectedStages:["write"],long:!0,title:"Deliver a package: folder, .iso, into your bucket, or peer to peer",description:`The app's i2o delivery, on this machine: the conform package a colorist or VFX house receives. Layout: 01_PROJECT_FILES/source (the original timeline), 01_PROJECT_FILES/converted (the requested host timelines, media paths rewritten to the package), 02_MEDIA (every used source trimmed byte-exact to the used frames + handles; RED clips as .RDC bundles), 03_REFERENCES.
|
|
440
|
-
destination=folder writes that tree into out_path. destination=iso writes ONE sparse UDF image (mountable on macOS/Windows/Linux; only the cut's frames are real bytes) at out_path, with its recipe inside so trims can be cut from any copy of it later (delivery_fetch as=trims).
|
|
441
|
-
destination=bucket puts that .iso into the org's OWN bucket (bring-your-own bucket, set up on conform.tools) as a delivery the web inbox lists: blocks an earlier delivery in that bucket already holds are copied there server-side instead of uploaded. Returns bucket:<id> for delivery_fetch / add_to; recipients=[emails] are notified.
|
|
442
|
-
destination=p2p serves that .iso from this machine to one recipient over Iroh (no upload, no bucket): returns a ticket for their delivery_fetch (mount it live, cut trims, or take the .iso) and a job_id that serves until job action=cancel.
|
|
443
|
-
add_to=<a .iso path or bucket:<id>> adds this delivery INTO an earlier one instead (any destination=iso|bucket): only what it lacks goes in \u2014 a clip's new frames, new clips into their folder, a changed timeline beside the old one as name_v2 \u2014 so a re-cut costs only its new frames; in a bucket only those bytes are uploaded.
|
|
444
|
-
Only linked references ship (run timeline_relink first). A clip that cannot be trimmed is reported and NEVER shipped whole. timeline_formats picks which host timelines ride along, e.g. ['resolve-drt','avid-avb'] (default resolve-drt).`,inputSchema:{session_id:f.string(),destination:f.enum(["folder","iso","bucket","p2p"]),out_path:f.string().optional().describe("folder: where to write; iso: the .iso path; bucket/p2p: optional \u2014 also keep the .iso here"),add_to:f.string().optional().describe("An earlier delivery to add this one into: a .iso path or bucket:<session id>"),recipients:f.array(f.string()).optional().describe("destination=bucket: emails to notify"),label:f.string().optional().describe("destination=bucket: the delivery's name in the inbox (default: the volume name)"),volume_name:f.string().optional().describe("Package / volume name; default from the source file"),handles:f.number().int().min(0).default(24),preserve_structure:f.boolean().default(!1).describe("Mirror the sources' parent folders under 02_MEDIA"),timeline_formats:f.array(f.string()).default(["resolve-drt"]),only_linked:f.boolean().default(!0)},run:async({session_id:e,destination:t,out_path:n,add_to:r,recipients:o,label:s,volume_name:i,handles:a,preserve_structure:l,timeline_formats:c,only_linked:u,__progress:p,__signal:d})=>{try{let m=await bt(e),h={volume_name:i,handles:a,preserve_structure:l,timeline_formats:c,only_linked:u},g=b=>`${(b/1e6).toFixed(1)} MB`;if(t==="folder"){if(r)return J(new L("invalid_args","add_to adds into a .iso: use destination=iso or bucket"));if(!n)return J(new L("invalid_args","out_path is required"));let b=await C_(m.session,m.source_path,{...h,out_path:n});await Xt(m,`deliver folder \u2192 ${n}`);let w=await Ys("delivery-qc",b.keys);return _t(`${b.text}${w?`
|
|
445
|
-
|
|
446
|
-
Reading this delivery (conform.tools playbook):
|
|
447
|
-
${w}`:""}`)}let y=await Dt("conform-deliver-"),k=!1;try{let b=n&&!r?n:B(y,`${i??ie(m.source_path,Qn(m.source_path))}.iso`);p?.(0,0,"building the .iso");let w=await E_(m.session,m.source_path,{...h,out_path:b}),_=w.text.split(`
|
|
448
|
-
`).filter(S=>!S.startsWith("wrote ")&&!S.startsWith("- ")).join(`
|
|
449
|
-
`);if(r){let S=kf(r),T=await Kx(S,w.path,{onProgress:p,signal:d});return await Xt(m,`deliver add_to \u2192 ${r}`),X(`added into ${r}: ${g(T.bytes)} in ${T.filled} range(s)${T.added.length?`
|
|
450
|
-
new: ${T.added.filter(x=>!x.startsWith(".conform/")).join(", ")}`:""}${T.versioned.filter(x=>!x.startsWith(".conform/")).length?`
|
|
451
|
-
changed, added beside the old: ${T.versioned.filter(x=>!x.startsWith(".conform/")).join(", ")}`:""}${T.bytes===0?`
|
|
452
|
-
(nothing new \u2014 this delivery was already in it)`:""}`+`${T.uploaded!==void 0?`
|
|
453
|
-
bucket: uploaded ${g(T.uploaded)}, copied ${g(T.copied??0)} server-side; the delivery is now ${g(T.image)}`:""}
|
|
454
|
-
|
|
455
|
-
${_}`.trimEnd(),T)}if(t==="iso"){await Xt(m,`deliver iso \u2192 ${w.path}`);let S=await Ys("delivery-qc",w.keys);return _t(`${w.text}${S?`
|
|
456
|
-
|
|
457
|
-
Reading this delivery (conform.tools playbook):
|
|
458
|
-
${S}`:""}`)}if(t==="bucket"){let S=await Gx(w.path,{label:s,recipients:o,onProgress:p,signal:d});return await Xt(m,`deliver bucket \u2192 ${S.session_id}`),X([`delivered to your bucket as bucket:${S.session_id} (${g(S.image)} image): uploaded ${g(S.uploaded)}${S.copied?`, ${g(S.copied)} already in ${S.reused_from} earlier deliver${S.reused_from===1?"y":"ies"} \u2014 copied there server-side, not uploaded`:""}`,`it is in the conform.tools inbox; delivery_fetch from=bucket:${S.session_id} lists it, cuts trims or mounts it${o?.length?`; ${o.join(", ")} notified`:""}`,...n?[`kept a copy at ${w.path}`]:[],"",_].join(`
|
|
459
|
-
`).trimEnd(),S)}let v=await yf([w.path]);k=!n;let R=ti("media_deliver",async(S,T)=>(await new Promise(x=>{T.addEventListener("abort",()=>x()),v.closed.then(x)}),v.stop(),k&&await Ht(y),_t("stopped serving")));return await Xt(m,`deliver p2p (${R.id})`),X(`serving ${ie(w.path)} (${g(w.bytes)}) peer to peer as ${R.id} \u2014 job action=cancel job_id=${R.id} to stop
|
|
460
|
-
ticket for the recipient's delivery_fetch (as=mount to watch it now, as=trims, or as=iso): ${v.ticket}
|
|
461
|
-
|
|
462
|
-
${_}`.trimEnd(),{ticket:v.ticket,job_id:R.id})}finally{k||await Ht(y)}}catch(m){return J(m)}}},{name:"timeline_judge",hidden:!0,repoOnly:!0,title:"Judge a written timeline against its source",description:"Law-backed check of a written timeline file against the source it came from: the same timing, sizing, link and content judges that run on every production conversion, using each host's decoded rules. Pass the source file and the written file (e.g. the AAF you read and the .drt you wrote). Returns a verdict (clean / issues), the reasons, per-tier tallies and the clips with issues. Judged formats: prproj, drt, xmeml, aaf, avb, flame. Use after timeline_write when the user asks whether the conversion is right, or before delivering.",inputSchema:{source_path:f.string().describe("The original timeline file"),output_path:f.string().describe("The written timeline file to judge")},run:async({source_path:e,output_path:t})=>{try{return _t(await Sg(e,t))}catch(n){return J(n)}}},{name:"timeline_autoconform",long:!0,protectedStages:["canonicalize"],title:"Auto conform a reference to source media",description:`Rebuild a cut from a reference render, in the analysis engine (one native process): every frame of the reference and the pool as a small luma grid at each codec's cheapest tier, one alignment of the whole reference against the pool (grade-proof take codes name the clip, motion names the frame), each shot matched whole in its own framing (punch-ins, flops, retimes, ramps), every placement pinned by one sharp frame check, the production sound for what the picture can't settle, each shot's sizing measured (keyframed moves too), and a new timeline session at the reference's raster and rate with markers on every issue (gap, unresolved, ambiguous, xml). reference: the cut's render (ProRes, H.264, HEVC, or a camera original). pool: folders and/or files of source media (mov/mp4/r3d/mxf/braw/ari/crm; spanned RED = one clip). hints_session_id: an editor's timeline of the same cut \u2014 CHECKED, never believed: each claim is pinned from its own take and in-point, only what the claims that hold leave unexplained is searched (nearest takes first), and every claim not kept as written is reported ("the timeline has A at 120, the picture matches B at 133"). With a good timeline nothing is searched at all. trust=true (with hints_session_id): the Aligner \u2014 the timeline's takes and in-points stand as written and only the sizing is measured (Baselight-style: the clips have the right TC, match the framing, keyframed moves included). Returns a session_id for timeline_write plus the coverage stats and the issue list. H.264/HEVC decode with the OS's own decoder (macOS today).`,inputSchema:{reference:f.string().describe("Path to the reference render of the cut (ProRes, H.264, HEVC, or a camera original)"),pool:f.array(f.string()).min(1).describe("Folders and/or media files to search"),hints_session_id:f.string().optional().describe("Session id of the editor's timeline for this cut, if you have one"),trust:f.boolean().optional().describe("With hints_session_id: keep the timeline's takes and in-points as written and measure only the sizing (the Aligner)"),reference_audio:f.string().optional().describe("The reference's sound from another file (a .wav beside a picture-only render)"),display_transform:f.boolean().optional().describe("Decode camera originals display-referred (Log \u2192 Rec.709/2.4 through the Color Space Transform) to match a GRADED reference. Experimental; X-OCN today"),sizing:f.boolean().optional().describe("Measure each placed shot's scale/position/rotation/mirror (default on; shots it cannot measure are left at 100 % and flagged)"),name:f.string().optional().describe("Timeline name"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status, cancel with job action=cancel")},run:async({reference:e,pool:t,hints_session_id:n,trust:r,reference_audio:o,display_transform:s,sizing:i,name:a,__progress:l,__signal:c})=>{try{if(r&&!n)throw new L("invalid_args","trust keeps a timeline's in-points: give hints_session_id");let u=n?(await bt(n)).session:void 0,p=await ec({reference:e,pool:t,hints:u,trust:r,reference_audio:o,display_transform:s,sizing:i,name:a,onProgress:l,signal:c}),d=await qn(p.session,e,"autoconform");await ra(d.id,Zl,p.rebuild);let m=await Ys("auto-conform",bv(p)),h=Ps(p.rebuild).length;return X(`session_id: ${d.id}
|
|
463
|
-
${yv(p)}
|
|
464
|
-
${await Tr(p.session)}`+(h?`
|
|
465
|
-
|
|
466
|
-
${h} shot(s) the engine was unsure of: timeline_autoconform_review session_id=${d.id} shows each with a contact sheet to accept or reject.`:"")+(m?`
|
|
467
|
-
|
|
468
|
-
Reading this result (conform.tools playbook):
|
|
469
|
-
${m}`:""),{session_id:d.id,unsure:h})}catch(u){return J(u)}}},{name:"media_cuts",long:!0,title:"Find the cuts in a movie (scene detection)",description:"Every shot boundary of a movie, from the analysis engine's one cut detector (a cut is a spike in the frame-to-frame change against the frames around it; going to or from black is a cut, black to black is not; a jump within one take counts when it stands far over the change around it), plus its black runs. Returns the shots with source timecode and a session_id of the movie cut at every shot (one clip per shot, the movie as its source) for timeline_write to any host \u2014 the cut-up an editor imports to re-edit or conform a flat render. Measured against authored cuts with an exact answer key (bench/cuts-bench.ts). Reads the grid index the conform builds, so a file already conformed is instant.",inputSchema:{path:f.string().describe("The movie (a render, a reference, a camera original)"),name:f.string().optional().describe("Name of the cut-up timeline (default: <file> cuts)"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status")},run:async({path:e,name:t,__progress:n})=>{try{let r=await Rv(e,t,n),o=await qn(r.session,e,"cuts");return X(`session_id: ${o.id}
|
|
470
|
-
${r.text}`,{session_id:o.id,...r.data})}catch(r){return J(r)}}},{name:"media_sync",long:!0,title:"Sync dailies: each picture file's sound found in the sound recorder's files",description:"Dailies sound sync in the analysis engine: every picture file's scratch track is found in the production sound recorder's WAVs (spectral landmarks, then the waveform lined up to the sample \u2014 it survives a different microphone, level and room). The sound decides and the timecode confirms: where camera and recorder both carry timecode (BWF time reference), how far they disagree is reported in frames (a jam to fix); a file with no scratch sound, or too quiet to match, is placed by timecode alone and says so. Returns, per picture file, the recorder file, the sync (recorder seconds / samples / timecode at the picture's first frame) and how it was found, plus a session_id of the dailies: every picture file whole on V1 in timecode order with its recorder file laid under it at the sync, one audio track per channel \u2014 for timeline_write to any host. Pinned by an authored test with an exact answer (rust/analysis-core/tests/sync_planted.rs).",inputSchema:{picture:f.array(f.string()).min(1).describe("Picture files or folders (camera originals, proxies), searched recursively"),sound:f.array(f.string()).min(1).describe("The sound recorder's WAVs or folders of them, searched recursively"),name:f.string().optional().describe("Name of the dailies timeline"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status")},run:async({picture:e,sound:t,name:n,__progress:r})=>{try{let o=await Ev({picture:e,sound:t,name:n},r),s=await qn(o.session,t[0],"sync");return X(`session_id: ${s.id}
|
|
471
|
-
${o.text}`,{session_id:s.id,...o.data})}catch(o){return J(o)}}},{name:"qc_media",long:!0,title:"QC of a movie: frames, edges, pixels, sound",description:"QC of one file, picture and sound, in the analysis engine: every frame for doubled frames inside motion, freezes, black flashes and black segments mid-program, and flash frames (one frame far from both neighbours that match each other; 4+ in 2 s is a strobe, reported to check); every frame's edges at full resolution for blanking (a flat-black line on any edge, 1 px counts) and black corners; and stuck / hot / dead pixels across 24 frames spread over the file (a pixel that holds one value while the picture around it moves). Sound, every audio track: integrated loudness (BS.1770) and true peak, clipping (runs at full scale), dropouts (digital silence cut into sound), a silent channel beside live ones, DC offset, a stereo pair out of phase. Verdict PASS / CHECK / FAIL with each finding at source timecode. Heads and tails (leaders, holds) are reported as information, not failures. edges_every N reads every Nth frame's edges instead of all (faster on long programs).",inputSchema:{path:f.string().describe("The file to QC (a deliverable render, a master)"),edges_every:f.number().int().min(1).max(240).optional().describe("Check the edges of every Nth frame (default 1: all)"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status")},run:async({path:e,edges_every:t,__progress:n})=>{try{let r=await Cv(e,{edges_every:t},n);return X(r.text,r.data)}catch(r){return J(r)}}},{name:"timeline_autoconform_review",title:"Review the shots auto conform was unsure of",description:"After timeline_autoconform: the shots the engine could not confirm, each with an A/B contact sheet (top row = the reference, bottom = the guessed source clip, five frames across the shot) returned as images. gap_guess = left as a gap, with the engine's best guess; doubtful = placed, but the in-point or the take is in doubt. Look at each sheet and settle only what you are sure of: accept=[ref_start] places a gap's guess, reject=[ref_start] turns a doubtful placement into a gap. Same set, different moment or a near-identical take of the same setup: leave it and name it to the artist. Rebuilds the session from the engine's own result (no re-run); then timeline_write. offset/limit page through the sheets (4 per call).",inputSchema:{session_id:f.string().describe("The session timeline_autoconform returned"),accept:f.array(f.number().int()).optional().describe("ref_start of each gap_guess to place"),reject:f.array(f.number().int()).optional().describe("ref_start of each doubtful shot to turn into a gap"),offset:f.number().int().min(0).optional().describe("First review shot to show (default 0)"),limit:f.number().int().min(0).max(12).optional().describe("Contact sheets per call (default 4; 0 = list only)")},run:async e=>{try{let t=await hv(e),{images:n,...r}=t;return{...X(gv(t),{...r,session_id:e.session_id}),images:n}}catch(t){return J(t)}}},{name:"qc_compare",long:!0,title:"Compare two versions of a cut and rebuild the new one from the old",description:"Reference Compare: rebuild a new render of a cut (B) from the old one (A) and say what changed: frames inserted, removed, moved, replaced, held, reversed or retimed. It is an auto conform of B with A as the only source (the analysis engine), so it is perceptual (survives a regrade or a re-render), takes any codec and resolution either side, and places every frame of B on A's own frame with its timing: a freeze, a reverse, a retime at its speed, a ramp as its curve. Builds the reconform: A-source events + holes of new material tiling B (motion effects as CMX3600 M2); events the engine wants an eye on are flagged CHECK. Writes a CMX3600 EDL and/or CSV when given paths, and returns a session of B rebuilt from A's media (session_id, for timeline_write). Use for a re-cut after color ('what changed in v3?'), checking a deliverable against the approved version, or reconforming changes into a graded timeline. Long: background=true for a job id.",inputSchema:{a:f.string().describe("Path to the OLD version (whose media and grade exist)"),b:f.string().describe("Path to the NEW version, to rebuild from A"),edl_path:f.string().optional().describe("Write the reconform as a CMX3600 EDL here"),csv_path:f.string().optional().describe("Write the reconform events as CSV here")},run:async({a:e,b:t,edl_path:n,csv_path:r,__progress:o,__signal:s})=>{try{let i=await Mv({a:e,b:t,onProgress:o,signal:s});n&&await Ve(n,i.edl),r&&await Ve(r,i.csv);let a=await qn(i.session,t,"reconform"),l=[`session_id: ${a.id} (B rebuilt from A; timeline_write it to any host)`,...n?[`EDL: ${n}`]:[],...r?[`CSV: ${r}`]:[],Pv(i,{a:e,b:t})].join(`
|
|
472
|
-
`);return X(l,{session_id:a.id,summary:i.summary,stats:i.stats,events:i.events.map(c=>({index:c.index,kind:c.kind,record:[c.recordInTc,c.recordOutTc],...c.aInTc?{a:[c.aInTc,c.aOutTc]}:{},...c.motion?{speed:c.motion.ramp?"ramp":c.motion.percent}:{}})),check:i.check.map(c=>({index:c.index,record:[c.recordInTc,c.recordOutTc],note:c.unreproducible.note}))})}catch(i){return J(i)}}},{name:"render_gate",title:"Check a timeline before a deliverable render",description:"Run BEFORE every deliverable render. From the read timeline and the mix WAVs (placed by their BWF timecode): the program start (the mix's 2-pop + 2 s, else program_start, else the artist profile's, else the picture's first frame), picture end vs the mix's last sound (any difference, even 1 frame, is an EDIT ERROR: fix or ask, never cut at picture), picture/mix starting late, the last program frame (picture, not a gap), gaps inside the program, video layers ending just short of the end, and the deliverable name's audio promise (8CH_5-1_STEREO = 6ch + 2ch) vs the mix files. Returns READY/STOP and the Mark In/Out to render with (Out inclusive). Then render (host_render, audio_tracks for the output routing) and qc_deliverable the file.",inputSchema:{session_id:f.string().describe("The timeline (timeline_read / host_current)"),mix:f.array(f.string()).optional().describe("The mix WAV(s); the first sets the program length"),program_start:f.string().optional().describe("Program start TC when the mix has no 2-pop (default: the artist profile's program_start)"),name:f.string().optional().describe("The deliverable file name about to be rendered"),timeline_id:f.string().optional()},run:async({session_id:e,...t})=>{try{let n=await hT((await bt(e)).session,t);return X(gT(n),{...n})}catch(n){return J(n)}}},{name:"qc_deliverable",long:!0,title:"Sign off a deliverable render",description:"QC a rendered deliverable before it goes out, PASS/FAIL per check: codec/raster/rate/bit depth/chroma (when given), start TC (mark_in, start_tc or the artist profile's program_start; else reported only) and frame count (mark_in..mark_out inclusive, or frames), the file name against the facility naming profile and against the file itself (codec, raster, color tags, audio channels), black at the head/tail with its length (WARN; end_on_picture=true makes tail black FAIL), audio per output track (channels, integrated loudness, true peak; AAC included) and against the mix WAVs (each track must match one mix within 0.5 LU: +6 LU = summed twice, an unmatched mix = missing bus), and picture vs the approved REF (frame-exact at the render's start TC; burn-ins and a regrade do not count as differences). Use after every deliverable render. Long: background=true for a job id.",inputSchema:{path:f.string().describe("The rendered deliverable"),mark_in:f.union([f.string(),f.number().int()]).optional().describe("Timeline Mark In (TC or frame): the expected start TC"),mark_out:f.union([f.string(),f.number().int()]).optional().describe("Timeline Mark Out, INCLUSIVE: with mark_in, the expected frame count"),start_tc:f.string().optional().describe("Expected start TC when there is no mark_in (default: the artist profile's program_start)"),frames:f.number().int().positive().optional().describe("Expected frame count"),codec:f.string().optional().describe("e.g. 'ProRes 4444', 'ProRes 422 HQ', 'H.264'"),width:f.number().int().positive().optional(),height:f.number().int().positive().optional(),fps:f.number().positive().optional(),bit_depth:f.number().int().optional(),chroma:f.string().optional().describe("e.g. 4:4:4"),channels:f.number().int().min(0).optional().describe("Total audio channels expected"),loudness_lufs:f.number().optional().describe("Target integrated loudness per track (e.g. -24)"),loudness_tolerance:f.number().positive().optional().describe("\xB1 LU (default 1)"),true_peak:f.number().optional().describe("True-peak ceiling, dBTP (e.g. -2)"),mix:f.array(f.string()).optional().describe("The mix WAVs / stems the audio outputs must carry"),ref:f.string().optional().describe("The approved reference movie"),ref_in:f.union([f.string(),f.number().int()]).optional().describe("The REF's TC/frame for the render's first frame (default the render's start TC)"),name:f.boolean().optional().describe("Check the name against the naming profile (default true)"),end_on_picture:f.boolean().optional().describe("The program ends on its end card: any black at the tail FAILS (default: WARN with its length)")},run:async({__progress:e,__signal:t,...n})=>{try{let r=await pT(n);return X(mT(r),{...r})}catch(r){return J(r)}}},{name:"patch_plan",title:"Plan patch renders for changed shots",description:"Work out the patches to re-render for changed shots on a read timeline (a session from host_current / timeline_read), before anything is queued. Each patch runs from the head of the WHOLE clip before the change to the tail of the WHOLE clip after it, cut on existing edits of the picture as it plays (the topmost enabled video layer), never inside a lower third/title (graphics tracks, by name) or a transition; contiguous changes share one patch. Says the neighbouring clips, whether TEXTLESS is needed (a graphics track has content in range \u2192 TEXTED + TEXTLESS, with the tracks to leave out of TEXTLESS), picture only, file TC = record TC of the head. Returns host_render-ready ranges (absolute frames, inclusive) plus record TC. Give master (a delivered file's name) to get each patch's file name, render job name and folder from the naming profile. Read-only.",inputSchema:{session_id:f.string(),changes:f.array(f.union([f.string(),f.object({in:f.union([f.string(),f.number()]),out:f.union([f.string(),f.number()])})])).min(1).describe("The changed shots: clip item_ids (timeline_query), or record ranges {in, out} as record TC or absolute timeline frames, out inclusive"),timeline_id:f.string().optional().describe("The timeline (default the session's first with video)"),master:f.string().optional().describe("A delivered master's file name (or path) to name the patches from (naming profile)"),first_patch:f.number().int().min(1).default(1).describe("Number of the first patch (PATCH01)")},run:async({session_id:e,changes:t,timeline_id:n,master:r,first_patch:o})=>{try{let s=await bt(e),i=ST(s.session,t,{timeline_id:n,first_patch:o}),a=$T(i);if(r){let l=await vo(),c=new Date,u=i.patches.map(d=>d.versions.map(m=>({text:m,...Jc(l,r,{nn:d.nn,text:m,when:c})})));a+=`
|
|
473
|
-
`+u.flat().map(d=>`name ${d.file}${d.job?` job ${d.job}`:""} \u2192 ${d.folder}`).join(`
|
|
474
|
-
`);let p=[...new Set(u.flat().flatMap(d=>d.warnings))];return p.length&&(a+=`
|
|
475
|
-
`+p.map(d=>`warning: ${d}`).join(`
|
|
476
|
-
`)),X(a,{...i,names:u})}return X(a,{...i})}catch(s){return J(s)}}},{name:"media_frame",title:"Grab frames from a media file",description:"Decode a frame of a media file to a PNG on this machine (our own decoders: ProRes, DNx, H.264/HEVC, MXF, camera originals, stills \u2014 exr/dpx/tiff/jpg/png/dng/cr3, scaled with width=; never uploads). frame is a frame index (0 = first) or an ABSOLUTE source timecode (the file's start TC is honoured); default the middle frame. around=N makes a contact sheet of the frames \xB1N (every step-th), each labelled with its TC \u2014 check a shot change, not one middle frame. b = a second file: A/B rows of the same frames (b_frame defaults to the same absolute TC; give it when the TC bases differ) with a perceptual difference score per column (survives a regrade, burn-in/watermark, rescale). Prove a frame offset with media_align. session_id + item_id / record grabs the source frame under a timeline position (returns the source file, frame and TC it resolved to). Writes out_path (.png) or a temp file; returns the path \u2014 open it to look.",inputSchema:{path:f.string().optional().describe("The media file; or session_id + item_id / record for the source frame under a timeline position"),session_id:f.string().optional().describe("Through a session: the source file and frame under item_id (record moves inside it) or under record (the topmost enabled video clip); the clip must be linked (timeline_relink first)"),item_id:f.string().optional(),record:f.union([f.string(),f.number().int()]).optional().describe("With session_id: record TC like 01:00:10:00, or frames from the timeline head"),timeline:f.string().optional().describe("With session_id: timeline id or name (default the primary)"),frame:f.union([f.string(),f.number().int()]).optional().describe("Frame index or absolute source TC like 01:00:10:00; default the middle frame"),around:f.number().int().min(0).max(48).optional().describe("Contact sheet: \xB1N frames around frame"),step:f.number().int().min(1).optional().describe("Contact sheet: every Nth frame (default 1)"),b:f.string().optional().describe("A second file for A/B (e.g. the master against the temp)"),b_frame:f.union([f.string(),f.number().int()]).optional().describe("B's frame or TC for A's frame; default the same absolute TC"),width:f.number().int().min(16).max(8192).optional().describe("Output width per frame (default full size; 480 per tile on a sheet)"),out_path:f.string().optional().describe("PNG to write; default a temp file")},run:async({session_id:e,item_id:t,record:n,timeline:r,...o})=>{if(e)return wn("timeline_frame").run({session_id:e,item_id:t,record:n,timeline:r,...o});if(!o.path)return J(new L("invalid_args","media_frame needs path, or session_id with item_id / record"));try{let s=await _o(o);return X(Kc(s),{...s})}catch(s){return J(s)}}},{name:"timeline_frame",hidden:!0,title:"Grab the source frame under a timeline position",description:"media_frame through a session: the source file and frame under an item (item_id; record moves inside it) or under a record TC (the topmost enabled video clip there), decoded to a PNG; around=N for a contact sheet. Returns the file, source frame and TC it resolved to. The clip must be linked (timeline_relink first).",inputSchema:{session_id:f.string(),item_id:f.string().optional(),record:f.union([f.string(),f.number().int()]).optional().describe("Record TC like 01:00:10:00, or frames from the timeline head"),timeline:f.string().optional().describe("Timeline id or name (default the primary)"),around:f.number().int().min(0).max(48).optional(),step:f.number().int().min(1).optional(),width:f.number().int().min(16).max(8192).optional(),out_path:f.string().optional()},run:async({session_id:e,item_id:t,record:n,timeline:r,...o})=>{try{let s=await bt(e),i=W1(s.session,{item_id:t,record:n,timeline:r}),a=await _o({...o,path:i.path,frame:i.frame});return X(`record ${i.record_tc} (${i.track}, item ${i.item}) = ${ie(i.path)} frame ${i.frame} (${a.frames[a.frames.length>>1]?.tc??"?"})
|
|
477
|
-
${Kc(a)}`,{...a,source:i})}catch(s){return J(s)}}},{name:"timeline_align",long:!0,title:"Match each clip's framing to a reference track",description:"The Aligner: for every clip on the target video tracks that sits over a clip of the REFERENCE track (an offline, a client render, the graded master), the reference's picture and the clip's raw source frame at the same record frame are fitted in the analysis engine (the sizing auto conform uses), and the clip's WHOLE transform comes back \u2014 scale, position, rotation, flips \u2014 in IR units and as Resolve edit-page properties (Pan, Tilt, ZoomX, ZoomY, RotationAngle, FlipX, FlipY in its scripting API's units). Verdict per clip: aligned / animated (samples \u2265 2 and the framing moves: the clip is then measured on EVERY frame, each frame's answer in `keys`, and written as the fewest keyframes on Resolve's own ease (Dissolve Type) that stay within 1 px at rest and half a frame of timing while it moves \u2014 `grade_keys`, for sizing_target input / node one keyframed Colour-page op (`grade_keys` on Resolve's Dissolve-Type ease); for edit an `edit_keys` op (`edit_keys` on Resolve's Edit-page Bezier law), keyed on a copy of the timeline, '<timeline> ALIGNED', as Resolve's API cannot keyframe the Edit page) / no_match (another shot or moment; confidence = the fit's agreement 0\u20131, trusted from 0.4) / refused (not linked, no reference under it, the reference clip itself resized). Returns host_apply ops: `properties` for every aligned clip and a marker per clip (data \"ConformTools:align\"); apply them with host_apply on the live timeline (host_current via=export it first, timeline_relink so the media is linked). apply_session writes the aligned transforms into the session (timeline_write / host_open builds a <TL>_ALIGNED). Resolve units assume the timeline's input scaling 'fit' (Scale entire image to fit); pass input_scaling for fill / crop / stretch. sizing_target says where the framing goes in Resolve: edit (default) = the Edit page transform (`properties` ops); input = the Color page's clip Input Sizing, node = the Sizing of node 1 (`grade_sizing` ops, written as a grade .drx). input / node leave the clip's own edit transform (the client XML's) untouched and carry only the correction on top of it, so the cut goes back to Premiere without the aligner's resizes; input ADDS the sizing to the clip's grade as it stands (every node and version kept) on a new local version 'conform.tools aligned', leaving the colorist's own version untouched (undo goes back to it); node writes Sizing into the chosen node of that same kept grade (a node that already has Sizing of its own is refused); a clip on a REMOTE grade version (shared by every use of that source clip, in every timeline) is first moved onto its local version, so the other uses never change. Node sizing has no flip and cannot show picture outside the clip's own fitted raster.",inputSchema:{session_id:f.string(),reference_track:f.union([f.number().int().positive(),f.literal("offline")]).optional().describe(`The reference's video track, 1-based (V1 = 1), or "offline" = the timeline's linked offline reference clip. Leave out: a track named REF / REFERENCE / OFFLINE, else the top video track`),tracks:f.array(f.number().int().positive()).optional().describe("Video tracks to align (default: every other video track)"),timeline_id:f.string().optional().describe("Timeline id or name (default the primary)"),samples:f.union([f.number().int().min(1).max(600),f.literal("all"),f.literal("half"),f.literal("ends")]).optional().describe('Frames measured per clip to SEE a move: "ends" = the first and last frames and the quarters between (a move shows as them disagreeing, even one that returns to where it started), "half" = every half second and the last frame (the default), a count spread over it, or "all" = every frame (up to 600 per clip; the static answer is the median of the trusted frames). A clip they show moving is measured on every frame anyway'),step:f.number().int().min(1).optional().describe("Measure every step-th frame instead (12 = every half second at 24 fps)"),scope:f.enum(["all","playhead","selected"]).optional().describe("Which clips: all (default), the clip under `at`, or the `picks`"),at:f.number().int().optional().describe("scope playhead: the record frame (from the timeline start)"),picks:f.array(f.string()).optional().describe('scope selected: "track:start" of each clip (video track, record start in frames from the timeline start)'),input_scaling:f.enum(ou).optional().describe("Resolve's input scaling for the clips (default fit)"),apply_session:f.boolean().optional().describe("Write the aligned transforms into the session"),markers:f.boolean().optional().describe("Include marker ops (default true)"),sizing_target:f.enum($g).optional().describe("Where the framing goes in Resolve: edit (Edit page transform, default), input (Color page Input Sizing) or node (node 1 Sizing)"),node:f.union([f.number().int().positive(),f.string(),f.object({layer:f.number().int().positive(),node:f.union([f.number().int().positive(),f.string()])})]).optional().describe("node: which node gets the Sizing \u2014 its number as Resolve shows it, or its label (default 1), or {layer, node}. The clip's grade goes onto a new local version 'conform.tools aligned', every node kept, the colorist's version untouched"),layer:f.number().int().positive().optional().describe("node: which node stack `node` is in (1 = the first; default 1)"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status")},run:async({session_id:e,__progress:t,__signal:n,...r})=>{try{let o=await bt(e),s;if(o.source_format==="drt"&&o.source_path&&await nt(o.source_path)){s=new Map;let a=Dg(await tn(o.source_path));for(let[l,c]of a)if(c.active){let u=jg(c.active);u.length&&s.set(l,u)}}let i=await Rg(o.session,{...r,inputs:s},t,n);return r.apply_session&&i.applied&&await Xt(o,`timeline_align: ${i.applied} transform(s) from V${i.reference_track}`),X(Cg(i),{...i,session_id:e})}catch(o){return J(o)}}},{name:"qc_decide",title:"Decide a QC finding",description:"Record what the artist decided about one Master QC finding (0.9.5 dispositions): fixed, intent (artistic intent), best_available, wont_fix, not_issue \u2014 or open to undecide. Kept per project + timeline and per finding `key` (each Finishing QC row carries it: check|start|end|clip), across re-runs: a decided finding stays listed and stops counting against the verdict.",inputSchema:{project:f.string().describe("The host project (a Finishing QC row's scope.project)"),timeline:f.string().describe("The timeline (the row's scope.timeline)"),key:f.string().describe("The finding's key (the row's key)"),status:f.enum(Ma.map(([e])=>e)),note:f.string().optional().describe("Why, in the artist's words")},run:async({project:e,timeline:t,key:n,status:r,note:o})=>(await vb(e,t,n,r,o),X(`${n}: ${r==="open"?"open again":Pa({status:r,note:o,at:""})}`,{key:n,status:r}))},{name:"qc_blanking",long:!0,title:"Find clips whose sizing shows black",description:"The Blanking Detector on a session: every clip's placement (its IR transform at each frame: scale, position, rotation, anchor, crop, over the source's fit) checked for black inside the delivery frame \u2014 the whole raster, or with `aspect` the centred delivered ratio (16:9, 1.85, 2.00, 2.20, 2.35, 2.39, 2.76, 4:3, 1:1, 9:16, none, or a number), so the deliverable's own bars are never a finding. pixels=true also decodes `samples` source frames per clip in the analysis engine and measures the source's own black edges (QC's edge rule): a letterbox baked into a source and revealed by a pull-out is caught too. Each frame is judged on the topmost enabled clip; findings are ranges (strictness strict 1 px / 1 frame \u2014 default, standard 2 px / 2 frames, relaxed 6 px / 4 frames) with depth per edge, zones, and the least zoom that fills the frame (about the clip's anchor, position kept). Returns host_apply ops: a ZoomX/ZoomY `properties` fix per clip (a keyframed clip gets markers only) and a marker per range (data \"ConformTools:blanking\").",inputSchema:{session_id:f.string(),timeline_id:f.string().optional().describe("Timeline id or name (default the primary)"),aspect:f.union([f.enum(Object.keys(Eg)),f.number().positive(),f.string()]).optional().describe("Delivered aspect when bars are part of the deliverable (default none: the whole raster)"),strictness:f.enum(Object.keys(Uc)).optional(),tolerance_px:f.number().int().min(0).optional().describe("the strictness's black-edge tolerance in px (overrides its number)"),min_frames:f.number().int().min(1).optional().describe("frames a reveal must last to count"),gap_frames:f.number().int().min(0).optional().describe("frames between reveals that still make one range"),black_threshold:f.number().int().min(0).max(255).optional().describe("8-bit level at or under which a pixel is black"),pixels:f.boolean().optional().describe("Also measure the sources' own black edges on decoded frames (needs linked media)"),samples:f.number().int().min(1).max(12).optional().describe("pixels: source frames measured per clip (default 3)"),input_scaling:f.enum(ou).optional().describe("Resolve's input scaling, for the zoom fix's units (default fit)"),markers:f.boolean().optional().describe("Include marker ops (default true)"),background:f.boolean().default(!1).describe("Return a job id immediately; follow it with job action=status")},run:async({session_id:e,__progress:t,__signal:n,...r})=>{try{let o=await bt(e),s=await Mg(o.session,r,t,n);return X(Pg(s),{...s,session_id:e})}catch(o){return J(o)}}},{name:"patch_verify",long:!0,title:"Verify a rendered patch against the delivered master",description:"Check a rendered patch against the master it patches: spec (codec, ProRes profile, pixel format, bit depth, raster, frame rate, color tags), frame count, start TC = the record TC, picture only, then the picture frame by frame against the master at the same TC (every frame; per-frame mismatches with their TC and difference, plus the patch's shot changes). After a splice (media_patch), the seam decode proof: full-raster decoded frames \xB12 s around each seam, exact: inside the span = the patch, outside = original (a backup or the unpatched master) when given, and every frame decodes. Use after every patch render, before it goes to the client. Read-only. Long: background=true for a job id.",inputSchema:{patch:f.string().describe("The rendered patch file"),master:f.string().describe("The delivered master file it patches"),expected_tc:f.string().optional().describe("The record TC the patch must start at (patch_plan start_tc)"),expected_frames:f.number().int().min(1).optional().describe("The frame count it must have (patch_plan frames)"),tolerance:f.number().min(0).max(255).default(10).describe("Largest luma difference (0-255, on a 64-wide thumbnail) still counted as the same picture"),original:f.string().optional().describe("After a splice: the backup / unpatched master, so the seam proof checks the neighbouring frames are untouched")},run:async({patch:e,master:t,expected_tc:n,expected_frames:r,tolerance:o,original:s,__progress:i})=>{try{let a=await RT({patch:e,master:t,expected_tc:n,expected_frames:r,tolerance:o,original:s},i);return X(CT(a,{patch:e,master:t}),{...a})}catch(a){return J(a)}}},{name:"artist_profile",title:"How this artist works: learn, read and remember",description:"conform.tools works the way THIS artist/facility works, never one built-in way. Their profile holds naming templates, the usual deliverable set, folders/bins, conventions (program_start TC, end_on_picture, theatrical_tag) and workflow rules in their words, each with where it came from. action=get (default) shows it; read it before naming, rendering or delivering. learn reads a folder of their DELIVERED files (read only): matches each name element to what the file really is (codec, raster+rate, color, audio, dates) and saves the naming template, the usual deliverable set and the codec folders (project= keeps them as that project's spellings; save=false previews). remember saves a preference: rule='\u2026' (topic e.g. deliverables/naming/render/patch) and/or conventions={program_start:'01:00:00:00', \u2026}. Save only what is THIS artist's choice; when they correct you, ask: 'your preference, or should every artist work this way?'; the second is a product issue (report kind=issue), not a profile rule. forget removes a rule (number or text). set replaces the whole profile JSON.",inputSchema:{action:f.enum(["get","learn","remember","forget","set"]).default("get"),path:f.string().optional().describe("learn: a folder of delivered files (or one file)"),project:f.string().optional().describe("learn: save as this project's spellings over the artist's"),facility:f.string().optional().describe("learn: the artist's or facility's name"),save:f.boolean().default(!0).describe("learn: false = preview only"),rule:f.string().optional().describe("remember: the preference in the artist's words; forget: text or number"),topic:f.string().optional().describe("remember: naming, deliverables, render, patch, conform\u2026"),source:f.string().optional().describe("remember: where it came from (default 'told')"),conventions:f.object({program_start:f.string().optional(),end_on_picture:f.boolean().optional(),theatrical_tag:f.string().optional(),no_audio_tag:f.string().optional()}).optional(),profile:f.record(f.string(),f.unknown()).optional().describe("set: the whole profile JSON")},run:async({action:e,path:t,project:n,facility:r,save:o,rule:s,topic:i,source:a,conventions:l,profile:c})=>{try{let u=await Js();switch(e??"get"){case"learn":{if(!t)return J(new L("invalid_args","learn needs path (a folder of delivered files)"));let p=await rg(t,{project:n,facility:r,save:o}),d=[`${p.source}${p.saved?` \u2192 saved ${p.saved}`:" (preview, not saved)"}`,...Object.entries(p.learned.templates??{}).map(([m,h])=>` ${m}: ${h}`),...(p.learned.deliverables??[]).map(m=>` usual: ${m.label} (${m.CODEC} ${m.AUDIOCONFIG} .${m.ext}${m.texts.length?`, ${m.texts.join("/")}`:""})`),...Object.entries(p.learned.codec_folders??{}).map(([m,h])=>` folder: ${m}\u2026 \u2192 ${h}`),...p.misfits.length?[` ${p.misfits.length} name(s) follow another pattern: ${p.misfits.slice(0,5).join(", ")}`]:[],...p.name_issues.map(m=>` check ${m.file}: ${m.issues.join("; ")}`),"Ask the artist what files cannot show: is this the usual set, the program start TC, any optional kinds (artist_profile action=remember)."];return X(d.join(`
|
|
478
|
-
`),{...p})}case"remember":{if(!s&&!l)return J(new L("invalid_args","remember needs rule or conventions"));s&&(u=og(u,{rule:s,topic:i,source:a??"told"})),l&&(u=ig(u,l,a??"told"));let p=await Qs(u);return X(`remembered \u2192 ${p}
|
|
479
|
-
${Xs(u)}`,{profile:u,path:p})}case"forget":{if(!s)return J(new L("invalid_args","forget needs rule (its number or text)"));u=sg(u,/^\d+$/.test(s)?Number(s):s);let p=await Qs(u);return X(`forgotten \u2192 ${p}
|
|
480
|
-
${Xs(u)}`,{profile:u,path:p})}case"set":{let p=await Qs(c);return X(`saved \u2192 ${p}`,{path:p})}default:return X(Xs(u),{profile:u})}}catch(u){return J(u)}}},{name:"naming",title:"The artist's naming: build and check names",description:"The artist's own naming convention (from their artist_profile) for everything conform.tools names: deliverables, patches, timelines, documents, render jobs, folders. There is no built-in convention: with no profile, learn it first (artist_profile action=learn) or ask. Names are copied EXACTLY from the convention (separators, order, spellings). action=get shows the profile; set saves one ({facility, templates: {kind: '[TITLE]_[TEXT]_\u2026'}, values?, codec_folders?}); build makes a name of a kind from values; patch derives a patch's file name, render job name and folder FROM a delivered master's file name (the artist's patch template, their no-audio tag when picture-only, today's date/time, every other element the master's); check validates a name against the template (separators, order), against the file's probe facts (path: codec, raster, rate, color tags, audio channels, the H264_25mbps bitrate) and against the master it patches; legacy operator initials after the date are noted, not required. deliverables expands the artist's usual deliverable set for a program (values: TITLE, COLORSPACE, GAMMA, FORMAT at the OAR) into file names: TEXTLESS only with textless=true (text over picture), optional kinds (UHD H.264) with include_optional. project applies that project's own spellings (profile.projects[PROJECT]: templates/values/deliverables) over the facility's structure.",inputSchema:{action:f.enum(["get","set","build","patch","check","deliverables"]).default("get"),project:f.string().optional().describe("Use this project's spellings (profile.projects[project]) over the facility's"),textless:f.boolean().optional().describe("deliverables: the program has text over picture, so a TEXTLESS version is made"),include_optional:f.boolean().optional().describe("deliverables: include the optional kinds (e.g. UHD H.264)"),profile:f.record(f.string(),f.unknown()).optional().describe("set: the profile JSON"),kind:f.string().optional().describe("build/check: the template kind (deliverable, patch, timeline, replace_list, tracklayout, qc, render_job, deliverables_folder)"),values:f.record(f.string(),f.string()).optional().describe("build: the elements, e.g. {TITLE: 'TRIMBLE', SOURCE: 'TRIMBLE_LP COLOR', PURPOSE: 'ARCHIVAL', SCOPE: 'REPLACE_XD32995'}; YYYYMMDD/HHMM default to now"),name:f.string().optional().describe("check: the name to check"),path:f.string().optional().describe("check: the file the name is for (probed)"),master:f.string().optional().describe("patch/check: the delivered master's file name"),nn:f.number().int().min(1).default(1).describe("patch: the patch number"),text:f.enum(["TEXTED","TEXTLESS"]).optional().describe("patch: the version (default the master's)"),picture_only:f.boolean().default(!0).describe("patch: AUDIOCONFIG = the artist's no-audio tag")},run:async({action:e,profile:t,kind:n,values:r,name:o,path:s,master:i,nn:a,text:l,picture_only:c,project:u,textless:p,include_optional:d})=>{try{let m=await vo(u);switch(e??"get"){case"set":{let h=await Qs(t);return X(`saved the ${t?.facility??""} naming profile \u2192 ${h}`,{path:h})}case"build":{if(!n)return J(new L("invalid_args","build needs kind"));let h=tg(m,n,{...ng(),...r});return X(h,{name:h,kind:n})}case"patch":{if(!i)return J(new L("invalid_args","patch needs master (a delivered file's name)"));let h=Jc(m,i,{nn:a??1,text:l,picture_only:c});return X([h.file,h.job?`render job: ${h.job}`:"",`folder: ${h.folder}`,...h.warnings.map(g=>`warning: ${g}`)].filter(Boolean).join(`
|
|
481
|
-
`),{...h})}case"check":{if(!o)return J(new L("invalid_args","check needs name"));let h=wa(m,o,{kind:n,master:i,probe:s?await mt(s):void 0}),g=h.issues.filter(y=>y.level==="error");return X([`${g.length?"WRONG":"ok"}: ${o} (${m.facility} ${h.kind})`,...h.issues.map(y=>` ${y.level}: ${y.element}: ${y.message}`)].join(`
|
|
482
|
-
`),{...h,ok_name:!g.length})}case"deliverables":{let h=Z1(m,r??{},{textless:!!p,include_optional:d});return X([`${m.facility}${u?` / ${u}`:""} usual deliverables:`,...h.map(g=>` ${g.name} (${g.label}, ${g.text}, ${g.raster}${g.container?" 16x9 container":""}, ${g.audio})`),...p?[]:[" (no TEXTLESS: pass textless=true when the program has text over picture)"]].join(`
|
|
483
|
-
`),{deliverables:h})}default:return X(Object.keys(m.templates).length?`${m.facility} naming profile
|
|
484
|
-
${JSON.stringify(m,null,2)}`:Xs(m),{profile:m})}}catch(m){return J(m)}}},{name:"media_align",long:!0,title:"Frame offset between a temp and its master",description:"Prove (or find) where a range of file A (the temp / graded reference) sits in file B (the master), frame-exact. Give a_in/a_out (frame or absolute TC in A; default all of A) and b_in, the frame/TC in B the client maps a_in to; without b_in all of B is searched. Checks \xB1search frames (default 12), anchored on shot changes present in both; perceptual (a regrade, a burned-in TC/watermark, a rescale do not move it). Reports overall and per shot: exact / offset N frames (+ = later in B) with a confidence / unverifiable (static picture: the offsets that fit equally) / no match, plus flash-frame risk (a B shot change inside or within 3 frames of the range). Use before replacing a temp with a master on another TC base, and when the client's mapping disagrees with the graded temp.",inputSchema:{a:f.string().describe("The temp / graded reference"),a_in:f.union([f.string(),f.number().int()]).optional(),a_out:f.union([f.string(),f.number().int()]).optional().describe("Last frame included"),b:f.string().describe("The master"),b_in:f.union([f.string(),f.number().int()]).optional().describe("The client's in-point in B for a_in; omit to search"),search:f.number().int().min(1).max(250).optional().describe("\xB1frames checked (default 12)")},run:async({__progress:e,__signal:t,...n})=>{try{let r=await ya({...n,signal:t});return X(H1(r),{...r})}catch(r){return J(r)}}},{name:"tool",title:"Tools: the artist's own and the ones that ship, as recipes",description:`Every tool in the conform.tools app is a recipe: typed inputs + nodes wired by reference, each node a block \u2014 a conform.tools verb (verb.<name>), a Resolve call (resolve.pull, resolve.apply, resolve.<edit>), or logic (rows.filter, review, ops.collect, plan.*). Every tool the app ships (${Ta.filter(e=>!e.hidden).map(e=>e.name).join(", ")}) and every verb as a one-node tool is an editable default: saving a recipe under a default's id replaces it for this artist, delete puts the default back. Host blocks (host.read, host.apply, host.open, host.render, edit.<op>) take host = resolve | premiere | avid | flame | nuke | fcp and work on whichever host's adapter or panel can do it (tool action=blocks says which). action=list (every tool) \xB7 show (id: its recipe) \xB7 blocks (every block with its params, to build with) \xB7 save (spec: a recipe \u2014 {id, name, group?, about?, host?, preview?, inputs:[{id, label, type: text|number|bool|choice|color|marker_color|file|files|folder|rename_steps|track|tracks|timeline|timelines|render_preset|source, choices?:[[value,label]], default?, optional?, when?:{input, is:[\u2026]}}], nodes:[{id, use, args, when?, label?}], view?}; view = the tool's screen when it opens in the app, a split tree {split:'row'|'col', panes:[\u2026], size?} whose leaves are {pane: knobs|viewer|rows|result|compare|graphics|running, show?: '$source'|'$review'|'$result'|'$<node>' (or two for compare), size?: 0\u20131}; leave it out and the app lays the screen out from the steps) \xB7 delete (id: one of the artist's own, or an edited default: back to the default) \xB7 export (ids or id, path: save the recipes out to a .json recipe file to share) \xB7 import (path: a recipe .json file; each tool checked and saved) \xB7 layout (the artist's hidden tools and \u2605 favourites) \xB7 arrange (layout: {hidden?:[ids], favourites?:[tool ids or block uses] | null}: merged in) \xB7 hide / show_tool (id) \xB7 workspace (project_id: the job's tabs \u2014 {open:[tool ids in tabs], source: {host} | {session_id, name?} | {path} | null (the timeline the tools work on)}) \xB7 workspace_save (project_id, workspace: the whole thing; open a tool in a tab for the artist). References in args: "$in.x" an input, "$node" or "$node.a.b" an earlier node's output, "$a|$b" the first that is set; when: "$in.source=file". A review node pauses a run on its rows for the artist's OK. When the artist describes a tool they want, read tool action=blocks, write the recipe, save it, and tell them it is in Tools; run it with tool_run.`,inputSchema:{action:f.enum(["list","show","blocks","save","delete","layout","arrange","hide","show_tool","export","import","workspace","workspace_save"]).default("list"),project_id:f.string().optional().describe("workspace: the project"),workspace:f.record(f.unknown()).optional().describe("workspace_save: {open:[tool ids], source}"),id:f.string().optional(),ids:f.array(f.string()).optional().describe("export: several tools into one file"),path:f.string().optional().describe("export: the .json recipe file to write \xB7 import: the file to read"),spec:f.record(f.unknown()).optional().describe("save: the recipe"),layout:f.record(f.unknown()).optional().describe("arrange: the parts of the layout to change")},run:async({action:e,id:t,ids:n,path:r,spec:o,layout:s,project_id:i,workspace:a})=>{try{if(e==="workspace"||e==="workspace_save"){let c=i||"local",u=e==="workspace_save"?await os(c,a??{}):await Ia(c),p=u?.source?"host"in u.source?`${u.source.host} (live)`:"session_id"in u.source?`timeline ${u.source.name??u.source.session_id}`:u.source.path:"none chosen";return X(u?`open: ${u.open.join(", ")||"nothing"} \xB7 timeline: ${p}`:"nothing open",{workspace:u})}if(e==="export"){if(!r)return J(new L("invalid_args","export needs path"));let c=await hb(n?.length?n:t?[t]:[],r);return X(`saved ${c.tools.length} tool(s) to ${c.path}`,c)}if(e==="import"){if(!r)return J(new L("invalid_args","import needs path"));let c=await gb(r,vu);for(let u of c)(await Br(u.id)).shipped||await Ea(u.id);return X(`imported ${c.map(u=>`'${u.name}' (${u.id})`).join(", ")} \u2014 in Tools`,{tools:c})}if(e==="layout"){let c=await rs();return X(JSON.stringify(c,null,2),{layout:c})}if(e==="arrange"){let c=await Ca(s??{});return X("layout saved",{layout:c})}if(e==="hide"||e==="show_tool"){if(!t)return J(new L("invalid_args",`${e} needs id`));let c=await rs(),u=e==="hide"?[...new Set([...c.hidden,t])]:c.hidden.filter(m=>m!==t),p=c.favourites&&e==="hide"?c.favourites.filter(m=>m!==t):c.favourites,d=await Ca({hidden:u,favourites:p});return e==="show_tool"&&await Ea(t),X(`${t} ${e==="hide"?"hidden":"shown"}`,{layout:d})}if(e==="blocks"){let c=Xb();return X(c.map(u=>`- ${u.use}${u.effect?" (changes things)":""}: ${u.about}`).join(`
|
|
485
|
-
`),{blocks:c})}if(e==="save"){let c=await fu(o,vu);return(await Br(c.id)).shipped||await Ea(c.id),X(`saved tool '${c.name}' (${c.id}) \u2014 it is in Tools; tool_run id=${c.id}`,{tool:c})}if(e==="delete"){if(!t)return J(new L("invalid_args","delete needs id"));let c=(await ns()).find(u=>u.id===t);return await db(t)?_t(c?.shipped?`${t} is back to the default`:`deleted ${t}`):J(new L("not_found",`${t} is not one of your tools, nor an edited default (a default as it ships can be hidden: action=hide)`))}if(e==="show"){if(!t)return J(new L("invalid_args","show needs id"));let c=await Br(t);return X(JSON.stringify(c,null,2),{tool:c})}let l=await ns();return X(l.map(c=>`- ${c.id}: ${c.name} [${c.group}]${c.template?" (default)":c.shipped?" (default, edited)":" (yours)"}${c.hidden?" (hidden)":""} \u2014 ${c.about.split(". ")[0]}`).join(`
|
|
486
|
-
`),{tools:l})}catch(l){return J(l)}finally{["save","delete","import","arrange","hide","show_tool"].includes(e)&&ag().catch(()=>{})}}},{name:"tool_run",long:!0,title:"Run a tool, and the job's runs: what is waiting for an OK, apply, undo",description:"Run a tool (tool action=list) with its inputs: {id, inputs} \u2014 on top of the settings the artist left in its tab in this job (app action=state shows them), so 'run it' runs what they see. When it reaches a review it stops and answers state=review with the rows and a run_id: show the artist the rows, then action=apply (run_id, and keep:[row ids] or drop:[row ids or 1-based row numbers]; neither = every row). Every run is shared with the app: a run you start shows in that tool's tab in the artist's window, and a review the artist has open in a tab is yours to read (action=list), apply or drop. action=list (project_id?, id?: the job's runs, newest first \u2014 waiting reviews with their rows, results, what can be undone) \xB7 csv (path, run_id? | id? | table: the rows it shows, a review's or the result's table, as a .csv) \xB7 apply (run_id?, keep? | drop?: no run_id = the job's latest review, that tool's with id) \xB7 drop (leave a review without applying) \xB7 undo (run_id?: put back what a run changed; none = the job's latest run that can be undone). preview=true runs only up to the first review or the first node that changes anything (nothing changes). Answers state=done with the result (and undo_id when the host can put it back), and sessions: each step that made a timeline \u2192 its session_id. until = a node id: run only what that node needs and answer its output (the tool editor's Run on a node). A `source` input takes a timeline already read (a host.read answer, or {session_id}); left out, the tool reads its host's open timeline. project_id: the job (default: the open one).",inputSchema:{action:f.enum(["run","list","apply","drop","undo","csv"]).default("run"),id:f.string().optional().describe("run: the tool \xB7 list / apply / undo: only that tool's runs"),spec:f.record(f.unknown()).optional().describe("a recipe to run without saving it (the builder's Try it)"),inputs:f.record(f.unknown()).default({}),preview:f.boolean().default(!1),run_id:f.string().optional().describe("apply / drop / undo: the run (its id, or its review's run_id)"),keep:f.array(f.string()).optional().describe("apply: exactly these review rows"),drop:f.array(f.union([f.string(),f.number().int()])).optional().describe("apply: every row but these (row ids, or 1-based row numbers)"),until:f.string().optional().describe("a node id: run only what it needs, answer its output"),path:f.string().optional().describe("csv: the .csv file to write"),table:f.object({rows:f.array(f.object({id:f.string(),cells:f.record(f.unknown())})),columns:f.array(f.tuple([f.string(),f.string()]))}).optional().describe("csv: these rows instead of a run's (the window's own preview, which is not a recorded run)"),project_id:f.string().optional().describe("the job (default: the job open in the app / the current project)"),by:f.string().optional().describe("who is asking (the app window says 'app'; default 'assistant')")},protectedStages:["canonicalize","write"],run:async({action:e,id:t,spec:n,inputs:r,preview:o,run_id:s,keep:i,drop:a,until:l,path:c,table:u,project_id:p,by:d,__signal:m,__progress:h})=>{try{let g=p||(await ho())?.id||"local",y={signal:m,progress:h,tool:Br,until:l};if(e==="list"){let R=Fo(g,t);return X(R.length?R.slice(0,20).map(S=>Jp(S)).join(`
|
|
487
|
-
`):"no runs in this job yet",{runs:R})}if(e==="csv"){if(!c)return J(new L("invalid_args","csv needs a path"));let R=u?{name:t??"rows",state:{state:"done",ok:!0,text:"",table:u}}:s?Ni(s):Fo(g,t)[0];if(!R)return J(new L("not_found","no run to save (run the tool first)"));let S=Tk(R);return S===null?J(new L("not_found",`${R.name}: this run has no rows to save`)):(await Ve(Nt(c),S),X(`${R.name}: ${S.split(`
|
|
488
|
-
`).length-1} row(s) saved to ${c}`,{path:c}))}if(e==="drop"){let R=_k(g,{id:s,tool:t});return X(`left ${R.name}'s review; nothing applied`,{run:R})}if(e==="undo"){let R=await vk(g,{id:s,tool:t},async(S,T)=>{let x=[],$=!0;for(let U of S.split("+").reverse()){let E=U.startsWith("files-")?await $o("media_move",{undo:U}):await $o("host_apply",{undo:U,...T&&!S.includes("+")?{timeline:T}:{}});$&&=!E.isError,x.push(E.content.map(z=>z.text).join(`
|
|
489
|
-
`))}return{ok:$,text:x.join(`
|
|
490
|
-
`)}});return X(`${R.name}: ${R.undone}`,{run:R})}let k={project:g,by:d||"assistant"},b,w;if(e==="apply"||s)({run:b,state:w}=await kk(g,{id:s,tool:t,keep:i,drop:a,by:k.by,inputs:r},y));else{let R=n?si.parse(n):await Br(String(t??"")),S=await Ia(g);if(!n&&S?.settings[R.id]&&k.by!=="app"){let T={...S.settings[R.id],...r};r=Object.fromEntries(Object.entries(T).filter(([x,$])=>{let U=R.inputs.find(E=>E.id===x);return $!==""&&$!=null&&!(Array.isArray($)&&!$.length)&&(!U?.when||U.when.is.includes(String(T[U.when.input]??"")))}))}R.inputs.some(T=>T.type==="source")&&r.source===void 0&&S?.source&&"session_id"in S.source&&(r={...r,source:{session_id:S.source.session_id}}),{run:b,state:w}=await wk(R,r,k,{...y,preview:o})}let _=w.state==="review"?`${w.label}: ${w.rows.length} row(s) waiting for the artist's OK (in the ${b?.name??"tool"} tab too) \u2014 tool_run action=apply run_id=${w.run_id} [keep | drop]`:w.state==="ready"?`ready to run: next is ${w.label}, which changes things`:w.text,v={...w,...b?{run:{id:b.id,tool:b.tool,status:b.status}}:{}};return w.state==="done"&&!w.ok?J(new L("engine",_)):X(_,v)}catch(g){return J(g)}}},{name:"app",title:"The app window: open a tool for the artist (settings filled in), its timeline, Home",description:"Drive the conform.tools app the artist has open, the way they would by hand. Everything here is saved with the job (its workspace), so it holds when the window opens later; a window that is open follows at once. action=state (project_id?: the job's open tabs, its timeline, each tool's settings, runs waiting for an OK) \xB7 open (tool, settings?, source?: open that tool's tab with these settings filled in \u2014 what the artist asked for, ready to Run; the rest stay at their defaults; source = its timeline) \xB7 close (tool) \xB7 timeline (source: {host: resolve|premiere|avid|flame|nuke|fcp} live | {session_id, name?} a timeline in the job | {path} a file; with tool: that tool's own timeline (each tab picks its own), without: the job's, which a tool takes until it has its own and when it works in that app) \xB7 home (back to Home). Every tool is listed in the window's sidebar. To run a tool, review and apply: tool_run (its runs show in the tool's tab).",inputSchema:{action:f.enum(["state","open","close","timeline","home"]).default("state"),project_id:f.string().optional().describe("the job (default: local, the one the window works in)"),tool:f.string().optional().describe("open / close: the tool id (tool action=list)"),settings:f.record(f.unknown()).optional().describe("open: the tool's inputs to fill in, by input id"),source:f.record(f.unknown()).optional().describe("timeline / open: {host} | {session_id, name?} | {path}")},run:async({action:e,project_id:t,tool:n,settings:r,source:o})=>{try{let s=t||"local",i=async()=>await Ia(s)??Aa.parse({}),a=c=>{if(!n)throw new L("invalid_args",`${c} needs tool`);return n},l=()=>ri()?"":" (the app window is not open: it shows when it opens)";if(e==="state"){let c=await i(),u=Fo(s).filter(h=>h.status==="review"),p=c.source?"host"in c.source?`${c.source.host} (live)`:"session_id"in c.source?`timeline ${c.source.name??c.source.session_id}`:c.source.path:"none chosen",d=ri()?ab():null,m=d?` \xB7 the artist is looking at ${d.project!==s?`job ${d.project}, `:""}${d.view==="tool"&&d.tool?`the ${d.tool} tab`:"Home"}`:"";return X([`job ${s} \xB7 tabs: ${c.open.join(", ")||"none"} \xB7 timeline: ${p}${ri()?m:" \xB7 the window is not open"}`,...Object.entries(c.sources).map(([h,g])=>`${h} timeline: ${JSON.stringify(g)}`),...Object.entries(c.settings).filter(([h])=>c.open.includes(h)).map(([h,g])=>`${h} settings: ${JSON.stringify(g).slice(0,400)}`),...u.map(h=>Jp(h,10))].join(`
|
|
491
|
-
`),{workspace:c,waiting:u,window_open:ri()>0,front:d})}if(e==="open"){let c=await Br(a("open")),u=await i();if(r){let p=new Set(c.inputs.map(m=>m.id)),d=Object.keys(r).filter(m=>!p.has(m));if(d.length)throw new L("invalid_args",`${c.name} has no setting ${d.join(", ")} (it has ${[...p].join(", ")})`)}return await os(s,{...u,open:u.open.includes(c.id)?u.open:[...u.open,c.id],settings:r?{...u.settings,[c.id]:{...ub(c),...r}}:u.settings,sources:o?{...u.sources,[c.id]:o}:u.sources}),xo({type:"open",project:s,tool:c.id}),X(`opened ${c.name}${r?` with ${Object.entries(r).map(([p,d])=>`${p}=${JSON.stringify(d)}`).join(", ")}`:""}${l()}`,{tool:c.id})}if(e==="close"){let c=await i();return await os(s,{...c,open:c.open.filter(u=>u!==a("close"))}),X(`closed ${n}`)}if(e==="timeline"){if(!o)throw new L("invalid_args","timeline needs source");let c=await i();if(n){let p=await Br(n),d=await os(s,{...c,sources:{...c.sources,[p.id]:o}});return X(`${p.name}'s timeline is ${JSON.stringify(d.sources[p.id])}${l()}`,{tool:p.id,source:d.sources[p.id]})}let u=await os(s,{...c,source:o});return X(`the job's timeline is ${JSON.stringify(u.source)}${l()}`,{source:u.source})}return e==="home"?(xo({type:"home",project:s}),X(`Home${l()}`)):J(new L("invalid_args",`unknown action ${e}`))}catch(s){return J(s)}}},{name:"job_status",hidden:!0,title:"Status of a background job",description:"Status, phase and progress of a job started with background=true (auto conform, deliver, consolidate), and its result once finished.",inputSchema:{job_id:f.string()},run:async({job_id:e})=>{let t=await nb(e);if(!t)return J(new L("not_found",`no job ${e}`));let n=uu(t);return t.status==="done"&&t.result?X(`${n}
|
|
492
|
-
|
|
493
|
-
${t.result.content.map(r=>r.text).join(`
|
|
494
|
-
`)}`,{job:t,result:t.result.structuredContent??null}):X(n,{job:t})}},{name:"job_cancel",hidden:!0,title:"Cancel a background job",description:"Cancel a running background job. Partial outputs already written stay on disk and are named in the job's result.",inputSchema:{job_id:f.string()},run:async({job_id:e})=>cu(e)?X(`cancelling ${e}`,{job_id:e}):J(new L("not_found",`no running job ${e}`))},{name:"job_list",hidden:!0,title:"List jobs",description:"Recent background jobs (running and finished) with status and progress.",inputSchema:{},run:async()=>{let e=await rb();return X(e.length?e.map(uu).join(`
|
|
495
|
-
`):"(no jobs)",{jobs:e})}},{name:"job",title:"Background jobs: status, cancel, list",description:"Jobs started with background=true (auto conform, deliver, consolidate, peer-to-peer serving). action=status (job_id): status, phase, progress and, once finished, its result \xB7 cancel (job_id): stop it; partial outputs already written stay on disk and are named in its result \xB7 list: recent jobs, running and finished.",inputSchema:{action:f.enum(["status","cancel","list"]).default("status"),job_id:f.string().optional()},run:async({action:e,job_id:t})=>e==="list"?wn("job_list").run({}):t?wn(e==="cancel"?"job_cancel":"job_status").run({job_id:t}):J(new L("invalid_args",`action=${e} needs job_id`))}],fN=new Set(["account_login","account_status","account_logout","account_telemetry","timeline_routes","report","report_note","find_verb"]),hN=/^(account_|report|job|conform_learn$|find_verb$|script_(run|read)$)/;function Yx(e){let t=e==="script_read",n=r=>!!wn(r)&&!Zx.test(r)&&(!t||li.has(r));return{name:e,title:t?"Run a script of conformtools calls that only read":"Run a script of conformtools calls",description:(t?"script_run for jobs that only read (probe every clip, inspect a cut, QC each file): its scripts can call only tools that change nothing, so clients run it without asking first. Same arguments and answer as script_run. ":"For a job of many calls (read a cut, probe or relink every clip, QC each one, report only the failures): write it as one TypeScript script instead of a call per step; only what the script returns comes back. Only reading? script_read is the same and runs without asking in more clients. ")+"Every conformtools tool is `await ct.<tool>(args)` with the tool's own arguments; it resolves to the tool's answer ({ok, text, ...its fields}) and throws an Error (e.code, e.verb) when the tool fails. The code is the body of an async function: await, loops, Promise.all, try/catch; `return` the answer, console.log lines come back too. Return only what the user needs: a few fields, or `r.text` (the tool's own short summary) when you do not know its fields; never whole answers. Sandboxed: no files, network or processes except through ct.*. types = tool names answers with their TypeScript declarations (arguments, and the answer's fields once a script here has seen them) and runs nothing: ask it first when unsure of a tool's fields.",inputSchema:{code:f.string().max(1e5).optional().describe('The script: the body of an async function, e.g. `const r = await ct.timeline_read({ path: "~/cut.aaf" }); return r.summary;`'),path:f.string().optional().describe("A saved script (.ts) to run instead of code"),save_as:f.string().regex(/^[\w.-]{1,64}$/).optional().describe("Also keep the script in the current project's scripts/ folder under this name; run it again later with path"),types:f.array(f.string()).max(20).optional().describe("Tool names whose ct.* TypeScript declarations to answer with; nothing runs")},long:!0,run:async({code:r,path:o,save_as:s,types:i,__signal:a,__progress:l})=>{if(i?.length){let b=i.filter(_=>!n(_));if(b.length)return J(new L("not_found",`no tool ${b.join(", ")} for scripts`));let w=await eS();return X(fk(i.map(_=>wn(_)),Object.fromEntries(Object.entries(w).map(([_,v])=>[_,Oi(v)]))))}if(!r==!o)return J(new L("invalid_args","give code (the script) or path (a saved .ts script), not both"));let c=r??await et(o);if(s){let b=B(Xe(),"projects",(await ho())?.id??"local","scripts");await Ke(b),await Ve(B(b,s.endsWith(".ts")?s:`${s}.ts`),c)}let u=await eS(),p=[],d=async(b,w)=>{if(!n(b))throw new L("not_found",t&&wn(b)&&!Zx.test(b)?`${b} changes things: script_read calls only tools that read; use script_run`:`no tool ${b} for scripts`);let _=xN(b,w),v=_.ok?await $o(b,_.data,{signal:a}):_.result,R=v.structuredContent??{},S=v.content.map(U=>U.text).join(`
|
|
496
|
-
`);if(v.isError)throw new L(R.code??"engine",String(R.message??S));let T={ok:!0,...R,text:S},x=u[b],$=Fi(x??"null",Pl(T));return JSON.stringify($)!==JSON.stringify(x)&&(u[b]=$,p.includes(b)||p.push(b)),T},m;try{m=await ck(c,d,{signal:a,onCall:(b,w)=>l?.(b,0,`ct.${w}`)})}catch(b){return J(b)}let h=m.value===void 0?"":typeof m.value=="string"?m.value:JSON.stringify(m.value,null,1),g=new Map;for(let b of m.calls)g.set(b,(g.get(b)??0)+1);let y=[...g].map(([b,w])=>`${b}${w>1?` \xD7${w}`:""}`).join(", "),k=[h.length>vf?`${h.slice(0,vf)}
|
|
497
|
-
\u2026 (${h.length-vf} more characters cut: return less, or a summary)`:h||"(the script returned nothing)",...m.logs.length?["console:",...m.logs]:[],`${m.calls.length} call${m.calls.length===1?"":"s"}${y?`: ${y}`:""}${s?` \xB7 saved as scripts/${s}`:""}`,...p.length?["answer fields (beside ok and text), for the next script:",...p.map(b=>`ct.${b} \u2192 ${Oi(u[b])}`)]:[]];return p.length&&await Ve(nS(),JSON.stringify(u)).catch(()=>{}),X(k.join(`
|
|
498
|
-
`),{calls:m.calls.length})}}}var Zx=/^(account_(login|logout|telemetry)|script_(run|read))$/,nS=()=>B(Xe(),"script-shapes.json"),eS=async()=>{try{return JSON.parse(await et(nS()))}catch{return{}}},vf=2e4,li=new Set(["account_status","conform_learn","find_verb","timeline_read","host_project","timeline_inspect","timeline_routes","timeline_sessions","host_items","media_probe","media_find","media_coverage","timeline_judge","timeline_autoconform","job_status","job_list","patch_plan","patch_verify","media_align","media_cuts","qc_media","media_sync","qc_blanking","gfx_fonts","script_read"]),gN=new Set(["account_login","account_logout","account_telemetry","report","job","timeline_query","host_current","report_note","host_open","host_setup","timeline_edit","timeline_autoconform_review","timeline_author","timeline_generate","timeline_relink","project","project_link","color_match","color_prep","job_cancel","naming","artist_profile","media_frame","timeline_frame","timeline_align","tool","app"]);function RW(e){return{readOnlyHint:li.has(e),destructiveHint:!li.has(e)&&!gN.has(e)}}var bN={asked:f.string().max(Vc+40).optional().describe("First call of each user request only: the request in one line, every name/path as a {placeholder}; start with [solved], [partly] or [failed: why] for the request before (solved = the user got what they asked for; blocked, refused or a workaround is partly or failed)")},rS=e=>({...bN,...e.inputSchema}),tS=new Set(["timeline_id","path","media_reference_id","media_reference","source_start","source_duration","at_frame","track_id","fit","without_audio"]);async function yN(e,t){let n=Object.keys(t).filter(u=>!tS.has(u));if(n.length)throw new L("refused",`add_clip does not take ${n.join(", ")}; it takes ${[...tS].filter(u=>u!=="media_reference").join(", ")} (path = a file to probe; media_reference_id = a reference already in the session, from timeline_query table=media)`);if(typeof t.path!="string"||!t.path){if(t.media_reference_id)return t;throw new L("refused","add_clip needs path (the media file to cut in)")}let{path:r,...o}=t,s=await mt(Nt(r)),i=e.media_references??[],a=i.find(u=>u.target_url===s.target_url);if(a)return{...o,media_reference_id:a.id};let l=s.id,c=2;for(;i.some(u=>u.id===l);)l=`${s.id} (${c++})`;return{...o,media_reference_id:l,media_reference:{...s,id:l}}}async function $o(e,t,n={}){let r=wn(e);if(!r)return J(new L("not_found",`unknown verb '${e}'`));let o=mg(t.asked);if(!("asked"in r.inputSchema)){let{asked:c,...u}=t;t=u}if(!fN.has(e))try{await Nf()}catch(c){let u=J(c);return ka(e,u,0,Object.keys(t),{request:o,client:n.client}),u}let s=kN(t),i=t.engine==="local"||t.engine==="hosted"?t.engine:void 0,a=()=>G1.run({verb:e,declared:r.protectedStages??[]},()=>TN(r,e,s,n,o)),l=i?await V1.run(i,a):await a();return r.long&&s.background||du(e,s,l),vN(e,l)}var wN=new Set(["path","paths","out_path","out_dir","media_root","reference","pool","source_path","output_path","plate","render","target_dir","media_dirs","a","b","edl_path","csv_path","patch","master","credits_path","images_dir","look_path","fonts","destination_root","export_dir","grades_dir"]);function kN(e){let t={...e};for(let n of wN){let r=t[n];n==="reference"&&r==="ai"||(typeof r=="string"&&r?t[n]=Nt(r):Array.isArray(r)&&(t[n]=r.map(o=>typeof o=="string"&&o?Nt(o):o)))}return t}var _N={timeline_read:"conform",host_current:"conform",timeline_relink:"conform",timeline_write:"conform",timeline_autoconform:"autoconform",media_consolidate:"deliver",media_deliver:"deliver"};function vN(e,t){let n=_N[e];return!n||t.isError||lg()?t:{...t,content:[...t.content,{type:"text",text:`Next: call conform_learn task=${n} (with the hosts involved) before going further, and follow the playbook it returns.`}]}}async function TN(e,t,n,r,o){let s=performance.now(),i=async(l,c)=>{let u=Math.round(performance.now()-s),p=l.content.map(m=>m.text).join(`
|
|
499
|
-
`),d=typeof n.session_id=="string"?n.session_id:p.match(/session_id: (\w+)/)?.[1];return await Y1({ts:new Date().toISOString(),verb:t,ms:u,ok:!l.isError,code:l.isError?String(l.structuredContent?.code??"engine"):void 0,msg:l.isError?p.slice(0,500):void 0,...c.withArgs?{args:Q1(n)}:{},job:c.job,session:d,note:c.note}),u},a=async(l,c)=>{let u=await i(l,{job:c,withArgs:!0}),p=t==="find_verb"&&Array.isArray(l.structuredContent?.hits)?l.structuredContent.hits:void 0;return e.long&&n.background||ka(t,l,u,Object.keys(n),{request:o,hits:p,client:r.client}),l};if(e.long){let{background:l,...c}=n,u=ti(t,async(p,d)=>await e.run({...c,__signal:d,__progress:l||!r.progress?p:(m,h,g)=>{p(m,h,g),r.progress(m,h,g)}}));return l||r.signal?.addEventListener("abort",()=>cu(u.id),{once:!0}),l?(lu(u.id)?.then(async p=>{du(t,c,p),ka(t,p,await i(p,{job:u.id,note:"job finished"}),Object.keys(c),{request:o,client:r.client})}),a(X(`started ${u.id} (${t}) \u2014 poll job action=status`,{job_id:u.id}),u.id)):a(await lu(u.id),u.id)}try{return await a(await e.run(n))}catch(l){return a(J(l))}}function xN(e,t){let n=wn(e);if(!n)return{ok:!1,result:J(new L("not_found",`unknown verb '${e}'`))};let r=f.object(rS(n)).safeParse(t??{});if(r.success)return{ok:!0,data:r.data};nu(e,_a(r.error.issues));let o=r.error.issues.map(s=>`${s.path.join(".")||"(args)"}: ${s.message}`).join("; ");return{ok:!1,result:J(new L("invalid_args",o,{fields:_a(r.error.issues)}))}}function CW(e,t){let n=wn(e);if(!n)return;let r=f.object(rS(n)).safeParse(t??{});r.success||nu(e,_a(r.error.issues))}var oS=mN.filter(e=>!e.repoOnly||K1),ss=oS.filter(e=>!e.hidden);function wn(e){return ss.find(t=>t.name===e)??oS.find(t=>t.name===e)}export{EN as a,IN as b,MN as c,nb as d,cu as e,rb as f,RW as g,rS as h,$o as i,xN as j,CW as k,ss as l,wn as m};
|