conformtools 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/browser/timeline_core_bg.wasm +0 -0
  2. package/dist/{chunk-R7P7WVNI.js → chunk-42QQI3WX.js} +1 -1
  3. package/dist/{chunk-WE4S4PEA.js → chunk-BW2NQ54J.js} +1 -1
  4. package/dist/{chunk-JBSH4AK3.js → chunk-CL26XMDO.js} +1 -1
  5. package/dist/{chunk-FMYTLXWN.js → chunk-EO5NIBOV.js} +1 -1
  6. package/dist/{chunk-5K56Q5EX.js → chunk-EPZ6NWE4.js} +1 -1
  7. package/dist/{chunk-D2RXAX5C.js → chunk-HKP4P6JN.js} +1 -1
  8. package/dist/{chunk-LO4K2ZF3.js → chunk-JB7PR2TQ.js} +1 -1
  9. package/dist/chunk-QTKRMXL5.js +363 -0
  10. package/dist/{chunk-BK62N3ID.js → chunk-QTPCU2TF.js} +1 -1
  11. package/dist/chunk-TEZP6VEQ.js +3 -0
  12. package/dist/{chunk-CETBLAWM.js → chunk-WT6NIJCB.js} +1 -1
  13. package/dist/{claude-setup-XSNTKEU7.js → claude-setup-BM3AAUKR.js} +1 -1
  14. package/dist/cli.js +2 -2
  15. package/dist/conformtools-decode +0 -0
  16. package/dist/{cr3-wasm-HTRSUBJK.js → cr3-wasm-WKWMEK3V.js} +1 -1
  17. package/dist/{dng-wasm-2I7S2SN4.js → dng-wasm-Z5OVO4UI.js} +1 -1
  18. package/dist/{dpx-wasm-AHH7D56L.js → dpx-wasm-QNYXAOAJ.js} +1 -1
  19. package/dist/{exr-wasm-3TAN64WQ.js → exr-wasm-BHSBJLQH.js} +1 -1
  20. package/dist/{h264-2LU2X635.js → h264-LIZVHN2W.js} +1 -1
  21. package/dist/{h264-mxf-5HJUSZLL.js → h264-mxf-MWS7DDV7.js} +1 -1
  22. package/dist/http.js +1 -1
  23. package/dist/i2o-transfer +0 -0
  24. package/dist/{inspect-NY36WVMH.js → inspect-DZF537QL.js} +1 -1
  25. package/dist/{isobmff-HSF7B3Y7.js → isobmff-HM3UPWPZ.js} +1 -1
  26. package/dist/mcp.js +8 -8
  27. package/dist/{media_core_bg-MEORQOCQ.js → media_core_bg-FGAR5KA5.js} +1 -1
  28. package/dist/{mxf-IQBPP3JA.js → mxf-K465SWBN.js} +1 -1
  29. package/dist/{ops-PFEKOSET.js → ops-73NR3X6R.js} +1 -1
  30. package/dist/{r3d-QLV4J6YF.js → r3d-RR3FUM6H.js} +1 -1
  31. package/dist/{r3d-YZH6X2D7.js → r3d-VUOYU2KQ.js} +1 -1
  32. package/dist/resolve-bridge.py +66 -8
  33. package/dist/{still-LORP3E5C.js → still-4G25EYN5.js} +1 -1
  34. package/dist/{tiff-wasm-6XFTTCL4.js → tiff-wasm-QJPCR7JT.js} +1 -1
  35. package/dist/{wav-PMVKVYNP.js → wav-63QF6SCT.js} +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-D5DEQ467.js +0 -3
  38. package/dist/chunk-EV52G33S.js +0 -354
  39. /package/dist/{arriraw-GUQEZ7CH.js → arriraw-3GKCR6K2.js} +0 -0
  40. /package/dist/{chunk-GIZIR52D.js → chunk-WHY3DVXS.js} +0 -0
  41. /package/dist/{media_core_bg-5QHIWEZB.js → media_core_bg-YK63OUDM.js} +0 -0
  42. /package/dist/{prores-BR2YURFP.js → prores-L4JZZWGH.js} +0 -0
  43. /package/dist/{timeline_core_bg-DFKQ7XOU.js → timeline_core_bg-2TYWZ35G.js} +0 -0
  44. /package/dist/{udf_bg-ZIB3GK52.js → udf_bg-A4WEMSAX.js} +0 -0
@@ -1,354 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{A as Sr,B as xp,C as Pp,D as Mr,E as dn,F as Za,G as kp,H as Mn,I as vf,J as DT,K as qT,L as UT,M as yf,N as Sp,O as te,P as Ln,Q as ar,R as Q,S as CT,T as JT,b as Rt,c as Ro,d as No,g as or,h as hf,i as ZT,j as vt,k as bf,l as gf,m as Pr,n as un,o as jn,p as Er,q as gi,r as er,s as yn,t as fr,u as rn,v as bt,w as Vr,x as Xo,y as oy,z as Br}from"./chunk-D5DEQ467.js";import{a as wp,d as HT,e as iy}from"./chunk-GXEVALBL.js";import{a as VT,b as ry,c as WT}from"./chunk-Y2BEEOPB.js";import{a as ai,b as Lo,c as ET,d as zp,g as KT,h as GT,i as AT,j as BT}from"./chunk-LO4K2ZF3.js";import{S as Tp}from"./chunk-C2ESM27Z.js";import{b as MT}from"./chunk-D2RXAX5C.js";import{b as LT}from"./chunk-5K56Q5EX.js";import{b as RT}from"./chunk-R7P7WVNI.js";import{b as pf,c as bp,d as ST,f as TT}from"./chunk-6FVGUJ6L.js";import{a as NT}from"./chunk-QDWB7QU7.js";import{b as yp,c as FT,e as IT,f as $c}from"./chunk-P7OVDUA5.js";import{b as PT,c as kT}from"./chunk-UCMNH6Q6.js";import{b as zT}from"./chunk-WE4S4PEA.js";import{a as OT,b as vp}from"./chunk-CETBLAWM.js";import{a as gp}from"./chunk-DKGGJM6Z.js";import{a as gT}from"./chunk-GIZIR52D.js";import{a as js,b as vT,d as yT,e as hp}from"./chunk-BUEIRRNY.js";import{a as wT}from"./chunk-TK55FA56.js";import{a as xT}from"./chunk-FMYTLXWN.js";import{d as XT,e as jT,f as Fs,i as lo}from"./chunk-BK62N3ID.js";import{$ as aT,A as B8,B as Y8,Ba as _c,C as Q8,Ca as oi,D as _8,I as $8,K as eT,M as tT,N as nT,P as rT,Q as iT,R as oT,aa as sT,b as Wa,d as D8,ea as cT,f as q8,g as Ha,i as U8,ia as lT,j as C8,q as J8,qa as uT,r as K8,ra as fT,s as pp,ua as dT,va as mT,w as G8,x as A8,xa as pT,ya as hT,za as bT}from"./chunk-JBSH4AK3.js";import{a as na,c as ot,d as ra,f as Z8}from"./chunk-PSANHDZM.js";var _d=ot((wve,mS)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?mS.exports={nextTick:a_}:mS.exports=process;function a_(e,t,n,i){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var r=arguments.length,o,a;switch(r){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,n)});case 4:return process.nextTick(function(){e.call(null,t,n,i)});default:for(o=new Array(r-1),a=0;a<o.length;)o[a++]=arguments[a];return process.nextTick(function(){e.apply(null,o)})}}});var LN=ot((xve,MN)=>{var s_={}.toString;MN.exports=Array.isArray||function(e){return s_.call(e)=="[object Array]"}});var pS=ot((Pve,RN)=>{RN.exports=na("stream")});var $d=ot((hS,XN)=>{var q0=na("buffer"),wa=q0.Buffer;function NN(e,t){for(var n in e)t[n]=e[n]}wa.from&&wa.alloc&&wa.allocUnsafe&&wa.allocUnsafeSlow?XN.exports=q0:(NN(q0,hS),hS.Buffer=cu);function cu(e,t,n){return wa(e,t,n)}NN(wa,cu);cu.from=function(e,t,n){if(typeof e=="number")throw new TypeError("Argument must not be a number");return wa(e,t,n)};cu.alloc=function(e,t,n){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=wa(e);return t!==void 0?typeof n=="string"?i.fill(t,n):i.fill(t):i.fill(0),i};cu.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return wa(e)};cu.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return q0.SlowBuffer(e)}});var lu=ot(fi=>{function c_(e){return Array.isArray?Array.isArray(e):U0(e)==="[object Array]"}fi.isArray=c_;function l_(e){return typeof e=="boolean"}fi.isBoolean=l_;function u_(e){return e===null}fi.isNull=u_;function f_(e){return e==null}fi.isNullOrUndefined=f_;function d_(e){return typeof e=="number"}fi.isNumber=d_;function m_(e){return typeof e=="string"}fi.isString=m_;function p_(e){return typeof e=="symbol"}fi.isSymbol=p_;function h_(e){return e===void 0}fi.isUndefined=h_;function b_(e){return U0(e)==="[object RegExp]"}fi.isRegExp=b_;function g_(e){return typeof e=="object"&&e!==null}fi.isObject=g_;function v_(e){return U0(e)==="[object Date]"}fi.isDate=v_;function y_(e){return U0(e)==="[object Error]"||e instanceof Error}fi.isError=y_;function w_(e){return typeof e=="function"}fi.isFunction=w_;function x_(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}fi.isPrimitive=x_;fi.isBuffer=na("buffer").Buffer.isBuffer;function U0(e){return Object.prototype.toString.call(e)}});var jN=ot((Sve,bS)=>{typeof Object.create=="function"?bS.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:bS.exports=function(t,n){if(n){t.super_=n;var i=function(){};i.prototype=n.prototype,t.prototype=new i,t.prototype.constructor=t}}});var uu=ot((Tve,vS)=>{try{if(gS=na("util"),typeof gS.inherits!="function")throw"";vS.exports=gS.inherits}catch{vS.exports=jN()}var gS});var IN=ot((zve,yS)=>{"use strict";function P_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var FN=$d().Buffer,em=na("util");function k_(e,t,n){e.copy(t,n)}yS.exports=(function(){function e(){P_(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(n){var i={data:n,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length},e.prototype.unshift=function(n){var i={data:n,next:this.head};this.length===0&&(this.tail=i),this.head=i,++this.length},e.prototype.shift=function(){if(this.length!==0){var n=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,n}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(n){if(this.length===0)return"";for(var i=this.head,r=""+i.data;i=i.next;)r+=n+i.data;return r},e.prototype.concat=function(n){if(this.length===0)return FN.alloc(0);for(var i=FN.allocUnsafe(n>>>0),r=this.head,o=0;r;)k_(r.data,i,o),o+=r.data.length,r=r.next;return i},e})();em&&em.inspect&&em.inspect.custom&&(yS.exports.prototype[em.inspect.custom]=function(){var e=em.inspect({length:this.length});return this.constructor.name+" "+e})});var wS=ot((Ove,EN)=>{"use strict";var C0=_d();function S_(e,t){var n=this,i=this._readableState&&this._readableState.destroyed,r=this._writableState&&this._writableState.destroyed;return i||r?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,C0.nextTick(J0,this,e)):C0.nextTick(J0,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,C0.nextTick(J0,n,o)):C0.nextTick(J0,n,o):t&&t(o)}),this)}function T_(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function J0(e,t){e.emit("error",t)}EN.exports={destroy:S_,undestroy:T_}});var WN=ot((Mve,VN)=>{VN.exports=na("util").deprecate});var PS=ot((Lve,KN)=>{"use strict";var vc=_d();KN.exports=Rr;function ZN(e){var t=this;this.next=null,this.entry=null,this.finish=function(){U_(t,e)}}var z_=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:vc.nextTick,fu;Rr.WritableState=nm;var DN=Object.create(lu());DN.inherits=uu();var O_={deprecate:WN()},qN=pS(),G0=$d().Buffer,M_=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function L_(e){return G0.from(e)}function R_(e){return G0.isBuffer(e)||e instanceof M_}var UN=wS();DN.inherits(Rr,qN);function N_(){}function nm(e,t){fu=fu||yc(),e=e||{};var n=t instanceof fu;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,r=e.writableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:n&&(r||r===0)?this.highWaterMark=r:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(s){W_(t,s)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new ZN(this)}nm.prototype.getBuffer=function(){for(var t=this.bufferedRequest,n=[];t;)n.push(t),t=t.next;return n};(function(){try{Object.defineProperty(nm.prototype,"buffer",{get:O_.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var K0;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(K0=Function.prototype[Symbol.hasInstance],Object.defineProperty(Rr,Symbol.hasInstance,{value:function(e){return K0.call(this,e)?!0:this!==Rr?!1:e&&e._writableState instanceof nm}})):K0=function(e){return e instanceof this};function Rr(e){if(fu=fu||yc(),!K0.call(Rr,this)&&!(this instanceof fu))return new Rr(e);this._writableState=new nm(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),qN.call(this)}Rr.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function X_(e,t){var n=new Error("write after end");e.emit("error",n),vc.nextTick(t,n)}function j_(e,t,n,i){var r=!0,o=!1;return n===null?o=new TypeError("May not write null values to stream"):typeof n!="string"&&n!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),vc.nextTick(i,o),r=!1),r}Rr.prototype.write=function(e,t,n){var i=this._writableState,r=!1,o=!i.objectMode&&R_(e);return o&&!G0.isBuffer(e)&&(e=L_(e)),typeof t=="function"&&(n=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),typeof n!="function"&&(n=N_),i.ended?X_(this,n):(o||j_(this,i,e,n))&&(i.pendingcb++,r=I_(this,i,o,e,t,n)),r};Rr.prototype.cork=function(){var e=this._writableState;e.corked++};Rr.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&CN(this,e))};Rr.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function F_(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=G0.from(t,n)),t}Object.defineProperty(Rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function I_(e,t,n,i,r,o){if(!n){var a=F_(t,i,r);i!==a&&(n=!0,r="buffer",i=a)}var s=t.objectMode?1:i.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:r,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else xS(e,t,!1,s,i,r,o);return c}function xS(e,t,n,i,r,o,a){t.writelen=i,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(r,t.onwrite):e._write(r,o,t.onwrite),t.sync=!1}function E_(e,t,n,i,r){--t.pendingcb,n?(vc.nextTick(r,i),vc.nextTick(tm,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(r(i),e._writableState.errorEmitted=!0,e.emit("error",i),tm(e,t))}function V_(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function W_(e,t){var n=e._writableState,i=n.sync,r=n.writecb;if(V_(n),t)E_(e,n,i,t,r);else{var o=JN(n);!o&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&CN(e,n),i?z_(HN,e,n,o,r):HN(e,n,o,r)}}function HN(e,t,n,i){n||H_(e,t),t.pendingcb--,i(),tm(e,t)}function H_(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function CN(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,r=new Array(i),o=t.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)r[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;r.allBuffers=s,xS(e,t,!0,t.length,r,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new ZN(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback,f=t.objectMode?1:c.length;if(xS(e,t,!1,f,c,l,u),n=n.next,t.bufferedRequestCount--,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}Rr.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))};Rr.prototype._writev=null;Rr.prototype.end=function(e,t,n){var i=this._writableState;typeof e=="function"?(n=e,e=null,t=null):typeof t=="function"&&(n=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||q_(this,i,n)};function JN(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Z_(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),tm(e,t)})}function D_(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,vc.nextTick(Z_,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function tm(e,t){var n=JN(t);return n&&(D_(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),n}function q_(e,t,n){t.ending=!0,tm(e,t),n&&(t.finished?vc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function U_(e,t,n){var i=e.entry;for(e.entry=null;i;){var r=i.callback;t.pendingcb--,r(n),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(Rr.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Rr.prototype.destroy=UN.destroy;Rr.prototype._undestroy=UN.undestroy;Rr.prototype._destroy=function(e,t){this.end(),t(e)}});var yc=ot((Rve,YN)=>{"use strict";var GN=_d(),C_=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};YN.exports=xa;var AN=Object.create(lu());AN.inherits=uu();var BN=TS(),SS=PS();AN.inherits(xa,BN);for(kS=C_(SS.prototype),A0=0;A0<kS.length;A0++)B0=kS[A0],xa.prototype[B0]||(xa.prototype[B0]=SS.prototype[B0]);var kS,B0,A0;function xa(e){if(!(this instanceof xa))return new xa(e);BN.call(this,e),SS.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",J_)}Object.defineProperty(xa.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function J_(){this.allowHalfOpen||this._writableState.ended||GN.nextTick(K_,this)}function K_(e){e.end()}Object.defineProperty(xa.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});xa.prototype._destroy=function(e,t){this.push(null),this.end(),GN.nextTick(t,e)}});var MS=ot(_N=>{"use strict";var OS=$d().Buffer,QN=OS.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function G_(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function A_(e){var t=G_(e);if(typeof t!="string"&&(OS.isEncoding===QN||!QN(e)))throw new Error("Unknown encoding: "+e);return t||e}_N.StringDecoder=rm;function rm(e){this.encoding=A_(e);var t;switch(this.encoding){case"utf16le":this.text=e$,this.end=t$,t=4;break;case"utf8":this.fillLast=Q_,t=4;break;case"base64":this.text=n$,this.end=r$,t=3;break;default:this.write=i$,this.end=o$;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=OS.allocUnsafe(t)}rm.prototype.write=function(e){if(e.length===0)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""};rm.prototype.end=$_;rm.prototype.text=__;rm.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function zS(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function B_(e,t,n){var i=t.length-1;if(i<n)return 0;var r=zS(t[i]);return r>=0?(r>0&&(e.lastNeed=r-1),r):--i<n||r===-2?0:(r=zS(t[i]),r>=0?(r>0&&(e.lastNeed=r-2),r):--i<n||r===-2?0:(r=zS(t[i]),r>=0?(r>0&&(r===2?r=0:e.lastNeed=r-3),r):0))}function Y_(e,t,n){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function Q_(e){var t=this.lastTotal-this.lastNeed,n=Y_(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function __(e,t){var n=B_(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function $_(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function e$(e,t){if((e.length-t)%2===0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function t$(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function n$(e,t){var n=(e.length-t)%3;return n===0?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function r$(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function i$(e){return e.toString(this.encoding)}function o$(e){return e&&e.length?this.write(e):""}});var TS=ot((jve,uX)=>{"use strict";var mu=_d();uX.exports=dr;var a$=LN(),im;dr.ReadableState=oX;var Xve=na("events").EventEmitter,nX=function(e,t){return e.listeners(t).length},jS=pS(),om=$d().Buffer,s$=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c$(e){return om.from(e)}function l$(e){return om.isBuffer(e)||e instanceof s$}var rX=Object.create(lu());rX.inherits=uu();var LS=na("util"),In=void 0;LS&&LS.debuglog?In=LS.debuglog("stream"):In=function(){};var u$=IN(),iX=wS(),du;rX.inherits(dr,jS);var RS=["error","close","destroy","pause","resume"];function f$(e,t,n){if(typeof e.prependListener=="function")return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):a$(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function oX(e,t){im=im||yc(),e=e||{};var n=t instanceof im;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,r=e.readableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:n&&(r||r===0)?this.highWaterMark=r:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new u$,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(du||(du=MS().StringDecoder),this.decoder=new du(e.encoding),this.encoding=e.encoding)}function dr(e){if(im=im||yc(),!(this instanceof dr))return new dr(e);this._readableState=new oX(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),jS.call(this)}Object.defineProperty(dr.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});dr.prototype.destroy=iX.destroy;dr.prototype._undestroy=iX.undestroy;dr.prototype._destroy=function(e,t){this.push(null),t(e)};dr.prototype.push=function(e,t){var n=this._readableState,i;return n.objectMode?i=!0:typeof e=="string"&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=om.from(e,t),t=""),i=!0),aX(this,e,t,!1,i)};dr.prototype.unshift=function(e){return aX(this,e,null,!0,!1)};function aX(e,t,n,i,r){var o=e._readableState;if(t===null)o.reading=!1,h$(e,o);else{var a;r||(a=d$(o,t)),a?e.emit("error",a):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==om.prototype&&(t=c$(t)),i?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):NS(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||t.length!==0?NS(e,o,t,!1):sX(e,o)):NS(e,o,t,!1))):i||(o.reading=!1)}return m$(o)}function NS(e,t,n,i){t.flowing&&t.length===0&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&Y0(e)),sX(e,t)}function d$(e,t){var n;return!l$(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(n=new TypeError("Invalid non-string/buffer chunk")),n}function m$(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}dr.prototype.isPaused=function(){return this._readableState.flowing===!1};dr.prototype.setEncoding=function(e){return du||(du=MS().StringDecoder),this._readableState.decoder=new du(e),this._readableState.encoding=e,this};var $N=8388608;function p$(e){return e>=$N?e=$N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function eX(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=p$(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}dr.prototype.read=function(e){In("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return In("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?XS(this):Y0(this),null;if(e=eX(e,t),e===0&&t.ended)return t.length===0&&XS(this),null;var i=t.needReadable;In("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,In("length less than watermark",i)),t.ended||t.reading?(i=!1,In("reading or ended",i)):i&&(In("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=eX(n,t)));var r;return e>0?r=cX(e,t):r=null,r===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&XS(this)),r!==null&&this.emit("data",r),r};function h$(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,Y0(e)}}function Y0(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(In("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?mu.nextTick(tX,e):tX(e))}function tX(e){In("emit readable"),e.emit("readable"),FS(e)}function sX(e,t){t.readingMore||(t.readingMore=!0,mu.nextTick(b$,e,t))}function b$(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(In("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}dr.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};dr.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,In("pipe count=%d opts=%j",i.pipesCount,t);var r=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,o=r?s:b;i.endEmitted?mu.nextTick(o):n.once("end",o),e.on("unpipe",a);function a(v,g){In("onunpipe"),v===n&&g&&g.hasUnpiped===!1&&(g.hasUnpiped=!0,u())}function s(){In("onend"),e.end()}var c=g$(n);e.on("drain",c);var l=!1;function u(){In("cleanup"),e.removeListener("close",p),e.removeListener("finish",h),e.removeListener("drain",c),e.removeListener("error",m),e.removeListener("unpipe",a),n.removeListener("end",s),n.removeListener("end",b),n.removeListener("data",d),l=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var f=!1;n.on("data",d);function d(v){In("ondata"),f=!1;var g=e.write(v);g===!1&&!f&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&lX(i.pipes,e)!==-1)&&!l&&(In("false write response, pause",i.awaitDrain),i.awaitDrain++,f=!0),n.pause())}function m(v){In("onerror",v),b(),e.removeListener("error",m),nX(e,"error")===0&&e.emit("error",v)}f$(e,"error",m);function p(){e.removeListener("finish",h),b()}e.once("close",p);function h(){In("onfinish"),e.removeListener("close",p),b()}e.once("finish",h);function b(){In("unpipe"),n.unpipe(e)}return e.emit("pipe",n),i.flowing||(In("pipe resume"),n.resume()),e};function g$(e){return function(){var t=e._readableState;In("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&nX(e,"data")&&(t.flowing=!0,FS(e))}}dr.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<r;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=lX(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)};dr.prototype.on=function(e,t){var n=jS.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&Y0(this):mu.nextTick(v$,this))}return n};dr.prototype.addListener=dr.prototype.on;function v$(e){In("readable nexttick read 0"),e.read(0)}dr.prototype.resume=function(){var e=this._readableState;return e.flowing||(In("resume"),e.flowing=!0,y$(this,e)),this};function y$(e,t){t.resumeScheduled||(t.resumeScheduled=!0,mu.nextTick(w$,e,t))}function w$(e,t){t.reading||(In("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),FS(e),t.flowing&&!t.reading&&e.read(0)}dr.prototype.pause=function(){return In("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(In("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function FS(e){var t=e._readableState;for(In("flow",t.flowing);t.flowing&&e.read()!==null;);}dr.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;e.on("end",function(){if(In("wrapped end"),n.decoder&&!n.ended){var a=n.decoder.end();a&&a.length&&t.push(a)}t.push(null)}),e.on("data",function(a){if(In("wrapped data"),n.decoder&&(a=n.decoder.write(a)),!(n.objectMode&&a==null)&&!(!n.objectMode&&(!a||!a.length))){var s=t.push(a);s||(i=!0,e.pause())}});for(var r in e)this[r]===void 0&&typeof e[r]=="function"&&(this[r]=(function(a){return function(){return e[a].apply(e,arguments)}})(r));for(var o=0;o<RS.length;o++)e.on(RS[o],this.emit.bind(this,RS[o]));return this._read=function(a){In("wrapped _read",a),i&&(i=!1,e.resume())},this};Object.defineProperty(dr.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});dr._fromList=cX;function cX(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(t.decoder?n=t.buffer.join(""):t.buffer.length===1?n=t.buffer.head.data:n=t.buffer.concat(t.length),t.buffer.clear()):n=x$(e,t.buffer,t.decoder),n}function x$(e,t,n){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=n?P$(e,t):k$(e,t),i}function P$(e,t){var n=t.head,i=1,r=n.data;for(e-=r.length;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(a===o.length?r+=o:r+=o.slice(0,e),e-=a,e===0){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}function k$(e,t){var n=om.allocUnsafe(e),i=t.head,r=1;for(i.data.copy(n),e-=i.data.length;i=i.next;){var o=i.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),e-=a,e===0){a===o.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(a));break}++r}return t.length-=r,n}function XS(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,mu.nextTick(S$,t,e))}function S$(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function lX(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1}});var IS=ot((Fve,mX)=>{"use strict";mX.exports=Pa;var Q0=yc(),dX=Object.create(lu());dX.inherits=uu();dX.inherits(Pa,Q0);function T$(e,t){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,t!=null&&this.push(t),i(e);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function Pa(e){if(!(this instanceof Pa))return new Pa(e);Q0.call(this,e),this._transformState={afterTransform:T$.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",z$)}function z$(){var e=this;typeof this._flush=="function"?this._flush(function(t,n){fX(e,t,n)}):fX(this,null,null)}Pa.prototype.push=function(e,t){return this._transformState.needTransform=!1,Q0.prototype.push.call(this,e,t)};Pa.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")};Pa.prototype._write=function(e,t,n){var i=this._transformState;if(i.writecb=n,i.writechunk=e,i.writeencoding=t,!i.transforming){var r=this._readableState;(i.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}};Pa.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Pa.prototype._destroy=function(e,t){var n=this;Q0.prototype._destroy.call(this,e,function(i){t(i),n.emit("close")})};function fX(e,t,n){if(t)return e.emit("error",t);if(n!=null&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var gX=ot((Ive,bX)=>{"use strict";bX.exports=am;var pX=IS(),hX=Object.create(lu());hX.inherits=uu();hX.inherits(am,pX);function am(e){if(!(this instanceof am))return new am(e);pX.call(this,e)}am.prototype._transform=function(e,t,n){n(null,e)}});var ES=ot((ei,_0)=>{var Uo=na("stream");process.env.READABLE_STREAM==="disable"&&Uo?(_0.exports=Uo,ei=_0.exports=Uo.Readable,ei.Readable=Uo.Readable,ei.Writable=Uo.Writable,ei.Duplex=Uo.Duplex,ei.Transform=Uo.Transform,ei.PassThrough=Uo.PassThrough,ei.Stream=Uo):(ei=_0.exports=TS(),ei.Stream=Uo||ei,ei.Readable=ei,ei.Writable=PS(),ei.Duplex=yc(),ei.Transform=IS(),ei.PassThrough=gX())});var ka=ot(Ji=>{"use strict";Ji.base64=!0;Ji.array=!0;Ji.string=!0;Ji.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";Ji.nodebuffer=typeof Buffer<"u";Ji.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")Ji.blob=!1;else{VS=new ArrayBuffer(0);try{Ji.blob=new Blob([VS],{type:"application/zip"}).size===0}catch{try{vX=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,WS=new vX,WS.append(VS),Ji.blob=WS.getBlob("application/zip").size===0}catch{Ji.blob=!1}}}var VS,vX,WS;try{Ji.nodestream=!!ES().Readable}catch{Ji.nodestream=!1}});var ZS=ot(HS=>{"use strict";var O$=wr(),M$=ka(),Co="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";HS.encode=function(e){for(var t=[],n,i,r,o,a,s,c,l=0,u=e.length,f=u,d=O$.getTypeOf(e)!=="string";l<e.length;)f=u-l,d?(n=e[l++],i=l<u?e[l++]:0,r=l<u?e[l++]:0):(n=e.charCodeAt(l++),i=l<u?e.charCodeAt(l++):0,r=l<u?e.charCodeAt(l++):0),o=n>>2,a=(n&3)<<4|i>>4,s=f>1?(i&15)<<2|r>>6:64,c=f>2?r&63:64,t.push(Co.charAt(o)+Co.charAt(a)+Co.charAt(s)+Co.charAt(c));return t.join("")};HS.decode=function(e){var t,n,i,r,o,a,s,c=0,l=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");e=e.replace(/[^A-Za-z0-9+/=]/g,"");var f=e.length*3/4;if(e.charAt(e.length-1)===Co.charAt(64)&&f--,e.charAt(e.length-2)===Co.charAt(64)&&f--,f%1!==0)throw new Error("Invalid base64 input, bad content length.");var d;for(M$.uint8array?d=new Uint8Array(f|0):d=new Array(f|0);c<e.length;)r=Co.indexOf(e.charAt(c++)),o=Co.indexOf(e.charAt(c++)),a=Co.indexOf(e.charAt(c++)),s=Co.indexOf(e.charAt(c++)),t=r<<2|o>>4,n=(o&15)<<4|a>>2,i=(a&3)<<6|s,d[l++]=t,a!==64&&(d[l++]=n),s!==64&&(d[l++]=i);return d}});var sm=ot((Wve,yX)=>{"use strict";yX.exports={isNode:typeof Buffer<"u",newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if(typeof e=="number")throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&typeof e.on=="function"&&typeof e.pause=="function"&&typeof e.resume=="function"}}});var kX=ot((Hve,PX)=>{"use strict";var wX=global.MutationObserver||global.WebKitMutationObserver,pu;process.browser?wX?(DS=0,xX=new wX(cm),qS=global.document.createTextNode(""),xX.observe(qS,{characterData:!0}),pu=function(){qS.data=DS=++DS%2}):!global.setImmediate&&typeof global.MessageChannel<"u"?(US=new global.MessageChannel,US.port1.onmessage=cm,pu=function(){US.port2.postMessage(0)}):"document"in global&&"onreadystatechange"in global.document.createElement("script")?pu=function(){var e=global.document.createElement("script");e.onreadystatechange=function(){cm(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},global.document.documentElement.appendChild(e)}:pu=function(){setTimeout(cm,0)}:pu=function(){process.nextTick(cm)};var DS,xX,qS,US,CS,lm=[];function cm(){CS=!0;for(var e,t,n=lm.length;n;){for(t=lm,lm=[],e=-1;++e<n;)t[e]();n=lm.length}CS=!1}PX.exports=L$;function L$(e){lm.push(e)===1&&!CS&&pu()}});var RX=ot((Zve,LX)=>{"use strict";var SX=kX();function hu(){}var di={},TX=["REJECTED"],JS=["FULFILLED"],zX=["PENDING"];process.browser||(um=["UNHANDLED"]);var um;LX.exports=ls;function ls(e){if(typeof e!="function")throw new TypeError("resolver must be a function");this.state=zX,this.queue=[],this.outcome=void 0,process.browser||(this.handled=um),e!==hu&&OX(this,e)}ls.prototype.finally=function(e){if(typeof e!="function")return this;var t=this.constructor;return this.then(n,i);function n(r){function o(){return r}return t.resolve(e()).then(o)}function i(r){function o(){throw r}return t.resolve(e()).then(o)}};ls.prototype.catch=function(e){return this.then(null,e)};ls.prototype.then=function(e,t){if(typeof e!="function"&&this.state===JS||typeof t!="function"&&this.state===TX)return this;var n=new this.constructor(hu);if(process.browser||this.handled===um&&(this.handled=null),this.state!==zX){var i=this.state===JS?e:t;KS(n,i,this.outcome)}else this.queue.push(new fm(n,e,t));return n};function fm(e,t,n){this.promise=e,typeof t=="function"&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),typeof n=="function"&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}fm.prototype.callFulfilled=function(e){di.resolve(this.promise,e)};fm.prototype.otherCallFulfilled=function(e){KS(this.promise,this.onFulfilled,e)};fm.prototype.callRejected=function(e){di.reject(this.promise,e)};fm.prototype.otherCallRejected=function(e){KS(this.promise,this.onRejected,e)};function KS(e,t,n){SX(function(){var i;try{i=t(n)}catch(r){return di.reject(e,r)}i===e?di.reject(e,new TypeError("Cannot resolve promise with itself")):di.resolve(e,i)})}di.resolve=function(e,t){var n=MX(R$,t);if(n.status==="error")return di.reject(e,n.value);var i=n.value;if(i)OX(e,i);else{e.state=JS,e.outcome=t;for(var r=-1,o=e.queue.length;++r<o;)e.queue[r].callFulfilled(t)}return e};di.reject=function(e,t){e.state=TX,e.outcome=t,process.browser||e.handled===um&&SX(function(){e.handled===um&&process.emit("unhandledRejection",t,e)});for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e};function R$(e){var t=e&&e.then;if(e&&(typeof e=="object"||typeof e=="function")&&typeof t=="function")return function(){t.apply(e,arguments)}}function OX(e,t){var n=!1;function i(s){n||(n=!0,di.reject(e,s))}function r(s){n||(n=!0,di.resolve(e,s))}function o(){t(r,i)}var a=MX(o);a.status==="error"&&i(a.value)}function MX(e,t){var n={};try{n.value=e(t),n.status="success"}catch(i){n.status="error",n.value=i}return n}ls.resolve=N$;function N$(e){return e instanceof this?e:di.resolve(new this(hu),e)}ls.reject=X$;function X$(e){var t=new this(hu);return di.reject(t,e)}ls.all=j$;function j$(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var r=new Array(n),o=0,a=-1,s=new this(hu);++a<n;)c(e[a],a);return s;function c(l,u){t.resolve(l).then(f,function(d){i||(i=!0,di.reject(s,d))});function f(d){r[u]=d,++o===n&&!i&&(i=!0,di.resolve(s,r))}}}ls.race=F$;function F$(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var r=-1,o=new this(hu);++r<n;)a(e[r]);return o;function a(s){t.resolve(s).then(function(c){i||(i=!0,di.resolve(o,c))},function(c){i||(i=!0,di.reject(o,c))})}}});var bu=ot((Dve,NX)=>{"use strict";var GS=null;typeof Promise<"u"?GS=Promise:GS=RX();NX.exports={Promise:GS}});var jX=ot(XX=>{(function(e,t){"use strict";if(e.setImmediate)return;var n=1,i={},r=!1,o=e.document,a;function s(g){typeof g!="function"&&(g=new Function(""+g));for(var y=new Array(arguments.length-1),w=0;w<y.length;w++)y[w]=arguments[w+1];var x={callback:g,args:y};return i[n]=x,a(n),n++}function c(g){delete i[g]}function l(g){var y=g.callback,w=g.args;switch(w.length){case 0:y();break;case 1:y(w[0]);break;case 2:y(w[0],w[1]);break;case 3:y(w[0],w[1],w[2]);break;default:y.apply(t,w);break}}function u(g){if(r)setTimeout(u,0,g);else{var y=i[g];if(y){r=!0;try{l(y)}finally{c(g),r=!1}}}}function f(){a=function(g){process.nextTick(function(){u(g)})}}function d(){if(e.postMessage&&!e.importScripts){var g=!0,y=e.onmessage;return e.onmessage=function(){g=!1},e.postMessage("","*"),e.onmessage=y,g}}function m(){var g="setImmediate$"+Math.random()+"$",y=function(w){w.source===e&&typeof w.data=="string"&&w.data.indexOf(g)===0&&u(+w.data.slice(g.length))};e.addEventListener?e.addEventListener("message",y,!1):e.attachEvent("onmessage",y),a=function(w){e.postMessage(g+w,"*")}}function p(){var g=new MessageChannel;g.port1.onmessage=function(y){var w=y.data;u(w)},a=function(y){g.port2.postMessage(y)}}function h(){var g=o.documentElement;a=function(y){var w=o.createElement("script");w.onreadystatechange=function(){u(y),w.onreadystatechange=null,g.removeChild(w),w=null},g.appendChild(w)}}function b(){a=function(g){setTimeout(u,0,g)}}var v=Object.getPrototypeOf&&Object.getPrototypeOf(e);v=v&&v.setTimeout?v:e,{}.toString.call(e.process)==="[object process]"?f():d()?m():e.MessageChannel?p():o&&"onreadystatechange"in o.createElement("script")?h():b(),v.setImmediate=s,v.clearImmediate=c})(typeof self>"u"?typeof global>"u"?XX:global:self)});var wr=ot(Nr=>{"use strict";var us=ka(),I$=ZS(),gu=sm(),AS=bu();jX();function E$(e){var t=null;return us.uint8array?t=new Uint8Array(e.length):t=new Array(e.length),eg(e,t)}Nr.newBlob=function(e,t){Nr.checkSupport("blob");try{return new Blob([e],{type:t})}catch{try{var n=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,i=new n;return i.append(e),i.getBlob(t)}catch{throw new Error("Bug : can't construct the Blob.")}}};function dm(e){return e}function eg(e,t){for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)&255;return t}var $0={stringifyByChunk:function(e,t,n){var i=[],r=0,o=e.length;if(o<=n)return String.fromCharCode.apply(null,e);for(;r<o;)t==="array"||t==="nodebuffer"?i.push(String.fromCharCode.apply(null,e.slice(r,Math.min(r+n,o)))):i.push(String.fromCharCode.apply(null,e.subarray(r,Math.min(r+n,o)))),r+=n;return i.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:(function(){try{return us.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return us.nodebuffer&&String.fromCharCode.apply(null,gu.allocBuffer(1)).length===1}catch{return!1}})()}};function mm(e){var t=65536,n=Nr.getTypeOf(e),i=!0;if(n==="uint8array"?i=$0.applyCanBeUsed.uint8array:n==="nodebuffer"&&(i=$0.applyCanBeUsed.nodebuffer),i)for(;t>1;)try{return $0.stringifyByChunk(e,n,t)}catch{t=Math.floor(t/2)}return $0.stringifyByChar(e)}Nr.applyFromCharCode=mm;function tg(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}var fs={};fs.string={string:dm,array:function(e){return eg(e,new Array(e.length))},arraybuffer:function(e){return fs.string.uint8array(e).buffer},uint8array:function(e){return eg(e,new Uint8Array(e.length))},nodebuffer:function(e){return eg(e,gu.allocBuffer(e.length))}};fs.array={string:mm,array:dm,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return gu.newBufferFrom(e)}};fs.arraybuffer={string:function(e){return mm(new Uint8Array(e))},array:function(e){return tg(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:dm,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return gu.newBufferFrom(new Uint8Array(e))}};fs.uint8array={string:mm,array:function(e){return tg(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:dm,nodebuffer:function(e){return gu.newBufferFrom(e)}};fs.nodebuffer={string:mm,array:function(e){return tg(e,new Array(e.length))},arraybuffer:function(e){return fs.nodebuffer.uint8array(e).buffer},uint8array:function(e){return tg(e,new Uint8Array(e.length))},nodebuffer:dm};Nr.transformTo=function(e,t){if(t||(t=""),!e)return t;Nr.checkSupport(e);var n=Nr.getTypeOf(t),i=fs[n][e](t);return i};Nr.resolve=function(e){for(var t=e.split("/"),n=[],i=0;i<t.length;i++){var r=t[i];r==="."||r===""&&i!==0&&i!==t.length-1||(r===".."?n.pop():n.push(r))}return n.join("/")};Nr.getTypeOf=function(e){if(typeof e=="string")return"string";if(Object.prototype.toString.call(e)==="[object Array]")return"array";if(us.nodebuffer&&gu.isBuffer(e))return"nodebuffer";if(us.uint8array&&e instanceof Uint8Array)return"uint8array";if(us.arraybuffer&&e instanceof ArrayBuffer)return"arraybuffer"};Nr.checkSupport=function(e){var t=us[e.toLowerCase()];if(!t)throw new Error(e+" is not supported by this platform")};Nr.MAX_VALUE_16BITS=65535;Nr.MAX_VALUE_32BITS=-1;Nr.pretty=function(e){var t="",n,i;for(i=0;i<(e||"").length;i++)n=e.charCodeAt(i),t+="\\x"+(n<16?"0":"")+n.toString(16).toUpperCase();return t};Nr.delay=function(e,t,n){setImmediate(function(){e.apply(n||null,t||[])})};Nr.inherits=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n};Nr.extend=function(){var e={},t,n;for(t=0;t<arguments.length;t++)for(n in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],n)&&typeof e[n]>"u"&&(e[n]=arguments[t][n]);return e};Nr.prepareContent=function(e,t,n,i,r){var o=AS.Promise.resolve(t).then(function(a){var s=us.blob&&(a instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(a))!==-1);return s&&typeof FileReader<"u"?new AS.Promise(function(c,l){var u=new FileReader;u.onload=function(f){c(f.target.result)},u.onerror=function(f){l(f.target.error)},u.readAsArrayBuffer(a)}):a});return o.then(function(a){var s=Nr.getTypeOf(a);return s?(s==="arraybuffer"?a=Nr.transformTo("uint8array",a):s==="string"&&(r?a=I$.decode(a):n&&i!==!0&&(a=E$(a))),a):AS.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}});var Ki=ot((Cve,IX)=>{"use strict";function FX(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}FX.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return this.isFinished?!1:(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(n){t.processChunk(n)}),e.on("end",function(){t.end()}),e.on("error",function(n){t.error(n)}),this},pause:function(){return this.isPaused||this.isFinished?!1:(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}};IX.exports=FX});var yu=ot(ds=>{"use strict";var vu=wr(),wc=ka(),V$=sm(),ng=Ki(),pm=new Array(256);for(Sa=0;Sa<256;Sa++)pm[Sa]=Sa>=252?6:Sa>=248?5:Sa>=240?4:Sa>=224?3:Sa>=192?2:1;var Sa;pm[254]=pm[254]=1;var W$=function(e){var t,n,i,r,o,a=e.length,s=0;for(r=0;r<a;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(wc.uint8array?t=new Uint8Array(s):t=new Array(s),o=0,r=0;o<s;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?t[o++]=n:n<2048?(t[o++]=192|n>>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t},H$=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+pm[e[n]]>t?n:t},Z$=function(e){var t,n,i,r,o=e.length,a=new Array(o*2);for(n=0,t=0;t<o;){if(i=e[t++],i<128){a[n++]=i;continue}if(r=pm[i],r>4){a[n++]=65533,t+=r-1;continue}for(i&=r===2?31:r===3?15:7;r>1&&t<o;)i=i<<6|e[t++]&63,r--;if(r>1){a[n++]=65533;continue}i<65536?a[n++]=i:(i-=65536,a[n++]=55296|i>>10&1023,a[n++]=56320|i&1023)}return a.length!==n&&(a.subarray?a=a.subarray(0,n):a.length=n),vu.applyFromCharCode(a)};ds.utf8encode=function(t){return wc.nodebuffer?V$.newBufferFrom(t,"utf-8"):W$(t)};ds.utf8decode=function(t){return wc.nodebuffer?vu.transformTo("nodebuffer",t).toString("utf-8"):(t=vu.transformTo(wc.uint8array?"uint8array":"array",t),Z$(t))};function rg(){ng.call(this,"utf-8 decode"),this.leftOver=null}vu.inherits(rg,ng);rg.prototype.processChunk=function(e){var t=vu.transformTo(wc.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(wc.uint8array){var n=t;t=new Uint8Array(n.length+this.leftOver.length),t.set(this.leftOver,0),t.set(n,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var i=H$(t),r=t;i!==t.length&&(wc.uint8array?(r=t.subarray(0,i),this.leftOver=t.subarray(i,t.length)):(r=t.slice(0,i),this.leftOver=t.slice(i,t.length))),this.push({data:ds.utf8decode(r),meta:e.meta})};rg.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:ds.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)};ds.Utf8DecodeWorker=rg;function BS(){ng.call(this,"utf-8 encode")}vu.inherits(BS,ng);BS.prototype.processChunk=function(e){this.push({data:ds.utf8encode(e.data),meta:e.meta})};ds.Utf8EncodeWorker=BS});var HX=ot((Kve,WX)=>{"use strict";var EX=Ki(),VX=wr();function YS(e){EX.call(this,"ConvertWorker to "+e),this.destType=e}VX.inherits(YS,EX);YS.prototype.processChunk=function(e){this.push({data:VX.transformTo(this.destType,e.data),meta:e.meta})};WX.exports=YS});var qX=ot((Gve,DX)=>{"use strict";var ZX=ES().Readable,D$=wr();D$.inherits(QS,ZX);function QS(e,t,n){ZX.call(this,t),this._helper=e;var i=this;e.on("data",function(r,o){i.push(r)||i._helper.pause(),n&&n(o)}).on("error",function(r){i.emit("error",r)}).on("end",function(){i.push(null)})}QS.prototype._read=function(){this._helper.resume()};DX.exports=QS});var _S=ot((Ave,JX)=>{"use strict";var xc=wr(),q$=HX(),U$=Ki(),C$=ZS(),J$=ka(),K$=bu(),UX=null;if(J$.nodestream)try{UX=qX()}catch{}function G$(e,t,n){switch(e){case"blob":return xc.newBlob(xc.transformTo("arraybuffer",t),n);case"base64":return C$.encode(t);default:return xc.transformTo(e,t)}}function A$(e,t){var n,i=0,r=null,o=0;for(n=0;n<t.length;n++)o+=t[n].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(r=new Uint8Array(o),n=0;n<t.length;n++)r.set(t[n],i),i+=t[n].length;return r;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}function B$(e,t){return new K$.Promise(function(n,i){var r=[],o=e._internalType,a=e._outputType,s=e._mimeType;e.on("data",function(c,l){r.push(c),t&&t(l)}).on("error",function(c){r=[],i(c)}).on("end",function(){try{var c=G$(a,A$(o,r),s);n(c)}catch(l){i(l)}r=[]}).resume()})}function CX(e,t,n){var i=t;switch(t){case"blob":case"arraybuffer":i="uint8array";break;case"base64":i="string";break}try{this._internalType=i,this._outputType=t,this._mimeType=n,xc.checkSupport(i),this._worker=e.pipe(new q$(i)),e.lock()}catch(r){this._worker=new U$("error"),this._worker.error(r)}}CX.prototype={accumulate:function(e){return B$(this,e)},on:function(e,t){var n=this;return e==="data"?this._worker.on(e,function(i){t.call(n,i.data,i.meta)}):this._worker.on(e,function(){xc.delay(t,arguments,n)}),this},resume:function(){return xc.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(xc.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new UX(this,{objectMode:this._outputType!=="nodebuffer"},e)}};JX.exports=CX});var $S=ot(go=>{"use strict";go.base64=!1;go.binary=!1;go.dir=!1;go.createFolders=!0;go.date=null;go.compression=null;go.compressionOptions=null;go.comment=null;go.unixPermissions=null;go.dosPermissions=null});var e2=ot((Yve,KX)=>{"use strict";var ig=wr(),og=Ki(),Y$=16*1024;function wu(e){og.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(n){t.dataIsReady=!0,t.data=n,t.max=n&&n.length||0,t.type=ig.getTypeOf(n),t.isPaused||t._tickAndRepeat()},function(n){t.error(n)})}ig.inherits(wu,og);wu.prototype.cleanUp=function(){og.prototype.cleanUp.call(this),this.data=null};wu.prototype.resume=function(){return og.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,ig.delay(this._tickAndRepeat,[],this)),!0):!1};wu.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(ig.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))};wu.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=Y$,t=null,n=Math.min(this.max,this.index+e);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,n);break;case"uint8array":t=this.data.subarray(this.index,n);break;case"array":case"nodebuffer":t=this.data.slice(this.index,n);break}return this.index=n,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})};KX.exports=wu});var ag=ot((Qve,AX)=>{"use strict";var Q$=wr();function _$(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var GX=_$();function $$(e,t,n,i){var r=GX,o=i+n;e=e^-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t[a])&255];return e^-1}function eee(e,t,n,i){var r=GX,o=i+n;e=e^-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t.charCodeAt(a))&255];return e^-1}AX.exports=function(t,n){if(typeof t>"u"||!t.length)return 0;var i=Q$.getTypeOf(t)!=="string";return i?$$(n|0,t,t.length,0):eee(n|0,t,t.length,0)}});var n2=ot((_ve,YX)=>{"use strict";var BX=Ki(),tee=ag(),nee=wr();function t2(){BX.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}nee.inherits(t2,BX);t2.prototype.processChunk=function(e){this.streamInfo.crc32=tee(e.data,this.streamInfo.crc32||0),this.push(e)};YX.exports=t2});var _X=ot(($ve,QX)=>{"use strict";var ree=wr(),r2=Ki();function i2(e){r2.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}ree.inherits(i2,r2);i2.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}r2.prototype.processChunk.call(this,e)};QX.exports=i2});var sg=ot((eye,tj)=>{"use strict";var $X=bu(),ej=e2(),iee=n2(),o2=_X();function a2(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}a2.prototype={getContentWorker:function(){var e=new ej($X.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o2("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new ej($X.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};a2.createWorkerFrom=function(e,t,n){return e.pipe(new iee).pipe(new o2("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new o2("compressedSize")).withStreamInfo("compression",t)};tj.exports=a2});var oj=ot((tye,ij)=>{"use strict";var oee=_S(),aee=e2(),s2=yu(),c2=sg(),nj=Ki(),l2=function(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}};l2.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");n=e.toLowerCase();var i=n==="string"||n==="text";(n==="binarystring"||n==="text")&&(n="string"),t=this._decompressWorker();var r=!this._dataBinary;r&&!i&&(t=t.pipe(new s2.Utf8EncodeWorker)),!r&&i&&(t=t.pipe(new s2.Utf8DecodeWorker))}catch(o){t=new nj("error"),t.error(o)}return new oee(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof c2&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new s2.Utf8EncodeWorker)),c2.createWorkerFrom(n,e,t)},_decompressWorker:function(){return this._data instanceof c2?this._data.getContentWorker():this._data instanceof nj?this._data:new aee(this._data)}};var rj=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],see=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(cg=0;cg<rj.length;cg++)l2.prototype[rj[cg]]=see;var cg;ij.exports=l2});var Ta=ot(Si=>{"use strict";var cee=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function lee(e,t){return Object.prototype.hasOwnProperty.call(e,t)}Si.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var i in n)lee(n,i)&&(e[i]=n[i])}}return e};Si.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var uee={arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+i),r);return}for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){var t,n,i,r,o,a;for(i=0,t=0,n=e.length;t<n;t++)i+=e[t].length;for(a=new Uint8Array(i),r=0,t=0,n=e.length;t<n;t++)o=e[t],a.set(o,r),r+=o.length;return a}},fee={arraySet:function(e,t,n,i,r){for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};Si.setTyped=function(e){e?(Si.Buf8=Uint8Array,Si.Buf16=Uint16Array,Si.Buf32=Int32Array,Si.assign(Si,uee)):(Si.Buf8=Array,Si.Buf16=Array,Si.Buf32=Array,Si.assign(Si,fee))};Si.setTyped(cee)});var Mj=ot(ku=>{"use strict";var dee=Ta(),mee=4,aj=0,sj=1,pee=2;function Pu(e){for(var t=e.length;--t>=0;)e[t]=0}var hee=0,mj=1,bee=2,gee=3,vee=258,b2=29,wm=256,bm=wm+1+b2,xu=30,g2=19,pj=2*bm+1,Pc=15,u2=16,yee=7,v2=256,hj=16,bj=17,gj=18,p2=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],lg=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],wee=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],vj=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],xee=512,za=new Array((bm+2)*2);Pu(za);var hm=new Array(xu*2);Pu(hm);var gm=new Array(xee);Pu(gm);var vm=new Array(vee-gee+1);Pu(vm);var y2=new Array(b2);Pu(y2);var ug=new Array(xu);Pu(ug);function f2(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}var yj,wj,xj;function d2(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Pj(e){return e<256?gm[e]:gm[256+(e>>>7)]}function ym(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Vi(e,t,n){e.bi_valid>u2-n?(e.bi_buf|=t<<e.bi_valid&65535,ym(e,e.bi_buf),e.bi_buf=t>>u2-e.bi_valid,e.bi_valid+=n-u2):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function Jo(e,t,n){Vi(e,n[t*2],n[t*2+1])}function kj(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function Pee(e){e.bi_valid===16?(ym(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function kee(e,t){var n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,f,d,m,p,h=0;for(d=0;d<=Pc;d++)e.bl_count[d]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<pj;l++)u=e.heap[l],d=n[n[u*2+1]*2+1]+1,d>c&&(d=c,h++),n[u*2+1]=d,!(u>i)&&(e.bl_count[d]++,m=0,u>=s&&(m=a[u-s]),p=n[u*2],e.opt_len+=p*(d+m),o&&(e.static_len+=p*(r[u*2+1]+m)));if(h!==0){do{for(d=c-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(d=c;d!==0;d--)for(u=e.bl_count[d];u!==0;)f=e.heap[--l],!(f>i)&&(n[f*2+1]!==d&&(e.opt_len+=(d-n[f*2+1])*n[f*2],n[f*2+1]=d),u--)}}function Sj(e,t,n){var i=new Array(Pc+1),r=0,o,a;for(o=1;o<=Pc;o++)i[o]=r=r+n[o-1]<<1;for(a=0;a<=t;a++){var s=e[a*2+1];s!==0&&(e[a*2]=kj(i[s]++,s))}}function See(){var e,t,n,i,r,o=new Array(Pc+1);for(n=0,i=0;i<b2-1;i++)for(y2[i]=n,e=0;e<1<<p2[i];e++)vm[n++]=i;for(vm[n-1]=i,r=0,i=0;i<16;i++)for(ug[i]=r,e=0;e<1<<lg[i];e++)gm[r++]=i;for(r>>=7;i<xu;i++)for(ug[i]=r<<7,e=0;e<1<<lg[i]-7;e++)gm[256+r++]=i;for(t=0;t<=Pc;t++)o[t]=0;for(e=0;e<=143;)za[e*2+1]=8,e++,o[8]++;for(;e<=255;)za[e*2+1]=9,e++,o[9]++;for(;e<=279;)za[e*2+1]=7,e++,o[7]++;for(;e<=287;)za[e*2+1]=8,e++,o[8]++;for(Sj(za,bm+1,o),e=0;e<xu;e++)hm[e*2+1]=5,hm[e*2]=kj(e,5);yj=new f2(za,p2,wm+1,bm,Pc),wj=new f2(hm,lg,0,xu,Pc),xj=new f2(new Array(0),wee,0,g2,yee)}function Tj(e){var t;for(t=0;t<bm;t++)e.dyn_ltree[t*2]=0;for(t=0;t<xu;t++)e.dyn_dtree[t*2]=0;for(t=0;t<g2;t++)e.bl_tree[t*2]=0;e.dyn_ltree[v2*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function zj(e){e.bi_valid>8?ym(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Tee(e,t,n,i){zj(e),i&&(ym(e,n),ym(e,~n)),dee.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function cj(e,t,n,i){var r=t*2,o=n*2;return e[r]<e[o]||e[r]===e[o]&&i[t]<=i[n]}function m2(e,t,n){for(var i=e.heap[n],r=n<<1;r<=e.heap_len&&(r<e.heap_len&&cj(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!cj(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i}function lj(e,t,n){var i,r,o=0,a,s;if(e.last_lit!==0)do i=e.pending_buf[e.d_buf+o*2]<<8|e.pending_buf[e.d_buf+o*2+1],r=e.pending_buf[e.l_buf+o],o++,i===0?Jo(e,r,t):(a=vm[r],Jo(e,a+wm+1,t),s=p2[a],s!==0&&(r-=y2[a],Vi(e,r,s)),i--,a=Pj(i),Jo(e,a,n),s=lg[a],s!==0&&(i-=ug[a],Vi(e,i,s)));while(o<e.last_lit);Jo(e,v2,t)}function h2(e,t){var n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,o=t.stat_desc.elems,a,s,c=-1,l;for(e.heap_len=0,e.heap_max=pj,a=0;a<o;a++)n[a*2]!==0?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):n[a*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,r&&(e.static_len-=i[l*2+1]);for(t.max_code=c,a=e.heap_len>>1;a>=1;a--)m2(e,n,a);l=o;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],m2(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,n[l*2]=n[a*2]+n[s*2],e.depth[l]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,n[a*2+1]=n[s*2+1]=l,e.heap[1]=l++,m2(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],kee(e,t),Sj(n,c,e.bl_count)}function uj(e,t,n){var i,r=-1,o,a=t[1],s=0,c=7,l=4;for(a===0&&(c=138,l=3),t[(n+1)*2+1]=65535,i=0;i<=n;i++)o=a,a=t[(i+1)*2+1],!(++s<c&&o===a)&&(s<l?e.bl_tree[o*2]+=s:o!==0?(o!==r&&e.bl_tree[o*2]++,e.bl_tree[hj*2]++):s<=10?e.bl_tree[bj*2]++:e.bl_tree[gj*2]++,s=0,r=o,a===0?(c=138,l=3):o===a?(c=6,l=3):(c=7,l=4))}function fj(e,t,n){var i,r=-1,o,a=t[1],s=0,c=7,l=4;for(a===0&&(c=138,l=3),i=0;i<=n;i++)if(o=a,a=t[(i+1)*2+1],!(++s<c&&o===a)){if(s<l)do Jo(e,o,e.bl_tree);while(--s!==0);else o!==0?(o!==r&&(Jo(e,o,e.bl_tree),s--),Jo(e,hj,e.bl_tree),Vi(e,s-3,2)):s<=10?(Jo(e,bj,e.bl_tree),Vi(e,s-3,3)):(Jo(e,gj,e.bl_tree),Vi(e,s-11,7));s=0,r=o,a===0?(c=138,l=3):o===a?(c=6,l=3):(c=7,l=4)}}function zee(e){var t;for(uj(e,e.dyn_ltree,e.l_desc.max_code),uj(e,e.dyn_dtree,e.d_desc.max_code),h2(e,e.bl_desc),t=g2-1;t>=3&&e.bl_tree[vj[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Oee(e,t,n,i){var r;for(Vi(e,t-257,5),Vi(e,n-1,5),Vi(e,i-4,4),r=0;r<i;r++)Vi(e,e.bl_tree[vj[r]*2+1],3);fj(e,e.dyn_ltree,t-1),fj(e,e.dyn_dtree,n-1)}function Mee(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return aj;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return sj;for(n=32;n<wm;n++)if(e.dyn_ltree[n*2]!==0)return sj;return aj}var dj=!1;function Lee(e){dj||(See(),dj=!0),e.l_desc=new d2(e.dyn_ltree,yj),e.d_desc=new d2(e.dyn_dtree,wj),e.bl_desc=new d2(e.bl_tree,xj),e.bi_buf=0,e.bi_valid=0,Tj(e)}function Oj(e,t,n,i){Vi(e,(hee<<1)+(i?1:0),3),Tee(e,t,n,!0)}function Ree(e){Vi(e,mj<<1,3),Jo(e,v2,za),Pee(e)}function Nee(e,t,n,i){var r,o,a=0;e.level>0?(e.strm.data_type===pee&&(e.strm.data_type=Mee(e)),h2(e,e.l_desc),h2(e,e.d_desc),a=zee(e),r=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=r&&(r=o)):r=o=n+5,n+4<=r&&t!==-1?Oj(e,t,n,i):e.strategy===mee||o===r?(Vi(e,(mj<<1)+(i?1:0),3),lj(e,za,hm)):(Vi(e,(bee<<1)+(i?1:0),3),Oee(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),lj(e,e.dyn_ltree,e.dyn_dtree)),Tj(e),i&&zj(e)}function Xee(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(vm[n]+wm+1)*2]++,e.dyn_dtree[Pj(t)*2]++),e.last_lit===e.lit_bufsize-1}ku._tr_init=Lee;ku._tr_stored_block=Oj;ku._tr_flush_block=Nee;ku._tr_tally=Xee;ku._tr_align=Ree});var w2=ot((iye,Lj)=>{"use strict";function jee(e,t,n,i){for(var r=e&65535|0,o=e>>>16&65535|0,a=0;n!==0;){a=n>2e3?2e3:n,n-=a;do r=r+t[i++]|0,o=o+r|0;while(--a);r%=65521,o%=65521}return r|o<<16|0}Lj.exports=jee});var x2=ot((oye,Rj)=>{"use strict";function Fee(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var Iee=Fee();function Eee(e,t,n,i){var r=Iee,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t[a])&255];return e^-1}Rj.exports=Eee});var fg=ot((aye,Nj)=>{"use strict";Nj.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Zj=ot(Ao=>{"use strict";var Ti=Ta(),to=Mj(),Ij=w2(),ms=x2(),Vee=fg(),zc=0,Wee=1,Hee=3,vs=4,Xj=5,Go=0,jj=1,no=-2,Zee=-3,P2=-5,Dee=-1,qee=1,dg=2,Uee=3,Cee=4,Jee=0,Kee=2,bg=8,Gee=9,Aee=15,Bee=8,Yee=29,Qee=256,S2=Qee+1+Yee,_ee=30,$ee=19,ete=2*S2+1,tte=15,xn=3,bs=258,vo=bs+xn+1,nte=32,gg=42,T2=69,mg=73,pg=91,hg=103,kc=113,Pm=666,Dr=1,km=2,Sc=3,zu=4,rte=3;function gs(e,t){return e.msg=Vee[t],t}function Fj(e){return(e<<1)-(e>4?9:0)}function hs(e){for(var t=e.length;--t>=0;)e[t]=0}function ps(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Ti.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function ti(e,t){to._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ps(e.strm)}function Rn(e,t){e.pending_buf[e.pending++]=t}function xm(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function ite(e,t,n,i){var r=e.avail_in;return r>i&&(r=i),r===0?0:(e.avail_in-=r,Ti.arraySet(t,e.input,e.next_in,r,n),e.state.wrap===1?e.adler=Ij(e.adler,t,r,n):e.state.wrap===2&&(e.adler=ms(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)}function Ej(e,t){var n=e.max_chain_length,i=e.strstart,r,o,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-vo?e.strstart-(e.w_size-vo):0,l=e.window,u=e.w_mask,f=e.prev,d=e.strstart+bs,m=l[i+a-1],p=l[i+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(r=t,!(l[r+a]!==p||l[r+a-1]!==m||l[r]!==l[i]||l[++r]!==l[i+1])){i+=2,r++;do;while(l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&i<d);if(o=bs-(d-i),i=d-bs,o>a){if(e.match_start=t,a=o,o>=s)break;m=l[i+a-1],p=l[i+a]}}while((t=f[t&u])>c&&--n!==0);return a<=e.lookahead?a:e.lookahead}function Tc(e){var t=e.w_size,n,i,r,o,a;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-vo)){Ti.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,n=i;do r=e.head[--n],e.head[n]=r>=t?r-t:0;while(--i);i=t,n=i;do r=e.prev[--n],e.prev[n]=r>=t?r-t:0;while(--i);o+=t}if(e.strm.avail_in===0)break;if(i=ite(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=i,e.lookahead+e.insert>=xn)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+xn-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<xn)););}while(e.lookahead<vo&&e.strm.avail_in!==0)}function ote(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Tc(e),e.lookahead===0&&t===zc)return Dr;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((e.strstart===0||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,ti(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-vo&&(ti(e,!1),e.strm.avail_out===0))return Dr}return e.insert=0,t===vs?(ti(e,!0),e.strm.avail_out===0?Sc:zu):(e.strstart>e.block_start&&(ti(e,!1),e.strm.avail_out===0),Dr)}function k2(e,t){for(var n,i;;){if(e.lookahead<vo){if(Tc(e),e.lookahead<vo&&t===zc)return Dr;if(e.lookahead===0)break}if(n=0,e.lookahead>=xn&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+xn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-vo&&(e.match_length=Ej(e,n)),e.match_length>=xn)if(i=to._tr_tally(e,e.strstart-e.match_start,e.match_length-xn),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=xn){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+xn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=to._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(ti(e,!1),e.strm.avail_out===0))return Dr}return e.insert=e.strstart<xn-1?e.strstart:xn-1,t===vs?(ti(e,!0),e.strm.avail_out===0?Sc:zu):e.last_lit&&(ti(e,!1),e.strm.avail_out===0)?Dr:km}function Su(e,t){for(var n,i,r;;){if(e.lookahead<vo){if(Tc(e),e.lookahead<vo&&t===zc)return Dr;if(e.lookahead===0)break}if(n=0,e.lookahead>=xn&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+xn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=xn-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-vo&&(e.match_length=Ej(e,n),e.match_length<=5&&(e.strategy===qee||e.match_length===xn&&e.strstart-e.match_start>4096)&&(e.match_length=xn-1)),e.prev_length>=xn&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-xn,i=to._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-xn),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+xn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=xn-1,e.strstart++,i&&(ti(e,!1),e.strm.avail_out===0))return Dr}else if(e.match_available){if(i=to._tr_tally(e,0,e.window[e.strstart-1]),i&&ti(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Dr}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=to._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<xn-1?e.strstart:xn-1,t===vs?(ti(e,!0),e.strm.avail_out===0?Sc:zu):e.last_lit&&(ti(e,!1),e.strm.avail_out===0)?Dr:km}function ate(e,t){for(var n,i,r,o,a=e.window;;){if(e.lookahead<=bs){if(Tc(e),e.lookahead<=bs&&t===zc)return Dr;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=xn&&e.strstart>0&&(r=e.strstart-1,i=a[r],i===a[++r]&&i===a[++r]&&i===a[++r])){o=e.strstart+bs;do;while(i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&r<o);e.match_length=bs-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=xn?(n=to._tr_tally(e,1,e.match_length-xn),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=to._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(ti(e,!1),e.strm.avail_out===0))return Dr}return e.insert=0,t===vs?(ti(e,!0),e.strm.avail_out===0?Sc:zu):e.last_lit&&(ti(e,!1),e.strm.avail_out===0)?Dr:km}function ste(e,t){for(var n;;){if(e.lookahead===0&&(Tc(e),e.lookahead===0)){if(t===zc)return Dr;break}if(e.match_length=0,n=to._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(ti(e,!1),e.strm.avail_out===0))return Dr}return e.insert=0,t===vs?(ti(e,!0),e.strm.avail_out===0?Sc:zu):e.last_lit&&(ti(e,!1),e.strm.avail_out===0)?Dr:km}function Ko(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}var Tu;Tu=[new Ko(0,0,0,0,ote),new Ko(4,4,8,4,k2),new Ko(4,5,16,8,k2),new Ko(4,6,32,32,k2),new Ko(4,4,16,16,Su),new Ko(8,16,32,32,Su),new Ko(8,16,128,128,Su),new Ko(8,32,128,256,Su),new Ko(32,128,258,1024,Su),new Ko(32,258,258,4096,Su)];function cte(e){e.window_size=2*e.w_size,hs(e.head),e.max_lazy_match=Tu[e.level].max_lazy,e.good_match=Tu[e.level].good_length,e.nice_match=Tu[e.level].nice_length,e.max_chain_length=Tu[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=xn-1,e.match_available=0,e.ins_h=0}function lte(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bg,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Ti.Buf16(ete*2),this.dyn_dtree=new Ti.Buf16((2*_ee+1)*2),this.bl_tree=new Ti.Buf16((2*$ee+1)*2),hs(this.dyn_ltree),hs(this.dyn_dtree),hs(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Ti.Buf16(tte+1),this.heap=new Ti.Buf16(2*S2+1),hs(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Ti.Buf16(2*S2+1),hs(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Vj(e){var t;return!e||!e.state?gs(e,no):(e.total_in=e.total_out=0,e.data_type=Kee,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?gg:kc,e.adler=t.wrap===2?0:1,t.last_flush=zc,to._tr_init(t),Go)}function Wj(e){var t=Vj(e);return t===Go&&cte(e.state),t}function ute(e,t){return!e||!e.state||e.state.wrap!==2?no:(e.state.gzhead=t,Go)}function Hj(e,t,n,i,r,o){if(!e)return no;var a=1;if(t===Dee&&(t=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),r<1||r>Gee||n!==bg||i<8||i>15||t<0||t>9||o<0||o>Cee)return gs(e,no);i===8&&(i=9);var s=new lte;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=r+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+xn-1)/xn),s.window=new Ti.Buf8(s.w_size*2),s.head=new Ti.Buf16(s.hash_size),s.prev=new Ti.Buf16(s.w_size),s.lit_bufsize=1<<r+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Ti.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=n,Wj(e)}function fte(e,t){return Hj(e,t,bg,Aee,Bee,Jee)}function dte(e,t){var n,i,r,o;if(!e||!e.state||t>Xj||t<0)return e?gs(e,no):no;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===Pm&&t!==vs)return gs(e,e.avail_out===0?P2:no);if(i.strm=e,n=i.last_flush,i.last_flush=t,i.status===gg)if(i.wrap===2)e.adler=0,Rn(i,31),Rn(i,139),Rn(i,8),i.gzhead?(Rn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Rn(i,i.gzhead.time&255),Rn(i,i.gzhead.time>>8&255),Rn(i,i.gzhead.time>>16&255),Rn(i,i.gzhead.time>>24&255),Rn(i,i.level===9?2:i.strategy>=dg||i.level<2?4:0),Rn(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(Rn(i,i.gzhead.extra.length&255),Rn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ms(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=T2):(Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,i.level===9?2:i.strategy>=dg||i.level<2?4:0),Rn(i,rte),i.status=kc);else{var a=bg+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=dg||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,a|=s<<6,i.strstart!==0&&(a|=nte),a+=31-a%31,i.status=kc,xm(i,a),i.strstart!==0&&(xm(i,e.adler>>>16),xm(i,e.adler&65535)),e.adler=1}if(i.status===T2)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),ps(e),r=i.pending,i.pending===i.pending_buf_size));)Rn(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=mg)}else i.status=mg;if(i.status===mg)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),ps(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindex<i.gzhead.name.length?o=i.gzhead.name.charCodeAt(i.gzindex++)&255:o=0,Rn(i,o)}while(o!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.gzindex=0,i.status=pg)}else i.status=pg;if(i.status===pg)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),ps(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindex<i.gzhead.comment.length?o=i.gzhead.comment.charCodeAt(i.gzindex++)&255:o=0,Rn(i,o)}while(o!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=ms(e.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.status=hg)}else i.status=hg;if(i.status===hg&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ps(e),i.pending+2<=i.pending_buf_size&&(Rn(i,e.adler&255),Rn(i,e.adler>>8&255),e.adler=0,i.status=kc)):i.status=kc),i.pending!==0){if(ps(e),e.avail_out===0)return i.last_flush=-1,Go}else if(e.avail_in===0&&Fj(t)<=Fj(n)&&t!==vs)return gs(e,P2);if(i.status===Pm&&e.avail_in!==0)return gs(e,P2);if(e.avail_in!==0||i.lookahead!==0||t!==zc&&i.status!==Pm){var c=i.strategy===dg?ste(i,t):i.strategy===Uee?ate(i,t):Tu[i.level].func(i,t);if((c===Sc||c===zu)&&(i.status=Pm),c===Dr||c===Sc)return e.avail_out===0&&(i.last_flush=-1),Go;if(c===km&&(t===Wee?to._tr_align(i):t!==Xj&&(to._tr_stored_block(i,0,0,!1),t===Hee&&(hs(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),ps(e),e.avail_out===0))return i.last_flush=-1,Go}return t!==vs?Go:i.wrap<=0?jj:(i.wrap===2?(Rn(i,e.adler&255),Rn(i,e.adler>>8&255),Rn(i,e.adler>>16&255),Rn(i,e.adler>>24&255),Rn(i,e.total_in&255),Rn(i,e.total_in>>8&255),Rn(i,e.total_in>>16&255),Rn(i,e.total_in>>24&255)):(xm(i,e.adler>>>16),xm(i,e.adler&65535)),ps(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Go:jj)}function mte(e){var t;return!e||!e.state?no:(t=e.state.status,t!==gg&&t!==T2&&t!==mg&&t!==pg&&t!==hg&&t!==kc&&t!==Pm?gs(e,no):(e.state=null,t===kc?gs(e,Zee):Go))}function pte(e,t){var n=t.length,i,r,o,a,s,c,l,u;if(!e||!e.state||(i=e.state,a=i.wrap,a===2||a===1&&i.status!==gg||i.lookahead))return no;for(a===1&&(e.adler=Ij(e.adler,t,n,0)),i.wrap=0,n>=i.w_size&&(a===0&&(hs(i.head),i.strstart=0,i.block_start=0,i.insert=0),u=new Ti.Buf8(i.w_size),Ti.arraySet(u,t,n-i.w_size,i.w_size,0),t=u,n=i.w_size),s=e.avail_in,c=e.next_in,l=e.input,e.avail_in=n,e.next_in=0,e.input=t,Tc(i);i.lookahead>=xn;){r=i.strstart,o=i.lookahead-(xn-1);do i.ins_h=(i.ins_h<<i.hash_shift^i.window[r+xn-1])&i.hash_mask,i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++;while(--o);i.strstart=r,i.lookahead=xn-1,Tc(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=xn-1,i.match_available=0,e.next_in=c,e.input=l,e.avail_in=s,i.wrap=a,Go}Ao.deflateInit=fte;Ao.deflateInit2=Hj;Ao.deflateReset=Wj;Ao.deflateResetKeep=Vj;Ao.deflateSetHeader=ute;Ao.deflate=dte;Ao.deflateEnd=mte;Ao.deflateSetDictionary=pte;Ao.deflateInfo="pako deflate (from Nodeca project)"});var z2=ot(Ou=>{"use strict";var vg=Ta(),Dj=!0,qj=!0;try{String.fromCharCode.apply(null,[0])}catch{Dj=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{qj=!1}var Sm=new vg.Buf8(256);for(Oa=0;Oa<256;Oa++)Sm[Oa]=Oa>=252?6:Oa>=248?5:Oa>=240?4:Oa>=224?3:Oa>=192?2:1;var Oa;Sm[254]=Sm[254]=1;Ou.string2buf=function(e){var t,n,i,r,o,a=e.length,s=0;for(r=0;r<a;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new vg.Buf8(s),o=0,r=0;o<s;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?t[o++]=n:n<2048?(t[o++]=192|n>>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t};function Uj(e,t){if(t<65534&&(e.subarray&&qj||!e.subarray&&Dj))return String.fromCharCode.apply(null,vg.shrinkBuf(e,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n}Ou.buf2binstring=function(e){return Uj(e,e.length)};Ou.binstring2buf=function(e){for(var t=new vg.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t};Ou.buf2string=function(e,t){var n,i,r,o,a=t||e.length,s=new Array(a*2);for(i=0,n=0;n<a;){if(r=e[n++],r<128){s[i++]=r;continue}if(o=Sm[r],o>4){s[i++]=65533,n+=o-1;continue}for(r&=o===2?31:o===3?15:7;o>1&&n<a;)r=r<<6|e[n++]&63,o--;if(o>1){s[i++]=65533;continue}r<65536?s[i++]=r:(r-=65536,s[i++]=55296|r>>10&1023,s[i++]=56320|r&1023)}return Uj(s,i)};Ou.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Sm[e[n]]>t?n:t}});var O2=ot((lye,Cj)=>{"use strict";function hte(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}Cj.exports=hte});var Aj=ot(Om=>{"use strict";var Tm=Zj(),zm=Ta(),L2=z2(),R2=fg(),bte=O2(),Gj=Object.prototype.toString,gte=0,M2=4,Mu=0,Jj=1,Kj=2,vte=-1,yte=0,wte=8;function Oc(e){if(!(this instanceof Oc))return new Oc(e);this.options=zm.assign({level:vte,method:wte,chunkSize:16384,windowBits:15,memLevel:8,strategy:yte,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new bte,this.strm.avail_out=0;var n=Tm.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Mu)throw new Error(R2[n]);if(t.header&&Tm.deflateSetHeader(this.strm,t.header),t.dictionary){var i;if(typeof t.dictionary=="string"?i=L2.string2buf(t.dictionary):Gj.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,n=Tm.deflateSetDictionary(this.strm,i),n!==Mu)throw new Error(R2[n]);this._dict_set=!0}}Oc.prototype.push=function(e,t){var n=this.strm,i=this.options.chunkSize,r,o;if(this.ended)return!1;o=t===~~t?t:t===!0?M2:gte,typeof e=="string"?n.input=L2.string2buf(e):Gj.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new zm.Buf8(i),n.next_out=0,n.avail_out=i),r=Tm.deflate(n,o),r!==Jj&&r!==Mu)return this.onEnd(r),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(o===M2||o===Kj))&&(this.options.to==="string"?this.onData(L2.buf2binstring(zm.shrinkBuf(n.output,n.next_out))):this.onData(zm.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&r!==Jj);return o===M2?(r=Tm.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Mu):(o===Kj&&(this.onEnd(Mu),n.avail_out=0),!0)};Oc.prototype.onData=function(e){this.chunks.push(e)};Oc.prototype.onEnd=function(e){e===Mu&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=zm.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function N2(e,t){var n=new Oc(t);if(n.push(e,!0),n.err)throw n.msg||R2[n.err];return n.result}function xte(e,t){return t=t||{},t.raw=!0,N2(e,t)}function Pte(e,t){return t=t||{},t.gzip=!0,N2(e,t)}Om.Deflate=Oc;Om.deflate=N2;Om.deflateRaw=xte;Om.gzip=Pte});var Yj=ot((fye,Bj)=>{"use strict";var yg=30,kte=12;Bj.exports=function(t,n){var i,r,o,a,s,c,l,u,f,d,m,p,h,b,v,g,y,w,x,O,P,T,S,k,L;i=t.state,r=t.next_in,k=t.input,o=r+(t.avail_in-5),a=t.next_out,L=t.output,s=a-(n-t.avail_out),c=a+(t.avail_out-257),l=i.dmax,u=i.wsize,f=i.whave,d=i.wnext,m=i.window,p=i.hold,h=i.bits,b=i.lencode,v=i.distcode,g=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;e:do{h<15&&(p+=k[r++]<<h,h+=8,p+=k[r++]<<h,h+=8),w=b[p&g];t:for(;;){if(x=w>>>24,p>>>=x,h-=x,x=w>>>16&255,x===0)L[a++]=w&65535;else if(x&16){O=w&65535,x&=15,x&&(h<x&&(p+=k[r++]<<h,h+=8),O+=p&(1<<x)-1,p>>>=x,h-=x),h<15&&(p+=k[r++]<<h,h+=8,p+=k[r++]<<h,h+=8),w=v[p&y];n:for(;;){if(x=w>>>24,p>>>=x,h-=x,x=w>>>16&255,x&16){if(P=w&65535,x&=15,h<x&&(p+=k[r++]<<h,h+=8,h<x&&(p+=k[r++]<<h,h+=8)),P+=p&(1<<x)-1,P>l){t.msg="invalid distance too far back",i.mode=yg;break e}if(p>>>=x,h-=x,x=a-s,P>x){if(x=P-x,x>f&&i.sane){t.msg="invalid distance too far back",i.mode=yg;break e}if(T=0,S=m,d===0){if(T+=u-x,x<O){O-=x;do L[a++]=m[T++];while(--x);T=a-P,S=L}}else if(d<x){if(T+=u+d-x,x-=d,x<O){O-=x;do L[a++]=m[T++];while(--x);if(T=0,d<O){x=d,O-=x;do L[a++]=m[T++];while(--x);T=a-P,S=L}}}else if(T+=d-x,x<O){O-=x;do L[a++]=m[T++];while(--x);T=a-P,S=L}for(;O>2;)L[a++]=S[T++],L[a++]=S[T++],L[a++]=S[T++],O-=3;O&&(L[a++]=S[T++],O>1&&(L[a++]=S[T++]))}else{T=a-P;do L[a++]=L[T++],L[a++]=L[T++],L[a++]=L[T++],O-=3;while(O>2);O&&(L[a++]=L[T++],O>1&&(L[a++]=L[T++]))}}else if((x&64)===0){w=v[(w&65535)+(p&(1<<x)-1)];continue n}else{t.msg="invalid distance code",i.mode=yg;break e}break}}else if((x&64)===0){w=b[(w&65535)+(p&(1<<x)-1)];continue t}else if(x&32){i.mode=kte;break e}else{t.msg="invalid literal/length code",i.mode=yg;break e}break}}while(r<o&&a<c);O=h>>3,r-=O,h-=O<<3,p&=(1<<h)-1,t.next_in=r,t.next_out=a,t.avail_in=r<o?5+(o-r):5-(r-o),t.avail_out=a<c?257+(c-a):257-(a-c),i.hold=p,i.bits=h}});var rF=ot((dye,nF)=>{"use strict";var Qj=Ta(),Lu=15,_j=852,$j=592,eF=0,X2=1,tF=2,Ste=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Tte=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],zte=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Ote=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];nF.exports=function(t,n,i,r,o,a,s,c){var l=c.bits,u=0,f=0,d=0,m=0,p=0,h=0,b=0,v=0,g=0,y=0,w,x,O,P,T,S=null,k=0,L,z=new Qj.Buf16(Lu+1),X=new Qj.Buf16(Lu+1),V=null,R=0,j,J,q;for(u=0;u<=Lu;u++)z[u]=0;for(f=0;f<r;f++)z[n[i+f]]++;for(p=l,m=Lu;m>=1&&z[m]===0;m--);if(p>m&&(p=m),m===0)return o[a++]=1<<24|64<<16|0,o[a++]=1<<24|64<<16|0,c.bits=1,0;for(d=1;d<m&&z[d]===0;d++);for(p<d&&(p=d),v=1,u=1;u<=Lu;u++)if(v<<=1,v-=z[u],v<0)return-1;if(v>0&&(t===eF||m!==1))return-1;for(X[1]=0,u=1;u<Lu;u++)X[u+1]=X[u]+z[u];for(f=0;f<r;f++)n[i+f]!==0&&(s[X[n[i+f]]++]=f);if(t===eF?(S=V=s,L=19):t===X2?(S=Ste,k-=257,V=Tte,R-=257,L=256):(S=zte,V=Ote,L=-1),y=0,f=0,u=d,T=a,h=p,b=0,O=-1,g=1<<p,P=g-1,t===X2&&g>_j||t===tF&&g>$j)return 1;for(;;){j=u-b,s[f]<L?(J=0,q=s[f]):s[f]>L?(J=V[R+s[f]],q=S[k+s[f]]):(J=96,q=0),w=1<<u-b,x=1<<h,d=x;do x-=w,o[T+(y>>b)+x]=j<<24|J<<16|q|0;while(x!==0);for(w=1<<u-1;y&w;)w>>=1;if(w!==0?(y&=w-1,y+=w):y=0,f++,--z[u]===0){if(u===m)break;u=n[i+s[f]]}if(u>p&&(y&P)!==O){for(b===0&&(b=p),T+=d,h=u-b,v=1<<h;h+b<m&&(v-=z[h+b],!(v<=0));)h++,v<<=1;if(g+=1<<h,t===X2&&g>_j||t===tF&&g>$j)return 1;O=y&P,o[O]=p<<24|h<<16|T-a|0}}return y!==0&&(o[T+y]=u-b<<24|64<<16|0),c.bits=p,0}});var WF=ot(yo=>{"use strict";var Gi=Ta(),W2=w2(),Bo=x2(),Mte=Yj(),Mm=rF(),Lte=0,LF=1,RF=2,iF=4,Rte=5,wg=6,Mc=0,Nte=1,Xte=2,ro=-2,NF=-3,H2=-4,jte=-5,oF=8,XF=1,aF=2,sF=3,cF=4,lF=5,uF=6,fF=7,dF=8,mF=9,pF=10,kg=11,Ma=12,j2=13,hF=14,F2=15,bF=16,gF=17,vF=18,yF=19,xg=20,Pg=21,wF=22,xF=23,PF=24,kF=25,SF=26,I2=27,TF=28,zF=29,br=30,Z2=31,Fte=32,Ite=852,Ete=592,Vte=15,Wte=Vte;function OF(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function Hte(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Gi.Buf16(320),this.work=new Gi.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function jF(e){var t;return!e||!e.state?ro:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=XF,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Gi.Buf32(Ite),t.distcode=t.distdyn=new Gi.Buf32(Ete),t.sane=1,t.back=-1,Mc)}function FF(e){var t;return!e||!e.state?ro:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,jF(e))}function IF(e,t){var n,i;return!e||!e.state||(i=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?ro:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,FF(e))}function EF(e,t){var n,i;return e?(i=new Hte,e.state=i,i.window=null,n=IF(e,t),n!==Mc&&(e.state=null),n):ro}function Zte(e){return EF(e,Wte)}var MF=!0,E2,V2;function Dte(e){if(MF){var t;for(E2=new Gi.Buf32(512),V2=new Gi.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Mm(LF,e.lens,0,288,E2,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Mm(RF,e.lens,0,32,V2,0,e.work,{bits:5}),MF=!1}e.lencode=E2,e.lenbits=9,e.distcode=V2,e.distbits=5}function VF(e,t,n,i){var r,o=e.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Gi.Buf8(o.wsize)),i>=o.wsize?(Gi.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>i&&(r=i),Gi.arraySet(o.window,t,n-i,r,o.wnext),i-=r,i?(Gi.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=r))),0}function qte(e,t){var n,i,r,o,a,s,c,l,u,f,d,m,p,h,b=0,v,g,y,w,x,O,P,T,S=new Gi.Buf8(4),k,L,z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return ro;n=e.state,n.mode===Ma&&(n.mode=j2),a=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,l=n.hold,u=n.bits,f=s,d=c,T=Mc;e:for(;;)switch(n.mode){case XF:if(n.wrap===0){n.mode=j2;break}for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.wrap&2&&l===35615){n.check=0,S[0]=l&255,S[1]=l>>>8&255,n.check=Bo(n.check,S,2,0),l=0,u=0,n.mode=aF;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=br;break}if((l&15)!==oF){e.msg="unknown compression method",n.mode=br;break}if(l>>>=4,u-=4,P=(l&15)+8,n.wbits===0)n.wbits=P;else if(P>n.wbits){e.msg="invalid window size",n.mode=br;break}n.dmax=1<<P,e.adler=n.check=1,n.mode=l&512?pF:Ma,l=0,u=0;break;case aF:for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==oF){e.msg="unknown compression method",n.mode=br;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=br;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=Bo(n.check,S,2,0)),l=0,u=0,n.mode=sF;case sF:for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,S[2]=l>>>16&255,S[3]=l>>>24&255,n.check=Bo(n.check,S,4,0)),l=0,u=0,n.mode=cF;case cF:for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=Bo(n.check,S,2,0)),l=0,u=0,n.mode=lF;case lF:if(n.flags&1024){for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=Bo(n.check,S,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=uF;case uF:if(n.flags&1024&&(m=n.length,m>s&&(m=s),m&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Gi.arraySet(n.head.extra,i,o,m,P)),n.flags&512&&(n.check=Bo(n.check,i,m,o)),s-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=fF;case fF:if(n.flags&2048){if(s===0)break e;m=0;do P=i[o+m++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P));while(P&&m<s);if(n.flags&512&&(n.check=Bo(n.check,i,m,o)),s-=m,o+=m,P)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=dF;case dF:if(n.flags&4096){if(s===0)break e;m=0;do P=i[o+m++],n.head&&P&&n.length<65536&&(n.head.comment+=String.fromCharCode(P));while(P&&m<s);if(n.flags&512&&(n.check=Bo(n.check,i,m,o)),s-=m,o+=m,P)break e}else n.head&&(n.head.comment=null);n.mode=mF;case mF:if(n.flags&512){for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l!==(n.check&65535)){e.msg="header crc mismatch",n.mode=br;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Ma;break;case pF:for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}e.adler=n.check=OF(l),l=0,u=0,n.mode=kg;case kg:if(n.havedict===0)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,Xte;e.adler=n.check=1,n.mode=Ma;case Ma:if(t===Rte||t===wg)break e;case j2:if(n.last){l>>>=u&7,u-=u&7,n.mode=I2;break}for(;u<3;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}switch(n.last=l&1,l>>>=1,u-=1,l&3){case 0:n.mode=hF;break;case 1:if(Dte(n),n.mode=xg,t===wg){l>>>=2,u-=2;break e}break;case 2:n.mode=gF;break;case 3:e.msg="invalid block type",n.mode=br}l>>>=2,u-=2;break;case hF:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=br;break}if(n.length=l&65535,l=0,u=0,n.mode=F2,t===wg)break e;case F2:n.mode=bF;case bF:if(m=n.length,m){if(m>s&&(m=s),m>c&&(m=c),m===0)break e;Gi.arraySet(r,i,o,m,a),s-=m,o+=m,c-=m,a+=m,n.length-=m;break}n.mode=Ma;break;case gF:for(;u<14;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=br;break}n.have=0,n.mode=vF;case vF:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.lens[z[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[z[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,k={bits:n.lenbits},T=Mm(Lte,n.lens,0,19,n.lencode,0,n.work,k),n.lenbits=k.bits,T){e.msg="invalid code lengths set",n.mode=br;break}n.have=0,n.mode=yF;case yF:for(;n.have<n.nlen+n.ndist;){for(;b=n.lencode[l&(1<<n.lenbits)-1],v=b>>>24,g=b>>>16&255,y=b&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(y<16)l>>>=v,u-=v,n.lens[n.have++]=y;else{if(y===16){for(L=v+2;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l>>>=v,u-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=br;break}P=n.lens[n.have-1],m=3+(l&3),l>>>=2,u-=2}else if(y===17){for(L=v+3;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=v,u-=v,P=0,m=3+(l&7),l>>>=3,u-=3}else{for(L=v+7;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=v,u-=v,P=0,m=11+(l&127),l>>>=7,u-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=br;break}for(;m--;)n.lens[n.have++]=P}}if(n.mode===br)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=br;break}if(n.lenbits=9,k={bits:n.lenbits},T=Mm(LF,n.lens,0,n.nlen,n.lencode,0,n.work,k),n.lenbits=k.bits,T){e.msg="invalid literal/lengths set",n.mode=br;break}if(n.distbits=6,n.distcode=n.distdyn,k={bits:n.distbits},T=Mm(RF,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,k),n.distbits=k.bits,T){e.msg="invalid distances set",n.mode=br;break}if(n.mode=xg,t===wg)break e;case xg:n.mode=Pg;case Pg:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,Mte(e,d),a=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===Ma&&(n.back=-1);break}for(n.back=0;b=n.lencode[l&(1<<n.lenbits)-1],v=b>>>24,g=b>>>16&255,y=b&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(g&&(g&240)===0){for(w=v,x=g,O=y;b=n.lencode[O+((l&(1<<w+x)-1)>>w)],v=b>>>24,g=b>>>16&255,y=b&65535,!(w+v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=w,u-=w,n.back+=w}if(l>>>=v,u-=v,n.back+=v,n.length=y,g===0){n.mode=SF;break}if(g&32){n.back=-1,n.mode=Ma;break}if(g&64){e.msg="invalid literal/length code",n.mode=br;break}n.extra=g&15,n.mode=wF;case wF:if(n.extra){for(L=n.extra;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=xF;case xF:for(;b=n.distcode[l&(1<<n.distbits)-1],v=b>>>24,g=b>>>16&255,y=b&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if((g&240)===0){for(w=v,x=g,O=y;b=n.distcode[O+((l&(1<<w+x)-1)>>w)],v=b>>>24,g=b>>>16&255,y=b&65535,!(w+v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=w,u-=w,n.back+=w}if(l>>>=v,u-=v,n.back+=v,g&64){e.msg="invalid distance code",n.mode=br;break}n.offset=y,n.extra=g&15,n.mode=PF;case PF:if(n.extra){for(L=n.extra;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=br;break}n.mode=kF;case kF:if(c===0)break e;if(m=d-c,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=br;break}m>n.wnext?(m-=n.wnext,p=n.wsize-m):p=n.wnext-m,m>n.length&&(m=n.length),h=n.window}else h=r,p=a-n.offset,m=n.length;m>c&&(m=c),c-=m,n.length-=m;do r[a++]=h[p++];while(--m);n.length===0&&(n.mode=Pg);break;case SF:if(c===0)break e;r[a++]=n.length,c--,n.mode=Pg;break;case I2:if(n.wrap){for(;u<32;){if(s===0)break e;s--,l|=i[o++]<<u,u+=8}if(d-=c,e.total_out+=d,n.total+=d,d&&(e.adler=n.check=n.flags?Bo(n.check,r,d,a-d):W2(n.check,r,d,a-d)),d=c,(n.flags?l:OF(l))!==n.check){e.msg="incorrect data check",n.mode=br;break}l=0,u=0}n.mode=TF;case TF:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=br;break}l=0,u=0}n.mode=zF;case zF:T=Nte;break e;case br:T=NF;break e;case Z2:return H2;case Fte:default:return ro}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||d!==e.avail_out&&n.mode<br&&(n.mode<I2||t!==iF))&&VF(e,e.output,e.next_out,d-e.avail_out)?(n.mode=Z2,H2):(f-=e.avail_in,d-=e.avail_out,e.total_in+=f,e.total_out+=d,n.total+=d,n.wrap&&d&&(e.adler=n.check=n.flags?Bo(n.check,r,d,e.next_out-d):W2(n.check,r,d,e.next_out-d)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Ma?128:0)+(n.mode===xg||n.mode===F2?256:0),(f===0&&d===0||t===iF)&&T===Mc&&(T=jte),T)}function Ute(e){if(!e||!e.state)return ro;var t=e.state;return t.window&&(t.window=null),e.state=null,Mc}function Cte(e,t){var n;return!e||!e.state||(n=e.state,(n.wrap&2)===0)?ro:(n.head=t,t.done=!1,Mc)}function Jte(e,t){var n=t.length,i,r,o;return!e||!e.state||(i=e.state,i.wrap!==0&&i.mode!==kg)?ro:i.mode===kg&&(r=1,r=W2(r,t,n,0),r!==i.check)?NF:(o=VF(e,t,n,n),o?(i.mode=Z2,H2):(i.havedict=1,Mc))}yo.inflateReset=FF;yo.inflateReset2=IF;yo.inflateResetKeep=jF;yo.inflateInit=Zte;yo.inflateInit2=EF;yo.inflate=qte;yo.inflateEnd=Ute;yo.inflateGetHeader=Cte;yo.inflateSetDictionary=Jte;yo.inflateInfo="pako inflate (from Nodeca project)"});var D2=ot((pye,HF)=>{"use strict";HF.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var DF=ot((hye,ZF)=>{"use strict";function Kte(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}ZF.exports=Kte});var UF=ot(Rm=>{"use strict";var Ru=WF(),Lm=Ta(),Sg=z2(),Tr=D2(),q2=fg(),Gte=O2(),Ate=DF(),qF=Object.prototype.toString;function Lc(e){if(!(this instanceof Lc))return new Lc(e);this.options=Lm.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gte,this.strm.avail_out=0;var n=Ru.inflateInit2(this.strm,t.windowBits);if(n!==Tr.Z_OK)throw new Error(q2[n]);if(this.header=new Ate,Ru.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Sg.string2buf(t.dictionary):qF.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ru.inflateSetDictionary(this.strm,t.dictionary),n!==Tr.Z_OK)))throw new Error(q2[n])}Lc.prototype.push=function(e,t){var n=this.strm,i=this.options.chunkSize,r=this.options.dictionary,o,a,s,c,l,u=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?Tr.Z_FINISH:Tr.Z_NO_FLUSH,typeof e=="string"?n.input=Sg.binstring2buf(e):qF.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new Lm.Buf8(i),n.next_out=0,n.avail_out=i),o=Ru.inflate(n,Tr.Z_NO_FLUSH),o===Tr.Z_NEED_DICT&&r&&(o=Ru.inflateSetDictionary(this.strm,r)),o===Tr.Z_BUF_ERROR&&u===!0&&(o=Tr.Z_OK,u=!1),o!==Tr.Z_STREAM_END&&o!==Tr.Z_OK)return this.onEnd(o),this.ended=!0,!1;n.next_out&&(n.avail_out===0||o===Tr.Z_STREAM_END||n.avail_in===0&&(a===Tr.Z_FINISH||a===Tr.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=Sg.utf8border(n.output,n.next_out),c=n.next_out-s,l=Sg.buf2string(n.output,s),n.next_out=c,n.avail_out=i-c,c&&Lm.arraySet(n.output,n.output,s,c,0),this.onData(l)):this.onData(Lm.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&o!==Tr.Z_STREAM_END);return o===Tr.Z_STREAM_END&&(a=Tr.Z_FINISH),a===Tr.Z_FINISH?(o=Ru.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===Tr.Z_OK):(a===Tr.Z_SYNC_FLUSH&&(this.onEnd(Tr.Z_OK),n.avail_out=0),!0)};Lc.prototype.onData=function(e){this.chunks.push(e)};Lc.prototype.onEnd=function(e){e===Tr.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Lm.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function U2(e,t){var n=new Lc(t);if(n.push(e,!0),n.err)throw n.msg||q2[n.err];return n.result}function Bte(e,t){return t=t||{},t.raw=!0,U2(e,t)}Rm.Inflate=Lc;Rm.inflate=U2;Rm.inflateRaw=Bte;Rm.ungzip=U2});var KF=ot((gye,JF)=>{"use strict";var Yte=Ta().assign,Qte=Aj(),_te=UF(),$te=D2(),CF={};Yte(CF,Qte,_te,$te);JF.exports=CF});var AF=ot(zg=>{"use strict";var ene=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",tne=KF(),GF=wr(),Tg=Ki(),nne=ene?"uint8array":"array";zg.magic="\b\0";function Rc(e,t){Tg.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}GF.inherits(Rc,Tg);Rc.prototype.processChunk=function(e){this.meta=e.meta,this._pako===null&&this._createPako(),this._pako.push(GF.transformTo(nne,e.data),!1)};Rc.prototype.flush=function(){Tg.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)};Rc.prototype.cleanUp=function(){Tg.prototype.cleanUp.call(this),this._pako=null};Rc.prototype._createPako=function(){this._pako=new tne[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}};zg.compressWorker=function(e){return new Rc("Deflate",e)};zg.uncompressWorker=function(){return new Rc("Inflate",{})}});var J2=ot(C2=>{"use strict";var BF=Ki();C2.STORE={magic:"\0\0",compressWorker:function(){return new BF("STORE compression")},uncompressWorker:function(){return new BF("STORE decompression")}};C2.DEFLATE=AF()});var K2=ot(Nc=>{"use strict";Nc.LOCAL_FILE_HEADER="PK";Nc.CENTRAL_FILE_HEADER="PK";Nc.CENTRAL_DIRECTORY_END="PK";Nc.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07";Nc.ZIP64_CENTRAL_DIRECTORY_END="PK";Nc.DATA_DESCRIPTOR="PK\x07\b"});var $F=ot((xye,_F)=>{"use strict";var Nu=wr(),Xu=Ki(),G2=yu(),YF=ag(),Og=K2(),sr=function(e,t){var n="",i;for(i=0;i<t;i++)n+=String.fromCharCode(e&255),e=e>>>8;return n},rne=function(e,t){var n=e;return e||(n=t?16893:33204),(n&65535)<<16},ine=function(e){return(e||0)&63},QF=function(e,t,n,i,r,o){var a=e.file,s=e.compression,c=o!==G2.utf8encode,l=Nu.transformTo("string",o(a.name)),u=Nu.transformTo("string",G2.utf8encode(a.name)),f=a.comment,d=Nu.transformTo("string",o(f)),m=Nu.transformTo("string",G2.utf8encode(f)),p=u.length!==a.name.length,h=m.length!==f.length,b,v,g="",y="",w="",x=a.dir,O=a.date,P={crc32:0,compressedSize:0,uncompressedSize:0};(!t||n)&&(P.crc32=e.crc32,P.compressedSize=e.compressedSize,P.uncompressedSize=e.uncompressedSize);var T=0;t&&(T|=8),!c&&(p||h)&&(T|=2048);var S=0,k=0;x&&(S|=16),r==="UNIX"?(k=798,S|=rne(a.unixPermissions,x)):(k=20,S|=ine(a.dosPermissions,x)),b=O.getUTCHours(),b=b<<6,b=b|O.getUTCMinutes(),b=b<<5,b=b|O.getUTCSeconds()/2,v=O.getUTCFullYear()-1980,v=v<<4,v=v|O.getUTCMonth()+1,v=v<<5,v=v|O.getUTCDate(),p&&(y=sr(1,1)+sr(YF(l),4)+u,g+="up"+sr(y.length,2)+y),h&&(w=sr(1,1)+sr(YF(d),4)+m,g+="uc"+sr(w.length,2)+w);var L="";L+=`
4
- \0`,L+=sr(T,2),L+=s.magic,L+=sr(b,2),L+=sr(v,2),L+=sr(P.crc32,4),L+=sr(P.compressedSize,4),L+=sr(P.uncompressedSize,4),L+=sr(l.length,2),L+=sr(g.length,2);var z=Og.LOCAL_FILE_HEADER+L+l+g,X=Og.CENTRAL_FILE_HEADER+sr(k,2)+L+sr(d.length,2)+"\0\0\0\0"+sr(S,4)+sr(i,4)+l+g+d;return{fileRecord:z,dirRecord:X}},one=function(e,t,n,i,r){var o="",a=Nu.transformTo("string",r(i));return o=Og.CENTRAL_DIRECTORY_END+"\0\0\0\0"+sr(e,2)+sr(e,2)+sr(t,4)+sr(n,4)+sr(a.length,2)+a,o},ane=function(e){var t="";return t=Og.DATA_DESCRIPTOR+sr(e.crc32,4)+sr(e.compressedSize,4)+sr(e.uncompressedSize,4),t};function wo(e,t,n,i){Xu.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Nu.inherits(wo,Xu);wo.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,Xu.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))};wo.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=QF(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0};wo.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=QF(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:ane(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null};wo.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n=this.bytesWritten-e,i=one(this.dirRecords.length,n,e,this.zipComment,this.encodeFileName);this.push({data:i,meta:{percent:100}})};wo.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()};wo.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(n){t.processChunk(n)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(n){t.error(n)}),this};wo.prototype.resume=function(){if(!Xu.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};wo.prototype.error=function(e){var t=this._sources;if(!Xu.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch{}return!0};wo.prototype.lock=function(){Xu.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()};_F.exports=wo});var tI=ot(eI=>{"use strict";var sne=J2(),cne=$F(),lne=function(e,t){var n=e||t,i=sne[n];if(!i)throw new Error(n+" is not a valid compression method !");return i};eI.generateWorker=function(e,t,n){var i=new cne(t.streamFiles,n,t.platform,t.encodeFileName),r=0;try{e.forEach(function(o,a){r++;var s=lne(a.options.compression,t.compression),c=a.options.compressionOptions||t.compressionOptions||{},l=a.dir,u=a.date;a._compressWorker(s,c).withStreamInfo("file",{name:o,dir:l,date:u,comment:a.comment||"",unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions}).pipe(i)}),i.entriesCount=r}catch(o){i.error(o)}return i}});var rI=ot((kye,nI)=>{"use strict";var une=wr(),Mg=Ki();function Nm(e,t){Mg.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}une.inherits(Nm,Mg);Nm.prototype._bindStream=function(e){var t=this;this._stream=e,e.pause(),e.on("data",function(n){t.push({data:n,meta:{percent:0}})}).on("error",function(n){t.isPaused?this.generatedError=n:t.error(n)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})};Nm.prototype.pause=function(){return Mg.prototype.pause.call(this)?(this._stream.pause(),!0):!1};Nm.prototype.resume=function(){return Mg.prototype.resume.call(this)?(this._upstreamEnded?this.end():this._stream.resume(),!0):!1};nI.exports=Nm});var mI=ot((Sye,dI)=>{"use strict";var fne=yu(),Xm=wr(),sI=Ki(),dne=_S(),cI=$S(),iI=sg(),mne=oj(),pne=tI(),oI=sm(),hne=rI(),lI=function(e,t,n){var i=Xm.getTypeOf(t),r,o=Xm.extend(n||{},cI);o.date=o.date||new Date,o.compression!==null&&(o.compression=o.compression.toUpperCase()),typeof o.unixPermissions=="string"&&(o.unixPermissions=parseInt(o.unixPermissions,8)),o.unixPermissions&&o.unixPermissions&16384&&(o.dir=!0),o.dosPermissions&&o.dosPermissions&16&&(o.dir=!0),o.dir&&(e=uI(e)),o.createFolders&&(r=bne(e))&&fI.call(this,r,!0);var a=i==="string"&&o.binary===!1&&o.base64===!1;(!n||typeof n.binary>"u")&&(o.binary=!a);var s=t instanceof iI&&t.uncompressedSize===0;(s||o.dir||!t||t.length===0)&&(o.base64=!1,o.binary=!0,t="",o.compression="STORE",i="string");var c=null;t instanceof iI||t instanceof sI?c=t:oI.isNode&&oI.isStream(t)?c=new hne(e,t):c=Xm.prepareContent(e,t,o.binary,o.optimizedBinaryString,o.base64);var l=new mne(e,c,o);this.files[e]=l},bne=function(e){e.slice(-1)==="/"&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return t>0?e.substring(0,t):""},uI=function(e){return e.slice(-1)!=="/"&&(e+="/"),e},fI=function(e,t){return t=typeof t<"u"?t:cI.createFolders,e=uI(e),this.files[e]||lI.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function aI(e){return Object.prototype.toString.call(e)==="[object RegExp]"}var gne={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,i;for(t in this.files)i=this.files[t],n=t.slice(this.root.length,t.length),n&&t.slice(0,this.root.length)===this.root&&e(n,i)},filter:function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(i)}),t},file:function(e,t,n){if(arguments.length===1)if(aI(e)){var i=e;return this.filter(function(o,a){return!a.dir&&i.test(o)})}else{var r=this.files[this.root+e];return r&&!r.dir?r:null}else e=this.root+e,lI.call(this,e,t,n);return this},folder:function(e){if(!e)return this;if(aI(e))return this.filter(function(r,o){return o.dir&&e.test(r)});var t=this.root+e,n=fI.call(this,t),i=this.clone();return i.root=n.name,i},remove:function(e){e=this.root+e;var t=this.files[e];if(t||(e.slice(-1)!=="/"&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter(function(r,o){return o.name.slice(0,e.length)===e}),i=0;i<n.length;i++)delete this.files[n[i].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,n={};try{if(n=Xm.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:fne.utf8encode}),n.type=n.type.toLowerCase(),n.compression=n.compression.toUpperCase(),n.type==="binarystring"&&(n.type="string"),!n.type)throw new Error("No output type specified.");Xm.checkSupport(n.type),(n.platform==="darwin"||n.platform==="freebsd"||n.platform==="linux"||n.platform==="sunos")&&(n.platform="UNIX"),n.platform==="win32"&&(n.platform="DOS");var i=n.comment||this.comment||"";t=pne.generateWorker(this,n,i)}catch(r){t=new sI("error"),t.error(r)}return new dne(t,n.type||"string",n.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return e=e||{},e.type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};dI.exports=gne});var A2=ot((Tye,hI)=>{"use strict";var vne=wr();function pI(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}pI.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t=0,n;for(this.checkOffset(e),n=this.index+e-1;n>=this.index;n--)t=(t<<8)+this.byteAt(n);return this.index+=e,t},readString:function(e){return vne.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC((e>>25&127)+1980,(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(e&31)<<1))}};hI.exports=pI});var B2=ot((zye,gI)=>{"use strict";var bI=A2(),yne=wr();function ju(e){bI.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=e[t]&255}yne.inherits(ju,bI);ju.prototype.byteAt=function(e){return this.data[this.zero+e]};ju.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),o=this.length-4;o>=0;--o)if(this.data[o]===t&&this.data[o+1]===n&&this.data[o+2]===i&&this.data[o+3]===r)return o-this.zero;return-1};ju.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),o=this.readData(4);return t===o[0]&&n===o[1]&&i===o[2]&&r===o[3]};ju.prototype.readData=function(e){if(this.checkOffset(e),e===0)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};gI.exports=ju});var wI=ot((Oye,yI)=>{"use strict";var vI=A2(),wne=wr();function Fu(e){vI.call(this,e)}wne.inherits(Fu,vI);Fu.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)};Fu.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero};Fu.prototype.readAndCheckSignature=function(e){var t=this.readData(4);return e===t};Fu.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};yI.exports=Fu});var Q2=ot((Mye,PI)=>{"use strict";var xI=B2(),xne=wr();function Y2(e){xI.call(this,e)}xne.inherits(Y2,xI);Y2.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};PI.exports=Y2});var TI=ot((Lye,SI)=>{"use strict";var kI=Q2(),Pne=wr();function _2(e){kI.call(this,e)}Pne.inherits(_2,kI);_2.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};SI.exports=_2});var $2=ot((Rye,OI)=>{"use strict";var Lg=wr(),zI=ka(),kne=B2(),Sne=wI(),Tne=TI(),zne=Q2();OI.exports=function(e){var t=Lg.getTypeOf(e);return Lg.checkSupport(t),t==="string"&&!zI.uint8array?new Sne(e):t==="nodebuffer"?new Tne(e):zI.uint8array?new zne(Lg.transformTo("uint8array",e)):new kne(Lg.transformTo("array",e))}});var NI=ot((Nye,RI)=>{"use strict";var e4=$2(),ys=wr(),One=sg(),MI=ag(),Rg=yu(),Ng=J2(),Mne=ka(),Lne=0,Rne=3,Nne=function(e){for(var t in Ng)if(Object.prototype.hasOwnProperty.call(Ng,t)&&Ng[t].magic===e)return Ng[t];return null};function LI(e,t){this.options=e,this.loadOptions=t}LI.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(t=Nne(this.compressionMethod),t===null)throw new Error("Corrupted zip : compression "+ys.pretty(this.compressionMethod)+" unknown (inner file : "+ys.transformTo("string",this.fileName)+")");this.decompressed=new One(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),e===Lne&&(this.dosPermissions=this.externalFileAttributes&63),e===Rne&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=e4(this.extraFields[1].value);this.uncompressedSize===ys.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===ys.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===ys.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===ys.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t=e.index+this.extraFieldsLength,n,i,r;for(this.extraFields||(this.extraFields={});e.index+4<t;)n=e.readInt(2),i=e.readInt(2),r=e.readData(i),this.extraFields[n]={id:n,length:i,value:r};e.setIndex(t)},handleUTF8:function(){var e=Mne.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=Rg.utf8decode(this.fileName),this.fileCommentStr=Rg.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(t!==null)this.fileNameStr=t;else{var n=ys.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(n)}var i=this.findExtraFieldUnicodeComment();if(i!==null)this.fileCommentStr=i;else{var r=ys.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(r)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=e4(e.value);return t.readInt(1)!==1||MI(this.fileName)!==t.readInt(4)?null:Rg.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=e4(e.value);return t.readInt(1)!==1||MI(this.fileComment)!==t.readInt(4)?null:Rg.utf8decode(t.readData(e.length-5))}return null}};RI.exports=LI});var FI=ot((Xye,jI)=>{"use strict";var Xne=$2(),La=wr(),xo=K2(),jne=NI(),Fne=ka();function XI(e){this.files=[],this.loadOptions=e}XI.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+La.pretty(t)+", expected "+La.pretty(e)+")")}},isSignature:function(e,t){var n=this.reader.index;this.reader.setIndex(e);var i=this.reader.readString(4),r=i===t;return this.reader.setIndex(n),r},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=Fne.uint8array?"uint8array":"array",n=La.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e=this.zip64EndOfCentralSize-44,t=0,n,i,r;t<e;)n=this.reader.readInt(2),i=this.reader.readInt(4),r=this.reader.readData(i),this.zip64ExtensibleData[n]={id:n,length:i,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(xo.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(xo.CENTRAL_FILE_HEADER);)e=new jne({zip64:this.zip64},this.loadOptions),e.readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(xo.CENTRAL_DIRECTORY_END);if(e<0){var t=!this.isSignature(0,xo.LOCAL_FILE_HEADER);throw t?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(e);var n=e;if(this.checkSignature(xo.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===La.MAX_VALUE_16BITS||this.diskWithCentralDirStart===La.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===La.MAX_VALUE_16BITS||this.centralDirRecords===La.MAX_VALUE_16BITS||this.centralDirSize===La.MAX_VALUE_32BITS||this.centralDirOffset===La.MAX_VALUE_32BITS){if(this.zip64=!0,e=this.reader.lastIndexOfSignature(xo.ZIP64_CENTRAL_DIRECTORY_LOCATOR),e<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(xo.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,xo.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(xo.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(xo.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var r=n-i;if(r>0)this.isSignature(n,xo.CENTRAL_FILE_HEADER)||(this.reader.zero=r);else if(r<0)throw new Error("Corrupted zip: missing "+Math.abs(r)+" bytes.")},prepareReader:function(e){this.reader=Xne(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};jI.exports=XI});var VI=ot((jye,EI)=>{"use strict";var t4=wr(),Xg=bu(),Ine=yu(),Ene=FI(),Vne=n2(),II=sm();function Wne(e){return new Xg.Promise(function(t,n){var i=e.decompressed.getContentWorker().pipe(new Vne);i.on("error",function(r){n(r)}).on("end",function(){i.streamInfo.crc32!==e.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}EI.exports=function(e,t){var n=this;return t=t4.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:Ine.utf8decode}),II.isNode&&II.isStream(e)?Xg.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):t4.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(i){var r=new Ene(t);return r.load(i),r}).then(function(r){var o=[Xg.Promise.resolve(r)],a=r.files;if(t.checkCRC32)for(var s=0;s<a.length;s++)o.push(Wne(a[s]));return Xg.Promise.all(o)}).then(function(r){for(var o=r.shift(),a=o.files,s=0;s<a.length;s++){var c=a[s],l=c.fileNameStr,u=t4.resolve(c.fileNameStr);n.file(u,c.decompressed,{binary:!0,optimizedBinaryString:!0,date:c.date,dir:c.dir,comment:c.fileCommentStr.length?c.fileCommentStr:null,unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions,createFolders:t.createFolders}),c.dir||(n.file(u).unsafeOriginalName=l)}return o.zipComment.length&&(n.comment=o.zipComment),n})}});var n4=ot((Fye,WI)=>{"use strict";function io(){if(!(this instanceof io))return new io;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new io;for(var t in this)typeof this[t]!="function"&&(e[t]=this[t]);return e}}io.prototype=mI();io.prototype.loadAsync=VI();io.support=ka();io.defaults=$S();io.version="3.10.1";io.loadAsync=function(e,t){return new io().loadAsync(e,t)};io.external=bu();WI.exports=io});var Te=class extends Error{constructor(n,i,r){super(i);this.code=n;this.data=r;this.name="ConformError"}};function ut(e,t){return{content:[{type:"text",text:e}],...t?{structuredContent:{ok:!0,...t}}:{}}}var Vn=e=>ut(e);function Ge(e){let t=e instanceof Te?e:CD(e);return{content:[{type:"text",text:`error [${t.code}]: ${t.message}`}],structuredContent:{ok:!1,code:t.code,message:t.message,...t.data?{data:t.data}:{}},isError:!0}}function CD(e){let t=e instanceof Error?e.message:String(e);return/unknown session_id|not found on this machine|No such file|NotFound/i.test(t)?new Te("not_found",t):/unsupported|not supported|no local decoder|cannot detect/i.test(t)?new Te("unsupported",t):/before the file start|past the last frame|is before|required|unknown (operation|target|verb)/i.test(t)?new Te("invalid_args",t):/could not read|failed to parse|engine read failed/i.test(t)?new Te("unreadable",t):/refused|coverage|never shipped/i.test(t)?new Te("refused",t):/abort|cancel/i.test(t)?new Te("cancelled",t):new Te("engine",t)}function Jle(e,t){let[n,...i]=t.content,r=`[conformtools ${e}]`;return{...t,content:n?[{...n,text:`${r} ${n.text}`},...i]:[{type:"text",text:r}]}}var JD={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function Un(){let e=Rt("CONFORM_ENV")==="staging"?"staging":"production",t=JD[e];return{env:e,supabaseUrl:Rt("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:Rt("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:Rt("CONFORM_APP_BASE")??t.appBase}}var KD=600*1e3,YT=72*3600*1e3,GD=300*1e3,xf=()=>Q(vt(),Un().env==="production"?"auth.json":`auth-${Un().env}.json`);async function _T(){for(let e of new Set([xf(),Q(vt(),"auth.json")]))try{let t=JSON.parse(await yn(e));if(t.env===Un().env&&t.access_token)return t}catch{}return null}async function ay(e){await bt(vt()),await rn(xf(),JSON.stringify(e)),await Xo(xf(),384)}async function $T(e){if(e.expires_at-60>Date.now()/1e3)return e.access_token;let t=Un();try{let n=await fetch(`${t.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token})});if(!n.ok)return n.status===400||n.status===401?"":null;let i=await n.json();return e.access_token=i.access_token,i.refresh_token&&(e.refresh_token=i.refresh_token),e.expires_at=i.expires_at??Math.floor(Date.now()/1e3)+(i.expires_in??3600),await ay(e),e.access_token}catch{return null}}async function uo(){let e=await _T();return e&&await $T(e)||null}var el=null;function QT(e,t){return{signed_in:!0,entitled:e.entitled,env:Un().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"}}}async function tl(e={}){if(!e.force&&el&&Date.now()-el.at<KD)return{...el.status,source:"cache"};let t=Un(),n=await _T();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in"};let i=await $T(n);if(i==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(i)try{let r=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement`,{headers:{authorization:`Bearer ${i}`,apikey:t.anonKey}});if(r.status===401||r.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r.ok){let o=(await r.json()).data;n.last_entitlement=o,n.last_entitlement_at=Date.now(),await ay(n);let a=QT(o,"live");return el={at:Date.now(),status:a},a}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<YT){let r=YT-(Date.now()-n.last_entitlement_at);return{...QT(n.last_entitlement,"grace"),grace_remaining_h:Math.round(r/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}function Op(e){let t=Un();if(!e.signed_in)return`not signed in (${t.env}). Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled)return`${n}
5
- no active plan: the trial has ended and there is no subscription. Choose a plan at ${t.appBase}/pricing, then run account_status.`;let i=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:`subscribed${e.tier?` (${e.tier})`:""}`;return`${n}
6
- ${i}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}var AD=()=>tl();async function e7(){let e=await AD();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new Te(t,Op(e),{account:e})}var wf=null;function t7(e={}){if(wf)return wf;let t=Un(),n=crypto.randomUUID().replaceAll("-","");return wf=new Promise((i,r)=>{let o=!1,a=l=>{o||(o=!0,clearTimeout(c),setTimeout(()=>s.close(),250),wf=null,l())},s=UT({hostname:"127.0.0.1",port:0,onListen:async l=>{let u=`${t.appBase}/plugin-auth?client=engine&port=${l}&state=${n}`,f=await qT(u);e.onUrl?.(u,f)}},async l=>{let u=new URL(l.url);if(u.pathname!=="/callback")return new Response("not found",{status:404});let f=u.searchParams,d=f.get("access_token")??"",m=f.get("refresh_token")??"",p=!!d&&!!m&&f.get("state")===n;if(p){let h=Number(f.get("expires_at"));await ay({env:t.env,access_token:d,refresh_token:m,expires_at:h>0?h:Math.floor(Date.now()/1e3)+3600}),el=null,tl({force:!0}).then(b=>a(()=>i(b)),b=>a(()=>r(b)))}return new Response(BD(p),{status:p?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),c=setTimeout(()=>a(()=>r(new Te("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??GD)}),wf}async function n7(){el=null,await jn(xf())&&await Vr(xf());let e=Q(vt(),"auth.json");try{JSON.parse(await yn(e)).env===Un().env&&await Vr(e)}catch{}}function BD(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}function Qt(e,t,n=!1){if(!t||t<=0||!Number.isFinite(e))return String(e);let i=Math.round(t),r=Math.round(e);if(n&&(i===30||i===60)){let u=i===30?2:4,f=i*600-u*9,d=Math.floor(r/f),m=r%f;r+=u*9*d,m>u&&(r+=u*Math.floor((m-u)/(i*60-u)))}let o=r%i,a=Math.floor(r/i)%60,s=Math.floor(r/(i*60))%60,c=Math.floor(r/(i*3600)),l=u=>String(u).padStart(2,"0");return`${l(c)}:${l(s)}:${l(a)}${n?";":":"}${l(o)}`}function Cn(e,t){let n=e.trim().match(/^(\d+)[:;.](\d+)[:;.](\d+)([:;.])(\d+)$/);if(!n||!t)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=Math.round(t),c=(i*3600+r*60+o)*s+a;if(n[4]===";"&&(s===30||s===60)){let l=s===30?2:4,u=i*60+r;c-=l*(u-Math.floor(u/10))}return c}function Yr(e,t,n){if(typeof e=="number")return e;if(/^\d+$/.test(e.trim()))return parseInt(e,10);let i=Cn(e,t);if(i==null)throw new Error(`cannot parse timecode '${e}' at ${t} fps`);let r=n?Cn(n,t)??0:0;return i-r}async function Is(e,t,n,i={}){if(typeof VideoDecoder>"u")throw new Error("this browser has no VideoDecoder (WebCodecs) \u2014 H.264/HEVC needs Chrome/Edge/Safari 16+");let r={fileSize:e.size,read:async(m,p)=>new Uint8Array(await e.slice(m,m+p).arrayBuffer())},o=await wT(r),a=NT(o);if(!a)throw new Error("no H.264/HEVC decoder configuration found in this file");let s={codec:a.codec,description:a.description,hardwareAcceleration:"prefer-hardware"};if(!(await VideoDecoder.isConfigSupported(s).catch(()=>null))?.supported){if(!(await VideoDecoder.isConfigSupported({codec:a.codec,description:a.description}).catch(()=>null))?.supported)throw new Error(`this browser can't decode ${a.codec} \u2014 try a ProRes or H.264 export`);delete s.hardwareAcceleration}let l=a.decodeToPres.length||t.length,u=null,f=new VideoDecoder({output:m=>{try{n(m,Number(m.timestamp))}catch(p){u=u??(p instanceof Error?p:new Error(String(p)))}finally{m.close()}},error:m=>{u=m instanceof Error?m:new Error(String(m))}});f.configure(s);let d=[];for(let m=0;m<a.keyframes.length;m++){let p=a.keyframes[m],h=m+1<a.keyframes.length?a.keyframes[m+1]:t.length;h>p&&d.push([p,h])}try{for(let[m,p]of d){if(u||i.signal?.aborted)break;if(i.wantPres){let g=!1;for(let y=m;y<p&&!g;y++)g=i.wantPres.has(a.decodeToPres[y]);if(!g)continue}let h=1/0,b=0;for(let g=m;g<p;g++)h=Math.min(h,t[g].offset),b=Math.max(b,t[g].offset+t[g].size);let v=new Uint8Array(await e.slice(h,b).arrayBuffer());for(let g=m;g<p;g++){let y=t[g];f.decode(new EncodedVideoChunk({type:g===m?"key":"delta",timestamp:a.decodeToPres[g],data:v.subarray(y.offset-h,y.offset-h+y.size)}))}await f.flush()}}finally{try{f.close()}catch{}}if(u)throw u;if(i.signal?.aborted)throw new DOMException("aborted","AbortError");return l}var r7=new Set(["I420","I420A","I422","I444","NV12"]),YD=new Set(["I420P10","I420P12","I422P10","I422P12","I444P10","I444P12","I420AP10","I422AP10","I444AP10"]);async function QD(e){let t=e.visibleRect??{x:0,y:0,width:e.codedWidth,height:e.codedHeight},n=t.width,i=t.height,r=e.format??"";if(r7.has(r)||YD.has(r)){let l=new Uint8Array(e.allocationSize({rect:t})),u=await e.copyTo(l,{rect:t}),{offset:f,stride:d}=u[0],m=new Uint8Array(n*i);if(r7.has(r))for(let p=0;p<i;p++)m.set(l.subarray(f+p*d,f+p*d+n),p*n);else{let p=r.includes("P12")?4:2,h=new DataView(l.buffer,l.byteOffset,l.byteLength);for(let b=0;b<i;b++)for(let v=0;v<n;v++)m[b*n+v]=Math.min(255,h.getUint16(f+b*d+v*2,!0)>>p)}return{y:m,w:n,h:i}}let a=new OffscreenCanvas(n,i).getContext("2d",{willReadFrequently:!0});if(!a)return null;a.drawImage(e,0,0,n,i);let s=a.getImageData(0,0,n,i).data,c=new Uint8Array(n*i);for(let l=0,u=0;l<c.length;l++,u+=4)c[l]=s[u]*77+s[u+1]*150+s[u+2]*29>>8;return{y:c,w:n,h:i}}var i7=async(e,t,n)=>{let i=t.index;if(!i||i.kind!=="h264"&&i.kind!=="hevc")return null;let r=[];await Is(e,i.offs,(o,a)=>{a===n&&r.push(o.clone())},{wantPres:new Set([n])});try{return r.length?await QD(r[0]):null}finally{for(let o of r)o.close()}},Mp=i7;function o7(e){Mp=e}function a7(){return Mp===i7?null:Mp}function s7(e,t,n){return Mp(e,t,n)}function c7(e){let t=js(e);return t==="prores"||t==="h264"||t==="hevc"?t:"other"}var _D={prores:"ProRes",h264:"H.264",hevc:"HEVC",r3d:"R3D",arriraw:"ARRIRAW",xocn:"X-OCN",vc3:"DNxHR",braw:"BRAW",proresraw:"ProRes RAW",other:"unsupported"};function jo(e){return _D[e]??"unsupported"}function sy(e,t,n=.1){return e==null||t==null?!1:Math.abs(e-t)>n}function Lp(e){return e==null?"?":Number.isInteger(e)?String(e):String(Math.round(e*1e3)/1e3)}function $D(e){let t=JSON.parse(e),n=t.frames??[],i=n.length>>1,r=new Array(i);for(let o=0,a=0;a<i;o+=2,a++)r[a]={offset:n[o],size:n[o+1]};return{offs:r,codec:t.codec,kind:c7(t.codec),w:t.width,h:t.height,fps:t.fps??null,startFrame:t.start_frame??0,dropFrame:t.drop_frame??!1}}async function cy(e){await oi();let n=await pT((i,r)=>e.slice(i,i+r).arrayBuffer().then(o=>new Uint8Array(o)),e.size,"mov");return $D(n)}var ly=!1;function u7(e){ly=e}var Fo=8,f7=0,eq=3,Rp=2;async function tq(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=a=>String.fromCharCode(t[a],t[a+1],t[a+2],t[a+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let i=t[0]<<24|t[1]<<16|t[2]<<8|t[3],r=n(4);return/^[A-Za-z0-9 ]{4}$/.test(r)&&(i>=8||i===1)&&i<=e.size?"isobmff":null}function nq(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function rq(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function l7(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function wn(e){await oi();let t=await tq(e),n=[];if(t==="r3d"){let i=async(s,c,l)=>new Uint8Array(await e.slice(c,Math.min(c+l,e.size)).arrayBuffer()),r=JSON.stringify([{name:e.name,size:e.size}]),o=JSON.parse(await fT(i,r)),a=JSON.parse(await cT(i,r));return/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:a.map(s=>({offset:s.essenceOffset,size:s.essenceLength})),w:o.width??0,h:o.height??0,fps:l7(o),startFrame:o.timecode?.start_frame??0,dropFrame:o.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:f7},geometrySpec:{codec:"r3d",subbands:eq},index:null,warnings:n}}if(t==="mxf"){let i=rq(e),r=JSON.parse(await uT(i,e.size));if(!r)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await lT(i,e.size)),a=[];for(let m=0;m<o.frame_count;m++)a.push({offset:o.frames[m*2],size:o.frames[m*2+1]});let s=a.filter(m=>m.size===0).length;s&&n.push(`${s} frame(s) had no locatable picture KLV`);let c=r.width??0,l=r.height??0,u=(r.inner_codec??"").toLowerCase(),f=null,d="MXF";return u==="arriraw"?(f={codec:"arriraw",w:c,h:l,scale:Fo},d="ARRIRAW"):u==="xocn"?(f={codec:"xocn",scale:Fo,...ly?{display:"rec709"}:{}},d="X-OCN"):await sT(i,e.size)?(f={codec:"vc3",scale:Fo},d="DNxHR"):await aT(i,e.size)?(f={codec:"prores"},d="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:f?a:[],w:c,h:l,fps:l7(r),startFrame:r.timecode?.start_frame??0,dropFrame:r.timecode?.drop_frame??!1,label:d,spec:f,geometrySpec:f&&f.codec==="arriraw"?{...f,scale:Rp}:f&&f.codec==="xocn"?{codec:"xocn",scale:Rp,...ly?{display:"rec709"}:{}}:f&&f.codec==="vc3"?{codec:"vc3",scale:Rp}:null,index:null,warnings:n}}if(t==="isobmff"){let i=await cy(e),r=nq(e.name);if(i.kind==="prores")return{frames:i.offs,w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:jo(i.kind),spec:{codec:"prores"},geometrySpec:null,index:i,warnings:n};if(i.kind==="h264"||i.kind==="hevc")return{frames:i.offs,w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:jo(i.kind),spec:null,geometrySpec:null,index:i,warnings:n};let o=r==="braw"?{codec:"braw",scale:Fo}:i.codec==="aprh"||i.codec==="aprn"?{codec:"proresraw",scale:Fo}:null;return o||n.push(`codec ${i.codec} not wired to the fingerprint pool`),{frames:o?i.offs:[],w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:o?r==="braw"?"BRAW":"ProRes RAW":`unsupported (${i.codec})`,spec:o,geometrySpec:o?{...o,scale:Rp}:null,index:i,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}function uy(e,t,n){switch(e){case"prores":return{codec:"prores"};case"r3d":return{codec:"r3d",subbands:f7};case"arriraw":return{codec:"arriraw",w:t,h:n,scale:Fo};case"xocn":return{codec:"xocn",scale:Fo};case"vc3":return{codec:"vc3",scale:Fo};case"braw":return{codec:"braw",scale:Fo};case"proresraw":return{codec:"proresraw",scale:Fo};default:return null}}function Pf(){return _c({module_or_path:gT})}function fy(e){let t=new DataView(e.buffer,e.byteOffset,8);return{w:t.getUint32(0,!0),h:t.getUint32(4,!0)}}function dy(e){let t=Y8(e),{w:n,h:i}=fy(t),r=new Int32Array(n*i),o=new DataView(t.buffer,t.byteOffset+8,n*i*4);for(let a=0;a<n*i;a++)r[a]=o.getInt32(a*4,!0);return{y:r,w:n,h:i}}function d7(e){let t=pp(e),{w:n,h:i}=fy(t),r=new Uint16Array(n*i),o=new DataView(t.buffer,t.byteOffset+8,n*i*2);for(let a=0;a<n*i;a++)r[a]=o.getUint16(a*2,!0);return{y:r,width:n,height:i}}function m7(e){let t=B8(e),{w:n,h:i}=fy(t);return{rgba:new Uint8ClampedArray(t.buffer,t.byteOffset+8,n*i*4).slice(),width:n,height:i}}function nl(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0,!0),i=t.getUint32(4,!0),r=n*i;if(e.byteLength<8+r*4)throw new Error(`decoded frame short: ${e.byteLength} B for ${n}x${i}`);let o=new Uint8Array(r);for(let a=0,s=8;a<r;a++,s+=4)o[a]=54*e[s]+183*e[s+1]+19*e[s+2]+128>>8;return{y:o,w:n,h:i}}function Es(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),i=n.getUint32(0,!0),r=n.getUint32(4,!0),o=i*r;if(e.byteLength<8+o*2)throw new Error(`decoded luma short: ${e.byteLength} B for ${i}x${r}`);let a=new Uint16Array(o);for(let s=0,c=8;s<o;s++,c+=2)a[s]=n.getUint16(c,!0);return{y:a,w:i,h:r,peak:t}}function g7(e,t){switch(t.codec){case"prores":return Es(pp(e),1023);case"r3d":return Es(Q8(e),255);case"arriraw":return Es(D8(e,t.w,t.h),255);case"xocn":return Es(nT(e),255);case"vc3":return Es($8(e),255);case"braw":return Es(U8(e),4095);case"proresraw":return Es(G8(e),255)}}var p7={gpu:0,wasm:0};var my=null;function oq(){return my||(my=!!0||typeof navigator>"u"||!("gpu"in navigator)?Promise.resolve(null):import("./prores-BR2YURFP.js").catch(()=>null)),my}function aq(e,t,n,i){if(i===t&&e.length===t*n)return e;let r=new Uint16Array(t*n);for(let o=0;o<n;o++)r.set(e.subarray(o*i,o*i+t),o*t);return r}async function sq(e){try{let t=await oq();if(!t||!await t.proresGpuAvailable())return null;let n=await t.decodeProResFrameGpu(e);return n?{y:aq(n.y,n.width,n.height,n.strideY),w:n.width,h:n.height,peak:1023}:null}catch{return null}}async function cq(e,t){if(t.codec==="prores"){let n=await sq(e);if(n)return p7.gpu++,n;p7.wasm++}return g7(e,t)}function v7(e){let t=e.y.length,n=new Uint8Array(t);if(e.peak===255){for(let r=0;r<t;r++)n[r]=e.y[r]>255?255:e.y[r];return n}let i=255/e.peak;for(let r=0;r<t;r++){let o=Math.round(e.y[r]*i);n[r]=o>255?255:o}return n}var py=null;function hy(e){py=e}async function Np(e,t,n,i,r="coarse"){return py?py(e,t,n,i,r):ia(await Da(e,t,n,i,r),i,r)}function ia(e,t,n="coarse"){if(n==="exact"){let i=g7(e,t);return{y:v7(i),w:i.w,h:i.h}}if(n==="index"&&t.codec==="prores"){let i=dy(e),r=e.length>20?e[18]<<8|e[19]:0,o=r>0?Math.min(i.h,Math.max(1,Math.round(r/8))):i.h,a=new Uint8Array(i.w*o);for(let s=0;s<a.length;s++)a[s]=Math.max(0,Math.min(255,Math.round(i.y[s]/128+128)));return{y:a,w:i.w,h:o}}if(n==="index"&&t.codec==="xocn"){let i=tT(e),r=new DataView(i.buffer,i.byteOffset,i.byteLength),o=r.getUint32(0,!0),a=r.getUint32(4,!0);return{y:i.subarray(8,8+o*a),w:o,h:a}}switch(t.codec){case"prores":{let i=dy(e);return{y:i.y,w:i.w,h:i.h}}case"r3d":return nl(_8(e,t.subbands));case"arriraw":return nl(q8(e,t.w,t.h,t.scale));case"xocn":return nl(t.display==="rec709"?iT(e):rT(e,t.scale));case"vc3":return nl(eT(e,t.scale));case"braw":return nl(C8(e,t.scale));case"proresraw":return nl(A8(e,t.scale))}}var h7=512*1024,b7=160*1024;async function Da(e,t,n,i,r="coarse"){let o=async a=>new Uint8Array(await e.slice(t,t+a).arrayBuffer());if(r==="index"&&i?.codec==="xocn"&&n>b7){let a=await o(b7),s=hT(a.subarray(0,128));if(s>0&&s<=n)return s<=a.length?a.subarray(0,s):await o(s)}if(r!=="exact"&&i?.codec==="xocn"&&n>h7){let a=await o(h7),s=bT(a.subarray(0,128));if(s>0&&s<=n)return s<=a.length?a.subarray(0,s):await o(s)}return await o(n)}async function y7(e,t,n="coarse"){if(n!=="exact")return ia(e,t,n);let i=await cq(e,t);return{y:v7(i),w:i.w,h:i.h}}var Xp=32,w7=8,xue=(()=>{let e=new Float64Array(w7*Xp);for(let t=0;t<w7;t++)for(let n=0;n<Xp;n++)e[t*Xp+n]=Math.cos((2*n+1)*t*Math.PI/(2*Xp));return e})();function lq(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,Math.imul(e,16843009)>>>24}var Bn=64,x7=(()=>{let e=new Float64Array(16*Bn);for(let t=0;t<16;t++)for(let n=0;n<Bn;n++)e[t*Bn+n]=Math.cos(Math.PI*(t+1)*(2*n+1)/(2*Bn));return e})();function mn(e,t){let n=0;for(let i=0;i<8;i++)n+=lq((e.bits[i]^t.bits[i])>>>0);return n}var Yn=72;function Lr(e,t,n){let i=new Float64Array(Bn*Bn),r=t/Bn,o=n/Bn;for(let m=0;m<Bn;m++)for(let p=0;p<Bn;p++){let h=0,b=0,v=p*r|0,g=(p+1)*r|0,y=m*o|0,w=(m+1)*o|0;for(let x=y;x<w;x++){let O=x*t;for(let P=v;P<g;P++)h+=e[O+P],b++}i[m*Bn+p]=b?h/b:0}let a=new Float64Array(16*Bn);for(let m=0;m<16;m++)for(let p=0;p<Bn;p++){let h=0;for(let b=0;b<Bn;b++)h+=x7[m*Bn+b]*i[b*Bn+p];a[m*Bn+p]=h}let s=new Float64Array(256);for(let m=0;m<16;m++)for(let p=0;p<16;p++){let h=0;for(let b=0;b<Bn;b++)h+=a[m*Bn+b]*x7[p*Bn+b];s[m*16+p]=h}let c=Array.from(s).sort((m,p)=>m-p),l=(c[127]+c[128])/2,u=new Uint32Array(8);for(let m=0;m<256;m++)s[m]>l&&(u[m>>5]|=1<<(m&31));let f=0;for(let m=0;m<Bn;m++)for(let p=0;p<Bn-1;p++)f+=Math.abs(i[m*Bn+p+1]-i[m*Bn+p]);let d=0;for(let m=0;m<Bn*Bn;m++)d+=i[m];return{bits:u,quality:f,meanY:d/(Bn*Bn)}}var P7=3,uq=2,k7=48,fq=12,dq=28,mq=16,S7=6,pq=2,hq=32;function T7(e,t,n,i,r=0,o){let a=new Uint8Array(t),s=P=>{if(!i)return 0;let T=0;for(let S=0;S<P.count;S++)T+=i(P.aStart+S,P.bStart+S);return T},c=[],l=(P,T)=>P.count!==T.count?P.count>T.count:P.td!==T.td?P.td<T.td:P.bStart<T.bStart,u=P=>{let T={...P,td:s(P)};c.push(T);let S=c.length-1;for(;S>0;){let k=S-1>>1;if(l(c[S],c[k]))[c[S],c[k]]=[c[k],c[S]],S=k;else break}},f=()=>{if(c.length===0)return;let P=c[0],T=c.pop();if(c.length){c[0]=T;let S=0;for(;;){let k=2*S+1,L=k+1,z=S;if(k<c.length&&l(c[k],c[z])&&(z=k),L<c.length&&l(c[L],c[z])&&(z=L),z===S)break;[c[S],c[z]]=[c[z],c[S]],S=z}}return P};for(let P of n)u(P);let d=[];for(let P=f();P;P=f()){let T=-1,S=!0,k=[];for(let L=0;L<=P.count;L++)L<P.count&&!a[P.bStart+L]?T<0&&(T=L):(L<P.count&&(S=!1),T>=0&&(k.push({aStart:P.aStart+T,bStart:P.bStart+T,count:L-T}),T=-1));if(S){for(let L=0;L<P.count;L++)a[P.bStart+L]=1;d.push({aStart:P.aStart,bStart:P.bStart,count:P.count})}else for(let L of k)u(L)}d.sort((P,T)=>P.bStart-T.bStart),i&&bq(e,t,d,i,r,o);let m=[],p=0,h=-1;for(let P of d)P.bStart>p&&m.push({op:"insert",bStart:p,count:P.bStart-p}),m.push({op:P.aStart<h?"move":"equal",aStart:P.aStart,bStart:P.bStart,count:P.count}),h=P.aStart+P.count,p=P.bStart+P.count;p<t&&m.push({op:"insert",bStart:p,count:t-p});let b=new Uint8Array(e);for(let P of d)for(let T=0;T<P.count;T++)b[P.aStart+T]=1;let v=-1,g=0;for(let P=0;P<e;P++)b[P]?g>0&&(m.push({op:"delete",aStart:v,count:g}),g=0):(g===0&&(v=P),g++);g>0&&m.push({op:"delete",aStart:v,count:g});let y=0,w=0,x=0,O=0;for(let P of m)P.op==="equal"?y+=P.count:P.op==="insert"?w+=P.count:P.op==="delete"?x+=P.count:O+=P.count;return{ops:m,equalFrames:y,insertedFrames:w,deletedFrames:x,movedFrames:O,identical:w===0&&x===0&&O===0}}function bq(e,t,n,i,r,o){let a=(m,p)=>{let h=0;for(let b=0;b<m.count;b++)h+=i(m.bStart+b+p,m.bStart+b);return h},s=m=>m.aStart-m.bStart,c=Math.max(1,uq*r),l=[];for(let m=0;m<n.length;m++){let p=n[m],h=s(p),b=new Set([h]);for(let z=1;z<=P7;z++)b.add(h-z),b.add(h+z);n[m-1]&&b.add(s(n[m-1])),n[m+1]&&b.add(s(n[m+1]));let v=[...b],g=v.length,y=p.count,w=2147483647,x=(z,X)=>{let V=p.bStart+z+v[X];return V>=0&&V<e?i(V,p.bStart+z):w},O=new Float64Array(g),P=new Float64Array(g),T=new Uint8Array(g*y);for(let z=0;z<g;z++)O[z]=x(0,z);for(let z=1;z<y;z++){let X=0;for(let V=1;V<g;V++)O[V]<O[X]&&(X=V);for(let V=0;V<g;V++){let R=O[V],j=O[X]+c;R<=j?(P[V]=R+x(z,V),T[V*y+z]=V):(P[V]=j+x(z,V),T[V*y+z]=X)}[O,P]=[P,O]}let S=0;for(let z=1;z<g;z++)O[z]<O[S]&&(S=z);let k=new Uint8Array(y);k[y-1]=S;for(let z=y-1;z>0;z--)k[z-1]=T[k[z]*y+z];let L=0;for(let z=1;z<=y;z++)(z===y||v[k[z]]!==v[k[L]])&&(l.push({aStart:p.bStart+L+v[k[L]],bStart:p.bStart+L,count:z-L}),L=z)}n.length=0,n.push(...l),n.sort((m,p)=>m.bStart-p.bStart);for(let m=0;m<n.length;m++){let p=n[m];if(p.count>k7)continue;let h=s(p),b=h,v=a(p,h);for(let g of[n[m-1],n[m+1]]){if(!g)continue;let y=s(g);if(y===h||p.bStart+y<0||p.bStart+p.count+y>e)continue;let w=a(p,y);w<v&&(v=w,b=y)}b!==h&&(p.aStart=p.bStart+b)}for(let m=n.length-1;m>=0;m--){let p=n[m];if(p.count>pq)continue;let h=s(p),b=y=>!!y&&Math.abs(s(y)-h)<=P7;if(b(n[m-1])||b(n[m+1]))continue;let v=0,g=0;for(let y=0;y<p.count;y++){let w=p.aStart+y,x=p.bStart+y;o&&(o.a[w]||o.b[x])||(v++,g+=i(w,x))}(v===0||g/v>hq)&&n.splice(m,1)}let u=r+mq,f=(m,p,h,b)=>{let v=m,g=p;if(h){let y=s(h),w=0;for(;w<S7&&v<g&&v+y>=0&&v+y<e&&i(v+y,v)<=u;)h.count++,v++,w++}if(b){let y=s(b),w=0;for(;w<S7&&g>v&&g-1+y>=0&&g-1+y<e&&i(g-1+y,g-1)<=u;)b.aStart--,b.bStart--,b.count++,g--,w++}};n.length&&f(0,n[0].bStart,void 0,n[0]);for(let m=0;m+1<n.length;m++)f(n[m].bStart+n[m].count,n[m+1].bStart,n[m],n[m+1]);if(n.length){let m=n[n.length-1];f(m.bStart+m.count,t,m,void 0)}let d=r+dq;for(let m=0;m+1<n.length;m++){let p=n[m],h=n[m+1],b=s(p);if(s(h)!==b||h.bStart-(p.bStart+p.count)>fq)continue;let g=!0;for(let y=p.bStart+p.count;y<h.bStart;y++)if(y+b<0||y+b>=e||i(y+b,y)>d){g=!1;break}g&&(p.count=h.bStart+h.count-p.bStart,n.splice(m+1,1),m--)}for(let m=0;m+1<n.length;m++){let p=n[m],h=n[m+1];if(p.bStart+p.count!==h.bStart||Math.min(p.count,h.count)>k7)continue;let b=p.bStart,v=h.bStart+h.count,g=!1;for(let y of[s(p),s(h)]){if(b+y<0||v+y>e)continue;let w=!0;for(let x=b;x<v;x++)if(i(x+y,x)>r){w=!1;break}if(w){p.aStart=b+y,p.count=v-b,n.splice(m+1,1),g=!0;break}}g&&m--}}function gq(e,t,n){let i=[];for(let r=-(e-1);r<=t-1;r++){let o=0,a=-1,s=Math.max(0,-r),c=Math.min(e,t-r);for(let l=s;l<c;l++)n(l,l+r)?(o===0&&(a=l),o++):(o>0&&i.push({aStart:a,bStart:a+r,count:o}),o=0);o>0&&i.push({aStart:a,bStart:a+r,count:o})}return i}var vq=4e6,z7=16,yq=256,O7=512;function M7(e,t){let n=e.bits[t>>1]>>>0;return t&1?n>>>16&65535:n&65535}function wq(e,t,n,i,r,o){let a=e.length,s=t.length,c=new Map;for(let m=0;m<s;m++){if(r?.b[m])continue;let p=t[m];for(let h=0;h<z7;h++){let b=h*65536+M7(p,h),v=c.get(b);v||(v=[],c.set(b,v)),v.push(m)}}let l=new Map,u=new Int32Array(s).fill(-1);for(let m=0;m<a;m++){if(r?.a[m])continue;let p=e[m],h=0;for(let b=0;b<z7&&h<O7;b++){let v=c.get(b*65536+M7(p,b));if(!(!v||v.length>yq)){for(let g of v)if(u[g]!==m){if(u[g]=m,++h>O7)break;if(o?o(m,g):mn(p,t[g])<=n){let y=g-m,w=l.get(y);w||(w=[],l.set(y,w)),w.push(m)}}}}}let f=i??((m,p)=>mn(e[m],t[p])),d=[];for(let[m,p]of l){p.sort((b,v)=>b-v);let h=-1;for(let b of p){if(b<=h)continue;let v=b,g=b;for(;v-1>h&&v-1+m>=0&&f(v-1,v-1+m)<=n;)v--;for(;g+1<a&&g+1+m<s&&f(g+1,g+1+m)<=n;)g++;d.push({aStart:v,bStart:v+m,count:g-v+1}),h=g}}return d}var L7=.0015,R7=.03,xq=32,Pq=.1;function N7(e){if(e.length===0)return 0;let t=[...e].sort((n,i)=>n-i);return t[t.length>>1]}function X7(e,t,n=Yn,i){let r=e.length,o=t.length,a,s,c,l=()=>!1;if(i?.flatGate&&r>0&&o>0){let h=N7(e.map(w=>w.quality)),b=N7(t.map(w=>w.quality));a={a:new Uint8Array(r),b:new Uint8Array(o)},s=new Uint8Array(r),c=new Uint8Array(o);for(let w=0;w<r;w++)a.a[w]=e[w].quality<L7*h?1:0,s[w]=e[w].quality<R7*h?1:0;for(let w=0;w<o;w++)a.b[w]=t[w].quality<L7*b?1:0,c[w]=t[w].quality<R7*b?1:0;let v=(w,x)=>{let O=[];for(let S=0;S<w.length;S++)x[S]||O.push(w[S].meanY??0);if(O.length===0)return{med:0,inv:0};O.sort((S,k)=>S-k);let P=O[O.length>>1],T=Math.max(1e-9,O[Math.floor(O.length*.9)]-O[Math.floor(O.length*.1)],.05*Math.max(1,Math.abs(P)));return{med:P,inv:1/T}},g=v(e,a.a),y=v(t,a.b);l=(w,x)=>{let O=((e[w].meanY??0)-g.med)*g.inv,P=((t[x].meanY??0)-y.med)*y.inv;return Math.abs(O-P)<=Pq},(a.a.every(w=>w)||a.b.every(w=>w))&&(a=void 0,s=c=void 0)}let u=a,f=s,d=c,m=u?(h,b)=>{let v=u.a[h],g=u.b[b];return v&&g?l(h,b)?0:256:v||g?256:mn(e[h],t[b])}:(h,b)=>mn(e[h],t[b]),p=(h,b)=>u&&(u.a[h]||u.b[b])?!1:mn(e[h],t[b])<=(f&&d&&(f[h]||d[b])?xq:n);if(r===0||o===0||r*o<=vq){let h=gq(r,o,(b,v)=>m(b,v)<=n);return u&&(h=h.filter(b=>{for(let v=0;v<b.count;v++)if(p(b.aStart+v,b.bStart+v))return!0;return!1})),T7(r,o,h,m,n,a)}return T7(r,o,wq(e,t,n,m,a,p),m,n,a)}function j7(e){let t=e.ops.map(n=>n.op==="equal"?` = A[${n.aStart}..${n.aStart+n.count-1}] = B[${n.bStart}..${n.bStart+n.count-1}] (${n.count} unchanged)`:n.op==="delete"?` - A[${n.aStart}..${n.aStart+n.count-1}] removed (${n.count})`:n.op==="insert"?` + B[${n.bStart}..${n.bStart+n.count-1}] new/changed (${n.count})`:` ~ A[${n.aStart}..${n.aStart+n.count-1}] moved -> B[${n.bStart}..${n.bStart+n.count-1}] (${n.count})`);return[`${e.equalFrames} unchanged, ${e.insertedFrames} new, ${e.deletedFrames} removed, ${e.movedFrames} moved`+(e.identical?" (identical)":""),...t].join(`
7
- `)}var kf=class{constructor(t,n,i=100){this.channels=t;this.sampleRate=n;this.hz=i;this.counted=0;this.binSamples=Math.max(1,Math.round(n/i)),this.sums=new Float64Array(t),this.bins=Array.from({length:t},()=>[])}push(t){let n=this.channels,i=Math.floor(t.length/n);for(let r=0;r<i;r++){let o=r*n;for(let a=0;a<n;a++){let s=t[o+a];this.sums[a]+=s*s}++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 F7=48e3*30;function Ws(e){return(t,n)=>e.slice(t,t+n).arrayBuffer().then(i=>new Uint8Array(i))}var kq=async e=>{let t=globalThis.OfflineAudioContext;if(!t)return null;let i=await new t(1,1,48e3).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(i.length);for(let o=0;o<i.numberOfChannels;o++){let a=i.getChannelData(o);for(let s=0;s<a.length;s++)r[s]+=a[s]/i.numberOfChannels}return{sampleRate:i.sampleRate,channels:1,chunks:(async function*(){yield r})()}},I7=kq;function E7(e){I7=e}async function Sq(e){let t=await I7(e).catch(()=>null);if(!t)return null;let n=new kf(t.channels,t.sampleRate,100),i=0;for await(let r of t.chunks)n.push(r),i+=r.length/t.channels;return i?{sampleRate:t.sampleRate,channels:t.channels,sampleFrames:i,durationSec:i/t.sampleRate,envelopes:n.finish(),codec:"platform"}:null}async function jp(e){await oi();let t=Ws(e),n=await Wa(t,e.size),i=JSON.parse(n);if(!i||i.aac)return Sq(e);let r=i.sample_rate??0,o=i.channels??0,a=i.sample_frames??0;if(!r||!o||!a)return null;let s=new kf(o,r,100);for(let c=0;c<a;c+=F7){let l=Math.min(F7,a-c),u=await Ha(t,e.size,c,l);if(!u||u.length<12)break;let f=new DataView(u.buffer,u.byteOffset,u.byteLength),d=f.getUint32(8,!0),m=f.getUint32(4,!0);if(!d||!m)break;let p=u.byteOffset+12,h=p%4===0?new Float32Array(u.buffer,p,d*m):new Float32Array(u.slice(12).buffer,0,d*m);s.push(h)}return{sampleRate:r,channels:o,sampleFrames:a,durationSec:a/r,envelopes:s.finish(),codec:i.codec}}var by=10,W7=.5,zq=.5,Oq=.15;function Mq(e){let t=e.envelopes;if(t.length===0)return new Float32Array(0);if(t.length===1)return t[0];let n=Math.max(...t.map(r=>r.length)),i=new Float32Array(n);for(let r of t)for(let o=0;o<r.length;o++)r[o]>i[o]&&(i[o]=r[o]);return i}function gy(e,t){if(!e||!t)return null;let n=Mq(e);return n.length?{curve:n,fps:t}:null}function Lq(e,t,n,i,r,o=Math.round(W7*100)){let a=Math.max(0,-t,-i),s=t+a,c=i+a,l=Math.min(r-a,e.length-s,n.length-c);if(l<o)return null;let u=0,f=0;for(let g=0;g<l;g++)u+=e[s+g],f+=n[c+g];let d=u/l,m=f/l,p=0,h=0,b=0;for(let g=0;g<l;g++){let y=e[s+g]-d,w=n[c+g]-m;p+=y*w,h+=y*y,b+=w*w}if(h<=0||b<=0)return null;let v=p/Math.sqrt(h*b);return Number.isFinite(v)?v:null}function Rq(e,t,n){let i=0,r=Math.min(e.length,t+n);for(let o=Math.max(0,t);o<r;o++)e[o]>i&&(i=e[o]);return i}var V7=(e,t)=>Math.round(e/t*100);function H7(e,t,n={}){let i=n.decides??zq,r=n.margin??Oq,o=Math.round((n.minSpanSec??W7)*100),a=y=>t.map(()=>({score:null,outcome:"abstained",reason:y}));if(!e)return a("the reference carries no audio we can read");if(t.length<2)return a("nothing to arbitrate");let s=Math.max(...t.map(y=>y.refStart)),l=Math.min(...t.map(y=>y.refEnd))-s+1,u=V7(s,e.fps),f=V7(l,e.fps);if(f<o)return a(`disputed span is ${(l/e.fps).toFixed(2)}s \u2014 too short to decide by sound`);if(Rq(e.curve,u,f)<1e-4)return a("the reference is silent across this span");let d=t.map(y=>{if(!y.track)return null;let w=y.srcStart/y.track.fps+(s-y.refStart)/e.fps;return Lq(e.curve,u,y.track.curve,Math.round(w*100),f,o)}),m=d.filter(y=>y!==null);if(m.length<2)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:m.length===0?"no contender's audio could be scored across this span":"only one contender has readable audio \u2014 nothing to compare it against"}));let p=[...m].sort((y,w)=>w-y),h=p[0],b=p[1];if(h<i)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:`best correlation ${h.toFixed(2)} is below ${i} \u2014 none of these sound like the reference here`}));if(h-b<r)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:`${h.toFixed(2)} vs ${b.toFixed(2)} \u2014 an audio tie as well as a picture tie`}));let v=d.findIndex(y=>y===h),g=t[v].label;return t.map((y,w)=>({score:d[w],outcome:w===v?"won":"rejected",preferredLabel:g}))}var Nq=.5;function Xq(e,t){let n=Math.max(e.refStart,t.refStart),r=Math.min(e.refEnd,t.refEnd)-n+1;if(r<=0)return!1;let o=Math.min(e.refEnd-e.refStart+1,t.refEnd-t.refStart+1);return r/o>=Nq}function Z7(e,t=by){let n=e.length,i=Array.from({length:n},(s,c)=>c),r=s=>{for(;i[s]!==s;)i[s]=i[i[s]],s=i[s];return s},o=!1;for(let s=0;s<n;s++)for(let c=s+1;c<n;c++){let l=e[s],u=e[c];l.clipLabel!==u.clipLabel&&(l.score==null||u.score==null||Math.abs(l.score-u.score)>t||Xq(l,u)&&(i[r(s)]=r(c),o=!0))}if(!o)return[];let a=new Map;for(let s=0;s<n;s++){let c=r(s),l=a.get(c);l?l.push(e[s]):a.set(c,[e[s]])}return[...a.values()].filter(s=>s.length>1)}var D7=240;function q7(e,t,n,i=D7){let r=Math.max(1,Math.ceil(Math.max(t,n)/i));if(r===1)return{w:t,h:n,rgba:e};let o=Math.max(1,Math.floor(t/r)),a=Math.max(1,Math.floor(n/r)),s=new Uint8ClampedArray(o*a*4);for(let c=0,l=0;c<a;c++){let u=c*r*t;for(let f=0;f<o;f++,l+=4){let d=(u+f*r)*4;s[l]=e[d],s[l+1]=e[d+1],s[l+2]=e[d+2],s[l+3]=255}}return{w:o,h:a,rgba:s}}async function jq(e,t,n,i){await Pf();let r=new Map;for(let o of n){let a=t.offs[o];if(!a)continue;let s=new Uint8Array(await e.slice(a.offset,a.offset+a.size).arrayBuffer()),c=m7(s),l=q7(c.rgba,c.width,c.height,i);r.set(o,{frame:o,...l})}return r}async function Fq(e,t,n,i){let r=new Set(n),o=new Map,a=null,s=null;return await Is(e,t.offs,(c,l)=>{if(!r.has(l))return;let u=c.visibleRect,f=u?u.width:c.codedWidth,d=u?u.height:c.codedHeight,m=Math.min(1,i/Math.max(f,d)),p=Math.max(1,Math.round(f*m)),h=Math.max(1,Math.round(d*m));(!a||a.width!==p||a.height!==h)&&(a=new OffscreenCanvas(p,h),s=a.getContext("2d",{willReadFrequently:!0})),s&&(s.drawImage(c,0,0,p,h),o.set(l,{frame:l,w:p,h,rgba:s.getImageData(0,0,p,h).data}))},{wantPres:r}),o}async function Iq(e,t,n,i){let r=uy(t.kind,t.w,t.h),o=new Map;if(!r)return o;await Pf();for(let a of n){let s=t.offs[a];if(s)try{let c=new Uint8Array(await e.slice(s.offset,s.offset+s.size).arrayBuffer()),l=ia(c,r),u=1/0,f=-1/0;for(let h=0;h<l.y.length;h++){let b=l.y[h];b<u&&(u=b),b>f&&(f=b)}let d=f>u?f-u:1,m=new Uint8ClampedArray(l.w*l.h*4);for(let h=0,b=0;h<l.y.length;h++,b+=4){let v=(l.y[h]-u)/d*255;m[b]=v,m[b+1]=v,m[b+2]=v,m[b+3]=255}let p=q7(m,l.w,l.h,i);o.set(a,{frame:a,...p})}catch{}}return o}async function U7(e,t,n,i=D7){if(n.length===0)return new Map;if(t.kind==="prores")return jq(e,t,n,i);if(t.kind==="h264"||t.kind==="hevc")return Fq(e,t,n,i);if(uy(t.kind,t.w,t.h))return Iq(e,t,n,i);throw new Error(`unsupported codec "${t.codec}" for frame thumbnails`)}function Fp(e,t,n,i=255){let r=e instanceof Int32Array?-13110.4:i*.1,o=Math.floor(n*.45),a=Math.floor(t*.45),s=m=>{let p=0,h=m*t;for(let b=0;b<t;b++)e[h+b]<=r&&p++;return p>=t*.95},c=m=>{let p=0;for(let h=0;h<n;h++)e[h*t+m]<=r&&p++;return p>=n*.95},l=0;for(;l<o&&s(l);)l++;let u=0;for(;u<o&&s(n-1-u);)u++;let f=0;for(;f<a&&c(f);)f++;let d=0;for(;d<a&&c(t-1-d);)d++;return{top:l,bottom:u,left:f,right:d}}function rl(e,t=255){if(e.length===0)return null;let{w:n,h:i}=e[0];return vy(e.map(r=>Fp(r.luma,r.w,r.h,t)),n,i)}function vy(e,t,n){if(e.length===0)return null;let i=(l,u)=>{let f=Math.floor(u*.02),d=e.filter(m=>m[l]>f);return d.length<e.length*.8?0:Math.min(...d.map(m=>m[l]))},r=i("top",n),o=i("bottom",n),a=i("left",t),s=i("right",t);if(r+o+a+s===0)return null;let c={x:a,y:r,w:t-a-s,h:n-r-o};return c.w<t*.3||c.h<n*.3?null:c}function qa(e,t,n,i=255){let r=Fp(e,t,n,i),o=Math.floor(n*.02),a=Math.floor(t*.02),s=r.top>o?r.top:0,c=r.bottom>o?r.bottom:0,l=r.left>a?r.left:0,u=r.right>a?r.right:0;if(s+c+l+u===0)return null;let f={x:l,y:s,w:t-l-u,h:n-s-c};return f.w<t*.3||f.h<n*.3?null:f}function Ua(e,t,n,i){let r=i&&i.length>=n.w*n.h?i:new Float64Array(n.w*n.h);for(let o=0;o<n.h;o++){let a=(n.y+o)*t+n.x,s=o*n.w;for(let c=0;c<n.w;c++)r[s+c]=e[a+c]}return r}function Ca(e,t=16){if(e<=0)return[];let n=Math.min(t,e);if(n===1)return[e>>1];let i=[];for(let r=0;r<n;r++)i.push(Math.min(e-1,Math.floor((r+.5)*e/n)));return[...new Set(i)]}function Ip(e,t,n){return{x0:e.x/t,y0:e.y/n,x1:(e.x+e.w)/t,y1:(e.y+e.h)/n}}function C7(e,t,n){let i=Math.max(0,Math.min(t-1,Math.round(e.x0*t))),r=Math.max(0,Math.min(n-1,Math.round(e.y0*n))),o=Math.max(i+1,Math.min(t,Math.round(e.x1*t))),a=Math.max(r+1,Math.min(n,Math.round(e.y1*n))),s={x:i,y:r,w:o-i,h:a-r};return s.w<8||s.h<8||s.w===t&&s.h===n?null:s}function J7(e,t,n){if(!e)return null;let i=Math.round(e.y),r=Math.round(n-e.h-e.y),o=Math.round(e.x),a=Math.round(t-e.w-e.x),s=[];return(i||r)&&s.push(`letterboxed ${i===r?`${i} px top and bottom`:`${i} px top, ${r} px bottom`}`),(o||a)&&s.push(`pillarboxed ${o===a?`${o} px each side`:`${o} px left, ${a} px right`}`),s.length?s.join(", "):null}var Eq=256,Vq=120;async function K7(e,t,n={}){let i=[],r=0,o=null,a=null,s=await Is(e,t,(u,f)=>{let d=u.visibleRect,m=d?.width??u.codedWidth,p=d?.height??u.codedHeight,h=n.crop==="per-frame"?void 0:n.crop,b=(d?.x??0)+(h?h.x0*m:0),v=(d?.y??0)+(h?h.y0*p:0),g=h?Math.max(1,Math.round((h.x1-h.x0)*m)):m,y=h?Math.max(1,Math.round((h.y1-h.y0)*p)):p,w=Math.min(1,Eq/Math.max(g,y)),x=Math.max(1,Math.round(g*w)),O=Math.max(1,Math.round(y*w));if((!o||o.width!==x||o.height!==O)&&(o=new OffscreenCanvas(x,O),a=o.getContext("2d",{willReadFrequently:!0})),a){a.drawImage(u,b,v,g,y,0,0,x,O);let P=a.getImageData(0,0,x,O),T=P.data,S=new Float64Array(x*O);for(let L=0,z=0;L<S.length;L++,z+=4)S[L]=.2126*T[z]+.7152*T[z+1]+.0722*T[z+2];if(f>=0){let L=n.crop==="per-frame"?qa(S,x,O):null;i[f]=L?Lr(Ua(S,x,L),L.w,L.h):Lr(S,x,O)}let k=typeof performance<"u"?performance.now():Date.now();n.onThumb&&k-r>Vq&&(r=k,n.onThumb({idx:f,w:x,h:O,rgba:P.data}))}n.onTick?.()},{signal:n.signal}),c={bits:new Uint32Array(8),quality:0},l=new Array(s);for(let u=0;u<s;u++)l[u]=i[u]??c;return l}function Wq(e,t,n,i,r,o,a={codec:"prores"}){let s=Math.max(1,Math.min(navigator.hardwareConcurrency||4,16)),c=t.map((f,d)=>({idx:d,offset:f.offset,size:f.size})),l=new Array(t.length),u=Array.from({length:s},()=>[]);return c.forEach((f,d)=>u[d%s].push(f)),new Promise((f,d)=>{let m=s,p=[],h=()=>{for(let v of p)v.terminate();r?.removeEventListener("abort",b)};function b(){h(),d(new DOMException("aborted","AbortError"))}if(r?.aborted){b();return}r?.addEventListener("abort",b,{once:!0});for(let v=0;v<s;v++){if(u[v].length===0){m--;continue}let g=new Worker(new URL("./workers/qc-worker.ts",import.meta.url),{type:"module"});p.push(g),g.onmessage=y=>{let w=y.data;if(w.progress)for(let x=0;x<w.progress;x++)n();if(w.thumb&&i&&i(w.thumb),w.results){for(let x of w.results)l[x.idx]={bits:Uint32Array.from(x.bits),quality:x.q??0,meanY:x.my};--m===0&&(h(),f(l))}},g.onerror=y=>{h(),d(new Error(`worker error: ${y.message}`))},g.postMessage({file:e,jobs:u[v],crop:o,spec:a})}m===0&&(h(),f(l))})}async function Hq(e,t){try{let n=Ca(t.offs.length,12);if(n.length===0)return;let i=await U7(e,t,n,320),r=[];for(let a of i.values()){let s=new Uint8Array(a.w*a.h);for(let c=0,l=0;c<s.length;c++,l+=4)s[c]=a.rgba[l]*77+a.rgba[l+1]*150+a.rgba[l+2]*29>>8;r.push({luma:s,w:a.w,h:a.h})}if(r.length===0)return;let o=rl(r);return o?Ip(o,r[0].w,r[0].h):void 0}catch{return}}function Zq(e){return{codec:e.codec,kind:e.kind,label:jo(e.kind),w:e.w,h:e.h,fps:e.fps,frames:e.offs.length,startFrame:e.startFrame,dropFrame:e.dropFrame}}async function A7(e,t={}){if(!(e instanceof File))throw new Error("fingerprintFile expects a File input");let n=await wn(e),i={offs:n.frames,codec:n.index?.codec??n.label,kind:n.spec?Dq(n.spec):n.index?.kind??"other",w:n.w,h:n.h,fps:n.fps,startFrame:n.startFrame,dropFrame:n.dropFrame};if(!n.spec&&!n.index)throw new Error(`${e.name}: ${n.warnings[0]??"no decoder for this clip"} \u2014 QC handles ProRes / H.264 / HEVC in .mov/.mp4 and R3D / ARRIRAW / X-OCN / BRAW / ProRes RAW camera originals`);let r=Math.max(1,Math.floor(t.stride??1)),o=r===1?i.offs:i.offs.filter((f,d)=>d%r===0),a=o.length,s=0,c=()=>t.onProgress?.(++s,a),l=t.matte==="cut"?"per-frame":n.spec===null||n.spec.codec==="prores"?await Hq(e,i):void 0,u=n.spec?await Wq(e,o,c,G7(t),t.signal,l,n.spec):await K7(e,o,{onTick:c,onThumb:G7(t),signal:t.signal,crop:l});return{meta:Zq(i),index:i,pdq:u,matte:l==="per-frame"?void 0:l,stride:r}}function Dq(e){return e?e.codec:"other"}function G7(e){let t=e.side??"A",n=e.onThumb;return n?i=>n({side:t,...i}):void 0}function Ep(e,t){if(e.stride!==t.stride)throw new Error(`fingerprint stride mismatch: reference ${e.stride}, candidate ${t.stride} \u2014 both sides of a comparison must be sampled on the same grid`);let n=qq(e.meta.fps,t.meta.fps),i=n===1?t.pdq:Uq(t.pdq,n),r=X7(e.pdq,i,Yn,{flatGate:!0}),o=[];return sy(e.meta.fps,t.meta.fps)&&o.push(`${Lp(t.meta.fps)} fps against a ${Lp(e.meta.fps)} fps reference \u2014 resampled to the reference's timebase for matching, and its source in/out points are converted back to its own rate. Verify the in-points.`),{report:r,a:e.meta,b:t.meta,warnings:o,aPdq:e.pdq,bPdq:i,rateScale:n}}function qq(e,t){return!e||!t||e<=0||t<=0||Math.abs(e-t)<.001?1:t/e}function Uq(e,t){if(!Number.isFinite(t)||t<=0||t===1)return e;let n=[],i=Math.ceil(e.length/t);for(let r=0;r<i;r++){let o=Math.min(e.length-1,Math.round(r*t));n.push(e[o])}return n}var Sf=8;function Y7(e,t){return async n=>{let i=t.frames[n];if(!i||!t.spec)return null;try{let r=await Da(e,i.offset,i.size,t.spec),o=ia(r,t.spec);return Lr(o.y,o.w,o.h)}catch{return null}}}function B7(e){let t=new Map;return n=>{let i=t.get(n);return i||(i=e(n),t.set(n,i)),i}}async function Cq(e,t,n,i){let{stride:r,threshold:o,refFrames:a,srcFrames:s}=i,c=e.srcStart-e.refStart,l=async m=>{let p=m+c;if(m<0||m>=a||p<0||p>=s)return!1;let[h,b]=await Promise.all([t(m),n(p)]);return!!h&&!!b&&mn(h,b)<=o},u=e.refStart;for(let m=1;m<=r&&await l(e.refStart-m);m++)u=e.refStart-m;let f=e.refStart+e.count-1,d=f;for(let m=1;m<=r&&await l(f+m);m++)d=f+m;return{refStart:u,srcStart:u+c,count:d-u+1}}async function Q7(e,t,n,i){if(i.stride<=1||e.length===0)return e;let r=B7(t),o=B7(n),a=[];for(let s of e)a.push(await Cq(s,r,o,i));return a}function il(e,t){let n=Math.round(e);return t&&(n===30||n===60)}var _7=e=>e===60?4:2;function Vp(e,t){let n=e.match(/^(\d+):(\d+):(\d+)([:;])(\d+)$/);if(!n)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=n[4]===";",c=Math.round(t)||24,l=(i*3600+r*60+o)*c+a;if(il(t,s)){let u=_7(c),f=i*60+r;l-=u*(f-Math.floor(f/10))}return{frames:l,drop:s}}function Li(e,t,n=!1){let i=Math.round(t)||24,r=Math.max(0,Math.round(e)),o=il(t,n),a=o?";":":";if(o){let d=_7(i),m=i*60-d,p=i*600-d*9,h=Math.floor(r/p),b=r%p;r+=b>d?d*9*h+d*Math.floor((b-d)/m):d*9*h}let s=r%i,c=Math.floor(r/i)%60,l=Math.floor(r/(i*60))%60,u=Math.floor(r/(i*3600))%24,f=d=>String(d).padStart(2,"0");return`${f(u)}:${f(l)}:${f(c)}${a}${f(s)}`}var Jq=typeof process<"u"&&!!process.env?.CONFORM_PROFILE,yy=new Map;async function Qn(e,t){if(!Jq)return t();let n=performance.now();try{return await t()}finally{let i=yy.get(e)??{n:0,ms:0};i.n++,i.ms+=performance.now()-n,yy.set(e,i)}}function $7(){return[...yy].sort((e,t)=>t[1].ms-e[1].ms).map(([e,t])=>`[profile] ${e.padEnd(22)} ${String(t.n).padStart(7)} \xD7 ${(t.ms/t.n).toFixed(1).padStart(7)} ms = ${(t.ms/1e3).toFixed(1).padStart(7)} s`).join(`
8
- `)}var Kq=1/0;var Gq=256;function Aq(e){let[t,n,i,r,o,a,s,c,l]=e,u=t*(o*l-a*c)-n*(r*l-a*s)+i*(r*c-o*s);return u?[(o*l-a*c)/u,(i*c-n*l)/u,(n*a-i*o)/u,(a*s-r*l)/u,(t*l-i*s)/u,(i*r-t*a)/u,(r*c-o*s)/u,(n*s-t*c)/u,(t*o-n*r)/u]:[1,0,0,0,1,0,0,0,1]}function Bq(e,t,n,i,r,o,a){let s=Aq(a),c=Math.max(1,Math.round(Math.max(r,o)/Gq)),l=[],u=[],f=0;for(let b=0;b<o;b+=c)for(let v=0;v<r;v+=c){f++;let g=s[6]*v+s[7]*b+s[8];if(!g)continue;let y=(s[0]*v+s[1]*b+s[2])/g,w=(s[3]*v+s[4]*b+s[5])/g;y<0||w<0||y>t-1||w>n-1||(l.push(e[Math.round(w)*t+Math.round(y)]),u.push(i[b*r+v]))}if(l.length<f*.2)return 1/0;let d=b=>{let v=0;for(let y of b)v+=y;v/=b.length;let g=0;for(let y of b)g+=(y-v)**2;return{m:v,s:Math.sqrt(g/b.length)||1}},m=d(l),p=d(u),h=0;for(let b=0;b<l.length;b++)h+=Math.abs((l[b]-m.m)/m.s-(u[b]-p.m)/p.s);return h/l.length*42}var wy=null;function ez(e){wy=e}async function Qr(e,t,n,i,r,o,a={}){let{maxResidual:s=Kq,...c}=a,l;return wy?l=await Qn("orb",()=>wy(e,t,n,i,r,o,JSON.stringify(c))):(await _c(),l=JSON.parse(dT(e,t,n,i,r,o,JSON.stringify(c)))),Object.assign(l,{srcW:t,srcH:n,refW:r,refH:o}),l.ok&&(l.residual=Bq(e,t,n,i,r,o,l.transform),(!Number.isFinite(l.residual)||l.residual>s)&&(l.ok=!1,l.residualRejected=!0)),l}function ol(e,t,n,i){if(!n||!i||!(e>0)||!(t>0))return{w:e,h:t};let r=Math.min(e/n,t/i);return{w:n*r,h:i*r}}function Wp(e){let t=e.filter(a=>a.reframe!==null);if(e.length===0||t.length<2||t.length/e.length<.5)return{kind:"unresolved",keyframes:[],label:"unresolved \u2014 reframe not recoverable"};let n=a=>{let s=t.map(a);return Math.max(...s)-Math.min(...s)};if(!(n(a=>a.reframe.scale)>.05||n(a=>a.reframe.dxCenter)>12||n(a=>a.reframe.dyCenter)>12||n(a=>a.reframe.rotationDeg)>1)){let a=t[t.length>>1];return{kind:"static",keyframes:[a],label:a.reframe.label}}let r=t[0].reframe,o=t[t.length-1].reframe;return{kind:"animated",keyframes:t,label:`animated \xB7 ${r.label} \u2192 ${o.label}`}}var Yq=.04,Qq=.02;function tz(e){let t=e.length;if(t<2)return{slope:1,percent:100,kind:"normal",samples:t,residual:0};let n=0,i=0;for(let d of e)n+=d.refStart,i+=d.srcStart;let r=n/t,o=i/t,a=0,s=0;for(let d of e){let m=d.refStart-r;a+=m*(d.srcStart-o),s+=m*m}if(s<=1e-9)return{slope:1,percent:100,kind:"normal",samples:t,residual:0};let c=a/s,l=o-c*r,u=0;for(let d of e)u+=Math.abs(d.srcStart-(c*d.refStart+l));let f=Math.abs(c)<Qq?"freeze":Math.abs(c-1)>Yq?"retime":"normal";return{slope:c,percent:c*100,kind:f,samples:t,residual:u/t}}function nz(e,t){let n=c=>c.score==null?1/0:c.score,i=t.flatMap(c=>c.shots.map(l=>({...l,clipLabel:c.label}))).filter(c=>c.audio?.outcome!=="rejected").filter(c=>!(c.track.kind==="unresolved"&&c.score!=null&&c.score>_q)).sort((c,l)=>n(c)-n(l)||l.refEnd-l.refStart-(c.refEnd-c.refStart)||c.refStart-l.refStart||(c.clipLabel<l.clipLabel?-1:c.clipLabel>l.clipLabel?1:0)),r=t.flatMap(c=>c.shots.map(l=>({...l,clipLabel:c.label}))),o=new Int32Array(Math.max(0,e)).fill(-1);i.forEach((c,l)=>{for(let u=Math.max(0,c.refStart);u<=Math.min(e-1,c.refEnd);u++)o[u]<0&&(o[u]=l)});let a=[],s=(c,l)=>{let u=a[a.length-1];u?.kind==="gap"&&u.refEnd===c-1?u.refEnd=l:a.push({refStart:c,refEnd:l,kind:"gap"})};for(let c=0;c<e;){let l=o[c],u=c;for(;u+1<e&&o[u+1]===l;)u++;if(l<0){s(c,u),c=u+1;continue}let f=i[l],d=c!==f.refStart||u!==f.refEnd;if(d&&u-c+1<$q){s(c,u),c=u+1;continue}let m=f.refEnd>f.refStart?(f.srcEnd-f.srcStart)/(f.refEnd-f.refStart):1;a.push({refStart:c,refEnd:u,kind:f.track.kind,clipLabel:f.clipLabel,srcStart:d?Math.round(f.srcStart+(c-f.refStart)*m):f.srcStart,srcEnd:d?Math.round(f.srcStart+(u-f.refStart)*m):f.srcEnd,track:f.track,inPointAmbiguity:f.vote?.ambiguity,contest:eU(f,r)}),c=u+1}return a}var _q=32,$q=3;function eU(e,t){if(e.score==null)return;let n=t.filter(r=>r.clipLabel!==e.clipLabel&&r.score!=null&&r.refStart<=e.refEnd&&r.refEnd>=e.refStart&&Math.abs(r.score-e.score)<=by).sort((r,o)=>(r.score??1/0)-(o.score??1/0));if(n.length===0)return;let i=e.audio?.outcome!=null||n.some(r=>r.audio?.outcome!=null)?"audio":n.every(r=>r.score>e.score)?"score":n.some(r=>r.score===e.score&&r.refEnd-r.refStart===e.refEnd-e.refStart)?"label":"length";return{rivals:n.map(r=>({clipLabel:r.clipLabel,score:r.score})),winnerScore:e.score,settledBy:i}}function Hp(e,t){let n=[...new Set(t)].sort((r,o)=>r-o);if(n.length===0)return e;let i=[];for(let r of e){let o=n.filter(l=>l>r.refStart&&l<=r.refEnd);if(o.length===0){i.push(r);continue}let a=[r.refStart,...o,r.refEnd+1],s=r.refEnd-r.refStart,c=r.srcStart!=null&&r.srcEnd!=null&&s>0?(r.srcEnd-r.srcStart)/s:1;for(let l=0;l<a.length-1;l++){let u=a[l],f=a[l+1]-1;f<u||i.push({...r,refStart:u,refEnd:f,srcStart:r.srcStart==null?void 0:r.srcStart+Math.round((u-r.refStart)*c),srcEnd:r.srcStart==null?void 0:r.srcStart+Math.round((f-r.refStart)*c)})}}return i}var rz=180/Math.PI;function oa(e,t=2){let n=10**t;return Math.round(e*n)/n+0}function tU(e,t,n,i=t,r=n){let o=Math.min(t/i,n/r)||1,a=e[0]/o,s=e[1]/o,c=e[3]/o,l=e[4]/o,u=Math.hypot(a,c),f=a*l-s*c,d=u>1e-9?Math.abs(f/u):0,m=Math.sqrt(Math.abs(f)),p=Math.atan2(c,a)*rz,h=i/2,b=r/2,v=e[6]*h+e[7]*b+e[8],g=(e[0]*h+e[1]*b+e[2])/v,y=(e[3]*h+e[4]*b+e[5])/v,w=g-t/2,x=y-n/2,O=Math.abs(e[6])>1e-6||Math.abs(e[7])>1e-6;return{scale:oa(m,3),scaleX:oa(u,3),scaleY:oa(d,3),rotationDeg:oa(p,2),dxCenter:oa(w,1),dyCenter:oa(x,1),perspective:O,label:nU(m,p,w,x,O)}}function aa(e,t,n){return tU(e.transform,t,n,e.srcW??t,e.srcH??n)}function iz(e,t,n,i,r){let o=Math.min(i/t,r/n),a=e.rotationDeg/rz,s=Math.cos(a),c=Math.sin(a),l=e.scaleX*o,u=e.scaleY*o,f=l*s,d=-u*c,m=l*c,p=u*s,h=t/2,b=n/2,v=i/2+e.dxCenter-(f*h+d*b),g=r/2+e.dyCenter-(m*h+p*b);return[f,d,v,m,p,g,0,0,1]}function nU(e,t,n,i,r){let o=[];if(e>=1.01?o.push(`punch-in ${oa(e,2)}\xD7`):e<=.99&&o.push(`pull-out ${oa(e,2)}\xD7`),Math.abs(n)>=1||Math.abs(i)>=1){let a=n>=0?`+${Math.round(n)}`:`${Math.round(n)}`,s=i>=0?`+${Math.round(i)}`:`${Math.round(i)}`;o.push(`shift ${a},${s}px`)}return Math.abs(t)>=.1&&o.push(`rot ${oa(t,1)}\xB0`),r&&o.push("keystone"),o.length?o.join(" \xB7 "):"1:1 (no reframe)"}function xy(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n]>>2;t[n]=i>255?255:i}return t}function rU(e=typeof navigator<"u"?navigator.deviceMemory:void 0){let t=e&&e>0?e:8;return Math.max(64e6,Math.min(1e9,Math.floor(t*1024*1024*1024*.12)))}function Py(e){return e==null?64:e.y.byteLength+64}function oz(e=rU()){let t=new Map,n=0,i=0,r=0,o=0,a=0,s=0,c=l=>{for(let u of t.keys()){if(n<=l)break;let f=t.get(u);t.delete(u),n-=Py(f??null),a++}};return{get(l){if(!t.has(l)){o++;return}let u=t.get(l)??null;return t.delete(l),t.set(l,u),r++,u},set(l,u){if(t.has(l)){let d=t.get(l)??null;t.delete(l),n-=Py(d)}let f=Py(u);if(f>e){s++;return}t.set(l,u),n+=f,c(e),n>i&&(i=n)},stats:()=>({hits:r,misses:o,evictions:a,oversized:s,bytes:n,peakBytes:i,size:t.size,budgetBytes:e}),clear(){t.clear(),n=0}}}var ky=.6,iU=9,oU=4;function aU(e){let[t,n,i,r,o,a,s,c,l]=e,u=o*l-a*c,f=-(r*l-a*s),d=r*c-o*s,m=t*u+n*f+i*d;if(!Number.isFinite(m)||Math.abs(m)<1e-12)return null;let p=1/m;return[u*p,(i*c-n*l)*p,(n*a-i*o)*p,f*p,(t*l-i*s)*p,(i*r-t*a)*p,d*p,(n*s-t*c)*p,(t*o-n*r)*p]}function Sy(e,t,n,i){let r=aU(t);if(!r)return null;let o=new Float64Array(n*i),a=e.w-1,s=e.h-1,c=0;for(let l=0;l<i;l++)for(let u=0;u<n;u++){let f=r[6]*u+r[7]*l+r[8];if(Math.abs(f)<1e-12)continue;let d=(r[0]*u+r[1]*l+r[2])/f,m=(r[3]*u+r[4]*l+r[5])/f;d>=0&&d<=a&&m>=0&&m<=s&&c++;let p=d<0?0:d>a?a:d,h=m<0?0:m>s?s:m,b=Math.floor(p),v=Math.floor(h),g=b<a?b+1:b,y=v<s?v+1:v,w=p-b,x=h-v,O=e.y,P=v*e.w,T=y*e.w,S=O[P+b]+(O[P+g]-O[P+b])*w,k=O[T+b]+(O[T+g]-O[T+b])*w;o[l*n+u]=S+(k-S)*x}return{luma:o,coverage:c/(n*i)}}var sU=new WeakMap,cU=new WeakMap,lU=new WeakMap;function Ty(e,t,n){let i=e.get(t.y);return i===void 0&&(i=n(),e.set(t.y,i)),i}function cz(e,t,n,i){let r=Sy(e,t,n,i);return!r||r.coverage<ky?null:Lr(r.luma,n,i)}function Zp(e){return Ty(sU,e,()=>uU(e))}function uU(e){let t=new Float64Array(e.y.length);for(let n=0;n<t.length;n++)t[n]=e.y[n];return Lr(t,e.w,e.h)}function az(e){return Ty(cU,e,()=>fU(e))}function fU(e){let t=new Float64Array(e.y.length);for(let i=0;i<t.length;i++)t[i]=e.y[i];let n=qa(t,e.w,e.h);return n?Lr(Ua(t,e.w,n),n.w,n.h):Lr(t,e.w,e.h)}function Tf(e,t,n){let i=Sy(t,n,e.w,e.h),r=!!i&&i.coverage>=ky,o=r?mn(Zp(e),Lr(i.luma,e.w,e.h)):1/0;return Math.min(o,mn(az(e),az(t)),r?lz(e,i.luma):1/0)}var sz=[[0,0,.5,1],[.5,0,.5,1],[0,0,1,.5],[0,.5,1,.5]],dU=32;function mU(e,t,n){let i=Sy(t,n,e.w,e.h);return!i||i.coverage<ky?1/0:lz(e,i.luma)}function lz(e,t){let n=(o,[a,s,c,l])=>{let u=Math.floor(a*e.w),f=Math.floor(s*e.h),d=Math.floor(c*e.w),m=Math.floor(l*e.h),p=new Float64Array(d*m);for(let h=0;h<m;h++)for(let b=0;b<d;b++)p[h*d+b]=o[(f+h)*e.w+u+b];return Lr(p,d,m)},i=Ty(lU,e,()=>sz.map(o=>n(e.y,o))),r=1/0;return sz.forEach((o,a)=>{r=Math.min(r,mn(i[a],n(t,o)))}),r}async function zf(e,t,n,i,r,o){if(e.score<=o)return!0;let[a,s]=await Promise.all([n(r),i(e.srcFrame)]);return!!a&&!!s&&mU(a,s,t)<=dU}function pU(e,t,n,i,r){let o=c=>e-t+c>=0&&e+t+c<n,a=[];o(0)&&a.push(0);let s=Math.max(1,Math.round(i));for(let c=1;a.length<r&&c*s<n;c++)for(let l of[-c*s,c*s])a.length<r&&o(l)&&a.push(l);return a.length?a:[0]}var al=4;async function sl(e){let t=e.probes??iU,n=pU(e.srcProbe,e.search,e.frameCount,e.runSpread??0,e.runSamples??1),i=new Map,r=new Map,o=0,a=async m=>(i.has(m)||i.set(m,await e.refLuma(m)),i.get(m)??null),s=async(m,p)=>{let h=m*1e3+p.length;if(r.has(h))return r.get(h)??null;let b=0,v=0;for(let y of p){let w=e.srcProbe+m+y;if(w<0||w>=e.frameCount)continue;let[x,O]=await Promise.all([a(e.refProbe+y),e.candLuma(w)]);if(!x||!O)continue;o++;let P=Tf(x,O,e.transform);Number.isFinite(P)&&(b+=P,v++)}let g=v===p.length?b/v:null;return r.set(h,g),g},c=-e.search,l=e.search,u=null,f=1,d=!1;for(;;){let m=Math.max(1,Math.round((l-c)/(t-1))),p=m<=oU?n:[n[0]??0],h=null,b=[];for(let v=c;v<=l;v+=m){let g=await s(v,p);g!=null&&(b.push(g),(!h||g<h.score||g===h.score&&Math.abs(v)<Math.abs(h.d))&&(h={d:v,score:g}))}if(!h)return null;if(u=h,m===1){let v=b.filter(g=>g<=h.score+al).length;d=b.length>1&&v===b.length,f=Math.max(1,v);break}c=Math.max(-e.search,h.d-m),l=Math.min(e.search,h.d+m)}return u?{srcFrame:e.srcProbe+u.d,score:u.score,decodes:o,ambiguousFrames:f,flat:d}:null}var hU=3;async function uz(e){let t=await e.refLuma(e.refProbe);if(!t)return null;let n=Zp(t),i=Math.max(1,Math.floor(e.stride)),r=0,o=[];for(let l=0;l<e.frameCount;l+=i){let u=await e.candLuma(l);if(!u)continue;r++;let f=Tf(t,u,e.transform);Number.isFinite(f)&&o.push({s:l,d:f})}if(!o.length)return null;o.sort((l,u)=>l.d-u.d);let a=null;for(let l of o.slice(0,hU)){let u=await sl({transform:e.transform,refLuma:e.refLuma,candLuma:e.candLuma,refProbe:e.refProbe,srcProbe:l.s,frameCount:e.frameCount,runSpread:e.runSpread,runSamples:e.runSamples,probes:e.probes,search:i});u&&(!a||u.score<a.score)&&(a=u)}if(!a)return null;let s=Math.min(...o.map(l=>l.d)),c=o.filter(l=>l.d<=s+al).length;return{...a,decodes:r+a.decodes,ambiguousFrames:Math.max(a.ambiguousFrames,c*i)}}function zy(e,t){if(!t?.length)return e;let n=0,i=t.length-1;for(;n<i;){let a=n+i>>1;t[a]<e?n=a+1:i=a}let r=t[n],o=n>0?t[n-1]:r;return Math.abs(o-e)<=Math.abs(r-e)?o:r}var bU=3,Hs=12,gU=256,vU=(e,t,n)=>t<=1?n>>1:Math.round(e*(n-1)/(t-1));function dz(e,t,n,i,r){let o=Math.floor(t*e.w),a=Math.floor(n*e.h),s=Math.floor(i*e.w),c=Math.floor(r*e.h),l=new Uint8Array(s*c);for(let u=0;u<c;u++){let f=(a+u)*e.w+o,d=u*s;for(let m=0;m<s;m++)l[d+m]=e.y[f+m]}return{y:l,w:s,h:c}}var fz=8,yU=3,wU=[[0,0,.5,1],[.5,0,.5,1],[0,0,1,.5],[0,.5,1,.5]];function xU(e,t,n){return[e[0]+t*e[6],e[1]+t*e[7],e[2]+t*e[8],e[3]+n*e[6],e[4]+n*e[7],e[5]+n*e[8],e[6],e[7],e[8]]}function cl(e,t,n){return e.ok||e.inliers>=t&&e.inlierRatio>=n}function PU(e){let t=e.filter(r=>r.dist!=null);if(!t.length)return e.sort((r,o)=>o.res.inliers-r.res.inliers);t.sort((r,o)=>r.dist-o.dist);let n=t[0].dist;return[...t.filter(r=>r.dist<=n+al/2).sort((r,o)=>o.res.inliers-r.res.inliers),...t.filter(r=>r.dist>n+al/2)]}async function kU(e,t,n,i,r,o,a,s){let c=e.map(f=>f?Zp(f):null),l=e.map(()=>[]),u=e.map((f,d)=>f?d:-1).filter(f=>f>=0);if(!u.length)return l;for(let f=0;f<t.length;f++){let d=t[f];if(s?.aborted)throw new DOMException("Auto Conform cancelled","AbortError");a?.(f,t.length);let m=Math.min(n,Math.max(1,d.frameCount)),p=m>1?(d.frameCount-1)/(m-1):d.frameCount,h=-1;for(let b=0;b<m;b++){let v=Math.min(d.frameCount-1,zy(vU(b,m,d.frameCount),d.keyframes));if(v===h)continue;h=v;let g=await d.luma(v);if(g)for(let y of u){let w=e[y],x=await Qr(g.y,g.w,g.h,w.y,w.w,w.h,i);if(!cl(x,r,o))continue;let O=cz(g,x.transform,w.w,w.h);l[y].push({cand:d,srcFrame:v,res:x,dist:O?mn(c[y],O):null,spacing:p})}}}return l.map(PU)}var Oy=[[{x:0,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1}],[{x:0,y:0,w:1,h:.5},{x:0,y:.5,w:1,h:.5}]],SU=Oy.reduce((e,t)=>e+t.length,0),TU=1+SU;function zU(e,t,n){let i=null,r=0,o=0;for(let a of Oy){let s=[];for(let c of a){let l=n[o],u=e[t+1+o][0];o++,!(!l||!u)&&s.push({rect:c,clipLabel:u.cand.label,reframe:aa(u.res,l.w,l.h),inliers:u.res.inliers})}if(s.length===a.length&&new Set(s.map(c=>c.clipLabel)).size===s.length){let c=Math.min(...s.map(l=>l.inliers));c>r&&(r=c,i=s)}}return i}async function mz(e,t,n,i={}){let{signal:r,searchSamples:o=24,trackSamples:a=3,composite:s=!0,minRetrievalInliers:c=25,minRetrievalRatio:l=.03,refine:u=!0,escalationStride:f=Sf,onProgress:d,onPhase:m,...p}=i,h=k=>(k.kind==="gap"||k.kind==="unresolved")&&k.nothingSimilar==null,b=e.filter(h),v=b.length,g=[],y=0,w=b.map(k=>k.refStart+k.refEnd>>1),x=[];for(let k of w)x.push(await t(k));let O=[],P=[];for(let k of x){O.push(k);let L=[];for(let z of Oy)for(let X of z){let V=k&&s?dz(k,X.x,X.y,X.w,X.h):null;L.push(V),O.push(V)}P.push(L)}m?.("retrieval");let T=await kU(O,n,o,p,c,l,(k,L)=>d?.(Math.floor(k/Math.max(1,L)*v),v),r),S=new Map(b.map((k,L)=>[k,L]));m?.("placing");for(let k of e){if(!h(k)){g.push(k);continue}d?.(y++,v);let L=k.refEnd-k.refStart+1,z=S.get(k),X=w[z],V=x[z];if(!V){g.push(k);continue}let R=z*TU,j=T[R],J=s?zU(T,R,P[z]):null;if(J){g.push({refStart:k.refStart,refEnd:k.refEnd,kind:"composite",regions:J});continue}if(!j.length){g.push(k);continue}let q=u?j.slice(0,bU):j.slice(0,1),W=j[0],F=null;for(let de of q){if(!u)break;let Oe=await sl({transform:de.res.transform,refLuma:t,candLuma:Ze=>de.cand.luma(Ze),refProbe:X,srcProbe:de.srcFrame,frameCount:de.cand.frameCount,runSpread:(de.cand.rate??1)===1?Math.max(1,Math.floor(L/3)):0,runSamples:(de.cand.rate??1)===1?3:1,search:Math.ceil(de.spacing)});Oe&&(!F||Oe.score<F.score)&&(F=Oe,W=de)}if(u){let de=await uz({transform:W.res.transform,refLuma:t,candLuma:Oe=>W.cand.luma(Oe),refProbe:X,frameCount:W.cand.frameCount,stride:Math.max(f,Math.ceil(W.cand.frameCount/gU)),runSpread:(W.cand.rate??1)===1?Math.max(1,Math.floor(L/3)):0,runSamples:(W.cand.rate??1)===1?3:1});de&&(!F||de.score<F.score)?F=de:de&&F&&(F={...F,ambiguousFrames:Math.max(F.ambiguousFrames,de.ambiguousFrames)})}let H=F?.srcFrame??W.srcFrame,C=F?.score??W.dist,$=W.res.transform;if(F&&F.srcFrame!==W.srcFrame&&C!=null&&C>Hs){let[de,Oe]=await Promise.all([t(X),W.cand.luma(F.srcFrame)]),Ze=de&&Oe?await Qr(Oe.y,Oe.w,Oe.h,de.y,de.w,de.h,p):null;Ze&&cl(Ze,c,l)&&($=Ze.transform)}if(C!=null&&C>Hs&&!(F&&await zf(F,$,t,de=>W.cand.luma(de),X,Hs))){g.push(k);continue}let oe=W.cand.rate??1,ye=[];for(let de=0;de<a;de++){let Oe=a<=1?X:k.refStart+Math.round(de*(L-1)/(a-1)),Ze=H+Math.round((Oe-X)*oe),[ue,ze]=await Promise.all([t(Oe),Ze>=0&&Ze<W.cand.frameCount?W.cand.luma(Ze):Promise.resolve(null)]);if(ue&&ze){let Re=await Qr(ze.y,ze.w,ze.h,ue.y,ue.w,ue.h,p);ye.push({refFrame:Oe,reframe:Re.ok?aa(Re,ue.w,ue.h):null})}else ye.push({refFrame:Oe,reframe:null})}let Ae=Wp(ye);if(Ae.kind==="unresolved"){let de=aa(W.res,V.w,V.h);Ae={kind:"static",keyframes:[{refFrame:X,reframe:de}],label:de.label}}g.push({refStart:k.refStart,refEnd:k.refEnd,kind:Ae.kind,clipLabel:W.cand.label,srcStart:H-Math.round((X-k.refStart)*oe),srcEnd:H+Math.round((k.refEnd-X)*oe),track:Ae,score:F?.score??W.dist??void 0,inPointAmbiguity:F?.ambiguousFrames})}return d?.(v,v),g}async function Of(e){let{minInliers:t=25,minRatio:n=.03}=e,i=await e.refLuma(e.refProbe);if(!i)return null;let r=null,o=0,a=[];for(let l=-e.radius;l<=e.radius;l++){let u=e.srcGuess+l;u>=0&&u<e.cand.frameCount&&a.push(u)}let s=await Promise.all(a.map(async l=>{let u=await e.cand.luma(l);return u?{sf:l,res:await Qr(u.y,u.w,u.h,i.y,i.w,i.h,e.reframeOpts)}:null}));for(let l of s)l&&(o=Math.max(o,l.res.inliers),cl(l.res,t,n)&&(!r||l.res.inliers>r.res.inliers)&&(r=l));if(!r&&o>=fz){let l=s.filter(d=>!!d&&d.res.inliers>=fz).sort((d,m)=>m.res.inliers-d.res.inliers).slice(0,yU),u=new Set;for(let d of l)for(let m of[-1,0,1])d.sf+m>=0&&d.sf+m<e.cand.frameCount&&u.add(d.sf+m);let f=[...u].sort((d,m)=>d-m);for(let[d,m,p,h]of wU){let b=dz(i,d,m,p,h),v=Math.floor(d*i.w),g=Math.floor(m*i.h),y=await Promise.all(f.map(async w=>{let x=await e.cand.luma(w);return x?{sf:w,res:await Qr(x.y,x.w,x.h,b.y,b.w,b.h,e.reframeOpts)}:null}));for(let w of y)!w||!cl(w.res,t,n)||(!r||w.res.inliers>r.res.inliers)&&(r={sf:w.sf,res:{...w.res,transform:xU(w.res.transform,v,g)}})}}if(!r)return null;let c=await sl({transform:r.res.transform,refLuma:e.refLuma,candLuma:l=>e.cand.luma(l),refProbe:e.refProbe,srcProbe:r.sf,frameCount:e.cand.frameCount,search:4,runSpread:e.runSpread,runSamples:e.runSpread>0?3:1});if(!c)return null;if(c.srcFrame!==r.sf){let l=await e.cand.luma(c.srcFrame),u=l?await Qr(l.y,l.w,l.h,i.y,i.w,i.h,e.reframeOpts):null;u&&cl(u,t,n)&&(r={sf:c.srcFrame,res:u})}if(!await zf(c,r.res.transform,e.refLuma,l=>e.cand.luma(l),e.refProbe,Hs))return null;if(c.srcFrame!==e.srcGuess&&e.srcGuess>=0&&e.srcGuess<e.cand.frameCount){let l=await e.cand.luma(e.srcGuess),u=await e.cand.luma(c.srcFrame);if(l&&u){let f=d=>Tf(i,d,r.res.transform);f(u)>f(l)-al&&(c.srcFrame=e.srcGuess)}}return{srcAtProbe:c.srcFrame,transform:r.res.transform,srcW:r.res.srcW,srcH:r.res.srcH,score:c.score,ambiguity:c.ambiguousFrames,refPlane:i}}async function pz(e){let t=e.refEnd-e.refStart+1;if(t<8)return null;let n=e.cand.rate??1,i=e.refStart+e.refEnd>>1,r=await e.refLuma(i);if(!r)return null;let o=null,a=0,s=await Promise.all(Array.from({length:9},async(j,J)=>{let q=e.srcAt(i)+J-4;if(q<0||q>=e.cand.frameCount)return null;let W=await e.cand.luma(q);return W?Qr(W.y,W.w,W.h,r.y,r.w,r.h,e.reframeOpts):null}));for(let j of s)j&&cl(j,25,.03)&&j.inliers>a&&(o=j.transform,a=j.inliers);if(!o)return null;let c=o,l=5,u=Math.min(3,Math.floor(t/8)),f=Array.from({length:l},(j,J)=>Math.round(e.refStart+u+J*(t-1-2*u)/(l-1))),d=new Map;for(let j of f)d.set(j,await e.refLuma(j));let m=new Map,p=(j,J)=>{let q=`${j}:${J}`,W=m.get(q);return W||(W=(async()=>{let F=d.get(j);if(!F||J<0||J>=e.cand.frameCount)return 1/0;let H=await e.cand.luma(J);return H?Tf(F,H,c):1/0})(),m.set(q,W)),W},h=async(j,J,q)=>await Promise.all(j.flatMap(W=>Array.from({length:17},async(F,H)=>{let C=H-8,$=await Promise.all(f.map(oe=>J(oe,Math.round(g+C+(oe-i)*W))));return{slope:W,delta:C,mean:q*$.reduce((oe,ye)=>oe+ye,0)/l}}))),b=(e.srcAt(e.refEnd)-e.srcAt(e.refStart))/Math.max(1,t-1),v=[...new Set([1,n,b].map(j=>Math.round(j*1e3)/1e3))],g=e.srcAt(i),y=await h(v,p,1);y.sort((j,J)=>j.mean-J.mean);let w=y[0];if(!Number.isFinite(w.mean)||w.mean>Hs*3)return null;let x=2,O=y.find(j=>j.slope!==w.slope);if(O&&O.mean-w.mean<x){let j=new Map,q=await h(v,(H,C)=>{let $=`${H}:${C}`,oe=j.get($);return oe||(oe=(async()=>{let ye=d.get(H);if(!ye||C<0||C>=e.cand.frameCount)return 0;let Ae=await e.cand.luma(C);return Ae?(await Qr(Ae.y,Ae.w,Ae.h,ye.y,ye.w,ye.h,e.reframeOpts)).inliers:0})(),j.set($,oe)),oe},-1);q.sort((H,C)=>H.mean-C.mean);let W=q[0],F=q.find(H=>H.slope!==W.slope);if(W.mean<-25&&(!F||F.mean-W.mean>=.05*-W.mean))return{srcAtStart:g+W.delta-(i-e.refStart)*W.slope,slope:W.slope,model:Math.abs(W.slope-n)<.001?"real-time":Math.abs(W.slope-1)<.001?"frame-for-frame":"retime",anchors:f.map(H=>({ref:H,src:Math.round(g+W.delta+(H-i)*W.slope),ambiguity:0}))};w=y[0]}let P=y.find(j=>j.slope!==w.slope),T=!P||P.mean-w.mean>=x,S=v.find(j=>Math.abs(j-b)<.001)??b,k=T?w.slope:S,L=y.filter(j=>j.slope===k),z=L[0],X=L.find(j=>Math.abs(j.delta-z.delta)>1),V=X&&X.mean-z.mean<x/2?0:z.delta;if(!T&&V===0)return null;let R=Math.abs(k-n)<.001?"real-time":Math.abs(k-1)<.001?"frame-for-frame":"retime";return{srcAtStart:g+V-(i-e.refStart)*k,slope:k,model:R,anchors:f.map(j=>({ref:j,src:Math.round(g+V+(j-i)*k),ambiguity:0}))}}function Dp(e,t){let n=[...e].sort((i,r)=>i[0]-r[0]);if(t<=n[0][0])return n[0][1];for(let i=1;i<n.length;i++)if(t<=n[i][0])return n[i-1][1]+(n[i][1]-n[i-1][1])*(t-n[i-1][0])/Math.max(1e-9,n[i][0]-n[i-1][0]);return n[n.length-1][1]}function Mf(e,t,n,i,r,o,a=0){let s=e.map(([b,v])=>[b,v*r/i]),c=[0,...s.map(b=>b[0]).filter(b=>b>1e-9&&b<t-1e-9),t].filter((b,v,g)=>g.indexOf(b)===v).sort((b,v)=>b-v),l=c.map(b=>Dp(s,b)/100),u=n/r,f=c.map(b=>u+b/i),d=[u];for(let b=1;b<c.length;b++)d.push(d[b-1]+(l[b-1]+l[b])*.5*(c[b]-c[b-1])/r);let m=b=>l[b]*i/r,p=[],h=(b,v,g)=>p.push({id:`${o}-${p.length}`,parameter_path:"speed",time:{value:b,rate:i},value:v,interp:"bezier",tangent_in:null,tangent_out:null,order_index:p.length,raw_extraction:g});if(u>1e-9){let b=u/3;h(0,0,{drtNativeTangent:[0,0,b,b,0,0],speedPreRoll:!0})}for(let b=0;b<c.length;b++){let v=[0,0,0,0,0,0];if(b>0){let y=(f[b]-f[b-1])/3;v[0]=-y,v[1]=-m(b)*y}else if(u>1e-9){let y=u/3;v[0]=-y,v[1]=-y}if(b+1<c.length){let y=(f[b+1]-f[b])/3;v[2]=y,v[3]=m(b)*y}let g=s.find(y=>Math.abs(y[0]-c[b])<1e-9);h(f[b],d[b],g?{drtNativeTangent:v,speedGraphPoint:[c[b],g[1]]}:{drtNativeTangent:v,speedGraphPoint:[c[b],l[b]*100],speedGraphSynth:!0})}return{keyframes:p,sourceFrames:(d[d.length-1]-u)*r}}function My(e){if(!e||!Number.isFinite(e)||e<=0)return{num:24,den:1};for(let t of[24,30,60,120])if(Math.abs(e-t*1e3/1001)<.01)return{num:t*1e3,den:1001};return Math.abs(e-Math.round(e))<1e-6?{num:Math.round(e),den:1}:{num:Math.round(e*1e3),den:1e3}}function Ly(e,t,n=!1){let i=Math.max(1,Math.round(t)),r=Math.max(0,Math.round(e)),o=a=>String(a).padStart(2,"0");if(n&&(i===30||i===60)){let a=i===60?4:2,s=i*60-a,c=s*10+a,l=Math.floor(r/c),u=r%c;r=l*i*600+(u<=a?u:u+a*Math.floor((u-a)/s))}return`${o(Math.floor(r/(i*3600))%24)}:${o(Math.floor(r/(i*60))%60)}:${o(Math.floor(r/i)%60)}${n?";":":"}${o(r%i)}`}var Lf=(e,t)=>`conform-${e}-${t}`,OU=4,MU="1",LU=.025,RU=.005,NU=.5,XU=.001,jU=.5,FU=.05;function IU(e,t,n){let i=e.measuredBy==="sizing";if(e.flipH||e.flipV)return!1;let r=i?XU:LU,o=i?FU:NU,a=(s,c)=>!c||(i?Math.abs(s)<jU:Math.abs(s/c)<RU);return Math.abs(e.scaleX-1)<r&&Math.abs(e.scaleY-1)<r&&Math.abs(e.rotationDeg)<o&&a(e.dxCenter,t)&&a(e.dyCenter,n)&&!e.perspective}function EU(e,t,n,i){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),i>0&&(e.position_y=t.dyCenter/i),Math.abs(t.rotationDeg)>.001&&(e.rotation=t.rotationDeg);let r=e;t.flipH&&(r.flip_horizontal=!0),t.flipV&&(r.flip_vertical=!0)}function hz(e,t,n,i,r){let o=ol(t,n,i,r),a=(e.scale??100)/100,s={scaleX:(e.scale_x??e.scale??100)/100,scaleY:(e.scale_y??e.scale??100)/100,rotationDeg:e.rotation??0,dxCenter:(e.position_x??0)*o.w,dyCenter:(e.position_y??0)*o.h};return Math.abs(a-1)<1e-6&&Math.abs(s.scaleX-1)<1e-6&&Math.abs(s.scaleY-1)<1e-6&&Math.abs(s.rotationDeg)<1e-6&&Math.abs(s.dxCenter)<1e-6&&Math.abs(s.dyCenter)<1e-6?null:s}function VU(e,t,n,i,r,o,a){let s=[],c=n.srcStart??0,l=0;for(let u of t.keyframes){let f=u.refFrame-n.refStart,d=n.srcEnd!=null&&n.refEnd>n.refStart?(n.srcEnd-c)/(n.refEnd-n.refStart):i/(r||i),p={value:c+f*d,rate:i},h=(b,v)=>{s.push({id:`${e}-kf-${l++}`,parameter_path:b,time:p,value:v})};h("scale",u.reframe.scale*100),o>0&&h("position.x",u.reframe.dxCenter/o),a>0&&h("position.y",u.reframe.dyCenter/a),Math.abs(u.reframe.rotationDeg)>.001&&h("rotation",u.reframe.rotationDeg)}return s}function bz(e,t={}){let n=[],i=e.refFps??24,r=My(i),o=new Map(e.clips.map(y=>[y.label,y])),a=new Set(e.timeline.filter(y=>y.kind!=="gap"&&y.clipLabel).map(y=>y.clipLabel)),s=[],c=new Map;for(let y of e.clips){if(!a.has(y.label))continue;let w=Lf("media",y.clipIndex);c.set(y.label,w);let x=y.srcFps??i;s.push({id:w,kind:"external",content_kind:"video",target_url:y.label,display_name:y.label.replace(/\.[^.]+$/,""),source_fps:x,source_timecode:Ly(y.srcStartFrame,x,y.srcDropFrame??!1),available_range:{start:{value:0,rate:x},duration:{value:y.srcFrames,rate:x}},source_resolution_w:y.srcW??null,source_resolution_h:y.srcH??null,reel_name:null,raw_extraction:{},metadata:{codec:y.codec}}),y.srcFps&&e.refFps&&Math.abs(y.srcFps-e.refFps)>.01&&n.push({kind:"rate",message:`${y.label} is ${y.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 O of y.warnings)n.push({kind:"rate",message:`${y.label}: ${O}`})}let l=[],u=0,f=0,d=0,m=0,p=0,h=[];for(let y of e.timeline){if(y.kind==="gap"||!y.clipLabel||y.srcStart==null||y.srcStart>=0){h.push(y);continue}let w=o.get(y.clipLabel),x=y.srcEnd!=null&&y.refEnd>y.refStart?(y.srcEnd-y.srcStart)/(y.refEnd-y.refStart):(w?.srcFps??i)/(i||1),O=x>0?Math.ceil(-y.srcStart/x-1e-9):y.refEnd-y.refStart+1;if(O>y.refEnd-y.refStart){h.push({...y,kind:"gap",clipLabel:void 0});continue}n.push({kind:"source-range",refStart:y.refStart,refEnd:y.refStart+O-1,message:`${y.clipLabel}: placed from source frame ${y.srcStart}, before the clip's first frame \u2014 the first ${O} 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.`}),h.push({kind:"gap",refStart:y.refStart,refEnd:y.refStart+O-1}),h.push({...y,refStart:y.refStart+O,srcStart:y.srcStart+O*x})}for(let y of h){let w=y.refEnd-y.refStart+1;if(y.kind==="gap"||!y.clipLabel){f+=w,n.push({kind:"gap",refStart:y.refStart,refEnd:y.refEnd,message:`${w} frame(s) with no matching source \u2014 left empty on the timeline.`+(y.nothingSimilar!=null?` Nothing in the media you supplied resembles these frames (best similarity ${y.nothingSimilar.toFixed(2)}) \u2014 stock, graphics, or media that was not in the bucket.`:"")+(y.unconfirmed?` Best guess: ${y.unconfirmed.clipLabel} from source frame ${y.unconfirmed.srcFrame}, but the picture did not confirm it (${y.unconfirmed.why??"often graphics or stock that resembles a camera shot"}) \u2014 check it by eye if a shot is expected here.`:"")});continue}y.kind==="composite"&&n.push({kind:"composite",refStart:y.refStart,refEnd:y.refEnd,message:`split-screen / composite of ${y.regions?.length??0} sources \u2014 emitted as the first region only; rebuild the layout by hand.`});let x=o.get(y.clipLabel),O=c.get(y.clipLabel);if(!x||!O)continue;let P=x.srcFps??i,T=y.speed&&y.speed.kind==="retime"?y.speed.percent/100:1,S=(i>0?w*(P/i):w)*T,k=y.srcStart??0;y.takeRival&&n.push({kind:"contested",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel} or ${y.takeRival.clipLabel}? Two takes of one setup explain this shot almost equally (shot-sizing agreement ${y.takeRival.winnerAgreement.toFixed(2)} vs ${y.takeRival.agreement.toFixed(2)}). Conformed from ${y.clipLabel} \u2014 check the take against the offline.`}),y.contest?.settledBy==="label"&&n.push({kind:"contested",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel} and ${y.contest.rivals.map(V=>V.clipLabel).join(", ")} explain these frames equally well (tied at ${y.contest.winnerScore?.toFixed(1)??"\u2014"} bits). Conformed from ${y.clipLabel} because it sorts first by name \u2014 verify the source timecode.`});let L=Lf("item",p),z={id:L,kind:"clip",item_index:p++,name:y.clipLabel,enabled:!0,timeline_range:{start:{value:y.refStart,rate:i},duration:{value:w,rate:i}},source_range:{start:{value:k,rate:P},duration:{value:S,rate:P}},media_reference_id:O,raw_extraction:{},metadata:{}},X=y.track;if(X&&X.kind!=="unresolved"&&X.keyframes.length>0&&!(X.kind==="static"&&IU(X.keyframes[X.keyframes.length>>1].reframe,e.refW,e.refH))){let V=X.keyframes[X.keyframes.length>>1],R=ol(e.refW,e.refH,x.srcW,x.srcH);EU(z,V.reframe,R.w,R.h),d++,X.kind==="animated"&&(m++,z.keyframes=VU(L,{keyframes:X.keyframes},y,P,i,R.w,R.h),n.push({kind:"reframe",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: animated reframe (${X.keyframes.length} keys: ${X.label}) \u2014 measured, not declared; check the move against the reference.`}))}else X?.kind==="unresolved"&&n.push({kind:"unresolved",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: placed, but its reframe could not be recovered${X.label&&!X.label.startsWith("unresolved")?` (${X.label})`:""} \u2014 the clip is full-frame on the timeline and may need resizing.`});if(y.ramp&&y.ramp.length>=2){let V=Mf(y.ramp,w,k,i,P,`${L}-spd`);z.source_range={start:z.source_range.start,duration:{value:Math.max(1,Math.ceil(V.sourceFrames)+1),rate:P}},z.speed_ramped=!0,z.speed=Math.round(100*V.sourceFrames/w*(i/P)*100)/100;let R=z.keyframes??[];z.keyframes=[...R,...V.keyframes.map((j,J)=>({...j,order_index:R.length+J}))],n.push({kind:"retime",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: SPEED RAMP read from the picture \u2014 ${y.ramp.map(([j,J])=>`${J.toFixed(0)}%@${Math.round(j)}`).join(" \u2192 ")}. Check the ramp against the reference.`})}y.speed&&y.speed.kind!=="normal"&&(z.speed=y.speed.percent,z.speed_ramped=!1,n.push({kind:"retime",refStart:y.refStart,refEnd:y.refEnd,message:y.speed.kind==="freeze"?`${y.clipLabel}: FREEZE FRAME \u2014 the source holds on one frame across ${w} reference frame(s). Emitted at 0% speed; a host may want an explicit freeze instead.`:y.speed.basis==="frame-for-frame"?`${y.clipLabel}: plays FRAME FOR FRAME \u2014 one source frame per record frame, ${y.speed.percent.toFixed(1)}% of real time \u2014 measured from the picture at ${y.speed.samples} points. Usually the edit's rate-conform setting, not a retime.`:y.speed.basis==="convention"?`${y.clipLabel}: emitted at ${y.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.`:`${y.clipLabel}: retimed to ${y.speed.percent.toFixed(1)}% (fitted over ${y.speed.samples} runs, residual ${y.speed.residual.toFixed(1)} frames). A speed RAMP would not fit one slope \u2014 check it if the residual is high.`})),y.inPointAmbiguity!=null&&y.inPointAmbiguity>=OU?n.push({kind:"ambiguous",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: in-point uncertain \u2014 ${y.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(y.inPointAmbiguity/2)} frames. Check it against the offline.`}):y.inPointUnconfirmed&&n.push({kind:"ambiguous",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: in-point not confirmed \u2014 ${y.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.`}),l.push(z),u++}let b={id:Lf("track",1),kind:"Video",track_index:1,name:"V1",enabled:!0,items:l,source_element_id:null,raw_extraction:{},metadata:{}},v={id:Lf("timeline",1),name:t.name??t.referenceName??"Auto-Conform",kind:"primary",timeline_index:0,fps_num:r.num,fps_den:r.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:[b],markers:[],source_element_id:null,raw_extraction:{},metadata:{}};return{session:{projects:[{id:Lf("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:MU,status:"ready",error_message:null,metadata:{}}],timelines:[v],media_references:s,source_format:"auto-conform",source_filename:t.referenceName??null},issues:n,stats:{placed:u,gapFrames:f,reframed:d,animated:m}}}var WU=16,HU=1.5,ZU=10;function DU(e,t={}){let n=t.sigmas??HU,i=Math.max(1,t.minShotFrames??ZU),r=t.minCutBits??WU,o=e.length;if(o<2*i)return[];let a=new Float64Array(o-1);for(let m=1;m<o;m++)a[m-1]=mn(e[m-1],e[m]);let s=0;for(let m of a)s+=m;let c=s/a.length,l=0;for(let m of a)l+=(m-c)**2;let u=Math.sqrt(l/a.length),f=Math.max(c+n*u,r),d=[];for(let m=0;m<a.length;m++){if(a[m]<=f)continue;let p=m+1;p<i||o-p<i||d.length&&p-d[d.length-1]<i||d.push(p)}return d}var qU=4;function vz(e,t,n,i=qU){let r=e[t];if(!r||n<=t)return!1;for(let o=t+1;o<=n;o++){let a=e[o];if(!a||mn(r,a)>i)return!1}return!0}function UU(e,t){if(e<=0)return[];let n=[0,...t.filter(r=>r>0&&r<e),e],i=[];for(let r=0;r<n.length-1;r++)n[r+1]-n[r]>0&&i.push({start:n[r],end:n[r+1]-1});return i}var CU=1e3,JU=8;function KU(e,t){if(!e||!t)return 1/0;let n=0,i=Math.min(e.length,t.length);for(let r=0;r<i;r++)n+=e[r]*t[r];return(1-n)*CU}function yz(e,t,n,i){let r=i.embedding;return r?{d:(o,a,s)=>KU(r.ref[o],a.embed?.[s]),len:o=>o.embed?.length??0,threshold:r.threshold??1/0,tau:r.tau??n}:{d:(o,a,s)=>{let c=e[o],l=a.pdq[s];return c&&l?mn(c,l):1/0},len:o=>o.pdq.length,threshold:t,tau:n}}var wz=42,xz=.42,Pz=8,kz=.1,Sz=.25,Tz=3,zz=.9,GU=512;function AU(e,t,n,i,r,o,a){let s=[],c=new Map,l=0,u=0,f=!1;for(let d=n;d<=i;d++){if(d<0||d>=e)continue;let m=Oz(d,t,r,o,a);if(m.length!==0){m.length>=o&&(f=!0),l++,s.push({f:d,picks:m});for(let p of m)c.set(p.clipIndex,(c.get(p.clipIndex)??0)+p.weight),u+=p.weight}}return{frames:s,votingFrames:l,truncated:f,massByClip:c,totalMass:u}}function BU(e,t,n,i,r,o,a,s,c){let{bins:l,base:u}=c;l.fill(0);let f=1/0,d=-1/0;for(let w of e.frames){let x=w.f-n;for(let O of w.picks){if(O.clipIndex!==t)continue;let P=Math.round(O.frame-i*x)-u;P<0||P>=l.length||(l[P]+=O.weight,P<f&&(f=P),P>d&&(d=P))}}if(f>d)return null;let m=-1,p=f,h=Math.max(0,f),b=Math.min(l.length-1,d);for(let w=h;w<=b;w++){if(l[w]<=0)continue;let x=0,O=Math.max(0,w-r),P=Math.min(l.length-1,w+r);for(let T=O;T<=P;T++)l[T]<=0||(x+=l[T]*(1-Math.abs(T-w)/(r+1)));x>m&&(m=x,p=w)}if(m<=0)return null;let v=0,g=0;for(let w=h;w<=b;w++){if(l[w]<=0)continue;Math.abs(w-p)<=o&&(v+=l[w]);let x=0,O=Math.max(0,w-r),P=Math.min(l.length-1,w+r);for(let T=O;T<=P;T++)l[T]>0&&(x+=l[T]*(1-Math.abs(T-w)/(r+1)));x>=a*m&&g++}let y=0;for(let w of e.frames){let x=w.f-n;for(let O of w.picks)if(O.clipIndex===t&&Math.abs(Math.round(O.frame-i*x)-u-p)<=r){y++;break}}return{intercept:p+u,peak:m,consensus:s>0?v/s:0,ambiguity:g,coverage:y}}function Oz(e,t,n,i,r){let{threshold:o,tau:a}=n,s=f=>{let d=n.len(f);if(d<=0)return null;if(!r)return{from:0,to:d-1};if(r.clipIndex!==f.clipIndex)return null;let m=Math.max(0,r.lo),p=Math.min(d-1,r.hi);return m<=p?{from:m,to:p}:null},c=1/0;for(let f of t){let d=s(f);if(d)for(let m=d.from;m<=d.to;m++){let p=n.d(e,f,m);p<c&&(c=p)}}if(!(c<=o))return[];let l=[],u=0;for(let f of t){let d=s(f);if(d)for(let m=d.from;m<=d.to;m++){let p=n.d(e,f,m);if(!(p>o)){if(u+=Math.exp(-(p-c)/a),l.length<i)l.push({clipIndex:f.clipIndex,frame:m,dist:p}),l.length===i&&l.sort((h,b)=>h.dist-b.dist);else if(p<l[i-1].dist){l[i-1]={clipIndex:f.clipIndex,frame:m,dist:p};for(let h=i-1;h>0&&l[h].dist<l[h-1].dist;h--){let b=l[h];l[h]=l[h-1],l[h-1]=b}}}}}return u<=0?[]:l.map(f=>({clipIndex:f.clipIndex,frame:f.frame,weight:Math.exp(-(f.dist-c)/a)/u}))}function YU(e,t,n){let i=0,r=0,o=e.length;for(;r<o;){let a=r+o>>1;e[a].offset<t?r=a+1:o=a}for(let a=r;a<e.length;a++){let s=e[a].offset-t;if(s>n)break;i+=e[a].weight*(1-s/(n+1))}for(let a=r-1;a>=0;a--){let s=t-e[a].offset;if(s>n)break;i+=e[a].weight*(1-s/(n+1))}return i}function Ds(e,t,n,i,r={},o=!1){let a=r.threshold??Yn,s=r.kernelRadius??Tz,c=r.consensusWindow??wz,l=r.minClipShare??xz,u=r.tau??Pz,f=r.minConsensus??kz,d=r.minVotingFrames??Sz,m=r.ambiguityFraction??zz,p=Math.max(1,r.maxCandidates??GU),h=yz(e,a,u,r),b=i-n+1,v=[],g=new Map,y=0,w=0,x=!1,O=r.embedding?r.embedding.ref.length:e.length;for(let W=n;W<=i;W++){if(W<0||W>=O)continue;let F=Oz(W,t,h,p,r.searchWindow);if(F.length!==0){F.length>=p&&(x=!0),y++;for(let H of F)v.push({clipIndex:H.clipIndex,offset:H.frame-W,weight:H.weight}),g.set(H.clipIndex,(g.get(H.clipIndex)??0)+H.weight),w+=H.weight}}let P={refStart:n,refEnd:i,placement:null,ramp:null,hold:!1};if(v.length===0||w<=0)return{...P,declined:"no-votes"};if(y<d*b)return{...P,declined:"too-few-voting-frames"};let T=[...g.entries()].map(([W,F])=>({clipIndex:W,mass:F,share:F/w})).sort((W,F)=>F.mass-W.mass||W.clipIndex-F.clipIndex),S=T[0],k=t.find(W=>W.clipIndex===S.clipIndex)?.label??String(S.clipIndex);if(S.share<l)return{...P,declined:"no-dominant-clip"};if(T.length>1&&Math.abs(T[0].mass-T[1].mass)<=1e-9*w)return{...P,declined:"no-dominant-clip"};let L=v.filter(W=>W.clipIndex===S.clipIndex).sort((W,F)=>W.offset-F.offset),z=-1,X=L[0].offset,V=new Float64Array(L.length);for(let W=0;W<L.length;W++){let F=YU(L,L[W].offset,s);V[W]=F,F>z&&(z=F,X=L[W].offset)}let R=0;for(let W of L)Math.abs(W.offset-X)<=c&&(R+=W.weight);let j=R/S.mass;if(j<f)return{...P,declined:"no-consensus"};if(!o&&b>=2*8){let W=n+(b>>1),F=Ds(e,t,n,W-1,r,!0).placement,H=Ds(e,t,W,i,r,!0).placement,C=r.halvesTolerance??s,$=oe=>!!oe&&oe.clipIndex===S.clipIndex&&Math.abs(oe.offset-X)<=C;if(!$(F)||!$(H))return{...P,declined:"halves-disagree"}}let q=new Set;for(let W=0;W<L.length;W++)V[W]>=m*z&&q.add(L[W].offset);return{refStart:n,refEnd:i,declined:null,hold:!1,ramp:null,placement:{refStart:n,refEnd:i,clipIndex:S.clipIndex,clipLabel:k,offset:X,peak:z,share:S.share,consensus:j,votingFrames:y,ambiguity:q.size,truncated:x,rivals:T.slice(1).map(W=>({clipIndex:W.clipIndex,clipLabel:t.find(F=>F.clipIndex===W.clipIndex)?.label??String(W.clipIndex),share:W.share}))}}}var QU=8,_U=1,Ry=1e-6,$U=.05,eC=3,tC=64;function gz(e,t,n){let i=e.frames.filter(a=>a.f>=t&&a.f<=n),r=new Map,o=0;for(let a of i)for(let s of a.picks)r.set(s.clipIndex,(r.get(s.clipIndex)??0)+s.weight),o+=s.weight;return{frames:i,votingFrames:i.length,truncated:e.truncated,massByClip:r,totalMass:o}}function Ny(e,t,n,i,r={}){let o=r.threshold??Yn,a=r.kernelRadius??Tz,s=r.consensusWindow??wz,c=r.minClipShare??xz,l=r.tau??Pz,u=r.minConsensus??kz,f=r.minVotingFrames??Sz,d=r.ambiguityFraction??zz,m=Math.max(1,r.maxCandidates??tC),p=i-n+1;if(p<2)return null;let h=yz(e,o,l,r),b=r.embedding?r.embedding.ref.length:e.length,v=AU(b,t,n,i,h,m,r.searchWindow);if(v.totalMass<=0||v.votingFrames<f*p)return null;let g=[...v.massByClip.entries()].map(([F,H])=>({clipIndex:F,mass:H,share:H/v.totalMass})).sort((F,H)=>H.mass-F.mass||F.clipIndex-H.clipIndex),y=g[0];if(y.share<c||g.length>1&&Math.abs(g[0].mass-g[1].mass)<=1e-9*v.totalMass)return null;let w=t.find(F=>F.clipIndex===y.clipIndex)?.label??String(y.clipIndex),x=1/0,O=-1/0;for(let F of v.frames)for(let H of F.picks)H.clipIndex===y.clipIndex&&(H.frame<x&&(x=H.frame),H.frame>O&&(O=H.frame));if(!Number.isFinite(x))return null;let P=Math.ceil(Zs*p)+a+2,T=Math.floor(x)-P,S=Math.ceil(O)+P-T+1;if(S<=0||S>4e6)return null;let k={bins:new Float64Array(S),base:T},L=(F,H,C)=>BU(C??v,y.clipIndex,n,F,H,s,d,(C??v).massByClip.get(y.clipIndex)??0,k),z=Math.max(QU/p,1/64),X=Math.max(a,Math.ceil(z*p/2)),V=Math.max(_U/p,1/512),R=(F,H)=>{let C=Math.abs(F)<Ry;if(C&&!vz(e,n,i)||!C&&r.forceSlope==null&&Math.abs(F-1)<$U||!C&&Math.abs(F)<qp||H.consensus<u)return null;if(p>=2*8){let ue=n+(p>>1),ze=[gz(v,n,ue-1),gz(v,ue,i)];for(let Re of ze){if(Re.totalMass<=0)return null;let yt=Re.massByClip.get(y.clipIndex)??0;if(yt<=0||yt/Re.totalMass<c)return null;let rt=L(F,a,Re);if(!rt||Math.abs(rt.intercept-H.intercept)>(r.halvesTolerance??a))return null}}let oe=(ue,ze)=>{let Re=[];for(let yt of v.frames){let rt=yt.f-n,zt=ze+ue*rt;for(let qt of yt.picks)qt.clipIndex===y.clipIndex&&Math.abs(qt.frame-zt)<=eC&&Re.push({x:rt,y:qt.frame,w:qt.weight})}return Re},ye=(ue,ze,Re)=>{let yt=0,rt=0;for(let zt of ue)yt+=zt.w,rt+=zt.w*Math.abs(zt.y-(Re+ze*zt.x));return yt>0?rt/yt:1/0},Ae=F,de=H.intercept,Oe=oe(Ae,de);if(Oe.length===0)return null;let Ze=ye(Oe,Ae,de);if(C){let ue=0,ze=0;for(let Re of Oe)ue+=Re.w,ze+=Re.w*Re.y;if(ue>0){let Re=ze/ue,yt=oe(0,Re);yt.length>0&&ye(yt,0,Re)<Ze&&(de=Re,Oe=yt,Ze=ye(Oe,0,Re))}}else{let ue=0,ze=0,Re=0;for(let Ot of Oe)ue+=Ot.w,ze+=Ot.w*Ot.x,Re+=Ot.w*Ot.y;let yt=ze/ue,rt=Re/ue,zt=0,qt=0;for(let Ot of Oe){let pt=Ot.x-yt;zt+=Ot.w*pt*(Ot.y-rt),qt+=Ot.w*pt*pt}if(qt>1e-9){let Ot=zt/qt,pt=rt-Ot*yt,_=oe(Ot,pt);Math.abs(Ot-F)<=2*V&&Math.abs(Ot)>=qp&&Math.abs(Ot)<=Zs&&_.length>0&&ye(_,Ot,pt)<Ze&&(Ae=Ot,de=pt,Oe=_,Ze=ye(Oe,Ae,de))}}return{clipIndex:y.clipIndex,clipLabel:w,srcAtStart:Math.round(de),slope:C?0:Ae,pieces:v.votingFrames,residual:Ze,ambiguity:H.ambiguity}};if(r.forceSlope!=null){let F=L(r.forceSlope,a);return F?R(r.forceSlope,F):null}let j=[];for(let F=-Zs;F<=Zs+1e-9;F+=z){let H=Math.abs(F)<Ry?0:F,C=L(H,X);C&&j.push({slope:H,peak:C.peak})}let J=L(0,X);if(J&&j.push({slope:0,peak:J.peak}),j.length===0)return null;j.sort((F,H)=>H.peak-F.peak||F.slope-H.slope);let q=(F,H)=>F.coverage!==H.coverage?F.coverage>H.coverage:F.peak>H.peak,W=null;for(let F of j.slice(0,4)){for(let H=F.slope-z;H<=F.slope+z+1e-9;H+=V){let C=Math.abs(H)<Ry?0:H;if(Math.abs(C)>Zs)continue;let $=L(C,a);$&&(!W||q($,W.p))&&(W={slope:C,p:$})}if(F.slope===0){let H=L(0,a);H&&(!W||q(H,W.p))&&(W={slope:0,p:H})}}return W?R(W.slope,W.p):null}var qs=3,Mz=8,Xy=.5,qp=.1,Zs=8;function nC(e,t,n,i,r={}){let o=i-n+1,a=[6,4,3].filter(l=>Math.floor(o/l)>=Mz),s=null;for(let l of a){let u=Math.floor(o/l),f=iC(e,t,n,i,l,u,r);if(f.ramp){s=f.ramp;break}if(f.placed>=qs)return null}return s?rC(e,t,n,i,s,r)??s:null}function rC(e,t,n,i,r,o){let a=i-n+1,s=Math.min(6,Math.floor(a/Mz));if(s<qs)return null;let c=Math.floor(a/s),l=d=>r.srcAtStart+r.slope*(d-n),u=[];for(let d=0;d<s;d++){let m=n+d*c,p=d===s-1?i:m+c-1,h=m+p>>1,b=l(h),v=Ds(e,t,m,p,{...o,searchWindow:{clipIndex:r.clipIndex,lo:Math.floor(b-c*2),hi:Math.ceil(b+c*2)}},!0).placement;v&&u.push({ref:h,src:h+v.offset})}if(u.length<qs)return null;let f=Lz(u,Math.max(2,Xy*c));return!f||f.inliers<qs||!(Math.abs(f.slope)>=qp&&Math.abs(f.slope)<=Zs)||f.inliers<r.pieces||f.inliers===r.pieces&&f.residual>=r.residual?null:{...r,srcAtStart:Math.round(f.slope*n+f.intercept),slope:f.slope,pieces:f.inliers,residual:f.residual}}function iC(e,t,n,i,r,o,a){let s=[];for(let f=0;f<r;f++){let d=n+f*o,m=f===r-1?i:d+o-1,p=Ds(e,t,d,m,a,!0).placement;if(!p)continue;let h=d+m>>1;s.push({ref:h,src:h+p.offset,clipIndex:p.clipIndex})}if(s.length<qs)return{ramp:null,placed:s.length};let c=s[0].clipIndex,l=s.length;if(s.some(f=>f.clipIndex!==c))return{ramp:null,placed:l};let u=Lz(s,Math.max(2,Xy*o));return u?Math.abs(u.slope)>=qp&&Math.abs(u.slope)<=Zs?u.inliers<qs?{ramp:null,placed:l}:u.residual>Xy*o?{ramp:null,placed:l}:{ramp:{clipIndex:c,clipLabel:t.find(f=>f.clipIndex===c)?.label??String(c),srcAtStart:Math.round(u.slope*n+u.intercept),slope:u.slope,pieces:u.inliers,residual:u.residual},placed:l}:{ramp:null,placed:l}:{ramp:null,placed:l}}function Lz(e,t){let n=a=>{let s=0,c=0;for(let p of a)s+=p.ref,c+=p.src;let l=s/a.length,u=c/a.length,f=0,d=0;for(let p of a){let h=p.ref-l;f+=h*(p.src-u),d+=h*h}if(d<=1e-9)return null;let m=f/d;return{slope:m,intercept:u-m*l}},i=null;for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){let c=e[s].ref-e[a].ref;if(c===0)continue;let l=(e[s].src-e[a].src)/c,u=e[a].src-l*e[a].ref,f=e.filter(d=>Math.abs(d.src-(l*d.ref+u))<=t);(!i||f.length>i.length)&&(i=f)}if(!i||i.length<qs)return null;let r=n(i);if(!r)return null;let o=0;for(let a of i)o+=Math.abs(a.src-(r.slope*a.ref+r.intercept));return{...r,residual:o/i.length,inliers:i.length}}function Rz(e,t,n={}){let{embedding:i,...r}=n,o=i?{...r,embedding:i,halvesTolerance:n.halvesTolerance??JU}:null,a=DU(e,r);return UU(e.length,a).map(s=>{if(vz(e,s.start,s.end)){let u=Ds(e,t,s.start,s.end,r),f=u.placement?null:Ny(e,t,s.start,s.end,{...r,forceSlope:0});return{...u,hold:!0,ramp:f}}let c=Ds(e,t,s.start,s.end,r);if(c.placement)return c;if(c.declined==="halves-disagree"){let u=Ny(e,t,s.start,s.end,r)??nC(e,t,s.start,s.end,r);if(u)return{...c,ramp:u}}if(!o||c.declined!=="no-votes")return c;let l=Ds(e,t,s.start,s.end,o);if(l.placement)return{...l,tier:"embedding"};if(l.declined==="halves-disagree"){let u=Ny(e,t,s.start,s.end,o);if(u)return{...l,ramp:u,tier:"embedding"}}return c})}var oC=24,Nz=Yn+oC,jy=8,aC=4,Xz="screened out before full match:";function jz(e){return Math.max(1,e)*jy}function sC(e,t){let n=1/0;for(let i of e)for(let r of t){let o=mn(i,r);if(o<n&&(n=o,n===0))return 0}return n}function Fz(e,t){if(!e.length||!t.length)return{minDistance:1/0,skip:!1,reason:"coarse pass returned no frames \u2014 kept, absence of evidence is not evidence"};let n=sC(e,t),i=n>Nz;return{minDistance:n,skip:i,reason:i?`best frame ${n} bits from the reference, past the ${Nz}-bit cutoff`:`best frame ${n} bits \u2014 inside the cutoff, full pass`}}function Iz(e){return e>=aC}var Up=12,cC=12,Fy="not examined:";function Vz(e){return e<=Up?1:Math.max(1,Math.floor(e/Up))}function Wz(e,t,n,i,r){let o=0,a=1/0;for(let s of n){let c=1/0;for(let l of i){let u=mn(s,l);if(u<c&&(c=u,c===0))break}c<=Yn&&o++,c<a&&(a=c)}return{clipIndex:e,label:t,hits:o,minDistance:a,probes:n.length,spacing:r}}function Ez(e){return e.probes>0?e.hits/e.probes:0}function Hz(e){return e.map((t,n)=>({s:t,i:n})).sort((t,n)=>{let i=t.s.probes===0,r=n.s.probes===0;if(i!==r)return i?-1:1;let o=Ez(t.s),a=Ez(n.s);return o!==a?a-o:t.s.minDistance!==n.s.minDistance?t.s.minDistance-n.s.minDistance:t.i-n.i}).map(t=>t.s)}function Zz(e){return e>=cC}var Cp=3;function Dz(e){let t=0,n=0;for(let i=0;i<e.length;i++)e[i]?n=0:++n>t&&(t=n);return t}function qz(e){return Number.isFinite(e.worstContributor)?e.coverageComplete&&e.dryStreak>=Cp&&e.nextScore>e.worstContributor:!1}var lC=3,Ja=48,Uz=Yn;function Jp(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"").replace(/_\d{3}$/,"").toLowerCase()}function uC(e){return Jp(e).replace(/^v\d+-\d{4}_/,"")}function fC(e,t){let n=(c,l,u)=>{if(!c)return null;let f=l(c),d=t.reduce((m,p,h)=>u(p)===f?[...m,h]:m,[]);return d.length===1?d[0]:null},i=c=>n(c,Jp,l=>l),r=i(e.sourceFilename);if(r!=null)return r;let o=i(e.clipName);if(o!=null)return o;let a=c=>n(c,uC,l=>l.replace(/^v\d+-\d{4}_/,"")),s=a(e.sourceFilename)??a(e.clipName);if(s!=null)return s;if(e.reelName){let c=Jp(e.reelName),l=t.reduce((u,f,d)=>f.startsWith(c)?[...u,d]:u,[]);if(l.length===1)return l[0]}return null}function dC(e,t,n=lC){let i=t-e+1;if(i<=0)return[];if(i<=n)return Array.from({length:i},(s,c)=>e+c);let r=Math.max(1,Math.floor(i*.1)),o=e+r,a=t-r;return a<=o?[e+(i>>1)]:Array.from({length:n},(s,c)=>o+Math.round(c*(a-o)/(n-1)))}function mC(e,t,n){let i=e.declaredSpeed??1;return Math.round(n+(t-e.refStart)*i)}async function Cz(e,t,n,i,r,o){let a=o.srcFrames(t),s=0;for(let c=0;c<i.length;c++){let l=r[c];if(!l)return null;let u=mC(e,i[c],n);if(u<0||a>0&&u>=a)return null;let f=await o.srcHash(t,u);if(!f)return null;let d=mn(l,f);d>s&&(s=d)}return s}async function pC(e,t,n){let i={hint:e,clipIndex:t,srcStart:null,correction:0,worstDistance:1/0};if(t==null)return{...i,outcome:"unbound",reason:`no file in the bucket answers to ${[e.sourceFilename,e.clipName,e.reelName].filter(Boolean).join(" / ")||"any name"} \u2014 this shot goes to the pixel search`};if(e.declaredReframe)return{...i,clipIndex:t,srcStart:e.srcStart,outcome:"reframe-declined",reason:"the timeline declares a resize on this shot, so a whole-frame hash cannot confirm its in-point \u2014 the clip and the cut are taken, the in-point is resolved from the picture"};let r=dC(e.refStart,e.refEnd);if(!r.length)return{...i,outcome:"unreadable",reason:"the hinted span has no frames"};let o=await Promise.all(r.map(c=>n.refHash(c)));if(o.some(c=>!c))return{...i,outcome:"unreadable",reason:"the reference frames for this span could not be read \u2014 the claim is untested, not disproved"};let a=await Cz(e,t,e.srcStart,r,o,n);if(a!=null&&a<=Uz)return{...i,clipIndex:t,srcStart:e.srcStart,correction:0,worstDistance:a,outcome:"confirmed",reason:`every sample within ${a} bits at the declared in-point`};let s=null;for(let c=1;c<=Ja&&!s;c++)for(let l of[e.srcStart-c,e.srcStart+c]){if(l<0)continue;let u=await Cz(e,t,l,r,o,n);if(u!=null&&u<=Uz){s={srcStart:l,worst:u};break}}if(s){let c=s.srcStart-e.srcStart;return{...i,clipIndex:t,srcStart:s.srcStart,correction:c,worstDistance:s.worst,outcome:"corrected",reason:`the declared in-point is out by ${c>0?"+":""}${c} frame(s) \u2014 the picture matches at ${s.srcStart} within ${s.worst} bits`}}return{...i,clipIndex:t,outcome:"refuted",worstDistance:a??1/0,reason:a==null?"the claimed source frames could not be read from this clip \u2014 sent to the pixel search":`the picture does not match this clip at the declared in-point (${a} bits) or within ${Ja} frames of it \u2014 sent to the pixel search`}}async function Jz(e,t,n,i){let r=t.map(Jp),o=[];for(let a of e){let s=fC(a,r);o.push(await pC(s==null?a:await hC(a,s,n),s,n)),i?.(o.length,e.length)}return o}async function hC(e,t,n){if(e.srcTimecode==null||!n.srcTimecode)return e;let i=await n.srcTimecode(t).catch(()=>null);if(!i||!(i.fps>0))return e;let r=e.srcRate&&e.srcRate>0?e.srcRate:i.fps,o=Math.round(i.fps)===Math.round(r)&&!!e.srcDropFrame==!!i.dropFrame,a=o?null:Li(e.srcTimecode,r,!!e.srcDropFrame).split(/[:;]/).map(Number),s=o?e.srcTimecode:Vp(`${a[0]}:${a[1]}:${a[2]}${i.dropFrame?";":":"}${Math.round(a[3]*Math.round(i.fps)/Math.round(r))}`,i.fps)?.frames;if(s==null)return e;let c=s-i.start,l=n.srcFrames(t);return c<0||l>0&&c>=l||c===e.srcStart?e:{...e,srcStart:c}}function Kz(e){let t={confirmed:0,corrected:0,refuted:0,unbound:0,"reframe-declined":0,unreadable:0,total:e.length};for(let n of e)t[n.outcome]++;return t}var Rf=24,Kp=1440,bC=.55;function sa(e,t=0,n=e.length-1){let i=Math.max(1,t+1),r=Math.min(e.length-1,n),o=new Float64Array(Math.max(0,r-i+1));for(let a=i;a<=r;a++){let s=mn(e[a],e[a-1]);o[a-i]=Number.isFinite(s)?s:0}return o}function Iy(e,t,n,i={}){let{perClip:r=2,apart:o=24,minR:a=bC}=i,s=e.length;if(s<Rf)return[];let c=0;for(let m of e)c+=m;c/=s;let l=0;for(let m of e)l+=(m-c)**2;if(l<1e-9)return[];let u=Math.sqrt(l),f=e.map(m=>(m-c)/u),d=[];for(let m of n){let p=m.deltas;if(p.length<s)continue;let h=new Float64Array(p.length+1),b=new Float64Array(p.length+1);for(let y=0;y<p.length;y++)h[y+1]=h[y]+p[y],b[y+1]=b[y]+p[y]*p[y];let v=[];for(let y=0;y+s<=p.length;y++){let w=h[y+s]-h[y],x=b[y+s]-b[y]-w*w/s;if(x<1e-9)continue;let O=0;for(let T=0;T<s;T++)O+=f[T]*p[y+T];let P=O/Math.sqrt(x);P>=a&&v.push({at:y,r:P})}v.sort((y,w)=>w.r-y.r);let g=[];for(let y of v)if(g.every(w=>Math.abs(w.at-y.at)>=o)&&g.push(y),g.length>=r)break;for(let y of g)d.push({clipIndex:m.clipIndex,label:m.label,offset:y.at-t,r:y.r})}return d.sort((m,p)=>p.r-m.r)}var Gz=new Map;function gC(e,t){let n=Gz.get(e*4096+t);if(!n){n=new Int32Array(e);for(let i=0;i<e;i++)n[i]=Math.min(t-1,i*t/e|0);Gz.set(e*4096+t,n)}return n}function Wn(e,t=48,n=Math.max(1,Math.round(t*(e?.h??1)/(e?.w??1)))){if(!e||!e.w||!e.h)return null;let i=new Float32Array(t*n),r=new Float32Array(t*n),o=gC(e.w,t),a=e.y;for(let s=0;s<e.h;s++){let c=Math.min(n-1,s*n/e.h|0)*t,l=s*e.w;for(let u=0;u<e.w;u++){let f=c+o[u];i[f]+=a[l+u],r[f]++}}for(let s=0;s<i.length;s++)i[s]/=r[s]||1;return i}function vi(e,t,n,i,r=48,o=Math.max(1,Math.round(r*i/n))){if(!e||!e.w||!e.h||!n||!i)return null;let a=new Float32Array(r*o),s=4,[c,l,u,f,d,m,p,h,b]=t;for(let v=0;v<o;v++)for(let g=0;g<r;g++){let y=0,w=0;for(let x=0;x<s;x++)for(let O=0;O<s;O++){let P=(g+(O+.5)/s)*n/r-.5,T=(v+(x+.5)/s)*i/o-.5,S=p*P+h*T+b;if(Math.abs(S)<1e-12)continue;let k=Math.round((c*P+l*T+u)/S),L=Math.round((f*P+d*T+m)/S);k<0||L<0||k>=e.w||L>=e.h||(y+=e.y[L*e.w+k],w++)}a[v*r+g]=w?y/w:0}return a}function Az(e,t,n,i,r,o=3,a=6){let s=e.slice(1).map((f,d)=>Gp(e[d],f)),c=t.slice(1).map((f,d)=>Gp(t[d],f)),l=[];for(let f=i;f<=r;f++){let d=0,m=0;for(let p=0;p<s.length;p++){let h=c[f-n+p];!s[p]||!h||(d+=Bz(s[p],h),m++)}m>=Math.max(4,s.length>>1)&&l.push([f,d/m])}l.sort((f,d)=>d[1]-f[1]);let u=[];for(let[f,d]of l)if(u.every(m=>Math.abs(m.src-f)>=a)&&u.push({src:f,score:d}),u.length>=o)break;return u}function fo(e){let[t,n,i,r,o,a,s,c,l]=e,u=o*l-a*c,f=-(r*l-a*s),d=r*c-o*s,m=t*u+n*f+i*d;return!Number.isFinite(m)||Math.abs(m)<1e-12?null:[u/m,-(n*l-i*c)/m,(n*a-i*o)/m,f/m,(t*l-i*s)/m,-(t*a-i*r)/m,d/m,-(t*c-n*s)/m,(t*o-n*r)/m]}function Gp(e,t){if(!e||!t||e.length!==t.length)return null;let n=new Float32Array(e.length);for(let i=0;i<e.length;i++)n[i]=t[i]-e[i];return n}function Bz(e,t){let n=0,i=0;for(let s=0;s<e.length;s++)n+=e[s],i+=t[s];n/=e.length,i/=e.length;let r=0,o=0,a=0;for(let s=0;s<e.length;s++){let c=e[s]-n,l=t[s]-i;r+=c*l,o+=c*c,a+=l*l}return o>0&&a>0?r/Math.sqrt(o*a):0}function ca(e,t,n,i,r){let o=e.slice(1).map((d,m)=>Gp(e[m],d)),a=t.slice(1).map((d,m)=>Gp(t[m],d)),s=[];for(let d=i;d<=r;d++){let m=0,p=0;for(let h=0;h<o.length;h++){let b=a[d-n+h];!o[h]||!b||(m+=Bz(o[h],b),p++)}p>=Math.max(4,o.length>>1)&&s.push([d,m/p])}if(!s.length)return null;s.sort((d,m)=>m[1]-d[1]);let[c,l]=s[0],u=s.find(([d])=>Math.abs(d-c)>2)?.[1]??0,f=l-u;return{src:c,score:l,margin:f,clear:l>=.3&&f>=.1}}function Io(e,t){if(!e)return null;let n=e.length/t,i=new Float32Array(2*e.length);for(let r=0;r<n;r++)for(let o=0;o<t;o++){let a=r*t+o;i[a]=e[r*t+Math.min(t-1,o+1)]-e[r*t+Math.max(0,o-1)],i[e.length+a]=e[Math.min(n-1,r+1)*t+o]-e[Math.max(0,r-1)*t+o]}return i}function Ap(e,t){let n=0,i=0;for(let s=0;s<e.length;s++)n+=e[s],i+=t[s];n/=e.length,i/=t.length;let r=0,o=0,a=0;for(let s=0;s<e.length;s++){let c=e[s]-n,l=t[s]-i;r+=c*l,o+=c*c,a+=l*l}return o>0&&a>0?r/Math.sqrt(o*a):0}var Nf=.4,$z=12,$p=null;function e9(e){$p=e}function Vy(){return $p!==null}function Yz(e){let t=new Uint8Array(e.reduce((i,r)=>i+r.w*r.h,0)),n=0;for(let i of e)t.set(i.y.subarray(0,i.w*i.h),n),n+=i.w*i.h;return t}async function Ri(e,t={}){let n=e.filter(a=>a.src.w===e[0].src.w&&a.src.h===e[0].src.h&&a.ref.w===e[0].ref.w&&a.ref.h===e[0].ref.h);if(!n.length)return null;let i=n.map(a=>a.src),r=n.map(a=>a.ref),o;return $p?o=await $p(i,r,JSON.stringify(t)):(await _c(),o=JSON.parse(oT(Yz(i),i[0].w,i[0].h,Yz(r),r[0].w,r[0].h,i.length,JSON.stringify(t)))),o.ok?o:null}function vC(e,t,n,i,r,o=i,a=r){let s=e.transform,c=(t-1)/2,l=(n-1)/2,u=s[0]*c+s[1]*l+s[2]+.5,f=s[3]*c+s[4]*l+s[5]+.5,d=(u-i/2)*(o/i),m=(f-r/2)*(a/r);return{scale:e.scale_fit,scaleX:e.scale_fit,scaleY:e.scale_fit,rotationDeg:e.rotation_deg,dxCenter:d,dyCenter:m,perspective:!1,label:t9(e.scale_fit,d,m,e.rotation_deg,e.flip_h,e.flip_v),flipH:e.flip_h,flipV:e.flip_v,score:e.score,measuredBy:"sizing"}}function t9(e,t,n,i,r,o){let a=[];return Math.abs(e-1)>.001&&a.push(e>1?`punch-in ${e.toFixed(3)}\xD7`:`pull-out ${e.toFixed(3)}\xD7`),(Math.abs(t)>=1||Math.abs(n)>=1)&&a.push(`shift ${Math.round(t)},${Math.round(n)}px`),Math.abs(i)>=.05&&a.push(`rot ${i.toFixed(2)}\xB0`),r&&a.push("flop"),o&&a.push("flip"),a.join(" \xB7 ")||"1:1"}function Ni(e,t,n=$z){let i=Math.min(t,e+1),r=Math.max(i,t-1),o=Math.max(1,Math.min(n,r-i+1));return Array.from({length:o},(a,s)=>Math.round(i+(s+.5)*(r-i+1)/o-.5))}var Ey={scale:.004,px:1.5,deg:.1},Bp=3,yC=.05,Yp=[.04,.27,.5,.73,.96],Qp={scale:.003,px:1.5,deg:.1};function Qz(e,t){return Math.abs(Math.log(e.scale/t.scale))>Ey.scale||Math.hypot(e.dxCenter-t.dxCenter,e.dyCenter-t.dyCenter)>Ey.px||Math.abs(e.rotationDeg-t.rotationDeg)>Ey.deg||e.flipH!==t.flipH||e.flipV!==t.flipV}function _z(e,t,n,i,r){return{...e,scale:t,scaleX:t,scaleY:t,dxCenter:n,dyCenter:i,rotationDeg:r,label:t9(t,n,i,r,e.flipH,e.flipV)}}function _p(e,t){let n=e.length,i=e.reduce((l,u)=>l+u,0)/n,r=t.reduce((l,u)=>l+u,0)/n,o=0,a=0;for(let l=0;l<n;l++)o+=(e[l]-i)*(t[l]-r),a+=(e[l]-i)**2;let s=a>0?o/a:0,c=l=>r+s*(l-i);return{at:c,worst:Math.max(...e.map((l,u)=>Math.abs(c(l)-t[u])))}}async function n9(e,t,n={}){let i=0,r=0,o=0,a=e.timeline.filter(u=>u.clipLabel&&u.srcStart!=null&&u.srcEnd!=null&&(u.kind==="static"||u.kind==="unresolved")),s=0,c=async()=>{for(;s<a.length;)await l(a[s++])},l=async u=>{let f=Math.max(1,u.refEnd-u.refStart),d=n.hint?.(u.refStart),m=T=>d?{...n.params,min_scale:d/T,max_scale:d*T}:n.params,p=T=>Math.round(u.srcStart+(T-u.refStart)*(u.srcEnd-u.srcStart)/f),h=async T=>{let S=[];for(let k of T){let[L,z]=await Promise.all([t.ref(k),t.src(u.clipLabel,p(k))]);L&&z&&S.push({u:k,src:z,ref:L})}return S},b=(T,S)=>vC(T,S.src.w,S.src.h,S.ref.w,S.ref.h,e.refW||S.ref.w,e.refH||S.ref.h),v=async T=>{let S=Math.round(u.refStart+T*f),k=Math.max(u.refStart,Math.min(u.refEnd-Bp+1,S-(Bp>>1))),L=await h(Array.from({length:Math.min(Bp,f+1)},(X,V)=>k+V)),z=L.length?await Ri(L,m(1.35)):null;return z&&z.score>=Nf?{u:L.reduce((X,V)=>X+V.u,0)/L.length,r:b(z,L[0]),score:z.score}:null},g=await h(Ni(u.refStart,u.refEnd,n.pairs??$z)),y=g.length?await Ri(g,m(1.1)):null,w=u.refStart+u.refEnd>>1,x=f>=4*Bp?await Promise.all([v(Yp[0]),v(Yp[Yp.length-1])]):[null,null],O=y!=null&&x[0]!=null&&x[1]!=null&&y.score>=Math.min(x[0].score,x[1].score)-yC;if(x[0]&&x[1]&&Qz(x[0].r,x[1].r)&&n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ends differ (${x[0].r.label} \u2192 ${x[1].r.label}); static ${y?.score.toFixed(2)??"-"} vs ends ${x[0].score.toFixed(2)}/${x[1].score.toFixed(2)}`),x[0]&&x[1]&&Qz(x[0].r,x[1].r)&&!O){let T=await Promise.all(Yp.slice(1,-1).map(v)),S=[x[0],...T,x[1]].filter(W=>!!W),k=S.map(W=>W.u),L=_p(k,S.map(W=>W.r.scale)),z=_p(k,S.map(W=>W.r.dxCenter)),X=_p(k,S.map(W=>W.r.dyCenter)),V=_p(k,S.map(W=>W.r.rotationDeg)),R=L.worst/L.at(w)<Qp.scale&&z.worst<Qp.px&&X.worst<Qp.px&&V.worst<Qp.deg,j=(W,F,H)=>{let C=(H-W.u)/Math.max(1e-9,F.u-W.u),$=oe=>W.r[oe]+(F.r[oe]-W.r[oe])*C;return{refFrame:H,reframe:_z(W.r,$("scale"),$("dxCenter"),$("dyCenter"),$("rotationDeg"))}},J=S.length,q=R?[u.refStart,u.refEnd].map(W=>({refFrame:W,reframe:_z(S[0].r,L.at(W),z.at(W),X.at(W),V.at(W))})):[j(S[0],S[1],u.refStart),...S.map(W=>({refFrame:Math.round(W.u),reframe:W.r})),j(S[J-2],S[J-1],u.refEnd)];u.kind="animated",u.track={kind:"animated",keyframes:q,label:`animated \xB7 ${q[0].reframe.label} \u2192 ${q[q.length-1].reframe.label}`},i++,r++,n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ${u.track.label} (${R?"linear":`${q.length} keys`})`);return}if(!y||y.score<Nf){o++,u.kind="unresolved",u.track={kind:"unresolved",keyframes:[],label:`sizing not measured: agreement ${y?y.score.toFixed(2):"none"}, below ${Nf}`},n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: untrusted ${y?y.score.toFixed(2):"no fit"}`);return}let P=b(y,g[0]);u.kind="static",u.track={kind:"static",keyframes:[{refFrame:w,reframe:P}],label:P.label},i++,n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ${P.label} (agreement ${y.score.toFixed(2)})`)};return await Promise.all(Array.from({length:Math.max(1,n.concurrency??3)},c)),{sized:i,animated:r,untrusted:o}}var wC=(()=>{let e=new Float32Array(512);for(let t=0;t<512;t++)e[t]=.5-.5*Math.cos(2*Math.PI*t/512);return e})(),r9=(()=>{let e=new Float64Array(256),t=new Float64Array(512/2);for(let n=0;n<512/2;n++)e[n]=Math.cos(-2*Math.PI*n/512),t[n]=Math.sin(-2*Math.PI*n/512);return{c:e,s:t}})(),i9=(()=>{let e=new Uint16Array(512);for(let t=1,n=0;t<512;t++){let i=256;for(;n&i;i>>=1)n^=i;n^=i,e[t]=n}return e})();function xC(e){let t=[],n=new Float64Array(512),i=new Float64Array(512);for(let r=0;r+512<=e.length;r+=64){for(let a=0;a<512;a++)n[i9[a]]=e[r+a]*wC[a],i[i9[a]]=0;for(let a=2;a<=512;a<<=1){let s=a>>1,c=512/a;for(let l=0;l<512;l+=a)for(let u=0;u<s;u++){let f=r9.c[u*c],d=r9.s[u*c],m=l+u,p=m+s,h=n[p]*f-i[p]*d,b=n[p]*d+i[p]*f;n[p]=n[m]-h,i[p]=i[m]-b,n[m]+=h,i[m]+=b}}let o=new Float32Array(512/2);for(let a=0;a<512/2;a++)o[a]=Math.log1p(Math.hypot(n[a],i[a])*100);t.push(o)}return t}function PC(e){let t=new Map;for(let i=4;i<e.length-4;i++)for(let r=8;r<240;r++){let o=e[i][r];if(o<1)continue;let a=!0;for(let l=-4;l<=4&&a;l++)for(let u=-7;u<=7;u++)if((l||u)&&e[i+l][r+u]>=o){a=!1;break}if(!a)continue;let s=Math.floor(i/12),c=t.get(s);c||t.set(s,c=[]),c.push([i,r,o])}let n=[];for(let i of t.values())for(let r of i.sort((o,a)=>a[2]-o[2]).slice(0,5))n.push([r[0],r[1]]);return n.sort((i,r)=>i[0]-r[0])}function eh(e){let t=PC(xC(e)),n=[],i=[];for(let r=0;r<t.length;r++){let o=0;for(let a=r+1;a<t.length&&o<6;a++){let s=t[a][0]-t[r][0];if(s<2)continue;if(s>63)break;let c=t[a][1]-t[r][1];Math.abs(c)>63||(n.push(t[r][1]<<14|c+64<<6|s),i.push(t[r][0]),o++)}}return{hash:Uint32Array.from(n),t:Uint32Array.from(i)}}var Ka=class{constructor(){this.post=new Map;this.clips=new Set}add(t,n){this.addMarks(t,eh(n))}addMarks(t,{hash:n,t:i}){for(let r=0;r<n.length;r++){let o=this.post.get(n[r]);o||this.post.set(n[r],o=[]),o.push(t,i[r])}this.clips.add(t)}get size(){return this.post.size}static reference(t){return eh(t)}nominate(t,n,i,r=3){let o=Math.floor(n/.008),a=Math.ceil(i/.008),s=new Map;for(let u=0;u<t.hash.length;u++){let f=t.t[u];if(f<o||f>=a)continue;let d=this.post.get(t.hash[u]);if(d)for(let m=0;m<d.length;m+=2){let p=d[m]*16777216+(d[m+1]-f+8388608);s.set(p,(s.get(p)??0)+1)}}let c=[...s].sort((u,f)=>f[1]-u[1]),l=[];for(let[u,f]of c){let d=Math.floor(u/16777216),m=u%16777216-8388608;if(l.some(h=>h.clip===d))continue;let p=c.find(([h])=>Math.floor(h/16777216)!==d||Math.abs(h%16777216-8388608-m)>3)?.[1]??0;if(l.push({clip:d,shiftSec:m*.008,votes:f,rival:p}),l.length>=r)break}return l}},kC=12,SC=3,o9=e=>e.votes>=kC&&e.votes>=SC*Math.max(1,e.rival);function a9(e,t=6){let n=[],i=r=>r.length?(r.sort((o,a)=>o-a),r[r.length>>1]):0;for(let r=0;r<e.length;r++){let o=e[r];if(o<70)continue;let a=[],s=[];for(let p=Math.max(0,r-8);p<r;p++)a.push(e[p]);for(let p=r+1;p<=Math.min(e.length-1,r+8);p++)s.push(e[p]);let c=[a,s].filter(p=>p.length).map(p=>i([...p])),l=c.length?Math.min(...c):0,u=c.length?Math.max(...c):0,f=o>=2.5*Math.max(8,i([...a,...s])),d=o>=2.5*Math.max(8,l)&&o>=1.6*u;if(!f&&!d)continue;let m=r+1;if(n.length&&m-n[n.length-1]<t){o>e[n[n.length-1]-1]&&(n[n.length-1]=m);continue}n.push(m)}return n}function s9(e,t){let n=[],i=0;for(let r of[...t,e])r>i&&n.push({refStart:i,refEnd:r-1}),i=r;return n}function th(e,t=4){let i=e.refEnd-e.refStart+1>8?2:0,r=e.refStart+i,o=e.refEnd-i,a=Math.max(1,Math.min(t,Math.round((o-r+1)/24)));return a===1?[r+o>>1]:Array.from({length:a},(s,c)=>Math.round(r+c*(o-r)/(a-1)))}var TC=(e,t)=>{let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n};function Wy(e,t,n,i,r=4){let o=[];for(let a of t){let s=i(a.clipIndex),c=e.map(f=>a.vecs.map(d=>TC(f.vec,d))),l={score:-1/0,offset:0,sim:0};for(let f=0;f<e.length;f++){let d=0;for(let b=1;b<c[f].length;b++)c[f][b]>c[f][d]&&(d=b);let m=d*a.stride/s-e[f].frame,p=0;for(let b=0;b<e.length;b++){let v=Math.round((e[b].frame+m)*s/a.stride),g=0;for(let y=v-1;y<=v+1;y++)y>=0&&y<c[b].length&&(g=Math.max(g,c[b][y]));p+=g}let h=p/e.length;h>l.score&&(l={score:h,offset:m,sim:c[f][d]})}if(l.score===-1/0)continue;let u=Math.round((n+l.offset)*s);u<0||u>=a.frames||o.push({clipIndex:a.clipIndex,label:a.label,srcAtProbe:u,sim:l.score,why:`index ${l.score.toFixed(2)}`})}return o.sort((a,s)=>s.sim-a.sim).slice(0,r)}var nh=.35,zC=6,Hy=96,OC=6e3,Us=(e,t)=>Math.floor(e*t+.001),MC=2.5;function LC(e){let n=Wn(e,96);if(!n)return 0;let i=n.length/96,r=0,o=0;for(let a=1;a<i-1;a++)for(let s=1;s<95;s++){let c=a*96+s;r+=Math.abs(n[c+1]-n[c-1])+Math.abs(n[c+96]-n[c-96]),o++}return o?r/o:0}var RC=160;function NC(e,t){if(e.w<=t)return e;let n=t,i=Math.max(1,Math.round(e.h*n/e.w)),r=new Uint8Array(n*i),o=new Float32Array(n*i),a=new Float32Array(n*i);for(let s=0;s<e.h;s++){let c=Math.min(i-1,s*i/e.h|0)*n;for(let l=0;l<e.w;l++){let u=c+Math.min(n-1,l*n/e.w|0);o[u]+=e.y[s*e.w+l],a[u]++}}for(let s=0;s<r.length;s++)r[s]=o[s]/(a[s]||1);return{y:r,w:n,h:i}}var c9=6,Zy=8,rh={turns:!1},Ff=.5,si=12e3,ll=48,XC=24,jC=.3,FC=.1,IC=.15,l9=.35,EC=.05,Dy=3,VC=.05,u9=.1,f9=8,qy=4,Uy=6,WC=.58,HC=.55,Cy=8,d9=3;async function m9(e,t,n){if(t.kind!=="prores")return null;let i=t.offs[n];if(!i)return null;let r=new Uint8Array(await e.slice(i.offset,i.offset+i.size).arrayBuffer()),o=d7(r);return{y:o.y,w:o.width,h:o.height}}function ZC(e,t,n){let i=Math.max(1,Math.ceil(n.count/64)),r=0,o=0;for(let a=0;a<n.count;a+=i){let s=e[n.refStart+a],c=t[n.srcStart+a];!s||!c||(r+=mn(s,c),o++)}return o?r/o:null}async function DC(e){let t=Sf*8;try{for(let n of e){let i=await wn(n);if(!i.spec||i.frames.length<t)return 1}return Sf}catch{return 1}}function qC(e){let t=[];for(let n of e)(n.op==="equal"||n.op==="move")&&t.push({refStart:n.aStart,srcStart:n.bStart,count:n.count});return t}async function Jy(e,t,n={}){let{onProgress:i,signal:r,gapFill:o=!0,candidateLuma:a,referenceLuma:s,fingerprint:c,stride:l,hashFrame:u,audio:f=!0,audioSummary:d,lumaCacheBytes:m,shotVote:p=!0,shotVoteOptions:h,embedSweep:b,shortlist:v=!0,triage:g,examineAll:y=!1,frameCount:w,hints:x,keyframesOf:O,findFirst:P,candidateThumb:T,audioPcm:S,...k}=n,L=()=>{if(r?.aborted)throw new DOMException("Auto Conform cancelled","AbortError")};L(),await Pf();let z=l!==void 0?Math.max(1,Math.floor(l)):c||u?1:await DC([e,...t]),X=c??((Z,re,fe,xe)=>A7(Z,{side:re,onProgress:fe,stride:xe,matte:"cut"})),V=u??(async Z=>Y7(Z,await wn(Z)));i?.(0,t.length,"fingerprinting reference");let R=await X(e,"A",(Z,re)=>i?.(0,t.length,`fingerprinting reference \u2014 frame ${Z}/${re}`),z),j=R.index,J=z>1||x?.shots.length?await V(e,"A"):null,q=[],W=[],F=[],H=[],C=oz(m),$=async Z=>{if(s)return s(Z);let re=await m9(e,j,Z);return re?{y:xy(re.y),w:re.w,h:re.h}:null},oe=async(Z,re)=>{if(a)return a(Z,re);let fe=await m9(t[Z],W[Z],re);return fe?{y:xy(fe.y),w:fe.w,h:fe.h}:null},ye=new Map,Ae=async(Z,re)=>{let fe=C.get(Z);if(fe!==void 0)return fe;let xe=ye.get(Z);return xe||(xe=re().then(Y=>(C.set(Z,Y),Y)).finally(()=>ye.delete(Z)),ye.set(Z,xe)),xe},de=Z=>Ae(`r@${Z}`,()=>Qn("decode ref",()=>$(Z))),Oe=(Z,re)=>Ae(`c${Z}@${re}`,()=>Qn("decode src",()=>oe(Z,re))),Ze=w??(async Z=>(await wn(Z)).frames.length),ue=[],ze=new Map,Re=new Set,yt=[];if(x?.shots.length&&!y&&J){L(),i?.(0,t.length,`checking ${x.shots.length} claims from ${x.timelineName}`);let Z=new Map,re=async Y=>{let le=Z.get(Y);return le||(le={hash:await V(t[Y],"B"),frames:await Ze(t[Y]).catch(()=>0)},Z.set(Y,le)),le},fe={refHash:Y=>J(Y),srcHash:async(Y,le)=>(await re(Y)).hash(le),srcFrames:Y=>Z.get(Y)?.frames??0,srcTimecode:async Y=>{await re(Y);let le=await wn(t[Y]).catch(()=>null);return le&&le.fps?{start:le.startFrame,fps:le.fps,dropFrame:le.dropFrame}:null}},xe=await Jz(x.shots,t.map(Y=>Y.name),fe,(Y,le)=>i?.(0,t.length,`checking claim ${Y}/${le}`));if(a&&s)for(let Y of xe){if(Y.clipIndex==null||Y.outcome!=="refuted"&&Y.outcome!=="reframe-declined")continue;let le=Y.hint,Fe=Y.clipIndex,mt=le.refEnd-le.refStart+1;if(mt<3)continue;let We=le.refStart+le.refEnd>>1,xt=le.declaredSpeed??1,Je=fe.srcFrames(Fe)||await Ze(t[Fe]).catch(()=>0);if(!Je)continue;let qe=Math.round(le.srcStart+(We-le.refStart)*xt),St=await(async()=>{let Ye=le.declaredTransform;if(!Ye)return null;let Ue=await de(We),pn=await Oe(Fe,qe),En=Ue&&pn?hz(Ye,Ue.w,Ue.h,pn.w,pn.h):null;if(!Ue||!pn||!En)return null;let Ce=iz(En,pn.w,pn.h,Ue.w,Ue.h),Pn=Fr=>Oe(Fe,Fr),$n=await sl({transform:Ce,refLuma:de,candLuma:Pn,refProbe:We,srcProbe:qe,frameCount:Je,search:Ja,runSpread:xt===1?Math.max(1,Math.floor(mt/3)):0,runSamples:xt===1?3:1}).catch(()=>null);return!$n||!await zf($n,Ce,de,Pn,We,Hs)?null:{srcAtProbe:$n.srcFrame,score:$n.score}})(),$t=St??await Of({refLuma:de,cand:{label:t[Fe].name,frameCount:Je,luma:Ye=>Oe(Fe,Ye)},refProbe:We,srcGuess:qe,radius:Ja,runSpread:xt===1?Math.max(1,Math.floor(mt/3)):0,reframeOpts:k}).catch(()=>null);if(!$t)continue;let Ht=Math.round($t.srcAtProbe-(We-le.refStart)*xt),be=Ht-le.srcStart;Re.add(Y),Object.assign(Y,{srcStart:Ht,correction:be,worstDistance:$t.score,outcome:be===0?"confirmed":"corrected",reason:`confirmed by ${St?"the declared transform":"geometry"} (the whole-frame hash could not rule: ${Y.outcome==="reframe-declined"?"a declared resize":"a different grade or framing"}) \u2014 `+(be===0?"at the declared in-point":`the in-point is out by ${be>0?"+":""}${be} frame(s)`)})}ue.push(...xe);for(let Y of xe){if(Y.clipIndex==null)continue;let le=ze.get(Y.clipIndex)??{shots:[],clean:!0};if(Re.has(Y)&&Y.srcStart!=null){yt.push({clipIndex:Y.clipIndex,refStart:Y.hint.refStart,refEnd:Y.hint.refEnd,srcStart:Y.srcStart,speed:Y.hint.declaredSpeed??1}),le.clean=!1,ze.set(Y.clipIndex,le);continue}(Y.outcome==="confirmed"||Y.outcome==="corrected")&&Y.srcStart!=null?le.shots.push({refStart:Y.hint.refStart,refEnd:Y.hint.refEnd,srcStart:Y.srcStart}):le.clean=!1,ze.set(Y.clipIndex,le)}}let rt=v&&!y&&z>1&&Iz(t.length),zt=z*jy,qt=!P&&(g??Zz(t.length))&&t.length>1,Ot=[];if(qt){L();for(let Z=0;Z<t.length;Z++){L();let re=t[Z];i?.(Z/t.length,t.length,`triage ${Z+1}/${t.length} \u2014 ${re.name}`);let fe=0;try{fe=await Ze(re)}catch{}if(fe<=0){Ot.push({clipIndex:Z,label:re.name,hits:0,minDistance:1/0,probes:0,spacing:0});continue}let xe=Vz(fe);try{let Y=O?await O(re).catch(()=>null):null,le;if(Y?.length){let Fe=await V(re,"B"),mt=[...new Set(Array.from({length:Math.ceil(fe/xe)},(We,xt)=>Math.min(fe-1,zy(xt*xe,Y))))];le=[];for(let We of mt){let xt=await Fe(We).catch(()=>null);xt&&le.push(xt)}}else le=(await X(re,"B",void 0,xe)).pdq;Ot.push(Wz(Z,re.name,le,R.pdq,xe))}catch{Ot.push({clipIndex:Z,label:re.name,hits:0,minDistance:1/0,probes:0,spacing:xe})}}Ot=Hz(Ot)}let pt=P?t.map((Z,re)=>re).filter(Z=>ze.get(Z)?.clean&&ze.get(Z).shots.length):qt?Ot.map(Z=>Z.clipIndex):t.map((Z,re)=>re),_=new Map(Ot.map(Z=>[Z.clipIndex,Z])),pe=new Uint8Array(j.offs.length),Ne=0,nt=-1/0,dt=[],Kt=async(Z,re,fe,xe)=>{let Y=[];for(let le of re){let Fe=Math.min(5,Math.max(1,le.count)),mt=[];for(let Je=0;Je<Fe;Je++){let qe=Fe===1?le.count>>1:Math.round(Je*(le.count-1)/(Fe-1)),[St,$t]=await Promise.all([de(le.refStart+qe),Oe(Z,fe(le.srcStart+qe))]);if(St&&$t){let Ht=await Qr($t.y,$t.w,$t.h,St.y,St.w,St.h,k),be=Ht.ok?aa(Ht,St.w,St.h):null;mt.push({refFrame:le.refStart+qe,reframe:be,geometry:Ht})}else mt.push({refFrame:le.refStart+qe,reframe:null,geometry:null})}let We=Wp(mt.map(Je=>({refFrame:Je.refFrame,reframe:Je.reframe}))),xt=mt[mt.length>>1];Y.push({refStart:le.refStart,refEnd:le.refStart+le.count-1,srcStart:fe(le.srcStart),srcEnd:fe(le.srcStart+le.count-1),reframe:We.kind==="unresolved"?null:We.keyframes[We.keyframes.length>>1]?.reframe??null,geometry:xt.geometry,track:We,score:xe(le),contestedBy:null})}return Y.sort((le,Fe)=>le.refStart-Fe.refStart),Y},Xt=Z=>({offs:Z.frames,codec:Z.index?.codec??Z.label,kind:Z.spec?Z.spec.codec:Z.index?.kind??"other",w:Z.w,h:Z.h,fps:Z.fps,startFrame:Z.startFrame,dropFrame:Z.dropFrame}),At=2,on=new Map,Be=new Map,at=Z=>(Z.catch(()=>{}),Z),jt=Z=>{let re=pt[Z];re==null||rt||ze.get(re)?.clean&&ze.get(re).shots.length||(on.has(re)||on.set(re,at(X(t[re],"B",void 0,z))),b&&!Be.has(re)&&Be.set(re,at(b(t[re]))))};for(let Z=0;Z<pt.length;Z++){let re=pt[Z],fe=t[re];L();for(let be=1;be<=At;be++)jt(Z+be);let xe=ze.get(re);if(xe?.clean&&xe.shots.length){i?.(Z,t.length,`${fe.name} \u2014 confirmed from the timeline`);let be=await wn(fe),Ye=Xt(be);W[re]=Ye,H[re]=1;let Ue=xe.shots.map(Ce=>({refStart:Ce.refStart,srcStart:Ce.srcStart,count:Ce.refEnd-Ce.refStart+1})).sort((Ce,Pn)=>Ce.refStart-Pn.refStart),pn=await Kt(re,Ue,Ce=>Ce,()=>0),En=Ue.reduce((Ce,Pn)=>Ce+Pn.count,0);q.push({clipIndex:re,label:fe.name,shots:pn,coverage:Ye.offs.length?En/Ye.offs.length:0,srcFps:Ye.fps,srcStartFrame:Ye.startFrame,srcDropFrame:Ye.dropFrame,srcFrames:Ye.offs.length,srcW:Ye.w||null,srcH:Ye.h||null,codec:jo(Ye.kind),geometrySupported:Ye.kind==="prores"||!!a&&!!s,warnings:[]});for(let Ce of Ue)for(let Pn=Math.max(0,Ce.refStart);Pn<Math.min(pe.length,Ce.refStart+Ce.count);Pn++)pe[Pn]||(pe[Pn]=1);Ne=0,nt===-1/0&&(nt=0);continue}if(!y&&qt&&Ne>=Cp&&Number.isFinite(nt)){let be=_.get(re);if(qz({coverageComplete:pe.length>0&&Dz(pe)<=z,dryStreak:Ne,worstContributor:nt,nextScore:be?.minDistance??1/0})){for(let Ye=Z;Ye<pt.length;Ye++)dt.push(pt[Ye]);break}}if(i?.(Z,t.length,`matching ${fe.name}`),rt){let be=await X(fe,"B",(Ue,pn)=>i?.(Z+(pn?Ue/pn:0),t.length,`screening ${fe.name} \u2014 frame ${Ue}/${pn}`),zt),Ye=Fz(be.pdq,R.pdq);if(Ye.skip){let Ue=be.index;q.push({clipIndex:re,label:fe.name,shots:[],coverage:0,srcFps:Ue.fps,srcStartFrame:Ue.startFrame,srcDropFrame:Ue.dropFrame,srcFrames:Ue.offs.length,srcW:Ue.w||null,srcH:Ue.h||null,codec:jo(Ue.kind),geometrySupported:!1,warnings:[`${Xz} ${Ye.reason}. A contribution shorter than ${jz(z)} source frames could be missed at this screening density \u2014 re-run with the screen disabled if a shot you expected is absent.`]}),W[re]=Ue,H[re]=1,Ne++;continue}}let Y=await(on.get(re)??X(fe,"B",(be,Ye)=>i?.(Z+(Ye?be/Ye:0),t.length,`fingerprinting ${fe.name} \u2014 frame ${be}/${Ye}`),z));on.delete(re);let le=Ep(R,Y),Fe=Y.index;W[re]=Fe;let mt=qC(le.report.ops);if(z>1&&J){let be=mt.map(Ye=>({refStart:Ye.refStart*z,srcStart:Ye.srcStart*z,count:(Ye.count-1)*z+1}));mt=await Q7(be,J,await V(fe,"B"),{stride:z,threshold:Yn,refFrames:j.offs.length,srcFrames:Fe.offs.length})}let We=le.rateScale,xt=be=>Math.round(be*We),Je=b?await(Be.get(re)??b(fe)):null;Be.delete(re),F.push({clipIndex:re,label:fe.name,pdq:le.bPdq,embed:Je?le.bPdq.map((be,Ye)=>Je[Math.min(Je.length-1,xt(Ye))]):void 0}),H[re]=We;let qe=await Kt(re,mt,xt,be=>ZC(R.pdq,le.bPdq,be)),St=mt.reduce((be,Ye)=>be+Ye.count,0),$t=Fe.offs.length?St/Fe.offs.length:0;q.push({clipIndex:re,label:fe.name,shots:qe,coverage:$t,srcFps:Fe.fps,srcStartFrame:Fe.startFrame,srcDropFrame:Fe.dropFrame,srcFrames:Fe.offs.length,srcW:Fe.w||null,srcH:Fe.h||null,codec:jo(Fe.kind),geometrySupported:Fe.kind==="prores"||!!a&&!!s,warnings:le.warnings});let Ht=0;for(let be of qe)for(let Ye=Math.max(0,be.refStart);Ye<=Math.min(pe.length-1,be.refEnd);Ye++)pe[Ye]||(pe[Ye]=1,Ht++);if(Ht>0){Ne=0;let be=_.get(re);be&&be.minDistance>nt&&(nt=be.minDistance)}else Ne++}let an=[],Nn=[],Tn=new Set,Ut=new Set,Or=new Map;if(P){L();let Z=j.offs.length,re=t.map(()=>null),fe=0,xe=0;await Promise.all(Array.from({length:d9},async()=>{for(;fe<t.length;){let E=fe++;L(),!(ze.get(E)?.clean&&ze.get(E).shots.length)&&(re[E]=await P.index(E).catch(()=>null),i?.(++xe,t.length,`indexing ${t[E].name}`))}}));let Y=re.filter(E=>!!E&&E.vecs.length>0),le=new Map(Y.map(E=>[E.clipIndex,E.stride])),Fe=E=>le.get(E)??24,mt=new Map,We=async E=>{let I=mt.get(E);if(!I){if(I=Xt(await wn(t[E])),!I.offs.length){let D=await Ze(t[E]).catch(()=>0);D>0&&(I={...I,offs:Array.from({length:D},()=>({offset:0,size:0}))})}mt.set(E,I)}return I},xt=j.fps||24;for(let E of Y){let I=await We(E.clipIndex).catch(()=>null);H[E.clipIndex]=I?.fps?I.fps/xt:1}let Je=E=>H[E]??1;if(x?.shots.length){let E=new Set;for(let I of x.shots)I.refStart>0&&E.add(I.refStart),I.refEnd+1<Z&&E.add(I.refEnd+1);an=[...E].filter(I=>I>0&&I<Z).sort((I,D)=>I-D)}else an=a9(sa(R.pdq)).map(E=>E*z);let qe=s9(Z,an).filter(E=>{let I=0;for(let D=E.refStart;D<=E.refEnd;D++)I+=pe[D]?1:0;return I<(E.refEnd-E.refStart+1)/2}),St=qe.map(E=>th(E)),$t=[...new Set(St.flat())];i?.(0,qe.length,`describing ${qe.length} shots`);let Ht=await P.embedRef($t,(E,I)=>i?.(E,I,`describing ${qe.length} shots`)),be=new Map($t.map((E,I)=>[E,Ht[I]]));if(P.indexFine){let E=new Set;for(let ce of qe){let K=th(ce).map(Se=>({frame:Se,vec:be.get(Se)})).filter(Se=>Se.vec);if(K.length)for(let Se of Wy(K,Y,ce.refStart+ce.refEnd>>1,Je,4))Fe(Se.clipIndex)>24&&E.add(Se.clipIndex)}let I=[...E],D=0,he=0;await Promise.all(Array.from({length:d9},async()=>{for(;D<I.length;){let ce=I[D++];L();let K=await P.indexFine(ce).catch(()=>null);if(K?.vecs.length){let Se=Y.findIndex(ae=>ae.clipIndex===ce);Se>=0&&(Y[Se]=K),le.set(ce,K.stride)}i?.(++he,I.length,`indexing nominated takes finely: ${t[ce].name}`)}})),typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[find-first] fine index for ${I.length} nominated long-GOP clip(s)`)}let Ye=new Map,Ue=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,pn=S?(async()=>{let E=performance.now(),I=await S("ref").catch(()=>null);if(!I||I.length<8e3)return null;let D=new Ka;return await Promise.all(t.map(async(he,ce)=>{let K=await S(ce).catch(()=>null);K&&K.length>=8e3&&D.add(ce,K)})),Ue&&console.error(`[find-first] audio index: ${D.clips.size}/${t.length} clips with sound, ${D.size} hashes, ${Math.round(performance.now()-E)} ms`),D.clips.size?{ix:D,ref:Ka.reference(I)}:null})().catch(()=>null):Promise.resolve(null),En=async(E,I)=>{let D=await pn;if(!D)return[];let he=E.refStart/xt,ce=(E.refEnd+1)/xt;if(ce-he<1){let Se=(he+ce)/2;he=Math.max(0,Se-.5),ce=Se+.5}let K=[];for(let Se of D.ix.nominate(D.ref,he,ce)){if(!o9(Se))continue;let ae=await We(Se.clip).catch(()=>null);ae?.fps&&K.push({ci:Se.clip,srcAtProbe:Math.round((I/xt+Se.shiftSec)*ae.fps),votes:Se.votes,rival:Se.rival})}return K},Ce=new Map,Pn=E=>{let I=Ce.get(E);return I||(I=Qn("dense fingerprint",()=>X(t[E],"B",void 0,z)).then(D=>D.pdq).catch(()=>[]),Ce.set(E,I)),I},$n=async(E,I,D,he,ce)=>{if(z!==1||Je(E)!==1||!I.length)return null;let K=ce-he,Se=ke=>{let U=[],Me=Math.max(1,Math.floor((D.refEnd-D.refStart+1)/120));for(let Le=D.refStart;Le<=D.refEnd;Le+=Me){let Ve=Le+ke;if(Ve<0||Ve>=I.length||!R.pdq[Le])continue;let ct=mn(R.pdq[Le],I[Ve]);Number.isFinite(ct)&&U.push(ct)}return U.length<8?1/0:(U.sort((Le,Ve)=>Le-Ve),U[U.length>>1])},ae=K,ie=1/0;for(let ke=-6;ke<=6;ke++){let U=Se(K+ke);U<ie&&(ie=U,ae=K+ke)}let ee=1/0;for(let ke of[-48,-24,-12,12,24,48])ee=Math.min(ee,Se(ae+ke));if(Ue&&console.error(`[find-first] sequence: median ${ie} bits at offset ${ae} (guess ${K}) vs ${ee} around`),!(ie<=Yn)||!(ee-ie>=zC))return null;let ge=await de(he),je=await Oe(E,he+ae);if(!ge||!je)return null;let ne=await Qr(je.y,je.w,je.h,ge.y,ge.w,ge.h,k);return!ne.ok||ne.inliers<25?null:(Ue&&console.error(`[find-first] sequence: median ${ie} bits at offset ${ae} vs ${ee} around, ORB ${ne.inliers}`),{srcAtProbe:he+ae,score:ie})},Fr=async(E,I,D,he)=>{let ce={srcAtProbe:he,r:NaN,ambiguous:!0};if(z!==1||Je(E)!==1)return ce;let K=Math.max(I.refStart,D-240),Se=Math.min(I.refEnd,D+240);if(Se-K<Rf)return ce;let ae=sa(R.pdq,K,Se),ie=he-D,ee=Hy,ge=await We(E).catch(()=>null);if(!ge)return ce;let je=Math.max(0,K+ie-ee),ne=Math.min(ge.offs.length-1,Se+ie+ee+1),ke,U=Ce.has(E)||ge.offs.length<=OC?await Pn(E):[];if(U.length===ge.offs.length)ke=U.slice(je,ne+1);else{let B=await DD(E);ke=await Promise.all(Array.from({length:ne-je+1},(se,it)=>Qn("motion hash",()=>B(je+it)).catch(()=>null)))}let Me=B=>{let se=ke[B-je],it=ke[B+1-je];return se&&it?mn(se,it):NaN},Le=B=>{let se=0,it=0,lt=0,Mt=0,Vt=0,vr=0;for(let rr=0;rr<ae.length;rr++){let vn=Me(K+rr+B);if(!Number.isFinite(vn))continue;let ir=ae[rr];se++,it+=ir,lt+=vn,Mt+=ir*ir,Vt+=vn*vn,vr+=ir*vn}if(se<Rf)return NaN;let Mi=(Mt-it*it/se)*(Vt-lt*lt/se);return Mi>1e-9?(vr-it*lt/se)/Math.sqrt(Mi):NaN},Ve=new Map;for(let B=ie-ee;B<=ie+ee;B++){let se=Le(B);Number.isFinite(se)&&Ve.set(B,se)}if(!Ve.size)return ce;let ct=[...Ve].filter(([B,se])=>se>=(Ve.get(B-1)??-2)&&se>=(Ve.get(B+1)??-2)).map(([B,se])=>({off:B,r:se})).sort((B,se)=>se.r-B.r),Tt=ct[0];if(!Tt)return ce;let ln=ct.find(B=>Math.abs(B.off-Tt.off)>3)?.r??-1;if(Tt.r<.6||Tt.r-ln<.1)return{...ce,r:Tt.r};if(Tt.off===ie)return{srcAtProbe:he,r:Tt.r,ambiguous:!1};let Yt=await de(D),Et=await Oe(E,D+Tt.off);if(!Yt||!Et)return{...ce,r:Tt.r};let Sn=await Qr(Et.y,Et.w,Et.h,Yt.y,Yt.w,Yt.h,k);return!Sn.ok||Sn.inliers<25?{...ce,r:Tt.r}:{srcAtProbe:D+Tt.off,r:Tt.r,ambiguous:!1}},Xn=new Map,N=(E,I)=>{let D=Xn.get(E);return D||(D=I().then(he=>Wn(he)).catch(()=>null),Xn.set(E,D)),D},me=(E,I,D)=>{let he=Xn.get(E);return he||(he=I().then(ce=>vi(ce,D.refToSrc,D.refW,D.refH)).catch(()=>null),Xn.set(E,he)),he},He=async(E,I,D,he)=>{if(!E.transform)return null;let[ce,K]=await Promise.all([de(he),Oe(I,D)]);if(!ce||!K)return null;let Se=(E.srcW??K.w)/K.w,ae=(E.srcH??K.h)/K.h,ie=E.transform,ee=[ie[0]*Se,ie[1]*ae,ie[2],ie[3]*Se,ie[4]*ae,ie[5],ie[6]*Se,ie[7]*ae,ie[8]];if(Math.abs(ee[0]*K.w/ce.w-1)<.005&&Math.abs(ee[4]*K.h/ce.h-1)<.005&&Math.abs(ee[1])<.001&&Math.abs(ee[3])<.001&&Math.abs(ee[2])<1&&Math.abs(ee[5])<1)return null;let je=fo(ee);return je?{refToSrc:je,refW:ce.w,refH:ce.h,srcW:K.w,srcH:K.h}:null},Ke=async(E,I,D,he,ce,K)=>{let Se=await We(E).catch(()=>null);if(!Se)return null;let ae=Math.max(0,I+he-ce),ie=Math.min(Se.offs.length-1,I+he+ce+D);if(ie-ae<D)return null;let ee=K?K.refToSrc.map(ke=>ke.toFixed(4)).join(","):"",[ge,je]=await Promise.all([Promise.all(Array.from({length:D},(ke,U)=>N(`r@${I+U}`,()=>de(I+U)))),Promise.all(Array.from({length:ie-ae+1},(ke,U)=>K?me(`w${E}@${ae+U}|${ee}`,()=>Oe(E,ae+U),K):N(`c${E}@${ae+U}`,()=>Oe(E,ae+U))))]),ne=ca(ge,je,ae,I+he-ce,I+he+ce);return ne?{...ne,off:ne.src-I}:null},ht=async(E,I,D,he)=>{let ce=I.refEnd-I.refStart+1;if(Je(E)!==1||ce<8)return null;let K=Math.min(96,ce),Se=I.refStart+(ce-K>>1),ae=await Qn("map confirm",()=>Ke(E,Se,K,he-D,c9));if(Ue&&console.error(`[find-first] map confirm ${t[E].name}@${he}: ${ae?`${D+ae.off} (score ${ae.score.toFixed(2)}, margin ${ae.margin.toFixed(2)})`:"\u2013"}`),!ae||ae.score<.4||ae.margin<.2)return null;let ie=await de(D),ee=await Oe(E,D+ae.off),ge=ie&&ee?await Qr(ee.y,ee.w,ee.h,ie.y,ie.w,ie.h,k).catch(()=>null):null;return{srcAtProbe:D+ae.off,score:Yn,transform:ge?.ok?ge.transform:null,srcW:ge?.ok?ge.srcW:void 0,srcH:ge?.ok?ge.srcH:void 0,refPlane:ie??{y:new Uint8Array(0),w:0,h:0}}},De=async(E,I,D,he,ce=rh)=>{let K=await We(E).catch(()=>null);if(!K)return null;let Se=K.offs.length,ae=Ni(I.refStart,I.refEnd,Zy).filter(se=>se+D>=0&&se+D<Se);if(ae.length<3)return null;let ie=(await Qn("sz: pair reads",()=>Promise.all(ae.map(async se=>{let[it,lt]=await Promise.all([de(se),Oe(E,se+D)]);return it&&lt?{ref:it,src:lt}:null})))).filter(se=>!!se);if(ie.length<3)return null;let ee=await Qn("sz: fit",()=>Ri(ie,ce));if(!ee)return null;let ge={srcW:ie[0].src.w,srcH:ie[0].src.h,refW:ie[0].ref.w,refH:ie[0].ref.h},je={fit:ee,...ge},ne=fo(ee.transform);if(!ne)return{...je,off:D,map:null,margin:0};let ke=I.refEnd-I.refStart+1,U=Math.min(96,ke),Me=I.refStart+(ke-U>>1),Le=Math.max(0,Me+D-he),Ve=Math.min(Se-1,Me+D+he+U);if(Ve-Le<U)return{...je,off:D,map:null,margin:0};let{refW:ct,refH:Tt}=je,ln=ne.map(se=>se.toFixed(4)).join(","),[Yt,Et]=await Qn("sz: map block",()=>Promise.all([Promise.all(Array.from({length:U},(se,it)=>N(`r@${Me+it}`,()=>de(Me+it)))),Promise.all(Array.from({length:Ve-Le+1},async(se,it)=>{let lt=`w${E}@${Le+it}|${ln}`,Mt=Xn.get(lt);return Mt||(Mt=Oe(E,Le+it).then(Vt=>vi(Vt,ne,ct,Tt)).catch(()=>null),Xn.set(lt,Mt)),Mt}))])),Sn=ca(Yt,Et,Le,Me+D-he,Me+D+he);if(!Sn)return{...je,off:D,map:null,margin:0};let B=Sn.src-Me;if(B!==D){let se=(await Promise.all(ae.filter(lt=>lt+B>=0&&lt+B<Se).map(async lt=>{let[Mt,Vt]=await Promise.all([de(lt),Oe(E,lt+B)]);return Mt&&Vt?{ref:Mt,src:Vt}:null}))).filter(lt=>!!lt),it=se.length>=3?await Ri(se,ce):null;if(!it)return{...je,off:B,map:null,margin:0};je={fit:it,...ge}}return{...je,off:B,map:Sn.score,margin:Sn.margin}},gt=new Map,st=(E,I)=>{let D=gt.get(E);D||(gt.size>=3&&gt.delete(gt.keys().next().value),D=new Map,gt.set(E,D));let he=D.get(I);return he||(he=Qn("take scan",()=>(T??oe)(E,I)).then(ce=>ce?NC(ce,RC):null).catch(()=>null),D.set(I,he)),he},Qe=async(E,I,D,he,ce)=>{let K=await We(E).catch(()=>null);if(!K)return null;let Se=K.offs.length,ae=(await Promise.all(Ni(I.refStart,I.refEnd,Zy).map(async ee=>{let ge=Math.round(he+(ee-D)*ce);if(ge<0||ge>=Se)return null;let[je,ne]=await Promise.all([de(ee),Oe(E,ge)]);return je&&ne?{ref:je,src:ne}:null}))).filter(ee=>!!ee);if(ae.length<3)return null;let ie=await Ri(ae,rh);return ie?{fit:ie,srcW:ae[0].src.w,srcH:ae[0].src.h,refW:ae[0].ref.w,refH:ae[0].ref.h}:null},$e=async(E,I,D,he,ce)=>{let K=[...new Set([Je(E),1])],Se=null,ae=async(ee,ge)=>{let je=await Qn("off-rate sizing",()=>Qe(E,I,D,ee,ge)).catch(()=>null);je&&(!Se||je.fit.score>Se.v.fit.score)&&(Se={at:ee,rate:ge,v:je})};for(let ee of K)for(let ge=-ce;ge<=ce;ge+=Uy)await ae(he+ge,ee);let ie=Se;if(ie)for(let ee=-Uy+1;ee<Uy;ee++)ee&&await ae(ie.at+ee,ie.rate);return Se},wt=async(E,I,D,he=rh)=>{let ce=await We(E).catch(()=>null);if(!ce)return null;let K=ce.offs.length,Se=(await Promise.all(Ni(I.refStart,I.refEnd,Zy).filter(ee=>ee+D>=0&&ee+D<K).map(async ee=>{let[ge,je]=await Promise.all([de(ee),Oe(E,ee+D)]);return ge&&je?{ref:ge,src:je}:null}))).filter(ee=>!!ee);if(Se.length<3)return null;let ae=await Ri(Se,he),ie=ae?fo(ae.transform):null;return ae&&ie?{fit:ae,srcW:Se[0].src.w,srcH:Se[0].src.h,warp:{refToSrc:ie,refW:Se[0].ref.w,refH:Se[0].ref.h,srcW:Se[0].src.w,srcH:Se[0].src.h}}:null},nn=async(E,I,D,he)=>{let ce=await We(E).catch(()=>null);if(!ce)return null;let K=I.refEnd-I.refStart+1,Se=Math.min(96,K),ae=I.refStart+(K-Se>>1),ie=ce.offs.length,ee=ie<=si?0:Math.max(0,Math.min(ie-si,ae+he-(si>>1))),ge=Math.min(ie,ee+si);if(ge-ee<Se+2)return null;let je=await Promise.all(Array.from({length:Se},(Le,Ve)=>N(`r@${ae+Ve}`,()=>de(ae+Ve)))),ne=D?D.refToSrc.map(Le=>Le.toFixed(4)).join(","):"",ke=new Array(ge-ee).fill(null);for(let Le=ee;Le<ge;Le+=ll)L(),await Promise.all(Array.from({length:Math.min(ll,ge-Le)},async(Ve,ct)=>{let Tt=Le+ct,ln=D?`w${E}@${Tt}|${ne}`:`c${E}@${Tt}`,Yt=Xn.get(ln);Yt||(Yt=st(E,Tt).then(Et=>{if(!Et||!D)return Wn(Et);let Sn=Et.w/D.srcW,B=Et.h/D.srcH,se=D.refToSrc;return vi(Et,[se[0]*Sn,se[1]*Sn,se[2]*Sn,se[3]*B,se[4]*B,se[5]*B,se[6],se[7],se[8]],D.refW,D.refH)}).catch(()=>null),Xn.set(ln,Yt)),ke[Tt-ee]=await Yt}));let U=ca(je,ke,ee,ee,ge-Se),Me=Az(je,ke,ee,ee,ge-Se,Dy).map(Le=>({off:Le.src-ae,score:Le.score}));return U?{off:U.src-ae,score:U.score,margin:U.margin,peaks:Me}:null},kt=8,Bt=6,It=E=>{let I=new Uint8Array(E.y.length);for(let D=0;D<E.h;D++)for(let he=0;he<E.w;he++)I[D*E.w+he]=E.y[D*E.w+(E.w-1-he)];return{y:I,w:E.w,h:E.h}},zn=async(E,I,D,he=!1)=>{let ce=await We(E).catch(()=>null);if(!ce)return null;let K=I.refStart+I.refEnd>>1,Se=await de(K);if(!Se)return null;let ae=he?It(Se):Se,ie=ce.offs.length,ee=ie<=si?0:Math.max(0,Math.min(ie-si,K+D-(si>>1))),ge=Math.min(ie,ee+si),je=[],ne=[];for(let Me=ee;Me<ge;Me+=kt)ne.push(Me);let ke=0;for(let Me=0;Me<ne.length;Me+=Bt)L(),await Promise.all(ne.slice(Me,Me+Bt).map(async Le=>{let Ve=await Oe(E,Le).catch(()=>null);if(!Ve){ke++;return}let ct=await Qn("orb scan",()=>Qr(Ve.y,Ve.w,Ve.h,ae.y,ae.w,ae.h,k)).catch(()=>null);if(!ct){ke++;return}je.push({g:Le,inl:ct.ok?ct.inliers:0})}));if(Ue&&console.error(`[find-first] orb scan ${t[E].name}: ${je.length} frames (${ke} failed), best inliers ${Math.max(0,...je.map(Me=>Me.inl))}`),!je.length)return null;je.sort((Me,Le)=>Le.inl-Me.inl);let U=[];for(let Me of je)if(Me.inl<12||(U.every(Le=>Math.abs(Le.off-(Me.g-K))>3*kt)&&U.push({off:Me.g-K,score:Me.inl/100}),U.length>=Dy))break;return U.length?{off:U[0].off,score:U[0].score,margin:U[0].score-(U[1]?.score??0),peaks:U}:null},qn=6,ur=4,Lt=E=>{let I=t[E].path??t[E].name;return I.slice(0,I.lastIndexOf("/")+1)},tr=async(E,I,D)=>{let he=await de(E.refStart+E.refEnd>>1);if(!he||LC(he)<MC)return null;let ce=E.refStart+E.refEnd>>1,K=[],Se=(ne,ke)=>{!K.some(U=>U.ci===ne)&&K.length<qn&&K.push({ci:ne,near:ke})};for(let ne of D.slice(0,4))Se(ne.clipIndex,ne.srcAtProbe-I);for(let ne of D.slice(0,2))for(let ke=0;ke<t.length;ke++)Lt(ke)===Lt(ne.clipIndex)&&Se(ke,0);let ae=async ne=>{let ke=[];return await Promise.all(K.map(async U=>{let Me=await zn(U.ci,E,U.near,ne).catch(()=>null);if(Ue&&console.error(`[find-first] rescue scan${ne?" (mirrored)":""} ${t[U.ci].name}: ${Me?Me.peaks.map(Le=>`${ce+Le.off}:${Math.round(Le.score*100)}`).join(" "):"\u2013"}`),Me)for(let Le of Me.peaks)ke.push({ci:U.ci,off:Le.off,inl:Le.score})})),ke.sort((U,Me)=>Me.inl-U.inl)},ie=await ae(!1);ie.length||(ie=await ae(!0));let ee=[];for(let ne of ie.slice(0,ur)){let ke=Je(ne.ci);if(ke!==1){let Me=Math.round(ce+ne.off+(I-ce)*ke),Le=await Qn("rescue sizing",()=>$e(ne.ci,E,I,Me,kt)).catch(()=>null);if(!Le)continue;let Ve=Le.at,ct=fo(Le.v.fit.transform);if(ct){let Tt={refToSrc:ct,refW:Le.v.refW,refH:Le.v.refH,srcW:Le.v.srcW,srcH:Le.v.srcH},ln=E.refEnd-E.refStart+1,Yt=Math.min(96,ln),Et=E.refStart+(ln-Yt>>1),Sn=Ve/Le.rate-I,B=Le.rate===1?await Ke(ne.ci,Et,Yt,Math.round(Ve-I),48,Tt).catch(()=>null):await Dt(ne.ci,Et,Yt,Sn,48,Tt,Le.rate).catch(()=>null);Ue&&console.error(`[find-first] rescue polish ${t[ne.ci].name}: ${Ve} \u2192 ${B?`${Math.round((I+B.off)*(Le.rate===1?1:Le.rate))} (score ${B.score.toFixed(2)}, margin ${B.margin.toFixed(2)})`:"\u2013"}`),B&&B.score>=.3&&B.margin>=.05&&(Ve=Le.rate===1?I+B.off:Math.round((I+B.off)*Le.rate))}ee.push({ci:ne.ci,agree:Le.v.fit.score,ok:{clipIndex:ne.ci,srcAtProbe:Ve,score:Yn,transform:Le.v.fit.transform,srcW:Le.v.srcW,srcH:Le.v.srcH,refW:Le.v.refW,refH:Le.v.refH}});continue}let U=null;for(let Me=-kt/2;Me<=kt/2;Me+=2){let Le=await Qn("rescue sizing",()=>wt(ne.ci,E,ne.off+Me,{})).catch(()=>null);Le&&(!U||Le.fit.score>U.sw.fit.score)&&(U={off:ne.off+Me,sw:Le})}if(U)for(let Me=-1;Me<=1;Me+=2){let Le=await wt(ne.ci,E,U.off+Me,{}).catch(()=>null);Le&&Le.fit.score>U.sw.fit.score&&(U={off:U.off+Me,sw:Le})}U&&ee.push({ci:ne.ci,agree:U.sw.fit.score,ok:{clipIndex:ne.ci,srcAtProbe:I+U.off,score:Yn,transform:U.sw.fit.transform,srcW:U.sw.srcW,srcH:U.sw.srcH,refW:U.sw.warp.refW,refH:U.sw.warp.refH}})}ee.sort((ne,ke)=>ke.agree-ne.agree);let ge=ee[0],je=ee.find(ne=>ne.ci!==ge?.ci)?.agree??0;return Ue&&console.error(`[find-first] rescue ${E.refStart}\u2013${E.refEnd}: ${K.length} takes, ${ie.length} peaks; best ${ge?`${t[ge.ci].name}@${ge.ok.srcAtProbe} agreement ${ge.agree.toFixed(2)} (other takes ${je.toFixed(2)})`:"\u2013"}`),!ge||ge.agree<Ff||ge.agree<je+.1?null:ge.ok},gr=96,Gn=E=>{if(!E)return null;let I=gr,D=E.length/I,he=new Float32Array(2*E.length);for(let ce=0;ce<D;ce++)for(let K=0;K<I;K++){let Se=ce*I+K;he[Se]=E[ce*I+Math.min(I-1,K+1)]-E[ce*I+Math.max(0,K-1)],he[E.length+Se]=E[Math.min(D-1,ce+1)*I+K]-E[Math.max(0,ce-1)*I+K]}return he},hn=async(E,I,D,he)=>{let ce=await We(E).catch(()=>null);if(!ce)return null;let K=I.refEnd-I.refStart+1,Se=K>=5?[I.refStart+1,I.refStart+I.refEnd>>1,I.refEnd-1]:[I.refStart+I.refEnd>>1],ae=ce.offs.length,ie=ae<=si?0:Math.max(0,Math.min(ae-si,Se[0]+he-(si>>1))),ee=Math.min(ae,ie+si);if(ee-ie<K+2)return null;let ge=await Promise.all(Se.map(Ve=>de(Ve).then(ct=>Gn(Wn(ct,gr))).catch(()=>null))),je=D?D.refToSrc.map(Ve=>Ve.toFixed(4)).join(","):"",ne=new Array(ee-ie).fill(null);for(let Ve=ie;Ve<ee;Ve+=ll)L(),await Promise.all(Array.from({length:Math.min(ll,ee-Ve)},async(ct,Tt)=>{let ln=Ve+Tt,Yt=`a${gr}${E}@${ln}|${je}`,Et=Xn.get(Yt);Et||(Et=st(E,ln).then(Sn=>{if(!Sn)return null;if(!D)return Gn(Wn(Sn,gr));let B=Sn.w/D.srcW,se=Sn.h/D.srcH,it=D.refToSrc;return Gn(vi(Sn,[it[0]*B,it[1]*B,it[2]*B,it[3]*se,it[4]*se,it[5]*se,it[6],it[7],it[8]],D.refW,D.refH,gr))}).catch(()=>null),Xn.set(Yt,Et)),ne[ln-ie]=await Et}));let ke=(Ve,ct)=>{let Tt=0,ln=0;for(let B=0;B<Ve.length;B++)Tt+=Ve[B],ln+=ct[B];Tt/=Ve.length,ln/=ct.length;let Yt=0,Et=0,Sn=0;for(let B=0;B<Ve.length;B++){let se=Ve[B]-Tt,it=ct[B]-ln;Yt+=se*it,Et+=se*se,Sn+=it*it}return Et>0&&Sn>0?Yt/Math.sqrt(Et*Sn):0},U=[];for(let Ve=ie;Ve+(Se[Se.length-1]-Se[0])<ee;Ve++){let ct=Ve-Se[0],Tt=0,ln=0;for(let Yt=0;Yt<Se.length;Yt++){let Et=ne[Se[Yt]+ct-ie],Sn=ge[Yt];Et&&Sn&&(Tt+=ke(Sn,Et),ln++)}ln&&U.push({off:ct,score:Tt/ln})}if(!U.length)return null;U.sort((Ve,ct)=>ct.score-Ve.score);let Me=[];for(let Ve of U)if(Me.every(ct=>Math.abs(ct.off-Ve.off)>12)&&Me.push(Ve),Me.length>=Dy)break;let Le=U.find(Ve=>Math.abs(Ve.off-Me[0].off)>2)?.score??0;return{off:Me[0].off,score:Me[0].score,margin:Me[0].score-Le,peaks:Me}},en=240,ft=async(E,I,D,he,ce)=>{let K=[{refStart:I,refEnd:D,off:he}];if(D-I+1<288)return K;let ae=[];for(let ne=I;ne+96/2<=D;ne+=96){let ke=Math.min(96,D-ne+1),U=await Ke(E,ne,ke,he,2,ce),Me=he,Le=!!U&&U.score>=.5;if(!U||U.score<.5){let Ve=await Ke(E,ne,ke,he,en,ce);Ve&&Ve.margin>=.1&&Math.abs(Ve.off-he)>2?Me=Ve.off:Ve&&Math.abs(Ve.off-he)<=2&&(Le=!0)}ae.push({a:ne,len:ke,off:Me,backed:Le})}let ie=(ne,ke)=>Math.abs(ne-ke)<=1,ee=ae.map((ne,ke)=>ne.off!==he&&[ke-1,ke+1].some(U=>U>=0&&U<ae.length&&ie(ae[U].off,ne.off)));for(let ne=0;ne<ae.length;ne++)ae[ne].off!==he&&!ee[ne]&&(ae[ne].off=he);for(let ne=1;ne<ae.length;ne++)ae[ne].off!==he&&ie(ae[ne].off,ae[ne-1].off)&&(ae[ne].off=ae[ne-1].off);if(ae.some(ne=>ne.off!==he))for(let ne=0;ne<ae.length;ne++){if(ae[ne].off!==he||ae[ne].backed)continue;let ke=[ae[ne-1],ae[ne+1]].find(U=>U&&U.off!==he);ke&&(ae[ne].off=ke.off)}if(ae.every(ne=>ne.off===he))return K;let ge=[];for(let ne of ae){let ke=ge[ge.length-1];ke&&ke.off===ne.off?ke.refEnd=ne.a+ne.len-1:ge.push({refStart:ne.a,refEnd:ne.a+ne.len-1,off:ne.off})}ge[ge.length-1].refEnd=D;let je=async(ne,ke)=>{let[U,Me,Le,Ve]=await Promise.all([N(`r@${ne}`,()=>de(ne)),N(`r@${ne+1}`,()=>de(ne+1)),...[ne+ke,ne+ke+1].map(Tt=>ce?me(`w${E}@${Tt}|${ce.refToSrc.map(ln=>ln.toFixed(4)).join(",")}`,()=>Oe(E,Tt),ce):N(`c${E}@${Tt}`,()=>Oe(E,Tt)))]),ct=ca([U,Me],[Le,Ve],ne+ke,ne+ke,ne+ke);return ct?ct.score:0};for(let ne=1;ne<ge.length;ne++){let ke=ge[ne-1],U=ge[ne],Me=Math.max(ke.refStart+1,U.refStart-96),Le=Math.min(U.refEnd-1,U.refStart+96),Ve=await Promise.all(Array.from({length:Le-Me+1},(Yt,Et)=>je(Me+Et,ke.off))),ct=await Promise.all(Array.from({length:Le-Me+1},(Yt,Et)=>je(Me+Et,U.off))),Tt=U.refStart,ln=-1/0;for(let Yt=Me;Yt<=Le;Yt++){let Et=0;for(let Sn=0;Sn<=Le-Me;Sn++)Et+=Me+Sn<Yt?Ve[Sn]:ct[Sn];Et>ln&&(ln=Et,Tt=Yt)}ke.refEnd=Tt-1,U.refStart=Tt}return Ue&&console.error(`[find-first] split ${I}\u2013${D}: ${ge.map(ne=>`${ne.refStart}\u2013${ne.refEnd}@${ne.off}`).join(", ")}`),ge.filter(ne=>ne.refEnd>=ne.refStart)},Xe=18,tt=2.5,_e=240,Ft=5,Ct=96,kn=.6,fn=.03,bn=3,gn=async E=>{let[I,D]=await Promise.all([nr(E),nr(E+1)]);if(!I||!D)return 0;let he=0;for(let K=0;K<I.length;K++)he+=D[K]-I[K];he/=I.length;let ce=0;for(let K=0;K<I.length;K++){let Se=D[K]-I[K]-he;ce+=Se*Se}return Math.sqrt(ce/I.length)},tn=1,Ir=async(E,I)=>{let D=Math.floor(E/z),he=Math.floor(I/z),ce=sa(R.pdq,D,he),K=await Promise.all(Array.from({length:Math.max(0,I-E)},(ee,ge)=>gn(E+ge))),Se=(ee,ge,je)=>{if(ee[ge]<je)return 0;let ne=[];for(let U=Math.max(0,ge-8);U<=Math.min(ee.length-1,ge+8);U++)U!==ge&&ne.push(ee[U]);if(ne.length<4)return 0;ne.sort((U,Me)=>U-Me);let ke=ee[ge]/Math.max(je/tt,ne[ne.length>>1]);return ke>=tt?ke:0},ae=[];for(let ee=0;ee<ce.length;ee++){let ge=Se(ce,ee,Xe);ge&&ae.push({at:(D+ee+1)*z,r:ge})}for(let ee=0;ee<K.length;ee++){let ge=Se(K,ee,tn);ge&&ae.push({at:E+ee+1,r:ge})}ae.sort((ee,ge)=>ee.at-ge.at);let ie=[];for(let ee of ae){if(ee.at-E<Ft||I-ee.at+1<Ft)continue;let ge=ie[ie.length-1];if(ge&&ee.at-ge.at<Ft){ee.r>ge.r&&(ge.at=ee.at,ge.r=ee.r);continue}ie.push({...ee})}return ie.map(ee=>ee.at)},Dt=async(E,I,D,he,ce,K,Se)=>{if(Se===1)return Ke(E,I,D,Math.round(he),ce,K);let ae=await We(E).catch(()=>null);if(!ae)return null;let ie=Math.floor((ae.offs.length-1)/Se),ee=Math.round(I+he),ge=Math.max(0,ee-ce),je=Math.min(ie,ee+ce+D);if(je-ge<D)return null;let ne=K?K.refToSrc.map(Le=>Le.toFixed(4)).join(","):"",[ke,U]=await Promise.all([Promise.all(Array.from({length:D},(Le,Ve)=>N(`r@${I+Ve}`,()=>de(I+Ve)))),Promise.all(Array.from({length:je-ge+1},(Le,Ve)=>{let ct=Math.round((ge+Ve)*Se);return K?me(`w${E}@${ct}|${ne}`,()=>Oe(E,ct),K):N(`c${E}@${ct}`,()=>Oe(E,ct))}))]),Me=ca(ke,U,ge,ee-ce,ee+ce);return Me?{...Me,off:Me.src-I}:null},sn=160,xr=new Map,An=(E,I)=>{if(!E)return null;let D=E.length/I,he=new Float32Array(2*E.length);for(let ce=0;ce<D;ce++)for(let K=0;K<I;K++){let Se=ce*I+K;he[Se]=(E[ce*I+Math.min(I-1,K+1)]-E[ce*I+Math.max(0,K-1)])/2,he[E.length+Se]=(E[Math.min(D-1,ce+1)*I+K]-E[Math.max(0,ce-1)*I+K])/2}return he},nr=E=>{let I=`R${E}`,D=xr.get(I);return D||(D=de(E).then(he=>An(Wn(he,sn),sn)).catch(()=>null),xr.set(I,D)),D},Cr=(E,I,D)=>{let he=`C${E}@${I}|${D?D.refToSrc.map(K=>K.toFixed(4)).join(","):""}`,ce=xr.get(he);return ce||(ce=Oe(E,I).then(K=>An(D?vi(K,D.refToSrc,D.refW,D.refH,sn):Wn(K,sn),sn)).catch(()=>null),xr.set(he,ce)),ce},Jr=(E,I)=>{let D=0,he=0;for(let ae=0;ae<E.length;ae++)D+=E[ae],he+=I[ae];D/=E.length,he/=I.length;let ce=0,K=0,Se=0;for(let ae=0;ae<E.length;ae++){let ie=E[ae]-D,ee=I[ae]-he;ce+=ie*ee,K+=ie*ie,Se+=ee*ee}return K>0&&Se>0?ce/Math.sqrt(K*Se):0},Mo=async(E,I,D,he,ce,K,Se)=>{let ae=await We(E).catch(()=>null);if(!ae)return null;let ie=Math.floor((ae.offs.length-1)/Se),ee=Array.from({length:Math.min(8,D)},(ct,Tt)=>I+Math.round((Tt+.5)*D/Math.min(8,D)-.5)),ge=K?K.refToSrc.map(ct=>ct.toFixed(4)).join(","):"",je=ct=>Cr(E,Math.round(ct*Se),K),ne=await Promise.all(ee.map(ct=>nr(ct))),ke=[],U=Math.round(he);for(let ct=U-ce;ct<=U+ce;ct++){if(I+ct<0||I+D-1+ct>ie)continue;let Tt=await Promise.all(ee.map(Et=>je(Et+ct))),ln=0,Yt=0;for(let Et=0;Et<ee.length;Et++)ne[Et]&&Tt[Et]&&(ln+=Jr(ne[Et],Tt[Et]),Yt++);Yt>=Math.max(1,ee.length>>1)&&ke.push([ct,ln/Yt])}if(!ke.length)return null;let Me=ct=>ke.find(([Tt])=>Tt===ct)?.[1]??-1,Le=ke.reduce((ct,Tt)=>Tt[1]>ct[1]?Tt:ct),Ve=Math.max(-1,...ke.filter(([ct])=>Math.abs(ct-Le[0])>2).map(([,ct])=>ct));return{off:Le[0],score:Le[1],margin:Le[1]-Ve,here:Me(U)}},F8=async(E,I,D,he,ce,K)=>{if(K===1||D<5)return he;let Se=await We(E).catch(()=>null);if(!Se)return he;let ae=Se.offs.length,ie=Math.round((I+he)*K),ee=await Promise.all(Array.from({length:D},(ne,ke)=>N(`r@${I+ke}`,()=>de(I+ke)))),ge=ce?ce.refToSrc.map(ne=>ne.toFixed(4)).join(","):"",je={s:ie,score:-1/0};for(let ne=ie-2;ne<=ie+2;ne++){let ke=Array.from({length:D},(Le,Ve)=>ne+Us(Ve,K));if(ke[0]<0||ke[D-1]>=ae)continue;let U=await Promise.all(ke.map(Le=>ce?me(`w${E}@${Le}|${ge}`,()=>Oe(E,Le),ce):N(`c${E}@${Le}`,()=>Oe(E,Le)))),Me=ca(ee,U,0,0,0);Me&&Me.score>je.score&&(je={s:ne,score:Me.score})}return je.s/K-I},ZD=async(E,I,D,he)=>{let ce=await Ir(I.refStart,I.refEnd);if(Ue){let ee=[...sa(R.pdq,Math.floor(I.refStart/z),Math.floor(I.refEnd/z))].map((ke,U)=>[ke,(Math.floor(I.refStart/z)+U+1)*z]).sort((ke,U)=>U[0]-ke[0]).slice(0,5),ge=await Promise.all(Array.from({length:I.refEnd-I.refStart},(ke,U)=>gn(I.refStart+U))),je=ge.map((ke,U)=>[ke,I.refStart+U+1]).sort((ke,U)=>U[0]-ke[0]).slice(0,5),ne=[...ge].sort((ke,U)=>ke-U)[ge.length>>1]??0;console.error(`[find-first] soft cuts ${I.refStart}\u2013${I.refEnd}: [${ce.join(",")}] biggest deltas ${ee.map(([ke,U])=>`${U}:${ke}`).join(" ")} | grid ${je.map(([ke,U])=>`${U}:${ke.toFixed(2)}`).join(" ")} (median ${ne.toFixed(2)})`)}if(!ce.length)return D!==1&&I.refEnd-I.refStart+1>=Ft?[{...I,off:await F8(E,I.refStart,I.refEnd-I.refStart+1,I.off,he,D)}]:[I];let K=[I.refStart,...ce,I.refEnd+1],Se=[];for(let ie=0;ie+1<K.length;ie++){let ee=K[ie],ge=K[ie+1]-1,je=ge-ee+1,ne=I.off;if(je>=Ft){let ke=await Dt(E,ee,je,I.off,1,he,D);if(ke&&ke.score>=.5)ne=ke.off;else{let U=await Dt(E,ee,je,I.off,_e,he,D);if(U&&U.margin>=.1&&U.score>=(ke?.score??0)+.1&&Math.abs(U.off-I.off)>1)ne=U.off;else{let Me=await Mo(E,ee,je,I.off,Ct,he,D);if(Ue&&Me&&console.error(`[find-first] piece ${ee}\u2013${ge}: appearance ${Me.off} ${Me.score.toFixed(3)} m${Me.margin.toFixed(3)} (here ${Me.here.toFixed(3)})`),Me&&Me.score>=kn){let Le=Me.score-Me.here>=fn?Me.off:I.off,Ve=await Dt(E,ee,je,Le,bn,he,D),ct=Ve?Ve.off:Le;Ue&&console.error(`[find-first] piece ${ee}\u2013${ge}: basin ${Le}, polish ${Ve?`${Ve.off.toFixed(1)} ${Ve.score.toFixed(2)}`:"\u2013"}`),(Math.abs(ct-I.off)>1||Le!==I.off)&&(ne=ct)}}Ue&&console.error(`[find-first] piece ${ee}\u2013${ge}: here ${ke?`${ke.off.toFixed(1)} ${ke.score.toFixed(2)}`:"\u2013"}, wide ${U?`${U.off.toFixed(1)} ${U.score.toFixed(2)} m${U.margin.toFixed(2)}`:"\u2013"}`)}}Se.push({refStart:ee,refEnd:ge,off:ne})}let ae=[];for(let ie of Se){let ee=ae[ae.length-1];ee&&Math.abs(ee.off-ie.off)<=1?(ie.refEnd-ie.refStart>ee.refEnd-ee.refStart&&(ee.off=ie.off),ee.refEnd=ie.refEnd):ae.push({...ie})}if(D!==1)for(let ie of ae)ie.off=await F8(E,ie.refStart,ie.refEnd-ie.refStart+1,ie.off,he,D);return Ue&&ae.length>1&&console.error(`[find-first] jump cuts ${I.refStart}\u2013${I.refEnd} (soft cuts ${ce.join(",")}): ${ae.map(ie=>`${ie.refStart}\u2013${ie.refEnd}@${ie.off}`).join(", ")}`),ae},I8=new Map,DD=E=>{let I=I8.get(E);return I||(I=V(t[E],"B"),I8.set(E,I)),I},$v=async(E,I,D,he,ce,K,Se,ae=3)=>{let ie=Je(E),ee=he.refEnd-he.refStart+1,ge=[ce,...th(he,3).filter(je=>Math.abs(je-ce)>2)].slice(0,ae);for(let je of ge){let ne=await Qn("confirm probe",()=>Of({refLuma:de,cand:{label:I,frameCount:D,luma:ke=>Oe(E,ke)},refProbe:je,srcGuess:Math.round(K+(je-ce)*ie),radius:Se,runSpread:ie===1?Math.max(1,Math.floor(ee/3)):0,reframeOpts:k})).catch(()=>null);if(ne)return{...ne,srcAtProbe:Math.round(ne.srcAtProbe-(je-ce)*ie)}}return null},qD=12,UD=.6,dp=qe.map(()=>null),E8=qe.map(()=>null),ey=qe.map(()=>!1),df=0,ty=async(E,I)=>{L();let D=qe[E],he=performance.now();I||i?.(df,qe.length,`placing shots ${df}/${qe.length}`);let ce=D.refEnd-D.refStart+1,K=D.refStart+D.refEnd>>1,Se=St[E].map(B=>({frame:B,vec:be.get(B)})).filter(B=>B.vec),ae=Se.length?Wy(Se,Y,K,Je,1/0):[],ie=ae.slice(0,4),ee=ie[0]?.sim??-1;if(Ue&&console.error(`[find-first] shot ${D.refStart}\u2013${D.refEnd} probe ${K}: ${ie.map(B=>`${B.label}@${B.srcAtProbe} ${B.sim.toFixed(2)}`).join(", ")}`),ee<nh){I||(Nn.push({...D,best:ee}),ey[E]=!0);return}let ge=[];for(let B of I?[]:yt)B.refStart>K||B.refEnd<K||ge.push({clipIndex:B.clipIndex,label:t[B.clipIndex].name,srcAtProbe:Math.round(B.srcStart+(K-B.refStart)*B.speed),sim:ee,why:"timeline claim",radius:12});let je=I?[]:await En(D,K);Ue&&je.length&&console.error(`[find-first] audio: ${je.map(B=>`${t[B.ci].name}@${B.srcAtProbe} (${B.votes} vs ${B.rival})`).join(", ")}`);for(let B of je)ge.push({clipIndex:B.ci,label:t[B.ci].name,srcAtProbe:B.srcAtProbe,sim:ee,why:"audio",radius:3});if(I&&(I.refEnd===D.refStart-1||I.refEnd===D.refEnd)){let B=ae.find(se=>se.clipIndex===I.clipIndex);if(B&&B.sim>=ee-.05){let se=Je(I.clipIndex);ge.push({...B,srcAtProbe:Math.round(I.srcAtEnd+(K-I.refEnd)*se),why:"continuity",radius:Ja})}}for(let B of I?[]:ie){if(B.sim<ee-.1)break;ge.push({...B,radius:Math.ceil(Fe(B.clipIndex)*Je(B.clipIndex))})}let ne=ee<HC,ke=async B=>{if(ce<12||!Vy())return null;let se=null,it=B.map(lt=>Qn("sizing confirm",()=>De(lt.ci,D,lt.off,lt.radius)).catch(()=>null));for(let[lt,Mt]of B.entries()){if(se&&se.ci===Mt.ci&&Math.abs(se.off-Mt.off)<=Mt.radius)continue;let Vt=await it[lt];if(Ue&&console.error(`[find-first] sizing ${Mt.label}@${K+Mt.off} \xB1${Mt.radius} (${Mt.why}) \u2192 ${Vt?`agreement ${Vt.fit.score.toFixed(2)}${Vt.map!=null?`, map ${Vt.map.toFixed(2)} margin ${Vt.margin.toFixed(2)} at ${K+Vt.off}`:""}`:"\u2013"}`),!(!Vt||Vt.fit.score<Ff||Vt.map==null||Vt.map<.4||Vt.margin<.2)&&((!se||Vt.map>se.map)&&(se={ci:Mt.ci,off:Vt.off,fit:Vt.fit,map:Vt.map,srcW:Vt.srcW,srcH:Vt.srcH,refW:Vt.refW,refH:Vt.refH}),Vt.fit.score>=WC))break}if(!se&&B.length){let lt=B[0],Mt=await Qn("sizing confirm",()=>De(lt.ci,D,lt.off,lt.radius,{})).catch(()=>null);Ue&&console.error(`[find-first] sizing ${lt.label}@${K+lt.off} turned \u2192 ${Mt?`agreement ${Mt.fit.score.toFixed(2)}${Mt.map!=null?`, map ${Mt.map.toFixed(2)} margin ${Mt.margin.toFixed(2)}`:""}`:"\u2013"}`),Mt&&Mt.fit.score>=Ff&&Mt.map!=null&&Mt.map>=.4&&Mt.margin>=.2&&(se={ci:lt.ci,off:Mt.off,fit:Mt.fit,map:Mt.map,srcW:Mt.srcW,srcH:Mt.srcH,refW:Mt.refW,refH:Mt.refH})}return se?{clipIndex:se.ci,srcAtProbe:K+se.off,score:Yn,transform:se.fit.transform,srcW:se.srcW,srcH:se.srcH,refW:se.refW,refH:se.refH}:null},U=null;for(let B of ge.slice(0,ne?1:4)){let se=await We(B.clipIndex).catch(()=>null);if(!se)continue;let it=await $v(B.clipIndex,B.label,se.offs.length,D,K,B.srcAtProbe,B.radius,ne?1:3);if(Ue&&console.error(`[find-first] ${B.label}@${B.srcAtProbe} \xB1${B.radius} (${B.why}) \u2192 ${it?`confirmed at ${it.srcAtProbe}, ${it.score} bits`:"refused"}`),it){U={clipIndex:B.clipIndex,srcAtProbe:it.srcAtProbe,score:it.score,transform:"transform"in it?it.transform:null,srcW:"srcW"in it?it.srcW:void 0,srcH:"srcH"in it?it.srcH:void 0,refW:"refPlane"in it?it.refPlane.w:0,refH:"refPlane"in it?it.refPlane.h:0};break}}if(!U&&I){let B=ge.find(se=>se.why==="continuity");B&&(U=await ke([{ci:B.clipIndex,label:B.label,off:B.srcAtProbe-K,radius:Ja,why:"continuity"}]))}if(!U&&I){let B=I.refEnd===D.refStart-1;if(B||I.refEnd===D.refEnd){let se=I.clipIndex,it=Je(se),lt=await We(se).catch(()=>null),Mt=B?D.refStart:D.refEnd+1,Vt=Math.max(0,Mt-1),vr=Math.min(Z-1,Mt+qD-1),Mi=ir=>I.srcAtEnd+Math.round((ir-I.refEnd)*it),rr=(Ye.get(se)??[]).find(ir=>B?ir.refStart+ir.count-1===I.refEnd:ir.refStart===I.refEnd+1),vn=rr?await He(rr,se,Mi(rr.probe),rr.probe).catch(()=>null):null;if(lt&&Mi(Vt)>=0&&Mi(vr)<lt.offs.length){let ir=vn?vn.refToSrc.map(ni=>ni.toFixed(4)).join(","):"",Va=Array.from({length:vr-Vt+1},(ni,ta)=>Vt+ta),[Zt,Kr]=await Promise.all([Promise.all(Va.map(ni=>N(`r@${ni}`,()=>de(ni)))),Promise.all(Va.map(ni=>{let ta=Mi(ni);return vn?me(`w${se}@${ta}|${ir}`,()=>Oe(se,ta),vn):N(`c${se}@${ta}`,()=>Oe(se,ta))}))]),pr=ca(Zt,Kr,0,0,0);Ue&&console.error(`[find-first] seam ${Mt} continuing ${t[se].name}: maps ${pr?pr.score.toFixed(2):"\u2013"}`),pr&&pr.score>=UD&&(U={clipIndex:se,srcAtProbe:Mi(K),score:Yn,transform:rr?.transform??null,srcW:rr?.srcW,srcH:rr?.srcH,refW:rr?.refW??0,refH:rr?.refH??0})}}}!U&&je.length&&(U=await ke(je.filter(B=>Je(B.ci)===1).map(B=>({ci:B.ci,label:t[B.ci].name,off:B.srcAtProbe-K,radius:4,why:"audio"})))),!U&&!I&&(U=await ke(ie.filter(B=>B.sim>=ee-.06&&Je(B.clipIndex)===1).slice(0,4).map(B=>({ci:B.clipIndex,label:B.label,off:B.srcAtProbe-K,radius:Fe(B.clipIndex)+6,why:`index ${B.sim.toFixed(2)}`}))));let Me=[],Le=new Set(ie.filter(B=>B.sim>=ee-.06).map(B=>B.clipIndex)).size>=2;if(!U&&!I&&(!ne||Le)&&Se.length&&ce>=Rf){let B=sa(R.pdq,Math.floor(D.refStart/z),Math.floor(D.refEnd/z));Me.length=0;for(let se of ie)se.sim>=ee-.06&&Je(se.clipIndex)===1&&Pn(se.clipIndex);for(let se of ie){if(se.sim<ee-.06||Je(se.clipIndex)!==1)continue;Ce.has(se.clipIndex)||i?.(E,qe.length,`placing shot ${E+1}/${qe.length} \u2014 reading ${se.label}`);let it=Pn(se.clipIndex),lt=Iy(B,Math.floor(D.refStart/z),[{clipIndex:se.clipIndex,label:se.label,deltas:sa(await it)}]);if(await We(se.clipIndex).catch(()=>null)){Ue&&console.error(`[find-first] motion in ${se.label}: ${lt.map(Vt=>`@${Math.round((K/z+Vt.offset)*z)} r=${Vt.r.toFixed(2)}`).join(", ")||"none"}`);for(let Vt of lt.slice(0,2))Me.push({c:se,srcGuess:Math.round((K/z+Vt.offset)*z),r:Vt.r})}}Me.sort((se,it)=>it.r-se.r);for(let se of Me.slice(0,3)){let it=await We(se.c.clipIndex).catch(()=>null);if(!it)continue;let lt=await $v(se.c.clipIndex,se.c.label,it.offs.length,D,K,se.srcGuess,Math.max(4,2*z+2))??await $n(se.c.clipIndex,await Ce.get(se.c.clipIndex),D,K,se.srcGuess)??await ht(se.c.clipIndex,D,K,se.srcGuess);if(Ue&&console.error(`[find-first] ${se.c.label}@${se.srcGuess} (motion r=${se.r.toFixed(2)}) \u2192 ${lt?`confirmed at ${lt.srcAtProbe}, ${lt.score} bits`:"refused"}`),lt){U={clipIndex:se.c.clipIndex,srcAtProbe:lt.srcAtProbe,score:lt.score,transform:lt.transform??null,srcW:lt.srcW,srcH:lt.srcH,refW:lt.refPlane?.w??0,refH:lt.refPlane?.h??0};break}}}if(!U&&!I&&ce>=8){let B=Math.min(96,ce),se=D.refStart+(ce-B>>1);for(let it of ie.filter(lt=>lt.sim>=ee-.06&&Je(lt.clipIndex)===1).slice(0,3)){let lt=await Qn("map place",()=>Ke(it.clipIndex,se,B,it.srcAtProbe-K,Hy));if(Ue&&console.error(`[find-first] map place ${it.label}: ${lt?`${lt.off} (score ${lt.score.toFixed(2)}, margin ${lt.margin.toFixed(2)})`:"\u2013"}`),!lt||lt.score<.4||lt.margin<.2)continue;let Mt=await de(K),Vt=await Oe(it.clipIndex,K+lt.off),vr=Mt&&Vt?await Qr(Vt.y,Vt.w,Vt.h,Mt.y,Mt.w,Mt.h,k).catch(()=>null):null;U={clipIndex:it.clipIndex,srcAtProbe:K+lt.off,score:Yn,transform:vr?.ok?vr.transform:null,srcW:vr?.ok?vr.srcW:void 0,srcH:vr?.ok?vr.srcH:void 0,refW:Mt?.w??0,refH:Mt?.h??0};break}}if(!U&&!I&&Me.length&&(U=await ke(Me.slice(0,3).map(B=>({ci:B.c.clipIndex,label:B.c.label,off:B.srcGuess-K,radius:c9,why:`motion r=${B.r.toFixed(2)}`})))),!U&&!I&&ce>=12&&Vy())for(let B of ie.filter(se=>se.sim>=ee-.06&&Je(se.clipIndex)!==1).slice(0,2)){let se=await $e(B.clipIndex,D,K,B.srcAtProbe,Math.ceil(Fe(B.clipIndex)*Je(B.clipIndex)));if(Ue&&console.error(`[find-first] off-rate sizing ${B.label}@${B.srcAtProbe}: ${se?`${se.at} at ${se.rate.toFixed(2)}\xD7, agreement ${se.v.fit.score.toFixed(2)}`:"\u2013"}`),!(!se||se.v.fit.score<Ff)){U={clipIndex:B.clipIndex,srcAtProbe:se.at,score:Yn,transform:se.v.fit.transform,srcW:se.v.srcW,srcH:se.v.srcH,refW:se.v.refW,refH:se.v.refH};break}}if(!U&&!I&&ce>=6&&(U=await Qn("orb rescue",()=>tr(D,K,ae))),!U){for(let B of ie)B.sim>=ee-.1&&Tn.add(B.clipIndex);return}{let B=await Qn("refine by motion",()=>Fr(U.clipIndex,D,K,U.srcAtProbe));Ue&&console.error(`[find-first] motion: ${U.srcAtProbe} \u2192 ${B.srcAtProbe} (r=${Number.isFinite(B.r)?B.r.toFixed(2):"\u2013"}${B.ambiguous?", undecided":""})`);let se=B.ambiguous;if(je.find(lt=>lt.ci!==U.clipIndex&&Je(lt.ci)===1)&&(se=!0),U={...U,srcAtProbe:B.srcAtProbe},Je(U.clipIndex)===1){let lt=Math.min(96,ce),Mt=D.refStart+(ce-lt>>1),Vt=await He(U,U.clipIndex,U.srcAtProbe,K).catch(()=>null),vr=await Qn("motion map",()=>Ke(U.clipIndex,Mt,lt,U.srcAtProbe-K,Hy,Vt));if(Ue&&console.error(`[find-first] map: ${U.srcAtProbe-K} \u2192 ${vr?`${vr.off} (score ${vr.score.toFixed(2)}, margin ${vr.margin.toFixed(2)})`:"\u2013"}`),vr?.clear&&(U={...U,srcAtProbe:K+vr.off},se=!1),se&&!vr?.clear){let Mi=vr?.score??0;for(let rr of ie.filter(vn=>vn.clipIndex!==U.clipIndex&&vn.sim>=ee-.1&&Je(vn.clipIndex)===1).slice(0,3)){let vn=await Qn("take check",()=>De(rr.clipIndex,D,rr.srcAtProbe-K,Fe(rr.clipIndex)+6)).catch(()=>null),ir=vn&&vn.map!=null?{off:vn.off,score:vn.map,margin:vn.margin,clear:vn.map>=.4&&vn.margin>=.2&&vn.fit.score>=Ff}:null;if(Ue&&console.error(`[find-first] take ${rr.label}: ${ir?`${ir.off} (score ${ir.score.toFixed(2)}, margin ${ir.margin.toFixed(2)}, agreement ${vn.fit.score.toFixed(2)})`:"\u2013"} vs ${Mi.toFixed(2)}`),!ir?.clear||ir.score<Mi+.2)continue;let Va=await We(rr.clipIndex).catch(()=>null),Zt=Va?await $v(rr.clipIndex,rr.label,Va.offs.length,D,K,K+ir.off,2,1):null;if(Zt){U={clipIndex:rr.clipIndex,srcAtProbe:K+ir.off,score:Zt.score,transform:"transform"in Zt?Zt.transform:null,srcW:"srcW"in Zt?Zt.srcW:void 0,srcH:"srcH"in Zt?Zt.srcH:void 0,refW:"refPlane"in Zt?Zt.refPlane.w:0,refH:"refPlane"in Zt?Zt.refPlane.h:0},se=!1;break}}}if(se&&!vr?.clear){let Mi=vr?.score??0,rr=[{ci:U.clipIndex,label:t[U.clipIndex].name,warp:Vt,fitScore:null,off0:U.srcAtProbe-K}];for(let Zt of ie.filter(Kr=>Kr.clipIndex!==U.clipIndex&&Kr.sim>=ee-.06&&Je(Kr.clipIndex)===1).slice(0,2)){let Kr=await wt(Zt.clipIndex,D,Zt.srcAtProbe-K).catch(()=>null);rr.push({ci:Zt.clipIndex,label:Zt.label,warp:Kr?.warp??null,fitScore:Kr?.fit.score??null,off0:Zt.srcAtProbe-K})}let vn=null,ir=je.filter(Zt=>Je(Zt.ci)===1).map(Zt=>({ci:Zt.ci,off:Zt.srcAtProbe-K,score:1}));for(let Zt of rr){let Kr=ce<XC,pr=await Qn("take scan",()=>Kr?zn(Zt.ci,D,Zt.off0):nn(Zt.ci,D,Zt.warp,Zt.off0)).catch(()=>null);if(Ue&&console.error(`[find-first] scan ${Zt.label}: ${pr?`${K+pr.off} (score ${pr.score.toFixed(2)}, margin ${pr.margin.toFixed(2)}; peaks ${pr.peaks.map(ni=>`${K+ni.off}:${ni.score.toFixed(2)}`).join(" ")})`:"\u2013"} vs ${Mi.toFixed(2)}`),pr)for(let ni of pr.peaks)ni.score>=VC&&ir.push({ci:Zt.ci,...ni});!Kr&&pr&&pr.score>=jC&&pr.margin>=FC&&pr.score>=Mi+IC&&(!vn||pr.score>vn.score)&&(vn={ci:Zt.ci,...pr})}let Va=!1;if(vn){let Zt=await wt(vn.ci,D,vn.off).catch(()=>null);Ue&&console.error(`[find-first] scan \u2192 ${t[vn.ci].name}@${K+vn.off}, agreement ${Zt?Zt.fit.score.toFixed(2):"\u2013"}`),Zt&&Zt.fit.score>=l9&&(U={clipIndex:vn.ci,srcAtProbe:K+vn.off,score:Yn,transform:Zt.fit.transform,srcW:Zt.srcW,srcH:Zt.srcH,refW:Zt.warp.refW,refH:Zt.warp.refH},se=!1,Va=!0)}if(!Va&&ir.length){let Kr=(await wt(U.clipIndex,D,U.srcAtProbe-K).catch(()=>null))?.fit.score??0,pr={best:null},ni=new Set,ta=async(ri,ii,mp)=>{let H8=`${ri}@${ii}`;if(ni.has(H8)||ri===U.clipIndex&&ii===U.srcAtProbe-K)return;ni.add(H8);let mf=await Qn("moment sizing",()=>wt(ri,D,ii)).catch(()=>null);Ue&&mp&&console.error(`[find-first] moment ${t[ri].name}@${K+ii} (${mp}): agreement ${mf?mf.fit.score.toFixed(2):"\u2013"} vs ${Kr.toFixed(2)} here`),mf&&(!pr.best||mf.fit.score>pr.best.sw.fit.score)&&(pr.best={ci:ri,off:ii,sw:mf})},W8=[];for(let ri of[...new Set(ir.map(ii=>ii.ci))])W8.push(...ir.filter(ii=>ii.ci===ri).sort((ii,mp)=>mp.score-ii.score).slice(0,2));for(let ri of W8)for(let ii=-f9;ii<=f9;ii+=qy)await ta(ri.ci,ri.off+ii,ii===0?`map ${ri.score.toFixed(2)}`:"");let ny=pr.best;if(ny)for(let ri=1-qy;ri<qy;ri++)ri&&await ta(ny.ci,ny.off+ri,"");let yr=pr.best;Ue&&yr&&console.error(`[find-first] moment sweep best ${t[yr.ci].name}@${K+yr.off}: agreement ${yr.sw.fit.score.toFixed(2)} vs ${Kr.toFixed(2)} here`),yr&&yr.ci!==U.clipIndex&&yr.sw.fit.score>=Kr-EC&&yr.sw.fit.score<Kr+u9&&Or.set(D.refStart,{clipLabel:t[yr.ci].name,agreement:yr.sw.fit.score,winnerAgreement:Kr}),yr&&yr.sw.fit.score>=l9&&yr.sw.fit.score>=Kr+u9&&(Or.delete(D.refStart),Ue&&console.error(`[find-first] moment \u2192 ${t[yr.ci].name}@${K+yr.off}, agreement ${yr.sw.fit.score.toFixed(2)}`),U={clipIndex:yr.ci,srcAtProbe:K+yr.off,score:Yn,transform:yr.sw.fit.transform,srcW:yr.sw.srcW,srcH:yr.sw.srcH,refW:yr.sw.warp.refW,refH:yr.sw.warp.refH},se=!1)}}}se&&Ut.add(D.refStart)}let Ve=Je(U.clipIndex),ct=await He(U,U.clipIndex,U.srcAtProbe,K).catch(()=>null),Tt=Ve===1?await Qn("split check",async()=>ft(U.clipIndex,D.refStart,D.refEnd,U.srcAtProbe-K,ct)):[{refStart:D.refStart,refEnd:D.refEnd,off:U.srcAtProbe/Ve-K}],ln=(await Qn("jump cuts",()=>Promise.all(Tt.map(B=>ZD(U.clipIndex,B,Ve,ct))))).flat(),Yt=Ye.get(U.clipIndex)??[];if(ln.length>1)for(let B of ln)Yt.push({refStart:B.refStart,srcStart:Ve===1?Math.round(B.refStart+B.off):B.refStart+B.off,count:B.refEnd-B.refStart+1,score:U.score,transform:U.transform??null,srcW:U.srcW,srcH:U.srcH,refW:U.refW??0,refH:U.refH??0,probe:B.refStart+(B.refEnd-B.refStart>>1)});else Yt.push({refStart:D.refStart,srcStart:Ve===1?Math.round(U.srcAtProbe-(K-D.refStart)):U.srcAtProbe/Ve-(K-D.refStart),count:ce,score:U.score,transform:U.transform??null,srcW:U.srcW,srcH:U.srcH,refW:U.refW??0,refH:U.refH??0,probe:K});Ye.set(U.clipIndex,Yt);for(let B=D.refStart;B<=D.refEnd;B++)pe[B]=1;let Et=ln[ln.length-1].off,Sn=ln[0].off;dp[E]={clipIndex:U.clipIndex,refEnd:D.refEnd,srcAtEnd:ln.length>1?Math.round((D.refEnd+Et)*Ve):Math.round(U.srcAtProbe+(D.refEnd-K)*Ve)},E8[E]={clipIndex:U.clipIndex,refEnd:D.refStart,srcAtEnd:ln.length>1?Math.round((D.refStart+Sn)*Ve):Math.round(U.srcAtProbe-(K-D.refStart)*Ve)},Ue&&console.error(`[find-first] shot ${D.refStart}\u2013${D.refEnd} took ${Math.round(performance.now()-he)} ms`)},ea=Math.min(qe.length,Number(typeof process<"u"&&process.env?.CONFORM_MAX_SHOTS||1/0)),V8=0;await Promise.all(Array.from({length:Cy},async()=>{for(;V8<ea;){let E=V8++;await ty(E,null),df++,i?.(df,qe.length,`placing shots ${df}/${qe.length}`)}}));for(let E=1;E<ea;E++){let I=dp[E-1];dp[E]||ey[E]||!I||I.refEnd!==qe[E].refStart-1||(i?.(E,ea,`continuity ${E}/${ea}`),await ty(E,I))}for(let E=ea-2;E>=0;E--){let I=E8[E+1];dp[E]||ey[E]||!I||I.refEnd!==qe[E].refEnd+1||(i?.(ea-E,ea,`continuity ${ea-E}/${ea}`),await ty(E,{...I,refEnd:I.refEnd-1,srcAtEnd:I.srcAtEnd-Math.round(Je(I.clipIndex))}))}typeof process<"u"&&process.env?.CONFORM_PROFILE&&console.error($7());for(let E of Y){let I=await We(E.clipIndex).catch(()=>null);if(!I)continue;W[E.clipIndex]=I;let D=Je(E.clipIndex),he=(Ye.get(E.clipIndex)??[]).sort((ae,ie)=>ae.refStart-ie.refStart),ce=new Map(he.map(ae=>[ae.refStart,ae.score])),K=he.length?await Kt(E.clipIndex,he,ae=>Math.round(ae*D),ae=>ce.get(ae.refStart)??null):[];for(let ae of K){if(ae.track.kind!=="unresolved")continue;let ie=he.find(ge=>ge.refStart===ae.refStart);if(ie&&!ie.transform){let ge=he.find(je=>je!==ie&&je.transform&&je.refW&&(je.refStart+je.count===ie.refStart&&Math.abs(Math.round((je.srcStart+je.count)*D)-Math.round(ie.srcStart*D))<=2||ie.refStart+ie.count===je.refStart&&Math.abs(Math.round((ie.srcStart+ie.count)*D)-Math.round(je.srcStart*D))<=2));ge&&(ie={...ie,transform:ge.transform,srcW:ge.srcW,srcH:ge.srcH,refW:ge.refW,refH:ge.refH})}if(!ie?.transform||!ie.refW)continue;let ee=aa({transform:ie.transform,srcW:ie.srcW,srcH:ie.srcH},ie.refW,ie.refH);ae.track={kind:"static",keyframes:[{refFrame:ie.probe,reframe:ee}],label:ee.label},ae.reframe=ee}let Se=he.reduce((ae,ie)=>ae+ie.count,0);q.push({clipIndex:E.clipIndex,label:t[E.clipIndex].name,shots:K,coverage:I.offs.length?Se/I.offs.length:0,srcFps:I.fps,srcStartFrame:I.startFrame,srcDropFrame:I.dropFrame,srcFrames:I.offs.length,srcW:I.w||null,srcH:I.h||null,codec:jo(I.kind),geometrySupported:!!a&&!!s,warnings:[]})}for(let E=0;E<t.length;E++)q.some(I=>I.clipIndex===E)||(q.push({clipIndex:E,label:t[E].name,shots:[],coverage:0,srcFps:null,srcStartFrame:0,srcFrames:0,srcW:null,srcH:null,codec:"not indexed",geometrySupported:!1,warnings:[`${Fy} this clip could not be read for the index.`]}),W[E]={offs:[],codec:"",kind:"other",w:0,h:0,fps:null,startFrame:0,dropFrame:!1},H[E]=1)}for(let Z of dt){let re=_.get(Z),fe=t[Z];q.push({clipIndex:Z,label:fe.name,shots:[],coverage:0,srcFps:null,srcStartFrame:0,srcFrames:0,srcW:null,srcH:null,codec:"not examined",geometrySupported:!1,warnings:[`${Fy} the reference was already fully accounted for and the last ${Cp} clips added nothing, so the run stopped here. On a ${Up}-frame probe this clip's closest frame was ${re&&Number.isFinite(re.minDistance)?`${re.minDistance} bits`:"not measurable"} from the reference \u2014 worse than every clip that won a shot. Re-run with "examine every clip" if a shot you expected is missing.`]}),W[Z]={offs:[],codec:"",kind:"other",w:0,h:0,fps:null,startFrame:0,dropFrame:!1},H[Z]=1}q.sort((Z,re)=>Z.clipIndex-re.clipIndex);let lr,co=null;if(p&&F.length){L(),i?.(t.length,t.length,"placing shots");let Z=b&&F.every(xe=>xe.embed)?await b(e):null;co=Z;let re=Rz(R.pdq,F,{...h,...Z?{embedding:{ref:Z,...h?.embedding}}:{}});lr=re;let fe=xe=>{let Y=Math.floor(xe/z);return re.find(le=>le.refStart<=Y&&le.refEnd>=Y)};for(let xe of q)for(let Y of xe.shots){let Fe=fe(Y.refStart+Y.refEnd>>1)?.placement;if(!Fe||Fe.clipIndex!==xe.clipIndex)continue;let mt=H[xe.clipIndex]??1,We=Fe.refStart*z,xt=Fe.refEnd*z+z-1;if(Y.refStart<We||Y.refEnd>xt)continue;let Je=Math.round((Y.refStart+Fe.offset*z)*mt),qe=Je-Y.srcStart;if(Math.abs(qe)>z){let St=Y.srcEnd-Y.srcStart;Y.srcStart=Je,Y.srcEnd=Je+St}Y.vote={offset:Fe.offset*z,ambiguity:Fe.ambiguity,share:Fe.share,consensus:Fe.consensus,movedBy:Math.abs(qe)>z?qe:0,truncated:Fe.truncated}}}if(f){let Z=q.flatMap(fe=>fe.shots.map(xe=>({shot:xe,clipLabel:fe.label,refStart:xe.refStart,refEnd:xe.refEnd,score:xe.score,srcFps:fe.srcFps,file:t[fe.clipIndex]}))),re=Z7(Z);if(re.length){L(),i?.(t.length,t.length,"audio arbitration");let fe=d??jp,xe=async mt=>{try{return await fe(mt)}catch{return null}},Y=new Map,le=async(mt,We,xt)=>(Y.has(mt)||Y.set(mt,gy(await xe(We),xt)),Y.get(mt)??null),Fe=gy(await xe(e),j.fps);for(let mt of re){let We=[];for(let Je of mt)We.push({label:Je.clipLabel,refStart:Je.refStart,refEnd:Je.refEnd,srcStart:Je.shot.srcStart,track:await le(Je.clipLabel,Je.file,Je.srcFps)});let xt=H7(Fe,We);mt.forEach((Je,qe)=>{Je.shot.audio=xt[qe]})}}}let Ee=nz(j.offs.length,q);if(P&&an.length&&(Ee=Hp(Ee,an),Ee=Ee.map(Z=>{if(Z.kind!=="gap")return Z;let re=Nn.find(fe=>fe.refStart<=Z.refStart&&fe.refEnd>=Z.refEnd);return re?{...Z,nothingSimilar:Math.max(0,re.best)}:Z}),Ee=Ee.map(Z=>Z.kind!=="gap"&&Ut.has(Z.refStart)&&Z.inPointAmbiguity==null?{...Z,inPointUnconfirmed:!0}:Z),Ee=Ee.map(Z=>{let re=Z.kind!=="gap"?Or.get(Z.refStart):void 0;return re&&re.clipLabel!==Z.clipLabel?{...Z,takeRival:re}:Z})),lr?.length){let Z=[];for(let re of Ee){if(re.kind!=="gap"){Z.push(re);continue}let fe=re.refStart;for(let xe of lr){let Y=xe.refStart*z,le=xe.refEnd*z+z-1,Fe=Math.max(fe,Y),mt=Math.min(re.refEnd,le);if(Fe>mt)continue;let We=xe.placement?.clipLabel??xe.ramp?.clipLabel;if(!We)continue;Fe>fe&&Z.push({...re,refStart:fe,refEnd:Fe-1});let xt=q.find(Ue=>Ue.label===We),Je=xt?H[xt.clipIndex]??1:1,qe=Ue=>{let pn=Ue/z,En=xe.ramp?xe.ramp.srcAtStart+xe.ramp.slope*(pn-xe.refStart):pn+xe.placement.offset;return Math.round(En*z*Je)},St=Fe+mt>>1,$t=Je===1&&!xe.ramp,Ht=xt?await Of({refLuma:de,cand:{label:We,frameCount:xt.srcFrames,luma:Ue=>Oe(xt.clipIndex,Ue)},refProbe:St,srcGuess:qe(St),radius:Math.max(4,Math.ceil(((xe.placement?.ambiguity??xe.ramp?.ambiguity??2)*z+2)*Je)),runSpread:$t?Math.max(1,Math.floor((mt-Fe+1)/3)):0,reframeOpts:k}):null;if(!Ht){Z.push({...re,refStart:Fe,refEnd:mt,unconfirmed:{clipLabel:We,srcFrame:qe(Fe)}}),fe=mt+1;continue}let be=Ht.srcAtProbe-qe(St),Ye=aa(Ht,Ht.refPlane.w,Ht.refPlane.h);Z.push({...re,refStart:Fe,refEnd:mt,kind:"static",clipLabel:We,srcStart:qe(Fe)+be,srcEnd:qe(mt)+be,track:{kind:"static",keyframes:[{refFrame:St,reframe:Ye}],label:Ye.label},score:Ht.score,inPointAmbiguity:Ht.ambiguity,...xe.ramp?{speed:{slope:xe.ramp.slope,percent:xe.ramp.slope*100,kind:xe.ramp.slope===0?"freeze":"retime",samples:xe.ramp.pieces,residual:xe.ramp.residual}}:{}}),fe=mt+1}fe<=re.refEnd&&Z.push({...re,refStart:fe,refEnd:re.refEnd})}Ee=Z}if(lr?.length){let Z=lr.map(re=>re.refStart*z).filter(re=>re>0);Ee=Ee.flatMap(re=>re.kind==="gap"?Hp([re],Z):[re])}if(co&&F.every(Z=>Z.embed)){let Z=[...new Set(F.flatMap(fe=>fe.embed))],re=(fe,xe)=>{let Y=0;for(let le=0;le<fe.length;le++)Y+=fe[le]*xe[le];return Y};Ee=Ee.map(fe=>{if(fe.kind!=="gap")return fe;let xe=-1;for(let Y=fe.refStart;Y<=fe.refEnd&&xe<nh;Y+=4){let le=co[Y];if(le)for(let Fe of Z){let mt=re(le,Fe);if(mt>xe&&(xe=mt,xe>=nh))break}}return xe>=0&&xe<nh?{...fe,nothingSimilar:xe}:fe})}if(!P&&a&&s&&Ee.some(Z=>Z.kind==="gap")){L(),i?.(t.length,t.length,"continuity and motion");let Z=F.map(Y=>({clipIndex:Y.clipIndex,label:Y.label,deltas:sa(Y.pdq)})),re=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,fe=new Map(q.map(Y=>[Y.clipIndex,Y])),xe=[];for(let Y=0;Y<Ee.length;Y++){let le=Ee[Y],Fe=le.refEnd-le.refStart+1;if(le.kind!=="gap"||Fe<8||le.nothingSimilar!=null){xe.push(le);continue}let mt=[],We=(be,Ye)=>{if(!be||!be.clipLabel||be.srcStart==null||be.srcEnd==null||be.kind!=="static"&&be.kind!=="animated"||(Ye==="before"?be.refEnd!==le.refStart-1:be.refStart!==le.refEnd+1))return;let Ue=q.find(Ce=>Ce.label===be.clipLabel);if(!Ue)return;let pn=be.refEnd>be.refStart?(be.srcEnd-be.srcStart)/(be.refEnd-be.refStart):H[Ue.clipIndex]??1,En=Ye==="before"?Ce=>Math.round(be.srcEnd+(Ce-be.refEnd)*pn):Ce=>Math.round(be.srcStart-(be.refStart-Ce)*pn);mt.push({clipIndex:Ue.clipIndex,label:Ue.label,at:En,radius:Ja,why:"continuity"})};for(let be of yt){if(be.refEnd<le.refStart||be.refStart>le.refEnd)continue;let Ye=fe.get(be.clipIndex);Ye&&mt.push({clipIndex:be.clipIndex,label:Ye.label,at:Ue=>Math.round(be.srcStart+(Ue-be.refStart)*be.speed),radius:12,why:"timeline claim"})}We(xe[xe.length-1],"before"),We(Ee[Y+1],"after");let xt=le.refStart,Je=le.refEnd;for(let be=Y-1;be>=0&&Ee[be].kind==="gap"&&Ee[be].refEnd===xt-1&&Ee[be].nothingSimilar==null;be--)xt=Ee[be].refStart;for(let be=Y+1;be<Ee.length&&Ee[be].kind==="gap"&&Ee[be].refStart===Je+1&&Ee[be].nothingSimilar==null;be++)Je=Ee[be].refEnd;let qe=(be,Ye)=>{let Ue=Math.ceil(be/z),pn=Math.floor(Ye/z);return pn-Ue>Kp&&(Ue=(Ue+pn>>1)-(Kp>>1),pn=Ue+Kp),Iy(sa(R.pdq,Ue,pn),Ue,Z).slice(0,4)},St=qe(le.refStart,le.refEnd);if(xt<le.refStart||Je>le.refEnd){for(let be of qe(xt,Je))St.some(Ye=>Ye.clipIndex===be.clipIndex&&Math.abs(Ye.offset-be.offset)<=2)||St.push(be);St.sort((be,Ye)=>Ye.r-be.r)}for(let be of St){let Ye=H[be.clipIndex]??1;mt.push({clipIndex:be.clipIndex,label:be.label,at:Ue=>Math.round((Ue/z+be.offset)*z*Ye),radius:Math.max(4,Math.ceil((2*z+2)*Ye)),why:`motion r=${be.r.toFixed(2)}`})}let $t=le.refStart+le.refEnd>>1,Ht=null;re&&console.error(`[nominate] gap ${le.refStart}\u2013${le.refEnd}: ${mt.map(be=>`${be.label}@${be.at($t)} (${be.why})`).join(", ")||"none"}`);for(let be of mt){let Ye=fe.get(be.clipIndex);if(!Ye)continue;let Ue=H[be.clipIndex]??1,pn=be.at($t);if(pn<0||pn>=Ye.srcFrames)continue;let En=await Of({refLuma:de,cand:{label:be.label,frameCount:Ye.srcFrames,luma:$n=>Oe(be.clipIndex,$n)},refProbe:$t,srcGuess:pn,radius:be.radius,runSpread:Ue===1?Math.max(1,Math.floor(Fe/3)):0,reframeOpts:k}).catch(()=>null);if(re&&console.error(`[nominate] ${be.label}@${pn} (${be.why}) \u2192 ${En?`confirmed at ${En.srcAtProbe}, ${En.score} bits`:"refused by the picture"}`),!En)continue;let Ce=En.srcAtProbe-pn,Pn=aa(En,En.refPlane.w,En.refPlane.h);Ht={refStart:le.refStart,refEnd:le.refEnd,kind:"static",clipLabel:be.label,srcStart:be.at(le.refStart)+Ce,srcEnd:be.at(le.refEnd)+Ce,track:{kind:"static",keyframes:[{refFrame:$t,reframe:Pn}],label:Pn.label},score:En.score,inPointAmbiguity:En.ambiguity};break}xe.push(Ht??le)}Ee=xe}if(o&&!P&&Ee.some(Z=>Z.kind==="gap"||Z.kind==="unresolved")){L(),i?.(t.length,t.length,"gap-fill");let Z=P?q.filter(Y=>Tn.has(Y.clipIndex)||Y.shots.length):q,re=await Promise.all(Z.map(async Y=>({label:Y.label,frameCount:Y.srcFrames,luma:le=>Oe(Y.clipIndex,le),rate:H[Y.clipIndex]??1,keyframes:O?await O(t[Y.clipIndex]).catch(()=>null):null}))),fe="retrieval";Ee=await mz(Ee,de,re,{...k,signal:r,onProgress:(Y,le)=>i?.(Y,le,`gap-fill ${fe}`),onPhase:Y=>{fe=Y,i?.(0,1,`gap-fill ${Y}`)}});let xe=new Map(q.map(Y=>[Y.label,Y]));for(let Y of Ee){if(!Y.clipLabel||Y.srcStart==null||Y.kind==="gap")continue;let le=xe.get(Y.clipLabel);le&&(le.shots.some(Fe=>Fe.refStart<=Y.refEnd&&Fe.refEnd>=Y.refStart)||le.shots.push({refStart:Y.refStart,refEnd:Y.refEnd,srcStart:Y.srcStart,srcEnd:Y.srcEnd??Y.srcStart+(Y.refEnd-Y.refStart),reframe:Y.track?.keyframes[Y.track.keyframes.length>>1]?.reframe??null,geometry:null,track:Y.track??{kind:"unresolved",keyframes:[],label:"unresolved"},score:Y.score??null,contestedBy:null}))}for(let Y of q)Y.shots.sort((le,Fe)=>le.refStart-Fe.refStart)}for(let Z of q)if(Z.shots.length!==0)for(let re of Ee){if(re.clipLabel!==Z.label)continue;let fe=Z.shots.filter(Fe=>Fe.refStart>=re.refStart&&Fe.refEnd<=re.refEnd);if(fe.length===0)continue;let xe=H[Z.clipIndex]??1,Y=tz(xe===1?fe:fe.map(Fe=>({refStart:Fe.refStart,srcStart:Fe.srcStart/xe})));if(Y.kind==="normal")continue;let le=re.refEnd-re.refStart+1;Y.residual>Math.max(2,.25*le)||(re.speed=Y)}if(lr?.length&&(Ee=Hp(Ee,lr.map(Z=>Z.refStart*z).filter(Z=>Z>0))),lr?.some(Z=>Z.ramp))for(let Z of Ee){if(!Z.clipLabel||Z.kind==="gap"||Z.srcStart==null)continue;let re=lr.find(Fe=>Fe.ramp&&Fe.ramp.clipLabel===Z.clipLabel&&Z.refStart>=Fe.refStart*z&&Z.refEnd<=Fe.refEnd*z+z-1),fe=re?.ramp;if(!fe||!re)continue;let xe=q.find(Fe=>Fe.label===Z.clipLabel),Y=xe?H[xe.clipIndex]??1:1,le=Fe=>Math.round((fe.srcAtStart*z+fe.slope*(Fe-re.refStart*z))*Y);Z.srcStart=le(Z.refStart),Z.srcEnd=le(Z.refEnd),Z.speed={slope:fe.slope,percent:fe.slope*100,kind:fe.slope===0?"freeze":"retime",samples:fe.pieces,residual:fe.residual}}i?.(t.length,t.length,"timing shots");let Kn=new Map,Zi=[],$o=new Map,Qc=Z=>{let re=Z.track?.keyframes?.[0]?.reframe;return Z.track?.kind==="animated"||!!(re&&(Math.abs(re.scale-1)>.02||Math.abs(re.rotationDeg)>.5||Math.hypot(re.dxCenter,re.dyCenter)>4))},up=async(Z,re,fe,xe)=>{if(Qc(Z))return fe;let Y=Z.refEnd-Z.refStart+1,le=Math.min(48,Y);if(le<6||xe<=0)return fe;let Fe=Z.refStart+(Y-le>>1),mt=(qe,St)=>{let $t=$o.get(qe);return $t||($t=St().then(Ht=>Wn(Ht)).catch(()=>null),$o.set(qe,$t)),$t},We=await Promise.all(Array.from({length:le},(qe,St)=>mt(`r@${Fe+St}`,()=>de(Fe+St)))),xt=q.find(qe=>qe.clipIndex===re),Je={s:fe,score:-1/0};for(let qe=-2;qe<=2;qe++){let St=Array.from({length:le},(be,Ye)=>fe+qe+Us(Fe-Z.refStart+Ye,xe));if(St[0]<0||xt?.srcFrames&&St[le-1]>=xt.srcFrames)continue;let $t=await Promise.all(St.map(be=>mt(`c${re}@${be}`,()=>Oe(re,be)))),Ht=ca(We,$t,0,0,0);Ht&&Ht.score>Je.score+(qe===0?-1e-9:.02)&&(Je={s:fe+qe,score:Ht.score})}return typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&Je.s!==fe&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}: start ${fe} \u2192 ${Je.s} (maps ${Je.score.toFixed(2)})`),Je.s},fp=async Z=>{if(!Z.clipLabel||Z.kind==="gap"||Z.kind==="composite"||Z.srcStart==null)return;let re=q.find(qe=>qe.label===Z.clipLabel);if(!re)return;let fe=re.srcFps&&j.fps?re.srcFps/j.fps:1,xe=(H[re.clipIndex]??1)!==1?H[re.clipIndex]:Math.abs(fe-1)>.01?fe:1;if(xe===1&&Z.score==null)return;L();let Y=Z.refEnd-Z.refStart,le=Z.srcStart,Fe=Z.srcEnd??Z.srcStart+Y*xe,mt=Date.now(),We=await pz({refLuma:de,cand:{label:re.label,frameCount:re.srcFrames,luma:qe=>Oe(re.clipIndex,qe),rate:xe},refStart:Z.refStart,refEnd:Z.refEnd,srcAt:qe=>Math.round(le+(Y?(qe-Z.refStart)*(Fe-le)/Y:0)),reframeOpts:k});if(typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}\u2013${Z.refEnd}: ${We?`${We.model} slope ${We.slope.toFixed(3)} in ${le}\u2192${Math.round(We.srcAtStart)}`:"no answer"} (${Date.now()-mt} ms)`),!We){xe!==1&&Zi.push({seg:Z,rate:xe});return}if(We.model==="retime"){let qe=[xe,1].find(St=>Math.abs(We.slope-St)/St<.025);if(qe!=null){let St=Z.refStart+Z.refEnd>>1,$t=Qc(Z)?le+(Y?(St-Z.refStart)*(Fe-le)/Y:0):We.srcAtStart+(St-Z.refStart)*We.slope;Z.srcStart=await up(Z,re.clipIndex,Math.round($t-(St-Z.refStart)*qe),qe),Z.srcEnd=Math.round(Z.srcStart+Y*qe);let Ht=qe/xe*100;Math.abs(Ht-100)<.5?delete Z.speed:Z.speed={slope:qe/xe,percent:Ht,kind:"retime",samples:We.anchors.length,residual:0,basis:"frame-for-frame"},typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}: retime ${We.slope.toFixed(3)} snapped to the natural ${qe===1?"frame-for-frame":"real-time"} line, start ${Z.srcStart}`);return}}if(xe!==1&&We.model!=="retime"){let qe=xe.toFixed(4),St=Kn.get(qe)??[],$t=St.find(Ht=>Math.abs(Ht.slopeOverRate-We.slope/xe)<.001);$t?$t.votes++:St.push({slopeOverRate:We.slope/xe,votes:1}),Kn.set(qe,St)}let xt=Math.abs(We.slope-xe)<1e-6||Math.abs(We.slope-1)<1e-6;if(Qc(Z)&&xt){let qe=Z.refStart+Z.refEnd>>1,St=le+(Y?(qe-Z.refStart)*(Fe-le)/Y:0);Z.srcStart=Math.round(St-(qe-Z.refStart)*We.slope)}else Z.srcStart=await up(Z,re.clipIndex,Math.round(We.srcAtStart),We.slope);Z.srcEnd=Math.round(Z.srcStart+Y*We.slope);let Je=We.slope/xe*100;Math.abs(Je-100)<.5?delete Z.speed:Z.speed={slope:We.slope/xe,percent:Je,kind:"retime",samples:We.anchors.length,residual:0,basis:We.model==="retime"?"measured":"frame-for-frame"}};{let Z=0;await Promise.all(Array.from({length:Cy},async()=>{for(;Z<Ee.length;)await fp(Ee[Z++])}))}for(let{seg:Z,rate:re}of Zi){let fe=(Kn.get(re.toFixed(4))??[]).sort((Je,qe)=>qe.votes-Je.votes);if(!fe.length||fe[1]&&fe[1].votes===fe[0].votes)continue;let xe=fe[0].slopeOverRate*re,Y=Z.refEnd-Z.refStart,le=Z.srcStart,Fe=Z.srcEnd??le+Y*re,mt=Z.refStart+Z.refEnd>>1,We=le+(Y?(mt-Z.refStart)*(Fe-le)/Y:0);Z.srcStart=Math.round(We-(mt-Z.refStart)*xe),Z.srcEnd=Math.round(We+(Z.refEnd-mt)*xe);let xt=fe[0].slopeOverRate*100;Math.abs(xt-100)<.5?delete Z.speed:Z.speed={slope:fe[0].slopeOverRate,percent:xt,kind:"retime",samples:fe[0].votes,residual:0,basis:"convention"}}{let xt=Io,Je=Ap,qe=new Map,St=(Ce,Pn)=>{let $n=qe.get(Ce);return $n||($n=Pn().catch(()=>null),qe.set(Ce,$n)),$n},$t=Ce=>{let Pn=Ce.srcFps&&j.fps?Ce.srcFps/j.fps:1;return(H[Ce.clipIndex]??1)!==1?H[Ce.clipIndex]:Math.abs(Pn-1)>.01?Pn:1},Ht=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,be=160,Ye=new Map,Ue=async(Ce,Pn,$n,Fr,Xn,N)=>{let me=q.find(kt=>kt.clipIndex===Ce),He=me?.srcFrames??0;if(!He)return[];let Ke=Us($n[$n.length-1]-Fr,Pn),ht=[0,$n.length>>1,$n.length-1].filter((kt,Bt,It)=>It.indexOf(kt)===Bt),De=await Promise.all(ht.map(kt=>de($n[kt]).then(Bt=>xt(Wn(Bt,be),be)).catch(()=>null))),gt=Xn?Xn.refToSrc.map(kt=>kt.toFixed(4)).join(","):"",st=kt=>{let Bt=`${Ce}@${kt}|${gt}`,It=Ye.get(Bt);return It||(It=(T??oe)(Ce,kt).then(zn=>{if(!zn)return null;if(!Xn)return xt(Wn(zn,be),be);let qn=zn.w/Xn.srcW,ur=zn.h/Xn.srcH,Lt=Xn.refToSrc;return xt(vi(zn,[Lt[0]*qn,Lt[1]*qn,Lt[2]*qn,Lt[3]*ur,Lt[4]*ur,Lt[5]*ur,Lt[6],Lt[7],Lt[8]],Xn.refW,Xn.refH,be),be)}).catch(()=>null),Ye.set(Bt,It)),It},Qe=He<=si?0:Math.max(0,Math.min(He-si,N-(si>>1))),$e=Math.min(He,Qe+si)-1-Ke,wt=[];for(let kt=Qe;kt<=$e;kt+=ll){L();let Bt=Array.from({length:Math.min(ll,$e-kt+1)},(zn,qn)=>kt+qn),It=await Promise.all(Bt.map(async zn=>{let qn=0,ur=0;for(let Lt=0;Lt<ht.length;Lt++){let tr=await st(zn+Us($n[ht[Lt]]-Fr,Pn));De[Lt]&&tr&&tr.length===De[Lt].length&&(qn+=Je(De[Lt],tr),ur++)}return ur?qn/ur:-1}));Bt.forEach((zn,qn)=>wt.push([zn,It[qn]]))}wt.sort((kt,Bt)=>Bt[1]-kt[1]);let nn=[];for(let[kt]of wt)if(nn.every(Bt=>Math.abs(Bt-kt)>=4)&&nn.push(kt),nn.length>=4)break;return Ht&&console.error(`[exact] swept ${wt.length} in-points of ${me?.label}: ${nn.map(kt=>`${kt}:${wt.find(Bt=>Bt[0]===kt)[1].toFixed(3)}`).join(" ")}`),nn},pn=async Ce=>{if(!Ce.clipLabel||Ce.kind==="gap"||Ce.kind==="composite"||Ce.srcStart==null)return;let Pn=q.find(ft=>ft.label===Ce.clipLabel);if(!Pn)return;let $n=Pn.clipIndex,Fr=$t(Pn),Xn=Ce.speed?Ce.speed.slope*Fr:Fr,N=Xn,me=Ce.refEnd-Ce.refStart+1;if(me<2||!(N>0))return;let He=Ce.srcStart,Ke=(ft,Xe)=>ft+Us(Xe-Ce.refStart,N),ht=ft=>ft>=0&&!(Pn.srcFrames&&ft>=Pn.srcFrames),De=Ce.track?.kind==="animated",gt=Math.min(De?8:16,me),st=Array.from({length:gt},(ft,Xe)=>Ce.refStart+Math.round((Xe+.5)*me/gt-.5)),Qe=async(ft,Xe,tt)=>{let _e=(await Promise.all(ft.map(async gn=>{let tn=Ke(Xe,gn);if(!ht(tn))return null;let[Ir,Dt]=await Promise.all([de(gn),Oe($n,tn)]);return Ir&&Dt?{ref:Ir,src:Dt}:null}))).filter(gn=>!!gn),Ft=_e.length>=3?await Ri(_e,tt).catch(()=>null):null,Ct=Ft?fo(Ft.transform):null;if(!Ft||!Ct)return null;let kn=Ft.transform,bn=kn[0]*kn[4]-kn[1]*kn[3]<0||Math.abs(Math.atan2(kn[3],kn[0])*180/Math.PI)>.5;return{warp:{refToSrc:Ct,refW:_e[0].ref.w,refH:_e[0].ref.h,srcW:_e[0].src.w,srcH:_e[0].src.h},turned:bn}},$e=De||Qc(Ce),wt=ft=>[ft-1,ft,ft+1].filter(Xe=>Xe>=Ce.refStart&&Xe<=Ce.refEnd).concat(ft===Ce.refStart?[ft+2]:ft===Ce.refEnd?[ft-2]:[]),nn=Ni(Ce.refStart,Ce.refEnd,6),kt={},Bt=async ft=>{if(De){let tt=await Promise.all(st.map(_e=>Qe(wt(_e),ft,kt)));return tt.some(_e=>!_e)?null:tt.map(_e=>_e.warp)}let Xe=await Qe(nn,ft,kt);return Xe?st.map(()=>Xe.warp):null};if($e){let ft=De?await Qe(wt(st[gt>>1]),He,{}):await Qe(nn,He,{});ft&&!ft.turned&&(kt=rh)}let It=await Promise.all(st.map(ft=>St(`r@${ft}`,()=>de(ft).then(Xe=>xt(Wn(Xe,640),640))))),zn=(ft,Xe)=>St(`c${$n}@${ft}|${Xe?Xe.refToSrc.map(tt=>tt.toFixed(4)).join(","):""}`,()=>Oe($n,ft).then(tt=>xt(Xe?vi(tt,Xe.refToSrc,Xe.refW,Xe.refH,640):Wn(tt,640),640))),qn=async(ft,Xe)=>{let tt=await Promise.all(ft.map((Ct,kn)=>zn(Ct,Xe[kn]))),_e=0,Ft=0;for(let Ct=0;Ct<gt;Ct++)It[Ct]&&tt[Ct]&&It[Ct].length===tt[Ct].length&&(_e+=Je(It[Ct],tt[Ct]),Ft++);return Ft>=Math.max(1,gt>>1)?_e/Ft:null},ur=!1,Lt=async ft=>{let Xe=[];for(let tt=-2;tt<=2;tt++){let _e=st.map(bn=>Ke(ft+tt,bn));if(!ht(_e[0])||!ht(_e[gt-1]))continue;let Ft=await qn(_e,st.map(()=>null)),Ct=$e?await Bt(ft+tt):null,kn=Ct?await qn(_e,Ct):null,fn=Math.max(Ft??-1/0,kn??-1/0);kn!=null&&(Ft==null||kn>Ft)&&(ur=!0),fn>-1/0&&Xe.push([ft+tt,fn])}return Xe},tr=await Lt(He),gr=tr.find(([ft])=>ft===He)?.[1];if(gr==null||tr.length<2){Ht&&console.error(`[exact] ${Ce.clipLabel} rec ${Ce.refStart}\u2013${Ce.refEnd}: nothing to compare`);return}let Gn=tr.reduce((ft,Xe)=>Xe[1]>ft[1]?Xe:ft);if(Ht&&console.error(`[exact] ${Ce.clipLabel} rec ${Ce.refStart}\u2013${Ce.refEnd}${ur?De?" (animated sizing)":" (sized)":""}: ${tr.map(([ft,Xe])=>`${ft-He>0?"+":""}${ft-He}:${Xe.toFixed(4)}`).join(" ")}`),Gn[1]<.9){let ft=await Ue($n,N,st,Ce.refStart,$e?(await Bt(Gn[0]))?.[gt>>1]??null:null,He);for(let Xe of ft.filter(tt=>Math.abs(tt-Gn[0])>2)){let tt=await Lt(Xe),_e=tt.length?tt.reduce((Ft,Ct)=>Ct[1]>Ft[1]?Ct:Ft):null;Ht&&console.error(`[exact] sweep peak ${Xe}: ${_e?`${_e[0]} ${_e[1].toFixed(4)}`:"\u2014"}`),_e&&_e[1]>Gn[1]+.02&&(Gn=_e)}}let hn=Xn;if(Math.abs(Fr-1)>.01){let ft=st[gt>>1],Xe=Gn[0]+Us(ft-Ce.refStart,Xn);for(let tt of[Fr,1]){if(Math.abs(tt-Xn)<1e-6)continue;N=tt;let _e=await Lt(Xe-Us(ft-Ce.refStart,tt)),Ft=_e.length?_e.reduce((Ct,kn)=>kn[1]>Ct[1]?kn:Ct):null;Ht&&console.error(`[exact] speed ${(tt/Fr*100).toFixed(0)} %: ${Ft?`${Ft[0]} ${Ft[1].toFixed(4)}`:"\u2014"} vs ${(Xn/Fr*100).toFixed(0)} % ${Gn[1].toFixed(4)}`),Ft&&Ft[1]>Gn[1]+.01&&(Gn=Ft,hn=tt)}N=hn}if((Gn[0]!==He||hn!==Xn)&&Gn[1]>gr+.002&&(Ht&&console.error(`[exact] \u2192 start ${He} \u2192 ${Gn[0]}${hn!==Xn?`, speed ${(Xn/Fr*100).toFixed(0)} \u2192 ${(hn/Fr*100).toFixed(0)} %`:""} (${gr.toFixed(4)} \u2192 ${Gn[1].toFixed(4)})`),Ce.srcStart=Gn[0],Ce.srcEnd=Math.round(Gn[0]+(Ce.refEnd-Ce.refStart)*hn),hn!==Xn)){let ft=hn/Fr*100;Math.abs(ft-100)<.5?delete Ce.speed:Ce.speed={slope:hn/Fr,percent:ft,kind:"retime",samples:gt,residual:0,basis:"frame-for-frame"}}},En=0;await Promise.all(Array.from({length:Cy},async()=>{for(;En<Ee.length;)L(),await pn(Ee[En++])}))}i?.(t.length,t.length,"attribution");{let Z=new Map,re=new Array(j.offs.length);for(let fe of Ee)if(!(!fe.clipLabel||fe.kind==="gap")){Z.set(fe.clipLabel,(Z.get(fe.clipLabel)??0)+(fe.refEnd-fe.refStart+1));for(let xe=fe.refStart;xe<=fe.refEnd;xe++)re[xe]=fe.clipLabel}for(let fe of q){for(let xe of fe.shots){let Y=xe.refStart+xe.refEnd>>1,le=re[Y];xe.contestedBy=le&&le!==fe.label?le:null}fe.coverage=fe.srcFrames?Math.min(1,(Z.get(fe.label)??0)/fe.srcFrames):0}}return i?.(t.length,t.length,"done"),{refFps:j.fps,refStartFrame:j.startFrame,refFrames:j.offs.length,refDropFrame:j.dropFrame,refW:j.w,refH:j.h,clips:q,timeline:Ee,shotVotes:lr,lumaCache:C.stats(),...ue.length?{hints:{timelineName:x?.timelineName??"",verdicts:ue,summary:Kz(ue),warnings:x?.warnings??[]}}:{},...qt?{triage:{scores:Ot.map(({clipIndex:Z,label:re,hits:fe,minDistance:xe,probes:Y})=>({clipIndex:Z,label:re,hits:fe,minDistance:xe,probes:Y})),examined:t.length-dt.length,skipped:dt.length}}:{}}}var Cs=1280;function UC(e){if(e.w<=Cs)return e;let t=mT(e.y,e.w,e.h,Cs),n=new DataView(t.buffer,t.byteOffset,t.byteLength),i=n.getUint32(0,!0),r=n.getUint32(4,!0);return{y:t.subarray(8,8+i*r),w:i,h:r}}async function ih(e,t="coarse"){let n=await wn(e),i=async(o,a,s)=>{let{offset:c,size:l}=n.frames[o]??{offset:0,size:0};return l>0?await Np(e,c,l,a,s):null},r=async o=>{let a=null;try{if(n.geometrySpec){let s=await i(o,n.geometrySpec,t);s&&(a={y:s.y instanceof Uint8Array?s.y:Uint8Array.from(s.y),w:s.w,h:s.h})}else if(n.spec?.codec==="prores"){let s=t==="index"?null:a7(),l=(s?await s(e,n,o).catch(()=>null):null)??await i(o,n.spec,t==="index"?"index":"exact");l&&(a={y:l.y,w:l.w,h:l.h})}else a=await s7(e,n,o)}catch{}return a?UC(a):null};return{src:n,frames:n.frames.length,luma:r}}var CC=Number(Rt("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(No()/2),Math.floor(Ro()/2**31))),Ky=0,p9=[],If=async(...e)=>{Ky>=CC?await new Promise(t=>p9.push(t)):Ky++;try{return await vf(...e)}finally{let t=p9.shift();t?t():Ky--}},ah=256;async function Wr(){let e=or()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[Rt("CONFORM_NATIVE_DECODE"),Pr(new URL(`./${e}`,import.meta.url)),Pr(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await Er(n))return n;return null}var Aa=class extends Error{constructor(n,i){super(i);this.why=n}};function sh(e,t){try{let n=JSON.parse(e.trim().split(`
9
- `).pop()??"");return new Aa(n.why,n.detail)}catch{return new Aa("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}async function Ks(e){let t=await Wr();if(!t)throw new Aa("missing","the native decoder (conformtools-decode) is not installed");let n=[],i=await If(t,["probe",e],r=>n.push(r));if(i.code!==0)throw sh(i.stderr,i.code);return JSON.parse(new TextDecoder().decode(Ef(n)))}function Ef(e){let t=e.reduce((r,o)=>r+o.length,0),n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.length;return n}var ul=new Map;function fl(e,t,n,i=ah){let r=`${e}\0${i}`,o=ul.get(r);return o||(o=JC(e,t,n,i),ul.set(r,o),o.catch(()=>ul.delete(r))),o}async function g9(e){let t=new Set(e);for(let n of t)Gy.delete(n);for(let[n,i]of[...ul.entries()])if(t.has(n.split("\0")[0])){ul.delete(n);try{await(await i).dispose()}catch{}}}async function JC(e,t,n,i=ah){let r=await Wr();if(!r)throw new Aa("missing","the native decoder (conformtools-decode) is not installed");let o=Q(vt(),"decode-cache");await bt(o);let a=Q(o,`${Date.now()}-${Math.random().toString(36).slice(2)}.luma`),s=await kp(a),c=null,l=new Uint8Array(0),u=0,f=new Set,d=[],m=await If(r,["luma",e,"--width",String(i)],h=>{if(l=l.length?Ef([l,h]):h,!c){let g=l.indexOf(10);if(g<0)return;c=JSON.parse(new TextDecoder().decode(l.subarray(0,g))),u=c.w*c.h,l=l.subarray(g+1)}let b=4+u,v=0;for(;l.length-v>=b;){let g=new DataView(l.buffer,l.byteOffset+v,4).getUint32(0,!0);d.push(s.writeAt(g*u,l.slice(v+4,v+b))),f.add(g),v+=b,f.size%48===0&&t?.(f.size,c.emitted)}l=l.subarray(v)},{signal:n});if(await Promise.all(d),await s.close(),m.code!==0||!c)throw await Vr(a),sh(m.stderr,m.code);let p=c;return t?.(f.size,p.emitted),{w:p.w,h:p.h,fps:p.fps,frames:p.frames,codec:p.codec,has:h=>f.has(h),async read(h){if(!f.has(h))return null;let b=await Za(a);try{return{y:await b.readAt(h*u,u),w:p.w,h:p.h}}finally{await b.close()}},async dispose(){ul.delete(`${e}\0${i}`),await un(a).catch(()=>null)&&await Vr(a)}}}async function Vf(e,t,n,i={}){let r=await Wr();if(!r)throw new Aa("missing","the native decoder (conformtools-decode) is not installed");let o=null,a=new Uint8Array(0),s=0,c=["bgra",e,"--width",String(i.width??32768)];i.from!=null&&c.push("--from",String(i.from)),i.count!=null&&c.push("--count",String(i.count));let l=await If(r,c,u=>{if(a=a.length?Ef([a,u]):u,!o){let m=a.indexOf(10);if(m<0)return;o=JSON.parse(new TextDecoder().decode(a.subarray(0,m))),s=o.w*o.h*4,t(o),a=a.subarray(m+1)}let f=4+s,d=0;for(;a.length-d>=f;){let m=new DataView(a.buffer,a.byteOffset+d,4).getUint32(0,!0);n(m,a.slice(d+4,d+f)),d+=f}a=a.subarray(d)},{signal:i.signal});if(l.code!==0||!o)throw sh(l.stderr,l.code)}var KC=Number(Rt("CONFORM_DECODE_CACHE_MB")??0)*2**20||Math.max(1.5*2**30,Math.min(4*2**30,Ro()/10)),Ga=[],oh=0;function GC(e,t){let n={bytes:e,drop:t};for(Ga.push(n),oh+=e;oh>KC&&Ga.length>1;){let i=Ga.shift();oh-=i.bytes,i.drop()}return n}function AC(e){let t=Ga.indexOf(e);t>=0&&Ga.push(...Ga.splice(t,1))}function BC(e){let t=Ga.indexOf(e);t>=0&&(Ga.splice(t,1),oh-=e.bytes)}var Js={runs:0,frames:0,unique:0},h9=new Map,YC=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS;function la(e,t=Cs,n=24){let i=[],r=null,o=-1,a=0,s=0,c=0,l;async function u(m,p,h){let b=await Wr();if(!b)throw new Aa("missing","the native decoder (conformtools-decode) is not installed");let v=new Map,g=null,y=new Uint8Array(0),w=0;Js.runs++,Js.frames+=p;let x=["luma",e,"--width",String(t),"--from",String(m),"--count",String(p)];h>1&&x.push("--stride",String(h));let O=await If(b,x,P=>{if(y=y.length?Ef([y,P]):P,!g){let S=y.indexOf(10);if(S<0)return;g=JSON.parse(new TextDecoder().decode(y.subarray(0,S))),w=g.w*g.h,y=y.subarray(S+1)}let T=0;for(;y.length-T>=4+w;){let S=new DataView(y.buffer,y.byteOffset+T,4).getUint32(0,!0);v.set(S,y.slice(T+4,T+4+w)),T+=4+w}y=y.subarray(T)});if(O.code!==0||!g)throw sh(O.stderr,O.code);if(YC){let P=`${e}@${t}`,T=h9.get(P);T||h9.set(P,T=new Set);for(let S of v.keys())T.has(S)||(T.add(S),Js.unique++)}return r={w:g.w,h:g.h},v}let f=(m,p)=>p>=m.from&&p<m.from+m.count&&(p-m.from)%m.stride===0;function d(m,p,h){let b={from:m,count:p,stride:h,frames:u(m,p,h)};return b.h=GC(Math.ceil(p/h)*t*Math.ceil(t*9/16),()=>{i=i.filter(v=>v!==b)}),b.frames.catch(()=>{i=i.filter(v=>v!==b),BC(b.h)}),i.push(b),b}return{async read(m){let p=m-o;s=p>1&&p<=16&&p===a?s+1:0,c=Math.abs(p)>n?c+1:0,a=p,o=m;let h=i.find(v=>f(v,m));if(h)AC(h.h);else if(s>=2)h=d(m,a*n*4,a);else if(c>=2)h=d(m,1,1);else{let v=await(l??=ch(e).catch(()=>null)),g=v&&v.length>1?QC(v,m):null;h=i.find(y=>f(y,m))??(g&&g.count>1&&g.count<=4*n?d(g.from,g.count,1):d(m-m%n,n,1))}if(h.stride>1&&s>=2){let v=h.from+h.count;i.some(g=>g.from===v&&g.stride===h.stride)||d(v,h.count,h.stride)}let b=(await h.frames).get(m);return b&&r?{y:b,w:r.w,h:r.h}:null}}}function QC(e,t){let n=0,i=e.length-1;if(t<e[0])return null;for(;n<i;){let r=n+i+1>>1;e[r]<=t?n=r:i=r-1}return n+1<e.length?{from:e[n],count:e[n+1]-e[n]}:null}var Gy=new Map;function v9(){return async(e,t,n)=>{let i=e.path;if(!i||!await Wr())return null;let r=Gy.get(i);return r||Gy.set(i,r=la(i)),r.read(n).catch(()=>null)}}var b9=new Map;function ch(e){let t=b9.get(e);return t||(t=(async()=>{let n=await Wr();if(!n)return null;let i=await Mn(n,["keyframes",e],{timeoutMs:6e4});if(!i.success)return null;try{let r=JSON.parse(i.stdout.trim().split(`
10
- `).pop()??"{}");return Array.isArray(r.keyframes)?r.keyframes:null}catch{return null}})(),b9.set(e,t)),t}function y9(e=16e3){return async t=>{let n=t.path,i=n?await Wr():null;if(!i||!n)return null;let r=[],o=null,a=new Uint8Array(0);return(await If(i,["audio",n,"--rate",String(e)],c=>{if(a=a.length?Ef([a,c]):c,!o){let d=a.indexOf(10);if(d<0)return;o=JSON.parse(new TextDecoder().decode(a.subarray(0,d))),a=a.subarray(d+1)}let l=a.length>>1;if(!l)return;let u=new DataView(a.buffer,a.byteOffset,l*2),f=new Float32Array(l);for(let d=0;d<l;d++)f[d]=u.getInt16(d*2,!0)/32768;r.push(f),a=a.subarray(l*2)})).code!==0||!o||!r.length?null:{sampleRate:e,channels:1,chunks:(async function*(){yield*r})()}}}var _C=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],lh=e=>(e>>4)*10+(e&15);function $C(e){let t=lh(e&63),n=lh(e>>>8&127),i=lh(e>>>16&127),r=lh(e>>>24&63),o=a=>String(a).padStart(2,"0");return`${o(r)}:${o(i)}:${o(n)}${e&64?";":":"}${o(t)}`}function eJ(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let n={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},i=8,r=()=>{let a=i;for(;i<e.length&&e[i]!==0;)i++;let s=new TextDecoder().decode(e.subarray(a,i));return i++,s},o=a=>({width:t.getInt32(a+8,!0)-t.getInt32(a,!0)+1,height:t.getInt32(a+12,!0)-t.getInt32(a+4,!0)+1});for(;i<e.length;){let a=r();if(!a)break;let s=r();if(i+4>e.length)return null;let c=t.getInt32(i,!0);if(i+=4,c<0||i+c>e.length)return null;if(n.attributes.push(`${a}:${s}`),a==="framesPerSecond"&&s==="rational"&&c>=8){let l=t.getInt32(i,!0),u=t.getUint32(i+4,!0);n.fps=u?l/u:null}else a==="timeCode"&&s==="timecode"&&c>=8?n.timecode=$C(t.getUint32(i,!0)):a==="dataWindow"&&s==="box2i"&&c>=16?{width:n.width,height:n.height}=o(i):a==="displayWindow"&&s==="box2i"&&c>=16?n.display=o(i):a==="compression"&&c>=1&&(n.compression=_C[e[i]]??`type ${e[i]}`);i+=c}return n}async function Ay(e){let t=e,n=null,i=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(te(e));if(await gi(e))n=/^(.*?)(\d+)(\.exr)$/i;else{t=Ln(e);let o=i?[null,i[1],i[2],i[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(te(e));if(!o)return{frames:[e],numbers:[]};let a=s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`^${a(o[1])}(\\d{${o[2].length}})${a(o[3])}$`,"i")}let r=[];for await(let o of dn(t)){let a=o.isFile?n.exec(o.name):null;a&&r.push({n:Number(a[a.length===4?2:1]),f:Q(t,o.name)})}return r.sort((o,a)=>o.n-a.n),{frames:r.map(o=>o.f),numbers:r.map(o=>o.n)}}async function w9(e){let t=await Ay(e),n=t.frames[0];if(!n)throw new Error(`no .exr frames for '${te(e)}'`);let i=await Za(n),r;try{r=eJ(await i.readAt(0,Math.min(i.size,1<<20)))}finally{await i.close()}if(!r)throw new Error(`'${te(n)}' is not an OpenEXR file`);let o=Math.max(1,t.frames.length),a=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,s=r.fps??0;return{id:te(n),kind:"external",target_url:n,local_path:n,content_kind:o>1?"video":"still",source_fps:r.fps??void 0,source_timecode:r.timecode??void 0,source_resolution_w:r.width,source_resolution_h:r.height,available_range:{start:{value:0,rate:s},duration:{value:o,rate:s}},streams:[{kind:"video",codec:"exr",width:r.width,height:r.height,rate:r.fps??void 0,codec_specific:{compression:r.compression}}],vendor_metadata:{exr:{frames:o,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:a,display_window:r.display,attributes:r.attributes,fps_source:r.fps!=null?"header framesPerSecond":"not in the header",timecode_source:r.timecode?"header timeCode (first frame)":"not in the header"}}}}var ua=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function tJ(e){let t=await Za(e);return{path:e,file:t,size:t.size}}function nJ(e){return(t,n)=>e.file.readAt(t,n)}async function Gs(e){let t=ai(te(e));if(!t)return[e];let n=Ln(e),i=[];for await(let r of dn(n)){if(!r.isFile)continue;let o=ai(r.name);o&&o.clipBase===t.clipBase&&i.push({n:o.partNumber,p:Q(n,r.name)})}return i.sort((r,o)=>r.n-o.n).map(r=>r.p)}async function By(e){if(await gi(e)){let o=[];for await(let a of dn(e))a.isFile&&ai(a.name)&&o.push(Q(e,a.name));if(!o.length)throw new Error(`'${te(e)}' is a folder with no .R3D parts`);e=o.sort()[0]}let t=FT(te(e));if(!t)throw new Error(`unsupported media file '${te(e)}' (supported: ${[...ua].join(" ")})`);let n=await Gs(e),i=await Promise.all(n.map(tJ));return{source:$c(t,i.map(o=>yp(te(o.path),{fileSize:o.size,read:nJ(o)}))),parts:i,format:t,anchor:n[0],close:()=>i.forEach(o=>o.file.close())}}async function dl(e,t,n){if(!/h264|avc|hevc|h265/.test(n)){let s=await By(e);try{return await lo(s.source,{verb:"decode",index:t,intent:"park"})}catch(c){if(!/no decoder/.test(String(c)))throw c}finally{s.close()}}let i=0,r=0,o=null;if(await Vf(e,s=>{i=s.w,r=s.h},(s,c)=>{s===t&&(o=c)},{from:t,count:1}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${te(e)}`);let a=o;for(let s=0;s<a.length;s+=4){let c=a[s];a[s]=a[s+2],a[s+2]=c}return{rgba:a,width:i,height:r}}async function Fn(e){if(/\.exr$/i.test(e))return w9(e);let t=await By(e);try{let n=await lo(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${te(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||te(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(i=>te(i.path))),n.size_bytes=t.parts.reduce((i,r)=>i+r.size,0),n}finally{t.close()}}function Yy(e,t,n,i){let r=Math.abs(i*1001-Math.round(i*1001/1e3)*1e3)<1?Math.round(i)*1e3/1001:i,o=Math.floor(e*r/t+1e-6);return{tc:Qt(o,i),frames:Math.round(n*r/t)}}var rJ=e=>String(Math.round(e*1e3)/1e3);function P9(e,t){let n=e.streams?.find(f=>f.kind==="video"),i=e.streams?.filter(f=>f.kind==="audio")??[],r=e.vendor_metadata?.bext;if(!n&&e.available_range&&i[0]?.rate){let f=i[0].rate,d=e.available_range.duration.value,p=(t?[t]:[24e3/1001,24]).map(h=>{let b=Yy(r?.time_reference??0,r?.sample_rate||f,d,h);return`${r?`start TC ${b.tc}, `:""}${b.frames} frames @ ${rJ(h)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/f).toFixed(3)} s)${r?`; BWF time_reference ${r.time_reference}`:"; no BWF timecode"}`,...p,...t?[]:["(pass fps for the project's rate)"],...i.map((h,b)=>`audio ${i.length>1?`${b+1}: `:""}${h.codec??"pcm"} ${h.channels??"?"}ch ${h.rate} Hz ${h.bit_depth??"?"}-bit`)].join(`
11
- `)}let o=e.available_range?.duration?.value??e.declared_duration?.value??null,a=e.source_fps??n?.rate??null,s=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=n?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,n?.bit_depth?`${n.bit_depth}-bit`:null,l.colr?`colour ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${a?` @ ${Math.round(a*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&a?` (${(o/a).toFixed(2)} s)`:""}`,i.length?i.map((f,d)=>{let m=f.codec_specific?.channel_layout;return`audio ${i.length>1?`${d+1}: `:""}${f.codec??"pcm"} ${f.channels??"?"}ch${m?` (${m})`:""} ${f.rate??"?"} Hz ${f.bit_depth??"?"}-bit`}).join(`
12
- `):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${s!=null?`${(s/1e6).toFixed(1)} MB`:""}${c?`; spanned ${c.length} parts`:""}`].join(`
13
- `)}var iJ=8*1024*1024,uh=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function oJ(e,t,n){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let i=new Map(t.parts.map(o=>[te(o.path),o]));await bt(Ln(n));let r=await kp(n);try{await r.truncate(e.total_size),await r.writeAt(0,uh(e.dest_header_bytes_base64));for(let o of e.src_byte_ranges){let a=o.src_file_name?i.get(te(o.src_file_name)):t.parts[0];if(!a)throw new Error(`plan references unknown source part '${o.src_file_name}'`);let s=0;for(;s<o.length;){let c=Math.min(iJ,o.length-s),l=await a.file.readAt(o.offset+s,c);if(l.length<c)throw new Error(`short read in ${te(a.path)} at ${o.offset+s}`);await r.writeAt(o.write_to_dest_offset+s,l),s+=c}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await r.writeAt(e.dest_footer_offset,uh(e.dest_footer_bytes_base64));for(let o of e.dest_patches??[])await r.writeAt(o.offset,uh(o.bytes_base64))}finally{await r.close()}for(let o of e.dest_sidecar_writes??[])await fr(Q(Ln(n),o.name),uh(o.bytes_base64))}function aJ(e,t){let n=[];for(let i of e){if(i.kind!=="clip"||!i.source_range)continue;let r=i.source_range.start.value,o=i.source_range.duration.value,a=Math.max(0,Math.floor(r)-t),s=Math.floor(r+o-1)+t;s>=a&&n.push({first_frame:a,last_frame:s})}return xT(n)}async function Qy(e,t,n,i,r){let o=await By(e);try{let a=aJ(t,n);if(!a.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let s=await lo(o.source,{verb:"trim",selection:{items:t,handles:n}}),c=ar(o.anchor),l=o.format==="r3d",u=l?ai(te(o.anchor))?.clipBase??te(o.anchor,c):te(o.anchor,c),f=[];for(let[d,m]of s.entries()){let p=m.output_clip_number??(a.length>1?d+1:void 0),h=a[(p??1)-1]??a[0],b=p&&(m.output_clip_count??a.length)>1?`_S${String(p).padStart(3,"0")}`:"",v;if(l){let g=m.output_part_number??d+1;v=Q(i,`${u}${b}.RDC`,`${u}_${String(g).padStart(3,"0")}.R3D`),f.push({path:v,bytes:m.total_size,island:h,part:g,clip:p})}else{let g=r&&s.length===1?r:`${u}${b||`_trim_${h.first_frame}-${h.last_frame}`}${c}`;v=Q(i,g),f.push({path:v,bytes:m.total_size,island:h,clip:p})}await oJ(m,o,v)}return{outputs:f,islands:a,format:o.format}}finally{o.close()}}async function fh(e){let t=await Fn(e.path),n=t.source_fps??t.streams?.find(f=>f.kind==="video")?.rate??null,i=t.available_range?.duration?.value??t.declared_duration?.value??null;if(!n)throw new Error("cannot trim: no frame rate / timecode track on this file");let r=Yr(e.in,n,t.source_timecode??null),o=Yr(e.out,n,t.source_timecode??null);if(e.out_exclusive&&(o-=1),o<r)throw new Error(`out (${o}) is before in (${r})`);if(r<0)throw new Error(`in (${r}) is before the file start (TC ${t.source_timecode})`);if(i!=null&&o>i-1)throw new Error(`out (${o}) is past the last frame (${i-1})`);let a={id:"trim",kind:"clip",source_range:{start:{value:r,rate:n},duration:{value:o-r+1,rate:n}}},s=Ln(e.path),c;if(e.out_path)try{(await un(e.out_path)).isDirectory?s=e.out_path:(s=Ln(e.out_path),c=te(e.out_path))}catch{s=Ln(e.out_path),c=te(e.out_path)}let l=await Qy(e.path,[a],Math.max(0,Math.floor(e.handles??0)),s,c),u=l.islands[0];return{outputs:l.outputs,first_frame:u.first_frame,last_frame:u.last_frame,frames:u.last_frame-u.first_frame+1,fps:n,facts:t}}function x9(e){let t=[...ua].map(n=>n.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function sJ(e,t){let n=x9(e),i=x9(t);if(i&&n.includes(i))return"name";let r=t.toLowerCase().split(/[^a-z0-9]+/).filter(o=>/\d/.test(o)&&o.length>=3);return r.length&&r.every(o=>n.includes(o))?"id":null}async function k9(e,t,n){let i=[],r=0,o=null,a=Date.now()+n.time_limit_s*1e3,s=async(c,l)=>{try{for await(let u of dn(c)){if(o&&!o.startsWith("folders"))return;if(++r>n.max_entries){o=`stopped after ${n.max_entries} entries (max_entries)`;return}if(Date.now()>a){o=`stopped after ${n.time_limit_s} s (time_limit_s)`;return}if(u.name.startsWith("."))continue;let f=Q(c,u.name);if(u.isDirectory)l<n.max_depth?await s(f,l+1):o??=`folders deeper than max_depth=${n.max_depth} not searched (e.g. ${f})`;else if(u.isFile&&ua.has(ar(u.name).toLowerCase())){let d=sJ(u.name,t);d&&i.push({path:f,match:d,size:(await un(f).catch(()=>({size:0}))).size})}}}catch{}};if(await s(e,0),n.probe)for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async l=>{try{l.facts=await Fn(l.path)}catch(u){l.error=u.message}}));return i.sort((c,l)=>c.path.localeCompare(l.path)),{hits:i,scanned:r,truncated:o}}function Wf(e){let t=e.streams?.find(s=>s.kind==="video"),n=e.source_fps??t?.rate??null,i=e.available_range?.duration?.value??e.declared_duration?.value??null,r=t?.codec_specific??{},o=e.source_timecode&&n?Cn(e.source_timecode,n):null,a=o!=null&&i!=null&&n?Qt((o+i)%(Math.round(n)*86400),n,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${r.profile?` ${r.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${n?` @ ${Math.round(n*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${a?`\u2013${a}`:""}; ${i??"?"} fr${i!=null&&n?` (${(i/n).toFixed(2)} s)`:""}`}function S9(e,t,n,i){let r=e.hits.slice(0,i),o=[];e.truncated&&o.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>r.length&&o.push(`TRUNCATED: showing ${r.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),o.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${n}" under ${t} (${e.scanned} entries scanned)`);let a=new Map;for(let c of e.hits)a.set(te(c.path).toLowerCase(),(a.get(te(c.path).toLowerCase())??0)+1);let s=[...a].filter(([,c])=>c>1);s.length&&o.push(`same name in several folders: ${s.map(([c,l])=>`${c} \xD7${l}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let c of r)o.push(`- ${c.path}${c.match==="id"?" (id match)":""}
14
- ${c.facts?Wf(c.facts):c.error?`probe failed: ${c.error}`:`${(c.size/1e6).toFixed(1)} MB`}`);return o.join(`
15
- `)}async function T9(e,t,n=0){let i=await Fn(e),r=i.source_fps??i.streams?.find(d=>d.kind==="video")?.rate??null,o=i.available_range?.duration?.value??i.declared_duration?.value??null;if(!r||o==null)throw new Error(`cannot check coverage: ${te(e)} has no frame rate or length`);let a=Math.round(r)*86400,s=i.source_timecode?Cn(i.source_timecode,r)??0:0,c=!!i.source_timecode?.includes(";"),l=d=>{let m=Yr(d,r,i.source_timecode??null);return typeof d=="number"||/^\d+$/.test(d.trim())?m:m<-a/2?m+a:m>a/2?m-a:m},u=d=>Qt(((s+d)%a+a)%a,r,c),f=t.map((d,m)=>{let p=l(d.in),h=l(d.out),b=p,v=o-h,g=b>=0&&v>=0&&h>p,y=Math.max(0,-b),w=Math.max(0,-v),x=[];return h<=p?x.push("out is not after in"):g?x.push(`covered; handles head ${b} / tail ${v} fr`):x.push(`NOT covered: short ${[y?`${y} fr at head`:"",w?`${w} fr at tail`:""].filter(Boolean).join(", ")}`),g&&n&&(b<n||v<n)&&x.push(`handles short of ${n}: ${[b<n?`head by ${n-b}`:"",v<n?`tail by ${n-v}`:""].filter(Boolean).join(", ")}`),{label:d.label??`range ${m+1}`,in_tc:u(p),out_tc:u(h),frames:h-p,covered:g,head:b,tail:v,short_head:y,short_tail:w,note:x.join("; ")}});return{facts:i,rows:f}}var z9={facility:"",templates:{}},cJ={TITLE:"[^_]+",NN:"\\d{2,3}",INITIALS:"[A-Z]{2,3}",COLORSPACE:"[A-Z0-9]+",GAMMA:"[A-Z0-9.]+",FORMAT:"\\d+x\\d+[pi]\\d+",YYYYMMDD:"\\d{8}",HHMM:"\\d{4}"},$y=()=>Q(vt(),"profile.json");async function Di(e){let t=z9;for(let n of[$y(),Q(vt(),"naming.json")])try{t={...z9,...JSON.parse(await yn(n))};break}catch{}return e?e1(t,e):t}function e1(e,t){let n=e.projects?.[t]??e.projects?.[t.toUpperCase()];return n?{...e,...n,templates:{...e.templates,...n.templates},values:{...e.values,...n.values},patterns:{...e.patterns,...n.patterns},codec_folders:{...e.codec_folders,...n.codec_folders},deliverables:n.deliverables??e.deliverables,conventions:{...e.conventions,...n.conventions}}:e}function M9(e,t,n){let i=/p(\d+)$/.exec(t.FORMAT??"")?.[1];if(!t.FORMAT||!i)throw new Te("invalid_args","deliverables needs FORMAT at the program's OAR, e.g. 3840x2160p23976");let r=[];for(let o of e.deliverables??[]){if(o.optional&&!n.include_optional)continue;let a=o.raster==="OAR"?t.FORMAT.replace(/p\d+$/,""):o.raster;for(let s of o.texts.length?o.texts:[""]){if(lJ.test(s)&&!n.textless)continue;let c=ml(e,"deliverable",{...dh(),...t,TEXT:s,CODEC:o.CODEC,AUDIOCONFIG:o.AUDIOCONFIG,FORMAT:`${a}p${i}`,HHMM:t.HHMM??""})+`.${o.ext}`;r.push({label:o.label,text:s,name:c,codec:o.CODEC,audio:o.AUDIOCONFIG,raster:a,container:o.raster!=="OAR"&&a!==t.FORMAT.replace(/p\d+$/,"")})}}return r}var lJ=/LESS|CLEAN|NOTEXT|NO-TEXT/i;async function t1(e,t={}){if(!e||typeof e.templates!="object")throw new Te("invalid_args","a profile needs templates: {kind: template}");for(let[n,i]of Object.entries(e.templates))if(!/\[[A-Z0-9]+\??\]/.test(i))throw new Te("invalid_args",`template ${n} has no [TOKEN] elements: ${i}`);return await bt(vt()),await rn($y(),JSON.stringify(t.stamp===!1?e:{...e,updated_at:new Date().toISOString()},null,2)),$y()}function As(e,t){let n=e.templates[t];if(!n&&!Object.keys(e.templates).length)throw new Te("invalid_args",`no artist profile yet, so no '${t}' naming: learn it from their delivered files (artist_profile action=learn path=<a delivery folder>) or ask the artist how they name a ${t}`);if(!n)throw new Te("invalid_args",`no '${t}' template in the ${e.facility||"artist"} profile (has: ${Object.keys(e.templates).join(", ")}): ask the artist, then artist_profile action=set`);return n}var L9=e=>e.split(/(\[[A-Z0-9]+\??\])/).filter(Boolean).map(t=>t.startsWith("[")?{tok:t.slice(1,-1).replace("?",""),opt:t.endsWith("?]")}:{lit:t}),_y=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function ml(e,t,n){let i=L9(As(e,t)),r="";return i.forEach((o,a)=>{if("lit"in o){r+=o.lit;return}let s=n[o.tok];if(s==null||s===""){if(!o.opt)throw new Te("invalid_args",`${t} name needs ${o.tok} (template ${As(e,t)})`);let c=i[a-1];c&&"lit"in c&&r.endsWith(c.lit.slice(-1))&&(r=r.slice(0,-1));return}r+=s}),r}function pl(e,t,n){let i=L9(As(e,t)),r=[],o="";i.forEach((c,l)=>{if("lit"in c){let d=i[l+1];o+=_y(d&&"tok"in d&&d.opt?c.lit.slice(0,-1):c.lit);return}let u=e.values?.[c.tok],f=e.patterns?.[c.tok]??(u?u.map(_y).join("|"):cJ[c.tok]??".+?");r.push(c.tok),o+=c.opt?`(?:${_y(i[l-1]?.lit?.slice(-1)??"")}(${f}))?`:`(${f})`});let a=new RegExp(`^${o}(?:\\.([A-Za-z0-9]{2,5}))?$`).exec(te(n));if(!a)return null;let s={};return r.forEach((c,l)=>{a[l+1]!=null&&(s[c]=a[l+1])}),{values:s,ext:a[r.length+1]??""}}var Hf=e=>String(e).padStart(2,"0"),dh=(e=new Date)=>({YYYYMMDD:`${e.getFullYear()}${Hf(e.getMonth()+1)}${Hf(e.getDate())}`,HHMM:`${Hf(e.getHours())}${Hf(e.getMinutes())}`});function uJ(e){let t=Number(/^(\d+)x/.exec(e.FORMAT??"")?.[1]??0);return{JOBCODEC:/^PR/i.test(e.CODEC??"")?"pr":(e.CODEC??"").split("_")[0].toLowerCase(),JOBTEXT:e.TEXT==="TEXTLESS"?"txtls":"txtd",JOBRASTER:t>=3840?"uhd":t>=1920?"hd":"sd"}}function n1(e,t,n){let i=e.conventions?.no_audio_tag;if(n.picture_only!==!1&&/\[AUDIOCONFIG/.test(As(e,"patch"))&&!i)throw new Te("invalid_args","how does this artist mark a picture-only file in AUDIOCONFIG (NOAUDIO, MOS\u2026)? ask, then artist_profile action=remember conventions={no_audio_tag: '\u2026'}");let r=pl(e,"deliverable",t);if(!r)throw new Te("invalid_args",`'${te(t)}' does not follow the ${e.facility} deliverable template ${As(e,"deliverable")}; name the patch from a real deliverable`);let o={...r.values,...dh(n.when),NN:Hf(n.nn),...n.text?{TEXT:n.text}:{},...n.picture_only!==!1&&i?{AUDIOCONFIG:i}:{},...Object.fromEntries((e.deprecated??[]).map(d=>[d,""]))},a=ml(e,"patch",o)+(r.ext?`.${r.ext}`:""),s=[],c=e.templates.render_job?ml(e,"render_job",{...o,...uJ(o)}):"";c||s.push(`no 'render_job' template in the ${e.facility||"artist"} profile: name the render job yourself, or ask the artist and artist_profile action=set`);let l=Object.entries(e.codec_folders??{}).find(([d])=>(o.CODEC??"").toUpperCase().startsWith(d))?.[1]??"",u=e.templates.patches_folder?"patches_folder":e.templates.deliverables_folder?"deliverables_folder":"",f=u?ml(e,u,{...o,CODECFOLDER:l}):"";return{file:a,job:c,folder:f,master_values:r.values,warnings:s}}var O9={ap4h:"PR4444",ap4x:"PR4444XQ",apch:"PRHQ",apcn:"PR422",apcs:"PRLT",apco:"PRPROXY"},fJ={bt709:"REC709",bt2020:"REC2020",smpte432:"P3D65",smpte431:"P3DCI"},dJ={smpte2084:"PQ","arib-std-b67":"HLG"},mJ=e=>String(Math.round(e*1e3)/1e3).replace(".","");function r1(e){let t=e.streams?.find(o=>o.kind==="video"),n=t?.codec_specific??{},i=e.source_fps??t?.rate??0,r=e.streams?.filter(o=>o.kind==="audio")??[];return{CODEC:n.fourcc&&O9[n.fourcc]?O9[n.fourcc]:/h264|avc/i.test(t?.codec??"")?"H264":null,FORMAT:t?.width&&t.height&&i?`${t.width}x${t.height}p${mJ(i)}`:null,COLORSPACE:n.colr?fJ[n.colr.primaries]??null:null,GAMMA:n.colr?dJ[n.colr.transfer]??null:null,AUDIOCH:r.length?String(r.reduce((o,a)=>o+(a.channels??0),0)):"0"}}function hl(e,t,n={}){let i=n.kind??(/[_-]PATCH\d/i.test(t)&&e.templates.patch?"patch":"deliverable"),r=pl(e,i,t),o=[];if(!r){let s=/\]_\[/.test(As(e,i))&&/[A-Z0-9]-[A-Z]/.test(t.replace(/\d-\d/g,""))?" ('-' used as a separator: this profile separates every element with '_')":"";return o.push({element:"template",level:"error",message:`does not follow the ${e.facility} ${i} template ${As(e,i)}${s}`}),{kind:i,values:null,issues:o}}let a=r.values;for(let s of e.deprecated??[])a[s]&&o.push({element:s,level:"warn",message:`${s} ${a[s]}: in older names, left out of new ones (unless asked)`});if(n.probe){let s=r1(n.probe);for(let u of["CODEC","FORMAT","COLORSPACE","GAMMA"]){if(a[u]==null)continue;if(s[u]==null){u==="GAMMA"&&/^(PQ|HLG)$/.test(a[u])&&o.push({element:u,level:"error",message:`name says ${a[u]}, the file's transfer tag is not ${a[u]}`});continue}(u==="CODEC"?a[u]===s[u]||s[u]==="H264"&&a[u].startsWith("H264"):a[u]===s[u])||o.push({element:u,level:"error",message:`name says ${a[u]}, the file is ${s[u]}`})}let c=/^H26[45]_(\d+)mbps$/i.exec(a.CODEC??"")?.[1],l=n.probe.available_range?n.probe.available_range.duration.value/(n.probe.available_range.duration.rate||1):0;if(c&&n.probe.size_bytes&&l>1){let u=n.probe.size_bytes*8/l/1e6;(u<Number(c)*.6||u>Number(c)*1.3)&&o.push({element:"CODEC",level:"error",message:`name says ${c} Mbps, the file averages ${u.toFixed(1)} Mbps`})}if(a.AUDIOCONFIG){let u=/^(\d+)CH/.exec(a.AUDIOCONFIG)?.[1],f=e.conventions?.no_audio_tag??"NOAUDIO";a.AUDIOCONFIG===f&&s.AUDIOCH!=="0"&&o.push({element:"AUDIOCONFIG",level:"error",message:`name says ${f}, the file has ${s.AUDIOCH} audio channels`}),u&&u!==s.AUDIOCH&&o.push({element:"AUDIOCONFIG",level:"error",message:`name says ${u}CH, the file has ${s.AUDIOCH} audio channels`})}}if(n.master){let s=pl(e,"deliverable",n.master)?.values;if(!s)o.push({element:"master",level:"error",message:`master '${te(n.master)}' does not follow the deliverable template`});else for(let[c,l]of Object.entries(s))/^(YYYYMMDD|HHMM|TEXT)$/.test(c)||c==="AUDIOCONFIG"&&a[c]===(e.conventions?.no_audio_tag??"NOAUDIO")||a[c]!==l&&o.push({element:c,level:"error",message:`${a[c]??"(missing)"} \u2260 the master's ${l}`})}return{kind:i,values:a,issues:o}}var pJ=/\.(mov|mp4|mxf|m4v|wav|aif|aiff)$/i,hJ=/^(REC709|REC2020|REC2100|P3D65|P3DCI|P3D60|DCIP3|ACES|ACESCG|SRGB|XYZ)$/i,bJ=/^(G\d(\.\d)?|G\d\d|PQ|HLG|ST2084|LOGC\d?|SLOG3|LINEAR|SRGB)$/i,gJ=/^(TEXTED|TEXTLESS|TXTD|TXTLS|TXTLESS|CLEAN|TEXT|NOTEXT|NO-TEXT|SUBBED|SUBTITLED)$/i,vJ=/^(\d+CH|NOAUDIO|MOS|STEREO|5-1|51|LTRT|LORO)$/i,yJ=e=>/^(19|20)\d\d(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/.test(e);function wJ(e){let t=n=>e.split(n).length-1;return["_","-"," ","."].reduce((n,i)=>t(i)>t(n)?i:n,"_")}function xJ(e,t,n={}){let i=e.split(t),r=[],o=(s,c)=>yJ(s)?"YYYYMMDD":/^([01]\d|2[0-3])[0-5]\d$/.test(s)&&c?.tok==="YYYYMMDD"?"HHMM":/^PATCH\d{1,3}$/i.test(s)?"PATCH":/^v\d{1,3}$/i.test(s)?"VERSION":n.FORMAT&&s===n.FORMAT||/^\d{3,5}x\d{3,5}[pi]\d{2,5}$/.test(s)?"FORMAT":n.CODEC&&(s===n.CODEC||n.CODEC==="H264"&&/^(H\.?264|AVC)/i.test(s))||/^(PR(4444(XQ)?|HQ|422|LT|PROXY)|H\.?26[45]|HEVC|DNX\w+|XAVC\w*|J2K|JPEG2000)$/i.test(s)?"CODEC":hJ.test(s)||n.COLORSPACE&&s===n.COLORSPACE?"COLORSPACE":bJ.test(s)||n.GAMMA&&s===n.GAMMA?"GAMMA":gJ.test(s)?"TEXT":vJ.test(s)?"AUDIOCONFIG":null;for(let s=0;s<i.length;s++){let c=i[s],l=o(c,r[r.length-1]);if(l==="CODEC"&&/^\d+mbps$/i.test(i[s+1]??"")){r.push({tok:l,raw:c+t+i[++s]});continue}if(l==="AUDIOCONFIG"){let u=c;for(;s+1<i.length&&!["YYYYMMDD","FORMAT","CODEC","COLORSPACE","GAMMA","TEXT","VERSION","PATCH"].includes(o(i[s+1])??"")&&!/^\d+$/.test(i[s+1]);)u+=t+i[++s];r.push({tok:l,raw:u});continue}r.push({tok:l??"?",raw:c})}let a=0;for(;a<r.length&&r[a].tok==="?";)a++;return a&&r.splice(0,a,{tok:"TITLE",raw:r.slice(0,a).map(s=>s.raw).join(t)}),r}function PJ(e,t){let n=[],i=0;for(let r of e){for(;i<t.length&&t[i]!==r.tok;)i++;if(i===t.length)return null;n.push(i++)}return n}function kJ(e,t){let n=Array.from({length:e.length+1},()=>new Array(t.length+1).fill(0));for(let a=e.length-1;a>=0;a--)for(let s=t.length-1;s>=0;s--)n[a][s]=e[a]===t[s]?n[a+1][s+1]+1:Math.max(n[a+1][s],n[a][s+1]);let i=[],r=0,o=0;for(;r<e.length&&o<t.length;)e[r]===t[o]?(i.push(e[r]),r++,o++):n[r+1][o]>=n[r][o+1]?i.push(e[r++]):i.push(t[o++]);return[n[0][0],[...i,...e.slice(r),...t.slice(o)]]}function SJ(e,t){if(!e.length)throw new Te("invalid_args","no names to learn from");let n=new Map;for(let f of e)n.set(f.toks.map(d=>d.tok).join(" "),(n.get(f.toks.map(d=>d.tok).join(" "))??0)+1);let i=[];for(let[f]of[...n].sort((d,m)=>m[1]-d[1])){let d=f.split(" ");if(!i.length){i=d;continue}let[m,p]=kJ(i,d);m*2>=d.length&&(i=p)}let r=i.map(()=>[]),o=[];for(let f of e){let d=PJ(f.toks,i);if(!d){o.push(f.file);continue}d.forEach((m,p)=>r[m].push(f.toks[p].raw))}let a=e.length-o.length,s={},c={},l=0;return{template:i.map((f,d)=>{let m=[...new Set(r[d])],p=r[d].length<a?"?":"";if(f==="?"){if(m.length===1&&!p)return m[0];let h=`FIELD${++l}`;return c[h]=m,`[${h}${p}]`}return f==="PATCH"?"PATCH[NN]":(f==="TEXT"&&(c.TEXT=m),f==="TITLE"&&(t!=="_"||m.some(h=>h.includes(t)))&&(s.TITLE=".+?"),`[${f}${p}]`)}).join(t),patterns:s,values:c,fitted:a,misfits:o}}async function*R9(e,t=3){for await(let n of dn(e)){if(n.name.startsWith("."))continue;let i=Q(e,n.name);n.isDirectory&&t>0?yield*R9(i,t-1):n.isFile&&pJ.test(n.name)&&(yield i)}}async function N9(e,t={}){let n=e.replace(/\/+$/,""),i=[];if(await gi(n))for await(let k of R9(n))i.push(k);else i.push(n);if(!i.length)throw new Te("not_found",`no media files under ${te(n)}`);i.length>200&&(i.length=200);let r=await Promise.all(i.map(async k=>{let L=await Fn(k).catch(()=>null);return{file:k,m:L,e:L?r1(L):{}}})),o=k=>te(k,ar(k)),a=wJ(o(i[0])),s=r.map(k=>({...k,toks:xJ(o(k.file),a,k.e)})),c=k=>k.toks.some(L=>L.tok==="PATCH"),l={templates:{},patterns:{},values:{}},u=[];for(let[k,L]of[["deliverable",s.filter(z=>!c(z))],["patch",s.filter(c)]]){if(!L.length)continue;let z=SJ(L.map(X=>({file:te(X.file),toks:X.toks})),a);l.templates[k]=z.template,Object.assign(l.patterns,z.patterns);for(let[X,V]of Object.entries(z.values))l.values[X]=[...new Set([...l.values[X]??[],...V])];u.push(...z.misfits)}let f={facility:"",...l},d=s.filter(k=>!c(k)).map(k=>({x:k,v:pl(f,"deliverable",k.file)?.values})).filter(k=>k.v),m=k=>(k.m?.size_bytes??0)/Math.max(1,k.m?.available_range?k.m.available_range.duration.value/(k.m.available_range.duration.rate||1):1),p=k=>/^(\d+x\d+)/.exec(k.FORMAT??"")?.[1]??"",h=[...d].sort((k,L)=>m(L.x)-m(k.x))[0],b=h?p(h.v):"",v=new Map;for(let{x:k,v:L}of d){let z=p(L),X=ar(k.file).slice(1).toLowerCase(),V=[L.CODEC,L.AUDIOCONFIG,X,z===b?"OAR":z].join("|"),R=v.get(V)??{label:`${L.CODEC??X} ${z===b?"at the OAR":z}`,CODEC:L.CODEC??"",AUDIOCONFIG:L.AUDIOCONFIG??"",ext:X,raster:z===b||!z?"OAR":z,texts:[]};L.TEXT&&!R.texts.includes(L.TEXT)&&R.texts.push(L.TEXT),v.set(V,R)}for(let k of v.values())k.texts.sort();if(v.size&&(l.deliverables=[...v.values()]),await gi(n)){let k=/(19|20)\d{6}/,L={},z=k.test(te(n))?n:null;for(let{x:X,v:V}of d){let R=CT(n,Ln(X.file)).split("/").filter(Boolean),j=R.findIndex(F=>k.test(F));j>=0&&!z&&(z=`${n}/${R.slice(0,j+1).join("/")}`);let J=R[R.length-1],q=V.CODEC?.split(a)[0]??"",W=q.replace(/\d+$/,"");J&&!k.test(J)&&q&&(L[W.length>=2?W:q]=J)}if(Object.keys(L).length&&(l.codec_folders=L),z){let X=te(z).replace(k,"[YYYYMMDD]").replace(/(\[YYYYMMDD\]\D?)([01]\d|2[0-3])[0-5]\d/,"$1[HHMM]");l.templates.deliverables_folder=`${te(Ln(z))}/${X}${Object.keys(L).length?"/[CODECFOLDER]":""}`}}let g=new Set(s.filter(k=>c(k)&&k.m&&!k.m.streams?.some(L=>L.kind==="audio")).map(k=>pl({facility:"",...l},"patch",k.file)?.values.AUDIOCONFIG).filter(Boolean));g.size===1&&(l.conventions={no_audio_tag:[...g][0]});let y=t.today??new Date().toISOString().slice(0,10),w=`learned from ${i.length} file(s) in ${te(n)} (${y})`;l.provenance=Object.fromEntries([...Object.keys(l.templates).map(k=>[`templates.${k}`,w]),...l.deliverables?[["deliverables",w]]:[],...l.codec_folders?[["codec_folders",w]]:[]]);let x=await Di(),O=TJ(x,l,t.project,t.facility),P=t.project?e1(O,t.project):O,T=r.flatMap(k=>{let z=hl(P,te(k.file),{probe:k.m??void 0}).issues.filter(X=>X.level==="error").map(X=>`${X.element}: ${X.message}`);return z.length?[{file:te(k.file),issues:z}]:[]}),S={profile:O,learned:l,files:i.length,misfits:u,name_issues:T,source:w};return t.save!==!1&&(S.saved=await bl(O)),S}function TJ(e,t,n,i){let r=a=>({...a,templates:{...a.templates,...t.templates},patterns:{...a.patterns,...t.patterns},values:{...a.values,...t.values},codec_folders:{...a.codec_folders,...t.codec_folders},deliverables:t.deliverables??a.deliverables,...t.conventions?{conventions:{...a.conventions,...t.conventions}}:{}}),o={...e.provenance,...Object.fromEntries(Object.entries(t.provenance??{}).map(([a,s])=>[n?`projects.${n}.${a}`:a,s]))};return n?{...e,facility:i??e.facility,provenance:o,projects:{...e.projects,[n]:r(e.projects?.[n]??{})}}:{...r(e),facility:i??e.facility,provenance:o}}function X9(e,t){let n=t.at??new Date().toISOString().slice(0,10);return{...e,rules:[...(e.rules??[]).filter(i=>i.rule!==t.rule),{...t,at:n}]}}function j9(e,t){let n=e.rules??[],i=typeof t=="number"?t-1:n.findIndex(r=>r.rule.toLowerCase().includes(t.toLowerCase()));if(i<0||i>=n.length)throw new Te("not_found",`no rule matching ${t}`);return{...e,rules:n.filter((r,o)=>o!==i)}}function F9(e,t,n){let i=new Date().toISOString().slice(0,10);return{...e,conventions:{...e.conventions,...t},provenance:{...e.provenance,...Object.fromEntries(Object.keys(t).map(r=>[`conventions.${r}`,`${n} (${i})`]))}}}var o1=e=>!Object.keys(e.templates).length&&!e.rules?.length&&!Object.keys(e.conventions??{}).length;function Zf(e){if(o1(e))return"No artist profile yet. Learn it: artist_profile action=learn path=<a folder of their delivered files>; ask what the files cannot show (usual deliverable set, program start TC, how they route audio).";let t=i=>e.provenance?.[i]??e.provenance?.["*"],n=[`Artist profile${e.facility?`: ${e.facility}`:""}`];for(let[i,r]of Object.entries(e.templates))n.push(` ${i}: ${r}${t(`templates.${i}`)?` [${t(`templates.${i}`)}]`:""}`);if(e.deliverables?.length){n.push(` usual deliverables${t("deliverables")?` [${t("deliverables")}]`:""}:`);for(let i of e.deliverables)n.push(` ${i.label}: ${i.CODEC} ${i.AUDIOCONFIG} .${i.ext} ${i.raster}${i.texts.length?` (${i.texts.join(", ")})`:""}${i.optional?" \u2014 on request":""}`)}for(let[i,r]of Object.entries(e.conventions??{}))n.push(` ${i}: ${r}${t(`conventions.${i}`)?` [${t(`conventions.${i}`)}]`:""}`);return(e.rules??[]).forEach((i,r)=>n.push(` rule ${r+1}${i.topic?` (${i.topic})`:""}: ${i.rule} [${i.source}, ${i.at}]`)),e.projects&&n.push(` projects: ${Object.keys(e.projects).join(", ")}`),n.join(`
16
- `)}async function ome(){await MJ();let e=await Di().catch(()=>null);return!e||o1(e)?"Artist profile: none yet. Conventions that are the artist's choice (naming, usual deliverables, start TC, bins, routing) are not assumed: learn them (artist_profile action=learn) or ask, and save the answer (artist_profile action=remember).":`Artist profile: ${e.facility||"this artist"} (${Object.keys(e.templates).length} naming templates, ${e.deliverables?.length??0} deliverable kinds, ${e.rules?.length??0} workflow rules). Read it (artist_profile) before naming, rendering or delivering, and follow it. When the artist corrects you, ask whether it is their preference (artist_profile action=remember) or a rule for everyone (report_issue).`}var zJ=()=>`${Un().supabaseUrl}/functions/v1/v1-me/v1/engine/artist-profile`;async function i1(e,t){let n=await uo().catch(()=>null);if(!n)return null;let i=await fetch(zJ(),{method:e,signal:AbortSignal.timeout(5e3),headers:{authorization:`Bearer ${n}`,apikey:Un().anonKey,...t?{"content-type":"application/json"}:{}},...t?{body:JSON.stringify(t)}:{}});return i.ok?await i.json():null}async function bl(e){let t=await t1(e);return await i1("PATCH",{profile:await Di()}).catch(()=>null),t}function OJ(e,t){let n=e.updated_at??"",i=t?.updated_at??"";return t&&i>n?"pull":!o1(e)&&n>i?"push":"same"}async function MJ(){try{let e=await i1("GET");if(!e)return"offline";let t=await Di(),n=e.profile??null,i=OJ(t,n);return i==="pull"&&await t1(n,{stamp:!1}),i==="push"&&await i1("PATCH",{profile:t}),i==="pull"?"pulled":i==="push"?"pushed":"same"}catch{return"offline"}}var mo="0.6.3";function LJ(e,t){let n=e.split("-")[0].split(".").map(Number),i=t.split("-")[0].split(".").map(Number);for(let r=0;r<Math.max(n.length,i.length);r++){let o=(n[r]||0)-(i[r]||0);if(o)return o>0}return!1}var RJ=null;function a1(){return Rt("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):RJ??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(e=>e.ok?e.json():null).then(e=>typeof e?.version=="string"?e.version:null).catch(()=>null)}var NJ="run npx -y conformtools@latest mcp (in the MCP client config too); if an old global install is shadowing it: npm rm -g conformtools";async function I9(){let e=await a1();return`conformtools ${mo}`+(e&&LJ(e,mo)?` \u2014 update available: ${e} \u2192 ${NJ}`:"")}var M={};ra(M,{$brand:()=>w1,$input:()=>Jx,$output:()=>Cx,INVALID:()=>xi,NEVER:()=>y1,TimePrecision:()=>n3,ZodAny:()=>UP,ZodArray:()=>GP,ZodBase64:()=>l0,ZodBase64URL:()=>u0,ZodBigInt:()=>$l,ZodBigIntFormat:()=>m0,ZodBoolean:()=>_l,ZodCIDRv4:()=>s0,ZodCIDRv6:()=>c0,ZodCUID:()=>e0,ZodCUID2:()=>t0,ZodCatch:()=>pk,ZodCodec:()=>Fd,ZodCompileAsyncError:()=>ho,ZodCompileUnsupportedError:()=>cn,ZodCreditCard:()=>IP,ZodCustom:()=>Id,ZodCustomStringFormat:()=>dc,ZodDate:()=>Md,ZodDefault:()=>ck,ZodDiscriminatedUnion:()=>BP,ZodE164:()=>f0,ZodEmail:()=>Yb,ZodEmoji:()=>_b,ZodEnum:()=>Bl,ZodError:()=>GB,ZodExactOptional:()=>g0,ZodFile:()=>ik,ZodFirstPartyTypeKind:()=>Mk,ZodFunction:()=>Sk,ZodGUID:()=>Qb,ZodIBAN:()=>EP,ZodIPv4:()=>o0,ZodIPv6:()=>a0,ZodISODate:()=>is,ZodISODateTime:()=>rs,ZodISODuration:()=>as,ZodISOTime:()=>os,ZodInstanceOf:()=>Ok,ZodIntersection:()=>YP,ZodIssueCode:()=>YB,ZodJWT:()=>d0,ZodKSUID:()=>i0,ZodLazy:()=>xk,ZodLiteral:()=>rk,ZodMAC:()=>FP,ZodMap:()=>tk,ZodNaN:()=>bk,ZodNanoID:()=>$b,ZodNever:()=>JP,ZodNonOptional:()=>v0,ZodNull:()=>DP,ZodNullable:()=>sk,ZodNumber:()=>Ql,ZodNumberFormat:()=>mc,ZodObject:()=>Rd,ZodOptional:()=>Xd,ZodPipe:()=>jd,ZodPrefault:()=>uk,ZodPreprocess:()=>gk,ZodPromise:()=>kk,ZodReadonly:()=>vk,ZodRealError:()=>Ei,ZodRecord:()=>Al,ZodSet:()=>nk,ZodString:()=>Yl,ZodStringFormat:()=>Jn,ZodSuccess:()=>mk,ZodSymbol:()=>HP,ZodTemplateLiteral:()=>wk,ZodTransform:()=>ok,ZodTuple:()=>_P,ZodType:()=>Gt,ZodULID:()=>n0,ZodURL:()=>Od,ZodUUID:()=>Ho,ZodUndefined:()=>ZP,ZodUnion:()=>Nd,ZodUnknown:()=>CP,ZodVoid:()=>KP,ZodXID:()=>r0,ZodXor:()=>AP,_ZodString:()=>Bb,_default:()=>lk,_function:()=>hL,any:()=>KM,array:()=>Ld,base64:()=>zM,base64url:()=>OM,bigint:()=>DM,boolean:()=>WP,catch:()=>hk,check:()=>bL,cidrv4:()=>SM,cidrv6:()=>TM,clone:()=>Hn,codec:()=>fL,coerce:()=>Rk,compile:()=>Bx,config:()=>kr,core:()=>ha,creditCard:()=>LM,cuid:()=>bM,cuid2:()=>gM,currencyCode:()=>IM,custom:()=>gL,date:()=>AM,decode:()=>OP,decodeAsync:()=>LP,deepPartial:()=>RL,describe:()=>vL,discriminatedUnion:()=>eL,e164:()=>MM,email:()=>aM,emoji:()=>pM,encode:()=>zP,encodeAsync:()=>MP,endsWith:()=>Vl,enum:()=>h0,exactOptional:()=>ak,file:()=>sL,flattenError:()=>Yf,float32:()=>VM,float64:()=>WM,formatError:()=>Qf,fromJSONSchema:()=>ML,function:()=>hL,getDiscriminatedOption:()=>vx,getErrorMap:()=>_B,globalRegistry:()=>$r,gt:()=>Vo,gte:()=>Ui,guid:()=>sM,hash:()=>EM,hex:()=>FM,hostname:()=>jM,httpUrl:()=>mM,iban:()=>RM,includes:()=>Il,input:()=>XL,instanceof:()=>wL,int:()=>Gb,int32:()=>HM,int64:()=>qM,intersection:()=>QP,invertCodec:()=>dL,ipv4:()=>xM,ipv6:()=>kM,iso:()=>Ed,json:()=>PL,jwt:()=>NM,keyof:()=>BM,ksuid:()=>wM,lazy:()=>Pk,length:()=>sc,literal:()=>aL,locales:()=>gd,looseObject:()=>_M,looseRecord:()=>nL,lowercase:()=>jl,lt:()=>Eo,lte:()=>qi,mac:()=>PM,map:()=>rL,maxLength:()=>ac,maxSize:()=>$a,memoizer:()=>hd,meta:()=>yL,mime:()=>Hl,minLength:()=>pa,minSize:()=>Wo,multipleOf:()=>_a,nan:()=>uL,nanoid:()=>hM,nativeEnum:()=>oL,negative:()=>Eb,never:()=>p0,nonnegative:()=>Wb,nonoptional:()=>dk,nonpositive:()=>Vb,normalize:()=>Zl,null:()=>qP,nullable:()=>zd,nullish:()=>cL,number:()=>VP,object:()=>YM,optional:()=>uc,output:()=>jL,overwrite:()=>bo,parse:()=>PP,parseAsync:()=>kP,partialRecord:()=>tL,pipe:()=>Ab,positive:()=>Ib,prefault:()=>fk,preprocess:()=>kL,prettifyError:()=>T1,promise:()=>pL,properties:()=>Wl,property:()=>Hb,readonly:()=>yk,record:()=>ek,refine:()=>Tk,regex:()=>Xl,regexes:()=>$i,registry:()=>ub,safeDecode:()=>NP,safeDecodeAsync:()=>jP,safeEncode:()=>RP,safeEncodeAsync:()=>XP,safeParse:()=>SP,safeParseAsync:()=>TP,set:()=>iL,setErrorMap:()=>QB,size:()=>oc,slugify:()=>Cl,startsWith:()=>El,strictObject:()=>QM,string:()=>Td,stringFormat:()=>XM,stringbool:()=>xL,success:()=>lL,superRefine:()=>zk,symbol:()=>CM,templateLiteral:()=>mL,toJSONSchema:()=>Ub,toLowerCase:()=>ql,toUpperCase:()=>Ul,toZod:()=>Df,transform:()=>b0,treeifyError:()=>S1,trim:()=>Dl,tuple:()=>$P,uint32:()=>ZM,uint64:()=>UM,ulid:()=>vM,undefined:()=>JM,union:()=>eu,unknown:()=>lc,uppercase:()=>Fl,url:()=>dM,util:()=>ve,uuid:()=>cM,uuidv4:()=>lM,uuidv6:()=>uM,uuidv7:()=>fM,validate:()=>_f,validateAsync:()=>$f,void:()=>GM,withParser:()=>fb,xid:()=>yM,xor:()=>$M});var ha={};ra(ha,{$ZodAny:()=>ux,$ZodArray:()=>hx,$ZodAsyncError:()=>Fi,$ZodBase64:()=>_w,$ZodBase64URL:()=>$w,$ZodBigInt:()=>Yh,$ZodBigIntFormat:()=>ax,$ZodBoolean:()=>ld,$ZodCIDRv4:()=>Yw,$ZodCIDRv6:()=>Qw,$ZodCUID:()=>Ww,$ZodCUID2:()=>Hw,$ZodCatch:()=>Fx,$ZodCheck:()=>_n,$ZodCheckBigIntFormat:()=>fw,$ZodCheckEndsWith:()=>kw,$ZodCheckGreaterThan:()=>Fh,$ZodCheckIncludes:()=>xw,$ZodCheckLengthEquals:()=>gw,$ZodCheckLessThan:()=>jh,$ZodCheckLowerCase:()=>yw,$ZodCheckMaxLength:()=>hw,$ZodCheckMaxSize:()=>dw,$ZodCheckMimeType:()=>zw,$ZodCheckMinLength:()=>bw,$ZodCheckMinSize:()=>mw,$ZodCheckMultipleOf:()=>lw,$ZodCheckNumberFormat:()=>uw,$ZodCheckOverwrite:()=>Ow,$ZodCheckProperties:()=>Tw,$ZodCheckProperty:()=>Sw,$ZodCheckRegex:()=>vw,$ZodCheckSizeEquals:()=>pw,$ZodCheckStartsWith:()=>Pw,$ZodCheckStringFormat:()=>Ol,$ZodCheckUpperCase:()=>ww,$ZodCodec:()=>fd,$ZodCreditCard:()=>tx,$ZodCustom:()=>Dx,$ZodCustomStringFormat:()=>ix,$ZodCyclicError:()=>rb,$ZodDate:()=>px,$ZodDefault:()=>Rx,$ZodDiscriminatedUnion:()=>yx,$ZodE164:()=>ex,$ZodEmail:()=>Xw,$ZodEmoji:()=>Ew,$ZodEncodeError:()=>Qa,$ZodEnum:()=>Sx,$ZodError:()=>k1,$ZodExactOptional:()=>Mx,$ZodFile:()=>zx,$ZodFunction:()=>Hx,$ZodGUID:()=>Rw,$ZodIBAN:()=>nx,$ZodIPv4:()=>Gw,$ZodIPv6:()=>Aw,$ZodISODate:()=>Cw,$ZodISODateTime:()=>Uw,$ZodISODuration:()=>Kw,$ZodISOTime:()=>Jw,$ZodIntersection:()=>wx,$ZodJWT:()=>rx,$ZodKSUID:()=>qw,$ZodLazy:()=>dd,$ZodLiteral:()=>Tx,$ZodMAC:()=>Bw,$ZodMap:()=>Px,$ZodNaN:()=>Ix,$ZodNanoID:()=>Vw,$ZodNever:()=>dx,$ZodNonOptional:()=>Xx,$ZodNull:()=>lx,$ZodNullable:()=>Lx,$ZodNumber:()=>Bh,$ZodNumberFormat:()=>ox,$ZodObject:()=>b5,$ZodObjectJIT:()=>bx,$ZodOptional:()=>_h,$ZodPipe:()=>$h,$ZodPrefault:()=>Nx,$ZodPreprocess:()=>Ex,$ZodPromise:()=>Zx,$ZodReadonly:()=>Vx,$ZodRealError:()=>Ii,$ZodRecord:()=>xx,$ZodRegistry:()=>lb,$ZodSet:()=>kx,$ZodString:()=>ec,$ZodStringFormat:()=>Zn,$ZodSuccess:()=>jx,$ZodSymbol:()=>sx,$ZodTemplateLiteral:()=>Wx,$ZodTransform:()=>Ox,$ZodTuple:()=>Qh,$ZodType:()=>Wt,$ZodULID:()=>Zw,$ZodURL:()=>Iw,$ZodUUID:()=>Nw,$ZodUndefined:()=>cx,$ZodUnion:()=>ud,$ZodUnknown:()=>fx,$ZodVoid:()=>mx,$ZodXID:()=>Dw,$ZodXor:()=>gx,$brand:()=>w1,$constructor:()=>G,$input:()=>Jx,$output:()=>Cx,Doc:()=>$s,INVALID:()=>xi,JSONSchema:()=>rM,JSONSchemaGenerator:()=>Cb,NEVER:()=>y1,TimePrecision:()=>n3,URL_BAD_FORMAT:()=>jw,URL_UNPARSEABLE:()=>id,ZodCompileAsyncError:()=>ho,ZodCompileUnsupportedError:()=>cn,_any:()=>y3,_array:()=>z3,_base64:()=>Nb,_base64url:()=>Xb,_bigint:()=>d3,_boolean:()=>u3,_catch:()=>IB,_check:()=>DO,_cidrv4:()=>Lb,_cidrv6:()=>Rb,_coercedBigint:()=>m3,_coercedBoolean:()=>f3,_coercedDate:()=>S3,_coercedNumber:()=>i3,_coercedString:()=>_x,_creditCard:()=>e3,_cuid:()=>Pb,_cuid2:()=>kb,_custom:()=>M3,_date:()=>k3,_decode:()=>Ph,_decodeAsync:()=>Sh,_default:()=>XB,_discriminatedUnion:()=>wB,_e164:()=>jb,_email:()=>pb,_emoji:()=>wb,_encode:()=>xh,_encodeAsync:()=>kh,_endsWith:()=>Vl,_enum:()=>zB,_file:()=>O3,_float32:()=>a3,_float64:()=>s3,_gt:()=>Vo,_gte:()=>Ui,_guid:()=>hb,_iban:()=>t3,_includes:()=>Il,_int:()=>o3,_int32:()=>c3,_int64:()=>p3,_intersection:()=>xB,_ipv4:()=>Ob,_ipv6:()=>Mb,_isoDate:()=>wd,_isoDateTime:()=>yd,_isoDuration:()=>Pd,_isoTime:()=>xd,_jwt:()=>Fb,_ksuid:()=>zb,_lazy:()=>HB,_length:()=>sc,_literal:()=>MB,_lowercase:()=>jl,_lt:()=>Eo,_lte:()=>qi,_mac:()=>$x,_map:()=>SB,_max:()=>qi,_maxLength:()=>ac,_maxSize:()=>$a,_mime:()=>Hl,_min:()=>Ui,_minLength:()=>pa,_minSize:()=>Wo,_multipleOf:()=>_a,_nan:()=>T3,_nanoid:()=>xb,_nativeEnum:()=>OB,_negative:()=>Eb,_never:()=>x3,_nonnegative:()=>Wb,_nonoptional:()=>jB,_nonpositive:()=>Vb,_normalize:()=>Zl,_null:()=>v3,_nullable:()=>NB,_number:()=>r3,_optional:()=>RB,_overwrite:()=>bo,_parse:()=>kl,_parseAsync:()=>Sl,_pipe:()=>EB,_positive:()=>Ib,_promise:()=>ZB,_properties:()=>Wl,_property:()=>Hb,_readonly:()=>VB,_record:()=>kB,_refine:()=>L3,_regex:()=>Xl,_safeDecode:()=>zh,_safeDecodeAsync:()=>Mh,_safeEncode:()=>Th,_safeEncodeAsync:()=>Oh,_safeParse:()=>Tl,_safeParseAsync:()=>zl,_set:()=>TB,_size:()=>oc,_slugify:()=>Cl,_startsWith:()=>El,_string:()=>Qx,_stringFormat:()=>cc,_stringbool:()=>j3,_success:()=>FB,_superRefine:()=>R3,_symbol:()=>b3,_templateLiteral:()=>WB,_toLowerCase:()=>ql,_toUpperCase:()=>Ul,_transform:()=>LB,_trim:()=>Dl,_tuple:()=>PB,_uint32:()=>l3,_uint64:()=>h3,_ulid:()=>Sb,_undefined:()=>g3,_union:()=>vB,_unknown:()=>w3,_uppercase:()=>Fl,_url:()=>vd,_uuid:()=>bb,_uuidv4:()=>gb,_uuidv6:()=>vb,_uuidv7:()=>yb,_void:()=>P3,_xid:()=>Tb,_xor:()=>yB,base64Charset:()=>Ch,base64urlCharset:()=>cd,canParseURL:()=>Fw,clone:()=>Hn,compile:()=>Bx,compileFn:()=>db,config:()=>kr,createStandardJSONSchemaMethod:()=>Jl,createToJSONSchemaMethod:()=>I3,decode:()=>PK,decodeAsync:()=>SK,describe:()=>N3,encode:()=>xK,encodeAsync:()=>kK,extractDefs:()=>ts,finalize:()=>ns,flattenError:()=>Yf,formatError:()=>Qf,getDiscriminatedOption:()=>vx,globalConfig:()=>Gr,globalRegistry:()=>$r,handleUnrepresentable:()=>Hr,initializeContext:()=>es,isBackEdge:()=>ob,isRecursiveSchema:()=>ib,isValidBase64:()=>sd,isValidBase64URL:()=>Jh,isValidCIDRv6:()=>Uh,isValidCreditCard:()=>Kh,isValidIBAN:()=>Gh,isValidIPv6:()=>ad,isValidJWT:()=>Ah,locales:()=>gd,memoizer:()=>hd,mergeValues:()=>Ml,meta:()=>X3,parse:()=>yh,parseAsync:()=>wh,parseURLObject:()=>m5,prettifyError:()=>T1,process:()=>Dn,processSchema:()=>Dn,regexes:()=>$i,registry:()=>ub,safeDecode:()=>zK,safeDecodeAsync:()=>MK,safeEncode:()=>TK,safeEncodeAsync:()=>OK,safeParse:()=>bK,safeParseAsync:()=>gK,standardProps:()=>Hh,stripTabAndNewline:()=>od,toDotPath:()=>K9,toJSONSchema:()=>Ub,toZod:()=>Df,treeifyError:()=>S1,urlHostnameOk:()=>Dh,urlProtocolOk:()=>qh,util:()=>ve,validate:()=>_f,validateAsync:()=>$f,validateURL:()=>Zh,version:()=>Mw,withParser:()=>fb});var ve={};ra(ve,{BIGINT_FORMAT_RANGES:()=>Kf,CONSTANT_CATCH:()=>gh,Class:()=>l1,NUMBER_FORMAT_RANGES:()=>Jf,aborted:()=>wi,allowsEval:()=>d1,assert:()=>EJ,assertEqual:()=>XJ,assertIs:()=>FJ,assertNever:()=>IJ,assertNotEqual:()=>jJ,assignProp:()=>_r,attachSchema:()=>bh,base64ToUint8Array:()=>Z9,base64urlToUint8Array:()=>tK,cached:()=>wl,captureStackTrace:()=>ph,cleanEnum:()=>eK,cleanRegex:()=>da,clone:()=>Hn,cloneDef:()=>HJ,codePointLength:()=>Qs,constantCatch:()=>g1,createTransparentProxy:()=>JJ,defineLazy:()=>u1,defineLazyInternal:()=>_t,derived:()=>oK,esc:()=>yi,escapeRegex:()=>_i,explicitlyAborted:()=>h1,extend:()=>AJ,finalizeIssue:()=>ji,floatSafeRemainder:()=>qf,getElementAtPath:()=>ZJ,getEnumValues:()=>vl,getLengthableOrigin:()=>Af,getParsedType:()=>CJ,getSizableOrigin:()=>Gf,hexToUint8Array:()=>rK,hide:()=>Bf,installLazyProp:()=>lK,isObject:()=>Ys,isPlainObject:()=>Qi,issue:()=>Pl,joinValues:()=>A,jsonStringifyReplacer:()=>yl,members:()=>b1,merge:()=>YJ,mergeDefs:()=>po,normalizeParams:()=>Ie,nullish:()=>mh,numKeys:()=>UJ,objectClone:()=>VJ,omit:()=>GJ,optionalKeys:()=>p1,own:()=>Ya,parsedType:()=>Pe,partial:()=>QJ,pick:()=>KJ,prefixIssues:()=>Xi,primitiveTypes:()=>m1,promiseAllObject:()=>DJ,propertyKeyTypes:()=>Cf,randomString:()=>qJ,rawShape:()=>xl,required:()=>_J,safeExtend:()=>BJ,shallowClone:()=>Uf,slugify:()=>f1,stringifyPrimitive:()=>we,toZod:()=>Df,uint8ArrayToBase64:()=>D9,uint8ArrayToBase64url:()=>nK,uint8ArrayToHex:()=>iK,unwrapMessage:()=>gl});function XJ(e){return e}function jJ(e){return e}function Df(){return e=>e}function FJ(e){}function IJ(e){throw new Error("Unexpected value in exhaustive check")}function EJ(e){}function vl(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function A(e,t="|"){return e.map(n=>we(n)).join(t)}function yl(e,t){return typeof t=="bigint"?t.toString():t}var c1=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function wl(e){return new c1(e)}function mh(e){return e==null}function da(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function qf(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}var E9=Symbol("evaluating");function u1(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==E9)return i===void 0&&(i=E9,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function VJ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function _r(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xl(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function fa(e){return xl(e._zod.def)??e._zod.def.shape}function V9(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return _r(this,t,i),i},enumerable:!0,configurable:!0})}function W9(e,t,n){t in e?_r(e,t,n):e[t]=n}function Bs(e,t,n,i){let r=fa(t);for(let o of n){let a=Object.getOwnPropertyDescriptor(r,o);a.enumerable&&(a.get?V9(e,o,()=>{let s=t._zod.def.shape[o];return i?i(s,o):s}):W9(e,o,i?i(a.value,o):a.value))}}function WJ(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);i.enumerable&&(i.get?V9(e,n,()=>t[n]):W9(e,n,i.value))}}function po(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function HJ(e){return po(e._zod.def)}function ZJ(e,t){return t?t.reduce((n,i)=>n?.[i],e):e}function DJ(e){let t=Object.keys(e),n=t.map(i=>e[i]);return Promise.all(n).then(i=>{let r={};for(let o=0;o<t.length;o++)r[t[o]]=i[o];return r})}function qJ(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let i=0;i<e;i++)n+=t[Math.floor(Math.random()*t.length)];return n}function yi(e){return JSON.stringify(e)}function f1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ph="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ys(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var d1=wl(()=>{if(Gr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Qi(e){if(Ys(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Ys(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Uf(e){return Qi(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function UJ(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var CJ=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Cf=new Set(["string","number","symbol"]),m1=new Set(["string","number","bigint","boolean","symbol","undefined"]);function _i(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hn(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function Ie(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function JJ(e){let t;return new Proxy({},{get(n,i,r){return t??(t=e()),Reflect.get(t,i,r)},set(n,i,r,o){return t??(t=e()),Reflect.set(t,i,r,o)},has(n,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(n,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(n,i,r){return t??(t=e()),Reflect.defineProperty(t,i,r)}})}function we(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function p1(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Jf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Kf={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function KJ(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return Bs(o,e,hh(e,t)),Hn(e,po(n,{shape:o,checks:[]}))}function hh(e,t){let n=fa(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw new Error(`Unrecognized key: "${String(r)}"`);t[r]&&i.push(r)}return i}function GJ(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(hh(e,t)),a={};return Bs(a,e,Reflect.ownKeys(fa(e)).filter(s=>!o.has(s))),Hn(e,po(n,{shape:a,checks:[]}))}function AJ(e,t){if(!Qi(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=fa(e);for(let o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Hn(e,po(e._zod.def,{shape:H9(e,t)}))}function H9(e,t){let n={};return Bs(n,e,Reflect.ownKeys(fa(e))),WJ(n,t),n}function BJ(e,t){if(!Qi(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Hn(e,po(e._zod.def,{shape:H9(e,t)}))}function YJ(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Bs(n,e,Reflect.ownKeys(fa(e))),Bs(n,t,Reflect.ownKeys(fa(t)));let i=po(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Hn(e,i)}function QJ(e,t,n,i="partial"){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=n?new Set(hh(t,n)):void 0,c={};return Bs(c,t,Reflect.ownKeys(fa(t)),e&&((l,u)=>s&&!s.has(u)?l:new e({type:"optional",innerType:l}))),Hn(t,po(t._zod.def,{shape:c,checks:[]}))}function _J(e,t,n){let i=n?new Set(hh(t,n)):void 0,r={};return Bs(r,t,Reflect.ownKeys(fa(t)),(o,a)=>i&&!i.has(a)?o:new e({type:"nonoptional",innerType:o})),Hn(t,po(t._zod.def,{shape:r}))}function wi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function h1(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Xi(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function gl(e){return typeof e=="string"?e:e?.message}function bh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ji(e,t,n){var i;let r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:gl(e.inst?._zod.def?.error?.(e))??gl(o?.(e))??gl(t?.error?.(e))??gl(n.customError?.(e))??gl(n.localeError?.(e))??"Invalid input",s={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(s[c]=e[c]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}function Gf(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var $J=/[\uD800-\uDBFF]/;function Qs(e){let t=e.length;if(!$J.test(e))return t;let n=t;for(let i=0;i<t-1;i++)(e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320&&(n--,i++);return n}function Af(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Pe(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Pl(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}function eK(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Z9(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function D9(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function tK(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Z9(t+n)}function nK(e){return D9(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rK(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)n[i/2]=Number.parseInt(t.slice(i,i+2),16);return n}function iK(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var l1=class{constructor(...t){}};function b1(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):aK(e,n,i.value)}}function Ya(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Bf(e,t,n){return Ya(e,t,n,!1)}function oK(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ya(this,n,i(this))},set(r){Ya(this,n,r)}})}return t}function aK(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ya(this,t,n.bind(this))},set(i){Ya(this,t,i)}})}function sK(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var s1,Ba=!1,cK={configurable:!0,get(){Ba=!0}};function _t(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&s1!==e._zod){s1=void 0;return}s1=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,cK);let r=Ba;Ba=!1;try{let o=n(this);return Ba?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),Ba=Ba||r,o}catch(o){throw delete this[t],Ba=Ba||r,o}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function lK(e,t,n,i){let r=sK(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var gh="~constantCatch";function g1(e){let t=()=>e;return t[gh]=!0,t}var q9,y1=Object.freeze({status:"aborted"}),v1={value:void 0,enumerable:!1},U9="captureStackTrace"in Error?Error:null;function uK(e){let t=U9;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return U9=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function G(e,t,n,i){let r={};function o(d){this.def=d,this.constr=f,this.traits=new Set}o.prototype=r;let a=n,s=a&&new WeakSet;function c(d,m){if(d._zod){if(d._zod.traits.has(e))return}else{v1.value=new o(m);try{Object.defineProperty(d,"_zod",v1)}finally{v1.value=void 0}}if(d._zod.traits.add(e),t(d,m),s){let h=Object.getPrototypeOf(d),b=d._zod.constr.prototype,v=h;for(;v&&v!==b;)v=Object.getPrototypeOf(v);let g=v??h;s.has(g)||(s.add(g),b1(g,a))}let p=f.prototype;for(let h in p)Object.prototype.hasOwnProperty.call(p,h)&&(h in d||(d[h]=p[h].bind(d)))}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(d){let m=i?.Parent?uK(u):this;c(m,d);let p=m._zod.deferred;if(p){for(let b of p)b();m._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(m),m}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:d=>i?.Parent&&d instanceof i.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var w1=Symbol("zod_brand"),Fi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qa=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(q9=globalThis).__zod_globalConfig??(q9.__zod_globalConfig={});var Gr=globalThis.__zod_globalConfig;function kr(e){return e&&Object.assign(Gr,e),Gr}function fK(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yl,2)),e.message}function dK(e){this._zod.message=e}var mK={get:fK,set:dK,enumerable:!0,configurable:!0},P1={value:void 0,enumerable:!1},C9=new WeakSet([Object.prototype,Error.prototype]),J9=(e,t)=>{e.name="$ZodError",P1.value=t,Object.defineProperty(e,"issues",P1),P1.value=void 0,Object.defineProperty(e,"message",mK);let n=Object.getPrototypeOf(e);C9.has(n)||(C9.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},k1=G("$ZodError",J9),Ii=G("$ZodError",J9,void 0,{Parent:Error});function pK(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Yf(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?pK(n,r.path[0],()=>[]).push(t(r)):i.push(t(r));return{formErrors:i,fieldErrors:n}}function Qf(e,t=n=>n.message){let n={_errors:[]},i=(r,o=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)n._errors.push(t(a));else{let c=n,l=0;for(;l<s.length;){let u=s[l],f=l===s.length-1;if(u==="_errors"){f&&c._errors.push(t(a)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];f&&d._errors.push(t(a)),c=d,l++}}}};return i(e),n}function S1(e,t=n=>n.message){let n={errors:[]},i=(r,o=[])=>{var a;for(let s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>i({issues:c},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let c=[...o,...s.path];if(c.length===0){n.errors.push(t(s));continue}let l=n,u=0;for(;u<c.length;){let f=c[u],d=u===c.length-1;typeof f=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,f)||Object.defineProperty(l.properties,f,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[f]):(l.items??(l.items=[]),(a=l.items)[f]??(a[f]={errors:[]}),l=l.items[f]),d&&l.errors.push(t(s)),u++}}};return i(e),n}function K9(e){let t=[],n=e.map(i=>typeof i=="object"?i.key:i);for(let i of n)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function T1(e){let t=[],n=[...e.issues].sort((i,r)=>(i.path??[]).length-(r.path??[]).length);for(let i of n)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${K9(i.path)}`);return t.join(`
17
- `)}function vh(e,t){return{callee:t?.callee??e,Err:t?.Err}}var kl=e=>{let t=(n,i,r,o)=>{let a=r?{...r,async:!1}:{async:!1},s=n._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new Fi;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(l=>ji(l,a,kr())));throw ph(c,o?.callee??t),c}return s.value};return t},yh=kl(Ii),Sl=e=>{let t=async(n,i,r,o)=>{let a=r?{...r,async:!0}:{async:!0},s=n._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(l=>ji(l,a,kr())));throw ph(c,o?.callee??t),c}return s.value};return t},wh=Sl(Ii),Tl=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new Fi;return o.issues.length?G9(e,o.issues,r):{success:!0,data:o.value}},bK=Tl(Ii);function G9(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(r=>ji(r,n,kr()))),t=void 0,n=void 0),i},set error(r){i=r,t=void 0,n=void 0}}}var zl=e=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?G9(e,o.issues,r):{success:!0,data:o.value}},gK=zl(Ii),vK=Symbol.for("zod.compile.invalid"),yK=Symbol.for("zod.compile.fallback"),_f=((e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==vK)return!0;if(i.definite===!0&&n===void 0)return!1}return wK(e,t,n)});function wK(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,o;if(r?(i[yK]=!0,o=r({value:t,issues:[]},i)):o=e._zod.run({value:t,issues:[]},i),o instanceof Promise)throw new Fi;return o.issues.length===0}var $f=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length===0},xh=e=>{let t=kl(e),n=(i,r,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return t(i,r,s,vh(n,a))};return n},xK=xh(Ii),Ph=e=>{let t=kl(e),n=(i,r,o,a)=>t(i,r,o,vh(n,a));return n},PK=Ph(Ii),kh=e=>{let t=Sl(e),n=async(i,r,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return await t(i,r,s,vh(n,a))};return n},kK=kh(Ii),Sh=e=>{let t=Sl(e),n=async(i,r,o,a)=>await t(i,r,o,vh(n,a));return n},SK=Sh(Ii),Th=e=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Tl(e)(t,n,r)},TK=Th(Ii),zh=e=>(t,n,i)=>Tl(e)(t,n,i),zK=zh(Ii),Oh=e=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return zl(e)(t,n,r)},OK=Oh(Ii),Mh=e=>async(t,n,i)=>zl(e)(t,n,i),MK=Mh(Ii);var $i={};ra($i,{anyString:()=>_1,base64:()=>U1,base64url:()=>C1,bigint:()=>ew,boolean:()=>tw,browserEmail:()=>EK,cidrv4:()=>D1,cidrv6:()=>q1,creditCard:()=>Lh,cuid:()=>O1,cuid2:()=>M1,currencyCode:()=>A1,date:()=>B1,datetime:()=>Q1,domain:()=>K1,duration:()=>F1,e164:()=>G1,email:()=>E1,emoji:()=>V1,extendedDuration:()=>LK,guid:()=>I1,hex:()=>aw,hostname:()=>J1,html5Email:()=>jK,httpProtocol:()=>ed,iban:()=>Rh,idnEmail:()=>IK,integer:()=>td,ipv4:()=>W1,ipv6:()=>H1,ksuid:()=>N1,lowercase:()=>iw,mac:()=>Z1,md5_base64:()=>ZK,md5_base64url:()=>DK,md5_hex:()=>HK,nanoid:()=>X1,nanoidOfLength:()=>j1,null:()=>nw,number:()=>ma,rfc5322Email:()=>FK,sha1_base64:()=>UK,sha1_base64url:()=>CK,sha1_hex:()=>qK,sha256_base64:()=>KK,sha256_base64url:()=>GK,sha256_hex:()=>JK,sha384_base64:()=>BK,sha384_base64url:()=>YK,sha384_hex:()=>AK,sha512_base64:()=>_K,sha512_base64url:()=>$K,sha512_hex:()=>QK,string:()=>$1,time:()=>Y1,ulid:()=>L1,undefined:()=>rw,unicodeEmail:()=>A9,uppercase:()=>ow,uuid:()=>_s,uuid4:()=>RK,uuid6:()=>NK,uuid7:()=>XK,xid:()=>R1});var O1=/^[cC][0-9a-z]{6,}$/,M1=/^[0-9a-z]+$/,L1=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,R1=/^[0-9a-vA-V]{20}$/,N1=/^[A-Za-z0-9]{27}$/,X1=/^[a-zA-Z0-9_-]{21}$/;function j1(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var F1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,LK=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,I1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_s=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,RK=_s(4),NK=_s(6),XK=_s(7),E1=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jK=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,FK=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,A9=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,IK=A9,EK=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,VK="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function V1(){return new RegExp(VK,"u")}var W1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,H1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Z1=e=>{let t=_i(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},D1=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,q1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,U1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C1=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,J1=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,K1=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,ed=/^https?$/,G1=/^\+[1-9]\d{6,14}$/,Lh=/^\d(?:[ -]?\d){11,18}$/,A1=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,Rh=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,B9="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function WK(e){return new RegExp(`^${e}$`)}var B1=WK(B9);function z1(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Y1(e){return new RegExp(`^${z1(e)}$`)}function Q1(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${z1({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${z1({precision:e.precision})}`:n;return new RegExp(`^${B9}T(?:${i})$`)}var _1=/^[\s\S]{0,}$/,$1=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ew=/^-?\d+n?$/,td=/^-?\d+$/,ma=/^-?\d+(?:\.\d+)?$/,tw=/^(?:true|false)$/i,nw=/^null$/i;var rw=/^undefined$/i;var iw=/^[^A-Z]*$/,ow=/^[^a-z]*$/,aw=/^[0-9a-fA-F]*$/;function nd(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function rd(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var HK=/^[0-9a-fA-F]{32}$/,ZK=nd(22,"=="),DK=rd(22),qK=/^[0-9a-fA-F]{40}$/,UK=nd(27,"="),CK=rd(27),JK=/^[0-9a-fA-F]{64}$/,KK=nd(43,"="),GK=rd(43),AK=/^[0-9a-fA-F]{96}$/,BK=nd(64,""),YK=rd(64),QK=/^[0-9a-fA-F]{128}$/,_K=nd(86,"=="),$K=rd(86);var _n=G("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sw=e=>{let t=e.value;return!mh(t)&&t.size!==void 0},cw=e=>{let t=e.value;return!mh(t)&&t.length!==void 0},Nh={number:"number",bigint:"bigint",object:"date"},jh=G("$ZodCheckLessThan",(e,t)=>{_n.init(e,t);let n=Nh[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:Nh[typeof i.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fh=G("$ZodCheckGreaterThan",(e,t)=>{_n.init(e,t);let n=Nh[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:Nh[typeof i.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lw=G("$ZodCheckMultipleOf",(e,t)=>{_n.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qf(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),uw=G("$ZodCheckNumberFormat",(e,t)=>{_n.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,o]=Jf[t.format];e._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),fw=G("$ZodCheckBigIntFormat",(e,t)=>{_n.init(e,t);let[n,i]=Kf[t.format];e._zod.check=r=>{let o=r.value;o<n&&r.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>i&&r.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),dw=G("$ZodCheckMaxSize",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=sw),e._zod.check=i=>{let r=i.value;r.size<=t.maximum||i.issues.push({origin:Gf(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mw=G("$ZodCheckMinSize",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=sw),e._zod.check=i=>{let r=i.value;r.size>=t.minimum||i.issues.push({origin:Gf(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pw=G("$ZodCheckSizeEquals",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=sw),e._zod.check=i=>{let r=i.value,o=r.size;if(o===t.size)return;let a=o>t.size;i.issues.push({origin:Gf(r),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),hw=G("$ZodCheckMaxLength",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=cw),e._zod.check=i=>{let r=i.value,o=r.length;if((typeof r=="string"&&o>t.maximum?Qs(r):o)<=t.maximum)return;let s=Af(r);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bw=G("$ZodCheckMinLength",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=cw),e._zod.check=i=>{let r=i.value,o=r.length;if((typeof r=="string"&&o>=t.minimum&&o<t.minimum*2?Qs(r):o)>=t.minimum)return;let s=Af(r);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gw=G("$ZodCheckLengthEquals",(e,t)=>{var n;_n.init(e,t),(n=e._zod.def).when??(n.when=cw),e._zod.check=i=>{let r=i.value,o=r.length,a=typeof r=="string"&&o>=t.length&&o<=t.length*2?Qs(r):o;if(a===t.length)return;let s=Af(r),c=a>t.length;i.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Ol=G("$ZodCheckStringFormat",(e,t)=>{var n,i;_n.init(e,t),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),vw=G("$ZodCheckRegex",(e,t)=>{Ol.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),yw=G("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=iw),Ol.init(e,t)}),ww=G("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ow),Ol.init(e,t)}),xw=G("$ZodCheckIncludes",(e,t)=>{_n.init(e,t);let n=_i(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Pw=G("$ZodCheckStartsWith",(e,t)=>{_n.init(e,t);let n=new RegExp(`^${_i(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),kw=G("$ZodCheckEndsWith",(e,t)=>{_n.init(e,t);let n=new RegExp(`.*${_i(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function Xh(e,t,n){e.issues.length&&t.issues.push(...Xi(n,e.issues))}var Sw=G("$ZodCheckProperty",(e,t)=>{_n.init(e,t),e._zod.check=n=>{let i=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(r=>Xh(r,n,t.property));Xh(i,n,t.property)}}),Tw=G("$ZodCheckProperties",(e,t)=>{_n.init(e,t),Bf(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=i=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(a=>[a,t.shape[a]]));let r=i.value,o;for(let[a,s]of n){let c=s._zod.run({value:r[a],issues:[]},{});c instanceof Promise?(o??(o=[]),o.push(c.then(l=>Xh(l,i,a)))):Xh(c,i,a)}if(o)return Promise.all(o).then(()=>{})}}),zw=G("$ZodCheckMimeType",(e,t)=>{_n.init(e,t);let n=new Set(t.mime);e._zod.check=i=>{n.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),Ow=G("$ZodCheckOverwrite",(e,t)=>{_n.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var $s=class{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
18
- `).filter(a=>a),r=Math.min(...i.map(a=>a.length-a.trimStart().length)),o=i.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
19
- ${n.join(`
20
- `)}
21
- };`)(...Object.values(this.closed))}};var Mw={major:4,minor:6,patch:5};var Wt=G("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mw;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let o of r)for(let a of o._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,c,l)=>{if(s.memo)return s;let u=wi(s),f;for(let d of c){if(d._zod.def.when){if(h1(s)||!d._zod.def.when(s))continue}else if(u)continue;let m=s.issues.length,p=d._zod.check(s);if(p instanceof Promise&&l?.async===!1)throw new Fi;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,s.issues.length!==m&&(bh(s.issues,m,e),u||(u=wi(s,m)))});else{if(s.issues.length===m)continue;bh(s.issues,m,e),u||(u=wi(s,m))}}return f?f.then(()=>s):s},a=(s,c,l)=>{if(wi(s))return s.aborted=!0,s;let u=o(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Fi;return u.then(f=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(f=>a(f,s,c)):a(u,s,c)}let l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new Fi;return l.then(u=>o(u,r,c))}return o(l,r,c)}}},{get"~standard"(){return Bf(this,"~standard",Hh(this))},set"~standard"(e){Ya(this,"~standard",e)}}),d5=(e,t)=>e.issues.length?{issues:e.issues.map(n=>ji(n,t,kr()))}:{value:e.value};async function eG(e,t){let n={async:!0};return d5(await e._zod.run({value:t,issues:[]},n),n)}function Hh(e){return{validate:t=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return d5(i,n)}catch{}return eG(e,t)},vendor:"zod",version:1}}var ec=G("$ZodString",(e,t)=>{Wt.init(e,t),e._zod.pattern=t.pattern??_1,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Zn=G("$ZodStringFormat",(e,t)=>{Ol.init(e,t),ec.init(e,t)}),Rw=G("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=I1),Zn.init(e,t)}),Nw=G("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=_s(i))}else t.pattern??(t.pattern=_s());Zn.init(e,t)}),Xw=G("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=E1),Zn.init(e,t)}),jw=1,id=2;function Fw(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Zh(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Fw(e)||id:m5(e,t)}function m5(e,t){if(!t.normalize&&t.protocol?.source===ed.source&&!/^https?:\/\//i.test(e))return jw;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse=="function")return n.parse(e)??id}return new URL(e)}catch{return id}}var tG=/[\t\n\r]/g;function od(e){return e.replace(tG,"")}function Dh(e,t){return t.lastIndex=0,t.test(e.hostname)}function qh(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Iw=G("$ZodURL",(e,t)=>{Zn.init(e,t),e._zod.check=n=>{try{let i=n.value.trim(),r=Zh(i,t);if(r===jw){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===id){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=od(i);return}t.hostname&&!Dh(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!qh(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?r.href:od(i);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ew=G("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=V1()),Zn.init(e,t)}),Vw=G("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?X1:j1(t.length)),Zn.init(e,t)}),Ww=G("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=O1),Zn.init(e,t)}),Hw=G("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=M1),Zn.init(e,t)}),Zw=G("$ZodULID",(e,t)=>{t.pattern??(t.pattern=L1),Zn.init(e,t)}),Dw=G("$ZodXID",(e,t)=>{t.pattern??(t.pattern=R1),Zn.init(e,t)}),qw=G("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=N1),Zn.init(e,t)}),Uw=G("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Q1(t)),Zn.init(e,t)}),Cw=G("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=B1),Zn.init(e,t)}),Jw=G("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Y1(t)),Zn.init(e,t)}),Kw=G("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=F1),Zn.init(e,t)}),Gw=G("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=W1),Zn.init(e,t)}),nG=/^[0-9a-fA-F:.]+$/;function ad(e){return nG.test(e)?Fw(`http://[${e}]`):!1}var Aw=G("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=H1),Zn.init(e,t),e._zod.check=n=>{ad(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Bw=G("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Z1(t.delimiter)),Zn.init(e,t)}),Yw=G("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=D1),Zn.init(e,t)});function Uh(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);return`${r}`!==i||r<0||r>128?!1:ad(n)}var Qw=G("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=q1),Zn.init(e,t),e._zod.check=n=>{Uh(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function sd(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ch=/^[0-9a-zA-Z+/]*={0,2}$/,_w=G("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ch),Zn.init(e,t),e._zod.check=n=>{sd(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),cd=/^[A-Za-z0-9_-]*$/;function Jh(e){if(!cd.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return sd(n)}var $w=G("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cd),Zn.init(e,t),e._zod.check=n=>{Jh(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ex=G("$ZodE164",(e,t)=>{t.pattern??(t.pattern=G1),Zn.init(e,t)}),rG=/[- ]/g;function iG(e){let t=e.length,n=1,i=0;for(;t;){let r=e.charCodeAt(--t)-48;n^=1,i+=n?[0,2,4,6,8,1,3,5,7,9][r]:r}return i%10===0}function Kh(e){return Lh.test(e)?iG(e.replace(rG,"")):!1}var tx=G("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Lh),Zn.init(e,t),e._zod.check=n=>{Kh(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function oG(e){let t=0,n=e.length;for(let i=4;i<n;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}for(let i=0;i<4;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}return t===1}function Gh(e){return Rh.test(e)?oG(e):!1}var nx=G("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Rh),Zn.init(e,t),e._zod.check=n=>{Gh(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Ah(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}var rx=G("$ZodJWT",(e,t)=>{Zn.init(e,t),e._zod.check=n=>{Ah(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ix=G("$ZodCustomStringFormat",(e,t)=>{Zn.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Bh=G("$ZodNumber",(e,t)=>{Wt.init(e,t),e._zod.pattern=ma,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),ox=G("$ZodNumberFormat",(e,t)=>{uw.init(e,t),Bh.init(e,t)}),ld=G("$ZodBoolean",(e,t)=>{Wt.init(e,t),e._zod.pattern=tw,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Yh=G("$ZodBigInt",(e,t)=>{Wt.init(e,t),e._zod.pattern=ew,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),ax=G("$ZodBigIntFormat",(e,t)=>{fw.init(e,t),Yh.init(e,t)}),sx=G("$ZodSymbol",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),cx=G("$ZodUndefined",(e,t)=>{Wt.init(e,t),e._zod.pattern=rw,e._zod.values=new Set([void 0]),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),lx=G("$ZodNull",(e,t)=>{Wt.init(e,t),e._zod.pattern=nw,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),ux=G("$ZodAny",(e,t)=>{Wt.init(e,t),e._zod.parse=n=>n}),fx=G("$ZodUnknown",(e,t)=>{Wt.init(e,t),e._zod.parse=n=>n}),dx=G("$ZodNever",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),mx=G("$ZodVoid",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),px=G("$ZodDate",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,o=r instanceof Date;return o&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...o?{received:"Invalid Date"}:{},inst:e}),n}});function Q9(e,t,n){e.issues.length&&t.issues.push(...Xi(n,e.issues)),t.value[n]=e.value}var hx=G("$ZodArray",(e,t)=>{Wt.init(e,t);let n=Gr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=n?n.alloc(e,i,Array(o.length),r):Array(o.length);let a=[],s=r?.abortEarly;for(let c=0;c<o.length;c++){let l=o[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)a.push(u.then(f=>Q9(f,i,c)));else if(Q9(u,i,c),s&&u.issues.length!==0&&wi(u))break}return a.length?Promise.all(a).then(()=>i):i}});function Wh(e,t,n,i,r,o){let a=n in i,s=o==="optional";if(!(!a&&s&&r==="optional")){if(e.issues.length){if(r!==void 0&&s&&!a)return;t.issues.push(...Xi(n,e.issues))}if(!a&&r===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(a||r==="defaulted"&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var aG=[];function p5(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:aG,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let o=p1(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function h5(e,t,n,i,r,o,a){let s=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,f=l.optin,d=l.optout,m=0;for(let p in t){if(a&&n.issues.length!==m){if(wi(n,m))break;m=n.issues.length}if(c.has(p))continue;if(p==="__proto__"){u==="never"&&s.push(p);continue}if(u==="never"){s.push(p);continue}let h=l.run({value:t[p],issues:[]},i);h instanceof Promise?e.push(h.then(b=>Wh(b,n,p,t,f,d))):Wh(h,n,p,t,f,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var b5=G("$ZodObject",(e,t)=>{Wt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=wl(()=>p5(t));_t(e,"propValues",l=>{let u=l.def.shape,f={};for(let d in u){let m=u[d]._zod;if(m.values){Object.prototype.hasOwnProperty.call(f,d)||_r(f,d,new Set);for(let p of m.values)f[d].add(p);m.optin!==void 0&&f[d].add(void 0)}}return f});let o=Ys,a=t.catchall,s,c=Gr.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{s??(s=r.value);let f=l.value;if(!o(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],m=s.shape,p=u?.abortEarly,h=l.issues.length;for(let b of s.allKeys){if(p&&l.issues.length!==h){if(wi(l,h))break;h=l.issues.length}if(b==="__proto__")continue;let v=m[b],g=v._zod.optin,y=v._zod.optout,w=v._zod.run({value:f[b],issues:[]},u);w instanceof Promise?d.push(w.then(x=>Wh(x,l,b,f,g,y))):Wh(w,l,b,f,g,y)}return a?h5(d,f,l,u,r.value,e,p===!0):d.length?Promise.all(d).then(()=>l):l}}),bx=G("$ZodObjectJIT",(e,t)=>{b5.init(e,t);let n=e._zod.parse,i=wl(()=>p5(t)),r=Gr.memoizer,o=m=>{let p=i.value,h=p.symbolKeys,b=new $s(["payload","ctx"],{shape:m,inst:e,memo:r,syms:h}),v=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,g=(x,O)=>`
22
- let ${x}_ab = false;
23
- for (let i = 0; i < ${x}.issues.length; i++) {
24
- const iss = ${x}.issues[i];
25
- iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
26
- payload.issues.push(iss);
27
- if (iss.continue !== true) ${x}_ab = true;
28
- }
29
- if (${x}_ab && ctx && ctx.abortEarly) {
30
- payload.value = newResult;
31
- return payload;
32
- }`;b.write("const input = payload.value;");let y=Object.create(null),w=0;for(let x of p.allKeys)y[x]=`key_${w++}`;b.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of p.allKeys){if(x==="__proto__")continue;let O=y[x],P=typeof x=="symbol"?`syms[${h.indexOf(x)}]`:yi(x),T=`${P} in input`,S=m[x],k=S?._zod?.optin,L=k!==void 0,z=S?._zod?.optout==="optional";if(b.write(`const ${O} = ${v(P)};`),L&&z){let X=k==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;b.write(`
33
- const ${O}_present = ${T};
34
- if (!${O}.issues.length || ${O}_present) {
35
- if (${O}.issues.length) {${g(O,P)}
36
- }
37
-
38
- if (${X}) {
39
- newResult[${P}] = ${O}.value;
40
- }
41
- }
42
-
43
- `)}else L?(b.write(`
44
- if (${O}.issues.length) {${g(O,P)}
45
- }
46
- `),k==="defaulted"?b.write(`newResult[${P}] = ${O}.value;`):b.write(`
47
- if (${O}.value !== undefined || ${T}) {
48
- newResult[${P}] = ${O}.value;
49
- }
50
- `)):b.write(`
51
- const ${O}_present = ${T};
52
- if (${O}.issues.length) {${g(O,P)}
53
- }
54
- if (!${O}_present && !${O}.issues.length) {
55
- payload.issues.push({
56
- code: "invalid_type",
57
- expected: "nonoptional",
58
- input: undefined,
59
- path: [${P}]
60
- });
61
- if (ctx && ctx.abortEarly) {
62
- payload.value = newResult;
63
- return payload;
64
- }
65
- }
66
-
67
- if (${O}_present) {
68
- newResult[${P}] = ${O}.value;
69
- }
70
-
71
- `)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()},a,s=Ys,c=!Gr.jitless,u=c&&d1.value,f=t.catchall,d;e._zod.parse=(m,p)=>{d??(d=i.value);let h=m.value;return s(h)?c&&u&&p?.async===!1&&p.jitless!==!0?(a||(a=o(t.shape)),m=a(m,p),f?h5([],h,m,p,d,e,p?.abortEarly===!0):m):n(m,p):(m.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),m)}});function _9(e,t,n,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let r=e.filter(o=>!wi(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(a=>ji(a,i,kr())))}),t)}var ud=G("$ZodUnion",(e,t)=>{Wt.init(e,t),_t(e,"optin",i=>i.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),_t(e,"optout",i=>i.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),_t(e,"values",i=>{if(i.def.options.every(r=>r._zod.values))return new Set(i.def.options.flatMap(r=>Array.from(r._zod.values)))}),_t(e,"pattern",i=>{if(i.def.options.every(r=>r._zod.pattern)){let r=i.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>da(o.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(s=>_9(s,i,e,r)):_9(a,i,e,r)}});function $9(e,t,n,i){let r=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&r.push(o);return r.length===1?(t.value=e[r[0]].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(a=>ji(a,i,kr())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:r}),t)}var gx=G("$ZodXor",(e,t)=>{ud.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},r);c instanceof Promise?(a.push(c),o=!0):a.push(c)}return o?Promise.all(a).then(s=>$9(s,i,e,r)):$9(a,i,e,r)}});function vx(e,t){let n=e._zod,i=n.bag.optionsMap;i||(i=g5(n.def),n.bag.optionsMap=i);let r=i.get(t);if(r===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return r}function g5(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw new Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var yx=G("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ud.init(e,t);let n=e._zod.parse;_t(e,"propValues",r=>{let o={},a=0;for(let s of r.def.options){let c=s._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(s)}"`);c[r.def.discriminator]?.has(void 0)&&a++;for(let[l,u]of Object.entries(c)){Object.prototype.hasOwnProperty.call(o,l)||_r(o,l,new Set);for(let f of u)o[l].add(f)}}return!r.def.unionFallback&&a>1&&o[r.def.discriminator]?.delete(void 0),o}),t.options.forEach((r,o)=>{let a=xl(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});let i=wl(()=>g5(t));e._zod.parse=(r,o)=>{let a=r.value;if(!Ys(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let s=a?.[t.discriminator],c=i.value.get(s);return c&&(s!==void 0||o.direction!=="backward")?c._zod.run(r,o):t.unionFallback||o.direction==="backward"?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(l=>i.value.get(l)!==null),input:a,path:[t.discriminator],inst:e}),r)}}),wx=G("$ZodIntersection",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,o=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>e5(n,c,l)):e5(n,o,a)}});function Ml(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qi(e)&&Qi(t)){let n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(let o of i){if(o==="__proto__")continue;let a=Ml(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};r[o]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=t[i],a=Ml(r,o);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function e5(e,t,n){let i=new Map,r,o=new Map,a=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);o.has(d)||o.set(d,l),f=[d]}else return!1;for(let d of f)i.has(d)||i.set(d,{}),i.get(d)[u]=!0;return!0};for(let l of t.issues)a(l,"l")||e.issues.push(l);for(let l of n.issues)a(l,"r")||e.issues.push(l);let s=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length){let l=r?s.filter(u=>r.keys.includes(u)):[];l.length&&e.issues.push({...r,keys:l});for(let u of s)!l.includes(u)&&o.has(u)&&e.issues.push(o.get(u))}let c=Ml(t.value,n.value);if(!c.valid){if(wi(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qh=G("$ZodTuple",(e,t)=>{Wt.init(e,t);let n=t.items,i=Gr.memoizer;i?.attach(e),e._zod.parse=(r,o)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],o):[];let s=[],c=t5(n,"optin"),l=t5(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;a.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=new Array(n.length),f=t.rest?o?.abortEarly:void 0,d=!1;for(let m=0;m<n.length;m++){let p=n[m]._zod.run({value:a[m],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{u[m]=h})):(u[m]=p,f&&!d&&p.issues.length&&(d=wi(p)))}if(t.rest&&!d){let m=n.length-1,p=a.slice(n.length),h=r.issues.length;for(let b of p){if(f&&r.issues.length!==h){if(wi(r,h))break;h=r.issues.length}m++;let v=t.rest._zod.run({value:b,issues:[]},o);v instanceof Promise?s.push(v.then(g=>n5(g,r,m))):n5(v,r,m)}}return s.length?Promise.all(s).then(()=>r5(u,r,n,a,l)):r5(u,r,n,a,l)}});function t5(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function n5(e,t,n){e.issues.length&&t.issues.push(...Xi(n,e.issues)),t.value[n]=e.value}function r5(e,t,n,i,r){for(let o=0;o<n.length;o++){let a=e[o],s=o<i.length;if(!s&&o>=r&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(a.issues.length){if(!s&&o>=r){t.value.length=o;break}t.issues.push(...Xi(o,a.issues))}t.value[o]=a.value}for(let o=t.value.length-1;o>=i.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}var xx=G("$ZodRecord",(e,t)=>{Wt.init(e,t);let n=Gr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!Qi(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(p=>ji(p,r,kr())),input:u,path:[u],inst:e});continue}let d=f.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:o[u],issues:[]},r);m instanceof Promise?a.push(m.then(p=>{p.issues.length&&i.issues.push(...Xi(u,p.issues)),i.value[d]=p.value})):(m.issues.length&&i.issues.push(...Xi(u,m.issues)),i.value[d]=m.value)}let l;for(let u in o)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=o[u]}else l=l??[],l.push(u);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&ma.test(l)&&u.issues.length){let p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?i.value[l]=o[l]:s?(c=c??[],c.push(l)):i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>ji(p,r,kr())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:o[l],issues:[]},r);m instanceof Promise?a.push(m.then(p=>{p.issues.length&&i.issues.push(...Xi(l,p.issues)),i.value[d]=p.value})):(m.issues.length&&i.issues.push(...Xi(l,m.issues)),i.value[d]=m.value)}c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}return a.length?Promise.all(a).then(()=>i):i}}),Px=G("$ZodMap",(e,t)=>{Wt.init(e,t);let n=Gr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!(o instanceof Map))return i.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),i;let a=[];i.value=n?n.alloc(e,i,new Map,r):new Map;let s=r?.abortEarly,c=i.issues.length;for(let[l,u]of o){if(s&&i.issues.length!==c){if(wi(i,c))break;c=i.issues.length}let f=t.keyType._zod.run({value:l,issues:[]},r),d=t.valueType._zod.run({value:u,issues:[]},r);f instanceof Promise||d instanceof Promise?a.push(Promise.all([f,d]).then(([m,p])=>{i5(m,p,i,l,o,e,r)})):i5(f,d,i,l,o,e,r)}return a.length?Promise.all(a).then(()=>i):i}});function i5(e,t,n,i,r,o,a){e.issues.length&&(Cf.has(typeof i)?n.issues.push(...Xi(i,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:o,issues:e.issues.map(s=>ji(s,a,kr()))})),t.issues.length&&(Cf.has(typeof i)?n.issues.push(...Xi(i,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:o,key:i,issues:t.issues.map(s=>ji(s,a,kr()))})),n.value.set(e.value,t.value)}var kx=G("$ZodSet",(e,t)=>{Wt.init(e,t);let n=Gr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!(o instanceof Set))return i.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),i;let a=[];i.value=n?n.alloc(e,i,new Set,r):new Set;let s=r?.abortEarly,c=i.issues.length;for(let l of o){if(s&&i.issues.length!==c){if(wi(i,c))break;c=i.issues.length}let u=t.valueType._zod.run({value:l,issues:[]},r);u instanceof Promise?a.push(u.then(f=>o5(f,i))):o5(u,i)}return a.length?Promise.all(a).then(()=>i):i}});function o5(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Sx=G("$ZodEnum",(e,t)=>{Wt.init(e,t);let n=vl(t.entries),i=new Set(n);e._zod.values=i,_t(e,"pattern",r=>{let o=vl(r.def.entries).filter(a=>Cf.has(typeof a));return new RegExp(o.length?`^(${o.map(a=>_i(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let a=r.value;return i.has(a)||r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Tx=G("$ZodLiteral",(e,t)=>{Wt.init(e,t);let n=new Set(t.values);e._zod.values=n,_t(e,"pattern",i=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?_i(o):o?_i(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),zx=G("$ZodFile",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),Ox=G("$ZodTransform",(e,t)=>{Wt.init(e,t),e._zod.optin="optional",Gr.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Qa(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(a=>(n.value=a,n));if(r instanceof Promise)throw new Fi;return n.value=r,n}});function a5(e,t){return e.value=t.issues.length?void 0:t.value,e}var _h=G("$ZodOptional",(e,t)=>{Wt.init(e,t),_t(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_t(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),_t(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${da(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(o=>a5(n,o)):a5(n,r)}return t.innerType._zod.run(n,i)}}),Mx=G("$ZodExactOptional",(e,t)=>{_h.init(e,t),_t(e,"values",n=>n.def.innerType._zod.values),_t(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Lx=G("$ZodNullable",(e,t)=>{Wt.init(e,t),_t(e,"optin",n=>n.def.innerType._zod.optin),_t(e,"optout",n=>n.def.innerType._zod.optout),_t(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${da(i.source)}|null)$`):void 0}),_t(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),Rx=G("$ZodDefault",(e,t)=>{Wt.init(e,t),e._zod.optin="defaulted",_t(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>s5(o,t)):s5(r,t)}});function s5(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Nx=G("$ZodPrefault",(e,t)=>{Wt.init(e,t),e._zod.optin="defaulted",_t(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),Xx=G("$ZodNonOptional",(e,t)=>{Wt.init(e,t),_t(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>c5(o,e)):c5(r,e)}});function c5(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var jx=G("$ZodSuccess",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Qa("ZodSuccess");let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.issues.length===0,n)):(n.value=r.issues.length===0,n)}});function l5(e,t,n,i){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(r=>ji(r,i,kr()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Fx=G("$ZodCatch",(e,t)=>{Wt.init(e,t),_t(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_t(e,"optout",n=>n.def.innerType._zod.optout),_t(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(o=>l5(n,o,t,i)):l5(n,r,t,i)}}),Ix=G("$ZodNaN",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),$h=G("$ZodPipe",(e,t)=>{Wt.init(e,t),_t(e,"values",n=>n.def.in._zod.values),_t(e,"optin",n=>n.def.in._zod.optin),_t(e,"optout",n=>n.def.out._zod.optout),_t(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(a=>Ih(a,t.in,i)):Ih(o,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>Ih(o,t.out,i)):Ih(r,t.out,i)}});function Ih(e,t,n){return e.issues.some(i=>i.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var fd=G("$ZodCodec",(e,t)=>{Wt.init(e,t),_t(e,"values",n=>n.def.in._zod.values),_t(e,"optin",n=>n.def.in._zod.optin),_t(e,"optout",n=>n.def.out._zod.optout),_t(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if((i.direction||"forward")==="forward"){let o=t.in._zod.run(n,i);return o instanceof Promise?o.then(a=>Eh(a,t,i)):Eh(o,t,i)}else{let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(a=>Eh(a,t,i)):Eh(o,t,i)}}});function Eh(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(o=>Vh(e,o,t.out,n)):Vh(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(o=>Vh(e,o,t.in,n)):Vh(e,r,t.in,n)}}function Vh(e,t,n,i){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},i)}var Ex=G("$ZodPreprocess",(e,t)=>{$h.init(e,t)}),Vx=G("$ZodReadonly",(e,t)=>{Wt.init(e,t),_t(e,"propValues",n=>n.def.innerType._zod.propValues),_t(e,"values",n=>n.def.innerType._zod.values),_t(e,"optin",n=>n.def.innerType?._zod?.optin),_t(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(u5):u5(r)}});function u5(e){return e.memo||(e.value=Object.freeze(e.value)),e}function sG(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,o;for(let s of t.checks??[]){let c=s._zod.def;c.pattern&&(n=c.pattern),i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;l!==void 0&&(r===void 0||l>r)&&(r=l),u!==void 0&&(o===void 0||u<o)&&(o=u)}if(n)return n.source;if(r!==void 0&&o!==void 0&&r>o)return"(?!)";if(r!==void 0||o!==void 0)return $1({minimum:r,maximum:o}).source;let a=e._zod.pattern;return(i&&a===ma?td:a)?.source}function Lw(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,o=Lw(i);return n&&r&&o&&o!==r?n.replace(da(r),()=>da(o)):n}if(t.options){let r=t.options.map(Lw);if(r.every(Boolean))return`^(${r.map(o=>da(o)).join("|")})$`}return sG(e)}var Wx=G("$ZodTemplateLiteral",(e,t)=>{Wt.init(e,t);let n=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){let r=Lw(i);if(!r)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(da(r))}else if(i===null||m1.has(typeof i))n.push(_i(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),Hx=G("$ZodFunction",(e,t)=>(Wt.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...i){let r=e._def.input?yh(e._def.input,i):i,o=Reflect.apply(n,this,r);return e._def.output?yh(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...i){let r=e._def.input?await wh(e._def.input,i):i,o=await Reflect.apply(n,this,r);return e._def.output?await wh(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,i)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let i=e.constructor;return Array.isArray(n[0])?new i({type:"function",input:new Qh({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new i({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:n})},e)),Zx=G("$ZodPromise",(e,t)=>{Wt.init(e,t),e._zod.parse=(n,i)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},i))}),dd=G("$ZodLazy",(e,t)=>{Wt.init(e,t),u1(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),_t(e,"pattern",n=>n.innerType?._zod?.pattern),_t(e,"propValues",n=>n.innerType?._zod?.propValues),_t(e,"optin",n=>n.innerType?._zod?.optin??void 0),_t(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,i)=>e._zod.innerType._zod.run(n,i)}),Dx=G("$ZodCustom",(e,t)=>{_n.init(e,t),Wt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>f5(o,n,i,e));f5(r,n,i,e)}});function f5(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(Pl(r))}}var rb=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},Ux="~memo",y5=[];function w5(e){return e!==null&&typeof e=="object"}function qx(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var x5=new WeakMap,Ll=0,nb=1,md=2;function pd(e,t,n){let i=x5.get(e);if(i!==void 0)return i?md:Ll;if(t.has(e))return md;t.add(e);let r=Ll,o=u=>{if(r!==md&&u?._zod){let f=pd(u,t,n);f>r&&(r=f)}},a=(u,f)=>{let d=Ll;for(let m of Reflect.ownKeys(u)){let p=Object.getOwnPropertyDescriptor(u,m);if(f&&!p.enumerable)continue;let h=p.get?nb:p.value?._zod?pd(p.value,t,n):Ll;h>d&&(d=h)}return d},s=u=>{u>r&&(r=u)},c=e._zod.def,l=c.type;switch(l){case"object":{let u=xl(c);s(u?a(u,!0):nb),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);s(u?pd(u,t,!1):nb);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let d=f.value;if(!(!d||typeof d!="object")){if(d._zod)o(d);else if(Array.isArray(d))for(let m of d)o(m)}}}return t.delete(e),cG(e,r)}function cG(e,t){return t!==nb&&x5.set(e,t===md),t}function ib(e){return pd(e,new Set,!0)!==Ll}function lG(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var eb,tb=[],uG={alloc(e,t,n){let i=eb;if(!i)return n;eb=void 0;let r={value:n,issues:null};return i.set(t.value,r),tb.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,o)=>{if(o.direction!=="backward"&&ob(o,r.value))throw new rb;return n(r,o)};e._zod.parse=i,e._zod.run===n&&(e._zod.run=i)})},attach(e){var t;let n,i=!1,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,s=(c,l)=>{if(n===void 0){let v=pd(e,new Set,!1);if(v===Ll)return e._zod.parse=a,e._zod.run===s&&(e._zod.run=a),a(c,l);v===md||i?n=!0:i=!0}let u=c.value;if(!w5(u))return a(c,l);let f=l[Ux];f||(f={buckets:new WeakMap,backEdges:void 0},l[Ux]=f);let d;r===l?d=o:(d=lG(f,e),r=l,o=d);let m=d.get(u);if(m)return c.value=m.value,m.issues?m.issues.length&&c.issues.push(...qx(m.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(m.value)),c;eb=d;let p=tb.length,h=a(c,l);eb=void 0;let b=tb.length>p?tb.pop():void 0;return h instanceof Promise?h.then(v=>(b&&(b.issues=v.issues.length?qx(v.issues):y5),v)):(b&&(b.issues=h.issues.length?qx(h.issues):y5),h)};e._zod.parse=s,e._zod.run===a&&(e._zod.run=s)})}};function hd(){return uG}function ob(e,t){let n=e[Ux]?.backEdges;return n!==void 0&&w5(t)&&n.has(t)}var gd={};ra(gd,{ar:()=>P5,az:()=>k5,be:()=>T5,bg:()=>z5,bn:()=>O5,ca:()=>M5,ckb:()=>L5,cs:()=>R5,da:()=>N5,de:()=>X5,el:()=>j5,en:()=>ab,eo:()=>F5,es:()=>I5,fa:()=>E5,fi:()=>V5,fr:()=>W5,frCA:()=>H5,gu:()=>Z5,he:()=>D5,hi:()=>q5,hr:()=>U5,hu:()=>C5,hy:()=>K5,id:()=>G5,is:()=>A5,it:()=>B5,ja:()=>Y5,ka:()=>Q5,kh:()=>_5,km:()=>sb,kn:()=>$5,ko:()=>eO,lt:()=>nO,mk:()=>rO,ms:()=>iO,ne:()=>oO,nl:()=>aO,nn:()=>sO,no:()=>cO,ota:()=>lO,pl:()=>fO,ps:()=>uO,pt:()=>dO,ptBR:()=>mO,ro:()=>pO,ru:()=>bO,sk:()=>gO,sl:()=>vO,sv:()=>yO,ta:()=>wO,tg:()=>xO,th:()=>PO,tk:()=>kO,tr:()=>SO,ua:()=>TO,uk:()=>cb,ur:()=>zO,uz:()=>OO,vi:()=>MO,yo:()=>NO,zhCN:()=>LO,zhTW:()=>RO});var fG=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},map:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",mac:"\u0639\u0646\u0648\u0627\u0646 MAC",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",credit_card:"\u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0627\u0626\u062A\u0645\u0627\u0646",currency_code:"\u0631\u0645\u0632 \u0627\u0644\u0639\u0645\u0644\u0629",iban:"IBAN",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${we(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${n[o.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${A(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function P5(){return{localeError:fG()}}var dG=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"},map:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"kredit kart\u0131 n\xF6mr\u0259si",currency_code:"valyuta kodu",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${r.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${s}`}case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${we(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[o.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function k5(){return{localeError:dG()}}function S5(e,t,n,i){let r=Math.abs(e),o=r%10,a=r%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?n:i}var mG=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",mac:"MAC \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",credit_card:"\u043D\u0443\u043C\u0430\u0440 \u043A\u0440\u044D\u0434\u044B\u0442\u043D\u0430\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${we(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=S5(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${r.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=S5(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${r.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${A(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function T5(){return{localeError:mG()}}var pG=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${we(r.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.minimum.toString()} ${a.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${r.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u043E\u0432\u0435":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function z5(){return{localeError:pG()}}var hG=()=>{let e={string:{unit:"\u0985\u0995\u09CD\u09B7\u09B0",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},file:{unit:"\u09AC\u09BE\u0987\u099F",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},array:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},set:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},map:{unit:"\u098F\u09A8\u09CD\u099F\u09CD\u09B0\u09BF",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"}};function t(r){return e[r]??null}let n={regex:"\u0987\u09A8\u09AA\u09C1\u099F",email:"\u0987\u09AE\u09C7\u0987\u09B2 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",url:"URL",emoji:"\u0987\u09AE\u09CB\u099C\u09BF",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u09A4\u09BE\u09B0\u09BF\u0996 \u0993 \u09B8\u09AE\u09AF\u09BC",date:"ISO \u09A4\u09BE\u09B0\u09BF\u0996",time:"ISO \u09B8\u09AE\u09AF\u09BC",duration:"ISO \u09B8\u09AE\u09AF\u09BC\u0995\u09BE\u09B2",ipv4:"IPv4 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",ipv6:"IPv6 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",mac:"MAC \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",cidrv4:"IPv4 \u09B0\u09C7\u099E\u09CD\u099C",cidrv6:"IPv6 \u09B0\u09C7\u099E\u09CD\u099C",base64:"base64-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",base64url:"base64url-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",json_string:"JSON \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",e164:"E.164 \u09A8\u09AE\u09CD\u09AC\u09B0",credit_card:"\u0995\u09CD\u09B0\u09C7\u09A1\u09BF\u099F \u0995\u09BE\u09B0\u09CD\u09A1 \u09A8\u09AE\u09CD\u09AC\u09B0",currency_code:"\u09AE\u09C1\u09A6\u09CD\u09B0\u09BE \u0995\u09CB\u09A1",iban:"IBAN",jwt:"JWT",template_literal:"\u0987\u09A8\u09AA\u09C1\u099F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${o}, \u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4 ${s}`}case"invalid_value":return r.values.length===1?`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${we(r.values[0])}`:`\u0985\u09AC\u09C8\u09A7 \u0985\u09AA\u09B6\u09A8: ${A(r.values," | ")} \u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7 \u098F\u0995\u099F\u09BF \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${o}${r.maximum.toString()} ${a.unit??"\u098F\u09B2\u09BF\u09AE\u09C7\u09A8\u09CD\u099F"} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${o}${r.maximum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${o}${r.minimum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.prefix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C1\u09B0\u09C1 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="ends_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.suffix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C7\u09B7 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="includes"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.includes}" \u0985\u09A8\u09CD\u09A4\u09B0\u09CD\u09AD\u09C1\u0995\u09CD\u09A4 \u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="regex"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: ${o.pattern} \u09AA\u09CD\u09AF\u09BE\u099F\u09BE\u09B0\u09CD\u09A8 \u09AE\u09BF\u09B2\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09AC\u09C8\u09A7 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0985\u09AC\u09C8\u09A7 \u09A8\u09AE\u09CD\u09AC\u09B0: ${r.divisor} \u098F\u09B0 \u0997\u09C1\u09A3\u09BF\u09A4\u0995 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`;case"unrecognized_keys":return`\u0985\u099A\u09C7\u09A8\u09BE \u0995\u09C0${r.keys.length>1?"\u0997\u09C1\u09B2\u09CB":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u0995\u09C0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0985\u09AC\u09C8\u09A7 \u09A1\u09BF\u09B8\u0995\u09CD\u09B0\u09BF\u09AE\u09BF\u09A8\u09C7\u099F\u09B0 \u09AE\u09BE\u09A8\u0964 \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F";case"invalid_element":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u09AE\u09BE\u09A8`;default:return"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F"}}};function O5(){return{localeError:hG()}}var bG=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"},map:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",mac:"adre\xE7a MAC",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de targeta de cr\xE8dit",currency_code:"codi de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${r.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${s}`}case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${we(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${A(r.values," o ")}`;case"too_big":{let o=r.inclusive?"com a m\xE0xim":"menys de",a=t(r.origin);return a?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${o} ${r.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(r.origin);return a?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${o} ${r.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}};function M5(){return{localeError:bG()}}var gG=()=>{let e={string:{unit:"\u067E\u06CC\u062A",verb:"\u0628\u06CE\u062A"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u0628\u06CE\u062A"},array:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},set:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},map:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"}};function t(r){return e[r]??null}let n={regex:"regex",email:"\u0626\u06CC\u0645\u06D5\u06CC\u06B5",url:"\u0628\u06D5\u0633\u062A\u06D5\u0631 (URL)",emoji:"\u0626\u06CC\u0645\u06C6\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0695\u06CE\u06A9\u06D5\u0648\u062A \u0648 \u06A9\u0627\u062A",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",time:"\u06A9\u0627\u062A",duration:"\u0645\u0627\u0648\u06D5",ipv4:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv4",ipv6:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv6",mac:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC MAC",cidrv4:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv4",cidrv6:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv6",base64:"\u062F\u06D5\u0642\u06CC base64",base64url:"\u062F\u06D5\u0642\u06CC base64url",json_string:"\u062F\u06D5\u0642\u06CC JSON",e164:"\u0698\u0645\u0627\u0631\u06D5\u06CC E.164",credit_card:"\u0698\u0645\u0627\u0631\u06D5\u06CC \u06A9\u0627\u0631\u062A\u06CC \u06A9\u0631\u06CE\u062F\u06CC\u062A",currency_code:"\u06A9\u06C6\u062F\u06CC \u062F\u0631\u0627\u0648",iban:"IBAN",jwt:"JWT",template_literal:"\u062A\u06CE\u06A9\u0631\u062F\u06D5"},i={nan:"NaN",string:"\u0646\u0648\u0648\u0633\u06CC\u0646",number:"\u0698\u0645\u0627\u0631\u06D5",boolean:"boolean",array:"array",object:"object",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",integer:"\u0698\u0645\u0627\u0631\u06D5",float:"\u0698\u0645\u0627\u0631\u06D5",null:"null",undefined:"undefined",function:"function",symbol:"symbol",unknown:"unknown",promise:"promise",void:"void",never:"never",map:"map",set:"set"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a,c=["\u0627","\u0648","\u06C6","\u0648\u0648","\u06D5","\u06CC","\u06CE"].some(u=>s.endsWith(u))?"\u06CC\u06D5":"\u06D5",l=/^[a-zA-Z]+$/.test(s);return a==="null"||a==="undefined"?"\u062F\u0627\u0648\u0627\u06A9\u0631\u0627\u0648\u06D5":`\u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${o} \u0628\u06CE\u062A\u060C \u0628\u06D5\u06B5\u0627\u0645 ${s}${l?"":c}`}case"invalid_value":return r.values.length===1?`\u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0648\u0633\u062A\u06D5: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${we(r.values[0])} \u0628\u06CE\u062A`:`\u0647\u06D5\u06B5\u0628\u0698\u0627\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 \u06CC\u06D5\u06A9\u06CE\u06A9 \u0628\u06CE\u062A \u0644\u06D5 ${A(r.values,"|")}`;case"too_big":{let o=t(r.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} \u0628\u06CE\u062A`}case"too_small":{let o=t(r.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} \u0628\u06CE\u062A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u062F\u06D5\u0633\u062A\u067E\u06CE\u0628\u06A9\u0627\u062A \u0628\u06D5 "${o.prefix}"`:o.format==="ends_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u06A9\u06C6\u062A\u0627\u06CC\u06CC\u0628\u06CE\u062A \u0628\u06D5 "${o.suffix}"`:o.format==="includes"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 "${o.includes}" \u0644\u06D5\u062E\u06C6\u0628\u06AF\u0631\u06CE\u062A`:o.format==="regex"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0644\u06D5\u06AF\u06D5\u06B5 \u067E\u0627\u062A\u06CE\u0631\u0646\u06CC ${o.pattern} \u0628\u06AF\u0648\u0646\u062C\u06CE\u062A`:`\u0628\u06D5\u0647\u0627\u06CC ${n[o.format]??r.format} \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`}case"not_multiple_of":return`\u0698\u0645\u0627\u0631\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u062F\u06D5\u0628\u06CE\u062A \u0686\u06D5\u0646\u062F \u0647\u06CE\u0646\u062F\u06D5 \u0628\u06CE\u062A \u0628\u06C6 ${r.divisor}`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648: ${A(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A \u0644\u06D5 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0628\u06D5\u0647\u0627\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648 \u0647\u06D5\u06CC\u06D5. \u0628\u06D5\u0647\u0627\u06CC \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648: ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u06CC\u06D5\u06A9\u06AF\u0631\u062A\u0646\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A";case"invalid_element":return`${r.origin} \u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`;default:return"\u062A\u06CE\u06A9\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A"}}};function L5(){return{localeError:gG()}}var vG=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"},map:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditn\xED karty",currency_code:"k\xF3d m\u011Bny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${r.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${s}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${we(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${A(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function R5(){return{localeError:vG()}}var yG=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"},map:{unit:"elementer",verb:"indeholdt"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kreditkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldigt input: forventede instanceof ${r.expected}, fik ${s}`:`Ugyldigt input: forventede ${o}, fik ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig v\xE6rdi: forventede ${we(r.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`For stor: forventede ${s??"value"} ${a.verb} ${o} ${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`For lille: forventede ${s} ${a.verb} ${o} ${r.minimum.toString()} ${a.unit}`:`For lille: forventede ${s} havde ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${A(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${r.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${r.origin}`;default:return"Ugyldigt input"}}};function N5(){return{localeError:yG()}}var wG=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"},map:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",mac:"MAC-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",credit_card:"Kreditkartennummer",currency_code:"W\xE4hrungscode",iban:"IBAN",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${r.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${s}`}case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${we(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ist`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ist`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${A(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}};function X5(){return{localeError:wG()}}var xG=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(r){return e[r]??null}let n={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",credit_card:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 \u03C0\u03B9\u03C3\u03C4\u03C9\u03C4\u03B9\u03BA\u03AE\u03C2 \u03BA\u03AC\u03C1\u03C4\u03B1\u03C2",currency_code:"\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2 \u03BD\u03BF\u03BC\u03AF\u03C3\u03BC\u03B1\u03C4\u03BF\u03C2",iban:"IBAN",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return typeof r.expected=="string"&&/^[A-Z]/.test(r.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${r.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return r.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${we(r.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${r.maximum.toString()} ${a.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${r.minimum.toString()} ${a.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${o.prefix}"`:o.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${o.suffix}"`:o.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${o.includes}"`:o.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${r.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${r.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${r.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${A(r.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${r.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${r.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function j5(){return{localeError:xG()}}var PG=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(o,a){return o==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):i[o]??o}return o=>{switch(o.code){case"invalid_type":{let a=r(o.expected),s=Pe(o.input),c=r(s,o.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${we(o.values[0])}`:`Invalid option: expected one of ${A(o.values,"|")}`;case"too_big":{let a=o.exact?"exactly ":o.inclusive?"<=":"<",s=t(o.origin);return s?`Too big: expected ${o.origin??"value"} to have ${a}${o.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${a}${o.maximum.toString()}`}case"too_small":{let a=o.exact?"exactly ":o.inclusive?">=":">",s=t(o.origin);return s?`Too small: expected ${o.origin} to have ${a}${o.minimum.toString()} ${s.unit}`:`Too small: expected ${o.origin} to be ${a}${o.minimum.toString()}`}case"invalid_format":{let a=o;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${A(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(s=>`'${s}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function ab(){return{localeError:PG()}}var kG=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"},map:{unit:"elementojn",verb:"havi"}};function t(r){return e[r]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",mac:"MAC-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",credit_card:"kreditkarta numero",currency_code:"valuta kodo",iban:"IBAN",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${r.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${s}`}case"invalid_value":return r.values.length===1?`Nevalida enigo: atendi\u011Dis ${we(r.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Tro malgranda: atendi\u011Dis ke ${r.origin} havu ${o}${r.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${r.origin} estu ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${n[o.format]??r.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${r.divisor}`;case"unrecognized_keys":return`Nekonata${r.keys.length>1?"j":""} \u015Dlosilo${r.keys.length>1?"j":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${r.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${r.origin}`;default:return"Nevalida enigo"}}};function F5(){return{localeError:kG()}}var SG=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",mac:"direcci\xF3n MAC",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de tarjeta de cr\xE9dito",currency_code:"c\xF3digo de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${r.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${s}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${we(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${o}${r.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${o}${r.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[r.origin]??r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[r.origin]??r.origin}`;default:return"Entrada inv\xE1lida"}}};function I5(){return{localeError:SG()}}var TG=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},map:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",mac:"MAC \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",credit_card:"\u0634\u0645\u0627\u0631\u0647 \u06A9\u0627\u0631\u062A \u0627\u0639\u062A\u0628\u0627\u0631\u06CC",currency_code:"\u06A9\u062F \u0627\u0631\u0632",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${we(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${A(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[o.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${A(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function E5(){return{localeError:TG()}}var zG=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},map:{unit:"alkiota",subject:"kuvauksen"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",mac:"MAC-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",credit_card:"luottokortin numero",currency_code:"valuuttakoodi",iban:"IBAN",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Virheellinen tyyppi: odotettiin instanceof ${r.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${s}`}case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${we(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${o}${r.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${o}${r.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${n[o.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${A(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function V5(){return{localeError:zG()}}var OG=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"expression r\xE9guli\xE8re",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne de caract\xE8res encod\xE9e en base64",base64url:"cha\xEEne de caract\xE8res encod\xE9e en base64url",json_string:"cha\xEEne de caract\xE8res JSON",e164:"num\xE9ro au format E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne de caract\xE8res",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"record",map:"map",set:"ensemble",file:"fichier",nonoptional:"non optionnel",nan:"NaN",function:"fonction"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : instance de ${r.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${s} re\xE7u`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${we(r.values[0])} attendu`:`Option invalide : une valeur parmi ${A(r.values,"|")} attendue`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Trop grand : ${i[r.origin]??"valeur"} doit ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[r.origin]??"valeur"} doit \xEAtre ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Trop petit : ${i[r.origin]??"valeur"} doit ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Trop petit : ${i[r.origin]??"valeur"} doit \xEAtre ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne de caract\xE8res invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne de caract\xE8res invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne de caract\xE8res invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne de caract\xE8res invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${A(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function W5(){return{localeError:OG()}}var MG=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"},map:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : attendu instanceof ${r.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${s}`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${we(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u2264":"<",a=t(r.origin);return a?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${o}${r.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u2265":">",a=t(r.origin);return a?`Trop petit : attendu que ${r.origin} ait ${o}${r.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${r.origin} soit ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${A(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function H5(){return{localeError:MG()}}var LG=()=>{let e={string:{unit:"\u0A85\u0A95\u0ACD\u0AB7\u0AB0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},file:{unit:"\u0AAC\u0ABE\u0AAF\u0A9F",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},array:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},set:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},map:{unit:"\u0A8F\u0AA8\u0ACD\u0A9F\u0ACD\u0AB0\u0AC0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"}};function t(r){return e[r]??null}let n={regex:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F",email:"\u0A88\u0AAE\u0AC7\u0A87\u0AB2 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",url:"URL",emoji:"\u0A87\u0AAE\u0ACB\u0A9C\u0AC0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96 \u0A85\u0AA8\u0AC7 \u0AB8\u0AAE\u0AAF",date:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96",time:"ISO \u0AB8\u0AAE\u0AAF",duration:"ISO \u0A85\u0AB5\u0AA7\u0ABF",ipv4:"IPv4 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",ipv6:"IPv6 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",mac:"MAC \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",cidrv4:"IPv4 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",cidrv6:"IPv6 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",base64:"base64-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",base64url:"base64url-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",json_string:"JSON \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",e164:"E.164 \u0AA8\u0A82\u0AAC\u0AB0",credit_card:"\u0A95\u0ACD\u0AB0\u0AC7\u0AA1\u0ABF\u0A9F \u0A95\u0ABE\u0AB0\u0ACD\u0AA1 \u0AA8\u0A82\u0AAC\u0AB0",currency_code:"\u0A9A\u0AB2\u0AA3 \u0A95\u0ACB\u0AA1",iban:"IBAN",jwt:"JWT",template_literal:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${o}, \u0AAA\u0ACD\u0AB0\u0ABE\u0AAA\u0ACD\u0AA4 ${s}`}case"invalid_value":return r.values.length===1?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${we(r.values[0])}`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB5\u0ABF\u0A95\u0AB2\u0ACD\u0AAA: ${A(r.values," | ")} \u0AAE\u0ABE\u0AA7\u0ACD\u0AAF\u0AAE\u0AA5\u0AC0 \u0A8F\u0A95 \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${r.maximum.toString()} ${a.unit??"\u0A8F\u0AB2\u0ABF\u0AAE\u0AC7\u0AA8\u0ACD\u0A9F"} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${r.maximum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${o}${r.minimum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.prefix}" \u0AA5\u0AC0 \u0AB6\u0AB0\u0AC2 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="ends_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.suffix}" \u0AAA\u0AB0 \u0AB8\u0AAE\u0ABE\u0AAA\u0ACD\u0AA4 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="includes"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.includes}" \u0AB6\u0ABE\u0AAE\u0AC7\u0AB2 \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="regex"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: \u0AAA\u0AC7\u0A9F\u0AB0\u0ACD\u0AA8 ${o.pattern} \u0AB8\u0ABE\u0AA5\u0AC7 \u0AAE\u0AC7\u0AB3 \u0A96\u0ABE\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA8\u0A82\u0AAC\u0AB0: ${r.divisor} \u0AA8\u0ACB \u0A97\u0AC1\u0AA3\u0ABE\u0A82\u0A95 \u0AB9\u0ACB\u0AB5\u0ACB \u0A9C\u0ACB\u0A88\u0A8F`;case"unrecognized_keys":return`\u0A93\u0AB3\u0A96\u0AC0 \u0AB6\u0A95\u0ABE\u0AA4\u0ABE \u0AA8\u0AB9\u0AC0\u0A82 \u0AA4\u0AC7 \u0A95\u0AC0${r.keys.length>1?"\u0A93":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A95\u0AC0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA1\u0ABF\u0AB8\u0ACD\u0A95\u0ACD\u0AB0\u0ABF\u0AAE\u0ABF\u0AA8\u0AC7\u0A9F\u0AB0 \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF. \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F";case"invalid_element":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF`;default:return"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F"}}};function Z5(){return{localeError:LG()}}var RG=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},n=l=>l?e[l]:void 0,i=l=>{let u=n(l);return u?u.label:l??e.unknown.label},r=l=>`\u05D4${i(l)}`,o=l=>(n(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",a=l=>l?t[l]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},uuidv4:{label:"UUIDv4",gender:"m"},uuidv6:{label:"UUIDv6",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},mac:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA MAC",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},credit_card:{label:"\u05DE\u05E1\u05E4\u05E8 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05E9\u05E8\u05D0\u05D9",gender:"m"},currency_code:{label:"\u05E7\u05D5\u05D3 \u05DE\u05D8\u05D1\u05E2",gender:"m"},iban:{label:"IBAN",gender:"m"},jwt:{label:"JWT",gender:"m"},template_literal:{label:"\u05E7\u05DC\u05D8",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,f=c[u??""]??i(u),d=Pe(l.input),m=c[d]??e[d]?.label??d;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${we(l.values[0])}`;let u=l.values.map(m=>we(m));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let f=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${f}`}case"too_big":{let u=a(l.origin),f=r(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let d=l.inclusive?"<=":"<",m=o(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.maximum.toString()}`}case"too_small":{let u=a(l.origin),f=r(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let b=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${b}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let d=l.inclusive?">=":">",m=o(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let f=s[u.format],d=f?.label??u.format,p=(f?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${d} \u05DC\u05D0 ${p}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${A(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function D5(){return{localeError:RG()}}var NG=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},file:{unit:"\u092C\u093E\u0907\u091F\u094D\u0938",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F\u092F\u093E\u0901",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0924\u093F\u0925\u093F \u0914\u0930 \u0938\u092E\u092F",date:"ISO \u0924\u093F\u0925\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u092A\u0924\u093E",ipv6:"IPv6 \u092A\u0924\u093E",mac:"MAC \u092A\u0924\u093E",cidrv4:"IPv4 \u0936\u094D\u0930\u0947\u0923\u0940",cidrv6:"IPv6 \u0936\u094D\u0930\u0947\u0923\u0940",base64:"Base64-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",base64url:"Base64URL-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",e164:"E.164 \u0938\u0902\u0916\u094D\u092F\u093E",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0938\u0902\u0916\u094D\u092F\u093E",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${we(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u094B\u0902 \u092E\u0947\u0902 \u0938\u0947 \u090F\u0915 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} \u092E\u0947\u0902 ${o}${r.maximum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} ${o}${r.maximum} \u0939\u094B`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} \u092E\u0947\u0902 ${o}${r.minimum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} ${o}${r.minimum} \u0939\u094B`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.prefix}" \u0938\u0947 \u0936\u0941\u0930\u0942 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.suffix}" \u092A\u0930 \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u0907\u0938\u092E\u0947\u0902 "${o.includes}" \u0936\u093E\u092E\u093F\u0932 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u092A\u0948\u091F\u0930\u094D\u0928 ${o.pattern} \u0938\u0947 \u092E\u0947\u0932 \u0916\u093E\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: \u092F\u0939 ${r.divisor} \u0915\u093E \u0917\u0941\u0923\u091C \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u0902\u091C\u0940${r.keys.length>1?"\u092F\u093E\u0901":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u0902\u091C\u0940: ${r.origin} \u092E\u0947\u0902`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u0947\u0902`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function q5(){return{localeError:NG()}}var XG=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(r){return e[r]??null}let n={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",credit_card:"broj kreditne kartice",currency_code:"kod valute",iban:"IBAN",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${r.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${s}`}case"invalid_value":return r.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${we(r.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${o}${r.maximum.toString()} ${a.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Premalo: o\u010Dekivano da ${s} ima ${o}${r.minimum.toString()} ${a.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${n[o.format]??r.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${r.divisor}`;case"unrecognized_keys":return`Neprepoznat${r.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${A(r.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[r.origin]??r.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[r.origin]??r.origin}`;default:return"Neispravan unos"}}};function U5(){return{localeError:XG()}}var jG=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"},map:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",mac:"MAC c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",credit_card:"hitelk\xE1rtyasz\xE1m",currency_code:"p\xE9nznemk\xF3d",iban:"IBAN",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${r.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${we(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${r.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${o}${r.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[o.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function C5(){return{localeError:jG()}}function J5(e,t,n){return Math.abs(e)===1?t:n}function Rl(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}var FG=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},map:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(r){return e[r]??null}let n={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",mac:"MAC \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",credit_card:"\u056F\u0580\u0565\u0564\u056B\u057F \u0584\u0561\u0580\u057F\u056B \u0570\u0561\u0574\u0561\u0580",currency_code:"\u0561\u0580\u056A\u0578\u0582\u0575\u0569\u056B \u056F\u0578\u0564",iban:"IBAN",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${r.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return r.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${we(r.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=J5(s,a.unit.one,a.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Rl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Rl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=J5(s,a.unit.one,a.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Rl(r.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Rl(r.origin)} \u056C\u056B\u0576\u056B ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[o.format]??r.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${r.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${r.keys.length>1?"\u0576\u0565\u0580":""}. ${A(r.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Rl(r.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Rl(r.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function K5(){return{localeError:FG()}}var IG=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"},map:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",credit_card:"nomor kartu kredit",currency_code:"kode mata uang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input tidak valid: diharapkan instanceof ${r.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${o}, diterima ${s}`}case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${we(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${o}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: diharapkan ${r.origin} memiliki ${o}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${n[o.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function G5(){return{localeError:IG()}}var EG=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"},map:{unit:"hluti",verb:"a\xF0 hafa"}};function t(r){return e[r]??null}let n={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",credit_card:"kreditkortan\xFAmer",currency_code:"gjaldmi\xF0ilsk\xF3\xF0i",iban:"IBAN",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${r.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return r.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${we(r.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} hafi ${o}${r.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} s\xE9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} hafi ${o}${r.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} s\xE9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${n[o.format]??r.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${r.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${r.keys.length>1?"ir lyklar":"ur lykill"}: ${A(r.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${r.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${r.origin}`;default:return"Rangt gildi"}}};function A5(){return{localeError:EG()}}var VG=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"},map:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",mac:"indirizzo MAC",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",credit_card:"numero di carta di credito",currency_code:"codice valuta",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input non valido: atteso instanceof ${r.expected}, ricevuto ${s}`:`Input non valido: atteso ${o}, ricevuto ${s}`}case"invalid_value":return r.values.length===1?`Input non valido: atteso ${we(r.values[0])}`:`Opzione non valida: atteso uno tra ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Troppo grande: ${r.origin??"valore"} deve avere ${o}${r.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Troppo piccolo: ${r.origin} deve avere ${o}${r.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${r.origin} deve essere ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${n[o.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${A(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function B5(){return{localeError:VG()}}var WG=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},map:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",mac:"MAC\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",credit_card:"\u30AF\u30EC\u30B8\u30C3\u30C8\u30AB\u30FC\u30C9\u756A\u53F7",currency_code:"\u901A\u8CA8\u30B3\u30FC\u30C9",iban:"IBAN",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${we(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${A(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(r.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${a.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(r.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${a.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${A(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function Y5(){return{localeError:WG()}}var HG=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},map:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(r){return e[r]??null}let n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",mac:"MAC \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",credit_card:"\u10E1\u10D0\u10D9\u10E0\u10D4\u10D3\u10D8\u10E2\u10DD \u10D1\u10D0\u10E0\u10D0\u10D7\u10D8\u10E1 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",currency_code:"\u10D5\u10D0\u10DA\u10E3\u10E2\u10D8\u10E1 \u10D9\u10DD\u10D3\u10D8",iban:"IBAN",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${r.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return r.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${we(r.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${A(r.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${r.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${r.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${A(r.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${r.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${r.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function Q5(){return{localeError:HG()}}var ZG=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},map:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",mac:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 MAC",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",credit_card:"\u179B\u17C1\u1781\u1794\u17D0\u178E\u17D2\u178E\u17A5\u178E\u1791\u17B6\u1793",currency_code:"\u1780\u17BC\u178A\u179A\u17BC\u1794\u17B7\u1799\u1794\u17D0\u178E\u17D2\u178E",iban:"IBAN",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${we(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${A(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function sb(){return{localeError:ZG()}}function _5(){return sb()}var DG=()=>{let e={string:{unit:"\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},file:{unit:"\u0CAC\u0CC8\u0C9F\u0CCD\u200C\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},array:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},set:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},map:{unit:"entries",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"}};function t(r){return e[r]??null}let n={regex:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD",email:"email \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95\u0CA6 \u0CB8\u0CAE\u0CAF",date:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95",time:"ISO \u0CB8\u0CAE\u0CAF",duration:"ISO \u0C85\u0CB5\u0CA7\u0CBF",ipv4:"IPv4 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",ipv6:"IPv6 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",mac:"MAC \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",cidrv4:"IPv4 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",cidrv6:"IPv6 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",base64:"base64-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",base64url:"base64url-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",json_string:"JSON\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",e164:"E.164 \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",credit_card:"\u0C95\u0CCD\u0CB0\u0CC6\u0CA1\u0CBF\u0C9F\u0CCD \u0C95\u0CBE\u0CB0\u0CCD\u0CA1\u0CCD \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",currency_code:"\u0C95\u0CB0\u0CC6\u0CA8\u0CCD\u0CB8\u0CBF \u0C95\u0CCB\u0CA1\u0CCD",iban:"IBAN",jwt:"JWT",template_literal:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${o}, \u0CB8\u0CCD\u0CB5\u0CC0\u0C95\u0CB0\u0CBF\u0CB8\u0CBF\u0CA6\u0CA8\u0CC1 ${s}`}case"invalid_value":return r.values.length===1?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${we(r.values[0])}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C86\u0CAF\u0CCD\u0C95\u0CC6: \u0C87\u0CB5\u0CC1\u0C97\u0CB3\u0CB2\u0CCD\u0CB2\u0CBF \u0C92\u0C82\u0CA6\u0CA8\u0CCD\u0CA8\u0CC1 \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${r.maximum.toString()} ${a.unit??"\u0C85\u0C82\u0CB6\u0C97\u0CB3\u0CC1"}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${r.minimum.toString()} ${a.unit}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0CAA\u0CCD\u0CB0\u0CBE\u0CB0\u0C82\u0CAD\u0CBF\u0CB8\u0CAC\u0CC7\u0C95\u0CC1 "${o.prefix}"`:o.format==="ends_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0C95\u0CCA\u0CA8\u0CC6\u0C97\u0CCA\u0CB3\u0CCD\u0CB3\u0CAC\u0CC7\u0C95\u0CC1 "${o.suffix}"`:o.format==="includes"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C92\u0CB3\u0C97\u0CCA\u0C82\u0CA1\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 "${o.includes}"`:o.format==="regex"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0C97\u0CC6 \u0CB9\u0CCA\u0C82\u0CA6\u0CBF\u0C95\u0CC6\u0CAF\u0CBE\u0C97\u0CAC\u0CC7\u0C95\u0CC1 ${o.pattern}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6: \u0CAC\u0CB9\u0CC1\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CBE\u0C97\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 ${r.divisor}`;case"unrecognized_keys":return`\u0C97\u0CC1\u0CB0\u0CC1\u0CA4\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CA6 \u0C95\u0CC0 ${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0C95\u0CC0 \u0C87\u0CA8\u0CCD ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CA4\u0CBE\u0CB0\u0CA4\u0CAE\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF. \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD";case"invalid_element":return`\u0CB0\u0CB2\u0CCD\u0CB2\u0CBF \u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF ${r.origin}`;default:return"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD"}}};function $5(){return{localeError:DG()}}var qG=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"},map:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",mac:"MAC \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",credit_card:"\uC2E0\uC6A9\uCE74\uB4DC \uBC88\uD638",currency_code:"\uD1B5\uD654 \uCF54\uB4DC",iban:"IBAN",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${we(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${A(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),c=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${c} ${o}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${o}${a}`}case"too_small":{let o=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),c=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${c} ${o}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${o}${a}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[o.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${A(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function eO(){return{localeError:qG()}}var bd=e=>e.charAt(0).toUpperCase()+e.slice(1);function tO(e){let t=Math.abs(e),n=t%10,i=t%100;return i>=11&&i<=19||n===0?"many":n===1?"one":"few"}var UG=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(r,o,a,s){let c=e[r]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[s][a?"inclusive":"notInclusive"]}}let n={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",mac:"MAC adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",credit_card:"kredito kortel\u0117s numeris",currency_code:"valiutos kodas",iban:"IBAN",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${r.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${o}`}case"invalid_value":return r.values.length===1?`Privalo b\u016Bti ${we(r.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${A(r.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[r.origin]??r.origin,a=t(r.origin,tO(Number(r.maximum)),r.inclusive??!1,"smaller");if(a?.verb)return`${bd(o??r.origin??"reik\u0161m\u0117")} ${a.verb} ${r.maximum.toString()} ${a.unit??"element\u0173"}`;let s=r.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${bd(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${r.maximum.toString()} ${a?.unit}`}case"too_small":{let o=i[r.origin]??r.origin,a=t(r.origin,tO(Number(r.minimum)),r.inclusive??!1,"bigger");if(a?.verb)return`${bd(o??r.origin??"reik\u0161m\u0117")} ${a.verb} ${r.minimum.toString()} ${a.unit??"element\u0173"}`;let s=r.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${bd(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${r.minimum.toString()} ${a?.unit}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${n[o.format]??r.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${r.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${r.keys.length>1?"i":"as"} rakt${r.keys.length>1?"ai":"as"}: ${A(r.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[r.origin]??r.origin;return`${bd(o??r.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function nO(){return{localeError:UG()}}var CG=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},map:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",mac:"MAC \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",credit_card:"\u0431\u0440\u043E\u0458 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0438\u0447\u043A\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${we(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${A(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function rO(){return{localeError:CG()}}var JG=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"},map:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",credit_card:"nombor kad kredit",currency_code:"kod mata wang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input tidak sah: dijangka instanceof ${r.expected}, diterima ${s}`:`Input tidak sah: dijangka ${o}, diterima ${s}`}case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${we(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: dijangka ${r.origin??"nilai"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: dijangka ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${n[o.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${A(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function iO(){return{localeError:JG()}}var KG=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},file:{unit:"\u092C\u093E\u0907\u091F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0907\u092E\u0947\u0932 \u0920\u0947\u0917\u093E\u0928\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F",date:"ISO \u092E\u093F\u0924\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u0920\u0947\u0917\u093E\u0928\u093E",ipv6:"IPv6 \u0920\u0947\u0917\u093E\u0928\u093E",mac:"MAC \u0920\u0947\u0917\u093E\u0928\u093E",cidrv4:"IPv4 \u0926\u093E\u092F\u0930\u093E",cidrv6:"IPv6 \u0926\u093E\u092F\u0930\u093E",base64:"base64-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",base64url:"base64url-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0919",e164:"E.164 \u0928\u092E\u094D\u092C\u0930",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0928\u092E\u094D\u092C\u0930",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${we(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u0939\u0930\u0942 \u092E\u0927\u094D\u092F\u0947 \u090F\u0915 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} \u092E\u093E ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} ${o}${r.maximum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} \u092E\u093E ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} ${o}${r.minimum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.prefix}" \u092C\u093E\u091F \u0938\u0941\u0930\u0941 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.suffix}" \u092E\u093E \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.includes}" \u0938\u092E\u093E\u0935\u0947\u0936 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: \u0922\u093E\u0901\u091A\u093E ${o.pattern} \u0938\u0901\u0917 \u092E\u0947\u0932 \u0916\u093E\u0928\u0941\u092A\u0930\u094D\u091B`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: ${r.divisor} \u0915\u094B \u0917\u0941\u0923\u091C \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u091E\u094D\u091C\u0940${r.keys.length>1?"\u0939\u0930\u0942":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u091E\u094D\u091C\u0940: ${r.origin} \u092E\u093E`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u093E`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function oO(){return{localeError:KG()}}var GG=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"},map:{unit:"elementen",verb:"heeft"}};function t(r){return e[r]??null}let n={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",mac:"MAC-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",credit_card:"creditcardnummer",currency_code:"valutacode",iban:"IBAN",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ongeldige invoer: verwacht instanceof ${r.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${o}, ontving ${s}`}case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${we(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=r.origin==="date"?"laat":r.origin==="string"?"lang":"groot";return a?`Te ${s}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${s}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} is`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=r.origin==="date"?"vroeg":r.origin==="string"?"kort":"klein";return a?`Te ${s}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${s}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} is`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function aO(){return{localeError:GG()}}var AG=()=>{let e={string:{unit:"teikn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"element",verb:"\xE5 innehalde"},set:{unit:"element",verb:"\xE5 innehalde"},map:{unit:"element",verb:"\xE5 innehalde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varigheit",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkoda streng",base64url:"base64url-enkoda streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tal",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventa instanceof ${r.expected}, fekk ${s}`:`Ugyldig input: forventa ${o}, fekk ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventa ${we(r.values[0])}`:`Ugyldig val: forventa eitt av ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${a.unit??"element"}`:`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventa ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventa ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 slutte med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 innehalde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tal: m\xE5 vere eit multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjende n\xF8klar":"Ukjend n\xF8kkel"}: ${A(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function sO(){return{localeError:AG()}}var BG=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"},map:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventet instanceof ${r.expected}, fikk ${s}`:`Ugyldig input: forventet ${o}, fikk ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${we(r.values[0])}`:`Ugyldig valg: forventet en av ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${A(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function cO(){return{localeError:BG()}}var YG=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"},map:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",mac:"MAC ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",credit_card:"i'tib\xE2r kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`F\xE2sit giren: umulan instanceof ${r.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${s}`}case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${we(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=r;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[o.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function lO(){return{localeError:YG()}}var QG=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},map:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",mac:"\u062F MAC \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",credit_card:"\u062F \u06A9\u0631\u06CC\u0689\u06CC\u067C \u06A9\u0627\u0631\u062A \u0634\u0645\u06CC\u0631\u0647",currency_code:"\u062F \u0627\u0633\u0639\u0627\u0631\u0648 \u06A9\u0648\u0689",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${we(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${A(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[o.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${A(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function uO(){return{localeError:QG()}}var _G=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"},map:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",mac:"adres MAC",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",credit_card:"numer karty kredytowej",currency_code:"kod waluty",iban:"IBAN",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${r.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${s}`}case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${we(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[o.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${A(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function fO(){return{localeError:_G()}}var $G=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"o intervalo de endere\xE7os IPv4",cidrv6:"o intervalo de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tuplo",articles:i.masculine},record:{name:"registo",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"ficheiro",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=r[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=Pe(a.input),l=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${l}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${we(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${A(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Demasiado grande: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Demasiado grande: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Demasiado pequeno: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Demasiado pequeno: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar por "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar em "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${n[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${A(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function dO(){return{localeError:$G()}}var eA=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"a faixa de endere\xE7os IPv4",cidrv6:"a faixa de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tupla",articles:i.feminine},record:{name:"registro",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"arquivo",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=r[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=Pe(a.input),l=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${l}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${we(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${A(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Grande demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Grande demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Pequeno demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Pequeno demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${n[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${A(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function mO(){return{localeError:eA()}}var tA=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(r){return e[r]??null}let n={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",credit_card:"num\u0103r de card de credit",currency_code:"cod valutar",iban:"IBAN",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${s}`}case"invalid_value":return r.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${we(r.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} s\u0103 fie ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Prea mic: a\u0219teptat ca ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Prea mic: a\u0219teptat ca ${r.origin} s\u0103 fie ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${n[o.format]??r.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${r.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${A(r.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${r.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${r.origin}`;default:return"Intrare invalid\u0103"}}};function pO(){return{localeError:tA()}}function hO(e,t,n,i){let r=Math.abs(e),o=r%10,a=r%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?n:i}var nA=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${we(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=hO(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=hO(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function bO(){return{localeError:nA()}}var rA=()=>{let e={string:{unit:"znakov",verb:"ma\u0165"},file:{unit:"bajtov",verb:"ma\u0165"},array:{unit:"prvkov",verb:"ma\u0165"},set:{unit:"prvkov",verb:"ma\u0165"},map:{unit:"polo\u017Eiek",verb:"ma\u0165"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rny v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"d\xE1tum a \u010Das vo form\xE1te ISO",date:"d\xE1tum vo form\xE1te ISO",time:"\u010Das vo form\xE1te ISO",duration:"doba trvania ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64",base64url:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64url",json_string:"re\u0165azec vo form\xE1te JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditnej karty",currency_code:"k\xF3d meny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"re\u0165azec",function:"funkcia",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 instanceof ${r.expected}, obdr\u017Ean\xE9 ${s}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${o}, obdr\u017Ean\xE9 ${s}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${we(r.values[0])}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE1 jedna z hodn\xF4t ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${o}${r.maximum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${o}${r.minimum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD re\u0165azec: mus\xED za\u010D\xEDna\u0165 na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD re\u0165azec: mus\xED kon\u010Di\u0165 na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD re\u0165azec: mus\xED obsahova\u0165 "${o.includes}"`:o.format==="regex"?`Neplatn\xFD re\u0165azec: mus\xED zodpoveda\u0165 vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED by\u0165 n\xE1sobkom ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1me kl\xFA\u010De: ${A(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xFA\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function gO(){return{localeError:rA()}}var iA=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"},map:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",mac:"MAC naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",credit_card:"\u0161tevilka kreditne kartice",currency_code:"koda valute",iban:"IBAN",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${r.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${s}`}case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${we(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${o}${r.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${o}${r.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${n[o.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${A(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function vO(){return{localeError:iA()}}var oA=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"},map:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-adress",ipv6:"IPv6-adress",mac:"MAC-adress",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",credit_card:"kreditkortsnummer",currency_code:"valutakod",iban:"IBAN",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${r.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${s}`}case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${we(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${n[o.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${A(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function yO(){return{localeError:oA()}}var aA=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},map:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",mac:"MAC \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",credit_card:"\u0B95\u0B9F\u0BA9\u0BCD \u0B85\u0B9F\u0BCD\u0B9F\u0BC8 \u0B8E\u0BA3\u0BCD",currency_code:"\u0BA8\u0BBE\u0BA3\u0BAF\u0B95\u0BCD \u0B95\u0BC1\u0BB1\u0BBF\u0BAF\u0BC0\u0B9F\u0BC1",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${we(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${A(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} ${a.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function wO(){return{localeError:aA()}}var sA=()=>{let e={string:{unit:"\u0430\u043B\u043E\u043C\u0430\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},file:{unit:"\u0431\u0430\u0439\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},array:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},set:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},map:{unit:"\u0441\u0430\u0431\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0443\u0440\u0443\u0434",email:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",url:"URL",emoji:"\u044D\u043C\u043E\u04B7\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",date:"\u0441\u0430\u043D\u0430\u0438 ISO",time:"\u0432\u0430\u049B\u0442\u0438 ISO",duration:"\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",ipv4:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",ipv6:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",mac:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",cidrv4:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",cidrv6:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",base64:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",base64url:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",json_string:"\u0441\u0430\u0442\u0440\u0438 JSON",e164:"\u0440\u0430\u049B\u0430\u043C\u0438 E.164",credit_card:"\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",currency_code:"\u0440\u0430\u043C\u0437\u0438 \u0430\u0441\u044A\u043E\u0440",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0443\u0440\u0443\u0434"},i={nan:"NaN",number:"\u0440\u0430\u049B\u0430\u043C",string:"\u0441\u0430\u0442\u0440",array:"\u043C\u0430\u0441\u0441\u0438\u0432",object:"\u043E\u0431\u044A\u0435\u043A\u0442",date:"\u0441\u0430\u043D\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${o} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${s} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`}case"invalid_value":return r.values.length===1?`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${we(r.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:`\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${A(r.values,"|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${r.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${o}${r.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`:o.format==="ends_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`:o.format==="includes"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${o.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`:o.format==="regex"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${o.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`:`${n[o.format]??r.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`}case"not_multiple_of":return`\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${r.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;case"unrecognized_keys":return`\u041A\u0430\u043B\u0438\u0434${r.keys.length>1?"\u04B3\u043E\u0438":"\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${A(r.keys,", ")}`;case"invalid_key":return`\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${r.options.map(a=>`'${a}'`).join(" | ")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";case"invalid_element":return`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;default:return"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442"}}};function xO(){return{localeError:sA()}}var cA=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},map:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",mac:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 MAC",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",credit_card:"\u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E02\u0E1A\u0E31\u0E15\u0E23\u0E40\u0E04\u0E23\u0E14\u0E34\u0E15",currency_code:"\u0E23\u0E2B\u0E31\u0E2A\u0E2A\u0E01\u0E38\u0E25\u0E40\u0E07\u0E34\u0E19",iban:"IBAN",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${we(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${A(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function PO(){return{localeError:cA()}}var lA=()=>{let e={string:{unit:"simwol",verb:"bolmaly"},file:{unit:"ba\xFDt",verb:"bolmaly"},array:{unit:"elementler",verb:"bolmaly"},set:{unit:"elementler",verb:"bolmaly"},map:{unit:"elementler",verb:"bolmaly"}};function t(r){return e[r]??null}let n={regex:"giri\u015F",email:"e-po\xE7ta salgysy",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sene we wagt",date:"ISO sene",time:"ISO wagt",duration:"ISO wagt aralygy",ipv4:"IPv4 salgysy",ipv6:"IPv6 salgysy",mac:"MAC salgysy",cidrv4:"IPv4 aralygy",cidrv6:"IPv6 aralygy",base64:"base64 bilen \u015Fifrlenen setir",base64url:"base64url bilen \u015Fifrlenen setir",json_string:"JSON setiri",e164:"E.164 nomeri",credit_card:"kredit kartyny\u0148 nomeri",currency_code:"wal\xFDuta kody",iban:"IBAN",jwt:"JWT",template_literal:"\u015Fablon"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return`N\xE4dogry baha: gara\u015Fylan ${o} \xFDerine ${s} alyndy`}case"invalid_value":return r.values.length===1?`N\xE4dogry baha: ${we(r.values[0])} bolmaly`:`N\xE4dogry sa\xFDlaw: a\u015Fakdakylardan biri bolmaly: ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${o} ${r.maximum.toString()} ${a.unit??"element"}`:`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${o} ${r.minimum.toString()} ${a.unit}`:`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`N\xE4dogry setir: "${o.prefix}" bilen ba\u015Flamaly`:o.format==="ends_with"?`N\xE4dogry setir: "${o.suffix}" bilen gutarmaly`:o.format==="includes"?`N\xE4dogry setir: "${o.includes}" saklamaly`:o.format==="regex"?`N\xE4dogry setir: ${o.pattern} nusga la\xFDyk bolmaly`:`N\xE4dogry ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xE4dogry san: ${r.divisor} bilen galyndysyz b\xF6l\xFCnmeli`;case"unrecognized_keys":return`Tanalma\xFDan a\xE7ar${r.keys.length>1?"lar":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde n\xE4dogry a\xE7ar`;case"invalid_union":return"N\xE4dogry baha";case"invalid_element":return`${r.origin} i\xE7inde n\xE4dogry baha`;default:return"N\xE4dogry baha"}}};function kO(){return{localeError:lA()}}var uA=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},map:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(r){return e[r]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",mac:"MAC adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",credit_card:"kredi kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${r.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${s}`}case"invalid_value":return r.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${we(r.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[o.format]??r.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${r.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${r.keys.length>1?"lar":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${r.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function SO(){return{localeError:uA()}}var fA=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",mac:"\u0430\u0434\u0440\u0435\u0441\u0430 MAC",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0457 \u043A\u0430\u0440\u0442\u043A\u0438",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u0438",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${we(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${A(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function cb(){return{localeError:fA()}}function TO(){return cb()}var dA=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},map:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",mac:"\u0627\u06CC\u0645 \u0627\u06D2 \u0633\u06CC \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",credit_card:"\u06A9\u0631\u06CC\u0688\u0679 \u06A9\u0627\u0631\u0688 \u0646\u0645\u0628\u0631",currency_code:"\u06A9\u0631\u0646\u0633\u06CC \u06A9\u0648\u0688",iban:"IBAN",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${we(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${A(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${o}${r.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${o}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${A(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function zO(){return{localeError:dA()}}var mA=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(r){return e[r]??null}let n={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",credit_card:"kredit karta raqami",currency_code:"valyuta kodi",iban:"IBAN",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${r.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${s}`}case"invalid_value":return r.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${we(r.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[o.format]??r.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${r.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${r.keys.length>1?"lar":""}: ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${r.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function OO(){return{localeError:mA()}}var pA=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},map:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",mac:"\u0111\u1ECBa ch\u1EC9 MAC",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",credit_card:"s\u1ED1 th\u1EBB t\xEDn d\u1EE5ng",currency_code:"m\xE3 ti\u1EC1n t\u1EC7",iban:"IBAN",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${we(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${n[o.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${A(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function MO(){return{localeError:pA()}}var hA=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"},map:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",mac:"MAC\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",credit_card:"\u4FE1\u7528\u5361\u53F7",currency_code:"\u8D27\u5E01\u4EE3\u7801",iban:"IBAN",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${we(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${n[o.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${A(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function LO(){return{localeError:hA()}}var bA=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},map:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",mac:"MAC \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",credit_card:"\u4FE1\u7528\u5361\u865F",currency_code:"\u8CA8\u5E63\u4EE3\u78BC",iban:"IBAN",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${r.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${we(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${A(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function RO(){return{localeError:bA()}}var gA=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"},map:{unit:"nkan",verb:"n\xED"}};function t(r){return e[r]??null}let n={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",mac:"\xE0d\xEDr\u1EB9\u0301s\xEC MAC",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",credit_card:"n\u1ECDmba kaadi gbese",currency_code:"koodu ow\xF3",iban:"IBAN",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=Pe(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${r.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return r.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${we(r.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${A(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin??"iye"} ${a.verb} ${o}${r.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.maximum}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin} ${a.verb} ${o}${r.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.minimum}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${n[o.format]??r.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${r.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${A(r.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function NO(){return{localeError:gA()}}var XO,Cx=Symbol("ZodOutput"),Jx=Symbol("ZodInput"),lb=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let i={...this.get(n)??{}};delete i.id;let r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function ub(){return new lb}(XO=globalThis).__zod_globalRegistry??(XO.__zod_globalRegistry=ub());var $r=globalThis.__zod_globalRegistry;var xi=Symbol.for("zod.compile.invalid"),jO=Symbol.for("zod.compile.fallback"),ho=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},cn=class extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}};function yA(e,t){try{return db(e,{assertOnly:!0})}catch{return t}}function Bx(e,t){try{let n=db(e),i=fb(e,n);return i._zod.bag.validator=yA(e,n),i}catch(n){if(t?.strict)throw n;return e}}function fb(e,t){if(ib(e))throw new cn("a schema whose subtree contains a reference cycle");let n=Hn(e),i=e._zod.run,r=i.__originalRun??i,o=(a,s)=>{if(s?.async||s?.direction==="backward"||s?.skipChecks||s?.[jO]||s&&ob(s,a.value))return r(a,s);let c=t(a.value);return c!==xi?(a.value=c,a):(s&&(s[jO]=!0),r(a,s))};return o.__originalRun=r,n._zod.bag.fallbackRun=r,n._zod.bag.validator=t,n._zod.run=o,i.__originalRun||wA(n,e,t),n}function wA(e,t,n){let i=e,r=t;if(typeof r.safeParse=="function"){let o=r.safeParse;i.safeParse=(a,s)=>{let c=n(a);return c!==xi?{success:!0,data:c}:o(a,s)}}if(typeof r.parse=="function"){let o=r.parse;i.parse=(a,s)=>{let c=n(a);return c!==xi?c:o(a,s)}}}function db(e,t){let n=!0;try{n=ib(e)}catch{}if(n)throw new cn("a schema whose subtree contains a reference cycle");let i={constants:new Map,constantCounter:0,varCounter:0,definite:!0},r=new $s(["input"]),o=hr(r,i,e,"input",!t?.assertOnly);r.write(o===null?"return true;":`return ${o};`);let a=["INVALID",...i.constants.keys()],s=[xi,...i.constants.values()],c=r.content.join(`
72
- `),l=t?.debug?a.length>0?`// Constants: ${a.join(", ")}
73
- ${c}`:c:"",u=Function,f=`return (input) => {
74
- ${c}
75
- }`,d;try{d=new u(...a,f)(...s)}catch(m){throw new cn(`this schema (generated code failed to evaluate: ${m.message})`)}return t?.debug&&(d.code=l),d.definite=i.definite,d}function Nt(e,t){for(let[i,r]of e.constants)if(r===t)return i;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function rc(e,t){return e.definite=!1,Nt(e,t)}function Pt(e){return`v${e.varCounter++}`}function xA(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return xi;let i=n;return i.issues.length===0?i.value:xi}function ci(e,t,n,i,r=!0){let o=e.content.length,a=t.constants.size,s=t.constantCounter,c=t.varCounter;try{return hr(e,t,n,i,r)}catch(l){if(!(l instanceof cn)||!l.islandable)throw l;if(e.content.length=o,t.constants.size>a){let u=Array.from(t.constants.keys()).slice(a);for(let f of u)t.constants.delete(f)}return t.constantCounter=s,t.varCounter=c,PA(e,t,n,i)}}function PA(e,t,n,i){t.definite=!1;let r=Nt(t,n),o=Nt(t,xA),a=Pt(t);return e.write(`const ${a} = ${o}(${r}, ${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var kA=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function SA(e,t,n,i){let r=n._zod.def.checks;if(!r||r.length===0)return i;let o=i;for(let a of r){let s=a._zod.def;if(s.when&&!kA.has(s.check))throw new cn('check with a custom "when" condition');switch(s.check){case"greater_than":TA(e,t,s,o);break;case"less_than":zA(e,t,s,o);break;case"multiple_of":OA(e,t,s,o);break;case"number_format":HO(e,s,o);break;case"min_length":{let c=tc(s.minimum,"min_length"),l=Kx(e,t,o,`${o}.length >= ${c} && ${o}.length < ${s.minimum*2}`);e.write(`if (${l} < ${c}) return INVALID;`);break}case"max_length":{let c=tc(s.maximum,"max_length"),l=Kx(e,t,o,`${o}.length > ${c}`);e.write(`if (${l} > ${c}) return INVALID;`);break}case"length_equals":{let c=tc(s.length,"length_equals"),l=Kx(e,t,o,`${o}.length >= ${c} && ${o}.length <= ${s.length*2}`);e.write(`if (${l} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${tc(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${tc(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${tc(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=ZO(e,t,s,o);break;case"custom":o=jA(e,t,a,o);break;case"bigint_format":MA(e,s,o);break;case"mime_type":LA(e,t,s,o);break;case"property":NA(e,t,s,o);break;case"properties":RA(e,t,s,o);break;case"overwrite":{let c=Pt(t);XA(e,t,a,o,c),o=c;break}default:throw new cn(`check type ${s.check}`)}}return o}function Kx(e,t,n,i){let r=Nt(t,Qs),o=Pt(t);return e.write(`const ${o} = typeof ${n} === "string" && ${i} ? ${r}(${n}) : ${n}.length;`),o}function tc(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new cn(`${t} bound of type ${typeof e}`);return`${e}`}function WO(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new cn("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new cn("comparison check with Invalid Date bound");return Nt(e,t)}throw new cn(`comparison check bound of type ${typeof t}`)}function TA(e,t,n,i){let r=n.inclusive?"<":"<=";e.write(`if (${i} ${r} ${WO(t,n.value)}) return INVALID;`)}function zA(e,t,n,i){let r=n.inclusive?">":">=";e.write(`if (${i} ${r} ${WO(t,n.value)}) return INVALID;`)}function OA(e,t,n,i){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new cn("multiple_of check with a zero divisor");e.write(`if (${i} % ${n.value}n !== 0n) return INVALID;`)}else{let r=Nt(t,qf);e.write(`if (${r}(${i}, ${tc(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function HO(e,t,n){let i=t.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new cn(`number format ${i}`)}}function MA(e,t,n){let i=t.format;if(i)switch(i){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new cn(`bigint format ${i}`)}}function LA(e,t,n,i){let r=n.mime;if(r&&r.length>0){let o=Nt(t,new Set(r));e.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function RA(e,t,n,i){if(n.when)throw new cn('check with a custom "when" condition');e.write(`if (${i} == null) return INVALID;`);let r=n.shape;for(let o of Reflect.ownKeys(r)){let a=typeof o=="symbol"?Nt(t,o):yi(o),s=Pt(t);e.write(`const ${s} = ${i}[${a}];`),ci(e,t,r[o],s,!1)}}function NA(e,t,n,i){let r=`${i}[${JSON.stringify(n.property)}]`;hr(e,t,n.schema,r)}function XA(e,t,n,i,r){let o=n._zod.def.tx;if(!o)throw new cn("overwrite check without a transform function");if(ic(o))throw new ho("z.compile: async overwrite transforms are not supported");let a=Nt(t,o);e.write(`const ${r} = ${a}(${i});`)}function Gx(){throw new Fi}function Yx(e){this.issues.push(e)}function jA(e,t,n,i){let r=n._zod.def;if(r.fn){if(ic(r.fn))throw new ho("z.compile: async .refine() predicates are not supported");let o=rc(t,r.fn),a=Nt(t,Gx),s=Pt(t);return e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),i}if(n._zod.check){if(ic(n._zod.check))throw new ho("z.compile: async .superRefine() / check functions are not supported");let o=n._zod.check,s=rc(t,l=>{let u={value:l,issues:[],addIssue:Yx};return o(u)instanceof Promise&&Gx(),u.issues.length===0?u.value:xi}),c=Pt(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new cn("custom check without a predicate or check function")}var FA=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function ZO(e,t,n,i,r=!0){let o=n.format;if(o==="base64"){let l=Nt(t,sd);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="base64url"){let l=Nt(t,Jh);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="jwt"){let l=Nt(t,Ah),u=Nt(t,n.alg??null);return e.write(`if (!${l}(${i}, ${u})) return INVALID;`),i}if(o==="ipv6"){let l=Nt(t,ad);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="cidrv6"){let l=Nt(t,Uh);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="credit_card"){let l=Nt(t,Kh);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="iban"){let l=Nt(t,Gh);return e.write(`if (!${l}(${i})) return INVALID;`),i}let a=n;if(o==="url"||o==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let l=Nt(t,Zh),u=Nt(t,n),f=Pt(t),d=Pt(t);if(e.write(`const ${f} = ${i}.trim();`),e.write(`const ${d} = ${l}(${f}, ${u});`),e.write(`if (typeof ${d} === "number") return INVALID;`),a.hostname!==void 0){let h=Nt(t,Dh);e.write(`if (!${h}(${d}, ${u}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let h=Nt(t,qh);e.write(`if (!${h}(${d}, ${u}.protocol)) return INVALID;`)}if(!r)return null;let m=Pt(t),p=a.normalize?`${d}.href`:`${Nt(t,od)}(${f})`;return e.write(`const ${m} = ${p};`),m}let s=n.fn;if(s){if(ic(s))throw new cn(`async string format ${o}`);let l=Nt(t,s);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(FA.has(o)&&n.pattern){let l=Nt(t,n.pattern);return e.write(`${l}.lastIndex = 0;`),e.write(`if (!${l}.test(${i})) return INVALID;`),i}let c=n.format;switch(c){case"regex":throw new cn("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${yi(n.includes)})) return INVALID;`);break;case"starts_with":{let l=n.prefix;e.write(`if (${i}.slice(0, ${l.length}) !== ${yi(l)}) return INVALID;`);break}case"ends_with":{let l=n.suffix;e.write(`if (${i}.slice(-${l.length}) !== ${yi(l)}) return INVALID;`);break}default:throw new cn(`string format ${c}`)}return i}function hr(e,t,n,i,r=!0){let o=n._zod.def,a=o.type;if(o.coerce)throw new cn(`coercion (z.coerce.${a}())`);let s=r||!!o.checks?.length,c;switch(a){case"string":c=IA(e,t,n,i,s);break;case"number":c=EA(e,n,i);break;case"boolean":c=VA(e,i);break;case"bigint":c=WA(e,n,i);break;case"symbol":c=HA(e,i);break;case"undefined":c=ZA(e,i);break;case"null":c=DA(e,i);break;case"any":case"unknown":c=i;break;case"never":e.write("return INVALID;"),c=i;break;case"void":c=qA(e,i);break;case"nan":c=UA(e,i);break;case"date":c=CA(e,i);break;case"object":c=JA(e,t,n,i,s);break;case"optional":c=KA(e,t,n,i,s);break;case"nullable":c=BA(e,t,n,i,s);break;case"array":c=YA(e,t,n,i,s);break;case"literal":c=QA(e,t,n,i);break;case"enum":c=_A(e,t,n,i);break;case"readonly":{let l=IO(e,t,n,i),u=Pt(t);e.write(`const ${u} = Object.freeze(${l});`),c=u;break}case"success":IO(e,t,n,i),c="true";break;case"default":case"prefault":c=$A(e,t,n,i);break;case"nonoptional":c=eB(e,t,n,i);break;case"tuple":c=tB(e,t,n,i);break;case"union":c=nB(e,t,n,i);break;case"intersection":c=oB(e,t,n,i);break;case"record":c=aB(e,t,n,i);break;case"map":c=cB(e,t,n,i);break;case"set":c=lB(e,t,n,i);break;case"file":c=uB(e,i);break;case"template_literal":c=fB(e,t,n,i);break;case"lazy":c=dB(e,t,n,i);break;case"pipe":c=mB(e,t,n,i);break;case"custom":c=pB(e,t,n,i);break;case"transform":c=gB(e,t,n,i);break;case"catch":c=bB(e,t,n,i);break;default:throw new cn(`schema type ${a}`)}return c===null?null:SA(e,t,n,c)}function IA(e,t,n,i,r=!0){e.write(`if (typeof ${i} !== "string") return INVALID;`);let o=n._zod.def;return o.format===void 0?i:ZO(e,t,o,i,r)}function EA(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let i=t._zod.def;return i.check==="number_format"&&i.format&&HO(e,{format:i.format},n),n}function VA(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function WA(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let i=t._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function HA(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function ZA(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function DA(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function qA(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function UA(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function CA(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function JA(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),l=c.length?[...s,...c]:s,u=g=>typeof g=="symbol"?Nt(t,g):yi(g),f=g=>typeof g=="symbol"?`[${u(g)}]`:yi(g),d=a;if(s.includes("__proto__"))throw new cn('object shape key "__proto__"');let m=new Map;for(let g of l){let y=d[g],w=u(g),x=Pt(t);if(e.write(`const ${x} = ${i}[${w}];`),y._zod.optin!==void 0){let O=Pt(t);e.write(`let ${O} = (() => {`),e.indented(P=>{let T=ci(P,t,y,x);P.write(`return ${T};`)}),e.write("})();"),y._zod.optout==="optional"?(e.write(`if (${O} === INVALID) {`),e.indented(P=>{P.write(`if (${w} in ${i}) return INVALID;`),P.write(`${O} = undefined;`)}),e.write("}")):e.write(`if (${O} === INVALID) return INVALID;`),m.set(g,O)}else{AA(y)&&e.write(`if (!(${w} in ${i})) return INVALID;`);let O=ci(e,t,y,x,r);O!==null&&m.set(g,O)}}let p=o.catchall,h="none";if(p){let g=p._zod.def.type;if(g==="never"){let y=s.map(w=>`k !== ${yi(w)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(w=>{w.write(`if (${y}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?h="passthrough":h="schema"}let b=Pt(t),v=l.some(g=>FO(d[g])||Ax(d[g]));if(!r){if(h==="schema"){let g=s.length>0?Nt(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(y=>{y.write('if (k === "__proto__") continue;'),g&&y.write(`if (${g}.has(k)) continue;`);let w=Pt(t);y.write(`const ${w} = ${i}[k];`),ci(y,t,p,w,!1)}),e.write("}")}return null}if(v){e.write(`const ${b} = {};`);for(let g of l){let y=u(g),w=m.get(g);Ax(d[g])?e.write(`if (${y} in ${i}) ${b}[${y}] = ${w};`):FO(d[g])?e.write(`if (${w} !== undefined || ${y} in ${i}) ${b}[${y}] = ${w};`):e.write(`${b}[${y}] = ${w};`)}}else{let g=l.map(y=>`${f(y)}: ${m.get(y)}`).join(", ");e.write(`const ${b} = { ${g} };`)}if(h!=="none"){let g=s.length>0?Nt(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(y=>{if(y.write('if (k === "__proto__") continue;'),g&&y.write(`if (${g}.has(k)) continue;`),h==="passthrough")y.write(`${b}[k] = ${i}[k];`);else{let w=Pt(t);y.write(`const ${w} = ${i}[k];`);let x=ci(y,t,p,w);y.write(`${b}[k] = ${x};`)}}),e.write("}")}return b}function KA(e,t,n,i,r=!0){let o=n._zod.def;if(GA(n))return hr(e,t,o.innerType,i,r);if(o.innerType._zod.optin==="defaulted"){let s=Pt(t),c=Pt(t);return e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`const ${c} = (() => {`),l.indented(u=>{let f=hr(u,t,o.innerType,i);u.write(`return ${f};`)}),l.write("})();"),l.write(`if (${c} !== INVALID) ${s} = ${c};`)}),e.write("} else {"),e.indented(l=>{let u=hr(l,t,o.innerType,i);l.write(`${s} = ${u};`)}),e.write("}"),s}let a=r?Pt(t):null;return a&&e.write(`let ${a};`),e.write(`if (${i} !== undefined) {`),e.indented(s=>{let c=hr(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function GA(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function AA(e){return e._zod.optin===void 0&&nc(e)}function nc(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?nc(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?nc(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(nc):!0;case"intersection":return!t.left||!t.right?!0:nc(t.left)&&nc(t.right);case"pipe":return t.in?nc(t.in):!0;default:return!0}}function Ax(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function FO(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Nl(e)}function Nl(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?Nl(t.innerType):!0;case"union":return t.options?t.options.some(Nl):!0;case"intersection":return!t.left||!t.right||Nl(t.left)||Nl(t.right);case"pipe":return t.out?Nl(t.out):!0;default:return!0}}function BA(e,t,n,i,r=!0){let o=n._zod.def,a=r?Pt(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${i} !== null) {`),e.indented(s=>{let c=hr(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function YA(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`);let a=r?Pt(t):null,s=Pt(t),c=Pt(t);return a&&e.write(`const ${a} = new Array(${i}.length);`),e.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),e.indented(l=>{l.write(`const ${c} = ${i}[${s}];`);let u=ci(l,t,o.element,c,r);a&&u!==null&&l.write(`${a}[${s}] = ${u};`)}),e.write("}"),a}function QA(e,t,n,i){let o=n._zod.def.values;if(o.length!==1){let s=Nt(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=Nt(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")e.write(`if (${i} !== ${yi(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${i} !== ${a}n) return INVALID;`);else throw new cn(`literal type ${typeof a}`);return i}function _A(e,t,n,i){let r=n._zod.values;if(!r)throw new cn("enum schema without enumerated values");let o=Nt(t,r);return e.write(`if (!${o}.has(${i})) return INVALID;`),i}function IO(e,t,n,i){let r=n._zod.def;return hr(e,t,r.innerType,i)}function $A(e,t,n,i){let r=n._zod.def,a=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!a)return hr(e,t,r.innerType,i);let c=Nt(t,a),l=Pt(t);return e.write(`let ${l} = ${i};`),e.write(`if (${i} === undefined) ${l} = ${c}();`),hr(e,t,r.innerType,l)}let s=Pt(t);if(a){let c=Nt(t,a),l=Nt(t,Uf);e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(u=>{u.write(`${s} = ${l}(${c}());`)}),e.write("} else {"),e.indented(u=>{let f=hr(u,t,r.innerType,i);u.write(`${s} = ${f} === undefined ? ${l}(${c}()) : ${f};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(c=>{let l=hr(c,t,r.innerType,i);c.write(`${s} = ${l};`)}),e.write("}");return s}function eB(e,t,n,i){let r=n._zod.def,o=hr(e,t,r.innerType,i),a=Pt(t);return e.write(`const ${a} = ${o};`),e.write(`if (${a} === undefined) return INVALID;`),a}function tB(e,t,n,i){let r=n._zod.def,o=r.items,a=r.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let s=EO(o,"optin"),c=EO(o,"optout");a?e.write(`if (${i}.length < ${s}) return INVALID;`):e.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let l=Pt(t);e.write(`const ${l} = [];`);for(let u=0;u<o.length;u++){let f=o[u];if(u>=c)e.write(`if (${l}.length === ${u}) {`),e.indented(d=>{d.write(`if (${u} < ${i}.length) {`),d.indented(m=>{let p=Pt(t);m.write(`const ${p} = ${i}[${u}];`);let h=ci(m,t,f,p);m.write(`${l}[${u}] = ${h};`)}),d.write("} else {"),d.indented(m=>{if(Ax(f)){m.write(`${l}.length = ${u};`);return}let p=Pt(t),h=Pt(t);m.write(`const ${p} = undefined;`),m.write(`const ${h} = (() => {`),m.indented(b=>{let v=ci(b,t,f,p);b.write(`return ${v};`)}),m.write("})();"),m.write(`if (${h} === INVALID || ${h} === undefined) ${l}.length = ${u};`),m.write(`else ${l}[${u}] = ${h};`)}),d.write("}")}),e.write("}");else{let d=Pt(t);e.write(`const ${d} = ${i}[${u}];`);let m=ci(e,t,f,d);e.write(`${l}[${u}] = ${m};`)}}if(a){let u=Pt(t),f=Pt(t);e.write(`for (let ${u} = ${o.length}; ${u} < ${i}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${f} = ${i}[${u}];`);let m=ci(d,t,a,f);d.write(`${l}[${u}] = ${m};`)}),e.write("}")}return l}function EO(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function nB(e,t,n,i){let r=n._zod.def,o=r.options;if(r.discriminator)return rB(e,t,r,i);if(r.inclusive===!1)throw new cn("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),i;if(o.length===1)return hr(e,t,o[0],i);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(u=>u._zod.def.values)),l=Nt(t,c);return e.write(`if (!${l}.has(${i})) return INVALID;`),i}let s=Pt(t);e.write(`let ${s};`);for(let c=0;c<o.length;c++){let l=o[c];c===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(u=>{let f=hr(u,t,l,i);u.write(`return ${f};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function rB(e,t,n,i){if(n.unionFallback)throw new cn("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),i;let r=Pt(t),o=Pt(t);e.write(`const ${r} = ${i}?.[${yi(n.discriminator)}];`),e.write(`let ${o};`);let a=!0,s=new Set;for(let c of n.options){let l=c._zod.propValues?.[n.discriminator];if(!l||l.size===0)throw new cn("discriminated union option without static discriminator values");for(let d of l){if(s.has(d))throw new cn(`duplicate discriminator value ${String(d)}`);s.add(d)}let u=Array.from(l,d=>iB(t,r,d)),f=a?"if":"else if";e.write(`${f} (${u.join(" || ")}) {`),e.indented(d=>{let m=hr(d,t,c,i);d.write(`${o} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),o}function iB(e,t,n){if(typeof n=="string")return`${t} === ${yi(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){let i=Nt(e,n);return`${t} === ${i}`}throw new cn(`literal discriminator value ${String(n)}`)}function oB(e,t,n,i){let r=n._zod.def;t.definite=!1;let o=ci(e,t,r.left,i),a=ci(e,t,r.right,i),s=Nt(t,Ml),c=Pt(t);return e.write(`const ${c} = ${s}(${o}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function aB(e,t,n,i){let r=n._zod.def,o=Nt(t,Qi);e.write(`if (!${o}(${i})) return INVALID;`);let a=Pt(t),s=Pt(t),c=Pt(t);e.write(`const ${a} = {};`);let l=r,u=l.partial?void 0:r.keyType._zod.values;if(u){let m=[];for(let h of u){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new cn(`record key value ${String(h)}`);let b=typeof h=="number"?h.toString():h;if(b==="__proto__")throw new cn('record key "__proto__"');m.push(b);let v=Nt(t,h),g=hr(e,t,r.keyType,v),y=Pt(t);e.write(`const ${y} = ${i}[${sB(t,b)}];`);let w=ci(e,t,r.valueType,y);e.write(`${a}[${g}] = ${w};`)}let p=Nt(t,new Set(m));return e.write(`for (const ${s} in ${i}) {`),e.indented(h=>{h.write(`if (${p}.has(${s})) continue;`),l.mode==="loose"?h.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):h.write("return INVALID;")}),e.write("}"),a}let f=r.keyType._zod.def;if(!(f.type==="string"&&f.format===void 0&&!f.coerce&&(f.checks?.length??0)===0)){let m=r.mode==="loose",p=db(r.keyType);p.definite===!1&&(t.definite=!1);let h=Nt(t,p),b=Nt(t,ma),v=Pt(t);return VO(e,t,i,s,g=>{g.write(`let ${v} = ${h}(${s});`),g.write(`if (${v} === INVALID && typeof ${s} === "string" && ${b}.test(${s})) ${v} = ${h}(Number(${s}));`),m?g.write(`if (${v} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):g.write(`if (${v} === INVALID) return INVALID;`),g.write(`if (${v} === "__proto__") continue;`);let y=Pt(t);g.write(`const ${y} = ${i}[${s}];`);let w=ci(g,t,r.valueType,y);g.write(`${a}[${v}] = ${w};`)}),a}return VO(e,t,i,s,m=>{m.write(`const ${c} = ${i}[${s}];`);let p=ci(m,t,r.valueType,c);m.write(`${a}[${s}] = ${p};`)},"return INVALID;"),a}function VO(e,t,n,i,r,o){let a=Nt(t,Object.prototype.propertyIsEnumerable),s=Pt(t),c=Pt(t),l=Pt(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${l} = 0; ${l} < ${c}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${i} = ${c}[${l}];`),u.write(`if (${i} === "__proto__" || !${a}.call(${n}, ${i})) continue;`),r(u)}),e.write("}"),e.write(`for (let ${l} = 0; ${l} < ${s}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${i} = ${s}[${l}];`),u.write(`if (!${a}.call(${n}, ${i})) continue;`),o?u.write(o):r(u)}),e.write("}")}function sB(e,t){return typeof t=="string"?yi(t):Nt(e,t)}function cB(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`);let o=Pt(t),a=Pt(t),s=Pt(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${a}, ${s}] of ${i}) {`),e.indented(c=>{let l=hr(c,t,r.keyType,a),u=hr(c,t,r.valueType,s);c.write(`${o}.set(${l}, ${u});`)}),e.write("}"),o}function lB(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`);let o=Pt(t),a=Pt(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${a} of ${i}) {`),e.indented(s=>{let c=hr(s,t,r.valueType,a);s.write(`${o}.add(${c});`)}),e.write("}"),o}function uB(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function fB(e,t,n,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let r=n._zod.pattern;if(r){let o=Nt(t,r);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function dB(e,t,n,i){let r=n._zod.def,o=rc(t,r.getter),a=Nt(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${a}.parser = function(input) {`),c.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let s=Pt(t);return e.write(`const ${s} = ${a}.parser(${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function mB(e,t,n,i){let r=n._zod.def,o=hr(e,t,r.in,i);if(r.transform){if(ic(r.transform))throw new ho("z.compile: async transforms in pipes are not supported");let a=r.transform,c=rc(t,u=>{let f={value:u,issues:[],addIssue:Yx},d=a(u,f);return d instanceof Promise?xi:f.issues.length===0?d:xi}),l=Pt(t);return e.write(`const ${l} = ${c}(${o});`),e.write(`if (${l} === INVALID) return INVALID;`),hr(e,t,r.out,l)}else return hr(e,t,r.out,o)}function ic(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function pB(e,t,n,i){let r=n._zod.def;if(r.fn){if(ic(r.fn))throw new ho("z.compile: async custom predicates are not supported");let o=rc(t,r.fn),a=Nt(t,Gx),s=Pt(t);e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new cn("custom schema without a predicate function");return i}function hB(e,t,n){let i=e._zod.run({value:n,issues:[]},{});if(i&&typeof i.then=="function")return xi;let r=i;return r.issues.length===0?r.value:t()}function bB(e,t,n,i){let r=n._zod.def;if(!r.catchValue[gh])throw new cn("catch with a callback (only a constant catch value compiles)",!1);let o=Pt(t);e.write(`let ${o} = (() => {`),e.indented(l=>{let u=ci(l,t,r.innerType,i);l.write(`return ${u};`)}),e.write("})();");let a=Nt(t,r.innerType),s=rc(t,r.catchValue),c=Nt(t,hB);return e.write(`if (${o} === INVALID) {`),e.indented(l=>{l.write(`${o} = ${c}(${a}, ${s}, ${i});`),l.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function gB(e,t,n,i){let r=n._zod.def;if(r.transform){if(ic(r.transform))throw new ho("z.compile: async transforms are not supported");let o=r.transform,s=rc(t,l=>{let u={value:l,issues:[],addIssue:Yx},f=o(l,u);return f instanceof Promise?xi:u.issues.length===0?f:xi}),c=Pt(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return i}function mb(e){return e.checks&&(e.checks=[...e.checks]),e}function Qx(e,t){return new e(mb({type:"string",...Ie(t)}))}function _x(e,t){return new e(mb({type:"string",coerce:!0,...Ie(t)}))}function pb(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ie(t)})}function hb(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ie(t)})}function bb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ie(t)})}function gb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ie(t)})}function vb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ie(t)})}function yb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ie(t)})}function vd(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ie(t)})}function wb(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ie(t)})}function xb(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ie(t)})}function Pb(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ie(t)})}function kb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ie(t)})}function Sb(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ie(t)})}function Tb(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ie(t)})}function zb(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ie(t)})}function Ob(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ie(t)})}function Mb(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ie(t)})}function $x(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...Ie(t)})}function Lb(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ie(t)})}function Rb(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ie(t)})}function Nb(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ie(t)})}function Xb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ie(t)})}function jb(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ie(t)})}function e3(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...Ie(t)})}function t3(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...Ie(t)})}function Fb(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ie(t)})}var n3={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function yd(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ie(t)})}function wd(e,t){return new e({type:"string",format:"date",check:"string_format",...Ie(t)})}function xd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ie(t)})}function Pd(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ie(t)})}function r3(e,t){return new e(mb({type:"number",checks:[],...Ie(t)}))}function i3(e,t){return new e(mb({type:"number",coerce:!0,checks:[],...Ie(t)}))}function o3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ie(t)})}function a3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...Ie(t)})}function s3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...Ie(t)})}function c3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...Ie(t)})}function l3(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...Ie(t)})}function u3(e,t){return new e({type:"boolean",...Ie(t)})}function f3(e,t){return new e({type:"boolean",coerce:!0,...Ie(t)})}function d3(e,t){return new e({type:"bigint",...Ie(t)})}function m3(e,t){return new e({type:"bigint",coerce:!0,...Ie(t)})}function p3(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...Ie(t)})}function h3(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...Ie(t)})}function b3(e,t){return new e({type:"symbol",...Ie(t)})}function g3(e,t){return new e({type:"undefined",...Ie(t)})}function v3(e,t){return new e({type:"null",...Ie(t)})}function y3(e){return new e({type:"any"})}function w3(e){return new e({type:"unknown"})}function x3(e,t){return new e({type:"never",...Ie(t)})}function P3(e,t){return new e({type:"void",...Ie(t)})}function k3(e,t){return new e({type:"date",...Ie(t)})}function S3(e,t){return new e({type:"date",coerce:!0,...Ie(t)})}function T3(e,t){return new e({type:"nan",...Ie(t)})}function Eo(e,t){return new jh({check:"less_than",...Ie(t),value:e,inclusive:!1})}function qi(e,t){return new jh({check:"less_than",...Ie(t),value:e,inclusive:!0})}function Vo(e,t){return new Fh({check:"greater_than",...Ie(t),value:e,inclusive:!1})}function Ui(e,t){return new Fh({check:"greater_than",...Ie(t),value:e,inclusive:!0})}function Ib(e){return Vo(0,e)}function Eb(e){return Eo(0,e)}function Vb(e){return qi(0,e)}function Wb(e){return Ui(0,e)}function _a(e,t){return new lw({check:"multiple_of",...Ie(t),value:e})}function $a(e,t){return new dw({check:"max_size",...Ie(t),maximum:e})}function Wo(e,t){return new mw({check:"min_size",...Ie(t),minimum:e})}function oc(e,t){return new pw({check:"size_equals",...Ie(t),size:e})}function ac(e,t){return new hw({check:"max_length",...Ie(t),maximum:e})}function pa(e,t){return new bw({check:"min_length",...Ie(t),minimum:e})}function sc(e,t){return new gw({check:"length_equals",...Ie(t),length:e})}function Xl(e,t){return new vw({check:"string_format",format:"regex",...Ie(t),pattern:e})}function jl(e){return new yw({check:"string_format",format:"lowercase",...Ie(e)})}function Fl(e){return new ww({check:"string_format",format:"uppercase",...Ie(e)})}function Il(e,t){return new xw({check:"string_format",format:"includes",...Ie(t),includes:e})}function El(e,t){return new Pw({check:"string_format",format:"starts_with",...Ie(t),prefix:e})}function Vl(e,t){return new kw({check:"string_format",format:"ends_with",...Ie(t),suffix:e})}function Hb(e,t,n){return new Sw({check:"property",property:e,schema:t,...Ie(n)})}function Wl(e,t){return new Tw({check:"properties",shape:e,...Ie(t)})}function Hl(e,t){return new zw({check:"mime_type",mime:e,...Ie(t)})}function bo(e){return new Ow({check:"overwrite",tx:e})}function Zl(e){return bo(t=>t.normalize(e))}function Dl(){return bo(e=>e.trim())}function ql(){return bo(e=>e.toLowerCase())}function Ul(){return bo(e=>e.toUpperCase())}function Cl(){return bo(e=>f1(e))}function z3(e,t,n){return new e({type:"array",element:t,...Ie(n)})}function vB(e,t,n){return new e({type:"union",options:t,...Ie(n)})}function yB(e,t,n){return new e({type:"union",options:t,inclusive:!1,...Ie(n)})}function wB(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...Ie(i)})}function xB(e,t,n){return new e({type:"intersection",left:t,right:n})}function PB(e,t,n,i){let r=n instanceof Wt,o=r?i:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...Ie(o)})}function kB(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...Ie(i)})}function SB(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...Ie(i)})}function TB(e,t,n){return new e({type:"set",valueType:t,...Ie(n)})}function zB(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...Ie(n)})}function OB(e,t,n){return new e({type:"enum",entries:t,...Ie(n)})}function MB(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...Ie(n)})}function O3(e,t){return new e({type:"file",...Ie(t)})}function LB(e,t){return new e({type:"transform",transform:t})}function RB(e,t){return new e({type:"optional",innerType:t})}function NB(e,t){return new e({type:"nullable",innerType:t})}function XB(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Uf(n)}})}function jB(e,t,n){return new e({type:"nonoptional",innerType:t,...Ie(n)})}function FB(e,t){return new e({type:"success",innerType:t})}function IB(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:g1(n)})}function EB(e,t,n){return new e({type:"pipe",in:t,out:n})}function VB(e,t){return new e({type:"readonly",innerType:t})}function WB(e,t,n){return new e({type:"template_literal",parts:t,...Ie(n)})}function HB(e,t){return new e({type:"lazy",getter:t})}function ZB(e,t){return new e({type:"promise",innerType:t})}function M3(e,t,n){let i=Ie(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function L3(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ie(n)})}function R3(e,t){let n=DO(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(Pl(r,i.value,n._zod.def));else{let o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),i.issues.push(Pl(o))}},e(i.value,i)),t);return n}function DO(e,t){let n=new _n({check:"custom",...Ie(t)});return n._zod.check=e,n}function N3(e){let t=new _n({check:"describe"});return t._zod.onattach=[n=>{let i=$r.get(n)??{};$r.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function X3(e){let t=new _n({check:"meta"});return t._zod.onattach=[n=>{let i=$r.get(n)??{};$r.add(n,{...i,...e})}],t._zod.check=()=>{},t}function j3(e,t){let n=Ie(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(m=>typeof m=="string"?m.toLowerCase():m),r=r.map(m=>typeof m=="string"?m.toLowerCase():m));let o=new Set(i),a=new Set(r),s=e.Codec??fd,c=e.Boolean??ld,l=e.String??ec,u=new l({type:"string",error:n.error}),f=new c({type:"boolean",error:n.error}),d=new s({type:"pipe",in:u,out:f,transform:((m,p)=>{let h=m;return n.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:a.has(h)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:p.value,inst:d,continue:!1}),{})}),reverseTransform:((m,p)=>m===!0?i[0]||"true":r[0]||"false"),error:n.error});return d._zod.bag.truthy=i,d._zod.bag.falsy=r,d._zod.bag.case=n.case??"insensitive",d}function cc(e,t,n,i={}){let r=Ie(i),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(o.pattern=n),new e(o)}function kd(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,i)&&_r(e,i,n[i]);return e}function es(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??$r,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Hr(e,t,n,i,r){let o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(n,o),!0}function Dn(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let d=a.schema,m=t.processors[r.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);m(e,t,d,u)}let f=e._zod.parent;f&&(a.ref||(a.ref=f),Dn(f,t,u),t.seen.get(f).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&kd(a.schema,c),t.io==="input"&&Pi(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function qO(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ts(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let r=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(a[0])?.id,d=e.external.uri??(p=>p);if(f)return{ref:d(f)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${d("__shared")}#/${s}/${qO(m)}`}}let c="#",l=`${c}/${s}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+qO(u)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:l}=r(a);s.def={...s.schema},l&&(s.defId=l);let u=s.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
76
-
77
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&e.reused==="ref"&&o(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function JO(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!="object")return;JO(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var KO=new Set(["type","properties","required","additionalProperties"]),UO=["oneOf","anyOf"];function CO(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function F3(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!KO.has(a))return null;t.push(o)}let n={},i=new Set;for(let o of t){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let s=[];for(let l of t){let u=l.properties?.[a]??CO(l);u!=null&&(s.some(f=>JSON.stringify(f)===JSON.stringify(u))||s.push(u))}let c=s.length===1?s[0]:F3(s)??{allOf:s};_r(n,a,c)}for(let a of o.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size&&(r.required=[...i]),t.every(o=>o.additionalProperties===!1))r.additionalProperties=!1;else{let o=[];for(let a of t){let s=CO(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?r.additionalProperties=o[0]:o.length>1&&(r.additionalProperties={allOf:o})}return r}function DB(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of KO)if(r in e)return;let n=t.filter(r=>UO.some(o=>Array.isArray(r[o]))),i=null;if(!n.length)i=F3(t);else{let r=n[0],o=UO.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter(c=>c!==r),s=r[o].map(c=>F3([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete e.allOf,kd(e,i))}function ns(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let m=e.seen.get(f),p=m.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(p)):kd(l,p),kd(l,u),s._zod.parent===f)for(let b in l)b==="$ref"||b==="allOf"||b in u||delete l[b];if(p.$ref&&m.def)for(let b in l)b==="$ref"||b==="allOf"||b in m.def&&JSON.stringify(l[b])===JSON.stringify(m.def[b])&&delete l[b]}let d=s._zod.parent;if(d&&d!==f){i(d);let m=e.seen.get(d);if(m?.schema.$ref&&(l.$ref=m.schema.$ref,m.def))for(let p in l)p==="$ref"||p==="allOf"||p in m.def&&JSON.stringify(l[p])===JSON.stringify(m.def[p])&&delete l[p]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())JO(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=s.get(u);f?f.push(l):s.set(u,[l])}for(let c of e.intersections)for(let l of s.get(c)??[])DB(l)}}let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}kd(r,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&r.id===o&&delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,_r(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?r.$defs=a:r.definitions=a);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Jl(t,"input",e.processors),output:Jl(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Pi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Pi(i.element,n);if(i.type==="set")return Pi(i.valueType,n);if(i.type==="lazy")return Pi(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Pi(i.innerType,n);if(i.type==="intersection")return Pi(i.left,n)||Pi(i.right,n);if(i.type==="record"||i.type==="map")return Pi(i.keyType,n)||Pi(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Pi(i.in,n)||Pi(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Pi(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Pi(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Pi(r,n))return!0;return!!(i.rest&&Pi(i.rest,n))}return!1}var I3=(e,t={})=>n=>{let i=es({...n,processors:t});return Dn(e,i),ts(i,e),ns(i,e)},Jl=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},a=es({...r??{},target:o,io:t,processors:n});return Dn(e,a),ts(a,e),ns(a,e)};var Kl=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Gl=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},GO=(e,t)=>{Kl(e,"minimum",t),Gl(e,"maximum",t)},QO=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},_O=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},$O=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},eM=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},AO=(e,t)=>Kl(e,"minimum",t.minimum),BO=(e,t)=>Gl(e,"maximum",t.maximum),YO=e=>(t,n)=>{eM(t,n.format);let[i,r]=e[n.format];Kl(t,"minimum",i),Gl(t,"maximum",r)},qB={greater_than:(e,t)=>Kl(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Gl(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>QO(e,t.value),number_format:YO(Jf),bigint_format:YO(Kf),min_length:AO,max_length:BO,length_equals:(e,t)=>GO(e,t.length),min_size:AO,max_size:BO,size_equals:(e,t)=>GO(e,t.size),string_format:(e,t)=>{eM(e,t.format),t.pattern&&_O(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>$O(e,t.mime)};function Zr(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of i)qB[o._zod.def.check]?.(t,o._zod.def);let r=e._zod.bag;r.minimum!==void 0&&Kl(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Kl(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&Gl(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&Gl(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&QO(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&$O(t,r.mime);for(let o of r.patterns??[])_O(t,o);return t}var UB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},CB=new Map([[Ch,U1],[cd,C1]]),tM=e=>CB.get(e)??e,W3=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zr(e);if(typeof o=="number"&&(r.minLength=o),typeof a=="number"&&(r.maxLength=a),s&&(r.format=UB[s]??s,r.format===""&&delete r.format,(s==="time"||u)&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){let f=[...c].map(tM);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},H3=(e,t,n,i)=>{let r=n,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zr(e);r.type=u?"integer":"number";let f=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),d=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(f?m?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:typeof o=="number"&&(r.minimum=o),d?m?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof a=="number"&&(r.maximum=a),s){let p=new Set;for(let v of s)Number.isFinite(v)&&v!==0?p.add(Math.abs(v)):Hr(e,t,r,i,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[h,...b]=p;h!==void 0&&(r.multipleOf=h),b.length&&(r.allOf=[...r.allOf??[],...b.map(v=>({multipleOf:v}))])}},Z3=(e,t,n,i)=>{n.type="boolean"},D3=(e,t,n,i)=>{Hr(e,t,n,i,"BigInt cannot be represented in JSON Schema")},q3=(e,t,n,i)=>{Hr(e,t,n,i,"Symbols cannot be represented in JSON Schema")},U3=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},C3=(e,t,n,i)=>{Hr(e,t,n,i,"Undefined cannot be represented in JSON Schema")},J3=(e,t,n,i)=>{Hr(e,t,n,i,"Void cannot be represented in JSON Schema")},K3=(e,t,n,i)=>{n.not={}},G3=(e,t,n,i)=>{},A3=(e,t,n,i)=>{},B3=(e,t,n,i)=>{Hr(e,t,n,i,"Date cannot be represented in JSON Schema")},Y3=(e,t,n,i)=>{let r=e._zod.def,o=vl(r.entries);if(o.length===0){n.not={};return}o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),n.enum=o},Q3=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let o=[];for(let a of r.values)if(a===void 0){if(Hr(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Hr(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),o.every(a=>typeof a=="boolean")&&(n.type="boolean"),o.every(a=>a===null)&&(n.type="null"),n.enum=o},_3=(e,t,n,i)=>{Hr(e,t,n,i,"NaN cannot be represented in JSON Schema")},$3=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},eP=(e,t,n,i)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=Zr(e);o!==void 0&&(r.minLength=o),a!==void 0&&(r.maxLength=a),s&&(s.length===0?r.not={}:s.length===1?r.contentMediaType=s[0]:r.anyOf=s.map(c=>({contentMediaType:c})))},tP=(e,t,n,i)=>{n.type="boolean"},nP=(e,t,n,i)=>{Hr(e,t,n,i,"Custom types cannot be represented in JSON Schema")},rP=(e,t,n,i)=>{Hr(e,t,n,i,"Function types cannot be represented in JSON Schema")},iP=(e,t,n,i)=>{Hr(e,t,n,i,"Transforms cannot be represented in JSON Schema")},oP=(e,t,n,i)=>{Hr(e,t,n,i,"Map cannot be represented in JSON Schema")},aP=(e,t,n,i)=>{Hr(e,t,n,i,"Set cannot be represented in JSON Schema")},sP=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:a,maximum:s}=Zr(e);typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=Dn(o.element,t,{...i,path:[...i.path,"items"]})};function Sd(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Sd(t.out):t.type==="catch"?Sd(t.innerType):e._zod.optin}var cP=(e,t,n,i)=>{let r=n,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&Hr(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)_r(r.properties,l,Dn(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=o.shape[l];(t.io==="input"?Sd(u)===void 0:u._zod.optout===void 0)&&c.push(l)}c.length>0&&(r.required=c),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Dn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Db=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,a=r.options.map((s,c)=>Dn(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=a:n.anyOf=a},lP=(e,t,n,i)=>{let r=e._zod.def,o=Dn(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=Dn(r.right,t,{...i,path:[...i.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},uP=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,b)=>Dn(h,t,{...i,path:[...i.path,a,b]})),l=o.rest?Dn(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,u=o.items.length;for(;u>0;){let h=o.items[u-1];if(!(t.io==="input"?Sd(h)!==void 0:h._zod.optout==="optional"))break;u--}let f=o.items.length,d=!o.rest;t.target==="draft-2020-12"?(r.prefixItems=c,d?r.items=!1:l&&(r.items=l),u>0&&(r.minItems=u),d&&(r.maxItems=f)):t.target==="openapi-3.0"?(r.items={anyOf:c},l&&r.items.anyOf.push(l),u>0&&(r.minItems=u),d&&(r.maxItems=f)):(r.items=c,d?r.additionalItems=!1:l&&(r.additionalItems=l),u>0&&(r.minItems=u),d&&(r.maxItems=f));let{minimum:m,maximum:p}=Zr(e);typeof m=="number"&&(r.minItems=m),typeof p=="number"&&(r.maxItems=p)};function E3(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let p=e.get(t)?.def;if(!p)return t;let h=E3(e,p,n);return h===p?t:h}for(let p of["anyOf","oneOf"]){let h=t[p];if(!Array.isArray(h))continue;let b=h.map(v=>E3(e,v,n));b.some((v,g)=>v!==h[g])&&(t={...t,[p]:b})}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!o?.some(p=>typeof p=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:d,...m}=t;return m.enum?m.enum=m.enum.map(p=>typeof p=="number"?String(p):p):typeof m.const=="number"&&(m.const=String(m.const)),r&&(m.type="string",o||(m.pattern=(i.includes("number")?ma:td).source)),m}var V3=new WeakMap;function JB(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let n=new Map;for(let i of V3.get(e)??[]){let r=e.seen.get(i),o=(r?.def??r?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let a=E3(t,o,new Set);a!==o&&n.set(o,a)}if(n.size)for(let i of e.seen.values())for(let r of[i.schema,i.def]){let o=r&&n.get(r.propertyNames);o&&(r.propertyNames=o)}}var fP=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let a=o.keyType,s=Zr(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let u=Dn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of s)_r(r.patternProperties,tM(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Dn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=V3.get(t);u||(u=[],V3.set(t,u),t.deferred.push(()=>JB(t))),u.push(e)}r.additionalProperties=Dn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&Sd(o.valueType)!==void 0;if(c&&!o.partial&&!l){let u=[...c].filter(f=>typeof f=="string"||typeof f=="number");u.length>0&&(r.required=u.map(String))}},dP=(e,t,n,i)=>{let r=e._zod.def,o=Dn(r.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},mP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},pP=Symbol();function nM(e,t,n,i,r){let o=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Hr(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),pP):JSON.parse(a)}var hP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a=nM(r.defaultValue,e,t,n,i);a!==pP&&(n.default=a)},bP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);if(o.ref=r.innerType,t.io!=="input")return;let a=nM(r.defaultValue,e,t,n,i);a!==pP&&(n._prefault=a)},gP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{Hr(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},vP=(e,t,n,i)=>{let r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?r.out:r.in:r.out;Dn(a,t,i);let s=t.seen.get(e);s.ref=a},yP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},wP=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},qb=(e,t,n,i)=>{let r=e._zod.def;Dn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},xP=(e,t,n,i)=>{let r=e._zod.innerType;Dn(r,t,i);let o=t.seen.get(e);o.ref=r},Zb={string:W3,number:H3,boolean:Z3,bigint:D3,symbol:q3,null:U3,undefined:C3,void:J3,never:K3,any:G3,unknown:A3,date:B3,enum:Y3,literal:Q3,nan:_3,template_literal:$3,file:eP,success:tP,custom:nP,function:rP,transform:iP,map:oP,set:aP,array:sP,object:cP,union:Db,intersection:lP,tuple:uP,record:fP,nullable:dP,nonoptional:mP,default:hP,prefault:bP,catch:gP,pipe:vP,readonly:yP,promise:wP,optional:qb,lazy:xP};function Ub(e,t){if("_idmap"in e){let i=e,r=es({...t,processors:Zb}),o={};for(let c of i._idmap.entries()){let[l,u]=c;Dn(u,r)}let a={},s={registry:i,uri:t?.uri,defs:o};r.external=s;for(let c of i._idmap.entries()){let[l,u]=c;ts(r,u),_r(a,l,ns(r,u))}if(Object.keys(o).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let n=es({...t,processors:Zb});return Dn(e,n),ts(n,e),ns(n,e)}var Cb=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=es({processors:Zb,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return Dn(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ts(this.ctx,t);let i=ns(this.ctx,t),{"~standard":r,...o}=i;return o}};var rM={};var tu={};ra(tu,{ZodAny:()=>UP,ZodArray:()=>GP,ZodBase64:()=>l0,ZodBase64URL:()=>u0,ZodBigInt:()=>$l,ZodBigIntFormat:()=>m0,ZodBoolean:()=>_l,ZodCIDRv4:()=>s0,ZodCIDRv6:()=>c0,ZodCUID:()=>e0,ZodCUID2:()=>t0,ZodCatch:()=>pk,ZodCodec:()=>Fd,ZodCreditCard:()=>IP,ZodCustom:()=>Id,ZodCustomStringFormat:()=>dc,ZodDate:()=>Md,ZodDefault:()=>ck,ZodDiscriminatedUnion:()=>BP,ZodE164:()=>f0,ZodEmail:()=>Yb,ZodEmoji:()=>_b,ZodEnum:()=>Bl,ZodExactOptional:()=>g0,ZodFile:()=>ik,ZodFunction:()=>Sk,ZodGUID:()=>Qb,ZodIBAN:()=>EP,ZodIPv4:()=>o0,ZodIPv6:()=>a0,ZodISODate:()=>is,ZodISODateTime:()=>rs,ZodISODuration:()=>as,ZodISOTime:()=>os,ZodInstanceOf:()=>Ok,ZodIntersection:()=>YP,ZodJWT:()=>d0,ZodKSUID:()=>i0,ZodLazy:()=>xk,ZodLiteral:()=>rk,ZodMAC:()=>FP,ZodMap:()=>tk,ZodNaN:()=>bk,ZodNanoID:()=>$b,ZodNever:()=>JP,ZodNonOptional:()=>v0,ZodNull:()=>DP,ZodNullable:()=>sk,ZodNumber:()=>Ql,ZodNumberFormat:()=>mc,ZodObject:()=>Rd,ZodOptional:()=>Xd,ZodPipe:()=>jd,ZodPrefault:()=>uk,ZodPreprocess:()=>gk,ZodPromise:()=>kk,ZodReadonly:()=>vk,ZodRecord:()=>Al,ZodSet:()=>nk,ZodString:()=>Yl,ZodStringFormat:()=>Jn,ZodSuccess:()=>mk,ZodSymbol:()=>HP,ZodTemplateLiteral:()=>wk,ZodTransform:()=>ok,ZodTuple:()=>_P,ZodType:()=>Gt,ZodULID:()=>n0,ZodURL:()=>Od,ZodUUID:()=>Ho,ZodUndefined:()=>ZP,ZodUnion:()=>Nd,ZodUnknown:()=>CP,ZodVoid:()=>KP,ZodXID:()=>r0,ZodXor:()=>AP,_ZodString:()=>Bb,_default:()=>lk,_function:()=>hL,any:()=>KM,array:()=>Ld,base64:()=>zM,base64url:()=>OM,bigint:()=>DM,boolean:()=>WP,catch:()=>hk,check:()=>bL,cidrv4:()=>SM,cidrv6:()=>TM,codec:()=>fL,creditCard:()=>LM,cuid:()=>bM,cuid2:()=>gM,currencyCode:()=>IM,custom:()=>gL,date:()=>AM,describe:()=>vL,discriminatedUnion:()=>eL,e164:()=>MM,email:()=>aM,emoji:()=>pM,enum:()=>h0,exactOptional:()=>ak,file:()=>sL,float32:()=>VM,float64:()=>WM,function:()=>hL,guid:()=>sM,hash:()=>EM,hex:()=>FM,hostname:()=>jM,httpUrl:()=>mM,iban:()=>RM,instanceof:()=>wL,int:()=>Gb,int32:()=>HM,int64:()=>qM,intersection:()=>QP,invertCodec:()=>dL,ipv4:()=>xM,ipv6:()=>kM,json:()=>PL,jwt:()=>NM,keyof:()=>BM,ksuid:()=>wM,lazy:()=>Pk,literal:()=>aL,looseObject:()=>_M,looseRecord:()=>nL,mac:()=>PM,map:()=>rL,meta:()=>yL,nan:()=>uL,nanoid:()=>hM,nativeEnum:()=>oL,never:()=>p0,nonoptional:()=>dk,null:()=>qP,nullable:()=>zd,nullish:()=>cL,number:()=>VP,object:()=>YM,optional:()=>uc,partialRecord:()=>tL,pipe:()=>Ab,prefault:()=>fk,preprocess:()=>kL,promise:()=>pL,readonly:()=>yk,record:()=>ek,refine:()=>Tk,set:()=>iL,strictObject:()=>QM,string:()=>Td,stringFormat:()=>XM,stringbool:()=>xL,success:()=>lL,superRefine:()=>zk,symbol:()=>CM,templateLiteral:()=>mL,transform:()=>b0,tuple:()=>$P,uint32:()=>ZM,uint64:()=>UM,ulid:()=>vM,undefined:()=>JM,union:()=>eu,unknown:()=>lc,url:()=>dM,uuid:()=>cM,uuidv4:()=>lM,uuidv6:()=>uM,uuidv7:()=>fM,void:()=>GM,xid:()=>yM,xor:()=>$M});var Jb={};ra(Jb,{endsWith:()=>Vl,gt:()=>Vo,gte:()=>Ui,includes:()=>Il,length:()=>sc,lowercase:()=>jl,lt:()=>Eo,lte:()=>qi,maxLength:()=>ac,maxSize:()=>$a,mime:()=>Hl,minLength:()=>pa,minSize:()=>Wo,multipleOf:()=>_a,negative:()=>Eb,nonnegative:()=>Wb,nonpositive:()=>Vb,normalize:()=>Zl,overwrite:()=>bo,positive:()=>Ib,properties:()=>Wl,property:()=>Hb,regex:()=>Xl,size:()=>oc,slugify:()=>Cl,startsWith:()=>El,toLowerCase:()=>ql,toUpperCase:()=>Ul,trim:()=>Dl,uppercase:()=>Fl});var iM=new WeakSet([Object.prototype,Error.prototype]);function Kb(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var oM=(e,t)=>{k1.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);iM.has(n)||(iM.add(n),Kb(n,"format",i=>r=>Qf(i,r)),Kb(n,"flatten",i=>r=>Yf(i,r)),Kb(n,"addIssue",i=>r=>{i.issues.push(r),i.message=JSON.stringify(i.issues,yl,2)}),Kb(n,"addIssues",i=>r=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,yl,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},GB=G("ZodError",oM),Ei=G("ZodError",oM,void 0,{Parent:Error});var PP=kl(Ei),kP=Sl(Ei),SP=Tl(Ei),TP=zl(Ei),zP=xh(Ei),OP=Ph(Ei),MP=kh(Ei),LP=Sh(Ei),RP=Th(Ei),NP=zh(Ei),XP=Oh(Ei),jP=Mh(Ei);function BB(){Gr.localeError||kr(ab())}function fc(){Gr.memoizer||kr({memoizer:hd()})}var Gt=G("ZodType",(e,t)=>(BB(),Wt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ve.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Hn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Tk(e,t))},superRefine(e,t){return this.check(zk(e,t))},overwrite(e){return this.check(bo(e))},optional(){return uc(this)},exactOptional(){return ak(this)},nullable(){return zd(this)},nullish(){return uc(zd(this))},nonoptional(e){return dk(this,e)},array(){return Ld(this)},or(e){return eu([this,e])},and(e){return QP(this,e)},transform(e){return Ab(this,b0(e))},default(e){return lk(this,e)},prefault(e){return fk(this,e)},catch(e){return hk(this,e)},pipe(e){return Ab(this,e)},readonly(){return yk(this)},describe(e){let t=this.clone();return $r.add(t,{description:e}),t},meta(...e){if(e.length===0)return $r.get(this);let t=this.clone();return $r.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ve.hide(this,"~standard",{...Hh(this),jsonSchema:{input:Jl(this,"input"),output:Jl(this,"output")}})},set"~standard"(e){ve.own(this,"~standard",e)},parse:function e(t,n){return PP(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await kP(this,t,n,{callee:e})},safeParse(e,t){return SP(this,e,t)},async safeParseAsync(e,t){return TP(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ve.own(this,"spa",e)},validate(e,t){return _f(this,e,t)},validateAsync(e,t){return $f(this,e,t)},encode:function e(t,n){return zP(this,t,n,{callee:e})},decode:function e(t,n){return OP(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await MP(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await LP(this,t,n,{callee:e})},safeEncode(e,t){return RP(this,e,t)},safeDecode(e,t){return NP(this,e,t)},async safeEncodeAsync(e,t){return XP(this,e,t)},async safeDecodeAsync(e,t){return jP(this,e,t)},toJSONSchema(e){return I3(this,{})(e)},get description(){return $r.get(this)?.description},get _def(){return this._zod.def}}),Bb=G("_ZodString",(e,t)=>{ec.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>W3(e,n,i,r)},ve.derived({format:e=>Zr(e).format??null,minLength:e=>Zr(e).minimum??null,maxLength:e=>Zr(e).maximum??null},{regex(...e){return this.check(Xl(...e))},includes(...e){return this.check(Il(...e))},startsWith(...e){return this.check(El(...e))},endsWith(...e){return this.check(Vl(...e))},min(...e){return this.check(pa(...e))},max(...e){return this.check(ac(...e))},length(...e){return this.check(sc(...e))},nonempty(...e){return this.check(pa(1,...e))},lowercase(e){return this.check(jl(e))},uppercase(e){return this.check(Fl(e))},trim(){return this.check(Dl())},normalize(...e){return this.check(Zl(...e))},toLowerCase(){return this.check(ql())},toUpperCase(){return this.check(Ul())},slugify(){return this.check(Cl())}})),Yl=G("ZodString",(e,t)=>{ec.init(e,t),Bb.init(e,t)},{email(e){return this.check(pb(Yb,e))},url(e){return this.check(vd(Od,e))},jwt(e){return this.check(Fb(d0,e))},emoji(e){return this.check(wb(_b,e))},guid(e){return this.check(hb(Qb,e))},uuid(e){return this.check(bb(Ho,e))},uuidv4(e){return this.check(gb(Ho,e))},uuidv6(e){return this.check(vb(Ho,e))},uuidv7(e){return this.check(yb(Ho,e))},nanoid(e){return this.check(xb($b,e))},cuid(e){return this.check(Pb(e0,e))},cuid2(e){return this.check(kb(t0,e))},ulid(e){return this.check(Sb(n0,e))},base64(e){return this.check(Nb(l0,e))},base64url(e){return this.check(Xb(u0,e))},xid(e){return this.check(Tb(r0,e))},ksuid(e){return this.check(zb(i0,e))},ipv4(e){return this.check(Ob(o0,e))},ipv6(e){return this.check(Mb(a0,e))},cidrv4(e){return this.check(Lb(s0,e))},cidrv6(e){return this.check(Rb(c0,e))},e164(e){return this.check(jb(f0,e))},datetime(e){return this.check(yd(rs,e))},date(e){return this.check(wd(is,e))},time(e){return this.check(xd(os,e))},duration(e){return this.check(Pd(as,e))}});function Td(e){return Qx(Yl,e)}var Jn=G("ZodStringFormat",(e,t)=>{Zn.init(e,t),Bb.init(e,t)}),rs=G("ZodISODateTime",(e,t)=>{Uw.init(e,t),Jn.init(e,t)}),is=G("ZodISODate",(e,t)=>{Cw.init(e,t),Jn.init(e,t)}),os=G("ZodISOTime",(e,t)=>{Jw.init(e,t),Jn.init(e,t)}),as=G("ZodISODuration",(e,t)=>{Kw.init(e,t),Jn.init(e,t)}),Yb=G("ZodEmail",(e,t)=>{Xw.init(e,t),Jn.init(e,t)});function aM(e){return pb(Yb,e)}var Qb=G("ZodGUID",(e,t)=>{Rw.init(e,t),Jn.init(e,t)});function sM(e){return hb(Qb,e)}var Ho=G("ZodUUID",(e,t)=>{Nw.init(e,t),Jn.init(e,t)});function cM(e){return bb(Ho,e)}function lM(e){return gb(Ho,e)}function uM(e){return vb(Ho,e)}function fM(e){return yb(Ho,e)}var Od=G("ZodURL",(e,t)=>{Iw.init(e,t),Jn.init(e,t)});function dM(e){return vd(Od,e)}function mM(e){return vd(Od,{protocol:ed,hostname:K1,...ve.normalizeParams(e)})}var _b=G("ZodEmoji",(e,t)=>{Ew.init(e,t),Jn.init(e,t)});function pM(e){return wb(_b,e)}var $b=G("ZodNanoID",(e,t)=>{Vw.init(e,t),Jn.init(e,t)});function hM(e){return xb($b,e)}var e0=G("ZodCUID",(e,t)=>{Ww.init(e,t),Jn.init(e,t)});function bM(e){return Pb(e0,e)}var t0=G("ZodCUID2",(e,t)=>{Hw.init(e,t),Jn.init(e,t)});function gM(e){return kb(t0,e)}var n0=G("ZodULID",(e,t)=>{Zw.init(e,t),Jn.init(e,t)});function vM(e){return Sb(n0,e)}var r0=G("ZodXID",(e,t)=>{Dw.init(e,t),Jn.init(e,t)});function yM(e){return Tb(r0,e)}var i0=G("ZodKSUID",(e,t)=>{qw.init(e,t),Jn.init(e,t)});function wM(e){return zb(i0,e)}var o0=G("ZodIPv4",(e,t)=>{Gw.init(e,t),Jn.init(e,t)});function xM(e){return Ob(o0,e)}var FP=G("ZodMAC",(e,t)=>{Bw.init(e,t),Jn.init(e,t)});function PM(e){return $x(FP,e)}var a0=G("ZodIPv6",(e,t)=>{Aw.init(e,t),Jn.init(e,t)});function kM(e){return Mb(a0,e)}var s0=G("ZodCIDRv4",(e,t)=>{Yw.init(e,t),Jn.init(e,t)});function SM(e){return Lb(s0,e)}var c0=G("ZodCIDRv6",(e,t)=>{Qw.init(e,t),Jn.init(e,t)});function TM(e){return Rb(c0,e)}var l0=G("ZodBase64",(e,t)=>{_w.init(e,t),Jn.init(e,t)});function zM(e){return Nb(l0,e)}var u0=G("ZodBase64URL",(e,t)=>{$w.init(e,t),Jn.init(e,t)});function OM(e){return Xb(u0,e)}var f0=G("ZodE164",(e,t)=>{ex.init(e,t),Jn.init(e,t)});function MM(e){return jb(f0,e)}var IP=G("ZodCreditCard",(e,t)=>{tx.init(e,t),Jn.init(e,t)});function LM(e){return e3(IP,e)}var EP=G("ZodIBAN",(e,t)=>{nx.init(e,t),Jn.init(e,t)});function RM(e){return t3(EP,e)}var d0=G("ZodJWT",(e,t)=>{rx.init(e,t),Jn.init(e,t)});function NM(e){return Fb(d0,e)}var dc=G("ZodCustomStringFormat",(e,t)=>{ix.init(e,t),Jn.init(e,t)});function XM(e,t,n={}){return cc(dc,e,t,n)}function jM(e){return cc(dc,"hostname",J1,e)}function FM(e){return cc(dc,"hex",aw,e)}function IM(e){return cc(dc,"currency_code",A1,e)}function EM(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=$i[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return cc(dc,i,r,t)}var Ql=G("ZodNumber",(e,t)=>{Bh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>H3(e,n,i,r),e.isFinite=!0},ve.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zr(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zr(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=Zr(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zr(e).format??null},{gt(e,t){return this.check(Vo(e,t))},gte(e,t){return this.check(Ui(e,t))},min(e,t){return this.check(Ui(e,t))},lt(e,t){return this.check(Eo(e,t))},lte(e,t){return this.check(qi(e,t))},max(e,t){return this.check(qi(e,t))},int(e){return this.check(Gb(e))},safe(e){return this.check(Gb(e))},positive(e){return this.check(Vo(0,e))},nonnegative(e){return this.check(Ui(0,e))},negative(e){return this.check(Eo(0,e))},nonpositive(e){return this.check(qi(0,e))},multipleOf(e,t){return this.check(_a(e,t))},step(e,t){return this.check(_a(e,t))},finite(){return this}}));function VP(e){return r3(Ql,e)}var mc=G("ZodNumberFormat",(e,t)=>{ox.init(e,t),Ql.init(e,t)});function Gb(e){return o3(mc,e)}function VM(e){return a3(mc,e)}function WM(e){return s3(mc,e)}function HM(e){return c3(mc,e)}function ZM(e){return l3(mc,e)}var _l=G("ZodBoolean",(e,t)=>{ld.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Z3(e,n,i,r)});function WP(e){return u3(_l,e)}var $l=G("ZodBigInt",(e,t)=>{Yh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>D3(e,n,i,r)},ve.derived({minValue:e=>Zr(e).minimum??null,maxValue:e=>Zr(e).maximum??null,format:e=>Zr(e).format??null},{gte(e,t){return this.check(Ui(e,t))},min(e,t){return this.check(Ui(e,t))},gt(e,t){return this.check(Vo(e,t))},lt(e,t){return this.check(Eo(e,t))},lte(e,t){return this.check(qi(e,t))},max(e,t){return this.check(qi(e,t))},positive(e){return this.check(Vo(BigInt(0),e))},negative(e){return this.check(Eo(BigInt(0),e))},nonpositive(e){return this.check(qi(BigInt(0),e))},nonnegative(e){return this.check(Ui(BigInt(0),e))},multipleOf(e,t){return this.check(_a(e,t))}}));function DM(e){return d3($l,e)}var m0=G("ZodBigIntFormat",(e,t)=>{ax.init(e,t),$l.init(e,t)});function qM(e){return p3(m0,e)}function UM(e){return h3(m0,e)}var HP=G("ZodSymbol",(e,t)=>{sx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>q3(e,n,i,r)});function CM(e){return b3(HP,e)}var ZP=G("ZodUndefined",(e,t)=>{cx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>C3(e,n,i,r)});function JM(e){return g3(ZP,e)}var DP=G("ZodNull",(e,t)=>{lx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>U3(e,n,i,r)});function qP(e){return v3(DP,e)}var UP=G("ZodAny",(e,t)=>{ux.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>G3(e,n,i,r)});function KM(){return y3(UP)}var CP=G("ZodUnknown",(e,t)=>{fx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>A3(e,n,i,r)});function lc(){return w3(CP)}var JP=G("ZodNever",(e,t)=>{dx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>K3(e,n,i,r)});function p0(e){return x3(JP,e)}var KP=G("ZodVoid",(e,t)=>{mx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>J3(e,n,i,r)});function GM(e){return P3(KP,e)}var Md=G("ZodDate",(e,t)=>{px.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>B3(e,n,i,r),e.min=(n,i)=>e.check(Ui(n,i)),e.max=(n,i)=>e.check(qi(n,i))},ve.derived({minDate:e=>{let{minimum:t}=Zr(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Zr(e);return t?new Date(t):null}},{}));function AM(e){return k3(Md,e)}var GP=G("ZodArray",(e,t)=>{fc(),hx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sP(e,n,i,r),e.element=t.element},{min(e,t){return this.check(pa(e,t))},nonempty(e){return this.check(pa(1,e))},max(e,t){return this.check(ac(e,t))},length(e,t){return this.check(sc(e,t))},unwrap(){return this.element}});function Ld(e,t){return z3(GP,e,t)}function BM(e){let t=e._zod.def.shape;return h0(Object.keys(t))}var Rd=G("ZodObject",(e,t)=>{fc(),bx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cP(e,n,i,r),ve.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return h0(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ve.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ve.mergeDefs(this._zod.def,{catchall:lc()}))},loose(){return this.clone(ve.mergeDefs(this._zod.def,{catchall:lc()}))},strict(){return this.clone(ve.mergeDefs(this._zod.def,{catchall:p0()}))},strip(){return this.clone(ve.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return ve.extend(this,e)},safeExtend(e){return ve.safeExtend(this,e)},merge(e){return ve.merge(this,e)},pick(e){return ve.pick(this,e)},omit(e){return ve.omit(this,e)},partial(...e){return ve.partial(Xd,this,e[0])},exactPartial(...e){return ve.partial(g0,this,e[0],"exactPartial")},required(...e){return ve.required(v0,this,e[0])}});function YM(e,t){let n={type:"object",shape:e??{},...ve.normalizeParams(t)};return new Rd(n)}function QM(e,t){return new Rd({type:"object",shape:e,catchall:p0(),...ve.normalizeParams(t)})}function _M(e,t){return new Rd({type:"object",shape:e,catchall:lc(),...ve.normalizeParams(t)})}var Nd=G("ZodUnion",(e,t)=>{ud.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Db(e,n,i,r),e.options=t.options});function eu(e,t){return new Nd({type:"union",options:e,...ve.normalizeParams(t)})}var AP=G("ZodXor",(e,t)=>{Nd.init(e,t),gx.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Db(e,n,i,r),e.options=t.options});function $M(e,t){return new AP({type:"union",options:e,inclusive:!1,...ve.normalizeParams(t)})}var BP=G("ZodDiscriminatedUnion",(e,t)=>{Nd.init(e,t),yx.init(e,t)});function eL(e,t,n){return new BP({type:"union",options:t,discriminator:e,...ve.normalizeParams(n)})}var YP=G("ZodIntersection",(e,t)=>{wx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lP(e,n,i,r)});function QP(e,t){return new YP({type:"intersection",left:e,right:t})}var _P=G("ZodTuple",(e,t)=>{fc(),Qh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uP(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Xd({type:"optional",innerType:t}))})}});function $P(e,t,n){let i=t instanceof Wt,r=i?n:t,o=i?t:null;return new _P({type:"tuple",items:e,rest:o,...ve.normalizeParams(r)})}var Al=G("ZodRecord",(e,t)=>{fc(),xx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fP(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ek(e,t,n){return!t||!t._zod?new Al({type:"record",keyType:Td(),valueType:e,...ve.normalizeParams(t)}):new Al({type:"record",keyType:e,valueType:t,...ve.normalizeParams(n)})}function tL(e,t,n){return new Al({type:"record",keyType:e,valueType:t,...ve.normalizeParams(n),partial:!0})}function nL(e,t,n){return new Al({type:"record",keyType:e,valueType:t,mode:"loose",...ve.normalizeParams(n)})}var tk=G("ZodMap",(e,t)=>{fc(),Px.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>oP(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Wo(...n)),e.nonempty=n=>e.check(Wo(1,n)),e.max=(...n)=>e.check($a(...n)),e.size=(...n)=>e.check(oc(...n))});function rL(e,t,n){return new tk({type:"map",keyType:e,valueType:t,...ve.normalizeParams(n)})}var nk=G("ZodSet",(e,t)=>{fc(),kx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>aP(e,n,i,r),e.min=(...n)=>e.check(Wo(...n)),e.nonempty=n=>e.check(Wo(1,n)),e.max=(...n)=>e.check($a(...n)),e.size=(...n)=>e.check(oc(...n))});function iL(e,t){return new nk({type:"set",valueType:e,...ve.normalizeParams(t)})}var Bl=G("ZodEnum",(e,t)=>{Sx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>Y3(e,i,r,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let a of i)if(n.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Bl({...t,checks:[],...ve.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let a of i)if(n.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Bl({...t,checks:[],...ve.normalizeParams(r),entries:o})}});function h0(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Bl({type:"enum",entries:n,...ve.normalizeParams(t)})}function oL(e,t){return new Bl({type:"enum",entries:e,...ve.normalizeParams(t)})}var rk=G("ZodLiteral",(e,t)=>{Tx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Q3(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function aL(e,t){return new rk({type:"literal",values:Array.isArray(e)?e:[e],...ve.normalizeParams(t)})}var ik=G("ZodFile",(e,t)=>{zx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>eP(e,n,i,r),e.min=(n,i)=>e.check(Wo(n,i)),e.max=(n,i)=>e.check($a(n,i)),e.mime=(n,i)=>e.check(Hl(Array.isArray(n)?n:[n],i))});function sL(e){return O3(ik,e)}var ok=G("ZodTransform",(e,t)=>{fc(),Ox.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>iP(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Qa(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(ve.issue(o,n.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(ve.issue(a))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function b0(e){return new ok({type:"transform",transform:e})}var Xd=G("ZodOptional",(e,t)=>{_h.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function uc(e){return new Xd({type:"optional",innerType:e})}var g0=G("ZodExactOptional",(e,t)=>{Mx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ak(e){return new g0({type:"optional",innerType:e})}var sk=G("ZodNullable",(e,t)=>{Lx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function zd(e){return new sk({type:"nullable",innerType:e})}function cL(e){return uc(zd(e))}var ck=G("ZodDefault",(e,t)=>{Rx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lk(e,t){return new ck({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ve.shallowClone(t)}})}var uk=G("ZodPrefault",(e,t)=>{Nx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function fk(e,t){return new uk({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ve.shallowClone(t)}})}var v0=G("ZodNonOptional",(e,t)=>{Xx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function dk(e,t){return new v0({type:"nonoptional",innerType:e,...ve.normalizeParams(t)})}var mk=G("ZodSuccess",(e,t)=>{jx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function lL(e){return new mk({type:"success",innerType:e})}var pk=G("ZodCatch",(e,t)=>{Fx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hk(e,t){return new pk({type:"catch",innerType:e,catchValue:typeof t=="function"?t:ve.constantCatch(t)})}var bk=G("ZodNaN",(e,t)=>{Ix.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_3(e,n,i,r)});function uL(e){return T3(bk,e)}var jd=G("ZodPipe",(e,t)=>{$h.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vP(e,n,i,r),e.in=t.in,e.out=t.out});function Ab(e,t){return new jd({type:"pipe",in:e,out:t})}var Fd=G("ZodCodec",(e,t)=>{jd.init(e,t),fd.init(e,t)});function fL(e,t,n){return new Fd({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function dL(e){let t=e._zod.def;return new Fd({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var gk=G("ZodPreprocess",(e,t)=>{jd.init(e,t),Ex.init(e,t)}),vk=G("ZodReadonly",(e,t)=>{Vx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function yk(e){return new vk({type:"readonly",innerType:e})}var wk=G("ZodTemplateLiteral",(e,t)=>{Wx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$3(e,n,i,r)});function mL(e,t){return new wk({type:"template_literal",parts:e,...ve.normalizeParams(t)})}var xk=G("ZodLazy",(e,t)=>{dd.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xP(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});function Pk(e){return new xk({type:"lazy",getter:e})}var kk=G("ZodPromise",(e,t)=>{Zx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function pL(e){return new kk({type:"promise",innerType:e})}var Sk=G("ZodFunction",(e,t)=>{Hx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rP(e,n,i,r)});function hL(e){return new Sk({type:"function",input:Array.isArray(e?.input)?$P(e?.input):e?.input??Ld(lc()),output:e?.output??lc()})}var Id=G("ZodCustom",(e,t)=>{Dx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>nP(e,n,i,r)});function bL(e){let t=new _n({check:"custom"});return t._zod.check=e,t}function gL(e,t){return M3(Id,e??(()=>!0),t)}function Tk(e,t={}){return L3(Id,e,t)}function zk(e,t){return R3(e,t)}var vL=N3,yL=X3,Ok=G("ZodInstanceOf",(e,t)=>{Id.init(e,t)},{properties(e,t){return this.check(Wl(e,t))}});function wL(e,t={}){let n=new Ok({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...ve.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}var xL=(...e)=>j3({Codec:Fd,Boolean:_l,String:Yl},...e);function PL(e){let t=Pk(()=>eu([Td(e),VP(),WP(),qP(),Ld(t),ek(Td(),t)]));return t}function kL(e,t){return new gk({type:"pipe",in:b0(e),out:t})}var YB={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function QB(e){kr({customError:e})}function _B(){return kr().customError}var Mk;Mk||(Mk={});var Ed={};ra(Ed,{ZodISODate:()=>is,ZodISODateTime:()=>rs,ZodISODuration:()=>as,ZodISOTime:()=>os,date:()=>eY,datetime:()=>$B,duration:()=>nY,time:()=>tY});function $B(e){return yd(rs,e)}function eY(e){return wd(is,e)}function tY(e){return xd(os,e)}function nY(e){return Pd(as,e)}var et={...tu,...Jb,iso:Ed},rY=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function iY(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function SL(e,t){return e.map((n,i)=>i<t?n:n.optional())}function oY(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function aY(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1]===void 0?void 0:oY(n[1]);if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function sY(e,t){return et.transform(i=>i).check(i=>{let r=i.value;if(typeof r!="object"||r===null||Array.isArray(r))return;let o=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&o.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let a of o){let s=t.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function Lk(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let i=String(e);return`${n[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let o=[];for(let a of e){let s=Lk(a,t);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(e).sort(),r=[];for(let o of i){let a=Lk(e[o],t);if(a===null)return null;r.push(`${o.length}:${o}=${a}`)}return`o${r.length}:{${r.join(",")}}`}finally{t.delete(e)}}var cY=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),lY=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Vd(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Vd):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>cY.has(t)?Vd(n):!lY.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Vd))}function TL(e){return e===1?"element":"elements"}function uY(e,t){return et.transform(i=>i).check(i=>{let r=i.value;if(Array.isArray(r)){if(t.uniqueItems===!0){let o=new Map;for(let a=0;a<r.length;a++){let s=Lk(r[a],new Set);if(s===null)continue;let c=o.get(s);if(c===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:r,path:[a],continue:!0})}}if(t.containsSchema){let o=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let c of r)if(t.containsSchema.safeParse(c).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${TL(o)}; found ${s}`,input:r,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${TL(t.maxContains)}`,input:r,continue:!0})}}}).pipe(e)}function zL(e,t){if(e!==!1)return e===void 0||e===!0?et.any():ki(e,t)}var fY=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function OL(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return et.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return et.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=aY(r,t),a=ki(o,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return et.null();if(r.length===0)return et.never();if(r.length===1)return et.literal(r[0]);if(r.every(a=>typeof a=="string"))return et.enum(r);let o=r.map(a=>et.literal(a));return o.length<2?o[0]:et.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return et.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let a={...e,type:o};return OL(a,t)});return r.length===0?et.never():r.length===1?r[0]:et.union(r)}if(!n)return et.any();let i;switch(n){case"string":{let r=et.string();if(e.format){let o=e.format;o==="email"?r=r.check(et.email()):o==="uri"||o==="uri-reference"?r=r.check(et.url()):o==="uuid"||o==="guid"?r=r.check(et.uuid()):o==="date-time"?r=r.check(et.iso.datetime({offset:!0})):o==="date"?r=r.check(et.iso.date()):o==="time"?r=r.check(et.regex(fY)):o==="duration"?r=r.check(et.iso.duration()):o==="hostname"?r=r.check(et.hostname()):o==="ipv4"?r=r.check(et.ipv4()):o==="ipv6"?r=r.check(et.ipv6()):o==="mac"?r=r.check(et.mac()):o==="cidr"?r=r.check(et.cidrv4()):o==="cidr-v6"?r=r.check(et.cidrv6()):o==="base64"?r=r.check(et.base64()):o==="base64url"?r=r.check(et.base64url()):o==="e164"?r=r.check(et.e164()):o==="credit_card"?r=r.check(et.creditCard()):o==="iban"?r=r.check(et.iban()):o==="jwt"?r=r.check(et.jwt()):o==="emoji"?r=r.check(et.emoji()):o==="nanoid"?r=r.check(et.nanoid()):o==="cuid"?r=r.check(et.cuid()):o==="cuid2"?r=r.check(et.cuid2()):o==="ulid"?r=r.check(et.ulid()):o==="xid"?r=r.check(et.xid()):o==="ksuid"&&(r=r.check(et.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?et.number().int():et.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=et.boolean();break}case"null":{i=et.null();break}case"object":{let r={},o=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ki(e.additionalProperties,t):void 0;for(let[f,d]of Object.entries(o)){let m=ki(d,t);_r(r,f,a.has(f)?m:m.optional())}if(e.patternProperties){let f=e.patternProperties,d=Object.keys(f),m=[];for(let h of d){let b=ki(f[h],t),v=et.string().regex(new RegExp(h));m.push(et.looseRecord(v,b))}let p=[];if(Object.keys(r).length>0&&p.push(et.object(r).passthrough()),p.push(...m),p.length===0)i=et.object({}).passthrough();else if(p.length===1)i=p[0];else{let h=et.intersection(p[0],p[1]);for(let b=2;b<p.length;b++)h=et.intersection(h,p[b]);i=h}if(e.additionalProperties===!1){let h=Object.keys(r),b=d.map(g=>new RegExp(g)),v=i;i=i.check(g=>{if(!Qi(g.value))return;let y=[];for(let w of Object.keys(g.value))h.includes(w)||b.some(x=>x.test(w))||y.push(w);y.length&&g.issues.push({code:"unrecognized_keys",keys:y,input:g.value,inst:v})})}}else{let f=et.object(r);e.additionalProperties===!1?i=f.strict():s?i=f.catchall(s):i=f.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,u=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||l!==void 0||u!==void 0){let f;if(c){let d=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;f=ki(d,t)}i=sY(i,{keySchema:f,minProperties:l,maxProperties:u})}break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,s=r.map(f=>ki(f,t)),c=SL(s,a),l=Array.isArray(o)?void 0:zL(o,t),u=et.tuple(c);i=l?u.rest(l):u,typeof e.minItems=="number"&&(i=i.check(et.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(et.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,s=o.map(f=>ki(f,t)),c=SL(s,a),l=zL(e.additionalItems,t),u=et.tuple(c);i=l?u.rest(l):u,typeof e.minItems=="number"&&(i=i.check(et.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(et.maxLength(e.maxItems)))}else if(o!==void 0){let a=ki(o,t),s=et.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=et.array(et.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=uY(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?ki(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return i}function ki(e,t){if(typeof e=="boolean")return e?et.any():et.never();let n=OL(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>ki(l,t)),c=et.union(s);n=i?et.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>ki(l,t)),c=et.xor(s);n=i?et.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:et.any();else{let s=i?n:ki(e.allOf[0],t),c=i?0:1;for(let l=c;l<e.allOf.length;l++)s=et.intersection(s,ki(e.allOf[l],t));n=s}e.nullable===!0&&t.version==="openapi-3.0"&&(n=et.nullable(n)),e.readOnly===!0&&(n=et.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(r[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(r[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Vd(e.propertyNames)&&(r.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(r[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Vd(e.contains)&&(r.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(r[s]=e[s])}for(let s of Object.keys(e))rY.has(s)||_r(r,s,e[s]);return Object.keys(r).length>0&&t.registry.add(n,r),e.description&&(n=n.describe(e.description)),n}function ML(e,t){if(typeof e=="boolean")return e?et.any():et.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=iY(n,t?.defaultTarget),r=n.$defs||n.definitions||{},o={version:i,defs:r,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??$r};return ki(n,o)}var LL=Symbol("z.visit/resolving");function Wd(e,t){let n=typeof t=="function"?t:(a,s)=>{let c=t[a._zod.def.type];return c?c(a,s):a},i=new Map;function r(a){let s=i.get(a);if(s===LL)return new dd({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,LL);let c=o(a),l=n(c,c!==a);return i.set(a,l),l}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let l=s.shape,u=Object.keys(l),f=!1,d={};for(let p of u){let h=r(l[p]);h!==l[p]&&(f=!0),d[p]=h}let m=s.catchall;return s.catchall&&(m=r(s.catchall),m!==s.catchall&&(f=!0)),f?Hn(a,{...s,shape:d,catchall:m}):a}case"array":{let l=r(s.element);return l===s.element?a:Hn(a,{...s,element:l})}case"tuple":{let l=s.items,u=!1,f=[];for(let m of l){let p=r(m);p!==m&&(u=!0),f.push(p)}let d=s.rest;return s.rest&&(d=r(s.rest),d!==s.rest&&(u=!0)),u?Hn(a,{...s,items:f,rest:d}):a}case"record":case"map":{let l=r(s.keyType),u=r(s.valueType);return l===s.keyType&&u===s.valueType?a:Hn(a,{...s,keyType:l,valueType:u})}case"set":{let l=r(s.valueType);return l===s.valueType?a:Hn(a,{...s,valueType:l})}case"union":{let l=s.options,u=!1,f=[];for(let d of l){let m=r(d);m!==d&&(u=!0),f.push(m)}return u?Hn(a,{...s,options:f}):a}case"intersection":{let l=r(s.left),u=r(s.right);return l===s.left&&u===s.right?a:Hn(a,{...s,left:l,right:u})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=r(s.innerType);return l===s.innerType?a:Hn(a,{...s,innerType:l})}case"pipe":{let l=r(s.in),u=r(s.out);return l===s.in&&u===s.out?a:Hn(a,{...s,in:l,out:u})}case"function":{let l=r(s.input),u=r(s.output);return l===s.input&&u===s.output?a:Hn(a,{...s,input:l,output:u})}case"lazy":{let l=s.getter,{_cachedInner:u,...f}=s;return Hn(a,{...f,getter:()=>r(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return r(e)}function RL(e){return Wd(e,{object:t=>t.partial(),union:t=>{let n=t._zod.def;return n.discriminator===void 0?t:eu(n.options)}})}function dY(e,t){if(!t?.length)return e;let n=e._zod.def;return Hn(e,po(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function NL(e){return dY(e.out,e.checks)}function mY(e){return e.in._zod.traits.has("$ZodTransform")?NL(e):e.in}function XL(e){return Wd(e,{pipe:t=>mY(t._zod.def),default:(t,n)=>n?uc(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function jL(e){return Wd(e,{pipe:t=>NL(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}var Rk={};ra(Rk,{bigint:()=>gY,boolean:()=>bY,date:()=>vY,number:()=>hY,string:()=>pY});function pY(e){return _x(Yl,e)}function hY(e){return i3(Ql,e)}function bY(e){return f3(_l,e)}function gY(e){return m3($l,e)}function vY(e){return S3(Md,e)}import{AsyncLocalStorage as PY}from"node:async_hooks";var Nk=()=>{throw new Error("this build has no local engine \u2014 timelines are read and written on conform.tools")};function FL(e,t){return Nk()}function IL(e,t){return Nk()}function EL(e){return Nk()}KT(!0);var VL={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml"},wY=Object.keys(VL),xY=new Set([502,503,504,529,546]),WL=(e,t)=>`${Un().supabaseUrl}/functions/v1/${e}${t}`;async function HL(){let e=await uo();if(!e&&Rt("CONFORM_ANONYMOUS_READ")==="1")return Un().anonKey;if(!e)throw new Te("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function ZL(e,t){let n;for(let i=0;i<3;i++){try{let r=await fetch(e,t);if(!xY.has(r.status)||i===2)return r;n=new Error(`status ${r.status}`)}catch(r){if(n=r,i===2)break}await new Promise(r=>setTimeout(r,1500*(i+1)))}throw new Te("offline",`conform.tools is unreachable (${n instanceof Error?n.message:String(n)}) \u2014 reading and writing timelines need the network`)}async function DL(e,t){let i=(await e.json().catch(()=>({})))?.error?.message??`${t} failed (${e.status})`;throw e.status===401?new Te("not_signed_in",`${i} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new Te("not_entitled",i):new Te(e.status>=500?"engine":"refused",i)}async function qL(e,t){let n=VL[e];if(!n)throw new Te("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:i,extract:r}=await GT(t,n),a=JSON.stringify({format:i,source_filename:t.name,persist:!1})+`
78
- `+(typeof r=="string"?r:JSON.stringify(r)),s=await ZL(WL("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":"application/x-ct-canonicalize-v1",authorization:`Bearer ${await HL()}`,apikey:Un().anonKey},body:a});s.ok||await DL(s,"read");let c=await s.json();return JSON.stringify(c.session)}async function UL(e,t){let n=await ZL(WL("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await HL()}`,apikey:Un().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:t})});n.ok||await DL(n,"write");let i=BT(n.headers.get(AT))??[];if(n.headers.get("x-engine-delivery")==="cdn"){let o=await n.json(),a=await fetch(o.download_url);if(!a.ok)throw new Te("engine",`download failed (${a.status})`);let s=new Uint8Array(await a.arrayBuffer());if(s.byteLength!==o.size)throw new Te("engine",`download incomplete: ${s.byteLength} of ${o.size} bytes`);return{body:s,contentType:o.content_type,filenameSuggestion:o.filename,issues:i}}let r=n.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await n.arrayBuffer()),contentType:n.headers.get("content-type")??"application/octet-stream",filenameSuggestion:r??`timeline.${e}`,issues:i}}var Xk=new PY;function jk(e){let t=Xk.getStore();if(!t||t.declared.includes(e))return;let n=`verb '${t.verb}' reached the protected stage '${e}' without declaring it in protectedStages (core/verbs.ts)`;if(Rt("CONFORM_STRICT_STAGES")==="1")throw new Te("internal",n);console.error(`[conform] warning: ${n}`)}var JL=!1;function pc(){return Rt("CONFORM_ENGINE")==="hosted"||!!1?"hosted":"local"}async function KL(e){return jk("canonicalize"),pc()==="local"?await FL(e.fmt,e.data):await qL(e.fmt,e.file)}async function y0(e,t){return jk("write"),pc()==="local"?await IL(e,t):await UL(e,t)}async function GL(e){if(pc()!=="local")return null;jk("canonicalize");let t=JSON.parse(await EL(JSON.stringify(e)));return{session:t.session,issues:t.issues??[]}}var u0e="io.modelcontextprotocol/skills",YL=3e5,kY=512,SY=16*1024*1024;async function TY(){let e=Rt("CONFORM_PLAYBOOKS_DIR");if(e)return await gi(e)?e:null;let t=Pr(new URL("../../api/playbooks/",import.meta.url));return await gi(t)?t:null}var zY={md:"text/markdown",txt:"text/plain",json:"application/json",yaml:"application/yaml",yml:"application/yaml",py:"text/x-python",ts:"text/typescript",js:"text/javascript",sh:"text/x-shellscript",csv:"text/csv",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",svg:"image/svg+xml",pdf:"application/pdf"},OY=e=>zY[e.split(".").pop()?.toLowerCase()??""]??"application/octet-stream";async function MY(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",e));return"sha256:"+Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function LY(e){let t=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e);if(!t)return null;let n={};for(let i of t[1].split(/\r?\n/)){let r=/^([A-Za-z0-9_-]+):\s*(.*)$/.exec(i);if(!r)continue;let o=r[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),n[r[1]]=o}return n}async function QL(e,t,n,i){let r=[];for await(let o of dn(e))r.push(o);r.sort((o,a)=>o.name.localeCompare(a.name));for(let o of r){if(o.name.startsWith("."))continue;let a=t?`${t}/${o.name}`:o.name;o.isDirectory?(i.push(a),await QL(Q(e,o.name),a,n,i)):o.isFile&&n.push({rel:a,abs:Q(e,o.name)})}}async function RY(e){let t=[];for await(let i of dn(e))i.isDirectory&&!i.name.startsWith(".")&&t.push(i.name);let n=[];for(let i of t.sort()){let r=[];await QL(Q(e,i),"",r,[]),n.push({name:i,files:await Promise.all(r.filter(o=>o.rel.endsWith(".md")).map(async o=>({path:o.rel,bytes:await er(o.abs)})))})}return n}var NY=()=>`${Un().supabaseUrl}/functions/v1/v1-me/v1/engine/playbooks`;async function XY(){let e=await uo().catch(()=>null);if(!e)throw new Error("not signed in: call account_login, then try again");let t=await fetch(NY(),{headers:{authorization:`Bearer ${e}`,apikey:Un().anonKey},signal:AbortSignal.timeout(8e3)}),n=await t.json().catch(()=>null);if(!t.ok||!Array.isArray(n?.playbooks))throw new Error(n?.error?.message??`conform.tools answered ${t.status}`);let i=new TextEncoder;return{version:String(n.version??"unknown"),skills:n.playbooks.map(r=>({name:r.name,files:r.files.map(o=>({path:o.path,bytes:i.encode(o.text)}))}))}}async function AL(e){let t=[];for(let n of e){if(!n.files.some(s=>s.path==="SKILL.md"))continue;let i=`skill://${n.name}`,r=[],o=new Set([""]);for(let s of[...n.files].sort((c,l)=>c.path.localeCompare(l.path))){let c=s.path.split("/");for(let l=1;l<c.length;l++)o.add(c.slice(0,l).join("/"));r.push({uri:`${i}/${s.path}`,path:s.path,name:c[c.length-1],bytes:s.bytes,digest:await MY(s.bytes),mimeType:OY(s.path)})}let a=LY(new TextDecoder().decode(r.find(s=>s.path==="SKILL.md").bytes));!a||a.name!==n.name||typeof a.description!="string"||r.length>kY||r.reduce((s,c)=>s+c.bytes.length,0)>SY||t.push({name:n.name,uri:`${i}/SKILL.md`,root:i,frontmatter:a,files:r,dirs:o})}return t}var w0=null;function Fk(){w0??=(async()=>{let t=await TY();if(t)return{skills:await AL(await RY(t)),source:"local",version:"local"};let n=await XY();return{skills:await AL(n.skills),source:"conform.tools",version:n.version}})();let e=w0;return e.catch(()=>{w0===e&&(w0=null)}),e}async function P0(){try{return(await Fk()).skills}catch{return[]}}function _L(e){return{uri:e.uri,frontmatter:e.frontmatter,resources:e.files.map(t=>({uri:t.uri,digest:t.digest,size:t.bytes.length}))}}var x0=class extends Error{constructor(n,i){super(i);this.code=n}},$L=-32602;async function f0e(){return{resultType:"complete",skills:(await P0()).map(_L),ttlMs:YL,cacheScope:"public"}}async function d0e(e){let t=(await P0()).find(n=>n.uri===e);if(!t)throw new x0($L,`No skill is served at ${String(e)}`);return{resultType:"complete",skill:_L(t),ttlMs:YL,cacheScope:"public"}}async function m0e(e){let t=String(e??"").replace(/\/$/,"");for(let n of await P0()){if(t!==n.root&&!t.startsWith(n.root+"/"))continue;let i=t===n.root?"":t.slice(n.root.length+1);if(!n.dirs.has(i))break;let r=i?i+"/":"",o=[];for(let a of[...n.dirs].sort())a&&a.startsWith(r)&&!a.slice(r.length).includes("/")&&o.push({uri:`${n.root}/${a}`,name:a.slice(r.length),mimeType:"inode/directory"});for(let a of n.files)a.path.startsWith(r)&&!a.path.slice(r.length).includes("/")&&o.push({uri:a.uri,name:a.name,mimeType:a.mimeType});return{resultType:"complete",resources:o}}throw new x0($L,`No skill directory at ${t}`)}async function p0e(){let e=await P0();return e.length?["Skills: this server ships Agent Skills that say how a conform artist uses these tools. Load the one that fits the task:",...e.map(t=>`- ${t.uri} \u2014 ${t.frontmatter.description}`)].join(`
79
- `):""}var eR=["conform","autoconform","deliver","deliverables","troubleshoot","patch"],Ik=["avid","premiere","resolve","finalcut","flame","baselight","protools"],jY={conform:["conform-artist",["SKILL.md","references/turnover-checklist.md"]],autoconform:["auto-conform",["SKILL.md"]],deliver:["delivery-qc",["SKILL.md"]],deliverables:["deliverables",["SKILL.md"]],troubleshoot:["conform-artist",["references/troubleshooting.md"]],patch:["finishing-fixes",["SKILL.md"]]},BL={avid:"references/avid.md",premiere:"references/premiere.md",resolve:"references/resolve.md",finalcut:"references/other-hosts.md",flame:"references/other-hosts.md",baselight:"references/other-hosts.md",protools:"references/other-hosts.md"},FY=e=>e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trimStart(),tR=new Set,nR=()=>tR.size>0;async function rR(e,t=[]){let{skills:n,version:i}=await Fk(),[r,o]=jY[e],a=n.find(d=>d.name===r);if(!a)throw new Error(`the ${r} playbook is not available (version ${i})`);let s=n.find(d=>d.name==="conform-artist"),c=o.map(d=>[a,d]);for(let d of t)c.some(([,m])=>m===BL[d])||c.push([s,BL[d]]);let l=[],u=[];for(let[d,m]of c){let p=d?.files.find(h=>h.path===m);p&&(u.push(p.uri),l.push(`<!-- ${p.uri} -->
80
- ${FY(new TextDecoder().decode(p.bytes)).trimEnd()}`))}tR.add(e);let f=`conform.tools playbook \u2014 ${e} (version ${i}). Follow it for this task; it says how a conform artist uses these tools and what to tell the user.`;return{task:e,version:i,files:u,text:[f,...l].join(`
81
-
82
- ---
83
-
84
- `)}}async function Hd(e,t){let n;try{n=(await Fk()).skills.find(a=>a.name===e)}catch{return""}let i=n?.files.find(a=>a.path==="SKILL.md");if(!i)return"";let r=new Set(["always",...t]),o=[];for(let a of new TextDecoder().decode(i.bytes).split(/^(?=#{1,3} )/m)){let s=a.match(/^### (.+?) \(when: ([a-z_, ]+)\)\s*\n/);s&&s[2].split(",").some(c=>r.has(c.trim()))&&o.push(`**${s[1]}.** ${a.slice(s[0].length).trim().replace(/\s*\n\s*/g," ")}`)}return o.join(`
85
- `)}var IY=vt(),hc=Q(IY,"jobs"),Zd=new Map;function EY(){let e=new Uint8Array(4);return crypto.getRandomValues(e),"job-"+Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}async function k0(e){try{await bt(hc),await rn(Q(hc,`${e.id}.json`),JSON.stringify(e));let{result:t,...n}=e;await rn(Q(hc,".current"),JSON.stringify(n))}catch{}}function Dd(e,t){let n=new AbortController,i=new Date().toISOString(),r={id:EY(),verb:e,status:"running",started_at:i,updated_at:i,phase:"starting",done:0,total:0},o=0,s=t((c,l,u)=>{r.done=c,r.total=l,r.phase=u,r.updated_at=new Date().toISOString();let f=Date.now();f-o>2e3&&(o=f,k0(r))},n.signal).then(c=>(r.status=c.isError?"failed":"done",r.result=c,r.error=c.isError?c.content[0]?.text:void 0,r.finished_at=new Date().toISOString(),k0(r),c),c=>{r.status=n.signal.aborted?"cancelled":"failed",r.error=c instanceof Error?c.message:String(c),r.finished_at=new Date().toISOString(),k0(r);let l={content:[{type:"text",text:`error: ${r.error}`}],isError:!0,structuredContent:{ok:!1,code:r.status==="cancelled"?"cancelled":"engine",message:r.error}};return r.result=l,l});return Zd.set(r.id,{rec:r,ctrl:n,promise:s}),k0(r),r}function Ek(e){return Zd.get(e)?.promise??null}async function iR(e){let t=Zd.get(e);if(t)return t.rec;try{return JSON.parse(await yn(Q(hc,`${e}.json`)))}catch{return null}}function Vk(e){let t=Zd.get(e);return!t||t.rec.status!=="running"?!1:(t.ctrl.abort(),!0)}async function oR(){let e=new Map;try{await bt(hc);for await(let t of dn(hc))if(t.name.endsWith(".json"))try{let n=JSON.parse(await yn(Q(hc,t.name)));e.set(n.id,n)}catch{}}catch{}for(let t of Zd.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 Wk(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?`
86
- ${e.error}`:""}`}var sR=()=>Q(vt(),"logs","engine.jsonl"),aR=new Set;function cR(e){if(!e||typeof e!="object")return{};let t={};for(let[n,i]of Object.entries(e))typeof i=="string"?t[n]=i.length>200?`${i.slice(0,200)}\u2026`:i:Array.isArray(i)?t[n]=i.length>20?`[${i.length} items]`:i:i&&typeof i=="object"?t[n]=JSON.stringify(i).length>400?"{\u2026}":i:t[n]=i;return t}async function lR(e){let t=JSON.stringify(e);console.error(`[conform] ${e.verb} ${e.ok?"ok":`FAIL ${e.code??""}`} ${e.ms} ms${e.job?` job ${e.job}`:""}`);try{let n=sR(),i=Q(vt(),"logs");aR.has(i)||(await bt(i),aR.add(i)),await rn(n,t+`
87
- `,{append:!0})}catch{}}async function uR(e,t={}){let n="";try{n=await yn(sR())}catch{return[]}let i=n.split(`
88
- `).slice(-5e3),r=[];for(let o=i.length-1;o>=0&&r.length<e;o--){if(!i[o])continue;let a;try{a=JSON.parse(i[o])}catch{continue}let s=t.session_id,c=t.job_id;(s||c)&&!(s&&(a.session===s||a.args?.session_id===s||a.args?.hints_session_id===s)||c&&(a.job===c||a.args?.job_id===c))||r.push(a)}return r.reverse()}var fR=["issue","gap","note"],Dk=["low","medium","high","blocker"],qk=["missing_tool","missing_option","tool_failed","did_not_know","other"];var Hk=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+(?: [^\s"'${"`"}<>|,;()[\]{}\\/:]+(?=$|[\s"'${"`"}<>|,;()[\]{}\\/]))*`,dR=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+`,VY=new RegExp(String.raw`(?<![A-Za-z0-9_.~:\\/-])(?:file://)?(?:~|[A-Za-z]:)?(?:[\\/]${Hk}){2,}[\\/]?|\\\\${Hk}(?:\\${Hk})+`+String.raw`|(?<![A-Za-z0-9_.~:\\/-])${dR}(?:[\\/]${dR}){2,}`,"g");function WY(e){let t=e.replace(/[\\/]+$/,""),n=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return n>=0?t.slice(n+1):t}function mR(e){return e.replace(VY,t=>WY(t.replace(/^file:\/\//,"")))}function Zk(e,t=300,n=0){if(typeof e=="string")return S0(mR(e),t);if(typeof e=="number"||typeof e=="boolean"||e===null)return e;if(n>4)return null;if(Array.isArray(e))return e.slice(0,20).map(i=>Zk(i,t,n+1));if(e&&typeof e=="object"){let i={};for(let[r,o]of Object.entries(e).slice(0,40))i[S0(r,64)]=Zk(o,t,n+1);return i}return null}var S0=(e,t)=>e.length>t?`${e.slice(0,t)}\u2026`:e;function ss(e,t){if(typeof e!="string")return null;let n=e.trim();return n?S0(mR(n),t):null}var HY=/^[A-Za-z0-9_.:-]{1,64}$/;function Zo(e){return typeof e=="string"&&HY.test(e)?e:null}var bc=(e,t)=>typeof e=="string"&&t.includes(e)?e:null;function Uk(e){if(!e||typeof e!="object")return null;let t=e,n={};typeof t.ts=="string"&&(n.ts=S0(t.ts,40));let i=Zo(t.verb);i&&(n.verb=i),typeof t.ms=="number"&&Number.isFinite(t.ms)&&(n.ms=Math.round(t.ms)),typeof t.ok=="boolean"&&(n.ok=t.ok);for(let o of["code","job","session"]){let a=Zo(t[o]);a&&(n[o]=a)}let r=ss(t.msg,500);return r&&(n.msg=r),t.args&&typeof t.args=="object"&&(n.args=Zk(t.args,160)),n.verb?n:null}var li={summary:300,task:500,used_instead:300,what_happened:4e3,expected:4e3};function pR(e){if(!e||typeof e!="object")return"body must be a JSON object";let t=e,n=bc(t.kind??"issue",fR);if(!n)return`kind must be one of ${fR.join(", ")}`;let i=ss(t.task,li.task),r=ss(t.summary,li.summary)??(n==="gap"?i:null);if(!r)return n==="gap"?"task is required":"summary is required";let o=Array.isArray(t.log_lines)?t.log_lines.slice(-20).map(Uk).filter(a=>!!a):[];return{kind:n,summary:r,what_happened:ss(t.what_happened,li.what_happened),expected:ss(t.expected,li.expected),severity:n==="issue"?bc(t.severity,Dk)??"medium":null,session_id:Zo(t.session_id),verb:Zo(t.verb),job_id:Zo(t.job_id),task:n==="gap"?i:null,used_instead:n==="gap"?ss(t.used_instead,li.used_instead):null,why_not_conformtools:n==="gap"?bc(t.why_not_conformtools,qk)??(t.why_not_conformtools?"other":null):null,conformtools_verb_tried:Zo(t.conformtools_verb_tried),version:Zo(t.version),engine:bc(t.engine,["local","hosted"]),platform:ss(t.platform,80),runtime:ss(t.runtime,80),account_env:bc(t.account_env,["production","staging"]),log_lines:o}}var ZY=/^[a-z_]{1,32}$/,DY=/^[A-Za-z0-9_.]{1,64}$/;function qY(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t={};for(let[n,i]of Object.entries(e).slice(0,16))ZY.test(n)&&typeof i=="number"&&Number.isFinite(i)&&i>=0&&(t[n]=Math.round(i));return Object.keys(t).length?t:null}function hR(e){if(!e||typeof e!="object")return null;let t=e,n=bc(t.kind,["outcome","invalid_args"]),i=Zo(t.verb);if(!n||!i)return null;let r=n==="invalid_args"&&Array.isArray(t.fields)?t.fields.filter(o=>typeof o=="string"&&DY.test(o)).slice(0,16):null;return{kind:n,verb:i,ok:n==="outcome"&&typeof t.ok=="boolean"?t.ok:null,code:Zo(t.code),duration_ms:typeof t.duration_ms=="number"&&Number.isFinite(t.duration_ms)&&t.duration_ms>=0?Math.round(t.duration_ms):null,version:Zo(t.version),engine:bc(t.engine,["local","hosted"]),counts:n==="outcome"?qY(t.counts):null,fields:r,run_at:typeof t.run_at=="string"&&!Number.isNaN(Date.parse(t.run_at))?new Date(t.run_at).toISOString():null}}var JY="support@conform.tools",vR=15,bR=2e3,M0e=[`conformtools ${mo} is the conform.tools engine on this machine: timeline exchange between editing hosts (Avid, Premiere, Resolve, Final Cut, Flame), relinking, media probe/trim/consolidate, delivery packages and auto conform. account_status shows the running version and whether a newer one is on npm.`,"0. Before any conform, timeline conversion, relink, verification or delivery task, call conform_learn with the task (and the hosts involved) and follow the playbook it returns. It needs a signed-in account; if it cannot load, carry on with the tools.",'1. When you call one of these tools, say so in one short line first: "using conformtools: <tool>" (for example "using conformtools: timeline_read").','2. Whenever you do a post-production task (anything about timelines, edits, media files, codecs, timecode, relinking, conforming, delivery) with ANYTHING other than conformtools, such as ffmpeg, ffprobe, mediainfo, exiftool, a python or shell script, another MCP server, or manual steps you ask the user to do in a host app, or when conformtools cannot do the task at all, call report_gap once for that task, before or right after the workaround. Say what the user wanted (task), what you used instead (used_instead, e.g. "ffprobe -show_streams"), why not conformtools (missing_tool, missing_option, tool_failed, did_not_know), and what you needed from it (needed: the information or operation, and which of its output fields you used) so the team can build it into conformtools. Tell the user you sent it. Never put full file paths in it; file names at most.',"3. When the user says a conformtools result is wrong, complains about it, corrects an output, or a tool failed unexpectedly, call report_issue with a short summary, what happened and what they expected, plus the session_id / verb / job_id involved. Tell the user it was sent and give them the report id.",'4. A lesson, workflow rule or suggestion (nothing broke: "the patch range runs whole clip before to whole clip after", "this facility files renders in 200 - FINISH") goes to report_note, not report_issue.',"report_issue, report_gap and report_note never send media, file contents or timeline files. Outcome telemetry is off unless the user turned it on (account_telemetry)."].join(`
89
- `),yR=()=>Q(vt(),"config.json");async function wR(){try{return JSON.parse(await yn(yR()))}catch{return{}}}async function KY(e){await bt(vt()),await rn(yR(),JSON.stringify(e,null,1))}async function nu(){return Rt("CONFORM_TELEMETRY")==="off"||Rt("CONFORM_TELEMETRY")==="0"?!1:(await wR()).telemetry===!0}async function xR(e){let t=await wR();t.telemetry=e,t.telemetry_changed_at=new Date().toISOString(),await KY(t),e||await Vr(Cd()).catch(()=>{})}var gR="per tool run: the tool name, ok or the error code, duration, package version, engine mode (local/hosted) and counts (clips, files, matched/unmatched\u2026, numbers only); per rejected call: the tool name and the names of the arguments that failed validation. Never paths, file or clip names, timeline contents or media.";async function PR(){let e=await nu(),t=(await Kk()).length;return e?`outcome telemetry: ON \u2014 records ${gR}
90
- sent in batches at most every ${vR} min${t?`; ${t} event(s) waiting`:""}. Turn off: conformtools telemetry off`:`outcome telemetry: OFF (the default). Nothing is recorded. If turned on it records ${gR} Turn on: conformtools telemetry on`}var GY=e=>`${Un().supabaseUrl}/functions/v1/v1-me/v1/engine/${e}`;async function Ak(e,t,n){return await fetch(GY(e),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`,apikey:Un().anonKey},body:JSON.stringify(t),signal:AbortSignal.timeout(1e4)})}async function T0(e,t){let{platform:n,runtime:i}=ZT(),r=t,o=e==="issue"?(await uR(20,{session_id:r.session_id,job_id:r.job_id})).map(Uk).filter(s=>!!s):[],a=pR({...t,kind:e,version:mo,engine:pc(),platform:n,runtime:i,account_env:Un().env,log_lines:o});if(typeof a=="string")throw new Error(a);return a}async function z0(e){let t=Q(vt(),"reports");await bt(t);let n=Q(t,`${new Date().toISOString().replace(/[:.]/g,"-")}-${e.kind}.json`);await rn(n,JSON.stringify(e,null,1));let i=await uo().catch(()=>null);if(!i)return{sent:!1,saved:n,reason:"not signed in (account_login)"};let r=(await tl().catch(()=>null))?.email??null;try{let o=await Ak("report",e,i),a=await o.json().catch(()=>({}));return!o.ok||!a.id?{sent:!1,saved:n,email:r,status:o.status,reason:`conform.tools answered ${o.status}${a.error?.message?`: ${a.error.message}`:""}`}:(await rn(n,JSON.stringify({id:a.id,...e},null,1)),{sent:!0,id:a.id,saved:n,email:r,resent:await BY(i)})}catch(o){return{sent:!1,saved:n,email:r,reason:`conform.tools is unreachable (${o instanceof Error?o.message:String(o)})`}}}var AY=20,Ck=!1;async function BY(e){if(Ck)return 0;Ck=!0;let t=0,n=0;try{let i=Q(vt(),"reports"),r=[];for await(let o of dn(i))o.isFile&&o.name.endsWith(".json")&&r.push(o.name);for(let o of r.sort()){if(n>=AY)break;let a=Q(i,o),s;try{s=JSON.parse(await yn(a))}catch{continue}if(s.id||s.rejected)continue;n++;let c=await Ak("report",s,e).catch(()=>null),l=await c?.json().catch(()=>({}));if(c?.status===400){await rn(a,JSON.stringify({rejected:l?.error?.message??"400",...s},null,1));continue}if(!c?.ok||!l?.id)break;await rn(a,JSON.stringify({id:l.id,...s},null,1)),t++}}catch{}finally{Ck=!1}return t}function YY(e){let t=e;return Object.entries(li).filter(([n,i])=>typeof t[n]=="string"&&t[n].trim().length>i).map(([n])=>n)}function O0(e,t,n,i){let r=YY(i),o=ut(QY(e,t,n,r),{sent:t.sent,report_id:t.id??null,saved:t.saved,reason:t.reason??null,status:t.status??null,resent:t.resent??0,clipped:r,...e==="issue"?{log_lines:n.log_lines.length}:{}});return t.sent||(o.structuredContent.ok=!1),o}function QY(e,t,n,i=[]){let r=e==="issue"?`issue report${n.log_lines.length?` with the last ${n.log_lines.length} log line(s)${n.session_id||n.job_id?" for that session/job":""}`:""}`:e==="gap"?"tool-gap report":"note",o=i.length?`
91
- Cut to fit: ${i.map(a=>`${a} (max ${li[a]} chars)`).join(", ")}.`:"";return t.sent?`sent ${r} to conform.tools \u2014 report id ${t.id.slice(0,8)}${t.email?` (account ${t.email})`:""}.
92
- No media, file contents or timeline files were sent; paths were cut to file names. Copy of what was sent: ${t.saved}`+(t.resent?`
93
- Also sent ${t.resent} earlier report(s) that had been saved unsent.`:"")+o:`NOT SENT \u2014 ${t.reason}. The ${r} is saved to ${t.saved}; it is resent automatically after the next report that gets through, or send that file to ${JY}.`+o}var Ud=()=>Q(vt(),"telemetry"),Cd=()=>Q(Ud(),"queue.jsonl"),Jk=()=>Q(Ud(),"state.json");async function Kk(){try{return(await yn(Cd())).split(`
94
- `).filter(Boolean).flatMap(e=>{try{return[JSON.parse(e)]}catch{return[]}})}catch{return[]}}var _Y=new Set(["account_login","account_status","account_logout","account_telemetry","report_issue","report_gap","report_note","job_status","job_cancel","job_list","timeline_routes","timeline_sessions"]),$Y=[["clips",/\b(\d+) clips?\b/i],["files",/\b(\d+) (?:output )?files?(?:\(s\))?\b/i],["sources",/\b(\d+) sources?(?:\(s\))?\b/i],["skipped",/\bskipped (\d+)\b/i],["matched",/\b(?:(\d+) matched|matched[: =]+(\d+))\b/i],["unmatched",/\b(?:(\d+) unmatched|unmatched[: =]+(\d+))\b/i],["ambiguous",/\b(?:(\d+) ambiguous|ambiguous[: =]+(\d+))\b/i],["unresolved",/\b(?:(\d+) unresolved|unresolved[: =]+(\d+))\b/i],["linked",/\b(?:(\d+) linked|linked[: =]+(\d+))\b/i],["issues",/\bissues \((\d+)\)/i],["frames",/\((\d+) frames\)/i]];function eQ(e){let t={},n=e.content.map(i=>i.text).join(`
95
- `);for(let[i,r]of $Y){let o=n.match(r),a=o?Number(o[1]??o[2]):NaN;Number.isFinite(a)&&(t[i]=a)}for(let[i,r]of Object.entries(e.structuredContent??{}))typeof r=="number"&&/^[a-z_]{1,32}$/.test(i)&&!(i in t)&&(t[i]=r);return t}async function kR(e){let t=hR(e);t&&(await bt(Ud()),await rn(Cd(),JSON.stringify(t)+`
96
- `,{append:!0}))}var Gk=new Set;function SR(e){return Gk.add(e),e.finally(()=>Gk.delete(e)),e}async function L0e(){await Promise.allSettled([...Gk])}function Bk(e,t,n){return SR(tQ(e,t,n))}async function tQ(e,t,n){try{if(_Y.has(e)||!await nu())return;await kR({kind:"outcome",verb:e,ok:!t.isError,code:t.isError?String(t.structuredContent?.code??"engine"):void 0,duration_ms:n,version:mo,engine:pc(),counts:eQ(t),run_at:new Date().toISOString()}),TR()}catch{}}function Yk(e,t){return SR(nQ(e,t))}async function nQ(e,t){try{if(!await nu())return;await kR({kind:"invalid_args",verb:e,fields:t,version:mo,engine:pc(),run_at:new Date().toISOString()}),TR()}catch{}}function M0(e){return[...new Set(e.map(t=>t.path.map(String).join(".")||"(root)"))]}var qd=null;function TR(e={}){return qd||(qd=(async()=>{try{if(!await nu())return;let t={};try{t=JSON.parse(await yn(Jk()))}catch{}if(!e.force&&!t.last_flush){await bt(Ud()),await rn(Jk(),JSON.stringify({last_flush:Date.now()}));return}if(!e.force&&Date.now()-t.last_flush<vR*6e4)return;let n=await Kk();if(!n.length)return;let i=await uo().catch(()=>null);if(!i)return;await bt(Ud()),await rn(Jk(),JSON.stringify({last_flush:Date.now()}));let r=n.slice(0,500),o=await Ak("telemetry",{events:r},i).catch(()=>null);if(o?.ok||o?.status===400){let a=await Kk();await rn(Cd(),a.slice(r.length).map(s=>JSON.stringify(s)+`
97
- `).join(""))}else n.length>bR&&await rn(Cd(),n.slice(-bR).map(a=>JSON.stringify(a)+`
98
- `).join(""));await o?.body?.cancel().catch(()=>{})}catch{}finally{qd=null}})(),qd)}var rQ=vt(),ru=Q(rQ,"sessions"),L0=new Map;function iQ(){let e=new Uint8Array(4);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}async function ba(e,t,n){let i=new Date().toISOString(),r={id:iQ(),source_path:t,source_format:n,created_at:i,updated_at:i,history:[],session:e};return L0.set(r.id,r),await OR(r),r}async function ui(e){let t=L0.get(e);if(t)return t;try{let n=await yn(Q(ru,`${e}.json`)),i=JSON.parse(n);return L0.set(e,i),i}catch{throw new Error(`unknown session_id '${e}' \u2014 call timeline_read first, or timeline_sessions to list`)}}async function eo(e,t){e.updated_at=new Date().toISOString(),e.history.push(t),L0.set(e.id,e),await OR(e)}async function zR(){await bt(ru);let e=[];for await(let t of dn(ru))if(t.name.endsWith(".json"))try{let n=JSON.parse(await yn(Q(ru,t.name))),{session:i,...r}=n;e.push(r)}catch{}return e.sort((t,n)=>n.updated_at.localeCompare(t.updated_at))}async function OR(e){await bt(ru),await rn(Q(ru,`${e.id}.json`),JSON.stringify(e))}function MR(e,t){if(!t||t<=0)return null;let n=e.match(/^(\d+):(\d+):(\d+)([:;])(\d+)$/);if(!n)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=Math.round(t),c=(i*3600+r*60+o)*s+a;if(n[4]===";"&&(s===30||s===60)){let l=s===60?4:2,u=i*60+r;c-=l*(u-Math.floor(u/10))}return c}function oQ(e){return{path:e.path,resolution_w:e.resolution_w??null,resolution_h:e.resolution_h??null,codec:e.codec??null,container:e.container??null,fps:e.fps??null,bit_depth:e.bit_depth??null,reel:e.reel_name??null,timecode:e.timecode??null}}function Qk(e,t,n,i,r){if(!(e>0&&t>0&&i>0&&r>0))return{baseW:i,baseH:r,kx:1,ky:1};let o=e/t,a=i/r,[s,c]=o>a?[1,o/a]:o<a?[a/o,1]:[1,1],l=Math.max(e/i,t/r)||1;return{baseW:e*n/l,baseH:t/l,kx:s,ky:c}}var R0=(e,{matches:t})=>{let n=e.media_references??[],i=[];for(let o of t){let a=n.find(V=>V.id===o.ref_id);if(!a)continue;let s=a.source_facts_origin??null,c={path:a.target_url??null,resolution_w:a.source_resolution_w??null,resolution_h:a.source_resolution_h??null,codec:a.codec??null,container:a.container??null,fps:a.source_fps??null,bit_depth:a.streams?.[0]?.bit_depth??null,reel:a.reel_name??null,timecode:a.source_timecode??null},l=a.metadata??={};l.pre_relink||(l.pre_relink={...c,pixel_aspect:a.source_pixel_aspect??null,facts_origin:a.source_facts_origin??null,available_range:a.available_range?JSON.parse(JSON.stringify(a.available_range)):null});let u=o.to;a.target_url=u.path,u.size_bytes!=null&&(a.size_bytes=u.size_bytes),u.resolution_w!=null&&(a.source_resolution_w=u.resolution_w),u.resolution_h!=null&&(a.source_resolution_h=u.resolution_h),u.codec!=null&&(a.codec=u.codec),u.container!=null&&(a.container=u.container),u.fps!=null&&(a.source_fps=u.fps),u.pixel_aspect!=null&&(a.source_pixel_aspect=u.pixel_aspect),u.bitrate_bps!=null&&(a.bitrate_bps=u.bitrate_bps),u.reel_name!=null&&(a.reel_name=u.reel_name),u.timecode!=null&&(a.source_timecode=u.timecode),u.local_path!=null&&(a.local_path=u.local_path),u.streams&&u.streams.length>0&&(a.streams=u.streams),(u.resolution_w!=null||u.timecode!=null||u.fps!=null||u.pixel_aspect!=null)&&(a.source_facts_origin="probed"),u.vendor_metadata&&Object.keys(u.vendor_metadata).length>0&&(a.vendor_metadata={...a.vendor_metadata??{},...u.vendor_metadata}),u.reel_sources&&(a.reel_sources={...a.reel_sources??{},...u.reel_sources}),u.recipe!==void 0&&(a.recipe=u.recipe);let f=u.fps??null,d=u.recipe&&"frame_count"in u.recipe?u.recipe.frame_count:u.frame_count??null,m=d??null,p=f??a.source_fps??null;m!=null&&p?a.available_range={start:{value:0,rate:p},duration:{value:m,rate:p}}:u.keep_range_if_unknown||(a.available_range=null);let h=a.raw_extraction;h&&"proxyResolution"in h&&delete h.proxyResolution;let b=c.resolution_w,v=c.resolution_h,g=u.resolution_w??null,y=u.resolution_h??null,w=u.pixel_aspect??a.source_pixel_aspect??1,x=b!=null&&v!=null&&g!=null&&y!=null&&b*y!==g*v,O=g!=null&&y!=null,P=[];for(let V of e.timelines??[]){let R=V.resolution_w??0,j=V.resolution_h??0;for(let J of V.tracks??[])for(let q of J.items??[])if(q.media_reference_id===o.ref_id&&q.source_range){if(P.push({it:q}),x){let W=Qk(b,v,1,R,j),F=Qk(g,y,w,R,j),H=W.kx!==0?F.kx/W.kx:1,C=W.ky!==0?F.ky/W.ky:1;typeof q.position_x=="number"&&(q.position_x*=H),typeof q.position_y=="number"&&(q.position_y*=C);for(let $ of q.keyframes??[])if($.parameter_path==="position"&&Array.isArray($.value)){let oe=$.value;typeof oe[0]=="number"&&(oe[0]*=H),typeof oe[1]=="number"&&(oe[1]*=C)}}if(O){let W=Qk(g,y,w,R,j);q.render_base_w=W.baseW,q.render_base_h=W.baseH,q.render_pos_div_x=W.kx,q.render_pos_div_y=W.ky}}}let T="linked",S,k=!1,L=u.path.split(/[/\\]/).pop()??u.path,z=()=>{let V=P.find(({it:R})=>(R.source_range.duration?.value??0)>m);if(V){T="unbound",k=!0,S=`cut duration ${V.it.source_range.duration?.value??0}f exceeds linked media ${L} extent ${m}f`;return}for(let{it:R}of P){let j=R.source_range.duration?.value??0,J=R.source_range.start.value;if(J<0||J+j>m){let q=Math.max(0,Math.floor((m-j)/2));R.source_range={...R.source_range,start:{...R.source_range.start,value:q}};let W=R.raw_extraction??(R.raw_extraction={});W.sourceConformedToMedia=!0}}};if(bp(a))a.content_kind==null&&(a.content_kind="still");else if(m==null)T="unbound",S=`matched ${L} by name but not probed \u2014 coverage unverified`;else if(c.timecode&&u.timecode!=null){let V=u.fps??c.fps??null,R=MR(c.timecode,V),j=MR(u.timecode,V);if(R==null||j==null)T="unbound",S=`could not verify ${L} timecode placement \u2014 coverage unverified`;else{let J=R-j,q=P.find(({it:W})=>{let F=W.source_range.start.value+J,H=W.source_range.duration?.value??0;return F<0||F+H>m});if(q)if(s!=="probed"&&R===0)z();else{T="unbound",k=!0;let F=q.it.source_range.start.value+J,H=q.it.source_range.duration?.value??0;S=`cut [${F}..${F+H}] not within linked media ${L} [0..${m}] (source TC ${c.timecode} \u2192 ${u.timecode})`}else if(J!==0)for(let{it:W}of P){let F=W.source_range.start.rate||1;W.source_range={...W.source_range,start:{...W.source_range.start,value:W.source_range.start.value+J}};for(let C of W.keyframes??[])if(!(!C.time||typeof C.time.value!="number"))if(C.parameter_path==="speed"){let $=J/F;if(C.time.value===0&&C.value===0)continue;C.time={...C.time,value:Math.max(0,C.time.value+$)},typeof C.value=="number"&&(C.value=Math.max(0,C.value+$))}else{let $=C.time.rate||F;C.time={...C.time,value:Math.max(0,C.time.value+J*($/F))}}let H=W.raw_extraction??(W.raw_extraction={});typeof H.alternateFrame=="number"&&(H.alternateFrame=j),H.sourceConformedToMedia=!0}}}else z();a.binding_state=T;let X;S?(a.coverage_reason=S,k&&(X=S)):delete a.coverage_reason,i.push({ref_id:o.ref_id,confidence:o.confidence,reasons:o.reasons??[],before:c,after:oQ(u),...X?{warning:X}:{}})}let r=i.filter(o=>o.warning).length;return{summary:`Relinked ${i.length} reference${i.length===1?"":"s"}`+(r?` \xB7 ${r} unresolved (cut not covered)`:""),meta:{applied:i}}};function ga(e,t){return e.timelines?.find(n=>n.id===t)}function iu(e,t,n){let i=ga(e,t);if(i)for(let r of i.tracks??[]){let o=(r.items??[]).findIndex(a=>a.id===n);if(o!==-1)return{timeline:i,track:r,item:r.items[o],index:o}}}function va(e){(e.items??[]).forEach((t,n)=>{t.item_index=n})}function Do(e){let t=0;for(let n of e.tracks??[])for(let i of n.items??[])t=Math.max(t,i.timeline_range.start.value+i.timeline_range.duration.value);e.duration_frames=t}function Jd(e,t){let n=new Set;for(let r of e.timelines??[])for(let o of r.tracks??[]){n.add(o.id);for(let a of o.items??[])n.add(a.id)}for(let r of e.media_references??[])n.add(r.id);let i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}function LR(e){let t=e.timeline_range.start.value;return[t,t+e.timeline_range.duration.value]}function aQ(e,t,n,i){return n>t?(e.items??[]).filter(r=>{if(i&&r.id===i)return!1;let[o,a]=LR(r);return o<n&&t<a}):[]}function cs(e,t,n,i,r){let o={removed:0,trimmed:0,split:0},a=aQ(t,n,i,r);if(a.length===0)return o;let s=new Set,c=[];for(let l of a){let[u,f]=LR(l);if(l.kind==="transition"||u>=n&&f<=i){s.add(l),o.removed++;continue}if(u<n&&f>i){let d=structuredClone(l);d.id=Jd(e,"ov-it"),d.timeline_range.start.value=i,d.timeline_range.duration.value=f-i,d.source_range&&(d.source_range.start.value+=i-u,d.source_range.duration.value=f-i),c.push(d),l.timeline_range.duration.value=n-u,l.source_range&&(l.source_range.duration.value=n-u),o.split++;continue}if(u<n)l.timeline_range.duration.value=n-u,l.source_range&&(l.source_range.duration.value=n-u);else{let d=i-u;l.timeline_range.start.value=i,l.timeline_range.duration.value=f-i,l.source_range&&(l.source_range.start.value+=d,l.source_range.duration.value=f-i)}o.trimmed++}return(s.size||c.length)&&(t.items=[...(t.items??[]).filter(l=>!s.has(l)),...c]),(t.items??=[]).sort((l,u)=>l.timeline_range.start.value-u.timeline_range.start.value),va(t),o}function ou(e){let t=[];return e.removed&&t.push(`${e.removed} overwritten`),e.trimmed&&t.push(`${e.trimmed} trimmed`),e.split&&t.push(`${e.split} split`),t.length?` \xB7 ${t.join(", ")}`:""}var N0={head:null,tail:null};function sQ(e,t){if(!t?.start||!t.duration||!e||e.content_kind==="still")return N0;let n=e.available_range,i=n?.duration?.value;if(!n||typeof i!="number"||!(i>1))return N0;let r=n.start?.value??0,o=r+i,a=t.start.value,s=a+t.duration.value;return{head:Math.max(0,Math.round(a-r)),tail:Math.max(0,Math.round(o-s))}}function _k(e,t){if(!t.media_reference_id)return N0;let n=(e.media_references??[]).find(i=>i.id===t.media_reference_id);return sQ(n,t.source_range)}function cQ(e,t,n,i,r={}){let o=Math.round(t),a=Math.max(0,n-1);if(e==="in"){let c=[i.head,r.startFrame,r.sourceStart].filter(u=>typeof u=="number").map(u=>-Math.max(0,u)),l=c.length?Math.max(...c):-1/0;return Math.min(a,Math.max(l,o))}let s=i.tail==null?1/0:i.tail;return Math.max(-a,Math.min(s,o))}function lQ(e,t,n,i,r){return(e==="in"?t<0:t>0)?e==="out"?"there is no media after its out point":r<=0?"it already starts at the head of the timeline":"there is no media before its in point":n<=1?"it is already one frame long":"it cannot get any shorter"}var RR=(e,{timeline_id:t,item_id:n,edge:i,delta_frames:r,ripple:o})=>{let a=ga(e,t);if(!a)return{summary:"Trim: timeline not found"};for(let s of a.tracks??[]){let c=(s.items??[]).find(w=>w.id===n);if(!c)continue;let l=c.timeline_range,u=c.source_range,f=c.name??"clip",d=l.start.value,m=d+l.duration.value,p=_k(e,c),h=Math.round(Number(r)||0),b=cQ(i,h,l.duration.value,p,{startFrame:d,sourceStart:u?.start.value});if(b===0)return{summary:h===0?`Trim: "${f}" \u2014 no change`:`Trim: "${f}" won't move \u2014 ${lQ(i,h,l.duration.value,p,d)}`,meta:{timeline_id:t,item_id:n,edge:i,delta_frames:0,asked:h,clamped:h!==0}};let v=0;if(i==="out"?(l.duration.value+=b,u&&(u.duration.value+=b),v=b):(l.start.value+=b,l.duration.value-=b,u&&(u.start.value+=b,u.duration.value-=b),v=-b),o&&v!==0)for(let w of s.items)w.id!==c.id&&w.timeline_range.start.value>=m&&(w.timeline_range.start.value+=v);let g={removed:0,trimmed:0,split:0};i==="in"&&b<0?g=cs(e,s,l.start.value,d,c.id):i==="out"&&b>0&&!o&&(g=cs(e,s,m,l.start.value+l.duration.value,c.id)),Do(a);let y=b>0?"+":"";return{summary:`Trimmed ${i} of "${f}" by ${y}${b}f`+(o?" (rippled)":"")+(b!==h?" (limited by the media)":"")+ou(g),meta:{timeline_id:t,item_id:n,edge:i,delta_frames:b,asked:h,clamped:b!==h,ripple:!!o,cleared:g}}}return{summary:"Trim: item not found"}};var NR=(e,{timeline_id:t,item_id:n,delta_frames:i})=>{let r=iu(e,t,n);if(!r)return{summary:"Slip: item not found"};let{item:o}=r;if(!o.source_range)return{summary:"Slip: clip has no source range"};let{head:a,tail:s}=_k(e,o),c=Math.round(Number(i)||0),l=s??1/0,u=a==null?-o.source_range.start.value:-a,f=Math.max(u,Math.min(l,c)),d=Math.max(0,o.source_range.start.value+f),m=d-o.source_range.start.value;if(o.source_range.start.value=d,m===0)return{summary:c===0?`Slip: "${o.name??"clip"}" \u2014 no change`:`Slip: "${o.name??"clip"}" is already at the ${c>0?"end":"start"} of its media`,meta:{timeline_id:t,item_id:n,delta_frames:0,asked:c,clamped:c!==0}};let p=m>0?"+":"";return{summary:`Slipped "${o.name??"clip"}" ${p}${m}f`+(m!==c?" (limited by the media)":""),meta:{timeline_id:t,item_id:n,delta_frames:m,asked:c,clamped:m!==c}}};var XR=(e,{timeline_id:t,item_id:n,ripple:i})=>{let r=ga(e,t);if(!r)return{summary:"Delete: timeline not found"};for(let o of r.tracks??[]){let a=(o.items??[]).findIndex(u=>u.id===n);if(a===-1)continue;let s=o.items[a],c=s.timeline_range.start.value,l=s.timeline_range.duration.value;if(o.items.splice(a,1),i)for(let u of o.items)u.timeline_range.start.value>=c&&(u.timeline_range.start.value-=l);return va(o),Do(r),{summary:`Deleted "${s.name??"clip"}"${i?" (rippled)":""}`,meta:{timeline_id:t,item_id:n,ripple:!!i}}}return{summary:"Delete: item not found"}};function X0(e){return e==="fit"||e==="fill"||e==="stretch"||e==="none"}var uQ=.005;function fQ(e,t,n,i){if(e<=0||t<=0||n<=0||i<=0)return!1;let r=e/t,o=n/i;return Math.abs(r-o)/Math.max(r,o)<=uQ}function eS(e,t,n,i,r){let o=i,a=r;if(!e||!t||e<=0||t<=0||o<=0||a<=0)return[o,a,1,1];let s=e,c=t,l=s/c,u=o/a,f=1,d=1;l>u?d=l/u:l<u&&(f=u/l);let m=Math.max(s/o,c/a);return m>0||(m=1),[s*n/m,c/m,f,d]}function tS(e,t,n,i){let r=Math.max(e/n,t/i);return r>0?r:1}function jR(e,t,n,i){let r=e/n,o=t/i,a=Math.max(r,o),s=Math.min(r,o);return s>0?a/s:1}function Kd(e,t){return`${e}\xD7${t}`}function dQ(e,t){for(let n of e.tracks??[])if(n.kind==="Video"){for(let i of n.items??[])if(FR(i)&&(i.reframe_fit??"fit")!==t)return!0}return!1}function FR(e){let t=e.kind??"clip";return t==="clip"||t==="nested"}function IR(e,t,n,i){return e/n<t/i?"x":"y"}function mQ(e,t,n,i,r){let o=e.reframe_fit;if(!o||o==="fit")return;let a=o==="none"?tS(t,n,i,r):jR(t,n,i,r);a!==1&&(o==="fill"||o==="none"?(e.scale!=null&&(e.scale=e.scale/a),e.raw_scale!=null&&(e.raw_scale=e.raw_scale/a)):o==="stretch"&&(IR(t,n,i,r)==="x"?e.scale_x!=null&&(e.scale_x=e.scale_x/a):e.scale_y!=null&&(e.scale_y=e.scale_y/a)))}function ER(e,t,n,i,r,o){if(!n||!i||n<=0||i<=0){e.reframe_fit=t;return}VR(e,t,n,i,r,o)}function VR(e,t,n,i,r,o){if(e.reframe_fit=t,t==="fit")return;if(t==="none"){let s=tS(n,i,r,o);if(s===1)return;e.scale=(e.scale??100)*s,e.raw_scale!=null&&(e.raw_scale=e.raw_scale*s);return}let a=jR(n,i,r,o);if(a!==1)if(t==="fill")e.scale=(e.scale??100)*a,e.raw_scale!=null&&(e.raw_scale=e.raw_scale*a);else{let s=e.scale??100;IR(n,i,r,o)==="x"?e.scale_x=(e.scale_x??s)*a:e.scale_y=(e.scale_y??s)*a}}function $k(e,t,n,i,r,o,a){let s=0;for(let c of e.tracks??[])if(c.kind==="Video")for(let l of c.items??[]){if(!FR(l))continue;let{w:u,h:f,par:d}=t(l),m=!!u&&!!f&&u>0&&f>0;m&&a!=null&&mQ(l,u,f,r,o);let[p,h,b,v]=eS(u,f,d,n,i);l.render_base_w=p,l.render_base_h=h,l.render_pos_div_x=b,l.render_pos_div_y=v,l.raw_scale!=null&&m&&(l.raw_scale=(l.scale??100)/tS(u,f,n,i)),m&&a!=null&&VR(l,a,u,f,n,i),s++}return a!=null&&(e.mismatch_policy=a),s}var WR=(e,t)=>{let n=Math.round(Number(t?.resolution_w)),i=Math.round(Number(t?.resolution_h));if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{summary:"Reformat: resolution must be two positive numbers"};if(n%2!==0||i%2!==0)return{summary:`Reformat: ${Kd(n,i)} \u2014 dimensions must be even`};let r=t?.fit??null;if(r!=null&&!X0(r))return{summary:`Reformat: unknown fit policy "${r}"`};let o=new Map;for(let g of e.media_references??[])g.id&&o.set(g.id,g);let a=g=>{let y=g.media_reference_id?o.get(g.media_reference_id):void 0,w=g.pixel_aspect_ratio??y?.source_pixel_aspect??1;return{w:y?.source_resolution_w??null,h:y?.source_resolution_h??null,par:w>0?w:1}},s=e.timelines??[],c;if(t.timeline_id&&t.timeline_id!=="*"){let g=ga(e,t.timeline_id);if(!g)return{summary:"Reformat: timeline not found"};c=[g]}else c=s;if(c.length===0)return{summary:"Reformat: no timelines in this session"};let l=[],u=[],f=0,d=!1,m=!1;for(let g of c){let y=g.resolution_w,w=g.resolution_h;if(y==null||w==null||y<=0||w<=0){g.resolution_w=n,g.resolution_h=i,f+=$k(g,a,n,i,n,i,r),l.push(g.id);continue}if(y===n&&w===i){let O=r!=null&&dQ(g,r),P=r!=null&&(g.mismatch_policy??"fit")!==r;if(O||P){O?f+=$k(g,a,n,i,y,w,r):r!=null&&(g.mismatch_policy=r),l.push(g.id),m=!0;continue}u.push({timeline_id:g.id,name:g.name??null,reason:`already ${Kd(n,i)}`});continue}let x=!fQ(y,w,n,i);if(x&&r==null){u.push({timeline_id:g.id,name:g.name??null,reason:`${Kd(y,w)} \u2192 ${Kd(n,i)} changes the aspect ratio \u2014 choose fit (bars), fill (crop), stretch (distort) or none (native pixels)`});continue}g.resolution_w=n,g.resolution_h=i,f+=$k(g,a,n,i,y,w,r),l.push(g.id),x&&(d=!0)}let p=l.length,h=f>0?` \xB7 ${f} clip${f===1?"":"s"}`:"",b=u.length>0?` \xB7 ${u.length} skipped`:"";return{summary:p===0?`Reformat: nothing changed \u2014 ${u[0]?.reason??"no eligible timeline"}`:m&&!d?`Reframed ${p} timeline${p===1?"":"s"} to ${r}${h}${b}`:`Reformatted ${p} timeline${p===1?"":"s"} to ${Kd(n,i)}`+(d&&r?` (${r})`:"")+(h?`${h} re-based`:"")+b,meta:{resolution_w:n,resolution_h:i,fit:r??void 0,changed:l,skipped:u,clips_rebased:f,reframe_only:m}}};var DR="conform.stringout",HR=(e,t)=>({value:e,rate:t}),ZR=(e,t,n)=>({start:HR(e,n),duration:HR(t,n)});function qR(e){return e.generated_by===DR}function pQ(e){let t=e?.available_range;if(!t)return null;let n=t.start?.value,i=t.duration?.value;return typeof n!="number"||typeof i!="number"||i<=0?null:{start:n,duration:i}}function hQ(e,t,n,i){let r=e.source_range,o=pQ(t);if(n==="full")return o||(r?{start:r.start.value,duration:r.duration.value}:null);if(!r||!(r.duration.value>0))return null;let a=r.start.value,s=r.duration.value;if(n==="handles"&&i>0){let c=a-i,l=a+s+i;o?(c=Math.max(o.start,c),l=Math.min(o.start+o.duration,l)):c=Math.max(0,c),a=c,s=Math.max(1,l-c)}return{start:a,duration:s}}function bQ(e,t,n){let i=new Map;for(let u of e.media_references??[])u.id&&i.set(u.id,u);let r=(e.timelines??[]).filter(u=>!qR(u)),o=r[0],a=o&&o.fps_den?o.fps_num/o.fps_den:24,s=[],c=0,l=0;for(let u of r)for(let f of u.tracks??[])if(f.kind==="Video")for(let d of f.items??[]){if(d.kind!=="clip"||d.enabled===!1)continue;let m=d.media_reference_id?i.get(d.media_reference_id):void 0,p=m?.source_resolution_w,h=m?.source_resolution_h;if(!p||!h||p<=0||h<=0){l++;continue}let b=hQ(d,m,t,n);if(!b){c++;continue}let v=d.source_range,g=v?.duration?.rate||v?.start?.rate||m?.available_range?.duration?.rate||a,y=d.pixel_aspect_ratio??m?.source_pixel_aspect??1;s.push({item:d,mrefId:d.media_reference_id??null,w:p,h,par:y>0?y:1,start:b.start,duration:b.duration,rate:g,name:d.name,reel:d.reel_name??null})}return{shots:s,fallbackRate:a,noRange:c,noRaster:l}}function gQ(e,t){let n=new Set,i=[];for(let r of e){let o=t==="full"?`m:${r.mrefId??r.item.id}`:`m:${r.mrefId??r.item.id}|${r.start}|${r.duration}`;n.has(o)||(n.add(o),i.push(r))}return i}var UR=(e,t)=>{let n=t?.extent??"cut";if(n!=="cut"&&n!=="handles"&&n!=="full")return{summary:`Stringout: unknown extent "${n}"`};let i=n==="handles"?Math.max(0,Math.round(t?.handles??24)):0,r=(t?.name_prefix??"STRINGOUT").trim()||"STRINGOUT",{shots:o,fallbackRate:a,noRange:s,noRaster:c}=bQ(e,n,i),l=gQ(o,n);if(l.length===0)return{summary:c>0?`Stringout: no clip has a probed resolution to group by (${c} unprobed)`:"Stringout: no clips with a usable range in this session"};let u=new Map;for(let P of l){let T=`${P.w}x${P.h}`,S=u.get(T);S?S.push(P):u.set(T,[P])}let f=[...u.entries()].sort((P,T)=>{let[S,k]=P[0].split("x").map(Number),[L,z]=T[0].split("x").map(Number);return L*z-S*k||L-S||z-k}),d=(e.timelines??[]).filter(P=>!qR(P)),m=d[0]?.fps_num??Math.round(a*1e3),p=d[0]?.fps_den??1e3,h=p?m/p:a,b=0,v=P=>`so-${P}-${++b}`,g=[],y=(e.timelines??[]).length;for(let[,P]of f){let{w:T,h:S,par:k}=P[0],L=v("tl"),z=`${r} ${T}\xD7${S}${k!==1?` PAR ${vQ(k)}`:""}`,X=[],V=0;P.forEach((j,J)=>{X.push({id:v("it"),kind:"clip",item_index:J,name:j.name,enabled:!0,timeline_range:ZR(V,j.duration,h),source_range:ZR(j.start,j.duration,j.rate||h),media_reference_id:j.mrefId,reel_name:j.reel,pixel_aspect_ratio:j.par,scale:100,position_x:0,position_y:0,rotation:0,crop_left:0,crop_right:0,crop_top:0,crop_bottom:0,render_base_w:T*j.par,render_base_h:S,render_pos_div_x:1,render_pos_div_y:1,keyframes:[],effects:[]}),V+=j.duration});let R={id:v("tr"),kind:"Video",track_index:0,name:"V1",enabled:!0,items:X};(e.timelines??=[]).push({id:L,name:z,kind:"primary",timeline_index:y++,fps_num:m,fps_den:p,resolution_w:T,resolution_h:S,pixel_aspect_ratio:k,start_frame:0,is_drop_frame:d[0]?.is_drop_frame??!1,duration_frames:V,tracks:[R],markers:[],generated_by:DR}),g.push({id:L,name:z,w:T,h:S,clips:P.length})}let w=o.length-l.length,x=n==="handles"?`handles \xB1${i}f`:n;return{summary:`Strung out ${l.length} clip${l.length===1?"":"s"} into ${g.length} reel${g.length===1?"":"s"} by resolution (${g.map(P=>`${P.w}\xD7${P.h}\xD7${P.clips}`).join(", ")}) \xB7 ${x}`+(w>0?` \xB7 ${w} duplicate${w===1?"":"s"} collapsed`:"")+(c>0?` \xB7 ${c} unprobed skipped`:"")+(s>0?` \xB7 ${s} skipped (no range)`:""),meta:{timelines:g,clips:l.length,extent:n,handles:i,duplicates_collapsed:w,skipped_no_raster:c,skipped_no_range:s}}};function vQ(e){return Math.round(e*1e4)/1e4}var yQ=["position","scale","rotation"];function j0(e,t){return t.length===0?[e,e]:[Math.min(...t),Math.max(...t)]}var wQ={"anchor-or-flip":"flipped or off-centre anchor",nested:"compound clip",retimed:"retimed",cropped:"cropped","mixed-format":"mixed-format conform sizing",revealing:"zooms out or repositions past the frame"};function xQ(e,t){let n=new Map;for(let $ of e.keyframes??[]){let oe=$.parameter_path??"";if(!yQ.some(Ae=>oe===Ae||oe.startsWith(Ae+".")))continue;let ye=n.get(oe)??[];ye.push($.value),n.set(oe,ye)}let i=$=>{let oe=n.get($);if(!oe||oe.length===0)return!1;let ye=JSON.stringify(oe[0]);return oe.some(Ae=>JSON.stringify(Ae)!==ye)},r=[...n.keys()].some(i),o=$=>typeof $=="number"?$:null,a=($,oe)=>(n.get($)??[]).map(ye=>oe?oe(ye):o(ye)).filter(ye=>ye!=null),s=[...a("position",$=>Array.isArray($)?o($[0]):null),...a("position.x")],c=[...a("position",$=>Array.isArray($)?o($[1]):null),...a("position.y")],l=a("scale"),u=a("rotation"),f=e.position_x??0,d=e.position_y??0,m=e.scale??100,p=e.scale_x??null,h=e.scale_y??null,b=e.rotation??0;if(!(r||Math.abs(f)>1e-9||Math.abs(d)>1e-9||Math.abs(m-100)>1e-9||p!=null&&Math.abs(p-m)>1e-9||h!=null&&Math.abs(h-m)>1e-9||Math.abs(b)>1e-9||s.some($=>Math.abs($)>1e-9)||c.some($=>Math.abs($)>1e-9)||l.some($=>Math.abs($-100)>1e-9)||u.some($=>Math.abs($)>1e-9)))return{verdict:"none"};let g=Math.abs(e.anchor_x??0)>1e-9||Math.abs(e.anchor_y??0)>1e-9,y=e,w=y.flip_horizontal===!0||y.flip_vertical===!0;if(g||w)return{verdict:"kept",reason:"anchor-or-flip"};if(e.kind==="nested")return{verdict:"kept",reason:"nested"};if(y.speed!=null&&Math.abs(y.speed-100)>1e-9||y.speed_reverse===!0||y.speed_ramped===!0)return{verdict:"kept",reason:"retimed"};if([e.crop_left,e.crop_right,e.crop_top,e.crop_bottom].some($=>Math.abs($??0)>1e-9)||(e.keyframes??[]).some($=>($.parameter_path??"").startsWith("crop")&&Math.abs(o($.value)??0)>1e-9))return{verdict:"kept",reason:"cropped"};if(t){let $=t.sourcePar??1;if(Math.abs($-1)>1e-4)return{verdict:"kept",reason:"mixed-format"};let oe=t.sourceW??0,ye=t.sourceH??0;if(oe>0&&ye>0&&Math.abs(oe/ye-t.frameAr)/t.frameAr>.005)return{verdict:"kept",reason:"mixed-format"}}let P=t?.frameAr??16/9,[T]=j0(m,l),[S,k]=j0(f,s),[L,z]=j0(d,c),[X,V]=j0(b,u),R=Math.max(Math.abs(S),Math.abs(k)),j=Math.max(Math.abs(L),Math.abs(z)),q=Math.max(Math.abs(X),Math.abs(V))*Math.PI/180,W=Math.cos(q)+P*Math.sin(q),F=(p!=null&&l.length===0?p:T)/100,H=(h!=null&&l.length===0?h:T)/100;return F>=W+2*R-1e-6&&H>=W+2*j-1e-6?{verdict:"moves"}:{verdict:"kept",reason:"revealing"}}function PQ(e,t){let n=e.timeline_range;if(!n)return!1;let i=n.start.value,r=n.start.value+n.duration.value;return(t.items??[]).some(o=>{if(o.kind!=="transition"||!o.timeline_range)return!1;let a=o.timeline_range.start.value,s=o.timeline_range.start.value+o.timeline_range.duration.value;return a<r&&s>i})}function kQ(e,t){let n=new Map((t?.media_references??[]).map(s=>[s.id,s])),i=(e.resolution_w||1920)/(e.resolution_h||1080),r=0,o=0,a={};for(let s of e.tracks??[])if(s.kind==="Video")for(let c of s.items??[]){if(c.kind!=="clip"&&c.kind!=="nested")continue;let l=c.media_reference_id?n.get(c.media_reference_id):void 0,u=xQ(c,{frameAr:i,sourceW:l?.source_resolution_w,sourceH:l?.source_resolution_h,sourcePar:l?.source_pixel_aspect,transitionOverlap:PQ(c,s)});u.verdict==="moves"?r++:u.verdict==="kept"&&(o++,u.reason&&(a[u.reason]=(a[u.reason]??0)+1))}return{moves:r,kept:o,reasons:a}}var CR=(e,t)=>{let n=t?.surface==="edit"?"edit":"node",i=t?.timeline_id,r=(e.timelines??[]).filter(u=>!i||i==="*"||u.id===i);if(r.length===0)return{summary:"No matching timeline"};let o=0,a=0,s={};for(let u of r){u.sizing_surface=n;let f=kQ(u,e);o+=f.moves,a+=f.kept;for(let[d,m]of Object.entries(f.reasons)){let p=d;s[p]=(s[p]??0)+(m??0)}}let c=Object.entries(s).sort((u,f)=>(f[1]??0)-(u[1]??0)).map(([u,f])=>`${f} ${wQ[u]}`).join(" \xB7 ");if(n==="edit")return{summary:"Sizing back on the edit page \u2014 the next Resolve export keeps clip transforms in the inspector",meta:{surface:n,moves:o,kept:a,reasons:s,timelines:r.length}};let l=[`${o} clip${o===1?"":"s"} move to the color page in the next Resolve export`];return a>0&&l.push(`${a} stay on the edit page (${c})`),o===0&&a===0&&(l[0]="No clip transforms to move \u2014 the flag is set for anything added later"),{summary:l.join(" \xB7 "),meta:{surface:n,moves:o,kept:a,reasons:s,timelines:r.length}}};var JR=(e,t)=>({value:e,rate:t}),F0=(e,t,n)=>({start:JR(e,n),duration:JR(t,n)});function SQ(e){let t=e.streams??[];return t.length?t.some(n=>n.kind==="video"):e.content_kind!=="audio"}function rS(e){let t=e.streams??[];return t.length?t.some(n=>n.kind==="audio"):e.content_kind==="audio"||e.content_kind==="video_audio"}function TQ(e){return(e.streams??[]).find(t=>t.kind==="audio")?.channels??null}function KR(e,t,n){let i=[...t.tracks??[]].reverse().find(a=>a.kind===n);if(i)return i;let r=(t.tracks??[]).filter(a=>a.kind===n).length,o={id:Jd(e,"ac-tr"),kind:n,track_index:r,name:`${n==="Video"?"V":"A"}${r+1}`,enabled:!0,items:[]};return(t.tracks??=[]).push(o),o}function nS(e){return e.display_name?e.display_name:(e.target_url??"").split("/").pop()||e.id}var GR=(e,t)=>{let n=(e.timelines??[]).find(S=>S.id===t.timeline_id);if(!n)return{summary:"Add clip: timeline not found"};let i=(e.media_references??[]).find(S=>S.id===t.media_reference_id);if(!i){if(!t.media_reference||t.media_reference.id!==t.media_reference_id)return{summary:"Add clip: media reference not in session and none supplied"};(e.media_references??=[]).push(t.media_reference),i=t.media_reference}let r=n.fps_den?n.fps_num/n.fps_den:24,o=i.available_range,a=o?.duration?.rate||o?.start?.rate||r,s=t.source_start??o?.start?.value??0,c=Math.max(1,Math.round(t.source_duration??o?.duration?.value??r)),l=SQ(i),u=!t.without_audio&&rS(i),f=l?"Video":"Audio",d=t.track_id?(n.tracks??[]).find(S=>S.id===t.track_id):null;if(t.track_id&&!d)return{summary:"Add clip: track not found"};if(d&&d.kind!==f)return{summary:`Add clip: ${d.name??d.id} is a ${d.kind} track`};let m=d??KR(e,n,f),p=0;for(let S of m.items??[]){let k=S.timeline_range.start.value+S.timeline_range.duration.value;k>p&&(p=k)}typeof t.at_frame=="number"&&Number.isFinite(t.at_frame)&&(p=Math.max(0,Math.round(t.at_frame)));let h=cs(e,m,p,p+c),b=i.source_pixel_aspect??1,[v,g,y,w]=eS(i.source_resolution_w,i.source_resolution_h,b,n.resolution_w??0,n.resolution_h??0),x=X0(t.fit)?t.fit:X0(n.mismatch_policy)?n.mismatch_policy:"fit",O={id:Jd(e,"ac-it"),kind:"clip",item_index:(m.items??[]).length,name:nS(i),enabled:!0,timeline_range:F0(p,c,r),source_range:F0(s,c,a),media_reference_id:i.id,reel_name:i.reel_name??null,pixel_aspect_ratio:b,scale:100,position_x:0,position_y:0,rotation:0,crop_left:0,crop_right:0,crop_top:0,crop_bottom:0,render_base_w:v,render_base_h:g,render_pos_div_x:y,render_pos_div_y:w,keyframes:[],effects:[]};ER(O,x,i.source_resolution_w,i.source_resolution_h,n.resolution_w??0,n.resolution_h??0),(m.items??=[]).push(O),m.items.sort((S,k)=>S.timeline_range.start.value-k.timeline_range.start.value),va(m);let P=null;if(u&&l){let S=KR(e,n,"Audio");S.audio_channel_count==null&&(S.audio_channel_count=TQ(i)),cs(e,S,p,p+c);let k={id:Jd(e,"ac-it"),kind:"clip",item_index:(S.items??[]).length,name:nS(i),enabled:!0,timeline_range:F0(p,c,r),source_range:F0(s,c,a),media_reference_id:i.id,reel_name:i.reel_name??null,keyframes:[],effects:[]};(S.items??=[]).push(k),S.items.sort((L,z)=>L.timeline_range.start.value-z.timeline_range.start.value),va(S),P={track:S,item:k}}Do(n);let T=P?"picture + sound":l?"picture":"sound";return{summary:`Added "${nS(i)}" (${T}) to ${n.name??"timeline"} at ${p}f (${c}f)`+ou(h),meta:{timeline_id:n.id,track_id:m.id,item_id:O.id,media_reference_id:i.id,at_frame:p,duration_frames:c,ref_added:i===t.media_reference,fit:x,cleared:h,audio_track_id:P?.track.id??null,audio_item_id:P?.item.id??null}}};function zQ(e,t){let n=new Set((e.timelines??[]).map(r=>r.id)),i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}function OQ(e){let t=new Set((e.timelines??[]).map(i=>i.name)),n=(e.timelines??[]).length+1;for(;t.has(`Timeline ${n}`);)n++;return`Timeline ${n}`}var AR=(e,t)=>{let n=e.timelines??[];if(t.timeline_id&&n.some(d=>d.id===t.timeline_id))return{summary:`New timeline: id "${t.timeline_id}" is already in the session`};let i=t.timeline_id||zQ(e,"nt-tl"),r=t.name||OQ(e),o=n.find(d=>d.kind==="primary")??n[0],a=typeof t.fps_num=="number"&&t.fps_num>0&&typeof t.fps_den=="number"&&t.fps_den>0,s=a?t.fps_num:o?.fps_num??24,c=a?t.fps_den:o?.fps_den??1,l={id:`${i}-v1`,kind:"Video",track_index:0,name:"V1",enabled:!0,items:[]},u={id:i,name:r,kind:"primary",timeline_index:n.length,fps_num:s,fps_den:c,resolution_w:t.resolution_w||o?.resolution_w||1920,resolution_h:t.resolution_h||o?.resolution_h||1080,pixel_aspect_ratio:t.pixel_aspect_ratio??1,start_frame:t.start_frame??0,is_drop_frame:t.is_drop_frame??!1,duration_frames:0,tracks:[l],markers:[],source_element_id:null,raw_extraction:{},metadata:{}};(e.timelines??=[]).push(u);let f=c?s/c:0;return{summary:`New timeline "${r}" \u2014 ${u.resolution_w}\xD7${u.resolution_h} @ ${Number.isInteger(f)?f:f.toFixed(3)}`,meta:{timeline_id:i,track_id:l.id,name:r,fps_num:s,fps_den:c,resolution_w:u.resolution_w,resolution_h:u.resolution_h}}};function MQ(e,t){let n=new Set;for(let r of e.timelines??[])for(let o of r.tracks??[])n.add(o.id);let i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}var BR=(e,t)=>{let n=(e.timelines??[]).find(s=>s.id===t.timeline_id);if(!n)return{summary:"Add track: timeline not found"};let i=t.kind??"Video",r=(n.tracks??[]).filter(s=>s.kind===i).length,o=`${i==="Video"?"V":"A"}${r+1}`,a={id:MQ(e,"at-tr"),kind:i,track_index:r,name:o,enabled:!0,items:[]};return(n.tracks??=[]).push(a),{summary:`Added ${o} to ${n.name??"timeline"}`,meta:{timeline_id:n.id,track_id:a.id,kind:i,name:o}}};function LQ(e){let t=e;return t.finish_ops??=[]}var YR=(e,t)=>{let n,i,r;if(t.timeline_level){let s=(e.timelines??[]).find(c=>c.id===t.timeline_id);if(!s)return{summary:"Finish: timeline not found"};n=s,i=s.name??"timeline",r=s.id}else{if(!t.item_id)return{summary:"Finish: item_id required for a clip-level stack"};let s=iu(e,t.timeline_id,t.item_id);if(!s)return{summary:"Finish: item not found"};n=s.item,i=s.item.name??"clip",r=s.item.id}let o={id:r},a=LQ(n);if(t.entry){let s=a.findIndex(l=>l.id===t.entry.id),c=s>=0;return c?a[s]=t.entry:a.push(t.entry),{summary:`${c?"Updated":"Added"} ${t.entry.label??t.entry.kind} on "${i}"`,meta:{item_id:o.id,entry_id:t.entry.id,upserted:!0}}}if(t.toggle_id){let s=a.find(c=>c.id===t.toggle_id);return s?(s.enabled=!s.enabled,{summary:`${s.enabled?"Enabled":"Bypassed"} ${s.label??s.kind} on "${i}"`,meta:{item_id:o.id,entry_id:s.id,enabled:s.enabled}}):{summary:`Finish: operator not found on "${i}"`}}if(t.remove_id){let s=a.findIndex(l=>l.id===t.remove_id);if(s<0)return{summary:`Finish: operator not found on "${i}"`};let[c]=a.splice(s,1);return{summary:`Removed ${c.label??c.kind} from "${i}"`,meta:{item_id:o.id,entry_id:c.id,removed:!0}}}return{summary:"Finish: nothing to do (no entry / toggle_id / remove_id)"}};var QR=(e,t)=>{let n=(e.timelines??[]).find(s=>s.id===t.timeline_id);if(!n)return{summary:"Delete track: timeline not found"};let i=(n.tracks??[]).findIndex(s=>s.id===t.track_id);if(i<0)return{summary:"Delete track: track not found"};let[r]=n.tracks.splice(i,1),o=0;for(let s of n.tracks)s.kind===r.kind&&(s.track_index=o++);Do(n);let a=(r.items??[]).filter(s=>s.kind!=="gap").length;return{summary:`Deleted ${r.name??r.kind} (${a} clip${a===1?"":"s"}) from ${n.name??"timeline"}`,meta:{timeline_id:n.id,track_id:r.id,kind:r.kind,clips:a}}};var _R=(e,t)=>{let n=(e.timelines??[]).find(m=>m.id===t.timeline_id);if(!n)return{summary:"Move: timeline not found"};let i,r,o=-1;for(let m of n.tracks??[]){let p=(m.items??[]).findIndex(h=>h.id===t.item_id);if(p>=0){i=m,r=m.items[p],o=p;break}}if(!i||!r)return{summary:"Move: clip not found"};let a=t.to_track_id?(n.tracks??[]).find(m=>m.id===t.to_track_id):i;if(!a)return{summary:"Move: destination track not found"};if(a.kind!==i.kind)return{summary:`Move: can't put a ${i.kind} clip on a ${a.kind} track`};let s=r.timeline_range.start.value,c=r.timeline_range.duration.value,l=typeof t.to_frame=="number"&&Number.isFinite(t.to_frame)?Math.max(0,Math.round(t.to_frame)):s;if(a===i&&l===s)return{summary:"Move: already there"};let u=cs(e,a,l,l+c,r.id);if(a!==i){let m=i.items.findIndex(p=>p.id===r.id);i.items.splice(m>=0?m:o,1),(a.items??=[]).push(r)}r.timeline_range.start.value=l,a.items.sort((m,p)=>m.timeline_range.start.value-p.timeline_range.start.value),va(i),a!==i&&va(a),Do(n);let f=a!==i?` to ${a.name??"track"}`:"",d=l!==s?` to ${l}f`:"";return{summary:`Moved "${r.name??"clip"}"${f}${d}${ou(u)}`,meta:{timeline_id:n.id,item_id:r.id,from_track_id:i.id,to_track_id:a.id,from_frame:s,to_frame:l,cleared:u}}};var RQ=[{label:"23.976",num:24e3,den:1001},{label:"24",num:24,den:1},{label:"25",num:25,den:1},{label:"29.97",num:3e4,den:1001},{label:"30",num:30,den:1},{label:"48",num:48,den:1},{label:"50",num:50,den:1},{label:"59.94",num:6e4,den:1001},{label:"60",num:60,den:1}];function NQ(e){let t=0;for(let n of e.tracks??[])t+=(n.items??[]).length;return t}function $R(e,t){if(!(t>0))return"\u2014";let n=RQ.find(r=>r.num===e&&r.den===t);if(n)return n.label;let i=e/t;return Number.isInteger(i)?String(i):i.toFixed(3).replace(/0+$/,"").replace(/\.$/,"")}var eN=(e,t)=>{let n=Math.round(Number(t?.fps_num)),i=Math.round(Number(t?.fps_den));if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{summary:"Frame rate: must be a positive rational (fps_num / fps_den)"};let r=ga(e,t?.timeline_id);if(!r)return{summary:"Frame rate: timeline not found"};let o=$R(r.fps_num??0,r.fps_den??0),a=$R(n,i);if(r.fps_num===n&&r.fps_den===i)return{summary:`Frame rate: already ${a} fps`};let s=NQ(r);return s>0?{summary:`Frame rate: ${r.name??"this timeline"} has ${s} item${s===1?"":"s"} in it \u2014 changing ${o} \u2192 ${a} would move every cut. Set the rate on an empty timeline, or export and re-conform at the new rate.`,meta:{timeline_id:r.id,refused:"populated",items:s}}:(r.fps_num=n,r.fps_den=i,{summary:`Frame rate: ${o} \u2192 ${a} fps`,meta:{timeline_id:r.id,fps_num:n,fps_den:i,was:o}})};var XQ=["crop_left","crop_right","crop_top","crop_bottom"],jQ={scale:"scale",opacity:"opacity",position_x:"position X",position_y:"position Y",rotation:"rotation",crop_left:"crop L",crop_right:"crop R",crop_top:"crop T",crop_bottom:"crop B"},iS=(e,t,n)=>Math.min(n,Math.max(t,e));function au(e){return typeof e=="number"&&Number.isFinite(e)?e:null}var tN=(e,t)=>{let n=iu(e,t.timeline_id,t.item_id);if(!n)return{summary:"Transform: clip not found"};let i=n.item,r=[],o=(m,p)=>{i[m]!==p&&(i[m]=p,r.push(m))},a=au(t.scale);a!=null&&o("scale",iS(a,.01,1e5));let s=au(t.opacity);s!=null&&o("opacity",iS(s,0,100));let c=au(t.position_x);c!=null&&o("position_x",c);let l=au(t.position_y);l!=null&&o("position_y",l);let u=au(t.rotation);u!=null&&o("rotation",u);for(let m of XQ){let p=au(t[m]);p!=null&&o(m,iS(p,0,100))}if(r.length===0)return{summary:"Transform: nothing changed"};let f=i.name??t.item_id;return{summary:`Set ${r.map(m=>jQ[m]??m).join(", ")} on "${f}"`,meta:{timeline_id:t.timeline_id,item_id:t.item_id,changed:r}}};var FQ=e=>!!e&&typeof e=="object"&&Number.isFinite(e.value)&&Number.isFinite(e.rate)&&e.rate>0,nN=(e,t)=>{let n=e.timelines??[],i=t.timeline_id?n.find(f=>f.id===t.timeline_id):n.length===1?n[0]:n.find(f=>f.kind==="primary");if(!i)return{summary:`Add markers: timeline not found (${t.timeline_id??"no timeline_id"}); timelines: ${n.map(f=>f.id).join(", ")||"none"}`};let r=(i.fps_num??24)/(i.fps_den??1),o=(f,d)=>typeof f=="number"&&Number.isFinite(f)?{value:f,rate:r}:FQ(f)?f:f==null&&d?d:null,a=new Set((i.tracks??[]).flatMap(f=>(f.items??[]).map(d=>d.id))),s=new Set((i.markers??[]).map(f=>f.id)),c=[],l=[];(t.markers??[]).forEach((f,d)=>{let m=f??{},p=`marker ${d}${typeof m.name=="string"?` "${m.name}"`:""}`;if(typeof f!="object"||f===null)return void l.push(`${p}: not an object`);let h=o(m.time??m.frame);if(!h)return void l.push(`${p}: time must be timeline frames or {value, rate}, got ${JSON.stringify(m.time??m.frame)}`);if(h.value<0)return void l.push(`${p}: time ${h.value} is before the timeline start`);let b=o(m.duration,{value:1,rate:h.rate});if(!b||b.value<0)return void l.push(`${p}: duration must be frames or {value, rate}, got ${JSON.stringify(m.duration)}`);let v=typeof m.item_id=="string"?m.item_id:null;if(v&&!a.has(v))return void l.push(`${p}: no item ${v} on this timeline`);let g=typeof m.id=="string"&&m.id?m.id:"";if(g&&s.has(g))return void l.push(`${p}: id ${g} already present`);for(let y=(i.markers??[]).length+c.length;!g||s.has(g);y++)g=`marker-${y}`;s.add(g),c.push({kind:null,raw_extraction:{},source_element_id:null,metadata:{},...m,id:g,time:h,duration:b,item_id:v,name:typeof m.name=="string"?m.name:null,note:typeof m.note=="string"?m.note:null,color:typeof m.color=="string"?m.color:null})});let u=l.length?`; dropped ${l.length}: ${l.join("; ")}`:"";return c.length===0?{summary:`Add markers: nothing added${u||" (no markers given)"}`,meta:{added:0,dropped:l}}:(i.markers=[...i.markers??[],...c],{summary:`Added ${c.length} marker(s) to "${i.name}"${u}`,meta:{timeline_id:i.id,added:c.length,dropped:l}})};var Gd={relink:R0,slip:NR,delete:XR,trim:RR,reformat:WR,stringout:UR,node_sizing:CR,add_clip:GR,new_timeline:AR,add_track:BR,finish_op:YR,delete_track:QR,move_clip:_R,timeline_rate:eN,transform:tN,add_markers:nN};function I0(e){return Gd[e]}var IQ=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});IQ.decode();var oS=new TextEncoder;"encodeInto"in oS||(oS.encodeInto=function(e,t){let n=oS.encode(e);return t.set(n),{read:e.length,written:n.length}});var Zge=new TextEncoder,Dge=new TextDecoder;var qge=256*1024;var Uge=new Uint8Array(0);var eve=2*1024*1024,aS=["resolve-otio","resolve-xmeml","flame-fcpxml","flame-archive","resolve-drt","avid-aaf","resolve-aaf","avid-avb","premiere-prproj","premiere-otio","baselight-blscene","finalcut-fcpxmld","protools-aaf","protools-ptx","session_json"],rN=["premiere-prproj","resolve-drt","flame-archive","avid-avb","resolve-xmeml"],iN=["resolve-otio","flame-fcpxml","avid-aaf","resolve-aaf","premiere-otio","session_json"],oN=["baselight-blscene","finalcut-fcpxmld","protools-ptx","protools-aaf"],aN=[];var E0={prproj:"premiere-prproj",otio:"resolve-otio","resolve-xml":"resolve-xmeml",xmeml:"resolve-xmeml",drt:"resolve-drt",fcpxml:"flame-fcpxml",aaf:"avid-aaf",avb:"avid-avb"};function sN(e){return e==="Video"?"V":e==="Audio"?"A":e?.[0]??"T"}function Ci(e,t){let n=e.name?.trim();if(n)return n;let i=VQ(e.kind,t),r=i.indexOf(e);return r<0&&e.id&&(r=i.findIndex(o=>o?.id===e.id)),r<0?`${sN(e.kind)}${Math.max(1,Math.abs(e.track_index??0))}`:`${sN(e.kind)}${r+1}`}function VQ(e,t){let n=t.filter(o=>o?.kind===e),i=n.length>0&&n.every(o=>(o.track_index??0)<=0),r=o=>i?-(o.track_index??0):o.track_index??0;return[...n].sort((o,a)=>r(o)-r(a))}var WQ=["proxy","prx","low","offline","rough","preview","comp","temp","draft","h264","dnxhr","prores"];function Ad(e,t,n,i={}){let r=UQ(i),o=[],a=[],s=[],c=new Map,l=BQ(t),u=GQ(n.fileExtensions),f=u?l.filter(m=>u.has(KQ(m.filename))):l;for(let m of e){let p=[];for(let w of f){let x=CQ(m,w,n,r);if(x.confidence>0){let O=V0(m,w,r);p.push({candidate:w,contains:O.known&&O.contains,confidence:x.confidence,reasons:x.reasons})}else x.refusal&&!c.has(m.id)&&c.set(m.id,{candidate_id:w.id,reason:x.refusal})}if(p.sort((w,x)=>x.confidence-w.confidence),p.length===0){a.push(m.id);continue}let h=p[0].confidence,b=p.filter(w=>h-w.confidence<.05),v=b.filter(w=>w.contains);if(v.length===1&&!b[0].contains){let w=p.indexOf(v[0]);p.splice(w,1),p.unshift(v[0])}let g=p[0],y=p.slice(1).filter(w=>g.confidence-w.confidence<.05&&w.contains===g.contains);y.length>0&&s.push({proxy_id:m.id,candidate_ids:[g,...y].map(w=>w.candidate.id)}),o.push({proxy_id:m.id,candidate_id:g.candidate.id,matched_path:g.candidate.path??g.candidate.filename,confidence:g.confidence,reasons:g.reasons})}if(a.length>0&&o.length>0){let m=new Map(e.map(y=>[y.id,y])),p=new Map(f.map(y=>[y.id,y])),h=new Map;for(let y of f){let w=gc(y.filename).toLowerCase(),x=h.get(w);x?x.push(y):h.set(w,[y])}let b=o.filter(y=>y.confidence>=.5),v=new Set,g=[];for(let y of b){let w=m.get(y.proxy_id),x=p.get(y.candidate_id);if(!w||!x)continue;let O=ZQ(gc(w.filename),gc(x.filename));O&&v.add(O);let P=w.original_path??w.id,T=DQ(P,x.path);T&&g.push(T)}if(v.size>0||g.length>0){let y=[];for(let w of a){let x=m.get(w);if(!x){y.push(w);continue}let O=null,P=null;for(let T of v){let S=(gc(x.filename)+T).toLowerCase(),k=h.get(S);if(k&&k.length>0){O=HQ(x,k,r),P=`filename pattern inferred (${T} suffix)`;break}}if(!O&&x.original_path)for(let T of g){let S=qQ(x.original_path,T);if(!S)continue;let k=S.toLowerCase();for(let L of f){let z=(L.path??"").replace(/\\/g,"/").toLowerCase();if(z&&z.endsWith(k)){O=L,P="directory proximity";break}}if(O)break}O?o.push({proxy_id:x.id,candidate_id:O.id,matched_path:O.path??O.filename,confidence:.5,reasons:P?[P]:[]}):y.push(w)}a.length=0,a.push(...y)}}let d=a.filter(m=>c.has(m)).map(m=>({proxy_id:m,...c.get(m)}));return{matches:o,unmatched:a,ambiguous:s,refusals:d}}function HQ(e,t,n){return t.length===1?t[0]:t.find(r=>V0(e,r,n).contains)??t[0]}function cN(e,t,n,i,r){if(n==null||i==null||t==null)return{known:!1,contains:!1};let o=su(n,r);if(o==null)return{known:!1,contains:!1};let a=su(e??"00:00:00:00",r)??0;return{known:!0,contains:a<=o&&o+i<=a+t}}function V0(e,t,n){if(e.cut_timecode_start==null||e.cut_duration_frames==null)return{known:!1,contains:!1};let i=e.fps??t.fps??n.timecode_rate,r=t.duration_frames??(t.duration_seconds!=null?Math.round(t.duration_seconds*i):null);return cN(t.timecode_start,r,e.cut_timecode_start,e.cut_duration_frames,i)}function ZQ(e,t){let n=e.toLowerCase(),i=t.toLowerCase();if(i.length<=n.length||!i.startsWith(n))return null;let r=i.slice(n.length);return!r.startsWith("_")&&!r.startsWith("-")?null:t.slice(e.length)}function DQ(e,t){if(!e||!t)return null;let n=e.replace(/\\/g,"/").split("/").filter(Boolean),i=t.replace(/\\/g,"/").split("/").filter(Boolean),r=0;for(;r<n.length&&r<i.length&&n[n.length-1-r].toLowerCase()===i[i.length-1-r].toLowerCase();)r++;return r===0?null:{proxyPrefix:n.slice(0,n.length-r).join("/")}}function qQ(e,t){let n=e.replace(/\\/g,"/").replace(/^\/+/,""),i=t.proxyPrefix.replace(/^\/+/,"");return i?n.toLowerCase().startsWith(i.toLowerCase())?n.slice(i.length).replace(/^\/+/,""):null:n}function UQ(e){return{timecode_tolerance_frames:e.timecode_tolerance_frames??1,timecode_rate:e.timecode_rate??24,duration_tolerance_seconds:e.duration_tolerance_seconds??.1,min_name_similarity:e.min_name_similarity??.6,aspect_tolerance:e.aspect_tolerance??.01,fps_tolerance:e.fps_tolerance??.005}}function CQ(e,t,n,i){let r=[],o=0;if(n.fileName)if(n.fileNameMode==="tight"){if(gc(e.filename)!==gc(t.filename))return{confidence:0,reasons:[]};o+=.6,r.push("exact filename")}else{let s=Bd(qo(e.filename),qo(t.filename));if(s<i.min_name_similarity)return{confidence:0,reasons:[]};let c=e.cut_timecode_start??e.timecode_start,l=c==null||/^00:00:00[:;]00$/.test(c),u=qo(e.filename).toLowerCase(),f=qo(t.filename).toLowerCase(),d=u===f||f.startsWith(u)||u.startsWith(f);if(l&&!d)return{confidence:0,reasons:[],refusal:`filename similarity ${s.toFixed(2)} but no source timecode to confirm a non-exact name \u2014 exact name required`};o+=s*.6,r.push(`filename similarity ${s.toFixed(2)}`)}else o+=.1;let a=pf(e.filename)||pf(t.filename);if(!a)if(e.tc_unrecorded){let s=V0(e,t,i);s.known&&s.contains&&(o+=.2,r.push("cut within source timecode range"))}else{let s=V0(e,t,i);if(s.known)if(s.contains)o+=.2,r.push("cut within source timecode range");else{let c=e.fps??t.fps??i.timecode_rate,l=su(e.cut_timecode_start??"00:00:00:00",c)??0,u=su(t.timecode_start??"00:00:00:00",c)??0,f=t.duration_frames??(t.duration_seconds!=null?Math.round(t.duration_seconds*c):0);return{confidence:0,reasons:[],refusal:`cut [${l}..${l+(e.cut_duration_frames??0)}] not within linked media ${t.filename} [${u}..${u+f}]`}}else{let c=e.fps??t.fps??i.timecode_rate,l=su(e.cut_timecode_start??e.timecode_start??"00:00:00:00",c),u=su(t.timecode_start??"00:00:00:00",c),f=e.duration_seconds!=null?Math.round(e.duration_seconds*c):null,d=t.duration_seconds!=null?Math.round(t.duration_seconds*c):null;if(l!=null&&u!=null)if(f!=null&&d!=null)if(Math.max(l,u)<Math.min(l+f,u+d))o+=.2,r.push("source timecode overlaps");else return{confidence:0,reasons:[],refusal:`source timecode [${l}..${l+f}] does not overlap ${t.filename} [${u}..${u+d}]`};else Math.abs(l-u)<=i.timecode_tolerance_frames&&(o+=.2,r.push("source timecode aligned"))}}if(n.reelName){let s=e.reel_name&&t.reel_name&&e.reel_name===t.reel_name,c=s?null:JQ(e.reel_sources,t.reel_sources);if(s)o+=.15,r.push("reel name matched");else if(c)o+=.075,r.push(`reel matched (proxy.${c.proxySource} = candidate.${c.candidateSource})`);else if(e.reel_name&&t.reel_name)return{confidence:0,reasons:[]}}if(n.totalDuration&&!a&&e.duration_seconds!=null&&t.duration_seconds!=null){let s=u=>u==null?null:u>=1e3?"sample":"frame",c=s(e.duration_rate),l=s(t.duration_rate);if(c!=null&&l!=null&&c!==l)r.push("duration units differ (frames vs samples) \u2014 not compared");else if(Math.abs(e.duration_seconds-t.duration_seconds)<=i.duration_tolerance_seconds)o+=.1,r.push("duration matches");else return{confidence:0,reasons:[]}}if(n.resolution&&e.resolution_w!=null&&e.resolution_h!=null&&t.resolution_w!=null&&t.resolution_h!=null)if(e.resolution_w===t.resolution_w&&e.resolution_h===t.resolution_h)o+=.05,r.push(`resolution ${t.resolution_w}\xD7${t.resolution_h}`);else return{confidence:0,reasons:[]};if(n.bitDepth&&e.bit_depth!=null&&t.bit_depth!=null)if(e.bit_depth===t.bit_depth)o+=.05,r.push(`${t.bit_depth}-bit`);else return{confidence:0,reasons:[]};if(e.fps!=null&&t.fps!=null&&!pf(e.filename)&&!pf(t.filename)){let s=e.fps;if(Math.abs(t.fps-s)/s<i.fps_tolerance)o+=.05,r.push(`${s} fps`);else return{confidence:0,reasons:[],refusal:`frame rate ${t.fps} does not match the edit's ${s} \u2014 different-rate media is never the same clip`}}if(n.fileFormat&&e.container&&t.container)if(AQ(t.container,e.container))o+=.05,r.push(`container ${t.container}`);else return{confidence:0,reasons:[]};if(n.codec&&e.codec&&t.codec)if(lN(t.codec,e.codec))o+=.05,r.push(`codec ${t.codec}`);else return{confidence:0,reasons:[]};return n.mediaUmid&&e.media_umid&&t.media_umid&&e.media_umid===t.media_umid&&(o=Math.max(o,.95),r.push("UMID match")),{confidence:Math.min(o,1),reasons:r}}function gc(e){return e.replace(/\.[^.]+$/,"").toLowerCase()}function qo(e){let t=gc(e);t=t.replace(/[-_]s\d{3}$/i,""),t=t.replace(/[-_]+v\d+$/i,"");let n=new Set(WQ);return t.split(/[-_\s]+/).filter(i=>i&&!n.has(i)).join("_")}function JQ(e,t){if(!e||!t)return null;let n=["embedded","project_metadata","parent_folder","filename_pattern"];for(let i of n){let r=e[i];if(r)for(let o of n){let a=t[o];if(a&&r===a)return{proxySource:i,candidateSource:o}}}return null}function Bd(e,t){if(!e||!t)return 0;if(e===t)return 1;if(Math.min(e.length,t.length)>=6&&(e.includes(t)||t.includes(e)))return .8;let i=e.split(/[_\-\s]+/),r=new Set(t.split(/[_\-\s]+/)),o=i.filter(a=>r.has(a));return o.length===0?0:o.length/Math.max(i.length,r.size)}function su(e,t){let n=e.match(/^(\d{1,2}):(\d{2}):(\d{2})[:;](\d{2})$/);return n?parseInt(n[1],10)*3600*t+parseInt(n[2],10)*60*t+parseInt(n[3],10)*t+parseInt(n[4],10):null}function KQ(e){let t=e.match(/\.([^.]+)$/);return t?t[1].toLowerCase():""}function GQ(e){if(!e||!e.trim())return null;let t=e.split(/[,\s]+/).map(n=>n.replace(/^\./,"").toLowerCase()).filter(Boolean);return t.length===0?null:new Set(t)}function AQ(e,t){let n=e.toLowerCase(),i=t.toLowerCase();return!!(n===i||i.includes("quicktime")&&(n==="mov"||n==="quicktime")||i.includes("mxf")&&n==="mxf"||i.includes("mp4")&&(n==="mp4"||n==="mpeg-4"))}function lN(e,t){let n=js(e),i=js(t);if(n&&i)return n===i;let r=e.toLowerCase(),o=t.toLowerCase();return r.includes(o)||o.includes(r)}function BQ(e){let t=e.filter(r=>/\.r3d$/i.test(r.filename)),n=e.filter(r=>!/\.r3d$/i.test(r.filename));if(t.length===0)return e;let i=new Map;for(let r of t){let a=`${r.filename.toLowerCase().replace(/_\d{3}\.r3d$/i,"")}|${r.timecode_start??r.id??""}`,s=i.get(a);(!s||r.filename<s.filename)&&i.set(a,r)}return[...n,...i.values()]}function YQ(e){return e?e.split(/[/\\]/).pop()??"":""}var QQ={fileName:"a file name",timecode:"source timecode",reelName:"a reel name",totalDuration:"duration data",resolution:"resolution data",bitDepth:"bit-depth data",frameRate:"frame-rate data",fileFormat:"container/format data",codec:"codec data",mediaUmid:"a UMID/clip-ID"};function ya(e,t){let n=e.length,i=0;for(let r of e)r!=null&&r!==""&&i++;return uN(i,n,t)}function uN(e,t,n){return t===0?{populated:0,total:0,available:!0,unavailable_reason:null}:e===0?{populated:e,total:t,available:!1,unavailable_reason:`No clips in this timeline carry ${QQ[n]}.`}:{populated:e,total:t,available:!0,unavailable_reason:null}}function _Q(e){let t=e.vendor_metadata??{},n=["umid","media_umid","clip_id","mxf_umid","package_uid","material_package_uid","source_package_uid","mob_id","MobID","avid_mob_id","MasterMobID","SourceMobID","SourceID","media_pool_item_id"];for(let i of n){let r=t[i];if(typeof r=="string"&&r.length>0)return r}return null}function W0(e){for(let t of e.streams??[]){if(t.kind!=="video")continue;if(typeof t.bit_depth=="number")return t.bit_depth;let n=t.codec_specific;if(!n)continue;let i=n.BitDepth??n.bit_depth??n.bits_per_sample;if(typeof i=="number")return i;if(typeof i=="string"&&/^\d+$/.test(i))return parseInt(i,10)}return null}function fN(e){let t=e.length,i=e.map(r=>YQ(r.target_url)).filter(r=>r.length>0).length;return{fileName:uN(i,t,"fileName"),timecode:ya(e.map(r=>r.source_timecode),"timecode"),reelName:ya(e.map(r=>r.reel_name),"reelName"),totalDuration:ya(e.map(r=>{let o=r.available_range?.duration;if(o&&o.value!=null&&o.rate)return o.value;let a=r.declared_duration;return a&&a.value!=null&&a.rate?a.value:null}),"totalDuration"),resolution:ya(e.map(r=>r.source_resolution_w&&r.source_resolution_h?`${r.source_resolution_w}\xD7${r.source_resolution_h}`:null),"resolution"),bitDepth:ya(e.map(r=>W0(r)),"bitDepth"),frameRate:ya(e.map(r=>r.source_fps??null),"frameRate"),fileFormat:ya(e.map(r=>r.container??null),"fileFormat"),codec:ya(e.map(r=>r.codec??null),"codec"),mediaUmid:ya(e.map(r=>_Q(r)),"mediaUmid")}}function sS(e){let t=H0(e.target_url);return{id:e.id,filename:t,original_path:e.target_url??null,container:e.container??null,codec:e.codec??null,size_bytes:e.size_bytes??null,duration_seconds:e.available_range?.duration?.value?e.available_range.duration.value/(e.available_range.duration.rate??1):e.declared_duration?.value&&e.declared_duration.rate?e.declared_duration.value/e.declared_duration.rate:null,duration_rate:e.available_range?.duration?.rate??e.declared_duration?.rate??null,duration_frames:e.available_range?.duration?.value??(typeof e.vendor_metadata?.frame_count=="number"?e.vendor_metadata.frame_count:null),timecode_start:e.source_timecode??null,reel_name:e.reel_name??null,reel_sources:e.reel_sources,resolution_w:e.source_resolution_w??null,resolution_h:e.source_resolution_h??null,fps:e.source_fps??null,bit_depth:W0(e),media_umid:e.vendor_metadata?.umid??null,facts_origin:e.source_facts_origin??null}}function cS(e){return{...sS(e),path:e.local_path??e.target_url??null}}function lS(e,t){let n=sS(t),i=pN(e,t);i&&(n.cut_timecode_start=i.tcStart,n.cut_duration_frames=i.durFrames);let r=mN(t.source_timecode,t.source_fps??24);return(t.source_facts_origin??"declared")!=="probed"&&(r==null||r===0)&&(n.tc_unrecorded=!0),n}function mN(e,t){if(!e)return null;let n=e.match(/^(\d+):(\d+):(\d+)[:;](\d+)$/);if(!n)return null;let i=Math.round(t)||24;return(+n[1]*3600+ +n[2]*60+ +n[3])*i+ +n[4]}function $Q(e,t){let n=Math.round(t)||24,i=Math.max(0,Math.round(e)),r=i%n,o=Math.floor(i/n)%60,a=Math.floor(i/(n*60))%60,s=Math.floor(i/(n*3600))%24,c=l=>String(l).padStart(2,"0");return`${c(s)}:${c(a)}:${c(o)}:${c(r)}`}function pN(e,t){let n=t.source_fps??24,i=mN(t.source_timecode,n);if(i==null)return null;let r=1/0,o=-1/0;for(let a of e.timelines??[])for(let s of a.tracks??[])for(let c of s.items??[])if(c.media_reference_id===t.id&&c.source_range){let l=i+c.source_range.start.value,u=l+(c.source_range.duration?.value??0);l<r&&(r=l),u>o&&(o=u)}return r===1/0?null:{tcStart:$Q(r,n),durFrames:Math.max(0,o-r)}}function uS(e,t,n,i=!1){let r=new Map;for(let f of t)r.set(f.id,f);let o=[],a=new Set;for(let f of n){let d=r.get(f.candidate_id);d&&(o.push({ref_id:f.proxy_id,to:{path:d.local_path??d.target_url??"",size_bytes:d.size_bytes??null,resolution_w:d.source_resolution_w??null,resolution_h:d.source_resolution_h??null,codec:d.codec??null,container:d.container??null,fps:d.source_fps??null,bit_depth:W0(d),reel_name:d.reel_name??null,timecode:d.source_timecode??null,recipe:d.recipe??null,frame_count:d.available_range?.duration?.value??null,pixel_aspect:d.source_pixel_aspect??null,bitrate_bps:d.bitrate_bps??null,local_path:d.local_path??null,vendor_metadata:d.vendor_metadata??null,reel_sources:d.reel_sources??null},confidence:f.confidence,reasons:f.reasons}),a.add(d.id))}let s=e_(e)?structuredClone(e):e,l=R0(s,{matches:o}).meta?.applied??[],u=i?(s.media_references??[]).filter(f=>!a.has(f.id)):s.media_references??[];return{session:{...s,media_references:u},applied:l}}function e_(e){return Object.isFrozen(e)||Object.isFrozen(e.media_references??{})||(e.media_references??[]).some(t=>Object.isFrozen(t)||Object.isFrozen(t.metadata??{}))}function H0(e){return e?e.split(/[/\\]/).pop()??"":""}var dN=(e,t)=>`${H0(e)}|${t}`,t_=2;function fS(e,t){let n=new Map,i=new Map;for(let c of t){n.set(dN(c.source_path,c.source_in),c);let l=H0(c.source_path);(i.get(l)??(i.set(l,[]),i.get(l))).push(c)}let r=e.media_references??(e.media_references=[]),o=new Map(r.map(c=>[c.id,c])),a=0,s=0;for(let c of e.timelines??[])for(let l of c.tracks??[])for(let u of l.items??[]){if(!u.media_reference_id)continue;let f=o.get(u.media_reference_id);if(!f){s++;continue}let d=u.source_range?.start?.value??0,m=f.target_url??"",p=n.get(dN(m,d));if(!p&&m&&(p=n_(i.get(H0(m)),d)),!p){s++;continue}let h={...f,id:crypto.randomUUID(),kind:"external",content_kind:f.content_kind??"video",target_url:p.render_path,source_timecode:p.render_start_tc??f.source_timecode,available_range:{start:{value:0,rate:p.rate},duration:{value:p.render_frames,rate:p.rate}}};r.push(h),o.set(h.id,h),u.media_reference_id=h.id;let b=u.source_range?.duration??{value:p.render_frames,rate:p.rate};if(u.source_range={start:{value:p.lead_handle,rate:p.rate},duration:b},p.render_start_frame!=null){let v=u.raw_extraction??(u.raw_extraction={});v.alternateFrame=p.render_start_frame}a++}return{matched:a,unmatched:s}}function n_(e,t){if(!e||e.length===0)return;let n,i=1/0,r=!1;for(let o of e){let a=Math.abs(o.source_in-t);a<i?(i=a,n=o,r=!1):a===i&&(r=!0)}if(!(!n||i>t_||r))return n}var r_=new Set(["mov","mp4","m4v","mxf","avi","mkv","mts","m2ts","webm","r3d","braw","ari","arx","arri","crm","dng","dpx","exr","png","jpg","jpeg","tif","tiff","wav","aif","aiff","psd","tga","bmp","gif","webp","avif"]),i_={...zp,fileName:!0,fileNameMode:"tight"};function hN(e){return{...i_,...e?.file_name!=null?{fileName:e.file_name}:{},...e?.file_name_mode?{fileNameMode:e.file_name_mode}:{},...e?.reel_name!=null?{reelName:e.reel_name}:{},...e?.total_duration!=null?{totalDuration:e.total_duration}:{},...e?.resolution!=null?{resolution:e.resolution}:{},...e?.bit_depth!=null?{bitDepth:e.bit_depth}:{},...e?.file_format!=null?{fileFormat:e.file_format}:{},...e?.codec!=null?{codec:e.codec}:{},...e?.media_umid!=null?{mediaUmid:e.media_umid}:{},...e?.extensions?.length?{fileExtensions:e.extensions.join(",")}:{}}}function bN(e,t){let n=new Map;for(let r of e.timelines)for(let o of r.tracks)for(let a of o.items)a.media_reference_id&&(n.get(a.media_reference_id)??n.set(a.media_reference_id,new Set).get(a.media_reference_id)).add(o.kind);let i=t.ref_ids?new Set(t.ref_ids):null;return(e.media_references??[]).filter(r=>{if(!n.has(r.id)||i&&!i.has(r.id)||!t.reset&&r.binding_state==="linked")return!1;if(t.lane&&t.lane!=="both"){let o=n.get(r.id),a=o.has("Video"),s=o.has("Audio");if(t.lane==="video"&&!a||t.lane==="audio"&&!s)return!1}return!0})}var Yd=e=>e.replace(/\.[^.]+$/,"");async function gN(e,t,n=2e3){let i=t.map(l=>qo(Yd(te(l.target_url??l.reel_name??"")).toLowerCase())).filter(Boolean),r=new Set(t.map(l=>ai(te(l.target_url??""))?.clipBase.toLowerCase()).filter(Boolean)),o=l=>{if(!i.length)return!0;let u=ai(l)?.clipBase.toLowerCase();if(u&&r.has(u))return!0;let f=qo(Yd(l.toLowerCase()));return!!f&&i.some(d=>Bd(d,f)>=.5)},a=[],s=!1;async function c(l,u){if(u>12||s)return;let f=[];try{for await(let d of dn(l))f.push(d)}catch{return}for(let d of f){if(d.name.startsWith("."))continue;let m=Q(l,d.name);if(d.isDirectory){await c(m,u+1);continue}if(!d.isFile)continue;let p=ar(d.name).slice(1).toLowerCase();if(!(!r_.has(p)||!o(d.name))&&(a.push(m),a.length>=n)){s=!0;return}}}return await c(e,0),{paths:a,capped:s}}async function vN(e,t){let n=t.split(/[/\\]/).filter(Boolean),i=te(e).toLowerCase(),r=[];for(let o=n.length-2;o>=0;o--)n[o].toLowerCase()===i&&r.push(n.slice(o+1));r.push([n[n.length-1]]);for(let o of r){let a=Q(e,...o);try{if((await un(a)).isFile)return a}catch{}}return null}async function yN(e){let t=[],n=[],i=new Set,r=0;for(let o of e){let a=await Gs(o).catch(()=>[o]);if(!i.has(a[0])){a.forEach(s=>i.add(s));try{let s=await Fn(a[0]);s.id=`cand-${++r}`,s.binding_state="unbound",t.push(s)}catch(s){n.push(`${te(o)}: ${s.message.slice(0,80)}`),t.push({id:`cand-${++r}`,kind:"external",target_url:a[0],local_path:a[0],reel_name:Yd(te(a[0])),binding_state:"unbound",streams:[],raw_extraction:{},metadata:{}})}}}return{refs:t,failed:n}}function wN(e,t,n,i,r){let o=t.map(f=>lS(e,f)),a=n.map(cS),s=Ad(o,a,i,r),c=Ad(o,a,{...i,reelName:!1,totalDuration:!1,resolution:!1,bitDepth:!1,fileFormat:!1,codec:!1,mediaUmid:!1,fileNameMode:"loose"},r),l=new Map(n.map(f=>[f.id,f]));return{rows:t.map(f=>{let d=s.matches.find(b=>b.proxy_id===f.id),m=s.ambiguous.find(b=>b.proxy_id===f.id),p=s.refusals?.filter(b=>b.proxy_id===f.id).map(b=>`${te(l.get(b.candidate_id)?.target_url??b.candidate_id)}: ${b.reason}`).join("; "),h=new Set;for(let b of c.matches)b.proxy_id===f.id&&b.candidate_id!==d?.candidate_id&&h.add(b.candidate_id);for(let b of c.ambiguous)b.proxy_id===f.id&&b.candidate_ids.forEach(v=>v!==d?.candidate_id&&h.add(v));if(m&&m.candidate_ids.forEach(b=>h.add(b)),!d&&!m&&!h.size){let b=qo(Yd(te(f.target_url??"")).toLowerCase()),v=n.map(g=>({c:g,s:Bd(b,qo(Yd(te(g.target_url??"")).toLowerCase()))})).filter(g=>g.s>=.4).sort((g,y)=>y.s-g.s)[0];v&&h.add(v.c.id)}return{ref_id:f.id,name:te(f.target_url??f.reel_name??f.id),status:d?"matched":m?"ambiguous":"unmatched",candidate:d?l.get(d.candidate_id):void 0,confidence:d?.confidence??0,reasons:d?.reasons??[],alternatives:[...h].map(b=>l.get(b)).filter(Boolean),refusal:p||void 0}}),result:s,candidates:n,config:i}}function o_(e,t,n,i){let r=a=>a.streams?.find(s=>s.kind==="video");return[["file name",i.fileName,te(t.target_url??""),te(n.target_url??"")],["reel",i.reelName,t.reel_name??"\u2014",n.reel_name??"\u2014"],["timecode (cut must be inside)",!0,`${t.source_timecode??"\u2014"}`,`${n.source_timecode??"\u2014"} \xD7 ${n.available_range?.duration?.value??n.declared_duration?.value??"?"} fr`],["fps (must agree)",!0,`${t.source_fps??"\u2014"}`,`${n.source_fps??r(n)?.rate??"\u2014"}`],["duration",i.totalDuration,`${t.declared_duration?.value??"\u2014"} fr`,`${n.available_range?.duration?.value??n.declared_duration?.value??"\u2014"} fr`],["resolution",i.resolution,`${t.source_resolution_w??"\u2014"}x${t.source_resolution_h??"\u2014"}`,`${n.source_resolution_w??r(n)?.width??"\u2014"}x${n.source_resolution_h??r(n)?.height??"\u2014"}`],["bit depth",i.bitDepth,`${r(t)?.bit_depth??"\u2014"}`,`${r(n)?.bit_depth??"\u2014"}`],["format",i.fileFormat,ar(t.target_url??"").slice(1)||"\u2014",ar(n.target_url??"").slice(1)||"\u2014"],["codec",i.codec,r(t)?.codec??"\u2014",r(n)?.codec??"\u2014"]].map(([a,s,c,l])=>` ${s?"\u2022":"\xB7"} ${a}: ${c} \u2192 ${l}`)}function xN(e,t,n){let i=n.map(r=>({proxy_id:r.ref_id,candidate_id:r.candidate_id,matched_path:t.candidates.find(o=>o.id===r.candidate_id)?.target_url??"",confidence:1,reasons:["accepted"]}));return uS(e,t.candidates,i,!0)}var PN=vt(),kN=Q(PN,"locations.json");async function Qd(){try{return JSON.parse(await yn(kN))}catch{return[]}}async function SN(e){await bt(PN);let t=(await Qd()).filter(n=>n!==e);await rn(kN,JSON.stringify([e,...t].slice(0,12)))}function TN(e){let t=e.media_references??[],n=fN(t);return Object.entries(n).map(([i,r])=>`- ${i}: ${r.available?"usable":"not usable"} (${r.populated}/${r.total} populated${r.unavailable_reason?`; ${r.unavailable_reason}`:""})`).join(`
99
- `)}function zN(e,t,n){let i=[],r=o=>t.rows.filter(a=>a.status===o).length;i.push(`proposal: ${r("matched")} matched, ${r("ambiguous")} ambiguous, ${r("unmatched")} unmatched of ${t.rows.length} in scope; ${t.candidates.length} candidates`);for(let o of t.rows){let a=e.media_references.find(c=>c.id===o.ref_id),s=`- ${o.ref_id} ${o.name}: ${o.status}`;o.candidate&&(s+=` \u2192 ${o.candidate.target_url} (${Math.round(o.confidence*100)}%${o.reasons.length?`; ${o.reasons.join("; ")}`:""})`),o.refusal&&(s+=`
100
- refused: ${o.refusal}`),o.alternatives.length&&(s+=`
101
- alternatives: ${o.alternatives.slice(0,4).map(c=>`${c.id} ${te(c.target_url??"")}`).join(", ")}`),i.push(s),n.compare&&o.candidate&&i.push(...o_(e,a,o.candidate,t.config))}return i.join(`
102
- `)}var Z0=[{id:"resolve",label:"Blackmagic DaVinci Resolve",folder:"DaVinci Resolve",primary:{target:"resolve-drt",label:"Resolve timeline (.drt)",extension:"drt",status:"ready",open:"In Resolve: File > Import > Timeline, choose the .drt."},fallback:{target:"resolve-xmeml",label:"XML for Resolve (.xml)",extension:"xml",status:"ready",open:"In Resolve: File > Import > Timeline, choose the .xml."}},{id:"premiere",label:"Adobe Premiere Pro",folder:"Premiere Pro",primary:{target:"premiere-prproj",label:"Premiere project (.prproj)",extension:"prproj",status:"ready",open:"In Premiere Pro: File > Open Project, choose the .prproj."},fallback:{target:"premiere-xmeml",label:"XML for Premiere (.xml)",extension:"xml",status:"pending",open:"In Premiere Pro: File > Import, choose the .xml."}},{id:"avid",label:"Avid Media Composer",folder:"Media Composer",primary:{target:"avid-avb",label:"Media Composer bin (.avb)",extension:"avb",status:"ready",open:"Copy the .avb into your project folder, then open it from the Project window."},fallback:{target:"avid-aaf",label:"AAF for Media Composer (.aaf)",extension:"aaf",status:"ready",open:"In Media Composer: File > Input > Import, choose the .aaf."}},{id:"flame",label:"Autodesk Flame",folder:"Flame",quality:"Beta",primary:{target:"flame-archive",label:"Flame archive (.hdr + .seg)",extension:"flame-archive.zip",status:"ready",open:"Unzip, then open the .hdr in Project Manager > Archive Browser and restore."},fallback:{target:"flame-xmeml",label:"XML for Flame (.xml)",extension:"xml",status:"pending",open:"In Flame: import the .xml from the MediaHub."}},{id:"finalcut",label:"Apple Final Cut Pro",folder:"Final Cut Pro",quality:"Beta",primary:{target:"finalcut-fcpxmld",label:"Final Cut Pro bundle (.fcpxmld)",extension:"fcpxmld.zip",status:"ready",open:"Unzip, then in Final Cut Pro: File > Import > XML, choose the .fcpxmld."},fallback:null},{id:"baselight",label:"FilmLight Baselight",folder:"Baselight",quality:"Beta",primary:{target:"baselight-blscene",label:"Baselight scene (.blscene)",extension:"blscene",status:"ready",open:"Open the .blscene in Baselight."},fallback:{target:"baselight-xmeml",label:"XML for Baselight (.xml)",extension:"xml",status:"pending",open:"In Baselight: import the .xml as an edit."}},{id:"protools",label:"Avid Pro Tools",folder:"Pro Tools",quality:"Beta",primary:{target:"protools-ptx",label:"Pro Tools session (.ptx)",extension:"ptx",status:"ready",open:"Open the .ptx in Pro Tools."},fallback:{target:"protools-aaf",label:"AAF for Pro Tools (.aaf)",extension:"aaf",status:"ready",open:"In Pro Tools: File > Open Session, choose the .aaf."}}];function D0(e){let t=e.trim().toLowerCase();return Z0.find(n=>n.id===t)}function dS(e){return[e.primary,...e.fallback&&e.fallback.status==="ready"?[e.fallback]:[]]}function ON(e,t,n){let i=[];i.push(`${e.label}${n?` \u2014 ${n}`:""}`,"");let r=t.find(a=>a.file.target===e.primary.target),o=e.fallback?t.find(a=>a.file.target===e.fallback.target):void 0;r&&i.push(`1. Open ${r.filename} first.`,` ${e.primary.open}`),e.fallback&&o?i.push("",`2. If ${e.label.replace(/^\S+ /,"")} refuses it, use ${o.filename} instead.`,` ${e.fallback.open}`):e.fallback&&e.fallback.status==="pending"&&i.push("",`${e.fallback.label} is not included yet: its writer is still being built to ${e.label.replace(/^\S+ /,"")}'s own import rules.`);for(let a of t){if(i.push("",`${a.filename} \u2014 ${a.file.label}`),!a.issues.length){i.push(" Everything in the source timeline carried.");continue}i.push(" Not carried / check:");for(let s of a.issues)i.push(` - ${s.message}`)}return i.join(`
103
- `)+`
104
- `}var HI=Z8(n4(),1);var Fg=["aaf","avb","prproj","drt","fcpxml","xmeml","otio","flame","ptx"];function Hne(e){switch(ar(e).toLowerCase()){case".aaf":return"aaf";case".avb":return"avb";case".ptx":return"ptx";case".prproj":return"prproj";case".drt":return"drt";case".fcpxml":case".fcpxmld":return"fcpxml";case".xml":return"xmeml";case".otio":return"otio";default:return null}}async function Iu(e,t){let n=t??Hne(e);if(!n)throw new Error(`cannot detect timeline format from '${e}' \u2014 pass format explicitly (${Fg.join("|")})`);let i,r=null;if(n==="drt"){r=await er(e);let c=await HI.default.loadAsync(r),l={};for(let[u,f]of Object.entries(c.files))f.dir||(l[u]=await f.async("string"));i=new TextEncoder().encode(JSON.stringify(l))}else n==="fcpxml"&&e.toLowerCase().endsWith(".fcpxmld")?i=await er(Q(e,"Info.fcpxml")):i=await er(e);let o=n==="fcpxml"&&e.toLowerCase().endsWith(".fcpxmld")?"Info.fcpxml":te(e),a=new File([r??i],o),s=JSON.parse(await KL({fmt:n,data:i,file:a}));return s.source_format=n,s.source_filename=te(e),{session:s,format:n}}function Ig(e){return e.fps_den?e.fps_num/e.fps_den:e.fps_num}var ZI=e=>e==null?"?":String(Math.round(e*1e3)/1e3);function jg(e,t){return Qt(e,Ig(t),!!t.is_drop_frame)}async function ws(e){let t=[],n=e.media_references??[];for(let c of e.timelines){let l=Ig(c),u=c.start_frame??0;t.push(`timeline ${c.id} "${c.name}" \u2014 ${ZI(l)} fps${c.is_drop_frame?" DF":""}, ${c.resolution_w}x${c.resolution_h}, start ${jg(u,c)}, duration ${c.duration_frames} fr (${jg(c.duration_frames??0,c)})${c.kind&&c.kind!=="primary"?` [${c.kind}]`:""}`);let f={},d=0,m=0,p=0,h=[];for(let b of c.tracks){let v=b.items.length,g=b.items.filter(y=>y.kind==="clip").length;h.push(`${Ci(b,c.tracks)}${b.enabled===!1?"(off)":""}:${g}`);for(let y of b.items)f[y.kind]=(f[y.kind]??0)+1,d+=y.effects?.length??0,m+=y.metadata?.conform_flags?.length??0,(y.speed_ramped||y.speed_reverse||y.speed_factor!=null&&y.speed_factor!==1)&&p++}m+=UI(c).length,t.push(` tracks: ${h.join(" ")}`),t.push(` items: ${Object.entries(f).map(([b,v])=>`${v} ${b}`).join(", ")}; ${d} effects, ${p} retimes, ${c.markers?.length??0} markers, ${m} conform flags`)}let i=n.filter(c=>c.binding_state==="linked").length,r=n.filter(c=>c.kind==="missing").length,o=n.filter(c=>c.binding_state!=="linked"&&c.kind!=="generator"),a=o.map(c=>c.local_path||c.target_url).filter(c=>!!c).map(c=>c.startsWith("file://")?decodeURIComponent(new URL(c).pathname):c),s="paths not checked";return a.length&&a.length<=5e3&&(s=`${(await Promise.all(a.map(l=>jn(l)))).filter(Boolean).length} of ${o.length} on disk at their recorded paths`),t.push(`media: ${n.length} references (${i} linked, ${o.length} not linked yet \u2014 ${o.length?`${s}; timeline_relink probes and links them`:"nothing to link"}${r?`, ${r} missing`:""})`),t.join(`
105
- `)}function DI(e,t){let n=new Map((e.media_references??[]).map(r=>[r.id,r])),i=[];for(let r of e.timelines)if(!(t&&r.id!==t)){i.push(`# ${r.id} "${r.name}"`);for(let o of r.tracks){i.push(`## track ${o.id} ${o.kind} ${Ci(o,r.tracks)}${o.enabled===!1?" (disabled)":""}`);for(let a of o.items){let s=a.timeline_range.start.value+(r.start_frame??0),c=s+a.timeline_range.duration.value,l=`- ${a.id} [${a.kind}] "${a.name??""}" rec ${jg(s,r)}\u2013${jg(c,r)} (${a.timeline_range.duration.value} fr)`;if(a.source_range){let f=a.media_reference_id?n.get(a.media_reference_id):void 0,d=a.source_range.start.rate||Ig(r),m=a.source_range.start.value,p=m+a.source_range.duration.value,h=f?.source_timecode??null,b=f?.source_fps||d,v=h?Cn(h,b):null,g=!!h?.includes(";"),y=w=>v==null?Qt(w,d):Qt(v+w*b/d,b,g);l+=` src ${y(m)}\u2013${y(p)}${h?` (file TC ${h})`:""}`,f&&(l+=` media ${f.id}${f.reel_name?` reel "${f.reel_name}"`:""}${f.binding_state==="linked"?"":" UNBOUND"}`)}a.speed_factor!=null&&a.speed_factor!==1&&(l+=` speed ${a.speed_factor}${a.speed_reverse?" reverse":""}`),a.speed_ramped&&(l+=" ramped"),a.enabled===!1&&(l+=" DISABLED"),a.effects?.length&&(l+=` effects[${a.effects.map(f=>f.name??f.kind).join(", ")}]`);let u=a.metadata?.conform_flags;u?.length&&(l+=`
106
- \u2691 ${u.join(`
107
- \u2691 `)}`),i.push(l)}}}return i.join(`
108
- `)}function qI(e){let t=new Set;for(let n of e.timelines)for(let i of n.tracks)for(let r of i.items)r.media_reference_id&&t.add(r.media_reference_id);return(e.media_references??[]).map(n=>{let i=n.streams?.find(r=>r.kind==="video");return`- ${n.id} [${n.kind}${n.binding_state==="linked"?", linked":", unbound"}${t.has(n.id)?"":", unused"}] ${n.target_url??"(no path)"}${n.reel_name?` reel "${n.reel_name}"`:""}${n.source_timecode?` TC ${n.source_timecode}`:""}${n.source_resolution_w?` ${n.source_resolution_w}x${n.source_resolution_h}`:""}${n.source_fps?` ${ZI(n.source_fps)} fps`:""}${i?.codec?` ${i.codec}`:""}${n.declared_duration?` dur ${n.declared_duration.value} fr`:""}${n.binding_state!=="linked"&&n.coverage_reason?`
109
- \u26A0 ${n.coverage_reason}`:""}`}).join(`
110
- `)}function UI(e){return(e.markers??[]).filter(t=>t.kind==="conform_issue").map(t=>({note:t.note??"",frame:Number(t.time?.value??0)}))}function CI(e){let t=[];for(let n of e.timelines){for(let i of n.tracks)for(let r of i.items){let o=r.metadata?.conform_flags;for(let a of o??[])t.push(`- ${n.id}/${r.id} "${r.name??""}": ${a}`)}for(let i of UI(n))t.push(`- ${n.id} @ ${Qt(i.frame,Ig(n))}: ${i.note}`)}return t.length?t.join(`
111
- `):"(no conform flags)"}var Eg=Object.keys(Gd);function r4(e,t,n){let i=I0(t);if(!i)throw new Error(`unknown operation '${t}'; known: ${Eg.join(", ")}`);return i(e,n)}function i4(e){let t=e.trim().toLowerCase(),n=E0[t]??t;if(!aS.includes(n))throw new Error(`unknown target '${e}'; valid: ${aS.filter(i=>!aN.includes(i)).join(", ")} (aliases: ${Object.keys(E0).join(", ")})`);return n}async function o4(e,t,n,i){let r=i4(t),o=await y0(r,e),a=typeof o.body=="string"?new TextEncoder().encode(o.body):o.body,s=(e.timelines.find(f=>f.kind==="primary")??e.timelines[0])?.name?.trim(),c=s?s.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").slice(0,120):"",l=c?o.filenameSuggestion.replace(/^[^.]+/,c):o.filenameSuggestion,u=n;if(!u)u=Q(Ln(i),l);else try{(await un(u)).isDirectory&&(u=Q(u,l))}catch{}if(r==="finalcut-fcpxmld"){let f=Tp(a),d=u.toLowerCase().endsWith(".fcpxmld.zip")?Ln(u):u.toLowerCase().endsWith(".fcpxmld")?Ln(u):u,m="",p=0;for(let[h,b]of Object.entries(f)){if(h.endsWith("/"))continue;let v=u.toLowerCase().endsWith(".fcpxmld")?Q(te(u),...h.split("/").slice(1)):h,g=Q(d,v);await bt(Ln(g)),await fr(g,b),m=Q(d,v.split("/")[0]),p+=b.byteLength}return{path:m,bytes:p,issues:o.issues??[]}}return await fr(u,a),{path:u,bytes:a.byteLength,issues:o.issues??[]}}async function JI(e,t,n,i){let r=D0(t);if(!r)throw new Error(`unknown destination ${t} (one of ${Z0.map(l=>l.id).join(", ")})`);let o=Q(n??Ln(i),r.folder);await bt(o);let a=[];for(let l of dS(r)){let u=await o4(e,l.target,o,i);a.push({...u,target:l.target})}let s=(e.timelines.find(l=>l.kind==="primary")??e.timelines[0])?.name?.trim(),c=ON(r,a.map(l=>({file:[r.primary,r.fallback].find(u=>u?.target===l.target),filename:te(l.path),issues:l.issues})),s);return await fr(Q(o,"README.txt"),new TextEncoder().encode(c)),{folder:o,files:a,pending:r.fallback?.status==="pending"?r.fallback.label:null}}function KI(){return[`read (any of): ${Fg.join(", ")} \u2014 .aaf .avb .prproj .drt .fcpxml/.fcpxmld .xml(FCP7/xmeml) .otio, flame archive (pass format=flame)`,`destinations (pick the host; each delivers its native file + fallback): ${Z0.map(e=>`${e.id} = ${dS(e).map(t=>t.target).join(" + ")}${e.fallback?.status==="pending"?` (${e.fallback.label} pending)`:""}`).join("; ")}`,`write first-class: ${rN.join(", ")}`,`write beta: ${oN.join(", ")}`,`write deprecated (still available): ${iN.join(", ")}`,`aliases: ${Object.entries(E0).map(([e,t])=>`${e}\u2192${t}`).join(", ")}`,`edit operations: ${Eg.join(", ")}`,"Loss report: timeline_write returns per-target capability issues (what the target host cannot carry)."].join(`
112
- `)}async function GI(e){let t=e.media_references??[],n=t.filter(r=>r.binding_state!=="linked").map(r=>`- ${r.id} ${te(r.target_url??r.reel_name??"")}: ${r.coverage_reason??"no file matched yet"}`),i=await Qd();return["match criteria usable on this timeline:",TN(e),`unresolved (${n.length} of ${t.length}):`,...n.length?n:[" (none)"],`remembered locations: ${i.length?i.join(", "):"(none)"}`].join(`
113
- `)}async function AI(e,t,n,i){let r=new Map((e.media_references??[]).map(d=>[d.id,d])),o=new Map;for(let d of e.timelines)for(let m of d.tracks)for(let p of m.items)p.kind!=="clip"||!p.media_reference_id||!p.source_range||(o.get(p.media_reference_id)??o.set(p.media_reference_id,[]).get(p.media_reference_id)).push(p);let a=[],s=[],c=[],l=[];for(let[d,m]of o){let p=r.get(d),h=p?.local_path??p?.target_url??null;if(!p||!h){s.push(`${d}: no path`);continue}if(i.only_linked&&p.binding_state!=="linked"){s.push(`${d} ${te(h)}: not linked (run timeline_relink first, or only_linked=false)`);continue}if(!await jn(h)){s.push(`${d} ${h}: file not found on this machine`);continue}if(!ua.has(ar(h).toLowerCase())){s.push(`${d} ${te(h)}: unsupported container`);continue}try{let b=await Qy(h,m,n,t),v=m[0].source_range.start.rate||p.source_fps||24,g=p.source_timecode?Cn(p.source_timecode,v)??0:0;for(let y of b.outputs)if(a.push(y),!(!y.island||(y.part??1)!==1))for(let w of m){let x=w.source_range.start.value;x<y.island.first_frame||x>y.island.last_frame||c.push({source_path:h,source_in:x,render_path:y.path,render_frames:y.island.last_frame-y.island.first_frame+1,lead_handle:x-y.island.first_frame,rate:v,render_start_tc:p.source_timecode?Qt(g+y.island.first_frame,v):void 0})}l.push(`- ${te(h)} \u2192 ${b.outputs.map(y=>`${te(Ln(y.path))===te(t)?te(y.path):`${te(Ln(y.path))}/${te(y.path)}`} (${y.island?`${y.island.last_frame-y.island.first_frame+1} fr`:""}${y.part?` part ${y.part}`:""})`).join(", ")}`)}catch(b){s.push(`${d} ${te(h)}: ${b.message}`)}}let u="";if(i.relink&&c.length){let d=fS(e,c);u=`
114
- relinked ${d.matched} references to the trims (${d.unmatched} unmatched)`}return{text:[`consolidated ${a.length} output file(s) from ${c.length} source(s) into ${t} with ${n}-frame handles`,...l,...s.length?[`skipped ${s.length}:`,...s.map(d=>` - ${d}`)]:[]].join(`
115
- `)+u,outputs:a,skipped:s}}async function BI(e,t){let n=Rt("CONFORM_PYTHON")??"python3",i=Pr(new URL("./judge_local.py",import.meta.url)),r=await Mn(n,[i,e,t]),o=r.stderr.trim();if(!r.success)throw new Error(`judge failed: ${o.split(`
116
- `).slice(-4).join(" | ")}`);let a=JSON.parse(r.stdout.trim().split(`
117
- `).pop()),s=a.tiers??{},c=[`verdict: ${a.verdict} (${a.source_format} \u2192 ${a.target_format})`,...(a.reasons??[]).map(d=>`- ${d}`),...Object.entries(s).map(([d,m])=>`${d}: ${m?.tally?Object.entries(m.tally).map(([p,h])=>`${p} ${h}`).join(", "):"not run"}${m?.notes?.length?`
118
- notes: ${m.notes.join("; ")}`:""}`)],l=a.clips_with_issues??[];l.length&&c.push(`clips with issues (${l.length}):`,...l.slice(0,20).map(d=>`- ${d.track??"?"} @${d.rec??"?"} ${d.name??""}: ${d.issues.map(m=>`${m.check}: ${m.reason}`).join("; ").slice(0,300)}`));let u=a.clips?.not_checked??{},f=Object.entries(u).flatMap(([d,m])=>Object.entries(m).map(([p,h])=>`- ${d}: ${h}\xD7 ${p}`));return f.length&&c.push("not checked:",...f),c.join(`
119
- `)}async function YI(e,t){let n=t.media_root?[t.media_root]:await Qd();if(!n.length)throw new Error("no media_root given and no remembered locations \u2014 pass the folder to link from");for(let w of n)try{if(!(await un(w)).isDirectory)throw 0}catch{throw new Error(`media_root is not a folder on this machine: ${w}`)}let i=bN(e,{ref_ids:t.ref_ids,lane:t.lane,reset:t.reset});if(!i.length)return{session:e,changed:!1,note:"",text:"nothing in scope: every reference in scope is already linked (use reset=true to re-point) or the ids/lane matched nothing"};if(t.reset)for(let w of i)w.binding_state="unbound",delete w.coverage_reason;let r=[],o=!1,a=[];for(let w of n)if(t.gather==="path")for(let x of i){let O=x.local_path??x.target_url??"",P=O?await vN(w,O):null;P?r.push(P):a.push(`${x.id} ${te(O)}: not at its recorded path under ${w}`)}else{let x=await gN(w,i,t.cap);r.push(...x.paths),o||=x.capped}let{refs:s,failed:c}=await yN([...new Set(r)]);t.remember&&t.media_root&&await SN(t.media_root);let l=hN(t.criteria),u=wN(e,i,s,l,t.tolerances),f=[`scope: ${i.length} reference(s)${t.lane!=="both"?` (${t.lane} lane)`:""}${t.ref_ids?` (zone of ${t.ref_ids.length})`:""}; gather=${t.gather} under ${n.join(", ")}: ${s.length} candidate clip(s)${o?` (CAPPED at ${t.cap} \u2014 narrow the folder)`:""}`,`criteria: ${Object.entries(l).filter(([,w])=>w===!0).map(([w])=>w).join(", ")}${l.fileName?` (${l.fileNameMode})`:""}${l.fileExtensions?`; ext ${l.fileExtensions}`:""}; timecode containment + fps always on`,...c.length?[`could not probe ${c.length}: ${c.slice(0,5).join("; ")}`]:[],...a.slice(0,20)];if(t.dry_run)return{session:e,changed:!1,note:"",text:[...f,zN(e,u,{compare:t.compare}),"(dry run \u2014 nothing changed; pass accept=[{ref_id,candidate_id}] to commit chosen rows, or run again without dry_run to apply every matched row)"].join(`
120
- `)};let d,m=[];if(t.accept?.length){d=[];for(let w of t.accept){let x=u.rows.find(P=>P.ref_id===w.ref_id);x&&(x.candidate?.id===w.candidate_id||x.alternatives.some(P=>P.id===w.candidate_id))?d.push(w):m.push(`${w.ref_id} \u2192 ${w.candidate_id}: not a proposed match or alternative for that reference`)}}else d=u.rows.filter(w=>w.status==="matched"&&w.candidate).map(w=>({ref_id:w.ref_id,candidate_id:w.candidate.id}));let p=xN(e,u,d),h=p.session.media_references??[],b=h.filter(w=>i.some(x=>x.id===w.id)&&w.binding_state==="linked").length,v=p.applied,g=h.filter(w=>i.some(x=>x.id===w.id)&&w.binding_state!=="linked").map(w=>` - ${w.id} ${te(w.target_url??"")}: ${w.coverage_reason??(u.rows.find(x=>x.ref_id===w.id)?.status==="ambiguous"?"ambiguous \u2014 pick one with accept":"no file matched")}`),y=[...f,`Linked ${b} of ${i.length}${m.length?`; ${m.length} pick(s) vetoed`:""}`,...v.map(w=>`- ${w.ref_id}: ${te(w.before.path??"?")} \u2192 ${w.after.path}${w.warning?` \u26A0 ${w.warning}`:""}`),...m.map(w=>` \u2717 ${w}`),...g.length?["unresolved:",...g]:[]].join(`
121
- `);return{session:p.session,changed:!0,note:`relink ${t.gather} ${n[0]} (${b}/${i.length})`,text:y}}function QI(e,t){let n=e.time??e.timeline_range?.start;if(!n||!Number.isFinite(n.value))return null;let i=n.rate&&n.rate>0?n.rate:t;return Math.round(n.value*(t/i))}function _I(e,t){let n=e.duration??e.timeline_range?.duration;if(!n||!Number.isFinite(n.value))return 1;let i=n.rate&&n.rate>0?n.rate:t;return Math.max(1,Math.round(n.value*(t/i)))}function jm(e){let t=(e.timelines??[]).filter(n=>n.kind==="primary");return t.length?t:e.timelines??[]}function a4(e,t){if(t.media_reference_id)return(e.media_references??[]).find(n=>n.id===t.media_reference_id)}function $I(e){if(e.fps_num&&e.fps_den)return e.fps_num/e.fps_den;for(let t of e.tracks??[])for(let n of t.items??[]){let i=n.timeline_range?.start?.rate;if(i&&i>0)return i}return 24}function Zne(e){let t=e?.duration?.value,n=e?.duration?.rate;if(!t||!n)return"n/a";let i=a=>String(a).padStart(2,"0");if(n>=1e3){let a=t/n,s=Math.round((a-Math.floor(a))*1e3);return`${i(Math.floor(a/3600))}:${i(Math.floor(a/60)%60)}:${i(Math.floor(a)%60)}.${String(s).padStart(3,"0")}`}let r=Math.round(n)||24,o=Math.max(0,Math.round(t));return`${i(Math.floor(o/r/3600))}:${i(Math.floor(o/r/60)%60)}:${i(Math.floor(o/r)%60)}:${i(o%r)}`}function Dne(e){return String(Math.round(e*1e3)/1e3).replace(/\.0+$/,"")}function eE(e){for(let t of e?.streams??[])if(t.kind==="video"&&t.bit_depth!=null)return t.bit_depth;return null}var s4=[{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=>Zne(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=eE(e);return t!=null?`${t}-bit`:"n/a"},has:e=>eE(e)!=null},{label:"Frame rate",criterion:"frameRate",standing:!0,get:e=>e?.source_fps!=null?Dne(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}],tE=s4.map(e=>e.label);var nE=["#","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",...tE];function qne(e){if(!e||typeof e!="object")return!1;let t=e,n=t.start,i=t.duration;return!!n&&!!i&&typeof n.value=="number"&&typeof i.value=="number"}function iE(e,t,n){for(let[i,r]of Object.entries(t)){let o=e?`${e}.${i}`:i;if(r==null)n[o]=null;else if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")n[o]=r;else if(qne(r))n[`${o}.start`]=Math.round(r.start.value),n[`${o}.dur`]=Math.round(r.duration.value);else if(Array.isArray(r))n[o]=r.length?`[${r.length}]`:null;else if(typeof r=="object"){let a=JSON.stringify(r);n[o]=a==="{}"?null:a}}}function oE(e){let t=[],n=new Set,i=[],r=s=>{n.has(s)||(n.add(s),i.push(s))},o=0;for(let s of jm(e))for(let c of s.tracks??[])for(let l of c.items??[]){if(l.kind==="gap")continue;let u={};u["#"]=++o,u.timeline=s.name,u.timeline_fps=s.fps_den?s.fps_num/s.fps_den:s.fps_num??null,u.track=Ci(c,s.tracks??[]),iE("",l,u),u.source_fps_n=a4(e,l)?.source_fps??null;let f=a4(e,l);for(let d of s4){let m=f?d.get(f):null;u[d.label]=m==="n/a"?null:m}u.binding_state=f?f.binding_state??"unbound":null;for(let d of Object.keys(u))r(d);t.push({id:l.id,item:l,cells:u})}return{columns:[...nE,...i.filter(s=>!nE.includes(s))],rows:t}}var rE=["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 aE(e){let t=[],n=new Set,i=[],r=a=>{n.has(a)||(n.add(a),i.push(a))};for(let a of e){let s={};s.name=a.name,s.origin=a.origin,a.ref&&iE("",a.ref,s),a.extra&&Object.assign(s,a.extra);for(let c of Object.keys(s))r(c);t.push({id:a.id,name:a.name,ref:a.ref,origin:a.origin,cells:s})}return{columns:[...rE,...i.filter(a=>!rE.includes(a))],rows:t}}var Une={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 Vg(e){let t=Une[e];return t||e.split(".").map(n=>n.replace(/_/g," ").replace(/^./,i=>i.toUpperCase())).join(" \xB7 ")}var Cne=/^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/,Xc="[-+]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][-+]?\\d+)?";function jc(e){let t=e.trim();if(!Cne.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}function Jne(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string")return null;let t=jc(e);if(t!==null)return t;let n=e.trim().match(new RegExp(`^(${Xc})\\s*[a-zA-Z%\xB0\xD7]*$`));if(!n)return null;let i=Number(n[1]);return Number.isFinite(i)?i:null}function sE(e){let t=e.trim(),n=t.indexOf(".");if(n===-1||/[eE]/.test(t))return 1e-4;let i=t.length-n-1;return Math.max(1e-4,.5*Math.pow(10,-(i+1)))}function Eu(e){let t=e.trim();if(!t||t.includes("...."))return null;let i=t.match(new RegExp(`^between\\s+(${Xc})\\s+and\\s+(${Xc})$`,"i"))??t.match(new RegExp(`^(${Xc})\\s*(?:\\.\\.\\.?|,,|\\s+to\\s+|-)\\s*(${Xc})$`,"i"));if(i){let s=jc(i[1]),c=jc(i[2]);return s===null||c===null?null:{op:"range",value:Math.min(s,c),high:Math.max(s,c)}}let r=t.match(new RegExp(`^(?:in\\s+)?(${Xc}(?:\\s*[,|]\\s*${Xc})+)$`,"i"));if(r){let s=r[1].split(/\s*[,|]\s*/).map(jc);if(s.some(l=>l===null))return null;let c=s;return{op:"in",value:c[0],values:c,tolerance:1e-4}}let o=t.match(/^(>=|<=|!=|==|=|>|<)\s*(.+)$/);if(o){let s=jc(o[2]);return s===null?null:{op:o[1]==="=="?"=":o[1],value:s,tolerance:sE(o[2])}}let a=jc(t);return a!==null?{op:"=",value:a,tolerance:sE(t)}:null}function Kne(e){let t=e.trim();if(!t)return null;let n=Eu(t);if(n)return[n];let i=t.split(/(?:\s*(?:,|&|\band\b)\s*|\s+)(?=(?:>=|<=|!=|==|=|>|<))/i).map(o=>o.trim().replace(/(?:\s*(?:,|&|\band))+$/i,"").trim()).filter(Boolean);if(i.length<2)return null;let r=i.map(Eu);return r.some(o=>o===null)?null:r}function Gne(e,t,n){if(!Number.isFinite(e))return!1;let i=n??t.tolerance??1e-6;switch(t.op){case"=":return Math.abs(e-t.value)<=i;case"!=":return Math.abs(e-t.value)>i;case">":return e>t.value;case"<":return e<t.value;case">=":return e>=t.value-i;case"<=":return e<=t.value+i;case"range":return e>=t.value-i&&e<=(t.high??t.value)+i;case"in":return(t.values??[t.value]).some(r=>Math.abs(e-r)<=i);default:return!1}}function c4(e,t=0){if(t>4||e===null||e===void 0)return[];let n=Jne(e);return n!==null?[n]:Array.isArray(e)?e.flatMap(i=>c4(i,t+1)):typeof e=="object"?Object.values(e).flatMap(i=>c4(i,t+1)):[]}function Vu(e,t,n="="){let i=Kne(t);if(!i)return!1;let r=c4(e);if(r.length===0)return!1;let o=jc(t)!==null,a=i.map(s=>o&&n!=="="?{...s,op:n}:s);return r.some(s=>a.every(c=>Gne(s,c)))}var cE="Key > value \xB7 Key = value \xB7 Key ~ text \xB7 Key (exists)",lE=">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 Ane=/^is:(.*)$/,Bne=/^([A-Za-z_][\w. -]*?)\s*(>=|<=|!=|=|>|<|:)\s*(.*)$/s,Yne=/^"([^"]+)"\s*(>=|<=|!=|=|>|<|:)\s*(.*)$/s,uE=/^\/(.*)\/([a-z]*)$/s,l4=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function Hg(e){return e.match(/[^\s"]*(?::|=)in\s+[^\s"]+|(?:[^\s"]+|"[^"]*")+/gi)??[]}function mE(e){return/^".*"$/s.test(e)?e.slice(1,-1):null}function fE(e,t){let n=l4(t);if(!n)return[];let i=Object.keys(e.cells),r=i.filter(a=>l4(a)===n);return(r.length?r:i.filter(a=>l4(a).includes(n))).map(a=>e.cells[a])}var Qne=e=>e==null?null:String(e);function Wg(e,t,n){let i=Qne(e),r=mE(n.trim());if(r!=null)return i==null?!1:t==="="?i.toLowerCase()===r.toLowerCase():t==="!="?i.toLowerCase()!==r.toLowerCase():i.toLowerCase().includes(r.toLowerCase());let o=n.trim(),a=/^in\s+(.+)$/is.exec(o);if(a&&(t===":"||t==="="))return a[1].split(/\s*[,|]\s*/).some(c=>c!==""&&Wg(e,"=",c));if(!o)return i!=null&&i!==""&&i!=="n/a";if(o.includes("|")&&!uE.test(o))return o.split("|").some(c=>c.trim()&&Wg(e,t,c));let s=uE.exec(o);if(s){if(i==null)return!1;try{return new RegExp(s[1],s[2]||"i").test(i)}catch{return!1}}if(t===":"){let c=Eu(o);return c&&!/^[-+]?[\d.]+$/.test(o)?Vu(e,o):c!=null&&Vu(e,o)||i!=null&&i.toLowerCase().includes(o.toLowerCase())}if(Eu(o)&&t!=="="&&t!=="!=")return Vu(e,t+o);if(t==="="||t==="!="){let c=Eu(o)?Vu(e,o):i!=null&&i.toLowerCase()===o.toLowerCase();return t==="="?c:!c}return Vu(e,t+o)}function u4(e,t,n){let i=Yne.exec(t);if(i){let s=fE(e,i[1]);return s.length>0&&s.some(c=>Wg(c,i[2],i[3]))}let r=mE(t);if(r!=null)return dE(e,r);let o=Ane.exec(t);if(o){let s=n[o[1].toLowerCase()];return s?s(e):!1}let a=Bne.exec(t.replace(/^"([^"]+)"(?=\s*(?:[<>!=:]))/,(s,c)=>c));if(a){let s=fE(e,a[1]);return s.length?s.some(c=>Wg(c,a[2],a[3])):!1}return t.includes("|")?t.split("|").some(s=>s.trim()&&u4(e,s.trim(),n)):dE(e,t)}function dE(e,t){let n=t.toLowerCase();return Object.values(e.cells).some(i=>i!=null&&String(i).toLowerCase().includes(n))}function pE(e,t,n={}){let i=t.trim();if(!i)return!0;let r=Object.fromEntries(Object.entries(n).map(([o,a])=>[o.toLowerCase(),a]));return Hg(i).every(o=>{let a=o.startsWith("-")||o.startsWith("!"),s=a?o.slice(1):o;if(!s)return u4(e,o,r);let c=u4(e,s,r);return a?!c:c})}function hE(e){return Object.keys(e).sort()}var bE={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}},gE={unused:e=>Number(e.cells.usage??0)===0,offline:e=>e.cells.binding_state!=="linked",linked:e=>e.cells.binding_state==="linked"};function vE(e){let t=new Map;for(let n of e?.timelines??[])for(let i of n?.tracks??[])for(let r of i?.items??[]){let o=r?.media_reference_id;!o||r.kind==="gap"||t.set(o,(t.get(o)??0)+1)}return t}function _ne(e){return(typeof e.display_name=="string"?e.display_name:"")||e.target_url&&e.target_url.split(/[\\/]/).pop()||e.id}function yE(e,t={}){let n=vE(e),i=t.idPrefix??"mr:";return(e?.media_references??[]).flatMap(r=>{let o=_ne(r);return t.skip?.(o)?[]:[{id:`${i}${r.id}`,name:o,ref:r,origin:"from timeline",extra:{usage:n.get(r.id)??0}}]})}function wE(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function $ne(e){return e==null?"":String(e)}function Zg(e,t){let n=e.map(r=>wE(r.header)).join(","),i=t.map(r=>e.map(o=>wE($ne(o.value(r)))).join(","));return[n,...i].join(`
122
- `)}var ere=["Blue","Cyan","Green","Yellow","Red","Pink","Purple","Fuchsia","Rose","Lavender","Sky","Mint","Lemon","Sand","Cocoa","Cream"];function xE(e,t){let n=$I(e),i=il(n,!!e.is_drop_frame),r=e.start_frame??0,o=new Map,a=(e.tracks??[]).filter(l=>l.kind==="Video")[0];for(let l of e.tracks??[])for(let u of l.items??[])o.set(u.id,{name:u.name??u.id});let s=l=>{for(let u of a?.items??[]){let f=u.timeline_range?.start?.value??0,d=u.timeline_range?.duration?.value??0;if(l>=f&&l<f+d)return u.name??u.id}return""},c=[];return(e.markers??[]).forEach((l,u)=>{let f=QI(l,n);if(f==null)return;let d=_I(l,n),m=l.id??`marker-${u}`,p=l.item_id&&o.get(l.item_id)?.name||s(f),h={id:m,marker:l,frame:f,tc:Li(r+f,n,i),duration:d,durationTc:d>1?Li(d,n,!1).replace(/^00:/,""):"",color:l.color??"",name:l.name??"",note:l.note??l.comment??"",clip:p,cells:{}};h.cells={tc:h.tc,frame:f,color:h.color,name:h.name,note:h.note,duration:h.durationTc,clip:p},c.push(h)}),c.sort((l,u)=>l.frame-u.frame)}var PE={...Object.fromEntries(ere.map(e=>[e.toLowerCase(),t=>t.color.toLowerCase()===e.toLowerCase()])),duration:e=>e.duration>1};function kE(e){return Zg([{header:"Record TC",value:n=>n.tc},{header:"Source TC",value:()=>""},{header:"Frame",value:n=>n.frame},{header:"Color",value:n=>n.color},{header:"Source",value:n=>n.marker.item_id?"clip":"timeline"},{header:"Clip Name",value:n=>n.clip},{header:"Name",value:n=>n.name},{header:"Note",value:n=>n.note},{header:"Duration",value:n=>n.duration},{header:"Keywords",value:()=>""},{header:"Custom Data",value:n=>n.marker.metadata?JSON.stringify(n.marker.metadata):""}],e)}function SE(e,t){let n=e.map(i=>({header:Vg(i),value:r=>{let o=r.cells[i];return o==null?"":typeof o=="boolean"?o?"true":"false":o}}));return Zg(n,[...t])}function TE(e,t,n=new Date){let i=n.toISOString().slice(0,16).replace(/[-:T]/g,""),r=o=>o.replace(/[^a-zA-Z0-9_-]/g,"_");return`${i}_${r(e)}_${r(t)}.csv`}var zE=["clips","media","markers"],tre={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"]},f4=`Terms are separated by spaces and ALL must match; a leading - negates a term. 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: ${lE} (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; media: is:unused, is:offline, is:linked; markers: is:<colour>, is:duration). An unknown field or lens matches nothing.`,nre=/^([-!]?)overlaps?:(.+)$/i;function rre(e){let t=[];return{rest:Hg(e).filter(i=>{let r=nre.exec(i);if(!r)return!0;let[o,a=o]=r[2].split(/\.\.\.?|-(?=\d)/);return t.push(s=>{if(!s.item||!s.tl)return!1;let c=s.tl.fps_den?s.tl.fps_num/s.tl.fps_den:s.tl.fps_num,l=Qt(s.tl.start_frame??0,c,!!s.tl.is_drop_frame),u,f;try{u=Yr(o,c,l),f=Yr(a,c,l)}catch{return!1}u>f&&([u,f]=[f,u]);let d=s.item.timeline_range.start.value,m=d+s.item.timeline_range.duration.value,p=d<=f&&m>u;return r[1]?!p:p}),!1}).join(" "),tests:t}}function ire(e){let t=o=>[o.timeline_range.start.value,o.timeline_range.start.value+o.timeline_range.duration.value],n=(e.tracks??[]).filter(o=>o.kind==="Video"&&o.enabled!==!1).sort((o,a)=>a.track_index-o.track_index).map(o=>o.items.filter(a=>a.enabled!==!1&&(a.kind==="clip"||a.kind==="nested")&&!a.title)),i=[...new Set(n.flat().flatMap(o=>t(o)))].sort((o,a)=>o-a),r=new Set;for(let o=0;o+1<i.length;o++){let a=i[o];for(let s of n){let c=s.find(l=>t(l)[0]<=a&&a<t(l)[1]);if(c){r.add(c.id);break}}}return r}var ore=/^([-!]?)is:visible$/i;function are(e){let t=new Map,n=[];return{rest:Hg(e).filter(r=>{let o=ore.exec(r);return o?(n.push(a=>{if(!a.tl)return!1;t.has(a.tl)||t.set(a.tl,ire(a.tl));let s=t.get(a.tl).has(a.id);return o[1]?!s:s}),!1):!0}).join(" "),tests:n}}function sre(e,t,n){let i=e,r=jm(i).filter(a=>!n||a.id===n);if(n&&!r.length){let a=jm(i).map(s=>`${s.id} "${s.name}"`).join(", ");throw new Te("not_found",`no timeline ${n} in this session (timelines: ${a||"none"})`)}if(t==="clips"){let a=new Set(r.map(f=>f.id)),s=new Map;for(let f of e.timelines){if(!a.has(f.id))continue;let d=f.fps_den?f.fps_num/f.fps_den:f.fps_num,m=p=>Qt(p+(f.start_frame??0),d,!!f.is_drop_frame);for(let p of f.tracks??[])for(let h of p.items??[]){let b=h.timeline_range.start.value,v=b+h.timeline_range.duration.value;s.set(h.id,{tl:f,cells:{track_name:p.name??null,track_enabled:p.enabled!==!1,rec_in_tc:m(b),rec_out_tc:m(v)}})}}let c=oE(i),l=c.rows.filter(f=>s.has(f.id)).map(f=>({...f,tl:s.get(f.id).tl,cells:{...f.cells,...s.get(f.id).cells}})),u=[...c.columns];return u.splice(u.indexOf("track")+1,0,"track_name","track_enabled"),u.splice(u.indexOf("timeline_range.dur")+1,0,"rec_in_tc","rec_out_tc"),{rows:l,columns:u,lenses:bE}}if(t==="media"){let a=aE(yE(i));return{rows:a.rows,columns:a.columns,lenses:gE}}return{rows:r.flatMap(a=>xE(a,i).map(s=>({...s,id:`${a.id}:${s.id}`,cells:{timeline:a.name,...s.cells}}))),columns:["timeline","tc","frame","color","name","note","duration","clip"],lenses:PE}}function cre(e,t,n){if(!e?.length)return tre[t].filter(a=>n.includes(a));let i=a=>a.toLowerCase().replace(/[^a-z0-9]/g,""),r=[],o=[];for(let a of e){let s=n.find(c=>c===a)??n.find(c=>i(c)===i(a)||i(Vg(c))===i(a));s?r.push(s):o.push(a)}if(o.length)throw new Te("invalid_args",`unknown column${o.length>1?"s":""} ${o.join(", ")} for ${t} (columns: ${n.slice(0,60).join(", ")}${n.length>60?", \u2026":""})`,{available:n});return r}function OE(e,t){let{rows:n,columns:i,lenses:r}=sre(e,t.table,t.timeline_id),o=cre(t.columns,t.table,i),a=are(t.query?.trim()??""),{rest:s,tests:c}=rre(a.rest),l=[...a.tests,...c],u=n.filter(d=>l.every(m=>m(d))&&(!s||pE(d,s,r))),f={table:t.table,columns:o,available:i,lenses:hE(r),total:n.length,matched:u.length,rows:u.map(d=>({id:d.id,cells:Object.fromEntries(o.map(m=>[m,d.cells[m]??null]))}))};return t.csv&&(f.csv=t.table==="markers"&&!t.columns?.length?kE(u):SE(o,u)),f}async function ME(e,t,n){let i=e.table==="clips"?"Edit_Index":e.table==="media"?"Media":"Markers",r=await gi(t)?Q(t,TE(n,i)):t;return await rn(r,e.csv??""),r}function LE(e,t,n){let i=`${e.table}: ${e.matched} of ${e.total} row${e.total===1?"":"s"}${t?` match "${t}"`:""}`;if(!e.matched)return`${i}
123
- lenses: ${e.lenses.map(f=>`is:${f}`).join(" ")||"(none)"}
124
- columns: ${e.available.slice(0,40).join(", ")}${e.available.length>40?", \u2026":""}
125
- grammar: ${f4}
126
- field queries: ${cE}`;let r=e.rows.slice(0,n),o=f=>(f==null?"":String(f)).replace(/\s+/g," ").slice(0,60),a=e.columns.map(f=>Math.min(60,Math.max(f.length,...r.map(d=>o(d.cells[f]).length)))),s=f=>f.map((d,m)=>d.padEnd(a[m])).join(" ").trimEnd(),c=[s(e.columns),...r.map(f=>s(e.columns.map(d=>o(f.cells[d]))))],l=e.matched>r.length?`TRUNCATED: showing ${r.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.
127
- `:"",u=l?`
128
- \u2026 ${e.matched-r.length} more not shown (see TRUNCATED above)`:"";return`${l}${i}
129
- ${c.join(`
130
- `)}${u}`}var lre=/^0[1-4]_[A-Z_]+\//;function m4(e,t){let n=d4(e.target_url);if(!n)return"";let i=e.role==="reference"?"03_REFERENCES":"02_MEDIA";if(t&&e.target_url){let r=fre(e.target_url),o=r?r.replace(lre,""):n;return`${i}/${o}`}return`${i}/${n}`}function p4(e,t,n){return{entries:ure(e,t,n).entries.map(o=>{if(o.inlineBytes)return{path:o.path,bytes:o.inlineBytes};if(o.sourceBasename)return{path:o.path,sourceBasename:o.sourceBasename};throw new Error(`folder-layout entry missing both inlineBytes and sourceBasename: ${o.path}`)})}}function ure(e,t,n){let i=[],r=new Map,o=new Set;for(let c of n.sourceFiles??[]){let l=Wu(`01_PROJECT_FILES/source/${c.name}`,o);i.push({path:l,section:"project-source",inlineBytes:c.data})}let a=new Set,s=(e.media_references??[]).filter(c=>{if(!c.target_url)return!1;let l=d4(c.target_url);if(!(l.length>0&&t.has(l)))return!1;let u=`${l.toLowerCase()}\0${c.role??""}`;return a.has(u)?!1:(a.add(u),!0)});for(let c of s){let l=d4(c.target_url);if(c.bundle&&c.bundle.files.length>0){for(let f of c.bundle.files){if(!t.has(f.basename))continue;let d=Wu(`02_MEDIA/${f.rel_path}`,o);i.push({path:d,section:"media",sourceBasename:f.basename}),r.set(f.basename,d)}continue}let u=Wu(m4(c,n.preserveStructure===!0),o);i.push({path:u,section:c.role==="reference"?"reference":"media",sourceBasename:l}),c.role!=="reference"&&r.set(l,u)}for(let c of n.exchangeFiles??[]){let l=c.text?RE(c.bytes,r,n.volumeName):c.bytes,u=Wu(`01_PROJECT_FILES/converted/${c.filename}`,o);i.push({path:u,section:"project-converted",inlineBytes:l})}if(n.timelineFile){let c=n.timelineFile,l=RE(c.bytes,r,n.volumeName);if(c.isConversion){let u=Wu(`01_PROJECT_FILES/converted/${c.filename}`,o);i.push({path:u,section:"project-converted",inlineBytes:l})}else{let u=c.filename.includes(".")?c.filename.slice(c.filename.lastIndexOf(".")):"",d=`${c.filename.includes(".")?c.filename.slice(0,c.filename.lastIndexOf(".")):c.filename}_relinked${u}`,m=Wu(`01_PROJECT_FILES/source/${d}`,o);i.push({path:m,section:"project-source",inlineBytes:l})}}return{entries:i,basenameToIsoPath:r}}function RE(e,t,n){let i;try{i=new TextDecoder("utf-8",{fatal:!1}).decode(e)}catch{return e}for(let[r,o]of t){let a=`/Volumes/${n}/${o}`,s=dre(r);i=i.replace(new RegExp(`(<pathurl>)[^<]*${s}(</pathurl>)`,"g"),`$1file://localhost${a}$2`).replace(new RegExp(`("target_url"\\s*:\\s*")[^"]*${s}"`,"g"),`$1${a}"`).replace(new RegExp(`(src="file://)[^"]*${s}"`,"g"),`$1localhost${a}"`)}return new TextEncoder().encode(i)}function d4(e){return e?e.split(/[/\\]/).pop()??"":""}function fre(e){if(e)try{return decodeURIComponent(e.replace(/^file:\/\//,"").replace(/^\//,"").replace(/^Volumes\//,""))||void 0}catch{return}}function Wu(e,t){if(!t.has(e))return t.add(e),e;let n=e.lastIndexOf("."),i=n>0?e.slice(0,n):e,r=n>0?e.slice(n):"",o=2,a=`${i}_${o}${r}`;for(;t.has(a);)o++,a=`${i}_${o}${r}`;return t.add(a),a}function dre(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function NE(e){return kT(e)}function XE(e,t){let n=Math.max(0,Math.floor(e.handles??0)),i=e.frame_in-n,r=e.frame_out+n,o=Math.max(0,i),a=t!==void 0?Math.min(t,r):r;return{frame_in:o,frame_out:a,handles_applied_in:e.frame_in-o,handles_applied_out:a-e.frame_out,handles_requested:n}}function Fc(e,t){if(t.format==="iso")return pre(e,t);if(t.format==="folder")return mre(e,t);throw new Error(`deriveLayout: unsupported format "${t.format}"`)}function mre(e,t){let n=jE(e),i=[],r=new Set,o=new Set,a=0;for(let s of n){let c=h4(s);if(!c)continue;o.add(c);let l=hre(s,c,t);r.add(l);let u=FE(s.id??c,t),f=IE(e,s,u,t.handles??0);i.push({dest_file:l,dest_offset:0,length:f,source:{kind:"file",basename:c,offset:0}}),a+=f}return{regions:i,total_bytes:a,dest_files:Array.from(r),source_basenames:Array.from(o)}}function pre(e,t){if(!t.volume_name)throw new Error("deriveLayout(iso): intent.volume_name is required");let n=jE(e),i=`${t.volume_name}.iso`,r=[],o=new Set,a=0;for(let s of n){let c=h4(s);if(!c)continue;o.add(c);let l=FE(s.id??c,t),u=IE(e,s,l,t.handles??0);r.push({dest_file:i,dest_offset:a,length:u,source:{kind:"file",basename:c,offset:0}}),a+=u}return{regions:r,total_bytes:a,dest_files:[i],source_basenames:Array.from(o)}}function jE(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 h4(e){if(!e.target_url)return null;let t=e.target_url.split(/[\\/]/).pop();return t&&t.length>0?t:null}function hre(e,t,n){let i=n.per_file_overrides?.[e.id]?.rel_path;if(i)return i;switch(n.folder_layout??"flat"){case"flat":return t;case"by-camera":{let r=e.reel_name;return r?`${r}/${t}`:t}case"media-organized":{let r=bre(e);return r?`${r}/${t}`:t}case"canonical-i2o":return m4(e,!1)}}function bre(e){if(bp(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 FE(e,t){return t.per_file_overrides?.[e]?.mode??t.per_file_mode}function IE(e,t,n,i){let r=t.size_bytes??0;if(r===0)return 0;let o=h4(t);if(!o||!NE(o)||n.mode==="sparse"&&n.populate.full===!0)return r;let a=t.available_range?.duration?.value??0;if(a<=0)return r;let s=gre(e,t.id);if(s.length===0)return r;let c=s.map(d=>{let m=XE({frame_in:d.start,frame_out:d.end,handles:i},a);return{start:m.frame_in,end:m.frame_out}});c.sort((d,m)=>d.start-m.start);let l=[{...c[0]}];for(let d=1;d<c.length;d++){let m=c[d],p=l[l.length-1];m.start<=p.end?p.end=Math.max(p.end,m.end):l.push({...m})}let u=0;for(let d of l){let m=Math.max(0,d.start),p=Math.min(a,d.end);p>m&&(u+=p-m)}let f=Math.min(1,u/a);return Math.round(f*r)}function gre(e,t){let n=[],i=e?.timelines??[];for(let r of i)for(let o of r.tracks??[])for(let a of o.items??[]){if(a.media_reference_id!==t||!a.source_range)continue;let s=a.source_range.start.value,c=a.source_range.duration.value;c>0&&n.push({start:s,end:s+c})}return n}function EE(e,t){let n=vre(e),i=n>=0?e.slice(0,n+1):"",r=n>=0?e.slice(n+1):e,o=r.lastIndexOf(".");return o<=0?i+r+t:i+r.slice(0,o)+t+r.slice(o)}function vre(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("\\");return t>n?t:n}async function VE(e){try{return await e()}catch(t){let n=XT(t);throw n?new jT(n):t}}async function Dg(e){let t=PT(e);if(!t||!t.trimSupported)return null;let n=t.flavor,i=r=>$c(n,[yp(e,r)]);return{byteSourceFromFile:yre,async prepareWrite(r,o,a){let c=(await VE(()=>lo(i(r),{verb:"sparsify",selection:{items:o,handles:a}})))[0];return{fileSize:c.fileSize,structuralRanges:c.structuralRanges,essenceRanges:c.essenceRanges,trimInputs:c.trimInputs??[],wholeFileFallback:c.wholeFileFallback}},async planTrim(r,o,a){let s=await VE(()=>lo(i(r),{verb:"trim",selection:{items:o,handles:a}}));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 s}}}async function yre(e){return{fileSize:e.size,async read(t,n){let i=Math.min(t+n,e.size),r=e.slice(t,i);return new Uint8Array(await r.arrayBuffer())}}}var wre=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let i=0;i<8;i++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;wre[e]=t&65535}var b4=0,WE=2;var Fm=Date.UTC(2020,0,1,0,0,0);function DE(e,t,n,i,r,o,a,s,c,l,u,f,d,m,p,h){let b=Vm(r,Jt.__wbindgen_export3,Jt.__wbindgen_export4),v=Po,g=y4(a,Jt.__wbindgen_export3),y=Po,w=Jt.udf_add_file_stream(On(e),On(t),On(n),On(i),b,v,o,g,y,s,c,l,u,f,d,m,p,h);return Du(w)}function qE(e,t,n,i){let r,o;try{let d=Jt.__wbindgen_add_to_stack_pointer(-16),m=Vm(e,Jt.__wbindgen_export3,Jt.__wbindgen_export4),p=Po,h=Vm(t,Jt.__wbindgen_export3,Jt.__wbindgen_export4),b=Po,v=Vm(n,Jt.__wbindgen_export3,Jt.__wbindgen_export4),g=Po;Jt.udf_build_layout(d,m,p,h,b,v,g,i);var a=oo().getInt32(d+0,!0),s=oo().getInt32(d+4,!0),c=oo().getInt32(d+8,!0),l=oo().getInt32(d+12,!0),u=a,f=s;if(l)throw u=0,f=0,Du(c);return r=u,o=f,Ec(u,f)}finally{Jt.__wbindgen_add_to_stack_pointer(16),Jt.__wbindgen_export5(r,o,1)}}function UE(e,t,n,i,r,o,a){let s=Vm(r,Jt.__wbindgen_export3,Jt.__wbindgen_export4),c=Po,l=y4(a,Jt.__wbindgen_export3),u=Po,f=Jt.udf_fill_sparse_stream(On(e),On(t),On(n),On(i),s,c,o,l,u);return Du(f)}function CE(){let e,t;try{let r=Jt.__wbindgen_add_to_stack_pointer(-16);Jt.udf_last_panic(r);var n=oo().getInt32(r+0,!0),i=oo().getInt32(r+4,!0);return e=n,t=i,Ec(n,i)}finally{Jt.__wbindgen_add_to_stack_pointer(16),Jt.__wbindgen_export5(e,t,1)}}function JE(e,t){let n=Jt.udf_parse_stream(On(e),On(t));return Du(n)}function KE(e){let t,n;try{let o=Jt.__wbindgen_add_to_stack_pointer(-16),a=y4(e,Jt.__wbindgen_export3),s=Po;Jt.udf_read_conform_iuvd(o,a,s);var i=oo().getInt32(o+0,!0),r=oo().getInt32(o+4,!0);return t=i,n=r,Ec(i,r)}finally{Jt.__wbindgen_add_to_stack_pointer(16),Jt.__wbindgen_export5(t,n,1)}}function xre(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof cr(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return cr(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let i=cr(n),r=typeof i=="number"?i:void 0;oo().setFloat64(t+8,Hu(r)?0:r,!0),oo().setInt32(t+0,!Hu(r),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(Ec(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){cr(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return g4(function(t,n,i,r){let o=cr(t).call(cr(n),cr(i),cr(r));return On(o)},arguments)},__wbg_call_5575218572ead796:function(){return g4(function(t,n,i){let r=cr(t).call(cr(n),cr(i));return On(r)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return g4(function(t,n){let i=cr(t).call(cr(n));return On(i)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(Ec(t,n))},__wbg_length_589238bdcf171f0e:function(t){return cr(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(cr(t));return On(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let i=new Uint8Array(ZE(t,n));return On(i)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let i=new Function(Ec(t,n));return On(i)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var i={a:t,b:n},r=(a,s)=>{let c=i.a;i.a=0;try{return kre(c,i.b,a,s)}finally{i.a=c}};let o=new Promise(r);return On(o)}finally{i.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,i){Uint8Array.prototype.set.call(ZE(t,n),cr(i))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=cr(t).queueMicrotask;return On(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(cr(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(cr(t));return On(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return Hu(t)?0:On(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return Hu(t)?0:On(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return Hu(t)?0:On(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return Hu(t)?0:On(t)},__wbg_then_05edfc8a4fea5106:function(t,n,i){let r=cr(t).then(cr(n),cr(i));return On(r)},__wbg_then_591b6b3a75ee817a:function(t,n){let i=cr(t).then(cr(n));return On(i)},__wbindgen_cast_0000000000000001:function(t,n){let i=Tre(t,n,Pre);return On(i)},__wbindgen_cast_0000000000000002:function(t){return On(t)},__wbindgen_cast_0000000000000003:function(t,n){let i=Ec(t,n);return On(i)},__wbindgen_object_clone_ref:function(t){let n=cr(t);return On(n)},__wbindgen_object_drop_ref:function(t){Du(t)}}}}function Pre(e,t,n){try{let o=Jt.__wbindgen_add_to_stack_pointer(-16);Jt.__wasm_bindgen_func_elem_252(o,e,t,On(n));var i=oo().getInt32(o+0,!0),r=oo().getInt32(o+4,!0);if(r)throw Du(i)}finally{Jt.__wbindgen_add_to_stack_pointer(16)}}function kre(e,t,n,i){Jt.__wasm_bindgen_func_elem_266(e,t,On(n),On(i))}function On(e){Em===Ra.length&&Ra.push(Ra.length+1);let t=Em;return Em=Ra[t],Ra[t]=e,t}var HE=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Jt.__wbindgen_export2(e.a,e.b));function Sre(e){e<1028||(Ra[e]=Em,Em=e)}function ZE(e,t){return e=e>>>0,Zu().subarray(e/1,e/1+t)}var Ic=null;function oo(){return(Ic===null||Ic.buffer.detached===!0||Ic.buffer.detached===void 0&&Ic.buffer!==Jt.memory.buffer)&&(Ic=new DataView(Jt.memory.buffer)),Ic}function Ec(e,t){return Ore(e>>>0,t)}var Im=null;function Zu(){return(Im===null||Im.byteLength===0)&&(Im=new Uint8Array(Jt.memory.buffer)),Im}function cr(e){return Ra[e]}function g4(e,t){try{return e.apply(this,t)}catch(n){Jt.__wbindgen_export(On(n))}}var Ra=new Array(1024).fill(void 0);Ra.push(void 0,null,!0,!1);var Em=Ra.length;function Hu(e){return e==null}function Tre(e,t,n){let i={a:e,b:t,cnt:1},r=(...o)=>{i.cnt++;let a=i.a;i.a=0;try{return n(a,i.b,...o)}finally{i.a=a,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{--i.cnt===0&&(Jt.__wbindgen_export2(i.a,i.b),i.a=0,HE.unregister(i))},HE.register(r,i,i),r}function y4(e,t){let n=t(e.length*1,1)>>>0;return Zu().set(e,n/1),Po=e.length,n}function Vm(e,t,n){if(n===void 0){let s=Wm.encode(e),c=t(s.length,1)>>>0;return Zu().subarray(c,c+s.length).set(s),Po=s.length,c}let i=e.length,r=t(i,1)>>>0,o=Zu(),a=0;for(;a<i;a++){let s=e.charCodeAt(a);if(s>127)break;o[r+a]=s}if(a!==i){a!==0&&(e=e.slice(a)),r=n(r,i,i=a+e.length*3,1)>>>0;let s=Zu().subarray(r+a,r+i),c=Wm.encodeInto(e,s);a+=c.written,r=n(r,i,a,1)>>>0}return Po=a,r}function Du(e){let t=cr(e);return Sre(e),t}var qg=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qg.decode();var zre=2146435072,v4=0;function Ore(e,t){return v4+=t,v4>=zre&&(qg=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qg.decode(),v4=t),qg.decode(Zu().subarray(e,e+t))}var Wm=new TextEncoder;"encodeInto"in Wm||(Wm.encodeInto=function(e,t){let n=Wm.encode(e);return t.set(n),{read:e.length,written:n.length}});var Po=0,Mre,Lre,Jt;function Rre(e,t){return Lre=e,Jt=e.exports,Mre=t,Ic=null,Im=null,Jt.__wbindgen_start(),Jt}async function Nre(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}else{let i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}function n(i){switch(i){case"basic":case"cors":case"default":return!0}return!1}}async function Ug(e){if(Jt!==void 0)return Jt;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("udf_bg.wasm",import.meta.url));let t=xre();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:i}=await Nre(await e,t);return Rre(n,i)}var w4=null;function Xre(e){return w4||(w4=(async()=>{if(e!==void 0)return Ug(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:i}=await import(n),r=await i(new URL("./wasm/udf_bg.wasm",import.meta.url));return Ug({module_or_path:r})}let{default:t}=await import("./udf_bg-ZIB3GK52.js");return Ug({module_or_path:t})})()),w4}function Vc(){return Xre()}function Cg(e){return(t,n)=>e.read(t,n)}function x4(e){return(t,n)=>e.write(t,n)}function Jg(e){return()=>e.getSize()}function P4(e){return t=>e.setSize?e.setSize(t):Promise.resolve()}function jre(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}async function Hm(e,t="i2o",n,i,r=Fm){await Vc();let o;try{o=qE(JSON.stringify(e),t,i?JSON.stringify(i):"",r)}catch(s){let c="";try{c=CE()}catch{}throw c?new Error(`udf_build_layout failed: ${c} (raw: ${s instanceof Error?s.message:String(s)})`):s instanceof Error?s:new Error(`udf_build_layout failed: ${String(s)}`)}let a=JSON.parse(o);return{totalBytes:a.totalBytes,totalSectors:a.totalSectors,structuralRegions:a.structuralRegions.map(s=>({sectorStart:s.sectorStart,sectorCount:s.sectorCount,data:jre(s.dataB64)})),fileDataRegions:a.fileDataRegions}}async function GE(e){await Vc();let t=32*2048,n=16*2048,i;if(e instanceof Uint8Array){if(e.length<t+n)return null;i=e.subarray(t,t+n)}else{if(e.size<t+n)return null;i=new Uint8Array(await e.slice(t,t+n).arrayBuffer())}let r=KE(i);if(!r)return null;try{return JSON.parse(r)}catch{return null}}function Fre(e){return e.speed!=null&&e.speed!==100||e.speed_reverse||e.speed_ramped?!0:(e.keyframes??[]).some(t=>t.parameter_path==="speed")}function Ire(e,t){let n=e.timelines??[];if(t)return n.filter(o=>o.name===t);let i=new Set;for(let o of n)for(let a of o.tracks??[])for(let s of a.items??[])s.nested_timeline_id&&i.add(s.nested_timeline_id);let r=n.filter(o=>!i.has(o.id));return r.length?r:n}function Ere(e,t,n){let i=new Map((e.timelines??[]).map(o=>[o.id,o])),r=(o,a,s,c)=>{if(!(!o||s>8))for(let l of o.tracks??[])for(let u of l.items??[]){let f=s===0?u:c??u,d=Math.round(u.timeline_range?.start?.value??0),m=d+Math.round(u.timeline_range?.duration?.value??0),p=a?a.map(([b,v])=>[Math.max(d,b),Math.min(m,v)]).filter(([b,v])=>v>b):[[d,m]];if(p.length===0)continue;let h=Fre(u);if(u.nested_timeline_id){let b=i.get(u.nested_timeline_id),v=Math.round(u.source_range?.start?.value??0),g=(o.fps_num??0)/Math.max(o.fps_den??1,1),y=b?(b.fps_num??0)/Math.max(b.fps_den??1,1):g,w=g>0&&y>0?y/g:1,x=p.map(([O,P])=>[Math.floor((v+(O-d))*w),Math.floor((v+(P-d))*w)]);r(b,x,s+1,f)}else if(u.media_reference_id){let b=Math.round(u.source_range?.start?.value??0),v=Math.round(u.source_range?.duration?.value??0);if(h){n({item:u,root:f,tl_id:o.id,depth:s,has_speed:!0,tl_in:d,src_in:b,a:d,b:d+v,reached_in:b,reached_out:b+v});continue}for(let[g,y]of p)n({item:u,root:f,tl_id:o.id,depth:s,has_speed:!1,tl_in:d,src_in:b,a:g,b:y,reached_in:b+(g-d),reached_out:b+(y-d)})}}};for(let o of Ire(e,t.rootTimelineName))r(o,null,0,null)}function AE(e,t={}){let n=new Map;return Ere(e,t,i=>{let r=i.item.media_reference_id,o={clip_src_in:i.src_in,reached_in:i.reached_in,reached_out:i.reached_out,has_speed:i.has_speed},a=n.get(r);a?a.push(o):n.set(r,[o])}),n}var Na=2048;function Gg(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 BE(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:i}=await Vre(e),r=[],o=[];for(let v of e.entries){if("bytes"in v){r.push({path:v.path,totalSize:v.bytes.length,keptRanges:[{offset:0,length:v.bytes.length}],inlineBytes:v.bytes});continue}let g=e.files.get(v.sourceBasename);if(!g)continue;let y=()=>({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:[{offset:0,length:g.size}],file:g}),w=await Dg(v.sourceBasename);if(!w||t.full){r.push(y());continue}if(Lo(v.sourceBasename)){if(i.has(v.sourceBasename)){Gg(o,v.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}let S=n.get(v.sourceBasename);if(S&&(S.structuralRanges.length>0||S.essenceRanges.length>0)){let k=[...S.structuralRanges];t.segments&&k.push(...S.essenceRanges),r.push({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:k,prep:{fileSize:g.size,structuralRanges:S.structuralRanges,essenceRanges:S.essenceRanges,trimInputs:[]},file:g})}else Gg(o,v.sourceBasename,"R3D part has no planned sparse ranges");continue}let x=QE(e.session,v.sourceBasename),O=await w.byteSourceFromFile(g),P;try{P=await w.prepareWrite(O,x,e.handles)}catch(S){let k=Fs(S);if(k){console.warn(`[planIsoRegions] coverage miss detail for "${v.sourceBasename}":`,k),Gg(o,v.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}Gg(o,v.sourceBasename,S instanceof Error?S.message:String(S));continue}let T=[...P.structuralRanges];t.segments&&T.push(...P.essenceRanges),r.push({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:T,prep:P,source:O,file:g})}let a=r.map(v=>{let g=v.prep?Wre(v.keptRanges,v.totalSize):void 0,y=e.pinSectorByPath?.get(v.path);return{name:v.path,totalSize:v.totalSize,...g?{dataExtents:g}:{},...y!==void 0?{fixedPartSector:y}:{}}}),s=await Hm(a,e.volumeName,{},e.iuvd,e.buildTimestamp),c=new Map;for(let v of s.fileDataRegions)c.has(v.name)||c.set(v.name,{byteOffset:v.sectorStart*Na,partSector:v.sectorStart-257});let l=`${e.volumeName}.iso`,u=[],f=new Set;for(let v of s.structuralRegions)v.data.length!==0&&u.push({dest_file:l,dest_offset:v.sectorStart*Na,length:v.data.length,source:{kind:"inline",bytes:v.data}});let d=new Map;for(let v of r)d.set(v.path,v);let m=new Map,p=new Map;for(let v of s.fileDataRegions){let g=d.get(v.name);if(!g)continue;let y=!!g.file&&!g.inlineBytes&&(!g.prep||g.prep.wholeFileFallback===!0);if(p.has(g.path)||p.set(g.path,y),g.inlineBytes){let P=g.inlineBytes.subarray(v.sourceOffset,v.sourceOffset+v.sourceLength);u.push({dest_file:l,dest_offset:v.sectorStart*Na,length:P.length,source:{kind:"inline",bytes:P}}),m.set(g.path,(m.get(g.path)??0)+P.length);continue}if(!g.file){p.set(g.path,!0);continue}if(!g.prep){f.add(g.sourceBasename??g.file.name),u.push({dest_file:l,dest_offset:v.sectorStart*Na,length:v.sourceLength,source:{kind:"file",basename:g.sourceBasename??g.file.name,offset:v.sourceOffset}}),m.set(g.path,(m.get(g.path)??0)+v.sourceLength);continue}let w=g.sourceBasename??g.file.name;f.add(w);let x=v.sourceOffset,O=v.sourceOffset+v.sourceLength;for(let P of g.keptRanges){let T=Math.max(P.offset,x),S=Math.min(P.offset+P.length,O);if(S<=T)continue;let k=S-T;u.push({dest_file:l,dest_offset:v.sectorStart*Na+(T-x),length:k,source:{kind:"file",basename:w,offset:T}}),m.set(g.path,(m.get(g.path)??0)+k)}}u.sort((v,g)=>v.dest_offset-g.dest_offset);let h=r.map(v=>({path:v.path,bytesWritten:m.get(v.path)??0,fellBack:p.get(v.path)??!1})),b=0;for(let v of u)b+=v.length;return{layout:{regions:u,total_bytes:b,dest_files:[l],source_basenames:Array.from(f),image_total_bytes:s.totalBytes},isoPositions:c,totalBytes:s.totalBytes,perFileSummary:h,untrimmable:o}}async function YE(e,t,n,i={}){let{layout:r,totalBytes:o}=e;if(r.dest_files.length!==1)throw new Error(`executeIsoPlan: expected single dest_file, got ${r.dest_files.length}`);let a=0;for(let c of r.regions)c.source.kind!=="zero"&&(a+=c.length);await n.reserveSize(o);let s=0;try{for(let c of r.regions){if(i.signal?.aborted)throw new DOMException("Aborted","AbortError");if(c.length!==0){switch(c.source.kind){case"inline":{await n.writeAt(c.dest_offset,c.source.bytes),s+=c.source.bytes.length;break}case"file":{let l=t.get(c.source.basename);if(!l)throw new Error(`executeIsoPlan: file not in files map: "${c.source.basename}"`);let u=16*1024*1024,f=0;for(;f<c.length;){let d=Math.min(u,c.length-f),m=l.slice(c.source.offset+f,c.source.offset+f+d),p=new Uint8Array(await m.arrayBuffer());await n.writeAt(c.dest_offset+f,p),f+=d,s+=d,i.onProgress?.({bytesWritten:s,totalBytes:a,currentFile:c.source.basename})}continue}case"zero":break;case"pack":throw new Error("executeIsoPlan: `pack` regions require the CAS executor, not a local-file build")}i.onProgress?.({bytesWritten:s,totalBytes:a})}}await n.close()}catch(c){throw await n.abort?.(c),c}return{bytesWritten:s}}async function Vre(e){let t=new Map,n=new Set,i=e.session.media_references??[],r=[],o=new Set;for(let c of i){if(c.bundle?.kind!=="rdc")continue;let l=c.bundle,u=l.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 f=(c.target_url??"").split(/[/\\]/).pop()||u[0].filename;r.push({label:l.folder,anchorBasename:f,parts:u});for(let d of u)o.add(d.filename)}for(let c of i){if(c.bundle?.kind==="rdc")continue;let l=(c.target_url??"").split(/[/\\]/).pop()??"";if(!Lo(l)||o.has(l))continue;let u=ET(l,e.files.keys()).map(f=>({filename:f,file:e.files.get(f)})).filter(f=>!!f.file);if(u.length!==0){r.push({label:l,anchorBasename:l,parts:u});for(let f of u)o.add(f.filename)}}if(r.length===0)return{ranges:t,dropped:n};let{mediaOp:a}=await import("./ops-PFEKOSET.js"),{sourceFromFiles:s}=await import("./source-BDJAUQVR.js");for(let c of r){let{label:l,anchorBasename:u,parts:f}=c,d=QE(e.session,u);try{let m=s(f.map(h=>h.file)),p=await a(m,{verb:"sparsify",selection:{items:d,handles:e.handles}});for(let h of p)t.set(h.filename,{structuralRanges:h.structuralRanges,essenceRanges:h.essenceRanges})}catch(m){let p=Fs(m);if(p){for(let h of f)n.add(h.filename);console.warn(`[planIsoRegions] DROPPING R3D clip "${l}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,p);continue}console.warn(`[planIsoRegions] R3D spanned prep failed for "${l}":`,m)}}return{ranges:t,dropped:n}}function QE(e,t){let n=new Set,i=t.toLowerCase();for(let u of e.media_references??[]){if(!u.target_url)continue;(u.target_url.split(/[/\\]/).pop()??"").toLowerCase()===i&&n.add(u.id)}let r=[],o=!1;for(let u of e.timelines??[])for(let f of u.tracks??[])for(let d of f.items??[])d.media_reference_id&&n.has(d.media_reference_id)&&r.push(d),d.nested_timeline_id&&(o=!0);if(!o||r.length===0)return r;let a=AE(e),s=[...n].flatMap(u=>a.get(u)??[]);if(s.length===0)return r;let c=r[0],l=c.source_range?.start?.rate??c.source_range?.duration?.rate??1;return s.map(u=>({...c,kind:"clip",source_range:{start:{value:u.reached_in,rate:l},duration:{value:u.reached_out-u.reached_in,rate:l}}}))}function Wre(e,t){if(e.length===0)return e;let n=e.map(r=>{let o=Math.floor(r.offset/Na)*Na,a=Math.min(Math.ceil((r.offset+r.length)/Na)*Na,t);return{offset:o,length:Math.max(0,a-o)}}).filter(r=>r.length>0);n.sort((r,o)=>r.offset-o.offset);let i=[];for(let r of n){let o=i[i.length-1];o&&r.offset<=o.offset+o.length?o.length=Math.max(o.length,r.offset+r.length-o.offset):i.push({...r})}return i}async function qu(e,t,n,i,r){if(i.format==="iso"){if(!r)throw new Error("refineLayoutForTrim(iso): isoOptions is required (entries, pinSectorByPath, iuvd come from buildI2oFolderLayout in the wizard).");if(!i.volume_name)throw new Error("refineLayoutForTrim(iso): intent.volume_name is required");let l=qre(i,n),u=await BE({session:n,files:t,handles:i.handles??0,perFile:l,volumeName:i.volume_name,entries:r.entries,pinSectorByPath:r.pinSectorByPath,iuvd:r.iuvd,buildTimestamp:r.buildTimestamp});return u.untrimmable.length>0?{...u.layout,untrimmable:u.untrimmable}:u.layout}if(i.per_file_mode.mode!=="trim")return e;let o=S4(n),a=T4(n),s=new Map;for(let l of e.regions){let u=s.get(l.dest_file);u?u.push(l):s.set(l.dest_file,[l])}let c=[];for(let[l,u]of s){let f=u.length===1?u[0]:null;if(!f||f.source.kind!=="file"){c.push(...u);continue}let d=f.source.basename,m=t.get(d);if(!m){c.push(f);continue}let p=a.get(d),h=p?o.get(p.id)??[]:[],b=await Hre({destFile:l,basename:d,file:m,ref:p,items:h,handles:i.handles??0});b!=="coverage-miss"&&(b?c.push(...b):c.push({dest_file:l,dest_offset:0,length:m.size,source:{kind:"file",basename:d,offset:0}}))}return Dre(c)}async function Hre(e){if(e.items.length===0)return null;let t=await Dg(e.basename);if(!t||!t.planTrim)return null;let n;try{let r=await t.byteSourceFromFile(e.file);n=await t.planTrim(r,e.items,e.handles)}catch(r){let o=Fs(r);return o?(console.warn(`[refineLayoutForTrim] DROPPING "${e.basename}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,o),"coverage-miss"):null}if(n.length===0)return null;if(n.length===1)return Zm(n[0],e.destFile,e.basename);let i=Math.max(3,String(n.length).length);return n.flatMap((r,o)=>Zm(r,EE(e.destFile,`_S${String(o+1).padStart(i,"0")}`),e.basename))}function Zm(e,t,n){let i=[],r=e.dest_header_bytes_base64?k4(e.dest_header_bytes_base64):null;r&&r.length>0&&i.push({dest_file:t,dest_offset:0,length:r.length,source:{kind:"inline",bytes:r}});for(let o of e.src_byte_ranges)o.length<=0||i.push({dest_file:t,dest_offset:o.write_to_dest_offset,length:o.length,source:{kind:"file",basename:o.src_file_name??n,offset:o.offset}});if(e.dest_footer_bytes_base64&&e.dest_footer_offset!=null){let o=k4(e.dest_footer_bytes_base64);o.length>0&&i.push({dest_file:t,dest_offset:e.dest_footer_offset,length:o.length,source:{kind:"inline",bytes:o}})}if(e.dest_patches)for(let o of e.dest_patches){let a=k4(o.bytes_base64);a.length!==0&&i.push({dest_file:t,dest_offset:o.offset,length:a.length,source:{kind:"inline",bytes:a}})}return i.sort((o,a)=>o.dest_offset-a.dest_offset),i}function S4(e){let t=new Map,n=e?.timelines??[];for(let i of n)for(let r of i.tracks??[])for(let o of r.items??[]){if(!o?.media_reference_id)continue;let a=t.get(o.media_reference_id);a?a.push(o):t.set(o.media_reference_id,[o])}return t}function Zre(e,t){let n=e.match(/^(\d+):(\d+):(\d+)[:;](\d+)$/);if(!n)return null;let i=Math.round(t);return(+n[1]*3600+ +n[2]*60+ +n[3])*i+ +n[4]}function _E(e,t,n){let i=t?.source_timecode?Zre(t.source_timecode,n):null;return i==null?e:e.map(r=>{let o=r?.raw_extraction;if(o?.sourceConformedToMedia)return r;let a=o?.alternateFrame;if(a==null||!r.source_range)return r;let s=a-i;return s===0?r:{...r,source_range:{...r.source_range,start:{...r.source_range.start,value:r.source_range.start.value+s}}}})}function T4(e){let t=new Map,n=e?.media_references??[];for(let i of n){if(!i.target_url)continue;let r=i.target_url.split(/[\\/]/).pop();r&&r.length>0&&t.set(r,i)}return t}function Dre(e){let t=new Set,n=new Set,i=0;for(let r of e)t.add(r.dest_file),r.source.kind==="file"&&n.add(r.source.basename),i+=r.length;return{regions:e,total_bytes:i,dest_files:Array.from(t),source_basenames:Array.from(n)}}function k4(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function qre(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 Uu=class{constructor(t){this.opts=t}async execute(){let{layout:t,sink:n}=this.opts,i=t.total_bytes,r=Ure(t.regions),o=Math.max(1,this.opts.concurrency??1),a=0,s=0,c=[],l,u=async(f,d)=>{this.opts.signal?.throwIfAborted(),d.sort((b,v)=>b.dest_offset-v.dest_offset);let m=Cre(d),p=await n.openFile(f,m),h=0;try{for(let b of d){this.opts.signal?.throwIfAborted(),l=f,this.opts.onProgress?.({bytesWritten:a,totalBytes:i,currentFile:l});let v=0,g=await this.writeRegion(b,p,y=>{s+=y-v,v=y,this.opts.onProgress?.({bytesWritten:s,totalBytes:i,currentFile:l})});h+=g,a+=g}await p.close()}catch(b){throw await p.abort?.(b),b}return{path:f,bytesWritten:h}};if(o===1)for(let[f,d]of r)c.push(await u(f,d));else{let f=Array.from(r.entries()),d=0,m=[];for(let p=0;p<Math.min(o,f.length);p++)m.push((async()=>{for(;d<f.length;){let h=d++;if(h>=f.length)break;let[b,v]=f[h],g=await u(b,v);c.push(g)}})());await Promise.all(m)}return await n.closeCollection(),this.opts.onProgress?.({bytesWritten:a,totalBytes:i}),{bytesWritten:a,perFile:c}}async writeRegion(t,n,i){if(t.length===0)return 0;switch(t.source.kind){case"inline":return await n.writeAt(t.dest_offset,t.source.bytes),i?.(t.source.bytes.length),t.source.bytes.length;case"file":{let r=this.opts.files.get(t.source.basename);if(!r)throw new Error(`LocalDirectoryExecutor: file not found in files map: "${t.source.basename}"`);let o=16*1024*1024,a=t.source.offset,s=0;for(;s<t.length;){let c=Math.min(o,t.length-s),l=r.slice(a+s,a+s+c),u=new Uint8Array(await l.arrayBuffer());await n.writeAt(t.dest_offset+s,u),s+=c,i?.(s)}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 Ure(e){let t=new Map;for(let n of e){let i=t.get(n.dest_file);i?i.push(n):t.set(n.dest_file,[n])}return t}function Cre(e){let t=0;for(let n of e){let i=n.dest_offset+n.length;i>t&&(t=i)}return t}var Ag=class{constructor(t){this.opts=t}async execute(){return YE({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 Jre,open as $E}from"node:fs/promises";import{dirname as Kre,join as Gre}from"node:path";function eV(e){let t=!1;return{async reserveSize(n){await e.truncate(n)},async writeAt(n,i){if(t)throw new Error("nodeFileStream: closed");let r=Buffer.from(i.buffer,i.byteOffset,i.byteLength);await e.write(r,0,i.byteLength,n)},async close(){t||(t=!0,await e.close())},async abort(n){if(!t){t=!0;try{await e.close()}catch{}}}}}async function tV(e){let t=await $E(e,"w");return eV(t)}function Bg(e){return{async openFile(t,n){let i=Gre(e,t);await Jre(Kre(i),{recursive:!0});let r=await $E(i,"w"),o=eV(r);return await o.reserveSize(n),o},async closeCollection(){}}}async function O4(e){let t=z4(e),n=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")}function z4(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(z4).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${z4(t[r])}`).join(",")}}`}var Bre="i2o-2026-05-08",Yre=1;function nV(e){let t=e?.created_at?Date.parse(e.created_at):NaN;return Number.isFinite(t)?t:Fm}async function rV(e){let[t,n]=await Promise.all([O4(e.session),O4(e.layoutIntent)]);return{payload:{v:1,conform_tools_version:Bre,session_sha256:t,delivery_intent_sha256:n,layout_fn_version:Yre,written_at:e.writtenAt??new Date(Fm).toISOString(),...e.sessionIdHint?{session_id_hint:e.sessionIdHint}:{}},session_sha256:t,delivery_intent_sha256:n}}function Yg(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 Qre(e,t,n,i=""){let r=ai(t),o=r?r.clipBase:t.replace(/\.R3D$/i,""),a=`${o}_${String(n).padStart(3,"0")}.R3D`,s=e.split("/");return s.pop(),s.length&&/\.rdc$/i.test(s[s.length-1])&&s.pop(),[...s,`${o}${i}.RDC`,a].join("/")}function _re(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 $re(e){let t=new Map;for(let n of e){let i=ai(n.basename),r=i?i.clipBase:n.basename,o=t.get(r);o?o.push(n):t.set(r,[n])}for(let n of t.values())n.sort((i,r)=>(ai(i.basename)?.partNumber??0)-(ai(r.basename)?.partNumber??0));return[...t.values()]}async function Qg(e){let t=[],n=new Map,i=[],r=0;for(let o of $re(e.parts)){let a=o[0];if(new Set(o.map(c=>c.basename)).size!==o.length){let c=ai(a.basename),l=c?c.clipBase:a.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 "${l}" fail-closed:`,u.reason),i.push({clipBase:l,parts:o.map(f=>f.basename),reason:u});continue}let s;try{s=await e.planClip(o)}catch(c){let l=Fs(c);if(!l)throw c;let u=ai(a.basename),f=u?u.clipBase:a.basename.replace(/\.R3D$/i,"");console.warn(`[r3d-trim-pass] DROPPING R3D clip "${f}" fail-closed \u2014 delivery coverage miss (cut not within the file's real frames); NOT whole-filing:`,l),i.push({clipBase:f,parts:o.map(d=>d.basename),reason:l});continue}for(let c of o)n.set(c.basename,c.file);for(let c of s){let l=Qre(a.destPathHint,a.basename,c.partNumber,_re(c));t.push(...Zm(c.plan,l,a.basename)),r+=c.plan.src_byte_ranges.reduce((u,f)=>u+f.length,0)}}return{regions:t,filesByBasename:n,bytes:r,dropped:i}}async function ko(e){await Vc();let t=JSON.parse(await JE(Cg(e),Jg(e)));if(t.error)throw new Error(t.error);let n=null;if(t.iuvdPayload)try{n=JSON.parse(t.iuvdPayload)}catch{}let i=null,r=t.files.find(o=>o.name===".i2o-manifest.json");if(r&&r.extents.length>0&&r.extents[0].type===b4){let o=r.extents[0].position,a=await e.read((t.partitionStartSector+o)*2048,r.totalSize);try{i=JSON.parse(new TextDecoder().decode(a))}catch{}}return{totalSectors:t.totalSectors,partitionStartSector:t.partitionStartSector,partitionLength:t.partitionLength,volumeName:t.volumeName,files:t.files,manifest:i,iuvdPayload:n,rootIcbSector:t.rootIcbSector,rootDataSector:t.rootDataSector,rootDataLength:t.rootDataLength,rootDataSectors:t.rootDataSectors,vdsStartSector:t.vdsStartSector,partitionDescVdsSector:t.partitionDescVdsSector}}function iV(e){let t=[],n=0;for(let i of e.extents)i.type===WE&&t.push({offset:n,length:i.length}),n+=i.length;return t}function So(e){let t=[],n=0;for(let i of e.extents)i.type===b4&&t.push({offset:n,length:i.length,imageSector:i.position}),n+=i.length;return t}async function oV(e,t,n,i,r){return await Vc(),await UE(Cg(e),x4(e),Jg(e),P4(e),n,i,r),ko(e)}async function aV(e,t,n,i,r,o=0){await Vc();let a=new Date,s=!!(r&&r.length>0);return await DE(Cg(e),x4(e),Jg(e),P4(e),n,i,s?r:new Uint8Array(0),s,o,a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),-a.getTimezoneOffset()),ko(e)}function sV(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 eie=2048,xs=".conform",cV=`${xs}/delivery.json`;function lV(e,t){let n=new Set;for(let o of e.timelines)for(let a of o.tracks)for(let s of a.items)s.media_reference_id&&n.add(s.media_reference_id);let i=(e.media_references??[]).filter(o=>n.has(o.id)).map(o=>{let{local_path:a,target_url:s,...c}=o;return{...c,target_url:s&&s.split(/[\\/]/).pop()}}),r={v:1,timelines:e.timelines,media_references:i,handles:t};return new TextEncoder().encode(JSON.stringify(r))}var _g=class{constructor(t,n,i,r){this.img=t;this.info=n;this.f=i;this.name=r;this.size=i.totalSize}slice(t=0,n=this.size){let i=Math.max(0,Math.min(t,this.size)),r=Math.max(i,Math.min(n,this.size)),{img:o,info:a,f:s}=this;return{size:r-i,async arrayBuffer(){let c=new Uint8Array(r-i);for(let l of So(s)){let u=Math.max(i,l.offset),f=Math.min(r,l.offset+l.length);f>u&&c.set(await o.read((a.partitionStartSector+l.imageSector)*eie+(u-l.offset),f-u),u-i)}return c.buffer}}}async arrayBuffer(){return this.slice().arrayBuffer()}dataRanges(){return So(this.f).map(({offset:t,length:n})=>({offset:t,length:n}))}},Wc=e=>e.split("/").pop()||e,M4=e=>e.startsWith("02_MEDIA/")||e.startsWith("03_PROXIES/");async function L4(e){let t=await ko(e);return{image:e.size(),recipes:t.files.filter(n=>n.name.startsWith(`${xs}/`)).length,files:t.files.filter(n=>!n.name.startsWith(`${xs}/`)&&n.name!==".i2o-manifest.json").map(n=>({name:n.name,size:n.totalSize,recorded:So(n).reduce((i,r)=>i+r.length,0)}))}}async function uV(e,t){let n=t.files.filter(a=>a.name.startsWith(`${xs}/delivery`)&&a.name.endsWith(".json"));if(!n.length)return null;let i=[],r=new Map,o=0;for(let a of n){let s=JSON.parse(new TextDecoder().decode(await new _g(e,t,a,a.name).arrayBuffer()));i.push(...s.timelines);for(let c of s.media_references)c.id&&r.set(c.id,c);o=Math.max(o,s.handles??0)}return{session:{timelines:i,media_references:[...r.values()]},handles:o}}async function fV(e,t){let n=await uV(e,t);return n?{timelines:n.session.timelines,media:n.session.media_references??[],handles:n.handles}:{timelines:[],media:[],handles:0}}async function R4(e,t,n={}){let i=await ko(e),r=g=>!n.only?.length||n.only.some(y=>g.includes(y)),o=await uV(e,i),a=new Map,s=new Map,c=[];for(let g of i.files){if(g.name.startsWith(`${xs}/`)||g.name===".i2o-manifest.json"||!r(g.name))continue;let y=new _g(e,i,g,Wc(g.name));M4(g.name)&&Lo(Wc(g.name))?c.push({udfPath:g.name,basename:Wc(g.name),file:y}):M4(g.name)&&o?a.set(Wc(g.name),y):s.set(g.name,y)}n.onProgress?.(0,0,"planning trims");let l=[],u={regions:[],total_bytes:0,dest_files:[],source_basenames:[]};if(o&&a.size){let g={format:"folder",folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:o.handles},y={...o.session,media_references:(o.session.media_references??[]).filter(w=>a.has(Wc(w.target_url??""))).map(w=>({...w,binding_state:"linked"}))};u=await qu(Fc(y,g),a,y,g);for(let w of u.untrimmable??[])l.push(`${w.basename}: ${w.reason}`)}else if(!o)for(let g of s.keys())M4(g)&&l.push(`${Wc(g)}: no recipe in this .iso \u2014 written as stored`);let f=await Qg({parts:c.map(g=>({basename:g.basename,destPathHint:g.udfPath,file:g.file,dataRanges:g.file.dataRanges()})),planClip:async g=>{let y=$c("r3d",g.map(w=>({filename:w.basename,fileSize:w.file.size,dataRanges:w.dataRanges??[],read:(x,O)=>w.file.slice(x,x+O).arrayBuffer().then(P=>new Uint8Array(P))})));return Yg(await lo(y,{verb:"trim",selection:{items:[],handles:0}}))}}),d=new Set([...u.dest_files,...f.regions.map(g=>g.dest_file)]),m=[];for(let[g,y]of s)d.has(g)||m.push({dest_file:g,dest_offset:0,length:y.size,source:{kind:"file",basename:g,offset:0}});for(let[g,y]of a){let w=i.files.find(x=>Wc(x.name)===g).name;!u.dest_files.includes(w)&&!u.regions.some(x=>x.source.kind==="file"&&x.source.basename===g)&&(m.push({dest_file:w,dest_offset:0,length:y.size,source:{kind:"file",basename:w,offset:0}}),s.set(w,y),l.push(`${g}: not in the recipe's cut \u2014 written as stored`))}let p=[...u.regions,...f.regions,...m],h={regions:p,total_bytes:p.reduce((g,y)=>g+y.length,0),dest_files:[...new Set(p.map(g=>g.dest_file))],source_basenames:[]},b=new Map([...a,...s,...f.filesByBasename]);await bt(t);let v=await new Uu({layout:h,files:b,sink:Bg(t),signal:n.signal,concurrency:4,onProgress:g=>n.onProgress?.(g.bytesWritten,g.totalBytes,"writing trims")}).execute();return{files:h.dest_files.length,bytes:v.bytesWritten,untrimmed:l}}import{open as N4}from"node:fs/promises";import{createServer as tie}from"node:http";function dV(e,t=8*1024*1024,n=32){let i=new Map,r=(o,a)=>{let s=`${o}@${a}`,c=i.get(s);if(c)return i.delete(s),i.set(s,c),c;if(c=e(o,a*t,t).catch(l=>{throw i.delete(s),l}),i.set(s,c),i.size>n){let l=i.keys().next().value;l!==void 0&&i.delete(l)}return c};return async(o,a,s)=>{let c=Math.floor(a/t),l=Math.floor((a+s-1)/t);if(c===l){let m=await r(o,c),p=a-c*t;return m.subarray(p,Math.min(p+s,m.length))}let u=await Promise.all(Array.from({length:l-c+1},(m,p)=>r(o,c+p))),f=new Uint8Array(s),d=0;for(let m=0;m<u.length;m++){let p=u[m],h=(c+m)*t,b=Math.max(0,a-h),v=Math.min(p.length,a+s-h);v>b&&(f.set(p.subarray(b,v),d),d+=v-b)}return d===s?f:f.subarray(0,d)}}async function Hc(e,t=!1){let n=await N4(e,t?"r+":"r"),i=(await n.stat()).size;return{read:async(r,o)=>{let a=new Uint8Array(o),{bytesRead:s}=await n.read(a,0,o,r);return s===o?a:a.subarray(0,s)},write:async(r,o)=>{await n.write(o,0,o.length,r),i=Math.max(i,r+o.length)},getSize:async()=>i,setSize:async r=>{await n.truncate(r),i=r},size:()=>i,close:()=>n.close()}}var nie=4<<20;async function X4(e,t=fetch){let n=await e(),i=async(s,c)=>{for(let l=0;;l++){let u=await t(n,{headers:{range:`bytes=${s}-${s+c-1}`}});if(u.status===403&&l===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&&s>0)throw new Error("the bucket ignored the byte range (no ranged GET)");return new Uint8Array(await u.arrayBuffer())}},r=await t(n,{headers:{range:"bytes=0-0"}});await r.body?.cancel();let o=Number(/\/(\d+)$/.exec(r.headers.get("content-range")??"")?.[1]??r.headers.get("content-length"));if(!r.ok||!Number.isFinite(o))throw new Error(`reading the .iso: ${r.status}`);let a=dV((s,c,l)=>i(c,Math.min(l,o-c)),1<<20,64);return{read:(s,c)=>{let l=Math.max(0,Math.min(c,o-s));return l?l<nie?a("iso",s,l):i(s,l):Promise.resolve(new Uint8Array(0))},write:()=>Promise.reject(new Error("a bucket .iso is read-only here (add_to patches an overlay)")),getSize:async()=>o,size:()=>o,close:async()=>{}}}function rie(e){let t=[];for(let n of[...e].sort((i,r)=>i.offset-r.offset)){let i=t[t.length-1];i&&n.offset<=i.offset+i.length?i.length=Math.max(i.length,n.offset+n.length-i.offset):t.push({...n})}return t}async function mV(e,t){let n=await N4(t,"w+"),i=[],r=e.size();return{read:async(a,s)=>{s=Math.max(0,Math.min(s,r-a));let c=new Uint8Array(s),l=Math.max(0,Math.min(s,e.size()-a));l>0&&c.set(await e.read(a,l),0);for(let u of i){let f=Math.max(u.offset,a),d=Math.min(u.offset+u.length,a+s);d>f&&await n.read(c,f-a,d-f,f)}return c},write:async(a,s)=>{await n.write(s,0,s.length,a),i=rie([...i,{offset:a,length:s.length}]),r=Math.max(r,a+s.length)},getSize:async()=>r,setSize:async a=>{r=a},size:()=>r,writes:()=>i,scratch:t,close:()=>n.close()}}async function pV(e){let t=tie((n,i)=>void(async()=>{let r=e.size(),o=/bytes=(\d+)-(\d*)/.exec(n.headers.range??""),a=o?Number(o[1]):0,s=o&&o[2]?Math.min(Number(o[2])+1,r):r;if(i.writeHead(o?206:200,{"Accept-Ranges":"bytes","Content-Length":s-a,...o?{"Content-Range":`bytes ${a}-${s-1}/${r}`}:{}}),n.method==="HEAD")return i.end();for(let c=a;c<s;c+=8388608)i.write(await e.read(c,Math.min(8388608,s-c)));i.end()})().catch(()=>{i.headersSent||i.writeHead(503),i.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 hV(e){if(or()!=="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((r,o)=>t("/usr/bin/hdiutil",["attach",e,"-readonly","-noverify","-noautoopen"],(a,s,c)=>a?o(new Error(c||a.message)):r(s))),i=n.trim().split(`
131
- `).map(r=>r.split(" ").pop().trim()).filter(r=>r.startsWith("/")).pop();if(!i)throw new Error(`hdiutil attached nothing: ${n}`);return{mountpoint:i,detach:()=>new Promise(r=>t("/usr/bin/hdiutil",["detach",i,"-force"],()=>r()))}}async function bV(e,t,n,i,r=32<<20){let o=await N4(t,"w"),a=e.size(),s=0,c=0;try{await o.truncate(a),await Promise.all(Array.from({length:4},async()=>{for(;s<a;){i?.throwIfAborted();let l=s;s+=r;let u=await e.read(l,Math.min(r,a-l));await o.write(u,0,u.length,l),c+=u.length,n?.(c,a)}}))}finally{await o.close()}return a}var mr=class e extends File{#e;constructor(t,n,i){super([],n),this.path=t,this.#e=i}get size(){return this.#e}static async open(t,n=te(t)){return new e(t,n,(await un(t)).size)}slice(t=0,n=this.size){let i=Math.max(0,t),r=Math.min(this.size,n),o=this.path;return{size:r-i,async arrayBuffer(){let a=await Za(o);try{let s=await a.readAt(i,r-i);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}finally{await a.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))}};async function gV(e,t){let n=new Map,i=[],r=new Set;for(let o of e.timelines)for(let a of o.tracks)for(let s of a.items)s.media_reference_id&&r.add(s.media_reference_id);for(let o of e.media_references??[]){if(!r.has(o.id))continue;let a=o.local_path??o.target_url;if(!a){i.push(`${o.id}: no path`);continue}if(t.only_linked&&o.binding_state!=="linked"){i.push(`${o.id} ${te(a)}: not linked (run timeline_relink, or only_linked=false)`);continue}if(!await jn(a)){i.push(`${o.id} ${a}: not on this machine`);continue}if(!ua.has(ar(a).toLowerCase())){i.push(`${o.id} ${te(a)}: unsupported container`);continue}for(let s of await Gs(a))n.set(te(s),await mr.open(s))}return{files:n,skipped:i}}var iie=new Set(["resolve-xmeml","flame-fcpxml","resolve-otio","premiere-otio"]);async function vV(e,t,n){let i=await jn(t)?[{name:te(t),data:await er(t)}]:[],r=[],o=[];for(let s of n){let c=i4(s),l=await y0(c,e),u=typeof l.body=="string"?new TextEncoder().encode(l.body):l.body;if(c==="finalcut-fcpxmld"){for(let[f,d]of Object.entries(Tp(u)))f.endsWith("/")||r.push({filename:f,bytes:d,text:!0});for(let f of l.issues??[])o.push(`${c}: ${f.message}`);continue}r.push({filename:l.filenameSuggestion,bytes:u,text:iie.has(c)});for(let f of l.issues??[])o.push(`${c}: ${f.message}`)}return{timelineFile:r.length?{bytes:r[0].bytes,filename:r[0].filename,isConversion:!0}:void 0,sourceFiles:i,exchangeFiles:r.slice(1),issues:o}}function oie(e,t){let n=t.filter(i=>i.bytes).map(i=>({dest_file:i.path,dest_offset:0,length:i.bytes.length,source:{kind:"inline",bytes:i.bytes}}));return n.length?{...e,regions:[...e.regions,...n],dest_files:[...new Set([...e.dest_files,...n.map(i=>i.dest_file)])],total_bytes:e.total_bytes+n.reduce((i,r)=>i+r.length,0)}:e}var yV=(e,t,n,i)=>["deliver",...t.length?["untrimmable"]:[],...n.length?["skipped"]:[],...e.length?["capability"]:[],...i?[]:["iso_unverified"]];async function wV(e,t,n){let{files:i,skipped:r}=await gV(e,{only_linked:n.only_linked});if(!i.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${r.length?`:
132
- - ${r.join(`
133
- - `)}`:""}`);let o=n.volume_name??te(n.out_path),a=await vV(e,t,n.timeline_formats),{entries:s}=p4(e,i,{volumeName:o,preserveStructure:n.preserve_structure,timelineFile:a.timelineFile,sourceFiles:a.sourceFiles,exchangeFiles:a.exchangeFiles,handles:n.handles}),c={format:"folder",volume_name:o,folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:n.handles},l=Fc(e,c),u=[...i.keys()].filter(Lo),f=u.length?{...e,media_references:(e.media_references??[]).filter(g=>!Lo(te(g.target_url??"")))}:e,d=await qu(l,i,f,c),m=[];if(u.length){let g=new Map;for(let T of l.regions){let S=te(T.dest_file);Lo(S)&&g.set(S,T.dest_file)}let y=S4(e),w=T4(e),x=await Qg({parts:u.map(T=>({basename:T,destPathHint:g.get(T)??`02_MEDIA/${T}`,file:i.get(T)})),planClip:async T=>{let S=w.get(T[0].basename),k=_E(S?y.get(S.id)??[]:[],S,S?.source_fps??24),L=await lo(IT(T.map(z=>z.file)),{verb:"trim",selection:{items:k,handles:n.handles}});return Yg(L)}});m=x.dropped??[];let P=[...d.regions.filter(T=>!Lo(te(T.dest_file))),...x.regions];d={...d,regions:P,total_bytes:P.reduce((T,S)=>T+S.length,0),dest_files:[...new Set(P.map(T=>T.dest_file))],source_basenames:[...new Set(P.map(T=>T.source.kind==="file"?T.source.basename:"").filter(Boolean))]}}d=oie(d,s);let p=d.regions.filter(g=>g.source.kind!=="file"||i.has(g.source.basename));d={...d,regions:p,dest_files:[...new Set(p.map(g=>g.dest_file))],total_bytes:p.reduce((g,y)=>g+y.length,0)},await bt(n.out_path);let h=await new Uu({layout:d,files:i,sink:Bg(n.out_path)}).execute(),b=[...d.untrimmable??[],...m],v=[...i.values()].reduce((g,y)=>g+y.size,0);return{text:[`delivered ${d.dest_files.length} file(s), ${(h.bytesWritten/1e6).toFixed(1)} MB (sources ${(v/1e6).toFixed(1)} MB) \u2192 ${n.out_path}`,...d.dest_files.map(g=>`- ${g}`),...a.issues.length?["timeline capability issues:",...a.issues.map(g=>` - ${g}`)]:[],...b.length?["not shipped (could not be trimmed \u2014 never shipped whole):",...b.map(g=>` - ${g.basename}: ${g.reason}`)]:[],...r.length?["skipped:",...r.map(g=>` - ${g}`)]:[]].join(`
134
- `),files:d.dest_files.length,bytes:h.bytesWritten,keys:yV(a.issues,b,r,!0)}}async function xV(e,t,n){let{files:i,skipped:r}=await gV(e,{only_linked:n.only_linked});if(!i.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${r.length?`:
135
- - ${r.join(`
136
- - `)}`:""}`);let o=n.out_path.toLowerCase().endsWith(".iso")?n.out_path:Q(n.out_path,`${n.volume_name??te(t,ar(t))}.iso`),a=n.volume_name??te(o,".iso"),s=await vV(e,t,n.timeline_formats),c=p4(e,i,{volumeName:a,preserveStructure:n.preserve_structure,timelineFile:s.timelineFile,sourceFiles:s.sourceFiles,exchangeFiles:s.exchangeFiles,handles:n.handles}),{pinSectorByPath:l}=c,u=[...c.entries,{path:cV,bytes:lV(e,n.handles)}],f={format:"iso",volume_name:a,per_file_mode:sV("sparse"),handles:n.handles},d=nV(e),{payload:m}=await rV({session:e,layoutIntent:f,writtenAt:new Date(d).toISOString()}),p=await qu(Fc(e,f),i,e,f,{entries:u,pinSectorByPath:l,iuvd:m,buildTimestamp:d}),h=p.image_total_bytes??p.total_bytes;await bt(Ln(o));let b=await new Ag({layout:p,files:i,totalBytes:h,sink:await tV(o)}).execute(),v=await GE(await mr.open(o)).catch(()=>null),g=p.untrimmable??[],y=[...i.values()].reduce((w,x)=>w+x.size,0);return{text:[`wrote ${o}: ${(h/1e6).toFixed(1)} MB image, ${(b.bytesWritten/1e6).toFixed(1)} MB real data (sources ${(y/1e6).toFixed(1)} MB), volume "${a}"${v?", IUVD verified":", IUVD readback FAILED"}`,...[...new Set(p.dest_files)].map(w=>`- ${w}`),...s.issues.length?["timeline capability issues:",...s.issues.map(w=>` - ${w}`)]:[],...g.length?["not shipped (could not be planned \u2014 never shipped whole):",...g.map(w=>` - ${w.basename}: ${w.reason}`)]:[],...r.length?["skipped:",...r.map(w=>` - ${w}`)]:[]].join(`
137
- `),path:o,bytes:h,keys:yV(s.issues,g,r,!!v)}}function aie(e,t){let n=[];for(let i of e){let r=[i];for(let o of t)r=r.flatMap(a=>{let s=Math.max(a.offset,o.offset),c=Math.min(a.offset+a.length,o.offset+o.length);return c<=s?[a]:[{offset:a.offset,length:s-a.offset},{offset:c,length:a.offset+a.length-c}].filter(l=>l.length>0)});n.push(...r)}return n}async function j4(e,t){let n=typeof t=="string"?await Hc(t):t,i=typeof e=="string"?await Hc(e,!0):e;try{let r=await ko(n),o=await ko(i),a=2048,s=r.partitionStartSector,c=(m,p)=>{let h=new Uint8Array(p.length);return Promise.all(So(m).map(async b=>{let v=Math.max(b.offset,p.offset),g=Math.min(b.offset+b.length,p.offset+p.length);g<=v||h.set(await n.read((s+b.imageSector)*a+(v-b.offset),g-v),v-p.offset)})).then(()=>h)},l=0,u=0,f=[],d=[];for(let m of r.files){let p=So(m).map(({offset:S,length:k})=>({offset:S,length:k})),h=m.name.lastIndexOf("."),b=h>m.name.lastIndexOf("/")?m.name.slice(0,h):m.name,v=b===m.name?"":m.name.slice(h),g=o.files.filter(S=>S.name===m.name||S.name.startsWith(`${b}_v`)&&S.name.endsWith(v)&&/^\d+$/.test(S.name.slice(b.length+2,S.name.length-v.length))),y=async S=>{if(S.totalSize!==m.totalSize)return!1;for(let k of So(S))for(let L of p){let z=Math.max(k.offset,L.offset),X=Math.min(k.offset+k.length,L.offset+L.length);if(X<=z)continue;let V=await c(m,{offset:z,length:X-z}),R=await i.read((o.partitionStartSector+k.imageSector)*a+(z-k.offset),X-z);if(V.some((j,J)=>j!==R[J]))return!1}return!0},w;for(let S of g)if(await y(S)){w=S;break}let x=w?.name??m.name;if(!w&&g.length){let S=2;for(;o.files.some(k=>k.name===`${b}_v${S}${v}`);)S++;x=`${b}_v${S}${v}`,d.push(x)}if(!w){try{o=await aV(i,o,x,m.totalSize)}catch(S){if(x.startsWith(".conform/"))continue;throw S}d.includes(x)||f.push(x)}let O=o.files.find(S=>S.name===x),P=aie(p,So(O).map(({offset:S,length:k})=>({offset:S,length:k}))),T=iV(O).flatMap(S=>P.map(k=>{let L=Math.max(S.offset,k.offset),z=Math.min(S.offset+S.length,k.offset+k.length);return{offset:L,length:z-L}})).filter(S=>S.length>0);for(let S of T)o=await oV(i,o,x,S.offset,await c(m,S)),l++,u+=S.length}return{filled:l,added:f,versioned:d,bytes:u}}finally{typeof t=="string"&&await n.close(),typeof e=="string"&&await i.close()}}var F4=16;function PV(e,t,n,i=Yn){for(let l of e){if(delete l.unreproducible,l.kind!=="a-source"||l.aIn==null)continue;let u=Math.min(32,l.count),f=0,d=0;for(let p=0;p<u;p++){let h=u===1?l.count>>1:Math.round(p*(l.count-1)/(u-1)),b=t[l.aIn+h],v=n[l.recordIn+h];!b||!v||(f++,mn(b,v)>i&&d++)}let m=0;for(let p=1;p<l.count;p++){let h=n[l.recordIn+p-1],b=n[l.recordIn+p],v=t[l.aIn+p-1],g=t[l.aIn+p];!h||!b||!v||!g||mn(b,h)<=F4&&mn(g,v)>F4&&m++}if(f>0&&(d>0||m>0)){let p=[];d>0&&p.push(d===f?"none of the sampled frames match the source frames this event names":`${d} of ${f} sampled frames do not match the source frames this event names`),m>0&&p.push(`${m} record frame(s) repeat where the named source frames advance \u2014 a hold this event cannot source`),l.unreproducible={checked:f,failed:d+m,note:p.join("; ")}}}let o=2,a=e.filter(l=>l.kind==="a-source"&&l.aIn!=null),s=[],c=()=>{if(s.length>o)for(let l of s){let u="source frames run backwards across this span \u2014 a reverse no a-source event can express";l.unreproducible=l.unreproducible?{...l.unreproducible,note:`${l.unreproducible.note}; ${u}`}:{checked:s.length,failed:s.length,note:u}}s=[]};for(let l=1;l<a.length;l++){let u=a[l-1],f=a[l];f.recordIn===u.recordOut&&f.aIn<u.aIn?(s.length===0&&s.push(u),s.push(f)):c()}return c(),e}var I4=3;function kV(e,t,n,i=I4){let r=[];for(let c of e.ops)c.op==="equal"||c.op==="move"?r.push({kind:"a-source",recordIn:c.bStart,count:c.count,aIn:c.aStart}):c.op==="insert"&&r.push({kind:"hole",recordIn:c.bStart,count:c.count});r.sort((c,l)=>c.recordIn-l.recordIn);for(let c=0;c<r.length;c++){let l=r[c];if(l.kind!=="a-source"||l.count>=i)continue;let u=c===0||r[c-1].kind==="hole",f=c===r.length-1||r[c+1].kind==="hole";u&&f&&(l.kind="hole",l.aIn=void 0)}let o=[];for(let c of r){let l=o[o.length-1];l&&l.kind==="hole"&&c.kind==="hole"?l.count+=c.count:o.push({...c})}let a=c=>t.fps?Li(t.startFrame+c,t.fps,t.dropFrame):"",s=c=>n.fps?Li(n.startFrame+c,n.fps,n.dropFrame):"";return o.map((c,l)=>{let u=c.recordIn+c.count,f={index:l+1,kind:c.kind,count:c.count,recordIn:c.recordIn,recordOut:u,recordInTc:s(c.recordIn),recordOutTc:s(u)};return c.kind==="a-source"&&c.aIn!=null&&(f.aIn=c.aIn,f.aOut=c.aIn+c.count,f.aInTc=a(c.aIn),f.aOutTc=a(c.aIn+c.count)),f})}function SV(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 E4(e,t="AX"){return e.replace(/\.[^.]+$/,"").replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,8)||t}function TV(e,t,n){let i=n?.title??"QC RECONFORM",r=E4(n?.aReel??"AX"),o=(n?.aReel??"").replace(/[\r\n]+/g," ").trim(),a=t.fps??24,s=il(a,t.dropFrame)?"DROP FRAME":"NON-DROP FRAME",c=Li(0,a,t.dropFrame),l=[`TITLE: ${i}`,`FCM: ${s}`],u=0;for(let f of e){u++;let d=String(u).padStart(3,"0");if(f.kind==="hole"){let m=Li(f.count,a,t.dropFrame);l.push(`${d} ${"BL".padEnd(8)} V C ${c} ${m} ${f.recordInTc} ${f.recordOutTc}`),l.push(`* NEW MATERIAL (${f.count} frames)`)}else l.push(`${d} ${r.padEnd(8)} V C ${f.aInTc} ${f.aOutTc} ${f.recordInTc} ${f.recordOutTc}`),o&&l.push(`* FROM CLIP NAME: ${o}`),f.unreproducible&&(l.push(`* CHECK BY EYE \u2014 ${f.unreproducible.note.toUpperCase()}`),l.push("* THIS EVENT MAY NOT REBUILD THE CUT (HOLD / REVERSE / RETIME NOT EXPRESSIBLE)"))}return l.join(`\r
138
- `)+`\r
139
- `}function sie(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function zV(e){let t=[["#","kind","rec_in","rec_out","A_in","A_out","frames"]];for(let n of e)t.push([String(n.index),n.kind==="hole"?"HOLE":"A-SOURCE",n.recordInTc,n.recordOutTc,n.aInTc??"",n.aOutTc??"",String(n.count)]);return t.map(n=>n.map(sie).join(",")).join(`\r
140
- `)+`\r
141
- `}var V4=["only_in_a","only_in_b","different_file","same_name_different_clip","source_tc"],Zc=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,cie=e=>e.replace(/^file:\/\//,"").split(/[\\/]/).pop()??e;function $g(e,t){let n=e.timelines??[],i=t?n.find(r=>r.id===t):n.find(r=>r.kind==="primary"&&r.tracks?.some(o=>o.items?.length))??n[0];if(!i)throw new Te("not_found",t?`no timeline ${t} (timelines: ${n.map(r=>`${r.id} "${r.name}"`).join(", ")})`:"the session has no timeline");return i}function ev(e,t){let n=e.start_frame??0,i=[];for(let a of t)if(a.enabled!==!1)for(let s of a.items){if(s.kind!=="clip"||s.enabled===!1||!s.timeline_range.duration.value)continue;let c=n+s.timeline_range.start.value;i.push({s:c,e:c+s.timeline_range.duration.value,it:s,track:Ci(a,e.tracks),z:a.track_index??0})}let r=[...new Set(i.flatMap(a=>[a.s,a.e]))].sort((a,s)=>a-s),o=[];for(let a=0;a+1<r.length;a++){let[s,c]=[r[a],r[a+1]],l;for(let u of i)u.s<=s&&u.e>=c&&(!l||u.z>=l.z)&&(l=u);l&&o.push({s,e:c,it:l.it,track:l.track})}return o}function OV(e,t,n,i){let r=e.it,o=r.media_reference_id?i.get(r.media_reference_id):void 0,a=o?.local_path??o?.target_url??null,s=r.source_range?.start.rate||Zc(n),c=o?.source_fps||s,l=o?.source_timecode?Cn(o.source_timecode,c)??0:0,u=(n.start_frame??0)+r.timeline_range.start.value,f=(r.speed??100)/100*(r.speed_reverse?-1:1),d=(r.source_range?.start.value??0)+(t-u)*f*s/Zc(n),m=Math.round(l+d*c/s);return{item_id:r.id,track:e.track,file:a?cie(a):r.name??"(unnamed)",path:a,reel:o?.reel_name??r.reel_name??null,file_tc:o?.source_timecode??null,file_frames:o?.available_range?.duration?.value??o?.declared_duration?.value??null,src_tc:Qt(m,c,!!o?.source_timecode?.includes(";")),src_frame:m,rate:c}}function lie(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(),i=t.file.toLowerCase();if(n!==i)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 r=t.src_frame-e.src_frame;return r?{kind:"source_tc",note:`same file, source ${r>0?"+":""}${r} fr (A ${e.src_tc}, B ${t.src_tc})`}:null}function LV(e,t,n={}){let i=$g(e,n.a_timeline_id),r=$g(t,n.b_timeline_id),o=Zc(i),a=Zc(r);if(Math.abs(o-a)>.001)throw new Te("invalid_args",`the timelines run at different rates (${o} vs ${a} fps); record TC cannot be aligned frame for frame`);let s=new Map((e.media_references??[]).map(m=>[m.id,m])),c=new Map((t.media_references??[]).map(m=>[m.id,m])),l=m=>m.tracks.filter(p=>p.kind==="Video"),u=[];if(n.by_track){let m=new Set([...l(i).map(p=>Ci(p,i.tracks)),...l(r).map(p=>Ci(p,r.tracks))]);for(let p of m)u.push({name:p,a:l(i).filter(h=>Ci(h,i.tracks)===p),b:l(r).filter(h=>Ci(h,r.tracks)===p)})}else u.push({name:"top",a:l(i),b:l(r)});let f=m=>Qt(m,o,!!i.is_drop_frame),d=[];for(let m of u){let p=ev(i,m.a),h=ev(r,m.b),b=[...new Set([...p,...h].flatMap(g=>[g.s,g.e]))].sort((g,y)=>g-y),v=(g,y)=>g.find(w=>w.s<=y&&w.e>y);for(let g=0;g+1<b.length;g++){let[y,w]=[b[g],b[g+1]],x=v(p,y),O=v(h,y),P=x?OV(x,y,i,s):null,T=O?OV(O,y,r,c):null,S=lie(P,T);if(!S)continue;let k=d[d.length-1];if(k&&k.lane===m.name&&k.rec_out===y&&k.kind===S.kind&&k.a?.item_id===P?.item_id&&k.b?.item_id===T?.item_id){k.rec_out=w,k.rec_out_tc=f(w),k.frames=w-k.rec_in;continue}d.push({lane:m.name,kind:S.kind,rec_in:y,rec_out:w,rec_in_tc:f(y),rec_out_tc:f(w),frames:w-y,a:P,b:T,note:S.note})}}return{ranges:d,ta:i,tb:r,lanes:u.map(m=>m.name)}}var MV=e=>e?`${e.file} @ ${e.src_tc} [${e.track} ${e.item_id}]`:"(nothing)";function RV(e,t,n,i){let r=V4.map(l=>[l,e.ranges.filter(u=>u.kind===l).length]).filter(([,l])=>l),o=e.ranges.length?`${e.ranges.length} record range${e.ranges.length===1?"":"s"} differ in source between A and B (${r.map(([l,u])=>`${u} ${l}`).join(", ")})`:`no source differences: A and B show the same source on every record frame (${e.lanes.join(", ")})`,a=e.ranges.slice(0,i),s=e.ranges.length>a.length?`TRUNCATED: showing ${a.length} of ${e.ranges.length} ranges \u2014 NOT the full list. Pass limit=${e.ranges.length}, or csv_path for all.
142
- `:"",c=a.map(l=>`- ${l.lane==="top"?"":`${l.lane} `}${l.rec_in_tc}\u2013${l.rec_out_tc} (${l.frames} fr) ${l.kind}: A ${MV(l.a)} | B ${MV(l.b)} \u2014 ${l.note}`);return`${s}${o}
143
- A: ${t} "${e.ta.name}"
144
- B: ${n} "${e.tb.name}"
145
- 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${c.length?`
146
- ${c.join(`
147
- `)}`:""}`}var uie=e=>{let t=e==null?"":String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t};function NV(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(i=>[i.lane,i.kind,i.rec_in_tc,i.rec_out_tc,i.frames,i.a?.file,i.a?.src_tc,i.a?.file_tc,i.a?.track,i.a?.item_id,i.a?.path,i.b?.file,i.b?.src_tc,i.b?.file_tc,i.b?.track,i.b?.item_id,i.b?.path,i.note]);return[t,...n].map(i=>i.map(uie).join(",")).join(`
148
- `)+`
149
- `}function XV(e,t){let n=Zc(e.tb),i=!!e.tb.is_drop_frame,r=a=>Qt(a,n,i),o=[`TITLE: ${t}`,`FCM: ${i?"DROP FRAME":"NON-DROP FRAME"}`];return e.ranges.forEach((a,s)=>{let c=String(s+1).padStart(3,"0");if(!a.b){o.push(`${c} ${"BL".padEnd(8)} V C ${r(0)} ${r(a.frames)} ${a.rec_in_tc} ${a.rec_out_tc}`,`* ${a.kind.toUpperCase()}: B HAS NO PICTURE HERE`);return}o.push(`${c} ${E4(a.b.reel??a.b.file).padEnd(8)} V C ${a.b.src_tc} ${Qt(a.b.src_frame+Math.round(a.frames*a.b.rate/n),a.b.rate,a.b.src_tc.includes(";"))} ${a.rec_in_tc} ${a.rec_out_tc}`,`* FROM CLIP NAME: ${a.b.file}`,`* ${a.kind.toUpperCase()}: ${a.note.toUpperCase()}`)}),o.join(`\r
150
- `)+`\r
151
- `}function jV(e,t){let n=structuredClone(e),i=n.timelines.find(o=>o.id===t.tb.id);n.timelines=[i];let r=new Set(t.ranges.map(o=>o.b?.item_id).filter(Boolean));for(let o of i.tracks)o.items=o.kind==="Video"?o.items.filter(a=>r.has(a.id)):[];return i.name=`${i.name} \u2014 source diff`,n}async function FV(e){let t=Rt("CONFORM_PYTHON")??"python3",i=[Pr(new URL("./cadence_repair.py",import.meta.url)),"--plate",e.plate,"--render",e.render];e.out_path&&i.push("--out",e.out_path),e.plate_start&&i.push("--plate-start",String(e.plate_start)),e.plate_frames&&i.push("--plate-frames",String(e.plate_frames)),e.mask&&i.push("--mask",e.mask.join(",")),e.plan_only&&i.push("--plan-only"),e.force&&i.push("--force");let r=await Mn(t,i,{env:{OMP_NUM_THREADS:"1"}}),o=r.stdout.trim().split(`
152
- `).pop()??"";if(!r.success||!o.startsWith("{"))throw new Error(`cadence repair failed: ${r.stderr.trim().split(`
153
- `).slice(-4).join(" | ")}`);return JSON.parse(o)}function IV(e){let t=e.gaps.reduce((i,r)=>i+r.missing,0),n=[`${e.status}: render ${e.render.frames} frames \u2192 ${e.output_frames} (plate ${e.plate.frames} from frame ${e.plate.start})`,`held frames cut (${e.held_frames.length}): ${e.held_frames.join(", ")||"none"}`];if(e.real_pauses_kept.length&&n.push(`kept as real pauses (the plate pauses too): ${e.real_pauses_kept.join(", ")}`),n.push(`skipped source frames (${t}): ${e.gaps.map(i=>`after render ${i.after_render_frame} \u2192 plate ${i.plate_frames.join("/")}`).join("; ")||"none"}`),e.repace.detected&&n.push(`RE-PACE: render frames ${e.repace.runs.fast.map(([i,r])=>`${i}\u2013${r}`).join(", ")} race ahead of the plate. ${e.repace.note}`),e.repace.runs.slow.length&&n.push(`slower than the plate (reported only): ${e.repace.runs.slow.map(([i,r])=>`${i}\u2013${r}`).join(", ")}`),e.wrote){n.push(`wrote ${e.wrote} (${e.frames_written} frames); RIFE frames at output ${e.rife_output_frames?.join(", ")||"none"}`);let i=e.motion_flags??[];n.push(i.length?`motion vs plate flagged (${i.length}): ${i.map(r=>`${r.output_frame} ${r.kind} ${r.vs_plate}\xD7`).join(", ")}`:"motion vs plate: no dips or jumps")}return n.join(`
154
- `)}async function Dc(e){let t=await Wr();if(!t)throw new Te("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 Mn(t,["patch",JSON.stringify(e)]);if(n.code!==0){let i=n.stderr.trim();try{i=JSON.parse(i.split(`
155
- `).pop()).detail}catch{}let r=/not supported|does not match|refus|outside|disagrees|no timecode|timecode mismatch|exists/.test(i);throw new Te(r?"refused":"engine",i)}return JSON.parse(n.stdout.trim().split(`
156
- `).pop())}var Z4=()=>Q(vt(),"patches.jsonl"),tv=e=>`${(e/1e9).toFixed(e<1e10?2:1)} GB`;function fie(e,t){return[`layout: ${e.top_level.map(n=>n.type).join(" ")} (index at the ${e.moov_at}), ${tv(e.master_bytes)}`,` in_place grows the file by ${tv(e.in_place_grows_by)}; new needs ${tv(e.new_needs_free)} free${t!=null?` (${tv(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(`
157
- `)}async function die(e){if(e.in==null||e.out==null)throw new Te("invalid_args","plan needs in and out (the fixed range on the master, frames or TC)");let t=await Fn(e.path),n=t.source_fps??t.streams?.find(l=>l.kind==="video")?.rate??0,i=t.source_timecode??null,r=Yr(e.in,n,i),o=Yr(e.out,n,i);if(r<0||o<r)throw new Te("invalid_args","in/out must be inside the master, in before out");let a=await Dc({mode:"plan",master:e.path,master_in:r,frames:o-r+1}),s=l=>Qt((a.master_tc_start_frame??0)+l,n),c=a.frames-(o-r+1);return{text:[`${a.codec}: render master frames ${a.span[0]}\u2013${a.span[1]} (${a.frames} frames, ${s(a.span[0])}\u2013${s(a.span[1])}) for the fix at ${r}\u2013${o}${c?` (+${c} to whole GOPs)`:""}`,`GOP ${a.gop??"?"}${a.fixed_gop?" (fixed)":" (varies)"}, ${a.b_frames?"B-frames":"no B-frames"}${a.open_gop_after?"; the GOP after the fix is open, so it is included":""}`,a.swappable?`then: ${a.render}`:`the master's GOP at ${s(a.span[0])} is open: a swap there needs a re-encode across the seam; ask before rendering`].join(`
158
- `),data:{...a,fixed:[r,o],tc_in:s(a.span[0]),tc_out:s(a.span[1])}}}async function mie(){try{return(await yn(Z4())).split(`
159
- `).filter(Boolean).map(e=>JSON.parse(e))}catch{return[]}}var W4=e=>`${((Number(e)||0)/1e6).toFixed(1)} MB`;async function D4(e,t){let n=e.mode??"new";if(n==="undo")return pie(e.path);if(e.patches?.length){if(n!=="in_place"&&n!=="check")throw new Te("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 Te("invalid_args","with patches, each is placed by its own TC: leave patch/in/out/patch_in out");let p=[];for(let[v,g]of e.patches.entries())t?.(v,e.patches.length,`check ${te(g)}`),p.push(await Dc({mode:"check",master:e.path,patch:g}));let h=p.map(v=>[v.master_in,v.master_in+v.frames-1]).sort((v,g)=>v[0]-g[0]);for(let v=1;v<h.length;v++)if(h[v][0]<=h[v-1][1])throw new Te("refused",`patches overlap at master frames ${h[v][0]}\u2013${h[v-1][1]}; nothing written`);if(n==="check")return{text:`all ${p.length} patches fit: ${p.map(v=>`${v.frames} frames at ${v.master_in}`).join(", ")}
160
- nothing written (mode=check)`,data:{plans:p}};let b=[];for(let[v,g]of e.patches.entries())t?.(v,e.patches.length,`patch ${v+1}/${e.patches.length}: ${te(g)}`),b.push(await D4({path:e.path,patch:g,mode:n,verify:e.verify}));return t?.(e.patches.length,e.patches.length,"done"),{text:b.map(v=>v.text).join(`
161
-
162
- `),data:{mode:n,path:e.path,patches:b.map(v=>v.data)}}}if(n==="plan")return die(e);if(!e.patch)throw new Te("invalid_args","patch (the render of the fixed range, with record TC) is required");let i,r;if(e.in!=null||e.out!=null){let p=await Fn(e.path),h=p.source_fps??p.streams?.find(v=>v.kind==="video")?.rate??0,b=p.source_timecode??null;if(e.in!=null&&(i=Yr(e.in,h,b)),e.out!=null){if(i==null)throw new Te("invalid_args","out needs in");if(r=Yr(e.out,h,b)-i+1,r<1)throw new Te("invalid_args","out is before in")}if(i!=null&&i<0)throw new Te("invalid_args",`in is before the master's start TC (${b})`)}let o=await Dc({mode:"check",master:e.path,patch:e.patch,master_in:i,frames:r,patch_in:e.patch_in}),a=`${o.master_in}\u2013${o.master_in+o.frames-1}`,s=ar(e.path),c=te(e.path,s),l=async p=>{let h=e.out_path??Q(Ln(e.path),p);try{(await un(h)).isDirectory&&(h=Q(h,p))}catch{}if(await jn(h))throw new Te("refused",`${h} already exists; not overwriting (pass another out_path)`);return h},u=`${o.frames} frame${o.frames===1?"":"s"} of ${o.codec} cut in by timecode at master frames ${a} (patch frames ${o.patch_in}\u2013${o.patch_in+o.frames-1})`;if(n==="check"){let p=o.layout,h=await Pp(Ln(e.path)).catch(()=>null);return{text:`patch fits: ${u}, no re-encode
163
- ${p?fie(p,h)+`
164
- `:""}nothing written (mode=check)`,data:{...o,free_bytes:h}}}let f={patch_in:o.patch_in,frames:o.frames};if(n==="section"){let p=await l(`${c}_patch_${a.replace("\u2013","-")}${s}`),h=await Mr("conform-patch-");try{let b=Q(h,`range${s}`);await fh({path:e.path,in:o.master_in,out:o.master_in+o.frames-1,out_path:b});let v=await Dc({mode:"new",master:b,patch:e.patch,out_path:p,...f}),g=await Fn(p);return{text:`wrote section ${p}: ${u}, with the master's TC and audio, no re-encode
165
- verified: ${H4(v)}; start TC ${g.source_timecode??"none"}`,data:{...f,master_in:o.master_in,mode:n,path:p,start_tc:g.source_timecode??null,verify:v.verify,cost:v.cost}}}finally{await Sr(h)}}if(n==="in_place"){t?.(0,1,`write + verify ${te(e.patch)}`);let p=await Dc({mode:"in_place",master:e.path,patch:e.patch,...f,verify:e.verify??"index"}),h={...p.undo,patch:e.patch,at:new Date().toISOString()};await bt(vt()),await rn(Z4(),JSON.stringify(h)+`
166
- `,{append:!0});let b=p.cost??{};return{text:`patched ${te(e.path)} in place: ${u}, no re-encode
167
- verified: ${H4(p)}
168
- cost: the file grew ${W4(b.grew_bytes)}; ${W4(b.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)${b.btrt_refreshed?"; bitrate box refreshed":""}
169
- undo: media_patch mode=undo path=${e.path} restores the original byte for byte`,data:{...f,master_in:o.master_in,mode:n,path:e.path,verify:p.verify,cost:p.cost,undo:h}}}let d=await l(`${c}_patched${s}`),m=await Dc({mode:"new",master:e.path,patch:e.patch,out_path:d,...f});return{text:`wrote ${d}: ${te(e.path)} with ${u}, no re-encode
170
- verified: ${H4(m)}
171
- rewritten contiguously in the master's interleave order (${W4(m.cost?.bytes)}); the master was not touched`,data:{...f,master_in:o.master_in,mode:n,path:d,verify:m.verify,cost:m.cost}}}function H4(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(i=>!i.is.startsWith("patch")).map(i=>i.frame).join(", ")||"none: the span is the whole file"}), ${n}`}async function pie(e){let t=await mie(),n=(await un(e)).size,i=t.findLastIndex(o=>o.path===e&&o.size_after===n);if(i<0){let o=t.some(a=>a.path===e);throw new Te(o?"refused":"not_found",o?`${te(e)} changed since its last in-place patch (size ${n}); nothing undone`:`no in-place patch of ${te(e)} on record`)}let r=t[i];return await Dc({mode:"undo",record:r}),t.splice(i,1),await rn(Z4(),t.map(o=>JSON.stringify(o)+`
172
- `).join("")),{text:`undid the in-place patch of ${te(e)} (master frames ${r.master_in}\u2013${r.master_in+r.frames-1}): the file is byte-identical to before it`,data:{mode:"undo",path:e,undone:r}}}function EV(e,t,n){let i=new Float64Array(t*n),r=new Float64Array(t*n);for(let a=0;a<e.h;a++){let s=Math.min(n-1,a*n/e.h|0)*t;for(let c=0;c<e.w;c++){let l=s+Math.min(t-1,c*t/e.w|0);i[l]+=e.y[a*e.w+c],r[l]++}}let o=new Uint16Array(t*n);for(let a=0;a<o.length;a++)o[a]=Math.round(16*i[a]/(r[a]||1));return o}var hie=Math.max(2,Math.min(12,No()-4)),VV=typeof Worker<"u",Cu=null,nv=new Map,WV=1;function HV(){return Cu||(Cu=Array.from({length:hie},()=>{let e=new Worker(new URL("./decode-worker.ts",import.meta.url).href,{type:"module"}),t={w:e,busy:0};return e.onmessage=n=>{let i=nv.get(n.data.id);i&&(nv.delete(n.data.id),i.slot.busy--,n.data.ok?i.res(n.data.g??{y:n.data.y,w:n.data.w,h:n.data.h}):i.rej(new Error(n.data.why)))},t}),Cu)}var bie=(e,t,n,i,r)=>{let o=e.path;if(!o)return Da(e,t,n,i,r).then(c=>ia(c,i,r));let a=HV().reduce((c,l)=>l.busy<c.busy?l:c),s=WV++;return a.busy++,new Promise((c,l)=>{nv.set(s,{res:c,rej:l,slot:a}),a.w.postMessage({id:s,path:o,offset:t,size:n,spec:i,tier:r})})};function ZV(e,t,n,i,r,o,a){if(!VV)return mr.open(e).then(async l=>EV(ia(await Da(l,t,n,i,r),i,r),o,a));let s=HV().reduce((l,u)=>u.busy<l.busy?u:l),c=WV++;return s.busy++,new Promise((l,u)=>{nv.set(c,{res:l,rej:u,slot:s}),s.w.postMessage({id:c,path:e,offset:t,size:n,spec:i,tier:r,grid:[o,a]})})}function DV(){VV&&hy(bie)}function qV(){hy(null);for(let e of Cu??[])e.w.terminate();Cu=null}var iv=640,CV=100,JV=.03,q4=67,gie=7,UV=3;function rv(e,t,n,i){let r=new Float32Array(e.length),o=new Float32Array(e.length),a=2*i+1;for(let s=0;s<n;s++){let c=0;for(let l=-i;l<=i;l++)c+=e[s*t+Math.min(t-1,Math.max(0,l))];for(let l=0;l<t;l++)r[s*t+l]=c/a,c+=e[s*t+Math.min(t-1,l+i+1)]-e[s*t+Math.max(0,l-i)]}for(let s=0;s<t;s++){let c=0;for(let l=-i;l<=i;l++)c+=r[Math.min(n-1,Math.max(0,l))*t+s];for(let l=0;l<n;l++)o[l*t+s]=c/a,c+=r[Math.min(n-1,l+i+1)*t+s]-r[Math.max(0,l-i)*t+s]}return o}function av(e,t,n=iv){let i=e?Math.round(n*e.h/e.w):0,r=Wn(e,n,i);if(!r)return[];let o=rv(r,n,i,1),a=new Float32Array(n*i),s=new Float32Array(n*i),c=new Float32Array(n*i);for(let b=1;b<i-1;b++)for(let v=1;v<n-1;v++){let g=b*n+v,y=o[g+1]-o[g-1],w=o[g+n]-o[g-n];a[g]=y*y,s[g]=w*w,c[g]=y*w}let l=rv(a,n,i,2),u=rv(s,n,i,2),f=rv(c,n,i,2),d=new Float32Array(n*i);for(let b=0;b<n*i;b++)d[b]=l[b]*u[b]-f[b]*f[b]-.05*(l[b]+u[b])**2;let m=[],p=6,h=Math.max(p,Math.round(n/64));for(let b=h;b<i-h;b++)for(let v=h;v<n-h;v++){let g=d[b*n+v];if(g<=0)continue;let y=!0;for(let w=-p;w<=p&&y;w++)for(let x=-p;x<=p;x++)if(d[(b+w)*n+v+x]>g){y=!1;break}y&&m.push([g,v,b])}return m.sort((b,v)=>v[0]-b[0]).slice(0,t).map(([,b,v])=>[b*iv/n,v*iv/n])}function U4(e){let t=e.length,n=[],i=new Set,r=Math.min(gie+1,t),o=new Float64Array(t),a=Array.from({length:t},(u,f)=>f),s=new Array(r),c=new Array(4),l=[0,0,0,0];for(let u=0;u<t;u++){for(let f=0;f<t;f++)o[f]=(e[f][0]-e[u][0])**2+(e[f][1]-e[u][1])**2;for(let f=0;f<t;f++)a[f]=f;for(let f=0;f<r;f++){let d=f;for(let p=f+1;p<t;p++){let h=a[p],b=a[d];(o[h]<o[b]||o[h]===o[b]&&h<b)&&(d=p)}let m=a[f];a[f]=a[d],a[d]=m,s[f]=a[f]}for(let f=0;f<r;f++)for(let d=f+1;d<r;d++)for(let m=d+1;m<r;m++)for(let p=m+1;p<r;p++){l[0]=s[f],l[1]=s[d],l[2]=s[m],l[3]=s[p],l.sort((T,S)=>T-S);let h=((l[0]*128+l[1])*128+l[2])*128+l[3];if(i.has(h))continue;i.add(h);for(let T=0;T<4;T++)c[T]=e[l[T]];let b=-1,v=0,g=1;for(let T=0;T<4;T++)for(let S=T+1;S<4;S++){let k=(c[T][0]-c[S][0])**2+(c[T][1]-c[S][1])**2;k>b&&(b=k,v=T,g=S)}if(b<400)continue;let y=[0,1,2,3].filter(T=>T!==v&&T!==g),w=(T,S)=>{let k=S[0]-T[0],L=S[1]-T[1],z=k*k+L*L;return y.map(X=>{let V=c[X][0]-T[0],R=c[X][1]-T[1],j=(V*k+R*L)/z,J=(-V*L+R*k)/z;return[j-J,j+J]})},x=c[v],O=c[g],P=w(x,O);P[0][0]+P[1][0]>1&&([x,O]=[O,x],P=w(x,O)),P.sort((T,S)=>T[0]-S[0]),n.push({code:[P[0][0],P[0][1],P[1][0],P[1][1]],a:x,b:O})}}return n}var KV=e=>{let t=[e[1],e[0],e[3],e[2]];return t[0]>t[2]?[t[2],t[3],t[0],t[1]]:t},ov=e=>{let t=0;for(let n of e)t=t*q4+Math.max(0,Math.min(q4-1,Math.round(n/JV)+17));return t};function vie(e,t,n,i,r){let o=new Map;for(let f of i){let d=ov(f.code);(o.get(d)??o.set(d,[]).get(d)).push(f)}let a=new Map;for(let f of n){let d=Math.round(f[0]/4)*4096+Math.round(f[1]/4);(a.get(d)??a.set(d,[]).get(d)).push(f)}let s=(f,d)=>{let m=Math.round(f/4),p=Math.round(d/4);for(let h=-1;h<=1;h++)for(let b=-1;b<=1;b++)for(let v of a.get((m+h)*4096+p+b)??[])if((v[0]-f)**2+(v[1]-d)**2<UV*UV)return!0;return!1},c=f=>r?[-f[0],f[1]]:f,l={inl:0,scale:0,rot:0,flip:r},u=0;for(let f of t){let d=r?KV(f.code):f.code;for(let m of o.get(ov(d))??[]){if(d.some((L,z)=>Math.abs(L-m.code[z])>JV)||++u>4e3)continue;let p=c(f.a),h=c(f.b),b=h[0]-p[0],v=h[1]-p[1],g=m.b[0]-m.a[0],y=m.b[1]-m.a[1],w=b*b+v*v,x=(g*b+y*v)/w,O=(y*b-g*v)/w,P=Math.hypot(x,O);if(P<.3||P>1.2)continue;let T=m.a[0]-(x*p[0]-O*p[1]),S=m.a[1]-(O*p[0]+x*p[1]),k=0;for(let L of e){let z=c(L);s(x*z[0]-O*z[1]+T,O*z[0]+x*z[1]+S)&&k++}k/e.length>l.inl&&(l={inl:k/e.length,scale:1/P,rot:Math.atan2(O,x)*180/Math.PI,flip:r})}}return l}var C4=e=>Int32Array.from(new Set(U4(e).map(t=>ov(t.code)))),yie=[1,1.25,1.5,1.8],Dm=class{constructor(){this.ents=[];this.pk=new Int32Array(65536);this.pid=new Int32Array(65536);this.n=0;this.off=null;this.post=new Int32Array(0)}add(t,n,i,r=C4(i)){let o=this.ents.length;if(this.n+r.length>this.pk.length){let a=s=>{let c=new Int32Array(Math.max(s.length*2,this.n+r.length));return c.set(s.subarray(0,this.n)),c};this.pk=a(this.pk),this.pid=a(this.pid)}for(let a of r)this.pk[this.n]=a,this.pid[this.n++]=o;this.ents.push({clip:t,frame:n,st:Float32Array.from(i.flat()),nk:r.length}),this.off=null}postings(){if(this.off)return this.off;let t=new Int32Array(q4**4+1),n=new Int32Array(this.n);for(let r=0;r<this.n;r++)t[this.pk[r]+1]++;for(let r=1;r<t.length;r++)t[r]+=t[r-1];let i=t.slice(0,-1);for(let r=0;r<this.n;r++)n[i[this.pk[r]]++]=this.pid[r];return this.post=n,this.off=t}get size(){return this.ents.length}find(t,n=40){let i=yie.map(s=>{let c=av(t,60,Math.round(iv/s)).map(([l,u])=>[l/s,u/s]);return{rs:s,st:c,q:U4(c)}}),r=new Map,o=this.postings();for(let{q:s}of i)for(let c of[!1,!0]){let l=new Set(s.map(f=>ov(c?KV(f.code):f.code))),u=new Map;for(let f of l){let d=o[f],m=o[f+1];if(d===m)continue;let p=Math.log(this.ents.length/(m-d));for(let h=d;h<m;h++){let b=this.post[h];u.set(b,(u.get(b)??0)+p)}}for(let[f,d]of u)r.set(f,Math.max(r.get(f)??0,d/Math.sqrt(this.ents[f].nk*l.size)))}let a=null;for(let[s]of[...r].sort((c,l)=>l[1]-c[1]).slice(0,n)){let c=this.ents[s],l=Array.from({length:c.st.length/2},(f,d)=>[c.st[2*d],c.st[2*d+1]]),u=U4(l);for(let{rs:f,st:d,q:m}of i)for(let p of[!1,!0]){let h=vie(d,m,l,u,p);(!a||h.inl>a.inl)&&(a={...h,scale:h.scale*f,clip:c.clip,frame:c.frame})}}return a}};if(import.meta.main){let e=7,t=()=>(e=e*16807%2147483647)/2147483647,n=()=>{let u=new Uint8Array(518400).fill(60);for(let f=0;f<120;f++){let d=t()*960,m=t()*540,p=6+t()*30,h=120+t()*135;for(let b=Math.max(0,m|0);b<Math.min(540,m+p);b++)for(let v=Math.max(0,d|0);v<Math.min(960,d+p);v++)u[b*960+v]=h}return{y:u,w:960,h:540}},i=(c,l,u,f)=>{let{w:d,h:m}=c,p=new Uint8Array(d*m),h=Math.cos(u*Math.PI/180),b=Math.sin(u*Math.PI/180);for(let v=0;v<m;v++)for(let g=0;g<d;g++){let y=(g-d/2)/l,w=(v-m/2)/l;f&&(y=-y);let x=h*y-b*w+d/2,O=b*y+h*w+m/2;p[v*d+g]=x>=0&&O>=0&&x<d&&O<m?c.y[(O|0)*d+(x|0)]:0}return{y:p,w:d,h:m}},r=new Dm,o=Array.from({length:6},n);o.forEach((c,l)=>r.add(0,l,av(c,100)));let a=r.find(o[3]),s=r.find(i(o[4],1.5,4,!0));if(a.frame!==3||a.inl<.8)throw new Error(`plain ${JSON.stringify(a)}`);if(s.frame!==4||!s.flip||Math.abs(s.scale-1.5)>.1||s.inl<.5)throw new Error(`turned ${JSON.stringify(s)}`);console.log("plate-solve self-check ok",a.inl.toFixed(2),s.inl.toFixed(2),s.scale.toFixed(2),s.rot.toFixed(1))}var GV=Math.max(2,Math.min(8,No()-4)),sv=null,wie=0,xie=1,J4=new Map;function AV(e){if(typeof Worker>"u")return Promise.resolve(e.map(C4));sv??=Array.from({length:GV},()=>{let n=new Worker(new URL("./plate-worker.ts",import.meta.url).href,{type:"module"});return n.onmessage=i=>{J4.get(i.data.id)?.(i.data.keys),J4.delete(i.data.id)},n});let t=xie++;return new Promise(n=>{J4.set(t,n),sv[wie++%GV].postMessage({id:t,stars:e})})}function BV(){for(let e of sv??[])e.terminate();sv=null}var Pie=1;async function YV(e,t){try{let n=await un(e);if(!n.isFile)return null;let i=JSON.stringify([Pie,e,n.size,Math.round(n.mtimeMs),te(t.model),t.stride,t.geometryWidth,...t.display?[t.display]:[]]),r=new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)));return Array.from(r.slice(0,16),o=>o.toString(16).padStart(2,"0")).join("")}catch{return null}}var cv=()=>Q(vt(),"cache","sscd");async function qm(e,t){let n=await YV(e,t);if(!n)return null;let i;try{i=await er(Q(cv(),`${n}.sscd`))}catch{return null}try{let r=new DataView(i.buffer,i.byteOffset,i.byteLength),[o,a,s]=[r.getUint32(0,!0),r.getUint32(4,!0),r.getUint32(8,!0)],c=new Uint32Array(i.slice(12,12+o*4).buffer),l=new Float32Array(i.slice(12+o*4,12+o*4+a*s*4).buffer);if(l.length!==a*s)return null;let u=Array.from({length:a},(f,d)=>l.subarray(d*s,(d+1)*s));return Array.from(c,f=>u[f])}catch{return null}}async function K4(e,t,n){let i=await YV(e,t);if(!i||!n.length)return;let r=new Map,o=new Uint32Array(n.length);n.forEach((f,d)=>{let m=r.get(f);m===void 0&&r.set(f,m=r.size),o[d]=m});let a=n[0].length,s=new Uint8Array(12+o.byteLength+r.size*a*4),c=new DataView(s.buffer);c.setUint32(0,n.length,!0),c.setUint32(4,r.size,!0),c.setUint32(8,a,!0),s.set(new Uint8Array(o.buffer),12);let l=12+o.byteLength;for(let f of r.keys())s.set(new Uint8Array(f.buffer,f.byteOffset,a*4),l),l+=a*4;await bt(cv()),await Xo(Q(vt(),"cache"),448);let u=Q(cv(),`${i}.${crypto.randomUUID()}.tmp`);await fr(u,s),await Xo(u,384);try{await Br(u,Q(cv(),`${i}.sscd`))}catch{await Vr(u)}}function $V(e){let t=()=>(e=e*1103515245+12345>>>0)/4294967296;return{rnd:t,gauss:()=>Math.sqrt(-2*Math.log(t()+1e-12))*Math.cos(2*Math.PI*t())}}var QV=e=>(e-=e>>>1&1431655765,e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),Um=(e,t,n,i)=>1-(QV(e[2*t]^n[2*i])+QV((e[2*t+1]^n[2*i+1])&(1<<20)-1))/52;function G4(e,t,n,i){if(t<1||i<1||e.still[t]||n.still[i])return null;let r=0,o=0,a=t*1152,s=i*1152;for(let f=0;f<1152;f++)r+=e.g[a+f]-e.g[a-1152+f],o+=n.g[s+f]-n.g[s-1152+f];r/=1152,o/=1152;let c=0,l=0,u=0;for(let f=0;f<1152;f++){let d=e.g[a+f]-e.g[a-1152+f]-r,m=n.g[s+f]-n.g[s-1152+f]-o;c+=d*m,l+=d*d,u+=m*m}return l&&u?c/Math.sqrt(l*u):null}function kie(e){let t=new Uint16Array(e.g.length);for(let n=0;n<e.n;n++){let i=n*1152;for(let r=0;r<1152;r++)t[i+r]=e.g[i+1152-1-r]}return{n:e.n,ok:e.ok,g:t}}function Y4(e,t,n={}){let i=n.L??24,r=n.STRIDE??12,o=n.CANDS??8,a=n.ALTS??4,s=n.REFINE??16,c=n.PEN??4,l=n.PENHI??40,u=n.CONT??.95,f=n.SPW??4,d=n.SP0??.75,m=n.SPMIN??.8,p=n.EXT??.85,h=n.EXTALTS??2,b=n.SEGSURE??.3,v=n.ROT??!0,g=v?2:1,{rnd:y,gauss:w}=$V(99),x=new Float32Array(32*1152);for(let _=0;_<32;_++)for(let pe=0;pe<1152/2;pe++){let Ne=w();x[_*1152+pe]=Ne,x[_*1152+1152-1-pe]=_&1?-Ne:Ne}let O=48/8,P=24/4,T=(_,pe)=>{let{n:Ne,ok:nt,g:dt}=_;if(!pe&&_.feat?.mp.length===Ne*32)return{n:Ne,ok:nt,g:dt,..._.feat};let Kt=new Uint32Array(Ne*2),Xt=new Float32Array(Ne*32),At=new Uint8Array(Ne),on=new Float32Array(32),Be=new Float32Array(1152);for(let at=0;at<Ne;at++){if(!nt[at]){At[at]=1;continue}let jt=at*1152;on.fill(0);for(let Ee=0;Ee<24;Ee++)for(let Kn=0;Kn<48;Kn++)on[(Ee/P|0)*8+(Kn/O|0)]+=dt[jt+Ee*48+Kn];let an=0,Nn=0,Tn=0,Ut=Ee=>{an<32?Nn|=(Ee>0?1:0)<<an:Tn|=(Ee>0?1:0)<<an-32,an++};for(let Ee=0;Ee<4;Ee++)for(let Kn=0;Kn<7;Kn++)Ut(on[Ee*8+Kn]-on[Ee*8+Kn+1]);for(let Ee=0;Ee<3;Ee++)for(let Kn=0;Kn<8;Kn++)Ut(on[Ee*8+Kn]-on[(Ee+1)*8+Kn]);if(Kt[2*at]=Nn>>>0,Kt[2*at+1]=Tn>>>0,pe){At[at]=pe.still[at];for(let Ee=0;Ee<32;Ee++)Xt[at*32+Ee]=Ee&1?-pe.mp[at*32+Ee]:pe.mp[at*32+Ee];continue}if(at===0||!nt[at-1]){At[at]=1;continue}let Or=0;for(let Ee=0;Ee<1152;Ee++)Be[Ee]=dt[jt+Ee]-dt[jt-1152+Ee],Or+=Be[Ee];Or/=1152;let lr=0;for(let Ee=0;Ee<1152;Ee++)Be[Ee]-=Or,lr+=Be[Ee]*Be[Ee];if(!lr){At[at]=1;continue}let co=1/Math.sqrt(lr);for(let Ee=0;Ee<32;Ee++){let Kn=0,Zi=Ee*1152;for(let $o=0;$o<1152;$o++)Kn+=x[Zi+$o]*Be[$o];Xt[at*32+Ee]=Kn*co/Math.sqrt(32)}}return pe||(_.feat={sp:Kt,mp:Xt,still:At}),{n:Ne,ok:nt,g:dt,sp:Kt,mp:Xt,still:At}},S=[],k=[];t.forEach((_,pe)=>{let Ne=T(_);S.push(Ne),k.push(n.rates?.[pe]??1),v&&(S.push(T(kie(_),Ne)),k.push(n.rates?.[pe]??1))});let L=(_,pe)=>k[_]===1?pe:Math.floor(pe*k[_]+.001),z=T(e),X=Array.from({length:12},()=>{let _=[...Array(52).keys()];for(let pe=_.length-1;pe>0;pe--){let Ne=y()*(pe+1)|0;[_[pe],_[Ne]]=[_[Ne],_[pe]]}return _.slice(0,18)}),V=(_,pe,Ne)=>Ne<32?_[2*pe]>>>Ne&1:_[2*pe+1]>>>Ne-32&1,R=(_,pe,Ne)=>{let nt=0;for(let dt of Ne)nt=nt*2+V(_,pe,dt);return nt},j=X.map(()=>new Map);S.forEach((_,pe)=>{for(let Ne=0;Ne<_.n;Ne++)if(_.ok[Ne])for(let nt=0;nt<12;nt++){let dt=R(_.sp,Ne,X[nt]),Kt=j[nt].get(dt);Kt||j[nt].set(dt,Kt=new Map),Kt.set(pe,(Kt.get(pe)??0)+1)}});let J=new Float32Array(z.n);for(let _=1;_<z.n;_++){if(!z.ok[_]||!z.ok[_-1])continue;let pe=0,Ne=0,nt=(_-1)*1152,dt=_*1152;for(let on=0;on<1152;on++)pe+=z.g[nt+on],Ne+=z.g[dt+on];pe/=1152,Ne/=1152;let Kt=0,Xt=0,At=0;for(let on=0;on<1152;on++){let Be=z.g[nt+on]-pe,at=z.g[dt+on]-Ne;Kt+=Be*at,Xt+=Be*Be,At+=at*at}J[_]=Xt&&At?Kt/Math.sqrt(Xt*At):0}let q=_=>1-J[_],W=new Uint8Array(z.n);for(let _=2;_<z.n-1;_++){let pe=[];for(let nt=-6;nt<=6;nt++)nt&&_+nt>=1&&_+nt<z.n&&pe.push(q(_+nt));pe.sort((nt,dt)=>nt-dt);let Ne=pe[pe.length>>1];q(_)>.004&&q(_)>4*Ne+.002&&q(_)>=Math.max(q(_-1),q(_+1))&&(W[_]=1)}for(let _=1;_<z.n;_++)W[_]&&(J[_]=Math.min(J[_],u-.001));let F=_=>_<=0||_>=z.n||J[_]<u,H=Sie(z),C=[];for(let _=0;_+i<=z.n;_+=r)C.push([_,i]);for(let _=0;_<z.n;){let pe=_+1;for(;pe<z.n&&!F(pe);)pe++;pe-_>=4&&pe-_<i&&C.push([_,pe-_]),_=pe}let $=[],oe=C.length;for(let[_,[pe,Ne]]of C.entries()){_%25===0&&n.onProgress?.(_,oe,"align: windows");let nt=new Map;for(let Be=pe;Be<pe+Ne;Be++)if(z.ok[Be])for(let at=0;at<12;at++){let jt=j[at].get(R(z.sp,Be,X[at]));if(!jt)continue;let an=1/Math.sqrt(jt.size);for(let[Nn]of jt)nt.set(Nn,(nt.get(Nn)??0)+an)}let dt=[...nt].sort((Be,at)=>at[1]-Be[1]).slice(0,o).map(([Be])=>Be);dt=[...new Set(dt.flatMap(Be=>{let at=Be-Be%g;return[at-g,at,at+g].flatMap(jt=>v?[jt,jt+1]:[jt])}).filter(Be=>Be>=0&&Be<S.length))];let Kt=pe+(Ne>>1),Xt=[];for(let Be=pe;Be<pe+Ne;Be++)z.still[Be]||Xt.push(Be);let At=[];for(let Be of dt){let at=S[Be];for(let jt=-L(Be,pe);jt+L(Be,pe+Ne)<=at.n;jt++){let an=Kt;if(!at.ok[L(Be,Kt)+jt]){an=-1;for(let Ut=pe;Ut<pe+Ne;Ut++)if(at.ok[L(Be,Ut)+jt]&&z.ok[Ut]){an=Ut;break}if(an<0)continue}if(Um(z.sp,an,at.sp,L(Be,an)+jt)<m)continue;let Nn=0,Tn=0;if(Xt.length>=4){for(let Ut=0;Ut<Xt.length;Ut+=2){let Or=Xt[Ut],lr=L(Be,Or)+jt;if(at.still[lr]){if(!at.ok[lr])continue;Tn++;continue}let co=0,Ee=Or*32,Kn=lr*32;for(let Zi=0;Zi<32;Zi++)co+=z.mp[Ee+Zi]*at.mp[Kn+Zi];Nn+=co,Tn++}if(!Tn)continue;Nn/=Tn}else{for(let Ut=pe;Ut<pe+Ne;Ut+=4)Nn+=Um(z.sp,Ut,at.sp,L(Be,Ut)+jt),Tn++;Nn=Nn/Tn-1}At.push({ci:Be,s:jt,sc:Nn})}}At.sort((Be,at)=>at.sc-Be.sc);let on=At.slice(0,s).map(Be=>{if(Xt.length<4)return Be;let at=0,jt=0;for(let an of Xt){let Nn=L(Be.ci,an)+Be.s;!S[Be.ci].ok[Nn]||!S[Be.ci].ok[Nn-1]||(at+=G4(z,an,S[Be.ci],Nn)??0,jt++)}return{...Be,sc:jt?at/jt:-1}}).sort((Be,at)=>at.sc-Be.sc);$.push({a:pe,len:Ne,alts:[...on,...At.slice(s,40)].filter((Be,at,jt)=>jt.findIndex(an=>an.ci===Be.ci&&Math.abs(an.s-Be.s)<=2)===at).slice(0,a)})}n.onProgress?.(oe,oe,"align: path");let ye=(_,pe)=>_*1e6+pe+5e5,Ae=_=>({ci:Math.floor(_/1e6),d:_%1e6-5e5}),de=(_,pe,Ne)=>{let nt=0,dt=0;for(let Kt=-1;Kt<=1;Kt++){let Xt=Ne+Kt,At=L(_,Xt)+pe;Xt<0||Xt>=z.n||At<0||At>=S[_].n||!z.ok[Xt]||!S[_].ok[At]||(nt+=Um(z.sp,Xt,S[_].sp,At),dt++)}return dt?nt/dt:0},Oe=Array.from({length:z.n},()=>new Set);for(let _ of $){let pe=_.a;for(;!F(pe);)pe--;let Ne=_.a+_.len;for(;Ne<z.n&&!F(Ne);)Ne++;pe=Math.max(0,Math.min(pe,_.a-i)),Ne=Math.min(z.n,Math.max(Ne,_.a+2*i));for(let nt of _.alts)for(let dt=pe;dt<Ne;dt++)Oe[dt].add(ye(nt.ci,nt.s))}let Ze=new Set;for(let _ of $)for(let pe of _.alts.slice(0,h)){let Ne=ye(pe.ci,pe.s);if(!Ze.has(Ne)){Ze.add(Ne);for(let nt of[-1,1])for(let dt=nt<0?_.a-i-1:_.a+2*i;dt>=0&&dt<z.n&&!(de(pe.ci,pe.s,dt)<p);dt+=nt)Oe[dt].add(Ne)}}let ue=(_,pe)=>{let{ci:Ne,d:nt}=Ae(pe),dt=L(Ne,_)+nt,Kt=S[Ne];return dt<0||dt>=Kt.n||!Kt.ok[dt]||!z.ok[_]||H[_]?-1/0:f*(Um(z.sp,_,Kt.sp,dt)-d)+(G4(z,_,Kt,dt)??0)},ze=(_,pe)=>{let{ci:Ne,d:nt}=Ae(_),dt=S[Ne],Kt=L(Ne,pe)+nt,Xt=L(Ne,pe-1)+nt;if(Xt<0||Kt>=dt.n||!dt.ok[Kt]||!dt.ok[Xt])return 0;let At=0,on=0,Be=Xt*1152,at=Kt*1152;for(let Tn=0;Tn<1152;Tn++)At+=dt.g[Be+Tn],on+=dt.g[at+Tn];At/=1152,on/=1152;let jt=0,an=0,Nn=0;for(let Tn=0;Tn<1152;Tn++){let Ut=dt.g[Be+Tn]-At,Or=dt.g[at+Tn]-on;jt+=Ut*Or,an+=Ut*Ut,Nn+=Or*Or}return an&&Nn?jt/Math.sqrt(an*Nn):0},Re=new Map([[-1,0]]),yt=[],rt=[];for(let _=0;_<z.n;_++){let pe=-1,Ne=-1/0;for(let[Xt,At]of Re)At>Ne&&(Ne=At,pe=Xt);let nt=new Map,dt=new Map,Kt=new Map;for(let Xt of[-1,...Oe[_]]){let At=Xt===-1?0:ue(_,Xt);if(At===-1/0)continue;Kt.set(Xt,At);let on=J[_]<u&&Xt!==-1&&ze(Xt,_)>=u?l:0,Be=(Re.get(Xt)??-1/0)-on,at=Ne-(J[_]>=u?l:c);Be>=at?(nt.set(Xt,Be+At),dt.set(Xt,Xt)):(nt.set(Xt,at+At),dt.set(Xt,pe))}yt.push(dt),rt.push(Kt),Re=nt}let zt=-1,qt=-1/0;for(let[_,pe]of Re)pe>qt&&(qt=pe,zt=_);let Ot=new Array(z.n);for(let _=z.n-1;_>=0;_--)Ot[_]=zt,zt=yt[_].get(zt)??-1;let pt=[];for(let _=0;_<z.n;){let pe=_;for(;pe<z.n&&Ot[pe]===Ot[_];)pe++;let Ne=Ot[_];if(Ne===-1)pt.push({refStart:_,refEnd:pe-1,clip:-1,srcStart:0,srcEnd:0,rot180:!1,conf:0,sure:!1});else{let{ci:nt,d:dt}=Ae(Ne),Kt=new Map,Xt=0;for(let Be=_;Be<pe;Be++){Xt+=rt[Be].get(Ne)??0;for(let[at,jt]of rt[Be]){if(at===-1)continue;let an=Ae(at);an.ci===nt&&Math.abs(an.d-dt)<=2||Kt.set(at,(Kt.get(at)??0)+jt)}}let At=(Xt-Math.max(0,...Kt.values()))/(pe-_),on=L(nt,_)+dt;{let Be=-1/0,at=Math.ceil(2*k[nt]);for(let jt=on-at;jt<=on+at;jt++){let an=0;for(let Nn=_;Nn<pe;Nn++){let Tn=jt+Math.floor((Nn-_)*k[nt]+.001),Ut=S[nt];Tn>=1&&Tn<Ut.n&&Ut.ok[Tn]&&(an+=f*Um(z.sp,Nn,Ut.sp,Tn)+(G4(z,Nn,Ut,Tn)??0))}an>Be&&(Be=an,on=jt)}}pt.push({refStart:_,refEnd:pe-1,clip:Math.floor(nt/g),srcStart:on,srcEnd:on+Math.floor((pe-1-_)*k[nt]+.001),rot180:v&&nt%2===1,conf:At,sure:At>=b})}_=pe}return Oie(pt,z,t,k,H,n),pt}function Sie(e){let t=new Uint8Array(e.n);for(let n=0;n<e.n;n++){if(!e.ok[n])continue;let i=0,r=0,o=n*1152;for(let a=0;a<1152;a++)i+=e.g[o+a];i/=1152;for(let a=0;a<1152;a++)r+=(e.g[o+a]-i)**2;Math.sqrt(r/1152)<32&&(t[n]=1)}return t}var Tie=[1.15,1.3,1.5,1.75,2];function A4(e,t,n,i,r=48,o=24){let a=new Float32Array(n*i),s=new Float32Array(n*i);for(let f=0;f<o;f++){let d=Math.min(i-1,f*i/o|0);for(let m=0;m<r;m++){let p=d*n+Math.min(n-1,m*n/r|0);a[p]+=e[t+f*r+m],s[p]++}}let c=0;for(let f=0;f<a.length;f++)a[f]/=s[f]||1,c+=a[f];c/=a.length;let l=0;for(let f=0;f<a.length;f++)a[f]-=c,l+=a[f]*a[f];let u=Math.sqrt(l)||1;for(let f=0;f<a.length;f++)a[f]/=u;return a}function zie(e,t,n){let i=new Float64Array((t+1)*(n+1)),r=new Float64Array((t+1)*(n+1));for(let o=0;o<n;o++){let a=0,s=0;for(let c=0;c<t;c++){let l=e[o*t+c];a+=l,s+=l*l,i[(o+1)*(t+1)+c+1]=i[o*(t+1)+c+1]+a,r[(o+1)*(t+1)+c+1]=r[o*(t+1)+c+1]+s}}return{I:i,I2:r}}function B4(e,t,n,i,r,o=48,a=24,s){let c=-2,l=0,u=0,f=t*n,d=o+1;for(let m=0;m+n<=a;m++)for(let p=0;p+t<=o;p++){let h=0,b=0,v=0;if(s){let w=m*d+p,x=w+t,O=(m+n)*d+p,P=O+t;h=s.I[P]-s.I[x]-s.I[O]+s.I[w],b=s.I2[P]-s.I2[x]-s.I2[O]+s.I2[w];for(let T=0;T<n;T++){let S=r+(m+T)*o+p,k=T*t;for(let L=0;L<t;L++)v+=e[k+L]*i[S+L]}}else for(let w=0;w<n;w++){let x=r+(m+w)*o+p,O=w*t;for(let P=0;P<t;P++){let T=i[x+P];h+=T,b+=T*T,v+=e[O+P]*T}}let g=b-h*h/f;if(g<=0)continue;let y=v/Math.sqrt(g);y>c&&(c=y,l=p,u=m)}return{ncc:c,px:l,py:u}}function _V(e,t,n,i,r,o,a,s,c){let l=new Float32Array(n*i),u=new Float32Array(n*i),f=new Float32Array(n*i);for(let v=0;v<24;v++){let g=Math.min(i-1,v*i/24|0);for(let y=0;y<48;y++){let w=g*n+Math.min(n-1,y*n/48|0);l[w]+=e[t*1152+v*48+y]-e[(t-1)*1152+v*48+y],f[w]++}}for(let v=0;v<i;v++)for(let g=0;g<n;g++){let y=(c+v)*48+s+g;u[v*n+g]=r[o*1152+y]-r[a*1152+y]}let d=0,m=0;for(let v=0;v<l.length;v++)l[v]/=f[v]||1,d+=l[v],m+=u[v];d/=l.length,m/=l.length;let p=0,h=0,b=0;for(let v=0;v<l.length;v++){let g=l[v]-d,y=u[v]-m;p+=g*y,h+=g*g,b+=y*y}return h>1e-6&&b>1e-6?p/Math.sqrt(h*b):null}function Oie(e,t,n,i,r,o){let a=o.ROT??!0?2:1,s=b=>i[b*a]??1,c=e.filter(b=>b.refEnd-b.refStart>=3&&(b.clip<0||!b.sure));if(!c.length)return;let l=[...new Set(e.filter(b=>b.clip>=0&&b.sure).flatMap(b=>[b.clip-1,b.clip,b.clip+1]))].filter(b=>b>=0&&b<n.length),u=n.length<=16||!l.length?n.map((b,v)=>v):l,f=(b,v,g,y)=>v+Math.floor((y-g)*s(b)+.001),d=24,m=12,p=new Map,h=(b,v)=>{let g=b*1e7+v,y=p.get(g);if(!y){let w=n[b].g,x=v*1152,O=new Float32Array(d*m);for(let P=0;P<m;P++)for(let T=0;T<d;T++){let S=x+2*P*48+2*T;O[P*d+T]=(w[S]+w[S+1]+w[S+48]+w[S+48+1])/4}p.set(g,y={h:O,sat:zie(O,d,m)})}return y};for(let[b,v]of c.entries()){o.onProgress?.(b,c.length,"align: reframed shots");let g=[v.refStart+1,v.refStart+v.refEnd>>1,v.refEnd-1].filter(k=>t.ok[k]&&!r[k]);if(g.length<2)continue;let y=[];for(let k of Tie){let L=Math.round(d/k),z=Math.round(m/k),X=g.map(V=>A4(t.g,V*1152,L,z));for(let V of u){let R=n[V],j=f(V,0,g[0],g[g.length-1]);for(let J=0;J+j<R.n;J+=6){let q=0,W=0;for(let F=0;F<g.length;F++){let H=f(V,J,g[0],g[F]);if(!R.ok[H])continue;let C=h(V,H);q+=B4(X[F],L,z,C.h,0,d,m,C.sat).ncc,W++}W>=2&&y.push({ci:V,S:J-f(V,0,v.refStart,g[0]),sc:q/W,scale:k})}}}y.sort((k,L)=>L.sc-k.sc);let w=[];for(let k=v.refStart;k<=v.refEnd;k+=Math.max(1,(v.refEnd-v.refStart)/8|0))t.ok[k]&&!r[k]&&w.push(k);let x=[],O=new Map;for(let k of y){let L=O.get(k.ci)??0;if(!(L>=3||x.some(z=>z.ci===k.ci&&Math.abs(z.S-k.S)<12))&&(O.set(k.ci,L+1),x.push(k),x.length>=12))break}let P=null,T=new Map;for(let k of x)for(let L of[k.scale/1.07,k.scale,k.scale*1.07]){let z=Math.round(48/L),X=Math.round(24/L);if(z>=48)continue;let V=w.map(j=>A4(t.g,j*1152,z,X)),R=n[k.ci];for(let j=k.S-6;j<=k.S+6;j++){let J=0,q=0,W=0,F=0;for(let $=0;$<w.length;$++){let oe=w[$],ye=f(k.ci,j,v.refStart,oe),Ae=f(k.ci,j,v.refStart,oe-1);if(ye<1||ye>=R.n||!R.ok[ye])continue;let de=B4(V[$],z,X,R.g,ye*1152);if(J+=de.ncc,q++,oe>v.refStart&&Ae>=0&&Ae!==ye&&R.ok[Ae]&&t.ok[oe-1]){let Oe=_V(t.g,oe,z,X,R.g,ye,Ae,de.px,de.py);Oe!==null&&(W+=Oe,F++)}}let H=q?J/q+(F>=2?W/F:0):-9;if(q<Math.max(2,w.length>>1))continue;(!P||H>P.sc)&&(P={ci:k.ci,S:j,sc:H,scale:L});let C=T.get(k);(!C||H>C.sc)&&T.set(k,{ci:k.ci,S:j,sc:H,scale:L})}}if(globalThis.ALIGN_DEBUG&&console.error(`rescue ${v.refStart}-${v.refEnd}: short ${x.map(k=>`${k.ci}@${k.S}x${k.scale}:${k.sc.toFixed(2)}`).join(" ")} \u2192 best ${P?`${P.ci}@${P.S}x${P.scale.toFixed(2)}:${P.sc.toFixed(2)}`:"-"}`),!P)continue;let S=0;if(v.clip>=0){let k=n[v.clip],L=w.map(R=>A4(t.g,R*1152,48,24)),z=0,X=0,V=0;for(let R=0;R<w.length;R++){let j=w[R],J=f(v.clip,v.srcStart,v.refStart,j),q=f(v.clip,v.srcStart,v.refStart,j-1);if(!(J<1||J>=k.n||!k.ok[J])&&(S+=B4(L[R],48,24,k.g,J*1152).ncc,z++,j>v.refStart&&q>=0&&q!==J&&k.ok[q]&&t.ok[j-1])){let W=_V(t.g,j,48,24,k.g,J,q,0,0);W!==null&&(X+=W,V++)}}S=z?S/z+(V>=2?X/V:0):0}v.candidates=[...T.values()].sort((k,L)=>L.sc-k.sc).slice(0,6).map(k=>({clip:k.ci,srcStart:k.S,scale:k.scale,score:k.sc})),v.clip>=0&&v.candidates.push({clip:v.clip,srcStart:v.srcStart,scale:1,score:S}),!(P.sc<.6||P.sc<S+.1)&&(v.clip=P.ci,v.srcStart=P.S,v.srcEnd=P.S+Math.floor((v.refEnd-v.refStart)*s(P.ci)+.001),v.rot180=!1,v.conf=P.sc-Math.max(S,0),v.sure=!1,v.reframed=P.scale)}}function Mie(){let{gauss:e}=$V(7),t=s=>{let c=new Uint16Array(s*1152),l=0,u=0,f=Float32Array.from({length:5632},()=>2e3+800*e());for(let d=0;d<s;d++){l+=.7,u+=.3;for(let m=0;m<24;m++)for(let p=0;p<48;p++)c[d*1152+m*48+p]=f[(m+(u|0))%64*88+(p+(l|0))%88]}return{n:s,ok:new Uint8Array(s).fill(1),g:c}},n=t(60),i=t(60),r={n:60,ok:new Uint8Array(60).fill(1),g:new Uint16Array(60*1152)};r.g.set(n.g.subarray(10*1152,40*1152),0),r.g.set(i.g.subarray(5*1152,35*1152),30*1152);let o=Y4(r,[n,i]).filter(s=>s.clip>=0),a=s=>o.find(c=>s>=c.refStart&&s<=c.refEnd);for(let[s,c,l]of[[15,0,10],[45,1,-25]]){let u=a(s);if(!u||u.clip!==c||u.srcStart-u.refStart!==l)throw new Error(`alignSelfCheck: frame ${s} \u2192 ${JSON.stringify(u)}`)}}import.meta.main&&(Mie(),console.log("align self-check ok"));var Lie=[1,...Array.from({length:97},(e,t)=>.25*16**(t/96))],Rie=1.25,Nie=.3,eW=[.25,.5,.75,1,1.25,1.5,2,3,4];function lv(e){let t=0;for(let o of e)t+=o;t/=e.length;let n=0;for(let o of e)n+=(o-t)**2;let i=1/(Math.sqrt(n)||1),r=new Float32Array(e.length);for(let o=0;o<e.length;o++)r[o]=(e[o]-t)*i;return r}function Q4(e,t,n,i=1){let r=e.length,o=n.length,a=new Float32Array(r*o).fill(NaN);for(let b=0;b<r;b++){let v=e[b];if(v)for(let g=0;g<o;g++){let y=n[g];if(!y)continue;let w=0;for(let x=0;x<v.length;x++)w+=v[x]*y[x];a[b*o+g]=w}}let s=(b,v)=>{let g=0,y=0;for(let w=0;w<r;w++){let x=Math.floor(b*t[w]+v+.001);if(x<0||x>=o)return-1/0;let O=a[w*o+x];O===O&&(g+=O,y++)}return y>=Math.max(3,r>>1)?g/y:-1/0},c=t[r-1]-t[0],l=Lie.map(b=>{let v={score:-1/0,off:0};for(let g=0;g+b*c<o;g+=.5){let y=s(b,g);y>v.score&&(v={score:y,off:g})}return{sp:b,...v}}),u=l.reduce((b,v)=>v.score>b.score?v:b);if(!isFinite(u.score))return null;let f=Math.max(-1,...l.filter(b=>Math.abs(Math.log(b.sp/u.sp))>Math.log(Rie)).map(b=>b.score)),d=[...eW,...eW.map(b=>b*i)].reduce((b,v)=>Math.abs(Math.log(v/u.sp))<Math.abs(Math.log(b/u.sp))?v:b),m=u.sp,p=u.off;if(Math.abs(Math.log(d/u.sp))<.07){let b=u.sp*c/2+u.off,v=-1/0;for(let g=Math.round(b-d*c/2)-2;g<=b-d*c/2+2;g+=.5){let y=s(d,g);y>v&&(v=y,p=g)}isFinite(v)?m=d:p=u.off}let h=(u.score-f)/Math.max(1e-6,1-f);return{score:s(m,p),margin:h,speed:m,start:Math.floor(p+.001),observable:h>=Nie,scoreOf:s}}var uv=160,fv=2,Xie=12;async function tW(e,t,n,i=16,r=9){let o=Math.max(1,e.refEnd-e.refStart);if(o<fv+2)return null;let a=Math.round(uv*r/i),s=b=>Math.round(e.srcStart+(b-e.refStart)*(e.srcEnd-e.srcStart)/o),c=b=>b.catch(()=>null),l=(await Promise.all(Ni(e.refStart,e.refEnd-fv,Xie).map(b=>Promise.all([c(t(b)),c(t(b+fv)),c(n(s(b))),c(n(s(b+fv)))])))).filter(b=>b.every(Boolean));if(l.length<3)return null;let u=await Ri(l.map(b=>({ref:b[0],src:b[2]})),{turns:!1}).catch(()=>null),f=u?fo(u.transform):null,d=l[0][0].w,m=l[0][0].h,p=(b,v)=>Io(v&&f?vi(b,f,d,m,uv,a):Wn(b,uv,a),uv),h=b=>{let v=0,g=0,y=0;for(let w of l){let x=p(w[0],!1),O=p(w[1],!1),P=p(w[2],b),T=p(w[3],b);if(!(!x||!O||!P||!T))for(let S=0;S<x.length;S++){let k=O[S]-x[S],L=T[S]-P[S];v+=k*L,g+=k*k,y+=L*L}}return g&&y?v/Math.sqrt(g*y):0};return Math.max(h(!1),f?h(!0):-1)}var _4=Array.from({length:30},(e,t)=>(t+1)/10),dv=[-1,0,1],jie=.004;function $4(e,t,n){if(t<2||n<2)return null;let i=n*10,r=_4.length,o=_4.map((b,v)=>v+1),a=(b,v)=>{let g=e[b*n+Math.floor(v/10)];return g===g?g:0},s=new Float32Array(i*r);for(let b=0;b<i;b++){let v=a(0,b);for(let g=0;g<r;g++)s[b*r+g]=v}let c=new Int8Array(t*i*r);for(let b=1;b<t;b++){let v=new Float32Array(i*r).fill(-1/0);for(let g=0;g<i;g++){let y=a(b,g);for(let w=0;w<r;w++){let x=g-o[w];if(x<0)continue;let O=-1/0,P=0;for(let T=0;T<dv.length;T++){let S=w-dv[T];if(S<0||S>=r)continue;let k=s[x*r+S]-jie*Math.abs(dv[T]);k>O&&(O=k,P=T)}v[g*r+w]=O+y,c[(b*i+g)*r+w]=P}}s=v}let l=0;for(let b=1;b<i*r;b++)s[b]>s[l]&&(l=b);if(!isFinite(s[l]))return null;let u=s[l]/t,f=Math.floor(l/r),d=l%r,m=new Int32Array(t),p=new Float32Array(t),h=new Float64Array(t);for(let b=t-1;b>=0&&(m[b]=Math.floor(f/10),p[b]=_4[d],h[b]=(f+.5)/10,b!==0);b--){let v=c[(b*i+f)*r+d];f-=o[d],d-=dv[v]}return{frames:m,speeds:p,score:u,pos:h}}function nW(e,t,n){let i=o=>{if(o<=e[0][0])return e[0][1];for(let a=1;a<e.length;a++)if(o<=e[a][0])return e[a-1][1]+(e[a][1]-e[a-1][1])*(o-e[a-1][0])/Math.max(1e-9,e[a][0]-e[a-1][0]);return e[e.length-1][1]},r=new Float64Array(n);r[0]=t;for(let o=1;o<n;o++){let a=[o-1,...e.map(c=>c[0]).filter(c=>c>o-1&&c<o),o],s=0;for(let c=1;c<a.length;c++)s+=(i(a[c-1])+i(a[c]))/2*(a[c]-a[c-1]);r[o]=r[o-1]+s}return r}var Fie=e=>Math.floor(e+.002);function e6(e){let{frames:t,pos:n}=e,i=t.length,r=t[0],o=Array.from({length:i},(l,u)=>u===0?0:n[u]-(u===1?r:n[u-1])),a=o.map((l,u)=>u===0?o[1]:u===i-1?o[u]:(o[u]+o[u+1])/2),s=[[0,a[0]]];for(let l=1;l<i;l++)s.push([l-.5,(4*o[l]-a[l-1]-a[l])/2],[l,a[l]]);let c=l=>{let u=nW(l,r,i);for(let f=0;f<i;f++)if(Fie(u[f])!==t[f])return!1;return!0};if(!c(s))return s;for(let l=s.length-2;l>=1;l--){let u=[...s.slice(0,l),...s.slice(l+1)];c(u)&&(s=u)}return s.map(([l,u])=>[l,Math.round(u*1e4)/1e4])}if(import.meta.main){let n=[],i=20;for(let u=0;u<90;u++)n.push(Math.floor(i)),i+=u<30?1:u<60?.4:1;let r=new Float32Array(18e3);for(let u=0;u<90;u++)for(let f=0;f<200;f++)r[u*200+f]=Math.exp(-((f-n[u])**2)/2)+.05*Math.sin(u*7+f*3);let o=$4(r,90,200),a=n.filter((u,f)=>o.frames[f]===u).length,s=e6(o),c=nW(s,o.frames[0],90),l=n.filter((u,f)=>Math.floor(c[f]+.002)===u).length;if(console.log(`decoded exact ${a}/90; graph ${JSON.stringify(s)} plays back exact ${l}/90`),a<90*.95||l<90*.9)throw new Error("time path self-check failed")}var Iie=16,Ps=1152,mv=()=>Q(vt(),"cache","grids");async function pv(e){let t=await un(e);return Q(mv(),`${te(e)}.${t.size}.${Math.floor(t.mtimeMs)}.g${48}x${24}`)}function Eie(e,t,n){let i=new Float32Array(Ps),r=new Float32Array(Ps);for(let o=0;o<e.h;o++){let a=Math.min(23,o*24/e.h|0)*48;for(let s=0;s<e.w;s++){let c=a+Math.min(47,s*48/e.w|0);i[c]+=e.y[o*e.w+s],r[c]++}}for(let o=0;o<Ps;o++)t[n+o]=Math.round(Iie*i[o]/(r[o]||1))}async function t6(e,t={}){let n=await pv(e);try{let u=await er(n),f=new DataView(u.buffer,u.byteOffset).getUint32(0,!0),d=4+f+1&-2;return{n:f,ok:u.slice(4,4+f),g:new Uint16Array(u.slice(d,d+f*Ps*2).buffer)}}catch{}let i=await wn(await mr.open(e)),r=i.geometrySpec??(i.spec?.codec==="prores"?i.spec:null),o,a,s;if(r){o=i.frames.length,a=new Uint16Array(o*Ps),s=new Uint8Array(o);let u=0;await Promise.all(Array.from({length:64},async()=>{for(;u<o;){t.signal?.throwIfAborted();let f=u++,{offset:d,size:m}=i.frames[f];if(!(m<=0)){try{a.set(await ZV(e,d,m,r,"index",48,24),f*Ps),s[f]=1}catch{}f%500===0&&t.onFrames?.(f)}}}))}else{let u=await fl(e,void 0,t.signal,96);o=u.frames,a=new Uint16Array(o*Ps),s=new Uint8Array(o);for(let f=0;f<o;f++){let d=u.has(f)?await u.read(f):null;d&&(Eie(d,a,f*Ps),s[f]=1)}}let c=4+o+1&-2,l=new Uint8Array(c+a.byteLength);return new DataView(l.buffer).setUint32(0,o,!0),l.set(s,4),l.set(new Uint8Array(a.buffer),c),await bt(mv()),await fr(`${n}.tmp`,l),await Br(`${n}.tmp`,n),{n:o,ok:s,g:a}}async function iW(e,t){try{let n=await er(`${await pv(e)}.f${1}`),i=new DataView(n.buffer,n.byteOffset).getUint32(0,!0);if(i!==t.n)return;let r=n.slice(4).buffer;t.feat={sp:new Uint32Array(r,0,2*i),mp:new Float32Array(r,8*i,32*i),still:new Uint8Array(r,136*i,i)}}catch{}}async function oW(e,t){let n=t.feat;if(!n||n.mp.length!==32*t.n)return;let i=t.n,r=new Uint8Array(4+137*i),o=`${await pv(e)}.f${1}`;new DataView(r.buffer).setUint32(0,i,!0),r.set(new Uint8Array(n.sp.buffer,n.sp.byteOffset,8*i),4),r.set(new Uint8Array(n.mp.buffer,n.mp.byteOffset,128*i),4+8*i),r.set(n.still,4+136*i),await bt(mv()),await fr(`${o}.tmp`,r),await Br(`${o}.tmp`,o)}async function aW(e,t,n,i,r){let o=(await pv(e)).replace(`${mv()}`,Q(vt(),"cache","stars"))+`.s${i}.json`;try{return JSON.parse(new TextDecoder().decode(await er(o)))}catch{}let a=[];for(let s=0;s<t;s+=i){r?.throwIfAborted();let c=await n(s).catch(()=>null);c&&a.push({frame:s,st:av(c,CV).map(([l,u])=>[Math.round(l*4)/4,Math.round(u*4)/4])})}return await bt(Q(vt(),"cache","stars")),await fr(`${o}.tmp`,new TextEncoder().encode(JSON.stringify(a))),await Br(`${o}.tmp`,o),a}var Vie={gap:"Green",unresolved:"Red",contested:"Red",composite:"Yellow",rate:"Yellow",reframe:"Yellow",retime:"Yellow",ambiguous:"Yellow","source-range":"Yellow"},Wie={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"};function Hie(e,t){return e.map((n,i)=>{let r=n.refStart??0,o=n.refEnd!=null&&n.refStart!=null?n.refEnd-n.refStart+1:1;return{id:`conform-marker-${i}`,name:Wie[n.kind]??n.kind.toUpperCase(),color:Vie[n.kind]??"Yellow",kind:null,note:n.message,time:{value:r,rate:t},duration:{value:Math.max(1,o),rate:t},item_id:null,raw_extraction:{},source_element_id:null,metadata:{}}})}function sW(e,t){let n=(e.timelines??[])[0];if(!n||t.length===0)return e;let i=n.fps_den?n.fps_num/n.fps_den:24;return{...e,timelines:[{...n,markers:[...n.markers??[],...Hie(t,i)]},...(e.timelines??[]).slice(1)]}}var Zie=.02,n6=100,Die="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 cW(e){return e&&e.split(/[\\/]/).pop()||null}function Xa(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 lW(e){let t=e,n=(i,r)=>i!=null&&Number.isFinite(i)&&Math.abs(i-r)>1e-6;return n(t.scale,n6)||n(t.scale_x,n6)||n(t.scale_y,n6)||n(t.position_x,0)||n(t.position_y,0)||n(t.rotation,0)}var qie=3;function Uie(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 Cie(e){let n=(e.tracks??[]).filter(i=>i.kind==="Video"&&i.enabled!==!1).sort((i,r)=>i.track_index-r.track_index).filter(i=>(i.items??[]).some(r=>r.kind==="clip"));return{track:n[0]??null,extraVideo:Math.max(0,n.length-1)}}function Jie(e,t,n){return!n||n<=0||!e.length?0:Math.min(...e.map(r=>Xa(r.timeline_range?.start,t)))>=n-1?n:0}function uW(e,t,n={}){let i=[],r=(e.timelines??[]).filter(x=>x.kind!=="compound"),o=(t?r.find(x=>x.name===t):null)??r[0]??(e.timelines??[])[0];if(!o)return{timelineName:"",timelineId:null,startOffset:0,fps:0,frames:0,shots:[],cuts:[],warnings:["no timeline in this file"]};r.length>1&&i.push(`this file holds ${r.length} sequences \u2014 hinting from "${o.name}". If that is not the cut you rendered, the claims below will disagree with the picture everywhere.`);let a=o.fps_den?o.fps_num/o.fps_den:o.fps_num||24,{track:s,extraVideo:c}=Cie(o);if(!s)return{timelineName:o.name,timelineId:o.id??null,startOffset:0,fps:a,frames:o.duration_frames??0,shots:[],cuts:[],warnings:[...i,"no video track with clips \u2014 nothing to hint from"]};let l=n.allTracks?(o.tracks??[]).filter(x=>x.kind==="Video"&&x.enabled!==!1):[s];c>0&&i.push(n.allTracks?`${c} video track(s) above the spine \u2014 their clips are hinted too, each checked against the picture like any other claim.`:`${c} video track(s) above the spine \u2014 ${Die}.`);let u=l.flatMap(x=>x.items??[]).sort((x,O)=>Xa(x.timeline_range?.start,a)-Xa(O.timeline_range?.start,a)),f=Jie(u,a,o.start_frame??0);f>0&&i.push(`item times carry the timeline's start timecode (${f} frames); removed so they line up with a render that begins at its first frame.`);let d=new Map((e.media_references??[]).map(x=>[x.id,x])),m=new Map;for(let x of l)for(let O of x.items??[])m.set(O,x.track_index);let p=[];for(let x of l)for(let O of x.items??[]){if(O.enabled===!1||O.kind!=="clip"||!Uie(O))continue;let P=O.media_reference_id?d.get(O.media_reference_id):void 0;if(P?.content_kind==="still"||/\.(png|webp|tiff?|psd|exr|dpx|gif|jpe?g)$/i.test(P?.target_url??P?.display_name??""))continue;let T=Xa(O.timeline_range?.start,a)-f,S=Xa(O.timeline_range?.duration,a);S>0&&p.push({track:x.track_index,lo:T,hi:T+S-1})}let h=(x,O,P)=>{let T=[[x,O]];for(let S of p)S.track<=P||(T=T.flatMap(([k,L])=>{if(S.hi<k||S.lo>L)return[[k,L]];let z=[];return S.lo>k&&z.push([k,S.lo-1]),S.hi<L&&z.push([S.hi+1,L]),z}));return T.filter(([S,k])=>k-S+1>=qie)},b=[],v=0,g=0,y=0,w=0;for(let x of u){if(x.enabled===!1){g++;continue}if(x.kind==="nested"||x.nested_timeline_id){v++;continue}if(x.kind!=="clip"){y++;continue}let O=Xa(x.timeline_range?.start,a)-f,P=Xa(x.timeline_range?.duration,a);if(P<=0){y++;continue}let T=x.media_reference_id?d.get(x.media_reference_id):void 0,S=cW(T?.local_path)??cW(T?.target_url)??T?.display_name??null,k=x.name??null,L=x.reel_name??T?.reel_name??null;if(!S&&!k&&!L){w++;continue}let z=x.source_range?.start?.rate||a,X=Xa(x.source_range?.start,z),V=Xa(x.source_range?.duration,z),R=P>0&&V>0?V/P:1,j=Math.abs(R-1)>Zie?R:null,J=m.get(x)??0,q=T?.source_timecode?Vp(T.source_timecode,z):null;for(let[W,F]of h(O,O+P-1,J)){let H=Math.round((W-O)*R);b.push({index:b.length,itemId:x.id??null,refStart:W,refEnd:F,clipName:k,reelName:L,sourceFilename:S,srcStart:X+H,srcTimecode:q?q.frames+X+H:null,srcRate:z,srcDropFrame:q?.drop??!1,declaredReframe:lW(x),declaredTransform:lW(x)?{scale:x.scale,scale_x:x.scale_x,scale_y:x.scale_y,position_x:x.position_x,position_y:x.position_y,rotation:x.rotation}:null,declaredSpeed:j})}}return v&&i.push(`${v} 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.`),g&&i.push(`${g} disabled clip(s) ignored.`),y&&i.push(`${y} non-clip item(s) (transitions, gaps) ignored.`),w&&i.push(`${w} 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:o.name,timelineId:o.id??null,startOffset:f,fps:a,frames:o.duration_frames??(b.length?b[b.length-1].refEnd+1:0),shots:b,cuts:[...new Set(b.slice(1).map(x=>x.refStart))].sort((x,O)=>x-O),warnings:i}}import{resolve as Kie,dirname as Gie}from"node:path";import{fileURLToPath as Aie}from"node:url";var dW=Kie(Gie(Aie(import.meta.url)),"../../../../public/sscd/sscd_disc_mixup.288.fp16.onnx"),fW=new Map;function Bie(e=dW){let t=fW.get(e);return t||(t=import("onnxruntime-node").then(n=>n.InferenceSession.create(e,{executionProviders:["cpu"]})),fW.set(e,t)),t}async function hv(e,t=dW,n=288){if(e.length===0)return[];let i=await import("onnxruntime-node"),r=await Bie(t),o=[];for(let a=0;a<e.length;a+=8){let s=e.slice(a,a+8),l=(await r.run({rgb:new i.Tensor("float32",WT(s,n),[s.length,3,n,n])})).embedding,u=l.dims[1],f=l.data;for(let d=0;d<s.length;d++)o.push(f.slice(d*u,(d+1)*u))}return o}var V3e=8*1024*1024;var noe=new Set(["mov","mp4","m4v","r3d","mxf","braw","ari","arx","arri","crm"]),r6=e=>e.split(".").pop()?.toLowerCase()??"",i6=e=>noe.has(r6(e)),mW=new Set(["mov","mp4","m4v"]),bv=e=>(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"").toUpperCase();function pW(e,t){let n=new Set(e.map(t).filter(a=>!mW.has(r6(a))).map(bv)),i=new Set(e.map(t).map(bv)),r=[],o=[];for(let a of e){let s=t(a),c=/^(.*)_TRIM_\d+-\d+$/.exec(bv(s))?.[1];(mW.has(r6(s))&&n.has(bv(s))||c!=null&&i.has(c)?o:r).push(a)}return{kept:r,proxies:o}}var roe=1;async function hW(e,t){try{let n=await un(e);if(!n.isFile)return null;let i=JSON.stringify([roe,e,n.size,Math.round(n.mtimeMs),t.matte,t.stride,t.motion,t.lane]),r=new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)));return Array.from(r.slice(0,16),o=>o.toString(16).padStart(2,"0")).join("")}catch{return null}}var gv=()=>Q(vt(),"cache","pdq"),o6=48;async function bW(e,t){let n=await hW(e,t);if(!n)return null;let i;try{i=await er(Q(gv(),`${n}.pdq`))}catch{return null}try{let r=new DataView(i.buffer,i.byteOffset,i.byteLength),o=r.getUint32(0,!0),a=JSON.parse(new TextDecoder().decode(i.subarray(4,4+o))),s=4+o,c=[];for(let m=0;m<a.frames;m++,s+=o6){let p=r.getFloat64(s+40,!0);c.push({bits:new Uint32Array(i.slice(s,s+32).buffer),quality:r.getFloat64(s+32,!0),...Number.isNaN(p)?{}:{meanY:p}})}let l=a.motion?new Float32Array(i.slice(s,s+a.motion*4).buffer):void 0,{frames:u,motion:f,...d}=a;return{...d,pdq:c,...l?{motion:l}:{}}}catch{return null}}async function gW(e,t,n){let i=await hW(e,t);if(!i)return;let{pdq:r,motion:o,...a}=n,s=new TextEncoder().encode(JSON.stringify({...a,frames:r.length,motion:o?.length??0})),c=new Uint8Array(4+s.length+r.length*o6+(o?.byteLength??0)),l=new DataView(c.buffer);l.setUint32(0,s.length,!0),c.set(s,4);let u=4+s.length;for(let d of r)c.set(new Uint8Array(d.bits.buffer,d.bits.byteOffset,32),u),l.setFloat64(u+32,d.quality??0,!0),l.setFloat64(u+40,d.meanY??NaN,!0),u+=o6;o&&c.set(new Uint8Array(o.buffer,o.byteOffset,o.byteLength),u),await bt(gv()),await Xo(Q(vt(),"cache"),448);let f=Q(gv(),`${i}.${crypto.randomUUID()}.tmp`);await fr(f,c),await Xo(f,384);try{await Br(f,Q(gv(),`${i}.pdq`))}catch{await Vr(f)}}async function Ju(e){let t=e.path;if(!t||!await Wr())return!1;try{return await Ks(t),!0}catch{return!1}}async function Yo(e,t,n={}){let i=await wn(e);if(i.spec&&t!=="os-decoder"){let a=i.spec;return{src:i,frames:i.frames.length,lane:"media-core",luma:async s=>{let c=i.frames[s];if(!c||c.size<=0)return null;try{return await Np(e,c.offset,c.size,a)}catch{return null}}}}let r=e.path;if(!r||!await Wr())throw new Error(`${e.name}: ${i.warnings[0]??"no decoder for this clip"} (H.264/HEVC need the native decoder, conformtools-decode, which is not installed)`);if(n.sparse){let a=la(r,ah);return{src:i,frames:i.frames.length||(await Ks(r)).frames,luma:s=>a.read(s).catch(()=>null),lane:"os-decoder"}}let o=await fl(r);return{src:i,frames:i.frames.length||o.frames,luma:a=>o.read(a),lane:"os-decoder"}}async function Jm(e,t){let n=e.path,i=Math.max(1,Math.floor(t.stride??1)),r=t.lane??await wn(e).then(s=>s.spec?`media-core${"display"in s.spec&&s.spec.display?`+${s.spec.display}`:""}`:"os-decoder").catch(()=>"?"),o={matte:t.matte,stride:i,motion:!!t.motion,lane:r};if(n){let s=await bW(n,o);if(s)return t.onProgress?.(s.pdq.length,s.pdq.length),s}let a=await ioe(e,t);return n&&await gW(n,o,a).catch(()=>{}),a}async function ioe(e,t){let{src:n,frames:i,luma:r,lane:o}=await Yo(e,t.lane,{sparse:(t.stride??1)>1}),a={offs:n.frames.length?n.frames:Array.from({length:i},()=>({offset:0,size:0})),codec:n.index?.codec??n.label,kind:n.spec?n.spec.codec:n.index?.kind??"other",w:n.w,h:n.h,fps:n.fps,startFrame:n.startFrame,dropFrame:n.dropFrame},s=Math.max(1,Math.floor(t.stride??1)),c;if(t.matte==="clip"){let h=[];for(let v of Ca(i,12)){let g=await r(v);g&&h.push({luma:Uint8Array.from(g.y),w:g.w,h:g.h})}let b=h.length?rl(h):null;c=b?Ip(b,h[0].w,h[0].h):void 0}let l=[],u=t.motion&&s===1?new Float32Array(Math.ceil(i/s)):void 0,f=null,d=0,m=Math.ceil(i/s);for(let h=0;h<i;h+=s){if(t.signal?.aborted)throw new Error("cancelled");let b=await r(h);if(!b)l.push({bits:new Uint32Array(8),quality:0,meanY:0}),f=null;else{let v=t.matte==="cut"?qa(b.y,b.w,b.h):c?C7(c,b.w,b.h):null;if(l.push(v?Lr(Ua(b.y,b.w,v),v.w,v.h):Lr(b.y,b.w,b.h)),u&&f&&f.w===b.w&&f.h===b.h){let g=0;for(let y=0;y<b.y.length;y++)g+=Math.abs(b.y[y]-f.y[y]);u[l.length-1]=g/b.y.length}f=b}t.onProgress?.(++d,m)}return{meta:{codec:a.codec,kind:a.kind,label:n.label,w:a.w,h:a.h,fps:a.fps,frames:i,startFrame:a.startFrame,dropFrame:a.dropFrame},index:a,pdq:l,...u?{motion:u}:{},...c?{matte:c}:{},stride:s,lane:o}}var Km=Number(Rt("CONFORM_REFRAMERS")??0)||Math.max(1,Math.min(12,No()-4,Math.floor(Ro()/2**33))),a6=Array(Km).fill(null),Qo=Array(Km).fill(0);function yW(e){return(async()=>{let t=await Wr();if(!t)return null;let n=[],i="",r=DT(t,["reframe-server"],c=>{i+=new TextDecoder().decode(c);let l;for(;(l=i.indexOf(`
173
- `))>=0;){let u=i.slice(0,l);i=i.slice(l+1),n.shift()?.(u)}},Rt("SIZING_DEBUG")?c=>console.error(c.trimEnd()):void 0);r.exited.then(()=>{a6[e]=null;for(let c of n.splice(0))c(JSON.stringify({ok:!1,why:"exited"}))});let o=Promise.resolve(),a=0;return{io:r,ask:(c,l)=>{a++===0&&r.hold(!0);let u=o.then(async()=>{let f=new Promise(d=>n.push(d));return await r.write(new TextEncoder().encode(JSON.stringify(c)+`
174
- `)),l&&await r.write(l),JSON.parse(await f)}).finally(()=>{--a===0&&r.hold(!1)});return o=u.catch(()=>{}),u}}})()}var Gm=new WeakMap,ooe=1;async function vW(e,t,n,i,r,o){let a=Gm.get(n);a||(a=new Map,Gm.set(n,a));let s=`${t}|${o}`,c=a.get(s);if(c)return c;let l=ooe++,u=await e.ask({op:"extract",id:l,w:i,h:r,opts:o},n);if(!u.ok)throw new Error(`reframe-server extract failed: ${JSON.stringify(u)}`);return a.set(s,l),l}function aoe(e,t){let n=Gm.get(e),i=0;for(let r=1;r<Km;r++)Qo[r]<Qo[i]&&(i=r);for(let r=0;r<Km;r++)if(Qo[r]<=Qo[i]&&n?.has(`${r}|${t}`))return r;return i}var soe=async(e,t,n,i,r,o,a)=>{let s=aoe(i,a);Qo[s]++;try{let c=await(a6[s]??=yW(s));if(!c)throw new Error("the native reframe engine is not available");for(let l=0;l<2;l++){let u=await vW(c,s,e,t,n,a),f=await vW(c,s,i,r,o,a),d=await c.ask({op:"match",a:u,b:f,opts:a});if(d.why==="unknown_id"){Gm.delete(e),Gm.delete(i);continue}if(d.ok===!1&&d.why)throw new Error(`reframe-server: ${JSON.stringify(d)}`);return d}throw new Error("reframe-server kept evicting the frames it was asked to match")}finally{Qo[s]--}},coe=async(e,t,n)=>{let i=0;for(let r=1;r<Km;r++)Qo[r]<Qo[i]&&(i=r);Qo[i]++;try{let r=await(a6[i]??=yW(i));if(!r)throw new Error("the native reframe engine is not available");let[o,a,s,c]=[e[0].w,e[0].h,t[0].w,t[0].h],l=new Uint8Array(e.length*(o*a+s*c)),u=0;for(let f of e)l.set(f.y.subarray(0,o*a),u),u+=o*a;for(let f of t)l.set(f.y.subarray(0,s*c),u),u+=s*c;return await r.ask({op:"sizing",n:e.length,sw:o,sh:a,rw:s,rh:c,opts:n},l)}finally{Qo[i]--}};async function wW(){return await Wr()?(ez(soe),e9(coe),!0):!1}var xW=new Map;async function loe(e){let t=await Wr();if(!t)return null;let n=await new Deno.Command(t,{args:["audio",e,"--rate",String(8e3)],stdout:"piped",stderr:"null"}).output();if(!n.success)return null;let i=n.stdout,r=i.indexOf(10);if(r<0||!JSON.parse(new TextDecoder().decode(i.subarray(0,r))).ok)return null;let a=i.subarray(r+1),s=a.length>>1,c=new DataView(a.buffer,a.byteOffset,s*2),l=new Float32Array(s);for(let u=0;u<s;u++)l[u]=c.getInt16(u*2,!0)/32768;return l}async function uoe(e){await oi();let t=await mr.open(e),n=Ws(t),i=JSON.parse(await Wa(n,t.size)||"null");if(!i||i.aac||!i.sample_rate||!i.sample_frames)return null;let r=i.sample_rate,o=i.sample_frames,a=Math.max(1,Math.round(r/8e3)),s=new Float32Array(Math.floor(o/a)),c=0,l=0,u=0,f=r*10;for(let d=0;d<o;d+=f){let m=await Ha(n,t.size,d,Math.min(f,o-d));if(!m||m.length<12)break;let p=new DataView(m.buffer,m.byteOffset,m.byteLength),h=p.getUint32(8,!0),b=p.getUint32(4,!0);if(!h||!b)break;let v=new Float32Array(m.slice(12).buffer,0,h*b);for(let g=0;g<h;g++){let y=0;for(let w=0;w<b;w++)y+=v[g*b+w];l+=y/b,++u===a&&(c<s.length&&(s[c++]=l/a),l=0,u=0)}}return c?s.subarray(0,c):null}var PW=e=>loe(e).then(t=>t??uoe(e)).catch(()=>null),kW=async(e,t)=>{let n=await un(e);return Q(vt(),"cache","pcm",`${te(e)}.${n.size}.${Math.floor(n.mtimeMs)}.${t}`)};async function Ku(e){let t=null;try{t=await kW(e,`r${8e3}`)}catch{return PW(e)}try{let i=await er(t),r=new Int16Array(i.buffer,i.byteOffset,i.length>>1),o=new Float32Array(r.length);for(let a=0;a<r.length;a++)o[a]=r[a]/32767;return o}catch{}let n=await PW(e);if(!n)return null;try{let i=new Int16Array(n.length);for(let r=0;r<i.length;r++)i[r]=Math.max(-32767,Math.min(32767,Math.round(n[r]*32767)));await bt(Q(vt(),"cache","pcm")),await fr(`${t}.tmp`,new Uint8Array(i.buffer)),await Br(`${t}.tmp`,t)}catch{}return n}function SW(e){let t=xW.get(e);return t||(t=Ku(e),xW.set(e,t)),t}async function TW(e){let t=null;try{t=await kW(e,`r${8e3}.lm1`);let r=await er(t),o=new DataView(r.buffer,r.byteOffset).getUint32(0,!0),a=r.slice(4);return{hash:new Uint32Array(a.buffer,0,o),t:new Uint32Array(a.buffer,o*4,o)}}catch{}let n=await Ku(e);if(!n||n.length<8e3)return null;let i=eh(n);if(t)try{let r=new Uint8Array(4+i.hash.length*8);new DataView(r.buffer).setUint32(0,i.hash.length,!0),r.set(new Uint8Array(i.hash.buffer,i.hash.byteOffset,i.hash.byteLength),4),r.set(new Uint8Array(i.t.buffer,i.t.byteOffset,i.t.byteLength),4+i.hash.byteLength),await bt(Q(vt(),"cache","pcm")),await fr(`${t}.tmp`,r),await Br(`${t}.tmp`,t)}catch{}return i}function zW(e,t,n,i,r,o=.05){let a=8e3,s=Math.round(n*a),c=Math.min(Math.round((i-n)*a),4*a);if(c<a/20||s+c>e.length)return null;let l=e.subarray(s,s+c),u=0;for(let b=0;b<c;b++)u+=l[b];u/=c;let f=0;for(let b=0;b<c;b++)f+=(l[b]-u)**2;if(f<1e-9)return null;let d=Math.round(r*a),m=Math.round(o*a),p=-2,h=-1;for(let b=Math.max(0,d-m);b<=Math.min(t.length-c,d+m);b++){let v=0,g=0,y=0;for(let O=0;O<c;O++){let P=t[b+O];v+=(l[O]-u)*P,g+=P,y+=P*P}let w=y-g*g/c,x=v/Math.sqrt(Math.max(w,1e-12)*f);x>p&&(p=x,h=b)}return h<0?null:{clipSec:h/a,ncc:p}}function s6(e,t,n){let i=t*n,r=new Float32Array(i*3);for(let o=0;o<i;o++)r[o*3]=e[o*4]/255,r[o*3+1]=e[o*4+1]/255,r[o*3+2]=e[o*4+2]/255;return{data:r,w:t,h:n}}function ao(e){return e<0?0:e>1?1:e}var c6="srgb";function OW(e){c6=e}function ja(e){return c6==="g24"?Math.pow(Math.max(e,0),2.4):e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function l6(e){return c6==="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 ks(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));if(n>=1)return e;let i=Math.max(1,Math.round(e.w*n)),r=Math.max(1,Math.round(e.h*n)),o=new Float32Array(i*r*3),a=e.w/i,s=e.h/r;for(let c=0;c<r;c++){let l=Math.floor(c*s),u=Math.min(e.h,Math.max(l+1,Math.floor((c+1)*s)));for(let f=0;f<i;f++){let d=Math.floor(f*a),m=Math.min(e.w,Math.max(d+1,Math.floor((f+1)*a))),p=0,h=0,b=0,v=0;for(let y=l;y<u;y++)for(let w=d;w<m;w++){let x=(y*e.w+w)*3;p+=e.data[x],h+=e.data[x+1],b+=e.data[x+2],v++}let g=(c*i+f)*3;o[g]=p/v,o[g+1]=h/v,o[g+2]=b/v}}return{data:o,w:i,h:r}}function u6(e,t,n){if(e.w===t&&e.h===n)return e;let i=new Float32Array(t*n*3);for(let r=0;r<n;r++){let o=Math.min(e.h-1,Math.floor(r*e.h/n));for(let a=0;a<t;a++){let s=Math.min(e.w-1,Math.floor(a*e.w/t)),c=(o*e.w+s)*3,l=(r*t+a)*3;i[l]=e.data[c],i[l+1]=e.data[c+1],i[l+2]=e.data[c+2]}}return{data:i,w:t,h:n}}var gke=Promise.resolve();var foe=.7,doe=.35;function moe(e,t){let n=Math.max(e.x0,t.x0),i=Math.max(e.y0,t.y0),r=Math.min(e.x1,t.x1),o=Math.min(e.y1,t.y1),a=Math.max(0,r-n)*Math.max(0,o-i),s=(e.x1-e.x0)*(e.y1-e.y0)+(t.x1-t.x0)*(t.y1-t.y0);return a/Math.max(s-a,1e-9)}function MW(e,t,n,i=foe){let r=s=>s<0?0:s>1?1:s,o=[];for(let s=0;s<n;s++){let c=e[s*2+1];if(!(c>i))continue;let l=r(t[s*4]),u=r(t[s*4+1]),f=r(t[s*4+2]),d=r(t[s*4+3]);f<=l||d<=u||o.push({x0:l,y0:u,x1:f,y1:d,score:c})}o.sort((s,c)=>c.score-s.score);let a=[];for(let s of o)a.every(c=>moe(s,c)<doe)&&a.push(s);return a}var poe="klein4b-q8",vv="https://pub-ed884bfa772244d89e9b6178f3b8ec9a.r2.dev/klein4b-q8/v1/manifest.json",hoe=["media-gen","mlx.metallib","transformer.safetensors","vae.safetensors","balance.safetensors"],boe=16e9,Gu=()=>Q(vt(),"models",poe);function d6(){return or()!=="darwin"||hf()!=="arm64"?`the local AI colour model runs on Apple Silicon Macs for now (this is ${or()}/${hf()})`:Ro()<boe?`the local AI colour model needs 16 GB of memory (this machine has ${Math.round(Ro()/1e9)} GB)`:null}async function m6(){let e=Rt("CONFORM_AI_MODEL")??Gu(),t=Rt("CONFORM_MEDIA_GEN")??Q(Gu(),"media-gen"),n={runner:t,model:e,preset:Q(e,"balance.safetensors")};for(let i of[t,n.preset,Q(e,"transformer.safetensors"),Q(e,"vae.safetensors")])if(!await Er(i))return null;return n}async function LW(e={}){let t=d6();if(t)throw new Error(t);let n=e.manifestUrl??Rt("CONFORM_AI_PACK_URL")??vv;if(!n)throw new Error("the AI colour model has not been published yet (no pack manifest URL)");let i=await fetch(n);if(!i.ok)throw new Error(`could not read the AI pack manifest (${i.status})`);let r=await i.json(),o=Gu();await bt(o);for(let s of r.files){if(!hoe.includes(s.name))throw new Error(`unexpected file in the AI pack: ${s.name}`);let c=Q(o,s.name);if(await Er(c)&&await yf(c)===s.sha256)continue;let l=0;await Sp(new URL(s.url,n).href,c,(f,d)=>{let m=Math.floor(100*f/(d||s.bytes));m>=l+5&&(l=m,e.onProgress?.(`${s.name} ${m}% of ${(s.bytes/1e9).toFixed(2)} GB`))});let u=await yf(c);if(u!==s.sha256)throw await Vr(c),new Error(`${s.name} failed its checksum (got ${u}); deleted, run again to re-download`);s.name==="media-gen"&&await vf("chmod",["+x",c],()=>{})}let a=await m6();if(!a)throw new Error("the AI pack downloaded but is incomplete");return a}async function RW(e,t,n={}){let i=new Uint8Array(t.w*t.h*3);for(let c=0;c<i.length;c++)i[c]=Math.max(0,Math.min(255,Math.round(t.data[c]*255)));let r=await Mr("conform-ai-"),o=Q(r,"in.rgb");await fr(o,i);let a=[],s=Date.now();try{let c=await vf(e.runner,["balance","--input-rgb",`${o}:${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"],h=>a.push(h));if(c.code!==0)throw new Error(`the AI colour model failed (exit ${c.code}): ${c.stderr.trim().slice(-400)}`);let l=c.stderr.match(/ (\d+)x(\d+) [\d.]+s/);if(!l)throw new Error(`the AI colour model gave no output size: ${c.stderr.trim().slice(-200)}`);let[u,f]=[Number(l[1]),Number(l[2])],d=new Uint8Array(a.reduce((h,b)=>h+b.length,0)),m=0;for(let h of a)d.set(h,m),m+=h.length;if(d.length!==u*f*3)throw new Error(`the AI colour model returned ${d.length} bytes for ${u}x${f}`);let p=new Float32Array(d.length);for(let h=0;h<d.length;h++)p[h]=d[h]/255;return{data:p,w:u,h:f,ms:Date.now()-s}}finally{await Vr(r).catch(()=>{})}}var f6=[.2126,.7152,.0722];function NW(e,t,n=2){let i=(u,f)=>f6[0]*Math.max(0,Math.min(1,u[f]))**2.4+f6[1]*Math.max(0,Math.min(1,u[f+1]))**2.4+f6[2]*Math.max(0,Math.min(1,u[f+2]))**2.4,r=[];for(let u=0;u<e.data.length;u+=3){let f=i(e.data,u);f>1e-5&&Math.max(e.data[u],e.data[u+1],e.data[u+2])<.99&&r.push(Math.log2(Math.max(i(t.data,u),1e-9)/Math.max(f,1e-9)))}if(r.length<64)return{image:t,askedStops:0,appliedStops:0};r.sort((u,f)=>u-f);let o=r.length,a=o%2?r[o-1>>1]:(r[o/2-1]+r[o/2])/2;if(Math.abs(a)<.01)return{image:t,askedStops:a,appliedStops:a};let s=a*Math.exp(-Math.abs(a)/n),c=2**(s-a),l=new Float32Array(t.data.length);for(let u=0;u<l.length;u++)l[u]=Math.min(1,(Math.max(0,Math.min(1,t.data[u]))**2.4*c)**(1/2.4));return{image:{data:l,w:t.w,h:t.h},askedStops:a,appliedStops:s}}var p6="ultraface_rfb640.onnx",goe="a9e7cb5308de493844547e3ffdc4458f68fc81da9672f33f1074ed149db36578";async function voe(){let e=Q(Gu(),p6);if(await Er(e))return e;let t=decodeURIComponent(new URL("../../color-balance-lab/balance-pass/models/"+p6,import.meta.url).pathname);if(await Er(t))return t;if(!vv)return null;try{return await bt(Gu()),await Sp(new URL(p6,vv).href,e,()=>{}),await yf(e)!==goe?(await Vr(e),null):e}catch{return null}}var XW=null,yoe=null;function h6(){return yoe??=import("onnxruntime-node").catch(e=>(console.error(`conformtools: onnxruntime-node unavailable (${e instanceof Error?e.message:e}); face protection and the reframe tier are off`),null))}async function jW(e){let t=await voe();if(!t)return[];let n=await h6();if(!n)return[];XW??=n.InferenceSession.create(t,{executionProviders:["cpu"]});let i=await XW,r=640,o=480,a=u6(ks(e,r),r,o),s=r*o,c=new Float32Array(s*3);for(let d=0;d<s;d++)c[d]=(a.data[d*3]*255-127)/128,c[s+d]=(a.data[d*3+1]*255-127)/128,c[2*s+d]=(a.data[d*3+2]*255-127)/128;let l=await i.run({input:new n.Tensor("float32",c,[1,3,o,r])}),u=l.scores.data,f=l.boxes.data;return MW(u,f,u.length/2)}var woe=6e3;async function xoe(){let e=[Rt("CONFORM_SSCD_MODEL"),Pr(new URL("../../public/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url)),Pr(new URL("../../.qc-scratch/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url)),Pr(new URL("../../../tbd_conformtools/.qc-scratch/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url))].filter(Boolean);for(let t of e)try{if((await un(t)).isFile)return t}catch{}return null}var Poe=async(e,t,n,i=1)=>{let{lane:r,...o}=await Jm(e,{matte:t==="A"?"cut":"none",stride:i,onProgress:n});return o},koe=async(e,t)=>{let{luma:n}=await Yo(e,void 0,{sparse:!0});return async i=>{let r=await n(i);if(!r)return null;let o=t==="A"?qa(r.y,r.w,r.h):null;return o?Lr(Ua(r.y,r.w,o),o.w,o.h):Lr(r.y,r.w,r.h)}};async function Soe(e,t=4e3){let n=[],i=new Set;async function r(a){let s=await Gs(a).catch(()=>[a]);i.has(s[0])||(s.forEach(c=>i.add(c)),n.push(s[0]))}async function o(a,s){if(!(s>10||n.length>=t))for await(let c of dn(a)){if(c.name.startsWith("."))continue;let l=Q(a,c.name);if(c.isDirectory?await o(l,s+1):c.isFile&&i6(c.name)&&await r(l),n.length>=t)return}}for(let a of e)if((await un(a)).isDirectory)await o(a,0);else if(i6(te(a)))await r(a);else throw new Error(`not a conformable media file: ${a}`);return pW(n,a=>a).kept}async function FW(e){await wW(),DV(),o7(v9()),E7(y9()),u7(!!e.display_transform);let t=e.display_transform?"rec709":void 0,n=await Soe(e.pool);if(!n.length)throw new Error("pool is empty \u2014 no mov/mp4/r3d/mxf/braw/ari/crm files found");let i=await mr.open(e.reference),r=await Promise.all(n.map(async z=>{try{let X=await mr.open(z);return{p:z,file:X,luma:await ih(X)}}catch(X){return{p:z,error:X instanceof Error?X.message:String(X)}}})),o=r.filter(z=>"error"in z),a=r.filter(z=>!("error"in z));if(!a.length)throw new Error(`no pool file could be read (${o.length} tried; first: ${o[0]?.error})`);let s=a.map(z=>z.p),c=a.map(z=>z.file),l=e.reframe_tier===!1?null:await xoe(),u=l&&await h6()?l:null;if(e.reframe_tier===!0&&!u)throw new Error("reframe_tier needs the SSCD model: set CONFORM_SSCD_MODEL to sscd_disc_mixup.288.fp16.onnx (exported by .qc-scratch/sscd_export_onnx.py, halved by scripts/sscd/weights_fp16.py)");let f=e.hints?(await GL(e.hints))?.session??e.hints:void 0,d=a.map(z=>z.luma),m=new Map,p=await ih(i),h=new Map;c.forEach((z,X)=>h.set(z,d[X])),h.set(i,p);let b=async(z,X)=>{if(z.frames)return z.frames;let V=X.path;return V?(await Ks(V)).frames:0},v=async(z,X)=>{if(!u)return null;let V=c[z],R=d[z],j=V.path,J=await b(R,V);if(!J)return null;let q=j&&!R.src.geometrySpec&&R.src.index?.kind!=="prores"?await ch(j).catch(()=>null):null,W=q&&q.length>3?q.slice(1).map((Ae,de)=>Ae-q[de]):[],F=W.length&&Math.max(...W)-Math.min(...W)<=1?W[0]:0,H=F>24&&F<=96&&(!X||J>woe),C=H?F:24,$=C===24?0:q[0],oe={model:u,stride:C,geometryWidth:Cs,display:t};if(H&&!X&&j){let Ae=await qm(j,{...oe,stride:24});if(Ae?.length)return{clipIndex:z,label:V.name,stride:24,frames:J,vecs:Ae}}let ye=j?await qm(j,oe):null;if(!ye&&j&&C===24){let Ae=await qm(j,{...oe,stride:wp});Ae?.length===J&&(ye=Array.from({length:Math.ceil(J/24)},(de,Oe)=>Ae[Oe*24]))}if(!ye){let Ae=Array.from({length:Math.ceil((J-$)/C)},(de,Oe)=>$+Oe*C);ye=await iy(R.luma,Ae,{embed:de=>hv(de,u),signal:e.signal}),j&&ye.length&&await K4(j,oe,ye).catch(()=>{})}return{clipIndex:z,label:V.name,stride:C,frames:J,vecs:ye}},g=e.engine??(f?"legacy":"align"),y=new Set,w=new Set,x=[],O=async()=>{let z=()=>{let N=globalThis.Deno?.memoryUsage();return N?` \u2014 rss ${Math.round(N.rss/1048576)} MB, heap ${Math.round(N.heapUsed/1048576)}, external ${Math.round(N.external/1048576)}`:""},X=performance.now(),V=N=>{globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[time] ${N} ${((performance.now()-X)/1e3).toFixed(1)} s \u2014 ${Js.runs} decodes, ${Js.frames} frames (${Js.unique} distinct)${z()}`)},R=c.map((N,me)=>me).sort((N,me)=>c[N].name.localeCompare(c[me].name)),j=0,J=Promise.all([0,1].map(async()=>{for(;j<R.length;)await Ku(s[R[j++]])})).catch(()=>{}),q=0,W=R.length+1,F=new Array(R.length),H=0,C=t6(e.reference,{signal:e.signal});await Promise.all(Array.from({length:4},async()=>{for(;H<R.length;){let N=H++;F[N]=await t6(s[R[N]],{signal:e.signal}).catch(()=>({n:0,ok:new Uint8Array(0),g:new Uint16Array(0)})),await iW(s[R[N]],F[N]),e.onProgress?.(++q,W,"index")}}));let $=await C;e.onProgress?.(W,W,"index");let oe=async N=>{let me=await wn(N);return{fps:me.fps,start:me.startFrame,drop:me.dropFrame,n:me.frames.length,w:me.w,h:me.h,codec:me.label}},ye=await oe(i),Ae=await Promise.all(R.map(N=>oe(c[N]).then(me=>me.fps).catch(()=>ye.fps))),de=Ae.map(N=>N&&ye.fps?N/ye.fps:1);V("grids");let Oe=F.map(N=>!!N.feat),Ze=Y4($,F,{onProgress:e.onProgress,rates:de});await Promise.all(F.map((N,me)=>Oe[me]?null:oW(s[R[me]],N).catch(()=>{}))),V("align"),await(async N=>{let me=0,He=0;await Promise.all(Array.from({length:8},async()=>{for(;me<N.length;){let Ke=N[me++];e.signal?.throwIfAborted(),e.onProgress?.(He++,N.length,"align: confirming");let ht=Ni(Ke.refStart,Ke.refEnd,4),De=await Promise.all(ht.map(st=>p.luma(st))),gt=null;for(let st of Ke.candidates){let Qe=d[R[st.clip]],$e=de[st.clip],wt=(await Promise.all(ht.map(async(Bt,It)=>{let zn=await Qe.luma(st.srcStart+Math.floor((Bt-Ke.refStart)*$e+.001));return zn&&De[It]?{src:zn,ref:De[It]}:null}))).filter(Bt=>!!Bt),nn=st.scale>0&&st.scale!==1?{min_scale:st.scale/1.2,max_scale:st.scale*1.2}:{},kt=wt.length>=2?await Ri(wt,{turns:!1,...nn}).catch(()=>null):null;kt&&(!gt||kt.score>gt.score)&&(gt={c:st,score:kt.score})}gt&&gt.score>=.4&&(Ke.clip=gt.c.clip,Ke.srcStart=gt.c.srcStart,Ke.srcEnd=gt.c.srcStart+Math.floor((Ke.refEnd-Ke.refStart)*de[gt.c.clip]+.001),Ke.rot180=Ke.rot180&&gt.c.scale===1,Ke.sure=gt.score>=.55)}}))})(Ze.filter(N=>(N.candidates?.length??0)>1)),V("confirm");let ze=640,Re=Math.round(ze*(ye.h||9)/(ye.w||16)),yt=8,rt=.002,zt=.5,qt=12,Ot=.01,pt=.6,_=.006,pe=12,Ne=.5,nt=160,dt=Math.round(nt*(ye.h||9)/(ye.w||16)),Kt=.6,Xt=72,At=12,on=N=>{if(!N)return null;let me=0,He=0;for(let ht of N)me+=ht;me/=N.length;for(let ht of N)He+=(ht-me)**2;let Ke=Math.sqrt(He/N.length)||1;return N.map(ht=>(ht-me)/Ke)},Be=N=>N.slice(1).map((me,He)=>{let Ke=N[He];if(!me||!Ke||me.length!==Ke.length)return NaN;let ht=0;for(let De=0;De<me.length;De++)ht+=Math.abs(me[De]-Ke[De]);return ht/me.length}),at=(N,me)=>{let He=N.map((Qe,$e)=>$e).filter(Qe=>isFinite(N[Qe])&&isFinite(me[Qe]));if(He.length<4)return-2;let Ke=0,ht=0;for(let Qe of He)Ke+=N[Qe],ht+=me[Qe];Ke/=He.length,ht/=He.length;let De=0,gt=0,st=0;for(let Qe of He)De+=(N[Qe]-Ke)*(me[Qe]-ht),gt+=(N[Qe]-Ke)**2,st+=(me[Qe]-ht)**2;return De/Math.sqrt(gt*st||1)},jt=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS,an=new Map,Nn=N=>{let me=an.get(N);return me||(me=p.luma(N).then(He=>Io(Wn(He,ze,Re),ze)).catch(()=>null),an.set(N,me)),me},Tn={n:0,ms:0},Ut=new Map,Or=new Set,lr=new Set,co=async(N,me=!1,He=qt,Ke=!1)=>{let ht=N.refEnd-N.refStart+1;if(N.clip<0||ht<2)return;let De=d[R[N.clip]],gt=de[N.clip],st=F[N.clip].n,Qe=gt,$e,wt=(Xe,tt)=>Xe+Math.floor((tt-N.refStart)*Qe+.001),nn=Xe=>De.luma(Xe).then(tt=>tt&&N.rot180?{...tt,y:tt.y.slice().reverse()}:tt).catch(()=>null),kt=Math.min(yt,ht),Bt=Array.from({length:kt},(Xe,tt)=>N.refStart+Math.round((tt+.5)*ht/kt-.5)),It=await Promise.all(Bt.map(Nn)),zn=async(Xe,tt)=>{let _e=(await Promise.all(tt.map(async bn=>{let[gn,tn]=await Promise.all([p.luma(bn),nn(wt(Xe,bn))]);return gn&&tn?{ref:gn,src:tn}:null}))).filter(bn=>!!bn),Ft=performance.now(),Ct=$e?{min_scale:$e/1.08,max_scale:$e*1.08}:{},kn=_e.length>=3?await Ri(_e,{...me?{}:{turns:!1},...Ct}).catch(()=>null):null;kn&&!$e&&($e=kn.scale_fit),Tn.n++,Tn.ms+=performance.now()-Ft;let fn=kn?fo(kn.transform):null;return fn?{inv:fn,w:_e[0].ref.w,h:_e[0].ref.h,sw:_e[0].src.w,sh:_e[0].src.h}:null},qn=Xe=>[Xe-1,Xe,Xe+1].filter(tt=>tt>=N.refStart&&tt<=N.refEnd).concat(Xe===N.refStart?[Xe+2]:Xe===N.refEnd?[Xe-2]:[]),ur=async(Xe,tt,_e)=>{let Ft=Bt.map(tn=>wt(Xe,tn));if(Ft[0]<0||Ft[kt-1]>=st)return null;let Ct=await Promise.all(Ft.map(nn)),kn=_e!==void 0?_e:tt?await zn(Xe,Ni(N.refStart,N.refEnd,6)):null,fn=tt&&_e===void 0?await Promise.all(Bt.map(tn=>zn(Xe,qn(tn)))):null,bn=[()=>null];kn&&bn.push(()=>kn),fn?.every(Boolean)&&bn.push(tn=>fn[tn]);let gn=[];for(let tn of bn){let Ir=0,Dt=0;for(let sn=0;sn<kt;sn++){let xr=tn(sn),An=Io(xr?vi(Ct[sn],xr.inv,xr.w,xr.h,ze,Re):Wn(Ct[sn],ze,Re),ze);It[sn]&&An&&(Ir+=Ap(It[sn],An),Dt++)}gn.push(Dt>=Math.max(1,kt>>1)?Ir/Dt:-1/0)}return gn};{if(ht>=At){let Ft=Math.max(0,wt(N.srcStart,N.refStart)-He),Ct=Math.min(st-1,wt(N.srcStart,N.refEnd)+He);await Promise.all(Array.from({length:Ct-Ft+1},(kn,fn)=>nn(Ft+fn)))}let Xe=(await ur(N.srcStart,!1))?.[0]??-1/0,tt=!!N.reframed||Xe<zt,_e=tt?await zn(N.srcStart,Ni(N.refStart,N.refEnd,6)):null;if((!tt||_e)&&ht>=At){let Ft=Array.from({length:ht},(Dt,sn)=>N.refStart+sn),Ct=Be(await Promise.all(Ft.map(Dt=>p.luma(Dt).then(sn=>on(Wn(sn,nt,dt))).catch(()=>null)))),kn=new Map,fn=Dt=>kn.get(Dt)??kn.set(Dt,Dt<0||Dt>=st?Promise.resolve(null):nn(Dt).then(sn=>on(_e?vi(sn,_e.inv,_e.w,_e.h,nt,dt):Wn(sn,nt,dt)))).get(Dt),bn=async(Dt,sn)=>{let xr={s:sn,r:-2};for(let An=-He;An<=He;An++){let nr=at(Ct,Be(await Promise.all(Ft.map(Cr=>fn(sn+An+Math.floor((Cr-N.refStart)*Dt+.001))))));nr>xr.r&&(xr={s:sn+An,r:nr})}return xr},gn={s:N.srcStart,e:N.srcEnd,slope:N.slope},tn=await bn(gt,N.srcStart),Ir=!1;if(Math.abs(gt-1)>.01){let Dt=Bt[kt>>1],sn=await bn(1,wt(N.srcStart,Dt)-(Dt-N.refStart));sn.r>tn.r+Ot&&(tn=sn,Ir=!0)}jt&&console.error(`[motion] ${N.refStart}-${N.refEnd} @${N.srcStart} \u2192 ${tn.s}${Ir?" frame for frame":""} r=${tn.r.toFixed(3)}${_e?" sized":""}`),tn.r>=Kt&&(Ir&&(Qe=1,N.slope=1),N.srcStart=tn.s,N.srcEnd=Ir?tn.s+(ht-1):tn.s+Math.floor((ht-1)*gt+.001));{let Dt=Be(await Promise.all(Ft.map(An=>fn(wt(N.srcStart,An))))),sn=(An,nr)=>{let Cr=An.slice(Math.max(0,nr-6),nr+7).filter((Jr,Mo)=>isFinite(Jr)&&Mo!==Math.min(nr,6)).sort((Jr,Mo)=>Jr-Mo);return An[nr]/(Cr[Cr.length>>1]||1e-6)},xr=Ct.flatMap((An,nr)=>{let Cr=sn(Ct,nr);return Cr>=2.5&&An-An/Cr>.01&&!(sn(Dt,nr)>Cr/2)?[N.refStart+nr+1]:[]}).filter(An=>An-N.refStart>=3&&N.refEnd-An>=2);if(xr.length&&He===qt){let An=[...xr,N.refEnd+1],nr=[],Cr=N.refStart;for(let Jr of An){if(Cr===N.refStart)N.refEnd=Jr-1,N.srcEnd=wt(N.srcStart,Jr-1),nr.push(N);else{let Mo={...N,refStart:Cr,refEnd:Jr-1,srcStart:wt(N.srcStart,Cr),candidates:void 0};Mo.srcEnd=Mo.srcStart+Math.floor((Jr-1-Cr)*Qe+.001),Ze.push(Mo),nr.push(Mo)}Cr=Jr}jt&&console.error(`[motion] jump cuts at ${xr.join(" ")}`);for(let Jr of nr)await co(Jr,me,Jr.refEnd-Jr.refStart+1>=At?Xt:3);return}}if(tn.r>=Kt){_e?$e&&m.set(N.refStart,$e):m.set(N.refStart,1);let Dt=async nr=>{let Cr=_e?await zn(N.srcStart+nr,Ni(N.refStart,N.refEnd,6))??_e:null,Jr=await ur(N.srcStart+nr,!1,Cr);return Jr?Math.max(...Jr):-1/0},[sn,xr,An]=await Promise.all([Dt(-1),Dt(0),Dt(1)]);if(!_e||Math.max(sn,xr,An)>=pt){let nr=sn>xr+rt&&sn>=An?-1:An>xr+rt?1:0;nr&&(N.srcStart+=nr,N.srcEnd+=nr),Ut.set(N,Math.max(sn,xr,An));return}N.srcStart=gn.s,N.srcEnd=gn.e,N.slope=gn.slope,Qe=gt}if(_e&&!Ke){let Dt=await ur(N.srcStart,!1,_e),sn=Dt?Math.max(...Dt):0;if(sn<pt){Ut.set(N,sn),Or.add(N);return}}}}let Lt=[-2,-1,0,1,2],tr=Xe=>Promise.all(Lt.map(tt=>ur(N.srcStart+tt,Xe))),gr=await tr(!!N.reframed);!N.reframed&&(gr[2]?.[0]??0)<zt&&(gr=await tr(!0));let Gn=Lt.map((Xe,tt)=>[Xe,gr[tt]?Math.max(...gr[tt]):null]).filter(Xe=>Xe[1]!=null&&Xe[1]>-1/0),hn=Gn.find(([Xe])=>Xe===0)?.[1];if(Gn.length>=3&&Math.max(...Gn.map(Xe=>Xe[1]))-Math.min(...Gn.map(Xe=>Xe[1]))<_?lr.add(N):lr.delete(N),jt&&console.error(`[exact] ${N.refStart}-${N.refEnd} @${N.srcStart}: ${Lt.map((Xe,tt)=>`${Xe}:${gr[tt]?.map(_e=>_e.toFixed(3)).join("/")}`).join(" ")}`),hn==null)return;let en=Gn.reduce((Xe,tt)=>tt[1]>Xe[1]?tt:Xe),ft=!!N.reframed||gr.some(Xe=>(Xe?.length??0)>1);for(let Xe=en[0]+Math.sign(en[0]);Math.abs(en[0])===Math.abs(Xe)-1&&Math.abs(Xe)<=qt&&Math.abs(en[0])>=2;Xe+=Math.sign(Xe)){let tt=await ur(N.srcStart+Xe,ft),_e=tt?Math.max(...tt):-1/0;if(_e>en[1])en=[Xe,_e];else break}if(Math.abs(gt-1)>.01){let Xe=Bt[kt>>1],tt=wt(N.srcStart+en[0],Xe);Qe=1;let _e=tt-(Xe-N.refStart),Ft=!1;for(let Ct=-2;Ct<=2;Ct++){let kn=await ur(_e+Ct,ft),fn=kn?Math.max(...kn):-1/0;fn>en[1]+Ot&&(en=[_e+Ct-N.srcStart,fn],Ft=!0)}jt&&console.error(`[exact] frame for frame: ${Ft?`wins at ${N.srcStart+en[0]} ${en[1].toFixed(3)}`:"no"}`),Ft?(N.slope=1,N.srcEnd=N.srcStart+en[0]+(ht-1)):Qe=gt}en[0]!==0&&en[1]>hn+rt&&(N.srcStart+=en[0],N.slope==null&&(N.srcEnd+=en[0])),Ut.set(N,Math.max(en[1],hn))},Ee=async(N,me=!1,He=!1)=>{let Ke=0,ht=0;await Promise.all(Array.from({length:8},async()=>{for(;Ke<N.length;)e.signal?.throwIfAborted(),await co(N[Ke++],me,qt,He),e.onProgress?.(++ht,N.length,"align: exact frame")}))};await Ee(Ze.filter(N=>N.clip>=0)),Ze.sort((N,me)=>N.refStart-me.refStart),V(`exact (${Tn.n} fits, ${(Tn.ms/1e3).toFixed(1)} s summed)`);let Kn=Ze.filter(N=>N.clip>=0&&N.refEnd-N.refStart>=3&&(Ut.get(N)??1)<pt);if(Kn.length){let N=new Dm,me=0;await Promise.all([0,1].map(async()=>{for(;me<R.length;){let De=me++,gt=R[De],st=await aW(s[gt],F[De].n,$e=>d[gt].luma($e),pe,e.signal).catch(()=>[]),Qe=(await Promise.all(Array.from({length:Math.ceil(st.length/64)},($e,wt)=>AV(st.slice(wt*64,wt*64+64).map(nn=>nn.st))))).flat();st.forEach(($e,wt)=>N.add(De,$e.frame,$e.st,Qe[wt]))}})),BV(),V(`star catalogue (${N.size} frames)`);let He=new Set,Ke=[],ht=[];for(let De of Kn){let gt=De.refStart+De.refEnd>>1,st=N.find(await p.luma(gt).catch(()=>null));if(ht.push(`${De.refStart}-${De.refEnd}:${Ut.get(De).toFixed(2)}${st?` ${st.clip}@${st.frame} ${(st.inl*100).toFixed(0)}% \xD7${st.scale.toFixed(2)} ${st.rot.toFixed(1)}\xB0${st.flip?" flop":""}`:""}`),!st||st.inl<Ne)continue;let Qe=Math.abs(st.rot)>90;(Math.abs(Qe?180-Math.abs(st.rot):st.rot)>1||st.flip)&&He.add(De);let wt=nn=>Math.floor((gt-De.refStart)*de[nn]+.001);st.clip===De.clip&&Math.abs(De.srcStart+wt(De.clip)-st.frame)<=pe||(De.clip=st.clip,De.srcStart=Math.max(0,st.frame-wt(st.clip)),De.srcEnd=De.srcStart+Math.floor((De.refEnd-De.refStart)*de[st.clip]+.001),De.slope=void 0,De.rot180=Qe,De.reframed=st.scale>1.03||He.has(De)?st.scale:void 0,De.sure=!0,Ke.push(De))}jt&&console.error(`[weak] ${Kn.length} weak shots, plate solved: ${ht.join(" | ")}; moved ${Ke.map(De=>De.refStart).join(" ")}; turned ${[...He].map(De=>De.refStart).join(" ")}`),await Ee(Ke.filter(De=>!He.has(De))),await Ee([...He],!0),await Ee(Kn.filter(De=>Or.has(De)&&!Ke.includes(De)&&!He.has(De)),!1,!0)}V("weak shots");let Zi=8,$o=3,Qc=12,up=2,fp=.9,Z=.95,re=.9,fe=[];for(let N=0;N<Ze.length;N++){let me=Ze[N];if(me.clip<0||me.refEnd-me.refStart+1>Zi)continue;let He=N;for(;He+1<Ze.length;){let De=Ze[He],gt=Ze[He+1];if(gt.clip!==me.clip||gt.refStart!==De.refEnd+1||gt.refEnd-gt.refStart+1>Zi||gt.srcStart<De.srcStart-up)break;He++}let Ke=Ze[He];if(He-N+1<$o||Ke.refEnd-me.refStart+1<Qc||Ke.srcStart<=me.srcStart)continue;let ht=(Ke.srcStart-me.srcStart)/Math.max(1,Ke.refStart-me.refStart);if(!(ht>fp*de[me.clip])){fe.push(`${me.refStart}-${Ke.refEnd} ${He-N+1} pieces @${me.srcStart}\u2192${Ke.srcStart} (${(ht/de[me.clip]*100).toFixed(0)} %)`),Object.assign(me,{refEnd:Ke.refEnd,srcEnd:me.srcStart+Math.floor((Ke.refEnd-me.refStart)*ht+.001),slope:ht,sure:!1});for(let De of Ze.slice(N+1,He+1))Ut.delete(De),Or.delete(De),lr.delete(De);Ze.splice(N+1,He-N),Ut.set(me,0)}}jt&&fe.length&&console.error(`[merge] ${fe.join(" | ")}`);let xe=128,Y=Math.round(xe*(ye.h||9)/(ye.w||16)),le=48,Fe=.02,mt=.9,We=256,xt=Math.round(We*(ye.h||9)/(ye.w||16)),Je=24,qe=.02,St=.2,$t=N=>N?lv(Io(N,xe)):null,Ht=[],be=new Set;for(let N of Ze.filter(me=>me.clip>=0&&me.refEnd-me.refStart>=7&&(Ut.get(me)??1)<mt)){e.signal?.throwIfAborted();let me=N.refEnd-N.refStart+1,He=de[N.clip],Ke=N.slope??He,ht=d[R[N.clip]],De=F[N.clip].n,gt=hn=>ht.luma(hn).then(en=>en&&N.rot180?{...en,y:en.y.slice().reverse()}:en).catch(()=>null),st=Ni(N.refStart,N.refEnd,6),Qe=(await Promise.all(st.map(async hn=>{let[en,ft]=await Promise.all([p.luma(hn).catch(()=>null),gt(N.srcStart+Math.floor((hn-N.refStart)*Ke+.001))]);return en&&ft?{ref:en,src:ft}:null}))).filter(hn=>!!hn),$e=Qe.length>=3?await Ri(Qe,N.reframed?{min_scale:N.reframed/1.2,max_scale:N.reframed*1.2}:{}).catch(()=>null):null,wt=$e?fo($e.transform):null,nn=Math.max(0,N.srcStart-Math.ceil(2*me*He)-24),kt=Math.min(De-1,N.srcStart+Math.ceil(5*me*He)+24),Bt=Math.ceil(me/le),It=Array.from({length:Math.ceil(me/Bt)},(hn,en)=>en*Bt),zn=await Promise.all(It.map(hn=>p.luma(N.refStart+hn).then(en=>$t(Wn(en,xe,Y))).catch(()=>null))),qn=await Promise.all(Array.from({length:kt-nn+1},(hn,en)=>gt(nn+en).then(ft=>[$t(Wn(ft,xe,Y)),wt&&Qe.length?$t(vi(ft,wt,Qe[0].ref.w,Qe[0].ref.h,xe,Y)):null]))),Lt=[Q4(zn,It,qn.map(hn=>hn[0]),He),wt?Q4(zn,It,qn.map(hn=>hn[1]),He):null].reduce((hn,en)=>en&&(!hn||en.score>hn.score)?en:hn,null);if(!Lt)continue;let tr=Lt.scoreOf(Ke,N.srcStart-nn),gr=c[R[N.clip]].name;Ht.push(`${N.refStart}-${N.refEnd}@${N.srcStart}: ${Lt.speed.toFixed(3)}\xD7@${nn+Lt.start} ${Lt.score.toFixed(3)} (now ${tr.toFixed(3)}) margin ${Lt.margin.toFixed(2)}`),Lt.observable&&Lt.score>tr+Fe&&(N.srcStart=nn+Lt.start,N.slope=Lt.speed,N.srcEnd=N.srcStart+Math.floor((me-1)*Lt.speed+.001)),Lt.observable&&Lt.score>=Z&&(N.slope??He)<fp*He&&be.add(N);let Gn=!1;if(me>=Je&&$e&&$e.score>=Nf){let hn=fn=>{let bn=wt&&Qe.length?vi(fn,wt,Qe[0].ref.w,Qe[0].ref.h,We,xt):Wn(fn,We,xt);return bn?lv(Io(bn,We)):null},en=await Promise.all(Array.from({length:me},(fn,bn)=>p.luma(N.refStart+bn).then(gn=>{let tn=Wn(gn,We,xt);return tn?lv(Io(tn,We)):null}).catch(()=>null))),ft=await Promise.all(Array.from({length:kt-nn+1},(fn,bn)=>gt(nn+bn).then(gn=>gn?hn(gn):null))),Xe=ft.length,tt=new Float32Array(me*Xe).fill(NaN);for(let fn=0;fn<me;fn++){let bn=en[fn];if(bn)for(let gn=0;gn<Xe;gn++){let tn=ft[gn];if(!tn)continue;let Ir=0;for(let Dt=0;Dt<bn.length;Dt++)Ir+=bn[Dt]*tn[Dt];tt[fn*Xe+gn]=Ir}}let _e=$4(tt,me,Xe),Ft=(()=>{let fn=N.slope??He,bn=0,gn=0;for(let tn=0;tn<me;tn++){let Ir=N.srcStart-nn+Math.floor(tn*fn+.001),Dt=Ir>=0&&Ir<Xe?tt[tn*Xe+Ir]:NaN;Dt===Dt&&(bn+=Dt,gn++)}return gn?bn/gn:-1})(),Ct=_e?_e.frames.reduce((fn,bn,gn)=>{let tn=tt[gn*Xe+bn];return tn===tn?fn+tn:fn},0)/me:-1,kn=_e?Math.max(..._e.speeds)-Math.min(..._e.speeds):0;if(Ht.push(` ramp? path ${Ct.toFixed(3)} vs line ${Ft.toFixed(3)}, speeds ${_e?`${Math.min(..._e.speeds)}\u2013${Math.max(..._e.speeds)}`:"-"}`),_e&&Ct>Ft+qe&&kn>=St){let fn=e6(_e);Object.assign(N,{srcStart:nn+_e.frames[0],srcEnd:nn+_e.frames[me-1],slope:void 0,ramp:fn.map(([bn,gn])=>[bn,gn/He*100])}),Gn=!0}}!Lt.observable&&!Gn&&x.push({kind:"speed_unobservable",refStart:N.refStart,refEnd:N.refEnd,message:`${gr}: too little motion to confirm this shot's moment and speed from the picture \u2014 check it against the reference.`})}jt&&Ht.length&&console.error(`[line] ${Ht.join(" | ")}`);let Ye=[],Ue=(N,me)=>{let He=0;for(let Ke=0;Ke<N.length;Ke++)He+=N[Ke]*me[Ke];return He};for(let N of be){let me=de[N.clip],He=N.slope??me,Ke=d[R[N.clip]],ht=F[N.clip].n,De=[N.refStart,N.refEnd],gt=st=>N.srcStart+Math.floor((st-N.refStart)*He+.001);for(let st of[-1,1])for(;;){e.signal?.throwIfAborted();let Qe=Ze.indexOf(N),$e=Ze[Qe+st];if(!$e||(st<0?$e.refEnd!==N.refStart-1:$e.refStart!==N.refEnd+1)||$e.clip>=0&&($e.refEnd-$e.refStart+1>Zi||$e.ramp||$e.sure&&(Ut.get($e)??1)>=mt))break;let wt=0,nn=0,kt=!1;for(let zn=$e.refStart;zn<=$e.refEnd;zn++){let qn=gt(zn);if(qn<0||qn>=ht){kt=!0;break}let[ur,Lt]=await Promise.all([p.luma(zn).then(tr=>$t(Wn(tr,xe,Y))).catch(()=>null),Ke.luma(qn).then(tr=>$t(Wn(tr&&N.rot180?{...tr,y:tr.y.slice().reverse()}:tr,xe,Y))).catch(()=>null)]);ur&&Lt&&(wt+=Ue(ur,Lt),nn++)}if(kt||!nn||wt/nn<re)break;if(st>0){N.refEnd=$e.refEnd,N.srcEnd=N.srcStart+Math.floor((N.refEnd-N.refStart)*He+.001),Ut.delete($e),Or.delete($e),lr.delete($e),Ze.splice(Ze.indexOf($e),1);continue}let Bt=N.refStart-$e.refStart,It=Bt;for(;It>0&&Math.abs(It*He-Math.round(It*He))>1e-6;)It--;if(It===0&&(It=Bt),N.srcStart-=Math.round(It*He),N.refStart-=It,N.srcEnd=N.srcStart+Math.floor((N.refEnd-N.refStart)*He+.001),It===Bt)Ut.delete($e),Or.delete($e),lr.delete($e),Ze.splice(Ze.indexOf($e),1);else{$e.refEnd=N.refStart-1;break}}(N.refStart!==De[0]||N.refEnd!==De[1])&&Ye.push(`${De[0]}-${De[1]} \u2192 ${N.refStart}-${N.refEnd} @${N.srcStart} ${(He/me*100).toFixed(0)} %`)}jt&&Ye.length&&console.error(`[grow] ${Ye.join(" | ")}`),V("speed line");let pn=.9,En=await Ku(e.reference_audio??e.reference),Ce=Ze.filter(N=>N.refEnd-N.refStart>=2&&(N.clip<0||(Ut.get(N)??1)<mt||lr.has(N)));if(En&&En.length>=8e3&&Ce.length){await J;let N=new Ka,me=Ka.reference(En),He=Qe=>Ku(s[R[Qe]]),Ke=Math.max(1,Math.min(6,No()>>1)),ht=[];for(let Qe=0;Qe<R.length;Qe++){for(let wt=ht.length;wt<Math.min(R.length,Qe+Ke);wt++)ht[wt]=TW(s[R[wt]]);let $e=await ht[Qe];delete ht[Qe],$e&&N.addMarks(Qe,$e)}let De=new Map,gt=Qe=>{let $e=De.get(Qe);return $e?(De.delete(Qe),De.set(Qe,$e),$e):($e=He(Qe),De.set(Qe,$e),De.size>8&&De.delete(De.keys().next().value),$e)},st=[];for(let Qe of Ce){e.signal?.throwIfAborted();let $e=Qe.refStart/ye.fps,wt=(Qe.refEnd+1)/ye.fps,nn=($e+wt)/2,[kt,Bt]=wt-$e<1?[Math.max(0,nn-.5),nn+.5]:[$e,wt],It=null,zn=wt-$e<1?[...N.nominate(me,$e,wt,5),...N.nominate(me,kt,Bt,5)]:N.nominate(me,kt,Bt,5);for(let Lt of zn){let tr=await gt(Lt.clip),gr=tr?zW(En,tr,$e,wt,$e+Lt.shiftSec):null;gr&&gr.ncc>=pn&&(!It||gr.ncc>It.ncc)&&(It={k:Lt.clip,...gr})}if(!It)continue;let qn=Math.round(It.clipSec*Ae[It.k]);if(Qe.clip>=0&&(Ut.get(Qe)??1)>=mt&&(It.k!==Qe.clip||Math.abs(qn-Qe.srcStart)>Xt))continue;let ur=Qe.clip<0?"gap":`${c[R[Qe.clip]].name}@${Qe.srcStart}`;st.push(`${Qe.refStart}-${Qe.refEnd} ${ur} \u2192 ${c[R[It.k]].name}@${qn} ncc ${It.ncc.toFixed(3)}`),Object.assign(Qe,{clip:It.k,srcStart:qn,srcEnd:qn+Math.floor((Qe.refEnd-Qe.refStart)*de[It.k]+.001),slope:void 0,ramp:void 0,sure:!0,rot180:!1}),w.add(Qe.refStart)}jt&&st.length&&console.error(`[sound] ${st.join(" | ")}`)}V("sound");let Pn=6;Ze.sort((N,me)=>N.refStart-me.refStart);for(let N=0;N<Ze.length;N++){let me=Ze[N];if(me.clip<0)continue;let He=N+1;for(;He<Ze.length&&Ze[He].clip<0;)He++;let Ke=Ze[He];if(!Ke||Ke.clip!==me.clip||!!Ke.rot180!=!!me.rot180||(me.slope??de[me.clip])!==(Ke.slope??de[Ke.clip]))continue;let ht=Ke.refStart-me.refEnd-1,De=me.slope??de[me.clip];ht<1||ht>Pn||Ke.srcStart!==me.srcStart+Math.floor((Ke.refStart-me.refStart)*De+.001)||(me.refEnd=Ke.refEnd,me.srcEnd=Ke.srcEnd,Ze.splice(N+1,He-N),N--)}let $n=[...new Set(Ze.filter(N=>N.clip>=0).map(N=>R[N.clip]))],Fr=await Promise.all($n.map(async N=>{let me=await oe(c[N]);return{clipIndex:N,label:c[N].name,shots:[],coverage:0,srcFps:me.fps,srcStartFrame:me.start,srcFrames:me.n||F[R.indexOf(N)].n,srcW:me.w,srcH:me.h,codec:me.codec,warnings:[]}})),Xn=Ze.map(N=>{if(N.clip<0)return{refStart:N.refStart,refEnd:N.refEnd,kind:"gap"};let me=c[R[N.clip]].name;N.rot180&&y.add(N.refStart),N.sure||x.push({kind:"ambiguous",refStart:N.refStart,refEnd:N.refEnd,message:`${me}: in-point uncertain \u2014 aligner confidence ${N.conf.toFixed(2)}; check this shot against the reference.`});let He=de[N.clip],Ke=N.slope!=null&&Math.abs(N.slope/He-1)>.005?{slope:N.slope/He,percent:N.slope/He*100,kind:"retime",samples:yt,residual:0,basis:"frame-for-frame"}:void 0,ht=N.ramp;return{refStart:N.refStart,refEnd:N.refEnd,kind:"static",clipLabel:me,srcStart:N.srcStart,srcEnd:N.srcEnd,...ht?{ramp:ht}:Ke?{speed:Ke}:{}}});return{refFps:ye.fps,refStartFrame:ye.start,refFrames:$.n,refDropFrame:ye.drop,refW:ye.w,refH:ye.h,clips:Fr,timeline:Xn}},P=new Map,T;try{if(T=g==="align"?await O():await Jy(i,c,{lumaCacheBytes:Math.min(6*2**30,Math.max(2**30,Math.floor(Ro()/20))),fingerprint:Poe,hashFrame:koe,onProgress:e.onProgress,signal:e.signal,candidateLuma:(z,X)=>d[z].luma(X),candidateThumb:(z,X)=>{let V=d[z],R=c[z].path;if(R&&!t&&V.src.index?.kind!=="prores"&&!V.src.geometrySpec)return fl(R).then(J=>J.read(X)).catch(()=>V.luma(X));let j=P.get(z);return j||(j=ih(c[z],"index").catch(()=>d[z]),P.set(z,j)),j.then(J=>J.luma(X))},referenceLuma:z=>p.luma(z),audioPcm:z=>{let X=z==="ref"?e.reference_audio??e.reference:c[z].path;return X?SW(X):Promise.resolve(null)},examineAll:e.examine_all,keyframesOf:async z=>{let X=z.path;return X?ch(X):null},frameCount:async z=>{let X=h.get(z);return X?b(X,z):0},...e.find_first&&u?{findFirst:{index:z=>v(z,!1),indexFine:z=>v(z,!0),embedRef:(z,X)=>iy(p.luma,z,{embed:V=>hv(V,u),signal:e.signal,onProgress:X})}}:{},...f?{hints:uW(f,void 0,{allTracks:!0})}:{},...u?{embedSweep:async z=>{let X=h.get(z),V=z.path,R={model:u,stride:wp,geometryWidth:Cs,display:t},j=V?await qm(V,R):null;if(j)return j;let J=await HT(X.luma,await b(X,z),{stride:wp,embed:q=>hv(q,u),signal:e.signal,onProgress:(q,W)=>e.onProgress?.(q,W,`reframe tier: ${z.name}`)});return V&&await K4(V,R,J).catch(()=>{}),J}}:{}}),e.sizing!==!1){let z=new Map(c.map((H,C)=>[H.name,C])),X=T.timeline.filter(H=>H.clipLabel&&(H.kind==="static"||H.kind==="unresolved")).length,V=0,R=performance.now(),j=await n9(T,{ref:H=>p.luma(H),src:async(H,C)=>{let $=z.get(H);return $==null?null:await d[$].luma(C)}},{log:()=>e.onProgress?.(++V,X,"sizing"),hint:H=>m.get(H)}),J=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS;J&&console.error(`[time] sizing ${((performance.now()-R)/1e3).toFixed(1)} s`),e.onProgress?.(X,X,`sizing: ${j.sized} measured (${j.animated} moving), ${j.untrusted} left unresized`);let q=Number(globalThis.process?.env?.CONFORM_DYN_KEEP??.05),W=T.timeline.filter(H=>H.kind==="unresolved"&&!w.has(H.refStart)&&H.clipLabel&&H.srcStart!=null&&H.srcEnd!=null),F=[];for(let H of W){e.signal?.throwIfAborted();let C=z.get(H.clipLabel),$=C==null?null:await tW(H,ye=>p.luma(ye),ye=>d[C].luma(ye),T.refW||16,T.refH||9);if(F.push(`${H.refStart}-${H.refEnd} ${H.clipLabel}@${H.srcStart}: ${$==null?"n/a":$.toFixed(3)}`),$!=null&&$>=q)continue;let oe=`${H.track?.label??"sizing not measured"}; motion agreement ${$==null?"not measurable":$.toFixed(2)}, below ${q}`;Object.assign(H,{kind:"gap",unconfirmed:{clipLabel:H.clipLabel,srcFrame:H.srcStart,why:oe}});for(let ye of["clipLabel","srcStart","srcEnd","track","speed"])delete H[ye]}J&&F.length&&console.error(`[dyn] keep \u2265 ${q}: ${F.join(" | ")}`)}}finally{qV(),await g9([e.reference,...s])}let S=bz(T,{name:e.name??`${te(e.reference)} auto conform`,referenceName:te(e.reference)});for(let z of S.session.timelines[0]?.tracks[0]?.items??[]){let X=Math.round(z.timeline_range?.start.value??-1);y.has(X)&&!T.timeline.find(V=>V.refStart===X)?.track&&(z.rotation=180)}S.issues.push(...x);let k=sW(S.session,S.issues),L=new Map(s.map(z=>[te(z),z]));for(let z of k.media_references??[]){let X=L.get(te(z.target_url??""))??L.get(z.reel_name??"");X&&(z.target_url=X,z.local_path=X)}return{session:k,report:T,issues:S.issues,stats:S.stats,pool:s,unreadable:o.map(z=>({path:z.p,error:z.error}))}}function IW(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"),t}function EW(e){let t=e.report,n=t.timeline??[],i={};for(let a of n)i[a.kind??"?"]=(i[a.kind??"?"]??0)+1;let r=e.issues,o={};for(let a of r)o[a.kind]=(o[a.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(a=>`${te(a.path)}: ${a.error.slice(0,80)}`).join("; ")}${e.unreadable.length>5?"; \u2026":""}`]:[],`timeline segments: ${Object.entries(i).map(([a,s])=>`${s} ${a}`).join(", ")}`,`stats: ${JSON.stringify(e.stats)}`,`issues: ${r.length?Object.entries(o).map(([a,s])=>`${s} ${a}`).join(", "):"none"}`,...r.slice(0,25).map(a=>`- [${a.kind}] ${a.message??a.note??""}${a.refStart!=null?` @ ${a.refStart}${a.refEnd!=null?`\u2013${a.refEnd}`:""}`:""}`)].join(`
175
- `)}var Bm=["plain","short","jump","lookalike","punch_in","turned","animated","offrate","retime","ramp","pip","gap","lower_third","locator","title","frankenbite"],Au={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}},b6=new Set(["lower_third","locator","title"]),VW=["MARIA ALVAREZ","DR. JAMES OKAFOR","SARAH CHEN","TOM WHITFIELD","ANA LUCIA REYES","MARCUS BELL"],WW=["Small Business Owner","Emergency Physician","City Council Member","Rancher, 4th Generation","Teacher","Veteran, U.S. Army"],HW=["AUSTIN, TEXAS","LOCKHART, TX","SAN MARCOS","CALDWELL COUNTY","HOUSTON, TEXAS","WEST TEXAS"],ZW=["STRONGER TOGETHER","THE ROAD AHEAD","PLANNING AHEAD","RIGHT HERE AT HOME","VOTE NOVEMBER 5"];var Toe=(e,t)=>e.path<t.path?-1:e.path>t.path?1:0;function zoe(e){let t=[],n=[],i=new Map;for(let{path:r,ref:o}of[...e].sort(Toe)){let a=o.available_range?.duration?.value??0,s=o.available_range?.duration?.rate||o.source_fps||0;if(!s||a<s*5||!o.source_resolution_w){n.push({path:r,reason:"too short or no picture"});continue}let c=r.slice(0,r.lastIndexOf("/")),l=i.get(c)??0;i.set(c,l+1);let u=rS(o);t.push({path:r,dir:c,idx:l,frames:a,rate:s,w:o.source_resolution_w,h:o.source_resolution_h??0,sound:u})}return{clips:t,skipped:n}}function Ooe(e){let t=e>>>0,n=()=>{t=t+1831565813>>>0;let i=t;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296};return{next:n,int:(i,r)=>i+Math.floor(n()*(r-i+1)),pick:i=>i[Math.floor(n()*i.length)],range:(i,r)=>i+n()*(r-i)}}function DW(e){let t=typeof e=="object"&&e!==null?e:Au[e??"hard"];if(!t)throw new Error(`unknown mix '${e}' (presets: ${Object.keys(Au).join(", ")})`);return t}function yv(e){let t=DW(e),n=Bm.filter(i=>(t[i]??0)>0);if(!n.length)throw new Error("the mix weights no class");return n}function Moe(e,t){let n=Ooe(e.seed),i=e.fps_num??24e3,r=e.fps_den??1001,o=e.width??1920,a=e.height??1080,s=i/r,c=DW(e.mix),l=yv(e.mix),u=l.reduce((T,S)=>T+c[S],0),f=()=>{let T=n.next()*u;for(let S of l)if((T-=c[S])<0)return S;return l[l.length-1]};if(!t.length)throw new Error("no usable clips");let d=t.filter(T=>Math.abs(T.rate-s)>.01),m=[],p=e.shots??24,h=0,b=null,v=0,g=(T,S,k)=>Math.max(1,Math.round(S*(T.rate/s)*(k/100))),y=T=>Math.ceil(T.rate*Math.min(12,Math.max(2,.15*T.frames/T.rate))),w=(T,S,k)=>(e.avoid??[]).some(L=>L.path===T&&S<L.to&&S+k>L.from),x=(T,S)=>{let k=y(T),L=T.frames-Math.ceil(T.rate)-S;if(L<=k)return-1;for(let z=0;z<24;z++){let X=n.int(k,L);if(!w(T.path,X,S))return X}return-1},O=(T,S,k)=>{let L=0;for(let z=0;z<S;z++)L+=Dp(k,z+.5)/100;return Math.max(1,Math.ceil(L*(T.rate/s))+1)},P=[];for(let T=0;T<p;T++){let S=f(),k=[S];S==="gap"&&(h+=n.int(6,48));let L=S==="short"||S!=="plain"&&S!=="ramp"&&!b6.has(S)&&n.next()<.2;L&&S!=="short"&&k.push("short");let z=S==="ramp"?n.int(60,144):b6.has(S)?n.int(48,120):L?n.int(4,23):S==="plain"?n.int(24,120):24+Math.floor(n.next()**2*96),X,V=n.pick(t),R=100,j=-1,J={};if(S==="jump"&&b){V=b.clip;let C=b.srcOut+n.int(6,120);C+g(V,z,100)<V.frames-V.rate&&!w(V.path,C,g(V,z,100))&&(j=C)}else if(S==="lookalike"&&b){let C=t.filter($=>$.dir===b.clip.dir&&$!==b.clip).sort(($,oe)=>Math.abs($.idx-b.clip.idx)-Math.abs(oe.idx-b.clip.idx));C.length&&(V=C[Math.min(C.length-1,n.int(0,2))])}else if(S==="offrate"&&d.length)V=n.pick(d),R=n.next()<.6?Math.round(s/V.rate*1e4)/100:100;else if(S==="retime")R=n.pick([25,50,150,200]);else if(S==="ramp"){let C=Math.round(z*n.range(.2,.4)),$=Math.round(z*n.range(.6,.8));X=n.pick([[[C,100],[$,40]],[[C,40],[$,100]],[[C,100],[$,200]],[[C,200],[$,100]],[[0,100],[C,100],[Math.round((C+$)/2),30],[$,100]]])}S==="jump"&&j<0&&(k[0]="plain"),S==="lookalike"&&(!b||V.dir!==b.clip.dir)&&(k[0]="plain"),S==="offrate"&&R===100&&Math.abs(V.rate-s)<.01&&(k[0]="plain");let q=X?O(V,z,X):g(V,z,R);if(j<0&&(j=x(V,q)),j<0){if(++v>p*50)throw new Error("the clips are too short for this mix");T--;continue}let W=C=>(C/100-1)/2*.8;if(S==="punch_in"){let C=Math.round(n.range(110,200));Object.assign(J,{scale:C,position_x:Math.round(n.range(-1,1)*W(C)*o),position_y:Math.round(n.range(-1,1)*W(C)*a)})}else if(S==="turned")if(n.next()<.35)Object.assign(J,n.next()<.7?{flip_h:!0}:{flip_v:!0});else{let C=Math.round(n.range(1,6)*10)/10*(n.next()<.5?-1:1);Object.assign(J,{rotation:C,scale:Math.round(100+Math.abs(C)*4)})}else if(S==="animated")if(n.next()<.5)Object.assign(J,{scale:100,scale_end:Math.round(n.range(115,150))});else{let C=Math.round(n.range(125,150)),$=W(C)*o;Object.assign(J,{scale:C,position_x:Math.round(-$),position_x_end:Math.round($)})}let F=e.audio&&V.sound&&R===100&&!X&&Math.abs(V.rate-s)<.01,H;if(S==="frankenbite")if(!F)k[0]="plain";else{let C=t.filter(ye=>ye.dir===V.dir&&ye!==V&&ye.sound&&Math.abs(ye.rate-s)<.01),$=C.length&&n.next()<.6?n.pick(C):V,oe=x($,q);oe>=0&&($!==V||Math.abs(oe-j)>48)?H={path:$.path,source_in:oe}:k[0]="plain"}if(m.push({path:V.path,source_in:j,duration:z,at:h,track:1,...R!==100?{speed:R}:{},...X?{ramp:X}:{},...F?{audio:!0}:{},...H?{audio_from:H}:{},...J,classes:k,record_in:h,record_out:h+z}),b6.has(S)){let C=h+Math.floor(z*n.range(0,.2)),$=h+z-Math.floor(z*n.range(0,.15)),oe=n.int(0,VW.length-1),ye=S==="lower_third"?`${VW[oe]}
176
- ${WW[n.int(0,WW.length-1)]}`:S==="locator"?HW[n.int(0,HW.length-1)]:ZW[n.int(0,ZW.length-1)];P.push({kind:S,text:ye,at:C,duration:Math.max(12,$-C),track:3})}if(S==="pip"&&z>=12){let C=n.pick(t),$=Math.max(8,Math.floor(z*n.range(.5,1))),oe=x(C,g(C,$,100));if(oe>=0){let ye=Math.round(n.range(25,45)),Ae=(1-ye/100)/2*.85,de=h+Math.floor((z-$)*n.next());m.push({path:C.path,source_in:oe,duration:$,at:de,track:2,scale:ye,position_x:Math.round((n.next()<.5?-1:1)*Ae*o),position_y:Math.round((n.next()<.5?-1:1)*Ae*a),classes:["pip"],record_in:de,record_out:de+$})}}b={clip:V,srcOut:j+q},h+=z}return{shots:m,titles:P}}function Am(e,t,n){let i=I0(t);if(!i)throw new Error(`unknown operation '${t}'; known: ${Object.keys(Gd).join(", ")}`);return i(e,n)}function g6(e,t){let n={projects:[],timelines:[],media_references:[]},i="author-tl";Am(n,"new_timeline",{timeline_id:i,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 r=n.timelines.find(l=>l.id===i),o=e.fps_num/e.fps_den,a=()=>r.tracks.filter(l=>l.kind==="Video"),s=new Map,c=[];for(let[l,u]of e.shots.entries()){let f=Math.max(1,u.track??1);for(;a().length<f;)Am(n,"add_track",{timeline_id:i,kind:"Video"});let d=a()[f-1],m=s.get(u.path);m||s.set(u.path,m=t(u.path));let p=m.available_range,h=p?.duration?.rate||m.source_fps||o,b=p?.duration?.value??1/0,v=u.speed??100,g=u.ramp?Mf(u.ramp,u.duration,u.source_in,o,h,"spd"):null,y=g?Math.max(1,Math.ceil(g.sourceFrames)+1):Math.max(1,Math.round(u.duration*(h/o)*(v/100)));if(u.source_in<0||u.source_in+y>b)throw new Error(`shot ${l+1} (${m.id}): source ${u.source_in}+${y} is outside the clip (0\u2013${b-1})`);let w=Am(n,"add_clip",{timeline_id:i,media_reference_id:m.id,media_reference:m,source_start:(p?.start?.value??0)+u.source_in,source_duration:u.duration,at_frame:u.at,track_id:d.id,without_audio:!u.audio}),x=w.meta?.item_id,O=d.items.find(z=>z.id===x);if(!O)throw new Error(`shot ${l+1}: ${w.summary}`);O.source_range={start:O.source_range.start,duration:{value:y,rate:h}};let P=w.meta?.audio_item_id;if(P&&u.audio_from){let z=r.tracks.flatMap(V=>V.items).find(V=>V.id===P),X=s.get(u.audio_from.path);if(X||s.set(u.audio_from.path,X=t(u.audio_from.path)),z){n.media_references.some(R=>R.id===X.id)||n.media_references.push(X),z.media_reference_id=X.id,z.name=X.id;let V=X.available_range?.duration?.rate||X.source_fps||o;z.source_range={start:{value:(X.available_range?.start?.value??0)+u.audio_from.source_in,rate:V},duration:{value:u.duration*(V/o),rate:V}}}}g?(O.speed_ramped=!0,O.speed=Math.round(100*g.sourceFrames/u.duration*(o/h)*100)/100):v!==100&&(O.speed=v);let T=ol(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)&&Am(n,"transform",{timeline_id:i,item_id:O.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 S=[["scale",u.scale??100,u.scale_end,z=>z],["position.x",u.position_x??0,u.position_x_end,z=>z/T.w],["position.y",u.position_y??0,u.position_y_end,z=>z/T.h],["rotation",u.rotation??0,u.rotation_end,z=>z]],k=[];for(let[z,X,V,R]of S)if(V!=null)for(let[j,J]of[[0,X],[y-1,V]])k.push({id:`${O.id}-kf-${k.length}`,parameter_path:z,time:{value:O.source_range.start.value+j,rate:h},value:R(J),interp:"linear",order_index:k.length,raw_extraction:{}});if(g)for(let z of g.keyframes)k.push({...z,id:`${O.id}-${z.id}`,order_index:k.length});k.length&&(O.keyframes=k);let L=O;u.flip_h&&(L.flip_horizontal=!0),u.flip_v&&(L.flip_vertical=!0),c.push(`${l+1}. V${f} @${O.timeline_range.start.value} ${u.duration}f ${m.id} src+${u.source_in}${v!==100?` ${v}%`:""}${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":""}${g?` ramp ${u.ramp.map(([z,X])=>`${X}%@${z}`).join("\u2192")}`:""}${k.length&&!g?` animated (${k.length/2} params)`:""}`)}for(let[l,u]of(e.titles??[]).entries()){for(;a().length<u.track;)Am(n,"add_track",{timeline_id:i,kind:"Video"});let f=a()[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+"},p=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"};f.items.push({id:`${i}-title-${l}`,kind:"clip",item_index:f.items.length,name:u.text.split(`
177
- `)[0],enabled:!0,timeline_range:{start:{value:u.at,rate:o},duration:{value:u.duration,rate:o}},title:{text:u.text,...m,...p}}),c.push(`T${l+1}. V${u.track} @${u.at} ${u.duration}f ${u.kind} "${u.text.replace(`
178
- `," / ")}"`)}return{session:n,summary:c}}function qW(e,t){yv(e.mix);let{clips:n,skipped:i}=zoe(t);if(!n.length)throw new Error(`no usable clips (${i.length} skipped)`);let{shots:r,titles:o}=Moe(e,n),a=e.fps_num??24e3,s=e.fps_den??1001,c=e.width??1920,l=e.height??1080,u=new Map(t.map(p=>[p.path,p.ref])),f=e.name??`generated ${e.seed}`,{session:d,summary:m}=g6({name:f,fps_num:a,fps_den:s,width:c,height:l,shots:r.map(({classes:p,record_in:h,record_out:b,...v})=>v),titles:o},p=>u.get(p));return{session:d,summary:m,shots:r,titles:o,pool:{used:n.length,skipped:i}}}async function UW(e){if(e.start_tc){let i=Cn(e.start_tc,e.fps_num/e.fps_den);if(i==null)throw new Error(`start_tc: cannot parse '${e.start_tc}' (HH:MM:SS:FF, ';' before FF for drop frame)`);e={...e,start_frame:i,drop_frame:e.drop_frame??e.start_tc.includes(";")}}let t=new Map;for(let i of e.shots)if(!t.has(i.path))try{t.set(i.path,await Fn(i.path))}catch(r){t.set(i.path,r instanceof Error?r:new Error(String(r)))}let n=new Set;for(let i of t.values()){if(i instanceof Error)continue;let r=i.id,o=2;for(;n.has(r);)r=`${i.id} (${o++})`;n.add(i.id=r)}return g6(e,i=>{let r=t.get(i);if(r instanceof Error)throw r;return r})}var Loe=2.5;function Roe(e){let n=Wn(e,96),i=n.length/96,r=0,o=0;for(let a=1;a<i-1;a++)for(let s=1;s<95;s++){let c=a*96+s;r+=Math.abs(n[c+1]-n[c-1])+Math.abs(n[c+96]-n[c-96]),o++}return o?r/o:0}var CW=new Map;async function Noe(e){let t=[];return await Promise.all(e.map(async n=>{let i=CW.get(n.path);i||CW.set(n.path,i=la(n.path));let r=Math.max(1,Math.round(n.duration*((n.speed??100)/100))),o=[n.source_in,n.source_in+(r>>1),n.source_in+r-1],a=0;for(let s of o){let c=await i.read(s).catch(()=>null);c&&Roe(c)<Loe&&a++}a>=2&&t.push({path:n.path,from:n.source_in-24,to:n.source_in+r+24})})),t}var Xoe=/\.(mov|mxf|mp4|m4v|mts|braw|r3d|ari)$/i,joe=/prox(y|ies)|^cache$/i;async function JW(e,t,n=!0){if((await Deno.stat(e)).isFile){Xoe.test(e)&&!e.split("/").pop().startsWith("._")&&t.push(e);return}if(!(!n&&joe.test(e.split("/").pop())))for await(let r of Deno.readDir(e))r.name.startsWith(".")||await JW(`${e}/${r.name}`,t,!1)}async function KW(e){yv(e.mix);let t=[];for(let c of e.media)await JW(c,t);if(t.sort(),!t.length)throw new Error("no video files under the media given");let n=[],i=new Map;for(let c of t)try{n.push({path:c,ref:await Fn(c)})}catch(l){i.set(c,l instanceof Error?l.message:String(l))}let r=[...e.avoid??[]],o;for(let c=0;c<(e.look===!1?1:5);c++){try{o=qW({...e,avoid:r},n)}catch(u){throw u instanceof Error&&u.message.startsWith("no usable clips")?new Error(`no usable clips (${t.length} skipped)`):u}if(e.look===!1)break;let l=await Noe(o.shots);if(!l.length)break;r.push(...l)}if(!o)throw new Error("no cut");let a=new Map([...i,...o.pool.skipped.map(c=>[c.path,c.reason])]),s=t.filter(c=>a.has(c)).map(c=>`${c} (${a.get(c)})`);return{session:o.session,summary:o.summary,shots:o.shots,titles:o.titles,pool:{used:o.pool.used,skipped:s}}}var Foe="1",Bu=(e,t)=>`reconform-${e}-${t}`,GW=e=>e.replace(/\.[^.]+$/,"");function AW(e,t,n,i){let r=GW(i.aName),o=GW(i.bName),a=t.fps??n.fps??24,s=t.fps??a,c=My(a),l=[],u=0,f=(T,S,k,L,z)=>{l.push({id:Bu("marker",u++),name:T,color:S,kind:null,note:k,time:{value:L,rate:a},duration:{value:Math.max(1,z),rate:a},item_id:null,raw_extraction:{},source_element_id:null,metadata:{}})},d=Bu("media","a"),m=[{id:d,kind:"external",content_kind:"video",target_url:i.aName,display_name:r,source_fps:s,source_timecode:Ly(t.startFrame,s,t.dropFrame),available_range:{start:{value:0,rate:s},duration:{value:t.frames,rate:s}},source_resolution_w:t.w||null,source_resolution_h:t.h||null,reel_name:null,raw_extraction:{},metadata:{codec:t.codec}}],p=[],h=0,b=0,v=0,g=0,y=0;for(let T of e){if(T.kind==="hole"){v+=T.count,f("NEW MATERIAL","Green",`${T.count} frame(s) not in ${r} \u2014 cut the new material in here.`,T.recordIn,T.count);continue}if(T.aIn==null)continue;let S=Bu("item",y);p.push({id:S,kind:"clip",item_index:y++,name:r,enabled:!0,timeline_range:{start:{value:T.recordIn,rate:a},duration:{value:T.count,rate:a}},source_range:{start:{value:T.aIn,rate:s},duration:{value:T.count,rate:s}},media_reference_id:d,raw_extraction:{},metadata:{}}),h++,b+=T.count,T.unreproducible&&(g++,f("CHECK BY EYE","Red",`${T.unreproducible.note}. This clip is the closest straight source frames can get \u2014 a hold, reverse or retime here must be rebuilt by hand from ${r} (${T.aInTc??"?"}\u2013${T.aOutTc??"?"}).`,T.recordIn,T.count))}t.fps&&n.fps&&Math.abs(t.fps-n.fps)>.01&&f("RATE MISMATCH","Yellow",`Old cut is ${t.fps.toFixed(3)} fps, new cut ${n.fps.toFixed(3)} fps. This timeline is emitted at ${a.toFixed(3)} fps (the matcher's timebase) \u2014 frame counts near edits need checking by eye.`,0,1);for(let T of i.warnings??[])f("COMPARE WARNING","Yellow",T,0,1);let w={id:Bu("track",1),kind:"Video",track_index:1,name:"V1",enabled:!0,items:p,source_element_id:null,raw_extraction:{},metadata:{}},x=e.length?e[e.length-1].recordOut:0,O={id:Bu("timeline",1),name:i.name??`${o} \u2014 reconform from ${r}`,kind:"primary",timeline_index:0,fps_num:c.num,fps_den:c.den,resolution_w:n.w||null,resolution_h:n.h||null,start_frame:n.startFrame,is_drop_frame:n.dropFrame,duration_frames:x,tracks:[w],markers:l,source_element_id:null,raw_extraction:{},metadata:{}};return{session:{projects:[{id:Bu("project",1),user_id:"",created_at:"",source_format:"ref-compare",source_filename:i.bName,source_file_sha256:null,source_file_bytes:null,parser_name:"reconform-session",parser_version:Foe,status:"ready",error_message:null,metadata:{}}],timelines:[O],media_references:m,source_format:"ref-compare",source_filename:i.bName},stats:{placed:h,aSourceFrames:b,holeFrames:v,flagged:g}}}async function BW(e){let t=await mr.open(e.a),n=await mr.open(e.b),[i,r]=[!(await wn(t)).spec,!(await wn(n)).spec],o=(i||r)&&await Ju(t)&&await Ju(n)?"os-decoder":void 0,a=await Jm(t,{matte:"clip",motion:!0,lane:o,onProgress:(f,d)=>e.onProgress?.(f,d,`fingerprinting ${te(e.a)}`),signal:e.signal}),s=await Jm(n,{matte:"clip",motion:!0,lane:o,onProgress:(f,d)=>e.onProgress?.(f,d,`fingerprinting ${te(e.b)}`),signal:e.signal}),c=Ep(a,s),l=PV(kV(c.report,c.a,c.b,e.min_run??I4),c.aPdq,c.bPdq),u=AW(l,c.a,c.b,{aName:te(e.a),bName:te(e.b),name:`${te(e.b)} rebuilt from ${te(e.a)}`,warnings:c.warnings});for(let f of u.session.media_references??[])f.target_url=e.a,f.local_path=e.a;return{result:c,events:l,summary:SV(l),unreproducible:l.filter(f=>f.unreproducible),edl:TV(l,c.b,{title:`${te(e.b)} FROM ${te(e.a)}`.toUpperCase().slice(0,70),aReel:te(e.a).replace(/\.[^.]+$/,"").slice(0,8)}),csv:zV(l),session:u.session,stats:u.stats,lanes:{a:a.lane,b:s.lane}}}function YW(e,t){let{a:n,b:i}=e.result,r=e.summary.hole===0&&e.events.length===1&&!e.unreproducible.length;return[`A (old) ${te(t.a)}: ${n.label} ${n.w}x${n.h} @ ${n.fps??"?"} fps, ${n.frames} frames (${e.lanes.a})`,`B (new) ${te(t.b)}: ${i.label} ${i.w}x${i.h} @ ${i.fps??"?"} fps, ${i.frames} frames (${e.lanes.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(a=>a.kind!=="hole").length} from A (${e.summary.aSource} frames), ${e.events.filter(a=>a.kind==="hole").length} hole(s) of new material (${e.summary.hole} frames)`,...e.result.warnings.map(a=>`warning: ${a}`),...e.unreproducible.map(a=>`CHECK BY EYE event ${a.index} ${a.recordInTc}\u2013${a.recordOutTc}: ${a.unreproducible.note}`),"",j7(e.result.report)].join(`
179
- `)}import{basename as Cc}from"node:path";async function QW(e){await oi();try{return gp(K8(e))}catch{return null}}async function _W(e){await oi();try{return gp(J8(e))}catch{return null}}var Ioe=/\.(dpx|exr|tif|tiff|cin|ari|arx|jpg|jpeg|png)$/i;function v6(e){if(!Ioe.test(e))return null;let t=e.match(/^(.*?)(\d{3,})(\.[^.]+)$/);return t?{stem:t[1],frame:parseInt(t[2],10),digits:t[2].length,ext:t[3].toLowerCase()}:null}var y6=new Set([".png",".jpg",".jpeg",".jpe",".jfif",".tif",".tiff",".exr",".dpx",".dng",".cr3"]),w6=new Set([".webp",".avif",".heic",".heif",".gif",".bmp"]),wv=e=>y6.has(ar(e).toLowerCase());async function Ym(e){let t=ar(e).toLowerCase();if(w6.has(t))throw new Error(`${te(e)}: ${t.slice(1)} stills are not decoded by the engine yet \u2014 save it as PNG or JPEG`);let n=t===".png"?QW:t===".jpg"||t===".jpeg"||t===".jpe"||t===".jfif"?_W:t===".dpx"?zT:t===".exr"?vp:t===".tif"||t===".tiff"?RT:t===".dng"?MT:t===".cr3"?LT:null;if(!n)throw new Error(`unsupported still: ${te(e)}`);let i=await n(await er(e));if(!i)throw new Error(`could not decode ${te(e)}`);return{rgba:new Uint8Array(i.rgba.buffer,i.rgba.byteOffset,i.rgba.byteLength),width:i.width,height:i.height}}var Eoe=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab"];async function $W(e){let t=await OT(await er(e));if(!t)return null;let n=t.attributes??{},i=/^(\d+)\/(\d+)$/.exec(n.framesPerSecond??"");return{meta:t,fps:i&&+i[2]?+i[1]/+i[2]:null,timecode:n.timeCode??null}}async function eH(e){let t=ar(e).toLowerCase(),n={file:te(e),width:null,height:null,fps:null,timecode:null};if(t===".exr"){let r=await $W(e);r&&Object.assign(n,{width:r.meta.width,height:r.meta.height,fps:r.fps,timecode:r.timecode,exr:{compression:r.meta.compression,channels:r.meta.channels.map(o=>o.name),attributes:r.meta.attributes??{}}})}else{let r=await TT(t.slice(1),ST(await er(e)));if(r)Object.assign(n,{width:r.width,height:r.height});else{let o=await Ym(e);Object.assign(n,{width:o.width,height:o.height})}}let i=v6(te(e));if(i){let r=[],o=te(e),a=te(e);for await(let l of dn(Ln(e))){let u=l.isFile?v6(l.name):null;!u||u.stem!==i.stem||u.digits!==i.digits||u.ext!==i.ext||r.push(u.frame)}r.sort((l,u)=>l-u);let s=l=>`${i.stem}${String(l).padStart(i.digits,"0")}${i.ext}`;o=s(r[0]),a=s(r[r.length-1]);let c=null;if(t===".exr"&&(c=(await $W(Q(Ln(e),o)).catch(()=>null))?.timecode??null),!c&&n.timecode&&n.fps){let l=Cn(n.timecode,n.fps);l!=null&&(c=Qt(l-(i.frame-r[0]),n.fps,n.timecode.includes(";")))}n.sequence={first:o,last:a,frames:r.length,first_frame:r[0],last_frame:r[r.length-1],missing:r[r.length-1]-r[0]+1-r.length,start_tc:c,index:r.indexOf(i.frame)}}return n}function tH(e){let t=e.fps?String(Math.round(e.fps*1e3)/1e3):null;return[`${e.file}: still${e.exr?` OpenEXR (${Eoe[e.exr.compression]??e.exr.compression}, channels ${e.exr.channels.join(",")})`:""}, ${e.width??"?"}x${e.height??"?"}`,e.exr?`header: ${t?`${t} fps`:"no framesPerSecond"}; ${e.timecode?`timeCode ${e.timecode}`:"no timeCode"} (what the file says, not a timeline's declaration)`:"",e.sequence?`sequence: ${e.sequence.first} \u2026 ${e.sequence.last}, ${e.sequence.frames} frames (${e.sequence.first_frame}\u2013${e.sequence.last_frame}${e.sequence.missing?`, ${e.sequence.missing} MISSING`:""})${e.sequence.start_tc?`, starts ${e.sequence.start_tc}`:""}; this is frame ${e.sequence.index} of it`:"",e.exr&&Object.keys(e.exr.attributes).length?`attributes: ${Object.entries(e.exr.attributes).filter(([n])=>!["channels","chlist"].includes(n)).map(([n,i])=>`${n}=${i.length>60?i.slice(0,60)+"\u2026":i}`).join("; ")}`:""].filter(Boolean).join(`
180
- `)}var Uc=32,Qu=18;function iH(e,t,n,i=1,r=0){let o=new Float64Array(Uc*Qu),a=new Uint32Array(Uc*Qu);for(let u=0;u<n;u++){let f=Math.min(Qu-1,Math.floor(u*Qu/n))*Uc;for(let d=0;d<t;d++){let m=f+Math.min(Uc-1,Math.floor(d*Uc/t));o[m]+=e[(u*t+d)*i+r],a[m]++}}let s=new Float32Array(Uc*Qu);for(let u=0;u<s.length;u++)s[u]=a[u]?o[u]/a[u]:0;let c=_u(Float32Array.from(s)),l=Math.max(_u(s.map(u=>Math.abs(u-c))),2);for(let u=0;u<s.length;u++)s[u]=(s[u]-c)/l;return s}function _u(e){return e.sort(),e.length?e[e.length>>1]:0}var Yu=new Float32Array(Uc*Qu);function x6(e,t){return Math.max(nH(e,t),nH(t,e))}function nH(e,t){let n=e.length;for(let a=0;a<n;a++)Yu[a]=e[a]-t[a];let i=null,r=1,o=_u(Float32Array.from(Yu));for(let a=0;a<5;a++){if(i){let l=0,u=0,f=0,d=0,m=0;for(let h=0;h<n;h++)i(h)&&(l+=e[h],u+=t[h],f+=t[h]*t[h],d+=e[h]*t[h],m++);let p=f-u*u/m;r=p>1e-6?Math.max(0,(d-l*u/m)/p):0,o=(l-r*u)/m}for(let l=0;l<n;l++)Yu[l]=Math.abs(e[l]-r*t[l]-o);let s=_u(Float32Array.from(Yu)),c=Float32Array.from(Yu);i=l=>c[l]<=s}return _u(Yu)}function rH(e){let t=e.slice(0,-1).map((i,r)=>i&&e[r+1]?x6(i,e[r+1]):0),n=_u(Float32Array.from(t));return t.flatMap((i,r)=>i>Math.max(Voe,4*n)?[r]:[])}var Voe=.6,P6=.35,Woe=e=>e*1.25+.005,Hoe=e=>(/\.[^./]+$/.exec(e)?.[0]??"").toLowerCase();async function Zoe(e,t){let n=await t(await er(e));if(!n)throw new Error(`could not decode ${te(e)}`);return n}async function Doe(e,t){if(e.codec==="still")return Ym(e.path);if(e.codec==="exr"){let n=await Ay(e.path);return Zoe(n.frames[t]??n.frames[0],vp)}return dl(e.path,t,e.codec)}async function xv(e){if(wv(e)&&Hoe(e)!==".exr")return{path:e,name:te(e),fps:24,start:0,df:!1,frames:1,codec:"still"};let t=await Fn(e),n=t.streams?.find(o=>o.kind==="video");if(!n)throw new Error(`${te(e)} has no video`);let i=t.source_fps??n.rate??24,r=t.source_timecode??null;return{path:e,name:te(e),fps:i,start:r?Cn(r,i)??0:0,df:!!r?.includes(";"),frames:t.available_range?.duration?.value??0,codec:(n.codec??"").toLowerCase()}}var qr=(e,t)=>Qt(e.start+t,e.fps,e.df);function $u(e,t){let n=t==null?Math.floor(e.frames/2):Yr(t,e.fps,e.start?qr(e,0):null);if(e.frames&&(n<0||n>=e.frames))throw new Error(`frame ${n} is outside ${e.name} (0\u2013${e.frames-1}, ${qr(e,0)}\u2013${qr(e,e.frames-1)})`);return n}async function k6(e){if(e.out_path&&!/\.png$/i.test(e.out_path))throw new Te("invalid_args",`out_path must be a .png file (${te(e.out_path)})`);let t=await xv(e.path),n=$u(t,e.frame),i=e.b?await xv(e.b):null,r=i?e.b_frame!=null?$u(i,e.b_frame):$u(i,qr(t,n)):0,o=Math.max(0,Math.floor(e.around??0)),a=Math.max(1,Math.floor(e.step??1)),s=Array.from({length:2*Math.floor(o/a)+1},(P,T)=>(T-Math.floor(o/a))*a),c=s.length>1||!!i,l=[{clip:t,frames:s.map(P=>n+P)}];i&&l.push({clip:i,frames:s.map(P=>r+P)});let u=[];for(let P of l){let T=[];for(let S of P.frames){if(S<0||P.clip.frames&&S>=P.clip.frames){T.push(null);continue}let k=await Doe(P.clip,S),L=e.width??(c?Math.min(k.width,480):k.width),z=L===k.width?{rgba:k.rgba,w:k.width,h:k.height}:qoe(k.rgba,k.width,k.height,L);T.push({...z,label:`${i?P.clip===t?"A ":"B ":""}${qr(P.clip,S)} f${S}`,feat:iH(k.rgba,k.width,k.height,4,1)})}u.push(T)}let f=u.flat().filter(Boolean);if(!f.length)throw new Error("no frame in range");let d=Math.max(...f.map(P=>P.w)),m=Math.max(...f.map(P=>P.h)),p=Math.max(1,Math.round(d/240)),h=c?7*p+6:0,b=c?4:0,v=s.length*d+(s.length-1)*b,g=l.length*(m+h)+(l.length-1)*b,y=new Uint8Array(v*g*4);for(let P=3;P<y.length;P+=4)y[P]=255;u.forEach((P,T)=>P.forEach((S,k)=>{if(!S)return;let L=k*(d+b),z=T*(m+h+b);for(let X=0;X<S.h;X++)y.set(S.rgba.subarray(X*S.w*4,(X+1)*S.w*4),((z+X)*v+L)*4);c&&Coe(y,v,L+3,z+m+3,S.label,p)}));let w=e.out_path??Q(await Mr("conform-frame-"),`${t.name.replace(/\.[^.]+$/,"")}_${qr(t,n).replace(/[:;]/g,"")}${i?"_AB":o?`_pm${o}`:""}.png`);await fr(w,await Goe(y,v,g));let x=l.flatMap(P=>P.frames.filter(T=>T>=0&&(!P.clip.frames||T<P.clip.frames)).map(T=>({file:P.clip.name,frame:T,tc:qr(P.clip,T)}))),O=i?s.flatMap((P,T)=>{let S=u[0][T],k=u[1][T];if(!S||!k)return[];let L=+x6(S.feat,k.feat).toFixed(3);return[{a_frame:n+P,b_frame:r+P,tc:qr(t,n+P),distance:L,same:L<=P6}]}):void 0;return{out_path:w,w:v,h:g,frames:x,...O?{diff:O}:{}}}function S6(e){let t=`wrote ${e.out_path} (${e.w}x${e.h} PNG, ${e.frames.length} frame${e.frames.length>1?"s":""})`;if(!e.diff)return[t,...e.frames.map(i=>`${i.file} f${i.frame} ${i.tc}`)].join(`
181
- `);let n=e.diff[e.diff.length>>1];return[`${n?.same?"A and B show the same picture":"A and B DIFFER"} at A ${n?.tc??"?"} (distance ${n?.distance??"?"}; 0 = identical, \u2264${P6} = same picture through a grade/burn-in/rescale; a neighbouring frame also scores low, so prove the frame offset with media_align)`,t,...e.diff.map(i=>`A f${i.a_frame} vs B f${i.b_frame} (A ${i.tc}): ${i.distance}${i.same?"":" DIFFERENT"}`)].join(`
182
- `)}function qoe(e,t,n,i){i=Math.max(1,Math.round(i));let r=Math.max(1,Math.round(n*i/t)),o=new Uint8Array(i*r*4);for(let a=0;a<r;a++){let s=Math.floor(a*n/r),c=Math.max(s+1,Math.floor((a+1)*n/r));for(let l=0;l<i;l++){let u=Math.floor(l*t/i),f=Math.max(u+1,Math.floor((l+1)*t/i)),d=0,m=0,p=0,h=0;for(let v=s;v<c;v++)for(let g=u;g<f;g++){let y=(v*t+g)*4;d+=e[y],m+=e[y+1],p+=e[y+2],h++}let b=(a*i+l)*4;o[b]=d/h,o[b+1]=m/h,o[b+2]=p/h,o[b+3]=255}}return{rgba:o,w:i,h:r}}var Uoe={0:[14,17,19,21,25,17,14],1:[4,12,4,4,4,4,14],2:[14,17,1,2,4,8,31],3:[31,2,4,2,1,17,14],4:[2,6,10,18,31,2,2],5:[31,16,30,1,1,17,14],6:[6,8,16,30,17,17,14],7:[31,1,2,4,8,8,8],8:[14,17,17,14,17,17,14],9:[14,17,17,15,1,2,12],":":[0,12,12,0,12,12,0],";":[0,12,12,0,12,4,8],"+":[0,4,4,31,4,4,0],"-":[0,0,0,31,0,0,0],A:[14,17,17,31,17,17,17],B:[30,17,17,30,17,17,30],f:[6,9,8,28,8,8,8]};function Coe(e,t,n,i,r,o){for(let a of r){let s=Uoe[a];if(s){for(let c=0;c<7;c++)for(let l=0;l<5;l++)if(s[c]>>4-l&1)for(let u=0;u<o;u++)for(let f=0;f<o;f++){let d=((i+c*o+u)*t+n+l*o+f)*4;e[d]=e[d+1]=e[d+2]=255}}n+=6*o}}var Joe=Array.from({length:256},(e,t)=>{let n=t;for(let i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function Koe(e){let t=4294967295;for(let n of e)t=Joe[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}async function Goe(e,t,n){let i=new Uint8Array(n*(t*3+1));for(let f=0,d=0;f<n;f++){i[d++]=0;for(let m=0;m<t;m++){let p=(f*t+m)*4;i[d++]=e[p],i[d++]=e[p+1],i[d++]=e[p+2]}}let r=new Uint8Array(await new Response(new Blob([i]).stream().pipeThrough(new CompressionStream("deflate"))).arrayBuffer()),o=(f,d)=>{let m=new Uint8Array(12+d.length),p=new DataView(m.buffer);return p.setUint32(0,d.length),m.set(new TextEncoder().encode(f),4),m.set(d,8),p.setUint32(8+d.length,Koe(m.subarray(4,8+d.length))),m},a=new Uint8Array(13),s=new DataView(a.buffer);s.setUint32(0,t),s.setUint32(4,n),a[8]=8,a[9]=2;let c=[new Uint8Array([137,80,78,71,13,10,26,10]),o("IHDR",a),o("IDAT",r),o("IEND",new Uint8Array(0))],l=new Uint8Array(c.reduce((f,d)=>f+d.length,0)),u=0;for(let f of c)l.set(f,u),u+=f.length;return l}async function Pv(e){let t=await xv(e.a),n=await xv(e.b),i=await mr.open(e.a),r=await mr.open(e.b),[o,a]=[!(await wn(i)).spec,!(await wn(r)).spec],s=(o||a)&&await Ju(i)&&await Ju(r)?"os-decoder":void 0,c=await Yo(i,s,{sparse:!0}),l=await Yo(r,s,{sparse:!0}),u=t.frames||c.frames,f=n.frames||l.frames;t.frames=u,n.frames=f;let d=e.a_in!=null?$u(t,e.a_in):0,m=e.a_out!=null?$u(t,e.a_out):u-1;if(m<d)throw new Error(`a_out (${m}) is before a_in (${d})`);let p=m-d+1,h=Math.max(1,Math.floor(e.search??12)),b=async(q,W)=>{if(e.signal?.aborted)throw new Error("cancelled");let F=await q.luma(W);return F?iH(F.y,F.w,F.h):null},v=[];for(let q=d;q<=m;q++)v.push(await b(c,q));let g=new Map,y=async q=>q<0||q>=f?null:(g.has(q)||g.set(q,await b(l,q)),g.get(q)),w=async(q,W)=>{let F=0,H=0;for(let C of W){let $=v[C],oe=await y(q+C);$&&oe&&(F+=x6($,oe),H++)}return H>=Math.max(1,W.length*.8)?F/H:1/0},x=e.b_in!=null?$u(n,e.b_in):null,O=x??0;if(x==null){let q=Array.from(new Set(Array.from({length:Math.min(16,p)},(F,H)=>Math.round(H*(p-1)/Math.max(1,Math.min(16,p)-1))))),W=1/0;for(let F=-p+1;F<f;F++){let H=await w(F,q);H<W&&(W=H,O=F)}}let P=v.map((q,W)=>W),T=async q=>{let W=[];for(let Ze=-h;Ze<=h;Ze++)W.push({k:Ze,c:await w(O+Ze,q)});let F=[...W].sort((Ze,ue)=>Ze.c-ue.c),H=F[0],C=F[1]??{c:1/0},$=H.k+O-(x??O),oe=W.filter(Ze=>Ze.c<=Woe(H.c)).map(Ze=>Ze.k+O-(x??O)),ye=Number.isFinite(C.c)?+Math.min(1,(C.c-H.c)/Math.max(C.c,1e-6)).toFixed(2):0,Ae=d+q[0],de=d+q[q.length-1],Oe={a_in:Ae,a_out:de,a_tc:qr(t,Ae),cost:+H.c.toFixed(3),confidence:ye};return!Number.isFinite(H.c)||H.c>P6?{...Oe,verdict:"no_match",offset:null,confidence:0}:oe.length>1?{...Oe,verdict:"unverifiable",offset:null,ambiguous:[Math.min(...oe),Math.max(...oe)]}:{...Oe,verdict:$===0?"exact":"offset",offset:$}},S=await T(P),k=rH(v),L=[-1,...k,p-1],z=[];for(let q=0;q+1<L.length;q++)z.push(await T(P.slice(L[q]+1,L[q+1]+1)));let X=(x??O)+(S.offset??0),V=[];for(let q=X-3;q<=X+p+2;q++)V.push(await y(q));let R=rH(V).map(q=>q-3),j=k.map(q=>({a_cut:d+q,tc:qr(t,d+q+1),in_b:R.includes(q)})),J=[];for(let q of R)k.includes(q)||(q>=0&&q<p-1?J.push(`B has a shot change inside the range that A does not, at B ${qr(n,X+q+1)} (A ${qr(t,d+q+1)}): a flash frame / wrong shot`):q<0&&q>=-3?J.push(`B cuts ${-q} frame(s) before the head (B ${qr(n,X+q+1)}): a ${-q}-frame slip early shows the previous shot`):q>=p-1&&q<=p+1&&J.push(`B cuts ${q-p+2} frame(s) after the tail (B ${qr(n,X+q+1)}): a slip late shows the next shot`));return x!=null&&S.offset&&J.unshift(`the client's in-point ${qr(n,x)} is ${S.offset>0?"early":"late"} by ${Math.abs(S.offset)} frame(s): the measured in-point is ${qr(n,X)}`),{a:t.name,b:n.name,a_range:[d,m],a_tc:[qr(t,d),qr(t,m)],proposed_b_in:x,b_in:X,b_tc:qr(n,X),searched:x==null,overall:S,shots:z,anchors:j,flash:J,lane:c.lane}}function oH(e){let t=e.overall,n=t.verdict==="exact"?`EXACT: ${e.a} ${e.a_tc[0]} = ${e.b} ${e.b_tc} (confidence ${t.confidence})`:t.verdict==="offset"?`OFFSET ${t.offset>0?"+":""}${t.offset} frame(s): ${e.a} ${e.a_tc[0]} = ${e.b} ${e.b_tc}${e.proposed_b_in!=null?" (not the client's in-point)":""} (confidence ${t.confidence})`:t.verdict==="unverifiable"?`UNVERIFIABLE: offsets ${t.ambiguous[0]}\u2026${t.ambiguous[1]} fit equally (static picture, no shot change to anchor on)`:`NO MATCH: ${e.a} ${e.a_tc[0]}\u2013${e.a_tc[1]} is not in ${e.b} within the searched frames (cost ${t.cost})`,i=r=>` shot A ${r.a_tc} (f${r.a_in}\u2013${r.a_out}): ${r.verdict}${r.offset?` ${r.offset>0?"+":""}${r.offset}`:""}${r.ambiguous?` (${r.ambiguous[0]}\u2026${r.ambiguous[1]})`:""}, confidence ${r.confidence}`;return[n,`A ${e.a} ${e.a_tc[0]}\u2013${e.a_tc[1]} (${e.a_range[1]-e.a_range[0]+1} frames) vs B ${e.b}${e.searched?" (searched all of B)":` from ${e.b_tc}`}; offset = measured \u2212 client in-point (+ = later in B)`,`anchors: ${e.anchors.length?`${e.anchors.filter(r=>r.in_b).length} of ${e.anchors.length} shot change(s) in A are in B at the same frame`:"no shot change inside the range: the offset rests on motion alone"}`,`shots (${e.shots.length}):`,...e.shots.map(i),...e.flash.length?["flash-frame risk:",...e.flash.map(r=>` ${r}`)]:["flash-frame risk: none found (no B shot change within 3 frames of the range ends)"]].join(`
183
- `)}function aH(e,t){let n=e.timelines.filter(v=>!t.timeline||v.id===t.timeline||v.name===t.timeline),i=t.item_id?n.find(v=>v.tracks.some(g=>g.items.some(y=>y.id===t.item_id))):n.find(v=>v.kind==="primary")??n[0];if(!i)throw new Error(t.item_id?`no item ${t.item_id} in this session`:`no timeline ${t.timeline??""} in this session`);let r=i.fps_den?i.fps_num/i.fps_den:i.fps_num,o=i.start_frame??0,a=!!i.is_drop_frame,s=t.record!=null?Yr(t.record,r,Qt(o,r,a)):null,c=i.tracks.filter(v=>v.kind==="Video"),l;if(t.item_id){for(let v of c)for(let g of v.items)g.id===t.item_id&&(l={it:g,tr:v});if(!l)throw new Error(`${t.item_id} is not a video clip`)}else{if(s==null)throw new Error("give item_id or record (a record TC or frame)");for(let v of[...c].sort((g,y)=>y.track_index-g.track_index)){if(v.enabled===!1)continue;let g=v.items.find(y=>y.kind==="clip"&&y.enabled!==!1&&y.timeline_range.start.value<=s&&s<y.timeline_range.start.value+y.timeline_range.duration.value);if(g){l={it:g,tr:v};break}}if(!l)throw new Error(`no enabled video clip at record ${Qt(o+s,r,a)}`)}let{it:u,tr:f}=l,d=e.media_references.find(v=>v.id===u.media_reference_id),m=d?.local_path??d?.target_url?.replace(/^file:\/\//,"");if(!m||!u.source_range)throw new Error(`${u.name??u.id} has no linked media (relink it first)`);let p=u.timeline_range.start.value,h=s!=null?s-p:0;if(h<0||h>=u.timeline_range.duration.value)throw new Error(`record ${s} is outside ${u.name??u.id}`);let b=u.source_range.start.value+Math.floor(h*u.source_range.duration.value/Math.max(1,u.timeline_range.duration.value));return{path:m,frame:b,item:u.id,track:f.name??`V${f.track_index}`,record_tc:Qt(o+p+h,r,a)}}function Aoe(e){let t=1681.974450955533,n=3.999843853973347,i=.7071752369554196,r=Math.tan(Math.PI*t/e),o=Math.pow(10,n/20),a=Math.pow(o,.4996667741545416),s=1+r/i+r*r,c={b0:(o+a*r/i+r*r)/s,b1:2*(r*r-o)/s,b2:(o-a*r/i+r*r)/s,a1:2*(r*r-1)/s,a2:(1-r/i+r*r)/s},l=38.13547087602444,u=.5003270373238773,f=Math.tan(Math.PI*l/e),d=1+f/u+f*f,m={b0:1,b1:-2,b2:1,a1:2*(f*f-1)/d,a2:(1-f/u+f*f)/d};return{shelf:c,highpass:m}}function Boe(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 Yoe=-.691,Qoe=-70,_oe=10,$oe=.4,eae=.75;var ef=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 i=Aoe(n);this.shelf=i.shelf,this.highpass=i.highpass,this.weights=Boe(t),this.state=Array.from({length:t},()=>({s1:[0,0,0,0],s2:[0,0,0,0]})),this.blockSize=Math.round($oe*n),this.hop=Math.max(1,Math.round(this.blockSize*(1-eae))),this.blockSums=new Array(t).fill(0),this.history=Array.from({length:t},()=>new Float32Array(this.blockSize))}step(t,n,i){let r=t.b0*i+t.b1*n[0]+t.b2*n[1]-t.a1*n[2]-t.a2*n[3];return n[1]=n[0],n[0]=i,n[3]=n[2],n[2]=r,r}push(t){let n=Math.floor(t.length/this.channels);for(let i=0;i<n;i++){for(let r=0;r<this.channels;r++){let o=this.state[r],a=this.step(this.highpass,o.s2,this.step(this.shelf,o.s1,t[i*this.channels+r])),s=a*a;this.blockSums[r]+=s-this.history[r][this.historyAt],this.history[r][this.historyAt]=s}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 r=0;for(let o=0;o<this.channels;o++){let a=this.weights[o]??1;a!==0&&(r+=a*(this.blockSums[o]/this.blockSize))}this.blockPower.push(r)}}}finish(){return tae(this.blockPower)}get samplesSeen(){return this.totalSamples}};function tae(e){let t=s=>s>0?Yoe+10*Math.log10(s):-1/0,n=e.filter(s=>t(s)>Qoe);if(n.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let i=n.reduce((s,c)=>s+c,0)/n.length,r=t(i)-_oe,o=n.filter(s=>t(s)>r);if(o.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let a=o.reduce((s,c)=>s+c,0)/o.length;return{integratedLufs:t(a),gatedBlocks:o.length,totalBlocks:e.length}}var nae=4,kv=32;function rae(e=nae,t=kv){let n=[],i=t/2;for(let r=0;r<e;r++){let o=new Float32Array(t),a=0;for(let s=0;s<t;s++){let c=s-i+1-r/e,l=c===0?1:Math.sin(Math.PI*c)/(Math.PI*c),u=.42-.5*Math.cos(2*Math.PI*s/(t-1))+.08*Math.cos(4*Math.PI*s/(t-1));o[s]=l*u,a+=o[s]}if(a!==0)for(let s=0;s<t;s++)o[s]/=a;n.push(o)}return n}var sH=1024;var tf=class{constructor(t){this.channelCount=t;this.base=0;this.next=0;this.peak=0;this.phases=rae(),this.half=kv/2;let n=1;for(let i=1;i<this.phases.length;i++){let r=0;for(let o=0;o<kv;o++)r+=Math.abs(this.phases[i][o]);r>n&&(n=r)}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 r=0;r<this.channelCount;r++){let o=this.buffers[r],a=new Float32Array(o.length+n);a.set(o,0);for(let s=0;s<n;s++){let c=t[s*this.channelCount+r];a[o.length+s]=c;let l=c<0?-c:c;l>this.peak&&(this.peak=l)}this.buffers[r]=a}let i=this.base+this.buffers[0].length;this.evaluate(i-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 i=0;i<this.channelCount;i++){let r=this.buffers[i],o=this.base,a=this.base+r.length;for(let s=this.next;s<t;s+=sH){let c=Math.min(s+sH,t),l=Math.max(o,s-this.half),u=Math.min(a,c+this.half),f=0;for(let d=l;d<u;d++){let m=r[d-o]<0?-r[d-o]:r[d-o];m>f&&(f=m)}if(!(f*this.l1<=this.peak))for(let d=s;d<c;d++)for(let m=1;m<this.phases.length;m++){let p=this.phases[m],h=0;for(let v=0;v<kv;v++){let g=d+v-this.half+1;g>=o&&g<a&&(h+=r[g-o]*p[v])}let b=h<0?-h:h;b>this.peak&&(this.peak=b)}}}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 i=0;i<this.channelCount;i++)this.buffers[i]=this.buffers[i].slice(n);this.base=t}}};var iae={fps:24,minTonality:.7,minIsolationDb:20,maxFrameMultiple:3};function oae(e,t,n,i,r){let o=Math.round(n*i/r),a=2*Math.PI*o/n,s=2*Math.cos(a),c=0,l=0;for(let u=0;u<n;u++){let f=e[t+u]+s*c-l;l=c,c=f}return Math.sqrt(c*c+l*l-s*c*l)/(n/2)}function aae(e,t,n){let i=0;for(let r=0;r<n;r++){let o=e[t+r];i+=o*o}return Math.sqrt(i/n)}var Sv=e=>e>0?20*Math.log10(e):-1/0;function Tv(e,t,n={}){let i={...iae,...n};if(t<=0||e.length===0)return null;let r=1e3/i.fps,o=Math.max(64,Math.round(20/1e3*t)),a=Math.max(1,Math.round(o/2)),s=Math.min(e.length,Math.round(12*t));if(s<o*4)return null;let c=[],l=[];for(let h=0;h+o<=s;h+=a){let b=aae(e,h,o);c.push(b),l.push(b>1e-6?Math.min(1,oae(e,h,o,1e3,t)/(b*Math.SQRT2)):0)}if(c.length<4)return null;let u=[...c].sort((h,b)=>h-b),f=u[Math.floor(u.length/2)],d=h=>l[h]>=i.minTonality&&Sv(c[h])-Sv(Math.max(f,1e-9))>=i.minIsolationDb,m=null,p=0;for(;p<c.length;){if(!d(p)){p++;continue}let h=p;for(;h+1<c.length&&d(h+1);)h++;let b=h-p+1,v=((b-1)*a+o)*1e3/t;if(v<=r*i.maxFrameMultiple){let g=(p*a+(h*a+o))/2,y=Math.max(...c.slice(p,h+1)),w=l.slice(p,h+1).reduce((O,P)=>O+P,0)/b,x={atSeconds:g/t,durationMs:v,tonality:w,isolationDb:Sv(y)-Sv(Math.max(f,1e-9))};(!m||x.isolationDb>m.isolationDb)&&(m=x)}p=h+1}return m}function cH(e,t){if(t<=1)return e;let n=Math.floor(e.length/t),i=new Float32Array(n);for(let r=0;r<n;r++){let o=0;for(let a=0;a<t;a++)o+=e[r*t+a];i[r]=o/t}return i}var lH=1<<18;async function zv(e,t={}){await oi();let n=Ws(e),i=await Wa(n,e.size),r=JSON.parse(i);if(!r||r.aac)return{loudness:null,twoPop:null,truePeakDb:null};let o=r.sample_rate??0,a=r.channels??0,s=r.sample_frames??0;if(!o||!a||!s)return{loudness:null,twoPop:null,truePeakDb:null};let c=new ef(a,o),l=new tf(a),u=Math.min(s,Math.round(12*o)),f=new Float32Array(u*a),d=0;for(let b=0;b<s;b+=lH){if(t.signal?.aborted)return{loudness:null,twoPop:null,truePeakDb:null};let v=Math.min(lH,s-b),g=await Ha(n,e.size,b,v);if(!g||g.length<12)break;let y=new DataView(g.buffer,g.byteOffset,g.byteLength),w=y.getUint32(8,!0),x=y.getUint32(4,!0);if(!w||!x)break;let O=g.byteOffset+12,P=O%4===0?new Float32Array(g.buffer,O,w*x):new Float32Array(g.slice(12).buffer,0,w*x);if(c.push(P),l.push(P),d<f.length){let T=Math.min(P.length,f.length-d);f.set(P.subarray(0,T),d),d+=T}t.onProgress?.(Math.min(b+v,s),s)}let m=c.finish(),p=d>0?Tv(cH(f.subarray(0,d),a),o,{fps:t.fps&&t.fps>0?t.fps:void 0}):null,h=l.finish();return{loudness:m.integratedLufs===null?null:m,twoPop:p,truePeakDb:Number.isFinite(h)?h:null}}var cae={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 uH(e){let t=(e??"").toLowerCase().trim(),n=js(t);return{family:n,label:cae[t]??n??t,bitDepth:vT(t),chroma:yT(t)}}function T6(e){return e.toLowerCase().replace(/\b(apple|avid|sony|panasonic)\b/g,"").replace(/[\s_-]+/g,"")}function fH(e,t){let n=T6(e),i=T6(t.label);return!n||!i?!1:i===n||i.startsWith(n)?!0:t.family!=null&&T6(t.family)===n}var O2e={"23.98":24e3/1001,"23.976":24e3/1001,"29.97":3e4/1001,"59.94":6e4/1001,"47.95":48e3/1001,"119.88":12e4/1001};async function lae(e,t,n,i,r,o){let a=await y7(e,t,n),s={idx:r,ok:!0,w:a.w,h:a.h,black:Ov(a.y)};if(i.diff&&o&&(s.diff=pH(o.y,a.y)),i.hash){let c=Lr(a.y,a.w,a.h);s.bits=Array.from(c.bits),s.q=c.quality,s.my=c.meanY??0}return i.bars&&(s.bars=Fp(a.y,a.w,a.h)),{result:s,plane:a}}var dH=e=>({idx:e,ok:!1,w:0,h:0,black:!1});async function uae(e,t,n,i,r,o,a){let s=[],c=null;for(let l=0;l<t.length;l++){let u=t[l],f=l<n,d;try{let m=await Da(e,u.offset,u.size,i,r),p=await lae(m,i,r,o,u.idx,c);c=p.plane,d=p.result}catch{d=dH(u.idx)}f||s.push(d),a?.(f?null:d)}return s}function fae(e,t){let n=[],i=Math.min(t,e.length);if(i===0)return n;let r=Math.ceil(e.length/i);for(let o=0;o<e.length;o+=r){let a=e.slice(o,o+r);o===0?n.push({jobs:a,primers:0}):n.push({jobs:[e[o-1],...a],primers:1})}return n}async function mH(e,t,n,i,r,o={}){let{signal:a,onProgress:s}=o;if(t.length===0)return[];let c=t.length,l=0,u=()=>s?.(++l,c);if(typeof Worker>"u")return await uae(e,t,0,n,i,r,h=>{if(a?.aborted)throw new DOMException("aborted","AbortError");h&&u()});let f=Math.max(1,Math.min(navigator.hardwareConcurrency||4,16,t.length)),d=r.diff?fae(t,f):Array.from({length:f},(p,h)=>({jobs:t.filter((b,v)=>v%f===h),primers:0})),m=new Map;return await new Promise((p,h)=>{let b=d.filter(w=>w.jobs.length>0).length;if(b===0){p();return}let v=[],g=()=>{for(let w of v)w.terminate();a?.removeEventListener("abort",y)};function y(){g(),h(new DOMException("aborted","AbortError"))}if(a?.aborted){y();return}a?.addEventListener("abort",y,{once:!0});for(let w of d){if(w.jobs.length===0)continue;let x=new Worker(new URL("./workers/picture-worker.ts",import.meta.url),{type:"module"});v.push(x),x.onmessage=P=>{let T=P.data;if(T.progress)for(let S=0;S<T.progress;S++)u();if(T.results){for(let S of T.results)m.set(S.idx,S);--b===0&&(g(),p())}},x.onerror=P=>{g(),h(new Error(`picture worker error: ${P.message}`))};let O={file:e,jobs:w.jobs,primers:w.primers,spec:n,tier:i,want:r};x.postMessage(O)}}),t.map(p=>m.get(p.idx)??dH(p.idx))}var dae=16,mae=.075,pae=.12;function Ov(e){let t=0,n=0;for(let i=0;i<e.length;i++){let r=e[i];t+=r,r>n&&(n=r)}return t/e.length<=255*mae&&n<=255*pae}function pH(e,t){let n=Math.min(e.length,t.length);if(n===0)return 0;let i=0;for(let r=0;r<n;r++)i+=Math.abs(e[r]-t[r]);return i/n}var hae=1.5,bae=1,gae=30;function vae(e,t){let n=[];for(let i of t){let r=e.frames[i];r&&n.push({idx:i,offset:r.offset,size:r.size})}return n}async function Mv(e,t,n,i,r,o){if(!t.spec)return null;try{return await mH(e,vae(t,n),t.spec,i,r,{signal:o.signal,onProgress:o.onProgress})}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return null;throw a}}async function hH(e,t,n={}){let i;try{i=t??await wn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=Ca(i.frames.length,dae),o=await Mv(e,i,r,"exact",{bars:!0},n);if(!o)return null;let a=o.filter(g=>g.ok&&g.bars);if(a.length===0)return null;let{w:s,h:c}=a[0],l=vy(a.map(g=>g.bars),s,c),u=i.h>0&&c>0?i.h/c:1,f=i.w>0&&s>0?i.w/s:1,d=l?{x:Math.round(l.x*f),y:Math.round(l.y*u),w:Math.round(l.w*f),h:Math.round(l.h*u)}:null,m=d?J7(d,Math.round(s*f),Math.round(c*u)):null,p=Math.max(1,Math.round(u)),h=p>1?` (\xB1${p} px, measured at 1/${p} scale)`:"",b=`across ${a.length} sampled frame${a.length===1?"":"s"}`;return l==null||l.x===0&&l.y===0&&l.w===s&&l.h===c?{hasBlanking:!1,note:`none found ${b}`}:{hasBlanking:!0,note:`${m??"bars detected"}${h} ${b}`}}async function bH(e,t,n,i={}){let r;try{r=n??await wn(e)}catch{return null}if(!r.spec||r.frames.length===0)return null;let o=r.frames.length,a=Math.min(t,o),s=Math.max(a,o-t);if(s<=a)return null;let c=[];for(let p=a;p<s;p++)c.push(p);let l=await Mv(e,r,c,"exact",{},i);if(!l)return null;let u=[],f=0;for(let p of l)p.ok&&(f++,p.black&&u.push(p.idx));if(f===0)return null;let d=`${f} of ${s-a} 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 z6(e,t){let n=e/t,i=Math.floor(n/60);return`${i}:${(n-i*60).toFixed(2).padStart(5,"0")}`}async function gH(e,t,n={}){let i;try{i=t??await wn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=i.fps&&i.fps>0?i.fps:24,o=Math.min(i.frames.length,Math.round(r*gae)),a=[];for(let f=0;f<o;f++)a.push(f);let s=await Mv(e,i,a,"exact",{diff:!0},n);if(!s)return null;let c=[],l=[],u=0;for(let f=0;f<s.length;f++){let d=s[f];if(!d.ok){c.push(c[f-1]??!1),l.push(!1);continue}u++,c.push(d.black),l.push(d.diff==null?!1:d.diff>hae)}return u===0?null:yae(c,l,r)}function yae(e,t,n){let i=e.length,r=Math.max(2,Math.round(n*bae)),o=0;for(;o<i&&e[o];)o++;let a=o,s=-1,c=-1;for(;o<i;){if(e[o]){o++;continue}let f=o,d=o+1;for(;d<i&&!e[d]&&!t[d];)d++;if(d-f>=r){s=f,c=d;break}o=Math.max(d,o+1)}let l=null;for(let f=c>=0?c:a;f<i;f++)if(!e[f]){l=f;break}let u=[];return a>0&&u.push(`${(a/n).toFixed(2)} s black at head`),s>=0?u.push(`a static card ${z6(s,n)}\u2013${z6(c,n)} (${((c-s)/n).toFixed(2)} s)`):u.push(`no static card in the first ${(i/n).toFixed(0)} s`),l!=null&&u.push(`picture from ${z6(l,n)}`),{hasSlate:s>=0,programmeStart:l,note:u.join(", ")}}var wae=1200,xae=.5,Pae=.6,kae=.7,Sae=3;function Tae(e,t,n){let i=e.length;for(let r=n;r<i;r++){if(!e[r]||t[r])continue;let o=0,a=0;for(let s=r;s<i;s++)t[s]||(o++,e[s]&&a++);if(o>=3&&a>=o*kae)return r}return-1}async function vH(e,t,n={}){let i;try{i=t??await wn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=i.fps&&i.fps>0?i.fps:24,o=i.frames.length,a=Math.max(1,Math.round(r*xae),Math.ceil(o/wae)),s=[];for(let g=0;g<o;g+=a)s.push(g);let c=await Mv(e,i,s,"coarse",{hash:!0},n);if(!c)return null;let l=[],u=[],f=[];for(let g of c)!g.ok||!g.bits||(l.push(g.idx),u.push({bits:Uint32Array.from(g.bits),quality:g.q??0,meanY:g.my}),f.push(g.black));let d=u.length,m=`sampled every ${(a/r).toFixed(2)} s`;if(d<8)return null;let p=Math.floor(d*Pae);if(p<2)return null;let h=new Array(d).fill(!1);for(let g=p;g<d;g++)if(!f[g]){for(let y=0;y<p;y++)if(mn(u[g],u[y])<=Yn){h[g]=!0;break}}let b=Tae(h,f,p);if(b<0)return{hasTextlessTail:!1,note:`no repeated material at the tail (${m})`};let v=(l[d-1]-l[b])/r;return v<Sae?{hasTextlessTail:!1,note:`only ${v.toFixed(1)} s of repeated material at the tail, too short to be textless (${m})`}:{hasTextlessTail:!0,note:`${v.toFixed(1)} s from ${(l[b]/r/60).toFixed(0)}:${(l[b]/r%60).toFixed(2).padStart(5,"0")} repeats earlier picture (${m})`}}function zae(e){let t=e.toLowerCase().match(/\.([a-z0-9]{2,4})$/);return t?t[1]:void 0}function Oae(e){if(e===1)return"mono";if(e===2)return"stereo";if(e===6)return"5.1"}async function yH(e,t={}){let n={name:e.name,sizeBytes:e.size,wrapper:zae(e.name)},i;try{let r=await wn(e);i=r,n.width=r.w||void 0,n.height=r.h||void 0,n.fps=r.fps??void 0,n.durationFrames=r.frames.length||void 0;let o=r.index?.codec,a=uH(o??r.label);n.codec=o?a.label:r.label,n.bitDepth=a.bitDepth??void 0,n.chroma=a.chroma??void 0,r.fps&&Number.isFinite(r.startFrame)&&(n.startTimecode=Li(r.startFrame,r.fps,r.dropFrame))}catch{}if(t.audio!==!1){try{let r=await jp(e);r&&(n.audioChannels=r.channels,n.audioSampleRate=r.sampleRate,n.audioLayout=Oae(r.channels))}catch{}if(t.loudness!==!1)try{let r=await zv(e,{signal:t.signal,fps:n.fps});r.loudness?.integratedLufs!=null&&(n.loudnessLufs=r.loudness.integratedLufs),r.truePeakDb!=null&&(n.truePeakDb=r.truePeakDb),n.hasTwoPop=r.twoPop!==null}catch{}}if(t.picture?.blanking){let r=await hH(e,i,{signal:t.signal});r&&(n.hasBlanking=r.hasBlanking,n.blankingNote=r.note)}if(t.picture?.headStructure){let r=await gH(e,i,{signal:t.signal});r&&(n.hasSlate=r.hasSlate,n.slateNote=r.note)}if(t.picture?.textlessTail){let r=await vH(e,i,{signal:t.signal});r&&(n.hasTextlessTail=r.hasTextlessTail,n.textlessNote=r.note)}if(t.picture?.blackFrames){let r=n.fps&&n.fps>0?Math.round(n.fps):24,o=await bH(e,r,i,{signal:t.signal});o&&(n.hasBlackFrames=o.hasBlackFrames,n.blackFramesNote=o.note)}return n}function nf(e,t,n,i,r,o){let a=mi(e,t,n,i,(s,c)=>s===c,r);return o&&a.outcome!=="unstated"?{...a,note:o}:a}function O6(e,t){let n=t.plusMinus??0;return Math.abs(e-t.target)<=n+1e-9}function Mae(e){return e.plusMinus?`${e.target} \xB1${e.plusMinus}`:String(e.target)}function mi(e,t,n,i,r,o){if(n==null)return{field:e,label:t,outcome:"unstated"};let a=o.required(n.value);return i==null||typeof i=="number"&&!Number.isFinite(i)?{field:e,label:t,outcome:"unmeasurable",required:a,note:"not reported by the probe"}:{field:e,label:t,outcome:r(n.value,i)?"pass":"fail",required:a,measured:o.measured(i)}}var Qm={required:e=>e,measured:e=>e},rf={required:e=>String(e),measured:e=>String(e)},M6={required:Mae,measured:e=>String(e)};function wH(e,t){let n=e.video??{},i=e.audio??{},r=e.content??{};return[mi("video.codec","Codec",n.codec,t.codec,(o,a)=>fH(o,{family:null,label:a}),Qm),mi("video.wrapper","Wrapper",n.wrapper,t.wrapper,(o,a)=>o.toLowerCase()===a.toLowerCase(),Qm),mi("video.width","Width",n.width,t.width,(o,a)=>o===a,rf),mi("video.height","Height",n.height,t.height,(o,a)=>o===a,rf),mi("video.fps","Frame rate",n.fps,t.fps,(o,a)=>O6(a,o),M6),mi("video.durationFrames","Duration (frames)",n.durationFrames,t.durationFrames,(o,a)=>O6(a,o),M6),mi("video.startTimecode","Start timecode",n.startTimecode,t.startTimecode,(o,a)=>o===a,Qm),mi("video.par","Pixel aspect ratio",n.par,t.par,(o,a)=>Math.abs(o-a)<=.005,rf),mi("video.bitDepth","Bit depth",n.bitDepth,t.bitDepth,(o,a)=>o===a,rf),mi("video.chroma","Chroma",n.chroma,t.chroma,(o,a)=>hp(o)===hp(a),Qm),mi("audio.channels","Audio channels",i.channels,t.audioChannels,(o,a)=>o===a,rf),mi("audio.layout","Audio layout",i.layout,t.audioLayout,(o,a)=>o.toLowerCase()===a.toLowerCase(),Qm),mi("audio.sampleRate","Sample rate",i.sampleRate,t.audioSampleRate,(o,a)=>o===a,rf),mi("audio.loudnessLufs","Loudness (LUFS)",i.loudnessLufs,t.loudnessLufs,(o,a)=>O6(a,o),M6),mi("audio.truePeakDb","True peak (dBTP)",i.truePeakDb,t.truePeakDb,(o,a)=>a<=o+1e-9,{required:o=>`\u2264 ${o}`,measured:o=>o.toFixed(2)}),nf("content.twoPop","2-pop",r.twoPop,t.hasTwoPop,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"}),nf("content.slate","Slate",r.slate,t.hasSlate,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"},t.slateNote),nf("content.textlessAtTail","Textless at tail",r.textlessAtTail,t.hasTextlessTail,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"},t.textlessNote),nf("content.noBlanking","Free of blanking",r.noBlanking,t.hasBlanking==null?void 0:!t.hasBlanking,{required:o=>o?"no blanking":"blanking allowed",measured:o=>o?"none found":"blanking found"},t.blankingNote),nf("content.noBlackFrames","Free of black frames",r.noBlackFrames,t.hasBlackFrames==null?void 0:!t.hasBlackFrames,{required:o=>o?"no black frames":"black frames allowed",measured:o=>o?"none found":"black frames found"},t.blackFramesNote),nf("content.matchesMaster","Matches approved master",r.matchesMaster,t.matchesMaster,{required:o=>o?"must match":"need not match",measured:o=>o?"matches":"differs"})]}async function Lae(e,t){try{await oi();let n=await mr.open(e),i=Ws(n),r=JSON.parse(await Wa(i,n.size)||"null");if(!r||r.aac||!r.sample_rate||!r.sample_frames)return null;let o=r.sample_rate,a=r.sample_frames,s=0;for(let c=0;c<a;c+=o*10){let l=await Ha(i,n.size,c,Math.min(o*10,a-c));if(!l||l.length<12)break;let u=new DataView(l.buffer,l.byteOffset,l.byteLength),f=u.getUint32(4,!0),d=u.getUint32(8,!0);if(!d||!f)break;s=f,t(new Float32Array(l.slice(12,12+d*f*4).buffer),f,o)}return s?{tracks:1,channels:s,rate:o}:null}catch{return null}}async function L6(e,t,n){let i=await Wr();if(!i)return t===0?Lae(e,n):null;let r=new Deno.Command(i,{args:["audio",e,"--track",String(t)],stdout:"piped",stderr:"null"}).spawn(),o=r.stdout.getReader(),a=null,s=new Uint8Array(0);for(;;){let{value:c,done:l}=await o.read();if(l)break;let u=s.length?new Uint8Array([...s,...c]):c;if(!a){let m=u.indexOf(10);if(m<0){s=u;continue}if(a=JSON.parse(new TextDecoder().decode(u.subarray(0,m))),!a?.ok||!a.rate||!a.channels){await o.cancel();break}u=u.subarray(m+1)}let f=4*a.channels,d=u.length-u.length%f;d&&n(new Float32Array(u.slice(0,d).buffer),a.channels,a.rate),s=u.slice(d)}return await r.status,a?.ok&&a.rate&&a.channels?{tracks:a.tracks??1,channels:a.channels,rate:a.rate}:null}async function xH(e,t){let n=null,i=null,r=await L6(e,t,(a,s,c)=>{n??=new ef(s,c),i??=new tf(s),n.push(a),i.push(a)});if(!r||!n||!i)return null;let o=i.finish();return{track:t+1,tracks:r.tracks,channels:r.channels,rate:r.rate,lufs:n.finish().integratedLufs,peak_db:Number.isFinite(o)?o:null}}async function PH(e){let t=await xH(e,0);if(t){let o=[t];for(let a=1;a<t.tracks;a++){let s=await xH(e,a);s&&o.push(s)}return o.map(({track:a,channels:s,rate:c,lufs:l,peak_db:u})=>({track:a,channels:s,rate:c,lufs:l,peak_db:u}))}let i=(await Fn(e).catch(()=>null))?.streams?.filter(o=>o.kind==="audio").reduce((o,a)=>o+(a.channels??0),0)??0;if(!i)return[];let r=await zv(await mr.open(e)).catch(()=>null);return[{track:1,channels:i,rate:0,lufs:r?.loudness?.integratedLufs??null,peak_db:r?.truePeakDb??null}]}var Ts=e=>e==null?"\u2014":`${e.toFixed(1)}`;function Rae(e,t){if(!t.length)return[];let n=[],i=new Set;for(let r of e){if(r.lufs==null)continue;let o=t.map((c,l)=>({x:c,i:l,d:c.lufs==null?1/0:r.lufs-c.lufs})).sort((c,l)=>Math.abs(c.d)-Math.abs(l.d)),a=o.find(c=>Math.abs(c.d)<=.5&&c.x.channels===r.channels)??o.find(c=>Math.abs(c.d)<=.5),s=o.find(c=>c.d>=5&&c.d<=7);a&&i.add(a.i),n.push(a?{check:`Track ${r.track} vs mix`,outcome:a.x.channels===r.channels?"pass":"warn",measured:`= ${a.x.file} (${a.x.channels}ch, ${Ts(a.x.lufs)} LUFS, \u0394 ${a.d.toFixed(1)} LU)`,note:a.x.channels!==r.channels?"loudness matches but the channel count differs (downmix or wrong bus)":void 0}:{check:`Track ${r.track} vs mix`,outcome:"fail",measured:`${Ts(r.lufs)} LUFS`,note:s?`\u2248 +6 LU over ${s.x.file}: summed twice (two buses into one output, or a doubled track)`:`no mix file within 0.5 LU (nearest ${o[0]?.x.file??"\u2014"}: ${Ts(o[0]?.x.lufs??null)} LUFS)`})}return t.forEach((r,o)=>{i.has(o)||n.push({check:`Mix ${r.file}`,outcome:"warn",measured:`${r.channels}ch, ${Ts(r.lufs)} LUFS`,note:"no output track carries this mix (missing bus?)"})}),n}var Ss=e=>({value:e,source:"operator"});async function kH(e){let t=await mr.open(e.path),n=await yH(t,{loudness:!1}),i=e.fps??n.fps??24,r=g=>g==null?null:typeof g=="number"?g:Cn(g,i),o=r(e.mark_in),a=r(e.mark_out),s=await Di(),c=o!=null?Qt(o,i):e.start_tc??s.conventions?.program_start,l=e.end_on_picture??s.conventions?.end_on_picture,u=e.frames??(o!=null&&a!=null?a-o+1:void 0),f={label:Cc(e.path),video:{...e.codec?{codec:Ss(e.codec)}:{},...e.width?{width:Ss(e.width)}:{},...e.height?{height:Ss(e.height)}:{},...e.fps?{fps:Ss({target:e.fps,plusMinus:.001})}:{},...e.bit_depth?{bitDepth:Ss(e.bit_depth)}:{},...e.chroma?{chroma:Ss(e.chroma)}:{},...c?{startTimecode:Ss(c)}:{},...u?{durationFrames:Ss({target:u})}:{}}},d=wH(f,n).filter(g=>g.outcome!=="unstated").map(g=>({check:g.label,outcome:g.outcome==="pass"||g.outcome==="fail"?g.outcome:"unchecked",expected:g.required,measured:g.measured,note:g.note}));if(c||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 g=hl(s,Cc(e.path),{probe:await Fn(e.path)}),y=g.issues.filter(x=>x.level==="error"),w=g.issues.filter(x=>x.level==="warn");d.push({check:"Name",outcome:y.length?"fail":w.length?"warn":"pass",measured:Cc(e.path),note:g.issues.map(x=>`${x.element}: ${x.message}`).join("; ")||void 0})}catch(g){d.push({check:"Name",outcome:"unchecked",note:String(g.message??g)})}try{let g=await wn(t),y=n.durationFrames??g.frames.length,w=g.spec?null:la(e.path,256),x=g.spec?await Yo(t):null,O=async X=>{let V=w?await w.read(X):await x.luma(X);return V?Ov(V.y):null},P=async(X,V)=>{let R=Math.round(5*i),j=0;for(;j<R&&X+V*j>=0&&X+V*j<y&&await O(X+V*j);)j++;return j},[T,S]=[await O(0),await O(y-1)],k=T?await P(0,1):0,L=S?await P(y-1,-1):0,z=X=>X>=Math.round(5*i)?"5 s or more":`${X} frame(s)`;d.push({check:"First frame",outcome:T==null?"unchecked":T?"warn":"pass",measured:T==null?void 0:T?`black (${z(k)})`:"picture"}),d.push({check:"Last frame",outcome:S==null?"unchecked":S?l?"fail":"warn":"pass",measured:S==null?void 0:S?`black (last ${z(L)})`:"picture",note:S?l?"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 PH(e.path),p=m.reduce((g,y)=>g+y.channels,0);e.channels!=null&&d.push({check:"Audio channels",outcome:p===e.channels?"pass":"fail",expected:String(e.channels),measured:`${p} (${m.map(g=>`track ${g.track}: ${g.channels}ch`).join(", ")||"no audio"})`});for(let g of m){let y=e.loudness_lufs==null||g.lufs==null?null:Math.abs(g.lufs-e.loudness_lufs)<=(e.loudness_tolerance??1),w=e.true_peak==null||g.peak_db==null?null:g.peak_db<=e.true_peak;d.push({check:`Audio track ${g.track}`,outcome:y===!1||w===!1?"fail":g.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:`${g.channels}ch${g.rate?` ${g.rate/1e3} kHz`:""}, ${Ts(g.lufs)} LUFS, ${Ts(g.peak_db)} dBTP`})}let h=m.find(g=>g.channels===2)??m[0],b=s.conventions?.theatrical_tag;if(b&&h?.lufs!=null&&e.name!==!1){let g=new RegExp(`[_\\-. ]${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}([_\\-. ]|$)`,"i").test(Cc(e.path));g&&h.lufs>-20&&d.push({check:`${b} tag`,outcome:"warn",measured:`${Ts(h.lufs)} LUFS on track ${h.track}`,note:`tagged ${b} (theatrical) but measures at a web/nearfield level`}),!g&&h.lufs<-27&&d.push({check:`${b} tag`,outcome:"warn",measured:`${Ts(h.lufs)} LUFS on track ${h.track}`,note:`measures at a theatrical level: add _${b} 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 v=[];for(let g of e.mix??[]){let y=await PH(g);y.length||d.push({check:`Mix ${Cc(g)}`,outcome:"unchecked",measured:"no audio read from this file"});for(let w of y)v.push({...w,file:Cc(g)})}if(d.push(...Rae(m,v)),e.ref)try{let g=await Pv({a:e.path,b:e.ref,b_in:e.ref_in??n.startTimecode??c}),y=g.overall;d.push({check:"Picture vs REF",outcome:y.verdict==="exact"?"pass":y.verdict==="unverifiable"?"warn":"fail",measured:y.verdict==="offset"?`offset ${y.offset>0?"+":""}${y.offset} frame(s)`:y.verdict,expected:`exact at ${g.b_tc}`,note:[...g.shots.filter(w=>w.verdict!=="exact").slice(0,5).map(w=>`shot ${w.a_tc}: ${w.verdict}${w.offset?` ${w.offset>0?"+":""}${w.offset}`:""}`),...g.flash].join("; ")||void 0})}catch(g){d.push({check:"Picture vs REF",outcome:"unchecked",note:String(g.message??g)})}return{file:Cc(e.path),verdict:d.some(g=>g.outcome==="fail")?"FAIL":"PASS",rows:d,tracks:m,mix:v}}function SH(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(`
184
- `)}import{basename as TH}from"node:path";var Nae=10**(-60/20);async function Xae(e,t){let i=(await Fn(e).catch(()=>null))?.vendor_metadata?.bext,r=0,o=-1,a=0,s=0,c=[];if(!await L6(e,0,(p,h,b)=>{a=b,s=h;for(let v=0;v<p.length;v+=h){let g=0,y=0;for(let w=0;w<h;w++){let x=Math.abs(p[v+w]);x>g&&(g=x),y+=p[v+w]}g>Nae&&(o=r),r<b*15&&c.push(y/h),r++}}))return null;let u=Yy(i?.time_reference??0,i?.sample_rate||a,r,t),f=Cn(u.tc,t)??0,d=p=>f+Math.floor(p*u.frames/Math.max(r,1)),m=Tv(Float32Array.from(c),a,{fps:t});return{file:TH(e),channels:s,start:f,end:f+u.frames,last_sound:o<0?f:d(o)+1,pop:m?d(m.atSeconds*a):null}}function jae(e){let t=e.toUpperCase().split(/[_.]/),n=[];for(let r of t)r==="5-1"?n.push({label:"5.1",channels:6}):r==="7-1"?n.push({label:"7.1",channels:8}):r==="STEREO"||r==="LORO"?n.push({label:r==="LORO"?"LoRo":"stereo",channels:2}):r==="MONO"&&n.push({label:"mono",channels:1});let i=t.map(r=>/^(\d+)CH$/.exec(r)).find(Boolean);return{total:i?Number(i[1]):null,parts:n}}async function zH(e,t){let n=$g(e,t.timeline_id),i=Zc(n),r=!!n.is_drop_frame,o=x=>Qt(x,i,r),a=n.tracks.filter(x=>x.kind==="Video"),s=ev(n,a),c=[];if(!s.length)throw new Error("the timeline has no enabled video");let l=s[0].s,u=s[s.length-1].e,f=[];for(let x of t.mix??[]){let O=await Xae(x,i);O?f.push(O):c.push({check:`Mix ${TH(x)}`,outcome:"unchecked",measured:"no audio read from this file"})}let d=f[0],m=t.program_start??(await Di()).conventions?.program_start,p=m?Cn(m,i):null,h=d?.pop!=null?d.pop+Math.round(2*i):null,b=h??(p!=null&&p>=l-Math.round(10*i)?p:l);d&&c.push(d.pop!=null?{check:"2-pop",outcome:p==null||h===p?"pass":"warn",measured:`${o(d.pop)} in ${d.file} \u2192 program starts ${o(h)}`,note:p!=null&&h!==p?`the stated start is ${o(p)}`:void 0}:{check:"2-pop",outcome:"warn",measured:`none found in the first 15 s of ${d.file}`,note:`program start taken as ${o(b)}`});let v=d?d.last_sound:u;if(d){let x=u-d.last_sound;c.push({check:"Picture end vs mix end",outcome:x===0?"pass":"fail",measured:`picture ends ${o(u-1)} (last frame), sound ends ${o(d.last_sound-1)}`,note:x===0?void 0:x<0?`picture stops ${-x} frame(s) before the mix: ${-x} frame(s) of black under sound. EDIT ERROR: extend the last shot/card, or ask`:`picture runs ${x} frame(s) past the mix: picture with no sound at the end. EDIT ERROR: ask before trimming`});for(let O of f.slice(1))O.last_sound!==d.last_sound&&c.push({check:`Mix ${O.file} end`,outcome:"warn",measured:`sound ends ${o(O.last_sound-1)}`,note:`${d.file} ends ${o(d.last_sound-1)}`});d.start>b&&c.push({check:"Mix start",outcome:"fail",measured:`${d.file} starts ${o(d.start)}`,note:`after the program start ${o(b)}: no sound under the first frames`})}l>b&&c.push({check:"Picture start",outcome:"fail",measured:`first picture ${o(l)}`,note:`${l-b} frame(s) of black after the program start ${o(b)}`});let g=s.find(x=>x.s<=v-1&&x.e>=v);c.push({check:"Last program frame",outcome:g?"pass":"fail",measured:g?`${o(v-1)}: ${g.it.name??"clip"} (${g.track})`:`${o(v-1)}: no picture`,note:g?"confirm it is the end card, not black inside the clip":"the program ends on a gap"});let y=[],w=b;for(let x of s)if(!(x.e<=b)){if(x.s>=v)break;x.s>w&&y.push([w,Math.min(x.s,v)]),w=Math.max(w,x.e)}w<Math.min(v,u)&&y.push([w,Math.min(v,u)]),c.push(y.length?{check:"Gaps in the program",outcome:"warn",measured:y.map(([x,O])=>`${o(x)}\u2013${o(O-1)} (${O-x} 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 x of a){if(x.enabled===!1)continue;let O=x.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),P=Math.max(...O,-1/0);P>Math.min(v,u)-Math.round(i)&&P<Math.min(v,u)&&c.push({check:`Track ${Ci(x,n.tracks)}`,outcome:"warn",measured:`ends ${Math.min(v,u)-P} frame(s) before the picture ends`,note:"an effect/adjustment layer should cover the whole program"})}if(t.name){let x=jae(t.name),O=x.parts.reduce((P,T)=>P+T.channels,0);if(x.total!=null&&x.parts.length&&O!==x.total)c.push({check:"Name audio",outcome:"fail",measured:t.name,note:`${x.total}CH but ${x.parts.map(P=>P.label).join(" + ")} = ${O} channels`});else if(x.parts.length&&f.length){let P=[...f],T=x.parts.filter(S=>{let k=P.findIndex(L=>L.channels===S.channels);return k<0?!0:(P.splice(k,1),!1)});c.push({check:"Name audio vs mix",outcome:T.length?"fail":"pass",measured:`${x.parts.map(S=>`${S.label} (${S.channels}ch)`).join(" + ")} = ${O}ch`,note:T.length?`no ${T.map(S=>`${S.channels}ch mix for ${S.label}`).join(", ")} among ${f.map(S=>`${S.file} (${S.channels}ch)`).join(", ")}`:"route each to an output track in this order (host_render audio_tracks), then qc_deliverable the render"})}}return{verdict:c.some(x=>x.outcome==="fail"||x.outcome==="unchecked"&&x.check.startsWith("Mix "))?"STOP":"READY",rows:c,mark_in:o(b),mark_out:o(v-1),program:[b,v],mix:f}}function OH(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(`
185
- `)}import{basename as R6}from"node:path";var Fae=[[4/3,"1.33 (4:3)"],[1.66,"1.66"],[16/9,"1.78 (16:9)"],[1.85,"1.85"],[1.9,"1.90 (DCI)"],[2,"2.00"],[2.2,"2.20"],[2.35,"2.35"],[2.39,"2.39"],[2.4,"2.40"],[2.76,"2.76"]];function Iae(e){let t=Fae.reduce((n,i)=>Math.abs(i[0]-e)<Math.abs(n[0]-e)?i:n);return Math.abs(t[0]-e)/e<=.015?t[1]:e.toFixed(2)}async function MH(e,t=16){let n=await mr.open(e),i=await wn(n).catch(()=>null),r=i?null:await Ks(e),o=i?.w??r.w,a=i?.h??r.h,s=i?.frames.length??r.frames;if(!o||!a||!s)throw new Error(`${R6(e)}: no raster or frames in the probe`);let c=i?.spec?null:la(e,640),l=i?.spec?await Yo(n):null,u=[];for(let P of Ca(s,t)){let T=c?await c.read(P):await l.luma(P);T&&u.push({luma:T.y,w:T.w,h:T.h})}if(!u.length)throw new Error(`${R6(e)}: no frame decoded`);let f=u[0].w,d=u[0].h,m=rl(u)??{x:0,y:0,w:f,h:d},p=o/f,h=a/d,b={x:Math.round(m.x*p),y:Math.round(m.y*h),w:Math.round(m.w*p),h:Math.round(m.h*h)},v=b.h<a-2,g=b.w<o-2,y=v&&g?"windowbox":v?"letterbox":g?"pillarbox":"none",w=b.w/b.h,x=P=>2*Math.round(P/2),O=y==="pillarbox"?`${x(a*w)}x${a}`:`${o}x${x(o/w)}`;return{file:R6(e),width:o,height:a,frames_sampled:u.length,active:b,boxing:y,aspect:+w.toFixed(4),aspect_name:Iae(w),oar_raster:y==="none"?`${o}x${a}`:O}}function LH(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}`}
186
- (${e.frames_sampled} frames sampled across the clip; a bar counts only when \u226580% of them carry it)`}var EH=/lower ?thirds?|\bLTs?\b|titles?|subtitles?|\bsubs\b|captions?|graphics?|\bgfx\b|\btext\b|supers?/i,Eae=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,zi=e=>[e.timeline_range.start.value,e.timeline_range.start.value+e.timeline_range.duration.value],RH=e=>EH.test(e.name??"")||e.items.some(t=>t.kind!=="gap")&&e.items.every(t=>t.kind==="gap"||!!t.title),_m=e=>e.enabled!==!1&&(e.kind==="clip"||e.kind==="nested"),NH=e=>`V${e.track_index}${e.name?` "${e.name}"`:""}`,Vae=/\b(TEXTED|TEXTLESS|MASTER|MEZZ(ANINE)?)(\b|_)/i,XH=300,Wae=60;function VH(e,t,n={}){let i=e.timelines.filter(R=>R.kind!=="compound"),r=n.timeline_id?i.find(R=>R.id===n.timeline_id):i.find(R=>R.tracks.some(j=>j.kind==="Video"&&j.items.length));if(!r)throw new Te("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 Te("invalid_args","changes is empty: give clip ids or record ranges");let o=Eae(r),a=r.start_frame??0,s=!!r.is_drop_frame,c=R=>Qt(R+a,o,s),l=[],u=r.tracks.filter(R=>R.kind==="Video"&&R.enabled!==!1).sort((R,j)=>j.track_index-R.track_index),f=new Set,d=(R,j)=>u.some(J=>J.track_index<R.track_index&&J.items.some(q=>_m(q)&&zi(q)[0]<zi(j)[1]&&zi(q)[1]>zi(j)[0]));for(let R of u)for(let j of R.items)!_m(j)||j.title||(Vae.test(j.name??"")||j.timeline_range.duration.value>=XH*o&&d(R,j))&&f.add(j);f.size&&l.push(`baked picture (a laid-back master, or a clip of ${XH/60} min or more) left out of the cut points, the edits under it decide: ${[...f].map(R=>`"${R.name??R.id}" ${c(zi(R)[0])}\u2013${c(zi(R)[1]-1)}`).join(", ")}`);let m=R=>_m(R)&&!f.has(R),p=u.filter(RH),h=u.filter(R=>!RH(R));for(let R of r.tracks)R.kind==="Video"&&R.enabled===!1&&EH.test(R.name??"")&&R.items.some(_m)&&l.push(`${NH(R)} is a graphics track but disabled: left out of TEXTED too; enable it if the master carries it`);let b=Math.max(0,...u.flatMap(R=>R.items.filter(_m).map(j=>zi(j)[1]))),v=new Set([0,b]);for(let R of h)for(let j of R.items)m(j)&&zi(j).forEach(J=>v.add(J));let g=[...v].filter(R=>R>=0&&R<=b).sort((R,j)=>R-j),y=[];for(let R=0;R+1<g.length;R++){let[j,J]=[g[R],g[R+1]],q={start:j,end:J,item:null,track:null};for(let F of h){let H=F.items.find(C=>m(C)&&zi(C)[0]<=j&&zi(C)[1]>=J);if(H){q={start:j,end:J,item:H,track:F};break}}let W=y[y.length-1];W&&W.item===q.item?W.end=J:y.push(q)}let w=[...p.flatMap(R=>R.items.filter(m).map(zi)),...u.flatMap(R=>R.items.filter(j=>j.kind==="transition").map(zi))],x=new Set([0,b,...y.map(R=>R.start)].filter(R=>!w.some(([j,J])=>j<R&&R<J))),O=R=>Math.max(...[...x].filter(j=>j<=R)),P=R=>Math.min(...[...x].filter(j=>j>=R)),T=R=>y.find(j=>j.start<=R&&R<j.end),S=new Map(r.tracks.flatMap(R=>R.items.map(j=>[j.id,j]))),k=R=>{if(typeof R=="number")return R-a;let j=Cn(R,o);if(j==null){if(/^\d+$/.test(R))return Number(R)-a;throw new Te("invalid_args",`cannot read '${R}' as a record timecode`)}return j-a},L=t.map(R=>{if(typeof R=="string"){let q=S.get(R);if(!q)throw new Te("not_found",`no clip ${R} on ${r.name} (item ids come from timeline_query)`);return[...zi(q)]}let[j,J]=[k(R.in),k(R.out)+1];if(J<=j)throw new Te("invalid_args",`range ${R.in}..${R.out} is empty or backwards`);return[j,J]}).sort((R,j)=>R[0]-j[0]);for(let[R,j]of L)if(R<0||j>b)throw new Te("invalid_args",`change ${c(R)}\u2013${c(j-1)} is outside the timeline (${c(0)}\u2013${c(b-1)})`);let z=[];for(let[R,j]of L){let J=R>0?T(R-1):void 0,q=j<b?T(j):void 0,W=O(J?.item?J.start:R),F=P(q?.item?q.end:j),H=z[z.length-1];H&&W<=H.tail?(H.tail=Math.max(H.tail,F),H.changes.push([R,j])):z.push({head:W,tail:F,changes:[[R,j]]})}let X=R=>R.item?R.item.name??R.item.reel_name??R.item.id:"(black)",V=z.map((R,j)=>{let J=y.filter(oe=>oe.end>R.head&&oe.start<R.tail),q=oe=>R.changes.some(([ye,Ae])=>oe.end>ye&&oe.start<Ae),W=J.findIndex(q),F=J.length-1-[...J].reverse().findIndex(q),H=J.map((oe,ye)=>({role:q(oe)?"changed":ye===W-1?"before":ye===F+1?"after":"inside",name:X(oe),track:oe.track?NH(oe.track):"-",rec_in_tc:c(oe.start),frames:oe.end-oe.start})),C=p.filter(oe=>oe.items.some(ye=>m(ye)&&zi(ye)[1]>R.head&&zi(ye)[0]<R.tail)),$=[];for(let oe of H)(oe.role==="before"||oe.role==="after")&&oe.frames>Wae*o&&$.push(`the ${oe.role} clip "${oe.name}" runs ${Math.round(oe.frames/o)} s: check it is a real shot, not baked picture`);return H.some(oe=>oe.role==="before")||$.push("no clip before the change (timeline head or black): starts on the change"),H.some(oe=>oe.role==="after")||$.push("no clip after the change (timeline tail or black): ends on the change"),C.length||$.push("no graphics in range: one render serves TEXTED and TEXTLESS"),{nn:(n.first_patch??1)+j,range:{in:R.head+a,out:R.tail-1+a},frames:R.tail-R.head,rec_in_tc:c(R.head),rec_out_tc:c(R.tail-1),start_tc:c(R.head),versions:C.length?["TEXTED","TEXTLESS"]:["TEXTED"],textless_exclude_tracks:C.map(oe=>({index:oe.track_index,name:oe.name??null})),audio:!1,neighbours:H,notes:$}});return{timeline:r.name,fps:o,start_tc:c(0),patches:V,warnings:l}}function WH(e){let t=`${e.patches.length} patch${e.patches.length===1?"":"es"} on ${e.timeline}: `+e.patches.map(i=>`PATCH${String(i.nn).padStart(2,"0")} ${i.rec_in_tc}\u2013${i.rec_out_tc} (${i.frames} fr, ${i.versions.join("+")})`).join("; "),n=e.patches.flatMap(i=>[`PATCH${String(i.nn).padStart(2,"0")}: record ${i.rec_in_tc}\u2013${i.rec_out_tc} inclusive, ${i.frames} frames; host_render range {in:${i.range.in}, out:${i.range.out}}; file TC ${i.start_tc}; picture only`,...i.neighbours.map(r=>` ${r.role.padEnd(7)} ${r.rec_in_tc} ${String(r.frames).padStart(5)} fr ${r.track} ${r.name}`),i.textless_exclude_tracks.length?` TEXTLESS: leave out ${i.textless_exclude_tracks.map(r=>`V${r.index}${r.name?` "${r.name}"`:""}`).join(", ")}`:"",...i.notes.map(r=>` note: ${r}`)].filter(Boolean));return[t,...n,...e.warnings.map(i=>`warning: ${i}`)].join(`
187
- `)}var of=64;function jH(e,t,n){let i=Math.max(1,Math.round(of*n/t)),r=new Float32Array(of*i),o=new Uint32Array(of*i);for(let a=0;a<n;a++){let s=Math.min(i-1,Math.floor(a*i/n))*of;for(let c=0;c<t;c++){let l=(a*t+c)*4,u=s+Math.min(of-1,Math.floor(c*of/t));r[u]+=(e[l]+2*e[l+1]+e[l+2])/4,o[u]++}}for(let a=0;a<r.length;a++)r[a]/=o[a]||1;return r}var FH=async(e,t,n,i)=>{try{let r=0,o=0;await Vf(e,a=>{r=a.w,o=a.h},(a,s)=>i(a-t,jH(s,r,o)),{width:256,from:t,count:n})}catch(r){if(!/not installed|missing/.test(String(r)))throw r;let o=(await Fn(e)).streams?.find(a=>a.kind==="video");for(let a=0;a<n;a++){let s=await dl(e,t+a,o?.codec??"");i(a,jH(s.rgba,s.width,s.height))}}};function IH(e){let t=e.streams?.find(i=>i.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}}var Hae=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)).slice(0,8),t=>t.toString(16).padStart(2,"0")).join("");async function N6(e,t,n){let i=[];return await Vf(e,()=>{},(r,o)=>{r>=t&&r<t+n&&(i[r-t]=Hae(o))},{from:t,count:n}),Promise.all(Array.from({length:n},(r,o)=>i[o]??Promise.resolve(void 0)))}async function Zae(e){let t=Math.max(2,Math.round(e.fps*2)),n=[];for(let[i,r]of[["head",e.offset],["tail",e.offset+e.frames]]){let o=Math.max(0,r-t),a=Math.min(e.mframes,r+t),s=a-o;if(s<=0)continue;let c=await N6(e.master,o,s),l=Math.max(o,e.offset),u=Math.min(a,e.offset+e.frames),f=u>l?await N6(e.patch,l-e.offset,u-l):[],d=e.original?await N6(e.original,o,s):null,m=0,p=0,h=0,b=0;c.forEach((g,y)=>{let w=o+y;w>=l&&w<u?(p++,(!g||g!==f[w-l])&&m++):d&&(b++,(!g||g!==d[y])&&h++)});let v=c.filter(g=>!g).length;n.push({seam:i,tc:Qt(e.master_tc+r,e.fps),frames:[o,a-1],inside:p?m?`${m}/${p} frames differ from the patch`:`${p} frames = the patch`:"\u2014",outside:d?h?`${h}/${b} frames differ from the original`:`${b} frames = the original`:"no original given (pass original= a backup to prove the neighbours)",undecoded:v,ok:!m&&!h&&!v})}return n}async function HH(e,t=FH,n){let[i,r]=await Promise.all([Fn(e.patch),Fn(e.master)]),o=IH(i),a=IH(r),s=Object.keys(o).map(x=>({field:x,patch:o[x],master:a[x],ok:o[x]===a[x]})),c=i.available_range?.duration.value??i.declared_duration?.value??0,l=r.available_range?.duration.value??r.declared_duration?.value??0,u=o.fps||a.fps,f=[];e.expected_frames!=null&&f.push({what:"frames",ok:c===e.expected_frames,detail:`${c} frames, expected ${e.expected_frames}`});let d=i.source_timecode??null,m=r.source_timecode??null;e.expected_tc&&f.push({what:"start TC",ok:d!=null&&Cn(d,u)===Cn(e.expected_tc,u),detail:`starts ${d??"with no TC"}, expected ${e.expected_tc}`});let p=i.streams?.filter(x=>x.kind==="audio").length??0;f.push({what:"picture only",ok:p===0,detail:p?`${p} audio track(s)`:"no audio"});let h=null,b=[],v=[],g=d?Cn(d,u):null,y=m?Cn(m,u):null;if(g==null||y==null)f.push({what:"position in master",ok:!1,detail:"no start TC on the patch or the master: cannot place it"});else if(g-y<0||g-y+c>l)f.push({what:"position in master",ok:!1,detail:`${d} + ${c} fr is outside the master (${m}, ${l} fr)`});else{h=g-y,f.push({what:"position in master",ok:!0,detail:`master frames ${h}\u2013${h+c-1}`});let x=[];await t(e.patch,0,c,(S,k)=>{x[S]=k,n?.(S+1,c*2,"decoding the patch")});let O=null,P=[];await t(e.master,h,c,(S,k)=>{let L=x[S];if(n?.(c+S+1,c*2,"comparing with the master"),!L){P.push(S);return}let z=0,X=0;for(let V=0;V<L.length;V++){let R=Math.abs(L[V]-k[V]);z+=R,R>X&&(X=R)}if(X>(e.tolerance??10)&&b.push({frame:S,tc:Qt((g??0)+S,u),mean:Math.round(z/L.length*10)/10,max:Math.round(X)}),O){let V=0;for(let R=0;R<L.length;R++)V+=Math.abs(L[R]-O[R]);V/L.length>12&&v.push(Qt((g??0)+S,u))}O=L});let T=c-x.filter(Boolean).length;T&&f.push({what:"decode",ok:!1,detail:`${T} patch frame(s) did not decode`}),f.push({what:"picture vs master",ok:!b.length,detail:b.length?`${b.length}/${c} frames differ (first ${b[0].tc})`:`all ${c} frames match at the same TC`})}let w;if(h!=null&&t===FH)try{w=await Zae({master:e.master,patch:e.patch,original:e.original,offset:h,frames:c,mframes:l,fps:u,master_tc:y??0});let x=w.filter(P=>!P.ok);w.length&&w.every(P=>/^(\d+)\/\1 frames differ from the patch$/.test(P.inside)&&!P.undecoded)?(f.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):f.push({what:"seam decode",ok:!x.length,detail:x.length?x.map(P=>`${P.seam} ${P.tc}: ${[P.inside,P.outside,P.undecoded?`${P.undecoded} undecoded`:""].filter(Boolean).join("; ")}`).join(" | "):`${w.length} seam(s): every frame decodes and matches${e.original?"":" the patch (neighbours unchecked: no original)"}`})}catch(x){if(!/not installed|missing/.test(String(x)))throw x}return{ok:s.every(x=>x.ok)&&f.every(x=>x.ok),spec:s,frames:c,start_tc:d,master_offset:h,checks:f,mismatches:b,shot_changes:v,seams:w}}function ZH(e,t){let n=[...e.spec.filter(i=>!i.ok).map(i=>i.field),...e.checks.filter(i=>!i.ok).map(i=>i.what)];return[`${e.ok?"PASS":"FAIL"}: ${te(t.patch)} vs ${te(t.master)}${n.length?` (${n.join(", ")})`:""}`,...e.spec.map(i=>` ${i.ok?"ok ":"DIFF"} ${i.field}: ${i.patch??"-"}${i.ok?"":` (master ${i.master??"-"})`}`),...e.checks.map(i=>` ${i.ok?"ok ":"FAIL"} ${i.what}: ${i.detail}`),...e.mismatches.slice(0,40).map(i=>` frame ${i.frame} @ ${i.tc}: mean diff ${i.mean}, max ${i.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(i=>` seam ${i.seam} ${i.tc} (master frames ${i.frames[0]}\u2013${i.frames[1]}): ${i.ok?"ok":"FAIL"} \u2014 inside: ${i.inside}; outside: ${i.outside}${i.undecoded?`; ${i.undecoded} undecoded`:""}`)].filter(Boolean).join(`
188
- `)}var KH=Z8(n4(),1);function X6(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var Dae=ArrayBuffer,zr=Uint8Array,Lv=Uint16Array,qae=Int16Array;var Rv=Int32Array,j6=function(e,t,n){if(zr.prototype.slice)return zr.prototype.slice.call(e,t,n);(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var i=new zr(n-t);return i.set(e.subarray(t,n)),i},ep=function(e,t,n,i){if(zr.prototype.fill)return zr.prototype.fill.call(e,t,n,i);for((n==null||n<0)&&(n=0),(i==null||i>e.length)&&(i=e.length);n<i;++n)e[n]=t;return e},Uae=function(e,t,n,i){if(zr.prototype.copyWithin)return zr.prototype.copyWithin.call(e,t,n,i);for((n==null||n<0)&&(n=0),(i==null||i>e.length)&&(i=e.length);n<i;)e[t++]=e[n++]};var Cae=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],Xr=function(e,t,n){var i=new Error(t||Cae[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,Xr),!n)throw i;return i},DH=function(e,t,n){for(var i=0,r=0;i<n;++i)r|=e[t++]<<(i<<3);return r},Jae=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Kae=function(e,t){var n=e[0]|e[1]<<8|e[2]<<16;if(n==3126568&&e[3]==253){var i=e[4],r=i>>5&1,o=i>>2&1,a=i&3,s=i>>6;i&8&&Xr(0);var c=6-r,l=a==3?4:a,u=DH(e,c,l);c+=l;var f=s?1<<s:r,d=DH(e,c,f)+(s==1&&256),m=d;if(!r){var p=1<<10+(e[5]>>3);m=p+(p>>3)*(e[5]&7)}m>2145386496&&Xr(1);var h=new zr((t==1?d||m:t?0:m)+12);return h[0]=1,h[4]=4,h[8]=8,{b:c+f,y:0,l:0,d:u,w:t&&t!=1?t:h.subarray(12),e:m,o:new Rv(h.buffer,0,3),u:d,c:o,m:Math.min(131072,m)}}else if((n>>4|e[3]<<20)==25481893)return Jae(e,4)+8;Xr(0)},Jc=function(e){for(var t=0;1<<t<=e;++t);return t-1},tp=function(e,t,n){var i=(t<<3)+4,r=(e[t]&15)+5;r>n&&Xr(3);for(var o=1<<r,a=o,s=-1,c=-1,l=-1,u=o,f=new Dae(512+(o<<2)),d=new qae(f,0,256),m=new Lv(f,0,256),p=new Lv(f,512,o),h=512+(o<<1),b=new zr(f,h,o),v=new zr(f,h+o);s<255&&a>0;){var g=Jc(a+1),y=i>>3,w=(1<<g+1)-1,x=(e[y]|e[y+1]<<8|e[y+2]<<16)>>(i&7)&w,O=(1<<g)-1,P=w-a-1,T=x&O;if(T<P?(i+=g,x=T):(i+=g+1,x>O&&(x-=P)),d[++s]=--x,x==-1?(a+=x,b[--u]=s):a-=x,!x)do{var S=i>>3;c=(e[S]|e[S+1]<<8)>>(i&7)&3,i+=2,s+=c}while(c==3)}(s>255||a)&&Xr(0);for(var k=0,L=(o>>1)+(o>>3)+3,z=o-1,X=0;X<=s;++X){var V=d[X];if(V<1){m[X]=-V;continue}for(l=0;l<V;++l){b[k]=X;do k=k+L&z;while(k>=u)}}for(k&&Xr(0),l=0;l<o;++l){var R=m[b[l]]++,j=v[l]=r-Jc(R);p[l]=(R<<j)-o}return[i+7>>3,{b:r,s:b,n:v,t:p}]},Gae=function(e,t){var n=0,i=-1,r=new zr(292),o=e[t],a=r.subarray(0,256),s=r.subarray(256,268),c=new Lv(r.buffer,268);if(o<128){var l=tp(e,t+1,6),u=l[0],f=l[1];t+=o;var d=u<<3,m=e[t];m||Xr(0);for(var p=0,h=0,b=f.b,v=b,g=(++t<<3)-8+Jc(m);g-=b,!(g<d);){var y=g>>3;if(p+=(e[y]|e[y+1]<<8)>>(g&7)&(1<<b)-1,a[++i]=f.s[p],g-=v,g<d)break;y=g>>3,h+=(e[y]|e[y+1]<<8)>>(g&7)&(1<<v)-1,a[++i]=f.s[h],b=f.n[p],p=f.t[p],v=f.n[h],h=f.t[h]}++i>255&&Xr(0)}else{for(i=o-127;n<i;n+=2){var w=e[++t];a[n]=w>>4,a[n+1]=w&15}++t}var x=0;for(n=0;n<i;++n){var O=a[n];O>11&&Xr(0),x+=O&&1<<O-1}var P=Jc(x)+1,T=1<<P,S=T-x;for(S&S-1&&Xr(0),a[i++]=Jc(S)+1,n=0;n<i;++n){var O=a[n];++s[a[n]=O&&P+1-O]}var k=new zr(T<<1),L=k.subarray(0,T),z=k.subarray(T);for(c[P]=0,n=P;n>0;--n){var X=c[n];ep(z,n,X,c[n-1]=X+s[n]*(1<<P-n))}for(c[0]!=T&&Xr(0),n=0;n<i;++n){var V=a[n];if(V){var R=c[V];ep(L,n,R,c[V]=R+(1<<P-V))}}return[t,{n:z,b:P,s:L}]},Aae=tp(new zr([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Bae=tp(new zr([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Yae=tp(new zr([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],qH=function(e,t){for(var n=e.length,i=new Rv(n),r=0;r<n;++r)i[r]=t,t+=1<<e[r];return i},F6=new zr(new Rv([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Qae=qH(F6,0),I6=new zr(new Rv([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),_ae=qH(I6,3),$m=function(e,t,n){var i=e.length,r=t.length,o=e[i-1],a=(1<<n.b)-1,s=-n.b;o||Xr(0);for(var c=0,l=n.b,u=(i<<3)-8+Jc(o)-l,f=-1;u>s&&f<r;){var d=u>>3,m=(e[d]|e[d+1]<<8|e[d+2]<<16)>>(u&7);c=(c<<l|m)&a,t[++f]=n.s[c],u-=l=n.n[c]}(u!=s||f+1!=r)&&Xr(0)},$ae=function(e,t,n){var i=6,r=t.length,o=r+3>>2,a=o<<1,s=o+a;$m(e.subarray(i,i+=e[0]|e[1]<<8),t.subarray(0,o),n),$m(e.subarray(i,i+=e[2]|e[3]<<8),t.subarray(o,a),n),$m(e.subarray(i,i+=e[4]|e[5]<<8),t.subarray(a,s),n),$m(e.subarray(i),t.subarray(s),n)},ese=function(e,t,n){var i,r=t.b,o=e[r],a=o>>1&3;t.l=o&1;var s=o>>3|e[r+1]<<5|e[r+2]<<13,c=(r+=3)+s;if(a==1)return r>=e.length?void 0:(t.b=r+1,n?(ep(n,e[r],t.y,t.y+=s),n):ep(new zr(s),e[r]));if(!(c>e.length)){if(a==0)return t.b=c,n?(n.set(e.subarray(r,c),t.y),t.y+=s,n):j6(e,r,c);if(a==2){var l=e[r],u=l&3,f=l>>2&3,d=l>>4,m=0,p=0;u<2?f&1?d|=e[++r]<<4|(f&2&&e[++r]<<12):d=l>>3:(p=f,f<2?(d|=(e[++r]&63)<<4,m=e[r]>>6|e[++r]<<2):f==2?(d|=e[++r]<<4|(e[++r]&3)<<12,m=e[r]>>2|e[++r]<<6):(d|=e[++r]<<4|(e[++r]&63)<<12,m=e[r]>>6|e[++r]<<2|e[++r]<<10)),++r;var h=n?n.subarray(t.y,t.y+t.m):new zr(t.m),b=h.length-d;if(u==0)h.set(e.subarray(r,r+=d),b);else if(u==1)ep(h,e[r++],b);else{var v=t.h;if(u==2){var g=Gae(e,r);m+=r-(r=g[0]),t.h=v=g[1]}else v||Xr(0);(p?$ae:$m)(e.subarray(r,r+=m),h.subarray(b),v)}var y=e[r++];if(y){y==255?y=(e[r++]|e[r++]<<8)+32512:y>127&&(y=y-128<<8|e[r++]);var w=e[r++];w&3&&Xr(0);for(var x=[Bae,Yae,Aae],O=2;O>-1;--O){var P=w>>(O<<1)+2&3;if(P==1){var T=new zr([0,0,e[r++]]);x[O]={s:T.subarray(2,3),n:T.subarray(0,1),t:new Lv(T.buffer,0,1),b:0}}else P==2?(i=tp(e,r,9-(O&1)),r=i[0],x[O]=i[1]):P==3&&(t.t||Xr(0),x[O]=t.t[O])}var S=t.t=x,k=S[0],L=S[1],z=S[2],X=e[c-1];X||Xr(0);var V=(c<<3)-8+Jc(X)-z.b,R=V>>3,j=0,J=(e[R]|e[R+1]<<8)>>(V&7)&(1<<z.b)-1;R=(V-=L.b)>>3;var q=(e[R]|e[R+1]<<8)>>(V&7)&(1<<L.b)-1;R=(V-=k.b)>>3;var W=(e[R]|e[R+1]<<8)>>(V&7)&(1<<k.b)-1;for(++y;--y;){var F=z.s[J],H=z.n[J],C=k.s[W],$=k.n[W],oe=L.s[q],ye=L.n[q];R=(V-=oe)>>3;var Ae=1<<oe,de=Ae+((e[R]|e[R+1]<<8|e[R+2]<<16|e[R+3]<<24)>>>(V&7)&Ae-1);R=(V-=I6[C])>>3;var Oe=_ae[C]+((e[R]|e[R+1]<<8|e[R+2]<<16)>>(V&7)&(1<<I6[C])-1);R=(V-=F6[F])>>3;var Ze=Qae[F]+((e[R]|e[R+1]<<8|e[R+2]<<16)>>(V&7)&(1<<F6[F])-1);if(R=(V-=H)>>3,J=z.t[J]+((e[R]|e[R+1]<<8)>>(V&7)&(1<<H)-1),R=(V-=$)>>3,W=k.t[W]+((e[R]|e[R+1]<<8)>>(V&7)&(1<<$)-1),R=(V-=ye)>>3,q=L.t[q]+((e[R]|e[R+1]<<8)>>(V&7)&(1<<ye)-1),de>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=de-=3;else{var ue=de-(Ze!=0);ue?(de=ue==3?t.o[0]-1:t.o[ue],ue>1&&(t.o[2]=t.o[1]),t.o[1]=t.o[0],t.o[0]=de):de=t.o[0]}for(var O=0;O<Ze;++O)h[j+O]=h[b+O];j+=Ze,b+=Ze;var ze=j-de;if(ze<0){var Re=-ze,yt=t.e+ze;Re>Oe&&(Re=Oe);for(var O=0;O<Re;++O)h[j+O]=t.w[yt+O];j+=Re,Oe-=Re,ze=0}for(var O=0;O<Oe;++O)h[j+O]=h[ze+O];j+=Oe}if(j!=b)for(;b<h.length;)h[j++]=h[b++];else j=h.length;n?t.y+=j:h=j6(h,0,j)}else if(n){if(t.y+=d,b)for(var O=0;O<d;++O)h[O]=h[b+O]}else b&&(h=j6(h,b));return t.b=c,h}Xr(2)}},tse=function(e,t){if(e.length==1)return e[0];for(var n=new zr(t),i=0,r=0;i<e.length;++i){var o=e[i];n.set(o,r),r+=o.length}return n};function UH(e,t){for(var n=[],i=+!t,r=0,o=0;e.length;){var a=Kae(e,i||t);if(typeof a=="object"){for(i?(t=null,a.w.length==a.u&&(n.push(t=a.w),o+=a.u)):(n.push(t),a.e=0);!a.l;){var s=ese(e,a,t);s||Xr(5),t?a.e=a.y:(n.push(s),o+=s.length,Uae(a.w,0,s.length),a.w.set(s,a.w.length-s.length))}r=a.b+a.c*4}else r=a;e=e.subarray(r)}return tse(n,o)}var CH={classes:{SM_Project:{order:["FieldsBlob","LockId","User","Folder","UserId","SysId","ProjectId","UpToDate","OrigProjUpToDate","RevivalTaskSetID","PlayHeadsSplitDisplay","LastModTimeInSecs","UpgradeLockSysId","ProjectAgeInMs","ProjectName","FolderMap","TimelineVec","TimelineHandleVec","CurrentTimelineIndex","StreamCursorVector","StreamIdVector","StreamPlayHeadVector","StreamAdvanceVector","GangPlayHeadVector","NumTotalStreams","NumPlayStreams","CurrentStreamId","PlayingStreamId","PlayHeadMode","CommonConfig","DeletedSsnList","IsADeliverableProject","DeliverableProjectEDLStr","DeliverableSessionName","NumReader","ClipInfoSeed","ReelSeed","EDLSeed","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","activeStereoLeftSession","activeStereoRightSession","IsAutoSave","ProjRef","Thumbnails","MediaPool","ProjectVersion","GroupList","GroupListObj","IsLiveCollaborationEnabled","LockableBlobMap","PowerNodeList","Notes","FaceTaggingClipVec","FaceTaggingPeopleVec"],props:{FieldsBlob:{kind:"scalar"},LockId:{kind:"empty",values:{"":1}},User:{kind:"ref"},Folder:{kind:"empty",values:{"":1}},UserId:{kind:"scalar",values:{"-1":1}},SysId:{kind:"scalar",values:{F4D48876E6E2:1}},ProjectId:{kind:"scalar",values:{"0":1}},UpToDate:{kind:"scalar",values:{true:1}},OrigProjUpToDate:{kind:"scalar",values:{true:1}},RevivalTaskSetID:{kind:"scalar",values:{"-1":1}},PlayHeadsSplitDisplay:{kind:"scalar",values:{false:1}},LastModTimeInSecs:{kind:"scalar",values:{"0":1}},UpgradeLockSysId:{kind:"empty",values:{"":1}},ProjectAgeInMs:{kind:"scalar"},ProjectName:{kind:"scalar"},FolderMap:{kind:"empty",values:{"":1}},TimelineVec:{kind:"empty",values:{"":1}},TimelineHandleVec:{kind:"refvec"},CurrentTimelineIndex:{kind:"scalar",values:{"0":1}},StreamCursorVector:{kind:"scalarvec"},StreamIdVector:{kind:"scalarvec"},StreamPlayHeadVector:{kind:"scalarvec"},StreamAdvanceVector:{kind:"scalarvec"},GangPlayHeadVector:{kind:"scalarvec"},NumTotalStreams:{kind:"scalar",values:{"1":1}},NumPlayStreams:{kind:"scalar",values:{"1":1}},CurrentStreamId:{kind:"scalar",values:{"0":1}},PlayingStreamId:{kind:"scalar",values:{"0":1}},PlayHeadMode:{kind:"scalar"},CommonConfig:{kind:"inline"},DeletedSsnList:{kind:"empty",values:{"":1}},IsADeliverableProject:{kind:"scalar",values:{false:1}},DeliverableProjectEDLStr:{kind:"empty",values:{"":1}},DeliverableSessionName:{kind:"empty",values:{"":1}},NumReader:{kind:"scalar",values:{"0":1}},ClipInfoSeed:{kind:"scalar",values:{"0":1}},ReelSeed:{kind:"scalar",values:{"0":1}},EDLSeed:{kind:"scalar",values:{"0":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},activeStereoLeftSession:{kind:"empty",values:{"":1}},activeStereoRightSession:{kind:"empty",values:{"":1}},IsAutoSave:{kind:"scalar",values:{false:1}},ProjRef:{kind:"empty",values:{"":1}},Thumbnails:{kind:"empty",values:{"":1}},MediaPool:{kind:"inline"},ProjectVersion:{kind:"scalar",values:{"17":1}},GroupList:{kind:"empty",values:{"":1}},GroupListObj:{kind:"inline"},IsLiveCollaborationEnabled:{kind:"scalar",values:{false:1}},LockableBlobMap:{kind:"inline"},PowerNodeList:{kind:"inline"},Notes:{kind:"empty",values:{"":1}},FaceTaggingClipVec:{kind:"empty",values:{"":1}},FaceTaggingPeopleVec:{kind:"empty",values:{"":1}}}},SM_Config:{order:["FieldsBlob","User","ConfigId","UserId","ProjId","SsnId","Name","LockSysId","DbSavedTime","MultiSysData"],props:{FieldsBlob:{kind:"scalar"},User:{kind:"empty",values:{"":1}},ConfigId:{kind:"scalar",values:{"0":1}},UserId:{kind:"scalar",values:{"0":1}},ProjId:{kind:"scalar",values:{"0":1}},SsnId:{kind:"scalar",values:{"0":1}},Name:{kind:"scalar",values:{"260903_CONNIE_SCOTT.Cfg":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}},MultiSysData:{kind:"inline"}}},Sm2MultiSysData:{order:["FieldsBlob","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"scalar",values:{"00000001000000010000000c0044006100740061004200410000000c0000000037000000010000002f8012280000000100000001000000180046003400440034003800380037003600450036004500320000000020013000":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MediaPool:{order:["FieldsBlob","SmartFolderVec","StereoSource"],props:{FieldsBlob:{kind:"scalar"},SmartFolderVec:{kind:"empty",values:{"":1}},StereoSource:{kind:"scalar",values:{"2":1}}}},Sm2GroupList:{order:["FieldsBlob","GroupList","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},GroupList:{kind:"vec"},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2LockableBlobMap:{order:["FieldsBlob","LocableBlobSet"],props:{FieldsBlob:{kind:"empty",values:{"":1}},LocableBlobSet:{kind:"vec"}}},Sm2MediaPoolLockableBlob:{order:["FieldsBlob","BlobOwner","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},BlobOwner:{kind:"ref"},DbSavedTime:{kind:"scalar",values:{"0":1}}}},"ListMgt::LmPowerNodeList":{order:["FieldsBlob","PowerNodes","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},PowerNodes:{kind:"empty",values:{"":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpFolder:{order:["FieldsBlob","Name","UniqueMediaPoolItemId","MediaVec","MediaPool","Folded","ColorTag","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar",values:{Master:1}},UniqueMediaPoolItemId:{kind:"ref"},MediaVec:{kind:"vec"},MediaPool:{kind:"ref"},Folded:{kind:"scalar",values:{true:1}},ColorTag:{kind:"scalar",values:{FOLDER_COLOR_NONE:1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpTimelineClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","TimelineSharedHandle","VideoMetadata","MediaMetadata"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar"},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},TimelineSharedHandle:{kind:"inline"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}},SmPTZRPreset:{order:["FieldsBlob","Name","ID","IsCustom","Producer","Presets"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"empty",values:{"":1}},ID:{kind:"scalar",values:{"100":1}},IsCustom:{kind:"scalar",values:{true:1}},Producer:{kind:"scalar",values:{"Producer@Resolve":1}},Presets:{kind:"scalar",values:{"7b7d":1}}}},Sm2Timeline:{order:["FieldsBlob","Name","MpTimelineClip","Sequence","OfflineFrameOffset","PTZRPresetType","VideoStereoSource","Type","ImportExportMetadataBA","EnableLTC","LTCSyncDelay","EnableAudio","AudioSyncDelay","ModTimeInSecs","CreateTimeInSecs"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},MpTimelineClip:{kind:"ref"},Sequence:{kind:"inline"},OfflineFrameOffset:{kind:"scalar",values:{"0":1}},PTZRPresetType:{kind:"scalar",values:{"0":1}},VideoStereoSource:{kind:"scalar",values:{"0":1}},Type:{kind:"scalar",values:{"0":1}},ImportExportMetadataBA:{kind:"scalar"},EnableLTC:{kind:"scalar",values:{false:1}},LTCSyncDelay:{kind:"scalar",values:{"0":1}},EnableAudio:{kind:"scalar",values:{false:1}},AudioSyncDelay:{kind:"scalar",values:{"0":1}},ModTimeInSecs:{kind:"scalar",values:{"1790712446":1}},CreateTimeInSecs:{kind:"scalar",values:{"1790712446":1}}}},Sm2Sequence:{order:["FieldsBlob","UniqueSequenceId","MediaExtents","FrameRate","Resolution","VideoTrackVec","AudioTrackVec","Parent","pLmVerTable","LastChangedTime","RenderCacheBA","AuxRenderCacheBA","UIElementsState","NumOutputAudioChannels","OutputAudioGain","PinsBA","ImportExportMetadataBA","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"scalar"},UniqueSequenceId:{kind:"ref"},MediaExtents:{kind:"scalar"},FrameRate:{kind:"scalar",values:{"872211b5dcf937400000000000000000":1}},Resolution:{kind:"scalar"},VideoTrackVec:{kind:"empty",values:{"":1}},AudioTrackVec:{kind:"empty",values:{"":1}},Parent:{kind:"ref"},pLmVerTable:{kind:"inline"},LastChangedTime:{kind:"scalar",values:{"0":1}},RenderCacheBA:{kind:"scalar"},AuxRenderCacheBA:{kind:"scalar"},UIElementsState:{kind:"scalar"},NumOutputAudioChannels:{kind:"scalar",values:{"2":1}},OutputAudioGain:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},ImportExportMetadataBA:{kind:"scalar"},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar"}}},"ListMgt::LmVersionTable":{order:["FieldsBlob","VerType","pActive","Locals","DbSavedTime","pRemoteTable","LinkedGroup"],props:{FieldsBlob:{kind:"scalar"},VerType:{kind:"scalar"},pActive:{kind:"ref"},Locals:{kind:"vec"},DbSavedTime:{kind:"scalar"},pRemoteTable:{kind:"ref"},LinkedGroup:{kind:"ref"}}},"ListMgt::LmVersion":{order:["FieldsBlob","Name","HasCorrection","VerType","ImplVersion","IncludedInRecording","FlatPassEnabled","RGBAOutputEnabled","Body","UseVersionClipProcParams"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},HasCorrection:{kind:"scalar"},VerType:{kind:"scalar"},ImplVersion:{kind:"scalar",values:{"1":1}},IncludedInRecording:{kind:"scalar",values:{true:1}},FlatPassEnabled:{kind:"scalar",values:{false:1}},RGBAOutputEnabled:{kind:"scalar",values:{false:1}},Body:{kind:"scalar"},UseVersionClipProcParams:{kind:"scalar"}}},Sm2MpVideoClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","pLmVerTable","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","Video","EmbeddedAudioVec"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar"},pLmVerTable:{kind:"inline"},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},Video:{kind:"inline"},EmbeddedAudioVec:{kind:"vec"}}},BtVideoInfo:{order:["FieldsBlob","Clip","Time","Geometry","Radiometry","Proxy","VideoMetadata","MediaMetadata","Type","Eye"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Clip:{kind:"scalar"},Time:{kind:"scalar"},Geometry:{kind:"scalar"},Radiometry:{kind:"scalar"},Proxy:{kind:"scalar"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}},Type:{kind:"scalar",values:{STANDARD_CLIP:1}},Eye:{kind:"scalar",values:{SUB_TRACK_MONO:1}}}},BtAudioInfo:{order:["FieldsBlob","Clip","TracksBA","MediaMetadata"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Clip:{kind:"scalar"},TracksBA:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}},Sm2SequenceContainer:{order:["FieldsBlob","VideoTrackVec","AudioTrackVec","SubtitleTrackVec","GeometryTrackVec","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},VideoTrackVec:{kind:"vec"},AudioTrackVec:{kind:"vec"},SubtitleTrackVec:{kind:"empty",values:{"":1}},GeometryTrackVec:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2TiTrack:{order:["FieldsBlob","Type","SubType","Flags","Sequence","Items","FusionCompHolderItems","UserDefinedName","LayersVec"],props:{FieldsBlob:{kind:"scalar"},Type:{kind:"scalar"},SubType:{kind:"scalar"},Flags:{kind:"scalar"},Sequence:{kind:"ref"},Items:{kind:"vec"},FusionCompHolderItems:{kind:"empty",values:{"":1}},UserDefinedName:{kind:"empty",values:{"":1}},LayersVec:{kind:"empty",values:{"":1}}}},Sm2TiVideoClip:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In","MixedFrameRateAlignment","MediaRef","MediaStartTime","MediaFilePath","MediaReelNumber","MediaFrameRate","MediaTimemapBA","LastChangedTime","LastRenderedTime","IsMarkedForCaching","IsForceConformed","MatchConflictState","UseOppositeSrcForLeftEye","UseOppositeSrcForRightEye","RenderCacheBA","CurrentSelectorIdx","IsPreConformed","PreConformMediaExtents","MediaMetadata","Thumbnail","ThumbnailDirtyFlag","CompositionTable","pLmVerTable"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"scalar"},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"scalar"},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar"},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar"},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar"},RenderTextGanged:{kind:"scalar"},RenderTextPrefixed:{kind:"scalar"},In:{kind:"scalar"},MixedFrameRateAlignment:{kind:"scalar",values:{"0":1}},MediaRef:{kind:"ref"},MediaStartTime:{kind:"scalar"},MediaFilePath:{kind:"scalar"},MediaReelNumber:{kind:"scalar"},MediaFrameRate:{kind:"scalar"},MediaTimemapBA:{kind:"scalar"},LastChangedTime:{kind:"scalar",values:{"0":1}},LastRenderedTime:{kind:"scalar",values:{"0":1}},IsMarkedForCaching:{kind:"scalar",values:{false:1}},IsForceConformed:{kind:"scalar",values:{true:1}},MatchConflictState:{kind:"scalar",values:{"0":1}},UseOppositeSrcForLeftEye:{kind:"scalar",values:{false:1}},UseOppositeSrcForRightEye:{kind:"scalar",values:{false:1}},RenderCacheBA:{kind:"empty",values:{"":1}},CurrentSelectorIdx:{kind:"scalar"},IsPreConformed:{kind:"scalar",values:{false:1}},PreConformMediaExtents:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}},Thumbnail:{kind:"inline"},ThumbnailDirtyFlag:{kind:"scalar",values:{true:1}},CompositionTable:{kind:"inline"},pLmVerTable:{kind:"inline"}}},BtThumnail:{order:["FieldsBlob","ImgWidth","ImgHeight","Buffer"],props:{FieldsBlob:{kind:"empty",values:{"":1}},ImgWidth:{kind:"scalar",values:{"-1":1}},ImgHeight:{kind:"scalar",values:{"-1":1}},Buffer:{kind:"empty",values:{"":1}}}},Sm2TiGenerator:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"scalar"},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"empty",values:{"":1}},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar"},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},In:{kind:"empty",values:{"":1}}}},BtMetadataLockableBlob:{order:["FieldsBlob","BlobOwner","DbSavedTime"],props:{FieldsBlob:{kind:"scalar",values:{"0000000100000001000000100042006c006f006200440061007400610000000c000000003e0000271100000036801233000f42410000002b121c08d7011217535452454e4754485f544f5f574f524b5f76342e776176120508a6031200120408101200":1}},BlobOwner:{kind:"ref"},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpAudioClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","EmbeddedAudioVec"],props:{FieldsBlob:{kind:"scalar",values:{"00000002000001358128b52ffd602d0155090006923937404dd51c0fe966933d866178c09f07f3c95a791d455b2452e697a8d636adb733f7a55c19cc047efbcf7cf7c3d82ac7ba1af1ce8f90bd53320024002600a0938cbf153dd40a388013d507bcd2aace48a1a051b1d83a2cb82c481246a20b249146fa6810429e9156a140c4c0a321e211a9a7134afef117751b5afa7235ec8c7cd320c008c907139f4372d84d7dbb173db7a7dc37d952ca2df6927bbdc4bc7e307c4790102dad5b082a0739166648dd9a764e0eda49e1811b6edf1b0d8a1224082400e170442cd36ec5f7c1ee2927a442bdc88d90b5e466b098252e338ba5cc32f85e2935b10119009d975800b2042b4b5cc818b6241a56e06297b24c06a289619853d0585b42e341decb18010cd6c9a6f519af9103086d949f6294de56113286cbd666a63f7364":1}},Name:{kind:"scalar",values:{"STRENGTH_TO_WORK_v4.wav":1}},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},EmbeddedAudioVec:{kind:"vec"}}},Sm2TiAudioClip:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In","MixedFrameRateAlignment","MediaRef","MediaStartTime","MediaFilePath","MediaReelNumber","MediaFrameRate","MediaTimemapBA","LastChangedTime","LastRenderedTime","IsMarkedForCaching","IsForceConformed","MatchConflictState","UseOppositeSrcForLeftEye","UseOppositeSrcForRightEye","RenderCacheBA","VirtualAudioTrackBA","MediaTrackIdx"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"scalar"},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"empty",values:{"":1}},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{false:1}},RenderTextGanged:{kind:"scalar",values:{false:1}},RenderTextPrefixed:{kind:"scalar",values:{false:1}},In:{kind:"empty",values:{"":1}},MixedFrameRateAlignment:{kind:"scalar",values:{"0":1}},MediaRef:{kind:"ref"},MediaStartTime:{kind:"scalar"},MediaFilePath:{kind:"scalar"},MediaReelNumber:{kind:"scalar"},MediaFrameRate:{kind:"scalar",values:{"872211b5dcf937400000000000000000":1}},MediaTimemapBA:{kind:"scalar"},LastChangedTime:{kind:"scalar",values:{"0":1}},LastRenderedTime:{kind:"scalar",values:{"0":1}},IsMarkedForCaching:{kind:"scalar",values:{false:1}},IsForceConformed:{kind:"scalar",values:{true:1}},MatchConflictState:{kind:"scalar",values:{"0":1}},UseOppositeSrcForLeftEye:{kind:"scalar",values:{false:1}},UseOppositeSrcForRightEye:{kind:"scalar",values:{false:1}},RenderCacheBA:{kind:"empty",values:{"":1}},VirtualAudioTrackBA:{kind:"scalar",values:{"000000010000000200000014004300680061006e006e0065006c0073004200410000000c000000001000000002000000020000400100004002000000120041007500640069006f0054007900700065000000020000000000":1}},MediaTrackIdx:{kind:"scalar",values:{"0":1}}}},Sm2TiCompositionTable:{order:["FieldsBlob","DbSavedTime","CompositionBA","ActiveCompositionIdx"],props:{FieldsBlob:{kind:"scalar"},DbSavedTime:{kind:"scalar",values:{"0":1}},CompositionBA:{kind:"scalar"},ActiveCompositionIdx:{kind:"scalar",values:{"0":1}}}},Sm2TiTransition:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","AlignmentType","Position"],props:{FieldsBlob:{kind:"scalar",values:{"000000020000001b800a04a801940312120000002c789c636660642016000000da0005":1}},PrettyType:{kind:"scalar",values:{"Cross Dissolve":1}},Name:{kind:"scalar",values:{Transition:1}},Start:{kind:"scalar",values:{"404":1}},Duration:{kind:"scalar",values:{"8":1}},LinkedItemSync:{kind:"empty",values:{"":1}},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar",values:{"000000020000003a800a37081238024a004a004a004a004a29088b015224ffffffe00000000000000c0000000000000000000800000000000c00000000000000f03f":1}},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},AlignmentType:{kind:"scalar",values:{"2":1}},Position:{kind:"scalar",values:{"2":1}}}},Sm2Group:{order:["FieldsBlob","Name","pLmVerTable"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar",values:{"GROUP - 01":1}},pLmVerTable:{kind:"inline"}}},Sm2MpCompoundClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","Sequence","VideoMetadata","MediaMetadata"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},Sequence:{kind:"inline"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}}}};var rse="000000000000000300000000000000000000000000000000000000000000006400000000000000060000000000000f000000000000000870000000000000000000000000000000000000803f00000000000000170000000000000000ffffffffffffffff0000000000000001fffffffffffffffe0000000000000001000000000000000000000000000000c40000000000000005000000000000002c00000000000000040000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000f000000000000000870000000000000000000000000000000000000803fffffffffffffffff00000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000000000000000000000000000003f0000003f000000000000003b1800200e280140a001486872134e6f204f7574707574205472616e73666f726d880102e80101a00200b00208c80200e00228e80202800304a00301",E6=e=>Uint8Array.from(e.match(/../g)??[],t=>parseInt(t,16)),ise=e=>[...e].map(t=>t.toString(16).padStart(2,"0")).join(""),GH=e=>[...e].map(t=>t.charCodeAt(0).toString(16).padStart(4,"0")).join("");function ose(e,t,n,i){let r=E6(rse),o=new DataView(r.buffer);return o.setInt32(40,0),o.setInt32(44,e),o.setInt32(48,0),o.setInt32(52,t),o.setInt32(80,Math.floor(n)),o.setInt32(88,i?1:0),o.setInt32(232,e),o.setInt32(240,t),r}function ase(e,t,n){let i=e&&e.length>=16?e:"0000000100000000",r=parseInt(i.slice(8,16),16)+1,o=s=>s.toString(16).padStart(8,"0"),a=GH(t);return i.slice(0,8)+o(r)+o(a.length/2)+a+"0000000c00"+o(n.length)+ise(n)+i.slice(16)}function sse(e){let t=E6(e),n=-1;for(let u=0;u+4<=t.length;u++)if(t[u]===40&&t[u+1]===181&&t[u+2]===47&&t[u+3]===253){n=u;break}if(n<0)return null;let i;try{i=UH(t.subarray(n))}catch{return null}let r={},o="",a=0,s=()=>{let u=0,f=0;for(;;){let d=i[a++];if(u+=(d&127)*2**f,f+=7,!(d&128))return u}};for(;a<i.length;){let u=s(),f=Math.floor(u/8),d=u%8;if(d===0)r[f]=s();else if(d===1)a+=8;else if(d===5)a+=4;else if(d===2){let m=s();f===1&&(o=new TextDecoder().decode(i.subarray(a,a+m))),a+=m}else break}let c=u=>u%2?-(u+1)/2:u/2;if(r[2]&&r[3])return{w:c(r[2]),h:c(r[3])};let l=/(\d+)\s*x\s*(\d+)/.exec(o);return l?{w:+l[1],h:+l[2]}:null}function cse(e){let t=E6(e);return t.length<8?{fps:24,df:!1}:{fps:new DataView(t.buffer).getFloat64(0,!0),df:t.length>=16&&t[15]===1}}var lse=CH.classes,JH=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Nv=class e{constructor(t,n){this.path=t;this.copy=n;this.cols=new Map;this.rows=new Map;this.idTable=null;this.links=null;this.tables=null;this.mediaRefs=new Set;this.sequences=new Set;this.visited=new Set}static async open(t){let n=await Mr("conform-resolve-db-"),i=Q(n,"Project.db");await oy(t,i);for(let r of["-wal","-shm"])await jn(t+r)&&await oy(t+r,i+r);return new e(t,i)}async q(t){let n=await Mn("sqlite3",["-readonly","-json",this.copy,t]);if(!n.success)throw new Error(`sqlite3: ${n.stderr.trim()||n.stdout.trim()}`);return n.stdout.trim()?JSON.parse(n.stdout):[]}async tableNames(){return this.tables??=(await this.q("select name from sqlite_master where type='table' order by name")).map(t=>t.name)}async columns(t){let n=this.cols.get(t);return n||(n=(await this.q(`pragma table_info("${t}")`)).map(i=>({name:i.name,type:i.type})),this.cols.set(t,n)),n}async table(t){let n=this.rows.get(t);if(n)return n;let r=(await this.columns(t)).map(o=>`case when typeof("${o.name}")='blob' then lower(hex("${o.name}")) else "${o.name}" end as "${o.name}"`).join(", ");n=new Map;for(let o of await this.q(`select ${r} from "${t}"`))n.set(String(o[`${t}_id`]),o);return this.rows.set(t,n),n}async objectTables(){let t=[];for(let n of await this.tableNames())(await this.columns(n))[0]?.name===`${n}_id`&&t.push(n);return t}async tableOf(t){if(!this.idTable){let i=(await this.objectTables()).map(r=>`select '${r}' as t, "${r}_id" as id from "${r}"`).join(" union all ");this.idTable=new Map;for(let r of await this.q(i))this.idTable.set(r.id,r.t)}return this.idTable.get(t)}async linkRows(t,n){if(!this.links){this.links=new Map;let i=[];for(let o of await this.tableNames()){let a=await this.columns(o);["DbOwner","DbAssociate","DbPropertyName","DbIndex"].every(s=>a.some(c=>c.name===s))&&i.push(o)}let r=i.map(o=>`select DbOwner o, DbAssociate a, DbPropertyName p, DbIndex i from "${o}"`).join(" union all ");for(let o of await this.q(r)){let a=`${o.o}|${o.p}`,s=this.links.get(a)??[];s.push({idx:o.i,assoc:o.a}),this.links.set(a,s)}for(let o of this.links.values())o.sort((a,s)=>a.idx-s.idx)}return this.links.get(`${t}|${n}`)??[]}async object(t){let n=await this.tableOf(t);if(!n)return null;let i=(await this.table(n)).get(t);return i?{table:n,row:i}:null}async facts(){let t=(await this.q("select CurrentTimelineIndex from SM_Project limit 1"))[0],n=Number(t?.CurrentTimelineIndex??-1),r=(await this.q(`select t.Sm2Timeline_id id, t.Name name, t.ModTimeInSecs mod, l.DbIndex idx from Sm2Timeline t
189
- left join SM_Project_Sm2Timeline l on l.DbAssociate = t.Sm2Timeline_id order by l.DbIndex`)).map(o=>({id:o.id,name:o.name,modified_at:o.mod?new Date(o.mod*1e3).toISOString():null,is_current:o.idx===n}));return{project:te(Ln(this.path)),db_path:this.path,timelines:r,current:r.find(o=>o.is_current)??null}}scalar(t,n){return t==null?"":/bool/i.test(n)?t?"true":"false":typeof t=="number"?(Number.isInteger(t),String(t)):X6(String(t))}async serialize(t,n,i={}){let r=await this.object(t);if(!r)return"";let o=String(r.row.DbType??r.table),a=await this.columns(r.table),s=new Map(a.map(f=>[f.name,f.type])),c=lse[o]??this.fallbackSchema(r.table,a,r.row);this.visited.add(t),o==="Sm2Sequence"&&this.sequences.add(t);let l=[`${n}<${o} DbId="${t}">`],u=n+" ";for(let f of c.order){let d=c.props[f];if(f in i){let h=i[f];l.push(h===null?`${u}<${f}/>`:h);continue}let m=s.has(f),p=r.row[f];switch(d.kind){case"scalar":case"empty":{let h=m?this.scalar(p,s.get(f)):Object.keys(d.values??{})[0]??"";l.push(h===""?`${u}<${f}/>`:`${u}<${f}>${h}</${f}>`);break}case"ref":{let h=m&&p?String(p):"";h&&/^Sm2Ti/.test(o)&&/^Sm2Mp/.test(await this.tableOf(h)??"")&&this.mediaRefs.add(h),l.push(h?`${u}<${f}>${h}</${f}>`:`${u}<${f}/>`);break}case"inline":{let h=m&&p&&JH.test(String(p))?String(p):"";h||(h=(await this.linkRows(t,f))[0]?.assoc??""),h||(h=await this.inlineByBackRef(o,f,t));let b=h&&!this.visited.has(h)?await this.serialize(h,u+" "):"";l.push(b?`${u}<${f}>
190
- ${b}
191
- ${u}</${f}>`:`${u}<${f}/>`);break}case"vec":case"refvec":{let h=await this.linkRows(t,f);if(!h.length){l.push(`${u}<${f}/>`);break}l.push(`${u}<${f}>`);for(let{assoc:b}of h){if(d.kind==="refvec"){l.push(`${u} <Element>${b}</Element>`);continue}if(this.visited.has(b))continue;let v=await this.serialize(b,u+" ");v&&l.push(`${u} <Element>
192
- ${v}
193
- ${u} </Element>`)}l.push(`${u}</${f}>`);break}default:l.push(`${u}<${f}/>`)}}return l.push(`${n}</${o}>`),l.join(`
194
- `)}async inlineByBackRef(t,n,i){let o={"SM_Project.CommonConfig":["SM_Config","SM_Project_id"],"SM_Project.MediaPool":["Sm2MediaPool","SM_Project_id"],"Sm2Timeline.Sequence":["Sm2Sequence","Parent"]}[`${t}.${n}`];if(!o)return"";let[a,s]=o;if(!(await this.tableNames()).includes(a))return"";if(!(await this.columns(a)).some(l=>l.name===s)){let l=(await this.table(a)).keys().next();return l.done?"":l.value}for(let[l,u]of await this.table(a))if(String(u[s])===i)return l;return""}fallbackSchema(t,n,i){let r=["FieldsBlob",...n.map(a=>a.name).filter(a=>a!==`${t}_id`&&a!=="DbType"&&a!=="FieldsBlob")],o={};for(let a of r)o[a]={kind:JH.test(String(i[a]??""))?"ref":"scalar"};return{order:r,props:o}}async ensureSequenceSetup(t){let n=(await this.table("Sm2Sequence")).get(t);if(!n)return;let i=String(n.FieldsBlob??"");if(i.includes(GH("SequenceSetup")))return;let r=[...(await this.table("SM_Config")).values()][0],o=r?sse(String(r.FieldsBlob??"")):null;if(!o)return;let{fps:a,df:s}=cse(String(n.FrameRate??""));n.FieldsBlob=ase(i,"SequenceSetup",ose(o.w,o.h,a,s))}async exportDrt(t,n,i="21.0.0"){let r=await this.object(t);if(!r||r.table!=="Sm2Timeline")throw new Error(`no timeline ${t} in ${this.path}`);let o=`<?xml version="1.0" encoding="UTF-8"?>
195
- <!--DbAppVer="${i}" DbPrjVer="${(await this.q("select ProjectVersion v from SM_Project limit 1"))[0]?.v??17}"-->
196
- `;this.visited.clear(),this.mediaRefs.clear(),this.sequences.clear();let a=async g=>(await this.q(`select Sm2SequenceContainer_id id from Sm2SequenceContainer where Sm2Sequence_id='${g}'`))[0]?.id,s=String(r.row.Sequence??await this.inlineByBackRef("Sm2Timeline","Sequence",t));await this.ensureSequenceSetup(s),this.sequences.add(s);let c=new Map,l=[],u=new Set,f=String(r.row.MpTimelineClip??"");for(f&&(l.push(await this.serialize(f," ")),u.add(f));;){let g=!1;for(let y of[...this.sequences]){let w=await a(y);if(!w){if(y===s)throw new Error(`timeline ${t}: no sequence container for sequence ${y}`);continue}c.has(w)||(c.set(w,o+await this.serialize(w,"")),g=!0)}for(let y of[...this.mediaRefs]){if(u.has(y)||this.visited.has(y))continue;u.add(y);let w=await this.serialize(y," ");w&&l.push(w),g=!0}if(!g)break}let d=[...(await this.table("Sm2MpFolder")).entries()].find(([,g])=>g.Name==="Master")??[...(await this.table("Sm2MpFolder")).entries()][0],m=l.length?` <MediaVec>
197
- ${l.map(g=>` <Element>
198
- ${g.replace(/^/gm," ")}
199
- </Element>`).join(`
200
- `)}
201
- </MediaVec>`:" <MediaVec/>",p=o+(d?await this.serialize(d[0],"",{MediaVec:m}):""),h=(await this.q("select SM_Project_id id from SM_Project limit 1"))[0]?.id,b=o+(h?await this.serialize(h,"",{TimelineHandleVec:` <TimelineHandleVec>
202
- <Element>${t}</Element>
203
- </TimelineHandleVec>`,CurrentTimelineIndex:" <CurrentTimelineIndex>0</CurrentTimelineIndex>",ProjectName:` <ProjectName>${X6(String(r.row.Name??""))}</ProjectName>`}):""),v=new KH.default;v.file("project.xml",b);for(let[g,y]of c)v.file(`SeqContainer/${g}.xml`,y);return v.file("MediaPool/Master/MpFolder.xml",p),await fr(n,await v.generateAsync({type:"uint8array",compression:"DEFLATE"})),n}};var use="7145B29C33684D8AA1C7E5126F9B405D",Fa="conform.tools.dvcp.bundle",fse="https://raw.githubusercontent.com/tbdpost/conformtools-public/main/plugin/manifest.json";function BH(e=or()){return e==="win32"?{system:`${Rt("PROGRAMDATA")??"C:\\ProgramData"}\\Blackmagic Design\\DaVinci Resolve\\Support\\IOPlugins`,user:`${Rt("APPDATA")??""}\\Blackmagic Design\\DaVinci Resolve\\Support\\IOPlugins`}:e==="linux"?{system:"/opt/resolve/IOPlugins",user:Q(bf(),".local/share/DaVinciResolve/IOPlugins")}:{system:"/Library/Application Support/Blackmagic Design/DaVinci Resolve/IOPlugins",user:Q(bf(),"Library/Application Support/Blackmagic Design/DaVinci Resolve/IOPlugins")}}function dse(e=or()){return e==="win32"?`${Rt("APPDATA")??""}\\Blackmagic Design\\DaVinci Resolve\\Support\\logs\\ResolveDebug.txt`:e==="linux"?Q(bf(),".local/share/DaVinciResolve/logs/ResolveDebug.txt"):Q(bf(),"Library/Application Support/Blackmagic Design/DaVinci Resolve/logs/ResolveDebug.txt")}function YH(e=or(),t=hf()){return e==="darwin"?{key:"darwin-universal",binary:"Contents/MacOS/conform.tools.dvcp"}:e==="linux"&&/x86_64|x64/.test(t)?{key:"linux-x86_64",binary:"Contents/Linux-x86-64/conform.tools.dvcp"}:e==="win32"?{key:"windows-x86_64",binary:"Contents/Win64/conform.tools.dvcp"}:null}async function AH(e){let t=Q(e,"Contents/Resources/VERSION");if(await Er(t))return(await yn(t)).trim()||null;let n=Q(e,"Contents/Info.plist");return await Er(n)?/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)</.exec(await yn(n))?.[1]??null:null}function mse(e,t){let n=e.split(`
204
- `),i=n.find(s=>s.includes("Running DaVinci Resolve"));if(!i)return null;let r=/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}),(\d{3})/.exec(i);if(!r)return null;let o=new Date(`${r[1]}T${r[2]}.${r[3]}`),a=n.some(s=>/plugin repository/i.test(s)&&s.toUpperCase().includes(`LOADED PLUGIN [${use}]`));return{launched_at:o.toISOString(),loaded:a,installed_after_launch:t!==void 0&&t>o.getTime()}}async function af(e=or()){let t=YH(e),n=BH(e),i=Q(n.system,Fa),r=t?await gi(i)&&await jn(Q(i,t.binary)):!1,o=r?await AH(i):null,a=Q(n.user,Fa),s=await gi(a)?{path:a,version:await AH(a)}:void 0,c=null;try{let f=r&&t?(await un(Q(i,t.binary))).mtimeMs:void 0;c=mse(await yn(dse(e)),f)}catch{}let l=t?r?c?c.loaded&&!c.installed_after_launch?"ready":"needs-restart":"unknown":"plugin-missing":"unsupported-platform",u={ready:"The plugin is installed and loaded.","plugin-missing":s?`Only a per-user copy exists (${a}); Resolve loads I/O plugins only from ${n.system}. Install it with host_setup action=install_renderplugin.`:"Install it with host_setup action=install_renderplugin, then restart Resolve.","needs-restart":"Restart Resolve: it loads I/O plugins only at launch.","unsupported-platform":"There is no build of the plugin for this platform.",unknown:"Start Resolve once so its log says whether it loaded the plugin."}[l];return{platform:t?.key??null,installed:r,path:i,version:o,...s?{shadowed:s}:{},resolve:c,readiness:l,next:u}}async function QH(){for(let e of["./presets/conform.tools.xml","./resolve-presets/conform.tools.xml"]){let t=Pr(new URL(e,import.meta.url));if(await Er(t))return t}throw new Error("resolve: the conform.tools render preset is missing from this install")}async function pse(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",e));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}async function _H(e,t=3){for await(let n of dn(e)){if(!n.isDirectory)continue;let i=Q(e,n.name);if(n.name===Fa)return i;if(t>0&&!n.name.startsWith("__MACOSX")){let r=await _H(i,t-1);if(r)return r}}return null}var hse=async e=>{let t=await fetch(e,{signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new Error(`download failed: ${e} answered ${t.status}`);return new Uint8Array(await t.arrayBuffer())};async function $H(e={}){let t=e.os??or(),n=YH(t);if(!n)throw new Error("there is no build of the plugin for this platform");let i=e.fetcher??hse,r=JSON.parse(new TextDecoder().decode(await i(e.manifest_url??fse))),o=r.platforms?.[n.key]??(t==="darwin"&&r.bundle_url?{bundle_url:r.bundle_url,sha256:r.sha256??""}:void 0);if(!o)throw new Error(`plugin ${r.version} has no ${n.key} build`);let a=await i(o.bundle_url),s=await pse(a);if(s!==o.sha256.toLowerCase())throw new Error(`the downloaded plugin failed its checksum (got ${s}, the manifest says ${o.sha256}); nothing was installed`);let c=await Mr("conform-plugin-"),l=Q(c,"plugin.zip");await fr(l,a);let u=Q(c,"x");await bt(u);let f=t==="darwin"?await Mn("ditto",["-x","-k",l,u]):t==="win32"?await Mn("powershell",["-NoProfile","-Command",`Expand-Archive -LiteralPath '${l}' -DestinationPath '${u}' -Force`]):await Mn("unzip",["-q",l,"-d",u]);if(!f.success)throw new Error(`could not unpack the plugin: ${f.stderr.trim()}`);let d=await _H(u);if(!d||!await jn(Q(d,n.binary)))throw new Error(`the ${n.key} download does not contain ${n.binary}`);let m=e.targetDir??BH(t).system,p=Q(m,Fa),h=Q(m,`.${Fa}.staging`),b=Q(m,`.${Fa}.previous`),v=[],g=!1;try{await bt(m),await Sr(h),await xp(d,h),await Sr(b),await jn(p)&&await Br(p,b);try{await Br(h,p)}catch(y){throw await jn(b)&&await Br(b,p),y}await Sr(b)}catch(y){let w=y.code;if(w!=="EACCES"&&w!=="EPERM")throw y;g=!0,await bse(t,d,m)}return t==="darwin"&&((await Mn(g?"osascript":"xattr",g?["-e",`do shell script "xattr -dr com.apple.quarantine ${Oi(p)}" with administrator privileges`]:["-dr","com.apple.quarantine",p])).success||v.push("could not clear the quarantine flag; if Resolve refuses the plugin, run: xattr -dr com.apple.quarantine "+p)),await Sr(c),{version:r.version,path:p,elevated:g,restart_required:!0,notes:v}}var Oi=e=>`'${e.replace(/'/g,"'\\''")}'`;async function bse(e,t,n){let i=Q(n,Fa),r=Q(n,`.${Fa}.staging`),o=Q(n,`.${Fa}.previous`),a=[`mkdir -p ${Oi(n)}`,`rm -rf ${Oi(r)} ${Oi(o)}`,`cp -R ${Oi(t)} ${Oi(r)}`,`if [ -e ${Oi(i)} ]; then mv ${Oi(i)} ${Oi(o)}; fi`,`mv ${Oi(r)} ${Oi(i)} || { [ -e ${Oi(o)} ] && mv ${Oi(o)} ${Oi(i)}; exit 1; }`,`rm -rf ${Oi(o)}`].join(" && "),s=e==="darwin"?await Mn("osascript",["-e",`do shell script ${JSON.stringify(a)} with administrator privileges`]):e==="linux"?await Mn("pkexec",["sh","-c",a]):{success:!1,stderr:"run this from an administrator prompt",stdout:"",code:1};if(!s.success)throw new Error(`installing into ${n} needs an administrator, and that was refused or failed: ${s.stderr.trim()}`)}function V6(e=or()){if(e==="win32"){let t=Rt("PROGRAMDATA")??"C:\\ProgramData",n=Rt("PROGRAMFILES")??"C:\\Program Files";return{api:`${t}\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting`,lib:`${n}\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll`}}return e==="linux"?{api:"/opt/resolve/Developer/Scripting",lib:"/opt/resolve/libs/Fusion/fusionscript.so"}:{api:"/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting",lib:"/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so"}}async function gse(e){let t=Rt("RESOLVE_SCRIPT_LIB");if(t)return t;if(e==="darwin"){let i=(await Mn("ps",["-axo","comm="])).stdout.split(`
205
- `).map(r=>r.trim()).find(r=>/\/Contents\/MacOS\/Resolve$/.test(r));if(i){let r=i.replace(/\/MacOS\/Resolve$/,"/Libraries/Fusion/fusionscript.so");if(await jn(r))return r}}return V6(e).lib}async function vse(){for(let e of["./bridge.py","./resolve-bridge.py"]){let t=Pr(new URL(e,import.meta.url));if(await Er(t))return t}throw new Error("resolve: bridge.py is missing from this install")}var Kc=async(e,t,n)=>{let i=or(),{api:r}=V6(i),o=Rt("CONFORM_PYTHON")??(i==="win32"?"python":"python3"),a=await Mn(o,[await vse(),e,JSON.stringify(t)],{env:{RESOLVE_SCRIPT_API:Rt("RESOLVE_SCRIPT_API")??r,RESOLVE_SCRIPT_LIB:await gse(i),PYTHONPATH:Q(Rt("RESOLVE_SCRIPT_API")??r,"Modules")},timeoutMs:n}),s=a.stdout.trim().split(`
206
- `).pop()??"";try{return JSON.parse(s)}catch{return{ok:!1,why:"bridge",detail:a.code==="ENOENT"?`${o} is not installed (Resolve's scripting needs Python 3)`:a.stderr.trim().split(`
207
- `).pop()||`no answer from Resolve within ${Math.round(n/1e3)} s`}}},np=class extends Error{constructor(n,i){super(i);this.why=n}},yse={module:"Install DaVinci Resolve (its scripting module ships with it).",no_connection:"Start Resolve and set Preferences > System > General > External scripting using: Local (Resolve Studio).",no_project:"Open a project in Resolve."},Xv=class{constructor(t=Kc){this.runner=t;this.host="resolve";this.restore=new Map;this.startNotes=new Map}async call(t,n={},i=6e4){let r=await this.runner(t,n,i);if(r.ok)return r;throw r.why==="resolve_error"&&/NoneType' object is not callable/.test(String(r.detail))&&!(await this.runner("version",{},1e4)).ok?new np("host_quit",`resolve: Resolve stopped responding during ${t} (it may have quit; see its log, ResolveDebug.txt). Restart Resolve and try again.`):new np(r.why??"unknown",`resolve: ${r.detail||r.why}`)}async support(){let t=await this.runner("version",{},15e3),n=t.ok?t.product==="DaVinci Resolve Studio"?{ok:!0}:{ok:!1,reason:`${t.product} has no external scripting (Resolve Studio has)`}:{ok:!1,reason:t.detail??String(t.why),setup:yse[t.why??""]},i=n;if(n.ok){let r=await af();i=r.readiness==="ready"||r.readiness==="unknown"?{ok:!0}:{ok:!1,reason:`renderplugin: ${r.readiness}`,setup:r.next}}return{export:n,open:n,render:n,markers:n,renderplugin:i}}async current(){return await this.call("current")}async project(t){return await this.call("project",t,12e4)}async presets(t){return await this.call("presets",t,12e4)}async presetAuthor(t){return await this.call("preset_author",t,6e4)}async export(t){if(!t.out_path)throw new np("usage","resolve: export needs out_path");let n=await this.call("export",{timeline:t.timeline,out_path:t.out_path});return{path:String(n.path),format:"drt",project:String(n.project),timeline:String(n.timeline)}}async open(t){let n=await this.call("open",{path:t.path,into:t.into??"current",name:t.name,media_dir:t.media_dirs?.[0],stay:t.stay??!1,folder:t.folder,create_folder:t.create_folder??!1,link_existing:t.link_existing??!1},3e5),i=[...n.notes??[]];return(t.media_dirs?.length??0)>1&&i.push(`Resolve searches one media folder per import; used ${t.media_dirs[0]}`),{project:String(n.project),timeline:String(n.timeline),notes:i,restored:!!n.restored,...n.folder?{folder:String(n.folder)}:{}}}async renderStart(t){let n=await this.call("render_start",{...t}),i=String(n.job_id);this.restore.set(i,n.restore);let r=n.rejected_settings??[];return r.length&&this.startNotes.set(i,[`Resolve refused render setting(s) ${r.join(", ")} for this format; the rest were applied`]),{job_id:i,state:"queued",percent:0}}async renderStatus(t){let n=await this.call("render_status",{job_id:t},15e3),i={job_id:t,state:n.state,percent:Number(n.percent??0)};if(n.error&&(i.error=String(n.error)),i.state==="complete"||i.state==="failed"){let r=await this.call("render_finish",{job_id:t,restore:this.restore.get(t)});this.restore.delete(t),r.output&&(i.outputs=[String(r.output)]);let o=[...this.startNotes.get(t)??[],...r.tracks?[eZ(r)]:[]];this.startNotes.delete(t),o.length&&(i.notes=o)}return i}async renderCancel(t){let n=await this.call("render_cancel",{job_id:t,restore:this.restore.get(t)});return this.restore.delete(t),{job_id:t,state:"cancelled",percent:0,...n.output?{outputs:[String(n.output)]}:{},...n.tracks?{notes:[eZ(n)]}:{}}}},eZ=e=>{let t=e.tracks.map(n=>`V${n}`).join(", ");return e.tracks_restored?`video track(s) ${t} switched back on`:`could NOT switch video track(s) ${t} back on: re-enable them on the Edit page`};async function tZ(e,t){let n=[];for await(let i of dn(e))i.isFile&&i.name.startsWith(t)&&n.push(Q(e,i.name));return n.sort()}import{gunzipSync as wse}from"node:zlib";var Ia=["resolve","premiere","avid","flame","fcp"];function nZ(e,t){if(!t.tracks?.length)return;let n=e.timelines.find(i=>i.name===t.timeline)??e.timelines[0];if(n)for(let i of["video","audio"]){let r=n.tracks.filter(o=>(o.kind??"").toLowerCase()===i).sort((o,a)=>(o.track_index??0)-(a.track_index??0));for(let o of t.tracks.filter(a=>a.kind===i)){let a=r[o.index-1];a&&(a.enabled=o.enabled,o.name&&!/^(Video|Audio) \d+$/.test(o.name)&&(a.name=o.name))}}}async function xse(){return(await Mn("ps",["-axo","pid=,args="])).stdout.split(`
208
- `).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 Pse(){let e=`ObjC.import("CoreGraphics");
209
- const a = $.CGWindowListCopyWindowInfo($.kCGWindowListOptionAll, 0);
210
- const arr = ObjC.deepUnwrap(ObjC.castRefToObject(a)) || [];
211
- JSON.stringify(arr.filter(w => w.kCGWindowName).map(w => ({ pid: w.kCGWindowOwnerPID, owner: w.kCGWindowOwnerName, title: w.kCGWindowName })));`;if(or()!=="darwin")return[];let t=await Mn("osascript",["-l","JavaScript","-e",e]);try{return JSON.parse(t.stdout.trim())}catch{return[]}}async function H6(e){return(await Mn("lsof",["-p",String(e),"-Fn"])).stdout.split(`
212
- `).filter(n=>n.startsWith("n/")).map(n=>n.slice(1))}var W6=e=>new Date(e).toISOString();async function kse(e,t){let n=e.find(l=>/DaVinci Resolve\.app\/Contents\/MacOS\/Resolve(\s|$)/.test(l.args)),i={host:"resolve",running:!!n,pid:n?.pid,notes:[]};if(!n)return i;let r=(await H6(n.pid)).find(l=>/\/Project\.db$/.test(l));if(!r)return Tse(n.pid,i,t);i.project_path=r;let o=await Nv.open(r),a=await o.facts();if(i.project=a.project,i.timelines=a.timelines.map(l=>l.name),!a.current)return i.notes.push("no timeline is open in the viewer"),i;i.timeline=a.current.name;let s=Q(t,`${jv(a.project)}__${jv(a.current.name)}.drt`);await o.exportDrt(a.current.id,s),i.read={path:s,format:"drt"},i.notes.push("built from the project database Resolve autosaves (the live state, minus edits of the last few seconds)");let c=await Kc("current",{},15e3);return c.ok&&c.timeline===i.timeline&&(i.tracks=c.tracks),i}async function Sse(e){let n=(await Mn("lsof",["-a","-p",String(e),"-i","TCP","-P","-n","-Fn"])).stdout.split(`
213
- `).filter(i=>i.startsWith("n")&&i.includes("->")).map(i=>i.slice(i.indexOf("->")+2));return[...new Set(n.filter(i=>/:5432$/.test(i)))]}async function Tse(e,t,n){let i=await Sse(e),r=Q(n,`resolve_current_${Date.now()}.drt`),o=await Kc("current",{},6e4),a;o.why!=="bridge"&&(a=o,o.ok&&o.timeline&&(a.exported=(await Kc("export",{out_path:r},6e4)).ok));let s=i.length?`a PostgreSQL project library (${i.join(", ")})`:"no Project.db on disk";if(!a)return t.notes.push(`Resolve holds ${s}, and its scripting door could not be reached (${o.detail??"no answer"}). Export the timeline as a .drt from Resolve (File > Export > Timeline) and read that file.`),t;if(a.db?.DbType?t.project_path=`${a.db.DbType.toLowerCase()}://${a.db.IpAddress??i[0]??""}/${a.db.DbName??""}`:i.length&&(t.project_path=`postgresql://${i[0]}`),!a.ok){let l=a.why==="no_project"?"no project is open (only the Project Manager)":a.why==="no_connection"?"Resolve refused the local scripting connection (Preferences > System > General > External scripting using: Local)":`the Resolve scripting module is not installed (${a.detail??""})`;return t.notes.push(`Resolve holds ${s}; ${l}.`),t}if(t.project=a.project,t.timelines=a.timelines,!a.timeline)return t.notes.push("no timeline is open in the viewer"),t;if(t.timeline=a.timeline,o.ok&&(t.tracks=o.tracks),!a.exported||!await jn(r))return t.notes.push(`Resolve holds ${s}; it named the open timeline but its .drt export failed. Export it from Resolve (File > Export > Timeline) and read that file.`),t;let c=Q(n,`${jv(a.project??"resolve")}__${jv(a.timeline)}.drt`);return await Br(r,c),t.read={path:c,format:"drt"},t.notes.push(`project in ${s}: the timeline was exported by Resolve itself (its own .drt of the current state, including unsaved edits)`),t}async function zse(e,t){let n=e.find(u=>/Adobe Premiere Pro( \d{4})?\.app\/Contents\/MacOS\/Adobe Premiere Pro/.test(u.args)),i={host:"premiere",running:!!n,pid:n?.pid,notes:[]};if(!n)return i;let r=t.find(u=>u.pid===n.pid&&/\.prproj/i.test(u.title))?.title;if(!r)return i.notes.push("Premiere is running with no project window (home screen), or the window title carries no project path."),i;let o=r.replace(/\s*\*\s*$/,"").replace(/^.*?(\/.*\.prproj).*$/i,"$1");if(!await jn(o))return i.notes.push(`window title names ${o} but it is not on disk`),i;i.project_path=o,i.project=te(o).replace(/\.prproj$/i,""),i.read={path:o,format:"prproj"},await jn(o.replace(/\.prproj$/i,".prlock"))&&i.notes.push("lock file present beside the project (project locking is on)");let a=await er(o),s=new TextDecoder().decode(a[0]===31&&a[1]===139?wse(a):a),c=[...s.matchAll(/<MZ\.PrefixKey\.OpenSequenceGuidList\.(\d+)>([0-9a-f-]{36})</g)].map(u=>({idx:Number(u[1]),uid:u[2]})).sort((u,f)=>u.idx-f.idx),l=u=>{let f=s.indexOf(`<Sequence ObjectUID="${u}"`);if(f<0)return null;let d=/<Name>([^<]*)<\/Name>/.exec(s.slice(f,f+2e4));return d?d[1]:null};return i.timelines=c.map(u=>l(u.uid)).filter(u=>!!u),i.timelines.length&&(i.timeline=i.timelines[0]),i.notes.push("last saved state of the project file (Premiere has no outside door to unsaved edits; the panel has)"),i.notes.push(i.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"),i}async function Ose(e,t,n){let i=e.find(d=>/AvidMediaComposer\.app\/Contents\/MacOS\/AvidMediaComposer(\s|$)/.test(d.args)),r={host:"avid",running:!!i,pid:i?.pid,notes:[]};if(!i)return r;let o=(await H6(i.pid)).find(d=>/\.avp$/i.test(d)),a=t.find(d=>d.pid===i.pid&&/Media Composer/.test(d.title))?.title??"",s=/Media Composer[^-]*-\s*([^-]+?)\s*(?:-|$)/.exec(a)?.[1]?.trim();if(!o)return r.notes.push(s?`project "${s}" per the window title, but no .avp is held open`:"no project open"),r.project=s,r;r.project_path=o,r.project=te(o).replace(/\.avp$/i,"");let c=Ln(o),l=[];for await(let d of dn(c))if(d.isFile&&/\.avb$/i.test(d.name)&&!d.name.startsWith("_")){let m=await un(Q(c,d.name));l.push({path:Q(c,d.name),modified_at:W6(m.mtimeMs)})}l.sort((d,m)=>m.modified_at.localeCompare(d.modified_at)),r.bins=l;let u=l[0];if(n){for(let d of l.slice(0,12))if(await n(d.path,"avb")){u=d;break}}u&&(r.read={path:u.path,format:"avb"}),r.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 f=Q("/Users/Shared/AvidMediaComposer/Avid Attic",r.project,"Bins");if(await jn(f)){let d=null;for await(let m of dn(f)){if(!m.isDirectory)continue;let p=await un(Q(f,m.name));(!d||p.mtimeMs>d.m)&&(d={name:m.name,m:p.mtimeMs})}d&&r.notes.push(`Attic: last bin autosaved while open was "${d.name.replace(/\.[^.]*$/,"")}" at ${W6(d.m)}`)}return r}async function Mse(e){let t=e.find(c=>/\/flame\.app\/Contents\/MacOS\/flame(\s|$)/.test(c.args)||/\/flame_\d{4}\/bin\/flame(\s|$)/.test(c.args)),n={host:"flame",running:!!t,pid:t?.pid,notes:[]};if(!t)return n;let i=/\s-J\s+(\S+)/.exec(t.args)?.[1],r=/\s-W\s+(\S+)/.exec(t.args)?.[1]??"Workspace";if(!i)return n.notes.push("Flame is running but its command line names no project (-J)"),n;n.project=i;let o=["/opt/Autodesk/project","/private/var/opt/Autodesk/flame/projects","/var/opt/Autodesk/flame/projects"],a=null;for(let c of o){let l=Q(c,i,"catalog",`${r}.wksp`);if(await jn(l)){a=l;break}}if(!a)return n.notes.push(`no catalog folder for project ${i} / workspace ${r} under ${o.join(", ")}`),n;n.project_path=a;let s=null;for await(let c of dn(a))if(c.isFile&&/^\.#workspace\.\d+\.wks$/.test(c.name)){let l=await un(Q(a,c.name));(!s||l.mtimeMs>s.m)&&(s={path:Q(a,c.name),m:l.mtimeMs})}return s?(n.read={path:s.path,format:"flame"},n.notes.push(`live workspace file, written by Flame at ${W6(s.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)}async function Lse(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 i=[...new Set((await H6(t.pid)).map(c=>/^(.*?\.fcpbundle)(\/|$)/.exec(c)?.[1]).filter(c=>!!c))];if(!i.length)return n.notes.push("Final Cut is running with no library open"),n;n.timelines=[];let r=new Map;for(let c of i)for await(let l of dn(c))if(!(!l.isDirectory||/\.(localized)$/.test(l.name)||l.name.startsWith("_")))for await(let u of dn(Q(c,l.name)))u.isDirectory&&!/^(Original Media|Render Files|Analysis Files|Transcoded Media|Shared Items)$/.test(u.name)&&r.set(u.name,{library:c,event:l.name});let o=await Mn("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']),a=o.success?o.stdout.trim().split(", ").find(c=>r.has(c)):void 0;if(!a){let c=await Mn("osascript",["-e",'tell application "System Events" to tell process "Final Cut Pro" to get entire contents of window 2']);for(let l of c.stdout.matchAll(/static text ([^,]+?) of group/g))if(r.has(l[1])){a=l[1];break}}let s=a?r.get(a):void 0;return n.project=s?te(s.library).replace(/\.fcpbundle$/,""):i.length===1?te(i[0]).replace(/\.fcpbundle$/,""):void 0,n.project_path=s?.library??(i.length===1?i[0]:void 0),n.timeline=a,n.timelines=[...r.keys()],n.notes.push(`${i.length} librar${i.length===1?"y":"ies"} open: ${i.map(c=>te(c)).join(" | ")}`),a&&s?n.notes.push(`project "${a}" is in event "${s.event}" of ${te(s.library)}`):n.notes.push("could not read the Timeline title (no project loaded, or the accessibility layout differs)"),n.notes.push("no readable file: a Final Cut library is a Core Data store with a private object graph, not fcpxml. Reading the open project needs either a decode of that store or a UI-driven File > Export XML."),n}var jv=e=>e.replace(/[^\w.-]+/g,"_").slice(0,80);function Rse(e=or()){return e==="darwin"||e==="linux"?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 rZ(e,t,n){let i=Rse();if(i)throw new Te("unsupported",i);let r=e?.length?e:[...Ia],o=t??await Mr("conform-host-"),a=await xse(),s=r.some(l=>l==="premiere"||l==="avid")?await Pse():[],c=[];for(let l of r)try{l==="resolve"?c.push(await kse(a,o)):l==="premiere"?c.push(await zse(a,s)):l==="avid"?c.push(await Ose(a,s,n)):l==="flame"?c.push(await Mse(a)):c.push(await Lse(a))}catch(u){c.push({host:l,running:!0,notes:[`failed: ${u instanceof Error?u.message:String(u)}`]})}return c}function Z6(e){return e.map(t=>`${t.kind[0].toUpperCase()}${t.index}${t.name&&!/^(Video|Audio|Subtitle) \d+$/.test(t.name)?` ${t.name}`:""}${t.enabled?"":" (off)"}${t.locked?" (locked)":""}`).join(" | ")}function iZ(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: ${Z6(e.tracks)}`),e.bins?.length&&t.push(` bins (newest first): ${e.bins.slice(0,8).map(n=>te(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(`
214
- `)}function Fv(e,t){let n=async()=>{throw new Error(`${e}: ${t}`)},i={ok:!1,reason:t};return{host:e,support:async()=>({export:i,open:i,render:i,markers:i,renderplugin:i}),export:n,open:n,renderStart:n,renderStatus:n,renderCancel:n}}import Nse from"node:http";import{createHash as Xse}from"node:crypto";import{Buffer as so}from"node:buffer";var jse="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";function D6(e,t){let n=t.length,i=n<126?so.from([128|e,n]):n<65536?so.from([128|e,126,n>>8,n&255]):(()=>{let r=so.alloc(10);return r[0]=128|e,r[1]=127,r.writeBigUInt64BE(BigInt(n),2),r})();return so.concat([i,so.from(t)])}function Fse(e,t,n){let i=so.alloc(0),r=[],o=0,a=!1,s=[],c=[],l=()=>{a||(a=!0,c.forEach(f=>f()))},u=(f=1e3,d="")=>{if(a)return;let m=so.from(d),p=so.alloc(2+m.length);p.writeUInt16BE(f,0),m.copy(p,2);try{e.write(D6(8,p))}catch{}e.end(),l()};return e.on("data",f=>{for(i=so.concat([i,f]);i.length>=2;){let d=(i[0]&128)!==0,m=i[0]&15,p=(i[1]&128)!==0,h=i[1]&127,b=2;if(h===126){if(i.length<4)return;h=i.readUInt16BE(2),b=4}else if(h===127){if(i.length<10)return;let y=i.readBigUInt64BE(2);if(y>BigInt(n))return u(1009,"too big");h=Number(y),b=10}if(!p)return u(1002,"client frames must be masked");if(h>n||o+h>n)return u(1009,"message too big");if(i.length<b+4+h)return;let v=i.subarray(b,b+4),g=so.from(i.subarray(b+4,b+4+h));for(let y=0;y<g.length;y++)g[y]^=v[y&3];if(i=i.subarray(b+4+h),m===8)return u(1e3);if(m===9){e.write(D6(10,g));continue}if(m!==10){if(m===1||m===0){if(r.push(g),o+=g.length,d){let y=so.concat(r).toString("utf8");r=[],o=0,s.forEach(w=>w(y))}continue}return u(1003,"text frames only")}}}),e.on("close",l),e.on("error",l),{origin:t,send:f=>{a||e.write(D6(1,so.from(f,"utf8")))},close:u,onMessage:f=>{s.push(f)},onClose:f=>{c.push(f)}}}function oZ(e,t){let n=new Set,i=Nse.createServer((r,o)=>{o.writeHead(426,{"content-type":"text/plain"}),o.end("websocket only")});return i.on("upgrade",(r,o)=>{let a=r.headers["sec-websocket-key"];if(r.url?.split("?")[0]!==e.path||typeof a!="string"||String(r.headers.upgrade).toLowerCase()!=="websocket"){o.end(`HTTP/1.1 400 Bad Request\r
215
- \r
216
- `);return}let s=Xse("sha1").update(a+jse).digest("base64");o.write(`HTTP/1.1 101 Switching Protocols\r
217
- Upgrade: websocket\r
218
- Connection: Upgrade\r
219
- Sec-WebSocket-Accept: ${s}\r
220
- \r
221
- `),n.add(o),o.on("close",()=>n.delete(o));let c=typeof r.headers.origin=="string"?r.headers.origin:null;t(Fse(o,c,e.maxBytes))}),new Promise((r,o)=>{i.once("error",o),i.listen(e.port,e.hostname,()=>{let a=i.address();r({port:typeof a=="object"&&a?a.port:e.port,close:()=>new Promise(s=>{for(let c of n)c.destroy();i.close(()=>s())})})})})}var Iv=1,Ise=[48127,48128,48129,48130,48131,48132,48133,48134],Ese=5e3,aZ=4,Vse=8*1024*1024,Gc=class extends Error{constructor(n,i){super(i);this.code=n}},Ev=()=>Q(vt(),"host-bridge","pairing.json");function Wse(){let e=new Uint8Array(32);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}var q6=class{constructor(){this.token=Wse();this.port=0;this.live=new Map;this.waiters=[];this.seq=0;this.events=[]}async start(t=Ise){let n;for(let i of t)try{this.server=await oZ({hostname:"127.0.0.1",port:i,path:"/host-bridge",maxBytes:Vse},r=>this.accept(r)),this.port=this.server.port;break}catch(r){n=r}if(!this.server)throw new Gc("no_port",`every host-bridge port (${t.join(", ")}) is taken: ${n}`);await bt(Q(vt(),"host-bridge")),await rn(Ev(),JSON.stringify({protocol:Iv,url:`ws://127.0.0.1:${this.port}/host-bridge`,port:this.port,token:this.token})),await Xo(Ev(),384)}async stop(){for(let t of this.live.values())t.conn.close(1001,"engine stopping");this.live.clear(),await this.server?.close();try{JSON.parse(await yn(Ev())).token===this.token&&await Vr(Ev())}catch{}}peers(){return[...this.live.values()].map(t=>t.peer)}peer(t){return this.live.get(t)?.peer}async waitFor(t,n){return this.live.has(t)?this.peer(t):(await Promise.race([new Promise(i=>this.waiters.push({host:t,resolve:i})),new Promise(i=>setTimeout(i,n))]),this.peer(t))}request(t,n,i={},r=3e4){let o=this.live.get(t);if(!o)return Promise.reject(new Gc("not_connected",`${t}: its panel is not connected`));let a=`r${++this.seq}`;return new Promise((s,c)=>{let l=setTimeout(()=>{o.pending.delete(a),c(new Gc("timeout",`${t}: no answer to ${n} within ${Math.round(r/1e3)} s`))},r);o.pending.set(a,{resolve:s,reject:c,timer:l}),o.conn.send(JSON.stringify({type:"request",id:a,method:n,params:i}))})}accept(t){if(t.origin&&/^https?:/i.test(t.origin)){t.send(JSON.stringify({type:"error",code:"origin_refused",message:"web pages may not use the host bridge"})),t.close(1008,"origin");return}let n=null,i=setTimeout(()=>{n||(t.send(JSON.stringify({type:"error",code:"hello_timeout",message:"no hello"})),t.close(1008,"hello"))},Ese);t.onMessage(r=>{let o;try{o=JSON.parse(r)}catch{return}if(!n){let s=(f,d)=>{clearTimeout(i),t.send(JSON.stringify({type:"error",code:f,message:d})),t.close(1008,f)};if(o.type!=="hello")return s("hello_expected","the first frame must be hello");if(o.protocol!==Iv)return s("protocol_mismatch",`this engine speaks protocol ${Iv}`);if(o.token!==this.token)return s("bad_token","the pairing token does not match: re-read the pairing file");let c=o.host??{},l=String(c.id??"");if(!/^[a-z][a-z0-9_-]{1,31}$/.test(l))return s("bad_host","host.id is missing or malformed");if(!this.live.has(l)&&this.live.size>=aZ)return s("too_many_peers",`at most ${aZ} panels`);clearTimeout(i),this.live.get(l)?.conn.close(1e3,"replaced by a newer connection"),n=l;let u={id:l,name:String(c.name??l),version:String(c.version??""),platform:String(c.platform??""),capabilities:Array.isArray(o.capabilities)?o.capabilities.map(String):[],optional_verbs:Array.isArray(o.optional_verbs)?o.optional_verbs.map(String):[]};this.live.set(l,{peer:u,conn:t,pending:new Map}),t.send(JSON.stringify({type:"welcome",protocol:Iv,app:{name:"conformtools",version:mo}})),this.waiters=this.waiters.filter(f=>f.host===l?(f.resolve(),!1):!0);return}let a=this.live.get(n);if(!(!a||a.conn!==t))if(o.type==="response"){let s=a.pending.get(String(o.id));if(!s)return;if(a.pending.delete(String(o.id)),clearTimeout(s.timer),o.ok)s.resolve(o.result??null);else{let c=o.error??{};s.reject(new Gc(c.code??"peer_error",`${n}: ${c.message??c.code??"error"}`))}}else o.type==="event"&&(this.events.push({host:n,name:String(o.name),data:o.data}),this.events.length>200&&this.events.shift())}),t.onClose(()=>{if(clearTimeout(i),!n)return;let r=this.live.get(n);if(r?.conn===t){for(let o of r.pending.values())clearTimeout(o.timer),o.reject(new Gc("disconnected",`${n}: the panel disconnected`));this.live.delete(n)}})}},Vv=null;function sZ(){return Vv??=(async()=>{let e=new q6;return await e.start(),e})(),Vv.catch(()=>{Vv=null}),Vv}var Hse=16e3;var cZ="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.",Wi=class extends Error{constructor(n,i){super(i);this.code=n}},Wv=class{constructor(t=sZ,n=Hse){this.bridge=t;this.waitMs=n;this.host="premiere";this.renders=new Map}async connected(){let t=await this.bridge();if(!await t.waitFor("premiere",this.waitMs))throw new Wi("not_connected",`premiere: the conform.tools panel is not connected. ${cZ}`);return t}async ask(t,n={},i){return await(await this.connected()).request("premiere",t,n,i)}async support(){let t;try{let i=await(await this.bridge()).waitFor("premiere",3e3);if(t=i?{ok:!0}:{ok:!1,reason:"the conform.tools panel is not connected",setup:cZ},i){let r=o=>i.capabilities.includes(o)?{ok:!0}:{ok:!1,reason:`this panel version has no ${o}`};return{export:r("timeline_write"),open:r("timeline_write"),render:r("render"),markers:r("markers"),renderplugin:{ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"}}}}catch(n){t={ok:!1,reason:n instanceof Error?n.message:String(n)}}return{export:t,open:t,render:t,markers:t,renderplugin:{ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"}}}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async sequence(t){let n=await this.ask("session.current_project");if(!n)throw new Wi("no_project","premiere: no project is open");if(!t){let o=await this.ask("session.current_timeline",{project:n});if(!o)throw new Wi("no_timeline","premiere: no sequence is active");return{project:n,seq:o,name:await this.ask("session.name",{handle:o})}}let i=await this.ask("session.timeline_count",{project:n}),r=[];for(let o=1;o<=i;o++){let a=await this.ask("session.timeline_by_index",{project:n,index:o});if(!a)continue;let s=await this.ask("session.name",{handle:a});if(s===t)return{project:n,seq:a,name:s};r.push(s)}throw new Wi("not_found",`premiere: no sequence named "${t}" (have: ${r.join(", ")})`)}async export(t){if(!t.out_path)throw new Wi("usage","premiere: export needs out_path");let{project:n,seq:i,name:r}=await this.sequence(t.timeline),o=await this.ask("timeline_write.export_xml",{project:n,timeline:i,path:t.out_path},12e4);if(!o.ok||!await Er(t.out_path)||(await un(t.out_path)).size===0)throw new Wi("export_failed",`premiere: Premiere did not write ${t.out_path}${o.errors?.length?` (${o.errors.join("; ")})`:""}`);let a=await this.ask("session.describe");return{path:t.out_path,format:"xmeml",project:a.project,timeline:r}}async open(t){if(t.into==="scratch")throw new Wi("unsupported","premiere: opening into a scratch project is not supported; the import lands in the open project as a new bin");let n=await this.ask("session.current_project");if(!n)throw new Wi("no_project","premiere: no project is open");let i=await this.ask("timeline_write.import_file",{project:n,path:t.path},3e5);if(!i.ok||!i.imported.length)throw new Wi("import_failed",`premiere: Premiere did not import ${t.path}`);let r=await this.ask("session.describe"),o=i.imported.length>1?[`imported ${i.imported.length} sequences: ${i.imported.map(a=>a.name).join(", ")}`]:[];return t.name&&o.push("Premiere names imported sequences after the file's own; name was not applied"),t.media_dirs?.length&&o.push("Premiere links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)"),{project:r.project,timeline:i.imported[0].name,notes:o,restored:!t.stay}}async renderStart(t){if(t.range)throw new Wi("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new Wi("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:n,name:i}=await this.sequence(t.timeline);await bt(t.target_dir);let r=Q(t.target_dir,`${t.name??i}.mov`),o=await this.ask("render.export_sequence",{timeline:n,output_path:r,preset_path:t.preset,queue:!1},6e4);if(!o.ok)throw new Wi("render_refused","premiere: Premiere refused the export");let a=o.job||`ppro-${Date.now()}`;return this.renders.set(a,r),{job_id:a,state:"rendering",percent:0}}async renderStatus(t){let n=await this.ask("render.progress"),i=n[t]??n.last,r=this.renders.get(t);return i?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(i.data??"encode error")}:i?.event==="onEncodeComplete"||r&&await jn(r)&&!i?{job_id:t,state:"complete",percent:100,...r?{outputs:[r]}:{}}:{job_id:t,state:"rendering",percent:typeof i?.data=="number"?Math.round(Number(i.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};function lZ(e=or()){return e==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":e==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function uZ(){for(let e of["./uxp-plugin/","./premiere-uxp/"]){let t=Pr(new URL(e,import.meta.url));if(await Er(Q(t,"manifest.json")))return t}throw new Error("premiere: the conform.tools panel is missing from this install")}async function U6(){return JSON.parse(await yn(Q(await uZ(),"manifest.json"))).version}async function fZ(e=or()){let t=lZ(e);if(!t||!await jn(t))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let n=await Mn(t,e==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),i=n.stdout.split(`
222
- `).find(r=>/CONFORM\.TOOLS|conformtools/i.test(r));return{installed:!!i&&/enabled|installed/i.test(i),version:i?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:n.stdout.trim()}}async function dZ(e=or()){let t=lZ(e);if(!t||!await jn(t))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let n=await uZ(),i=await U6(),r=await Mr("conform-ccx-");for(let u of["manifest.json","index.html","index.js","lib","icons"])await xp(Q(n,u),Q(r,u));let o=Q(vt(),"premiere");await bt(o);let a=JT(Q(o,`conformtools-premiere-${i}.ccx`));await Sr(a);let s=e==="darwin"?await Mn("sh",["-c",`cd '${r.replace(/'/g,"'\\''")}' && zip -r -q -X '${a.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await Mn("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${r}\\*' -DestinationPath '${a.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${a.replace(/\.ccx$/,".zip")}' '${a}'`]);if(await Sr(r),!s.success)throw new Error(`premiere: could not package the panel: ${s.stderr.trim()}`);let c=await Mn(t,e==="win32"?["/install",a]:["--install",a],{timeoutMs:18e4}),l=`${c.stdout}
223
- ${c.stderr}`.trim();if(!c.success||!/Installation Successful/i.test(l))throw new Error(`premiere: Adobe's installer refused the panel: ${l.split(`
224
- `).pop()}`);return{version:i,ccx:a,output:l}}var Zse=new Xv,Dse=new Wv;function Ac(e){switch(e){case"resolve":return Zse;case"premiere":return Dse;case"avid":return Fv(e,"not wired yet: waiting on Avid's Panel SDK access (bins and AAFs on disk work without it)");case"flame":return Fv(e,"not wired yet");case"fcp":return Fv(e,"not wired yet")}}var ip={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},C6="strict",mZ={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function pZ(e,t={}){let n=(e??C6).trim().toLowerCase(),i=ip[n]??ip[C6],r=ip[n]?n:n==="custom"?"custom":C6,o={...i};for(let a of Object.keys(mZ)){let s=t[a];if(s===void 0||!Number.isFinite(Number(s)))continue;let[c,l]=mZ[a],u=Math.max(c,Math.min(l,Math.round(Number(s))));u!==o[a]&&(r="custom"),o[a]=u}return{...o,preset:r}}function rp(e,t){let n=Number(e),i=Number(t);return!Number.isFinite(n)||!Number.isFinite(i)?!1:n>0&&n>=i}function qse(e,t,n){return!(e>0)||!(t>0)||!(n>0)?!1:Math.abs(t/n-e)/e>=.02}function Use(e,t,n,i,r){let o=Math.max(2,Number(r)||0);return Math.abs(e-t)<=o&&Math.abs(n-i)<=o}function Cse(e,t,n,i,r,o){return!r||!(r.top>0||r.bottom>0||r.left>0||r.right>0)?!1:Math.abs(e-r.top)<=o&&Math.abs(t-r.bottom)<=o&&Math.abs(n-r.left)<=o&&Math.abs(i-r.right)<=o}var hZ=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],Hv=e=>Math.max(0,Math.trunc(Number(e)||0)),Zv=e=>Math.max(0,Math.min(1,Number(e)||0));function Jse(e,t,n,i,r,o={}){let a=o.tolerance_px??4;i=Math.max(1,Math.trunc(i)),r=Math.max(1,Math.trunc(r));let s=[];for(let c of e??[]){let l=Math.trunc(Number(c.pts)||0),u=Hv(c.bt),f=Hv(c.bb),d=Hv(c.bl),m=Hv(c.br);if(!rp(Math.max(u,f,d,m),a)||Cse(u,f,d,m,o.declared_blanking,a))continue;let p=Number(o.expected_aspect_ratio)||0;if(p>0){let v=Math.max(1,i-d-m),g=Math.max(1,r-u-f),y=d<=a&&m<=a,w=u<=a&&f<=a;if((y||w)&&qse(p,i,r)&&Use(u,f,d,m,a)&&Math.abs(v/g-p)/p<.02)continue}let h=n+l,b;for(let v of t??[])v.start<=h&&h<v.end&&(!b||v.track>b.track)&&(b=v);b&&s.push({frame_abs:h,bt:u,bb:f,bl:d,br:m,ct:Zv(c.ct),cb:Zv(c.cb),cl:Zv(c.cl),cr:Zv(c.cr),source:c.source??"pixels",clip:b})}return s.sort((c,l)=>c.frame_abs-l.frame_abs)}function Kse(e,t){let n=[];return rp(e.bt,t)&&n.push("Top"),rp(e.bb,t)&&n.push("Bottom"),rp(e.bl,t)&&n.push("Left"),rp(e.br,t)&&n.push("Right"),n}function bZ(e,t,n,i,r,o={}){let a=Math.max(1,Math.trunc(o.min_frames??1)),s=Math.max(0,Math.trunc(o.gap_frames??0)),c=o.tolerance_px??4,l=[],u;for(let f of Jse(e,t,n,i,r,o)){(!u||u.clip!==f.clip||f.frame_abs-u.end_frame-1>s)&&(u={clip:f.clip,start_frame:f.frame_abs,end_frame:f.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},l.push(u)),u.end_frame=f.frame_abs,u.frame_count++,u.sources.add(f.source);for(let[d,m]of hZ)f[d]>=u.measured[d]&&(u.measured[d]=f[d],u.coverage[m]=f[m])}return l.filter(f=>f.frame_count>=a).map(f=>({...f,duration_frames:f.end_frame-f.start_frame+1,sources:[...f.sources].sort(),zones:Kse(f.measured,c)}))}function gZ(e){let t=new Map;for(let i of e){let r=t.get(i.clip.id);r||(r={clip:i.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:i.start_frame,zones:[],sources:[],ranges:[]},t.set(i.clip.id,r)),r.frames+=i.frame_count,r.first_frame_abs=Math.min(r.first_frame_abs,i.start_frame);for(let[o,a]of hZ)i.measured[o]>=r.measured[o]&&(r.measured[o]=i.measured[o],r.coverage[a]=i.coverage[a]);r.sources=[...new Set([...r.sources,...i.sources])].sort(),r.ranges.push(i)}let n=["Top","Bottom","Left","Right"];return[...t.values()].map(i=>{let r=new Set(i.ranges.flatMap(o=>o.zones));return{...i,zones:n.filter(o=>r.has(o)),ranges:i.ranges.sort((o,a)=>o.start_frame-a.start_frame)}}).sort((i,r)=>i.clip.start-r.clip.start)}function vZ(e,t=1){let n=Math.max(0,Math.trunc(t)),i=[];for(let r of[...e].sort((o,a)=>o.frame-a.frame)){let o=i.at(-1);if(o&&r.frame-o.end_frame<=n+1){o.end_frame=Math.max(o.end_frame,r.frame),o.frames++,o.darkest=Math.min(o.darkest,r.avg);continue}i.push({start_frame:r.frame,end_frame:r.frame,duration_frames:1,frames:1,darkest:r.avg})}for(let r of i)r.duration_frames=r.end_frame-r.start_frame+1;return i}var Gse="ConformTools:blanking:error",Ase="ConformTools:blanking:black";function Bse(e,t,n){return e*175e4*(t*n/(1920*1080))}async function yZ(e,t){let n=-1;for(let i=Date.now()+t;Date.now()<i;){if(await jn(e)){let r=(await un(e)).size;if(r>0&&r===n)return!0;n=r}await new Promise(r=>setTimeout(r,500))}return n>0}async function J6(e,t,n,i){let r=new Promise(o=>i?.addEventListener("abort",()=>o(),{once:!0}));for(;t.state==="queued"||t.state==="rendering";){if(n?.(t.percent,100,"rendering"),await Promise.race([r.then(()=>!0),new Promise(a=>setTimeout(()=>a(!1),1e3))]))return await e.renderCancel(t.job_id);t=await e.renderStatus(t.job_id)}return t}async function wZ(e,t,n,i,r,o={}){let a=[],s=await(o.status??af)();if(s.readiness!=="ready")if(s.readiness==="unknown")a.push("Resolve's log does not say whether it loaded the renderplugin; trying anyway");else throw new Error(`renderplugin ${s.readiness}: ${s.next}`);let c=async(J,q)=>{let W=await t(J,q,6e4);if(!W.ok)throw new Error(`resolve: ${W.detail||W.why}`);return W};i?.(0,100,"preparing");let l=await c("renderplugin_preset",{preset_path:await QH()});l.imported&&a.push(`imported the conform.tools render preset into this Resolve database${l.replaced?" (replaced a stale one)":""}`);let u=await c("clips",{timeline:n.timeline}),f=n.range?.in??u.start_frame,d=n.range?n.range.out-n.range.in+1:u.end_frame-u.start_frame,m=Q(vt(),"renderplugin",`${u.timeline.replace(/[^\w.-]+/g,"_")}_${Date.now()}`);await bt(m);let p=Bse(d,u.width,u.height)*1.15+5e9,h=await Pp(m);if(!n.ignore_space&&h!==null&&h<p)throw await Sr(m),new Error(`not enough space for the throwaway render: about ${(p/1e9).toFixed(1)} GB needed, ${(h/1e9).toFixed(1)} GB free on the volume holding ${vt()}. Free space, set CONFORM_MCP_HOME to a bigger volume, or pass ignore_space.`);let b=await e.renderStart({timeline:u.timeline,target_dir:m,name:"conform.tools",range:n.range,audio:n.audio??!0,renderplugin:n.checks??{}});if(b=await J6(e,b,i,r),b.state!=="complete")throw await Sr(m),new Error(`the renderplugin render ${b.state}${b.error?`: ${b.error}`:""}`);i?.(100,100,"reading the report");let v=Q(m,"qc_report.json");if(!await yZ(v,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 g=JSON.parse(await yn(v)),y=g.width||u.width,w=g.height||u.height,x=g.fps_num&&g.fps_den?g.fps_num/g.fps_den:Number(u.fps)||24,O=pZ(n.strictness,n.overrides),P=g.frame_stats??[],T=bZ(P,u.clips,f,y,w,{...O,expected_aspect_ratio:n.expected_aspect}),S=P.some(J=>(J.avg_luma??0)>1.5)?1:255,k=vZ(P.filter(J=>(J.avg_luma??255)*S<O.black_threshold).map(J=>({frame:f+J.pts,avg:(J.avg_luma??0)*S})),O.gap_frames),L=(g.checks??[]).filter(J=>J.status==="fail"||J.status==="warn").map(J=>({id:J.id,label:J.label??J.id,status:J.status,ranges:J.ranges?.length??0})),z,X=Q(m,"qc_audio.json");if((n.audio??!0)&&await yZ(X,8e3)){let J=JSON.parse(await yn(X));z={integrated_lufs:J.integrated_lufs,true_peak_dbtp:J.true_peak_dbtp,issues:J.issues?.length??0}}let V;if(n.markers??!0){let J=F=>Qt(F,x),q=[...T.map(F=>({frame:F.start_frame-u.start_frame,duration:F.duration_frames,color:"Red",tag:Gse,name:"conform.tools blanking",note:`Zone: ${F.zones.join(", ")} | max ${Math.max(F.measured.bt,F.measured.bb,F.measured.bl,F.measured.br)}px | ${F.frame_count} frame(s) | frames ${F.start_frame}-${F.end_frame} @ ${J(F.start_frame)}`})),...k.map(F=>({frame:F.start_frame-u.start_frame,duration:F.duration_frames,color:"Yellow",tag:Ase,name:"conform.tools black frames",note:`${F.frames} black frame(s) @ ${J(F.start_frame)}`}))];await c("markers",{timeline:u.timeline,tag:"ConformTools:blanking",clear:!0,place:[]});let W=await c("markers",{timeline:u.timeline,tag:"ConformTools:blanking",place:q});V={placed:Number(W.placed),skipped:W.skipped}}let R;for await(let J of dn(m))!J.isFile||J.name.startsWith("qc_")||(n.keep_render?(R??=[]).push(Q(m,J.name)):await Sr(Q(m,J.name)));let j=gZ(T).length;return T.length&&a.push(`${T.length} blanking finding(s) on ${j} clip(s)`),{timeline:u.timeline,frames:d,raster:{width:y,height:w},fps:x,strictness:O,blanking:T,black:k,checks:L,audio:z,markers:V,report_dir:m,...R?{render_kept:R}:{},notes:a}}function xZ(e){let t=r=>Qt(r,e.fps),n=e.blanking.length+e.black.length+e.checks.filter(r=>r.status==="fail").length,i=[`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 r of e.blanking){let o=Math.max(r.measured.bt,r.measured.bb,r.measured.bl,r.measured.br);i.push(` blanking ${t(r.start_frame)}\u2013${t(r.end_frame)} ${r.clip.name} (V${r.clip.track}) ${r.zones.join("/")} ${o}px, ${r.frame_count} frame(s)`)}for(let r of e.black)i.push(` black ${t(r.start_frame)}\u2013${t(r.end_frame)} ${r.frames} frame(s)`);for(let r of e.checks)i.push(` ${r.status.padEnd(9)} ${r.label}${r.ranges?` (${r.ranges} range(s))`:""}`);return e.audio&&i.push(` audio ${e.audio.integrated_lufs??"?"} LUFS integrated, ${e.audio.true_peak_dbtp??"?"} dBTP true peak, ${e.audio.issues} issue(s)`),e.markers&&i.push(`markers: ${e.markers.placed} placed on the timeline${e.markers.skipped.length?`, ${e.markers.skipped.length} skipped (a frame already had someone else's marker)`:""}`),i.push(...e.notes.map(r=>`note: ${r}`),`report: ${e.report_dir}`),e.render_kept&&i.push(`render kept: ${e.render_kept.join(", ")}`),i.join(`
225
- `)}function pi(e,t){let n=new Float64Array(9);for(let i=0;i<3;i++)for(let r=0;r<3;r++){let o=0;for(let a=0;a<3;a++)o+=e[i*3+a]*t[a*3+r];n[i*3+r]=o}return n}function A6(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let i=0;i<3;i++)t[n*3+i]=e[i*3+n];return t}function Dv(e){let t=new Float64Array(9);return t[0]=e[0],t[4]=e[1],t[8]=e[2],t}function B6(e){let t=Float64Array.from(e),n=new Float64Array([1,0,0,0,1,0,0,0,1]);for(let a=0;a<24;a++){let s=0;for(let[c,l]of[[0,1],[0,2],[1,2]])s+=t[c*3+l]**2;if(s<1e-30)break;for(let[c,l]of[[0,1],[0,2],[1,2]]){let u=t[c*3+l];if(Math.abs(u)<1e-300)continue;let f=(t[l*3+l]-t[c*3+c])/(2*u),d=Math.sign(f||1)/(Math.abs(f)+Math.sqrt(f*f+1)),m=1/Math.sqrt(d*d+1),p=d*m;for(let h=0;h<3;h++){let b=t[h*3+c],v=t[h*3+l];t[h*3+c]=m*b-p*v,t[h*3+l]=p*b+m*v}for(let h=0;h<3;h++){let b=t[c*3+h],v=t[l*3+h];t[c*3+h]=m*b-p*v,t[l*3+h]=p*b+m*v}for(let h=0;h<3;h++){let b=n[h*3+c],v=n[h*3+l];n[h*3+c]=m*b-p*v,n[h*3+l]=p*b+m*v}}}let i=[0,1,2].sort((a,s)=>t[a*3+a]-t[s*3+s]),r=new Float64Array(3),o=new Float64Array(9);return i.forEach((a,s)=>{r[s]=t[a*3+a];for(let c=0;c<3;c++)o[c*3+s]=n[c*3+a]}),{values:r,vectors:o}}function PZ(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let i=0;i<=n;i++){let r=e[n*3+i];for(let o=0;o<i;o++)r-=t[n*3+o]*t[i*3+o];if(n===i){if(r<=0)return null;t[n*3+i]=Math.sqrt(r)}else t[n*3+i]=r/t[i*3+i]}return t}function Yse(e){let t=new Float64Array(9);for(let n=0;n<3;n++){t[n*3+n]=1/e[n*3+n];for(let i=0;i<n;i++){let r=0;for(let o=i;o<n;o++)r+=e[n*3+o]*t[o*3+i];t[n*3+i]=-r/e[n*3+n]}}return t}function K6(e){let{values:t,vectors:n}=B6(e),i=1e-12*Math.max(...Array.from(t).map(Math.abs),1e-30),r=new Float64Array(3);for(let o=0;o<3;o++)r[o]=Math.abs(t[o])>i?1/t[o]:0;return pi(pi(n,Dv(r)),A6(n))}function Qse(e){let{values:t,vectors:n}=B6(e),i=new Float64Array(3);for(let r=0;r<3;r++)i[r]=Math.sqrt(Math.max(t[r],0));return pi(pi(n,Dv(i)),A6(n))}function kZ(e){let t=e.w*e.h,n=new Float64Array(3);for(let o=0;o<t;o++)for(let a=0;a<3;a++)n[a]+=e.data[o*3+a];for(let o=0;o<3;o++)n[o]/=t;let i=new Float64Array(9);for(let o=0;o<t;o++){let a=e.data[o*3]-n[0],s=e.data[o*3+1]-n[1],c=e.data[o*3+2]-n[2];i[0]+=a*a,i[1]+=a*s,i[2]+=a*c,i[4]+=s*s,i[5]+=s*c,i[8]+=c*c}let r=Math.max(1,t-1);for(let o of[0,1,2,4,5,8])i[o]/=r;return i[3]=i[1],i[6]=i[2],i[7]=i[5],{mean:n,cov:i}}function _se(e,t,n,i){let r=e.w*e.h,o=new Float32Array(r*3);for(let a=0;a<r;a++){let s=e.data[a*3]-n[0],c=e.data[a*3+1]-n[1],l=e.data[a*3+2]-n[2];o[a*3]=t[0]*s+t[1]*c+t[2]*l+i[0],o[a*3+1]=t[3]*s+t[4]*c+t[5]*l+i[1],o[a*3+2]=t[6]*s+t[7]*c+t[8]*l+i[2]}return{data:o,w:e.w,h:e.h}}function $se(e,t){let{values:n,vectors:i}=B6(e),r=new Float64Array(3),o=new Float64Array(3);for(let f=0;f<3;f++){let d=Math.max(n[f],0);r[f]=Math.sqrt(d),o[f]=r[f]>1e-12?1/r[f]:0}let a=Dv(r),s=Dv(o),c=A6(i),l=pi(pi(pi(pi(a,c),t),i),a),u=Qse(l);return pi(pi(pi(pi(i,s),u),s),c)}function ece(e,t){let i=Float64Array.from(e),r=Float64Array.from(t);for(let s of[0,4,8])i[s]+=1e-5,r[s]+=1e-5;let o=PZ(i),a=PZ(r);if(!o||!a){let s=new Float64Array(9);for(let c=0;c<3;c++){let l=Math.sqrt(Math.max(e[c*3+c],0)),u=Math.sqrt(Math.max(t[c*3+c],0));s[c*3+c]=l>1e-12?u/l:1}return s}return pi(a,Yse(o))}function tce(e,t,n,i){let r=K6(n.cov),o=K6(i.cov),a=e.w*e.h,s=new Float64Array(9);for(let l=0;l<a;l++){let u=t.data[l*3]-i.mean[0],f=t.data[l*3+1]-i.mean[1],d=t.data[l*3+2]-i.mean[2],m=e.data[l*3]-n.mean[0],p=e.data[l*3+1]-n.mean[1],h=e.data[l*3+2]-n.mean[2];s[0]+=u*m,s[1]+=u*p,s[2]+=u*h,s[3]+=f*m,s[4]+=f*p,s[5]+=f*h,s[6]+=d*m,s[7]+=d*p,s[8]+=d*h}let c=Math.max(1,a-1);for(let l=0;l<9;l++)s[l]/=c;return pi(pi(K6(o),o),pi(s,r))}var To=4096;function G6(e,t){let n=e.w*e.h,i=t.w*t.h,r=a=>Math.min(To-1,Math.max(0,Math.round(ao(a)*(To-1)))),o=[];for(let a=0;a<3;a++){let s=new Float64Array(To),c=new Float64Array(To);for(let p=0;p<n;p++)s[r(e.data[p*3+a])]++;for(let p=0;p<i;p++)c[r(t.data[p*3+a])]++;let l=0;for(let p=0;p<To;p++)l+=s[p],s[p]=l/n;let u=[],f=[];l=0;for(let p=0;p<To;p++)c[p]!==0&&(l+=c[p],u.push(p/(To-1)),f.push(l/i));let d=new Float32Array(To),m=0;for(let p=0;p<To;p++){let h=s[p];for(;m<f.length-1&&f[m]<h;)m++;if(m===0||f[m]<=h)d[p]=u[m]??0;else{let b=f[m-1],v=f[m],g=v>b?(h-b)/(v-b):0;d[p]=u[m-1]+(u[m]-u[m-1])*g}}o.push(d)}return o}var sf=1/Math.sqrt(3),cf=1/Math.sqrt(6),qv=1/Math.sqrt(2),T6e=[sf,sf,sf,cf,cf,-2*cf,qv,-qv,0],z6e=[sf,cf,qv,sf,cf,-qv,sf,-2*cf,0];function Uv(e,t,n="mvgd"){let i=e.w*e.h,r=b=>Math.min(To-1,Math.max(0,Math.round(ao(b)*(To-1)))),o=(b,v)=>{let g=new Float32Array(i*3);for(let y=0;y<3;y++){let w=v[y];for(let x=0;x<i;x++)g[x*3+y]=w[r(b.data[x*3+y])]}return{data:g,w:b.w,h:b.h}},a=G6(e,t),s=o(e,a),c=kZ(s),l=kZ(t),u;if(n==="mkl")u=$se(c.cov,l.cov);else if(n==="coral")u=ece(c.cov,l.cov);else if(n==="adain"){let b=new Float64Array(9);for(let v=0;v<3;v++){let g=Math.sqrt(Math.max(c.cov[v*3+v],0)),y=Math.sqrt(Math.max(l.cov[v*3+v],0));b[v*3+v]=g>1e-12?y/g:1}u=b}else u=tce(s,t,c,l);let f=_se(s,u,c.mean,l.mean),d={data:Float32Array.from(f.data,ao),w:e.w,h:e.h},m=G6(d,t),p=o(d,m),h=[l.mean[0]-(u[0]*c.mean[0]+u[1]*c.mean[1]+u[2]*c.mean[2]),l.mean[1]-(u[3]*c.mean[0]+u[4]*c.mean[1]+u[5]*c.mean[2]),l.mean[2]-(u[6]*c.mean[0]+u[7]*c.mean[1]+u[8]*c.mean[2])];return{hm1:a,matrix:Array.from(u),offset:h,mid:d,hm2:m,image:p}}function TZ(e,t,n=1){let i=e.w*e.h,r=new Float32Array(i*3),o=[Math.pow(t[0],n),Math.pow(t[1],n),Math.pow(t[2],n)];for(let a=0;a<i;a++)for(let s=0;s<3;s++){let c=ja(Math.min(1,Math.max(0,e.data[a*3+s])))*o[s];r[a*3+s]=l6(c<0?0:c>1?1:c)}return{data:r,w:e.w,h:e.h}}function SZ(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 Y6(e,t){let n=SZ(e),i=SZ(t),r=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=[n[1]*i[2]-n[2]*i[1],n[2]*i[0]-n[0]*i[2],n[0]*i[1]-n[1]*i[0]],a=Math.hypot(o[0],o[1],o[2]);return Math.atan2(a,r)*180/Math.PI}function zZ(e,t,n){return .2126*e+.7152*t+.0722*n}function nce(e,t){let n=e.length;if(n===0)return 0;if(n===1)return e[0];let i=Math.min(n-1,Math.max(0,t*(n-1))),r=Math.floor(i),o=Math.min(n-1,r+1),a=i-r;return e[r]+a*(e[o]-e[r])}function Q6(e,t,n=4,i=6e4){let r=e.w*e.h,o=Math.max(1,Math.floor(r/i)),a=new Float32Array(Math.ceil(r/o)),s=0;for(let l=0;l<r;l+=o){let u=ja(Math.max(0,Math.min(1,e.data[l*3]))),f=ja(Math.max(0,Math.min(1,e.data[l*3+1]))),d=ja(Math.max(0,Math.min(1,e.data[l*3+2]))),m=zZ(u,f,d);if(m<=1e-5||Math.max(u,f,d)>=.99)continue;let p=ja(Math.max(0,Math.min(1,t.data[l*3]))),h=ja(Math.max(0,Math.min(1,t.data[l*3+1]))),b=ja(Math.max(0,Math.min(1,t.data[l*3+2]))),v=zZ(p,h,b)/m;!Number.isFinite(v)||v<=0||(a[s++]=Math.max(-n,Math.min(n,Math.log2(v))))}if(s===0)return 0;let c=a.subarray(0,s);return c.sort(),nce(c,.5)}var Cv={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 zo=.435;var NZ={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:1,pivot:zo};function lf(e){if(!e)return!0;let t=n=>n.every(i=>Math.abs(i)<1e-9);return t(e.shadow)&&t(e.midtone)&&t(e.highlight)&&Math.abs(e.contrast-1)<1e-9}var hi=Cv.x,zs=hi.length;function $6(e){let t=Cv.controls[e],n=[],i=[];for(let o of t.amps)n.push(o),i.push(t.curves[`${o>=0?"+":""}${o.toFixed(2)}`]);let r=n.findIndex(o=>o>0);return r<0&&(r=n.length),n.splice(r,0,0),i.splice(r,0,new Array(zs).fill(0)),{amps:n,curves:i}}var ice=$6("shadow"),oce=$6("midtone"),ace=$6("highlight");function Bc(e,t){if(t<=hi[0])return e[0];let n=zs-1;if(t>=hi[n])return e[n];let i=0,r=n;for(;r-i>1;){let a=i+r>>1;hi[a]<=t?i=a:r=a}let o=(t-hi[i])/(hi[r]-hi[i]);return e[i]+(e[r]-e[i])*o}function _6(e,t,n){if(t===0)return 0;let{amps:i,curves:r}=e,o=i.length-1;if(t<=i[0])return Bc(r[0],n)*(t/i[0]);if(t>=i[o])return Bc(r[o],n)*(t/i[o]);let a=0,s=o;for(;s-a>1;){let l=a+s>>1;i[l]<=t?a=l:s=l}let c=(t-i[a])/(i[s]-i[a]);return Bc(r[a],n)+(Bc(r[s],n)-Bc(r[a],n))*c}var Jv=(()=>{let e=Cv.contrast,t=e.cs.filter(n=>n>1).map(n=>({c:n,y:e.curves[n.toFixed(2)].map((i,r)=>hi[r]+i)}));return t.unshift({c:1,y:[...hi]}),t})();function OZ(e,t){if(t<=e[0])return hi[0];let n=zs-1;if(t>=e[n])return hi[n];let i=0,r=n;for(;r-i>1;){let a=i+r>>1;e[a]<=t?i=a:r=a}let o=(t-e[i])/(e[r]-e[i]);return hi[i]+(hi[r]-hi[i])*o}function sce(e,t){let n=0;for(;n<Jv.length-2&&Jv[n+1].c<=e;)n++;let i=Jv[n],r=Jv[n+1],o=(e-i.c)/(r.c-i.c),a=zo,s=new Array(zs);for(let u=0;u<zs;u++){let f=hi[u],d=0,m=1;for(let p=0;p<30;p++){let h=(d+m)/2;OZ(i.y,h)*(1-o)+OZ(r.y,h)*o<f?d=h:m=h}s[u]=(d+m)/2}let c=s;if(Math.abs(t-a)>1e-6){c=new Array(zs);for(let u=0;u<zs;u++){let f=hi[u],d=f<t?a*(f/t):a+(1-a)*((f-t)/(1-t)),m=Bc(s,d);c[u]=m<a?t*(m/a):t+(1-t)*((m-a)/(1-a))}}let l=0;for(let u=0;u<zs;u++){let f=c[u]<l?l:c[u];c[u]=f<0?0:f>1?1:f,l=c[u]}return c}var MZ=NaN,LZ=NaN,RZ=null;function cce(e,t,n){return t<1?n+t*(e-n):((t!==MZ||n!==LZ)&&(RZ=sce(t,n),MZ=t,LZ=n),Bc(RZ,e))}function Os(e,t,n){let i=e+_6(ice,t.shadow[n],e)+_6(oce,t.midtone[n],e)+_6(ace,t.highlight[n],e);return t.contrast!==1&&(i=cce(i,t.contrast,t.pivot)),i}var XZ=[.2126,.7152,.0722];function jZ(e,t){let n=t.wheels??NZ,i=e8({...t,wheels:void 0,saturation:void 0,mixer:void 0}),r=!lf(t.wheels),o=e.w*e.h,a=new Float32Array(o*3),s=(l,u)=>{let f=l*i.slope[u]+i.offset[u],d=i.power[u];return d!==1&&(f=f<0?-Math.pow(-f,d):Math.pow(f,d)),r?Os(f,n,u):f};if(o*3>=32768){let u=new Float32Array(12288);for(let f=0;f<3;f++)for(let d=0;d<4096;d++)u[f*4096+d]=s(d/4095,f);for(let f=0;f<o;f++)for(let d=0;d<3;d++){let m=e.data[f*3+d];if(m>=0&&m<=1){let p=m*4095,h=p|0,b=p-h,v=u[d*4096+h];a[f*3+d]=b>0?v+(u[d*4096+h+1]-v)*b:v}else a[f*3+d]=s(m,d)}}else for(let l=0;l<o;l++)for(let u=0;u<3;u++)a[l*3+u]=s(e.data[l*3+u],u);let c=t.saturation??1;if(c!==1)for(let l=0;l<o;l++){let u=.21*a[l*3]+.7*a[l*3+1]+.09*a[l*3+2];for(let f=0;f<3;f++)a[l*3+f]=u+(a[l*3+f]-u)*c}if(!uf(t.mixer)){let l=Kv(t.mixer);for(let u=0;u<o;u++){let f=a[u*3],d=a[u*3+1],m=a[u*3+2];a[u*3]=l[0]*f+l[1]*d+l[2]*m,a[u*3+1]=l[3]*f+l[4]*d+l[5]*m,a[u*3+2]=l[6]*f+l[7]*d+l[8]*m}}return{data:a,w:e.w,h:e.h}}function uf(e){if(!e)return!0;let t=[1,0,0,0,1,0,0,0,1];return e.every((n,i)=>Math.abs(n-t[i])<1e-9)}function Kv(e){let t=e.slice();for(let n=0;n<3;n++){let i=-XZ[n];for(let r=0;r<3;r++)i+=XZ[r]*e[r*3+n];for(let r=0;r<3;r++)t[r*3+n]-=i}return t}function FZ(e,t){if(!lf(t.wheels)||t.saturation!==void 0&&t.saturation!==1||!uf(t.mixer)){let l=jZ(e,t);for(let u=0;u<l.data.length;u++)l.data[u]=ao(l.data[u]);return l}let n=t.blackPointOffset,i=Math.pow(2,t.exposureStops),r=[t.wbGain[0]*i,t.wbGain[1]*i,t.wbGain[2]*i],o=e.w*e.h,a=new Float32Array(o*3);for(let l=0;l<o;l++)a[l*3]=ao(e.data[l*3]+n[0]),a[l*3+1]=ao(e.data[l*3+1]+n[1]),a[l*3+2]=ao(e.data[l*3+2]+n[2]);let s=TZ({data:a,w:e.w,h:e.h},r,1),c=t.power;if(!c||c[0]===1&&c[1]===1&&c[2]===1)return s;for(let l=0;l<o;l++)for(let u=0;u<3;u++){let f=s.data[l*3+u];s.data[l*3+u]=f<=0?0:Math.pow(f,c[u])}return s}function e8(e){let t=Math.pow(2,e.exposureStops),n=e.wbGain.map(a=>Math.pow(a*t,1/2.4)),i=e.blackPointOffset.map((a,s)=>a*n[s]),r=e.power??[1,1,1],o={slope:n,offset:i,power:r};return lf(e.wheels)||(o.wheels=e.wheels),e.saturation!==void 0&&Math.abs(e.saturation-1)>1e-6&&(o.saturation=e.saturation),uf(e.mixer)||(o.mixer=e.mixer),o}function lce(e,t,n,i,r,o,a){let c=new Float64Array(1024),l=new Float64Array(1024),u=new Float64Array(1024),f=0;for(let k=0;k<n;k+=i){let L=e[k*3+r],z=t[k*3+r];if(!(L>.004&&L<.996)||!(z>5e-4&&z<.9995))continue;let X=L*1023+.5|0,V=o?o[k]:1;c[X]+=L*V,l[X]+=z*V,u[X]+=V,f++}let d=[],m=[],p=[];for(let k=0;k<1024;k++)u[k]!==0&&(d.push(c[k]/u[k]),m.push(l[k]/u[k]),p.push(u[k]));let h=d.length;if(f<32||h<8)return{slope:1,offset:0,power:1,residual:0,samples:f};let b=0;for(let k=0;k<h;k++)b+=p[k];let v=(k,L,z)=>{let X=0;for(let V=0;V<h;V++){let R=d[V]*k+L,j=R<=0?0:Math.pow(R,z);X+=p[V]*Math.abs((j>1?1:j)-m[V])}return X/b},g=k=>{let L=0,z=0,X=0,V=0,R=0;for(let W=0;W<h;W++){let F=k===1?m[W]:Math.pow(Math.max(m[W],1e-9),1/k),H=p[W];L+=H,z+=H*d[W],X+=H*d[W]*d[W],V+=H*F,R+=H*d[W]*F}let j=L*X-z*z;if(Math.abs(j)<1e-12)return null;let J=(L*R-z*V)/j,q=(X*V-z*R)/j;for(let W=0;W<3;W++){let F=0,H=0,C=0,$=0,oe=0;for(let Ae=0;Ae<h;Ae++){let de=d[Ae]*J+q;if(de<=1e-9)continue;let Oe=Math.pow(de,k),Ze=(Oe>1?1:Oe)-m[Ae],ue=k*Math.pow(de,k-1),ze=ue*d[Ae],Re=p[Ae];F+=Re*ze*ze,H+=Re*ze*ue,C+=Re*ue*ue,$+=Re*ze*Ze,oe+=Re*ue*Ze}let ye=F*C-H*H;if(!(Math.abs(ye)>1e-12))break;if(J-=(C*$-H*oe)/ye,q-=(F*oe-H*$)/ye,q>0&&(q=0),!(J>.02&&J<200)||!Number.isFinite(q))return null}return!(J>.02&&J<200)||!Number.isFinite(q)||q>0?null:{s:J,o:q}},y=a?Math.min(Math.max(1,a[0]),a[1]):1,w=g(y),x=w?{slope:w.s,offset:w.o,power:y,residual:v(w.s,w.o,y),samples:f}:{slope:1,offset:0,power:1,residual:v(1,0,1),samples:f},O=.02,P=160,T=Math.log(a?a[0]:.1),S=Math.log(a?a[1]:5);for(let k=0;k<P;k++){let L=Math.exp(T+(S-T)*k/(P-1)),z=g(L);if(!z)continue;let X=v(z.s,z.o,L);X<x.residual*(1-O)&&(x={slope:z.s,offset:z.o,power:L,residual:X,samples:f})}return x}function Gv(e,t,n=4e4,i,r){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 o=e.w*e.h;if(i&&i.length!==o)throw new Error(`fitShotAnalysis: weights length ${i.length} != ${o} pixels`);let a=Math.max(1,Math.floor(o/n)),s=[1,1,1],c=[0,0,0],l=[1,1,1],u=[0,0,0],f=0;for(let b=0;b<3;b++){let v=lce(e.data,t.data,o,a,b,i,r?.[b]);s[b]=v.slope,c[b]=v.offset,l[b]=v.power,u[b]=v.residual,f=Math.max(f,v.samples)}let d=s.map(b=>Math.pow(b,2.4)),m=[d[0]/d[1],1,d[2]/d[1]],p=Math.log2(d[1]);return{analysis:{blackPointOffset:[c[0]/s[0],c[1]/s[1],c[2]/s[2]],wbGain:m,exposureStops:p,power:l,castDeg:Y6(m,[1,1,1])},lumaStops:Q6(e,t),slope:s,offset:c,power:l,residual:u,maxResidual:Math.max(u[0],u[1],u[2]),samples:f}}function IZ(e,t,n,i=2e4,r,o){let a=e.w*e.h;if(r&&r.length!==a)throw new Error(`fitLogWheels: weights length ${r.length} != ${a} pixels`);let s=Math.max(1,Math.floor(a/i)),c=1024,l=[[],[],[]],u=[[],[],[]],f=[[],[],[]];for(let T=0;T<3;T++){let S=new Float64Array(c),k=new Float64Array(c),L=new Float64Array(c);for(let z=0;z<a;z+=s){let X=e.data[z*3+T];if(!(X>.002&&X<.998))continue;let V=X*(c-1)+.5|0,R=r?r[z]:1;S[V]+=X*R,k[V]+=t.data[z*3+T]*R,L[V]+=R}for(let z=0;z<c;z++)L[z]!==0&&(l[T].push(S[z]/L[z]),u[T].push(k[z]/L[z]),f[T].push(L[z]))}let d=(T,S)=>S?Math.min(S[1],Math.max(S[0],T)):T,m={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:d(1,o?.contrast),pivot:d(zo,o?.pivot)},p=n.wbGain,h=Math.pow(2,n.exposureStops),b=[0,1,2].map(T=>Math.pow(p[T]*h,1/2.4)),v=n.blackPointOffset,g=n.power??[1,1,1],y=[[],[],[]];for(let T=0;T<3;T++)for(let S=0;S<l[T].length;S++){let k=(l[T][S]+v[T])*b[T];g[T]!==1&&(k=k<0?-Math.pow(-k,g[T]):Math.pow(k,g[T])),y[T].push(k)}let w=0;for(let T=0;T<3;T++)for(let S of f[T])w+=S;let x=()=>{let T=0;for(let S=0;S<3;S++)for(let k=0;k<y[S].length;k++){let L=Os(y[S][k],m,S);T+=f[S][k]*Math.abs((L<0?0:L>1?1:L)-u[S][k])}return w?T/w:0},O=(T,S,k)=>{let L=.6180339887,z=S,X=k,V=X-L*(X-z),R=z+L*(X-z);T(V);let j=x();T(R);let J=x(),q=j,W=J;for(let H=0;H<18&&X-z>1e-4;H++)q<W?(X=R,R=V,W=q,V=X-L*(X-z),T(V),q=x()):(z=V,V=R,q=W,R=z+L*(X-z),T(R),W=x());let F=q<W?V:R;T(F)},P=x();for(let T=0;T<3;T++){O(k=>{m.contrast=k},Math.max(.4,o?.contrast[0]??.4),Math.min(2.2,o?.contrast[1]??2.2)),O(k=>{m.pivot=k},Math.max(.15,o?.pivot[0]??.15),Math.min(.85,o?.pivot[1]??.85));for(let k=0;k<3;k++)O(L=>{m.shadow[k]=L},-.4,.4),O(L=>{m.midtone[k]=L},-.4,.4),O(L=>{m.highlight[k]=L},-.4,.4);let S=x();if(P-S<1e-5)break;P=S}return Math.abs(m.contrast-1)<1e-4&&(m.contrast=1,m.pivot=zo),{wheels:m,residual:x()}}var Hi=e=>e<0?0:e>1?1:e;function VZ(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 uce(e,t){let n=e.w*e.h,i=new Float32Array(n*3);for(let r=0;r<3;r++){let o=t[r],a=o.length-1;for(let s=0;s<n;s++){let c=Math.min(a,Math.max(0,Math.round(Hi(e.data[s*3+r])*a)));i[s*3+r]=o[c]}}return{data:i,w:e.w,h:e.h}}function EZ(e,t,n=1){let i=0,r=0;for(let o=0;o<e.w*e.h;o+=n){for(let a=0;a<3;a++)i+=Math.abs(Hi(e.data[o*3+a])-Hi(t.data[o*3+a]));r+=3}return i/r}var p8e=.8/255;function WZ(e,t,n,i){let r=n??Uv(e,t,i?.inner??"mvgd"),o=i?.tone1Contrast??null,a=i?.enableTone2??!0,s=i?.trimContrast??null,c=r.matrix,l=k=>({data:Float32Array.from(k.data,Hi),w:k.w,h:k.h}),u=uce(e,r.hm1),f=n8(e,u),d=r.offset,m=VZ(c),p=[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]],h=e.w*e.h,b=new Float32Array(h*3);for(let k=0;k<h;k++){let L=f.out.data[k*3],z=f.out.data[k*3+1],X=f.out.data[k*3+2];b[k*3]=Hi(c[0]*L+c[1]*z+c[2]*X+d[0]),b[k*3+1]=Hi(c[3]*L+c[4]*z+c[5]*X+d[1]),b[k*3+2]=Hi(c[6]*L+c[7]*z+c[8]*X+d[2])}let v={data:b,w:e.w,h:e.h},g=n8(v,r.image);if(o==null&&a&&s==null){let k=EZ(l(g.out),r.image);return{tone1:f.tone,offset:p,matrix:c,tone2:g.tone,tone2Enabled:!0,trim:null,residual:k}}let y=o==null?f.tone:{...f.tone,contrast:o,pivot:f.tone.pivot??.435},w=s==null?null:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1],contrast:s,pivot:.435},x=t8(e,y),O=new Float32Array(h*3);for(let k=0;k<h;k++){let L=x.data[k*3],z=x.data[k*3+1],X=x.data[k*3+2];O[k*3]=Hi(c[0]*L+c[1]*z+c[2]*X+d[0]),O[k*3+1]=Hi(c[3]*L+c[4]*z+c[5]*X+d[1]),O[k*3+2]=Hi(c[6]*L+c[7]*z+c[8]*X+d[2])}let P={data:O,w:e.w,h:e.h},T=a?t8(P,g.tone):P;w&&(T=t8(T,w));let S=EZ(T,r.image);return{tone1:y,offset:p,matrix:c,tone2:g.tone,tone2Enabled:a,trim:w,residual:S}}function t8(e,t){let i=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,r=new Float32Array(3*4096);for(let a=0;a<3;a++){let s=t.power?.[a]??1;for(let c=0;c<4096;c++){let l=c/4095*t.slope[a]+t.offset[a];s!==1&&(l=l<0?-Math.pow(-l,s):Math.pow(l,s)),i&&(l=Os(l,i,a)),r[a*4096+c]=Hi(l)}}let o=new Float32Array(e.data.length);for(let a=0;a<e.w*e.h;a++)for(let s=0;s<3;s++)o[a*3+s]=r[s*4096+Math.min(4095,Math.max(0,Math.round(Hi(e.data[a*3+s])*4095)))];return{data:o,w:e.w,h:e.h}}function n8(e,t,n){let i=Gv(e,t,void 0,n),r=i.analysis,o=IZ(e,t,r,void 0,n);o.residual<i.maxResidual&&(r={...r,wheels:o.wheels});let a=FZ(e,r),s={data:Float32Array.from(a.data,Hi),w:e.w,h:e.h},c=e8(r);return{tone:{slope:c.slope,offset:c.offset,power:c.power,...c.wheels?{shadow:c.wheels.shadow,midtone:c.wheels.midtone,highlight:c.wheels.highlight,contrast:c.wheels.contrast,pivot:c.wheels.pivot}:{}},out:s}}function r8(e,t,n=16){let{w:i,h:r}=e,o=(s,c)=>.2126*s[c*3]+.7152*s[c*3+1]+.0722*s[c*3+2],a=new Float32Array(i*r);for(let s=0;s<r;s+=n)for(let c=0;c<i;c+=n){let l=0,u=0,f=0,d=0,m=0,p=0,h=Math.min(r,s+n),b=Math.min(i,c+n);for(let x=s;x<h;x++)for(let O=c;O<b;O++){let P=x*i+O,T=o(e.data,P),S=o(t.data,P);l++,u+=T,f+=S,d+=T*T,m+=S*S,p+=T*S}let v=d/l-(u/l)**2,g=m/l-(f/l)**2,y=2e-5,w=v<y&&g<y?1:v<y||g<y?.1:Math.min(1,Math.max(0,((p/l-u/l*(f/l))/Math.sqrt(v*g)-.2)/.6));for(let x=s;x<h;x++)for(let O=c;O<b;O++){let P=x*i+O,T=Math.max(e.data[P*3],e.data[P*3+1],e.data[P*3+2])>.99||Math.max(t.data[P*3],t.data[P*3+1],t.data[P*3+2])>.99;a[P]=T?0:w}}return a}function fce(e,t){let n=[0,1,2,3].map(i=>[e[i*4],e[i*4+1],e[i*4+2],e[i*4+3],t[i]]);for(let i=0;i<4;i++){let r=i;for(let o=i+1;o<4;o++)Math.abs(n[o][i])>Math.abs(n[r][i])&&(r=o);if([n[i],n[r]]=[n[r],n[i]],Math.abs(n[i][i])<1e-12)return i<3?[i===0?1:0,i===1?1:0,i===2?1:0,0]:[0,0,0,0];for(let o=0;o<4;o++)if(o!==i){let a=n[o][i]/n[i][i];for(let s=i;s<5;s++)n[o][s]-=a*n[i][s]}}return n.map((i,r)=>i[4]/i[r])}var dce=0;function HZ(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 i=e.w*e.h,r=n?.weights??r8(e,t),o=new Float64Array(16),a=new Float64Array(12),s=0;for(let O=0;O<i;O++){let P=r[O];if(!P)continue;s+=P;let T=[e.data[O*3],e.data[O*3+1],e.data[O*3+2],1];for(let S=0;S<4;S++){for(let k=0;k<4;k++)o[S*4+k]+=P*T[S]*T[k];for(let k=0;k<3;k++)a[S*3+k]+=P*T[S]*t.data[O*3+k]}}let c=(n?.ridge??dce)*s;for(let O=0;O<3;O++)o[O*4+O]+=c,a[O*3+O]+=c;let l=[0,1,2].map(O=>fce(o,[0,1,2,3].map(P=>a[P*3+O]))),u=l.flatMap(O=>O.slice(0,3)),f=l.map(O=>O[3]),d=VZ(u),m=[d[0]*f[0]+d[1]*f[1]+d[2]*f[2],d[3]*f[0]+d[4]*f[1]+d[5]*f[2],d[6]*f[0]+d[7]*f[1]+d[8]*f[2]],p=new Float32Array(i*3);for(let O=0;O<i;O++){let P=e.data[O*3],T=e.data[O*3+1],S=e.data[O*3+2];for(let k=0;k<3;k++)p[O*3+k]=Hi(u[k*3]*P+u[k*3+1]*T+u[k*3+2]*S+f[k])}let h={data:p,w:e.w,h:e.h},b=O=>{let P=0,T=0;for(let S=0;S<i;S++){let k=r[S];k&&(P+=k*(Math.abs(O.data[S*3]-t.data[S*3])+Math.abs(O.data[S*3+1]-t.data[S*3+1])+Math.abs(O.data[S*3+2]-t.data[S*3+2])),T+=3*k)}return T?P/T:0},v=n8(h,t,r),g=b(h),y=b(v.out),w=y<g-.5/255;return{tone1:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},offset:m,matrix:u,tone2:v.tone,tone2Enabled:w,trim:null,residual:w?y:g,trustedShare:s/i}}function ZZ(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 DZ(e){if(e.mixerLumaLock!==!1||uf(e.mixer))return!1;let t=(o,a)=>Math.abs(o-a)<1e-9,n=e.power??[1,1,1],i=e.curves,r=!!i&&[i.r,i.g,i.b].some(o=>o&&o.length>=2);return[0,1,2].every(o=>t(n[o],1))&&qZ(e)===null&&!r}function mce(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 i=0,r=e.length-1;for(;r-i>1;){let l=i+r>>1;e[l][0]<=t?i=l:r=l}let[o,a]=e[i],[s,c]=e[r];return s>o?a+(c-a)*(t-o)/(s-o):a}var Ea=[.21,.7,.09];function qZ(e){if(!e.shadow&&!e.midtone&&!e.highlight&&e.contrast===void 0)return null;let t=i=>[i?.[0]??0,i?.[1]??0,i?.[2]??0],n={shadow:t(e.shadow),midtone:t(e.midtone),highlight:t(e.highlight),contrast:e.contrast??1,pivot:e.pivot??zo};return lf(n)?null:n}function UZ(e,t){if(DZ(e))return a=>a;let n=qZ(e),i=e.power??[1,1,1],r=[e.curves?.r,e.curves?.g,e.curves?.b].map(a=>a&&a.length>=2?a:null),o=a=>a<0?0:a>1?1:a;return(a,s)=>{let c=a*e.slope[s]+e.offset[s],l=i[s];l!==1&&(c=c<0?-Math.pow(-c,l):Math.pow(c,l)),n&&(c=Os(c,n,s));let u=r[s];return u&&(c=mce(u,o(c))),t?o(c):c}}function CZ(e){let t=e.saturation??1,n=Math.abs(t-1)>1e-9,i=!uf(e.mixer),r=DZ(e);if(!n&&!i&&!r)return null;let o=[t+(1-t)*Ea[0],(1-t)*Ea[1],(1-t)*Ea[2],(1-t)*Ea[0],t+(1-t)*Ea[1],(1-t)*Ea[2],(1-t)*Ea[0],(1-t)*Ea[1],t+(1-t)*Ea[2]];if(i){let s=e.mixerLumaLock===!1?e.mixer:Kv(e.mixer),c=new Array(9);for(let l=0;l<3;l++)for(let u=0;u<3;u++)c[l*3+u]=s[l*3]*o[u]+s[l*3+1]*o[3+u]+s[l*3+2]*o[6+u];o=c}let a=[0,0,0];if(r){let s=e.slope,c=e.offset;for(let l=0;l<3;l++){a[l]=o[l*3]*c[0]+o[l*3+1]*c[1]+o[l*3+2]*c[2];for(let u=0;u<3;u++)o[l*3+u]*=s[u]}}return{m:o,add:a}}var op=-1,Ms=-1,KZ=!1,o8=.35,pce=[.25,-.5,Math.log(.25)],hce=[4,.5,Math.log(4)],_o=-1;function i8(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:op>=0?e[op]:zo,saturation:e[10]};if(_o>=0&&(t.master={slope:e[_o],offset:e[_o+1],power:Math.exp(e[_o+2])}),Ms>=0){let n=e.slice(Ms,Ms+6);t.mixer=[1,n[0],n[1],n[2],1,n[3],n[4],n[5],1],KZ&&(t.mixerLumaLock=!1)}return e.length-(op>=0?1:0)-(Ms>=0?6:0)-(_o>=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 bce=[.25,.25,.25,-.5,-.5,-.5,Math.log(.25),Math.log(.25),Math.log(.25),.5,0,...Array(9).fill(-.3)],gce=[4,4,4,.5,.5,.5,Math.log(4),Math.log(4),Math.log(4),2,2,...Array(9).fill(.3)],vce=e=>e.map((t,n)=>n===op?Math.min(.9,Math.max(.1,t)):_o>=0&&n>=_o?Math.min(hce[n-_o],Math.max(pce[n-_o],t)):Ms>=0&&n>=Ms&&n<Ms+6?Math.min(o8,Math.max(-o8,t)):Math.min(gce[n],Math.max(bce[n],t))),Av=(e,t)=>t===1?e:e<0?-Math.pow(-e,t):Math.pow(e,t);function JZ(e,t,n,i){let r=e.master,o=r?{...e,slope:[1,1,1],offset:[0,0,0],power:[1,1,1]}:{...e},a=UZ(o,!1),s=CZ(o);for(let c=0;c<t.length;c+=3){let l,u,f;if(r){let d=t[c],m=t[c+1],p=t[c+2],h=Av(d*e.slope[0]+e.offset[0],e.power[0]),b=Av(m*e.slope[1]+e.offset[1],e.power[1]),v=Av(p*e.slope[2]+e.offset[2],e.power[2]),g=.2126*h+.7152*b+.0722*v,y=.2126*d+.7152*m+.0722*p,w=Av(y*r.slope+r.offset,r.power);l=a(h-g+w,0),u=a(b-g+w,1),f=a(v-g+w,2)}else l=a(t[c],0),u=a(t[c+1],1),f=a(t[c+2],2);if(s){let d=s.m,m=s.add,p=d[0]*l+d[1]*u+d[2]*f+m[0],h=d[3]*l+d[4]*u+d[5]*f+m[1],b=d[6]*l+d[7]*u+d[8]*f+m[2];l=p,u=h,f=b}n[c]=l,n[c+1]=u,n[c+2]=f}i?.(n);for(let c=0;c<n.length;c++)n[c]=n[c]<0?0:n[c]>1?1:n[c]}function yce(e,t,n){let i=e.slice(),r=t.slice();for(let a=0;a<n;a++){let s=a;for(let l=a+1;l<n;l++)Math.abs(i[l*n+a])>Math.abs(i[s*n+a])&&(s=l);if(s!==a){for(let l=0;l<n;l++)[i[a*n+l],i[s*n+l]]=[i[s*n+l],i[a*n+l]];[r[a],r[s]]=[r[s],r[a]]}let c=i[a*n+a]||1e-12;for(let l=a+1;l<n;l++){let u=i[l*n+a]/c;if(u){for(let f=a;f<n;f++)i[l*n+f]-=u*i[a*n+f];r[l]-=u*r[a]}}}let o=new Array(n).fill(0);for(let a=n-1;a>=0;a--){let s=r[a];for(let c=a+1;c<n;c++)s-=i[a*n+c]*o[c];o[a]=s/(i[a*n+a]||1e-12)}return o}function a8(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 i=e.w*e.h,r=n.samples??6e3;if(n.skinBoost&&n.skinBoost>1){let ue=n.weights??new Float32Array(i).fill(1),ze=new Float32Array(i);for(let Re=0;Re<i;Re++){if(ze[Re]=ue[Re],!ue[Re])continue;let yt=t.data[Re*3]*255,rt=t.data[Re*3+1]*255,zt=t.data[Re*3+2]*255,qt=.299*yt+.587*rt+.114*zt,Ot=128-.168736*yt-.331264*rt+.5*zt,pt=128+.5*yt-.418688*rt-.081312*zt;(n.skinRegion===void 0||n.skinRegion!==null&&n.skinRegion[Re]>1)&&Ot>=77&&Ot<=127&&pt>=133&&pt<=173&&qt>40&&qt<235&&(ze[Re]=ue[Re]*n.skinBoost)}n={...n,weights:ze}}let o=[];for(let ue=0;ue<i;ue++)(!n.weights||n.weights[ue]>0)&&o.push(ue);let a=[],s=Math.max(1,o.length/r);for(let ue=0;ue<o.length&&a.length<r;ue+=s)a.push(o[Math.floor(ue)]);let c=a.length,l=new Float64Array(c*3),u=new Float64Array(c*3),f=new Float64Array(c);a.forEach((ue,ze)=>{for(let Re=0;Re<3;Re++)l[ze*3+Re]=e.data[ue*3+Re],u[ze*3+Re]=t.data[ue*3+Re];f[ze]=Math.sqrt(n.weights?n.weights[ue]: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?[zo]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[]];_o=n.lumMix100?d-3:-1,n.lumMix100&&(m=[...m,1,0,0]),Ms=n.mixer||n.mixerRaw?d-6-(n.lumMix100?3:0):-1,KZ=!!n.mixerRaw,o8=n.mixerRaw?1.5:.35,op=n.freePivot?d-1-(n.mixer||n.mixerRaw?6:0)-(n.lumMix100?3:0):-1;let p=[.2126,.7152,.0722],h=n.keepTone;h&&(m=[...h.slope,...h.offset,...h.power.map(Math.log),h.contrast,h.saturation,...m.slice(11)]);let b=ue=>{if(n.balanceOnly&&(ue[7]=ue[6],ue[8]=ue[6]),h){let ze=p[0]*ue[0]+p[1]*ue[1]+p[2]*ue[2],Re=p[0]*h.slope[0]+p[1]*h.slope[1]+p[2]*h.slope[2];for(let zt=0;zt<3;zt++)ue[zt]*=Re/ze;let yt=p[0]*ue[3]+p[1]*ue[4]+p[2]*ue[5],rt=p[0]*h.offset[0]+p[1]*h.offset[1]+p[2]*h.offset[2];for(let zt=3;zt<6;zt++)ue[zt]+=rt-yt}return ue};if(n.lumMix100){let ue=b;b=ze=>{ue(ze);let Re=p[0]*ze[0]+p[1]*ze[1]+p[2]*ze[2];for(let rt=0;rt<3;rt++)ze[rt]/=Re;let yt=p[0]*ze[3]+p[1]*ze[4]+p[2]*ze[5];for(let rt=3;rt<6;rt++)ze[rt]-=yt;return ze[6]=ze[7]=ze[8]=0,ze}}let v=new Set([...n.balanceOnly?[7,8]:[],...h?[6,7,8,9]:[],...n.lumMix100?[6,7,8]:[],...n.noContrastSat?[9,10]:[]]),g=[1,1,1,0,0,0,0,0,0,1,1,...n.wheels?Array(9).fill(0):[],...n.freePivot?[zo]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[],...n.lumMix100?[1,0,0]:[]],y=[6,7,8,9],w=0;for(let ue=0;ue<c;ue++)w+=f[ue]*f[ue];let x=Math.sqrt((n.prior??0)*w),O=[.02,.1,.25,.5,.75,.9,.98],P=ue=>{let ze=new Float64Array(c),Re=0,yt=0;for(let pt=0;pt<c;pt++){let _=ue[pt*3],pe=ue[pt*3+1],Ne=ue[pt*3+2],nt=f[pt]*f[pt];yt+=nt,Re+=nt*(Math.max(_,pe,Ne)-Math.min(_,pe,Ne)),ze[pt]=.2126*_+.7152*pe+.0722*Ne}let rt=new Float64Array(9),zt=[0,0,0];L.forEach((pt,_)=>{for(let pe of pt){for(let Ne=0;Ne<3;Ne++)rt[_*3+Ne]+=ue[pe*3+Ne];zt[_]++}});let qt=new Float64Array(6),Ot=[0,0];return V.forEach((pt,_)=>{for(let pe of pt){for(let Ne=0;Ne<3;Ne++)qt[_*3+Ne]+=ue[pe*3+Ne];Ot[_]++}}),ze.sort(),[...O.map(pt=>ze[Math.floor(pt*(c-1))]),Re/yt,...Array.from(rt,(pt,_)=>zt[_/3|0]?pt/zt[_/3|0]:0),...[0,1].flatMap(()=>Array.from(qt,(pt,_)=>Ot[_/3|0]?pt/Ot[_/3|0]:0))]},T=[];for(let ue=0;ue<c;ue++){let ze=u[ue*3],Re=u[ue*3+1],yt=u[ue*3+2],rt=.2126*ze+.7152*Re+.0722*yt;Math.max(ze,Re,yt)-Math.min(ze,Re,yt)<.06&&rt>.04&&rt<.96&&T.push(ue)}let S=ue=>.2126*u[ue*3]+.7152*u[ue*3+1]+.0722*u[ue*3+2];T.sort((ue,ze)=>S(ue)-S(ze));let k=Math.floor(T.length/3),L=k>=20?[T.slice(0,k),T.slice(k,2*k),T.slice(2*k)]:[[],[],[]],z=[];for(let ue=0;ue<c;ue++){let ze=u[ue*3]*255,Re=u[ue*3+1]*255,yt=u[ue*3+2]*255,rt=.299*ze+.587*Re+.114*yt,zt=128-.168736*ze-.331264*Re+.5*yt,qt=128+.5*ze-.418688*Re-.081312*yt;zt>=77&&zt<=127&&qt>=133&&qt<=173&&rt>40&&rt<235&&z.push(ue)}z.sort((ue,ze)=>S(ue)-S(ze));let X=Math.floor(z.length/2),V=X>=15?[z.slice(0,X),z.slice(X)]:[[],[]],R=P(u),j=n.matchStats?R.length:0,J=Math.sqrt((n.matchStats??0)*w*3/Math.max(1,j)),q=c*3+j+y.length,W=new Float64Array(c*3),F=ue=>{JZ(i8(ue),l,W,n.post);let ze=new Float64Array(q);for(let Re=0;Re<c*3;Re++)ze[Re]=(W[Re]-u[Re])*f[Re/3|0];if(j){let Re=P(W);for(let yt=0;yt<j;yt++)ze[c*3+yt]=J*(Re[yt]-R[yt])}return y.forEach((Re,yt)=>{ze[c*3+j+yt]=x*(ue[Re]-g[Re])}),ze},H=ue=>{let ze=0;for(let Re of ue)ze+=Re*Re;return ze},C=F(m),$=H(C),oe=.001,ye=0,Ae=n.iterations??80,de=new Float64Array(q*d);for(;ye<Ae;ye++){for(let rt=0;rt<d;rt++){if(v.has(rt)){for(let pt=0;pt<q;pt++)de[pt*d+rt]=0;continue}let zt=1e-4,qt=m.slice();qt[rt]+=zt,b(qt);let Ot=F(qt);for(let pt=0;pt<q;pt++)de[pt*d+rt]=(Ot[pt]-C[pt])/zt}let ue=new Array(d*d).fill(0),ze=new Array(d).fill(0);for(let rt=0;rt<q;rt++){let zt=C[rt];for(let qt=0;qt<d;qt++){let Ot=de[rt*d+qt];if(Ot){ze[qt]+=Ot*zt;for(let pt=qt;pt<d;pt++)ue[qt*d+pt]+=Ot*de[rt*d+pt]}}}for(let rt of v)ue[rt*d+rt]+=1;for(let rt=0;rt<d;rt++)for(let zt=0;zt<rt;zt++)ue[rt*d+zt]=ue[zt*d+rt];let Re=!1,yt=!1;for(let rt=0;rt<8;rt++){let zt=ue.slice();for(let pe=0;pe<d;pe++)zt[pe*d+pe]*=1+oe;let qt=yce(zt,ze.map(pe=>-pe),d),Ot=b(vce(m.map((pe,Ne)=>v.has(Ne)?pe:pe+qt[Ne]))),pt=F(Ot),_=H(pt);if(_<$){yt=($-_)/Math.max($,1e-12)<1e-7,m=Ot,$=_,C=pt,oe=Math.max(oe/3,1e-7),Re=!0;break}oe*=4}if(!Re||yt)break}JZ(i8(m),l,W,n.post);let Oe=0,Ze=0;for(let ue=0;ue<c*3;ue++){let ze=f[ue/3|0]**2;Oe+=ze*Math.abs(W[ue]-u[ue]),Ze+=ze}return{cdl:i8(m),residual:Ze?Oe/Ze:0,iterations:ye}}function GZ(e,t,n=8){let i=t.filter(a=>a.x1>a.x0&&a.y1>a.y0&&a.score>0);if(i.length===0)return null;let r=e.w*e.h,o=new Float32Array(r).fill(1);for(let a of i){let s=(a.x0+a.x1)/2*e.w,c=(a.y0+a.y1)/2*e.h,l=Math.max(1,(a.x1-a.x0)/2*e.w),u=Math.max(1,(a.y1-a.y0)/2*e.h),f=Math.max(0,Math.floor(s-2.5*l)),d=Math.min(e.w,Math.ceil(s+2.5*l)),m=Math.max(0,Math.floor(c-2.5*u)),p=Math.min(e.h,Math.ceil(c+2.5*u));for(let h=m;h<p;h++){let b=(h-c)/u;for(let v=f;v<d;v++){let g=(v-s)/l,y=g*g+b*b,w=1+(n-1)*a.score*Math.exp(-y/(2*.45)),x=h*e.w+v;w>o[x]&&(o[x]=w)}}}return o}var AZ=()=>({slope:[1,1,1],offset:[0,0,0],power:[1,1,1]});function s8(e,t){let n=Bv(t),i="engine"in e&&e.engine==="ai"?e:null,r=i?i.transferred?"AI Color Transfer":"AI Auto Balance":"Auto Balance",o={source:i?i.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,...i?{seed:i.seed,prompt:i.prompt,fitResidual:i.fitResidual,inferenceMs:i.inferenceMs,matchMethod:i.matchMethod,gradeStyle:i.gradeStyle,usesLogWheels:e.cdl.wheels!==void 0,usesSaturation:e.cdl.saturation!==void 0,facesDetected:i.facesDetected,skinWeighted:i.skinWeighted}:{}};if(i?.fold){let s=i.fold;return[{id:n[0],kind:"cdl",label:`${r} \xB7 tone 1`,enabled:!0,cdl:{...s.tone1},meta:o},{id:n[1],kind:"cdl",label:`${r} \xB7 match matrix`,enabled:!0,cdl:{...AZ(),offset:s.offset,mixer:s.matrix,mixerLumaLock:!1},meta:{source:o.source,part:"2/4"}},{id:n[2],kind:"cdl",label:`${r} \xB7 tone 2`,enabled:s.tone2Enabled??!0,cdl:{...s.tone2},meta:{source:o.source,part:"3/4"}},...s.trim?[{id:n[3],kind:"cdl",label:`${r} \xB7 trim`,enabled:!0,cdl:{...AZ(),contrast:s.trim.contrast,pivot:s.trim.pivot},meta:{source:o.source,part:"4/4"}}]:[]]}let a=ZZ(e.cdl);return[{id:n[0],kind:"cdl",label:r,enabled:!0,cdl:a,meta:o}]}function Bv(e){let t=e?`@${e}`:"";return[`auto-balance${t}`,`auto-balance${t}-2`,`auto-balance${t}-3`,`auto-balance${t}-4`]}function BZ(e,t,n,i){let r=s8(e,i),o=new Set(r.map(s=>s.id)),a=i?[...Bv(i),...Bv()]:Bv();return[...r.map(s=>({timeline_id:t,item_id:n,entry:s})),...a.filter(s=>!o.has(s)).map(s=>({timeline_id:t,item_id:n,remove_id:s}))]}var Oo=Math.pow,c8=Math.abs,YZ=Math.sqrt,l8=Math.exp,u8=Math.log,ff=Math.log2,bi=Math.log10,jr=Math.max,wce=Math.min,ap=e=>2**e,Ar=e=>10**e,f8=(e,t)=>t<0||Object.is(t,-0)?-Math.abs(e):Math.abs(e),d8=(e,t,n)=>Math.min(Math.max(e,t),n),QZ=[[1.00000368,-515198584e-15,-515198585e-15,-515198616e-15,1.00000368,-515198585e-15,-515198572e-15,-515198591e-15,1.00000368],[1.3283766,-.213535123,-.114806713,-.0131647719,.912903039,.100298097,.0983208714,.0796202945,.822095761],[.91485402,.00284464831,.082300271,.0311847086,.783316716,.185499076,.0674001183,.0855864176,.847013637],[.885059491,.103594767,.011348535,.0692279832,.919431107,.0113425625,.075369767,.0527967473,.871835841],[.99739712,-.0231662641,.0257692126,-.00918353172,.917632516,.0915523025,.0734886088,.093706093,.83280779],[.999999513,594083242e-14,594083241e-14,59408323e-13,.999999513,594083241e-14,594083244e-14,594083241e-14,.999999513],[.915392376,.111481322,-.0268837717,.0315093793,.912062715,.0564183595,.0539772892,.0767111453,.869301769],[1.01388821,-.0133451286,-.000553929226,-.00764941028,.986632885,.0210044931,.0675794637,-.0767402369,1.0091491],[.562769234,.32351647,.113716987,.0777569207,.74957615,.172669093,.0646713865,.191999033,.743331835],[.562763384,.323512938,.113712941,.077751854,.74957252,.172664934,.0646663168,.191995547,.743327331],[.562768974,.323517012,.113717437,.0777571756,.749576184,.172669465,.0646714537,.191999725,.743331502],[.906045424,.0776579414,.0162703378,.0496278728,.912843186,.0375012464,.0590268875,.038018816,.902928655],[1.11683939,-.178448648,.061597207,-.0102851182,.91916553,.0911099443,.0822863513,.082273997,.835430904],[.687688759,.189241013,.123086555,.0623075684,.749049224,.188658016,.0581538012,.129275981,.812584092],[.673521912,.201597163,.124897287,.0603385952,.750033918,.189642207,.0565531092,.12707993,.816380997],[.630231651,.247575576,.122209243,.0547055408,.757814867,.187494097,.0531260313,.13892445,.807963474],[.958788747,.0134176677,.0277953094,.00862222369,.898149502,.0932308985,.0654375657,.090931855,.843633568],[1.04618357,-.0821764172,.0359915517,.00299958567,.962281479,.034719491,.018300977,-.168021609,1.14971961],[.618130671,.264160079,.11770036,.0511006943,.762272078,.186618224,.0358150706,.110415519,.853760447],[.892108973,.0243698849,.0835184974,.0326174513,.786134934,.181245441,.0699777221,.104750152,.825269679],[.562767908,.323515292,.113716491,.077756134,.749574616,.172668145,.0646708499,.191997876,.743330321],[.996644264,-.0267422383,.0300872533,.0089598248,.925295128,.0657350315,.0680179717,.0977025194,.834269802],[.99664269,-.02674189,.0300880855,.00896030872,.925294707,.0657357244,.0680184217,.0977029445,.834269456],[.852787691,.132476445,.0147381578,-.014981672,.987029187,.0279531835,.0379094789,.0916796162,.870413593],[.562763627,.323513615,.113714016,.0777527842,.74957256,.172665736,.0646674598,.191996382,.74332738],[.562763627,.323513615,.113714016,.0777527842,.74957256,.172665736,.0646674598,.191996382,.74332738],[.562768967,.323515949,.113717627,.0777575702,.749574602,.17266932,.0646722317,.191998733,.743330807]],_Z=[[.999996315,515195053e-15,515195053e-15,515195085e-15,.999996315,515195053e-15,515195041e-15,515195059e-15,.999996315],[.748240597,.167690132,.084034057,.0208437942,1.11185917,-.132739222,-.0915066835,-.12773937,1.21920886],[1.10080925,.00787752201,-.108685585,-.0236465478,1.3077504,-.284104486,-.0852062433,-.132768368,1.21797438],[1.1409871,-.127800699,-.0131893461,-.0847563762,1.09793569,-.0131808569,-.0935050696,-.0554406252,1.14894334],[1.00540174,.0288831372,-.0342848965,.0191281138,1.10268288,-.121812109,-.090870903,-.126620677,1.21748872],[1.00000049,-59408029e-13,-59408029e-13,-594080279e-14,1.00000049,-59408029e-13,-594080293e-14,-59408029e-13,1.00000049],[1.09463511,-.137394341,.0427693641,-.0337968467,1.10667566,-.0728693005,-.0649864561,-.089126913,1.15412317],[.986385289,.01336226,.000263311082,.00903910733,1.01203247,-.021059546,-.06536767,.0760646734,.989314748],[1.89861262,-.792175792,-.106439986,-.168953481,1.48898092,-.320029486,-.121543302,-.315675691,1.43721676],[1.89862401,-.792177065,-.106436176,-.168945232,1.48898123,-.320025345,-.121535003,-.315675991,1.43722184],[1.89861419,-.79217754,-.106440622,-.168954217,1.48898181,-.320030365,-.121543317,-.315677224,1.437218],[1.10988175,-.0937497351,-.016105834,-.0574587847,1.10223009,-.0447434335,-.0701366045,-.0402819509,1.11044407],[.903449996,.183147864,-.0865859615,.0191163799,1.10254344,-.121650021,-.0908685379,-.12661876,1.21749563],[1.49843277,-.353560479,-.144889507,-.101709172,1.41475121,-.313056983,-.0910564321,-.199773126,1.29081609],[1.53154193,-.387193916,-.144365343,-.100332731,1.41326403,-.31294607,-.0904763604,-.193170193,1.28363286],[1.64213411,-.512759105,-.129392805,-.0959087304,1.4081623,-.31226806,-.0914843341,-.208409566,1.29988029],[1.04535104,-.0122670343,-.0330856785,-.00163687728,1.12601787,-.124383577,-.0809076189,-.12041741,1.20132189],[.956200995,.0760296483,-.0322294826,-.00241871347,1.03355388,-.0311357753,-.0155740655,.149834766,.86574008],[1.67056585,-.563401409,-.107155622,-.0979342425,1.3877905,-.289847234,-.0574142007,-.15584623,1.21326939],[1.13030634,-.0203939197,-.109909748,-.0255482353,1.31085413,-.28530381,-.0926001325,-.164655328,1.25725793],[1.89861596,-.792175918,-.106440427,-.1689524,1.48898259,-.320028905,-.121543011,-.315675008,1.437219],[1.00572255,.0331725183,-.0388843341,-.0039462376,1.08967311,-.0857168323,-.0815343557,-.130317716,1.21186166],[1.00572422,.0331723362,-.0388854268,-.00394667363,1.08967374,-.0857178026,-.0815350148,-.130318402,1.21186243],[1.17054769,-.155731372,-.0148188505,.0192685123,1.01360896,-.0328781397,-.0530108709,-.0999795801,1.15298754],[1.89862513,-.79217867,-.10643786,-.168947023,1.48898279,-.320026777,-.121537359,-.31567669,1.43722279],[1.89862513,-.79217867,-.10643786,-.168947023,1.48898279,-.320026777,-.121537359,-.31567669,1.43722279],[1.89861492,-.792176711,-.106441665,-.168955179,1.48898484,-.320030887,-.121545458,-.315675558,1.43721925]],m8=[0,27,14,1,2,28,13,23,7,8,9,6,11,24,12,16,17,18,22,25,10,5,15,26,4,3,19],xce=[100.000012,65504,65504,55.0795767,469.8,1,12.0000021,222.860944,8.29590938,65.8161133,16.2981127,13.5216946,41.9993927,7.28132488,58.250874,1,1,1,1,14.7808634,46.085528,184.322348,1,9.73759126,13.7582741,38.4209343,1];function Pce(e){return e<=.02740668?e/10.44426855:ap(e/.07329248-7)-.0075}function kce(e){return e<=.00262409?e*10.44426855:(ff(e+.0075)+7)*.07329248}function Sce(e){return e>5.367655*.010591+.092809?(Ar((e-.385537)/.24719)-.052272)/5.555556:(e-.092809)/5.367655}function Tce(e){return e>.010591?.24719*bi(jr(5.555556*e+.052272,1e-10))+.385537:5.367655*e+.092809}function zce(e){return e<0?e*.113597209+-.0180569961:(ap(14*(e-.0928641251)/.907135875+6)-64)/2231.82631}function Oce(e){return e<-.0180569961?(e- -.0180569961)/.113597209:(ff(jr(2231.82631*e+64,1e-10))-6)/14*.907135875+.0928641251}function Mce(e){return e>=171.2102946929/1023?Ar((e*1023-420)/261.5)*.19-.01:(e*1023-95)*.01125/(171.2102946929-95)}function Lce(e){return e>=.01125?(420+bi((jr(e,-.0099)+.01)/.19)*261.5)/1023:(e*(171.2102946929-95)/.01125+95)/1023}function Rce(e){let t=(e*1023-64)/876;return t>=.030001222851889303?219*(Ar((t-.646596)/.432699)-.037584)/155*.9:(t-.030001222851889303)/3.53881278538813*.9}function Nce(e){let t=e/.9;return((t>=0?.432699*bi(155*t/219+.037584)+.646596:t*3.53881278538813+.030001222851889303)*876+64)/1023}function Xce(e){return e<0?e/15.1927-.01:(Ar(e/.224282)-1)/155.975327-.01}function jce(e){let t=e+.01;return t<0?t*15.1927:.224282*bi(t*155.975327+1)}function Fce(e){let t=Ar(-1.9666666666666666);return(Ar((e*1023-685)/300)-t)/(1-t)}function Ice(e){let t=Ar(-1.9666666666666666);return(685+300*bi(jr(e*(1-t)+t,1e-10)))/1023}function Ece(e){return e<.12512248?-(Ar((.12512248-e)/.45310179)-1)/10.1596:(Ar((e-.12512248)/.45310179)-1)/10.1596}function Vce(e){return e<0?-.45310179*bi(1-10.1596*e)+.12512248:.45310179*bi(10.1596*e+1)+.12512248}function Wce(e){return e<.092864125?-(Ar((.092864125-e)/.24136077)-1)/87.099375:(Ar((e-.092864125)/.24136077)-1)/87.099375}function Hce(e){return e<0?-.24136077*bi(1-87.099375*e)+.092864125:.24136077*bi(87.099375*e+1)+.092864125}function Zce(e){return e<.097465473?-(Ar((.12783901-e)/.36726845)-1)/14.98325:e<=.15277891?(e-.12512219)/1.9754798:(Ar((e-.12240537)/.36726845)-1)/14.98325}function Dce(e){return e<-.014?-.36726845*bi(1-14.98325*e)+.12783901:e<=.014?1.9754798*e+.12512219:.36726845*bi(14.98325*e+1)+.12240537}function qce(e){return e<.181?(e-.125)/5.6:Ar((e-.598206)/.241514)-.00873}function Uce(e){return e<.01?5.6*e+.125:.241514*bi(jr(e+.00873,1e-10))+.598206}function Cce(e){return e<=.14?(e-.0929)*.165972075:(Ar(3.89616*e-2.27752)-.0108)/.9892}function Jce(e){return e<=.00781728475?e/.165972075+.0929:(bi(jr(e*.9892+.0108,1e-10))+2.27752)/3.89616}function Kce(e){return e<.100686685370811?(e-.092864)/8.799461:(Ar((e-.384316)/.245281)-.064829)/5.555556}function Gce(e){return e<889e-6?8.799461*e+.092864:.245281*bi(jr(5.555556*e+.064829,1e-10))+.384316}function Ace(e){return e>=.208555316?ap((e-.69336945)/.08550479)-.00964052:e>0?YZ(e/47.2871124)+-.05641088:-.05641088}function Bce(e){return e>=.01?.08550479*ff(e+.00964052)+.69336945:e>-.05641088?47.2871124*(e- -.05641088)*(e- -.05641088):0}function Yce(e){return e<=.155251141552511?(e-.0729055341958355)/10.5402377416545:ap(e*17.52-9.72)}function Qce(e){return e<=.0078125?10.5402377416545*e+.0729055341958355:(ff(jr(e,1e-10))+9.72)/17.52}function p8(e){return e<.081?e/4.5:Oo((e+.099)/1.099,1/.45)}function h8(e){return e<.018?4.5*e:1.099*Oo(jr(e,0),.45)-.099}function Ls(e,t){return f8(Oo(c8(e),t),e)}function _ce(e){let t=c8(e),n=t<=.04045?t/12.92:Oo((t+.055)/1.055,2.4);return f8(n,e)}function $ce(e){let t=c8(e),n=t<=.0031308?t*12.92:1.055*Oo(t,1/2.4)-.055;return f8(n,e)}function ele(e){let t=Oo(jr(e,0),.012683313515655966);return Oo(jr(t-.8359375,0)/(18.8515625-18.6875*t),1/.1593017578125)*100}function tle(e){let t=Oo(jr(e/100,0),.1593017578125);return Oo((.8359375+18.8515625*t)/(1+18.6875*t),78.84375)}function nle(e){return(e<=.5?e*e/3:(l8((e-.55991073)/.17883277)+.28466892)/12)*10}function rle(e){let t=jr(e/10,0);return t<=1/12?YZ(3*t):.17883277*u8(jr(12*t-.28466892,1e-10))+.55991073}function ile(e){return e<.133883783?(e-.0924657534)/8.28360593:l8((e-.530013339)/.0869287607)-.00549407243}function ole(e){return e<.005?8.28360593*e+.0924657534:.0869287607*u8(jr(e+.00549407243,1e-10))+.530013339}function ale(e){return e<.100537775223865?(e-.092864)/8.735631:(Ar((e-.790453)/.344676)-.009468)/.555556}function sle(e){return e<89e-5?8.735631*e+.092864:.344676*bi(jr(.555556*e+.009468,1e-10))+.790453}function cle(e){let t=e*1023;return t<452?Oo(t/650,3)-.0075:l8((t-619)/150)}function lle(e){return(e<.328?650*Oo(jr(e+.0075,0),.3333333333333333):150*u8(jr(e,1e-10))+619)/1023}function ule(e){let t=(e*1023-64)/876;return t>=.030001222851889303?(Ar((t-.646596)/.432699)-.037584)*.9:(t-.030001222851889303)/5*.9}function fle(e){let t=e/.9;return((t>=0?.432699*bi(t+.037584)+.646596:t*5+.030001222851889303)*876+64)/1023}function dle(e){let t=ap(e*17.52-9.72);return e<-.30136893?(t-152587890625e-16)*2:t}function mle(e){return e<=0?(ff(jr(152587890625e-16+e*.5,1e-38))+9.72)/17.52:(ff(jr(e,221336e-10))+9.72)/17.52}function $Z(e,t){switch(e){case 0:return Pce(t);case 1:return Sce(t);case 2:return zce(t);case 3:return Mce(t);case 4:return Rce(t);case 5:return Xce(t);case 6:return Fce(t);case 7:return Ece(t);case 8:return Wce(t);case 9:return Zce(t);case 10:return qce(t);case 11:return Cce(t);case 12:return Kce(t);case 13:return Ace(t);case 14:return Yce(t);case 15:return p8(t);case 16:return Ls(t,2.2);case 17:return Ls(t,2.4);case 18:return Ls(t,2.6);case 19:return _ce(t);case 20:return ele(t);case 21:return nle(t);case 22:return t;case 23:return ile(t);case 24:return ale(t);case 25:return cle(t);case 26:return ule(t);case 27:return dle(t);default:return Ls(t,2.19921875)}}function eD(e,t){switch(e){case 0:return kce(t);case 1:return Tce(t);case 2:return Oce(t);case 3:return Lce(t);case 4:return Nce(t);case 5:return jce(t);case 6:return Ice(t);case 7:return Vce(t);case 8:return Hce(t);case 9:return Dce(t);case 10:return Uce(t);case 11:return Jce(t);case 12:return Gce(t);case 13:return Bce(t);case 14:return Qce(t);case 15:return h8(t);case 16:return Ls(t,1/2.2);case 17:return Ls(t,1/2.4);case 18:return Ls(t,1/2.6);case 19:return $ce(t);case 20:return tle(t);case 21:return rle(t);case 22:return t;case 23:return ole(t);case 24:return sle(t);case 25:return lle(t);case 26:return fle(t);case 27:return mle(t);default:return Ls(t,1/2.19921875)}}function b8(e,t){return e==18&&(t==1||t==2)?100:xce[e]}function g8(e,t,n,i,r){if(e<0)return e;let o=wce(e,i);return d8(t*o/(o+n),0,r)}var tD=["DWG_COLORSPACE","ACES_AP0_COLORSPACE","ACES_AP1_COLORSPACE","ALEXA3_COLORSPACE","ARRI_LOGC4_COLORSPACE","ADOBE_RGB_COLORSPACE","APPLE_WG_COLORSPACE","CANONLOG2_COLORSPACE","CANONLOG3_COLORSPACE","CANONLOG_COLORSPACE","CINEON_COLORSPACE","DGAMUT_COLORSPACE","FGAMUT_C_COLORSPACE","P3D60_COLORSPACE","P3D65_COLORSPACE","P3DCI_COLORSPACE","VLOG_COLORSPACE","RWG_COLORSPACE","REDCOLOR4_COLORSPACE","REC2020_COLORSPACE","REC709_COLORSPACE","SGAMUT_COLORSPACE","SGAMUT3_COLORSPACE","SGAMUT3CINE_COLORSPACE","VENICE_SGAMUT3_COLORSPACE","VENICE_SGAMUT3CINE_COLORSPACE","SRGB_COLORSPACE"],nD=["DAV_INTER_OETF_GAMMA","ACESCC_GAMMA","ACESCCT_GAMMA","LOGC_EI800_GAMMA","LOGC4_EI800_GAMMA","ADOBE_RGB_GAMMA","APPLE_LOG_GAMMA","BMDFILMV5_GAMMA","CANONLOG_GAMMA","CANONLOG2_GAMMA","CANONLOG3_GAMMA","CINEON_GAMMA","DJI_DLOG_GAMMA","FLOG_OETF_GAMMA","FLOG2_OETF_GAMMA","TWOPOINTTWO_GAMMA","TWOPOINTFOUR_GAMMA","TWOPOINTSIX_GAMMA","LINEAR_GAMMA","NLOG_OETF_GAMMA","PANASONIC_VLOG_GAMMA","RED_LOG3G10_GAMMA","REC709_GAMMA","SONY_SLOG_GAMMA","SONY_SLOG2_GAMMA","SONY_SLOG3_GAMMA","SRGB_GAMMA"],v8={inputColorSpace:"REC709_COLORSPACE",inputGamma:"TWOPOINTFOUR_GAMMA",outputColorSpace:"REC709_COLORSPACE",outputGamma:"TWOPOINTFOUR_GAMMA"};function rD(e){let t=String(e.outputGamma??v8.outputGamma);return t==="TWOPOINTFOUR_GAMMA"||t==="REC709_GAMMA"?"g24":t==="SRGB_GAMMA"?"srgb":null}function y8(e){let t=n=>String(e[n]??v8[n]).replace(/_(COLORSPACE|GAMMA)$/,"");return`${t("inputColorSpace")}/${t("inputGamma")} \u2192 ${t("outputColorSpace")}/${t("outputGamma")}`}function iD(e,t){let n=(x,O)=>{let P=String(t[O]??v8[O]),T=x.indexOf(P);if(T<0)throw new Error(`the clip's Color Space Transform uses ${O} ${P}, which our CST does not model yet`);return T},i=n(tD,"inputColorSpace"),r=n(nD,"inputGamma"),o=n(tD,"outputColorSpace"),a=n(nD,"outputGamma"),s=m8[r],c=m8[a],l=b8(r,i),u=b8(a,o),f=Math.abs(l-u)>1e-9,d=f?(l-.09*(l/u))/(l/u-1):0,m=f?u*(l+d)/l:0,p=Number(t.doFwdOOTF??0)===1,h=Number(t.doInvOOTF??0)===1,b=QZ[i],v=_Z[o],g=new Float32Array(e.data.length),y=[0,0,0],w=[0,0,0];for(let x=0;x<g.length;x+=3){for(let O=0;O<3;O++)y[O]=$Z(s,e.data[x+O]),h&&(y[O]=p8(Math.sign(y[O])*Math.abs(y[O])**(1/2.4))),f&&l>u&&(y[O]=g8(y[O],m,d,l,u));for(let O=0;O<3;O++)w[O]=b[O*3]*y[0]+b[O*3+1]*y[1]+b[O*3+2]*y[2];for(let O=0;O<3;O++){let P=v[O*3]*w[0]+v[O*3+1]*w[1]+v[O*3+2]*w[2];f&&l<u&&(P=g8(P,m,d,l,u)),p&&(P=Math.max(h8(P),0)**2.4),g[x+O]=d8(eD(c,P),0,1)}}return{data:g,w:e.w,h:e.h}}var cD=["primaries","pixel","hm-mkl-hm","hm-coral-hm","hm-adain-hm","hm-mvgd-hm"],oD=1024;async function ple(e){let t=await Ym(e);return s6(t.rgba,t.width,t.height)}async function hle(e,t){let n=await Fn(e),i=n.streams?.find(u=>u.kind==="video"),r=(i?.codec??"").toLowerCase(),o=n.source_fps??i?.rate??24,a=n.available_range?.duration?.value??0;if(["r3d","braw","crm","canon","arriraw","ari","xocn","prores_raw","prores raw","aprn","aprh"].some(u=>r.includes(u)))throw new Error(`${te(e)} is camera-native raw (${r}): the engine decodes it as log, so a display-referred match would be wrong \u2014 match on a proxy or a rendered frame`);let c=t==null?Math.floor(a/2):Yr(t,o,n.source_timecode??null);if(a&&(c<0||c>=a))throw new Error(`frame ${c} is outside ${te(e)} (0\u2013${a-1})`);let l=await dl(e,c,r);return{image:s6(l.rgba,l.width,l.height),frame:c,codec:r,transfer:"g24",fps:o}}async function aD(e,t){let n=ar(e).toLowerCase();if(y6.has(n)||w6.has(n))return{image:await ple(e),frame:0,codec:"still",transfer:"srgb",fps:0};if(ua.has(n))return hle(e,t);throw new Error(`unsupported file for color match: ${te(e)}`)}async function lD(e){let t=Date.now(),n=e.reference==="ai",i=e.method??(n?"primaries":"hm-mkl-hm"),r=i.split("-")[1],o=await aD(e.source,e.frame);if(e.cst){let w=rD(e.cst);if(!w)throw new Error(`the clip's Color Space Transform (${y8(e.cst)}) does not end on a display; balance needs Rec.709/sRGB out`);o.image=iD(o.image,e.cst),o.transfer=w}let a,s=n?await(async()=>{let w=d6();if(w)throw new Error(w);let x=await m6();if(!x&&!e.download)throw new Error("the local AI colour model is not installed yet: run again with download: true to fetch it once (~4.3 GB, stays on this machine)");x??=await LW({onProgress:e.onProgress});let O=await RW(x,ks(o.image,1024)),P=NW(sD(o.image,O.w,O.h),O);return a={ms:O.ms,askedStops:P.askedStops,appliedStops:P.appliedStops},{image:P.image,frame:0,codec:"ai",transfer:o.transfer,fps:0}})():await aD(e.reference,e.reference_frame),c=e.transfer??o.transfer;OW(c);let l=ks(o.image,oD),u=ks(s.image,oD);(r==="mvgd"||i==="pixel"||i==="primaries")&&(u.w!==l.w||u.h!==l.h)&&(u=sD(u,l.w,l.h));let f,d,m,p,h=0,b=0;if(i==="primaries"){let w=r8(l,u),x=0;for(let k of w)x+=k;let O,P=e.skinBoost??3;if(P>1){let k=await jW(u);h=k.length,O=GZ(u,k);let L=k.reduce((z,X)=>z+Math.max(0,X.x1-X.x0)*Math.max(0,X.y1-X.y0)*X.score,0);b=Math.min(1,L/.05)}let T={weights:w,balanceOnly:!0,mixerRaw:e.mixer===!0};p=a8(l,u,T);let S=1+(P-1)*b;O&&S>1.05&&(p=a8(l,u,{...T,skinBoost:S,skinRegion:O,keepTone:p.cdl})),d=u,m=x/w.length}else if(i==="pixel"){let w=HZ(l,u);f=w,d=u,m=w.trustedShare}else{let w=Uv(l,u,r);f=WZ(l,u,w,{tone1Contrast:null,enableTone2:!1,trimContrast:null}),d=w.image}let v=Gv(l,d),g={itemId:e.item_id??"color-match",averaged:l,balanced:d,report:{},analysis:v.analysis,cdl:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},framesUsed:[o.frame],issues:[],transfer:c,sourceW:o.image.w,sourceH:o.image.h,totalMs:Date.now()-t,engine:"ai",transferred:!0,reference:u,seed:n?376436993:0,prompt:n?"balance (FLUX.2 klein, local)":"",matchMethod:i,fitResidual:p?.residual??f.residual,lumaStops:v.lumaStops,inferenceMs:a?.ms??0,facesDetected:h,skinWeighted:h>0,gradeStyle:p?"primaries":"fold",fold:f};if(p){let w=p.cdl;g.cdl={slope:w.slope,offset:w.offset,power:w.power,saturation:w.saturation,...w.mixer?{mixer:w.mixer,mixerLumaLock:w.mixerLumaLock}:{},wheels:{shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:w.contrast,pivot:w.pivot}}}let y=s8(g);return{run:g,entries:y,method:i,transfer:c,source:{path:e.source,frame:o.frame,codec:o.codec,w:o.image.w,h:o.image.h},reference:{path:n?"FLUX.2 klein (local)":e.reference,w:s.image.w,h:s.image.h},residual:p?.residual??f.residual,lumaStops:v.lumaStops,ai:a,trustedShare:m,cst:e.cst?y8(e.cst):void 0}}function uD(e,t,n){return BZ(e.run,t,n)}function fD(e,t){for(let n of e.timelines)for(let i of n.tracks)for(let r of i.items){if(r.id!==t)continue;return(r.effects??[]).find(a=>a.kind==="color_space_transform")?.parameters}}function dD(e,t){let n=[];for(let i of e.timelines)for(let r of i.tracks)for(let o of r.items)(o.id===t||o.name===t)&&n.push({timelineId:i.id??"",itemId:o.id,name:o.name??""});return n.length===1?n[0]:n.length>1?n.find(r=>r.itemId===t)??n[0]:null}var Rs=e=>(Math.round(e*1e3)/1e3).toString(),Yc=e=>e?`[${e.map(Rs).join(", ")}]`:"\u2014";function mD(e){let t=[`source ${te(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 ${te(e.reference.path)} (${e.reference.w}x${e.reference.h})`,`method ${e.method}; fit residual ${Rs(e.residual)} (mean |chain \u2212 match|, 0\u20131 codes); luma ${e.lumaStops>=0?"+":""}${Rs(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?"+":""}${Rs(e.ai.askedStops)} stops, applied ${e.ai.appliedStops>=0?"+":""}${Rs(e.ai.appliedStops)})`]:[],...e.method==="primaries"?[(n=>n.facesDetected?`skin: ${n.facesDetected} face${n.facesDetected>1?"s":""} found \u2014 skin protected (colour 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 i=n.cdl??{},r=n.enabled===!1?" (bypassed)":"",o=[i.slope?`slope ${Yc(i.slope)}`:"",i.offset?`offset ${Yc(i.offset)}`:"",i.power?`power ${Yc(i.power)}`:"",i.mixer?`mixer ${Yc(i.mixer)}`:"",i.saturation!=null?`sat ${Rs(i.saturation)}`:"",i.contrast!=null?`contrast ${Rs(i.contrast)} @ pivot ${Rs(i.pivot??.435)}`:"",i.shadow?`wheels lift ${Yc(i.shadow)} gamma ${Yc(i.midtone)} gain ${Yc(i.highlight)}`:""].filter(Boolean);t.push(`- ${n.label??n.id}${r}: ${o.join("; ")}`)}return t.join(`
226
- `)}function sD(e,t,n){let i=new Float32Array(t*n*3);for(let r=0;r<n;r++){let o=Math.min(e.h-1,Math.floor((r+.5)*e.h/n));for(let a=0;a<t;a++){let s=Math.min(e.w-1,Math.floor((a+.5)*e.w/t)),c=(o*e.w+s)*3,l=(r*t+a)*3;i[l]=e.data[c],i[l+1]=e.data[c+1],i[l+2]=e.data[c+2]}}return{data:i,w:t,h:n}}import{execFile as vD,execFileSync as yD,spawn as ble}from"node:child_process";import{createServer as gle}from"node:http";import{open as vle,readdir as yle,stat as wD}from"node:fs/promises";import{basename as xD,join as wle,relative as xle}from"node:path";var sp=2048,Ple=4<<20,pD=6e4,k8=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 kle(){let e=or()==="win32"?"i2o-transfer.exe":"i2o-transfer",t=[Rt("CONFORM_P2P"),Pr(new URL(`./${e}`,import.meta.url)),Pr(new URL(`../../native-host/i2o-transfer/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await Er(n))return n;return null}var Sle=e=>Buffer.from(JSON.stringify(e)).toString("base64url");function Ns(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 PD(e,t){let n=await kle();if(!n)throw new Error("the peer-to-peer engine (i2o-transfer) is not installed");let i=ble(n,[],{stdio:["pipe","pipe","pipe"]}),r="";i.stdout.on("data",a=>{r+=a.toString();for(let s;(s=r.indexOf(`
227
- `))>=0;){let c=r.slice(0,s).trim();if(r=r.slice(s+1),c)try{t(JSON.parse(c))}catch{}}}),i.stderr.on("data",()=>{});let o=a=>i.stdin.write(JSON.stringify(a)+`
228
- `);return o(e),{child:i,send:o,stop:()=>i.kill()}}async function kD(e){return(await wD(e)).isDirectory()?(await yle(e,{recursive:!0,withFileTypes:!0})).filter(n=>n.isFile()&&!n.name.startsWith(".")).map(n=>wle(n.parentPath,n.name)).sort().map(n=>({path:n,name:xle(e,n).split("\\").join("/")})):[{path:e,name:xD(e)}]}async function S8(e,t={}){let n=d=>Promise.all(d.map(m=>typeof m=="string"?{path:m,name:xD(m)}:m).map(async m=>({...m,size:(await wD(m.path)).size}))),i=await n(e),r=Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("hex"),o=!1,a,s,c=new Promise(d=>{s=d}),l=async()=>{let d,m,p=new Promise((g,y)=>{d=g,m=y}),h=await PD({type:"start-sender",files:i,secret_key:r},g=>{g.type==="endpoint-ready"?d(Sle({v:1,node_id:String(g.node_id),relay_url:g.relay_url??null,addrs:g.addrs??[],files:i.map(({name:y,size:w})=>({name:y,size:w})),...i.length===1&&/\.iso$/i.test(i[0].name)?{iso:!0}:{},...t.label?{label:t.label}:{}})):g.type==="path"?t.onPath?.(g):g.type==="error"&&!String(g.error).startsWith("[debug]")&&m(new Error(String(g.error)))});a=h;let b=!1;h.child.on("exit",g=>{if(o)return s();if(!b)return m(new Error(`peer-to-peer sender exited (${g}) before its endpoint was ready`));l().catch(()=>s())});let v=await p;return b=!0,v};return{ticket:await l(),stop:()=>{o=!0,a?.stop()},closed:c,add:async d=>{let m=(await n(d)).filter(p=>!i.some(h=>h.name===p.name));return m.length?(i.push(...m),a?.send({type:"add-sender-files",files:m}),m.length):0}}}var w8=257,Tle=4096,zle=2e4,hD=e=>{let t=[];for(let n of[...e].sort((i,r)=>i[0]-r[0])){let i=t[t.length-1];i&&n[0]<=i[1]?i[1]=Math.max(i[1],n[1]):t.push([n[0],n[1]])}return t},bD=(e,t,n)=>{let i=[],r=e;for(let[o,a]of n)if(!(a<=r)){if(o>=t)break;o>r&&i.push([r,o]),r=Math.max(r,a)}return r<t&&i.push([r,t]),i};async function T8(e,t,n={}){let i=Ns(e),r=n.volume??"CONFORM_P2P",o=i.files.map(F=>({name:F.name,size:F.size})),a=await vle(t,"w+"),s=[],c=[],l=[],u=0,f=0,d=async F=>{for(let C of F)l[C]=u,u+=Math.ceil(o[C].size/sp);let H;try{H=await Hm(o.map((C,$)=>({name:C.name,totalSize:C.size,fixedPartSector:l[$]})),r)}catch(C){throw new Error(`can't add ${F.length} more file(s) to this mount: ${C.message}. Mount it again to see them`)}(await a.stat()).size<H.totalBytes&&await a.truncate(H.totalBytes);for(let C of H.structuralRegions)await a.write(C.data,0,C.data.length,C.sectorStart*sp);for(let C of F)s[C]=(w8+l[C])*sp;c.push({regions:H.structuralRegions,totalBytes:H.totalBytes,files:o.length})};if(i.iso)await a.truncate(o[0].size),s.push(0),c.push({regions:[],totalBytes:o[0].size,files:1});else{let F=await Hm(o.map(C=>({name:C.name,totalSize:C.size})),r);u=2*(Math.min(F.totalSectors-1,...F.fileDataRegions.map(C=>C.sectorStart))-w8)+Tle,f=(w8+u)*sp,await d(o.map((C,$)=>$))}let m=()=>o.reduce((F,H)=>F+H.size,0),p=F=>[s[F],s[F]+o[F].size],h=[],b=(F,H,C=o.length)=>{let $=0;for(let oe=0;oe<C;oe++){let[ye,Ae]=p(oe),de=Math.max(ye,F),Oe=Math.min(Ae,H);if(Oe>de)for(let[Ze,ue]of bD(de,Oe,h))$+=ue-Ze}return $},v=[],g=0,y,w=new Promise((F,H)=>{y=C=>C?H(C):F()});m()===0&&y();let x=(F,H)=>{h=hD([...h,[F,H]]),g=m()-b(0,1/0),n.onProgress?.(g,m());for(let C of[...v])b(C.a,C.b,C.n)||(v.splice(v.indexOf(C),1),C.ready());g>=m()&&y()},O=!1,P,T=null,S=[],k=(F,H)=>{if(!P)return;let C=Date.now();S=S.filter(([,,$])=>C-$<zle);for(let[$,oe]of bD(F,H,hD([...h,...S.map(([ye,Ae])=>[ye,Ae])])))P.send({type:"need-bytes",offset:$,length:oe-$}),S.push([$,oe,C])},L=(F,H,C=o.length)=>b(F,H,C)?new Promise(($,oe)=>{let ye={a:F,b:H,n:C,ready:()=>{clearTimeout(Ae),$()}},Ae=setTimeout(()=>{v.splice(v.indexOf(ye),1),oe(new Error(`bytes ${F}-${H} didn't arrive in ${pD/1e3} s`))},pD);v.push(ye);for(let de=0;de<C;de++){let[Oe,Ze]=p(de),ue=Math.max(Oe,F),ze=Math.min(Ze,Math.max(H,F+Ple));ze>ue&&k(ue,ze)}}):Promise.resolve(),z=gle((F,H)=>void X(F,H).catch(()=>{H.headersSent||(H.statusCode=503),H.end()})),X=async(F,H)=>{if(O)return H.writeHead(503).end();let C=new URL(F.url??"/","http://x");if(F.method==="POST"){let Oe=Number(C.searchParams.get("offset")),Ze=[];for await(let ze of F)Ze.push(ze);let ue=Buffer.concat(Ze);return await a.write(ue,0,ue.length,Oe),x(Oe,Oe+ue.length),H.end("ok")}let $=c[Number(/^\/disk(?:_v(\d+))?\.iso$/.exec(C.pathname)?.[1]??(C.pathname==="/disk.iso"?1:0))-1];if(!$)return H.writeHead(404).end();let oe=/bytes=(\d+)-(\d*)/.exec(F.headers.range??""),ye=oe?Number(oe[1]):0,Ae=oe&&oe[2]?Math.min(Number(oe[2])+1,$.totalBytes):$.totalBytes;if(F.method==="GET"&&await L(ye,Ae,$.files),H.writeHead(oe?206:200,{"Accept-Ranges":"bytes","Content-Length":Ae-ye,...oe?{"Content-Range":`bytes ${ye}-${Ae-1}/${$.totalBytes}`}:{}}),F.method==="HEAD")return H.end();let de=Buffer.alloc(Ae-ye);await a.read(de,0,de.length,ye),ye<f&&de.fill(0,0,Math.min(Ae,f)-ye);for(let Oe of $.regions){let Ze=Oe.sectorStart*sp,ue=Math.max(ye,Ze),ze=Math.min(Ae,Ze+Oe.data.length);ze>ue&&de.set(Oe.data.subarray(ue-Ze,ze-Ze),ue-ye)}H.end(de)};await new Promise(F=>z.listen(0,"127.0.0.1",F));let V=z.address().port,R=Promise.resolve(),j=F=>{i.iso||F.length<=o.length||o.some((H,C)=>F[C]?.name!==H.name)||(R=R.then(async()=>{let H=o.length;if(F.length<=H)return;o.push(...F.slice(H).map($=>({name:$.name,size:$.size})));let C=o.map(($,oe)=>oe).slice(H);await d(C),P.send({type:"update-file-offsets",fileOffsets:s,fileSizes:o.map($=>$.size),senderMapping:o.map(($,oe)=>oe<H?-2:-3)}),n.onGrow?.(c.length,C)}).catch(H=>{J=H.message}))},J=null;P=await PD({type:"start-receiver",http_port:V,iso_path:t,file_offsets:s,peer_node_id:i.node_id,peer_relay_url:i.relay_url,peer_addrs:i.addrs},F=>{F.type==="path"?T=F:F.type==="manifest"?j(F.files):F.type==="error"&&!String(F.error).startsWith("[debug]")&&y(new Error(String(F.error)))}),P.send({type:"volume-mounted"}),P.child.on("exit",F=>{!O&&g<m()&&y(new Error(`peer-to-peer receiver exited (${F}) with ${g} of ${m()} bytes`))});let q=async()=>{if(O=!0,P&&P.child.exitCode===null){let F=new Promise(H=>P.child.once("exit",()=>H()));P.send({type:"cancel"}),await Promise.race([F,new Promise(H=>setTimeout(H,2e3))]),P.stop()}z.close(),await a.close()};w.catch(()=>{});let W=`http://127.0.0.1:${V}`;return{t:i,files:o,offsets:s,done:w,close:q,daemon:P,ensure:L,fh:a,ask:k,url:(F=1)=>`${W}/${F===1?"disk":`disk_v${F}`}.iso`,get version(){return c.length},get size(){return c[c.length-1].totalBytes},get total(){return m()},get have(){return g},get path(){return T},get grewError(){return J}}}async function SD(e,t,n={}){let i=n.chunk??8388608,r,o=a=>{let[s,c]=[r.offsets[a],r.files[a]];for(let l=0;l<c.size;l+=i)r.ask(s+l,s+Math.min(l+i,c.size))};r=await T8(e,t,{onProgress:n.onProgress,onGrow:(a,s)=>{r&&s.forEach(o)}}),n.signal?.addEventListener("abort",()=>void r.close());try{return r.files.forEach((a,s)=>o(s)),await r.done,{path:t,bytes:r.have,files:r.files.length}}finally{await r.close()}}var x8=(e,t)=>new Promise((n,i)=>vD(e,t,(r,o,a)=>r?i(new Error(String(a||r.message).trim())):n(String(o)))),P8=e=>new Promise(t=>vD("/usr/bin/hdiutil",["detach",e,"-force"],t)),Yv=new Map,gD=!1;function Ole(e,t){if(Yv.set(e,t),!gD){gD=!0,process.on("exit",()=>{for(let n of Yv.values())for(let i of[...n].reverse())try{yD("/usr/bin/hdiutil",["detach",i,"-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 Mle(){let e;try{e=JSON.parse(yD("/bin/sh",["-c","/usr/bin/hdiutil info -plist | /usr/bin/plutil -convert json -o - -"],{encoding:"utf8",timeout:1e4}))}catch{return[]}let t=new Set([...Yv.values()].flat()),n=[];for(let i of e.images??[]){let r=i["image-path"]??"";if(!/^http:\/\/127\.0\.0\.1:\d+\/disk(_v\d+)?\.iso$/.test(r))continue;let o=i["system-entities"]??[],a=o.find(l=>l["mount-point"])?.["mount-point"],s=o[0]?.["dev-entry"];!s||t.has(s)||await fetch(r,{method:"HEAD",signal:AbortSignal.timeout(1500)}).then(()=>!0,()=>!1)||(await P8(s),n.push(a??s))}return n}var Lle=e=>e.normalize("NFKD").replace(/[^A-Za-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"CONFORM_P2P";async function TD(e,t,n={}){if(or()!=="darwin")throw new Error("live mount needs macOS (hdiutil attaches the image over HTTP); use p2p_receive elsewhere");await Mle();let i=0,r="",o=null,a,s=[],c=new Promise(p=>{a=p}),l=async p=>{if(p<=i)return;let h=/\/dev\/disk\d+/.exec(await x8("/usr/bin/hdiutil",["attach",u.url(p),"-nomount","-readonly","-noverify","-noautoopen"]))?.[0];if(!h)throw new Error("hdiutil attached nothing");try{await x8("/sbin/mount",["-t","udf","-r","-o","nobrowse",h,r])}catch(b){throw await P8(h),b}s.push(h)},u=await T8(e,t,{volume:Lle(n.volume??"CONFORM_P2P"),onGrow:p=>{c=c.then(()=>l(p)).catch(h=>{o=`files added, but not shown: ${h.message}`})}});try{i=u.version;let p=await x8("/usr/bin/hdiutil",["attach",u.url(i),"-readonly","-noverify","-noautoopen"]);r=p.trim().split(`
229
- `).map(b=>b.split(" ").pop().trim()).filter(b=>b.startsWith("/")).pop()??"";let h=/\/dev\/disk\d+/.exec(p)?.[0];if(!r||!h)throw new Error(`hdiutil attached nothing: ${p}`);s.push(h)}catch(p){throw await u.close(),p}Ole(r,s),a();let d={at:Date.now(),have:u.have},m=0;return{mountpoint:r,path:t,status:()=>{let p=Date.now();return p-d.at>=1e3&&(m=(u.have-d.have)/((p-d.at)/1e3),d={at:p,have:u.have}),{path:u.path,files:u.files.length,fetched:u.have,total:u.total,rate:m,error:u.grewError??o}},stop:async()=>{await c.catch(()=>{});for(let p of[...s].reverse())await P8(p);Yv.delete(r),await u.close()}}}async function zD(e,t){if(!Ns(e).iso)throw new Error("this ticket serves files, not a delivery .iso \u2014 use mount, or receive it whole");let n=await T8(e,t),i=n.size;return{read:async(r,o)=>{let a=Math.max(0,Math.min(o,i-r));await n.ensure(r,r+a);let s=new Uint8Array(a);return await n.fh.read(s,0,a,r),s},write:()=>Promise.reject(new Error("a peer's .iso is read-only")),getSize:async()=>i,size:()=>i,close:()=>n.close()}}import{createHash as Rle}from"node:crypto";import{open as Nle}from"node:fs/promises";var Qv=1<<20,Xs=5*Qv,OD=5*1024*Qv,z8=1e4,cp=8*Qv,Xle=2048;function M8(e,t,n=Math.max(16*Qv,Math.ceil(e/(z8-500)))){let i=[...t].filter(l=>l.len>0).sort((l,u)=>l.at-u.at),r=[];for(let l of i){let u=r[r.length-1];u&&l.at<u.at+u.len||(u&&u.at+u.len===l.at&&u.key===l.key&&u.offset+u.len===l.offset?u.len+=l.len:r.push({...l}))}let o=[],a=0;for(let l of r.filter(u=>u.len>=Xs))l.at>a&&o.push({at:a,len:l.at-a}),o.push({at:l.at,len:l.len,copy:l}),a=l.at+l.len;a<e&&o.push({at:a,len:e-a});let s=l=>l.reduce((u,f)=>{let d=u[u.length-1];return d&&!d.copy&&!f.copy?d.len+=f.len:u.push({...f}),u},[]);for(let l=!0;l;){l=!1,o=s(o);for(let u=0;u<o.length-1;u++){let f=o[u];if(f.len>=Xs)continue;let d=Xs-f.len,m=o[u+1],p=o[u-1];if(f.copy){delete f.copy,l=!0;break}m?.copy&&m.len-d>=Xs?(f.len+=d,m.at+=d,m.len-=d,m.copy={...m.copy,at:m.at,len:m.len,offset:m.copy.offset+d}):p?.copy&&p.len-d>=Xs?(p.len-=d,p.copy={...p.copy,len:p.len},f.at-=d,f.len+=d):m?.copy?delete m.copy:p?.copy&&delete p.copy,l=!0;break}}let c=[];for(let l of o){let u=l.copy?Math.min(OD,Math.max(n,Xs)):n;for(let f=l.at,d=l.at+l.len;f<d;){let m=Math.min(u,d-f);d-(f+m)>0&&d-(f+m)<Xs&&(m=d-f<=OD?d-f:m-Xs),c.push(l.copy?{kind:"copy",at:f,len:m,key:l.copy.key,offset:l.copy.offset+(f-l.at)}:{kind:"upload",at:f,len:m}),f+=m}}if(c.length>z8)throw new Error(`the image needs ${c.length} pieces (S3 allows ${z8})`);return c}function LD(e,t,n,i){let r=[...i].sort((s,c)=>s.offset-c.offset),o=[],a=0;for(let s of r){let c=Math.min(s.offset,t);c>a&&o.push({at:a,len:c-a,key:e,offset:a}),a=Math.max(a,s.offset+s.length)}return a<Math.min(t,n)&&o.push({at:a,len:Math.min(t,n)-a,key:e,offset:a}),o}async function L8(e,t,n,i,r){let o=[];for(let a of t.files)for(let s of So(a)){let c=(t.partitionStartSector+s.imageSector)*Xle;for(let l=s.offset;l<s.offset+s.length;){let u=Math.min(s.offset+s.length,(Math.floor(l/cp)+1)*cp),f=c+(l-s.offset);o.push(r?.(f,u-l)??[Rle("sha256").update(await e.read(f,u-l)).digest("hex"),f,u-l]),i?.(u-l),l=u}}return{v:1,block:cp,size:n,blocks:o}}function RD(e,t){let n=new Map;for(let r of t)for(let[o,a,s]of r.index.blocks)n.set(`${o}:${s}`,{key:r.key,offset:a});let i=[];for(let[r,o,a]of e.blocks){let s=n.get(`${r}:${a}`);s&&i.push({at:o,len:a,key:s.key,offset:s.offset})}return i}var MD=(e,t)=>`${Un().supabaseUrl}/functions/v1/${e}${t}`;async function Ur(e,t,n={}){let i=await uo();if(!i)throw new Error("not signed in to conform.tools \u2014 run account_login");let r=await fetch(MD(e,t),{method:n.method??(n.body?"POST":"GET"),headers:{authorization:`Bearer ${i}`,apikey:Un().anonKey,...n.body?{"content-type":"application/json"}:{}},...n.body?{body:JSON.stringify(n.body)}:{}}),o=await r.text();if(!r.ok){let a=o;try{let s=JSON.parse(o);a=s.error?.message??s.message??s.error??o}catch{}throw r.status===404&&/Requested function was not found/i.test(String(a))?new Error(`${e} isn't deployed on ${new URL(MD(e,t)).host}: this server doesn't have that feature yet (an older server, or a staging/production mismatch)`):new Error(`${n.method??"GET"} ${t}: ${r.status} ${a}`)}return o?JSON.parse(o):{}}function lp(e,t="org"){let n=`/v1/sessions/${e}/storage/multipart`,i=(r,o,a)=>Ur("v1-sessions",r,{body:o,method:a});return{start:async r=>String((await i(`${n}/start`,{key:r,content_type:"application/x-iso9660-image"})).upload_id),partUrls:async(r,o,a,s)=>(await i(`${n}/${o}/part-urls`,{key:r,first_part:a,count:s})).parts,copyPart:async(r,o,a,s)=>String((await i(`${n}/${o}/copy-part`,{key:r,part_number:a,source_ref:{scheme:t,bucket:"i2o",key:s.key},byte_range:{offset:s.offset,length:s.length}})).etag),complete:async(r,o,a)=>{await i(`${n}/${o}/complete`,{key:r,parts:a})},abort:async(r,o)=>{await i(`${n}/${encodeURIComponent(o)}?key=${encodeURIComponent(r)}`,void 0,"DELETE")},readUrl:async r=>String((await i(`/v1/sessions/${e}/download-url`,{storage_path:r})).download_url)}}async function O8(e,t,n=4){for(let i=1;;i++)try{return await t()}catch(r){if(i>=n)throw new Error(`${e} failed after ${n} tries: ${r instanceof Error?r.message:r}`);await new Promise(o=>setTimeout(o,500*2**i))}}async function R8(e,t,n,i,r={}){let o=r.fetchFn??fetch,a=await e.start(t),s=n.reduce((p,h)=>p+h.len,0),c=new Array(n.length),l=0,u=0,f=new Map,d=async p=>(f.has(p)||(await e.partUrls(t,a,p+1,Math.min(100,n.length-p))).forEach((b,v)=>f.set(p+v,b)),f.get(p)),m=async p=>{let h=n[p];if(h.kind==="copy")c[p]=await O8(`copy piece ${p+1}`,()=>e.copyPart(t,a,p+1,{key:h.key,offset:h.offset,length:h.len}));else{let b=await i(h.at,h.len);c[p]=await O8(`upload piece ${p+1}`,async()=>{let v=await d(p),g=await o(v.upload_url,{method:v.method,headers:v.headers,body:b,signal:r.signal});if(!g.ok)throw f.delete(p),new Error(`${g.status} ${(await g.text()).slice(0,200)}`);let y=g.headers.get("etag");if(!y)throw new Error("the bucket returned no ETag (expose it in the bucket's CORS / response headers)");return y})}l+=h.len,r.onProgress?.(l,s)};try{await Promise.all(Array.from({length:Math.min(6,n.length)},async()=>{for(;u<n.length;)r.signal?.throwIfAborted(),await m(u++)})),await O8("complete",()=>e.complete(t,a,c.map((p,h)=>({part_number:h+1,etag:p}))))}catch(p){throw await e.abort(t,a).catch(()=>{}),p}return{uploaded:n.filter(p=>p.kind==="upload").reduce((p,h)=>p+h.len,0),copied:n.filter(p=>p.kind==="copy").reduce((p,h)=>p+h.len,0),pieces:n.length}}function ND(e){let t=Nle(e,"r");return{read:async(n,i)=>{let r=new Uint8Array(i);return await(await t).read(r,0,i,n),r},close:async()=>{await(await t).close()}}}var jle=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function N8(e){let t=e.trim();if(t.startsWith("bucket:"))return{kind:"bucket",session_id:t.slice(7)};if(jle.test(t))return{kind:"bucket",session_id:t};if(/\.iso$/i.test(t)||t.includes("/")||t.includes("\\"))return{kind:"file",path:gf(t)};try{return Ns(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 X8(e){let{files:t}=await Ur("v1-sessions",`/v1/sessions/${e}/files`),n=t.find(i=>i.chunks?._format==="iso"&&i.chunks.b2FileName);if(!n)throw new Error(`delivery ${e} has no .iso in its bucket`);return n}async function _v(e,t){if(e.kind==="file")return Object.assign(await Hc(e.path),{name:te(e.path)});if(e.kind==="peer"){let r=Ns(e.ticket);return Object.assign(await zD(e.ticket,Q(t,r.files[0]?.name??"peer.iso")),{name:r.files[0]?.name??"peer.iso"})}let n=await X8(e.session_id),i=lp(e.session_id);return Object.assign(await X4(()=>i.readUrl(n.chunks.b2FileName)),{name:n.file_name})}async function Fle(){let{storage:e}=await Ur("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 XD=()=>Q(vt(),"bucket-index");async function Ile(e,t,n=50){let{sessions:i}=await Ur("v1-sessions",`/v1/sessions?limit=${n}`),r=[];await bt(XD());let o=i.filter(a=>a.id!==t);return await Promise.all(Array.from({length:6},async()=>{for(let a=o.shift();a;a=o.shift())try{let c=(await X8(a.id)).chunks;if(!c.blocksKey||c.bucket!==e)continue;let l=Q(XD(),`${a.id}-${c.isoSize}.json`),u;try{u=JSON.parse(await yn(l))}catch{let f=await lp(a.id).readUrl(c.blocksKey),d=await fetch(f);if(!d.ok)continue;u=await d.json(),await rn(l,JSON.stringify(u))}u.size===c.isoSize&&r.push({key:c.b2FileName,index:u})}catch{}})),r}async function jD(e,t,n){let i=await Ur("v1-sessions",`/v1/sessions/${e}/storage/upload-url`,{body:{key:t,content_type:"application/json",content_length:n.length}}),r=await fetch(i.upload_url,{method:i.method,headers:i.headers,body:n});if(!r.ok)throw new Error(`saving ${t}: ${r.status} ${(await r.text()).slice(0,200)}`)}async function FD(e,t,n){let i=await fV(t,n);i.timelines.length&&await Ur("v1-sessions",`/v1/sessions/${e}/contents`,{body:{projects:[],timelines:i.timelines,media:i.media,delivery_intent:{format:"folder",folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:i.handles}}})}async function ID(e,t={}){let n=await Fle(),i=await Hc(e),r=ND(e);try{let o=await ko(i),a=te(e);t.onProgress?.(0,i.size(),"indexing the image");let s=0,c=await L8(i,o,i.size(),g=>t.onProgress?.(s+=g,i.size(),"indexing the image")),{session:l}=await Ur("v1-sessions","/v1/sessions",{body:{destination:"b2",storage:"org",status:"ready",label:t.label??a.replace(/\.iso$/i,""),...t.recipients?.length?{recipient_emails:t.recipients}:{}}}),u=l.id,f=`sessions/${u}/${a}`,d=t.dedupe===!1?[]:await Ile(n.bucket,u),m=RD(c,d),p=M8(i.size(),m),h=(t.bucket??lp)(u),b=await R8(h,f,p,r.read,{onProgress:(g,y)=>t.onProgress?.(g,y,"uploading"),signal:t.signal}),v=`${f}.blocks.json`;return await jD(u,v,new TextEncoder().encode(JSON.stringify(c))),await Ur("v1-sessions",`/v1/sessions/${u}/files`,{body:{files:[{file_name:a,file_size:i.size(),status:"completed",chunks:{_format:"iso",b2FileName:f,isoSize:i.size(),blocksKey:v,bucket:n.bucket,files:o.files.filter(g=>!g.name.startsWith(`${xs}/`)).map(g=>({name:g.name,size:g.totalSize}))}}]}}),await FD(u,i,o),await Ur("v1-sessions",`/v1/sessions/${u}`,{method:"PATCH",body:{status:"completed"}}),{session_id:u,key:f,image:i.size(),uploaded:b.uploaded,copied:b.copied,reused_from:new Set(m.map(g=>g.key)).size}}finally{await r.close(),await i.close()}}async function ED(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 j4(e.path,t),f=await Hc(e.path),d=f.size();return await f.close(),{...u,image:d}}let i=e.session_id,r=await X8(i),o=r.chunks.b2FileName,a=(n.bucket??lp)(i),s=await X4(()=>a.readUrl(o)),c=await Mr("conform-grow-"),l=await mV(s,Q(c,"overlay"));try{n.onProgress?.(0,0,"patching");let u=await j4(l,t);if(!l.writes().length)return{...u,uploaded:0,copied:0,image:s.size()};let f=M8(l.size(),LD(o,s.size(),l.size(),l.writes())),d=await R8(a,o,f,l.read,{onProgress:(y,w)=>n.onProgress?.(y,w,"writing back"),signal:n.signal}),m=await ko(l),p=r.chunks.blocksKey?await fetch(await a.readUrl(r.chunks.blocksKey)).then(y=>y.ok?y.json():null).catch(()=>null):null,h=new Map((p?.blocks??[]).map(y=>[`${y[1]}:${y[2]}`,y])),b=(y,w)=>l.writes().some(x=>x.offset<y+w&&x.offset+x.length>y),{blocks:v}=await L8(l,m,l.size(),void 0,(y,w)=>b(y,w)?void 0:h.get(`${y}:${w}`)),g={v:1,block:cp,size:l.size(),blocks:v};return r.chunks.blocksKey&&await jD(i,r.chunks.blocksKey,new TextEncoder().encode(JSON.stringify(g))),await Ur("v1-sessions",`/v1/sessions/${i}/files/${r.id}`,{method:"PATCH",body:{bytes_uploaded:l.size(),chunks:{...r.chunks,isoSize:l.size(),files:m.files.filter(y=>!y.name.startsWith(`${xs}/`)).map(y=>({name:y.name,size:y.totalSize}))}}}),await FD(i,l,m),{...u,uploaded:d.uploaded,copied:d.copied,image:l.size()}}finally{await l.close(),await Sr(c)}}async function VD(e,t){if(e.kind==="peer"){let r=Ns(e.ticket),o=await TD(e.ticket,Q(t,r.iso?te(r.files[0].name):"shared.iso"),{volume:r.label});return{mountpoint:o.mountpoint,stop:o.stop,status:o.status}}let n=await _v(e,t),i=await pV(n);try{let r=await hV(i.url);return{mountpoint:r.mountpoint,stop:async()=>{await r.detach(),await i.close(),await n.close()}}}catch(r){throw await i.close(),await n.close(),r}}async function WD(e,t,n,i,r){if(e.kind==="peer")return(await SD(e.ticket,t,{onProgress:(a,s)=>i?.(a,s,"receiving"),signal:r})).bytes;let o=await _v(e,n);try{return await bV(o,t,(a,s)=>i?.(a,s,"downloading"),r)}finally{await o.close()}}var Ele=[{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 t7({onUrl:(n,i)=>{e=i?"":n,i||console.error(`open this URL to sign in: ${n}`)}});return ut(`signed in
230
- ${Op(t)}${e?`
231
- (sign-in URL: ${e})`:""}`,{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([tl({force:!0}),a1()]);return ut(`${await I9()}
232
- ${Op(e)}`,{account:e,version:mo,latest_version:t})}},{name:"account_logout",title:"Sign out",description:"Forget this machine's conform.tools sign-in.",inputSchema:{},run:async()=>(await n7(),ut(`signed out (${Un().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 OFF unless the user turns it on. When on it records, per tool run, the tool name, ok or the error code, duration, package version, engine mode and counts (numbers only), and per rejected call the tool name and the names of the failing arguments; never paths, file or clip names, timeline contents or media. Only change it when the user asks. Same as `conformtools telemetry on|off|status`.",inputSchema:{action:M.enum(["on","off","status"]).default("status")},run:async({action:e})=>((e==="on"||e==="off")&&await xR(e==="on"),ut(await PR(),{telemetry:await nu()}))},{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:M.enum(eR).describe("conform | autoconform | deliver | troubleshoot | patch"),hosts:M.array(M.enum(Ik)).max(Ik.length).optional().describe("The editing systems involved, source and target")},run:async({task:e,hosts:t})=>{try{let n=await rR(e,t??[]);return ut(n.text,{task:n.task,version:n.version,files:n.files})}catch(n){return Ge(new Te("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_issue",title:"Report a problem with a conformtools result",description:'Send the conform.tools team a problem report. Call it when the user says a conformtools result is wrong, complains about it, corrects an output ("that clip should be at 01:00:10:00", "the relink picked the proxy"), or when a tool failed unexpectedly. Give a short summary, what happened, what they expected, and the session_id / verb / job_id involved. It attaches the package version, engine mode, OS and runtime, the signed-in account, and the last 20 engine log lines for that session/job with paths cut to file names. It never sends media, file contents or timeline files. Tell the user it was sent and give the report id.',inputSchema:{summary:M.string().min(3).describe(`One line: what is wrong (max ${li.summary} chars; longer is cut)`),what_happened:M.string().optional().describe(`What the tool did or returned (max ${li.what_happened} chars; longer is cut)`),expected:M.string().optional().describe(`What the user expected instead (max ${li.expected} chars; longer is cut)`),session_id:M.string().optional().describe("The session involved, if any"),verb:M.string().optional().describe("The tool that produced the wrong result, e.g. timeline_write"),job_id:M.string().optional().describe("The background job involved, if any"),severity:M.enum(Dk).default("medium").describe("blocker = the user cannot continue")},run:async e=>{try{let t=await T0("issue",e),n=await z0(t);return O0("issue",n,t,e)}catch(t){return Ge(t)}}},{name:"report_gap",title:"Report a task done without conformtools",description:`Tell the conform.tools team which post-production task needed something other than conformtools, so the missing tool gets built. Call it once per task whenever you use ffmpeg, ffprobe, mediainfo, exiftool, a python or shell script, another MCP server, or manual steps in a host app for a timeline / media / conform / delivery task, or when conformtools cannot do the task at all; before or right after the workaround. task = what the user wanted; used_instead = the tool or command (e.g. "ffprobe -show_streams"); why_not_conformtools = missing_tool | missing_option | tool_failed | did_not_know; needed = what you needed from it and which output fields you used, so the team can build it in. File names at most, never full paths; never file contents or values from the user's media. Tell the user you sent it.`,inputSchema:{task:M.string().min(3).describe(`What the user wanted done (max ${li.task} chars; longer is cut)`),used_instead:M.string().optional().describe(`The tool, command or manual step used instead (max ${li.used_instead} chars; longer is cut)`),why_not_conformtools:M.enum(qk).optional().describe("missing_tool: no tool for it; missing_option: a tool exists but lacks the option; tool_failed; did_not_know: a conformtools tool exists but was not used"),conformtools_verb_tried:M.string().optional().describe("The conformtools tool tried first, if any"),needed:M.string().max(2e3).optional().describe(`What you needed from the other tool, so it can be built into conformtools: the information or operation, and which of its output fields you actually used (e.g. "per-stream start timecode and audio channel layout of a MOV: ffprobe streams[].tags.timecode, channel_layout"). Field names and the kind of value, never values from the user's media`),session_id:M.string().optional()},run:async({needed:e,...t})=>{try{let n=await T0("gap",{...t,...e?{expected:e}:{}}),i=await z0(n);return O0("gap",i,n,t)}catch(n){return Ge(n)}}},{name:"report_note",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. Use report_issue for a wrong result and report_gap for a task done with another tool. File names at most, never full paths or values from the user's media. Tell the user you sent it.`,inputSchema:{note:M.string().min(3).describe(`One line: the lesson or suggestion (max ${li.summary} chars; longer is cut)`),detail:M.string().optional().describe(`Why, when it applies, what went wrong without it (max ${li.what_happened} chars; longer is cut)`),topic:M.enum(["playbook","suggestion"]).default("playbook").describe("playbook = how the work should be done; suggestion = an idea for conformtools"),session_id:M.string().optional(),verb:M.string().optional().describe("The tool it is about, if any")},run:async({note:e,detail:t,topic:n,...i})=>{try{let r={...i,summary:`[${n??"playbook"}] ${e}`,...t?{what_happened:t}:{}},o=await T0("note",r),a=await z0(o);return O0("note",a,o,r)}catch(r){return Ge(r)}}},{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, 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:{path:M.string().describe("Absolute path to the timeline file (or .fcpxmld bundle directory)"),format:M.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:i}=await Iu(e,t),r=await ba(n,e,i);return Vn(`session_id: ${r.id}
233
- source: ${e} (${i})
234
- ${await ws(n)}`)}catch(n){return Ge(n)}}},{name:"host_current",protectedStages:["canonicalize"],title:"What is open in Resolve / Premiere / Media Composer / Flame / 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: the open project database \u2192 the timeline in the viewer, built into a .drt (identical to Resolve's own export). 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). Final Cut: the open libraries and the project in the Timeline (no readable file on disk). 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 without exporting.",inputSchema:{host:M.enum(Ia).optional().describe("One host; omit for all five"),read:M.boolean().default(!0).describe("Also read the open timeline into a session (session_id in the reply)")},run:async({host:e,read:t})=>{try{let i=await rZ(e?[e]:void 0,void 0,t?async(o,a)=>{try{let{session:s}=await Iu(o,a);return s.timelines.some(c=>c.tracks?.some(l=>l.items?.length))}catch{return!1}}:void 0),r=[];for(let o of i){let a=iZ(o);if(t&&o.read)try{let{session:s,format:c}=await Iu(o.read.path,o.read.format);nZ(s,o);let l=await ba(s,o.read.path,c);a+=`
235
- session_id: ${l.id}
236
- ${(await ws(s)).replace(/^/gm," ")}`}catch(s){a+=`
237
- read failed: ${s instanceof Error?s.message:String(s)}`}r.push(a)}return Vn(r.join(`
238
-
239
- `))}catch(n){return Ge(n)}}},{name:"host_export",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. 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:M.enum(Ia).describe("The host to export from"),timeline:M.string().optional().describe("Timeline name; the open one when omitted"),out_path:M.string().optional().describe("Where to write the file; a temp file when omitted"),read:M.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:i})=>{try{let r=n??Q(await Mr("conform-export-"),`${(t??"current").replace(/[^\w.-]+/g,"_")}.drt`),o=await Ac(e).export({timeline:t,out_path:r}),a=`exported ${o.project} / ${o.timeline} \u2192 ${o.path} (${o.format})`,s={...o};if(i!==!1){let{session:c,format:l}=await Iu(o.path,o.format),u=await ba(c,o.path,l);a+=`
240
- session_id: ${u.id}
241
- ${await ws(c)}`,s.session_id=u.id}return ut(a,s)}catch(r){return Ge(new Te("refused",r instanceof Error?r.message:String(r)))}}},{name:"host_open",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). 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.`,inputSchema:{host:M.enum(Ia).describe("The host to open it in"),path:M.string().describe("The timeline file (Resolve: .drt, .xml, .fcpxml, .aaf, .edl, .otio)"),name:M.string().optional().describe("Timeline name; the file name when omitted"),into:M.enum(["current","scratch"]).default("current").describe("current: the open project; scratch: our own project"),media_dirs:M.array(M.string()).optional().describe("Folders to link media from while importing"),stay:M.boolean().default(!1).describe("Leave the host showing the imported timeline"),folder:M.string().optional().describe('Resolve: media pool folder path to import into, e.g. "000 - TIMELINES/20261006" (default: conform.tools)'),create_folder:M.boolean().default(!1).describe("Create the folder (and its parents) when missing"),link_existing:M.boolean().default(!1).describe("Link to clips already in the media pool instead of importing new ones")},run:async({host:e,path:t,name:n,into:i,media_dirs:r,stay:o,folder:a,create_folder:s,link_existing:c})=>{try{let l=await Ac(e).open({path:t,name:n,into:i,media_dirs:r,stay:o,folder:a,create_folder:s,link_existing:c}),u=[`opened in ${e}: ${l.project} / ${l.timeline}${l.folder?` (media pool: ${l.folder})`:""}`,l.restored?"the user's timeline, folder and page were put back":"left showing the imported timeline",...c?["linked to clips already in the media pool (no new clips imported)"]:[],...l.notes];return ut(u.join(`
242
- `),{...l})}catch(l){return Ge(new Te("refused",l instanceof Error?l.message:String(l)))}}},{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. 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_status.`,inputSchema:{host:M.enum(Ia).describe("The host to render in"),timeline:M.string().optional().describe("Timeline name; the open one when omitted"),target_dir:M.string().optional().describe("Folder for the render (required unless renderplugin=true); created if missing"),name:M.string().optional().describe("Output name without extension; the timeline name when omitted"),preset:M.string().optional().describe("A render preset saved in the host"),range:M.object({in:M.number().int(),out:M.number().int()}).optional().describe("Frame range, absolute timeline frames, inclusive"),audio:M.boolean().optional().describe("Render audio with the picture (default: off = picture only; on for renderplugin)"),disable_tracks:M.array(M.string()).optional().describe('Video tracks to leave out of this render, by name or "V7" (e.g. ["Lower Thirds"] for TEXTLESS)'),audio_tracks:M.array(M.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:M.boolean().default(!1).describe("Resolve: render through the conform.tools renderplugin and return QC findings"),strictness:M.enum(Object.keys(ip)).optional().describe("renderplugin: strict (default) | standard | relaxed"),expected_aspect:M.number().positive().optional().describe("renderplugin: delivered aspect ratio when bars are expected, e.g. 2.39"),markers:M.boolean().default(!0).describe("renderplugin: place markers on the findings"),keep_render:M.boolean().default(!1).describe("renderplugin: keep the throwaway ProRes render"),ignore_space:M.boolean().default(!1).describe("renderplugin: skip the free-space check")},run:async({host:e,timeline:t,target_dir:n,name:i,preset:r,range:o,audio:a,disable_tracks:s,audio_tracks:c,renderplugin:l,strictness:u,expected_aspect:f,markers:d,keep_render:m,ignore_space:p,__progress:h,__signal:b})=>{let v=Ac(e);try{if(l){if(e!=="resolve")return Ge(new Te("unsupported","the renderplugin is a DaVinci Resolve plugin"));let w=await wZ(v,Kc,{timeline:t,range:o,strictness:u,expected_aspect:f,markers:d,keep_render:m,ignore_space:p,audio:a},h,b);return ut(xZ(w),{...w})}if(!n)return Ge(new Te("invalid_args","target_dir is required (unless renderplugin=true)"));if(c?.length&&e!=="resolve")return Ge(new Te("unsupported","audio_tracks (output routing) is for DaVinci Resolve"));let g=await v.renderStart({timeline:t,target_dir:n,name:i,preset:r,range:o,audio:(a??!1)||!!c?.length,...s?.length?{disable_tracks:s}:{},...c?.length?{audio_tracks:c}:{}});if(g=await J6(v,g,h,b),g.state!=="complete")return Ge(new Te(g.state==="cancelled"?"cancelled":"engine",`render ${g.state}${g.error?`: ${g.error}`:""}${g.notes?.length?`; ${g.notes.join("; ")}`:""}`));let y=g.outputs?.length?g.outputs:await tZ(n,i??t??"");return ut([`rendered in ${e} \u2192 ${y.join(", ")||n}${a||c?.length?"":" (picture only)"}`,...s?.length?[`without video tracks: ${s.join(", ")}`]:[],...c?.length?[`audio outputs: ${c.map((w,x)=>`${x+1} = timeline track ${w}`).join(", ")} \u2014 probe the file to confirm the channel layout`]:[],"the user's render settings, timeline and page were put back",...g.notes??[]].join(`
243
- `),{job_id:g.job_id,outputs:y,...g.notes?{notes:g.notes}:{}})}catch(g){return Ge(new Te("refused",g instanceof Error?g.message:String(g)))}}},{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:M.enum(Ia).default("resolve").describe("The host"),action:M.enum(["list","author"]).default("list"),names:M.array(M.string()).optional().describe("list: only these presets"),name:M.string().optional().describe("author: the new preset's name (no dots), e.g. PR4444_8CH_5-1_STEREO"),base:M.string().optional().describe("author: the preset to start from; the Deliver page's current settings when omitted"),audio_tracks:M.array(M.number().int().positive()).optional().describe("author: timeline track per audio output, e.g. [1, 2]")},run:async({host:e,action:t,names:n,name:i,base:r,audio_tracks:o})=>{try{let a=Ac(e??"resolve");if(!a.presets||!a.presetAuthor)return Ge(new Te("unsupported",`${a.host}: host_preset is for DaVinci Resolve`));let s=l=>l.error?`${l.name}: ${l.error}`:`${l.name}: ${l.format??"?"} ${l.codec??"?"} ${l.width??"?"}x${l.height??"?"}; audio ${l.audio==="true"?`${l.audio_codec??"on"} \u2192 ${l.audio_outputs?.length?l.audio_outputs.map((u,f)=>`out ${f+1} = ${u}`).join(", "):"default routing"}`:"off"}`;if(t==="author"){if(!i||!o?.length)return Ge(new Te("invalid_args","author needs name and audio_tracks"));let l=await a.presetAuthor({name:i,...r?{base:r}:{},audio_tracks:o});return ut(`saved render preset "${l.preset}"${l.summary?`
244
- ${s({...l.summary,name:l.preset})}`:""}
245
- prove it: host_render a ~11-frame range with this preset, then media_probe the channels`,l)}let c=await a.presets({...n?.length?{names:n}:{}});return ut([`${c.presets.length} render preset(s) in "${c.project}":`,...c.presets.map(s)].join(`
246
- `),c)}catch(a){return Ge(new Te("refused",a instanceof Error?a.message:String(a)))}}},{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:M.enum(Ia).default("resolve").describe("The host"),timeline:M.string().optional().describe("Timeline whose tracks to list; the open one when omitted"),clips:M.boolean().default(!1).describe("List every clip in every folder (large projects: long)"),find:M.array(M.string()).optional().describe("File paths or name fragments to look up in the media pool")},run:async({host:e,timeline:t,clips:n,find:i})=>{try{let r=Ac(e??"resolve");if(!r.project)return Ge(new Te("unsupported",`${r.host}: host_project is not available for this host yet`));let o=await r.project({timeline:t,clips:n,find:i}),a=0,s=0,c=[],l=(f,d)=>{d&&(a++,c.push(`${" ".repeat(d)}${f.path.split("/").pop()} (${f.clips} clip${f.clips===1?"":"s"})`)),s+=f.clips;for(let m of f.clip_list??[])c.push(`${" ".repeat(d+1)}- ${m.name} ${m.file}${m.start_tc?` TC ${m.start_tc}`:""}${m.usage?` used ${m.usage}x`:""}`);for(let m of f.folders)l(m,d+1)};l(o.pool,0);let u=[`${e??"resolve"} project "${o.project}": ${a} media pool folders, ${s} clips; ${o.jobs.length} render job(s)${o.timeline?`; timeline "${o.timeline}" has ${o.tracks.length} tracks`:""}`];u.push("media pool:",...c.length?c:[" (no folders)"]);for(let[f,d]of Object.entries(o.found??{}))u.push(d.length?`find "${f}": ${d.map(m=>`${m.folder||"Master"}/${m.name} (${m.file||"no file"}${m.usage?`, used ${m.usage}x`:""})`).join("; ")}`:`find "${f}": not in the project`);o.jobs.length&&u.push("render queue:");for(let f of o.jobs){let d=f.MarkIn!=null?` frames ${f.MarkIn}-${f.MarkOut}`:"";u.push(` ${f.RenderJobName??f.JobId} [${f.JobStatus||"?"}] "${f.TimelineName??""}" \u2192 ${Q(String(f.TargetDir??""),String(f.OutputFilename??""))}${d}${f.VideoCodec?` ${f.VideoFormat??""} ${f.VideoCodec}`:""}${f.PresetName?` preset ${f.PresetName}`:""}`)}return o.tracks?.length&&u.push(`tracks: ${Z6(o.tracks)}`),ut(u.join(`
247
- `),o)}catch(r){return Ge(new Te("refused",r instanceof Error?r.message:String(r)))}}},{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_panel (Premiere) installs the conform.tools UXP panel with Adobe's own installer; the user then opens Window > UXP Plugins > conform.tools once. Only install when the user asks.",inputSchema:{host:M.enum(Ia).default("resolve").describe("The host"),action:M.enum(["status","install_renderplugin","install_panel"]).default("status")},run:async({host:e,action:t})=>{try{let n=e??"resolve";if((t??"status")==="install_panel"){if(n!=="premiere")return Ge(new Te("unsupported","install_panel installs the conform.tools panel for Premiere Pro (host=premiere)"));let a=await dZ();return ut([`conform.tools panel ${a.version} installed for Premiere Pro (Adobe's installer: ${a.output.split(`
248
- `).pop()})`,"In Premiere: Window > UXP Plugins > conform.tools (restart Premiere first if it was running). It connects by itself from then on."].join(`
249
- `),{...a})}if((t??"status")==="install_renderplugin"){if(n!=="resolve")return Ge(new Te("unsupported","the renderplugin is a DaVinci Resolve plugin"));let a=await $H();return ut([`renderplugin ${a.version} installed at ${a.path}${a.elevated?" (with administrator approval)":""}`,"Restart Resolve: it loads I/O plugins only at launch.",...a.notes].join(`
250
- `),{...a})}let i=await Ac(n).support(),r=[`${n}:`,...Object.entries(i).map(([a,s])=>` ${a}: ${s.ok?"ready":`no: ${s.reason}${s.setup?` (${s.setup})`:""}`}`)],o={host:n,support:i};if(n==="premiere"){let a=await fZ();r.push(` panel: ${a.installed?`installed${a.version?` (${a.version})`:""}`:`not installed (this release ships ${await U6()}; host_setup host=premiere action=install_panel)`}`),o.panel={installed:a.installed,version:a.version}}if(n==="resolve"){let a=await af();r.push(` renderplugin: ${a.readiness}${a.version?` (${a.version})`:""}: ${a.next}`),o.renderplugin=a}return ut(r.join(`
251
- `),o)}catch(n){return Ge(new Te("refused",n instanceof Error?n.message:String(n)))}}},{name:"timeline_inspect",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:M.string(),detail:M.enum(["summary","clips","media","flags","link"]).default("summary"),timeline_id:M.string().optional().describe("Limit clips listing to one timeline")},run:async({session_id:e,detail:t,timeline_id:n})=>{try{let i=await ui(e);switch(t){case"clips":return Vn(DI(i.session,n));case"media":return Vn(qI(i.session));case"flags":return Vn(CI(i.session));case"link":return Vn(await GI(i.session));default:return Vn(`${await ws(i.session)}
252
- history: ${i.history.length?i.history.join(" \u2192 "):"(unedited)"}`)}}catch(i){return Ge(i)}}},{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, colour, name, note, duration and the clip under it \u2014 "is:red" lists red markers. query grammar: ${f4} 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). Read-only: to change what it finds use timeline_edit with the item_ids in the rows.`,inputSchema:{session_id:M.string(),table:M.enum(zE).default("clips"),query:M.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:M.string().optional().describe("Only this timeline (clips, markers); default every primary timeline"),columns:M.array(M.string()).optional().describe("Columns to return, by key or label; default the table's working set"),limit:M.number().int().min(1).max(5e3).default(50).describe("Rows in the reply (the CSV always has every match)"),out_path:M.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:i,columns:r,limit:o,out_path:a})=>{try{let s=await ui(e),c=OE(s.session,{table:t,query:n,timeline_id:i,columns:r,csv:!!a}),l=s.session.timelines.find(m=>m.id===i)?.name??s.source_path.split(/[\\/]/).pop()??"session",u=a?await ME(c,a,l):null,{csv:f,...d}=c;return ut(`${LE(c,n??"",o)}${u?`
253
- wrote ${u} (${c.matched} rows)`:""}`,{...d,rows:d.rows.slice(0,o),truncated:c.matched>o,csv_path:u})}catch(s){return Ge(s)}}},{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:
254
- - slip {timeline_id,item_id,delta_frames}: move the source window, keep the record position
255
- - trim {timeline_id,item_id,edge:'in'|'out',delta_frames,ripple?}: move one edge (+ lengthens the clip at out / shortens at in)
256
- - delete {timeline_id,item_id,ripple?}
257
- - move_clip {timeline_id,item_id,to_track_id?,to_frame?}
258
- - transform {timeline_id,item_id,scale?,opacity?,position_x?,position_y?,rotation?,crop_*?}
259
- - reformat {timeline_id?,resolution_w,resolution_h,fit?}: change the sequence raster
260
- - timeline_rate {timeline_id,fps_num,fps_den}
261
- - 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
262
- - stringout {extent?,handles?,name_prefix?}: build a string-out (every used source range, in order) with handles
263
- - relink, add_clip, new_timeline, add_track, delete_track, node_sizing, finish_op (advanced)
264
- Get item_id / timeline_id from timeline_inspect detail=clips. Frame deltas are in timeline frames.`,inputSchema:{session_id:M.string(),kind:M.enum(Eg),args:M.object({}).passthrough().describe("Arguments for the operation, see description")},run:async({session_id:e,kind:t,args:n})=>{try{let i=await ui(e),r=r4(i.session,t,n);return await eo(i,`${t} ${JSON.stringify(n)}`),Vn(`${r.summary}${r.meta?`
265
- ${JSON.stringify(r.meta,null,1).slice(0,4e3)}`:""}`)}catch(i){return Ge(i)}}},{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_inspect. 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:M.string().describe("Timeline name"),fps_num:M.number().int().positive().describe("Timeline rate numerator, e.g. 24000"),fps_den:M.number().int().positive().describe("Timeline rate denominator, e.g. 1001"),width:M.number().int().positive(),height:M.number().int().positive(),start_tc:M.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:M.array(M.object({path:M.string(),source_in:M.number().int().nonnegative(),duration:M.number().int().positive(),at:M.number().int().nonnegative().optional(),track:M.number().int().positive().optional(),scale:M.number().positive().optional(),position_x:M.number().optional(),position_y:M.number().optional(),rotation:M.number().optional(),flip_h:M.boolean().optional(),flip_v:M.boolean().optional(),scale_end:M.number().positive().optional(),position_x_end:M.number().optional(),position_y_end:M.number().optional(),rotation_end:M.number().optional(),speed:M.number().positive().optional()})).min(1)},run:async e=>{try{let{session:t,summary:n}=await UW(e),i=await ba(t,Q(vt(),"authored",`${e.name}.authored`),"authored");return Vn(`session_id: ${i.id}
266
- ${n.join(`
267
- `)}
268
- ${await ws(t)}`)}catch(t){return Ge(t)}}},{name:"timeline_generate",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: "+Bm.join(", ")+". mix: a preset ("+Object.keys(Au).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:M.array(M.string()).min(1).describe("Media files or folders (walked; folders named *proxy*/*proxies* or cache skipped)"),seed:M.number().int().describe("Random seed"),shots:M.number().int().positive().max(500).optional().describe("V1 shots (default 24)"),audio:M.boolean().optional().describe("Lay sync sound in under normal-speed shots whose clips have it (needed for frankenbite)"),look:M.boolean().optional().describe("Look at each planned shot and re-plan around flat picture \u2014 empty backdrops, grey cards (default true)"),mix:M.union([M.enum(Object.keys(Au)),M.record(M.enum(Bm),M.number().nonnegative())]).optional(),name:M.string().optional(),fps_num:M.number().int().positive().optional().describe("Default 24000"),fps_den:M.number().int().positive().optional().describe("Default 1001"),width:M.number().int().positive().optional().describe("Default 1920"),height:M.number().int().positive().optional().describe("Default 1080")},run:async e=>{try{let t=await KW(e),n=e.name??`generated ${e.seed}`,i=await ba(t.session,Q(vt(),"authored",`${n}.authored`),"authored"),r=new Map;for(let a of t.shots)for(let s of a.classes)r.set(s,(r.get(s)??0)+1);let o=[`session_id: ${i.id}`,`${t.shots.length} shots from ${t.pool.used} clips: ${[...r].map(([a,s])=>`${s} ${a}`).join(", ")}`,...t.pool.skipped.length?[`skipped ${t.pool.skipped.length}: ${t.pool.skipped.slice(0,5).join("; ")}`]:[],await ws(t.session)];return ut(o.join(`
269
- `),{session_id:i.id,shots:t.shots,titles:t.titles,skipped:t.pool.skipped})}catch(t){return Ge(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.
270
- 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.
271
- 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. 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.
272
- tolerances: timecode_tolerance_frames (1), duration_tolerance_seconds (0.1), min_name_similarity (0.6), fps_tolerance (0.005).
273
- 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).
274
- 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:M.string(),media_root:M.string().optional().describe("Folder to link from; omit to use remembered locations"),gather:M.enum(["walk","path"]).default("walk"),criteria:M.object({file_name:M.boolean().optional(),file_name_mode:M.enum(["tight","loose"]).optional(),reel_name:M.boolean().optional(),total_duration:M.boolean().optional(),resolution:M.boolean().optional(),bit_depth:M.boolean().optional(),file_format:M.boolean().optional(),codec:M.boolean().optional(),media_umid:M.boolean().optional(),extensions:M.array(M.string()).optional().describe("Only consider these extensions, e.g. ['mxf','mov']")}).optional(),tolerances:M.object({timecode_tolerance_frames:M.number().optional(),duration_tolerance_seconds:M.number().optional(),min_name_similarity:M.number().optional(),fps_tolerance:M.number().optional(),aspect_tolerance:M.number().optional()}).optional(),ref_ids:M.array(M.string()).optional().describe("Only these references (a zone)"),lane:M.enum(["video","audio","both"]).default("both"),reset:M.boolean().default(!1).describe("Re-point refs in scope even if already linked"),dry_run:M.boolean().default(!1).describe("Propose only; change nothing"),compare:M.boolean().default(!1).describe("With dry_run: show the per-criterion comparison for each matched row"),accept:M.array(M.object({ref_id:M.string(),candidate_id:M.string()})).optional().describe("Commit only these rows (from a dry run)"),cap:M.number().int().min(1).max(2e4).default(2e3),remember:M.boolean().default(!1)},run:async e=>{try{let t=await ui(e.session_id),n=await YI(t.session,e);return n.changed&&(t.session=n.session,await eo(t,n.note)),Vn(n.text)}catch(t){return Ge(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, resolve-otio. Short aliases drt/prproj/avb/aaf/xmeml/fcpxml/otio work. 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.",inputSchema:{session_id:M.string(),target:M.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:M.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.")},run:async({session_id:e,target:t,out_path:n})=>{try{let i=await ui(e);if(D0(t)){let s=await JI(i.session,t,n,i.source_path);await eo(i,`write ${t} \u2192 ${s.folder}`);let c=s.files.map(l=>`${l.path} (${l.bytes} bytes, ${l.target})`+(l.issues.length?`
275
- issues (${l.issues.length}):
276
- ${l.issues.map(u=>` - [${u.severity??"info"}] ${u.code?`${u.code}: `:""}${u.message}`).join(`
277
- `)}`:`
278
- no capability issues`));return Vn(`wrote ${s.folder}/ \u2014 README.txt says which to open first
279
- ${c.join(`
280
- `)}${s.pending?`
281
- ${s.pending} is not included yet (writer pending its host's import law)`:""}`)}let r=await o4(i.session,t,n,i.source_path);await eo(i,`write ${t} \u2192 ${r.path}`);let o=r.issues.length?`
282
- issues (${r.issues.length}):
283
- ${r.issues.map(s=>`- [${s.severity??"info"}] ${s.code?`${s.code}: `:""}${s.message}`).join(`
284
- `)}`:`
285
- no capability issues`,a=await Hd("conform-artist",["write"]);return Vn(`wrote ${r.path} (${r.bytes} bytes)${o}${a?`
286
-
287
- Reading this write (conform.tools playbook):
288
- ${a}`:""}`)}catch(i){return Ge(i)}}},{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:()=>Vn(KI())},{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 zR();return Vn(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(`
289
- `):"(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:M.string(),out_path:M.string()},run:async({session_id:e,out_path:t})=>{try{let n=await ui(e);return await rn(t,JSON.stringify(n.session,null,1)),Vn(`wrote ${t}`)}catch(n){return Ge(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:M.string(),fps:M.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(wv(e)){let n=await eH(e);return ut(tH(n),{...n})}return Vn(P9(await Fn(e),t))}catch(n){return Ge(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:M.string().optional().describe("A (online/colour) as a session"),a:M.string().optional().describe("A as a timeline file, instead of a_session_id"),b_session_id:M.string().optional().describe("B (editorial turnover) as a session"),b:M.string().optional().describe("B as a timeline file, instead of b_session_id"),a_timeline_id:M.string().optional(),b_timeline_id:M.string().optional(),by_track:M.boolean().default(!1).describe("Compare each video track by name instead of the topmost picture"),limit:M.number().int().min(1).max(5e3).default(100).describe("Ranges in the reply (files always have all)"),csv_path:M.string().optional(),edl_path:M.string().optional(),session:M.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:i,a_timeline_id:r,b_timeline_id:o,by_track:a,limit:s=100,csv_path:c,edl_path:l,session:u})=>{try{let f=async(g,y,w)=>{if(g){let x=await ui(g);return{session:x.session,name:`session ${g} (${te(x.source_path)})`}}if(y)return{session:(await Iu(y)).session,name:te(y)};throw new Te("invalid_args",`give ${w}_session_id or ${w} (a timeline file)`)},d=await f(e,t,"a"),m=await f(n,i,"b"),p=LV(d.session,m.session,{a_timeline_id:r,b_timeline_id:o,by_track:a}),h=[];c&&(await rn(c,NV(p.ranges)),h.push(`CSV: ${c} (${p.ranges.length} ranges)`)),l&&(await rn(l,XV(p,`${p.tb.name} SOURCE DIFF`)),h.push(`EDL: ${l} (B sources)`));let b;if(u&&p.ranges.length){let g=await ba(jV(m.session,p),Q(vt(),"authored",`${p.tb.name} source diff.authored`),"diff");b=g.id,h.push(`session_id: ${g.id} (B's clips under the differing ranges; timeline_write it)`)}let v=Object.fromEntries(V4.map(g=>[g,p.ranges.filter(y=>y.kind===g).length]));return ut([RV(p,d.name,m.name,s),...h].join(`
290
- `),{counts:v,total:p.ranges.length,ranges:p.ranges.slice(0,s),truncated:p.ranges.length>s,session_id:b,csv_path:c,edl_path:l})}catch(f){return Ge(f)}}},{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:M.string(),samples:M.number().int().min(4).max(64).optional().describe("Frames sampled (default 16)")},run:async({path:e,samples:t})=>{try{let n=await MH(e,t);return ut(LH(n),{...n})}catch(n){return Ge(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:M.string().describe("Folder or volume to search"),query:M.string().min(2).describe("Name or ID fragment, e.g. 'XD32995' or 'XD32995_0158_0221_MultiClip.mov'"),max_depth:M.number().int().min(0).max(30).default(10),max_entries:M.number().int().min(1).max(2e6).default(2e5).describe("Directory entries to visit before stopping"),time_limit_s:M.number().min(1).max(600).default(60),probe:M.boolean().default(!0).describe("Probe each match (codec, raster, rate, TC, length)"),limit:M.number().int().min(1).max(5e3).default(100)},run:async({path:e,query:t,max_depth:n,max_entries:i,time_limit_s:r,probe:o,limit:a})=>{try{let s=await k9(e,t,{max_depth:n??10,max_entries:i??2e5,time_limit_s:r??60,probe:o??!0});return a??=100,ut(S9(s,e,t,a),{scanned:s.scanned,truncated:s.truncated,total:s.hits.length,hits:s.hits.slice(0,a).map(c=>({path:c.path,match:c.match,size:c.size,facts:c.facts?Wf(c.facts):null,source_timecode:c.facts?.source_timecode??null,frames:c.facts?.available_range?.duration?.value??c.facts?.declared_duration?.value??null,error:c.error}))})}catch(s){return Ge(s)}}},{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:M.string().optional().describe("The media file to check (required with ranges)"),ranges:M.array(M.object({in:M.union([M.string(),M.number().int()]),out:M.union([M.string(),M.number().int()]),label:M.string().optional()})).optional(),session_id:M.string().optional(),item_ids:M.array(M.string()).optional().describe("Clip item ids (timeline_inspect detail=clips / timeline_query)"),handles:M.number().int().min(0).default(0).describe("Required handle per side, frames")},run:async({path:e,ranges:t,session_id:n,item_ids:i,handles:r})=>{try{let o=new Map,a=[];if(t?.length){if(!e)throw new Te("invalid_args","path is required with ranges");o.set(e,[...t])}if(n){if(!i?.length)throw new Te("invalid_args","item_ids is required with session_id");let d=(await ui(n)).session,m=new Map((d.media_references??[]).map(h=>[h.id,h])),p=new Map(d.timelines.flatMap(h=>h.tracks.flatMap(b=>b.items)).map(h=>[h.id,h]));for(let h of i){let b=p.get(h);if(!b?.source_range){a.push(`${h}: no such clip with a source range`);continue}let v=b.media_reference_id?m.get(b.media_reference_id):void 0,g=(v?.local_path??v?.target_url??"").replace(/^file:\/\//,""),y=e??g;if(!y){a.push(`${h}: the clip has no media path; pass path`);continue}let w=b.source_range.start.rate||v?.source_fps||24,x=v?.source_fps||w,O=b.source_range.start.value*x/w,P=b.source_range.duration.value*x/w,T=v?.source_timecode?Cn(v.source_timecode,x):null,S=Math.round(x)*86400,k=!!v?.source_timecode?.includes(";"),L=z=>T==null?Math.round(z):Qt(Math.round(T+z)%S,x,k);(o.get(y)??o.set(y,[]).get(y)).push({label:`${h} ${b.name??""}`.trim(),in:L(O),out:L(O+P)})}}if(!o.size)throw new Te("invalid_args",a.length?a.join("; "):"give path + ranges, or session_id + item_ids");let s=[],c=[],l=0,u=0;for(let[d,m]of o){let p=await T9(d,m,r);c.push({path:d,facts:Wf(p.facts),rows:p.rows}),s.push(`${d}
291
- ${Wf(p.facts)}`,...p.rows.map(h=>` - ${h.label}: ${h.in_tc}\u2013${h.out_tc} (${h.frames} fr) ${h.note}`)),l+=p.rows.filter(h=>!h.covered).length,u+=p.rows.length}let f=l?`${l} of ${u} range${u===1?"":"s"} NOT covered`:`all ${u} range${u===1?"":"s"} covered`;return ut([f,...s,...a.map(d=>`skipped ${d}`)].join(`
292
- `),{covered:u-l,not_covered:l,files:c,skipped:a})}catch(o){return Ge(o)}}},{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:M.string(),in:M.union([M.string(),M.number().int()]).describe("First frame: frame index or timecode like 01:00:10:00"),out:M.union([M.string(),M.number().int()]).describe("Last frame (inclusive) or timecode; set out_exclusive for an edit-style out point"),out_exclusive:M.boolean().optional(),handles:M.number().int().min(0).optional().describe("Extra frames on each side"),out_path:M.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 fh(e),n=t.facts.streams?.find(i=>i.kind==="video");return Vn(`${t.outputs.map(i=>`wrote ${i.path} (${(i.bytes/1e6).toFixed(1)} MB${i.part?`, part ${i.part}`:""})`).join(`
293
- `)}
294
- frames ${t.first_frame}\u2013${t.last_frame} (${t.frames} frames)
295
- source: ${n?.codec??"?"} ${n?.width??"?"}x${n?.height??"?"} @ ${t.fps} fps, start TC ${t.facts.source_timecode??"none"}`)}catch(t){return Ge(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 colour 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:M.string().describe("The master .mov"),patch:M.string().optional().describe("The render of the fixed range (not needed for mode=undo)"),mode:M.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:M.union([M.string(),M.number().int()]).optional().describe("Cross-check: the master frame (index or timecode) to start at; must agree with the patch's TC"),out:M.union([M.string(),M.number().int()]).optional().describe("Last master frame to replace (inclusive); default: to the end of the patch"),patch_in:M.number().int().min(0).optional().describe("First patch frame to use (default: the one at in= by TC, else 0)"),out_path:M.string().optional().describe("Output file or folder for mode new/section; never overwritten"),patches:M.array(M.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:M.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 i=await D4(n,e);return ut(i.text,i.data)}catch(i){return Ge(i)}}},{name:"media_repair_cadence",long:!0,repoOnly:!0,title:"Repair an AI render's cadence",description:"Put back the frames an AI video edit (e.g. Seedance video_edit) held or skipped, against the plate it was made from. Held frames (a near-copy of the previous frame while the plate moves) are cut; skipped source frames are found by aligning the render to the plate and filled with ONE RIFE v4.22.lite in-between each; every unique render frame passes through untouched and the output has the plate's frame count, at the plate's rate (ProRes 422 HQ). A render the AI RE-PACED (it races ahead of the performance, then pays it back) is reported and NOT repaired unless force=true \u2014 filling it would cut real frames, a creative decision. plan_only reports without writing. Report: held frames, gaps (which plate frames), RIFE output frames, motion dips/jumps against the plate. Needs CONFORM_PYTHON with torch + torchvision + numpy, and ffmpeg.",inputSchema:{plate:M.string().describe("The source plate the AI was given"),render:M.string().describe("The raw AI render"),out_path:M.string().optional().describe("Output .mov; default <render>_cadence.mov beside the render"),plate_start:M.number().int().min(0).optional().describe("First plate frame the AI was given (default 0)"),plate_frames:M.number().int().min(2).optional().describe("Plate frames the AI was given (default: to the end)"),mask:M.tuple([M.number(),M.number(),M.number(),M.number()]).optional().describe("x0,y0,x1,y1 fractions: an area the AI changed on purpose, left out of the alignment"),plan_only:M.boolean().optional(),force:M.boolean().optional().describe("Repair even when a re-pace is detected")},run:async e=>{try{return Vn(IV(await FV(e)))}catch(t){return Ge(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:M.string(),out_dir:M.string().describe("Folder for the trimmed media"),handles:M.number().int().min(0).default(24).describe("Frames of handle on each side of every used range"),relink:M.boolean().default(!0).describe("Repoint the session at the trims"),only_linked:M.boolean().default(!0)},run:async({session_id:e,out_dir:t,handles:n,relink:i,only_linked:r})=>{try{let o=await ui(e),a=await AI(o.session,t,n,{relink:i,only_linked:r});return await eo(o,`consolidate \u2192 ${t} (${a.outputs.length} files, ${n} handles)`),Vn(a.text)}catch(o){return Ge(o)}}},{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 (colour 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 colour 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:M.string().describe("Media file (ProRes/DNx/MXF) or a still to grade"),frame:M.union([M.number().int(),M.string()]).optional().describe("Frame index or timecode of the source frame (default: the middle of the file)"),reference:M.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:M.union([M.number().int(),M.string()]).optional(),method:M.enum(cD).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:M.boolean().optional().describe("method primaries: also use the RGB Mixer (default false: a plain balance of gain/lift/gamma/contrast/saturation)"),skin_protect:M.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 colour only and keeps the balance's contrast"),transfer:M.enum(["srgb","g24"]).optional().describe("Override the source's encoding (default: g24 for video, srgb for stills)"),session_id:M.string().optional().describe("Install the grade on a clip of this session"),item:M.string().optional().describe("The clip to grade: item id or unique clip name (with session_id)"),download:M.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:i,method:r,transfer:o,session_id:a,item:s,download:c,mixer:l,skin_protect:u})=>{try{let f=a?await ui(a):null;if(f&&!s)throw new Te("invalid_args","item is required with session_id");let d=f&&s?dD(f.session,s):null;if(f&&!d)throw new Te("not_found",`no clip '${s}' in session ${a} (timeline_inspect detail=clips lists ids and names)`);let m=d?fD(f.session,d.itemId):void 0,p=await lD({source:e,frame:t,reference:n,reference_frame:i,method:r,transfer:o,item_id:s,download:c,cst:m,mixer:l,skinBoost:u}),h={method:p.method,transfer:p.transfer,residual:p.residual,luma_stops:p.lumaStops,source:p.source,reference:p.reference,entries:p.entries,...p.cst?{cst:p.cst}:{}},b="";if(f&&d){let v=uD(p,d.timelineId,d.itemId);for(let g of v)r4(f.session,"finish_op",g);await eo(f,`color_match ${te(n)} \u2192 ${d.name||d.itemId} (${p.method})`),h.session_id=a,h.item_id=d.itemId,b=`
296
- installed on ${d.name||d.itemId} in session ${a}: timeline_write target=resolve-drt writes it as corrector nodes`}return ut(mD(p)+b,h)}catch(f){return Ge(f)}}},{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_cancel. The recipient only ever pulls the bytes it asks for (seek+response), so nothing is pushed.",inputSchema:{path:M.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 kD(e);if(!t.length)return Ge(new Te("not_found",`nothing to send in ${e}`));let n=await S8(t),i=Dd("p2p_send",async(o,a)=>(await new Promise(s=>{a.addEventListener("abort",()=>s()),n.closed.then(s)}),n.stop(),Vn("stopped serving"))),r=Ns(n.ticket).files.length;return ut(`serving ${r} file(s) as ${i.id} \u2014 job_cancel ${i.id} to stop
297
- ticket (give this to the recipient): ${n.ticket}`,{ticket:n.ticket,job_id:i.id,files:r})}catch(t){return Ge(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:M.enum(["show","set","forget"]).default("show"),endpoint:M.string().optional().describe("set: e.g. https://<account>.r2.cloudflarestorage.com, https://s3.us-west-2.amazonaws.com"),bucket:M.string().optional(),region:M.string().optional().describe("set: default auto"),access_key_id:M.string().optional(),secret_access_key:M.string().optional().describe("set: or CONFORM_BUCKET_SECRET in the environment")},run:async({action:e,endpoint:t,bucket:n,region:i,access_key_id:r,secret_access_key:o})=>{try{let a=l=>l?`your bucket: ${l.bucket} at ${l.endpoint} (key ${l.access_key_id}${l.verified_at?`, checked ${l.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:l}=await Ur("v1-me","/v1/me/storage");return ut(a(l),{storage:l})}if(e==="forget")return await Ur("v1-me","/v1/me/storage",{method:"DELETE"}),Vn("bucket forgotten; new projects use conform.tools storage");let s=o??Rt("CONFORM_BUCKET_SECRET");if(!t||!n||!r||!s)return Ge(new Te("invalid_args","set needs endpoint, bucket, access_key_id and secret_access_key (or CONFORM_BUCKET_SECRET)"));let{storage:c}=await Ur("v1-me","/v1/me/storage",{method:"PUT",body:{endpoint:t,bucket:n,region:i,access_key_id:r,secret_access_key:s}});return ut(`${a(c)} \u2014 tested and saved; new projects send into it`,{storage:c})}catch(a){return Ge(a)}}},{name:"project",title:"Projects: the jobs your clients send footage into",description:`A project is one job ("PRIMROSE \xB7 Ep 104") on conform.tools: what clients send through its links (project_link) lands in it, in conform.tools storage or the org's own bucket (storage='org'), trimmed to their cut + the project's handles. action=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:M.enum(["create","list","incoming","show","archive"]),project_id:M.string().optional(),name:M.string().optional().describe("create: the job's name"),client_name:M.string().optional(),handles:M.number().int().min(0).max(240).optional().describe("create: trim handles in frames for what clients send (default 24)"),storage:M.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:i,handles:r,storage:o})=>{try{let a=(l,u={})=>Ur("v1-projects",l,u),s=l=>`${(Number(l||0)/1e6).toFixed(1)} MB`;if(e==="create"){if(!n)return Ge(new Te("invalid_args","create needs name"));let l=o??((await Ur("v1-me","/v1/me/storage").catch(()=>({storage:null}))).storage?"org":"conform"),{project:u}=await a("/v1/projects",{body:{name:n,client_name:i,handles:r,storage:l}});return ut(`project ${u.name} (${u.id}) \u2014 ${u.handles}-frame handles, ${u.storage==="org"?"your bucket":"conform.tools storage"}
298
- next: project_link project_id=${u.id} for a link to send your client`,{project:u})}if(e==="list"){let{projects:l}=await a("/v1/projects");return ut(l.length?l.map(u=>`- ${u.name}${u.client_name?` (${u.client_name})`:""} \xB7 ${u.id}${u.live?.length?` \xB7 LIVE: ${u.live.length} sharing now (project action=incoming)`:""}`).join(`
299
- `):"no projects yet \u2014 project action=create name=\u2026",{projects:l})}if(e==="incoming"){let{projects:l}=await a("/v1/projects"),u=l.flatMap(f=>(f.live??[]).map(d=>({project:f.name,project_id:f.id,...d})));return ut(u.length?u.map(f=>`- ${f.project}${f.label?` \xB7 ${f.label}`:""} \xB7 sharing since ${String(f.seen_at).slice(11,16)} \u2192 delivery_fetch from=${f.ticket} as=mount (or as=trims / as=iso)`).join(`
300
- `):'nobody is sharing right now \u2014 a client presses "Let <you> connect" in their Send app (project_link makes one)',{live:u})}if(!t)return Ge(new Te("invalid_args",`${e} needs project_id`));if(e==="archive")return await a(`/v1/projects/${t}`,{method:"PATCH",body:{archived:!0}}),Vn(`archived ${t}; its links no longer work`);let c=await a(`/v1/projects/${t}`);return ut([`${c.project.name}${c.project.client_name?` \xB7 ${c.project.client_name}`:""} \u2014 ${c.project.handles}-frame handles, ${c.project.storage==="org"?"your bucket":"conform.tools storage"}`,`links (${c.links.length}):`,...c.links.flatMap(l=>[` - ${l.label??"(no label)"} ${l.url} ${l.alive?`\xB7 expires ${l.expires_at?.slice(0,10)??"never"}`:"\xB7 OFF"}${l.last_used_at?` \xB7 last used ${l.last_used_at.slice(0,16)}`:""}`,...l.peer?[` LIVE: their app is sharing its cut from their machine \u2192 delivery_fetch from=${l.peer.ticket} as=mount (or as=trims / as=iso)`]:[]]),`sends (${c.sessions.length}):`,...c.sessions.map(l=>` - ${l.created_at.slice(0,16)} ${l.label??""} ${l.sender_email??""} ${l.status} ${s(l.total_bytes)} \u2192 delivery_fetch from=bucket:${l.id}`)].join(`
301
- `),c)}catch(a){return Ge(a)}}},{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:M.enum(["create","revoke"]).default("create"),project_id:M.string(),link_id:M.string().optional(),label:M.string().optional(),recipient_email:M.string().optional(),expires_in_days:M.number().int().min(1).max(365).nullable().optional()},run:async({action:e,project_id:t,link_id:n,label:i,recipient_email:r,expires_in_days:o})=>{try{if(e==="revoke")return n?(await Ur("v1-projects",`/v1/projects/${t}/links/${n}`,{method:"DELETE"}),Vn(`link ${n} turned off`)):Ge(new Te("invalid_args","revoke needs link_id"));let{link:a}=await Ur("v1-projects",`/v1/projects/${t}/links`,{body:{label:i,recipient_email:r,expires_in_days:o}});return ut(`send this to your client: ${a.url}
302
- (expires ${a.expires_at?.slice(0,10)??"never"}; project_link action=revoke link_id=${a.id} turns it off)`,{link:a})}catch(a){return Ge(a)}}},{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:
303
- 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_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_status shows it live.
304
- A peer's machine must stay on and serving. Long: background=true for a job id.`,inputSchema:{from:M.string().describe("A .iso path, bucket:<session id> (or the bare id), or a p2p_send ticket"),as:M.enum(["list","iso","trims","mount"]).default("list"),out_path:M.string().optional().describe("as=iso: the .iso to write; as=trims: the folder to write into"),only:M.array(M.string()).optional().describe("as=trims: keep only paths containing one of these"),background:M.boolean().default(!1).describe("Return a job id immediately; poll with job_status, cancel with job_cancel")},run:async({from:e,as:t,out_path:n,only:i,__progress:r,__signal:o})=>{let a=await Mr("conform-fetch-");try{let s=N8(e);if(t==="mount"){let l=await VD(s,a),u=Dd("delivery_fetch",async(d,m)=>{let p=l.status&&setInterval(()=>{let h=l.status();d(h.fetched,h.total,`${h.files} files \xB7 ${k8(h.path)} \xB7 ${(h.rate/1e6).toFixed(1)} MB/s${h.error?` \xB7 ${h.error}`:""}`)},2e3);return await new Promise(h=>m.addEventListener("abort",()=>h())),p&&clearInterval(p),await l.stop(),await Sr(a),Vn(`unmounted ${l.mountpoint}`)});l.status&&await new Promise(d=>setTimeout(d,3e3));let f=l.status?.();return ut(`mounted at ${l.mountpoint}${s.kind==="file"?"":" \u2014 clips fetch as they are read; files the sender adds while sharing appear in it"}`+(f?`
305
- path: ${k8(f.path)} (job_status ${u.id} shows it live, with MB/s)`:"")+`
306
- job_cancel ${u.id} to unmount`,{mountpoint:l.mountpoint,job_id:u.id,...f?{path:f.path}:{}})}if(t==="iso"){if(!n)return Ge(new Te("invalid_args","as=iso needs out_path (the .iso to write)"));if(s.kind==="file")return Ge(new Te("invalid_args","that .iso is already on this machine"));let l=await WD(s,n,a,r,o);return ut(`fetched ${(l/1e6).toFixed(1)} MB \u2192 ${n}`,{path:n,bytes:l})}let c=await _v(s,a);try{if(t==="list"){let u=await L4(c),f=d=>`${(d/1e6).toFixed(1)} MB`;return ut([`${c.name}: ${u.files.length} file(s), ${f(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} ${f(d.size)}${d.recorded<d.size?` (${f(d.recorded)} real \u2014 the cut's frames)`:""}`)].join(`
307
- `),{...u,name:c.name})}if(!n)return Ge(new Te("invalid_args","as=trims needs out_path (the folder to write into)"));let l=await R4(c,n,{only:i,onProgress:r,signal:o});return ut([`wrote ${l.files} file(s), ${(l.bytes/1e6).toFixed(1)} MB of trims \u2192 ${n}`,...l.untrimmed.length?["not trimmed (written as stored):",...l.untrimmed.map(u=>` - ${u}`)]:[]].join(`
308
- `),l)}finally{await c.close()}}catch(s){return Ge(s)}finally{t!=="mount"&&await Sr(a)}}},{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 colourist 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.
309
- 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).
310
- 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.
311
- 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_cancel.
312
- 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.
313
- 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:M.string(),destination:M.enum(["folder","iso","bucket","p2p"]),out_path:M.string().optional().describe("folder: where to write; iso: the .iso path; bucket/p2p: optional \u2014 also keep the .iso here"),add_to:M.string().optional().describe("An earlier delivery to add this one into: a .iso path or bucket:<session id>"),recipients:M.array(M.string()).optional().describe("destination=bucket: emails to notify"),label:M.string().optional().describe("destination=bucket: the delivery's name in the inbox (default: the volume name)"),volume_name:M.string().optional().describe("Package / volume name; default from the source file"),handles:M.number().int().min(0).default(24),preserve_structure:M.boolean().default(!1).describe("Mirror the sources' parent folders under 02_MEDIA"),timeline_formats:M.array(M.string()).default(["resolve-drt"]),only_linked:M.boolean().default(!0)},run:async({session_id:e,destination:t,out_path:n,add_to:i,recipients:r,label:o,volume_name:a,handles:s,preserve_structure:c,timeline_formats:l,only_linked:u,__progress:f,__signal:d})=>{try{let m=await ui(e),p={volume_name:a,handles:s,preserve_structure:c,timeline_formats:l,only_linked:u},h=g=>`${(g/1e6).toFixed(1)} MB`;if(t==="folder"){if(i)return Ge(new Te("invalid_args","add_to adds into a .iso: use destination=iso or bucket"));if(!n)return Ge(new Te("invalid_args","out_path is required"));let g=await wV(m.session,m.source_path,{...p,out_path:n});await eo(m,`deliver folder \u2192 ${n}`);let y=await Hd("delivery-qc",g.keys);return Vn(`${g.text}${y?`
314
-
315
- Reading this delivery (conform.tools playbook):
316
- ${y}`:""}`)}let b=await Mr("conform-deliver-"),v=!1;try{let g=n&&!i?n:Q(b,`${a??te(m.source_path,ar(m.source_path))}.iso`);f?.(0,0,"building the .iso");let y=await xV(m.session,m.source_path,{...p,out_path:g}),w=y.text.split(`
317
- `).filter(P=>!P.startsWith("wrote ")&&!P.startsWith("- ")).join(`
318
- `);if(i){let P=N8(i),T=await ED(P,y.path,{onProgress:f,signal:d});return await eo(m,`deliver add_to \u2192 ${i}`),ut(`added into ${i}: ${h(T.bytes)} in ${T.filled} range(s)${T.added.length?`
319
- new: ${T.added.filter(S=>!S.startsWith(".conform/")).join(", ")}`:""}${T.versioned.filter(S=>!S.startsWith(".conform/")).length?`
320
- changed, added beside the old: ${T.versioned.filter(S=>!S.startsWith(".conform/")).join(", ")}`:""}${T.bytes===0?`
321
- (nothing new \u2014 this delivery was already in it)`:""}`+`${T.uploaded!==void 0?`
322
- bucket: uploaded ${h(T.uploaded)}, copied ${h(T.copied??0)} server-side; the delivery is now ${h(T.image)}`:""}
323
-
324
- ${w}`.trimEnd(),T)}if(t==="iso"){await eo(m,`deliver iso \u2192 ${y.path}`);let P=await Hd("delivery-qc",y.keys);return Vn(`${y.text}${P?`
325
-
326
- Reading this delivery (conform.tools playbook):
327
- ${P}`:""}`)}if(t==="bucket"){let P=await ID(y.path,{label:o,recipients:r,onProgress:f,signal:d});return await eo(m,`deliver bucket \u2192 ${P.session_id}`),ut([`delivered to your bucket as bucket:${P.session_id} (${h(P.image)} image): uploaded ${h(P.uploaded)}${P.copied?`, ${h(P.copied)} already in ${P.reused_from} earlier deliver${P.reused_from===1?"y":"ies"} \u2014 copied there server-side, not uploaded`:""}`,`it is in the conform.tools inbox; delivery_fetch from=bucket:${P.session_id} lists it, cuts trims or mounts it${r?.length?`; ${r.join(", ")} notified`:""}`,...n?[`kept a copy at ${y.path}`]:[],"",w].join(`
328
- `).trimEnd(),P)}let x=await S8([y.path]);v=!n;let O=Dd("media_deliver",async(P,T)=>(await new Promise(S=>{T.addEventListener("abort",()=>S()),x.closed.then(S)}),x.stop(),v&&await Sr(b),Vn("stopped serving")));return await eo(m,`deliver p2p (${O.id})`),ut(`serving ${te(y.path)} (${h(y.bytes)}) peer to peer as ${O.id} \u2014 job_cancel ${O.id} to stop
329
- ticket for the recipient's delivery_fetch (as=mount to watch it now, as=trims, or as=iso): ${x.ticket}
330
-
331
- ${w}`.trimEnd(),{ticket:x.ticket,job_id:O.id})}finally{v||await Sr(b)}}catch(m){return Ge(m)}}},{name:"timeline_judge",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:M.string().describe("The original timeline file"),output_path:M.string().describe("The written timeline file to judge")},run:async({source_path:e,output_path:t})=>{try{return Vn(await BI(e,t))}catch(n){return Ge(n)}}},{name:"timeline_autoconform",long:!0,protectedStages:["canonicalize"],title:"Auto conform a reference to source media",description:"Rebuild a cut from a reference render: reads every frame of the reference and the pool as a tiny luma grid at each codec's cheapest tier, aligns the whole reference against the pool in one pass (grade-proof take codes name the clip, difference-mode motion names the frame, one path over the film finds the cuts), measures each shot's sizing, and builds a new timeline session at the reference's raster and rate with markers on every issue (gap, unresolved, contested, reframe, retime). reference: a ProRes .mov (or camera original) of the cut. 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 to verify and correct instead of searching blind (much faster). reframe_tier: the SSCD embedding pass that places punched-in/reframed shots under graphics \u2014 on automatically when its model is installed; false skips it (faster), true requires it. examine_all=true disables early stopping. Returns a session_id for timeline_write plus the coverage stats and the issue list. H.264/HEVC (references or pool) decode with the OS's own decoder (macOS today).",inputSchema:{reference:M.string().describe("Path to the reference render of the cut (ProRes, H.264, HEVC, or a camera original)"),pool:M.array(M.string()).min(1).describe("Folders and/or media files to search"),hints_session_id:M.string().optional().describe("Session id of the editor's timeline for this cut, if you have one"),reframe_tier:M.boolean().optional().describe("SSCD reframe tier: omit = on when the model is installed"),examine_all:M.boolean().default(!1),display_transform:M.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"),engine:M.enum(["align","legacy"]).optional().describe("align (default): the whole-film aligner. legacy: the older per-shot matcher (used automatically with hints_session_id)"),find_first:M.boolean().optional().describe("legacy engine only: look each reference shot up in a sparse index of the pool and confirm it with pixels, instead of decoding every clip densely \u2014 far faster on big camera-original pools (needs the SSCD model)"),sizing:M.boolean().optional().describe("Measure each placed shot's scale/position/rotation/mirror from a dozen frame pairs (default on; shots it cannot measure are left at 100 % and flagged). false keeps the per-frame ORB estimate"),name:M.string().optional().describe("Timeline name"),background:M.boolean().default(!1).describe("Return a job id immediately; poll with job_status, cancel with job_cancel")},run:async({reference:e,pool:t,hints_session_id:n,reframe_tier:i,examine_all:r,engine:o,find_first:a,display_transform:s,sizing:c,name:l,__progress:u,__signal:f})=>{try{let d=n?(await ui(n)).session:void 0,m=await FW({reference:e,pool:t,hints:d,reframe_tier:i,examine_all:r,engine:o,find_first:a,display_transform:s,sizing:c,name:l,onProgress:u,signal:f}),p=await ba(m.session,e,"autoconform"),h=await Hd("auto-conform",IW(m));return Vn(`session_id: ${p.id}
332
- ${EW(m)}
333
- ${await ws(m.session)}${h?`
334
-
335
- Reading this result (conform.tools playbook):
336
- ${h}`:""}`)}catch(d){return Ge(d)}}},{name:"qc_compare",long:!0,title:"Compare two versions of a cut and rebuild the new one from the old",description:"Reference Compare: diff two renders of a cut (A = the old version, B = the new one) frame by frame and say what changed: frames inserted, removed, moved, replaced. Perceptual, so it survives a regrade or a re-render; A and B may differ in codec (ProRes, H.264, HEVC, camera originals) and resolution, and a frame-rate difference is normalised and reported. Builds the reconform: events that rebuild B from A (A-source events + holes of new material), each verified against the pictures (an event that does not reproduce B, a hold, a reverse or a retime, is flagged CHECK BY EYE, never shown as exact). 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 colour ('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:M.string().describe("Path to the OLD version (whose media and grade exist)"),b:M.string().describe("Path to the NEW version, to rebuild from A"),min_run:M.number().int().min(1).optional().describe("Shortest run in frames that counts as an event (default 3; shorter = noise)"),edl_path:M.string().optional().describe("Write the reconform as a CMX3600 EDL here"),csv_path:M.string().optional().describe("Write the reconform events as CSV here")},run:async({a:e,b:t,min_run:n,edl_path:i,csv_path:r,__progress:o,__signal:a})=>{try{let s=await BW({a:e,b:t,min_run:n,onProgress:o,signal:a});i&&await rn(i,s.edl),r&&await rn(r,s.csv);let c=await ba(s.session,t,"reconform"),l=[`session_id: ${c.id} (B rebuilt from A; timeline_write it to any host)`,...i?[`EDL: ${i}`]:[],...r?[`CSV: ${r}`]:[],YW(s,{a:e,b:t})].join(`
337
- `);return ut(l,{session_id:c.id,summary:s.summary,stats:s.stats,warnings:s.result.warnings,unreproducible:s.unreproducible.map(u=>({index:u.index,record:[u.recordInTc,u.recordOutTc],note:u.unreproducible.note})),lanes:s.lanes})}catch(s){return Ge(s)}}},{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:M.string().describe("The timeline (timeline_read / host_current)"),mix:M.array(M.string()).optional().describe("The mix WAV(s); the first sets the program length"),program_start:M.string().optional().describe("Program start TC when the mix has no 2-pop (default: the artist profile's program_start)"),name:M.string().optional().describe("The deliverable file name about to be rendered"),timeline_id:M.string().optional()},run:async({session_id:e,...t})=>{try{let n=await zH((await ui(e)).session,t);return ut(OH(n),{...n})}catch(n){return Ge(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, colour 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:M.string().describe("The rendered deliverable"),mark_in:M.union([M.string(),M.number().int()]).optional().describe("Timeline Mark In (TC or frame): the expected start TC"),mark_out:M.union([M.string(),M.number().int()]).optional().describe("Timeline Mark Out, INCLUSIVE: with mark_in, the expected frame count"),start_tc:M.string().optional().describe("Expected start TC when there is no mark_in (default: the artist profile's program_start)"),frames:M.number().int().positive().optional().describe("Expected frame count"),codec:M.string().optional().describe("e.g. 'ProRes 4444', 'ProRes 422 HQ', 'H.264'"),width:M.number().int().positive().optional(),height:M.number().int().positive().optional(),fps:M.number().positive().optional(),bit_depth:M.number().int().optional(),chroma:M.string().optional().describe("e.g. 4:4:4"),channels:M.number().int().min(0).optional().describe("Total audio channels expected"),loudness_lufs:M.number().optional().describe("Target integrated loudness per track (e.g. -24)"),loudness_tolerance:M.number().positive().optional().describe("\xB1 LU (default 1)"),true_peak:M.number().optional().describe("True-peak ceiling, dBTP (e.g. -2)"),mix:M.array(M.string()).optional().describe("The mix WAVs / stems the audio outputs must carry"),ref:M.string().optional().describe("The approved reference movie"),ref_in:M.union([M.string(),M.number().int()]).optional().describe("The REF's TC/frame for the render's first frame (default the render's start TC)"),name:M.boolean().optional().describe("Check the name against the naming profile (default true)"),end_on_picture:M.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 i=await kH(n);return ut(SH(i),{...i})}catch(i){return Ge(i)}}},{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 / host_export / 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:M.string(),changes:M.array(M.union([M.string(),M.object({in:M.union([M.string(),M.number()]),out:M.union([M.string(),M.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:M.string().optional().describe("The timeline (default the session's first with video)"),master:M.string().optional().describe("A delivered master's file name (or path) to name the patches from (naming profile)"),first_patch:M.number().int().min(1).default(1).describe("Number of the first patch (PATCH01)")},run:async({session_id:e,changes:t,timeline_id:n,master:i,first_patch:r})=>{try{let o=await ui(e),a=VH(o.session,t,{timeline_id:n,first_patch:r}),s=WH(a);if(i){let c=await Di(),l=new Date,u=a.patches.map(d=>d.versions.map(m=>({text:m,...n1(c,i,{nn:d.nn,text:m,when:l})})));s+=`
338
- `+u.flat().map(d=>`name ${d.file}${d.job?` job ${d.job}`:""} \u2192 ${d.folder}`).join(`
339
- `);let f=[...new Set(u.flat().flatMap(d=>d.warnings))];return f.length&&(s+=`
340
- `+f.map(d=>`warning: ${d}`).join(`
341
- `)),ut(s,{...a,names:u})}return ut(s,{...a})}catch(o){return Ge(o)}}},{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. Writes out_path (.png) or a temp file; returns the path \u2014 open it to look.",inputSchema:{path:M.string(),frame:M.union([M.string(),M.number().int()]).optional().describe("Frame index or absolute source TC like 01:00:10:00; default the middle frame"),around:M.number().int().min(0).max(48).optional().describe("Contact sheet: \xB1N frames around frame"),step:M.number().int().min(1).optional().describe("Contact sheet: every Nth frame (default 1)"),b:M.string().optional().describe("A second file for A/B (e.g. the master against the temp)"),b_frame:M.union([M.string(),M.number().int()]).optional().describe("B's frame or TC for A's frame; default the same absolute TC"),width:M.number().int().min(16).max(8192).optional().describe("Output width per frame (default full size; 480 per tile on a sheet)"),out_path:M.string().optional().describe("PNG to write; default a temp file")},run:async e=>{try{let t=await k6(e);return ut(S6(t),{...t})}catch(t){return Ge(t)}}},{name:"timeline_frame",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:M.string(),item_id:M.string().optional(),record:M.union([M.string(),M.number().int()]).optional().describe("Record TC like 01:00:10:00, or frames from the timeline head"),timeline:M.string().optional().describe("Timeline id or name (default the primary)"),around:M.number().int().min(0).max(48).optional(),step:M.number().int().min(1).optional(),width:M.number().int().min(16).max(8192).optional(),out_path:M.string().optional()},run:async({session_id:e,item_id:t,record:n,timeline:i,...r})=>{try{let o=await ui(e),a=aH(o.session,{item_id:t,record:n,timeline:i}),s=await k6({...r,path:a.path,frame:a.frame});return ut(`record ${a.record_tc} (${a.track}, item ${a.item}) = ${te(a.path)} frame ${a.frame} (${s.frames[s.frames.length>>1]?.tc??"?"})
342
- ${S6(s)}`,{...s,source:a})}catch(o){return Ge(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, colour 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:M.string().describe("The rendered patch file"),master:M.string().describe("The delivered master file it patches"),expected_tc:M.string().optional().describe("The record TC the patch must start at (patch_plan start_tc)"),expected_frames:M.number().int().min(1).optional().describe("The frame count it must have (patch_plan frames)"),tolerance:M.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:M.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:i,tolerance:r,original:o,__progress:a})=>{try{let s=await HH({patch:e,master:t,expected_tc:n,expected_frames:i,tolerance:r,original:o},void 0,a);return ut(ZH(s,{patch:e,master:t}),{...s})}catch(s){return Ge(s)}}},{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, colour, 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_issue), not a profile rule. forget removes a rule (number or text). set replaces the whole profile JSON.",inputSchema:{action:M.enum(["get","learn","remember","forget","set"]).default("get"),path:M.string().optional().describe("learn: a folder of delivered files (or one file)"),project:M.string().optional().describe("learn: save as this project's spellings over the artist's"),facility:M.string().optional().describe("learn: the artist's or facility's name"),save:M.boolean().default(!0).describe("learn: false = preview only"),rule:M.string().optional().describe("remember: the preference in the artist's words; forget: text or number"),topic:M.string().optional().describe("remember: naming, deliverables, render, patch, conform\u2026"),source:M.string().optional().describe("remember: where it came from (default 'told')"),conventions:M.object({program_start:M.string().optional(),end_on_picture:M.boolean().optional(),theatrical_tag:M.string().optional(),no_audio_tag:M.string().optional()}).optional(),profile:M.record(M.string(),M.unknown()).optional().describe("set: the whole profile JSON")},run:async({action:e,path:t,project:n,facility:i,save:r,rule:o,topic:a,source:s,conventions:c,profile:l})=>{try{let u=await Di();switch(e??"get"){case"learn":{if(!t)return Ge(new Te("invalid_args","learn needs path (a folder of delivered files)"));let f=await N9(t,{project:n,facility:i,save:r}),d=[`${f.source}${f.saved?` \u2192 saved ${f.saved}`:" (preview, not saved)"}`,...Object.entries(f.learned.templates??{}).map(([m,p])=>` ${m}: ${p}`),...(f.learned.deliverables??[]).map(m=>` usual: ${m.label} (${m.CODEC} ${m.AUDIOCONFIG} .${m.ext}${m.texts.length?`, ${m.texts.join("/")}`:""})`),...Object.entries(f.learned.codec_folders??{}).map(([m,p])=>` folder: ${m}\u2026 \u2192 ${p}`),...f.misfits.length?[` ${f.misfits.length} name(s) follow another pattern: ${f.misfits.slice(0,5).join(", ")}`]:[],...f.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 ut(d.join(`
343
- `),{...f})}case"remember":{if(!o&&!c)return Ge(new Te("invalid_args","remember needs rule or conventions"));o&&(u=X9(u,{rule:o,topic:a,source:s??"told"})),c&&(u=F9(u,c,s??"told"));let f=await bl(u);return ut(`remembered \u2192 ${f}
344
- ${Zf(u)}`,{profile:u,path:f})}case"forget":{if(!o)return Ge(new Te("invalid_args","forget needs rule (its number or text)"));u=j9(u,/^\d+$/.test(o)?Number(o):o);let f=await bl(u);return ut(`forgotten \u2192 ${f}
345
- ${Zf(u)}`,{profile:u,path:f})}case"set":{let f=await bl(l);return ut(`saved \u2192 ${f}`,{path:f})}default:return ut(Zf(u),{profile:u})}}catch(u){return Ge(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, colour 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:M.enum(["get","set","build","patch","check","deliverables"]).default("get"),project:M.string().optional().describe("Use this project's spellings (profile.projects[project]) over the facility's"),textless:M.boolean().optional().describe("deliverables: the program has text over picture, so a TEXTLESS version is made"),include_optional:M.boolean().optional().describe("deliverables: include the optional kinds (e.g. UHD H.264)"),profile:M.record(M.string(),M.unknown()).optional().describe("set: the profile JSON"),kind:M.string().optional().describe("build/check: the template kind (deliverable, patch, timeline, replace_list, tracklayout, qc, render_job, deliverables_folder)"),values:M.record(M.string(),M.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:M.string().optional().describe("check: the name to check"),path:M.string().optional().describe("check: the file the name is for (probed)"),master:M.string().optional().describe("patch/check: the delivered master's file name"),nn:M.number().int().min(1).default(1).describe("patch: the patch number"),text:M.enum(["TEXTED","TEXTLESS"]).optional().describe("patch: the version (default the master's)"),picture_only:M.boolean().default(!0).describe("patch: AUDIOCONFIG = the artist's no-audio tag")},run:async({action:e,profile:t,kind:n,values:i,name:r,path:o,master:a,nn:s,text:c,picture_only:l,project:u,textless:f,include_optional:d})=>{try{let m=await Di(u);switch(e??"get"){case"set":{let p=await bl(t);return ut(`saved the ${t?.facility??""} naming profile \u2192 ${p}`,{path:p})}case"build":{if(!n)return Ge(new Te("invalid_args","build needs kind"));let p=ml(m,n,{...dh(),...i});return ut(p,{name:p,kind:n})}case"patch":{if(!a)return Ge(new Te("invalid_args","patch needs master (a delivered file's name)"));let p=n1(m,a,{nn:s??1,text:c,picture_only:l});return ut([p.file,p.job?`render job: ${p.job}`:"",`folder: ${p.folder}`,...p.warnings.map(h=>`warning: ${h}`)].filter(Boolean).join(`
346
- `),{...p})}case"check":{if(!r)return Ge(new Te("invalid_args","check needs name"));let p=hl(m,r,{kind:n,master:a,probe:o?await Fn(o):void 0}),h=p.issues.filter(b=>b.level==="error");return ut([`${h.length?"WRONG":"ok"}: ${r} (${m.facility} ${p.kind})`,...p.issues.map(b=>` ${b.level}: ${b.element}: ${b.message}`)].join(`
347
- `),{...p,ok_name:!h.length})}case"deliverables":{let p=M9(m,i??{},{textless:!!f,include_optional:d});return ut([`${m.facility}${u?` / ${u}`:""} usual deliverables:`,...p.map(h=>` ${h.name} (${h.label}, ${h.text}, ${h.raster}${h.container?" 16x9 container":""}, ${h.audio})`),...f?[]:[" (no TEXTLESS: pass textless=true when the program has text over picture)"]].join(`
348
- `),{deliverables:p})}default:return ut(Object.keys(m.templates).length?`${m.facility} naming profile
349
- ${JSON.stringify(m,null,2)}`:Zf(m),{profile:m})}}catch(m){return Ge(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:M.string().describe("The temp / graded reference"),a_in:M.union([M.string(),M.number().int()]).optional(),a_out:M.union([M.string(),M.number().int()]).optional().describe("Last frame included"),b:M.string().describe("The master"),b_in:M.union([M.string(),M.number().int()]).optional().describe("The client's in-point in B for a_in; omit to search"),search:M.number().int().min(1).max(250).optional().describe("\xB1frames checked (default 12)")},run:async({__progress:e,__signal:t,...n})=>{try{let i=await Pv({...n,signal:t});return ut(oH(i),{...i})}catch(i){return Ge(i)}}},{name:"job_status",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:M.string()},run:async({job_id:e})=>{let t=await iR(e);if(!t)return Ge(new Te("not_found",`no job ${e}`));let n=Wk(t);return t.status==="done"&&t.result?ut(`${n}
350
-
351
- ${t.result.content.map(i=>i.text).join(`
352
- `)}`,{job:t,result:t.result.structuredContent??null}):ut(n,{job:t})}},{name:"job_cancel",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:M.string()},run:async({job_id:e})=>Vk(e)?ut(`cancelling ${e}`,{job_id:e}):Ge(new Te("not_found",`no running job ${e}`))},{name:"job_list",title:"List jobs",description:"Recent background jobs (running and finished) with status and progress.",inputSchema:{},run:async()=>{let e=await oR();return ut(e.length?e.map(Wk).join(`
353
- `):"(no jobs)",{jobs:e})}}],Vle=new Set(["account_login","account_status","account_logout","account_telemetry","timeline_routes","report_issue","report_gap","report_note"]),HD=new Set(["account_status","conform_learn","timeline_read","host_current","host_project","timeline_inspect","timeline_routes","timeline_sessions","media_probe","media_find","media_coverage","timeline_judge","timeline_autoconform","job_status","job_list","patch_plan","patch_verify","media_align"]),Wle=new Set(["account_login","account_logout","account_telemetry","report_issue","report_gap","report_note","host_open","host_setup","timeline_edit","timeline_author","timeline_generate","timeline_relink","project","project_link","color_match","job_cancel","naming","artist_profile","media_frame","timeline_frame"]);function t7e(e){return{readOnlyHint:HD.has(e),destructiveHint:!HD.has(e)&&!Wle.has(e)}}async function n7e(e,t,n={}){let i=j8(e);if(!i)return Ge(new Te("not_found",`unknown verb '${e}'`));if(!Vle.has(e))try{await e7()}catch(a){return Ge(a)}let r=Zle(t),o=await Xk.run({verb:e,declared:i.protectedStages??[]},()=>Ule(i,e,r,n));return qle(e,o)}var Hle=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"]);function Zle(e){let t={...e};for(let n of Hle){let i=t[n];n==="reference"&&i==="ai"||(typeof i=="string"&&i?t[n]=gf(i):Array.isArray(i)&&(t[n]=i.map(r=>typeof r=="string"&&r?gf(r):r)))}return t}var Dle={timeline_read:"conform",host_current:"conform",timeline_relink:"conform",timeline_write:"conform",timeline_autoconform:"autoconform",media_consolidate:"deliver",media_deliver:"deliver"};function qle(e,t){let n=Dle[e];return!n||t.isError||nR()?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 Ule(e,t,n,i){let r=performance.now(),o=async(s,c)=>{let l=Math.round(performance.now()-r),u=s.content.map(d=>d.text).join(`
354
- `),f=typeof n.session_id=="string"?n.session_id:u.match(/session_id: (\w+)/)?.[1];return await lR({ts:new Date().toISOString(),verb:t,ms:l,ok:!s.isError,code:s.isError?String(s.structuredContent?.code??"engine"):void 0,msg:s.isError?u.slice(0,500):void 0,...c.withArgs?{args:cR(n)}:{},job:c.job,session:f,note:c.note}),l},a=async(s,c)=>{let l=await o(s,{job:c,withArgs:!0});return e.long&&n.background||Bk(t,s,l),s};if(e.long){let{background:s,...c}=n,l=Dd(t,async(u,f)=>await e.run({...c,__signal:f,__progress:s||!i.progress?u:(d,m,p)=>{u(d,m,p),i.progress(d,m,p)}}));return s||i.signal?.addEventListener("abort",()=>Vk(l.id),{once:!0}),s?(Ek(l.id)?.then(async u=>Bk(t,u,await o(u,{job:l.id,note:"job finished"}))),a(ut(`started ${l.id} (${t}) \u2014 poll job_status`,{job_id:l.id}),l.id)):a(await Ek(l.id),l.id)}try{return await a(await e.run(n))}catch(s){return a(Ge(s))}}function r7e(e,t){let n=j8(e);if(!n)return{ok:!1,result:Ge(new Te("not_found",`unknown verb '${e}'`))};let i=M.object(n.inputSchema).safeParse(t??{});if(i.success)return{ok:!0,data:i.data};Yk(e,M0(i.error.issues));let r=i.error.issues.map(o=>`${o.path.join(".")||"(args)"}: ${o.message}`).join("; ");return{ok:!1,result:Ge(new Te("invalid_args",r,{fields:M0(i.error.issues)}))}}function i7e(e,t){let n=j8(e);if(!n)return;let i=M.object(n.inputSchema).safeParse(t??{});i.success||Yk(e,M0(i.error.issues))}var Cle=Ele.filter(e=>!e.repoOnly||JL);function j8(e){return Cle.find(t=>t.name===e)}export{Jle as a,tl as b,Op as c,ome as d,mo as e,LJ as f,a1 as g,NJ as h,Hn as i,Ie as j,Ya as k,lK as l,G as m,yh as n,wh as o,bK as p,gK as q,Wt as r,b5 as s,Ub as t,Td as u,VP as v,WP as w,qP as x,lc as y,Ld as z,YM as A,_M as B,eu as C,eL as D,QP as E,ek as F,h0 as G,aL as H,Xd as I,uc as J,gL as K,kL as L,Ed as M,M as N,pc as O,u0e as P,P0 as Q,x0 as R,f0e as S,d0e as T,m0e as U,p0e as V,iR as W,Vk as X,oR as Y,M0e as Z,L0e as _,t7e as $,n7e as aa,r7e as ba,i7e as ca,Cle as da,j8 as ea};