diff --git "a/assets/index-6Ucuj2YA.js" "b/assets/index-6Ucuj2YA.js" deleted file mode 100644--- "a/assets/index-6Ucuj2YA.js" +++ /dev/null @@ -1,228 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))l(s);new MutationObserver(s=>{for(const d of s)if(d.type==="childList")for(const f of d.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&l(f)}).observe(document,{childList:!0,subtree:!0});function o(s){const d={};return s.integrity&&(d.integrity=s.integrity),s.referrerPolicy&&(d.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?d.credentials="include":s.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(s){if(s.ep)return;s.ep=!0;const d=o(s);fetch(s.href,d)}})();var Vk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var af={exports:{}},js={};var eg;function v1(){if(eg)return js;eg=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(l,s,d){var f=null;if(d!==void 0&&(f=""+d),s.key!==void 0&&(f=""+s.key),"key"in s){d={};for(var g in s)g!=="key"&&(d[g]=s[g])}else d=s;return s=d.ref,{$$typeof:e,type:l,key:f,ref:s!==void 0?s:null,props:d}}return js.Fragment=t,js.jsx=o,js.jsxs=o,js}var tg;function x1(){return tg||(tg=1,af.exports=v1()),af.exports}var u=x1(),sf={exports:{}},It={};var ng;function b1(){if(ng)return It;ng=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),f=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function _(L){return L===null||typeof L!="object"?null:(L=S&&L[S]||L["@@iterator"],typeof L=="function"?L:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,z={};function G(L,X,Ee){this.props=L,this.context=X,this.refs=z,this.updater=Ee||T}G.prototype.isReactComponent={},G.prototype.setState=function(L,X){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,X,"setState")},G.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function Y(){}Y.prototype=G.prototype;function oe(L,X,Ee){this.props=L,this.context=X,this.refs=z,this.updater=Ee||T}var ce=oe.prototype=new Y;ce.constructor=oe,F(ce,G.prototype),ce.isPureReactComponent=!0;var ve=Array.isArray;function ye(){}var fe={H:null,A:null,T:null,S:null},Je=Object.prototype.hasOwnProperty;function ge(L,X,Ee){var ke=Ee.ref;return{$$typeof:e,type:L,key:X,ref:ke!==void 0?ke:null,props:Ee}}function qe(L,X){return ge(L.type,X,L.props)}function Ve(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Ke(L){var X={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(Ee){return X[Ee]})}var nt=/\/+/g;function it(L,X){return typeof L=="object"&&L!==null&&L.key!=null?Ke(""+L.key):X.toString(36)}function xt(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(ye,ye):(L.status="pending",L.then(function(X){L.status==="pending"&&(L.status="fulfilled",L.value=X)},function(X){L.status==="pending"&&(L.status="rejected",L.reason=X)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function K(L,X,Ee,ke,He){var et=typeof L;(et==="undefined"||et==="boolean")&&(L=null);var Ae=!1;if(L===null)Ae=!0;else switch(et){case"bigint":case"string":case"number":Ae=!0;break;case"object":switch(L.$$typeof){case e:case t:Ae=!0;break;case x:return Ae=L._init,K(Ae(L._payload),X,Ee,ke,He)}}if(Ae)return He=He(L),Ae=ke===""?"."+it(L,0):ke,ve(He)?(Ee="",Ae!=null&&(Ee=Ae.replace(nt,"$&/")+"/"),K(He,X,Ee,"",function(ue){return ue})):He!=null&&(Ve(He)&&(He=qe(He,Ee+(He.key==null||L&&L.key===He.key?"":(""+He.key).replace(nt,"$&/")+"/")+Ae)),X.push(He)),1;Ae=0;var C=ke===""?".":ke+":";if(ve(L))for(var se=0;se>>1,Me=K[ut];if(0>>1;uts(Ee,Le))kes(He,Ee)?(K[ut]=He,K[ke]=Le,ut=ke):(K[ut]=Ee,K[X]=Le,ut=X);else if(kes(He,Le))K[ut]=He,K[ke]=Le,ut=ke;else break e}}return ze}function s(K,ze){var Le=K.sortIndex-ze.sortIndex;return Le!==0?Le:K.id-ze.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;e.unstable_now=function(){return d.now()}}else{var f=Date,g=f.now();e.unstable_now=function(){return f.now()-g}}var v=[],m=[],x=1,b=null,S=3,_=!1,T=!1,F=!1,z=!1,G=typeof setTimeout=="function"?setTimeout:null,Y=typeof clearTimeout=="function"?clearTimeout:null,oe=typeof setImmediate<"u"?setImmediate:null;function ce(K){for(var ze=o(m);ze!==null;){if(ze.callback===null)l(m);else if(ze.startTime<=K)l(m),ze.sortIndex=ze.expirationTime,t(v,ze);else break;ze=o(m)}}function ve(K){if(F=!1,ce(K),!T)if(o(v)!==null)T=!0,ye||(ye=!0,Ke());else{var ze=o(m);ze!==null&&xt(ve,ze.startTime-K)}}var ye=!1,fe=-1,Je=5,ge=-1;function qe(){return z?!0:!(e.unstable_now()-geK&&qe());){var ut=b.callback;if(typeof ut=="function"){b.callback=null,S=b.priorityLevel;var Me=ut(b.expirationTime<=K);if(K=e.unstable_now(),typeof Me=="function"){b.callback=Me,ce(K),ze=!0;break t}b===o(v)&&l(v),ce(K)}else l(v);b=o(v)}if(b!==null)ze=!0;else{var L=o(m);L!==null&&xt(ve,L.startTime-K),ze=!1}}break e}finally{b=null,S=Le,_=!1}ze=void 0}}finally{ze?Ke():ye=!1}}}var Ke;if(typeof oe=="function")Ke=function(){oe(Ve)};else if(typeof MessageChannel<"u"){var nt=new MessageChannel,it=nt.port2;nt.port1.onmessage=Ve,Ke=function(){it.postMessage(null)}}else Ke=function(){G(Ve,0)};function xt(K,ze){fe=G(function(){K(e.unstable_now())},ze)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125ut?(K.sortIndex=Le,t(m,K),o(v)===null&&K===o(m)&&(F?(Y(fe),fe=-1):F=!0,xt(ve,Le-ut))):(K.sortIndex=Me,t(v,K),T||_||(T=!0,ye||(ye=!0,Ke()))),K},e.unstable_shouldYield=qe,e.unstable_wrapCallback=function(K){var ze=S;return function(){var Le=S;S=ze;try{return K.apply(this,arguments)}finally{S=Le}}}})(uf)),uf}var lg;function w1(){return lg||(lg=1,cf.exports=S1()),cf.exports}var df={exports:{}},pi={};var ag;function T1(){if(ag)return pi;ag=1;var e=Zf();function t(v){var m="https://react.dev/errors/"+v;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),df.exports=T1(),df.exports}var rg;function E1(){if(rg)return Os;rg=1;var e=w1(),t=Zf(),o=C1();function l(n){var i="https://react.dev/errors/"+n;if(1Me||(n.current=ut[Me],ut[Me]=null,Me--)}function Ee(n,i){Me++,ut[Me]=n.current,n.current=i}var ke=L(null),He=L(null),et=L(null),Ae=L(null);function C(n,i){switch(Ee(et,i),Ee(He,n),Ee(ke,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?T0(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=T0(i),n=C0(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}X(ke),Ee(ke,n)}function se(){X(ke),X(He),X(et)}function ue(n){n.memoizedState!==null&&Ee(Ae,n);var i=ke.current,a=C0(i,n.type);i!==a&&(Ee(He,n),Ee(ke,a))}function me(n){He.current===n&&(X(ke),X(He)),Ae.current===n&&(X(Ae),Us._currentValue=Le)}var q,Ie;function Re(n){if(q===void 0)try{throw Error()}catch(a){var i=a.stack.trim().match(/\n( *(at )?)/);q=i&&i[1]||"",Ie=-1)":-1h||U[r]!==le[h]){var xe=` -`+U[r].replace(" at new "," at ");return n.displayName&&xe.includes("")&&(xe=xe.replace("",n.displayName)),xe}while(1<=r&&0<=h);break}}}finally{ee=!1,Error.prepareStackTrace=a}return(a=n?n.displayName||n.name:"")?Re(a):""}function $e(n,i){switch(n.tag){case 26:case 27:case 5:return Re(n.type);case 16:return Re("Lazy");case 13:return n.child!==i&&i!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return be(n.type,!1);case 11:return be(n.type.render,!1);case 1:return be(n.type,!0);case 31:return Re("Activity");default:return""}}function Oe(n){try{var i="",a=null;do i+=$e(n,a),a=n,n=n.return;while(n);return i}catch(r){return` -Error generating stack: `+r.message+` -`+r.stack}}var ht=Object.prototype.hasOwnProperty,R=e.unstable_scheduleCallback,Ue=e.unstable_cancelCallback,We=e.unstable_shouldYield,Xe=e.unstable_requestPaint,Ye=e.unstable_now,ft=e.unstable_getCurrentPriorityLevel,jt=e.unstable_ImmediatePriority,gt=e.unstable_UserBlockingPriority,Et=e.unstable_NormalPriority,A=e.unstable_LowPriority,W=e.unstable_IdlePriority,M=e.log,D=e.unstable_setDisableYieldValue,k=null,ne=null;function B(n){if(typeof M=="function"&&D(n),ne&&typeof ne.setStrictMode=="function")try{ne.setStrictMode(k,n)}catch{}}var te=Math.clz32?Math.clz32:E,j=Math.log,we=Math.LN2;function E(n){return n>>>=0,n===0?32:31-(j(n)/we|0)|0}var O=256,V=262144,Fe=4194304;function Be(n){var i=n&42;if(i!==0)return i;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function tt(n,i,a){var r=n.pendingLanes;if(r===0)return 0;var h=0,y=n.suspendedLanes,w=n.pingedLanes;n=n.warmLanes;var N=r&134217727;return N!==0?(r=N&~y,r!==0?h=Be(r):(w&=N,w!==0?h=Be(w):a||(a=N&~n,a!==0&&(h=Be(a))))):(N=r&~y,N!==0?h=Be(N):w!==0?h=Be(w):a||(a=r&~n,a!==0&&(h=Be(a)))),h===0?0:i!==0&&i!==h&&(i&y)===0&&(y=h&-h,a=i&-i,y>=a||y===32&&(a&4194048)!==0)?i:h}function St(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function _e(n,i){switch(n){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ot(){var n=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),n}function Se(n){for(var i=[],a=0;31>a;a++)i.push(n);return i}function he(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function dt(n,i,a,r,h,y){var w=n.pendingLanes;n.pendingLanes=a,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=a,n.entangledLanes&=a,n.errorRecoveryDisabledLanes&=a,n.shellSuspendCounter=0;var N=n.entanglements,U=n.expirationTimes,le=n.hiddenUpdates;for(a=w&~a;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var la=/[\n"\\]/g;function Qn(n){return n.replace(la,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Qo(n,i,a,r,h,y,w,N){n.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?n.type=w:n.removeAttribute("type"),i!=null?w==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+gi(i)):n.value!==""+gi(i)&&(n.value=""+gi(i)):w!=="submit"&&w!=="reset"||n.removeAttribute("value"),i!=null?aa(n,w,gi(i)):a!=null?aa(n,w,gi(a)):r!=null&&n.removeAttribute("value"),h==null&&y!=null&&(n.defaultChecked=!!y),h!=null&&(n.checked=h&&typeof h!="function"&&typeof h!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?n.name=""+gi(N):n.removeAttribute("name")}function mr(n,i,a,r,h,y,w,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(n.type=y),i!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||i!=null)){ns(n);return}a=a!=null?""+gi(a):"",i=i!=null?""+gi(i):a,N||i===n.value||(n.value=i),n.defaultValue=i}r=r??h,r=typeof r!="function"&&typeof r!="symbol"&&!!r,n.checked=N?n.checked:!!r,n.defaultChecked=!!r,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(n.name=w),ns(n)}function aa(n,i,a){i==="number"&&Wo(n.ownerDocument)===n||n.defaultValue===""+a||(n.defaultValue=""+a)}function Zo(n,i,a,r){if(n=n.options,i){i={};for(var h=0;h"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lt=!1;if(P)try{var wt={};Object.defineProperty(wt,"passive",{get:function(){lt=!0}}),window.addEventListener("test",wt,wt),window.removeEventListener("test",wt,wt)}catch{lt=!1}var Ge=null,Ft=null,pt=null;function Ht(){if(pt)return pt;var n,i=Ft,a=i.length,r,h="value"in Ge?Ge.value:Ge.textContent,y=h.length;for(n=0;n=is),kp=" ",Rp=!1;function zp(n,i){switch(n){case"keyup":return jx.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ip(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ca=!1;function Vx(n,i){switch(n){case"compositionend":return Ip(i);case"keypress":return i.which!==32?null:(Rp=!0,kp);case"textInput":return n=i.data,n===kp&&Rp?null:n;default:return null}}function Hx(n,i){if(ca)return n==="compositionend"||!du&&zp(n,i)?(n=Ht(),pt=Ft=Ge=null,ca=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:a,offset:i-n};n=r}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Op(a)}}function Hp(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Hp(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Gp(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=Wo(n.document);i instanceof n.HTMLIFrameElement;){try{var a=typeof i.contentWindow.location.href=="string"}catch{a=!1}if(a)n=i.contentWindow;else break;i=Wo(n.document)}return i}function hu(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var Wx=P&&"documentMode"in document&&11>=document.documentMode,ua=null,mu=null,ss=null,gu=!1;function $p(n,i,a){var r=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;gu||ua==null||ua!==Wo(r)||(r=ua,"selectionStart"in r&&hu(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ss&&as(ss,r)||(ss=r,r=oc(mu,"onSelect"),0>=w,h-=w,yo=1<<32-te(i)+h|a<Bt?(Jt=yt,yt=null):Jt=yt.sibling;var an=re(J,yt,ie[Bt],Ce);if(an===null){yt===null&&(yt=Jt);break}n&&yt&&an.alternate===null&&i(J,yt),H=y(an,H,Bt),ln===null?Tt=an:ln.sibling=an,ln=an,yt=Jt}if(Bt===ie.length)return a(J,yt),Xt&&Ro(J,Bt),Tt;if(yt===null){for(;BtBt?(Jt=yt,yt=null):Jt=yt.sibling;var wl=re(J,yt,an.value,Ce);if(wl===null){yt===null&&(yt=Jt);break}n&&yt&&wl.alternate===null&&i(J,yt),H=y(wl,H,Bt),ln===null?Tt=wl:ln.sibling=wl,ln=wl,yt=Jt}if(an.done)return a(J,yt),Xt&&Ro(J,Bt),Tt;if(yt===null){for(;!an.done;Bt++,an=ie.next())an=Ne(J,an.value,Ce),an!==null&&(H=y(an,H,Bt),ln===null?Tt=an:ln.sibling=an,ln=an);return Xt&&Ro(J,Bt),Tt}for(yt=r(yt);!an.done;Bt++,an=ie.next())an=pe(yt,J,Bt,an.value,Ce),an!==null&&(n&&an.alternate!==null&&yt.delete(an.key===null?Bt:an.key),H=y(an,H,Bt),ln===null?Tt=an:ln.sibling=an,ln=an);return n&&yt.forEach(function(y1){return i(J,y1)}),Xt&&Ro(J,Bt),Tt}function Sn(J,H,ie,Ce){if(typeof ie=="object"&&ie!==null&&ie.type===F&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case _:e:{for(var Tt=ie.key;H!==null;){if(H.key===Tt){if(Tt=ie.type,Tt===F){if(H.tag===7){a(J,H.sibling),Ce=h(H,ie.props.children),Ce.return=J,J=Ce;break e}}else if(H.elementType===Tt||typeof Tt=="object"&&Tt!==null&&Tt.$$typeof===Je&&Pl(Tt)===H.type){a(J,H.sibling),Ce=h(H,ie.props),ps(Ce,ie),Ce.return=J,J=Ce;break e}a(J,H);break}else i(J,H);H=H.sibling}ie.type===F?(Ce=Il(ie.props.children,J.mode,Ce,ie.key),Ce.return=J,J=Ce):(Ce=Sr(ie.type,ie.key,ie.props,null,J.mode,Ce),ps(Ce,ie),Ce.return=J,J=Ce)}return w(J);case T:e:{for(Tt=ie.key;H!==null;){if(H.key===Tt)if(H.tag===4&&H.stateNode.containerInfo===ie.containerInfo&&H.stateNode.implementation===ie.implementation){a(J,H.sibling),Ce=h(H,ie.children||[]),Ce.return=J,J=Ce;break e}else{a(J,H);break}else i(J,H);H=H.sibling}Ce=Tu(ie,J.mode,Ce),Ce.return=J,J=Ce}return w(J);case Je:return ie=Pl(ie),Sn(J,H,ie,Ce)}if(xt(ie))return rt(J,H,ie,Ce);if(Ke(ie)){if(Tt=Ke(ie),typeof Tt!="function")throw Error(l(150));return ie=Tt.call(ie),Nt(J,H,ie,Ce)}if(typeof ie.then=="function")return Sn(J,H,Ar(ie),Ce);if(ie.$$typeof===oe)return Sn(J,H,Cr(J,ie),Ce);Mr(J,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,H!==null&&H.tag===6?(a(J,H.sibling),Ce=h(H,ie),Ce.return=J,J=Ce):(a(J,H),Ce=wu(ie,J.mode,Ce),Ce.return=J,J=Ce),w(J)):a(J,H)}return function(J,H,ie,Ce){try{fs=0;var Tt=Sn(J,H,ie,Ce);return Sa=null,Tt}catch(yt){if(yt===ba||yt===_r)throw yt;var ln=ki(29,yt,null,J.mode);return ln.lanes=Ce,ln.return=J,ln}}}var jl=hh(!0),mh=hh(!1),ll=!1;function Lu(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Uu(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function al(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function sl(n,i,a){var r=n.updateQueue;if(r===null)return null;if(r=r.shared,(cn&2)!==0){var h=r.pending;return h===null?i.next=i:(i.next=h.next,h.next=i),r.pending=i,i=br(n),Qp(n,null,a),i}return xr(n,r,i,a),br(n)}function hs(n,i,a){if(i=i.updateQueue,i!==null&&(i=i.shared,(a&4194048)!==0)){var r=i.lanes;r&=n.pendingLanes,a|=r,i.lanes=a,vt(n,a)}}function Fu(n,i){var a=n.updateQueue,r=n.alternate;if(r!==null&&(r=r.updateQueue,a===r)){var h=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var w={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?h=y=w:y=y.next=w,a=a.next}while(a!==null);y===null?h=y=i:y=y.next=i}else h=y=i;a={baseState:r.baseState,firstBaseUpdate:h,lastBaseUpdate:y,shared:r.shared,callbacks:r.callbacks},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=i:n.next=i,a.lastBaseUpdate=i}var Pu=!1;function ms(){if(Pu){var n=xa;if(n!==null)throw n}}function gs(n,i,a,r){Pu=!1;var h=n.updateQueue;ll=!1;var y=h.firstBaseUpdate,w=h.lastBaseUpdate,N=h.shared.pending;if(N!==null){h.shared.pending=null;var U=N,le=U.next;U.next=null,w===null?y=le:w.next=le,w=U;var xe=n.alternate;xe!==null&&(xe=xe.updateQueue,N=xe.lastBaseUpdate,N!==w&&(N===null?xe.firstBaseUpdate=le:N.next=le,xe.lastBaseUpdate=U))}if(y!==null){var Ne=h.baseState;w=0,xe=le=U=null,N=y;do{var re=N.lane&-536870913,pe=re!==N.lane;if(pe?(Yt&re)===re:(r&re)===re){re!==0&&re===va&&(Pu=!0),xe!==null&&(xe=xe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var rt=n,Nt=N;re=i;var Sn=a;switch(Nt.tag){case 1:if(rt=Nt.payload,typeof rt=="function"){Ne=rt.call(Sn,Ne,re);break e}Ne=rt;break e;case 3:rt.flags=rt.flags&-65537|128;case 0:if(rt=Nt.payload,re=typeof rt=="function"?rt.call(Sn,Ne,re):rt,re==null)break e;Ne=b({},Ne,re);break e;case 2:ll=!0}}re=N.callback,re!==null&&(n.flags|=64,pe&&(n.flags|=8192),pe=h.callbacks,pe===null?h.callbacks=[re]:pe.push(re))}else pe={lane:re,tag:N.tag,payload:N.payload,callback:N.callback,next:null},xe===null?(le=xe=pe,U=Ne):xe=xe.next=pe,w|=re;if(N=N.next,N===null){if(N=h.shared.pending,N===null)break;pe=N,N=pe.next,pe.next=null,h.lastBaseUpdate=pe,h.shared.pending=null}}while(!0);xe===null&&(U=Ne),h.baseState=U,h.firstBaseUpdate=le,h.lastBaseUpdate=xe,y===null&&(h.shared.lanes=0),fl|=w,n.lanes=w,n.memoizedState=Ne}}function gh(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function yh(n,i){var a=n.callbacks;if(a!==null)for(n.callbacks=null,n=0;ny?y:8;var w=K.T,N={};K.T=N,id(n,!1,i,a);try{var U=h(),le=K.S;if(le!==null&&le(N,U),U!==null&&typeof U=="object"&&typeof U.then=="function"){var xe=ab(U,r);xs(n,i,xe,Li(n))}else xs(n,i,r,Li(n))}catch(Ne){xs(n,i,{then:function(){},status:"rejected",reason:Ne},Li())}finally{ze.p=y,w!==null&&N.types!==null&&(w.types=N.types),K.T=w}}function fb(){}function td(n,i,a,r){if(n.tag!==5)throw Error(l(476));var h=Kh(n).queue;Jh(n,h,i,Le,a===null?fb:function(){return Xh(n),a(r)})}function Kh(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Le,baseState:Le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:Le},next:null};var a={};return i.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:a},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function Xh(n){var i=Kh(n);i.next===null&&(i=n.alternate.memoizedState),xs(n,i.next.queue,{},Li())}function nd(){return li(Us)}function Wh(){return jn().memoizedState}function Qh(){return jn().memoizedState}function pb(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var a=Li();n=al(a);var r=sl(i,n,a);r!==null&&(_i(r,i,a),hs(r,i,a)),i={cache:Ru()},n.payload=i;return}i=i.return}}function hb(n,i,a){var r=Li();a={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Br(n)?em(i,a):(a=bu(n,i,a,r),a!==null&&(_i(a,n,r),tm(a,i,r)))}function Zh(n,i,a){var r=Li();xs(n,i,a,r)}function xs(n,i,a,r){var h={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Br(n))em(i,h);else{var y=n.alternate;if(n.lanes===0&&(y===null||y.lanes===0)&&(y=i.lastRenderedReducer,y!==null))try{var w=i.lastRenderedState,N=y(w,a);if(h.hasEagerState=!0,h.eagerState=N,Mi(N,w))return xr(n,i,h,0),wn===null&&vr(),!1}catch{}if(a=bu(n,i,h,r),a!==null)return _i(a,n,r),tm(a,i,r),!0}return!1}function id(n,i,a,r){if(r={lane:2,revertLane:Ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Br(n)){if(i)throw Error(l(479))}else i=bu(n,a,r,2),i!==null&&_i(i,n,2)}function Br(n){var i=n.alternate;return n===Lt||i!==null&&i===Lt}function em(n,i){Ta=zr=!0;var a=n.pending;a===null?i.next=i:(i.next=a.next,a.next=i),n.pending=i}function tm(n,i,a){if((a&4194048)!==0){var r=i.lanes;r&=n.pendingLanes,a|=r,i.lanes=a,vt(n,a)}}var bs={readContext:li,use:Lr,useCallback:Ln,useContext:Ln,useEffect:Ln,useImperativeHandle:Ln,useLayoutEffect:Ln,useInsertionEffect:Ln,useMemo:Ln,useReducer:Ln,useRef:Ln,useState:Ln,useDebugValue:Ln,useDeferredValue:Ln,useTransition:Ln,useSyncExternalStore:Ln,useId:Ln,useHostTransitionStatus:Ln,useFormState:Ln,useActionState:Ln,useOptimistic:Ln,useMemoCache:Ln,useCacheRefresh:Ln};bs.useEffectEvent=Ln;var nm={readContext:li,use:Lr,useCallback:function(n,i){return vi().memoizedState=[n,i===void 0?null:i],n},useContext:li,useEffect:Bh,useImperativeHandle:function(n,i,a){a=a!=null?a.concat([n]):null,Fr(4194308,4,Hh.bind(null,i,n),a)},useLayoutEffect:function(n,i){return Fr(4194308,4,n,i)},useInsertionEffect:function(n,i){Fr(4,2,n,i)},useMemo:function(n,i){var a=vi();i=i===void 0?null:i;var r=n();if(Ol){B(!0);try{n()}finally{B(!1)}}return a.memoizedState=[r,i],r},useReducer:function(n,i,a){var r=vi();if(a!==void 0){var h=a(i);if(Ol){B(!0);try{a(i)}finally{B(!1)}}}else h=i;return r.memoizedState=r.baseState=h,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:h},r.queue=n,n=n.dispatch=hb.bind(null,Lt,n),[r.memoizedState,n]},useRef:function(n){var i=vi();return n={current:n},i.memoizedState=n},useState:function(n){n=Xu(n);var i=n.queue,a=Zh.bind(null,Lt,i);return i.dispatch=a,[n.memoizedState,a]},useDebugValue:Zu,useDeferredValue:function(n,i){var a=vi();return ed(a,n,i)},useTransition:function(){var n=Xu(!1);return n=Jh.bind(null,Lt,n.queue,!0,!1),vi().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,a){var r=Lt,h=vi();if(Xt){if(a===void 0)throw Error(l(407));a=a()}else{if(a=i(),wn===null)throw Error(l(349));(Yt&127)!==0||Th(r,i,a)}h.memoizedState=a;var y={value:a,getSnapshot:i};return h.queue=y,Bh(Eh.bind(null,r,y,n),[n]),r.flags|=2048,Ea(9,{destroy:void 0},Ch.bind(null,r,y,a,i),null),a},useId:function(){var n=vi(),i=wn.identifierPrefix;if(Xt){var a=vo,r=yo;a=(r&~(1<<32-te(r)-1)).toString(32)+a,i="_"+i+"R_"+a,a=Ir++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof r.is=="string"?w.createElement("select",{is:r.is}):w.createElement("select"),r.multiple?y.multiple=!0:r.size&&(y.size=r.size);break;default:y=typeof r.is=="string"?w.createElement(h,{is:r.is}):w.createElement(h)}}y[Zt]=i,y[Pn]=r;e:for(w=i.child;w!==null;){if(w.tag===5||w.tag===6)y.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===i)break e;for(;w.sibling===null;){if(w.return===null||w.return===i)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}i.stateNode=y;e:switch(si(y,h,r),h){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&Fo(i)}}return Nn(i),yd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,a),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==r&&Fo(i);else{if(typeof r!="string"&&i.stateNode===null)throw Error(l(166));if(n=et.current,ga(i)){if(n=i.stateNode,a=i.memoizedProps,r=null,h=oi,h!==null)switch(h.tag){case 27:case 5:r=h.memoizedProps}n[Zt]=i,n=!!(n.nodeValue===a||r!==null&&r.suppressHydrationWarning===!0||S0(n.nodeValue,a)),n||il(i,!0)}else n=lc(n).createTextNode(r),n[Zt]=i,i.stateNode=n}return Nn(i),null;case 31:if(a=i.memoizedState,n===null||n.memoizedState!==null){if(r=ga(i),a!==null){if(n===null){if(!r)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Zt]=i}else Dl(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Nn(i),n=!1}else a=Nu(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=a),n=!0;if(!n)return i.flags&256?(zi(i),i):(zi(i),null);if((i.flags&128)!==0)throw Error(l(558))}return Nn(i),null;case 13:if(r=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(h=ga(i),r!==null&&r.dehydrated!==null){if(n===null){if(!h)throw Error(l(318));if(h=i.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(l(317));h[Zt]=i}else Dl(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Nn(i),h=!1}else h=Nu(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=h),h=!0;if(!h)return i.flags&256?(zi(i),i):(zi(i),null)}return zi(i),(i.flags&128)!==0?(i.lanes=a,i):(a=r!==null,n=n!==null&&n.memoizedState!==null,a&&(r=i.child,h=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(h=r.alternate.memoizedState.cachePool.pool),y=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(y=r.memoizedState.cachePool.pool),y!==h&&(r.flags|=2048)),a!==n&&a&&(i.child.flags|=8192),Gr(i,i.updateQueue),Nn(i),null);case 4:return se(),n===null&&Bd(i.stateNode.containerInfo),Nn(i),null;case 10:return Io(i.type),Nn(i),null;case 19:if(X(Bn),r=i.memoizedState,r===null)return Nn(i),null;if(h=(i.flags&128)!==0,y=r.rendering,y===null)if(h)ws(r,!1);else{if(Un!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(y=Rr(n),y!==null){for(i.flags|=128,ws(r,!1),n=y.updateQueue,i.updateQueue=n,Gr(i,n),i.subtreeFlags=0,n=a,a=i.child;a!==null;)Zp(a,n),a=a.sibling;return Ee(Bn,Bn.current&1|2),Xt&&Ro(i,r.treeForkCount),i.child}n=n.sibling}r.tail!==null&&Ye()>Kr&&(i.flags|=128,h=!0,ws(r,!1),i.lanes=4194304)}else{if(!h)if(n=Rr(y),n!==null){if(i.flags|=128,h=!0,n=n.updateQueue,i.updateQueue=n,Gr(i,n),ws(r,!0),r.tail===null&&r.tailMode==="hidden"&&!y.alternate&&!Xt)return Nn(i),null}else 2*Ye()-r.renderingStartTime>Kr&&a!==536870912&&(i.flags|=128,h=!0,ws(r,!1),i.lanes=4194304);r.isBackwards?(y.sibling=i.child,i.child=y):(n=r.last,n!==null?n.sibling=y:i.child=y,r.last=y)}return r.tail!==null?(n=r.tail,r.rendering=n,r.tail=n.sibling,r.renderingStartTime=Ye(),n.sibling=null,a=Bn.current,Ee(Bn,h?a&1|2:a&1),Xt&&Ro(i,r.treeForkCount),n):(Nn(i),null);case 22:case 23:return zi(i),ju(),r=i.memoizedState!==null,n!==null?n.memoizedState!==null!==r&&(i.flags|=8192):r&&(i.flags|=8192),r?(a&536870912)!==0&&(i.flags&128)===0&&(Nn(i),i.subtreeFlags&6&&(i.flags|=8192)):Nn(i),a=i.updateQueue,a!==null&&Gr(i,a.retryQueue),a=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(a=n.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==a&&(i.flags|=2048),n!==null&&X(Fl),null;case 24:return a=null,n!==null&&(a=n.memoizedState.cache),i.memoizedState.cache!==a&&(i.flags|=2048),Io(Gn),Nn(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function xb(n,i){switch(Eu(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return Io(Gn),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return me(i),null;case 31:if(i.memoizedState!==null){if(zi(i),i.alternate===null)throw Error(l(340));Dl()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(zi(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Dl()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return X(Bn),null;case 4:return se(),null;case 10:return Io(i.type),null;case 22:case 23:return zi(i),ju(),n!==null&&X(Fl),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return Io(Gn),null;case 25:return null;default:return null}}function _m(n,i){switch(Eu(i),i.tag){case 3:Io(Gn),se();break;case 26:case 27:case 5:me(i);break;case 4:se();break;case 31:i.memoizedState!==null&&zi(i);break;case 13:zi(i);break;case 19:X(Bn);break;case 10:Io(i.type);break;case 22:case 23:zi(i),ju(),n!==null&&X(Fl);break;case 24:Io(Gn)}}function Ts(n,i){try{var a=i.updateQueue,r=a!==null?a.lastEffect:null;if(r!==null){var h=r.next;a=h;do{if((a.tag&n)===n){r=void 0;var y=a.create,w=a.inst;r=y(),w.destroy=r}a=a.next}while(a!==h)}}catch(N){gn(i,i.return,N)}}function ul(n,i,a){try{var r=i.updateQueue,h=r!==null?r.lastEffect:null;if(h!==null){var y=h.next;r=y;do{if((r.tag&n)===n){var w=r.inst,N=w.destroy;if(N!==void 0){w.destroy=void 0,h=i;var U=a,le=N;try{le()}catch(xe){gn(h,U,xe)}}}r=r.next}while(r!==y)}}catch(xe){gn(i,i.return,xe)}}function Nm(n){var i=n.updateQueue;if(i!==null){var a=n.stateNode;try{yh(i,a)}catch(r){gn(n,n.return,r)}}}function Am(n,i,a){a.props=Vl(n.type,n.memoizedProps),a.state=n.memoizedState;try{a.componentWillUnmount()}catch(r){gn(n,i,r)}}function Cs(n,i){try{var a=n.ref;if(a!==null){switch(n.tag){case 26:case 27:case 5:var r=n.stateNode;break;case 30:r=n.stateNode;break;default:r=n.stateNode}typeof a=="function"?n.refCleanup=a(r):a.current=r}}catch(h){gn(n,i,h)}}function xo(n,i){var a=n.ref,r=n.refCleanup;if(a!==null)if(typeof r=="function")try{r()}catch(h){gn(n,i,h)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(h){gn(n,i,h)}else a.current=null}function Mm(n){var i=n.type,a=n.memoizedProps,r=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":a.autoFocus&&r.focus();break e;case"img":a.src?r.src=a.src:a.srcSet&&(r.srcset=a.srcSet)}}catch(h){gn(n,n.return,h)}}function vd(n,i,a){try{var r=n.stateNode;Ob(r,n.type,a,i),r[Pn]=i}catch(h){gn(n,n.return,h)}}function km(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&yl(n.type)||n.tag===4}function xd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||km(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&yl(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function bd(n,i,a){var r=n.tag;if(r===5||r===6)n=n.stateNode,i?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(n,i):(i=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,i.appendChild(n),a=a._reactRootContainer,a!=null||i.onclick!==null||(i.onclick=ot));else if(r!==4&&(r===27&&yl(n.type)&&(a=n.stateNode,i=null),n=n.child,n!==null))for(bd(n,i,a),n=n.sibling;n!==null;)bd(n,i,a),n=n.sibling}function $r(n,i,a){var r=n.tag;if(r===5||r===6)n=n.stateNode,i?a.insertBefore(n,i):a.appendChild(n);else if(r!==4&&(r===27&&yl(n.type)&&(a=n.stateNode),n=n.child,n!==null))for($r(n,i,a),n=n.sibling;n!==null;)$r(n,i,a),n=n.sibling}function Rm(n){var i=n.stateNode,a=n.memoizedProps;try{for(var r=n.type,h=i.attributes;h.length;)i.removeAttributeNode(h[0]);si(i,r,a),i[Zt]=n,i[Pn]=a}catch(y){gn(n,n.return,y)}}var Po=!1,Yn=!1,Sd=!1,zm=typeof WeakSet=="function"?WeakSet:Set,Zn=null;function bb(n,i){if(n=n.containerInfo,Vd=fc,n=Gp(n),hu(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var r=a.getSelection&&a.getSelection();if(r&&r.rangeCount!==0){a=r.anchorNode;var h=r.anchorOffset,y=r.focusNode;r=r.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var w=0,N=-1,U=-1,le=0,xe=0,Ne=n,re=null;t:for(;;){for(var pe;Ne!==a||h!==0&&Ne.nodeType!==3||(N=w+h),Ne!==y||r!==0&&Ne.nodeType!==3||(U=w+r),Ne.nodeType===3&&(w+=Ne.nodeValue.length),(pe=Ne.firstChild)!==null;)re=Ne,Ne=pe;for(;;){if(Ne===n)break t;if(re===a&&++le===h&&(N=w),re===y&&++xe===r&&(U=w),(pe=Ne.nextSibling)!==null)break;Ne=re,re=Ne.parentNode}Ne=pe}a=N===-1||U===-1?null:{start:N,end:U}}else a=null}a=a||{start:0,end:0}}else a=null;for(Hd={focusedElem:n,selectionRange:a},fc=!1,Zn=i;Zn!==null;)if(i=Zn,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Zn=n;else for(;Zn!==null;){switch(i=Zn,y=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(a=0;a title"))),si(y,r,a),y[Zt]=n,kn(y),r=y;break e;case"link":var w=P0("link","href",h).get(r+(a.href||""));if(w){for(var N=0;NSn&&(w=Sn,Sn=Nt,Nt=w);var J=Vp(N,Nt),H=Vp(N,Sn);if(J&&H&&(pe.rangeCount!==1||pe.anchorNode!==J.node||pe.anchorOffset!==J.offset||pe.focusNode!==H.node||pe.focusOffset!==H.offset)){var ie=Ne.createRange();ie.setStart(J.node,J.offset),pe.removeAllRanges(),Nt>Sn?(pe.addRange(ie),pe.extend(H.node,H.offset)):(ie.setEnd(H.node,H.offset),pe.addRange(ie))}}}}for(Ne=[],pe=N;pe=pe.parentNode;)pe.nodeType===1&&Ne.push({element:pe,left:pe.scrollLeft,top:pe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,K.T=null,a=Ad,Ad=null;var y=hl,w=Ho;if(Xn=0,ka=hl=null,Ho=0,(cn&6)!==0)throw Error(l(331));var N=cn;if(cn|=4,Hm(y.current),jm(y,y.current,w,a),cn=N,ks(0,!1),ne&&typeof ne.onPostCommitFiberRoot=="function")try{ne.onPostCommitFiberRoot(k,y)}catch{}return!0}finally{ze.p=h,K.T=r,s0(n,i)}}function c0(n,i,a){i=Gi(a,i),i=sd(n.stateNode,i,2),n=sl(n,i,2),n!==null&&(he(n,2),bo(n))}function gn(n,i,a){if(n.tag===3)c0(n,n,a);else for(;i!==null;){if(i.tag===3){c0(i,n,a);break}else if(i.tag===1){var r=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(pl===null||!pl.has(r))){n=Gi(a,n),a=um(2),r=sl(i,a,2),r!==null&&(dm(a,r,i,n),he(r,2),bo(r));break}}i=i.return}}function zd(n,i,a){var r=n.pingCache;if(r===null){r=n.pingCache=new Tb;var h=new Set;r.set(i,h)}else h=r.get(i),h===void 0&&(h=new Set,r.set(i,h));h.has(a)||(Cd=!0,h.add(a),n=Ab.bind(null,n,i,a),i.then(n,n))}function Ab(n,i,a){var r=n.pingCache;r!==null&&r.delete(i),n.pingedLanes|=n.suspendedLanes&a,n.warmLanes&=~a,wn===n&&(Yt&a)===a&&(Un===4||Un===3&&(Yt&62914560)===Yt&&300>Ye()-Jr?(cn&2)===0&&Ra(n,0):Ed|=a,Ma===Yt&&(Ma=0)),bo(n)}function u0(n,i){i===0&&(i=Ot()),n=zl(n,i),n!==null&&(he(n,i),bo(n))}function Mb(n){var i=n.memoizedState,a=0;i!==null&&(a=i.retryLane),u0(n,a)}function kb(n,i){var a=0;switch(n.tag){case 31:case 13:var r=n.stateNode,h=n.memoizedState;h!==null&&(a=h.retryLane);break;case 19:r=n.stateNode;break;case 22:r=n.stateNode._retryCache;break;default:throw Error(l(314))}r!==null&&r.delete(i),u0(n,a)}function Rb(n,i){return R(n,i)}var tc=null,Ia=null,Id=!1,nc=!1,Dd=!1,gl=0;function bo(n){n!==Ia&&n.next===null&&(Ia===null?tc=Ia=n:Ia=Ia.next=n),nc=!0,Id||(Id=!0,Ib())}function ks(n,i){if(!Dd&&nc){Dd=!0;do for(var a=!1,r=tc;r!==null;){if(n!==0){var h=r.pendingLanes;if(h===0)var y=0;else{var w=r.suspendedLanes,N=r.pingedLanes;y=(1<<31-te(42|n)+1)-1,y&=h&~(w&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,h0(r,y))}else y=Yt,y=tt(r,r===wn?y:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(y&3)===0||St(r,y)||(a=!0,h0(r,y));r=r.next}while(a);Dd=!1}}function zb(){d0()}function d0(){nc=Id=!1;var n=0;gl!==0&&Hb()&&(n=gl);for(var i=Ye(),a=null,r=tc;r!==null;){var h=r.next,y=f0(r,i);y===0?(r.next=null,a===null?tc=h:a.next=h,h===null&&(Ia=a)):(a=r,(n!==0||(y&3)!==0)&&(nc=!0)),r=h}Xn!==0&&Xn!==5||ks(n),gl!==0&&(gl=0)}function f0(n,i){for(var a=n.suspendedLanes,r=n.pingedLanes,h=n.expirationTimes,y=n.pendingLanes&-62914561;0N)break;var xe=U.transferSize,Ne=U.initiatorType;xe&&w0(Ne)&&(U=U.responseEnd,w+=xe*(U"u"?null:document;function D0(n,i,a){var r=Da;if(r&&typeof i=="string"&&i){var h=Qn(i);h='link[rel="'+n+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),I0.has(h)||(I0.add(h),n={rel:n,crossOrigin:a,href:i},r.querySelector(h)===null&&(i=r.createElement("link"),si(i,"link",n),kn(i),r.head.appendChild(i)))}}function Qb(n){Go.D(n),D0("dns-prefetch",n,null)}function Zb(n,i){Go.C(n,i),D0("preconnect",n,i)}function e1(n,i,a){Go.L(n,i,a);var r=Da;if(r&&n&&i){var h='link[rel="preload"][as="'+Qn(i)+'"]';i==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+Qn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+Qn(a.imageSizes)+'"]')):h+='[href="'+Qn(n)+'"]';var y=h;switch(i){case"style":y=La(n);break;case"script":y=Ua(n)}Xi.has(y)||(n=b({rel:"preload",href:i==="image"&&a&&a.imageSrcSet?void 0:n,as:i},a),Xi.set(y,n),r.querySelector(h)!==null||i==="style"&&r.querySelector(Ds(y))||i==="script"&&r.querySelector(Ls(y))||(i=r.createElement("link"),si(i,"link",n),kn(i),r.head.appendChild(i)))}}function t1(n,i){Go.m(n,i);var a=Da;if(a&&n){var r=i&&typeof i.as=="string"?i.as:"script",h='link[rel="modulepreload"][as="'+Qn(r)+'"][href="'+Qn(n)+'"]',y=h;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Ua(n)}if(!Xi.has(y)&&(n=b({rel:"modulepreload",href:n},i),Xi.set(y,n),a.querySelector(h)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ls(y)))return}r=a.createElement("link"),si(r,"link",n),kn(r),a.head.appendChild(r)}}}function n1(n,i,a){Go.S(n,i,a);var r=Da;if(r&&n){var h=Ni(r).hoistableStyles,y=La(n);i=i||"default";var w=h.get(y);if(!w){var N={loading:0,preload:null};if(w=r.querySelector(Ds(y)))N.loading=5;else{n=b({rel:"stylesheet",href:n,"data-precedence":i},a),(a=Xi.get(y))&&Xd(n,a);var U=w=r.createElement("link");kn(U),si(U,"link",n),U._p=new Promise(function(le,xe){U.onload=le,U.onerror=xe}),U.addEventListener("load",function(){N.loading|=1}),U.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sc(w,i,r)}w={type:"stylesheet",instance:w,count:1,state:N},h.set(y,w)}}}function i1(n,i){Go.X(n,i);var a=Da;if(a&&n){var r=Ni(a).hoistableScripts,h=Ua(n),y=r.get(h);y||(y=a.querySelector(Ls(h)),y||(n=b({src:n,async:!0},i),(i=Xi.get(h))&&Wd(n,i),y=a.createElement("script"),kn(y),si(y,"link",n),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},r.set(h,y))}}function o1(n,i){Go.M(n,i);var a=Da;if(a&&n){var r=Ni(a).hoistableScripts,h=Ua(n),y=r.get(h);y||(y=a.querySelector(Ls(h)),y||(n=b({src:n,async:!0,type:"module"},i),(i=Xi.get(h))&&Wd(n,i),y=a.createElement("script"),kn(y),si(y,"link",n),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},r.set(h,y))}}function L0(n,i,a,r){var h=(h=et.current)?ac(h):null;if(!h)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(i=La(a.href),a=Ni(h).hoistableStyles,r=a.get(i),r||(r={type:"style",instance:null,count:0,state:null},a.set(i,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){n=La(a.href);var y=Ni(h).hoistableStyles,w=y.get(n);if(w||(h=h.ownerDocument||h,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(n,w),(y=h.querySelector(Ds(n)))&&!y._p&&(w.instance=y,w.state.loading=5),Xi.has(n)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Xi.set(n,a),y||l1(h,n,a,w.state))),i&&r===null)throw Error(l(528,""));return w}if(i&&r!==null)throw Error(l(529,""));return null;case"script":return i=a.async,a=a.src,typeof a=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Ua(a),a=Ni(h).hoistableScripts,r=a.get(i),r||(r={type:"script",instance:null,count:0,state:null},a.set(i,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function La(n){return'href="'+Qn(n)+'"'}function Ds(n){return'link[rel="stylesheet"]['+n+"]"}function U0(n){return b({},n,{"data-precedence":n.precedence,precedence:null})}function l1(n,i,a,r){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?r.loading=1:(i=n.createElement("link"),r.preload=i,i.addEventListener("load",function(){return r.loading|=1}),i.addEventListener("error",function(){return r.loading|=2}),si(i,"link",a),kn(i),n.head.appendChild(i))}function Ua(n){return'[src="'+Qn(n)+'"]'}function Ls(n){return"script[async]"+n}function F0(n,i,a){if(i.count++,i.instance===null)switch(i.type){case"style":var r=n.querySelector('style[data-href~="'+Qn(a.href)+'"]');if(r)return i.instance=r,kn(r),r;var h=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return r=(n.ownerDocument||n).createElement("style"),kn(r),si(r,"style",h),sc(r,a.precedence,n),i.instance=r;case"stylesheet":h=La(a.href);var y=n.querySelector(Ds(h));if(y)return i.state.loading|=4,i.instance=y,kn(y),y;r=U0(a),(h=Xi.get(h))&&Xd(r,h),y=(n.ownerDocument||n).createElement("link"),kn(y);var w=y;return w._p=new Promise(function(N,U){w.onload=N,w.onerror=U}),si(y,"link",r),i.state.loading|=4,sc(y,a.precedence,n),i.instance=y;case"script":return y=Ua(a.src),(h=n.querySelector(Ls(y)))?(i.instance=h,kn(h),h):(r=a,(h=Xi.get(y))&&(r=b({},a),Wd(r,h)),n=n.ownerDocument||n,h=n.createElement("script"),kn(h),si(h,"link",r),n.head.appendChild(h),i.instance=h);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(r=i.instance,i.state.loading|=4,sc(r,a.precedence,n));return i.instance}function sc(n,i,a){for(var r=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=r.length?r[r.length-1]:null,y=h,w=0;w title"):null)}function a1(n,i,a){if(a===1||i.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(n=i.disabled,typeof i.precedence=="string"&&n==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function j0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function s1(n,i,a,r){if(a.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var h=La(r.href),y=i.querySelector(Ds(h));if(y){i=y._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=cc.bind(n),i.then(n,n)),a.state.loading|=4,a.instance=y,kn(y);return}y=i.ownerDocument||i,r=U0(r),(h=Xi.get(h))&&Xd(r,h),y=y.createElement("link"),kn(y);var w=y;w._p=new Promise(function(N,U){w.onload=N,w.onerror=U}),si(y,"link",r),a.instance=y}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(a,i),(i=a.state.preload)&&(a.state.loading&3)===0&&(n.count++,a=cc.bind(n),i.addEventListener("load",a),i.addEventListener("error",a))}}var Qd=0;function r1(n,i){return n.stylesheets&&n.count===0&&dc(n,n.stylesheets),0Qd?50:800)+i);return n.unsuspend=a,function(){n.unsuspend=null,clearTimeout(r),clearTimeout(h)}}:null}function cc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)dc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var uc=null;function dc(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,uc=new Map,i.forEach(c1,n),uc=null,cc.call(n))}function c1(n,i){if(!(i.state.loading&4)){var a=uc.get(n);if(a)var r=a.get(null);else{a=new Map,uc.set(n,a);for(var h=n.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),rf.exports=E1(),rf.exports}var N1=_1();const A1=rv(N1),M1="modulepreload",k1=function(e){return"/"+e},ug={},Sf=function(t,o,l){let s=Promise.resolve();if(o&&o.length>0){let v=function(m){return Promise.all(m.map(x=>Promise.resolve(x).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),g=f?.nonce||f?.getAttribute("nonce");s=v(o.map(m=>{if(m=k1(m),m in ug)return;ug[m]=!0;const x=m.endsWith(".css"),b=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${b}`))return;const S=document.createElement("link");if(S.rel=x?"stylesheet":M1,x||(S.as="script"),S.crossOrigin="",S.href=m,g&&S.setAttribute("nonce",g),document.head.appendChild(S),x)return new Promise((_,T)=>{S.addEventListener("load",_),S.addEventListener("error",()=>T(new Error(`Unable to preload CSS for ${m}`)))})}))}function d(f){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=f,window.dispatchEvent(g),!g.defaultPrevented)throw f}return s.then(f=>{for(const g of f||[])g.status==="rejected"&&d(g.reason);return t().catch(d)})};const R1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),z1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,o,l)=>l?l.toUpperCase():o.toLowerCase()),dg=e=>{const t=z1(e);return t.charAt(0).toUpperCase()+t.slice(1)},cv=(...e)=>e.filter((t,o,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===o).join(" ").trim(),I1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var D1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const L1=Z.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:s="",children:d,iconNode:f,...g},v)=>Z.createElement("svg",{ref:v,...D1,width:t,height:t,stroke:e,strokeWidth:l?Number(o)*24/Number(t):o,className:cv("lucide",s),...!d&&!I1(g)&&{"aria-hidden":"true"},...g},[...f.map(([m,x])=>Z.createElement(m,x)),...Array.isArray(d)?d:[d]]));const ct=(e,t)=>{const o=Z.forwardRef(({className:l,...s},d)=>Z.createElement(L1,{ref:d,iconNode:t,className:cv(`lucide-${R1(dg(e))}`,`lucide-${e}`,l),...s}));return o.displayName=dg(e),o};const U1=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],F1=ct("activity",U1);const P1=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],fg=ct("align-vertical-justify-center",P1);const B1=[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]],j1=ct("align-vertical-justify-end",B1);const O1=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]],V1=ct("align-vertical-justify-start",O1);const H1=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],ff=ct("bold",H1);const G1=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],$1=ct("check",G1);const q1=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rr=ct("chevron-down",q1);const Y1=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],wf=ct("chevron-up",Y1);const J1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],K1=ct("circle-alert",J1);const X1=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],W1=ct("clipboard",X1);const Q1=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Z1=ct("copy",Q1);const eS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],tS=ct("disc",eS);const nS=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],iS=ct("download",nS);const oS=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],qs=ct("eye-off",oS);const lS=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ys=ct("eye",lS);const aS=[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]],sS=ct("fast-forward",aS);const rS=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],cS=ct("file-down",rS);const uS=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Pc=ct("file-text",uS);const dS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],uv=ct("film",dS);const fS=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],pS=ct("folder",fS);const hS=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],xc=ct("grip-horizontal",hS);const mS=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],gS=ct("grip-vertical",mS);const yS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],pg=ct("image",yS);const vS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],xS=ct("info",vS);const bS=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],pf=ct("italic",bS);const SS=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],wS=ct("key",SS);const TS=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Bc=ct("keyboard",TS);const CS=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M11 19H3",key:"zflm78"}],["path",{d:"M21 16V5",key:"yxg4q8"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],jc=ct("list-music",CS);const ES=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],hg=ct("loader-circle",ES);const _S=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],tr=ct("maximize",_S);const NS=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],mg=ct("minimize",NS);const AS=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Oa=ct("music",AS);const MS=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],kS=ct("palette",MS);const RS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],zS=ct("panels-top-left",RS);const IS=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],dv=ct("pause",IS);const DS=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Tf=ct("play",DS);const LS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fv=ct("plus",LS);const US=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],FS=ct("redo-2",US);const PS=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]],BS=ct("repeat-1",PS);const jS=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],gg=ct("repeat",jS);const OS=[["path",{d:"M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z",key:"2a1g8i"}],["path",{d:"M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z",key:"rg3s36"}]],VS=ct("rewind",OS);const HS=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Cf=ct("rotate-ccw",HS);const GS=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],$S=ct("scissors",GS);const qS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],YS=ct("search",qS);const JS=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Js=ct("settings",JS);const KS=[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]],XS=ct("shuffle",KS);const WS=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],QS=ct("skip-back",WS);const ZS=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],ew=ct("skip-forward",ZS);const tw=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Ef=ct("sparkles",tw);const nw=[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]],iw=ct("split",nw);const ow=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],_f=ct("square",ow);const lw=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],aw=ct("strikethrough",lw);const sw=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],$a=ct("trash-2",sw);const rw=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],cw=ct("triangle-alert",rw);const uw=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Cl=ct("type",uw);const dw=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],fw=ct("underline",dw);const pw=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],hw=ct("undo-2",pw);const mw=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ro=ct("upload",mw);const gw=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],yw=ct("user",gw);const vw=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],nr=ct("video",vw);const xw=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Tl=ct("volume-2",xw);const bw=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Pa=ct("volume-x",bw);const Sw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bi=ct("x",Sw);const ww=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Tw=ct("zoom-in",ww);const Cw=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Ew=ct("zoom-out",Cw);var ri=(e=>(e.PLAYER="PLAYER",e.EDITOR="EDITOR",e))(ri||{});const tp=e=>{const t=/([\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF])\s+([\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF])/g;return e.replace(t,"$1$2")},Ks=e=>{if(!e)return 0;const o=e.replace(",",".").trim().split(":");let l=0;return o.length===3?(l+=parseInt(o[0],10)*3600,l+=parseInt(o[1],10)*60,l+=parseFloat(o[2])):o.length===2?(l+=parseInt(o[0],10)*60,l+=parseFloat(o[1])):o.length===1&&(l+=parseFloat(o[0])),isNaN(l)?0:l},wo=e=>{const t=Math.floor(e/60),o=Math.floor(e%60);return`${t}:${o.toString().padStart(2,"0")}`},El=e=>{const t=e.split(` -`),o=[],l=/\[(\d{2}):(\d{2})(\.(\d{2,3}))?\]/g,s=/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g;return t.forEach(d=>{const f=[...d.matchAll(l)];if(f.length>0){let g=d.replace(l,"").trim();g=g.replace(/\\n/g,` -`);const v=[...g.matchAll(s)];let m,x=g.replace(s,"").replace(/ +/g," ").trim();if(v.length>0){m=[];for(let b=0;b{ve&&m.push({text:ve,startTime:z,endTime:0}),ye{const S=parseInt(b[1],10),_=parseInt(b[2],10),T=b[4];let F=S*60+_;T&&(T.length===2?F+=parseInt(T,10)/100:(T.length,F+=parseInt(T,10)/1e3)),o.push({time:F,text:x,words:m})})}}),o.sort((d,f)=>d.time-f.time)},_l=e=>{const o=e.replace(/\r\n/g,` -`).replace(/\r/g,` -`).split(` - -`),l=[],s=/(\d{2}):(\d{2}):(\d{2}),(\d{3})/,d=f=>{const g=f.match(s);if(g){const v=parseInt(g[1],10),m=parseInt(g[2],10),x=parseInt(g[3],10),b=parseInt(g[4],10);return v*3600+m*60+x+b/1e3}return null};return o.forEach(f=>{const g=f.split(` -`);if(g.length>=3){const v=g[1],x=g.slice(2).join(" ").trim(),b=tp(x),S=v.split(" --> ");if(S.length>=2){const _=d(S[0]),T=d(S[1]);_!==null&&b&&l.push({time:_,text:b,endTime:T!==null?T:void 0})}}}),l},Xl=e=>{const t=[];try{const l=new DOMParser().parseFromString(e,"text/xml"),d=Array.from(l.getElementsByTagName("*")).filter(v=>v.localName==="p"),f=v=>{if(!v)return;const m=v.trim();return m.endsWith("ms")?parseFloat(m.slice(0,-2))/1e3:m.endsWith("s")?parseFloat(m.slice(0,-1)):Ks(m)},g=(v,m)=>{if(v.hasAttribute(m))return v.getAttribute(m);for(let x=0;xY.localName==="span");for(let Y=0;Y0){const fe=f(ce),Je=f(ve);fe!==void 0&&Je!==void 0&&F.push({text:ye,startTime:fe,endTime:Je})}}_!==void 0&&t.push({time:_,text:S,endTime:T,words:F.length>0?F:void 0})}}}catch(o){console.error("Failed to parse TTML",o)}return t.sort((o,l)=>o.time-l.time)},_w=e=>{try{const t=JSON.parse(e);if(Array.isArray(t)&&t.every(l=>typeof l=="object"&&l!==null&&typeof l.time=="number"&&typeof l.text=="string"))return t}catch(t){console.warn("Failed to parse JSON lyrics",t)}return[]},Wl=e=>{const o=e.replace(/\r\n/g,` -`).replace(/\r/g,` -`).split(` -`),l=[],s=/(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})/,d=g=>{const v=g.match(s);if(v){const m=v[1]?parseInt(v[1].replace(":",""),10):0,x=parseInt(v[2],10),b=parseInt(v[3],10),S=parseInt(v[4],10);return m*3600+x*60+b+S/1e3}return null};let f=0;for(o[0]&&o[0].startsWith("WEBVTT")&&(f=1);f")){const v=g.split("-->");if(v.length>=2){const m=v[0].trim(),x=v[1].trim().split(" ")[0],b=d(m),S=d(x);if(b!==null){f++;let _=[];for(;f"))break;_.push(o[f]),f++}if(f"),_.length>0){const T=_.join(" ").trim(),F=/<(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})>/g;let z;const G=[...T.matchAll(F)];if(G.length>0){z=[],G.forEach((ce,ve)=>{const ye=ce[1]?parseInt(ce[1].replace(":",""),10):0,fe=parseInt(ce[2],10),Je=parseInt(ce[3],10),ge=parseInt(ce[4],10),qe=ye*3600+fe*60+Je+ge/1e3,Ve=(ce.index||0)+ce[0].length;let Ke=T.length;ve+10){const it=T.substring(0,ce.index);it.trim()&&z.push({text:it.trim(),startTime:b,endTime:qe})}nt&&z.push({text:nt,startTime:qe,endTime:0})});for(let ce=0;ce/g,"").replace(/\s+/g," ").trim(),oe=tp(Y);l.push({time:b,text:oe,endTime:S!==null?S:void 0,words:z&&z.length>0?z:void 0})}continue}}}f++}return l},Nw=({toast:e,onRemove:t})=>{const[o,l]=Z.useState(!1);Z.useEffect(()=>{const g=setTimeout(()=>{s()},e.duration||500);return()=>clearTimeout(g)},[]);const s=()=>{l(!0),setTimeout(t,300)},d=()=>{switch(e.type){case"success":return u.jsx($1,{size:18,className:"text-green-400"});case"error":return u.jsx(K1,{size:18,className:"text-red-400"});default:return u.jsx(xS,{size:18,className:"text-blue-400"})}},f=()=>{switch(e.type){case"success":return"border-green-500/30";case"error":return"border-red-500/30";default:return"border-blue-500/30"}};return u.jsxs("div",{className:` - flex items-center gap-3 bg-zinc-900/60 backdrop-blur-xl border ${f()} - text-zinc-100 px-4 py-3 rounded-xl shadow-2xl min-w-[300px] max-w-md - transition-all duration-300 transform - ${o?"opacity-0 translate-x-full":"opacity-100 translate-x-0"} - animate-in slide-in-from-right fade-in - `,role:"alert",children:[u.jsx("div",{className:"shrink-0",children:d()}),u.jsx("p",{className:"text-sm font-medium flex-1",children:e.message}),u.jsx("button",{onClick:s,className:"text-zinc-500 hover:text-white transition-colors",children:u.jsx(Bi,{size:16})})]})},Aw=({toasts:e,removeToast:t})=>u.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-3 pointer-events-none",children:e.map(o=>u.jsx("div",{className:"pointer-events-auto",children:u.jsx(Nw,{toast:o,onRemove:()=>t(o.id)})},o.id))}),Mw=({isOpen:e,message:t,onConfirm:o,onCancel:l,title:s="Confirm Action"})=>{const[d,f]=Z.useState(!1);return Z.useEffect(()=>{e?f(!0):setTimeout(()=>f(!1),300)},[e]),Z.useEffect(()=>{const g=v=>{e&&(v.key==="Enter"?(v.preventDefault(),o()):v.key==="Escape"&&(v.preventDefault(),l()))};return e&&window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[e,o,l]),!e&&!d?null:u.jsxs("div",{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 transition-all duration-300 ${e?"opacity-100":"opacity-0"}`,children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm transition-opacity",onClick:l}),u.jsxs("div",{className:` - relative bg-zinc-900 border border-white/10 rounded-2xl shadow-2xl w-full max-w-md overflow-hidden transform transition-all duration-300 - ${e?"scale-100 translate-y-0":"scale-95 translate-y-4"} - `,children:[u.jsx("div",{className:"p-6",children:u.jsxs("div",{className:"flex items-start gap-4",children:[u.jsx("div",{className:"p-3 bg-orange-500/10 rounded-full shrink-0",children:u.jsx(cw,{className:"text-orange-500",size:24})}),u.jsxs("div",{className:"flex-1",children:[u.jsx("h3",{className:"text-lg font-bold text-white mb-2",children:s}),u.jsx("p",{className:"text-zinc-400 text-sm leading-relaxed",children:t})]}),u.jsx("button",{onClick:l,className:"text-zinc-500 hover:text-white transition-colors",children:u.jsx(Bi,{size:20})})]})}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 bg-zinc-950/50 border-t border-white/5",children:[u.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors",children:"Cancel"}),u.jsx("button",{onClick:o,className:"px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-500 rounded-lg shadow-lg hover:shadow-purple-500/20 transition-all",children:"Confirm"})]})]})]})},pv=Z.createContext(void 0),ur=()=>{const e=Z.useContext(pv);if(!e)throw new Error("useUI must be used within a UIProvider");return e},kw=({children:e})=>{const[t,o]=Z.useState([]),l=Z.useCallback((b,S,_)=>{let T,F;typeof _=="number"?T=_:typeof _=="object"&&(T=_.duration,F=_.id);const z=F||Math.random().toString(36).substr(2,9);o(G=>[...G.filter(oe=>oe.id!==z),{id:z,type:b,message:S,duration:T}])},[]),s=Z.useCallback(b=>{o(S=>S.filter(_=>_.id!==b))},[]),d={success:(b,S)=>l("success",b,S),error:(b,S)=>l("error",b,S),info:(b,S)=>l("info",b,S)},[f,g]=Z.useState({isOpen:!1,message:"",title:"",resolve:null}),v=Z.useCallback((b,S="Confirm Action")=>new Promise(_=>{g({isOpen:!0,message:b,title:S,resolve:_})}),[]),m=Z.useCallback(()=>{f.resolve&&f.resolve(!0),g(b=>({...b,isOpen:!1,resolve:null}))},[f]),x=Z.useCallback(()=>{f.resolve&&f.resolve(!1),g(b=>({...b,isOpen:!1,resolve:null}))},[f]);return u.jsxs(pv.Provider,{value:{toast:d,confirm:v},children:[e,u.jsx(Aw,{toasts:t,removeToast:s}),u.jsx(Mw,{isOpen:f.isOpen,message:f.message,title:f.title,onConfirm:m,onCancel:x})]})},bc=e=>e>=150?.5:e>=100?1:e>=60?2:e>=40?5:e>=25?10:15,Rw=(e,t)=>{const o=Math.floor(e/60),l=e%60;return t<1?`${o}:${l.toFixed(1).padStart(4,"0")}`:`${o}:${Math.floor(l).toString().padStart(2,"0")}`},yg=10,zw=50,pn={VISUAL_L2_TOP:32,VISUAL_L2_HEIGHT:48,VISUAL_L1_TOP:84,VISUAL_L1_HEIGHT:48,LYRICS_TOP:136,LYRICS_HEIGHT:32,AUDIO_L1_TOP:172,AUDIO_L1_HEIGHT:32,AUDIO_L2_TOP:208,AUDIO_L2_HEIGHT:32},Iw=e=>new Promise(t=>{const o=URL.createObjectURL(e),l=document.createElement(e.type.startsWith("audio/")?"audio":"video");l.preload="metadata",l.onloadedmetadata=()=>{t(l.duration),URL.revokeObjectURL(o)},l.onerror=()=>{URL.revokeObjectURL(o),t(0)},l.src=o}),Dw=({value:e,onChange:t})=>{const[o,l]=Z.useState(e.toString());Z.useEffect(()=>{const f=parseFloat(o);!isNaN(f)&&Math.abs(f-e)<.001||l(e.toString())},[e]);const s=()=>{const f=parseFloat(o);o===""||isNaN(f)||f<=0?l(e.toString()):t(f)},d=f=>{const g=parseFloat(o),v=isNaN(g)?e:g,m=Math.round((v+f)*100)/100;m<.05||(t(m),l(m.toString()))};return u.jsxs("div",{className:"flex items-center bg-zinc-900 rounded border border-zinc-700 h-[18px]",children:[u.jsx("button",{onClick:()=>d(-.05),className:"px-0.5 hover:bg-zinc-700 text-zinc-400 hover:text-white transition-colors h-full flex items-center justify-center border-r border-zinc-700",children:u.jsx(rr,{size:10})}),u.jsx("input",{type:"text",name:"speed-input","aria-label":"Speed Input",className:"bg-transparent text-[10px] text-zinc-300 focus:outline-none w-10 text-center",value:o,onChange:f=>{/^\d*\.?\d*$/.test(f.target.value)&&l(f.target.value)},onBlur:s,onKeyDown:f=>{f.stopPropagation(),f.key==="ArrowUp"&&(f.preventDefault(),d(.05)),f.key==="ArrowDown"&&(f.preventDefault(),d(-.05)),f.key==="Enter"&&f.currentTarget.blur()}}),u.jsx("button",{onClick:()=>d(.05),className:"px-0.5 hover:bg-zinc-700 text-zinc-400 hover:text-white transition-colors h-full flex items-center justify-center border-l border-zinc-700",children:u.jsx(wf,{size:10})})]})},Lw=({slides:e,setSlides:t,currentTime:o,duration:l,lyrics:s,onSeek:d,onClose:f,renderConfig:g,setRenderConfig:v})=>{const{confirm:m,toast:x}=ur(),b=Z.useRef(null),S=Z.useRef(null),_=Z.useRef(null),[T,F]=Z.useState(40),[z,G]=Z.useState([]),[Y,oe]=Z.useState(null),[ce,ve]=Z.useState([]),[ye,fe]=Z.useState(null),[Je,ge]=Z.useState(!1),[qe,Ve]=Z.useState(null),[Ke,nt]=Z.useState([{slides:e,selection:[]}]),[it,xt]=Z.useState(0),K=Z.useRef(!1),[ze,Le]=Z.useState([]);Z.useEffect(()=>{if(K.current){K.current=!1;return}if(ye||Je)return;const A=Ke[it],W={slides:e,selection:z};if(JSON.stringify(A)!==JSON.stringify(W)){const M=Ke.slice(0,it+1);M.push(W),M.length>zw?(M.shift(),nt(M)):(nt(M),xt(it+1))}},[e,z,Ke,it,ye,Je]);const ut=it>0,Me=it{if(it>0){const A=it-1;xt(A),K.current=!0,t(Ke[A].slides),G(Ke[A].selection)}},[t,G,Ke,it]),X=Z.useCallback(()=>{if(itA.endTime)),ke=Math.max(l,60,Ee),He=ke*T,et=Z.useCallback(()=>{if(z.length===0)return;const A=e.filter(W=>z.includes(W.id));ve(A),x.success(`Copied ${A.length} items`)},[z,e,x]),Ae=Z.useCallback(()=>{if(z.length===0)return;const A=e.filter(W=>z.includes(W.id));ve(A),t(W=>W.filter(M=>!z.includes(M.id))),G([]),x.success(`Cut ${A.length} items`)},[z,e,t,x]),C=Z.useRef(e),se=Z.useRef(T);Z.useEffect(()=>{C.current=e,se.current=T},[e,T]);const ue=Z.useCallback(()=>{if(ce.length===0)return;const A=Math.min(...ce.map(D=>D.startTime)),W=o-A,M=ce.map(D=>({...D,id:Math.random().toString(36).substr(2,9),startTime:D.startTime+W,endTime:D.endTime+W}));t(D=>[...D,...M].sort((k,ne)=>k.startTime-ne.startTime)),G(M.map(D=>D.id)),x.success(`Pasted ${M.length} items`)},[ce,o,t,x]),me=Z.useCallback(()=>{const A=e.filter(k=>z.includes(k.id)&&o>k.startTime&&o{const ne=o,B={...k,id:Math.random().toString(36).substr(2,9),endTime:ne},te=ne-k.startTime,j={...k,id:Math.random().toString(36).substr(2,9),startTime:ne,mediaStartOffset:(k.mediaStartOffset||0)+te};M.push(k.id),W.push(B,j),D.push(j.id)}),t(k=>[...k.filter(B=>!M.includes(B.id)),...W].sort((B,te)=>B.startTime-te.startTime)),G(D),x.success(`Split ${A.length} items`)},[e,z,o,t,x]),q=async A=>{if(A.target.files&&A.target.files.length>0){const W=Array.from(A.target.files),M=W.every(k=>k.type.startsWith("image/")),D=[];if(M){const k=W.length,ne=o,te=Math.max(0,l-ne)/k,j=Math.max(3,te);W.forEach((we,E)=>{const O=URL.createObjectURL(we),V=ne+E*j,Fe=V+j;D.push({id:Math.random().toString(36).substr(2,9),url:O,type:"image",startTime:V,endTime:Fe,name:we.name,layer:0})})}else{let k=o;for(const ne of W){const B=ne.type.startsWith("image/")?"image":ne.type.startsWith("video/")?"video":"audio";let te=5;if(B!=="image"){const we=await Iw(ne);we>0&&(te=we)}const j=URL.createObjectURL(ne);D.push({id:Math.random().toString(36).substr(2,9),url:j,type:B,startTime:k,endTime:k+te,mediaDuration:B!=="image"?te:void 0,name:ne.name,isMuted:B==="video",volume:B==="video"||B==="audio"?1:void 0,layer:0}),k+=te}}t(k=>[...k,...D].sort((ne,B)=>ne.startTime-B.startTime)),A.target.value=""}},Ie=A=>{t(W=>W.filter(M=>M.id!==A))},Re=async A=>{A.stopPropagation(),e.length!==0&&await m("Are you sure you want to remove all visual slides?","Remove All Slides")&&t([])},ee=(A,W,M)=>{if(A.stopPropagation(),A.preventDefault(),b.current?.focus(),A.shiftKey&&Y){const j=e.findIndex(E=>E.id===Y),we=e.findIndex(E=>E.id===W);if(j!==-1&&we!==-1){const E=Math.min(j,we),O=Math.max(j,we),V=e.slice(E,O+1).map(Fe=>Fe.id);G(Fe=>{const Be=new Set([...Fe,...V]);return Array.from(Be)})}}else A.ctrlKey||A.metaKey?(G(j=>j.includes(W)?j.filter(we=>we!==W):[...j,W]),oe(W)):(z.includes(W)||G([W]),oe(W));const D=e.find(j=>j.id===W);if(!D)return;const k=z.includes(W),ne=A.ctrlKey||A.metaKey||A.shiftKey;let B=[];if(!ne&&!k)B=[W];else if(ne){if(B=[W],(A.ctrlKey||A.metaKey)&&!k)B=[...z,W];else if((A.ctrlKey||A.metaKey)&&k){B=z.filter(j=>j!==W);return}}else B=z;const te={};e.forEach(j=>{B.includes(j.id)&&(te[j.id]={start:j.startTime,end:j.endTime})}),te[W]||(te[W]={start:D.startTime,end:D.endTime}),fe({id:W,type:M,startX:A.clientX,initialStart:D.startTime,initialEnd:D.endTime,initialMap:te}),window.addEventListener("mousemove",Xe),window.addEventListener("mouseup",Ye)},be=A=>{A.button===0&&(A.stopPropagation(),b.current?.focus(),G([]),ge(!0),Oe(A.clientX),window.addEventListener("mousemove",ht),window.addEventListener("mouseup",R))},$e=A=>{if(A.button!==0)return;b.current?.focus();const W=A.clientX,M=A.clientY,D=_.current?.getBoundingClientRect();if(!D)return;const k=W-D.left,ne=M-D.top;let B=!1;const te=we=>{const E=Math.sqrt(Math.pow(we.clientX-W,2)+Math.pow(we.clientY-M,2));if(!B&&E>5&&(B=!0,Ve({x:k,y:ne,w:0,h:0})),B&&_.current){const O=_.current.getBoundingClientRect(),V=we.clientX-O.left,Fe=we.clientY-O.top;Ve(vt=>{if(!vt)return null;const Gt=V-k,dn=Fe-ne;return{x:Gt>0?k:V,y:dn>0?ne:Fe,w:Math.abs(Gt),h:Math.abs(dn)}});const Be=[],tt=C.current,St=se.current,_e=Math.min(k,V),Ot=Math.min(ne,Fe),Se=Math.abs(V-k),he=Math.abs(Fe-ne),dt=_e+Se,Dt=Ot+he;tt.forEach(vt=>{const Gt=vt.startTime*St+96,dn=vt.endTime*St+96;let Fn=0,Si=0;const mi=vt.layer||0;vt.type==="audio"?mi===0?(Fn=pn.AUDIO_L1_TOP,Si=pn.AUDIO_L1_TOP+pn.AUDIO_L1_HEIGHT):(Fn=pn.AUDIO_L2_TOP,Si=pn.AUDIO_L2_TOP+pn.AUDIO_L2_HEIGHT):mi===0?(Fn=pn.VISUAL_L1_TOP,Si=pn.VISUAL_L1_TOP+pn.VISUAL_L1_HEIGHT):(Fn=pn.VISUAL_L2_TOP,Si=pn.VISUAL_L2_TOP+pn.VISUAL_L2_HEIGHT);const ui=_eGt,Zt=OtFn;ui&&Zt&&Be.push(vt.id)}),G(Be)}},j=we=>{B||(G([]),Oe(we.clientX)),Ve(null),window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",te),window.addEventListener("mouseup",j)},Oe=A=>{if(!_.current)return;const W=_.current.getBoundingClientRect(),M=A-W.left-96;let D=Math.max(0,Math.min(M/T,ke));D=We(D),d(D)},ht=A=>{Oe(A.clientX)},R=()=>{ge(!1),window.removeEventListener("mousemove",ht),window.removeEventListener("mouseup",R)},Ue=A=>{const W=A.target;if(!(W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable)){if((A.ctrlKey||A.metaKey)&&A.key==="z"&&!A.shiftKey){A.preventDefault(),L();return}if((A.ctrlKey||A.metaKey)&&(A.key==="y"||A.key==="z"&&A.shiftKey)){A.preventDefault(),X();return}if((A.ctrlKey||A.metaKey)&&A.key==="c"){A.preventDefault(),et();return}if((A.ctrlKey||A.metaKey)&&A.key==="x"){A.preventDefault(),Ae();return}if((A.ctrlKey||A.metaKey)&&A.key==="v"){A.preventDefault(),ue();return}if(A.key.toLowerCase()==="x"&&!A.ctrlKey&&!A.metaKey||(A.ctrlKey||A.metaKey)&&A.key==="k"){A.preventDefault(),A.stopPropagation(),me();return}if((A.key==="Delete"||A.key==="Backspace")&&z.length>0&&(A.preventDefault(),t(M=>M.filter(D=>!z.includes(D.id))),G([])),z.length>0&&(A.key==="ArrowLeft"||A.key==="ArrowRight")){A.preventDefault(),A.stopPropagation();const M=A.key==="ArrowRight"?.01:-.01,D=e.find(k=>k.id===z[0]);if(D){const k=Math.max(0,D.startTime+M);d(k)}t(k=>k.map(B=>{if(z.includes(B.id)){const te=B.endTime-B.startTime;let j=B.startTime+M;return j=Math.max(0,j),{...B,startTime:j,endTime:j+te}}return B}).sort((B,te)=>B.startTime-te.startTime))}}},We=(A,W=[])=>{const M=yg/T,D=[0,l,o],k=bc(T),ne=Math.round(A/k)*k;D.push(ne),e.forEach(j=>{W.includes(j.id)||(D.push(j.startTime),D.push(j.endTime))}),s.forEach(j=>{D.push(j.time)});let B=A,te=M;for(const j of D){const we=Math.abs(j-A);we{fe(W=>{if(!W)return null;const D=(A.clientX-W.startX)/T;let k=[];return t(ne=>{if(W.type==="move"){const B=Object.keys(W.initialMap),te=Object.values(W.initialMap),j=Math.min(...te.map(he=>he.start)),we=Math.max(...te.map(he=>he.end)),E=W.initialMap[W.id],O=[{type:"drag-start",initVal:E.start,ref:"start"},{type:"drag-end",initVal:E.end,ref:"end"},{type:"group-start",initVal:j,ref:"start"},{type:"group-end",initVal:we,ref:"end"}],V=yg/T,Fe=[0,l,o],Be=bc(T);e.forEach(he=>{B.includes(he.id)||(Fe.push(he.startTime),Fe.push(he.endTime))}),s.forEach(he=>{Fe.push(he.time)});let tt=D,St=V,_e=!1,Ot=-1;O.forEach(he=>{const dt=he.initVal+D;for(const Gt of Fe){const dn=Math.abs(Gt-dt);dn{const dt=W.initialMap[he.id];if(dt){const Dt=dt.end-dt.start;let vt=he.layer||0;const Gt=_.current?.getBoundingClientRect();if(Gt){const dn=A.clientY-Gt.top,Fn=(Si,mi,ui)=>Si>=mi-10&&Si<=mi+ui+10;he.type==="audio"?Fn(dn,pn.AUDIO_L1_TOP,pn.AUDIO_L1_HEIGHT)?vt=0:Fn(dn,pn.AUDIO_L2_TOP,pn.AUDIO_L2_HEIGHT)&&(vt=1):Fn(dn,pn.VISUAL_L1_TOP,pn.VISUAL_L1_HEIGHT)?vt=0:Fn(dn,pn.VISUAL_L2_TOP,pn.VISUAL_L2_HEIGHT)&&(vt=1)}return{...he,startTime:dt.start+Se,endTime:dt.start+Se+Dt,layer:vt}}return he})}else if(W.type==="resize-start"){let B=W.initialStart+D;const te=We(B,[W.id]);Math.abs(te-B)>1e-4&&(k=[te]),B=te;const j=.5,we=W.initialEnd;return B=Math.max(0,Math.min(B,we-j)),B===0&&(k=[0]),ne.map(E=>E.id!==W.id?E:{...E,startTime:B})}else{let B=W.initialEnd+D;const te=We(B,[W.id]);Math.abs(te-B)>1e-4&&(k=[te]),B=te;const j=.5,we=W.initialStart;return B=Math.max(we+j,B),ne.map(E=>E.id!==W.id?E:{...E,endTime:B})}}),Le(k),W})},Ye=A=>{ye&&ye.type==="move"&&Math.abs(A.clientX-ye.startX)<5&&!A.ctrlKey&&!A.metaKey&&!A.shiftKey&&G([ye.id]),fe(null),Le([]),window.removeEventListener("mousemove",Xe),window.removeEventListener("mouseup",Ye),t(W=>[...W].sort((M,D)=>M.startTime-D.startTime))},ft=()=>F(A=>Math.min(200,A+10)),jt=()=>F(A=>Math.max(10,A-10)),gt=(A,W)=>{v(M=>{const D=M.layerVisibility?.[A]||{},k={...D,[W]:D[W]===!1};return{...M,layerVisibility:{...M.layerVisibility,[A]:k,...A==="visual"?{audio:M.layerVisibility?.audio||{}}:{visual:M.layerVisibility?.visual||{}}}}})},Et=(A,W)=>g.layerVisibility?.[A]?.[W]!==!1;return u.jsxs("div",{ref:b,className:"w-full max-w-[100vw] h-64 flex flex-col bg-zinc-900/95 backdrop-blur-md border-t border-white/10 z-20 shadow-xl outline-none overflow-hidden",tabIndex:0,onMouseDown:A=>A.currentTarget.focus(),onKeyDown:Ue,children:[u.jsxs("div",{className:"p-2 border-b border-white/10 flex items-center justify-between bg-zinc-900 z-30 shrink-0 h-12",children:[u.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[u.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap",children:[u.jsx(uv,{size:16,className:"text-purple-400"}),"Timeline"]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("label",{className:"flex items-center gap-2 px-3 py-1 bg-purple-600 hover:bg-purple-500 rounded text-xs font-medium cursor-pointer transition-colors text-white whitespace-nowrap",children:[u.jsx(fv,{size:14})," Import Media",u.jsx("input",{type:"file",name:"import-media",id:"import-media",className:"hidden",accept:"image/*,video/*,audio/*",multiple:!0,onChange:q})]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:jt,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white",title:"Zoom Out",children:u.jsx(Ew,{size:14})}),u.jsxs("div",{className:"text-[10px] text-zinc-500 font-mono min-w-[50px] text-center",children:[T,"px/s"]}),u.jsx("button",{onClick:ft,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white",title:"Zoom In",children:u.jsx(Tw,{size:14})})]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:L,disabled:!ut,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Undo (Ctrl+Z)",children:u.jsx(hw,{size:14})}),u.jsx("button",{onClick:X,disabled:!Me,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Redo (Ctrl+Y)",children:u.jsx(FS,{size:14})})]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:et,disabled:z.length===0,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Copy (Ctrl+C)",children:u.jsx(Z1,{size:14})}),u.jsx("button",{onClick:Ae,disabled:z.length===0,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Cut (Ctrl+X)",children:u.jsx($S,{size:14})}),u.jsx("button",{onClick:ue,disabled:ce.length===0,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Paste (Ctrl+V)",children:u.jsx(W1,{size:14})})]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsx("div",{className:"flex items-center gap-1",children:u.jsx("button",{onClick:me,disabled:z.length===0,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",title:"Split Content (X)",children:u.jsx(iw,{size:14})})}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:()=>{e.length>0&&z.length===e.length?G([]):G(e.map(A=>A.id))},className:"px-2 py-0.5 text-[10px] bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 rounded text-zinc-300 transition-colors",children:"Select All"}),z.length===1&&u.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800 rounded px-1 border border-zinc-700",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 px-1",children:"Dur:"}),u.jsx("input",{type:"text",name:"duration-input","aria-label":"Slide Duration",className:"w-12 bg-transparent text-[10px] text-white font-mono focus:outline-none py-0.5 text-center",placeholder:"MM:SS",defaultValue:(()=>{const A=e.find(W=>W.id===z[0]);return A?wo(A.endTime-A.startTime):"00:00"})(),onBlur:A=>{const M=A.target.value.split(":");if(M.length===2){const k=parseInt(M[0])||0,ne=parseInt(M[1])||0,B=k*60+ne;B>0&&t(te=>te.map(j=>j.id===z[0]?{...j,endTime:j.startTime+B}:j))}const D=e.find(k=>k.id===z[0]);D&&(A.target.value=wo(D.endTime-D.startTime))},onKeyDown:A=>{A.key==="Enter"&&A.currentTarget.blur()}},z[0])]}),z.length===1&&(()=>{const A=e.find(W=>W.id===z[0]);return A&&(A.type==="video"||A.type==="audio")?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 rounded px-2 border border-zinc-700 h-[22px]",children:[u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Vol:"}),u.jsxs("div",{className:"flex items-center gap-1 w-20",children:[u.jsx("button",{onClick:()=>{t(W=>W.map(M=>M.id===A.id?{...M,isMuted:!M.isMuted}:M))},className:"p-0.5 hover:bg-zinc-700 rounded cursor-pointer text-zinc-400 hover:text-white",title:A.isMuted!==!1?"Unmute":"Mute",children:A.isMuted!==!1?u.jsx(Pa,{size:10}):u.jsx(Tl,{size:10})}),u.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",name:"volume-input","aria-label":"Volume Level",className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer",value:A.volume!==void 0?A.volume:1,onChange:W=>{const M=parseFloat(W.target.value);t(D=>D.map(k=>k.id===A.id?{...k,volume:M,isMuted:M===0}:k))}})]}),u.jsxs("span",{className:"text-[9px] text-zinc-400 w-6 text-right",children:[Math.round((A.volume||1)*100),"%"]})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Spd:"}),u.jsx(Dw,{value:A.playbackRate||1,onChange:W=>{t(M=>M.map(D=>{if(D.id===A.id){const k=D.playbackRate||1,B=(D.endTime-D.startTime)*(k/W);return{...D,playbackRate:W,endTime:D.startTime+B}}return D}))}})]})]}):null})()]})]}),u.jsxs("div",{className:"flex gap-2 shrink-0",children:[u.jsx("button",{onClick:Re,className:"p-1 hover:bg-red-900/50 text-zinc-500 hover:text-red-200 rounded transition-colors",title:"Clear All Slides",children:u.jsx($a,{size:14})}),u.jsx("div",{className:"w-px h-4 bg-zinc-700 mx-1 self-center"}),u.jsx("button",{onClick:f,className:"p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors",title:"Close Timeline",children:u.jsx(Bi,{size:14})})]})]}),u.jsx("div",{ref:S,onWheel:A=>{S.current&&A.shiftKey&&(A.preventDefault(),S.current.scrollLeft+=A.deltaY)},className:"flex-1 overflow-x-auto overflow-y-auto relative bg-zinc-950 scroll-smooth custom-scrollbar cursor-default",children:u.jsxs("div",{ref:_,className:"relative",style:{width:`${He+96}px`,minWidth:"100%",height:"max(100%, 280px)"},onMouseDown:$e,children:[qe&&u.jsx("div",{className:"absolute border border-purple-500 bg-purple-500/20 z-50 pointer-events-none",style:{left:qe.x,top:qe.y,width:qe.w,height:qe.h}}),ze.map((A,W)=>u.jsx("div",{className:"absolute top-0 bottom-0 border-l border-yellow-400 z-[60] shadow-[0_0_8px_rgba(250,204,21,0.6)]",style:{left:A*T}},`snap-${W}`)),u.jsxs("div",{className:"absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none z-0",children:[(()=>{const A=bc(T);return Array.from({length:Math.ceil(He/(T*A))}).map((W,M)=>u.jsx("div",{className:"absolute top-0 bottom-0 border-l border-white/5",style:{left:M*A*T}},M))})(),l>0&&u.jsx("div",{className:"absolute top-0 bottom-0 border-l-2 border-red-900/50 flex flex-col justify-end z-0",style:{left:l*T},children:u.jsx("span",{className:"text-[9px] text-red-900/50 bg-black/50 px-1 whitespace-nowrap",children:"End"})})]}),u.jsxs("div",{className:"sticky top-0 left-0 right-0 h-6 border-b border-white/10 bg-zinc-900/90 backdrop-blur-sm select-none cursor-pointer z-[60] flex",onMouseDown:be,children:[u.jsx("div",{className:"w-[96px] shrink-0 border-r border-white/10 flex items-center justify-center text-[10px] text-zinc-500 bg-zinc-900/90",children:"Time"}),u.jsx("div",{className:"relative flex-1",children:(()=>{const A=bc(T);return Array.from({length:Math.ceil(He/(T*A))}).map((W,M)=>{const D=M*A;return D>ke?null:u.jsx("div",{className:"absolute bottom-0 border-l border-white/20 text-[9px] text-zinc-500 font-mono pl-1 pb-0.5 pointer-events-none",style:{left:D*T,width:A*T},children:Rw(D,A)},M)})})()})]}),u.jsx("div",{className:"absolute top-6 bottom-0 w-px bg-red-500 z-50 pointer-events-none",style:{left:"96px",transform:`translateX(${o*T}px)`,willChange:"transform"},children:u.jsx("div",{className:"absolute -top-1.5 -left-1.5 w-3 h-3 bg-red-500 rotate-45 transform origin-center shadow-sm"})}),u.jsxs("div",{className:"absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20",style:{top:pn.VISUAL_L1_TOP,height:pn.VISUAL_L1_HEIGHT},children:[u.jsxs("div",{className:"sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm",children:[u.jsx("span",{children:"Visual 1"}),u.jsx("button",{onClick:A=>{A.stopPropagation(),gt("visual",0)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Et("visual",0)?u.jsx(Ys,{size:12}):u.jsx(qs,{size:12,className:"text-zinc-600"})})]}),u.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Et("visual",0)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(A=>A.type!=="audio"&&(A.layer===0||A.layer===void 0)).map(A=>u.jsxs("div",{style:{left:A.startTime*T,width:Math.max(10,(A.endTime-A.startTime)*T)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move - ${ye?.id===A.id||z.includes(A.id)?"border-purple-400 z-30 shadow-xl opacity-90":"border-zinc-600 hover:border-zinc-400 z-10 hover:z-20"} - ${z.includes(A.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} - `,onMouseDown:W=>ee(W,A.id,"move"),children:[A.type==="video"?u.jsx("video",{src:A.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",muted:!0}):u.jsx("img",{src:A.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",draggable:!1,alt:A.name}),u.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-end",children:u.jsx("span",{className:"text-[10px] font-bold drop-shadow-md truncate text-zinc-200 bg-black/30 px-1 rounded w-max max-w-full",children:A.name})}),(ye?.id===A.id||z.includes(A.id))&&u.jsx("div",{className:"absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none",children:wo(A.startTime)}),A.type==="video"&&A.mediaDuration&&(Math.abs(A.endTime-A.startTime-A.mediaDuration)>.1||A.playbackRate!==void 0&&Math.abs(A.playbackRate-1)>.01)&&u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id&&D.mediaDuration?{...D,endTime:D.startTime+D.mediaDuration,playbackRate:1}:D))},className:"absolute top-1 left-12 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",title:"Reset to Original Duration",children:u.jsx(Cf,{size:10})}),A.type==="video"&&u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id?{...D,isMuted:!D.isMuted}:D))},className:"absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",title:A.isMuted!==!1?"Unmute":"Mute",children:A.isMuted!==!1?u.jsx(Pa,{size:10}):u.jsx(Tl,{size:10})}),u.jsx("button",{onClick:W=>{W.stopPropagation(),Ie(A.id)},className:"absolute top-1 right-4 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-30",children:u.jsx(Bi,{size:10})}),u.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-3 cursor-w-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-start"),children:u.jsx(xc,{size:10,className:"text-white/70 rotate-90"})}),u.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-3 cursor-e-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-end"),children:u.jsx(xc,{size:10,className:"text-white/70 rotate-90"})})]},A.id))})]}),u.jsxs("div",{className:"absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20",style:{top:pn.VISUAL_L2_TOP,height:pn.VISUAL_L2_HEIGHT},children:[u.jsxs("div",{className:"sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm",children:[u.jsx("span",{children:"Visual 2"}),u.jsx("button",{onClick:A=>{A.stopPropagation(),gt("visual",1)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Et("visual",1)?u.jsx(Ys,{size:12}):u.jsx(qs,{size:12,className:"text-zinc-600"})})]}),u.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Et("visual",1)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(A=>A.type!=="audio"&&A.layer===1).map(A=>u.jsxs("div",{style:{left:A.startTime*T,width:Math.max(10,(A.endTime-A.startTime)*T)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move - ${ye?.id===A.id||z.includes(A.id)?"border-purple-400 z-30 shadow-xl opacity-90":"border-zinc-600 hover:border-zinc-400 z-10 hover:z-20"} - ${z.includes(A.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} - `,onMouseDown:W=>ee(W,A.id,"move"),children:[A.type==="video"?u.jsx("video",{src:A.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",muted:!0}):u.jsx("img",{src:A.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",draggable:!1,alt:A.name}),u.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-end",children:u.jsx("span",{className:"text-[10px] font-bold drop-shadow-md truncate text-zinc-200 bg-black/30 px-1 rounded w-max max-w-full",children:A.name})}),(ye?.id===A.id||z.includes(A.id))&&u.jsx("div",{className:"absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none",children:wo(A.startTime)}),A.type==="video"&&A.mediaDuration&&(Math.abs(A.endTime-A.startTime-A.mediaDuration)>.1||A.playbackRate!==void 0&&Math.abs(A.playbackRate-1)>.01)&&u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id&&D.mediaDuration?{...D,endTime:D.startTime+D.mediaDuration,playbackRate:1}:D))},className:"absolute top-1 left-12 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",title:"Reset to Original Duration",children:u.jsx(Cf,{size:10})}),A.type==="video"&&u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id?{...D,isMuted:!D.isMuted}:D))},className:"absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",children:A.isMuted!==!1?u.jsx(Pa,{size:10}):u.jsx(Tl,{size:10})}),u.jsx("button",{onClick:W=>{W.stopPropagation(),Ie(A.id)},className:"absolute top-1 right-4 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-30",children:u.jsx(Bi,{size:10})}),u.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-3 cursor-w-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-start"),children:u.jsx(xc,{size:10,className:"text-white/70 rotate-90"})}),u.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-3 cursor-e-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-end"),children:u.jsx(xc,{size:10,className:"text-white/70 rotate-90"})})]},A.id))})]}),u.jsxs("div",{className:"absolute left-0 right-0 overflow-hidden",style:{top:pn.LYRICS_TOP,height:pn.LYRICS_HEIGHT},children:[u.jsx("div",{className:"sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center px-2 text-[10px] text-zinc-400 backdrop-blur-sm select-none",children:u.jsx("span",{children:"Lyrics"})}),u.jsx("div",{className:"absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none",children:s.map((A,W)=>u.jsxs("div",{className:"absolute top-1 bottom-1 text-[10px] text-zinc-400 truncate hover:text-white transition-colors hover:bg-zinc-800/50 rounded px-2 cursor-pointer border-l border-zinc-700 flex items-center whitespace-nowrap pointer-events-auto",style:{left:A.time*T},title:`${wo(A.time)} - ${A.text}`,onClick:M=>{M.stopPropagation(),d(A.time)},children:[u.jsx("span",{className:"mr-1 text-zinc-600 font-mono text-[9px]",children:wo(A.time)}),A.text]},W))})]}),u.jsxs("div",{className:"absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40",style:{top:pn.AUDIO_L1_TOP,height:pn.AUDIO_L1_HEIGHT},children:[u.jsxs("div",{className:"sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm",children:[u.jsx("span",{children:"Audio 1"}),u.jsx("button",{onClick:A=>{A.stopPropagation(),gt("audio",0)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Et("audio",0)?u.jsx(Ys,{size:12}):u.jsx(qs,{size:12,className:"text-zinc-600"})})]}),u.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Et("audio",0)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(A=>A.type==="audio"&&(A.layer===0||A.layer===void 0)).map(A=>u.jsxs("div",{style:{left:A.startTime*T,width:Math.max(10,(A.endTime-A.startTime)*T)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move - ${ye?.id===A.id||z.includes(A.id)?"border-emerald-400 z-30 shadow-xl opacity-90":"border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20"} - ${z.includes(A.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} - `,onMouseDown:W=>ee(W,A.id,"move"),children:[u.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-30",children:u.jsx(Tl,{size:16,className:"text-emerald-200"})}),u.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-center",children:u.jsx("span",{className:"text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1",children:A.name})}),(ye?.id===A.id||z.includes(A.id))&&u.jsx("div",{className:"absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none",children:wo(A.startTime)}),u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id?{...D,isMuted:!D.isMuted}:D))},className:"absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-emerald-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",title:A.isMuted===!0?"Unmute":"Mute",children:A.isMuted===!0?u.jsx(Pa,{size:10}):u.jsx(Tl,{size:10})}),u.jsx("button",{onClick:W=>{W.stopPropagation(),Ie(A.id)},className:"absolute top-1 right-3 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",children:u.jsx(Bi,{size:10})}),u.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-2 cursor-w-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-start")}),u.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-2 cursor-e-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-end")})]},A.id))})]}),u.jsxs("div",{className:"absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40",style:{top:pn.AUDIO_L2_TOP,height:pn.AUDIO_L2_HEIGHT},children:[u.jsxs("div",{className:"sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm",children:[u.jsx("span",{children:"Audio 2"}),u.jsx("button",{onClick:A=>{A.stopPropagation(),gt("audio",1)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Et("audio",1)?u.jsx(Ys,{size:12}):u.jsx(qs,{size:12,className:"text-zinc-600"})})]}),u.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Et("audio",1)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(A=>A.type==="audio"&&A.layer===1).map(A=>u.jsxs("div",{style:{left:A.startTime*T,width:Math.max(10,(A.endTime-A.startTime)*T)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move - ${ye?.id===A.id||z.includes(A.id)?"border-emerald-400 z-30 shadow-xl opacity-90":"border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20"} - ${z.includes(A.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} - `,onMouseDown:W=>ee(W,A.id,"move"),children:[u.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-30",children:u.jsx(Tl,{size:16,className:"text-emerald-200"})}),u.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-center",children:u.jsx("span",{className:"text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1",children:A.name})}),(ye?.id===A.id||z.includes(A.id))&&u.jsx("div",{className:"absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none",children:wo(A.startTime)}),u.jsx("button",{onClick:W=>{W.stopPropagation(),t(M=>M.map(D=>D.id===A.id?{...D,isMuted:!D.isMuted}:D))},className:"absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-emerald-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",title:A.isMuted===!0?"Unmute":"Mute",children:A.isMuted===!0?u.jsx(Pa,{size:10}):u.jsx(Tl,{size:10})}),u.jsx("button",{onClick:W=>{W.stopPropagation(),Ie(A.id)},className:"absolute top-1 right-3 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40",children:u.jsx(Bi,{size:10})}),u.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-2 cursor-w-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-start")}),u.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-2 cursor-e-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20",onMouseDown:W=>ee(W,A.id,"resize-end")})]},A.id))})]})]})})]})};var Uw={};let Fw,Pw;function Bw(){return{geminiUrl:Fw,vertexUrl:Pw}}function jw(e,t,o,l){var s,d;if(!e?.baseUrl){const f=Bw();return t?(s=f.vertexUrl)!==null&&s!==void 0?s:o:(d=f.geminiUrl)!==null&&d!==void 0?d:l}return e.baseUrl}class Jo{}function Ze(e,t){const o=/\{([^}]+)\}/g;return e.replace(o,(l,s)=>{if(Object.prototype.hasOwnProperty.call(t,s)){const d=t[s];return d!=null?String(d):""}else throw new Error(`Key '${s}' not found in valueMap.`)})}function p(e,t,o){for(let d=0;d({}));else throw new Error(`Value must be a list given an array path ${f}`);if(Array.isArray(e[g])){const v=e[g];if(Array.isArray(o))for(let m=0;mc(g,t.slice(l+1),o)):o}else return o}else e=e[s]}return e}catch(l){if(l instanceof TypeError)return o;throw l}}function Ow(e,t){for(const[o,l]of Object.entries(t)){const s=o.split("."),d=l.split("."),f=new Set;let g=-1;for(let v=0;vg)for(let v=g;v=t.length||typeof e!="object"||e===null)return;const d=t[l];if(d.endsWith("[]")){const f=d.slice(0,-2),g=e;if(f in g&&Array.isArray(g[f]))for(const v of g[f])Nf(v,t,o,l+1,s)}else if(d==="*"){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const f=e,g=Object.keys(f).filter(m=>!m.startsWith("_")&&!s.has(m)),v={};for(const m of g)v[m]=f[m];for(const[m,x]of Object.entries(v)){const b=[];for(const S of o.slice(l))S==="*"?b.push(m):b.push(S);p(f,b,x)}for(const m of g)delete f[m]}}else{const f=e;d in f&&Nf(f[d],t,o,l+1,s)}}function np(e){if(typeof e!="string")throw new Error("fromImageBytes must be a string");return e}function Vw(e){const t={},o=c(e,["operationName"]);o!=null&&p(t,["operationName"],o);const l=c(e,["resourceName"]);return l!=null&&p(t,["_url","resourceName"],l),t}function Hw(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response","generateVideoResponse"]);return f!=null&&p(t,["response"],$w(f)),t}function Gw(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response"]);return f!=null&&p(t,["response"],qw(f)),t}function $w(e){const t={},o=c(e,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>Yw(f))),p(t,["generatedVideos"],d)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&p(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&p(t,["raiMediaFilteredReasons"],s),t}function qw(e){const t={},o=c(e,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>Jw(f))),p(t,["generatedVideos"],d)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&p(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&p(t,["raiMediaFilteredReasons"],s),t}function Yw(e){const t={},o=c(e,["video"]);return o!=null&&p(t,["video"],eT(o)),t}function Jw(e){const t={},o=c(e,["_self"]);return o!=null&&p(t,["video"],tT(o)),t}function Kw(e){const t={},o=c(e,["operationName"]);return o!=null&&p(t,["_url","operationName"],o),t}function Xw(e){const t={},o=c(e,["operationName"]);return o!=null&&p(t,["_url","operationName"],o),t}function Ww(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response"]);return f!=null&&p(t,["response"],Qw(f)),t}function Qw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&p(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&p(t,["documentName"],s),t}function hv(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response"]);return f!=null&&p(t,["response"],Zw(f)),t}function Zw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&p(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&p(t,["documentName"],s),t}function eT(e){const t={},o=c(e,["uri"]);o!=null&&p(t,["uri"],o);const l=c(e,["encodedVideo"]);l!=null&&p(t,["videoBytes"],np(l));const s=c(e,["encoding"]);return s!=null&&p(t,["mimeType"],s),t}function tT(e){const t={},o=c(e,["gcsUri"]);o!=null&&p(t,["uri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&p(t,["videoBytes"],np(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["mimeType"],s),t}var vg;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(vg||(vg={}));var xg;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(xg||(xg={}));var bg;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(bg||(bg={}));var An;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.STRING="STRING",e.NUMBER="NUMBER",e.INTEGER="INTEGER",e.BOOLEAN="BOOLEAN",e.ARRAY="ARRAY",e.OBJECT="OBJECT",e.NULL="NULL"})(An||(An={}));var Sg;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(Sg||(Sg={}));var wg;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(wg||(wg={}));var Tg;(function(e){e.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",e.NO_AUTH="NO_AUTH",e.API_KEY_AUTH="API_KEY_AUTH",e.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",e.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",e.OAUTH="OAUTH",e.OIDC_AUTH="OIDC_AUTH"})(Tg||(Tg={}));var Cg;(function(e){e.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",e.HTTP_IN_QUERY="HTTP_IN_QUERY",e.HTTP_IN_HEADER="HTTP_IN_HEADER",e.HTTP_IN_PATH="HTTP_IN_PATH",e.HTTP_IN_BODY="HTTP_IN_BODY",e.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(Cg||(Cg={}));var Eg;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",e.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",e.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",e.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(Eg||(Eg={}));var _g;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH",e.MINIMAL="MINIMAL"})(_g||(_g={}));var Ng;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",e.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",e.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",e.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(Ng||(Ng={}));var Ag;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})(Ag||(Ag={}));var Mg;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE",e.OFF="OFF"})(Mg||(Mg={}));var kg;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.SPII="SPII",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.IMAGE_SAFETY="IMAGE_SAFETY",e.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",e.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",e.NO_IMAGE="NO_IMAGE",e.IMAGE_RECITATION="IMAGE_RECITATION",e.IMAGE_OTHER="IMAGE_OTHER"})(kg||(kg={}));var Rg;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(Rg||(Rg={}));var zg;(function(e){e.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",e.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",e.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",e.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",e.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(zg||(zg={}));var Ig;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",e.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",e.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",e.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",e.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Ig||(Ig={}));var Dg;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.IMAGE_SAFETY="IMAGE_SAFETY",e.MODEL_ARMOR="MODEL_ARMOR",e.JAILBREAK="JAILBREAK"})(Dg||(Dg={}));var Lg;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Lg||(Lg={}));var Oc;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(Oc||(Oc={}));var Ug;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Ug||(Ug={}));var Fg;(function(e){e.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",e.TUNING_MODE_FULL="TUNING_MODE_FULL",e.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Fg||(Fg={}));var Pg;(function(e){e.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",e.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",e.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",e.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",e.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",e.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",e.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Pg||(Pg={}));var Af;(function(e){e.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",e.JOB_STATE_QUEUED="JOB_STATE_QUEUED",e.JOB_STATE_PENDING="JOB_STATE_PENDING",e.JOB_STATE_RUNNING="JOB_STATE_RUNNING",e.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",e.JOB_STATE_FAILED="JOB_STATE_FAILED",e.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",e.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",e.JOB_STATE_PAUSED="JOB_STATE_PAUSED",e.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",e.JOB_STATE_UPDATING="JOB_STATE_UPDATING",e.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(Af||(Af={}));var Bg;(function(e){e.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",e.TUNING_TASK_I2V="TUNING_TASK_I2V",e.TUNING_TASK_T2V="TUNING_TASK_T2V",e.TUNING_TASK_R2V="TUNING_TASK_R2V"})(Bg||(Bg={}));var jg;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",e.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(jg||(jg={}));var Og;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(Og||(Og={}));var Vg;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(Vg||(Vg={}));var Hg;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(Hg||(Hg={}));var Gg;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Gg||(Gg={}));var $g;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})($g||($g={}));var qg;(function(e){e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(qg||(qg={}));var Yg;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(Yg||(Yg={}));var Jg;(function(e){e.auto="auto",e.en="en",e.ja="ja",e.ko="ko",e.hi="hi",e.zh="zh",e.pt="pt",e.es="es"})(Jg||(Jg={}));var Kg;(function(e){e.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",e.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",e.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",e.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",e.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Kg||(Kg={}));var Xg;(function(e){e.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",e.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",e.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",e.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Xg||(Xg={}));var Wg;(function(e){e.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",e.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",e.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",e.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Wg||(Wg={}));var Qg;(function(e){e.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",e.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",e.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",e.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",e.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",e.EDIT_MODE_STYLE="EDIT_MODE_STYLE",e.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",e.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Qg||(Qg={}));var Zg;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(Zg||(Zg={}));var ey;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(ey||(ey={}));var ty;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})(ty||(ty={}));var ny;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(ny||(ny={}));var iy;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING"})(iy||(iy={}));var oy;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(oy||(oy={}));var ly;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(ly||(ly={}));var ay;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED"})(ay||(ay={}));var sy;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.RESPONSE_REJECTED="RESPONSE_REJECTED",e.NEED_MORE_INPUT="NEED_MORE_INPUT"})(sy||(sy={}));var ry;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(ry||(ry={}));var cy;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",e.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",e.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(cy||(cy={}));var uy;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(uy||(uy={}));var dy;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(dy||(dy={}));var fy;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(fy||(fy={}));var py;(function(e){e.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(py||(py={}));var hy;(function(e){e.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(hy||(hy={}));var my;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(my||(my={}));var Va;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(Va||(Va={}));class Mf{constructor(t){const o={};for(const l of t.headers.entries())o[l[0]]=l[1];this.headers=o,this.responseInternal=t}json(){return this.responseInternal.json()}}class Vs{get text(){var t,o,l,s,d,f,g,v;if(((s=(l=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||l===void 0?void 0:l.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let m="",x=!1;const b=[];for(const S of(v=(g=(f=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content)===null||g===void 0?void 0:g.parts)!==null&&v!==void 0?v:[]){for(const[_,T]of Object.entries(S))_!=="text"&&_!=="thought"&&_!=="thoughtSignature"&&(T!==null||T!==void 0)&&b.push(_);if(typeof S.text=="string"){if(typeof S.thought=="boolean"&&S.thought)continue;x=!0,m+=S.text}}return b.length>0&&console.warn(`there are non-text parts ${b} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),x?m:void 0}get data(){var t,o,l,s,d,f,g,v;if(((s=(l=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||l===void 0?void 0:l.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let m="";const x=[];for(const b of(v=(g=(f=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content)===null||g===void 0?void 0:g.parts)!==null&&v!==void 0?v:[]){for(const[S,_]of Object.entries(b))S!=="inlineData"&&(_!==null||_!==void 0)&&x.push(S);b.inlineData&&typeof b.inlineData.data=="string"&&(m+=atob(b.inlineData.data))}return x.length>0&&console.warn(`there are non-data parts ${x} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),m.length>0?btoa(m):void 0}get functionCalls(){var t,o,l,s,d,f,g,v;if(((s=(l=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||l===void 0?void 0:l.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const m=(v=(g=(f=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content)===null||g===void 0?void 0:g.parts)===null||v===void 0?void 0:v.filter(x=>x.functionCall).map(x=>x.functionCall).filter(x=>x!==void 0);if(m?.length!==0)return m}get executableCode(){var t,o,l,s,d,f,g,v,m;if(((s=(l=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||l===void 0?void 0:l.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const x=(v=(g=(f=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content)===null||g===void 0?void 0:g.parts)===null||v===void 0?void 0:v.filter(b=>b.executableCode).map(b=>b.executableCode).filter(b=>b!==void 0);if(x?.length!==0)return(m=x?.[0])===null||m===void 0?void 0:m.code}get codeExecutionResult(){var t,o,l,s,d,f,g,v,m;if(((s=(l=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||l===void 0?void 0:l.parts)===null||s===void 0?void 0:s.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const x=(v=(g=(f=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content)===null||g===void 0?void 0:g.parts)===null||v===void 0?void 0:v.filter(b=>b.codeExecutionResult).map(b=>b.codeExecutionResult).filter(b=>b!==void 0);if(x?.length!==0)return(m=x?.[0])===null||m===void 0?void 0:m.output}}class gy{}class yy{}class nT{}class iT{}class oT{}class lT{}class vy{}class xy{}class by{}class aT{}class Vc{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new Vc;let s;const d=t;return o?s=Gw(d):s=Hw(d),Object.assign(l,s),l}}class Sy{}class wy{}class Ty{}class Cy{}class sT{}class rT{}class cT{}class ip{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new ip,d=Ww(t);return Object.assign(l,d),l}}class uT{}class dT{}class fT{}class Ey{}class pT{get text(){var t,o,l;let s="",d=!1;const f=[];for(const g of(l=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&l!==void 0?l:[]){for(const[v,m]of Object.entries(g))v!=="text"&&v!=="thought"&&m!==null&&f.push(v);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;d=!0,s+=g.text}}return f.length>0&&console.warn(`there are non-text parts ${f} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),d?s:void 0}get data(){var t,o,l;let s="";const d=[];for(const f of(l=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&l!==void 0?l:[]){for(const[g,v]of Object.entries(f))g!=="inlineData"&&v!==null&&d.push(g);f.inlineData&&typeof f.inlineData.data=="string"&&(s+=atob(f.inlineData.data))}return d.length>0&&console.warn(`there are non-data parts ${d} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),s.length>0?btoa(s):void 0}}class hT{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class op{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new op,d=hv(t);return Object.assign(l,d),l}}function sn(e,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw new Error("invalid model parameter");if(e.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const o=t.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function mv(e,t){const o=sn(e,t);return o?o.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${o}`:o.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${o}`:o:""}function gv(e){return Array.isArray(e)?e.map(t=>Hc(t)):[Hc(e)]}function Hc(e){if(typeof e=="object"&&e!==null)return e;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function yv(e){const t=Hc(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function vv(e){const t=Hc(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function _y(e){if(e==null)throw new Error("PartUnion is required");if(typeof e=="object")return e;if(typeof e=="string")return{text:e};throw new Error(`Unsupported part type: ${typeof e}`)}function xv(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("PartListUnion is required");return Array.isArray(e)?e.map(t=>_y(t)):[_y(e)]}function kf(e){return e!=null&&typeof e=="object"&&"parts"in e&&Array.isArray(e.parts)}function Ny(e){return e!=null&&typeof e=="object"&&"functionCall"in e}function Ay(e){return e!=null&&typeof e=="object"&&"functionResponse"in e}function hi(e){if(e==null)throw new Error("ContentUnion is required");return kf(e)?e:{role:"user",parts:xv(e)}}function lp(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(o=>{const l=hi(o);return l.parts&&l.parts.length>0&&l.parts[0].text!==void 0?[l.parts[0].text]:[]});if(e.isVertexAI()){const o=hi(t);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(t)?t.map(o=>hi(o)):[hi(t)]}function Zi(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("contents are required");if(!Array.isArray(e)){if(Ny(e)||Ay(e))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[hi(e)]}const t=[],o=[],l=kf(e[0]);for(const s of e){const d=kf(s);if(d!=l)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(d)t.push(s);else{if(Ny(s)||Ay(s))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");o.push(s)}}return l||t.push({role:"user",parts:xv(o)}),t}function mT(e,t){e.includes("null")&&(t.nullable=!0);const o=e.filter(l=>l!=="null");if(o.length===1)t.type=Object.values(An).includes(o[0].toUpperCase())?o[0].toUpperCase():An.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const l of o)t.anyOf.push({type:Object.values(An).includes(l.toUpperCase())?l.toUpperCase():An.TYPE_UNSPECIFIED})}}function qa(e){const t={},o=["items"],l=["anyOf"],s=["properties"];if(e.type&&e.anyOf)throw new Error("type and anyOf cannot be both populated.");const d=e.anyOf;d!=null&&d.length==2&&(d[0].type==="null"?(t.nullable=!0,e=d[1]):d[1].type==="null"&&(t.nullable=!0,e=d[0])),e.type instanceof Array&&mT(e.type,t);for(const[f,g]of Object.entries(e))if(g!=null)if(f=="type"){if(g==="null")throw new Error("type: null can not be the only possible type for the field.");if(g instanceof Array)continue;t.type=Object.values(An).includes(g.toUpperCase())?g.toUpperCase():An.TYPE_UNSPECIFIED}else if(o.includes(f))t[f]=qa(g);else if(l.includes(f)){const v=[];for(const m of g){if(m.type=="null"){t.nullable=!0;continue}v.push(qa(m))}t[f]=v}else if(s.includes(f)){const v={};for(const[m,x]of Object.entries(g))v[m]=qa(x);t[f]=v}else{if(f==="additionalProperties")continue;t[f]=g}return t}function ap(e){return qa(e)}function sp(e){if(typeof e=="object")return e;if(typeof e=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw new Error(`Unsupported speechConfig type: ${typeof e}`)}function rp(e){if("multiSpeakerVoiceConfig"in e)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function Qa(e){if(e.functionDeclarations)for(const t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=qa(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=qa(t.response));return e}function Za(e){if(e==null)throw new Error("tools is required");if(!Array.isArray(e))throw new Error("tools is required and must be an array of Tools");const t=[];for(const o of e)t.push(o);return t}function gT(e,t,o,l=1){const s=!t.startsWith(`${o}/`)&&t.split("/").length===l;return e.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${e.getProject()}/${t}`:t.startsWith(`${o}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:s?`projects/${e.getProject()}/locations/${e.getLocation()}/${o}/${t}`:t:s?`${o}/${t}`:t}function Ko(e,t){if(typeof t!="string")throw new Error("name must be a string");return gT(e,t,"cachedContents")}function bv(e){switch(e){case"STATE_UNSPECIFIED":return"JOB_STATE_UNSPECIFIED";case"CREATING":return"JOB_STATE_RUNNING";case"ACTIVE":return"JOB_STATE_SUCCEEDED";case"FAILED":return"JOB_STATE_FAILED";default:return e}}function Nl(e){return np(e)}function yT(e){return e!=null&&typeof e=="object"&&"name"in e}function vT(e){return e!=null&&typeof e=="object"&&"video"in e}function xT(e){return e!=null&&typeof e=="object"&&"uri"in e}function Sv(e){var t;let o;if(yT(e)&&(o=e.name),!(xT(e)&&(o=e.uri,o===void 0))&&!(vT(e)&&(o=(t=e.video)===null||t===void 0?void 0:t.uri,o===void 0))){if(typeof e=="string"&&(o=e),o===void 0)throw new Error("Could not extract file name from the provided input.");if(o.startsWith("https://")){const s=o.split("files/")[1].match(/[a-z0-9]+/);if(s===null)throw new Error(`Could not extract file name from URI ${o}`);o=s[0]}else o.startsWith("files/")&&(o=o.split("files/")[1]);return o}}function wv(e,t){let o;return e.isVertexAI()?o=t?"publishers/google/models":"models":o=t?"models":"tunedModels",o}function Tv(e){for(const t of["models","tunedModels","publisherModels"])if(bT(e,t))return e[t];return[]}function bT(e,t){return e!==null&&typeof e=="object"&&t in e}function ST(e,t={}){const o=e,l={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(l.responseJsonSchema=o.outputSchema),t.behavior&&(l.behavior=t.behavior),{functionDeclarations:[l]}}function wT(e,t={}){const o=[],l=new Set;for(const s of e){const d=s.name;if(l.has(d))throw new Error(`Duplicate function name ${d} found in MCP tools. Please ensure function names are unique.`);l.add(d);const f=ST(s,t);f.functionDeclarations&&o.push(...f.functionDeclarations)}return{functionDeclarations:o}}function Cv(e,t){let o;if(typeof t=="string")if(e.isVertexAI())if(t.startsWith("gs://"))o={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))o={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))o={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:t}}else o=t;const l=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,s=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(e.isVertexAI()){if(s>0||l!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(l>0||s!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return o}function TT(e){if(typeof e!="string")return e;const t=e;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}function Ev(e){if(typeof e!="object"||e===null)return{};const t=e,o=t.inlinedResponses;if(typeof o!="object"||o===null)return e;const s=o.inlinedResponses;if(!Array.isArray(s)||s.length===0)return e;let d=!1;for(const f of s){if(typeof f!="object"||f===null)continue;const v=f.response;if(typeof v!="object"||v===null)continue;if(v.embedding!==void 0){d=!0;break}}return d&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function es(e,t){const o=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(o))return o.split("/").pop();throw new Error(`Invalid batch job name: ${o}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(o))return o.split("/").pop();if(/^\d+$/.test(o))return o;throw new Error(`Invalid batch job name: ${o}.`)}function _v(e){const t=e;return t==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":t==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":t==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":t==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":t==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":t==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":t==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":t}function CT(e){const t={},o=c(e,["responsesFile"]);o!=null&&p(t,["fileName"],o);const l=c(e,["inlinedResponses","inlinedResponses"]);if(l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>oC(f))),p(t,["inlinedResponses"],d)}const s=c(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["inlinedEmbedContentResponses"],d)}return t}function ET(e){const t={},o=c(e,["predictionsFormat"]);o!=null&&p(t,["format"],o);const l=c(e,["gcsDestination","outputUriPrefix"]);l!=null&&p(t,["gcsUri"],l);const s=c(e,["bigqueryDestination","outputUri"]);return s!=null&&p(t,["bigqueryUri"],s),t}function _T(e){const t={},o=c(e,["format"]);o!=null&&p(t,["predictionsFormat"],o);const l=c(e,["gcsUri"]);l!=null&&p(t,["gcsDestination","outputUriPrefix"],l);const s=c(e,["bigqueryUri"]);if(s!=null&&p(t,["bigqueryDestination","outputUri"],s),c(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(c(e,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(c(e,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function Mc(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata","displayName"]);l!=null&&p(t,["displayName"],l);const s=c(e,["metadata","state"]);s!=null&&p(t,["state"],_v(s));const d=c(e,["metadata","createTime"]);d!=null&&p(t,["createTime"],d);const f=c(e,["metadata","endTime"]);f!=null&&p(t,["endTime"],f);const g=c(e,["metadata","updateTime"]);g!=null&&p(t,["updateTime"],g);const v=c(e,["metadata","model"]);v!=null&&p(t,["model"],v);const m=c(e,["metadata","output"]);return m!=null&&p(t,["dest"],CT(Ev(m))),t}function Rf(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["displayName"]);l!=null&&p(t,["displayName"],l);const s=c(e,["state"]);s!=null&&p(t,["state"],_v(s));const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["createTime"]);f!=null&&p(t,["createTime"],f);const g=c(e,["startTime"]);g!=null&&p(t,["startTime"],g);const v=c(e,["endTime"]);v!=null&&p(t,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&p(t,["updateTime"],m);const x=c(e,["model"]);x!=null&&p(t,["model"],x);const b=c(e,["inputConfig"]);b!=null&&p(t,["src"],NT(b));const S=c(e,["outputConfig"]);S!=null&&p(t,["dest"],ET(Ev(S)));const _=c(e,["completionStats"]);return _!=null&&p(t,["completionStats"],_),t}function NT(e){const t={},o=c(e,["instancesFormat"]);o!=null&&p(t,["format"],o);const l=c(e,["gcsSource","uris"]);l!=null&&p(t,["gcsUri"],l);const s=c(e,["bigquerySource","inputUri"]);return s!=null&&p(t,["bigqueryUri"],s),t}function AT(e,t){const o={};if(c(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(c(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(c(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const l=c(t,["fileName"]);l!=null&&p(o,["fileName"],l);const s=c(t,["inlinedRequests"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>iC(e,f))),p(o,["requests","requests"],d)}return o}function MT(e){const t={},o=c(e,["format"]);o!=null&&p(t,["instancesFormat"],o);const l=c(e,["gcsUri"]);l!=null&&p(t,["gcsSource","uris"],l);const s=c(e,["bigqueryUri"]);if(s!=null&&p(t,["bigquerySource","inputUri"],s),c(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(c(e,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function kT(e){const t={},o=c(e,["data"]);if(o!=null&&p(t,["data"],o),c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function RT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function zT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function IT(e){const t={},o=c(e,["content"]);o!=null&&p(t,["content"],o);const l=c(e,["citationMetadata"]);l!=null&&p(t,["citationMetadata"],DT(l));const s=c(e,["tokenCount"]);s!=null&&p(t,["tokenCount"],s);const d=c(e,["finishReason"]);d!=null&&p(t,["finishReason"],d);const f=c(e,["avgLogprobs"]);f!=null&&p(t,["avgLogprobs"],f);const g=c(e,["groundingMetadata"]);g!=null&&p(t,["groundingMetadata"],g);const v=c(e,["index"]);v!=null&&p(t,["index"],v);const m=c(e,["logprobsResult"]);m!=null&&p(t,["logprobsResult"],m);const x=c(e,["safetyRatings"]);if(x!=null){let S=x;Array.isArray(S)&&(S=S.map(_=>_)),p(t,["safetyRatings"],S)}const b=c(e,["urlContextMetadata"]);return b!=null&&p(t,["urlContextMetadata"],b),t}function DT(e){const t={},o=c(e,["citationSources"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),p(t,["citations"],l)}return t}function Nv(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(d=>dC(d))),p(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&p(t,["role"],l),t}function LT(e,t){const o={},l=c(e,["displayName"]);if(t!==void 0&&l!=null&&p(t,["batch","displayName"],l),c(e,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function UT(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&p(t,["displayName"],l);const s=c(e,["dest"]);return t!==void 0&&s!=null&&p(t,["outputConfig"],_T(TT(s))),o}function My(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["src"]);s!=null&&p(o,["batch","inputConfig"],AT(e,Cv(e,s)));const d=c(t,["config"]);return d!=null&<(d,o),o}function FT(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["model"],sn(e,l));const s=c(t,["src"]);s!=null&&p(o,["inputConfig"],MT(Cv(e,s)));const d=c(t,["config"]);return d!=null&&UT(d,o),o}function PT(e,t){const o={},l=c(e,["displayName"]);return t!==void 0&&l!=null&&p(t,["batch","displayName"],l),o}function BT(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["src"]);s!=null&&p(o,["batch","inputConfig"],qT(e,s));const d=c(t,["config"]);return d!=null&&PT(d,o),o}function jT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function OT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function VT(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["name"]);l!=null&&p(t,["name"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);return d!=null&&p(t,["error"],d),t}function HT(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["name"]);l!=null&&p(t,["name"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);return d!=null&&p(t,["error"],d),t}function GT(e,t){const o={},l=c(t,["contents"]);if(l!=null){let d=lp(e,l);Array.isArray(d)&&(d=d.map(f=>f)),p(o,["requests[]","request","content"],d)}const s=c(t,["config"]);return s!=null&&(p(o,["_self"],$T(s,o)),Ow(o,{"requests[].*":"requests[].request.*"})),o}function $T(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&p(t,["requests[]","taskType"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&p(t,["requests[]","title"],s);const d=c(e,["outputDimensionality"]);if(t!==void 0&&d!=null&&p(t,["requests[]","outputDimensionality"],d),c(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(c(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function qT(e,t){const o={},l=c(t,["fileName"]);l!=null&&p(o,["file_name"],l);const s=c(t,["inlinedRequests"]);return s!=null&&p(o,["requests"],GT(e,s)),o}function YT(e){const t={};if(c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=c(e,["fileUri"]);o!=null&&p(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function JT(e){const t={},o=c(e,["id"]);o!=null&&p(t,["id"],o);const l=c(e,["args"]);l!=null&&p(t,["args"],l);const s=c(e,["name"]);if(s!=null&&p(t,["name"],s),c(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(c(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function KT(e){const t={},o=c(e,["mode"]);o!=null&&p(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&p(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function XT(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&p(o,["systemInstruction"],Nv(hi(s)));const d=c(t,["temperature"]);d!=null&&p(l,["temperature"],d);const f=c(t,["topP"]);f!=null&&p(l,["topP"],f);const g=c(t,["topK"]);g!=null&&p(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&p(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&p(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&p(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&p(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&p(l,["logprobs"],S);const _=c(t,["presencePenalty"]);_!=null&&p(l,["presencePenalty"],_);const T=c(t,["frequencyPenalty"]);T!=null&&p(l,["frequencyPenalty"],T);const F=c(t,["seed"]);F!=null&&p(l,["seed"],F);const z=c(t,["responseMimeType"]);z!=null&&p(l,["responseMimeType"],z);const G=c(t,["responseSchema"]);G!=null&&p(l,["responseSchema"],ap(G));const Y=c(t,["responseJsonSchema"]);if(Y!=null&&p(l,["responseJsonSchema"],Y),c(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(c(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const oe=c(t,["safetySettings"]);if(o!==void 0&&oe!=null){let nt=oe;Array.isArray(nt)&&(nt=nt.map(it=>fC(it))),p(o,["safetySettings"],nt)}const ce=c(t,["tools"]);if(o!==void 0&&ce!=null){let nt=Za(ce);Array.isArray(nt)&&(nt=nt.map(it=>hC(Qa(it)))),p(o,["tools"],nt)}const ve=c(t,["toolConfig"]);if(o!==void 0&&ve!=null&&p(o,["toolConfig"],pC(ve)),c(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ye=c(t,["cachedContent"]);o!==void 0&&ye!=null&&p(o,["cachedContent"],Ko(e,ye));const fe=c(t,["responseModalities"]);fe!=null&&p(l,["responseModalities"],fe);const Je=c(t,["mediaResolution"]);Je!=null&&p(l,["mediaResolution"],Je);const ge=c(t,["speechConfig"]);if(ge!=null&&p(l,["speechConfig"],sp(ge)),c(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const qe=c(t,["thinkingConfig"]);qe!=null&&p(l,["thinkingConfig"],qe);const Ve=c(t,["imageConfig"]);Ve!=null&&p(l,["imageConfig"],nC(Ve));const Ke=c(t,["enableEnhancedCivicAnswers"]);return Ke!=null&&p(l,["enableEnhancedCivicAnswers"],Ke),l}function WT(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(m=>IT(m))),p(t,["candidates"],v)}const s=c(e,["modelVersion"]);s!=null&&p(t,["modelVersion"],s);const d=c(e,["promptFeedback"]);d!=null&&p(t,["promptFeedback"],d);const f=c(e,["responseId"]);f!=null&&p(t,["responseId"],f);const g=c(e,["usageMetadata"]);return g!=null&&p(t,["usageMetadata"],g),t}function QT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function ZT(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],es(e,l)),o}function eC(e){const t={};if(c(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=c(e,["enableWidget"]);return o!=null&&p(t,["enableWidget"],o),t}function tC(e){const t={};if(c(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(c(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=c(e,["timeRangeFilter"]);return o!=null&&p(t,["timeRangeFilter"],o),t}function nC(e){const t={},o=c(e,["aspectRatio"]);o!=null&&p(t,["aspectRatio"],o);const l=c(e,["imageSize"]);if(l!=null&&p(t,["imageSize"],l),c(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(c(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function iC(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["request","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let g=Zi(s);Array.isArray(g)&&(g=g.map(v=>Nv(v))),p(o,["request","contents"],g)}const d=c(t,["metadata"]);d!=null&&p(o,["metadata"],d);const f=c(t,["config"]);return f!=null&&p(o,["request","generationConfig"],XT(e,f,c(o,["request"],{}))),o}function oC(e){const t={},o=c(e,["response"]);o!=null&&p(t,["response"],WT(o));const l=c(e,["error"]);return l!=null&&p(t,["error"],l),t}function lC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);if(t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),c(e,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function aC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);t!==void 0&&s!=null&&p(t,["_query","pageToken"],s);const d=c(e,["filter"]);return t!==void 0&&d!=null&&p(t,["_query","filter"],d),o}function sC(e){const t={},o=c(e,["config"]);return o!=null&&lC(o,t),t}function rC(e){const t={},o=c(e,["config"]);return o!=null&&aC(o,t),t}function cC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["operations"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>Mc(f))),p(t,["batchJobs"],d)}return t}function uC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["batchPredictionJobs"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>Rf(f))),p(t,["batchJobs"],d)}return t}function dC(e){const t={},o=c(e,["mediaResolution"]);o!=null&&p(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&p(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&p(t,["executableCode"],s);const d=c(e,["fileData"]);d!=null&&p(t,["fileData"],YT(d));const f=c(e,["functionCall"]);f!=null&&p(t,["functionCall"],JT(f));const g=c(e,["functionResponse"]);g!=null&&p(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&p(t,["inlineData"],kT(v));const m=c(e,["text"]);m!=null&&p(t,["text"],m);const x=c(e,["thought"]);x!=null&&p(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&p(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&p(t,["videoMetadata"],S),t}function fC(e){const t={},o=c(e,["category"]);if(o!=null&&p(t,["category"],o),c(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const l=c(e,["threshold"]);return l!=null&&p(t,["threshold"],l),t}function pC(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&p(t,["functionCallingConfig"],KT(o));const l=c(e,["retrievalConfig"]);return l!=null&&p(t,["retrievalConfig"],l),t}function hC(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),p(t,["functionDeclarations"],x)}if(c(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=c(e,["googleSearchRetrieval"]);l!=null&&p(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&p(t,["computerUse"],s);const d=c(e,["fileSearch"]);d!=null&&p(t,["fileSearch"],d);const f=c(e,["codeExecution"]);if(f!=null&&p(t,["codeExecution"],f),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&p(t,["googleMaps"],eC(g));const v=c(e,["googleSearch"]);v!=null&&p(t,["googleSearch"],tC(v));const m=c(e,["urlContext"]);return m!=null&&p(t,["urlContext"],m),t}var Yo;(function(e){e.PAGED_ITEM_BATCH_JOBS="batchJobs",e.PAGED_ITEM_MODELS="models",e.PAGED_ITEM_TUNING_JOBS="tuningJobs",e.PAGED_ITEM_FILES="files",e.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e.PAGED_ITEM_DOCUMENTS="documents"})(Yo||(Yo={}));class ea{constructor(t,o,l,s){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(t,l,s)}init(t,o,l){var s,d;this.nameInternal=t,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o?.sdkHttpResponse,this.idxInternal=0;let f={config:{}};!l||Object.keys(l).length===0?f={config:{}}:typeof l=="object"?f=Object.assign({},l):f=l,f.config&&(f.config.pageToken=o.nextPageToken),this.paramsInternal=f,this.pageInternalSize=(d=(s=f.config)===null||s===void 0?void 0:s.pageSize)!==null&&d!==void 0?d:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}class mC extends Jo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new ea(Yo.PAGED_ITEM_BATCH_JOBS,l=>this.listInternal(l),await this.listInternal(o),o),this.create=async o=>(this.apiClient.isVertexAI()&&(o.config=this.formatDestination(o.src,o.config)),this.createInternal(o)),this.createEmbeddings=async o=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(o)}}createInlinedGenerateContentRequest(t){const o=My(this.apiClient,t),l=o._url,s=Ze("{model}:batchGenerateContent",l),g=o.batch.inputConfig.requests,v=g.requests,m=[];for(const x of v){const b=Object.assign({},x);if(b.systemInstruction){const S=b.systemInstruction;delete b.systemInstruction;const _=b.request;_.systemInstruction=S,b.request=_}m.push(b)}return g.requests=m,delete o.config,delete o._url,delete o._query,{path:s,body:o}}getGcsUri(t){if(typeof t=="string")return t.startsWith("gs://")?t:void 0;if(!Array.isArray(t)&&t.gcsUri&&t.gcsUri.length>0)return t.gcsUri[0]}getBigqueryUri(t){if(typeof t=="string")return t.startsWith("bq://")?t:void 0;if(!Array.isArray(t))return t.bigqueryUri}formatDestination(t,o){const l=o?Object.assign({},o):{},s=Date.now().toString();if(l.displayName||(l.displayName=`genaiBatchJob_${s}`),l.dest===void 0){const d=this.getGcsUri(t),f=this.getBigqueryUri(t);if(d)d.endsWith(".jsonl")?l.dest=`${d.slice(0,-6)}/dest`:l.dest=`${d}_dest_${s}`;else if(f)l.dest=`${f}_dest_${s}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return l}async createInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=FT(this.apiClient,t);return g=Ze("batchPredictionJobs",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>Rf(x))}else{const m=My(this.apiClient,t);return g=Ze("{model}:batchGenerateContent",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>Mc(x))}}async createEmbeddingsInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=BT(this.apiClient,t);return d=Ze("{model}:asyncBatchEmbedContent",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>Mc(v))}}async get(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=ZT(this.apiClient,t);return g=Ze("batchPredictionJobs/{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>Rf(x))}else{const m=QT(this.apiClient,t);return g=Ze("batches/{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>Mc(x))}}async cancel(t){var o,l,s,d;let f="",g={};if(this.apiClient.isVertexAI()){const v=zT(this.apiClient,t);f=Ze("batchPredictionJobs/{name}:cancel",v._url),g=v._query,delete v._url,delete v._query,await this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(v),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal})}else{const v=RT(this.apiClient,t);f=Ze("batches/{name}:cancel",v._url),g=v._query,delete v._url,delete v._query,await this.apiClient.request({path:f,queryParams:g,body:JSON.stringify(v),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal})}}async listInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=rC(t);return g=Ze("batchPredictionJobs",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=uC(x),S=new Ey;return Object.assign(S,b),S})}else{const m=sC(t);return g=Ze("batches",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=cC(x),S=new Ey;return Object.assign(S,b),S})}}async delete(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=OT(this.apiClient,t);return g=Ze("batchPredictionJobs/{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>HT(x))}else{const m=jT(this.apiClient,t);return g=Ze("batches/{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>VT(x))}}}function gC(e){const t={},o=c(e,["data"]);if(o!=null&&p(t,["data"],o),c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function ky(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(d=>BC(d))),p(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&p(t,["role"],l),t}function yC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&p(t,["ttl"],l);const s=c(e,["expireTime"]);t!==void 0&&s!=null&&p(t,["expireTime"],s);const d=c(e,["displayName"]);t!==void 0&&d!=null&&p(t,["displayName"],d);const f=c(e,["contents"]);if(t!==void 0&&f!=null){let x=Zi(f);Array.isArray(x)&&(x=x.map(b=>ky(b))),p(t,["contents"],x)}const g=c(e,["systemInstruction"]);t!==void 0&&g!=null&&p(t,["systemInstruction"],ky(hi(g)));const v=c(e,["tools"]);if(t!==void 0&&v!=null){let x=v;Array.isArray(x)&&(x=x.map(b=>OC(b))),p(t,["tools"],x)}const m=c(e,["toolConfig"]);if(t!==void 0&&m!=null&&p(t,["toolConfig"],jC(m)),c(e,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function vC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&p(t,["ttl"],l);const s=c(e,["expireTime"]);t!==void 0&&s!=null&&p(t,["expireTime"],s);const d=c(e,["displayName"]);t!==void 0&&d!=null&&p(t,["displayName"],d);const f=c(e,["contents"]);if(t!==void 0&&f!=null){let b=Zi(f);Array.isArray(b)&&(b=b.map(S=>S)),p(t,["contents"],b)}const g=c(e,["systemInstruction"]);t!==void 0&&g!=null&&p(t,["systemInstruction"],hi(g));const v=c(e,["tools"]);if(t!==void 0&&v!=null){let b=v;Array.isArray(b)&&(b=b.map(S=>VC(S))),p(t,["tools"],b)}const m=c(e,["toolConfig"]);t!==void 0&&m!=null&&p(t,["toolConfig"],m);const x=c(e,["kmsKeyName"]);return t!==void 0&&x!=null&&p(t,["encryption_spec","kmsKeyName"],x),o}function xC(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["model"],mv(e,l));const s=c(t,["config"]);return s!=null&&yC(s,o),o}function bC(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["model"],mv(e,l));const s=c(t,["config"]);return s!=null&&vC(s,o),o}function SC(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],Ko(e,l)),o}function wC(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],Ko(e,l)),o}function TC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function CC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function EC(e){const t={};if(c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=c(e,["fileUri"]);o!=null&&p(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function _C(e){const t={},o=c(e,["id"]);o!=null&&p(t,["id"],o);const l=c(e,["args"]);l!=null&&p(t,["args"],l);const s=c(e,["name"]);if(s!=null&&p(t,["name"],s),c(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(c(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function NC(e){const t={},o=c(e,["mode"]);o!=null&&p(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&p(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function AC(e){const t={};if(c(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=c(e,["description"]);o!=null&&p(t,["description"],o);const l=c(e,["name"]);l!=null&&p(t,["name"],l);const s=c(e,["parameters"]);s!=null&&p(t,["parameters"],s);const d=c(e,["parametersJsonSchema"]);d!=null&&p(t,["parametersJsonSchema"],d);const f=c(e,["response"]);f!=null&&p(t,["response"],f);const g=c(e,["responseJsonSchema"]);return g!=null&&p(t,["responseJsonSchema"],g),t}function MC(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],Ko(e,l)),o}function kC(e,t){const o={},l=c(t,["name"]);return l!=null&&p(o,["_url","name"],Ko(e,l)),o}function RC(e){const t={};if(c(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=c(e,["enableWidget"]);return o!=null&&p(t,["enableWidget"],o),t}function zC(e){const t={};if(c(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(c(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=c(e,["timeRangeFilter"]);return o!=null&&p(t,["timeRangeFilter"],o),t}function IC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),o}function DC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),o}function LC(e){const t={},o=c(e,["config"]);return o!=null&&IC(o,t),t}function UC(e){const t={},o=c(e,["config"]);return o!=null&&DC(o,t),t}function FC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["cachedContents"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["cachedContents"],d)}return t}function PC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["cachedContents"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["cachedContents"],d)}return t}function BC(e){const t={},o=c(e,["mediaResolution"]);o!=null&&p(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&p(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&p(t,["executableCode"],s);const d=c(e,["fileData"]);d!=null&&p(t,["fileData"],EC(d));const f=c(e,["functionCall"]);f!=null&&p(t,["functionCall"],_C(f));const g=c(e,["functionResponse"]);g!=null&&p(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&p(t,["inlineData"],gC(v));const m=c(e,["text"]);m!=null&&p(t,["text"],m);const x=c(e,["thought"]);x!=null&&p(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&p(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&p(t,["videoMetadata"],S),t}function jC(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&p(t,["functionCallingConfig"],NC(o));const l=c(e,["retrievalConfig"]);return l!=null&&p(t,["retrievalConfig"],l),t}function OC(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),p(t,["functionDeclarations"],x)}if(c(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=c(e,["googleSearchRetrieval"]);l!=null&&p(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&p(t,["computerUse"],s);const d=c(e,["fileSearch"]);d!=null&&p(t,["fileSearch"],d);const f=c(e,["codeExecution"]);if(f!=null&&p(t,["codeExecution"],f),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&p(t,["googleMaps"],RC(g));const v=c(e,["googleSearch"]);v!=null&&p(t,["googleSearch"],zC(v));const m=c(e,["urlContext"]);return m!=null&&p(t,["urlContext"],m),t}function VC(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>AC(S))),p(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&p(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&p(t,["googleSearchRetrieval"],s);const d=c(e,["computerUse"]);if(d!=null&&p(t,["computerUse"],d),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const f=c(e,["codeExecution"]);f!=null&&p(t,["codeExecution"],f);const g=c(e,["enterpriseWebSearch"]);g!=null&&p(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&p(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&p(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&p(t,["urlContext"],x),t}function HC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&p(t,["ttl"],l);const s=c(e,["expireTime"]);return t!==void 0&&s!=null&&p(t,["expireTime"],s),o}function GC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&p(t,["ttl"],l);const s=c(e,["expireTime"]);return t!==void 0&&s!=null&&p(t,["expireTime"],s),o}function $C(e,t){const o={},l=c(t,["name"]);l!=null&&p(o,["_url","name"],Ko(e,l));const s=c(t,["config"]);return s!=null&&HC(s,o),o}function qC(e,t){const o={},l=c(t,["name"]);l!=null&&p(o,["_url","name"],Ko(e,l));const s=c(t,["config"]);return s!=null&&GC(s,o),o}class YC extends Jo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new ea(Yo.PAGED_ITEM_CACHED_CONTENTS,l=>this.listInternal(l),await this.listInternal(o),o)}async create(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=bC(this.apiClient,t);return g=Ze("cachedContents",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>x)}else{const m=xC(this.apiClient,t);return g=Ze("cachedContents",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>x)}}async get(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=kC(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>x)}else{const m=MC(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>x)}}async delete(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=wC(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=CC(x),S=new Ty;return Object.assign(S,b),S})}else{const m=SC(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=TC(x),S=new Ty;return Object.assign(S,b),S})}}async update(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=qC(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>x)}else{const m=$C(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>x)}}async listInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=UC(t);return g=Ze("cachedContents",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=PC(x),S=new Cy;return Object.assign(S,b),S})}else{const m=LC(t);return g=Ze("cachedContents",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=FC(x),S=new Cy;return Object.assign(S,b),S})}}}function Gc(e,t){var o={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&t.indexOf(l)<0&&(o[l]=e[l]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,l=Object.getOwnPropertySymbols(e);s=e.length&&(e=void 0),{value:e&&e[l++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rt(e){return this instanceof Rt?(this.v=e,this):new Rt(e)}function uo(e,t,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var l=o.apply(e,t||[]),s,d=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",f),s[Symbol.asyncIterator]=function(){return this},s;function f(_){return function(T){return Promise.resolve(T).then(_,b)}}function g(_,T){l[_]&&(s[_]=function(F){return new Promise(function(z,G){d.push([_,F,z,G])>1||v(_,F)})},T&&(s[_]=T(s[_])))}function v(_,T){try{m(l[_](T))}catch(F){S(d[0][3],F)}}function m(_){_.value instanceof Rt?Promise.resolve(_.value.v).then(x,b):S(d[0][2],_)}function x(_){v("next",_)}function b(_){v("throw",_)}function S(_,T){_(T),d.shift(),d.length&&v(d[0][0],d[0][1])}}function fo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],o;return t?t.call(e):(e=typeof Ry=="function"?Ry(e):e[Symbol.iterator](),o={},l("next"),l("throw"),l("return"),o[Symbol.asyncIterator]=function(){return this},o);function l(d){o[d]=e[d]&&function(f){return new Promise(function(g,v){f=e[d](f),s(g,v,f.done,f.value)})}}function s(d,f,g,v){Promise.resolve(v).then(function(m){d({value:m,done:g})},f)}}function JC(e){var t;if(e.candidates==null||e.candidates.length===0)return!1;const o=(t=e.candidates[0])===null||t===void 0?void 0:t.content;return o===void 0?!1:Av(o)}function Av(e){if(e.parts===void 0||e.parts.length===0)return!1;for(const t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function KC(e){if(e.length!==0){for(const t of e)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function zy(e){if(e===void 0||e.length===0)return[];const t=[],o=e.length;let l=0;for(;l{var d,f,g;const v=await s,m=(f=(d=v.candidates)===null||d===void 0?void 0:d[0])===null||f===void 0?void 0:f.content,x=v.automaticFunctionCallingHistory,b=this.getHistory(!0).length;let S=[];x!=null&&(S=(g=x.slice(b))!==null&&g!==void 0?g:[]);const _=m?[m]:[];this.recordHistory(l,_,S)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),s}async sendMessageStream(t){var o;await this.sendPromise;const l=hi(t.message),s=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(l),config:(o=t.config)!==null&&o!==void 0?o:this.config});this.sendPromise=s.then(()=>{}).catch(()=>{});const d=await s;return this.processStreamResponse(d,l)}getHistory(t=!1){const o=t?zy(this.history):this.history;return structuredClone(o)}processStreamResponse(t,o){return uo(this,arguments,function*(){var s,d,f,g,v,m;const x=[];try{for(var b=!0,S=fo(t),_;_=yield Rt(S.next()),s=_.done,!s;b=!0){g=_.value,b=!1;const T=g;if(JC(T)){const F=(m=(v=T.candidates)===null||v===void 0?void 0:v[0])===null||m===void 0?void 0:m.content;F!==void 0&&x.push(F)}yield yield Rt(T)}}catch(T){d={error:T}}finally{try{!b&&!s&&(f=S.return)&&(yield Rt(f.call(S)))}finally{if(d)throw d.error}}this.recordHistory(o,x)})}recordHistory(t,o,l){let s=[];o.length>0&&o.every(d=>d.role!==void 0)?s=o:s.push({role:"model",parts:[]}),l&&l.length>0?this.history.push(...zy(l)):this.history.push(t),this.history.push(...s)}}class eu extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,eu.prototype)}}function QC(e){const t={},o=c(e,["file"]);return o!=null&&p(t,["file"],o),t}function ZC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function eE(e){const t={},o=c(e,["name"]);return o!=null&&p(t,["_url","file"],Sv(o)),t}function tE(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function nE(e){const t={},o=c(e,["name"]);return o!=null&&p(t,["_url","file"],Sv(o)),t}function iE(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),o}function oE(e){const t={},o=c(e,["config"]);return o!=null&&iE(o,t),t}function lE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["files"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["files"],d)}return t}class aE extends Jo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new ea(Yo.PAGED_ITEM_FILES,l=>this.listInternal(l),await this.listInternal(o),o)}async upload(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(t.file,t.config).then(o=>o)}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=oE(t);return d=Ze("files",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>{const m=lE(v),x=new uT;return Object.assign(x,m),x})}}async createInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=QC(t);return d=Ze("upload/v1beta/files",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=ZC(v),x=new dT;return Object.assign(x,m),x})}}async get(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=nE(t);return d=Ze("files/{file}",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>v)}}async delete(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=eE(t);return d=Ze("files/{file}",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>{const m=tE(v),x=new fT;return Object.assign(x,m),x})}}}function kc(e){const t={},o=c(e,["data"]);if(o!=null&&p(t,["data"],o),c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function sE(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(d=>TE(d))),p(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&p(t,["role"],l),t}function rE(e){const t={};if(c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=c(e,["fileUri"]);o!=null&&p(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function cE(e){const t={},o=c(e,["id"]);o!=null&&p(t,["id"],o);const l=c(e,["args"]);l!=null&&p(t,["args"],l);const s=c(e,["name"]);if(s!=null&&p(t,["name"],s),c(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(c(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function uE(e){const t={};if(c(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=c(e,["description"]);o!=null&&p(t,["description"],o);const l=c(e,["name"]);l!=null&&p(t,["name"],l);const s=c(e,["parameters"]);s!=null&&p(t,["parameters"],s);const d=c(e,["parametersJsonSchema"]);d!=null&&p(t,["parametersJsonSchema"],d);const f=c(e,["response"]);f!=null&&p(t,["response"],f);const g=c(e,["responseJsonSchema"]);return g!=null&&p(t,["responseJsonSchema"],g),t}function dE(e){const t={},o=c(e,["modelSelectionConfig"]);o!=null&&p(t,["modelConfig"],o);const l=c(e,["responseJsonSchema"]);l!=null&&p(t,["responseJsonSchema"],l);const s=c(e,["audioTimestamp"]);s!=null&&p(t,["audioTimestamp"],s);const d=c(e,["candidateCount"]);d!=null&&p(t,["candidateCount"],d);const f=c(e,["enableAffectiveDialog"]);f!=null&&p(t,["enableAffectiveDialog"],f);const g=c(e,["frequencyPenalty"]);g!=null&&p(t,["frequencyPenalty"],g);const v=c(e,["logprobs"]);v!=null&&p(t,["logprobs"],v);const m=c(e,["maxOutputTokens"]);m!=null&&p(t,["maxOutputTokens"],m);const x=c(e,["mediaResolution"]);x!=null&&p(t,["mediaResolution"],x);const b=c(e,["presencePenalty"]);b!=null&&p(t,["presencePenalty"],b);const S=c(e,["responseLogprobs"]);S!=null&&p(t,["responseLogprobs"],S);const _=c(e,["responseMimeType"]);_!=null&&p(t,["responseMimeType"],_);const T=c(e,["responseModalities"]);T!=null&&p(t,["responseModalities"],T);const F=c(e,["responseSchema"]);F!=null&&p(t,["responseSchema"],F);const z=c(e,["routingConfig"]);z!=null&&p(t,["routingConfig"],z);const G=c(e,["seed"]);G!=null&&p(t,["seed"],G);const Y=c(e,["speechConfig"]);Y!=null&&p(t,["speechConfig"],Y);const oe=c(e,["stopSequences"]);oe!=null&&p(t,["stopSequences"],oe);const ce=c(e,["temperature"]);ce!=null&&p(t,["temperature"],ce);const ve=c(e,["thinkingConfig"]);ve!=null&&p(t,["thinkingConfig"],ve);const ye=c(e,["topK"]);ye!=null&&p(t,["topK"],ye);const fe=c(e,["topP"]);if(fe!=null&&p(t,["topP"],fe),c(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function fE(e){const t={};if(c(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=c(e,["enableWidget"]);return o!=null&&p(t,["enableWidget"],o),t}function pE(e){const t={};if(c(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(c(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=c(e,["timeRangeFilter"]);return o!=null&&p(t,["timeRangeFilter"],o),t}function hE(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&p(t,["setup","generationConfig"],l);const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&p(t,["setup","generationConfig","responseModalities"],s);const d=c(e,["temperature"]);t!==void 0&&d!=null&&p(t,["setup","generationConfig","temperature"],d);const f=c(e,["topP"]);t!==void 0&&f!=null&&p(t,["setup","generationConfig","topP"],f);const g=c(e,["topK"]);t!==void 0&&g!=null&&p(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&p(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&p(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&p(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&p(t,["setup","generationConfig","speechConfig"],rp(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&p(t,["setup","generationConfig","thinkingConfig"],S);const _=c(e,["enableAffectiveDialog"]);t!==void 0&&_!=null&&p(t,["setup","generationConfig","enableAffectiveDialog"],_);const T=c(e,["systemInstruction"]);t!==void 0&&T!=null&&p(t,["setup","systemInstruction"],sE(hi(T)));const F=c(e,["tools"]);if(t!==void 0&&F!=null){let ye=Za(F);Array.isArray(ye)&&(ye=ye.map(fe=>EE(Qa(fe)))),p(t,["setup","tools"],ye)}const z=c(e,["sessionResumption"]);t!==void 0&&z!=null&&p(t,["setup","sessionResumption"],CE(z));const G=c(e,["inputAudioTranscription"]);t!==void 0&&G!=null&&p(t,["setup","inputAudioTranscription"],G);const Y=c(e,["outputAudioTranscription"]);t!==void 0&&Y!=null&&p(t,["setup","outputAudioTranscription"],Y);const oe=c(e,["realtimeInputConfig"]);t!==void 0&&oe!=null&&p(t,["setup","realtimeInputConfig"],oe);const ce=c(e,["contextWindowCompression"]);t!==void 0&&ce!=null&&p(t,["setup","contextWindowCompression"],ce);const ve=c(e,["proactivity"]);if(t!==void 0&&ve!=null&&p(t,["setup","proactivity"],ve),c(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function mE(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&p(t,["setup","generationConfig"],dE(l));const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&p(t,["setup","generationConfig","responseModalities"],s);const d=c(e,["temperature"]);t!==void 0&&d!=null&&p(t,["setup","generationConfig","temperature"],d);const f=c(e,["topP"]);t!==void 0&&f!=null&&p(t,["setup","generationConfig","topP"],f);const g=c(e,["topK"]);t!==void 0&&g!=null&&p(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&p(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&p(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&p(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&p(t,["setup","generationConfig","speechConfig"],rp(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&p(t,["setup","generationConfig","thinkingConfig"],S);const _=c(e,["enableAffectiveDialog"]);t!==void 0&&_!=null&&p(t,["setup","generationConfig","enableAffectiveDialog"],_);const T=c(e,["systemInstruction"]);t!==void 0&&T!=null&&p(t,["setup","systemInstruction"],hi(T));const F=c(e,["tools"]);if(t!==void 0&&F!=null){let fe=Za(F);Array.isArray(fe)&&(fe=fe.map(Je=>_E(Qa(Je)))),p(t,["setup","tools"],fe)}const z=c(e,["sessionResumption"]);t!==void 0&&z!=null&&p(t,["setup","sessionResumption"],z);const G=c(e,["inputAudioTranscription"]);t!==void 0&&G!=null&&p(t,["setup","inputAudioTranscription"],G);const Y=c(e,["outputAudioTranscription"]);t!==void 0&&Y!=null&&p(t,["setup","outputAudioTranscription"],Y);const oe=c(e,["realtimeInputConfig"]);t!==void 0&&oe!=null&&p(t,["setup","realtimeInputConfig"],oe);const ce=c(e,["contextWindowCompression"]);t!==void 0&&ce!=null&&p(t,["setup","contextWindowCompression"],ce);const ve=c(e,["proactivity"]);t!==void 0&&ve!=null&&p(t,["setup","proactivity"],ve);const ye=c(e,["explicitVadSignal"]);return t!==void 0&&ye!=null&&p(t,["setup","explicitVadSignal"],ye),o}function gE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["setup","model"],sn(e,l));const s=c(t,["config"]);return s!=null&&p(o,["config"],hE(s,o)),o}function yE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["setup","model"],sn(e,l));const s=c(t,["config"]);return s!=null&&p(o,["config"],mE(s,o)),o}function vE(e){const t={},o=c(e,["musicGenerationConfig"]);return o!=null&&p(t,["musicGenerationConfig"],o),t}function xE(e){const t={},o=c(e,["weightedPrompts"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),p(t,["weightedPrompts"],l)}return t}function bE(e){const t={},o=c(e,["media"]);if(o!=null){let m=gv(o);Array.isArray(m)&&(m=m.map(x=>kc(x))),p(t,["mediaChunks"],m)}const l=c(e,["audio"]);l!=null&&p(t,["audio"],kc(vv(l)));const s=c(e,["audioStreamEnd"]);s!=null&&p(t,["audioStreamEnd"],s);const d=c(e,["video"]);d!=null&&p(t,["video"],kc(yv(d)));const f=c(e,["text"]);f!=null&&p(t,["text"],f);const g=c(e,["activityStart"]);g!=null&&p(t,["activityStart"],g);const v=c(e,["activityEnd"]);return v!=null&&p(t,["activityEnd"],v),t}function SE(e){const t={},o=c(e,["media"]);if(o!=null){let m=gv(o);Array.isArray(m)&&(m=m.map(x=>x)),p(t,["mediaChunks"],m)}const l=c(e,["audio"]);l!=null&&p(t,["audio"],vv(l));const s=c(e,["audioStreamEnd"]);s!=null&&p(t,["audioStreamEnd"],s);const d=c(e,["video"]);d!=null&&p(t,["video"],yv(d));const f=c(e,["text"]);f!=null&&p(t,["text"],f);const g=c(e,["activityStart"]);g!=null&&p(t,["activityStart"],g);const v=c(e,["activityEnd"]);return v!=null&&p(t,["activityEnd"],v),t}function wE(e){const t={},o=c(e,["setupComplete"]);o!=null&&p(t,["setupComplete"],o);const l=c(e,["serverContent"]);l!=null&&p(t,["serverContent"],l);const s=c(e,["toolCall"]);s!=null&&p(t,["toolCall"],s);const d=c(e,["toolCallCancellation"]);d!=null&&p(t,["toolCallCancellation"],d);const f=c(e,["usageMetadata"]);f!=null&&p(t,["usageMetadata"],NE(f));const g=c(e,["goAway"]);g!=null&&p(t,["goAway"],g);const v=c(e,["sessionResumptionUpdate"]);v!=null&&p(t,["sessionResumptionUpdate"],v);const m=c(e,["voiceActivityDetectionSignal"]);return m!=null&&p(t,["voiceActivityDetectionSignal"],m),t}function TE(e){const t={},o=c(e,["mediaResolution"]);o!=null&&p(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&p(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&p(t,["executableCode"],s);const d=c(e,["fileData"]);d!=null&&p(t,["fileData"],rE(d));const f=c(e,["functionCall"]);f!=null&&p(t,["functionCall"],cE(f));const g=c(e,["functionResponse"]);g!=null&&p(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&p(t,["inlineData"],kc(v));const m=c(e,["text"]);m!=null&&p(t,["text"],m);const x=c(e,["thought"]);x!=null&&p(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&p(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&p(t,["videoMetadata"],S),t}function CE(e){const t={},o=c(e,["handle"]);if(o!=null&&p(t,["handle"],o),c(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function EE(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),p(t,["functionDeclarations"],x)}if(c(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=c(e,["googleSearchRetrieval"]);l!=null&&p(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&p(t,["computerUse"],s);const d=c(e,["fileSearch"]);d!=null&&p(t,["fileSearch"],d);const f=c(e,["codeExecution"]);if(f!=null&&p(t,["codeExecution"],f),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&p(t,["googleMaps"],fE(g));const v=c(e,["googleSearch"]);v!=null&&p(t,["googleSearch"],pE(v));const m=c(e,["urlContext"]);return m!=null&&p(t,["urlContext"],m),t}function _E(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>uE(S))),p(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&p(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&p(t,["googleSearchRetrieval"],s);const d=c(e,["computerUse"]);if(d!=null&&p(t,["computerUse"],d),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const f=c(e,["codeExecution"]);f!=null&&p(t,["codeExecution"],f);const g=c(e,["enterpriseWebSearch"]);g!=null&&p(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&p(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&p(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&p(t,["urlContext"],x),t}function NE(e){const t={},o=c(e,["promptTokenCount"]);o!=null&&p(t,["promptTokenCount"],o);const l=c(e,["cachedContentTokenCount"]);l!=null&&p(t,["cachedContentTokenCount"],l);const s=c(e,["candidatesTokenCount"]);s!=null&&p(t,["responseTokenCount"],s);const d=c(e,["toolUsePromptTokenCount"]);d!=null&&p(t,["toolUsePromptTokenCount"],d);const f=c(e,["thoughtsTokenCount"]);f!=null&&p(t,["thoughtsTokenCount"],f);const g=c(e,["totalTokenCount"]);g!=null&&p(t,["totalTokenCount"],g);const v=c(e,["promptTokensDetails"]);if(v!=null){let _=v;Array.isArray(_)&&(_=_.map(T=>T)),p(t,["promptTokensDetails"],_)}const m=c(e,["cacheTokensDetails"]);if(m!=null){let _=m;Array.isArray(_)&&(_=_.map(T=>T)),p(t,["cacheTokensDetails"],_)}const x=c(e,["candidatesTokensDetails"]);if(x!=null){let _=x;Array.isArray(_)&&(_=_.map(T=>T)),p(t,["responseTokensDetails"],_)}const b=c(e,["toolUsePromptTokensDetails"]);if(b!=null){let _=b;Array.isArray(_)&&(_=_.map(T=>T)),p(t,["toolUsePromptTokensDetails"],_)}const S=c(e,["trafficType"]);return S!=null&&p(t,["trafficType"],S),t}function AE(e){const t={},o=c(e,["data"]);if(o!=null&&p(t,["data"],o),c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function ME(e){const t={},o=c(e,["content"]);o!=null&&p(t,["content"],o);const l=c(e,["citationMetadata"]);l!=null&&p(t,["citationMetadata"],kE(l));const s=c(e,["tokenCount"]);s!=null&&p(t,["tokenCount"],s);const d=c(e,["finishReason"]);d!=null&&p(t,["finishReason"],d);const f=c(e,["avgLogprobs"]);f!=null&&p(t,["avgLogprobs"],f);const g=c(e,["groundingMetadata"]);g!=null&&p(t,["groundingMetadata"],g);const v=c(e,["index"]);v!=null&&p(t,["index"],v);const m=c(e,["logprobsResult"]);m!=null&&p(t,["logprobsResult"],m);const x=c(e,["safetyRatings"]);if(x!=null){let S=x;Array.isArray(S)&&(S=S.map(_=>_)),p(t,["safetyRatings"],S)}const b=c(e,["urlContextMetadata"]);return b!=null&&p(t,["urlContextMetadata"],b),t}function kE(e){const t={},o=c(e,["citationSources"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),p(t,["citations"],l)}return t}function RE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let d=Zi(s);Array.isArray(d)&&(d=d.map(f=>f)),p(o,["contents"],d)}return o}function zE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["tokensInfo"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(d=>d)),p(t,["tokensInfo"],s)}return t}function IE(e){const t={},o=c(e,["values"]);o!=null&&p(t,["values"],o);const l=c(e,["statistics"]);return l!=null&&p(t,["statistics"],DE(l)),t}function DE(e){const t={},o=c(e,["truncated"]);o!=null&&p(t,["truncated"],o);const l=c(e,["token_count"]);return l!=null&&p(t,["tokenCount"],l),t}function tu(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(d=>H_(d))),p(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&p(t,["role"],l),t}function LE(e){const t={},o=c(e,["controlType"]);o!=null&&p(t,["controlType"],o);const l=c(e,["enableControlImageComputation"]);return l!=null&&p(t,["computeControl"],l),t}function UE(e){const t={};if(c(e,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(c(e,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(c(e,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function FE(e,t){const o={},l=c(e,["systemInstruction"]);t!==void 0&&l!=null&&p(t,["systemInstruction"],hi(l));const s=c(e,["tools"]);if(t!==void 0&&s!=null){let f=s;Array.isArray(f)&&(f=f.map(g=>zv(g))),p(t,["tools"],f)}const d=c(e,["generationConfig"]);return t!==void 0&&d!=null&&p(t,["generationConfig"],A_(d)),o}function PE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let f=Zi(s);Array.isArray(f)&&(f=f.map(g=>tu(g))),p(o,["contents"],f)}const d=c(t,["config"]);return d!=null&&UE(d),o}function BE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let f=Zi(s);Array.isArray(f)&&(f=f.map(g=>g)),p(o,["contents"],f)}const d=c(t,["config"]);return d!=null&&FE(d,o),o}function jE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["totalTokens"]);l!=null&&p(t,["totalTokens"],l);const s=c(e,["cachedContentTokenCount"]);return s!=null&&p(t,["cachedContentTokenCount"],s),t}function OE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["totalTokens"]);return l!=null&&p(t,["totalTokens"],l),t}function VE(e,t){const o={},l=c(t,["model"]);return l!=null&&p(o,["_url","name"],sn(e,l)),o}function HE(e,t){const o={},l=c(t,["model"]);return l!=null&&p(o,["_url","name"],sn(e,l)),o}function GE(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function $E(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}function qE(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&p(t,["parameters","storageUri"],l);const s=c(e,["negativePrompt"]);t!==void 0&&s!=null&&p(t,["parameters","negativePrompt"],s);const d=c(e,["numberOfImages"]);t!==void 0&&d!=null&&p(t,["parameters","sampleCount"],d);const f=c(e,["aspectRatio"]);t!==void 0&&f!=null&&p(t,["parameters","aspectRatio"],f);const g=c(e,["guidanceScale"]);t!==void 0&&g!=null&&p(t,["parameters","guidanceScale"],g);const v=c(e,["seed"]);t!==void 0&&v!=null&&p(t,["parameters","seed"],v);const m=c(e,["safetyFilterLevel"]);t!==void 0&&m!=null&&p(t,["parameters","safetySetting"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&p(t,["parameters","personGeneration"],x);const b=c(e,["includeSafetyAttributes"]);t!==void 0&&b!=null&&p(t,["parameters","includeSafetyAttributes"],b);const S=c(e,["includeRaiReason"]);t!==void 0&&S!=null&&p(t,["parameters","includeRaiReason"],S);const _=c(e,["language"]);t!==void 0&&_!=null&&p(t,["parameters","language"],_);const T=c(e,["outputMimeType"]);t!==void 0&&T!=null&&p(t,["parameters","outputOptions","mimeType"],T);const F=c(e,["outputCompressionQuality"]);t!==void 0&&F!=null&&p(t,["parameters","outputOptions","compressionQuality"],F);const z=c(e,["addWatermark"]);t!==void 0&&z!=null&&p(t,["parameters","addWatermark"],z);const G=c(e,["labels"]);t!==void 0&&G!=null&&p(t,["labels"],G);const Y=c(e,["editMode"]);t!==void 0&&Y!=null&&p(t,["parameters","editMode"],Y);const oe=c(e,["baseSteps"]);return t!==void 0&&oe!=null&&p(t,["parameters","editConfig","baseSteps"],oe),o}function YE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["prompt"]);s!=null&&p(o,["instances[0]","prompt"],s);const d=c(t,["referenceImages"]);if(d!=null){let g=d;Array.isArray(g)&&(g=g.map(v=>K_(v))),p(o,["instances[0]","referenceImages"],g)}const f=c(t,["config"]);return f!=null&&qE(f,o),o}function JE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(d=>nu(d))),p(t,["generatedImages"],s)}return t}function KE(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&p(t,["requests[]","taskType"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&p(t,["requests[]","title"],s);const d=c(e,["outputDimensionality"]);if(t!==void 0&&d!=null&&p(t,["requests[]","outputDimensionality"],d),c(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(c(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function XE(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&p(t,["instances[]","task_type"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&p(t,["instances[]","title"],s);const d=c(e,["outputDimensionality"]);t!==void 0&&d!=null&&p(t,["parameters","outputDimensionality"],d);const f=c(e,["mimeType"]);t!==void 0&&f!=null&&p(t,["instances[]","mimeType"],f);const g=c(e,["autoTruncate"]);return t!==void 0&&g!=null&&p(t,["parameters","autoTruncate"],g),o}function WE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let g=lp(e,s);Array.isArray(g)&&(g=g.map(v=>v)),p(o,["requests[]","content"],g)}const d=c(t,["config"]);d!=null&&KE(d,o);const f=c(t,["model"]);return f!==void 0&&p(o,["requests[]","model"],sn(e,f)),o}function QE(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let f=lp(e,s);Array.isArray(f)&&(f=f.map(g=>g)),p(o,["instances[]","content"],f)}const d=c(t,["config"]);return d!=null&&XE(d,o),o}function ZE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["embeddings"]);if(l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["embeddings"],d)}const s=c(e,["metadata"]);return s!=null&&p(t,["metadata"],s),t}function e_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["predictions[]","embeddings"]);if(l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>IE(f))),p(t,["embeddings"],d)}const s=c(e,["metadata"]);return s!=null&&p(t,["metadata"],s),t}function t_(e){const t={},o=c(e,["endpoint"]);o!=null&&p(t,["name"],o);const l=c(e,["deployedModelId"]);return l!=null&&p(t,["deployedModelId"],l),t}function n_(e){const t={};if(c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=c(e,["fileUri"]);o!=null&&p(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function i_(e){const t={},o=c(e,["id"]);o!=null&&p(t,["id"],o);const l=c(e,["args"]);l!=null&&p(t,["args"],l);const s=c(e,["name"]);if(s!=null&&p(t,["name"],s),c(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(c(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function o_(e){const t={},o=c(e,["mode"]);o!=null&&p(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&p(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function l_(e){const t={};if(c(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=c(e,["description"]);o!=null&&p(t,["description"],o);const l=c(e,["name"]);l!=null&&p(t,["name"],l);const s=c(e,["parameters"]);s!=null&&p(t,["parameters"],s);const d=c(e,["parametersJsonSchema"]);d!=null&&p(t,["parametersJsonSchema"],d);const f=c(e,["response"]);f!=null&&p(t,["response"],f);const g=c(e,["responseJsonSchema"]);return g!=null&&p(t,["responseJsonSchema"],g),t}function a_(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&p(o,["systemInstruction"],tu(hi(s)));const d=c(t,["temperature"]);d!=null&&p(l,["temperature"],d);const f=c(t,["topP"]);f!=null&&p(l,["topP"],f);const g=c(t,["topK"]);g!=null&&p(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&p(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&p(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&p(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&p(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&p(l,["logprobs"],S);const _=c(t,["presencePenalty"]);_!=null&&p(l,["presencePenalty"],_);const T=c(t,["frequencyPenalty"]);T!=null&&p(l,["frequencyPenalty"],T);const F=c(t,["seed"]);F!=null&&p(l,["seed"],F);const z=c(t,["responseMimeType"]);z!=null&&p(l,["responseMimeType"],z);const G=c(t,["responseSchema"]);G!=null&&p(l,["responseSchema"],ap(G));const Y=c(t,["responseJsonSchema"]);if(Y!=null&&p(l,["responseJsonSchema"],Y),c(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(c(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const oe=c(t,["safetySettings"]);if(o!==void 0&&oe!=null){let nt=oe;Array.isArray(nt)&&(nt=nt.map(it=>X_(it))),p(o,["safetySettings"],nt)}const ce=c(t,["tools"]);if(o!==void 0&&ce!=null){let nt=Za(ce);Array.isArray(nt)&&(nt=nt.map(it=>iN(Qa(it)))),p(o,["tools"],nt)}const ve=c(t,["toolConfig"]);if(o!==void 0&&ve!=null&&p(o,["toolConfig"],nN(ve)),c(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const ye=c(t,["cachedContent"]);o!==void 0&&ye!=null&&p(o,["cachedContent"],Ko(e,ye));const fe=c(t,["responseModalities"]);fe!=null&&p(l,["responseModalities"],fe);const Je=c(t,["mediaResolution"]);Je!=null&&p(l,["mediaResolution"],Je);const ge=c(t,["speechConfig"]);if(ge!=null&&p(l,["speechConfig"],sp(ge)),c(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const qe=c(t,["thinkingConfig"]);qe!=null&&p(l,["thinkingConfig"],qe);const Ve=c(t,["imageConfig"]);Ve!=null&&p(l,["imageConfig"],I_(Ve));const Ke=c(t,["enableEnhancedCivicAnswers"]);return Ke!=null&&p(l,["enableEnhancedCivicAnswers"],Ke),l}function s_(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&p(o,["systemInstruction"],hi(s));const d=c(t,["temperature"]);d!=null&&p(l,["temperature"],d);const f=c(t,["topP"]);f!=null&&p(l,["topP"],f);const g=c(t,["topK"]);g!=null&&p(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&p(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&p(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&p(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&p(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&p(l,["logprobs"],S);const _=c(t,["presencePenalty"]);_!=null&&p(l,["presencePenalty"],_);const T=c(t,["frequencyPenalty"]);T!=null&&p(l,["frequencyPenalty"],T);const F=c(t,["seed"]);F!=null&&p(l,["seed"],F);const z=c(t,["responseMimeType"]);z!=null&&p(l,["responseMimeType"],z);const G=c(t,["responseSchema"]);G!=null&&p(l,["responseSchema"],ap(G));const Y=c(t,["responseJsonSchema"]);Y!=null&&p(l,["responseJsonSchema"],Y);const oe=c(t,["routingConfig"]);oe!=null&&p(l,["routingConfig"],oe);const ce=c(t,["modelSelectionConfig"]);ce!=null&&p(l,["modelConfig"],ce);const ve=c(t,["safetySettings"]);if(o!==void 0&&ve!=null){let K=ve;Array.isArray(K)&&(K=K.map(ze=>ze)),p(o,["safetySettings"],K)}const ye=c(t,["tools"]);if(o!==void 0&&ye!=null){let K=Za(ye);Array.isArray(K)&&(K=K.map(ze=>zv(Qa(ze)))),p(o,["tools"],K)}const fe=c(t,["toolConfig"]);o!==void 0&&fe!=null&&p(o,["toolConfig"],fe);const Je=c(t,["labels"]);o!==void 0&&Je!=null&&p(o,["labels"],Je);const ge=c(t,["cachedContent"]);o!==void 0&&ge!=null&&p(o,["cachedContent"],Ko(e,ge));const qe=c(t,["responseModalities"]);qe!=null&&p(l,["responseModalities"],qe);const Ve=c(t,["mediaResolution"]);Ve!=null&&p(l,["mediaResolution"],Ve);const Ke=c(t,["speechConfig"]);Ke!=null&&p(l,["speechConfig"],sp(Ke));const nt=c(t,["audioTimestamp"]);nt!=null&&p(l,["audioTimestamp"],nt);const it=c(t,["thinkingConfig"]);it!=null&&p(l,["thinkingConfig"],it);const xt=c(t,["imageConfig"]);if(xt!=null&&p(l,["imageConfig"],D_(xt)),c(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return l}function Iy(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let f=Zi(s);Array.isArray(f)&&(f=f.map(g=>tu(g))),p(o,["contents"],f)}const d=c(t,["config"]);return d!=null&&p(o,["generationConfig"],a_(e,d,o)),o}function Dy(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["contents"]);if(s!=null){let f=Zi(s);Array.isArray(f)&&(f=f.map(g=>g)),p(o,["contents"],f)}const d=c(t,["config"]);return d!=null&&p(o,["generationConfig"],s_(e,d,o)),o}function Ly(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(m=>ME(m))),p(t,["candidates"],v)}const s=c(e,["modelVersion"]);s!=null&&p(t,["modelVersion"],s);const d=c(e,["promptFeedback"]);d!=null&&p(t,["promptFeedback"],d);const f=c(e,["responseId"]);f!=null&&p(t,["responseId"],f);const g=c(e,["usageMetadata"]);return g!=null&&p(t,["usageMetadata"],g),t}function Uy(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let m=l;Array.isArray(m)&&(m=m.map(x=>x)),p(t,["candidates"],m)}const s=c(e,["createTime"]);s!=null&&p(t,["createTime"],s);const d=c(e,["modelVersion"]);d!=null&&p(t,["modelVersion"],d);const f=c(e,["promptFeedback"]);f!=null&&p(t,["promptFeedback"],f);const g=c(e,["responseId"]);g!=null&&p(t,["responseId"],g);const v=c(e,["usageMetadata"]);return v!=null&&p(t,["usageMetadata"],v),t}function r_(e,t){const o={};if(c(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(c(e,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const l=c(e,["numberOfImages"]);t!==void 0&&l!=null&&p(t,["parameters","sampleCount"],l);const s=c(e,["aspectRatio"]);t!==void 0&&s!=null&&p(t,["parameters","aspectRatio"],s);const d=c(e,["guidanceScale"]);if(t!==void 0&&d!=null&&p(t,["parameters","guidanceScale"],d),c(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const f=c(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&p(t,["parameters","safetySetting"],f);const g=c(e,["personGeneration"]);t!==void 0&&g!=null&&p(t,["parameters","personGeneration"],g);const v=c(e,["includeSafetyAttributes"]);t!==void 0&&v!=null&&p(t,["parameters","includeSafetyAttributes"],v);const m=c(e,["includeRaiReason"]);t!==void 0&&m!=null&&p(t,["parameters","includeRaiReason"],m);const x=c(e,["language"]);t!==void 0&&x!=null&&p(t,["parameters","language"],x);const b=c(e,["outputMimeType"]);t!==void 0&&b!=null&&p(t,["parameters","outputOptions","mimeType"],b);const S=c(e,["outputCompressionQuality"]);if(t!==void 0&&S!=null&&p(t,["parameters","outputOptions","compressionQuality"],S),c(e,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(c(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const _=c(e,["imageSize"]);if(t!==void 0&&_!=null&&p(t,["parameters","sampleImageSize"],_),c(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function c_(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&p(t,["parameters","storageUri"],l);const s=c(e,["negativePrompt"]);t!==void 0&&s!=null&&p(t,["parameters","negativePrompt"],s);const d=c(e,["numberOfImages"]);t!==void 0&&d!=null&&p(t,["parameters","sampleCount"],d);const f=c(e,["aspectRatio"]);t!==void 0&&f!=null&&p(t,["parameters","aspectRatio"],f);const g=c(e,["guidanceScale"]);t!==void 0&&g!=null&&p(t,["parameters","guidanceScale"],g);const v=c(e,["seed"]);t!==void 0&&v!=null&&p(t,["parameters","seed"],v);const m=c(e,["safetyFilterLevel"]);t!==void 0&&m!=null&&p(t,["parameters","safetySetting"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&p(t,["parameters","personGeneration"],x);const b=c(e,["includeSafetyAttributes"]);t!==void 0&&b!=null&&p(t,["parameters","includeSafetyAttributes"],b);const S=c(e,["includeRaiReason"]);t!==void 0&&S!=null&&p(t,["parameters","includeRaiReason"],S);const _=c(e,["language"]);t!==void 0&&_!=null&&p(t,["parameters","language"],_);const T=c(e,["outputMimeType"]);t!==void 0&&T!=null&&p(t,["parameters","outputOptions","mimeType"],T);const F=c(e,["outputCompressionQuality"]);t!==void 0&&F!=null&&p(t,["parameters","outputOptions","compressionQuality"],F);const z=c(e,["addWatermark"]);t!==void 0&&z!=null&&p(t,["parameters","addWatermark"],z);const G=c(e,["labels"]);t!==void 0&&G!=null&&p(t,["labels"],G);const Y=c(e,["imageSize"]);t!==void 0&&Y!=null&&p(t,["parameters","sampleImageSize"],Y);const oe=c(e,["enhancePrompt"]);return t!==void 0&&oe!=null&&p(t,["parameters","enhancePrompt"],oe),o}function u_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["prompt"]);s!=null&&p(o,["instances[0]","prompt"],s);const d=c(t,["config"]);return d!=null&&r_(d,o),o}function d_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["prompt"]);s!=null&&p(o,["instances[0]","prompt"],s);const d=c(t,["config"]);return d!=null&&c_(d,o),o}function f_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>C_(f))),p(t,["generatedImages"],d)}const s=c(e,["positivePromptSafetyAttributes"]);return s!=null&&p(t,["positivePromptSafetyAttributes"],kv(s)),t}function p_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>nu(f))),p(t,["generatedImages"],d)}const s=c(e,["positivePromptSafetyAttributes"]);return s!=null&&p(t,["positivePromptSafetyAttributes"],Rv(s)),t}function h_(e,t){const o={},l=c(e,["numberOfVideos"]);if(t!==void 0&&l!=null&&p(t,["parameters","sampleCount"],l),c(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(c(e,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const s=c(e,["durationSeconds"]);if(t!==void 0&&s!=null&&p(t,["parameters","durationSeconds"],s),c(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const d=c(e,["aspectRatio"]);t!==void 0&&d!=null&&p(t,["parameters","aspectRatio"],d);const f=c(e,["resolution"]);t!==void 0&&f!=null&&p(t,["parameters","resolution"],f);const g=c(e,["personGeneration"]);if(t!==void 0&&g!=null&&p(t,["parameters","personGeneration"],g),c(e,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const v=c(e,["negativePrompt"]);t!==void 0&&v!=null&&p(t,["parameters","negativePrompt"],v);const m=c(e,["enhancePrompt"]);if(t!==void 0&&m!=null&&p(t,["parameters","enhancePrompt"],m),c(e,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const x=c(e,["lastFrame"]);t!==void 0&&x!=null&&p(t,["instances[0]","lastFrame"],iu(x));const b=c(e,["referenceImages"]);if(t!==void 0&&b!=null){let S=b;Array.isArray(S)&&(S=S.map(_=>gN(_))),p(t,["instances[0]","referenceImages"],S)}if(c(e,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(c(e,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return o}function m_(e,t){const o={},l=c(e,["numberOfVideos"]);t!==void 0&&l!=null&&p(t,["parameters","sampleCount"],l);const s=c(e,["outputGcsUri"]);t!==void 0&&s!=null&&p(t,["parameters","storageUri"],s);const d=c(e,["fps"]);t!==void 0&&d!=null&&p(t,["parameters","fps"],d);const f=c(e,["durationSeconds"]);t!==void 0&&f!=null&&p(t,["parameters","durationSeconds"],f);const g=c(e,["seed"]);t!==void 0&&g!=null&&p(t,["parameters","seed"],g);const v=c(e,["aspectRatio"]);t!==void 0&&v!=null&&p(t,["parameters","aspectRatio"],v);const m=c(e,["resolution"]);t!==void 0&&m!=null&&p(t,["parameters","resolution"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&p(t,["parameters","personGeneration"],x);const b=c(e,["pubsubTopic"]);t!==void 0&&b!=null&&p(t,["parameters","pubsubTopic"],b);const S=c(e,["negativePrompt"]);t!==void 0&&S!=null&&p(t,["parameters","negativePrompt"],S);const _=c(e,["enhancePrompt"]);t!==void 0&&_!=null&&p(t,["parameters","enhancePrompt"],_);const T=c(e,["generateAudio"]);t!==void 0&&T!=null&&p(t,["parameters","generateAudio"],T);const F=c(e,["lastFrame"]);t!==void 0&&F!=null&&p(t,["instances[0]","lastFrame"],po(F));const z=c(e,["referenceImages"]);if(t!==void 0&&z!=null){let oe=z;Array.isArray(oe)&&(oe=oe.map(ce=>yN(ce))),p(t,["instances[0]","referenceImages"],oe)}const G=c(e,["mask"]);t!==void 0&&G!=null&&p(t,["instances[0]","mask"],mN(G));const Y=c(e,["compressionQuality"]);return t!==void 0&&Y!=null&&p(t,["parameters","compressionQuality"],Y),o}function g_(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response","generateVideoResponse"]);return f!=null&&p(t,["response"],b_(f)),t}function y_(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response"]);return f!=null&&p(t,["response"],S_(f)),t}function v_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["prompt"]);s!=null&&p(o,["instances[0]","prompt"],s);const d=c(t,["image"]);d!=null&&p(o,["instances[0]","image"],iu(d));const f=c(t,["video"]);f!=null&&p(o,["instances[0]","video"],Iv(f));const g=c(t,["source"]);g!=null&&w_(g,o);const v=c(t,["config"]);return v!=null&&h_(v,o),o}function x_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["prompt"]);s!=null&&p(o,["instances[0]","prompt"],s);const d=c(t,["image"]);d!=null&&p(o,["instances[0]","image"],po(d));const f=c(t,["video"]);f!=null&&p(o,["instances[0]","video"],Dv(f));const g=c(t,["source"]);g!=null&&T_(g,o);const v=c(t,["config"]);return v!=null&&m_(v,o),o}function b_(e){const t={},o=c(e,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>__(f))),p(t,["generatedVideos"],d)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&p(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&p(t,["raiMediaFilteredReasons"],s),t}function S_(e){const t={},o=c(e,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(f=>N_(f))),p(t,["generatedVideos"],d)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&p(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&p(t,["raiMediaFilteredReasons"],s),t}function w_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&p(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&p(t,["instances[0]","image"],iu(s));const d=c(e,["video"]);return t!==void 0&&d!=null&&p(t,["instances[0]","video"],Iv(d)),o}function T_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&p(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&p(t,["instances[0]","image"],po(s));const d=c(e,["video"]);return t!==void 0&&d!=null&&p(t,["instances[0]","video"],Dv(d)),o}function C_(e){const t={},o=c(e,["_self"]);o!=null&&p(t,["image"],L_(o));const l=c(e,["raiFilteredReason"]);l!=null&&p(t,["raiFilteredReason"],l);const s=c(e,["_self"]);return s!=null&&p(t,["safetyAttributes"],kv(s)),t}function nu(e){const t={},o=c(e,["_self"]);o!=null&&p(t,["image"],Mv(o));const l=c(e,["raiFilteredReason"]);l!=null&&p(t,["raiFilteredReason"],l);const s=c(e,["_self"]);s!=null&&p(t,["safetyAttributes"],Rv(s));const d=c(e,["prompt"]);return d!=null&&p(t,["enhancedPrompt"],d),t}function E_(e){const t={},o=c(e,["_self"]);o!=null&&p(t,["mask"],Mv(o));const l=c(e,["labels"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(d=>d)),p(t,["labels"],s)}return t}function __(e){const t={},o=c(e,["video"]);return o!=null&&p(t,["video"],pN(o)),t}function N_(e){const t={},o=c(e,["_self"]);return o!=null&&p(t,["video"],hN(o)),t}function A_(e){const t={},o=c(e,["modelSelectionConfig"]);o!=null&&p(t,["modelConfig"],o);const l=c(e,["responseJsonSchema"]);l!=null&&p(t,["responseJsonSchema"],l);const s=c(e,["audioTimestamp"]);s!=null&&p(t,["audioTimestamp"],s);const d=c(e,["candidateCount"]);d!=null&&p(t,["candidateCount"],d);const f=c(e,["enableAffectiveDialog"]);f!=null&&p(t,["enableAffectiveDialog"],f);const g=c(e,["frequencyPenalty"]);g!=null&&p(t,["frequencyPenalty"],g);const v=c(e,["logprobs"]);v!=null&&p(t,["logprobs"],v);const m=c(e,["maxOutputTokens"]);m!=null&&p(t,["maxOutputTokens"],m);const x=c(e,["mediaResolution"]);x!=null&&p(t,["mediaResolution"],x);const b=c(e,["presencePenalty"]);b!=null&&p(t,["presencePenalty"],b);const S=c(e,["responseLogprobs"]);S!=null&&p(t,["responseLogprobs"],S);const _=c(e,["responseMimeType"]);_!=null&&p(t,["responseMimeType"],_);const T=c(e,["responseModalities"]);T!=null&&p(t,["responseModalities"],T);const F=c(e,["responseSchema"]);F!=null&&p(t,["responseSchema"],F);const z=c(e,["routingConfig"]);z!=null&&p(t,["routingConfig"],z);const G=c(e,["seed"]);G!=null&&p(t,["seed"],G);const Y=c(e,["speechConfig"]);Y!=null&&p(t,["speechConfig"],Y);const oe=c(e,["stopSequences"]);oe!=null&&p(t,["stopSequences"],oe);const ce=c(e,["temperature"]);ce!=null&&p(t,["temperature"],ce);const ve=c(e,["thinkingConfig"]);ve!=null&&p(t,["thinkingConfig"],ve);const ye=c(e,["topK"]);ye!=null&&p(t,["topK"],ye);const fe=c(e,["topP"]);if(fe!=null&&p(t,["topP"],fe),c(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function M_(e,t){const o={},l=c(t,["model"]);return l!=null&&p(o,["_url","name"],sn(e,l)),o}function k_(e,t){const o={},l=c(t,["model"]);return l!=null&&p(o,["_url","name"],sn(e,l)),o}function R_(e){const t={};if(c(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=c(e,["enableWidget"]);return o!=null&&p(t,["enableWidget"],o),t}function z_(e){const t={};if(c(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(c(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=c(e,["timeRangeFilter"]);return o!=null&&p(t,["timeRangeFilter"],o),t}function I_(e){const t={},o=c(e,["aspectRatio"]);o!=null&&p(t,["aspectRatio"],o);const l=c(e,["imageSize"]);if(l!=null&&p(t,["imageSize"],l),c(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(c(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function D_(e){const t={},o=c(e,["aspectRatio"]);o!=null&&p(t,["aspectRatio"],o);const l=c(e,["imageSize"]);l!=null&&p(t,["imageSize"],l);const s=c(e,["outputMimeType"]);s!=null&&p(t,["imageOutputOptions","mimeType"],s);const d=c(e,["outputCompressionQuality"]);return d!=null&&p(t,["imageOutputOptions","compressionQuality"],d),t}function L_(e){const t={},o=c(e,["bytesBase64Encoded"]);o!=null&&p(t,["imageBytes"],Nl(o));const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function Mv(e){const t={},o=c(e,["gcsUri"]);o!=null&&p(t,["gcsUri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&p(t,["imageBytes"],Nl(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["mimeType"],s),t}function iu(e){const t={};if(c(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const o=c(e,["imageBytes"]);o!=null&&p(t,["bytesBase64Encoded"],Nl(o));const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function po(e){const t={},o=c(e,["gcsUri"]);o!=null&&p(t,["gcsUri"],o);const l=c(e,["imageBytes"]);l!=null&&p(t,["bytesBase64Encoded"],Nl(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["mimeType"],s),t}function U_(e,t,o){const l={},s=c(t,["pageSize"]);o!==void 0&&s!=null&&p(o,["_query","pageSize"],s);const d=c(t,["pageToken"]);o!==void 0&&d!=null&&p(o,["_query","pageToken"],d);const f=c(t,["filter"]);o!==void 0&&f!=null&&p(o,["_query","filter"],f);const g=c(t,["queryBase"]);return o!==void 0&&g!=null&&p(o,["_url","models_url"],wv(e,g)),l}function F_(e,t,o){const l={},s=c(t,["pageSize"]);o!==void 0&&s!=null&&p(o,["_query","pageSize"],s);const d=c(t,["pageToken"]);o!==void 0&&d!=null&&p(o,["_query","pageToken"],d);const f=c(t,["filter"]);o!==void 0&&f!=null&&p(o,["_query","filter"],f);const g=c(t,["queryBase"]);return o!==void 0&&g!=null&&p(o,["_url","models_url"],wv(e,g)),l}function P_(e,t){const o={},l=c(t,["config"]);return l!=null&&U_(e,l,o),o}function B_(e,t){const o={},l=c(t,["config"]);return l!=null&&F_(e,l,o),o}function j_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["_self"]);if(s!=null){let d=Tv(s);Array.isArray(d)&&(d=d.map(f=>zf(f))),p(t,["models"],d)}return t}function O_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["_self"]);if(s!=null){let d=Tv(s);Array.isArray(d)&&(d=d.map(f=>If(f))),p(t,["models"],d)}return t}function V_(e){const t={},o=c(e,["maskMode"]);o!=null&&p(t,["maskMode"],o);const l=c(e,["segmentationClasses"]);l!=null&&p(t,["maskClasses"],l);const s=c(e,["maskDilation"]);return s!=null&&p(t,["dilation"],s),t}function zf(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["displayName"]);l!=null&&p(t,["displayName"],l);const s=c(e,["description"]);s!=null&&p(t,["description"],s);const d=c(e,["version"]);d!=null&&p(t,["version"],d);const f=c(e,["_self"]);f!=null&&p(t,["tunedModelInfo"],oN(f));const g=c(e,["inputTokenLimit"]);g!=null&&p(t,["inputTokenLimit"],g);const v=c(e,["outputTokenLimit"]);v!=null&&p(t,["outputTokenLimit"],v);const m=c(e,["supportedGenerationMethods"]);m!=null&&p(t,["supportedActions"],m);const x=c(e,["temperature"]);x!=null&&p(t,["temperature"],x);const b=c(e,["maxTemperature"]);b!=null&&p(t,["maxTemperature"],b);const S=c(e,["topP"]);S!=null&&p(t,["topP"],S);const _=c(e,["topK"]);_!=null&&p(t,["topK"],_);const T=c(e,["thinking"]);return T!=null&&p(t,["thinking"],T),t}function If(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["displayName"]);l!=null&&p(t,["displayName"],l);const s=c(e,["description"]);s!=null&&p(t,["description"],s);const d=c(e,["versionId"]);d!=null&&p(t,["version"],d);const f=c(e,["deployedModels"]);if(f!=null){let b=f;Array.isArray(b)&&(b=b.map(S=>t_(S))),p(t,["endpoints"],b)}const g=c(e,["labels"]);g!=null&&p(t,["labels"],g);const v=c(e,["_self"]);v!=null&&p(t,["tunedModelInfo"],lN(v));const m=c(e,["defaultCheckpointId"]);m!=null&&p(t,["defaultCheckpointId"],m);const x=c(e,["checkpoints"]);if(x!=null){let b=x;Array.isArray(b)&&(b=b.map(S=>S)),p(t,["checkpoints"],b)}return t}function H_(e){const t={},o=c(e,["mediaResolution"]);o!=null&&p(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&p(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&p(t,["executableCode"],s);const d=c(e,["fileData"]);d!=null&&p(t,["fileData"],n_(d));const f=c(e,["functionCall"]);f!=null&&p(t,["functionCall"],i_(f));const g=c(e,["functionResponse"]);g!=null&&p(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&p(t,["inlineData"],AE(v));const m=c(e,["text"]);m!=null&&p(t,["text"],m);const x=c(e,["thought"]);x!=null&&p(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&p(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&p(t,["videoMetadata"],S),t}function G_(e){const t={},o=c(e,["productImage"]);return o!=null&&p(t,["image"],po(o)),t}function $_(e,t){const o={},l=c(e,["numberOfImages"]);t!==void 0&&l!=null&&p(t,["parameters","sampleCount"],l);const s=c(e,["baseSteps"]);t!==void 0&&s!=null&&p(t,["parameters","baseSteps"],s);const d=c(e,["outputGcsUri"]);t!==void 0&&d!=null&&p(t,["parameters","storageUri"],d);const f=c(e,["seed"]);t!==void 0&&f!=null&&p(t,["parameters","seed"],f);const g=c(e,["safetyFilterLevel"]);t!==void 0&&g!=null&&p(t,["parameters","safetySetting"],g);const v=c(e,["personGeneration"]);t!==void 0&&v!=null&&p(t,["parameters","personGeneration"],v);const m=c(e,["addWatermark"]);t!==void 0&&m!=null&&p(t,["parameters","addWatermark"],m);const x=c(e,["outputMimeType"]);t!==void 0&&x!=null&&p(t,["parameters","outputOptions","mimeType"],x);const b=c(e,["outputCompressionQuality"]);t!==void 0&&b!=null&&p(t,["parameters","outputOptions","compressionQuality"],b);const S=c(e,["enhancePrompt"]);t!==void 0&&S!=null&&p(t,["parameters","enhancePrompt"],S);const _=c(e,["labels"]);return t!==void 0&&_!=null&&p(t,["labels"],_),o}function q_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["source"]);s!=null&&J_(s,o);const d=c(t,["config"]);return d!=null&&$_(d,o),o}function Y_(e){const t={},o=c(e,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>nu(s))),p(t,["generatedImages"],l)}return t}function J_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&p(t,["instances[0]","prompt"],l);const s=c(e,["personImage"]);t!==void 0&&s!=null&&p(t,["instances[0]","personImage","image"],po(s));const d=c(e,["productImages"]);if(t!==void 0&&d!=null){let f=d;Array.isArray(f)&&(f=f.map(g=>G_(g))),p(t,["instances[0]","productImages"],f)}return o}function K_(e){const t={},o=c(e,["referenceImage"]);o!=null&&p(t,["referenceImage"],po(o));const l=c(e,["referenceId"]);l!=null&&p(t,["referenceId"],l);const s=c(e,["referenceType"]);s!=null&&p(t,["referenceType"],s);const d=c(e,["maskImageConfig"]);d!=null&&p(t,["maskImageConfig"],V_(d));const f=c(e,["controlImageConfig"]);f!=null&&p(t,["controlImageConfig"],LE(f));const g=c(e,["styleImageConfig"]);g!=null&&p(t,["styleImageConfig"],g);const v=c(e,["subjectImageConfig"]);return v!=null&&p(t,["subjectImageConfig"],v),t}function kv(e){const t={},o=c(e,["safetyAttributes","categories"]);o!=null&&p(t,["categories"],o);const l=c(e,["safetyAttributes","scores"]);l!=null&&p(t,["scores"],l);const s=c(e,["contentType"]);return s!=null&&p(t,["contentType"],s),t}function Rv(e){const t={},o=c(e,["safetyAttributes","categories"]);o!=null&&p(t,["categories"],o);const l=c(e,["safetyAttributes","scores"]);l!=null&&p(t,["scores"],l);const s=c(e,["contentType"]);return s!=null&&p(t,["contentType"],s),t}function X_(e){const t={},o=c(e,["category"]);if(o!=null&&p(t,["category"],o),c(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const l=c(e,["threshold"]);return l!=null&&p(t,["threshold"],l),t}function W_(e){const t={},o=c(e,["image"]);return o!=null&&p(t,["image"],po(o)),t}function Q_(e,t){const o={},l=c(e,["mode"]);t!==void 0&&l!=null&&p(t,["parameters","mode"],l);const s=c(e,["maxPredictions"]);t!==void 0&&s!=null&&p(t,["parameters","maxPredictions"],s);const d=c(e,["confidenceThreshold"]);t!==void 0&&d!=null&&p(t,["parameters","confidenceThreshold"],d);const f=c(e,["maskDilation"]);t!==void 0&&f!=null&&p(t,["parameters","maskDilation"],f);const g=c(e,["binaryColorThreshold"]);t!==void 0&&g!=null&&p(t,["parameters","binaryColorThreshold"],g);const v=c(e,["labels"]);return t!==void 0&&v!=null&&p(t,["labels"],v),o}function Z_(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["source"]);s!=null&&tN(s,o);const d=c(t,["config"]);return d!=null&&Q_(d,o),o}function eN(e){const t={},o=c(e,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>E_(s))),p(t,["generatedMasks"],l)}return t}function tN(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&p(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&p(t,["instances[0]","image"],po(s));const d=c(e,["scribbleImage"]);return t!==void 0&&d!=null&&p(t,["instances[0]","scribble"],W_(d)),o}function nN(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&p(t,["functionCallingConfig"],o_(o));const l=c(e,["retrievalConfig"]);return l!=null&&p(t,["retrievalConfig"],l),t}function iN(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),p(t,["functionDeclarations"],x)}if(c(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=c(e,["googleSearchRetrieval"]);l!=null&&p(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&p(t,["computerUse"],s);const d=c(e,["fileSearch"]);d!=null&&p(t,["fileSearch"],d);const f=c(e,["codeExecution"]);if(f!=null&&p(t,["codeExecution"],f),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&p(t,["googleMaps"],R_(g));const v=c(e,["googleSearch"]);v!=null&&p(t,["googleSearch"],z_(v));const m=c(e,["urlContext"]);return m!=null&&p(t,["urlContext"],m),t}function zv(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>l_(S))),p(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&p(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&p(t,["googleSearchRetrieval"],s);const d=c(e,["computerUse"]);if(d!=null&&p(t,["computerUse"],d),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const f=c(e,["codeExecution"]);f!=null&&p(t,["codeExecution"],f);const g=c(e,["enterpriseWebSearch"]);g!=null&&p(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&p(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&p(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&p(t,["urlContext"],x),t}function oN(e){const t={},o=c(e,["baseModel"]);o!=null&&p(t,["baseModel"],o);const l=c(e,["createTime"]);l!=null&&p(t,["createTime"],l);const s=c(e,["updateTime"]);return s!=null&&p(t,["updateTime"],s),t}function lN(e){const t={},o=c(e,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&p(t,["baseModel"],o);const l=c(e,["createTime"]);l!=null&&p(t,["createTime"],l);const s=c(e,["updateTime"]);return s!=null&&p(t,["updateTime"],s),t}function aN(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&p(t,["displayName"],l);const s=c(e,["description"]);t!==void 0&&s!=null&&p(t,["description"],s);const d=c(e,["defaultCheckpointId"]);return t!==void 0&&d!=null&&p(t,["defaultCheckpointId"],d),o}function sN(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&p(t,["displayName"],l);const s=c(e,["description"]);t!==void 0&&s!=null&&p(t,["description"],s);const d=c(e,["defaultCheckpointId"]);return t!==void 0&&d!=null&&p(t,["defaultCheckpointId"],d),o}function rN(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","name"],sn(e,l));const s=c(t,["config"]);return s!=null&&aN(s,o),o}function cN(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["config"]);return s!=null&&sN(s,o),o}function uN(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&p(t,["parameters","storageUri"],l);const s=c(e,["safetyFilterLevel"]);t!==void 0&&s!=null&&p(t,["parameters","safetySetting"],s);const d=c(e,["personGeneration"]);t!==void 0&&d!=null&&p(t,["parameters","personGeneration"],d);const f=c(e,["includeRaiReason"]);t!==void 0&&f!=null&&p(t,["parameters","includeRaiReason"],f);const g=c(e,["outputMimeType"]);t!==void 0&&g!=null&&p(t,["parameters","outputOptions","mimeType"],g);const v=c(e,["outputCompressionQuality"]);t!==void 0&&v!=null&&p(t,["parameters","outputOptions","compressionQuality"],v);const m=c(e,["enhanceInputImage"]);t!==void 0&&m!=null&&p(t,["parameters","upscaleConfig","enhanceInputImage"],m);const x=c(e,["imagePreservationFactor"]);t!==void 0&&x!=null&&p(t,["parameters","upscaleConfig","imagePreservationFactor"],x);const b=c(e,["labels"]);t!==void 0&&b!=null&&p(t,["labels"],b);const S=c(e,["numberOfImages"]);t!==void 0&&S!=null&&p(t,["parameters","sampleCount"],S);const _=c(e,["mode"]);return t!==void 0&&_!=null&&p(t,["parameters","mode"],_),o}function dN(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["_url","model"],sn(e,l));const s=c(t,["image"]);s!=null&&p(o,["instances[0]","image"],po(s));const d=c(t,["upscaleFactor"]);d!=null&&p(o,["parameters","upscaleConfig","upscaleFactor"],d);const f=c(t,["config"]);return f!=null&&uN(f,o),o}function fN(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(d=>nu(d))),p(t,["generatedImages"],s)}return t}function pN(e){const t={},o=c(e,["uri"]);o!=null&&p(t,["uri"],o);const l=c(e,["encodedVideo"]);l!=null&&p(t,["videoBytes"],Nl(l));const s=c(e,["encoding"]);return s!=null&&p(t,["mimeType"],s),t}function hN(e){const t={},o=c(e,["gcsUri"]);o!=null&&p(t,["uri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&p(t,["videoBytes"],Nl(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["mimeType"],s),t}function mN(e){const t={},o=c(e,["image"]);o!=null&&p(t,["_self"],po(o));const l=c(e,["maskMode"]);return l!=null&&p(t,["maskMode"],l),t}function gN(e){const t={},o=c(e,["image"]);o!=null&&p(t,["image"],iu(o));const l=c(e,["referenceType"]);return l!=null&&p(t,["referenceType"],l),t}function yN(e){const t={},o=c(e,["image"]);o!=null&&p(t,["image"],po(o));const l=c(e,["referenceType"]);return l!=null&&p(t,["referenceType"],l),t}function Iv(e){const t={},o=c(e,["uri"]);o!=null&&p(t,["uri"],o);const l=c(e,["videoBytes"]);l!=null&&p(t,["encodedVideo"],Nl(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["encoding"],s),t}function Dv(e){const t={},o=c(e,["uri"]);o!=null&&p(t,["gcsUri"],o);const l=c(e,["videoBytes"]);l!=null&&p(t,["bytesBase64Encoded"],Nl(l));const s=c(e,["mimeType"]);return s!=null&&p(t,["mimeType"],s),t}function vN(e,t){const o={},l=c(e,["displayName"]);return t!==void 0&&l!=null&&p(t,["displayName"],l),o}function xN(e){const t={},o=c(e,["config"]);return o!=null&&vN(o,t),t}function bN(e,t){const o={},l=c(e,["force"]);return t!==void 0&&l!=null&&p(t,["_query","force"],l),o}function SN(e){const t={},o=c(e,["name"]);o!=null&&p(t,["_url","name"],o);const l=c(e,["config"]);return l!=null&&bN(l,t),t}function wN(e){const t={},o=c(e,["name"]);return o!=null&&p(t,["_url","name"],o),t}function TN(e,t){const o={},l=c(e,["customMetadata"]);if(t!==void 0&&l!=null){let d=l;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["customMetadata"],d)}const s=c(e,["chunkingConfig"]);return t!==void 0&&s!=null&&p(t,["chunkingConfig"],s),o}function CN(e){const t={},o=c(e,["name"]);o!=null&&p(t,["name"],o);const l=c(e,["metadata"]);l!=null&&p(t,["metadata"],l);const s=c(e,["done"]);s!=null&&p(t,["done"],s);const d=c(e,["error"]);d!=null&&p(t,["error"],d);const f=c(e,["response"]);return f!=null&&p(t,["response"],_N(f)),t}function EN(e){const t={},o=c(e,["fileSearchStoreName"]);o!=null&&p(t,["_url","file_search_store_name"],o);const l=c(e,["fileName"]);l!=null&&p(t,["fileName"],l);const s=c(e,["config"]);return s!=null&&TN(s,t),t}function _N(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&p(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&p(t,["documentName"],s),t}function NN(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),o}function AN(e){const t={},o=c(e,["config"]);return o!=null&&NN(o,t),t}function MN(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["fileSearchStores"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["fileSearchStores"],d)}return t}function Lv(e,t){const o={},l=c(e,["mimeType"]);t!==void 0&&l!=null&&p(t,["mimeType"],l);const s=c(e,["displayName"]);t!==void 0&&s!=null&&p(t,["displayName"],s);const d=c(e,["customMetadata"]);if(t!==void 0&&d!=null){let g=d;Array.isArray(g)&&(g=g.map(v=>v)),p(t,["customMetadata"],g)}const f=c(e,["chunkingConfig"]);return t!==void 0&&f!=null&&p(t,["chunkingConfig"],f),o}function kN(e){const t={},o=c(e,["fileSearchStoreName"]);o!=null&&p(t,["_url","file_search_store_name"],o);const l=c(e,["config"]);return l!=null&&Lv(l,t),t}function RN(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&p(t,["sdkHttpResponse"],o),t}const zN="Content-Type",IN="X-Server-Timeout",DN="User-Agent",Df="x-goog-api-client",LN="1.34.0",UN=`google-genai-sdk/${LN}`,FN="v1beta1",PN="v1beta";class BN{constructor(t){var o,l;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const s={};this.clientOptions.vertexai?(s.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:FN,s.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(s.apiVersion=(l=this.clientOptions.apiVersion)!==null&&l!==void 0?l:PN,s.baseUrl="https://generativelanguage.googleapis.com/"),s.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=s,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(s,t.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}async getAuthHeaders(){const t=new Headers;return await this.clientOptions.auth.addAuthHeaders(t),t}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const l=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&l.push(t.apiVersion),l.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),o=new URL(t);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,o,l){const s=[this.getRequestUrlInternal(o)];return l&&s.push(this.getBaseResourcePath()),t!==""&&s.push(t),new URL(`${s.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const l=this.shouldPrependVertexProjectPath(t),s=this.constructUrl(t.path,o,l);if(t.queryParams)for(const[f,g]of Object.entries(t.queryParams))s.searchParams.append(f,String(g));let d={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else d.body=t.body;return d=await this.includeExtraHttpOptionsToRequestInit(d,o,s.toString(),t.abortSignal),this.unaryApiCall(s,d,t.httpMethod)}patchHttpOptions(t,o){const l=JSON.parse(JSON.stringify(t));for(const[s,d]of Object.entries(o))typeof d=="object"?l[s]=Object.assign(Object.assign({},l[s]),d):d!==void 0&&(l[s]=d);return l}async requestStream(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const l=this.shouldPrependVertexProjectPath(t),s=this.constructUrl(t.path,o,l);(!s.searchParams.has("alt")||s.searchParams.get("alt")!=="sse")&&s.searchParams.set("alt","sse");let d={};return d.body=t.body,d=await this.includeExtraHttpOptionsToRequestInit(d,o,s.toString(),t.abortSignal),this.streamApiCall(s,d,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,o,l,s){if(o&&o.timeout||s){const d=new AbortController,f=d.signal;if(o.timeout&&o?.timeout>0){const g=setTimeout(()=>d.abort(),o.timeout);g&&typeof g.unref=="function"&&g.unref()}s&&s.addEventListener("abort",()=>{d.abort()}),t.signal=f}return o&&o.extraBody!==null&&jN(t,o.extraBody),t.headers=await this.getHeadersInternal(o,l),t}async unaryApiCall(t,o,l){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:l})).then(async s=>(await Fy(s),new Mf(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}async streamApiCall(t,o,l){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:l})).then(async s=>(await Fy(s),this.processStreamResponse(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}processStreamResponse(t){return uo(this,arguments,function*(){var l;const s=(l=t?.body)===null||l===void 0?void 0:l.getReader(),d=new TextDecoder("utf-8");if(!s)throw new Error("Response body is empty");try{let f="";const g="data:",v=[` - -`,"\r\r",`\r -\r -`];for(;;){const{done:m,value:x}=yield Rt(s.read());if(m){if(f.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const b=d.decode(x,{stream:!0});try{const T=JSON.parse(b);if("error"in T){const F=JSON.parse(JSON.stringify(T.error)),z=F.status,G=F.code,Y=`got status: ${z}. ${JSON.stringify(T)}`;if(G>=400&&G<600)throw new eu({message:Y,status:G})}}catch(T){if(T.name==="ApiError")throw T}f+=b;let S=-1,_=0;for(;;){S=-1,_=0;for(const z of v){const G=f.indexOf(z);G!==-1&&(S===-1||G{throw new Error(`exception ${l} sending request`)})}getDefaultHeaders(){const t={},o=UN+" "+this.clientOptions.userAgentExtra;return t[DN]=o,t[Df]=o,t[zN]="application/json",t}async getHeadersInternal(t,o){const l=new Headers;if(t&&t.headers){for(const[s,d]of Object.entries(t.headers))l.append(s,d);t.timeout&&t.timeout>0&&l.append(IN,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(l,o),l}getFileName(t){var o;let l="";return typeof t=="string"&&(l=t.replace(/[/\\]+$/,""),l=(o=l.split(/[/\\]/).pop())!==null&&o!==void 0?o:""),l}async uploadFile(t,o){var l;const s={};o!=null&&(s.mimeType=o.mimeType,s.name=o.name,s.displayName=o.displayName),s.name&&!s.name.startsWith("files/")&&(s.name=`files/${s.name}`);const d=this.clientOptions.uploader,f=await d.stat(t);s.sizeBytes=String(f.size);const g=(l=o?.mimeType)!==null&&l!==void 0?l:f.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");s.mimeType=g;const v={file:s},m=this.getFileName(t),x=Ze("upload/v1beta/files",v._url),b=await this.fetchUploadUrl(x,s.sizeBytes,s.mimeType,m,v,o?.httpOptions);return d.upload(t,b,this)}async uploadFileToFileSearchStore(t,o,l){var s;const d=this.clientOptions.uploader,f=await d.stat(o),g=String(f.size),v=(s=l?.mimeType)!==null&&s!==void 0?s:f.type;if(v===void 0||v==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const m=`upload/v1beta/${t}:uploadToFileSearchStore`,x=this.getFileName(o),b={};l!=null&&Lv(l,b);const S=await this.fetchUploadUrl(m,g,v,x,b,l?.httpOptions);return d.uploadToFileSearchStore(o,S,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,o,l,s,d,f){var g;let v={};f?v=f:v={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${o}`,"X-Goog-Upload-Header-Content-Type":`${l}`},s?{"X-Goog-Upload-File-Name":s}:{})};const m=await this.request({path:t,body:JSON.stringify(d),httpMethod:"POST",httpOptions:v});if(!m||!m?.headers)throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const x=(g=m?.headers)===null||g===void 0?void 0:g["x-goog-upload-url"];if(x===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return x}}async function Fy(e){var t;if(e===void 0)throw new Error("response is undefined");if(!e.ok){const o=e.status;let l;!((t=e.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?l=await e.json():l={error:{message:await e.text(),code:e.status,status:e.statusText}};const s=JSON.stringify(l);throw o>=400&&o<600?new eu({message:s,status:o}):new Error(s)}}function jN(e,t){if(!t||Object.keys(t).length===0)return;if(e.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let o={};if(typeof e.body=="string"&&e.body.length>0)try{const d=JSON.parse(e.body);if(typeof d=="object"&&d!==null&&!Array.isArray(d))o=d;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function l(d,f){const g=Object.assign({},d);for(const v in f)if(Object.prototype.hasOwnProperty.call(f,v)){const m=f[v],x=g[v];m&&typeof m=="object"&&!Array.isArray(m)&&x&&typeof x=="object"&&!Array.isArray(x)?g[v]=l(x,m):(x&&m&&typeof x!=typeof m&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${v}". Original type: ${typeof x}, New type: ${typeof m}. Overwriting.`),g[v]=m)}return g}const s=l(o,t);e.body=JSON.stringify(s)}const ON="mcp_used/unknown";let VN=!1;function Uv(e){for(const t of e)if(HN(t)||typeof t=="object"&&"inputSchema"in t)return!0;return VN}function Fv(e){var t;const o=(t=e[Df])!==null&&t!==void 0?t:"";e[Df]=(o+` ${ON}`).trimStart()}function HN(e){return e!==null&&typeof e=="object"&&e instanceof cp}function GN(e){return uo(this,arguments,function*(o,l=100){let s,d=0;for(;d0)return;const d={},f=[];for(const x of this.mcpClients)try{for(var g=!0,v=(o=void 0,fo(GN(x))),m;m=await v.next(),t=m.done,!t;g=!0){s=m.value,g=!1;const b=s;f.push(b);const S=b.name;if(d[S])throw new Error(`Duplicate function name ${S} found in MCP tools. Please ensure function names are unique.`);d[S]=x}}catch(b){o={error:b}}finally{try{!g&&!t&&(l=v.return)&&await l.call(v)}finally{if(o)throw o.error}}this.mcpTools=f,this.functionNameToMcpClient=d}async tool(){return await this.initialize(),wT(this.mcpTools,this.config)}async callTool(t){await this.initialize();const o=[];for(const l of t)if(l.name in this.functionNameToMcpClient){const s=this.functionNameToMcpClient[l.name];let d;this.config.timeout&&(d={timeout:this.config.timeout});const f=await s.callTool({name:l.name,arguments:l.args},void 0,d);o.push({functionResponse:{name:l.name,response:f.isError?{error:f}:f}})}return o}}async function $N(e,t,o){const l=new hT;let s;o.data instanceof Blob?s=JSON.parse(await o.data.text()):s=JSON.parse(o.data),Object.assign(l,s),t(l)}class qN{constructor(t,o,l){this.apiClient=t,this.auth=o,this.webSocketFactory=l}async connect(t){var o,l;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const s=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion(),f=KN(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),v=`${s}/ws/google.ai.generativelanguage.${d}.GenerativeService.BidiGenerateMusic?key=${g}`;let m=()=>{};const x=new Promise(oe=>{m=oe}),b=t.callbacks,S=function(){m({})},_=this.apiClient,T={onopen:S,onmessage:oe=>{$N(_,b.onmessage,oe)},onerror:(o=b?.onerror)!==null&&o!==void 0?o:function(oe){},onclose:(l=b?.onclose)!==null&&l!==void 0?l:function(oe){}},F=this.webSocketFactory.create(v,JN(f),T);F.connect(),await x;const Y={setup:{model:sn(this.apiClient,t.model)}};return F.send(JSON.stringify(Y)),new YN(F,this.apiClient)}}class YN{constructor(t,o){this.conn=t,this.apiClient=o}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=xE(t);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const o=vE(t);this.conn.send(JSON.stringify(o))}sendPlaybackControl(t){const o={playbackControl:t};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(Va.PLAY)}pause(){this.sendPlaybackControl(Va.PAUSE)}stop(){this.sendPlaybackControl(Va.STOP)}resetContext(){this.sendPlaybackControl(Va.RESET_CONTEXT)}close(){this.conn.close()}}function JN(e){const t={};return e.forEach((o,l)=>{t[l]=o}),t}function KN(e){const t=new Headers;for(const[o,l]of Object.entries(e))t.append(o,l);return t}const XN="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function WN(e,t,o){const l=new pT;let s;o.data instanceof Blob?s=await o.data.text():o.data instanceof ArrayBuffer?s=new TextDecoder().decode(o.data):s=o.data;const d=JSON.parse(s);if(e.isVertexAI()){const f=wE(d);Object.assign(l,f)}else Object.assign(l,d);t(l)}class QN{constructor(t,o,l){this.apiClient=t,this.auth=o,this.webSocketFactory=l,this.music=new qN(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var o,l,s,d,f,g;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const v=this.apiClient.getWebsocketBaseUrl(),m=this.apiClient.getApiVersion();let x;const b=this.apiClient.getHeaders();t.config&&t.config.tools&&Uv(t.config.tools)&&Fv(b);const S=nA(b);if(this.apiClient.isVertexAI())x=`${v}/ws/google.cloud.aiplatform.${m}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(S,x);else{const ge=this.apiClient.getApiKey();let qe="BidiGenerateContent",Ve="key";ge?.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),m!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),qe="BidiGenerateContentConstrained",Ve="access_token"),x=`${v}/ws/google.ai.generativelanguage.${m}.GenerativeService.${qe}?${Ve}=${ge}`}let _=()=>{};const T=new Promise(ge=>{_=ge}),F=t.callbacks,z=function(){var ge;(ge=F?.onopen)===null||ge===void 0||ge.call(F),_({})},G=this.apiClient,Y={onopen:z,onmessage:ge=>{WN(G,F.onmessage,ge)},onerror:(o=F?.onerror)!==null&&o!==void 0?o:function(ge){},onclose:(l=F?.onclose)!==null&&l!==void 0?l:function(ge){}},oe=this.webSocketFactory.create(x,tA(S),Y);oe.connect(),await T;let ce=sn(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&ce.startsWith("publishers/")){const ge=this.apiClient.getProject(),qe=this.apiClient.getLocation();ce=`projects/${ge}/locations/${qe}/`+ce}let ve={};this.apiClient.isVertexAI()&&((s=t.config)===null||s===void 0?void 0:s.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[Oc.AUDIO]}:t.config.responseModalities=[Oc.AUDIO]),!((d=t.config)===null||d===void 0)&&d.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const ye=(g=(f=t.config)===null||f===void 0?void 0:f.tools)!==null&&g!==void 0?g:[],fe=[];for(const ge of ye)if(this.isCallableTool(ge)){const qe=ge;fe.push(await qe.tool())}else fe.push(ge);fe.length>0&&(t.config.tools=fe);const Je={model:ce,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?ve=yE(this.apiClient,Je):ve=gE(this.apiClient,Je),delete ve.config,oe.send(JSON.stringify(ve)),new eA(oe,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const ZN={turnComplete:!0};class eA{constructor(t,o){this.conn=t,this.apiClient=o}tLiveClientContent(t,o){if(o.turns!==null&&o.turns!==void 0){let l=[];try{l=Zi(o.turns),t.isVertexAI()||(l=l.map(s=>tu(s)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof o.turns}'`)}return{clientContent:{turns:l,turnComplete:o.turnComplete}}}return{clientContent:{turnComplete:o.turnComplete}}}tLiveClienttToolResponse(t,o){let l=[];if(o.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(o.functionResponses)?l=o.functionResponses:l=[o.functionResponses],l.length===0)throw new Error("functionResponses is required.");for(const d of l){if(typeof d!="object"||d===null||!("name"in d)||!("response"in d))throw new Error(`Could not parse function response, type '${typeof d}'.`);if(!t.isVertexAI()&&!("id"in d))throw new Error(XN)}return{toolResponse:{functionResponses:l}}}sendClientContent(t){t=Object.assign(Object.assign({},ZN),t);const o=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(o))}sendRealtimeInput(t){let o={};this.apiClient.isVertexAI()?o={realtimeInput:SE(t)}:o={realtimeInput:bE(t)},this.conn.send(JSON.stringify(o))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function tA(e){const t={};return e.forEach((o,l)=>{t[l]=o}),t}function nA(e){const t=new Headers;for(const[o,l]of Object.entries(e))t.append(o,l);return t}const Py=10;function By(e){var t,o,l;if(!((t=e?.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let s=!1;for(const f of(o=e?.tools)!==null&&o!==void 0?o:[])if(Ya(f)){s=!0;break}if(!s)return!0;const d=(l=e?.automaticFunctionCalling)===null||l===void 0?void 0:l.maximumRemoteCalls;return d&&(d<0||!Number.isInteger(d))||d==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",d),!0):!1}function Ya(e){return"callTool"in e&&typeof e.callTool=="function"}function iA(e){var t,o,l;return(l=(o=(t=e.config)===null||t===void 0?void 0:t.tools)===null||o===void 0?void 0:o.some(s=>Ya(s)))!==null&&l!==void 0?l:!1}function jy(e){var t;const o=[];return!((t=e?.config)===null||t===void 0)&&t.tools&&e.config.tools.forEach((l,s)=>{if(Ya(l))return;const d=l;d.functionDeclarations&&d.functionDeclarations.length>0&&o.push(s)}),o}function Oy(e){var t;return!(!((t=e?.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}class oA extends Jo{constructor(t){super(),this.apiClient=t,this.generateContent=async o=>{var l,s,d,f,g;const v=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!iA(o)||By(o.config))return await this.generateContentInternal(v);const m=jy(o);if(m.length>0){const F=m.map(z=>`tools[${z}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${F}.`)}let x,b;const S=Zi(v.contents),_=(d=(s=(l=v.config)===null||l===void 0?void 0:l.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&d!==void 0?d:Py;let T=0;for(;T<_&&(x=await this.generateContentInternal(v),!(!x.functionCalls||x.functionCalls.length===0));){const F=x.candidates[0].content,z=[];for(const G of(g=(f=o.config)===null||f===void 0?void 0:f.tools)!==null&&g!==void 0?g:[])if(Ya(G)){const oe=await G.callTool(x.functionCalls);z.push(...oe)}T++,b={role:"user",parts:z},v.contents=Zi(v.contents),v.contents.push(F),v.contents.push(b),Oy(v.config)&&(S.push(F),S.push(b))}return Oy(v.config)&&(x.automaticFunctionCallingHistory=S),x},this.generateContentStream=async o=>{var l,s,d,f,g;if(this.maybeMoveToResponseJsonSchem(o),By(o.config)){const b=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(b)}const v=jy(o);if(v.length>0){const b=v.map(S=>`tools[${S}]`).join(", ");throw new Error(`Incompatible tools found at ${b}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const m=(d=(s=(l=o?.config)===null||l===void 0?void 0:l.toolConfig)===null||s===void 0?void 0:s.functionCallingConfig)===null||d===void 0?void 0:d.streamFunctionCallArguments,x=(g=(f=o?.config)===null||f===void 0?void 0:f.automaticFunctionCalling)===null||g===void 0?void 0:g.disable;if(m&&!x)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(l=>{var s;let d;const f=[];if(l?.generatedImages)for(const v of l.generatedImages)v&&v?.safetyAttributes&&((s=v?.safetyAttributes)===null||s===void 0?void 0:s.contentType)==="Positive Prompt"?d=v?.safetyAttributes:f.push(v);let g;return d?g={generatedImages:f,positivePromptSafetyAttributes:d,sdkHttpResponse:l.sdkHttpResponse}:g={generatedImages:f,sdkHttpResponse:l.sdkHttpResponse},g}),this.list=async o=>{var l;const f={config:Object.assign(Object.assign({},{queryBase:!0}),o?.config)};if(this.apiClient.isVertexAI()&&!f.config.queryBase){if(!((l=f.config)===null||l===void 0)&&l.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");f.config.filter="labels.tune-type:*"}return new ea(Yo.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(f),f)},this.editImage=async o=>{const l={model:o.model,prompt:o.prompt,referenceImages:[],config:o.config};return o.referenceImages&&o.referenceImages&&(l.referenceImages=o.referenceImages.map(s=>s.toReferenceImageAPI())),await this.editImageInternal(l)},this.upscaleImage=async o=>{let l={numberOfImages:1,mode:"upscale"};o.config&&(l=Object.assign(Object.assign({},l),o.config));const s={model:o.model,image:o.image,upscaleFactor:o.upscaleFactor,config:l};return await this.upscaleImageInternal(s)},this.generateVideos=async o=>{var l,s,d,f,g,v;if((o.prompt||o.image||o.video)&&o.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((l=o.video)===null||l===void 0)&&l.uri&&(!((s=o.video)===null||s===void 0)&&s.videoBytes)?o.video={uri:o.video.uri,mimeType:o.video.mimeType}:!((f=(d=o.source)===null||d===void 0?void 0:d.video)===null||f===void 0)&&f.uri&&(!((v=(g=o.source)===null||g===void 0?void 0:g.video)===null||v===void 0)&&v.videoBytes)&&(o.source.video={uri:o.source.video.uri,mimeType:o.source.video.mimeType})),await this.generateVideosInternal(o)}}maybeMoveToResponseJsonSchem(t){t.config&&t.config.responseSchema&&(t.config.responseJsonSchema||Object.keys(t.config.responseSchema).includes("$schema")&&(t.config.responseJsonSchema=t.config.responseSchema,delete t.config.responseSchema))}async processParamsMaybeAddMcpUsage(t){var o,l,s;const d=(o=t.config)===null||o===void 0?void 0:o.tools;if(!d)return t;const f=await Promise.all(d.map(async v=>Ya(v)?await v.tool():v)),g={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:f})};if(g.config.tools=f,t.config&&t.config.tools&&Uv(t.config.tools)){const v=(s=(l=t.config.httpOptions)===null||l===void 0?void 0:l.headers)!==null&&s!==void 0?s:{};let m=Object.assign({},v);Object.keys(m).length===0&&(m=this.apiClient.getDefaultHeaders()),Fv(m),g.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:m})}return g}async initAfcToolsMap(t){var o,l,s;const d=new Map;for(const f of(l=(o=t.config)===null||o===void 0?void 0:o.tools)!==null&&l!==void 0?l:[])if(Ya(f)){const g=f,v=await g.tool();for(const m of(s=v.functionDeclarations)!==null&&s!==void 0?s:[]){if(!m.name)throw new Error("Function declaration name is required.");if(d.has(m.name))throw new Error(`Duplicate tool declaration name: ${m.name}`);d.set(m.name,g)}}return d}async processAfcStream(t){var o,l,s;const d=(s=(l=(o=t.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||l===void 0?void 0:l.maximumRemoteCalls)!==null&&s!==void 0?s:Py;let f=!1,g=0;const v=await this.initAfcToolsMap(t);return(function(m,x,b){return uo(this,arguments,function*(){for(var S,_,T,F,z,G;g0){f=!0;const ge=new Vs;ge.candidates=[{content:{role:"user",parts:fe}}],yield yield Rt(ge);const qe=[];qe.push(...Je),qe.push({role:"user",parts:fe});const Ve=Zi(b.contents).concat(qe);b.contents=Ve}else break}})})(this,v,t)}async generateContentInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=Dy(this.apiClient,t);return g=Ze("{model}:generateContent",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=Uy(x),S=new Vs;return Object.assign(S,b),S})}else{const m=Iy(this.apiClient,t);return g=Ze("{model}:generateContent",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=Ly(x),S=new Vs;return Object.assign(S,b),S})}}async generateContentStreamInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=Dy(this.apiClient,t);return g=Ze("{model}:streamGenerateContent?alt=sse",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.requestStream({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}),f.then(function(b){return uo(this,arguments,function*(){var S,_,T,F;try{for(var z=!0,G=fo(b),Y;Y=yield Rt(G.next()),S=Y.done,!S;z=!0){F=Y.value,z=!1;const oe=F,ce=Uy(yield Rt(oe.json()));ce.sdkHttpResponse={headers:oe.headers};const ve=new Vs;Object.assign(ve,ce),yield yield Rt(ve)}}catch(oe){_={error:oe}}finally{try{!z&&!S&&(T=G.return)&&(yield Rt(T.call(G)))}finally{if(_)throw _.error}}})})}else{const m=Iy(this.apiClient,t);return g=Ze("{model}:streamGenerateContent?alt=sse",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.requestStream({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}),f.then(function(b){return uo(this,arguments,function*(){var S,_,T,F;try{for(var z=!0,G=fo(b),Y;Y=yield Rt(G.next()),S=Y.done,!S;z=!0){F=Y.value,z=!1;const oe=F,ce=Ly(yield Rt(oe.json()));ce.sdkHttpResponse={headers:oe.headers};const ve=new Vs;Object.assign(ve,ce),yield yield Rt(ve)}}catch(oe){_={error:oe}}finally{try{!z&&!S&&(T=G.return)&&(yield Rt(T.call(G)))}finally{if(_)throw _.error}}})})}}async embedContent(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=QE(this.apiClient,t);return g=Ze("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=e_(x),S=new gy;return Object.assign(S,b),S})}else{const m=WE(this.apiClient,t);return g=Ze("{model}:batchEmbedContents",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=ZE(x),S=new gy;return Object.assign(S,b),S})}}async generateImagesInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=d_(this.apiClient,t);return g=Ze("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=p_(x),S=new yy;return Object.assign(S,b),S})}else{const m=u_(this.apiClient,t);return g=Ze("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=f_(x),S=new yy;return Object.assign(S,b),S})}}async editImageInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=YE(this.apiClient,t);return d=Ze("{model}:predict",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>{const m=JE(v),x=new nT;return Object.assign(x,m),x})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=dN(this.apiClient,t);return d=Ze("{model}:predict",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>{const m=fN(v),x=new iT;return Object.assign(x,m),x})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=q_(this.apiClient,t);return d=Ze("{model}:predict",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=Y_(v),x=new oT;return Object.assign(x,m),x})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=Z_(this.apiClient,t);return d=Ze("{model}:predict",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=eN(v),x=new lT;return Object.assign(x,m),x})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=k_(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>If(x))}else{const m=M_(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>zf(x))}}async listInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=B_(this.apiClient,t);return g=Ze("{models_url}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=O_(x),S=new vy;return Object.assign(S,b),S})}else{const m=P_(this.apiClient,t);return g=Ze("{models_url}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=j_(x),S=new vy;return Object.assign(S,b),S})}}async update(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=cN(this.apiClient,t);return g=Ze("{model}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>If(x))}else{const m=rN(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"PATCH",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>zf(x))}}async delete(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=HE(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=$E(x),S=new xy;return Object.assign(S,b),S})}else{const m=VE(this.apiClient,t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=GE(x),S=new xy;return Object.assign(S,b),S})}}async countTokens(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=BE(this.apiClient,t);return g=Ze("{model}:countTokens",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=OE(x),S=new by;return Object.assign(S,b),S})}else{const m=PE(this.apiClient,t);return g=Ze("{model}:countTokens",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=jE(x),S=new by;return Object.assign(S,b),S})}}async computeTokens(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=RE(this.apiClient,t);return d=Ze("{model}:computeTokens",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>{const m=zE(v),x=new aT;return Object.assign(x,m),x})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=x_(this.apiClient,t);return g=Ze("{model}:predictLongRunning",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f.then(x=>{const b=y_(x),S=new Vc;return Object.assign(S,b),S})}else{const m=v_(this.apiClient,t);return g=Ze("{model}:predictLongRunning",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f.then(x=>{const b=g_(x),S=new Vc;return Object.assign(S,b),S})}}}class lA extends Jo{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const o=t.operation,l=t.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=o.name.split("/operations/")[0];let d;l&&"httpOptions"in l&&(d=l.httpOptions);const f=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:s,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:f,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:o.name,config:l});return o._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async get(t){const o=t.operation,l=t.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const s=o.name.split("/operations/")[0];let d;l&&"httpOptions"in l&&(d=l.httpOptions);const f=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:s,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:f,_isVertexAI:!0})}else{const s=await this.getVideosOperationInternal({operationName:o.name,config:l});return o._fromAPIResponse({apiResponse:s,_isVertexAI:!1})}}async getVideosOperationInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=Xw(t);return g=Ze("{operationName}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json()),f}else{const m=Kw(t);return g=Ze("{operationName}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json()),f}}async fetchPredictVideosOperationInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=Vw(t);return d=Ze("{resourceName}:fetchPredictOperation",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s}else throw new Error("This method is only supported by the Vertex AI.")}}function aA(e){const t={},o=c(e,["data"]);if(o!=null&&p(t,["data"],o),c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function sA(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(d=>gA(d))),p(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&p(t,["role"],l),t}function rA(e,t,o){const l={},s=c(t,["expireTime"]);o!==void 0&&s!=null&&p(o,["expireTime"],s);const d=c(t,["newSessionExpireTime"]);o!==void 0&&d!=null&&p(o,["newSessionExpireTime"],d);const f=c(t,["uses"]);o!==void 0&&f!=null&&p(o,["uses"],f);const g=c(t,["liveConnectConstraints"]);o!==void 0&&g!=null&&p(o,["bidiGenerateContentSetup"],mA(e,g));const v=c(t,["lockAdditionalFields"]);return o!==void 0&&v!=null&&p(o,["fieldMask"],v),l}function cA(e,t){const o={},l=c(t,["config"]);return l!=null&&p(o,["config"],rA(e,l,o)),o}function uA(e){const t={};if(c(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=c(e,["fileUri"]);o!=null&&p(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&p(t,["mimeType"],l),t}function dA(e){const t={},o=c(e,["id"]);o!=null&&p(t,["id"],o);const l=c(e,["args"]);l!=null&&p(t,["args"],l);const s=c(e,["name"]);if(s!=null&&p(t,["name"],s),c(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(c(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function fA(e){const t={};if(c(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=c(e,["enableWidget"]);return o!=null&&p(t,["enableWidget"],o),t}function pA(e){const t={};if(c(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(c(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=c(e,["timeRangeFilter"]);return o!=null&&p(t,["timeRangeFilter"],o),t}function hA(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&p(t,["setup","generationConfig"],l);const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&p(t,["setup","generationConfig","responseModalities"],s);const d=c(e,["temperature"]);t!==void 0&&d!=null&&p(t,["setup","generationConfig","temperature"],d);const f=c(e,["topP"]);t!==void 0&&f!=null&&p(t,["setup","generationConfig","topP"],f);const g=c(e,["topK"]);t!==void 0&&g!=null&&p(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&p(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&p(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&p(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&p(t,["setup","generationConfig","speechConfig"],rp(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&p(t,["setup","generationConfig","thinkingConfig"],S);const _=c(e,["enableAffectiveDialog"]);t!==void 0&&_!=null&&p(t,["setup","generationConfig","enableAffectiveDialog"],_);const T=c(e,["systemInstruction"]);t!==void 0&&T!=null&&p(t,["setup","systemInstruction"],sA(hi(T)));const F=c(e,["tools"]);if(t!==void 0&&F!=null){let ye=Za(F);Array.isArray(ye)&&(ye=ye.map(fe=>vA(Qa(fe)))),p(t,["setup","tools"],ye)}const z=c(e,["sessionResumption"]);t!==void 0&&z!=null&&p(t,["setup","sessionResumption"],yA(z));const G=c(e,["inputAudioTranscription"]);t!==void 0&&G!=null&&p(t,["setup","inputAudioTranscription"],G);const Y=c(e,["outputAudioTranscription"]);t!==void 0&&Y!=null&&p(t,["setup","outputAudioTranscription"],Y);const oe=c(e,["realtimeInputConfig"]);t!==void 0&&oe!=null&&p(t,["setup","realtimeInputConfig"],oe);const ce=c(e,["contextWindowCompression"]);t!==void 0&&ce!=null&&p(t,["setup","contextWindowCompression"],ce);const ve=c(e,["proactivity"]);if(t!==void 0&&ve!=null&&p(t,["setup","proactivity"],ve),c(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function mA(e,t){const o={},l=c(t,["model"]);l!=null&&p(o,["setup","model"],sn(e,l));const s=c(t,["config"]);return s!=null&&p(o,["config"],hA(s,o)),o}function gA(e){const t={},o=c(e,["mediaResolution"]);o!=null&&p(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&p(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&p(t,["executableCode"],s);const d=c(e,["fileData"]);d!=null&&p(t,["fileData"],uA(d));const f=c(e,["functionCall"]);f!=null&&p(t,["functionCall"],dA(f));const g=c(e,["functionResponse"]);g!=null&&p(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&p(t,["inlineData"],aA(v));const m=c(e,["text"]);m!=null&&p(t,["text"],m);const x=c(e,["thought"]);x!=null&&p(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&p(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&p(t,["videoMetadata"],S),t}function yA(e){const t={},o=c(e,["handle"]);if(o!=null&&p(t,["handle"],o),c(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function vA(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),p(t,["functionDeclarations"],x)}if(c(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=c(e,["googleSearchRetrieval"]);l!=null&&p(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&p(t,["computerUse"],s);const d=c(e,["fileSearch"]);d!=null&&p(t,["fileSearch"],d);const f=c(e,["codeExecution"]);if(f!=null&&p(t,["codeExecution"],f),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&p(t,["googleMaps"],fA(g));const v=c(e,["googleSearch"]);v!=null&&p(t,["googleSearch"],pA(v));const m=c(e,["urlContext"]);return m!=null&&p(t,["urlContext"],m),t}function xA(e){const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const l=e[o];if(typeof l=="object"&&l!=null&&Object.keys(l).length>0){const s=Object.keys(l).map(d=>`${o}.${d}`);t.push(...s)}else t.push(o)}return t.join(",")}function bA(e,t){let o=null;const l=e.bidiGenerateContentSetup;if(typeof l=="object"&&l!==null&&"setup"in l){const d=l.setup;typeof d=="object"&&d!==null?(e.bidiGenerateContentSetup=d,o=d):delete e.bidiGenerateContentSetup}else l!==void 0&&delete e.bidiGenerateContentSetup;const s=e.fieldMask;if(o){const d=xA(o);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)d?e.fieldMask=d:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&s!==null&&Array.isArray(s)&&s.length>0){const f=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];s.length>0&&(g=s.map(m=>f.includes(m)?`generationConfig.${m}`:m));const v=[];d&&v.push(d),g.length>0&&v.push(...g),v.length>0?e.fieldMask=v.join(","):delete e.fieldMask}else delete e.fieldMask}else s!==null&&Array.isArray(s)&&s.length>0?e.fieldMask=s.join(","):delete e.fieldMask;return e}class SA extends Jo{constructor(t){super(),this.apiClient=t}async create(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=cA(this.apiClient,t);d=Ze("auth_tokens",g._url),f=g._query,delete g.config,delete g._url,delete g._query;const v=bA(g,t.config);return s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(v),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(m=>m.json()),s.then(m=>m)}}}function wA(e,t){const o={},l=c(e,["force"]);return t!==void 0&&l!=null&&p(t,["_query","force"],l),o}function TA(e){const t={},o=c(e,["name"]);o!=null&&p(t,["_url","name"],o);const l=c(e,["config"]);return l!=null&&wA(l,t),t}function CA(e){const t={},o=c(e,["name"]);return o!=null&&p(t,["_url","name"],o),t}function EA(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&p(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&p(t,["_query","pageToken"],s),o}function _A(e){const t={},o=c(e,["parent"]);o!=null&&p(t,["_url","parent"],o);const l=c(e,["config"]);return l!=null&&EA(l,t),t}function NA(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&p(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&p(t,["nextPageToken"],l);const s=c(e,["documents"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(f=>f)),p(t,["documents"],d)}return t}class AA extends Jo{constructor(t){super(),this.apiClient=t,this.list=async o=>new ea(Yo.PAGED_ITEM_DOCUMENTS,l=>this.listInternal({parent:o.parent,config:l.config}),await this.listInternal(o),o)}async get(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=CA(t);return d=Ze("{name}",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>v)}}async delete(t){var o,l;let s="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const f=TA(t);s=Ze("{name}",f._url),d=f._query,delete f._url,delete f._query,await this.apiClient.request({path:s,queryParams:d,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal})}}async listInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=_A(t);return d=Ze("{parent}/documents",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=NA(v),x=new sT;return Object.assign(x,m),x})}}}class MA extends Jo{constructor(t,o=new AA(t)){super(),this.apiClient=t,this.documents=o,this.list=async(l={})=>new ea(Yo.PAGED_ITEM_FILE_SEARCH_STORES,s=>this.listInternal(s),await this.listInternal(l),l)}async uploadToFileSearchStore(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(t.fileSearchStoreName,t.file,t.config)}async create(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=xN(t);return d=Ze("fileSearchStores",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>v)}}async get(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=wN(t);return d=Ze("{name}",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>v)}}async delete(t){var o,l;let s="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const f=SN(t);s=Ze("{name}",f._url),d=f._query,delete f._url,delete f._query,await this.apiClient.request({path:s,queryParams:d,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal})}}async listInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=AN(t);return d=Ze("fileSearchStores",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=MN(v),x=new rT;return Object.assign(x,m),x})}}async uploadToFileSearchStoreInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=kN(t);return d=Ze("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=RN(v),x=new cT;return Object.assign(x,m),x})}}async importFile(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=EN(t);return d=Ze("{file_search_store_name}:importFile",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json()),s.then(v=>{const m=CN(v),x=new ip;return Object.assign(x,m),x})}}}let Pv=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return Pv=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),o=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,l=>(+l^o()&15>>+l/4).toString(16))};const kA=()=>Pv();function Lf(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const Uf=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};class eo extends Error{}class bi extends eo{constructor(t,o,l,s){super(`${bi.makeMessage(t,o,l)}`),this.status=t,this.headers=s,this.error=o}static makeMessage(t,o,l){const s=o?.message?typeof o.message=="string"?o.message:JSON.stringify(o.message):o?JSON.stringify(o):l;return t&&s?`${t} ${s}`:t?`${t} status code (no body)`:s||"(no status code or body)"}static generate(t,o,l,s){if(!t||!s)return new ou({message:l,cause:Uf(o)});const d=o;return t===400?new jv(t,d,l,s):t===401?new Ov(t,d,l,s):t===403?new Vv(t,d,l,s):t===404?new Hv(t,d,l,s):t===409?new Gv(t,d,l,s):t===422?new $v(t,d,l,s):t===429?new qv(t,d,l,s):t>=500?new Yv(t,d,l,s):new bi(t,d,l,s)}}class Ff extends bi{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class ou extends bi{constructor({message:t,cause:o}){super(void 0,void 0,t||"Connection error.",void 0),o&&(this.cause=o)}}class Bv extends ou{constructor({message:t}={}){super({message:t??"Request timed out."})}}class jv extends bi{}class Ov extends bi{}class Vv extends bi{}class Hv extends bi{}class Gv extends bi{}class $v extends bi{}class qv extends bi{}class Yv extends bi{}const RA=/^[a-z][a-z0-9+.-]*:/i,zA=e=>RA.test(e);let Pf=e=>(Pf=Array.isArray,Pf(e));const IA=Pf;let DA=IA;const Vy=DA;function LA(e){if(!e)return!0;for(const t in e)return!1;return!0}function UA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const FA=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new eo(`${e} must be an integer`);if(t<0)throw new eo(`${e} must be a positive integer`);return t},PA=e=>{try{return JSON.parse(e)}catch{return}};const BA=e=>new Promise(t=>setTimeout(t,e));const Ba="0.0.1";function jA(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const OA=()=>{var e,t,o,l,s;const d=jA();if(d==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ba,"X-Stainless-OS":Gy(Deno.build.os),"X-Stainless-Arch":Hy(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:(t=(e=Deno.version)===null||e===void 0?void 0:e.deno)!==null&&t!==void 0?t:"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ba,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(d==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ba,"X-Stainless-OS":Gy((o=globalThis.process.platform)!==null&&o!==void 0?o:"unknown"),"X-Stainless-Arch":Hy((l=globalThis.process.arch)!==null&&l!==void 0?l:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(s=globalThis.process.version)!==null&&s!==void 0?s:"unknown"};const f=VA();return f?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ba,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${f.browser}`,"X-Stainless-Runtime-Version":f.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ba,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function VA(){if(typeof navigator>"u"||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:o}of e){const l=o.exec(navigator.userAgent);if(l){const s=l[1]||0,d=l[2]||0,f=l[3]||0;return{browser:t,version:`${s}.${d}.${f}`}}}return null}const Hy=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",Gy=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown");let Sc;const HA=()=>Sc??(Sc=OA());function GA(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Jv(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function $A(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Jv({start(){},async pull(o){const{done:l,value:s}=await t.next();l?o.close():o.enqueue(s)},async cancel(){var o;await((o=t.return)===null||o===void 0?void 0:o.call(t))}})}function Kv(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const o=await t.read();return o?.done&&t.releaseLock(),o}catch(o){throw t.releaseLock(),o}},async return(){const o=t.cancel();return t.releaseLock(),await o,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function qA(e){var t,o;if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await((o=(t=e[Symbol.asyncIterator]()).return)===null||o===void 0?void 0:o.call(t));return}const l=e.getReader(),s=l.cancel();l.releaseLock(),await s}const YA=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});const Xv=()=>{var e;if(typeof File>"u"){const{process:t}=globalThis,o=typeof((e=t?.versions)===null||e===void 0?void 0:e.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(o?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function hf(e,t,o){return Xv(),new File(e,t??"unknown_file",o)}function JA(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}const KA=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";const Wv=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",XA=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&Wv(e),WA=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function QA(e,t,o){if(Xv(),e=await e,XA(e))return e instanceof File?e:hf([await e.arrayBuffer()],e.name);if(WA(e)){const s=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),hf(await Bf(s),t,o)}const l=await Bf(e);if(t||(t=JA(e)),!o?.type){const s=l.find(d=>typeof d=="object"&&"type"in d&&d.type);typeof s=="string"&&(o=Object.assign(Object.assign({},o),{type:s}))}return hf(l,t,o)}async function Bf(e){var t,o,l,s,d;let f=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)f.push(e);else if(Wv(e))f.push(e instanceof Blob?e:await e.arrayBuffer());else if(KA(e))try{for(var g=!0,v=fo(e),m;m=await v.next(),t=m.done,!t;g=!0){s=m.value,g=!1;const x=s;f.push(...await Bf(x))}}catch(x){o={error:x}}finally{try{!g&&!t&&(l=v.return)&&await l.call(v)}finally{if(o)throw o.error}}else{const x=(d=e?.constructor)===null||d===void 0?void 0:d.name;throw new Error(`Unexpected data type: ${typeof e}${x?`; constructor: ${x}`:""}${ZA(e)}`)}return f}function ZA(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(o=>`"${o}"`).join(", ")}]`}class Qv{constructor(t){this._client=t}}Qv._key=[];function Zv(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const $y=Object.freeze(Object.create(null)),eM=(e=Zv)=>(function(o,...l){if(o.length===1)return o[0];let s=!1;const d=[],f=o.reduce((x,b,S)=>{var _,T,F;/[?#]/.test(b)&&(s=!0);const z=l[S];let G=(s?encodeURIComponent:e)(""+z);return S!==l.length&&(z==null||typeof z=="object"&&z.toString===((F=Object.getPrototypeOf((T=Object.getPrototypeOf((_=z.hasOwnProperty)!==null&&_!==void 0?_:$y))!==null&&T!==void 0?T:$y))===null||F===void 0?void 0:F.toString))&&(G=z+"",d.push({start:x.length+b.length,length:G.length,error:`Value of type ${Object.prototype.toString.call(z).slice(8,-1)} is not a valid path parameter`})),x+b+(S===l.length?"":G)},""),g=f.split(/[?#]/,1)[0],v=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let m;for(;(m=v.exec(g))!==null;)d.push({start:m.index,length:m[0].length,error:`Value "${m[0]}" can't be safely passed as a path parameter`});if(d.sort((x,b)=>x.start-b.start),d.length>0){let x=0;const b=d.reduce((S,_)=>{const T=" ".repeat(_.start-x),F="^".repeat(_.length);return x=_.start+_.length,S+T+F},"");throw new eo(`Path parameters result in path with invalid segments: -${d.map(S=>S.error).join(` -`)} -${f} -${b}`)}return f}),wc=eM(Zv);class ex extends Qv{create(t,o){var l;const{api_version:s=this._client.apiVersion}=t,d=Gc(t,["api_version"]);if("model"in d&&"agent_config"in d)throw new eo("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in d&&"generation_config"in d)throw new eo("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(wc`/${s}/interactions`,Object.assign(Object.assign({body:d},o),{stream:(l=t.stream)!==null&&l!==void 0?l:!1}))}delete(t,o={},l){const{api_version:s=this._client.apiVersion}=o??{};return this._client.delete(wc`/${s}/interactions/${t}`,l)}cancel(t,o={},l){const{api_version:s=this._client.apiVersion}=o??{};return this._client.post(wc`/${s}/interactions/${t}/cancel`,l)}get(t,o={},l){var s;const d=o??{},{api_version:f=this._client.apiVersion}=d,g=Gc(d,["api_version"]);return this._client.get(wc`/${f}/interactions/${t}`,Object.assign(Object.assign({query:g},l),{stream:(s=o?.stream)!==null&&s!==void 0?s:!1}))}}ex._key=Object.freeze(["interactions"]);class tx extends ex{}function tM(e){let t=0;for(const s of e)t+=s.length;const o=new Uint8Array(t);let l=0;for(const s of e)o.set(s,l),l+=s.length;return o}let Tc;function up(e){let t;return(Tc??(t=new globalThis.TextEncoder,Tc=t.encode.bind(t)))(e)}let Cc;function qy(e){let t;return(Cc??(t=new globalThis.TextDecoder,Cc=t.decode.bind(t)))(e)}class lu{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(t){if(t==null)return[];const o=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?up(t):t;this.buffer=tM([this.buffer,o]);const l=[];let s;for(;(s=nM(this.buffer,this.carriageReturnIndex))!=null;){if(s.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=s.index;continue}if(this.carriageReturnIndex!=null&&(s.index!==this.carriageReturnIndex+1||s.carriage)){l.push(qy(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const d=this.carriageReturnIndex!==null?s.preceding-1:s.preceding,f=qy(this.buffer.subarray(0,d));l.push(f),this.buffer=this.buffer.subarray(s.index),this.carriageReturnIndex=null}return l}flush(){return this.buffer.length?this.decode(` -`):[]}}lu.NEWLINE_CHARS=new Set([` -`,"\r"]);lu.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function nM(e,t){for(let s=t??0;s{if(e){if(UA($c,e))return e;xi(o).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys($c))}`)}};function Xs(){}function Ec(e,t,o){return!t||$c[e]>$c[o]?Xs:t[e].bind(t)}const oM={error:Xs,warn:Xs,info:Xs,debug:Xs};let Jy=new WeakMap;function xi(e){var t;const o=e.logger,l=(t=e.logLevel)!==null&&t!==void 0?t:"off";if(!o)return oM;const s=Jy.get(o);if(s&&s[0]===l)return s[1];const d={error:Ec("error",o,l),warn:Ec("warn",o,l),info:Ec("info",o,l),debug:Ec("debug",o,l)};return Jy.set(o,[l,d]),d}const $l=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,o])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":o]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class Ha{constructor(t,o,l){this.iterator=t,this.controller=o,this.client=l}static fromSSEResponse(t,o,l){let s=!1;const d=l?xi(l):console;function f(){return uo(this,arguments,function*(){var v,m,x,b;if(s)throw new eo("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let S=!1;try{try{for(var _=!0,T=fo(lM(t,o)),F;F=yield Rt(T.next()),v=F.done,!v;_=!0){b=F.value,_=!1;const z=b;if(!S)if(z.data.startsWith("[DONE]")){S=!0;continue}else try{yield yield Rt(JSON.parse(z.data))}catch(G){throw d.error("Could not parse message into JSON:",z.data),d.error("From chunk:",z.raw),G}}}catch(z){m={error:z}}finally{try{!_&&!v&&(x=T.return)&&(yield Rt(x.call(T)))}finally{if(m)throw m.error}}S=!0}catch(z){if(Lf(z))return yield Rt(void 0);throw z}finally{S||o.abort()}})}return new Ha(f,o,l)}static fromReadableStream(t,o,l){let s=!1;function d(){return uo(this,arguments,function*(){var v,m,x,b;const S=new lu,_=Kv(t);try{for(var T=!0,F=fo(_),z;z=yield Rt(F.next()),v=z.done,!v;T=!0){b=z.value,T=!1;const G=b;for(const Y of S.decode(G))yield yield Rt(Y)}}catch(G){m={error:G}}finally{try{!T&&!v&&(x=F.return)&&(yield Rt(x.call(F)))}finally{if(m)throw m.error}}for(const G of S.flush())yield yield Rt(G)})}function f(){return uo(this,arguments,function*(){var v,m,x,b;if(s)throw new eo("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let S=!1;try{try{for(var _=!0,T=fo(d()),F;F=yield Rt(T.next()),v=F.done,!v;_=!0){b=F.value,_=!1;const z=b;S||z&&(yield yield Rt(JSON.parse(z)))}}catch(z){m={error:z}}finally{try{!_&&!v&&(x=T.return)&&(yield Rt(x.call(T)))}finally{if(m)throw m.error}}S=!0}catch(z){if(Lf(z))return yield Rt(void 0);throw z}finally{S||o.abort()}})}return new Ha(f,o,l)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],o=[],l=this.iterator(),s=d=>({next:()=>{if(d.length===0){const f=l.next();t.push(f),o.push(f)}return d.shift()}});return[new Ha(()=>s(t),this.controller,this.client),new Ha(()=>s(o),this.controller,this.client)]}toReadableStream(){const t=this;let o;return Jv({async start(){o=t[Symbol.asyncIterator]()},async pull(l){try{const{value:s,done:d}=await o.next();if(d)return l.close();const f=up(JSON.stringify(s)+` -`);l.enqueue(f)}catch(s){l.error(s)}},async cancel(){var l;await((l=o.return)===null||l===void 0?void 0:l.call(o))}})}}function lM(e,t){return uo(this,arguments,function*(){var l,s,d,f;if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new eo("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new eo("Attempted to iterate over a response with no body");const g=new sM,v=new lu,m=Kv(e.body);try{for(var x=!0,b=fo(aM(m)),S;S=yield Rt(b.next()),l=S.done,!l;x=!0){f=S.value,x=!1;const _=f;for(const T of v.decode(_)){const F=g.decode(T);F&&(yield yield Rt(F))}}}catch(_){s={error:_}}finally{try{!x&&!l&&(d=b.return)&&(yield Rt(d.call(b)))}finally{if(s)throw s.error}}for(const _ of v.flush()){const T=g.decode(_);T&&(yield yield Rt(T))}})}function aM(e){return uo(this,arguments,function*(){var o,l,s,d;let f=new Uint8Array;try{for(var g=!0,v=fo(e),m;m=yield Rt(v.next()),o=m.done,!o;g=!0){d=m.value,g=!1;const x=d;if(x==null)continue;const b=x instanceof ArrayBuffer?new Uint8Array(x):typeof x=="string"?up(x):x;let S=new Uint8Array(f.length+b.length);S.set(f),S.set(b,f.length),f=S;let _;for(;(_=iM(f))!==-1;)yield yield Rt(f.slice(0,_)),f=f.slice(_)}}catch(x){l={error:x}}finally{try{!g&&!o&&(s=v.return)&&(yield Rt(s.call(v)))}finally{if(l)throw l.error}}f.length>0&&(yield yield Rt(f))})}class sM{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const d={event:this.event,data:this.data.join(` -`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],d}if(this.chunks.push(t),t.startsWith(":"))return null;let[o,l,s]=rM(t,":");return s.startsWith(" ")&&(s=s.substring(1)),o==="event"?this.event=s:o==="data"&&this.data.push(s),null}}function rM(e,t){const o=e.indexOf(t);return o!==-1?[e.substring(0,o),t,e.substring(o+t.length)]:[e,"",""]}async function cM(e,t){const{response:o,requestLogID:l,retryOfRequestLogID:s,startTime:d}=t,f=await(async()=>{var g;if(t.options.stream)return xi(e).debug("response",o.status,o.url,o.headers,o.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(o,t.controller,e):Ha.fromSSEResponse(o,t.controller,e);if(o.status===204)return null;if(t.options.__binaryResponse)return o;const v=o.headers.get("content-type"),m=(g=v?.split(";")[0])===null||g===void 0?void 0:g.trim();return m?.includes("application/json")||m?.endsWith("+json")?await o.json():await o.text()})();return xi(e).debug(`[${l}] response parsed`,$l({retryOfRequestLogID:s,url:o.url,status:o.status,body:f,durationMs:Date.now()-d})),f}class dp extends Promise{constructor(t,o,l=cM){super(s=>{s(null)}),this.responsePromise=o,this.parseResponse=l,this.client=t}_thenUnwrap(t){return new dp(this.client,this.responsePromise,async(o,l)=>t(await this.parseResponse(o,l),l))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,o]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:o}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,o){return this.parse().then(t,o)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}const nx=Symbol("brand.privateNullableHeaders");function*uM(e){if(!e)return;if(nx in e){const{values:l,nulls:s}=e;yield*l.entries();for(const d of s)yield[d,null];return}let t=!1,o;e instanceof Headers?o=e.entries():Vy(e)?o=e:(t=!0,o=Object.entries(e??{}));for(let l of o){const s=l[0];if(typeof s!="string")throw new TypeError("expected header name to be a string");const d=Vy(l[1])?l[1]:[l[1]];let f=!1;for(const g of d)g!==void 0&&(t&&!f&&(f=!0,yield[s,null]),yield[s,g])}}const Hs=e=>{const t=new Headers,o=new Set;for(const l of e){const s=new Set;for(const[d,f]of uM(l)){const g=d.toLowerCase();s.has(g)||(t.delete(d),s.add(g)),f===null?(t.delete(d),o.add(g)):(t.append(d,f),o.delete(g))}}return{[nx]:!0,values:t,nulls:o}};const mf=e=>{var t,o,l,s,d,f;if(typeof globalThis.process<"u")return(l=(o=(t=Uw)===null||t===void 0?void 0:t[e])===null||o===void 0?void 0:o.trim())!==null&&l!==void 0?l:void 0;if(typeof globalThis.Deno<"u")return(f=(d=(s=globalThis.Deno.env)===null||s===void 0?void 0:s.get)===null||d===void 0?void 0:d.call(s,e))===null||f===void 0?void 0:f.trim()};var ix;class au{constructor(t){var o,l,s,d,f,g,v,{baseURL:m=mf("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:x=(o=mf("GEMINI_API_KEY"))!==null&&o!==void 0?o:null,apiVersion:b="v1beta"}=t,S=Gc(t,["baseURL","apiKey","apiVersion"]);const _=Object.assign(Object.assign({apiKey:x,apiVersion:b},S),{baseURL:m||"https://generativelanguage.googleapis.com"});this.baseURL=_.baseURL,this.timeout=(l=_.timeout)!==null&&l!==void 0?l:au.DEFAULT_TIMEOUT,this.logger=(s=_.logger)!==null&&s!==void 0?s:console;const T="warn";this.logLevel=T,this.logLevel=(f=(d=Yy(_.logLevel,"ClientOptions.logLevel",this))!==null&&d!==void 0?d:Yy(mf("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&f!==void 0?f:T,this.fetchOptions=_.fetchOptions,this.maxRetries=(g=_.maxRetries)!==null&&g!==void 0?g:2,this.fetch=(v=_.fetch)!==null&&v!==void 0?v:GA(),this.encoder=YA,this._options=_,this.apiKey=x,this.apiVersion=b,this.clientAdapter=_.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:o}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!o.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){const o=Hs([t.headers]);if(!(o.values.has("authorization")||o.values.has("x-goog-api-key"))){if(this.apiKey)return Hs([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Hs([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([o,l])=>typeof l<"u").map(([o,l])=>{if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")return`${encodeURIComponent(o)}=${encodeURIComponent(l)}`;if(l===null)return`${encodeURIComponent(o)}=`;throw new eo(`Cannot stringify type ${typeof l}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Ba}`}defaultIdempotencyKey(){return`stainless-node-retry-${kA()}`}makeStatusError(t,o,l,s){return bi.generate(t,o,l,s)}buildURL(t,o,l){const s=!this.baseURLOverridden()&&l||this.baseURL,d=zA(t)?new URL(t):new URL(s+(s.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),f=this.defaultQuery();return LA(f)||(o=Object.assign(Object.assign({},f),o)),typeof o=="object"&&o&&!Array.isArray(o)&&(d.search=this.stringifyQuery(o)),d.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const o=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${o}`}}async prepareRequest(t,{url:o,options:l}){}get(t,o){return this.methodRequest("get",t,o)}post(t,o){return this.methodRequest("post",t,o)}patch(t,o){return this.methodRequest("patch",t,o)}put(t,o){return this.methodRequest("put",t,o)}delete(t,o){return this.methodRequest("delete",t,o)}methodRequest(t,o,l){return this.request(Promise.resolve(l).then(s=>Object.assign({method:t,path:o},s)))}request(t,o=null){return new dp(this,this.makeRequest(t,o,void 0))}async makeRequest(t,o,l){var s,d,f;const g=await t,v=(s=g.maxRetries)!==null&&s!==void 0?s:this.maxRetries;o==null&&(o=v),await this.prepareOptions(g);const{req:m,url:x,timeout:b}=await this.buildRequest(g,{retryCount:v-o});await this.prepareRequest(m,{url:x,options:g});const S="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),_=l===void 0?"":`, retryOf: ${l}`,T=Date.now();if(xi(this).debug(`[${S}] sending request`,$l({retryOfRequestLogID:l,method:g.method,url:x,options:g,headers:m.headers})),!((d=g.signal)===null||d===void 0)&&d.aborted)throw new Ff;const F=new AbortController,z=await this.fetchWithTimeout(x,m,b,F).catch(Uf),G=Date.now();if(z instanceof globalThis.Error){const oe=`retrying, ${o} attempts remaining`;if(!((f=g.signal)===null||f===void 0)&&f.aborted)throw new Ff;const ce=Lf(z)||/timed? ?out/i.test(String(z)+("cause"in z?String(z.cause):""));if(o)return xi(this).info(`[${S}] connection ${ce?"timed out":"failed"} - ${oe}`),xi(this).debug(`[${S}] connection ${ce?"timed out":"failed"} (${oe})`,$l({retryOfRequestLogID:l,url:x,durationMs:G-T,message:z.message})),this.retryRequest(g,o,l??S);throw xi(this).info(`[${S}] connection ${ce?"timed out":"failed"} - error; no more retries left`),xi(this).debug(`[${S}] connection ${ce?"timed out":"failed"} (error; no more retries left)`,$l({retryOfRequestLogID:l,url:x,durationMs:G-T,message:z.message})),ce?new Bv:new ou({cause:z})}const Y=`[${S}${_}] ${m.method} ${x} ${z.ok?"succeeded":"failed"} with status ${z.status} in ${G-T}ms`;if(!z.ok){const oe=await this.shouldRetry(z);if(o&&oe){const ge=`retrying, ${o} attempts remaining`;return await qA(z.body),xi(this).info(`${Y} - ${ge}`),xi(this).debug(`[${S}] response error (${ge})`,$l({retryOfRequestLogID:l,url:z.url,status:z.status,headers:z.headers,durationMs:G-T})),this.retryRequest(g,o,l??S,z.headers)}const ce=oe?"error; no more retries left":"error; not retryable";xi(this).info(`${Y} - ${ce}`);const ve=await z.text().catch(ge=>Uf(ge).message),ye=PA(ve),fe=ye?void 0:ve;throw xi(this).debug(`[${S}] response error (${ce})`,$l({retryOfRequestLogID:l,url:z.url,status:z.status,headers:z.headers,message:fe,durationMs:Date.now()-T})),this.makeStatusError(z.status,ye,fe,z.headers)}return xi(this).info(Y),xi(this).debug(`[${S}] response start`,$l({retryOfRequestLogID:l,url:z.url,status:z.status,headers:z.headers,durationMs:G-T})),{response:z,options:g,controller:F,requestLogID:S,retryOfRequestLogID:l,startTime:T}}async fetchWithTimeout(t,o,l,s){const d=o||{},{signal:f,method:g}=d,v=Gc(d,["signal","method"]);f&&f.addEventListener("abort",()=>s.abort());const m=setTimeout(()=>s.abort(),l),x=globalThis.ReadableStream&&v.body instanceof globalThis.ReadableStream||typeof v.body=="object"&&v.body!==null&&Symbol.asyncIterator in v.body,b=Object.assign(Object.assign(Object.assign({signal:s.signal},x?{duplex:"half"}:{}),{method:"GET"}),v);g&&(b.method=g.toUpperCase());try{return await this.fetch.call(void 0,t,b)}finally{clearTimeout(m)}}async shouldRetry(t){const o=t.headers.get("x-should-retry");return o==="true"?!0:o==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,o,l,s){var d;let f;const g=s?.get("retry-after-ms");if(g){const m=parseFloat(g);Number.isNaN(m)||(f=m)}const v=s?.get("retry-after");if(v&&!f){const m=parseFloat(v);Number.isNaN(m)?f=Date.parse(v)-Date.now():f=m*1e3}if(!(f&&0<=f&&f<60*1e3)){const m=(d=t.maxRetries)!==null&&d!==void 0?d:this.maxRetries;f=this.calculateDefaultRetryTimeoutMillis(o,m)}return await BA(f),this.makeRequest(t,o-1,l)}calculateDefaultRetryTimeoutMillis(t,o){const d=o-t,f=Math.min(.5*Math.pow(2,d),8),g=1-Math.random()*.25;return f*g*1e3}async buildRequest(t,{retryCount:o=0}={}){var l,s,d;const f=Object.assign({},t),{method:g,path:v,query:m,defaultBaseURL:x}=f,b=this.buildURL(v,m,x);"timeout"in f&&FA("timeout",f.timeout),f.timeout=(l=f.timeout)!==null&&l!==void 0?l:this.timeout;const{bodyHeaders:S,body:_}=this.buildBody({options:f}),T=await this.buildHeaders({options:t,method:g,bodyHeaders:S,retryCount:o});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:g,headers:T},f.signal&&{signal:f.signal}),globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"}),_&&{body:_}),(s=this.fetchOptions)!==null&&s!==void 0?s:{}),(d=f.fetchOptions)!==null&&d!==void 0?d:{}),url:b,timeout:f.timeout}}async buildHeaders({options:t,method:o,bodyHeaders:l,retryCount:s}){let d={};this.idempotencyHeader&&o!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),d[this.idempotencyHeader]=t.idempotencyKey);const f=await this.authHeaders(t);let g=Hs([d,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),HA()),this._options.defaultHeaders,l,t.headers,f]);return this.validateHeaders(g),g.values}buildBody({options:{body:t,headers:o}}){if(!t)return{bodyHeaders:void 0,body:void 0};const l=Hs([o]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&l.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:$A(t)}:this.encoder({body:t,headers:l})}}au.DEFAULT_TIMEOUT=6e4;class ni extends au{constructor(){super(...arguments),this.interactions=new tx(this)}}ix=ni;ni.GeminiNextGenAPIClient=ix;ni.GeminiNextGenAPIClientError=eo;ni.APIError=bi;ni.APIConnectionError=ou;ni.APIConnectionTimeoutError=Bv;ni.APIUserAbortError=Ff;ni.NotFoundError=Hv;ni.ConflictError=Gv;ni.RateLimitError=qv;ni.BadRequestError=jv;ni.AuthenticationError=Ov;ni.InternalServerError=Yv;ni.PermissionDeniedError=Vv;ni.UnprocessableEntityError=$v;ni.toFile=QA;ni.Interactions=tx;function dM(e,t){const o={},l=c(e,["name"]);return l!=null&&p(o,["_url","name"],l),o}function fM(e,t){const o={},l=c(e,["name"]);return l!=null&&p(o,["_url","name"],l),o}function pM(e,t){const o={},l=c(e,["sdkHttpResponse"]);return l!=null&&p(o,["sdkHttpResponse"],l),o}function hM(e,t){const o={},l=c(e,["sdkHttpResponse"]);return l!=null&&p(o,["sdkHttpResponse"],l),o}function mM(e,t,o){const l={};if(c(e,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const s=c(e,["tunedModelDisplayName"]);if(t!==void 0&&s!=null&&p(t,["displayName"],s),c(e,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const d=c(e,["epochCount"]);t!==void 0&&d!=null&&p(t,["tuningTask","hyperparameters","epochCount"],d);const f=c(e,["learningRateMultiplier"]);if(f!=null&&p(l,["tuningTask","hyperparameters","learningRateMultiplier"],f),c(e,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(c(e,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(c(e,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const g=c(e,["batchSize"]);t!==void 0&&g!=null&&p(t,["tuningTask","hyperparameters","batchSize"],g);const v=c(e,["learningRate"]);if(t!==void 0&&v!=null&&p(t,["tuningTask","hyperparameters","learningRate"],v),c(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(c(e,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return l}function gM(e,t,o){const l={};let s=c(o,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const _=c(e,["validationDataset"]);t!==void 0&&_!=null&&p(t,["supervisedTuningSpec"],Ky(_))}else if(s==="PREFERENCE_TUNING"){const _=c(e,["validationDataset"]);t!==void 0&&_!=null&&p(t,["preferenceOptimizationSpec"],Ky(_))}const d=c(e,["tunedModelDisplayName"]);t!==void 0&&d!=null&&p(t,["tunedModelDisplayName"],d);const f=c(e,["description"]);t!==void 0&&f!=null&&p(t,["description"],f);let g=c(o,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const _=c(e,["epochCount"]);t!==void 0&&_!=null&&p(t,["supervisedTuningSpec","hyperParameters","epochCount"],_)}else if(g==="PREFERENCE_TUNING"){const _=c(e,["epochCount"]);t!==void 0&&_!=null&&p(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],_)}let v=c(o,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const _=c(e,["learningRateMultiplier"]);t!==void 0&&_!=null&&p(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],_)}else if(v==="PREFERENCE_TUNING"){const _=c(e,["learningRateMultiplier"]);t!==void 0&&_!=null&&p(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],_)}let m=c(o,["config","method"]);if(m===void 0&&(m="SUPERVISED_FINE_TUNING"),m==="SUPERVISED_FINE_TUNING"){const _=c(e,["exportLastCheckpointOnly"]);t!==void 0&&_!=null&&p(t,["supervisedTuningSpec","exportLastCheckpointOnly"],_)}else if(m==="PREFERENCE_TUNING"){const _=c(e,["exportLastCheckpointOnly"]);t!==void 0&&_!=null&&p(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],_)}let x=c(o,["config","method"]);if(x===void 0&&(x="SUPERVISED_FINE_TUNING"),x==="SUPERVISED_FINE_TUNING"){const _=c(e,["adapterSize"]);t!==void 0&&_!=null&&p(t,["supervisedTuningSpec","hyperParameters","adapterSize"],_)}else if(x==="PREFERENCE_TUNING"){const _=c(e,["adapterSize"]);t!==void 0&&_!=null&&p(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],_)}if(c(e,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(c(e,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const b=c(e,["labels"]);t!==void 0&&b!=null&&p(t,["labels"],b);const S=c(e,["beta"]);return t!==void 0&&S!=null&&p(t,["preferenceOptimizationSpec","hyperParameters","beta"],S),l}function yM(e,t){const o={},l=c(e,["baseModel"]);l!=null&&p(o,["baseModel"],l);const s=c(e,["preTunedModel"]);s!=null&&p(o,["preTunedModel"],s);const d=c(e,["trainingDataset"]);d!=null&&AM(d);const f=c(e,["config"]);return f!=null&&mM(f,o),o}function vM(e,t){const o={},l=c(e,["baseModel"]);l!=null&&p(o,["baseModel"],l);const s=c(e,["preTunedModel"]);s!=null&&p(o,["preTunedModel"],s);const d=c(e,["trainingDataset"]);d!=null&&MM(d,o,t);const f=c(e,["config"]);return f!=null&&gM(f,o,t),o}function xM(e,t){const o={},l=c(e,["name"]);return l!=null&&p(o,["_url","name"],l),o}function bM(e,t){const o={},l=c(e,["name"]);return l!=null&&p(o,["_url","name"],l),o}function SM(e,t,o){const l={},s=c(e,["pageSize"]);t!==void 0&&s!=null&&p(t,["_query","pageSize"],s);const d=c(e,["pageToken"]);t!==void 0&&d!=null&&p(t,["_query","pageToken"],d);const f=c(e,["filter"]);return t!==void 0&&f!=null&&p(t,["_query","filter"],f),l}function wM(e,t,o){const l={},s=c(e,["pageSize"]);t!==void 0&&s!=null&&p(t,["_query","pageSize"],s);const d=c(e,["pageToken"]);t!==void 0&&d!=null&&p(t,["_query","pageToken"],d);const f=c(e,["filter"]);return t!==void 0&&f!=null&&p(t,["_query","filter"],f),l}function TM(e,t){const o={},l=c(e,["config"]);return l!=null&&SM(l,o),o}function CM(e,t){const o={},l=c(e,["config"]);return l!=null&&wM(l,o),o}function EM(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&p(o,["sdkHttpResponse"],l);const s=c(e,["nextPageToken"]);s!=null&&p(o,["nextPageToken"],s);const d=c(e,["tunedModels"]);if(d!=null){let f=d;Array.isArray(f)&&(f=f.map(g=>ox(g))),p(o,["tuningJobs"],f)}return o}function _M(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&p(o,["sdkHttpResponse"],l);const s=c(e,["nextPageToken"]);s!=null&&p(o,["nextPageToken"],s);const d=c(e,["tuningJobs"]);if(d!=null){let f=d;Array.isArray(f)&&(f=f.map(g=>jf(g))),p(o,["tuningJobs"],f)}return o}function NM(e,t){const o={},l=c(e,["name"]);l!=null&&p(o,["model"],l);const s=c(e,["name"]);return s!=null&&p(o,["endpoint"],s),o}function AM(e,t){const o={};if(c(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(c(e,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const l=c(e,["examples"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(d=>d)),p(o,["examples","examples"],s)}return o}function MM(e,t,o){const l={};let s=c(o,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const f=c(e,["gcsUri"]);t!==void 0&&f!=null&&p(t,["supervisedTuningSpec","trainingDatasetUri"],f)}else if(s==="PREFERENCE_TUNING"){const f=c(e,["gcsUri"]);t!==void 0&&f!=null&&p(t,["preferenceOptimizationSpec","trainingDatasetUri"],f)}let d=c(o,["config","method"]);if(d===void 0&&(d="SUPERVISED_FINE_TUNING"),d==="SUPERVISED_FINE_TUNING"){const f=c(e,["vertexDatasetResource"]);t!==void 0&&f!=null&&p(t,["supervisedTuningSpec","trainingDatasetUri"],f)}else if(d==="PREFERENCE_TUNING"){const f=c(e,["vertexDatasetResource"]);t!==void 0&&f!=null&&p(t,["preferenceOptimizationSpec","trainingDatasetUri"],f)}if(c(e,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return l}function ox(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&p(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&p(o,["name"],s);const d=c(e,["state"]);d!=null&&p(o,["state"],bv(d));const f=c(e,["createTime"]);f!=null&&p(o,["createTime"],f);const g=c(e,["tuningTask","startTime"]);g!=null&&p(o,["startTime"],g);const v=c(e,["tuningTask","completeTime"]);v!=null&&p(o,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&p(o,["updateTime"],m);const x=c(e,["description"]);x!=null&&p(o,["description"],x);const b=c(e,["baseModel"]);b!=null&&p(o,["baseModel"],b);const S=c(e,["_self"]);return S!=null&&p(o,["tunedModel"],NM(S)),o}function jf(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&p(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&p(o,["name"],s);const d=c(e,["state"]);d!=null&&p(o,["state"],bv(d));const f=c(e,["createTime"]);f!=null&&p(o,["createTime"],f);const g=c(e,["startTime"]);g!=null&&p(o,["startTime"],g);const v=c(e,["endTime"]);v!=null&&p(o,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&p(o,["updateTime"],m);const x=c(e,["error"]);x!=null&&p(o,["error"],x);const b=c(e,["description"]);b!=null&&p(o,["description"],b);const S=c(e,["baseModel"]);S!=null&&p(o,["baseModel"],S);const _=c(e,["tunedModel"]);_!=null&&p(o,["tunedModel"],_);const T=c(e,["preTunedModel"]);T!=null&&p(o,["preTunedModel"],T);const F=c(e,["supervisedTuningSpec"]);F!=null&&p(o,["supervisedTuningSpec"],F);const z=c(e,["preferenceOptimizationSpec"]);z!=null&&p(o,["preferenceOptimizationSpec"],z);const G=c(e,["tuningDataStats"]);G!=null&&p(o,["tuningDataStats"],G);const Y=c(e,["encryptionSpec"]);Y!=null&&p(o,["encryptionSpec"],Y);const oe=c(e,["partnerModelTuningSpec"]);oe!=null&&p(o,["partnerModelTuningSpec"],oe);const ce=c(e,["customBaseModel"]);ce!=null&&p(o,["customBaseModel"],ce);const ve=c(e,["experiment"]);ve!=null&&p(o,["experiment"],ve);const ye=c(e,["labels"]);ye!=null&&p(o,["labels"],ye);const fe=c(e,["outputUri"]);fe!=null&&p(o,["outputUri"],fe);const Je=c(e,["pipelineJob"]);Je!=null&&p(o,["pipelineJob"],Je);const ge=c(e,["serviceAccount"]);ge!=null&&p(o,["serviceAccount"],ge);const qe=c(e,["tunedModelDisplayName"]);qe!=null&&p(o,["tunedModelDisplayName"],qe);const Ve=c(e,["veoTuningSpec"]);return Ve!=null&&p(o,["veoTuningSpec"],Ve),o}function kM(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&p(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&p(o,["name"],s);const d=c(e,["metadata"]);d!=null&&p(o,["metadata"],d);const f=c(e,["done"]);f!=null&&p(o,["done"],f);const g=c(e,["error"]);return g!=null&&p(o,["error"],g),o}function Ky(e,t){const o={},l=c(e,["gcsUri"]);l!=null&&p(o,["validationDatasetUri"],l);const s=c(e,["vertexDatasetResource"]);return s!=null&&p(o,["validationDatasetUri"],s),o}class RM extends Jo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new ea(Yo.PAGED_ITEM_TUNING_JOBS,l=>this.listInternal(l),await this.listInternal(o),o),this.get=async o=>await this.getInternal(o),this.tune=async o=>{var l;if(this.apiClient.isVertexAI())if(o.baseModel.startsWith("projects/")){const s={tunedModelName:o.baseModel};!((l=o.config)===null||l===void 0)&&l.preTunedModelCheckpointId&&(s.checkpointId=o.config.preTunedModelCheckpointId);const d=Object.assign(Object.assign({},o),{preTunedModel:s});return d.baseModel=void 0,await this.tuneInternal(d)}else{const s=Object.assign({},o);return await this.tuneInternal(s)}else{const s=Object.assign({},o),d=await this.tuneMldevInternal(s);let f="";return d.metadata!==void 0&&d.metadata.tunedModel!==void 0?f=d.metadata.tunedModel:d.name!==void 0&&d.name.includes("/operations/")&&(f=d.name.split("/operations/")[0]),{name:f,state:Af.JOB_STATE_QUEUED}}}}async getInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=bM(t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>jf(x))}else{const m=xM(t);return g=Ze("{name}",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>ox(x))}}async listInternal(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=CM(t);return g=Ze("tuningJobs",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=_M(x),S=new Sy;return Object.assign(S,b),S})}else{const m=TM(t);return g=Ze("tunedModels",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"GET",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=EM(x),S=new Sy;return Object.assign(S,b),S})}}async cancel(t){var o,l,s,d;let f,g="",v={};if(this.apiClient.isVertexAI()){const m=fM(t);return g=Ze("{name}:cancel",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=hM(x),S=new wy;return Object.assign(S,b),S})}else{const m=dM(t);return g=Ze("{name}:cancel",m._url),v=m._query,delete m._url,delete m._query,f=this.apiClient.request({path:g,queryParams:v,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(d=t.config)===null||d===void 0?void 0:d.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),f.then(x=>{const b=pM(x),S=new wy;return Object.assign(S,b),S})}}async tuneInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI()){const g=vM(t,t);return d=Ze("tuningJobs",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>jf(v))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var o,l;let s,d="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=yM(t);return d=Ze("tunedModels",g._url),f=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:d,queryParams:f,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(l=t.config)===null||l===void 0?void 0:l.abortSignal}).then(v=>v.json().then(m=>{const x=m;return x.sdkHttpResponse={headers:v.headers},x})),s.then(v=>kM(v))}}}class zM{async download(t,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const IM=1024*1024*8,DM=3,LM=1e3,UM=2,qc="x-goog-upload-status";async function FM(e,t,o){var l;const s=await lx(e,t,o),d=await s?.json();if(((l=s?.headers)===null||l===void 0?void 0:l[qc])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return d.file}async function PM(e,t,o){var l;const s=await lx(e,t,o),d=await s?.json();if(((l=s?.headers)===null||l===void 0?void 0:l[qc])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const f=hv(d),g=new op;return Object.assign(g,f),g}async function lx(e,t,o){var l,s;let d=0,f=0,g=new Mf(new Response),v="upload";for(d=e.size;f=d&&(v+=", finalize");let b=0,S=LM;for(;bsetTimeout(t,e))}class OM{async upload(t,o,l){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await FM(t,o,l)}async uploadToFileSearchStore(t,o,l){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await PM(t,o,l)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await BM(t)}}class VM{create(t,o,l){return new HM(t,o,l)}}class HM{constructor(t,o,l){this.url=t,this.headers=o,this.callbacks=l}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}const Xy="x-goog-api-key";class GM{constructor(t){this.apiKey=t}async addAuthHeaders(t,o){if(t.get(Xy)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(Xy,this.apiKey)}}}const $M="gl-node/";class qM{get interactions(){if(this._interactions!==void 0)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const t=this.httpOptions;t?.extraBody&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const o=new ni({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:t?.timeout});return this._interactions=o.interactions,this._interactions}constructor(t){var o;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(o=t.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=t.apiKey;const l=jw(t.httpOptions,t.vertexai,void 0,void 0);l&&(t.httpOptions?t.httpOptions.baseUrl=l:t.httpOptions={baseUrl:l}),this.apiVersion=t.apiVersion,this.httpOptions=t.httpOptions;const s=new GM(this.apiKey);this.apiClient=new BN({auth:s,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:$M+"web",uploader:new OM,downloader:new zM}),this.models=new oA(this.apiClient),this.live=new QN(this.apiClient,s,new VM),this.batches=new mC(this.apiClient),this.chats=new XC(this.models,this.apiClient),this.caches=new YC(this.apiClient),this.files=new aE(this.apiClient),this.operations=new lA(this.apiClient),this.authTokens=new SA(this.apiClient),this.tunings=new RM(this.apiClient),this.fileSearchStores=new MA(this.apiClient)}}const YM=e=>new qM({apiKey:e}),JM={type:An.OBJECT,properties:{segments:{type:An.ARRAY,items:{type:An.OBJECT,properties:{startTime:{type:An.STRING,description:"Absolute timestamp in MM:SS.mmm format (e.g. '01:05.300'). Cumulative from start."},endTime:{type:An.STRING,description:"Absolute timestamp in MM:SS.mmm format."},text:{type:An.STRING,description:"Transcribed text. Exact words spoken. No hallucinations. Must include every single word."}},required:["startTime","endTime","text"]}}},required:["segments"]},KM={type:An.OBJECT,properties:{segments:{type:An.ARRAY,items:{type:An.OBJECT,properties:{startTime:{type:An.STRING},endTime:{type:An.STRING},text:{type:An.STRING},words:{type:An.ARRAY,items:{type:An.OBJECT,properties:{text:{type:An.STRING,description:"The single word, or character (for Chinese), or linguistic unit."},startTime:{type:An.STRING,description:"Start time of the word"},endTime:{type:An.STRING,description:"End time of the word"}},required:["text","startTime","endTime"]}}},required:["startTime","endTime","text","words"]}}},required:["segments"]};function _c(e){if(!e)return"00:00.000";let t=e.trim().replace(/[^\d:.]/g,""),o=0;if(!t.includes(":")&&/^[\d.]+$/.test(t))o=parseFloat(t);else{const f=t.split(":");if(f.length===3){const g=parseInt(f[0],10)||0,v=parseInt(f[1],10)||0,m=f[2].split("."),x=parseInt(m[0],10)||0;let b=0;m[1]&&(b=parseFloat("0."+m[1])),o=g*3600+v*60+x+b}else if(f.length===2){const g=parseInt(f[0],10)||0,v=f[1].split("."),m=parseInt(v[0],10)||0;let x=0;v[1]&&(x=parseFloat("0."+v[1])),o=g*60+m+x}}if(isNaN(o)||o<0)return"00:00.000";const l=Math.floor(o/60),s=Math.floor(o%60),d=Math.round(o%1*1e3);return`${String(l).padStart(2,"0")}:${String(s).padStart(2,"0")}.${String(d).padStart(3,"0")}`}function XM(e){const t=e.trim();try{const f=JSON.parse(t);if(f.segments&&Array.isArray(f.segments))return f;if(Array.isArray(f))return{segments:f}}catch{}const o=t.lastIndexOf("}");if(o!==-1){const f=["]}","}","]}"];for(const v of f)try{const m=t+v,x=JSON.parse(m);if(x.segments)return x}catch{}const g=t.substring(0,o+1)+"]}";try{const v=JSON.parse(g);if(v.segments&&Array.isArray(v.segments))return v}catch{}}if(t.includes('"words"'))throw new Error("Complex nested JSON (word-level) could not be parsed. PLease try again.");const l=[],s=/\{\s*"startTime"\s*:\s*"?([^",]+)"?\s*,\s*"endTime"\s*:\s*"?([^",]+)"?\s*,\s*"text"\s*:\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/g;let d;for(;(d=s.exec(t))!==null;){const f=d[3]!==void 0?d[3]:d[4];let g=f;try{g=JSON.parse(`"${f.replace(/"/g,'\\"')}"`)}catch{g=f.replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}l.push({startTime:d[1],endTime:d[2],text:g})}if(l.length>0)return{segments:l};throw new Error("Response structure invalid and could not be repaired.")}async function WM(e,t,o,l,s,d="line"){try{const f=YM(l),g=e.includes("gemini-3"),v=` - TIMING RULES: - 1. FORMAT: strictly **MM:SS.mmm** (e.g., 01:23.450). - 2. CONTINUITY: Timestamps must be strictly chronological. - 3. ACCURACY: Sync text exactly to the audio. - 4. PRECISION: For fast speech/rap, ensure word-level timestamps are millisecond-accurate. - `;let m="";d==="word"?m=` - SEGMENTATION: HIERARCHICAL WORD-LEVEL (TTML/KARAOKE/Enhanced LRC) - --------------------------------------------------- - CRITICAL: You are generating data for rich TTML or Karaoke display. - - 1. STRUCTURE: Group words into short, natural lines/phrases (this is the parent object). - 2. LINE LENGTH: **CRITICAL** Keep lines SHORT (approx 3-8 words). Split long sentences into multiple lines. - - Example: "I will love you forever and ever" -> Line 1: "I will love you", Line 2: "forever and ever". - 3. REPEATED WORDS & STUTTERS: **EXTREMELY IMPORTANT** - - Treat every spoken utterance as a distinct word which must be timestamped. - - Example: "No no no wait" -> 4 distinct word objects. - - Example: "I I I didn't mean it" -> 3 distinct "I" objects followed by "didn't", "mean", "it". - - NEVER merge repeated words into a single event. - 4. DETAILS: Inside each line object, you MUST provide a "words" array. - 5. WORDS: The "words" array must contain EVERY single word from that line with its own precise start/end time. - 6. CJK HANDLING: For Chinese, Japanese, or Korean scripts, treat each character (or logical block of characters) as a separate "word" for the purposes of karaoke timing. - 7. FAST SPEECH / RAP / CONVERSATION HANDLING: - - Anticipate RAPID speech delivery (high words-per-minute). - - Ensure NO DRIFT: Align every word's start/end exactly to its pronunciation. - - For rapid-fire lyrics or conversation, word segments should be distinct and tightly packed. - `:m=` - SEGMENTATION: LINE-LEVEL (SUBTITLE/LRC MODE) - --------------------------------------------------- - CRITICAL: You are generating subtitles for a movie/music video. - - 1. PHRASES: Group words into complete sentences or musical phrases. - 2. CLARITY: Do not break a sentence in the middle unless there is a pause. - 3. REPETITIONS: Separate repetitive vocalizations (e.g. "Oh oh oh") from the main lyrics into their own lines. - 4. LENGTH: Keep segments between 2 and 6 seconds for readability. - 5. WORDS ARRAY: You may omit the "words" array in this mode to save tokens. - `;const x=` - You are an expert Audio Transcription AI specialized in generating precise timed lyrics and subtitled conversations. - - TASK: Transcribe the audio file into JSON segments. - MODE: ${d.toUpperCase()} LEVEL. - - ${v} - - ${m} - - LANGUAGE HANDLING (CRITICAL): - 1. RAPID CODE-SWITCHING: Audio often contains multiple languages mixed within the SAME sentence. - 2. MULTI-LINGUAL EQUALITY: The languages might NOT include English (e.g. Indonesian mixed with Japanese, Chinese mixed with Japanese). Treat all detected languages as equally probable. - 3. WORD-LEVEL DETECTION: Detect the language of every individual word. - 4. NATIVE SCRIPT STRICTNESS: Write EACH word in its native script. - - Example: "Aku cinta kamu" (Indonesian) -> Latin. - - Example: "愛してる" (Japanese) -> Kanji/Kana. - 5. MIXED SCRIPT PRESERVATION (IMPORTANT): - - If specific English/Latin words are spoken amidst Japanese/Chinese/etc., KEEP them in LATIN script. - - DO NOT transliterate English words into Katakana (e.g. if audio says "I love you", write "I love you", NOT "アイラブユー"). - - Maintain mixed text (Kanji/Kana + Latin) exactly as spoken. - 6. PROHIBITIONS: - - DO NOT translate. - - DO NOT romanize (unless explicitly spelled out). - - DO NOT force English if it is not spoken. - - GENERAL RULES: - - Verbatim: Transcribe exactly what is heard. Include fillers (um, ah) if sung. - - Completeness: Transcribe from 00:00 to the very end. Do not summarize. - - JSON Only: Output pure JSON. No markdown fences. - `,b={responseMimeType:"application/json",responseSchema:d==="word"?KM:JM,temperature:.1};g&&(b.thinkingConfig={thinkingBudget:1024});const S=new Promise((G,Y)=>{s?.aborted&&Y(new DOMException("Aborted","AbortError")),s?.addEventListener("abort",()=>Y(new DOMException("Aborted","AbortError")))});let T=(await Promise.race([f.models.generateContent({model:e,contents:[{parts:[{inlineData:{data:t,mimeType:o}},{text:x}]}],config:b}),S])).text;if(!T)throw new Error("Empty response from model");return T=T.trim(),T.startsWith("```json")?T=T.replace(/^```json\s*/,"").replace(/\s*```$/,""):T.startsWith("```")&&(T=T.replace(/^```\s*/,"").replace(/\s*```$/,"")),(XM(T).segments||[]).map(G=>({startTime:_c(String(G.startTime)),endTime:_c(String(G.endTime)),text:String(G.text),words:G.words?G.words.map(Y=>({text:String(Y.text),startTime:_c(String(Y.startTime)),endTime:_c(String(Y.endTime))})):void 0}))}catch(f){throw f.name==="AbortError"?f:(console.error(`Error with ${e}:`,f),new Error(f.message||"Transcription failed"))}}const QM=({playlist:e,setPlaylist:t,currentTrackIndex:o,setCurrentTrackIndex:l,onPlayTrack:s,isPlaying:d,onTogglePlay:f,onSeek:g,onClearPlaylist:v,onRemoveTrack:m,currentTime:x,onClose:b})=>{const{confirm:S}=ur(),_=Z.useRef(null),T=Z.useRef(new Map),F=M=>{const D=Math.floor(M/60).toString().padStart(2,"0"),k=(M%60).toFixed(2).padStart(5,"0");return`[${D}:${k}]`},[z,G]=Z.useState(null),[Y,oe]=Z.useState({key:null,direction:"asc"}),[ce,ve]=Z.useState(new Set),[ye,fe]=Z.useState(new Set),[Je,ge]=Z.useState(localStorage.getItem("gemini_api_key")||""),[qe,Ve]=Z.useState("gemini-2.5-flash"),[Ke,nt]=Z.useState("line"),[it,xt]=Z.useState(!1),K=Z.useRef(null),[ze,Le]=Z.useState(null);Z.useEffect(()=>{Je&&localStorage.setItem("gemini_api_key",Je)},[Je]);const ut=o>=0?e[o]:null,Me=ut?.parsedLyrics||[],L=Z.useMemo(()=>ut?Me.findIndex((M,D)=>{if(M.endTime!==void 0)return x>=M.time&&x=M.time&&(!k||x{if(L!==-1){const M=document.getElementById(`lyric-active-${o}`);M&&M.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}},[L,o]);const X=M=>{if(e.length===0)return;const D=o>=0?e[o]:null,k=[...e];let ne="asc";if(M==="random"){oe({key:"random",direction:"asc"});for(let B=k.length-1;B>0;B--){const te=Math.floor(Math.random()*(B+1));[k[B],k[te]]=[k[te],k[B]]}}else{Y.key===M&&Y.direction==="asc"&&(ne="desc"),oe({key:M,direction:ne});const B=ne==="asc"?1:-1;M==="filename"?k.sort((te,j)=>B*te.audioFile.name.localeCompare(j.audioFile.name)):M==="artist"?k.sort((te,j)=>B*(te.metadata.artist||"").localeCompare(j.metadata.artist||"")):M==="title"?k.sort((te,j)=>B*(te.metadata.title||"").localeCompare(j.metadata.title||"")):M==="album"&&k.sort((te,j)=>B*(te.metadata.album||"").localeCompare(j.metadata.album||""))}if(t(k),D){const B=k.findIndex(te=>te.id===D.id);B!==-1&&l(B)}},Ee=Z.useCallback(M=>{z!==null&&M.key==="Delete"?(M.preventDefault(),M.stopPropagation(),m?m(z):t(D=>{const k=[...D];return k.splice(z,1),k}),z>=e.length-1&&G(e.length>1?e.length-2:null)):M.key==="ArrowDown"&&e.length>0?(M.preventDefault(),M.stopPropagation(),G(D=>D===null?0:Math.min(D+1,e.length-1))):M.key==="ArrowUp"&&e.length>0?(M.preventDefault(),M.stopPropagation(),G(D=>D===null?0:Math.max(D-1,0))):M.key==="Enter"&&z!==null?(M.preventDefault(),M.stopPropagation(),s(z)):M.key==="Escape"&&G(null)},[z,e.length,t,s]);Z.useEffect(()=>{const M=_.current;if(M)return M.addEventListener("keydown",Ee),()=>M.removeEventListener("keydown",Ee)},[Ee]),Z.useEffect(()=>{z!==null&&z>=e.length&&G(e.length>0?e.length-1:null)},[e.length,z]);const ke=async M=>{const D=new Map;M.forEach(te=>{const j=te.name.split(".").pop()?.toLowerCase(),E=(te.webkitRelativePath||te.name).replace(/\.[^/.]+$/,"");D.has(E)||D.set(E,{});const O=D.get(E);["mp3","wav","ogg","flac","m4a","mp4","webm","ogg","mkv","mov","avi","m4v"].includes(j||"")?O.audio=te:["lrc","srt","ttml","xml","json","vtt"].includes(j||"")&&(O.lyric=te)});const k=[],ne=async(te,j)=>new Promise(we=>{if(te.type.startsWith("video/")){we({title:j,artist:"Unknown Artist",coverUrl:URL.createObjectURL(te),backgroundType:"video"});return}Sf(()=>import("./jsmediatags.min-CQERko6n.js").then(E=>E.j),[]).then(E=>{E.read(te,{onSuccess:O=>{const{title:V,artist:Fe,album:Be,picture:tt}=O.tags;let St=null;if(tt){const{data:_e,format:Ot}=tt;let Se="";for(let he=0;he<_e.length;he++)Se+=String.fromCharCode(_e[he]);St=`data:${Ot};base64,${window.btoa(Se)}`}we({title:V||j,artist:Fe||"Unknown Artist",album:Be||void 0,coverUrl:St})},onError:()=>{we({title:j,artist:"Unknown Artist",coverUrl:null})}})}).catch(()=>{we({title:j,artist:"Unknown Artist",coverUrl:null})})}),B=async te=>{try{const j=await te.text(),we=te.name.split(".").pop()?.toLowerCase();if(we==="lrc")return El(j);if(we==="srt")return _l(j);if(we==="ttml"||we==="xml")return Xl(j);if(we==="vtt")return Wl(j);if(we==="json")return _w(j)}catch(j){console.error("Failed to parse lyrics",j)}return[]};for(const[te,j]of D.entries())if(j.audio){const we=await ne(j.audio,te),E=Math.random().toString(36).substr(2,9);let O=[];j.lyric&&(O=await B(j.lyric)),k.push({id:E,audioFile:j.audio,lyricFile:j.lyric,parsedLyrics:O,metadata:we,duration:0})}if(k.length>0){const te=[...e,...k];t(te),s(0,!1,te)}},He=async M=>{if(M.target.files&&M.target.files.length>0){const D=Array.from(M.target.files);await ke(D),M.target.value=""}},[et,Ae]=Z.useState(!1),[C,se]=Z.useState(null),[ue,me]=Z.useState(null),[q,Ie]=Z.useState(null),Re=(M,D)=>{se(D),M.dataTransfer.effectAllowed="move"},ee=(M,D)=>{if(M.preventDefault(),M.stopPropagation(),C===null||C===D)return;const k=M.currentTarget.getBoundingClientRect(),ne=k.top+k.height/2,B=M.clientY{if(M.preventDefault(),M.stopPropagation(),C===null)return;const k=[...e],[ne]=k.splice(C,1);let B=D;q==="after"&&B++,C=o?l(o-1):C>o&&B<=o&&l(o+1),$e()},$e=()=>{se(null),me(null),Ie(null)},Oe=M=>{M.preventDefault(),M.stopPropagation(),C===null&&Ae(!0)},ht=M=>{M.preventDefault(),M.stopPropagation(),Ae(!1)},R=async M=>{if(M.preventDefault(),M.stopPropagation(),Ae(!1),M.dataTransfer.files&&M.dataTransfer.files.length>0){const D=Array.from(M.dataTransfer.files);await ke(D)}},Ue=M=>{m?m(M):t(D=>{const k=[...D];return k.splice(M,1),k})},We=M=>new Promise((D,k)=>{const ne=new FileReader;ne.readAsDataURL(M),ne.onload=()=>{const B=ne.result.split(",")[1];D(B)},ne.onerror=B=>k(B)}),Xe=async M=>{if(!navigator.onLine){alert("Unable to transcribe: No internet connection.");return}if(ce.has(M.id)){const B=T.current.get(M.id);B&&B.abort();return}const D=Je||"PLACEHOLDER_API_KEY";if(D.trim().length<39){alert(`Invalid API Key length (${D.trim().length}). It must be at least 39 characters.`),xt(!0);return}ve(B=>new Set(B).add(M.id));const k=new AbortController;T.current.set(M.id,k);const ne=19.5*1024*1024;if(M.audioFile.size>ne){alert(`File is too large (${(M.audioFile.size/1024/1024).toFixed(1)}MB). Gemini inline audio limit is ~20MB. - -Please convert to MP3/M4A or use a smaller file.`),ve(B=>{const te=new Set(B);return te.delete(M.id),te}),T.current.delete(M.id);return}try{const B=await We(M.audioFile);let te=M.duration||0;if(te===0)try{te=await new Promise(E=>{const O=new Audio(URL.createObjectURL(M.audioFile));O.onloadedmetadata=()=>{E(O.duration),URL.revokeObjectURL(O.src)},O.onerror=()=>{URL.revokeObjectURL(O.src),E(0)}})}catch(E){console.warn("Could not determine duration for AI validation",E)}let we=(await WM(qe,B,M.audioFile.type,D,k.signal,Ke)).map(E=>({time:Ks(E.startTime),text:E.text,endTime:Ks(E.endTime),words:E.words?E.words.map(O=>({text:O.text,startTime:Ks(O.startTime),endTime:Ks(O.endTime)})):void 0}));te>0&&(we=we.filter(E=>E.time=0)),t(E=>E.map(O=>O.id===M.id?{...O,parsedLyrics:we.sort((V,Fe)=>V.time-Fe.time),duration:te>0?te:O.duration}:O))}catch(B){if(B.name==="AbortError")console.log("Transcription aborted via user action.");else{console.error("Transcription failed:",B);let te="Transcription failed. Please check your API key or file format.";if(!navigator.onLine)te="Connection lost. Please check your internet connection.";else if(B.message){const j=B.message.toLowerCase();j.includes("fetch")||j.includes("network")||j.includes("failed to connect")?te="Network error. Please check your connection.":(j.includes("api key")||B.message.includes("400")||B.message.includes("401")||B.message.includes("403"))&&(te="API Key Error: Please check if your key is valid and has credits.")}alert(te)}}finally{T.current.delete(M.id),ve(B=>{const te=new Set(B);return te.delete(M.id),te})}},Ye=async M=>{if(!navigator.onLine){alert("No internet connection.");return}fe(D=>new Set(D).add(M.id));try{const D=await Sf(()=>import("./index.min-BxHvltil.js").then(we=>we.i),[]);let k;const ne=D.default||D;console.log("SyncLyrics Module:",D);const B=["musixmatch","lrclib","netease"];if(typeof ne=="function"&&ne.prototype&&ne.prototype.getLyrics){console.log("Detected Class usage");const we=new ne({sources:B});k=E=>we.getLyrics(E)}else if(ne.getLyrics&&typeof ne.getLyrics=="function")console.log("Detected Instance usage"),k=we=>ne.getLyrics(we);else if(ne.SyncLyrics){console.log("Detected Mod.SyncLyrics export");const we=ne.SyncLyrics;if(typeof we=="function"&&we.prototype&&we.prototype.getLyrics){console.log("Using SyncLyrics as Class");const E=new we({sources:B});k=O=>E.getLyrics(O)}else if(typeof we=="function")console.log("Using SyncLyrics as Function"),k=we;else throw new Error("Mod.SyncLyrics found but is not a function or class.")}else if(typeof ne=="function")console.log("Detected Function usage"),k=ne;else throw new Error(`Could not find suitable search function. Mod type: ${typeof ne}. Keys: ${typeof ne=="object"?JSON.stringify(Object.keys(ne)):"N/A"}`);const te={track:M.metadata.title,artist:M.metadata.artist,album:M.metadata.album,sources:B};console.log("Searching lyrics with options:",te);const j=await k(te);if(j&&typeof j=="string")ft(j,M);else{console.warn("npm package returned no result. Attempting fallback to LrcLib.net API directly...");let we=M.duration||0;if(we===0)try{we=await new Promise(Fe=>{const Be=new Audio(URL.createObjectURL(M.audioFile));Be.onloadedmetadata=()=>{const tt=Be.duration;URL.revokeObjectURL(Be.src),Fe(tt)},Be.onerror=()=>Fe(0)})}catch(Fe){console.warn("Could not determine duration for search",Fe)}const E=new URLSearchParams({artist_name:M.metadata.artist,track_name:M.metadata.title,album_name:M.metadata.album||"",duration:we.toString()}),O=await fetch(`https://lrclib.net/api/get?${E.toString()}`);if(!O.ok){const Fe=await fetch(`https://lrclib.net/api/search?q=${encodeURIComponent(M.metadata.title+" "+M.metadata.artist)}`);if(Fe.ok){const Be=await Fe.json();if(Array.isArray(Be)&&Be.length>0){const tt=Be.find(St=>St.syncedLyrics);if(tt){ft(tt.syncedLyrics,M);return}else if(Be[0].plainLyrics){ft(Be[0].plainLyrics,M);return}}}throw new Error("No lyrics found in fallback source.")}const V=await O.json();V.syncedLyrics?ft(V.syncedLyrics,M):V.plainLyrics?ft(V.plainLyrics,M):alert("No lyrics found.")}}catch(D){console.error("Search failed:",D),D.message?.includes("CORS")||D.message?.includes("etwork")||D.message?.includes("Failed to fetch")?alert(`Network Error: Could not connect to lyric services. -(Possible CORS blocking in browser).`):alert("Search failed: "+D.message)}finally{fe(D=>{const k=new Set(D);return k.delete(M.id),k})}},ft=(M,D)=>{let k=El(M);if(k.length===0&&(k=_l(M)),k.length>0){const ne=k.some(B=>B.words&&B.words.length>0);console.log(ne?"Word-level (enhanced) lyrics found!":"Line-level lyrics found."),t(B=>B.map(te=>te.id===D.id?{...te,parsedLyrics:k,lyricFile:new File([M],`synched-lyrics${ne?".lrc-enhanced":".lrc"}`,{type:"text/plain"})}:te))}else alert("Lyrics found but could not be parsed.")},jt=(M,D,k)=>{const ne=new Blob([M],{type:"application/octet-stream"}),B=URL.createObjectURL(ne),te=document.createElement("a");te.href=B,te.download=D,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(B)},gt=async(M,D)=>{const k=M.parsedLyrics||[];if(k.length===0)return;let ne="";const B=D==="lrc-enhanced"?"lrc":D,te=`${M.metadata.title||"lyrics"}.${B}`;let j=M.duration||0;if(j===0)try{j=await new Promise(E=>{const O=new Audio(URL.createObjectURL(M.audioFile));O.onloadedmetadata=()=>{E(O.duration),URL.revokeObjectURL(O.src)},O.onerror=()=>E(0)})}catch(E){console.warn("Could not determine duration for export check",E)}const we=k.map(E=>({...E,words:E.words?E.words.filter(O=>O.text.trim().length>0).map(O=>({...O})):void 0}));for(let E=0;E0?j:O.time+5),O.words&&O.words.length>0)for(let Fe=0;FeE.text).join(` -`);else if(D==="json")ne=JSON.stringify(we,null,2);else if(D==="srt"){const E=O=>{const V=Math.floor(O/3600).toString().padStart(2,"0"),Fe=Math.floor(O%3600/60).toString().padStart(2,"0"),Be=Math.floor(O%60).toString().padStart(2,"0"),tt=Math.floor(O%1*1e3).toString().padStart(3,"0");return`${V}:${Fe}:${Be},${tt}`};ne=we.map((O,V)=>{const Fe=E(O.time),Be=O.endTime!==void 0&&O.endTime>O.time?O.endTime:O.time+2,tt=E(Be);return`${V+1} -${Fe} --> ${tt} -${O.text} -`}).join(` -`)}else if(D==="lrc"){const E=[],O=V=>{const Fe=Math.floor(V/60).toString().padStart(2,"0"),Be=(V%60).toFixed(2).padStart(5,"0");return`[${Fe}:${Be}]`};for(let V=0;V0)||St<=j)&&(Be?Be.time>St&&E.push(`${O(St)}`):E.push(`${O(St)}`))}ne=E.join(` -`)}else if(D==="lrc-enhanced"){const E=[],O=Fe=>{const Be=Math.floor(Fe/60).toString().padStart(2,"0"),tt=(Fe%60).toFixed(2).padStart(5,"0");return`[${Be}:${tt}]`},V=Fe=>{const Be=Math.floor(Fe/60).toString().padStart(2,"0"),tt=(Fe%60).toFixed(2).padStart(5,"0");return`<${Be}:${tt}>`};for(let Fe=0;Fe0?Be.words.forEach((he,dt)=>{const Dt=he.text.replace(/[ \t]+/g," ").trim().replace(/\n/g,"\\n");St+=`${V(he.startTime)}${Dt}`,dt0)||Ot<=j)&&(tt?tt.time>Ot&&E.push(`${O(Ot)}`):E.push(`${O(Ot)}`))}ne=E.join(` -`)}else if(D==="ttml"){const E=O=>{const V=Math.floor(O/3600).toString().padStart(2,"0"),Fe=Math.floor(O%3600/60).toString().padStart(2,"0"),Be=Math.floor(O%60).toString().padStart(2,"0"),tt=Math.floor(O%1*1e3).toString().padStart(3,"0");return`${V}:${Fe}:${Be}.${tt}`};ne=` - - -
`,we.forEach(O=>{const V=E(O.time),Fe=O.endTime!==void 0&&O.endTime>O.time?O.endTime:O.time+3,Be=E(Fe);ne+=` -

`,O.words&&O.words.length>0?O.words.forEach(tt=>{if(!tt.text.trim())return;const St=E(tt.startTime);let _e=tt.endTime;(_e===void 0||_e<=tt.startTime)&&(_e=tt.startTime+.5);const Ot=E(_e);let Se=tt.text.replace(/[ \t]+/g," ").trim();Se.endsWith("-")||(Se+=" "),ne+=` - ${Se}`}):ne+=` - ${O.text.replace(/-\s+/g,"-").replace(/[ \t]+/g," ").trim()}`,ne+=` -

`}),ne+=` -
- -
`}else if(D==="vtt"){const E=O=>{const V=Math.floor(O/3600).toString().padStart(2,"0"),Fe=Math.floor(O%3600/60).toString().padStart(2,"0"),Be=Math.floor(O%60).toString().padStart(2,"0"),tt=Math.floor(O%1*1e3).toString().padStart(3,"0");return`${V}:${Fe}:${Be}.${tt}`};ne=`WEBVTT - -`,we.forEach(O=>{const V=E(O.time),Fe=O.endTime!==void 0&&O.endTime>O.time?O.endTime:O.time+2,Be=E(Fe);let tt=O.text.trim();if(O.words&&O.words.length>0){const St=O.words.map(_e=>`<${E(_e.startTime)}>${_e.text.trim()}`).join(" ");St.length>0&&(tt=St)}ne+=`${V} --> ${Be} -${tt} - -`})}jt(ne,te)},Et=async()=>{if(e.length===0)return;const M=async k=>new Promise(ne=>{const B=new Audio(URL.createObjectURL(k));B.onloadedmetadata=()=>{ne(B.duration),URL.revokeObjectURL(B.src)},B.onerror=()=>{ne(0),URL.revokeObjectURL(B.src)}});let D=`#EXTM3U -`;for(const k of e){let ne=k.duration||0;if(ne===0)try{ne=await M(k.audioFile)}catch(E){console.error("Failed to get duration for export",E)}const B=Math.round(ne),te=(k.metadata.artist||"Unknown Artist").replace(/[\r\n]/g,""),j=(k.metadata.title||"Unknown Title").replace(/[\r\n]/g,"");D+=`#EXTINF:${B},${te} - ${j} -`;const we=k.audioFile.webkitRelativePath||k.audioFile.name;D+=`${we} -`}jt(D,"playlist.m3u8")},A=async M=>{await S("Are you sure you want to clear the lyric timeline?","Clear Lyrics")&&t(D=>D.map(k=>k.id===M.id?{...k,parsedLyrics:[],lyricFile:void 0}:k))},W=async M=>{const D=M.target.files?.[0];if(!(!D||!ze)){try{const k=await D.text(),ne=D.name.split(".").pop()?.toLowerCase();let B=[];ne==="lrc"?B=El(k):ne==="srt"?B=_l(k):ne==="ttml"||ne==="xml"?B=Xl(k):ne==="vtt"&&(B=Wl(k)),B.length>0?t(te=>te.map(j=>j.id===ze?{...j,lyricFile:D,parsedLyrics:B}:j)):alert("Could not parse lyrics. Ensure file is .lrc, .srt, or .vtt")}catch(k){console.error("Failed to load lyrics",k),alert("Failed to load lyrics file.")}Le(null),M.target.value=""}};return u.jsxs("div",{className:`w-full max-w-[100vw] h-64 flex flex-col bg-zinc-900/95 backdrop-blur-md border-t border-white/10 z-20 shadow-xl overflow-hidden outline-none relative transition-colors ${et?"bg-zinc-800 border-orange-500":""}`,onDragOver:Oe,onDragLeave:ht,onDrop:R,children:[et&&u.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-zinc-900/90 backdrop-blur-sm pointer-events-none",children:u.jsxs("div",{className:"flex flex-col items-center gap-4 text-orange-500 animate-pulse",children:[u.jsx(ro,{size:48}),u.jsx("h3",{className:"text-xl font-bold",children:"Drop Audio & Lyrics Here"}),u.jsx("p",{className:"text-sm text-zinc-400",children:"Supported formats: MP3, WAV, FLAC, Video (MP4/WebM), LRC, SRT, VTT"})]})}),u.jsx("input",{type:"file",name:"manual-lyric-upload",id:"manual-lyric-upload",ref:K,className:"hidden",accept:".lrc,.srt,.ttml,.xml,.vtt",onChange:W}),u.jsxs("div",{className:"p-2 border-b border-white/10 flex items-center justify-between bg-zinc-900 z-30 shrink-0 h-12",children:[u.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[u.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap",children:[u.jsx(jc,{size:16,className:"text-orange-400"}),"Playlist"]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex bg-orange-600 rounded overflow-hidden",children:[u.jsxs("label",{className:"flex items-center gap-2 px-3 py-1 hover:bg-orange-500 cursor-pointer transition-colors text-white text-xs font-medium whitespace-nowrap border-r border-orange-700",children:[u.jsx(fv,{size:14})," Add Files",u.jsx("input",{type:"file",name:"add-files",id:"add-files",className:"hidden",accept:"audio/*,video/*,.lrc,.srt,.ttml,.xml,.vtt",multiple:!0,onChange:He})]}),u.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 hover:bg-orange-500 cursor-pointer transition-colors text-white text-xs whitespace-nowrap",title:"Add Folder",children:[u.jsx(pS,{size:14}),u.jsx("input",{type:"file",name:"add-folder",id:"add-folder",className:"hidden",multiple:!0,webkitdirectory:"",onChange:He})]})]}),u.jsx("div",{className:"w-px h-4 bg-zinc-700"}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:()=>X("filename"),className:`p-1 rounded transition-colors ${Y.key==="filename"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Filename ${Y.key==="filename"?Y.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:u.jsx(Pc,{size:14,className:Y.key==="filename"&&Y.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),u.jsx("button",{onClick:()=>X("artist"),className:`p-1 rounded transition-colors ${Y.key==="artist"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Artist ${Y.key==="artist"?Y.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:u.jsx(yw,{size:14,className:Y.key==="artist"&&Y.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),u.jsx("button",{onClick:()=>X("title"),className:`p-1 rounded transition-colors ${Y.key==="title"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Title ${Y.key==="title"?Y.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:u.jsx(Oa,{size:14,className:Y.key==="title"&&Y.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),u.jsx("button",{onClick:()=>X("album"),className:`p-1 rounded transition-colors ${Y.key==="album"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Album ${Y.key==="album"?Y.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:u.jsx(tS,{size:14,className:Y.key==="album"&&Y.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),u.jsx("button",{onClick:()=>X("random"),className:`p-1 rounded transition-colors ${Y.key==="random"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:"Shuffle",children:u.jsx(XS,{size:14})})]})]}),u.jsxs("div",{className:"flex gap-2 shrink-0 items-center",children:[u.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded px-1",children:[u.jsx("button",{onClick:()=>xt(!it),className:`p-1 rounded transition-colors ${it?"text-orange-400":"text-zinc-500 hover:text-zinc-300"}`,title:"Gemini API Key",children:u.jsx(wS,{size:14})}),it&&u.jsx("input",{type:Je?"password":"text",name:"api-key","aria-label":"Gemini API Key",value:Je,onChange:M=>ge(M.target.value),placeholder:"Paste API Key here",className:"bg-transparent border-none outline-none text-xs text-zinc-200 w-32 placeholder:text-zinc-600",autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),u.jsx("div",{className:"relative group",children:u.jsxs("select",{value:qe,onChange:M=>Ve(M.target.value),className:"bg-zinc-800 text-[10px] text-zinc-300 border border-zinc-700 rounded px-1 py-1 focus:outline-none focus:border-orange-500 appearance-none cursor-pointer hover:bg-zinc-700",title:"Select Gemini Model",name:"gemini-model",id:"gemini-model","aria-label":"Gemini Model",children:[u.jsx("option",{value:"gemini-2.5-flash",children:"Gemini 2.5 Flash"}),u.jsx("option",{value:"gemini-3-flash-preview",children:"Gemini 3.0 Flash Preview"})]})}),u.jsx("div",{className:"relative group",children:u.jsxs("select",{value:Ke,onChange:M=>nt(M.target.value),className:"bg-zinc-800 text-[10px] text-zinc-300 border border-zinc-700 rounded px-1 py-1 focus:outline-none focus:border-orange-500 appearance-none cursor-pointer hover:bg-zinc-700 w-[60px]",title:"Transcription Mode (Line or Word Level)",name:"transcription-mode",id:"transcription-mode","aria-label":"Transcription Mode",children:[u.jsx("option",{value:"line",children:"Line"}),u.jsx("option",{value:"word",children:"Word"})]})}),u.jsx("button",{onClick:Et,className:"p-1 hover:bg-zinc-700 text-zinc-500 hover:text-white rounded transition-colors",title:"Export Playlist (.m3u8)",children:u.jsx(cS,{size:14})}),u.jsx("button",{onClick:async()=>{e.length>0&&await S("Clear entire playlist?","Clear Playlist")&&(v(),t([]))},className:"p-1 hover:bg-red-900/50 text-zinc-500 hover:text-red-200 rounded transition-colors",title:"Clear Playlist",children:u.jsx($a,{size:14})}),u.jsx("div",{className:"w-px h-4 bg-zinc-700 mx-1 self-center"}),u.jsx("button",{onClick:b,className:"p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors",title:"Close Playlist",children:u.jsx(Bi,{size:14})})]})]}),u.jsx("div",{ref:_,tabIndex:0,onMouseEnter:()=>_.current?.focus(),className:"flex-1 overflow-y-auto overflow-x-hidden custom-scrollbar bg-zinc-950 p-1 space-y-1 focus:outline-none",children:e.length===0?u.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-zinc-500 text-xs",children:[u.jsx(jc,{size:32,className:"mb-2 opacity-50"}),u.jsx("p",{children:"Playlist is empty"}),u.jsx("p",{className:"opacity-50",children:"Add audio files (matches .lrc/.srt/.ttml by name)"})]}):e.map((M,D)=>{const k=D===o,ne=D===z,B=M.parsedLyrics||[],te=k?B.findIndex((j,we)=>{if(j.endTime!==void 0)return x>=j.time&&x=j.time&&(!E||xRe(j,D),onDragEnd:$e,onDragOver:j=>ee(j,D),onDrop:j=>be(j,D),onClick:()=>G(D),className:`group relative flex gap-2 p-1.5 rounded-md border transition-all cursor-pointer - ${k?"bg-zinc-800 border-orange-500/50 shadow-lg":"bg-zinc-900/50 border-zinc-800 hover:bg-zinc-800 hover:border-zinc-700"} - ${ne?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} - ${C===D?"opacity-50 border-dashed border-zinc-500":""} - ${ue===D&&q==="before"?"border-t-2 border-t-orange-500":""} - ${ue===D&&q==="after"?"border-b-2 border-b-orange-500":""} - `,children:[u.jsx("div",{className:"flex items-center justify-center px-1 cursor-grab active:cursor-grabbing text-zinc-600 hover:text-zinc-400 self-stretch",onMouseDown:j=>j.stopPropagation(),children:u.jsx(gS,{size:12})}),u.jsxs("div",{className:"flex flex-col gap-1 shrink-0 w-48",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:j=>{j.stopPropagation(),k?f():s(D)},className:`p-1.5 rounded-full transition-colors flex-shrink-0 - ${k?"bg-orange-500 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700 hover:text-white"} - `,children:k?d?u.jsx(dv,{size:14}):u.jsx(Tf,{size:14}):u.jsx(Tf,{size:14})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:`text-xs font-medium truncate ${k?"text-orange-100":"text-zinc-300"}`,title:M.audioFile.name,children:M.metadata.title}),u.jsx("div",{className:"text-[9px] text-zinc-500 truncate",title:M.metadata.artist,children:M.metadata.artist})]})]}),u.jsxs("div",{className:"ml-8 flex items-center gap-2",children:[u.jsxs("span",{className:"text-[8px] text-zinc-600",children:[(M.audioFile.size/1024/1024).toFixed(1),"MB"]}),M.lyricFile?u.jsxs("div",{className:"flex items-center gap-0.5 text-[8px] px-1 rounded bg-blue-900/30 text-blue-300/80",title:M.lyricFile.name,children:[u.jsx(Pc,{size:7}),u.jsx("span",{className:"truncate max-w-[80px]",children:M.lyricFile.name})]}):u.jsx("span",{className:"text-[8px] text-zinc-700 italic",children:"No Lyrics"})]})]}),u.jsx("div",{className:"flex-1 min-w-0 h-12 bg-zinc-950/50 rounded border border-zinc-800/50 overflow-x-auto overflow-y-hidden custom-scrollbar",children:B.length>0?u.jsx("div",{className:"relative h-full min-w-max flex items-center px-1",children:B.map((j,we)=>{const E=we===te;return u.jsxs("div",{id:E?`lyric-active-${D}`:void 0,className:`flex items-center gap-1 px-1.5 py-0.5 mx-0.5 rounded text-[9px] transition-colors whitespace-nowrap cursor-pointer - ${E?"bg-orange-600 text-white border border-orange-400 shadow-[0_0_10px_rgba(234,88,12,0.3)]":"bg-zinc-800/50 hover:bg-blue-900/50 border border-zinc-700/30 hover:border-blue-500/50 text-zinc-400"} - `,title:`${F(j.time)} - ${j.text}`,onClick:O=>{O.stopPropagation(),D!==o?(s(D),setTimeout(()=>g(j.time),150)):g(j.time)},children:[u.jsx("span",{className:`font-mono text-[8px] ${E?"text-orange-200":"text-zinc-500"}`,children:F(j.time)}),u.jsx("span",{className:`truncate max-w-[120px] ${E?"text-white font-medium":"text-zinc-400"}`,children:j.text||"♪"})]},we)})}):u.jsx("div",{className:"h-full flex items-center justify-center text-zinc-700 text-[9px] italic",children:"No lyric timeline"})}),u.jsxs("div",{className:"flex items-center gap-1 shrink-0 px-1",children:[u.jsx("button",{onClick:j=>{j.stopPropagation(),Le(M.id),K.current&&(K.current.value=""),K.current?.click()},className:"p-1.5 rounded bg-blue-900/30 border border-blue-500/30 text-blue-400 hover:bg-blue-800/50 transition-colors",title:"Load Lyrics Manually",children:u.jsx(ro,{size:14})}),u.jsx("button",{onClick:j=>{j.stopPropagation(),Ye(M)},className:`group/btn relative p-1.5 rounded bg-cyan-900/30 border border-cyan-500/30 text-cyan-400 hover:bg-cyan-800/50 transition-colors ${ye.has(M.id)?"animate-pulse":""}`,title:"Search Lyrics (Online)",disabled:ye.has(M.id),children:ye.has(M.id)?u.jsx(hg,{size:14,className:"animate-spin"}):u.jsx(YS,{size:14})}),u.jsx("button",{onClick:j=>{j.stopPropagation(),Xe(M)},className:`group/btn relative p-1.5 rounded bg-purple-900/30 border border-purple-500/30 text-purple-400 hover:bg-purple-800/50 transition-colors ${ce.has(M.id)?"text-red-400 border-red-500/50 hover:bg-red-900/30":""}`,title:ce.has(M.id)?"Stop Transcription":"AI Sync Transcribe",children:ce.has(M.id)?u.jsxs(u.Fragment,{children:[u.jsx(hg,{size:14,className:"animate-spin group-hover/btn:hidden"}),u.jsx(_f,{size:14,className:"hidden group-hover/btn:block fill-current"})]}):u.jsx(Ef,{size:14})}),B.length>0&&u.jsxs("div",{className:"flex items-center gap-0.5 bg-zinc-800/50 rounded p-0.5 border border-zinc-700/50",children:[u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"txt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download TXT",children:"TXT"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"lrc")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download LRC",children:"LRC"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"lrc-enhanced")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download Enhanced LRC (Word Level)",children:"eLRC"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"srt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download SRT",children:"SRT"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"vtt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download VTT",children:"VTT"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"ttml")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download TTML",children:"TTML"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),gt(M,"json")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download JSON",children:"JSON"}),u.jsx("div",{className:"w-px h-3 bg-zinc-700 mx-0.5"}),u.jsx("button",{onClick:j=>{j.stopPropagation(),A(M)},className:"p-1 hover:bg-red-900/50 rounded text-[8px] text-red-500 hover:text-red-300 font-bold",title:"Clear Lyrics",children:"CLR"})]})]}),u.jsx("button",{onClick:j=>{j.stopPropagation(),Ue(D)},className:"p-1 text-zinc-600 hover:text-red-400 hover:bg-red-900/20 rounded self-start",title:"Remove Track",children:u.jsx($a,{size:12})})]},M.id)})})]})},fp=[{label:"Modern & Clean",options:[{label:"System Sans Serif",value:"ui-sans-serif, system-ui, sans-serif"},{label:"Inter",value:"'Inter', sans-serif"},{label:"Roboto",value:"'Roboto', sans-serif"},{label:"Poppins",value:"'Poppins', sans-serif"},{label:"Montserrat",value:"'Montserrat', sans-serif"},{label:"Open Sans",value:"'Open Sans', sans-serif"},{label:"Lato",value:"'Lato', sans-serif"},{label:"Raleway",value:"'Raleway', sans-serif"},{label:"Outfit",value:"'Outfit', sans-serif"},{label:"Nunito",value:"'Nunito', sans-serif"}]},{label:"Classic & Elegant",options:[{label:"System Serif",value:"ui-serif, Georgia, serif"},{label:"Playfair Display",value:"'Playfair Display', serif"},{label:"Merriweather",value:"'Merriweather', serif"},{label:"Lora",value:"'Lora', serif"},{label:"Crimson Text",value:"'Crimson Text', serif"},{label:"EB Garamond",value:"'EB Garamond', serif"},{label:"Libre Baskerville",value:"'Libre Baskerville', serif"}]},{label:"Display & Bold",options:[{label:"Bebas Neue",value:"'Bebas Neue', sans-serif"},{label:"Anton",value:"'Anton', sans-serif"},{label:"Oswald",value:"'Oswald', sans-serif"},{label:"Archivo Black",value:"'Archivo Black', sans-serif"},{label:"Staatliches",value:"'Staatliches', cursive"},{label:"Righteous",value:"'Righteous', cursive"},{label:"Bungee",value:"'Bungee', cursive"}]},{label:"Handwritten & Script",options:[{label:"Dancing Script",value:"'Dancing Script', cursive"},{label:"Pacifico",value:"'Pacifico', cursive"},{label:"Great Vibes",value:"'Great Vibes', cursive"},{label:"Satisfy",value:"'Satisfy', cursive"},{label:"Shadows Into Light",value:"'Shadows Into Light', cursive"},{label:"Caveat",value:"'Caveat', cursive"},{label:"Indie Flower",value:"'Indie Flower', cursive"},{label:"Kalam",value:"'Kalam', cursive"},{label:"Sacramento",value:"'Sacramento', cursive"}]},{label:"Fun & Playful",options:[{label:"Fredoka One",value:"'Fredoka One', cursive"},{label:"Bangers",value:"'Bangers', cursive"},{label:"Luckiest Guy",value:"'Luckiest Guy', cursive"},{label:"Chewy",value:"'Chewy', cursive"},{label:"Bubblegum Sans",value:"'Bubblegum Sans', cursive"},{label:"Cherry Cream Soda",value:"'Cherry Cream Soda', cursive"},{label:"Patrick Hand",value:"'Patrick Hand', cursive"}]},{label:"Tech & Futuristic",options:[{label:"System Monospace",value:"ui-monospace, monospace"},{label:"Orbitron",value:"'Orbitron', sans-serif"},{label:"Audiowide",value:"'Audiowide', cursive"},{label:"Share Tech Mono",value:"'Share Tech Mono', monospace"},{label:"VT323",value:"'VT323', monospace"},{label:"Press Start 2P",value:"'Press Start 2P', cursive"},{label:"Fira Code",value:"'Fira Code', monospace"},{label:"JetBrains Mono",value:"'JetBrains Mono', monospace"}]},{label:"Decorative & Themed",options:[{label:"Metal Mania",value:"'Metal Mania', cursive"},{label:"UnifrakturMaguntia",value:"'UnifrakturMaguntia', cursive"},{label:"Cinzel",value:"'Cinzel', serif"},{label:"Creepster",value:"'Creepster', cursive"},{label:"Pirata One",value:"'Pirata One', cursive"},{label:"Rubik Moonrocks",value:"'Rubik Moonrocks', cursive"},{label:"Nabla",value:"'Nabla', cursive"}]},{label:"International & Multilingual",options:[{label:"Noto Sans SC (Chinese)",value:"'Noto Sans SC', sans-serif"},{label:"Noto Sans JP (Japanese)",value:"'Noto Sans JP', sans-serif"},{label:"Noto Sans KR (Korean)",value:"'Noto Sans KR', sans-serif"},{label:"Noto Sans Arabic (Arabic)",value:"'Noto Sans Arabic', sans-serif"},{label:"Noto Sans Devanagari (Hindi)",value:"'Noto Sans Devanagari', sans-serif"}]}],ax=["Metal Mania","Bebas Neue","Anton","Staatliches","Righteous","Bungee","Dancing Script","Pacifico","Great Vibes","Satisfy","Shadows Into Light","Caveat","Indie Flower","Kalam","Sacramento","Fredoka One","Bangers","Luckiest Guy","Chewy","Bubblegum Sans","Cherry Cream Soda","Patrick Hand","Orbitron","Audiowide","Share Tech Mono","VT323","Press Start 2P","Fira Code","JetBrains Mono","UnifrakturMaguntia","Creepster","Pirata One","Rubik Moonrocks","Nabla"],ZM=()=>{if(!document.getElementById("google-fonts-preconnect")){const e=document.createElement("link");e.id="google-fonts-preconnect",e.rel="preconnect",e.href="https://fonts.googleapis.com",document.head.appendChild(e);const t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t)}fp.forEach((e,t)=>{const o=new Set;if(e.options.forEach(v=>{const m=v.value.split(",")[0].trim().replace(/['"]/g,"");!m.startsWith("ui-")&&m!=="system-ui"&&m!=="sans-serif"&&m!=="serif"&&m!=="monospace"&&o.add(m)}),o.size===0)return;const d=`https://fonts.googleapis.com/css2?${Array.from(o).map(v=>{const m=v.replace(/['"]/g,"");return ax.includes(m)?`family=${v.replace(/ /g,"+")}`:`family=${v.replace(/ /g,"+")}:wght@400;700`}).join("&")}&display=swap`,f=`google-fonts-group-${t}`;if(document.getElementById(f))return;const g=document.createElement("link");g.id=f,g.rel="stylesheet",g.href=d,document.head.appendChild(g)})},e2=e=>{const t=`google-font-${e.replace(/\s+/g,"-").toLowerCase()}`;if(document.getElementById(t))return;const o=e.replace(/['"]/g,"");let l=`family=${e.replace(/\s+/g,"+")}:wght@400;700`;ax.includes(o)&&(l=`family=${e.replace(/\s+/g,"+")}`);const s=document.createElement("link");s.id=t,s.rel="stylesheet",s.href=`https://fonts.googleapis.com/css2?${l}&display=swap`,document.head.appendChild(s)},pp=[{label:"Basic",options:[{label:"Default",value:"default"},{label:"Custom",value:"custom"}]},{label:"Typography",options:[{label:"Large Text",value:"large"},{label:"Large Uppercase",value:"large_upper"},{label:"Big Center",value:"big_center"},{label:"Classic Serif",value:"classic"},{label:"Monospace",value:"monospace"}]},{label:"Thematic",options:[{label:"Heavy Metal",value:"metal"},{label:"Kids Fun",value:"kids"},{label:"Melancholy",value:"sad"},{label:"Romantic",value:"romantic"},{label:"Tech / Sci-Fi",value:"tech"},{label:"Gothic",value:"gothic"}]},{label:"Layout & Minimal",options:[{label:"Slideshow (Small)",value:"slideshow"},{label:"Subtitle Mode",value:"subtitle"},{label:"Video Only",value:"just_video"}]},{label:"Debug",options:[{label:"Testing",value:"testing"},{label:"Testing Up",value:"testing_up"}]}],Yc={default:{fontSizeScale:1,fontFamily:"ui-sans-serif, system-ui, sans-serif",textCase:"none",textAlign:"center",fontColor:"#ffffff"},large:{fontSizeScale:1.8,fontFamily:"ui-sans-serif, system-ui, sans-serif",fontColor:"#ffffff",fontWeight:"bold"},classic:{fontSizeScale:1,fontFamily:'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',fontColor:"#fef3c7",fontStyle:"italic",fontWeight:"bold"},large_upper:{fontSizeScale:1.6,fontFamily:"ui-sans-serif, system-ui, sans-serif",textCase:"upper",fontColor:"#ffffff",fontWeight:"bold"},monospace:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontColor:"#ffffff",fontWeight:"bold"},big_center:{fontSizeScale:1.6,fontFamily:"ui-sans-serif, system-ui, sans-serif",textCase:"upper",textAlign:"center",contentPosition:"center",fontColor:"#ffffff",fontWeight:"bold"},metal:{fontFamily:'"Metal Mania", cursive',fontSizeScale:1.6,textCase:"upper",fontColor:"#ffffff"},kids:{fontFamily:'"Fredoka One", cursive',fontSizeScale:1.6,textCase:"upper",fontColor:"#ffffff"},sad:{fontFamily:'"Shadows Into Light", cursive',fontSizeScale:1.2,fontColor:"#e4e4e7"},romantic:{fontFamily:'"Dancing Script", cursive',fontSizeScale:1.2,fontColor:"#fce7f3",fontStyle:"italic"},tech:{fontFamily:'"Orbitron", sans-serif',fontSizeScale:1.6,textCase:"upper",fontColor:"#ecfeff",fontWeight:"bold"},gothic:{fontFamily:'"UnifrakturMaguntia", cursive',fontSizeScale:1.2,fontColor:"#d4d4d8"},slideshow:{fontSizeScale:.6,fontColor:"#ffffff"},just_video:{},subtitle:{fontSizeScale:.6,contentPosition:"bottom",fontColor:"#ffffff"},testing:{fontSizeScale:1.6},testing_up:{fontSizeScale:1.6,textCase:"upper"}},gf=pp.flatMap(e=>e.options.map(t=>t.value)),yf=({onApply:e,placeholder:t="Google Font Name"})=>{const{toast:o}=ur(),[l,s]=Z.useState(""),d=()=>{if(!l.trim())return;const f=l.trim().replace(/['"]/g,"").replace(/\s+/g," ");e2(f),e(f),o.success(`Loaded & Applied: ${f}`),s("")};return u.jsxs("div",{className:"flex gap-2 mt-2 items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase whitespace-nowrap",children:"Google Font:"}),u.jsx("input",{type:"text",name:"google-font-name","aria-label":"Google Font Name",value:l,onChange:f=>s(f.target.value),placeholder:t,className:"flex-1 min-w-0 bg-zinc-900 border border-white/10 rounded-md px-2 py-1 text-[10px] text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500",onKeyDown:f=>{f.key==="Enter"&&d()}}),u.jsx("button",{onClick:d,disabled:!l.trim(),className:"bg-zinc-700 hover:bg-zinc-600 text-white text-[10px] px-2 py-1 rounded-md font-medium disabled:opacity-50 transition-colors",title:"Load and apply",children:"Load"})]})},Wy={backgroundSource:"custom",backgroundColor:"#581c87",backgroundGradient:"linear-gradient(to bottom right, #312e81, #581c87, #000000)",renderMode:"current",textAlign:"center",contentPosition:"center",fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSizeScale:1,lyricLineHeight:1.3,fontColor:"#ffffff",textEffect:"preset",textAnimation:"none",transitionEffect:"none",lyricDisplayMode:"all",fontWeight:"bold",fontStyle:"normal",lyricStyleTarget:"active-only",textDecoration:"none",showTitle:!0,showArtist:!0,showCover:!0,showIntro:!0,showLyrics:!0,infoPosition:"top-left",infoStyle:"classic",infoMarginScale:1,infoSizeScale:1,infoFontFamily:"ui-sans-serif, system-ui, sans-serif",infoFontWeight:"bold",infoFontStyle:"normal",infoFontColor:"#ffffff",backgroundBlurStrength:0,introMode:"auto",introText:"",textCase:"none",highlightEffect:"karaoke",highlightColor:"#fb923c",highlightBackground:"#fb923c",showChannelInfo:!1,channelInfoText:"Music Channel",channelInfoPosition:"bottom-right",channelInfoStyle:"classic",channelInfoSizeScale:1,channelInfoMarginScale:1,channelInfoFontFamily:"ui-sans-serif, system-ui, sans-serif",channelInfoFontWeight:"bold",channelInfoFontStyle:"normal",channelInfoFontColor:"#ffffff",channelInfoImage:void 0,useCustomHighlightColors:!1,backgroundImage:void 0,visualTransitionType:"none",visualTransitionDuration:1,enableGradientOverlay:!1,useRealColorMedia:!1,marginTopScale:1,marginBottomScale:1,showVisualization:!1,visualizationType:"bars",visualizationColorMode:"gradient",visualizationColor1:"#a855f7",visualizationColor2:"#6366f1",visualizationOpacity:.6,visualizationPosition:"bottom",visualizationSensitivity:1.5,visualizationBarCount:48},Qy=[{label:"Basic",options:[{label:"Use Preset Default",value:"preset"},{label:"None",value:"none"},{label:"Drop Shadow",value:"shadow"},{label:"Outline",value:"outline"}]},{label:"Glow Effects",options:[{label:"Soft Glow",value:"glow"},{label:"Neon Glow",value:"neon"},{label:"Multi-Color Neon",value:"neon-multi"}]},{label:"3D & Pop",options:[{label:"3D Pop",value:"3d"},{label:"Embossed",value:"emboss"},{label:"Chrome Metallic",value:"chrome"},{label:"Gold Foil",value:"gold"}]},{label:"Artistic",options:[{label:"Glassmorphism",value:"glass"},{label:"Gradient Fill",value:"gradient"},{label:"Fire",value:"fire"},{label:"Frozen Ice",value:"frozen"},{label:"Rainbow",value:"rainbow"},{label:"Reflection",value:"mirror"}]},{label:"Retro & Stylized",options:[{label:"VHS Glitch",value:"vhs"},{label:"Retro 80s",value:"retro"},{label:"Cyberpunk",value:"cyberpunk"},{label:"Hologram",value:"hologram"},{label:"Comic Book",value:"comic"},{label:"Digital Glitch",value:"glitch-text"}]}],Zy=[{label:"Static",options:[{label:"None (Static)",value:"none"}]},{label:"Subtle",options:[{label:"Pulse",value:"pulse"},{label:"Breathe",value:"breathe"},{label:"Float",value:"float"},{label:"Sway",value:"sway"},{label:"Flicker",value:"flicker"}]},{label:"Energetic",options:[{label:"Bounce",value:"bounce"},{label:"Shake",value:"shake"},{label:"Wave",value:"wave"},{label:"Wobble",value:"wobble"},{label:"Jello",value:"jello"},{label:"Rubber Band",value:"rubberband"}]},{label:"Attention",options:[{label:"Heartbeat",value:"heartbeat"},{label:"Flash",value:"flash"},{label:"Tada!",value:"tada"},{label:"Swing",value:"swing"}]},{label:"Rotation",options:[{label:"Gentle Rotate",value:"rotate"},{label:"Spin",value:"spin"}]},{label:"Special",options:[{label:"Glitch",value:"glitch"},{label:"Typewriter",value:"typewriter"}]}],ev=[{label:"Basic",options:[{label:"Instant",value:"none"},{label:"Smooth Fade",value:"fade"}]},{label:"Slide & Move",options:[{label:"Slide In",value:"slide"},{label:"Float Up",value:"float"},{label:"Drop In",value:"drop"},{label:"Lightspeed",value:"lightspeed"},{label:"Roll In",value:"roll"}]},{label:"Scale & Transform",options:[{label:"Zoom In",value:"zoom"},{label:"Bounce In",value:"bounce"},{label:"Elastic Pop",value:"elastic"},{label:"Scale + Rotate",value:"scale-rotate"}]},{label:"Rotation",options:[{label:"Flip In",value:"flip"},{label:"Rotate In",value:"rotate-in"},{label:"Spiral In",value:"spiral"},{label:"Swing In",value:"swing"}]},{label:"Special",options:[{label:"Motion Blur",value:"blur"},{label:"Shatter In",value:"shatter"},{label:"Typewriter",value:"typewriter"}]}],tv=[{label:"Visual Transition",options:[{label:"None (Cut)",value:"none"},{label:"Crossfade",value:"crossfade"},{label:"Fade Through Black",value:"fade-to-black"}]}],Of=[{label:"Basic",options:[{label:"None",value:"none"},{label:"Simple Color",value:"color"},{label:"Scale Up",value:"scale"},{label:"Intense Glow",value:"glow"},{label:"Background Box",value:"background"}]},{label:"Karaoke Standard",options:[{label:"Default (Line/Fill)",value:"karaoke"},{label:"Smooth Transition",value:"karaoke-smooth"},{label:"Smooth Transition White",value:"karaoke-smooth-white"},{label:"Smooth Transition Plus",value:"karaoke-smooth-plus"},{label:"Fill Background",value:"karaoke-fill"},{label:"Outline Only",value:"karaoke-outline"},{label:"Underline",value:"karaoke-underline"},{label:"Shadow",value:"karaoke-shadow"},{label:"Gradient",value:"karaoke-gradient"}]},{label:"Animations",options:[{label:"Bounce",value:"karaoke-bounce"},{label:"Wave",value:"karaoke-wave"},{label:"Zoom In",value:"karaoke-scale"}]},{label:"Neon & Glow",options:[{label:"Neon White",value:"karaoke-neon"},{label:"Glow Blue",value:"karaoke-glow-blue"},{label:"Glow Pink",value:"karaoke-glow-pink"},{label:"Multi-Color Neon",value:"karaoke-neon-multi"},{label:"Soft Glow",value:"karaoke-soft-glow"}]},{label:"3D & Artistic",options:[{label:"3D Pop",value:"karaoke-3d"},{label:"Embossed",value:"karaoke-emboss"},{label:"Chrome Metallic",value:"karaoke-chrome"},{label:"Gold Foil",value:"karaoke-gold"},{label:"Glassmorphism",value:"karaoke-glass"},{label:"Gradient Fill",value:"karaoke-gradient-fill"},{label:"Fire",value:"karaoke-fire"},{label:"Frozen Ice",value:"karaoke-frozen"},{label:"Rainbow",value:"karaoke-rainbow"},{label:"Reflection",value:"karaoke-mirror"}]},{label:"Retro & Stylized",options:[{label:"VHS Glitch",value:"karaoke-vhs"},{label:"Retro 80s",value:"karaoke-retro"},{label:"Cyberpunk",value:"karaoke-cyberpunk"},{label:"Hologram",value:"karaoke-hologram"},{label:"Comic Book",value:"karaoke-comic"},{label:"Digital Glitch",value:"karaoke-glitch-text"}]},{label:"Detailed Animations",options:[{label:"Pulse",value:"karaoke-pulse"},{label:"Breathe",value:"karaoke-breathe"},{label:"Float",value:"karaoke-float"},{label:"Sway",value:"karaoke-sway"},{label:"Flicker",value:"karaoke-flicker"},{label:"Shake",value:"karaoke-shake"},{label:"Wobble",value:"karaoke-wobble"},{label:"Jello",value:"karaoke-jello"},{label:"Rubber Band",value:"karaoke-rubberband"},{label:"Heartbeat",value:"karaoke-heartbeat"},{label:"Flash",value:"karaoke-flash"},{label:"Tada!",value:"karaoke-tada"},{label:"Swing",value:"karaoke-swing"},{label:"Gentle Rotate",value:"karaoke-rotate"},{label:"Spin",value:"karaoke-spin"},{label:"Glitch Anim",value:"karaoke-glitch"},{label:"Typewriter",value:"karaoke-typewriter"}]},{label:"Motion & Transitions",options:[{label:"Smooth Fade",value:"karaoke-fade"},{label:"Slide In",value:"karaoke-slide"},{label:"Drop In",value:"karaoke-drop"},{label:"Lightspeed",value:"karaoke-lightspeed"},{label:"Roll In",value:"karaoke-roll"},{label:"Zoom In",value:"karaoke-zoom"},{label:"Elastic Pop",value:"karaoke-elastic"},{label:"Scale + Rotate",value:"karaoke-scale-rotate"},{label:"Flip In",value:"karaoke-flip"},{label:"Rotate In",value:"karaoke-rotate-in"},{label:"Spiral In",value:"karaoke-spiral"},{label:"Motion Blur",value:"karaoke-blur"},{label:"Shatter",value:"karaoke-shatter"}]},{label:"Solid Colors",options:[{label:"Blue",value:"karaoke-blue"},{label:"Purple",value:"karaoke-purple"},{label:"Green",value:"karaoke-green"},{label:"Pink",value:"karaoke-pink"},{label:"Cyan",value:"karaoke-cyan"}]},{label:"Shapes",options:[{label:"Pill Shape",value:"karaoke-pill"},{label:"Square Box",value:"karaoke-box"},{label:"Rounded Box",value:"karaoke-rounded"}]}],Rc=e=>{let t="",o="";return e.includes("blue")||e.includes("cyan")?(t=e.includes("cyan")?"#06b6d4":"#3b82f6",o=t):e.includes("purple")?(t="#a855f7",o=t):e.includes("green")?(t="#22c55e",o=t):e.includes("pink")?(t="#ec4899",o=t):(e==="karaoke-pill"||e==="karaoke-box"||e==="karaoke-rounded")&&(t="#fb923c",o="#fb923c"),t?{color:t,bg:o}:null},nv=[{label:"Source",options:[{label:"From Timeline",value:"timeline"},{label:"Metadata / Default",value:"custom"},{label:"Smart Gradient",value:"smart-gradient"},{label:"Gradient (Manual)",value:"gradient"},{label:"Solid Color",value:"color"},{label:"Custom Image",value:"image"},{label:"Custom Video (Loops)",value:"video"}]}],Vf=[{label:"Display Modes",options:[{label:"Show All (Default)",value:"all"},{label:"Prev & Next (Centered)",value:"previous-next"},{label:"Current & Next",value:"next-only"},{label:"Current Line Only",value:"active-only"}]}],sx=["none","upper","lower","title","sentence","invert"],iv=[{label:"Layout Styles",options:[{label:"Classic (Detailed)",value:"classic"},{label:"Modern + Cover",value:"modern_art"},{label:"Circle Cover",value:"circle_art"},{label:"Modern (Text Only)",value:"modern"},{label:"Boxed Cover",value:"box"},{label:"Minimal (Text Only)",value:"minimal"}]}],ov=[{label:"Layout Styles",options:[{label:"Classic (Row)",value:"classic"},{label:"Modern (Col)",value:"modern"},{label:"Minimal (Text Only)",value:"minimal"},{label:"Circle (Avatar)",value:"circle"},{label:"Logo Only",value:"logo"},{label:"Boxed",value:"box"}]}],t2=[{label:"Frame Rate",options:[{label:"24 FPS (Cinematic)",value:"24"},{label:"30 FPS (Standard)",value:"30"},{label:"60 FPS (Smooth)",value:"60"}]}],Ui=({value:e,onChange:t,groups:o})=>{const[l,s]=Z.useState(!1),[d,f]=Z.useState(e);Z.useEffect(()=>{l||f(e)},[e,l]);const g=b=>{for(const S of o){const _=S.options.find(T=>T.value===b);if(_)return _.label}return b},v=b=>{t(b)},m=()=>{l&&t(d),s(!1)},x=b=>{t(b),f(b),s(!1)};return u.jsxs("div",{className:"space-y-2 relative",onMouseLeave:m,children:[u.jsxs("button",{onClick:()=>s(!l),className:"w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-zinc-200 flex items-center justify-between focus:outline-none focus:ring-1 focus:ring-purple-500 hover:bg-zinc-700/50 transition-colors",title:l?"Close List":"Expand List",children:[u.jsx("span",{className:"truncate",children:g(e)}),u.jsx(rr,{size:14,className:`transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&u.jsx("div",{className:"bg-zinc-900/50 border border-white/10 rounded-lg overflow-hidden transition-all animate-in fade-in slide-in-from-top-2 z-10",children:o.map(b=>u.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5 last:border-0",children:[u.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:b.label}),u.jsx("div",{className:"grid grid-cols-1 gap-0.5",children:b.options.map(S=>u.jsx("button",{onMouseEnter:()=>v(S.value),onClick:()=>x(S.value),className:`w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors ${e===S.value?"bg-purple-600/50 text-white":"text-zinc-300 hover:bg-white/10"}`,children:S.label},S.value))})]},b.label))})]})},n2=(e,t,o)=>{if(e==="CustomFont"&&o)return o;for(const l of t){const s=l.options.find(d=>d.value===e);if(s)return s.label}return"Select Font"},vf=({value:e,onChange:t,customFontName:o,groups:l=fp})=>{const[s,d]=Z.useState(!1),[f,g]=Z.useState(e);Z.useEffect(()=>{s||g(e)},[e,s]);const v=b=>{t(b)},m=()=>{s&&t(f)},x=b=>{t(b),g(b),d(!1)};return u.jsxs("div",{className:"space-y-2",onMouseLeave:m,children:[u.jsxs("button",{onClick:()=>d(!s),className:"w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-zinc-200 flex items-center justify-between focus:outline-none focus:ring-1 focus:ring-purple-500 hover:bg-zinc-700/50 transition-colors",title:s?"Close Font List":"Expand Font List",children:[u.jsx("span",{className:"truncate",style:{fontFamily:e},children:n2(e,l,o)}),u.jsx(rr,{size:14,className:`transition-transform duration-200 ${s?"rotate-180":""}`})]}),s&&u.jsxs("div",{className:"bg-zinc-900/50 border border-white/10 rounded-lg overflow-hidden transition-all animate-in fade-in slide-in-from-top-2",children:[o&&u.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5",children:[u.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:"Custom"}),u.jsx("button",{onMouseEnter:()=>v("CustomFont"),onClick:()=>x("CustomFont"),className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${e==="CustomFont"?"bg-purple-600 text-white":"text-zinc-300 hover:bg-white/10"}`,children:u.jsxs("span",{style:{fontFamily:"CustomFont"},children:["✨ ",o]})})]}),l.map(b=>u.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5 last:border-0",children:[u.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:b.label}),u.jsx("div",{className:"grid grid-cols-1 gap-0.5",children:b.options.map(S=>u.jsx("button",{onMouseEnter:()=>v(S.value),onClick:()=>x(S.value),className:`w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors ${e===S.value?"bg-purple-600/50 text-white":"text-zinc-300 hover:bg-white/10"}`,title:S.label,children:u.jsx("span",{style:{fontFamily:S.value},children:S.label})},S.value))})]},b.label))]})]})},i2=Object.values(Yc).filter(e=>e.fontFamily).reduce((e,t)=>{if(!e.find(o=>o.value===t.fontFamily)){let o=t.fontFamily.split(",")[0].replace(/['"]/g,"");o.includes("ui-serif")?o="Classic Serif":o.includes("ui-monospace")?o="Monospace":o==="sans-serif"&&(o="Default Sans"),e.push({label:`${o} (Preset)`,value:t.fontFamily})}return e},[]),o2=[{label:"Visual Presets",options:i2},...fp],l2=({config:e,setConfig:t,preset:o,setPreset:l,onClose:s,isPlaylistMode:d,hasPlaylist:f,onRender:g,customFontName:v,onFontUpload:m,onClearCustomFont:x,resolution:b,setResolution:S,aspectRatio:_,setAspectRatio:T,renderCodec:F,setRenderCodec:z,supportedCodecs:G,renderQuality:Y,setRenderQuality:oe,renderFps:ce,setRenderFps:ve,renderEngine:ye,setRenderEngine:fe,ffmpegCodec:Je,setFfmpegCodec:ge,customChannelFontName:qe,onChannelFontUpload:Ve,onClearChannelCustomFont:Ke,customInfoFontName:nt,onInfoFontUpload:it,onClearInfoCustomFont:xt})=>{const{toast:K,confirm:ze}=ur(),[Le,ut]=Z.useState([]),Me=(R,Ue)=>{Le.includes(R)||ut(Xe=>[R,...Xe]);const We=R.includes(" ")?`'${R}'`:R;q(Ue,We)},L=ep.useMemo(()=>{const R=[],Ue=e.fontFamily?e.fontFamily.split(",")[0].replace(/['"]/g,""):"";return Ue&&R.push({label:"Matched",options:[{label:`Use Lyric Font (${Ue})`,value:e.fontFamily}]}),Le.length>0&&R.push({label:"Loaded Google Fonts",options:Le.map(We=>({label:We,value:We.includes(" ")?`'${We}'`:We}))}),[...R,...o2]},[Le,e.fontFamily]),X=Z.useRef(null),Ee=Z.useRef(null),ke=Z.useRef(null),He=Z.useRef(null),et=Z.useRef(null),Ae=Z.useRef(null),C=Z.useRef(null),se=Z.useRef(null),[ue,me]=Z.useState(!1),q=(R,Ue)=>{let We={...e,[R]:Ue};if(R==="highlightEffect"){const Ye=Rc(Ue);We.useCustomHighlightColors=!1,Ye?(We.highlightColor=Ye.color,We.highlightBackground=Ye.bg):(We.highlightColor="#fb923c",We.highlightBackground="#fb923c")}else if(R==="useCustomHighlightColors"&&Ue===!1){const Xe=e.highlightEffect,Ye=Rc(Xe);Ye?(We.highlightColor=Ye.color,We.highlightBackground=Ye.bg):(We.highlightColor="#fb923c",We.highlightBackground="#fb923c")}t(We)},Ie=R=>{l(R);const Ue=Yc[R];Ue&&t({...e,...{fontFamily:"sans-serif",fontSizeScale:1,fontColor:"#ffffff",fontWeight:"bold",fontStyle:"normal",textCase:"none",textAlign:"center",contentPosition:"center",textDecoration:"none",textEffect:"preset",textAnimation:"none",highlightEffect:"karaoke",highlightColor:"#fb923c",highlightBackground:"#fb923c",useCustomHighlightColors:!1,lyricStyleTarget:"active-only",transitionEffect:"none"},...Ue})},Re=R=>{const Ue=R.target.files?.[0];if(Ue){const We=new FileReader;We.onload=Xe=>{Xe.target?.result&&q("channelInfoImage",Xe.target.result)},We.readAsDataURL(Ue)}R.target.value=""},ee=R=>{const Ue=R.target.files?.[0];if(Ue){const We=new FileReader;We.onload=Xe=>{Xe.target?.result&&q("backgroundImage",Xe.target.result)},We.readAsDataURL(Ue)}R.target.value=""},be=R=>{const Ue=R.target.files?.[0];if(Ue){if(!Ue.type.startsWith("video/")){K.error("Please upload a valid video file.");return}const We=new FileReader;We.onload=Xe=>{Xe.target?.result&&q("backgroundVideo",Xe.target.result)},We.readAsDataURL(Ue)}R.target.value=""},$e=async()=>{await ze("Reset all render settings, including styles and watermark, to default values?","Reset All Settings")&&(t(Wy),l("default"),S("1080p"),T("16:9"),z("auto"),ve(30),oe("med"),fe("mediarecorder"),ge("h264"),et.current&&(et.current.value=""),Ae.current&&(Ae.current.value=""),C.current&&(C.current.value=""),x(),Ke&&Ke(),xt&&xt(),e.channelInfoFontFamily==="ChannelFont"&&ke.current&&(ke.current.value=""),e.infoFontFamily==="InfoFont"&&He.current&&(He.current.value=""),K.success("All settings have been reset to default."))},Oe=()=>{const R=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),Ue={...e,fontSizeScale:typeof e.fontSizeScale=="number"?Number(e.fontSizeScale.toFixed(6)):e.fontSizeScale,infoSizeScale:typeof e.infoSizeScale=="number"?Number(e.infoSizeScale.toFixed(6)):e.infoSizeScale,infoMarginScale:typeof e.infoMarginScale=="number"?Number(e.infoMarginScale.toFixed(6)):e.infoMarginScale,channelInfoSizeScale:typeof e.channelInfoSizeScale=="number"?Number(e.channelInfoSizeScale.toFixed(6)):e.channelInfoSizeScale,channelInfoMarginScale:typeof e.channelInfoMarginScale=="number"?Number(e.channelInfoMarginScale.toFixed(6)):e.channelInfoMarginScale,marginTopScale:typeof e.marginTopScale=="number"?Number(e.marginTopScale.toFixed(6)):e.marginTopScale,marginBottomScale:typeof e.marginBottomScale=="number"?Number(e.marginBottomScale.toFixed(6)):e.marginBottomScale,visualizationOpacity:typeof e.visualizationOpacity=="number"?Number(e.visualizationOpacity.toFixed(4)):e.visualizationOpacity,visualizationSensitivity:typeof e.visualizationSensitivity=="number"?Number(e.visualizationSensitivity.toFixed(4)):e.visualizationSensitivity,preset:o,resolution:b,aspectRatio:_,renderCodec:F,renderFps:ce,renderQuality:Y,renderEngine:ye,ffmpegCodec:Je,customFontName:v,customChannelFontName:qe,customInfoFontName:nt,channelInfoFontWeight:e.channelInfoFontWeight,channelInfoFontStyle:e.channelInfoFontStyle,infoFontWeight:e.infoFontWeight,infoFontStyle:e.infoFontStyle};Ue.backgroundSource!=="image"&&(Ue.backgroundImage=void 0),Ue.backgroundSource!=="video"&&(Ue.backgroundVideo=void 0),Ue.showChannelInfo||(Ue.channelInfoImage=void 0);try{const We=JSON.stringify(Ue,null,2),Xe=new Blob([We],{type:"application/json"}),Ye=URL.createObjectURL(Xe),ft=document.createElement("a");ft.setAttribute("href",Ye),ft.setAttribute("download",`render_settings_${R}.json`),document.body.appendChild(ft),ft.click(),ft.remove(),URL.revokeObjectURL(Ye)}catch(We){console.error("Export failed:",We),K.error("Failed to export settings.")}},ht=R=>{const Ue=R.target.files?.[0];if(!Ue)return;const We=new FileReader;We.onload=Xe=>{try{const Ye=JSON.parse(Xe.target?.result);if(Ye&&typeof Ye=="object"){const{resolution:ft,aspectRatio:jt,renderCodec:gt,renderFps:Et,renderQuality:A,renderEngine:W,ffmpegCodec:M,preset:D,customFontName:k,customChannelFontName:ne,customInfoFontName:B,channelInfoFontWeight:te,channelInfoFontStyle:j,infoFontWeight:we,infoFontStyle:E,...O}=Ye,V={...Wy,...O};if(te&&(V.channelInfoFontWeight=te),j&&(V.channelInfoFontStyle=j),we&&(V.infoFontWeight=we),E&&(V.infoFontStyle=E),["backgroundBlurStrength","fontSizeScale","infoMarginScale","infoSizeScale","channelInfoSizeScale","channelInfoMarginScale","visualTransitionDuration","lyricLineHeight","marginTopScale","marginBottomScale","visualizationOpacity","visualizationSensitivity","visualizationBarCount"].forEach(Se=>{V[Se]!==void 0&&(V[Se]=Number(V[Se]))}),V.useCustomHighlightColors!==void 0&&(V.useCustomHighlightColors=!!V.useCustomHighlightColors),V.useRealColorMedia!==void 0&&(V.useRealColorMedia=!!V.useRealColorMedia),V.showChannelInfo!==void 0&&(V.showChannelInfo=!!V.showChannelInfo),V.showIntro!==void 0&&(V.showIntro=!!V.showIntro),V.showTitle!==void 0&&(V.showTitle=!!V.showTitle),V.showArtist!==void 0&&(V.showArtist=!!V.showArtist),V.showCover!==void 0&&(V.showCover=!!V.showCover),V.showLyrics!==void 0&&(V.showLyrics=!!V.showLyrics),V.showVisualization!==void 0&&(V.showVisualization=!!V.showVisualization),V.enableGradientOverlay!==void 0&&(V.enableGradientOverlay=!!V.enableGradientOverlay),V.highlightEffect&&(!V.highlightColor||!V.highlightBackground)){const Se=Rc(V.highlightEffect);Se&&(V.highlightColor||(V.highlightColor=Se.color),V.highlightBackground||(V.highlightBackground=Se.bg))}const Be=(Se,he)=>he.some(dt=>dt.options.some(Dt=>Dt.value===Se));V.textEffect&&!Be(V.textEffect,Qy)&&(V.textEffect="shadow"),V.textAnimation&&!Be(V.textAnimation,Zy)&&(V.textAnimation="none"),V.transitionEffect&&!Be(V.transitionEffect,ev)&&(V.transitionEffect="none"),V.visualTransitionType&&!Be(V.visualTransitionType,tv)&&(V.visualTransitionType="none"),V.highlightEffect&&!Be(V.highlightEffect,Of)&&(V.highlightEffect="karaoke"),V.backgroundSource&&!Be(V.backgroundSource,nv)&&(V.backgroundSource="custom"),["current","playlist"].includes(V.renderMode)||(V.renderMode="current"),["left","center","right"].includes(V.textAlign)||(V.textAlign="center"),["top","center","bottom"].includes(V.contentPosition)||(V.contentPosition="center"),V.marginTopScale===void 0||isNaN(V.marginTopScale)?V.marginTopScale=1:V.marginTopScale=Math.max(0,Math.min(5,V.marginTopScale)),V.marginBottomScale===void 0||isNaN(V.marginBottomScale)?V.marginBottomScale=1:V.marginBottomScale=Math.max(0,Math.min(5,V.marginBottomScale)),V.lyricDisplayMode&&!Be(V.lyricDisplayMode,Vf)&&(V.lyricDisplayMode="all"),["normal","bold"].includes(V.fontWeight)||(V.fontWeight="bold"),["normal","italic"].includes(V.fontStyle)||(V.fontStyle="normal"),["none","underline","line-through"].includes(V.textDecoration)||(V.textDecoration="none"),sx.includes(V.textCase)||(V.textCase="none"),["auto","manual"].includes(V.introMode)||(V.introMode="auto"),V.lyricStyleTarget&&!["active-only","all"].includes(V.lyricStyleTarget)&&(V.lyricStyleTarget="active-only");const tt=["top-left","top-right","bottom-left","bottom-right","top-center","bottom-center"];V.infoPosition&&!tt.includes(V.infoPosition)&&(V.infoPosition="top-left"),V.infoStyle&&!Be(V.infoStyle,iv)&&(V.infoStyle="classic"),V.channelInfoPosition&&!tt.includes(V.channelInfoPosition)&&(V.channelInfoPosition="bottom-right"),V.channelInfoStyle&&!Be(V.channelInfoStyle,ov)&&(V.channelInfoStyle="classic");const St=["bars","wave","circular","particles","pulse-ring"];V.visualizationType&&!St.includes(V.visualizationType)&&(V.visualizationType="bars");const _e=["accent","gradient","custom","rainbow"];V.visualizationColorMode&&!_e.includes(V.visualizationColorMode)&&(V.visualizationColorMode="gradient");const Ot=["bottom","top","full","center"];V.visualizationPosition&&!Ot.includes(V.visualizationPosition)&&(V.visualizationPosition="bottom"),V.visualizationOpacity!==void 0&&(V.visualizationOpacity=Math.max(0,Math.min(1,V.visualizationOpacity))),V.visualizationSensitivity!==void 0&&(V.visualizationSensitivity=Math.max(.5,Math.min(3,V.visualizationSensitivity))),V.visualizationBarCount!==void 0&&(V.visualizationBarCount=Math.max(16,Math.min(128,Math.round(V.visualizationBarCount)))),t(V),ft&&S(ft),jt&&T(jt),gt&&z(gt),Et&&ve(Number(Et)),A&&oe(A),W&&fe(W),M&&ge(M),l(D||"custom"),k&&k!==v?K.success(`Settings loaded. Note: Config used font "${k}".`):ne||B?K.success(`Settings loaded. Custom fonts referenced: ${[ne,B].filter(Boolean).join(", ")}`):K.success("Settings loaded successfully!")}}catch(Ye){console.error(Ye),K.error("Failed to parse settings file. Please ensure it is a valid JSON file.")}},We.readAsText(Ue),R.target.value=""};return Z.useEffect(()=>{const R=Ue=>{X.current&&!X.current.contains(Ue.target)&&s()};return document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[s]),u.jsxs("div",{ref:X,onMouseDown:R=>R.stopPropagation(),className:"no-minimal-mode-toggle absolute right-0 top-0 bottom-0 w-full sm:w-80 bg-zinc-900/95 backdrop-blur-xl border-l border-white/10 z-50 flex flex-col shadow-2xl animate-in slide-in-from-right duration-300",children:[u.jsxs("div",{className:"h-14 border-b border-white/10 flex items-center justify-between px-3 md:px-4 bg-zinc-900/50",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Js,{size:18,className:"text-purple-400"}),u.jsx("h2",{className:"font-bold text-zinc-200",children:"Render Settings"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{ref:se,type:"file",name:"import-settings",id:"import-settings","aria-label":"Import Settings",accept:".json,.txt",className:"hidden",onChange:ht}),u.jsx("button",{onClick:()=>se.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",title:"Import Settings",children:u.jsx(ro,{size:16})}),u.jsx("button",{onClick:Oe,className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",title:"Export Settings",children:u.jsx(iS,{size:16})}),u.jsx("div",{className:"w-px h-4 bg-white/10 mx-1"}),u.jsx("button",{onClick:$e,className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",title:"Reset to Default",children:u.jsx(Cf,{size:16})}),u.jsx("button",{onClick:s,className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",children:u.jsx(Bi,{size:20})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4 space-y-6 custom-scrollbar",children:[u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Ef,{size:14})," Visual Preset"]}),u.jsx(Ui,{value:o,onChange:R=>Ie(R),groups:pp})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(nr,{size:14})," Render Scope"]}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsx("button",{onClick:()=>q("renderMode","current"),className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.renderMode==="current"?"bg-purple-600 border-purple-500 text-white shadow-[0_0_10px_rgba(147,51,234,0.3)]":"bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20"}`,children:"Current Song"}),u.jsx("button",{onClick:()=>q("renderMode","playlist"),disabled:!f,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.renderMode==="playlist"?"bg-purple-600 border-purple-500 text-white shadow-[0_0_10px_rgba(147,51,234,0.3)]":"bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20 disabled:opacity-30 disabled:cursor-not-allowed"}`,children:"All Playlist"})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(pg,{size:14})," Background Source"]}),u.jsx(Ui,{value:e.backgroundSource,onChange:R=>{R==="gradient"&&!e.backgroundGradient?(l("custom"),t({...e,backgroundSource:"gradient",backgroundGradient:"linear-gradient(to bottom right, #312e81, #581c87, #000000)"})):R==="smart-gradient"&&(!e.backgroundColor||e.backgroundColor==="#000000")?(l("custom"),t({...e,backgroundSource:"smart-gradient",backgroundColor:"#581c87"})):R==="color"&&!e.backgroundColor?(l("custom"),t({...e,backgroundSource:"color",backgroundColor:"#000000"})):q("backgroundSource",R)},groups:nv}),e.backgroundSource==="smart-gradient"&&u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"smart-bg-color","aria-label":"Smart Gradient Base Color",value:e.backgroundColor,onChange:R=>q("backgroundColor",R.target.value),className:"w-10 h-10 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[u.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Pick Base Color"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Hex:"}),u.jsx("input",{type:"text",name:"smart-bg-hex","aria-label":"Smart Gradient Base Color Hex",value:e.backgroundColor,onChange:R=>q("backgroundColor",R.target.value),className:"bg-transparent border-b border-zinc-700 focus:border-purple-500 text-[10px] text-zinc-300 font-mono focus:outline-none p-0 w-20 uppercase"})]})]})]}),e.backgroundSource==="color"&&u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"solid-bg-color","aria-label":"Background Color",value:e.backgroundColor,onChange:R=>q("backgroundColor",R.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("input",{type:"text",name:"solid-bg-hex","aria-label":"Background Color Hex",value:e.backgroundColor,onChange:R=>q("backgroundColor",R.target.value),className:"bg-transparent border-b border-zinc-700 text-xs text-zinc-300 font-mono flex-1 focus:outline-none focus:border-purple-500 uppercase py-1"})]}),e.backgroundSource==="gradient"&&u.jsx("input",{type:"text",name:"custom-gradient","aria-label":"Custom CSS Gradient",value:e.backgroundGradient,onChange:R=>q("backgroundGradient",R.target.value),placeholder:"linear-gradient(to bottom right, #312e81, #581c87, #000000)",className:"w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-xs font-mono text-zinc-300 focus:outline-none focus:ring-1 focus:ring-purple-500"}),e.backgroundSource==="image"&&u.jsx("div",{className:"space-y-3 animate-in slide-in-from-top-1 fade-in duration-200",children:u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("label",{htmlFor:"bg-image-upload",className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Custom Background Image"}),u.jsx("input",{ref:Ae,type:"file",name:"bg-image-upload",id:"bg-image-upload",accept:"image/*",onChange:ee,className:"hidden"}),e.backgroundImage?u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10",children:[u.jsx("div",{className:"w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5",children:u.jsx("img",{src:e.backgroundImage,alt:"Background",className:"w-full h-full object-cover"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-xs text-zinc-300 truncate",children:"Image Loaded"}),u.jsx("button",{onClick:()=>q("backgroundImage",void 0),className:"text-[10px] text-red-400 hover:text-red-300",children:"Remove"})]}),u.jsx("button",{onClick:()=>Ae.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white",children:u.jsx(Js,{size:14})})]}):u.jsxs("button",{onClick:()=>Ae.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors",children:[u.jsx(ro,{size:14}),u.jsx("span",{className:"text-xs",children:"Upload Background"})]})]})}),e.backgroundSource==="video"&&u.jsx("div",{className:"space-y-3 animate-in slide-in-from-top-1 fade-in duration-200",children:u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("label",{htmlFor:"bg-video-upload",className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Custom Background Video"}),u.jsx("input",{ref:C,type:"file",name:"bg-video-upload",id:"bg-video-upload",accept:"video/*",onChange:be,className:"hidden"}),e.backgroundVideo?u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10",children:[u.jsx("div",{className:"w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5",children:u.jsx("video",{src:e.backgroundVideo,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,loop:!0})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-xs text-zinc-300 truncate",children:"Video Loaded"}),u.jsx("button",{onClick:()=>q("backgroundVideo",void 0),className:"text-[10px] text-red-400 hover:text-red-300",children:"Remove"})]}),u.jsx("button",{onClick:()=>C.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white",children:u.jsx(Js,{size:14})})]}):u.jsxs("button",{onClick:()=>C.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors",children:[u.jsx(ro,{size:14}),u.jsx("span",{className:"text-xs",children:"Upload Video Loop"})]})]})})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(kS,{size:14})," Background Effects"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex bg-zinc-800 p-1 rounded-lg border border-white/5",children:[u.jsx("button",{onClick:()=>q("backgroundBlurStrength",0),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${e.backgroundBlurStrength===0?"bg-zinc-600 text-white shadow-sm":"text-zinc-400 hover:text-zinc-200 hover:bg-white/5"}`,children:"Sharp"}),u.jsx("button",{onClick:()=>q("backgroundBlurStrength",12),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${e.backgroundBlurStrength>0?"bg-purple-600 text-white shadow-sm":"text-zinc-400 hover:text-zinc-200 hover:bg-white/5"}`,children:"Blur"})]}),e.backgroundBlurStrength>0&&u.jsxs("div",{className:"space-y-1.5 animate-in slide-in-from-top-2 fade-in duration-200",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Blur Intensity"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[e.backgroundBlurStrength,"px"]})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"blur-strength","aria-label":"Blur Intensity",min:"1",max:"64",step:"1",value:e.backgroundBlurStrength,onChange:R=>q("backgroundBlurStrength",parseInt(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]})]}),u.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("label",{htmlFor:"real-color-media",className:"text-xs text-zinc-300 font-medium cursor-pointer",children:"Real Color Media Source"}),u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Disable dark dimming effect on background"})]}),u.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",id:"real-color-media",name:"real-color-media","aria-label":"Real Color Media",checked:e.useRealColorMedia??!1,onChange:R=>q("useRealColorMedia",R.target.checked),className:"sr-only peer"}),u.jsx("label",{htmlFor:"real-color-media",className:"w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer"})]})]}),u.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("label",{htmlFor:"gradient-overlay",className:"text-xs text-zinc-300 font-medium cursor-pointer",children:"Black Gradient Overlay"}),u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Fade bottom to top (readability)"})]}),u.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",id:"gradient-overlay",name:"gradient-overlay","aria-label":"Gradient Overlay",checked:e.enableGradientOverlay??!1,onChange:R=>q("enableGradientOverlay",R.target.checked),className:"sr-only peer"}),u.jsx("label",{htmlFor:"gradient-overlay",className:"w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer"})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsx("div",{className:"flex items-center justify-between",children:u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(F1,{size:14})," Audio Visualizer"]})}),u.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("label",{htmlFor:"show-visualization",className:"text-xs text-zinc-300 font-medium cursor-pointer",children:"Show Visualization"}),u.jsx("span",{className:"text-[10px] text-zinc-500",children:"Real-time audio reactive visuals"})]}),u.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",id:"show-visualization",name:"show-visualization","aria-label":"Show Visualization",checked:e.showVisualization??!1,onChange:R=>q("showVisualization",R.target.checked),className:"sr-only peer"}),u.jsx("label",{htmlFor:"show-visualization",className:"w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer"})]})]}),e.showVisualization&&u.jsxs("div",{className:"space-y-3 animate-in slide-in-from-top-2 fade-in duration-200",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Visualization Type"}),u.jsx(Ui,{value:e.visualizationType||"bars",onChange:R=>q("visualizationType",R),groups:[{label:"Minimalist",options:[{label:"Bars",value:"bars"},{label:"Waveform",value:"wave"}]},{label:"Dynamic",options:[{label:"Circular",value:"circular"},{label:"Particles",value:"particles"},{label:"Pulse Ring",value:"pulse-ring"}]}]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Color Mode"}),u.jsx("div",{className:"grid grid-cols-4 gap-1",children:["accent","gradient","rainbow","custom"].map(R=>u.jsx("button",{onClick:()=>q("visualizationColorMode",R),className:`px-2 py-1.5 rounded-md text-[10px] font-medium border transition-all capitalize ${e.visualizationColorMode===R?"bg-purple-600/40 border-purple-500/50 text-purple-200":"bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20"}`,children:R},R))})]}),e.visualizationColorMode==="custom"&&u.jsxs("div",{className:"grid grid-cols-2 gap-2 animate-in slide-in-from-top-2 fade-in duration-200",children:[u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"viz-color-1","aria-label":"Visualization Color 1",value:e.visualizationColor1||"#a855f7",onChange:R=>q("visualizationColor1",R.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("span",{className:"text-[10px] text-zinc-400",children:"Color 1"})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"viz-color-2","aria-label":"Visualization Color 2",value:e.visualizationColor2||"#6366f1",onChange:R=>q("visualizationColor2",R.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("span",{className:"text-[10px] text-zinc-400",children:"Color 2"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Position"}),u.jsx("div",{className:"grid grid-cols-4 gap-1",children:[{label:"Bottom",value:"bottom"},{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Full",value:"full"}].map(R=>u.jsx("button",{onClick:()=>q("visualizationPosition",R.value),className:`px-2 py-1.5 rounded-md text-[10px] font-medium border transition-all ${(e.visualizationPosition||"bottom")===R.value?"bg-purple-600/40 border-purple-500/50 text-purple-200":"bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20"}`,children:R.label},R.value))})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Opacity"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[((e.visualizationOpacity??.6)*100).toFixed(0),"%"]})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"viz-opacity","aria-label":"Visualization Opacity",min:"0.1",max:"1.0",step:"0.05",value:e.visualizationOpacity??.6,onChange:R=>q("visualizationOpacity",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Sensitivity"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.visualizationSensitivity??1.5).toFixed(1),"x"]})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"viz-sensitivity","aria-label":"Visualization Sensitivity",min:"0.5",max:"3.0",step:"0.1",value:e.visualizationSensitivity??1.5,onChange:R=>q("visualizationSensitivity",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]}),["bars","circular","pulse-ring"].includes(e.visualizationType||"bars")&&u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:["circular","pulse-ring"].includes(e.visualizationType||"bars")?"Segments":"Bar Count"}),u.jsx("span",{className:"text-[10px] text-zinc-400 font-mono",children:e.visualizationBarCount??48})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"viz-bar-count","aria-label":"Visualization Bar Count",min:"16",max:"128",step:"4",value:e.visualizationBarCount??48,onChange:R=>q("visualizationBarCount",parseInt(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Pc,{size:14})," Lyric Display Mode"]}),u.jsx(Ui,{value:e.lyricDisplayMode,onChange:R=>q("lyricDisplayMode",R),groups:Vf})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Ef,{size:14})," Highlight Effect"]}),u.jsx(Ui,{value:e.highlightEffect||"none",onChange:R=>{q("highlightEffect",R)},groups:Of}),e.highlightEffect&&e.highlightEffect!=="none"&&u.jsxs("div",{className:"mt-2 space-y-2 animate-in slide-in-from-top-2",children:[u.jsxs("button",{onClick:()=>q("useCustomHighlightColors",!e.useCustomHighlightColors),className:`w-full flex items-center justify-between p-2 rounded-lg border text-xs font-medium transition-all ${e.useCustomHighlightColors?"bg-purple-900/30 border-purple-500/50 text-purple-200":"bg-zinc-800 border-white/5 text-zinc-400 hover:bg-zinc-700"}`,children:[u.jsx("span",{children:"Custom Colors"}),u.jsx("div",{className:`w-8 h-4 rounded-full p-0.5 transition-colors ${e.useCustomHighlightColors?"bg-purple-500":"bg-zinc-600"}`,children:u.jsx("div",{className:`w-3 h-3 bg-white rounded-full shadow-sm transition-transform ${e.useCustomHighlightColors?"translate-x-4":"translate-x-0"}`})})]}),e.useCustomHighlightColors&&u.jsxs("div",{className:"grid grid-cols-2 gap-3 animate-in fade-in duration-200",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx("span",{className:"text-[10px] text-zinc-400 font-bold uppercase",children:"Text/Glow Color"}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"highlight-color","aria-label":"Highlight Text Color",value:e.highlightColor||"#fb923c",onChange:R=>q("highlightColor",R.target.value),className:"w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("input",{type:"text",name:"highlight-color-hex","aria-label":"Highlight Text Color Hex",value:e.highlightColor||"#fb923c",onChange:R=>q("highlightColor",R.target.value),className:"bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase"})]})]}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("span",{className:"text-[10px] text-zinc-400 font-bold uppercase",children:"Back/Shape Color"}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"highlight-bg-color","aria-label":"Highlight Background Color",value:e.highlightBackground||"#fb923c",onChange:R=>q("highlightBackground",R.target.value),className:"w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("input",{type:"text",name:"highlight-bg-hex","aria-label":"Highlight Background Color Hex",value:e.highlightBackground||"#fb923c",onChange:R=>q("highlightBackground",R.target.value),className:"bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase"})]})]})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(zS,{size:14})," Visible Elements"]}),u.jsx("div",{className:"space-y-2",children:[{label:"Lyrics / Subtitles",key:"showLyrics"},{label:"Song Title",key:"showTitle"},{label:"Artist Name",key:"showArtist"},{label:"Cover Art",key:"showCover"},{label:"Intro Info",key:"showIntro"}].map(R=>u.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-zinc-800/30 border border-white/5 hover:bg-zinc-800/50 cursor-pointer transition-colors",children:[u.jsx("label",{htmlFor:R.key,className:"text-xs text-zinc-300 cursor-pointer w-full",children:R.label}),u.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",id:R.key,name:R.key,"aria-label":R.label,checked:e[R.key],onChange:Ue=>q(R.key,Ue.target.checked),className:"sr-only peer"}),u.jsx("label",{htmlFor:R.key,className:"w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer"})]})]},R.key))})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Cl,{size:14})," Intro Settings"]}),u.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Intro Text"}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 rounded-md p-1 border border-white/5",children:[u.jsx("button",{onClick:()=>q("introMode","auto"),className:`px-2 py-1 text-[10px] font-medium rounded transition-all ${e.introMode==="auto"?"bg-zinc-600 text-white shadow-sm":"text-zinc-400 hover:text-zinc-200"}`,children:"Auto"}),u.jsx("button",{onClick:()=>q("introMode","manual"),className:`px-2 py-1 text-[10px] font-medium rounded transition-all ${e.introMode==="manual"?"bg-purple-600 text-white shadow-sm":"text-zinc-400 hover:text-zinc-200"}`,children:"Manual"})]})]}),e.introMode==="manual"&&u.jsxs("div",{className:"space-y-1 animate-in slide-in-from-top-1 fade-in duration-200",children:[u.jsx("label",{htmlFor:"intro-text",className:"text-[10px] text-zinc-500 uppercase font-bold",children:"Custom Intro Content"}),u.jsx("textarea",{id:"intro-text",name:"intro-text","aria-label":"Intro Text",value:e.introText,onChange:R=>q("introText",R.target.value),placeholder:"Enter intro text...",className:"w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500 min-h-[60px]"})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(pg,{size:14})," Channel Info / Watermark"]}),u.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between cursor-pointer",children:[u.jsx("label",{htmlFor:"show-channel-info",className:"text-xs text-zinc-300 font-medium cursor-pointer",children:"Show Channel Info"}),u.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[u.jsx("input",{type:"checkbox",id:"show-channel-info",name:"show-channel-info","aria-label":"Show Channel Info",checked:e.showChannelInfo??!1,onChange:R=>q("showChannelInfo",R.target.checked),className:"sr-only peer"}),u.jsx("label",{htmlFor:"show-channel-info",className:"w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer"})]})]}),e.showChannelInfo&&u.jsxs("div",{className:"space-y-3 animate-in slide-in-from-top-1 fade-in duration-200 pt-2 border-t border-white/5",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("label",{htmlFor:"channel-image-upload",className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Channel Logo / Image"}),u.jsx("input",{ref:et,type:"file",name:"channel-image-upload",id:"channel-image-upload",accept:"image/*",onChange:Re,className:"hidden"}),e.channelInfoImage?u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10",children:[u.jsx("div",{className:"w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5",children:u.jsx("img",{src:e.channelInfoImage,alt:"Channel",className:"w-full h-full object-cover"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-xs text-zinc-300 truncate",children:"Image Loaded"}),u.jsx("button",{onClick:()=>q("channelInfoImage",void 0),className:"text-[10px] text-red-400 hover:text-red-300",children:"Remove"})]}),u.jsx("button",{onClick:()=>et.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white",children:u.jsx(Js,{size:14})})]}):u.jsxs("button",{onClick:()=>et.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors",children:[u.jsx(ro,{size:14}),u.jsx("span",{className:"text-xs",children:"Upload Image"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("label",{htmlFor:"channel-info-text",className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Channel Name / SVG Code"}),u.jsx("textarea",{id:"channel-info-text",name:"channel-info-text","aria-label":"Channel Info Text",value:e.channelInfoText??"",onChange:R=>q("channelInfoText",R.target.value),placeholder:"Display Name or ...",className:"w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500 min-h-[40px] resize-y font-mono",rows:2})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Position"}),u.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u.jsx("button",{onClick:()=>q("channelInfoPosition","top-left"),className:`h-8 rounded-md border flex items-start justify-start p-1 transition-all ${e.channelInfoPosition==="top-left"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Top Left",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("channelInfoPosition","top-center"),className:`h-8 rounded-md border flex items-start justify-center p-1 transition-all ${e.channelInfoPosition==="top-center"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Top Center",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("channelInfoPosition","top-right"),className:`h-8 rounded-md border flex items-start justify-end p-1 transition-all ${e.channelInfoPosition==="top-right"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Top Right",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("channelInfoPosition","bottom-left"),className:`h-8 rounded-md border flex items-end justify-start p-1 transition-all ${e.channelInfoPosition==="bottom-left"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Bottom Left",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("channelInfoPosition","bottom-center"),className:`h-8 rounded-md border flex items-end justify-center p-1 transition-all ${e.channelInfoPosition==="bottom-center"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Bottom Center",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("channelInfoPosition","bottom-right"),className:`h-8 rounded-md border flex items-end justify-end p-1 transition-all ${e.channelInfoPosition==="bottom-right"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,title:"Bottom Right",children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),u.jsx(Ui,{value:e.channelInfoStyle||"classic",onChange:R=>q("channelInfoStyle",R),groups:ov})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Edge Margin"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.channelInfoMarginScale??1).toFixed(1),"x"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(tr,{size:12})}),u.jsx("input",{type:"range",name:"channel-margin","aria-label":"Channel Info Margin",min:"0.0",max:"5.0",step:"0.1",value:e.channelInfoMarginScale??1,onChange:R=>q("channelInfoMarginScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Size"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.channelInfoSizeScale??1).toFixed(1),"x"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(tr,{size:12})}),u.jsx("input",{type:"range",name:"channel-size","aria-label":"Channel Info Size",min:"0.5",max:"3.0",step:"0.1",value:e.channelInfoSizeScale??1,onChange:R=>q("channelInfoSizeScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),u.jsx(vf,{value:e.channelInfoFontFamily||"sans-serif",onChange:R=>q("channelInfoFontFamily",R),customFontName:qe||null,groups:L}),u.jsx(yf,{onApply:R=>Me(R,"channelInfoFontFamily"),placeholder:"Channel Font (e.g. Oswald)"}),u.jsx("input",{"aria-label":"Upload Channel Font",ref:ke,type:"file",name:"channel-font-upload",id:"channel-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:Ve,className:"hidden"}),qe?u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-2 py-1.5 mt-1",children:[u.jsx("span",{className:"text-[10px] text-purple-300 font-medium truncate flex-1",children:qe}),u.jsx("button",{onClick:()=>q("channelInfoFontFamily","ChannelFont"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${e.channelInfoFontFamily==="ChannelFont"?"bg-purple-600 text-white":"bg-zinc-700 text-zinc-300 hover:bg-zinc-600"}`,children:"Use"}),u.jsx("button",{onClick:Ke,className:"text-zinc-500 hover:text-red-400",children:u.jsx($a,{size:12})})]}):u.jsxs("button",{onClick:()=>ke.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/30 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-2 py-1.5 text-zinc-500 hover:text-purple-300 transition-colors mt-1",children:[u.jsx(ro,{size:10}),u.jsx("span",{className:"text-[10px]",children:"Upload Font"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Style"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>q("channelInfoFontWeight",e.channelInfoFontWeight==="bold"?"normal":"bold"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.channelInfoFontWeight==="bold"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Bold",children:u.jsx(ff,{size:14})}),u.jsx("button",{onClick:()=>q("channelInfoFontStyle",e.channelInfoFontStyle==="italic"?"normal":"italic"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.channelInfoFontStyle==="italic"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Italic",children:u.jsx(pf,{size:14})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Color"}),u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"channel-font-color","aria-label":"Channel Font Color",value:e.channelInfoFontColor||"#ffffff",onChange:R=>q("channelInfoFontColor",R.target.value),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("span",{className:"text-[10px] text-zinc-400 font-mono uppercase",children:e.channelInfoFontColor||"#ffffff"})]})]})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Oa,{size:14})," Song Info Design"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Position"}),u.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u.jsx("button",{onClick:()=>q("infoPosition","top-left"),className:`h-8 rounded-md border flex items-start justify-start p-1 transition-all ${e.infoPosition==="top-left"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("infoPosition","top-center"),className:`h-8 rounded-md border flex items-start justify-center p-1 transition-all ${e.infoPosition==="top-center"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("infoPosition","top-right"),className:`h-8 rounded-md border flex items-start justify-end p-1 transition-all ${e.infoPosition==="top-right"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("infoPosition","bottom-left"),className:`h-8 rounded-md border flex items-end justify-start p-1 transition-all ${e.infoPosition==="bottom-left"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("infoPosition","bottom-center"),className:`h-8 rounded-md border flex items-end justify-center p-1 transition-all ${e.infoPosition==="bottom-center"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),u.jsx("button",{onClick:()=>q("infoPosition","bottom-right"),className:`h-8 rounded-md border flex items-end justify-end p-1 transition-all ${e.infoPosition==="bottom-right"?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20"}`,children:u.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),u.jsx(Ui,{value:e.infoStyle||"classic",onChange:R=>q("infoStyle",R),groups:iv})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Edge Margin"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.infoMarginScale??1).toFixed(1),"x"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(tr,{size:12})}),u.jsx("input",{type:"range",name:"info-margin","aria-label":"Song Info Margin",min:"0.0",max:"5.0",step:"0.1",value:e.infoMarginScale??1,onChange:R=>q("infoMarginScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Info Size"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.infoSizeScale??1).toFixed(1),"x"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(Cl,{size:12})}),u.jsx("input",{type:"range",name:"info-size","aria-label":"Song Info Size",min:"0.5",max:"3.0",step:"0.1",value:e.infoSizeScale??1,onChange:R=>q("infoSizeScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),u.jsx(vf,{value:e.infoFontFamily||"sans-serif",onChange:R=>q("infoFontFamily",R),customFontName:nt||null,groups:L}),u.jsx(yf,{onApply:R=>Me(R,"infoFontFamily"),placeholder:"Info Font (e.g. Roboto)"}),u.jsx("input",{"aria-label":"Upload Info Font",ref:He,type:"file",name:"info-font-upload",id:"info-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:it,className:"hidden"}),nt?u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-2 py-1.5 mt-1",children:[u.jsx("span",{className:"text-[10px] text-purple-300 font-medium truncate flex-1",children:nt}),u.jsx("button",{onClick:()=>q("infoFontFamily","InfoFont"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${e.infoFontFamily==="InfoFont"?"bg-purple-600 text-white":"bg-zinc-700 text-zinc-300 hover:bg-zinc-600"}`,children:"Use"}),u.jsx("button",{onClick:xt,className:"text-zinc-500 hover:text-red-400",children:u.jsx($a,{size:12})})]}):u.jsxs("button",{onClick:()=>He.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/30 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-2 py-1.5 text-zinc-500 hover:text-purple-300 transition-colors mt-1",children:[u.jsx(ro,{size:10}),u.jsx("span",{className:"text-[10px]",children:"Upload Font"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Style"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>q("infoFontWeight",e.infoFontWeight==="bold"?"normal":"bold"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.infoFontWeight==="bold"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Bold",children:u.jsx(ff,{size:14})}),u.jsx("button",{onClick:()=>q("infoFontStyle",e.infoFontStyle==="italic"?"normal":"italic"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.infoFontStyle==="italic"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Italic",children:u.jsx(pf,{size:14})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Color"}),u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"info-font-color","aria-label":"Song Info Text Color",value:e.infoFontColor||"#ffffff",onChange:R=>q("infoFontColor",R.target.value),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("span",{className:"text-[10px] text-zinc-400 font-mono uppercase",children:e.infoFontColor||"#ffffff"})]})]})]})]}),u.jsxs("section",{className:"space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(Cl,{size:14})," Typography & Style"]}),u.jsxs("div",{className:"space-y-4 pt-1",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Alignment"}),u.jsx("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:["left","center","right"].map(R=>u.jsx("button",{onClick:()=>q("textAlign",R),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${e.textAlign===R?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:R},R))})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Vertical Position"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>q("contentPosition","top"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition==="top"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Top",children:u.jsx(V1,{size:14})}),u.jsx("button",{onClick:()=>q("contentPosition","center"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition==="center"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Center",children:u.jsx(fg,{size:14})}),u.jsx("button",{onClick:()=>q("contentPosition","bottom"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition==="bottom"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Bottom",children:u.jsx(j1,{size:14})})]}),u.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Top Margin"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.marginTopScale??1).toFixed(1),"x"]})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"margin-top","aria-label":"Lyrics Top Margin",min:"0.0",max:"5.0",step:"0.1",value:e.marginTopScale??1,onChange:R=>q("marginTopScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Bottom Margin"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.marginBottomScale??1).toFixed(1),"x"]})]}),u.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:u.jsx("input",{type:"range",name:"margin-bottom","aria-label":"Lyrics Bottom Margin",min:"0.0",max:"5.0",step:"0.1",value:e.marginBottomScale??1,onChange:R=>q("marginBottomScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>q("fontWeight",e.fontWeight==="bold"?"normal":"bold"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.fontWeight==="bold"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Bold",children:u.jsx(ff,{size:14})}),u.jsx("button",{onClick:()=>q("fontStyle",e.fontStyle==="italic"?"normal":"italic"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.fontStyle==="italic"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Italic",children:u.jsx(pf,{size:14})}),u.jsx("button",{onClick:()=>q("textDecoration",e.textDecoration==="underline"?"none":"underline"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.textDecoration==="underline"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Underline",children:u.jsx(fw,{size:14})}),u.jsx("button",{onClick:()=>q("textDecoration",e.textDecoration==="line-through"?"none":"line-through"),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.textDecoration==="line-through"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,title:"Strikethrough",children:u.jsx(aw,{size:14})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Apply Style To"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>q("lyricStyleTarget","active-only"),className:`flex-1 py-1.5 rounded-md text-[10px] transition-all ${e.lyricStyleTarget==="active-only"||!e.lyricStyleTarget?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,title:"Apply style to current line only (others normal)",children:"Current Only"}),u.jsx("button",{onClick:()=>q("lyricStyleTarget","all"),className:`flex-1 py-1.5 rounded-md text-[10px] transition-all ${e.lyricStyleTarget==="all"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,title:"Apply style to all lines (previous, current, next)",children:"All Lines"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Case"}),u.jsxs("div",{className:"grid grid-cols-3 gap-1 bg-zinc-800 rounded-lg p-1",children:[u.jsx("button",{onClick:()=>q("textCase","none"),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase==="none"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Normal"}),u.jsx("button",{onClick:()=>q("textCase","upper"),className:`py-1.5 rounded-md text-[10px] uppercase transition-all ${e.textCase==="upper"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Upper"}),u.jsx("button",{onClick:()=>q("textCase","lower"),className:`py-1.5 rounded-md text-[10px] lowercase transition-all ${e.textCase==="lower"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Lower"}),u.jsx("button",{onClick:()=>q("textCase","title"),className:`py-1.5 rounded-md text-[10px] capitalize transition-all ${e.textCase==="title"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Title Case"}),u.jsx("button",{onClick:()=>q("textCase","sentence"),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase==="sentence"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Sentence case"}),u.jsx("button",{onClick:()=>q("textCase","invert"),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase==="invert"?"bg-zinc-600 text-white shadow-sm font-bold":"text-zinc-500 hover:text-zinc-300"}`,children:"Invert Case"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),u.jsx(vf,{value:e.fontFamily,onChange:R=>q("fontFamily",R),customFontName:v,groups:L}),u.jsx(yf,{onApply:R=>Me(R,"fontFamily"),placeholder:"Lyrics Font (e.g. Pacifico)"})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("label",{htmlFor:"main-font-upload",className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Custom Font File"}),u.jsx("input",{ref:Ee,type:"file",name:"main-font-upload",id:"main-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:m,className:"hidden"}),v?u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-3 py-2",children:[u.jsx(Cl,{size:14,className:"text-purple-400 shrink-0"}),u.jsx("span",{className:"text-xs text-purple-300 font-medium truncate flex-1",children:v}),u.jsx("button",{onClick:()=>{q("fontFamily","CustomFont")},className:`text-[10px] px-2 py-1 rounded transition-colors ${e.fontFamily==="CustomFont"?"bg-purple-600 text-white":"bg-zinc-700 text-zinc-300 hover:bg-zinc-600"}`,children:e.fontFamily==="CustomFont"?"Active":"Use"}),u.jsx("button",{onClick:x,className:"p-1 text-zinc-500 hover:text-red-400 transition-colors",title:"Remove custom font",children:u.jsx($a,{size:14})})]}):u.jsxs("button",{onClick:()=>Ee.current?.click(),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-2.5 text-zinc-400 hover:text-purple-300 transition-colors",children:[u.jsx(ro,{size:14}),u.jsx("span",{className:"text-xs",children:"Upload Custom Font (.ttf, .otf, .woff2)"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Size"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.fontSizeScale*100).toFixed(0),"%"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(Cl,{size:12})}),u.jsx("input",{type:"range",name:"font-size","aria-label":"Font Size",min:"0.1",max:"3.0",step:"0.1",value:e.fontSizeScale,onChange:R=>q("fontSizeScale",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"}),u.jsx("span",{className:"text-zinc-300",children:u.jsx(Cl,{size:16})})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Current Line Height"}),u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.lyricLineHeight||1.3).toFixed(1),"x"]})]}),u.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[u.jsx("span",{className:"text-zinc-500",children:u.jsx(fg,{size:12})}),u.jsx("input",{type:"range",name:"line-height","aria-label":"Line Height",min:"1.0",max:"3.0",step:"0.1",value:e.lyricLineHeight||1.3,onChange:R=>q("lyricLineHeight",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})]})]}),e.fontFamily!=="sans-serif"&&e.fontFamily!=="CustomFont"&&u.jsx("div",{className:"text-[10px] text-zinc-500 bg-zinc-800/30 p-2 rounded border border-white/5",children:"Some presets like Gothic, Metal, or Tech use specific fonts. Changing Font Family here might override that look."}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Color"}),u.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[u.jsx("input",{type:"color",name:"main-font-color","aria-label":"Main Font Color",value:e.fontColor,onChange:R=>q("fontColor",R.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),u.jsx("input",{type:"text",name:"main-font-hex","aria-label":"Main Font Color Hex",value:e.fontColor,onChange:R=>q("fontColor",R.target.value),className:"bg-transparent border-b border-zinc-700 text-xs text-zinc-300 font-mono flex-1 focus:outline-none focus:border-purple-500 uppercase py-1"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Effect"}),u.jsx(Ui,{value:e.textEffect,onChange:R=>q("textEffect",R),groups:Qy})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Animation"}),u.jsx(Ui,{value:e.textAnimation,onChange:R=>q("textAnimation",R),groups:Zy})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Transition"}),u.jsx(Ui,{value:e.transitionEffect,onChange:R=>q("transitionEffect",R),groups:ev})]}),u.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-white/5",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Visual Transition (Images/Video)"}),e.visualTransitionDuration&&u.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[e.visualTransitionDuration.toFixed(1),"s"]})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(Ui,{value:e.visualTransitionType||"none",onChange:R=>q("visualTransitionType",R),groups:tv})}),e.visualTransitionType&&e.visualTransitionType!=="none"&&u.jsx("div",{className:"w-1/3 flex items-center bg-zinc-800 border border-white/10 rounded-lg px-2",children:u.jsx("input",{type:"range",name:"transition-duration","aria-label":"Transition Duration",min:"0.1",max:"5.0",step:"0.1",value:e.visualTransitionDuration||1,onChange:R=>q("visualTransitionDuration",parseFloat(R.target.value)),className:"w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all"})})]})]}),u.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-3",children:[u.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[u.jsx(nr,{size:14})," Output Settings"]}),u.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Resolution"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:[u.jsx("button",{onClick:()=>S("720p"),className:`flex-1 py-1 px-2 rounded-md text-[10px] font-bold transition-all ${b==="720p"?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:"720p"}),u.jsx("button",{onClick:()=>S("1080p"),className:`flex-1 py-1 px-2 rounded-md text-[10px] font-bold transition-all ${b==="1080p"?"bg-purple-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:"1080p"})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"FPS"}),u.jsx(Ui,{value:String(ce),onChange:R=>ve(parseInt(R)),groups:t2})]})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Aspect Ratio"}),u.jsx("div",{className:"grid grid-cols-4 gap-1",children:["16:9","9:16","1:1","4:5","3:4","4:3","2:3","3:2","1:2","2:1","20:9","21:9"].map(R=>u.jsx("button",{onClick:()=>T(R),className:`py-1.5 rounded-md text-[10px] font-mono transition-all border ${_===R?"bg-purple-600 border-purple-500 text-white":"bg-zinc-800 border-white/5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300"}`,children:R},R))})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Render Engine"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[u.jsx("button",{onClick:()=>fe("mediarecorder"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${ye==="mediarecorder"?"bg-purple-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,title:"Uses browser's MediaRecorder API. Renders in realtime while playing audio.",children:"Realtime"}),u.jsx("button",{onClick:()=>fe("webcodecs"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${ye==="webcodecs"?"bg-blue-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,title:"Uses WebCodecs API. Hardware accelerated rendering. Fastest option.",children:"WebCodecs 🚀"}),u.jsx("button",{onClick:()=>fe("ffmpeg"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${ye==="ffmpeg"?"bg-orange-500 text-white":"text-zinc-500 hover:text-zinc-300"}`,title:"Uses FFmpeg WASM. Frame-by-frame rendering with professional codecs.",children:"FFmpeg ⚡"})]}),u.jsx("p",{className:"text-[9px] text-zinc-600 ml-1 leading-tight",children:ye==="mediarecorder"?"Realtime recording. Fast but quality depends on browser.":ye==="webcodecs"?"Hardware accelerated (GPU). Very fast export with simple MP4.":"Software rendering. High compatiblity but slower."})]}),ye==="mediarecorder"&&u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Video Codec"}),u.jsx(Ui,{value:F,onChange:R=>z(R),groups:[{label:"Format",options:[{label:"Auto Select (Best)",value:"auto"},...G]}]})]}),ye==="ffmpeg"&&u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"FFmpeg Codec"}),u.jsx("div",{className:"grid grid-cols-2 gap-1",children:[{label:"H.264",value:"h264",desc:"Best Compatibility"},{label:"H.265",value:"h265",desc:"Higher Quality"}].map(R=>u.jsxs("button",{onClick:()=>ge(R.value),className:`py-2 px-2 rounded-md text-[10px] font-medium transition-all border text-left ${Je===R.value?"bg-orange-500 border-orange-400 text-white":"bg-zinc-800 border-white/5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200"}`,title:R.desc,children:[u.jsx("div",{className:"font-bold",children:R.label}),u.jsx("div",{className:"text-[8px] opacity-75",children:R.desc})]},R.value))})]}),ye==="webcodecs"&&u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Video Codec"}),u.jsx("div",{className:"p-2 bg-zinc-800/50 rounded border border-white/5 text-[10px] text-zinc-400",children:"H.264 / AAC (Hardware Accelerated)"})]}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Render Quality (Bitrate)"}),u.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:[u.jsx("button",{onClick:()=>oe("low"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${Y==="low"?"bg-zinc-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"Low"}),u.jsx("button",{onClick:()=>oe("med"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${Y==="med"?"bg-zinc-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"Medium"}),u.jsx("button",{onClick:()=>oe("high"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${Y==="high"?"bg-purple-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"High"})]})]})]}),u.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[u.jsxs("p",{className:"text-[10px] text-zinc-500 italic leading-relaxed",children:[u.jsx("span",{className:"text-purple-400 font-bold",children:"*Tip:"})," You can backup your current configuration using the ",u.jsx("span",{className:"text-zinc-300",children:"Export"})," button above."]}),u.jsxs("button",{onClick:()=>me(!0),className:"w-full flex items-center justify-center gap-2 bg-zinc-800/30 border border-white/5 hover:bg-zinc-800 hover:border-white/20 text-xs text-zinc-400 hover:text-white py-2 rounded-lg transition-all",children:[u.jsx(Bc,{size:14})," View Keyboard Shortcuts"]})]})]}),ue&&u.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-blur-sm animate-in fade-in cursor-default",onClick:()=>me(!1),children:u.jsxs("div",{className:"no-minimal-mode-toggle bg-zinc-900 border border-white/10 rounded-xl shadow-2xl w-[480px] max-w-[90vw] overflow-hidden flex flex-col max-h-[85vh] animate-in slide-in-from-bottom-5",onClick:R=>R.stopPropagation(),children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/10 bg-zinc-800/50",children:[u.jsxs("h3",{className:"font-bold text-white flex items-center gap-2",children:[u.jsx(Bc,{size:18,className:"text-purple-400"}),"Keyboard Shortcuts"]}),u.jsx("button",{onClick:()=>me(!1),className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",children:u.jsx(Bi,{size:18})})]}),u.jsxs("div",{className:"p-4 overflow-y-auto space-y-6 custom-scrollbar",children:[u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Media Controls"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Play / Pause"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"Space"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Stop"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"S"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Next Song"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"N"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Prev Song"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"B"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Repeat Mode"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"R"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Mute / Unmute"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"M"})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"View & Appearance"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Fullscreen"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"F"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Playlist Mode"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"L"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Timeline / Edit"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"T"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Info"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"I"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Player"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"P"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Auto-Hide HUD"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"H"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Minimal Mode"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"O"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Lyric Display Mode"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"G"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Text Case"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"C"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Render Settings"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"D"})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Visual Effects"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Highlight On/Off"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"X"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Next Highlight Effect"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"Z"})]})]})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Adjustment & Export"}),u.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Presets"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"J"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Font Size"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"+ / -"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Seek +/- 5s"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"Arrows"})]}),u.jsxs("div",{className:"flex justify-between items-center",children:[u.jsx("span",{className:"text-zinc-300",children:"Scroll Lyrics"})," ",u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[10px] border border-white/10",children:"Up/Down"})]}),u.jsxs("div",{className:"flex justify-between col-span-2 items-center bg-purple-900/20 p-2 rounded-lg border border-purple-500/20",children:[u.jsx("span",{className:"text-purple-300 font-medium",children:"Quick Export"}),u.jsxs("div",{className:"flex gap-1 items-center",children:[u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-300 font-mono text-[10px] border border-white/10",children:"Ctrl"}),u.jsx("span",{className:"text-zinc-500 text-[10px]",children:"+"}),u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-300 font-mono text-[10px] border border-white/10",children:"Shift"}),u.jsx("span",{className:"text-zinc-500 text-[10px]",children:"+"}),u.jsx("kbd",{className:"bg-zinc-800 px-1.5 py-0.5 rounded text-zinc-300 font-mono text-[10px] border border-white/10",children:"E"})]})]})]})]})]}),u.jsx("div",{className:"p-4 border-t border-white/10 bg-zinc-900/50 text-center",children:u.jsxs("p",{className:"text-[10px] text-zinc-500",children:["Press ",u.jsx("kbd",{className:"font-mono text-zinc-400",children:"Esc"})," to close"]})})]})})]}),u.jsxs("div",{className:"p-4 border-t border-white/10 bg-zinc-900/50 space-y-3",children:[u.jsxs("button",{onClick:g,className:"w-full py-2.5 rounded-lg bg-purple-600 hover:bg-purple-500 text-white font-bold text-sm shadow-lg shadow-purple-500/20 active:scale-95 transition-all flex items-center justify-center gap-2",children:[u.jsx(nr,{size:16})," Start Render"]}),u.jsx("p",{className:"text-[10px] text-zinc-500 text-center leading-relaxed italic",children:"These settings will be applied to the final video. Ensure all sources are loaded correctly."})]})]})};function lv(e){const t=e.replace("#","");return[parseInt(t.substring(0,2),16)||0,parseInt(t.substring(2,4),16)||0,parseInt(t.substring(4,6),16)||0]}function a2(e,t,o,l,s,d,f,g){const v=t>1?e/(t-1):0;switch(l){case"rainbow":return`hsla(${(v*360+g*.05)%360}, 80%, ${55+o*15}%, ${f})`;case"accent":return`hsla(270, 80%, ${50+o*20}%, ${f})`;case"custom":{const[m,x,b]=lv(s),[S,_,T]=lv(d),F=Math.round(m+(S-m)*v),z=Math.round(x+(_-x)*v),G=Math.round(b+(T-b)*v);return`rgba(${F}, ${z}, ${G}, ${f})`}default:{const m=260+v*60,x=50+o*15;return`hsla(${m}, 75%, ${x}%, ${f})`}}}function rx(e){return{type:e.visualizationType||"bars",colorMode:e.visualizationColorMode||"gradient",color1:e.visualizationColor1||"#a855f7",color2:e.visualizationColor2||"#6366f1",opacity:e.visualizationOpacity??.6,position:e.visualizationPosition||"bottom",sensitivity:e.visualizationSensitivity??1.5,barCount:e.visualizationBarCount??48}}function cx(e,t,o,l,s,d,f){const{type:g,sensitivity:v,barCount:m}=d,b=s2(t)/255;e.save();const S=r2(d.position,l,s);switch(e.beginPath(),e.rect(S.x,S.y,S.w,S.h),e.clip(),g){case"bars":c2(e,t,S,d,f);break;case"wave":u2(e,o||t,S,d,f);break;case"circular":d2(e,t,S,d,f,b);break;case"particles":f2(e,t,S,d,f);break;case"pulse-ring":p2(e,t,o,S,d,f,b);break}e.restore()}function s2(e){let t=0;for(let o=0;o{const oe=Math.sin(Y*127.1+Y*311.7)*43758.5453;return oe-Math.floor(oe)},F=Math.min(80,Math.floor(m*40+10));for(let Y=0;Yo.x+o.w||ito.y+o.h)continue;const xt=(1+fe*3)*(1-ge*.6),K=(1-ge)*fe*l.opacity*.6;K<.03||(e.globalAlpha=K,e.fillStyle=co(l,ye/t.length,1,fe,s),e.beginPath(),e.arc(nt,it,xt,0,Math.PI*2),e.fill())}const G=Math.min(15,Math.floor(b*8+3));for(let Y=0;Yo.x+o.w||geo.y+o.h)continue;const qe=1+Math.sin(f*3+ve*10)*.3*b,Ve=(3+ve*5)*qe,Ke=.08+b*.15;e.globalAlpha=Ke*l.opacity;const nt=e.createRadialGradient(Je,ge,0,Je,ge,Ve),it=co(l,oe,1,.7,s);nt.addColorStop(0,it),nt.addColorStop(.5,it.replace(/[\d.]+\)$/,`${.3})`)),nt.addColorStop(1,it.replace(/[\d.]+\)$/,"0)")),e.fillStyle=nt,e.beginPath(),e.arc(Je,ge,Ve,0,Math.PI*2),e.fill()}if(m>.5){const Y=f*.8%1,oe=Y*Math.min(o.w,o.h)*.45,ce=(1-Y)*(m-.5)*l.opacity*.5;if(ce>.03){const ve=o.x+o.w/2,ye=o.y+o.h/2;e.globalAlpha=ce,e.beginPath(),e.arc(ve,ye,oe,0,Math.PI*2),e.strokeStyle=co(l,0,1,m,s),e.lineWidth=2+(1-Y)*3,e.stroke()}}e.globalAlpha=1}function p2(e,t,o,l,s,d,f){const g=l.x+l.w/2,v=l.y+l.h/2,m=Math.min(l.w,l.h)*.4,x=3,b=d*.001;for(let S=0;S=0&&b=0&&b{}),Wi=null),zc=null,Ws=null,Qs=null}catch(e){console.warn("AudioVisualizer: disconnect failed",e)}}const m2=({audioElement:e,config:t,isPlaying:o})=>{const l=Z.useRef(null),s=Z.useRef(0),d=Z.useRef(0);return Z.useEffect(()=>{if(e&&!(zc===e&&Fi&&Wi)){try{if(Wi||(Wi=new(window.AudioContext||window.webkitAudioContext)),Fi=Wi.createAnalyser(),Fi.fftSize=512,Fi.smoothingTimeConstant=.8,zc!==e)try{Ja=Wi.createMediaElementSource(e)}catch{}Ja&&(Ja.connect(Fi),Fi.connect(Wi.destination));const f=Fi.frequencyBinCount;Ws=new Uint8Array(f),Qs=new Uint8Array(f),zc=e}catch(f){console.warn("AudioVisualizer: Failed to connect audio context",f)}return()=>{}}},[e]),Z.useEffect(()=>{o&&Wi&&Wi.state==="suspended"&&Wi.resume()},[o]),Z.useEffect(()=>{if(!t.showVisualization)return;const f=l.current;if(!f)return;const g=f.getContext("2d",{alpha:!0});if(!g)return;let v=!0;const m=x=>{if(!v||(s.current=requestAnimationFrame(m),x-d.current<33))return;d.current=x;const b=f.getBoundingClientRect(),S=Math.min(window.devicePixelRatio||1,2),_=Math.round(b.width*S),T=Math.round(b.height*S);(f.width!==_||f.height!==T)&&(f.width=_,f.height=T);const F=b.width,z=b.height;if(g.setTransform(S,0,0,S,0,0),g.clearRect(0,0,F,z),!Fi||!Ws||!Qs)return;Fi.getByteFrequencyData(Ws);const G=rx(t),Y=G.type==="wave"||G.type==="pulse-ring";Y&&Fi.getByteTimeDomainData(Qs),cx(g,Ws,Y?Qs:null,F,z,G,x)};return s.current=requestAnimationFrame(m),()=>{v=!1,cancelAnimationFrame(s.current)}},[t.showVisualization,t.visualizationType,t.visualizationColorMode,t.visualizationColor1,t.visualizationColor2,t.visualizationOpacity,t.visualizationPosition,t.visualizationSensitivity,t.visualizationBarCount]),t.showVisualization?u.jsx("canvas",{ref:l,className:"absolute inset-0 w-full h-full pointer-events-none z-[5]"}):null},su=(e,t,o,l,s,d,f,g,v,m,x,b,S,_,T,F=!0,z=!0,G,Y)=>{const oe=C=>{const se=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(C);return se?{r:parseInt(se[1],16),g:parseInt(se[2],16),b:parseInt(se[3],16)}:{r:255,g:255,b:255}},ce=C=>{let se=0,ue=0;if(C instanceof ImageBitmap?(se=C.width,ue=C.height):C instanceof HTMLVideoElement?(se=C.videoWidth,ue=C.videoHeight):(se=C.width,ue=C.height),se&&ue){const me=Math.max(t/se,o/ue),q=t/2-se/2*me,Ie=o/2-ue/2*me;e.drawImage(C,q,Ie,se*me,ue*me)}},ve=(C,se,ue)=>{if(se.includes(` -`))return se.split(` -`).flatMap(ee=>ve(C,ee,ue));const me=se.split(" ");let q=[],Ie=me[0]||"";for(let ee=1;ee{if(q==="vhs"&&C instanceof CanvasRenderingContext2D)C.save(),C.globalCompositeOperation="screen",C.fillStyle="#ff0000",C.fillText(se,ue-2,me),C.fillStyle="#00ff00",C.fillText(se,ue,me),C.fillStyle="#0000ff",C.fillText(se,ue+2,me),C.restore();else if(q==="3d"){const Re=C.fillStyle;C.fillStyle="rgba(0,0,0,0.5)";for(let ee=1;ee<=4;ee++)C.fillText(se,ue+ee,me+ee);C.fillStyle=Re,C.fillText(se,ue,me)}else if(q==="neon"){const Re=C.fillStyle;C.shadowColor=Re,C.shadowBlur=20,C.fillText(se,ue,me),C.shadowBlur=40,C.fillText(se,ue,me)}else if(q==="outline")C.strokeText(se,ue,me),C.fillText(se,ue,me);else if(q==="gradient"){const Re=C.createLinearGradient(ue,me-20,ue,me+20);Re.addColorStop(0,C.fillStyle),Re.addColorStop(1,"#ffffff"),C.fillStyle=Re,C.fillText(se,ue,me)}else if(q==="fire")C.save(),C.shadowBlur=5,C.shadowColor="#ff0000",C.fillStyle="#ff4500",C.fillText(se,ue,me),C.shadowBlur=2,C.shadowColor="#ffff00",C.fillStyle="#ffcc00",C.fillText(se,ue+1,me-1),C.restore();else if(q==="emboss")C.fillStyle="rgba(255,255,255,0.7)",C.fillText(se,ue-1,me-1),C.fillStyle="rgba(0,0,0,0.7)",C.fillText(se,ue+1,me+1),C.fillStyle="rgba(128,128,128,0.5)",C.fillText(se,ue,me);else if(q==="mirror")C.fillText(se,ue,me),C.save(),C.translate(ue,me),C.scale(1,-1),C.translate(-ue,-me),C.globalAlpha*=.2,C.fillText(se,ue,me-40),C.restore();else if(q==="neon-multi")C.fillStyle,C.shadowBlur=10,C.shadowColor="#fff",C.fillText(se,ue,me),C.shadowBlur=20,C.shadowColor="#ff00de",C.fillText(se,ue,me),C.shadowBlur=35,C.shadowColor="#00ffff",C.fillText(se,ue,me);else if(q==="gold"){const Re=C.createLinearGradient(ue,me-20,ue,me+20);Re.addColorStop(0,"#d4af37"),Re.addColorStop(1,"#C5A028"),C.fillStyle=Re,C.fillText(se,ue,me)}else if(q==="chrome"){const Re=C.createLinearGradient(ue,me-20,ue,me+20);Re.addColorStop(0,"#ebebeb"),Re.addColorStop(.5,"#616161"),Re.addColorStop(.51,"#ebebeb"),Re.addColorStop(1,"#ebebeb"),C.fillStyle=Re,C.fillText(se,ue,me)}else if(q==="frozen")C.shadowColor="#03A9F4",C.shadowBlur=20,C.fillStyle="#ffffff",C.fillText(se,ue,me);else if(q==="rainbow"){const Re=C.createLinearGradient(ue-100,me,ue+100,me);Re.addColorStop(0,"violet"),Re.addColorStop(.16,"indigo"),Re.addColorStop(.32,"blue"),Re.addColorStop(.48,"green"),Re.addColorStop(.64,"yellow"),Re.addColorStop(.8,"orange"),Re.addColorStop(1,"red"),C.fillStyle=Re,C.fillText(se,ue,me)}else if(q==="retro")C.fillStyle="#ff00ff",C.shadowColor="#00ffff",C.shadowBlur=0,C.shadowOffsetX=4,C.shadowOffsetY=4,C.fillText(se,ue,me);else if(q==="cyberpunk")C.save(),C.fillStyle="#05d9e8",C.fillText(se,ue-1,me-1),C.restore(),C.save(),C.fillStyle="#000000",C.fillText(se,ue+2,me+2),C.restore(),C.save(),C.fillStyle="#fcee0a",C.fillText(se,ue,me),C.restore();else if(q==="glitch-text"){const Re=(Math.random()-.5)*5,ee=(Math.random()-.5)*2;C.save(),C.fillStyle="red",C.fillText(se,ue+Re,me+ee),C.restore(),C.save(),C.fillStyle="cyan",C.fillText(se,ue-Re,me-ee),C.restore(),C.fillStyle="#ffffff",C.fillText(se,ue,me)}else q==="hologram"?(C.fillStyle="rgba(0, 255, 255, 0.7)",C.shadowColor="rgba(0,255,255,0.5)",C.shadowBlur=10,C.fillText(se,ue,me)):(q==="comic"&&(C.lineWidth=3,C.strokeStyle="#000000",C.strokeText(se,ue,me),C.fillStyle="#ffcc00"),C.fillText(se,ue,me));if(Ie&&Ie!=="none"){const ee=C.measureText(se).width;let be=ue;if(C.textAlign==="center"?be=ue-ee/2:C.textAlign==="right"&&(be=ue-ee),C.save(),C.beginPath(),C.lineWidth=Math.max(2,4*Me),C.strokeStyle=C.fillStyle,Ie.includes("line-through")&&(C.moveTo(be,me),C.lineTo(be+ee,me)),Ie.includes("underline")){const $e=C.font.match(/(\d+(\.\d+)?)px/),Oe=$e?parseFloat($e[1]):50,ht=me+Oe*.4;C.moveTo(be,ht),C.lineTo(be+ee,ht)}C.stroke(),C.restore()}},fe=(C,se,ue,me,q,Ie,Re,ee,be,$e,Oe,ht,R)=>{const Ue=ee?.textCase||"none",We=(B,te)=>{if(!B)return B;if(Ue==="upper")return B.toUpperCase();if(Ue==="lower")return B.toLowerCase();if(Ue==="title")return B.replace(/\w\S*/g,j=>j.charAt(0).toUpperCase()+j.substr(1).toLowerCase());if(Ue==="sentence"){const j=B.toLowerCase();return te?j.charAt(0).toUpperCase()+j.slice(1):j}return Ue==="invert"?B.replace(/\w\S*/g,j=>j.charAt(0).toLowerCase()+j.slice(1).toUpperCase()):B};let Xe=se.words||[];if(Xe.length===0){const B=se.text.split(` -`);Xe=[],B.forEach((te,j)=>{const we=te.split(" ").map(E=>({text:E,startTime:se.time,endTime:se.endTime||se.time+3}));Xe.push(...we),jB.text===` -`||B.text.trim().length>0).map((B,te)=>({...B,text:B.text===` -`?` -`:We(B.text,te===0).trim()}));(ee?.highlightEffect?.includes("cyberpunk")||ee?.textEffect==="cyberpunk")&&(be="'Orbitron', sans-serif"),C.font=`${ht} ${Oe} ${$e}px ${be}`;const ft=[];let jt=[],gt=0,Et=.3;["default","custom"].includes(m)?Et=.25:m==="monospace"&&(Et=.5);const A=C.measureText("M").width*Et;Ye.forEach((B,te)=>{if(B.text===` -`){jt.length>0&&ft.push(jt),jt=[],gt=0;return}const j=C.measureText(B.text).width;let E=!B.text.endsWith(" ");const O=/[-‐‑‒–—―]$/,V=/^[-‐‑‒–—―]/;O.test(B.text.trim())&&(E=!1);const Fe=Ye[te+1];Fe&&(V.test(Fe.text.trim())||Fe.text===` -`)&&(E=!1);const Be=E?A:0;gt+j>q&&jt.length>0&&(ft.push(jt),jt=[],gt=0),jt.push(B),gt+=j+Be}),jt.length>0&&ft.push(jt);const W=me-(ft.length-1)*Ie/2;let M=ee.highlightColor||"#fb923c",D=ee.highlightBackground||"#ffffff";const k=ee.highlightEffect||"none";ee.useCustomHighlightColors||(k.includes("blue")||k.includes("cyan")?(M="#3b82f6",D="#3b82f6"):k.includes("purple")?(M="#a855f7",D="#a855f7"):k.includes("green")?(M="#22c55e",D="#22c55e"):k.includes("pink")?(M="#ec4899",D="#ec4899"):k.includes("neon")?(M="#ffffff",D="#ffffff"):k.includes("gold")?(M="#FFD700",D="#B8860B"):k.includes("chrome")?(M="#E0E0E0",D="#757575"):k.includes("fire")?(M="#FF4500",D="#FF0000"):k.includes("glass")?(M="#ffffff",D="rgba(255,255,255,0.1)"):k==="karaoke"&&(M="#fb923c",D="#fb923c"));let ne=ee.fontColor||"#ffffff";ee.highlightEffect==="karaoke-smooth-white"&&(ne="#ffffff"),ft.forEach((B,te)=>{const j=W+te*Ie;let we=0;B.forEach((O,V)=>{if(we+=C.measureText(O.text).width,V{const Fe=C.measureText(O.text).width,Be=Re>=O.startTime,tt=Re>=O.startTime&&Re.3&&on<.45)&&(Dt=1.15,vt=1.15)}else if(k.includes("flash"))Gt=.5+Math.sin(Re*10)*.5;else if(k.includes("tada")){const on=Re*2%1;on<.1?(dt=-.05,Dt=.9):on<.2&&(dt=.05,Dt=1.1)}else k.includes("swing")?dt=Math.sin(Re*4)*.15:k.includes("glitch")&&Math.sin(Re*15)>.8&&(he+=(Math.random()-.5)*10,Se+=(Math.random()-.5)*10);const Ut=.3;if(mt1-Math.pow(1-zn,3))(on);if(k.includes("fade"))Gt=on;else if(k.includes("slide"))Se+=(1-en)*30*R,Gt=en;else if(k.includes("drop"))Se-=(1-en)*50*R,Gt=en;else if(k.includes("zoom")||k.includes("scale")){const zn=.5+.5*en;Dt*=zn,vt*=zn}else if(k.includes("elastic")){const zn=on===0?0:on===1?1:Math.pow(2,-10*on)*Math.sin((on*10-.75)*(2*Math.PI)/3)+1;Dt*=zn,vt*=zn}else if(k.includes("flip"))vt*=en;else if(k.includes("rotate-in"))dt+=(1-en)*-1,Gt=en;else if(k.includes("roll"))he-=(1-en)*50*R,dt-=(1-en)*Math.PI,Gt=en;else if(k.includes("lightspeed"))he+=(1-en)*100*R,Gt=en;else if(k.includes("blur"))dn=(1-en)*10,Gt=en;else if(k.includes("shatter")){const zn=1+(1-en)*2;Dt*=zn,vt*=zn,dn=(1-en)*10,Gt=en}else k.includes("spiral")&&(Dt*=en,vt*=en,dt+=(1-en)*Math.PI*2)}else k.includes("scale")&&(Dt*=1.3,vt*=1.3)}if(C.save(),Gt<1&&(C.globalAlpha*=Gt),dn>0&&(C.filter=`blur(${dn}px)`),dt!==0||Dt!==1||vt!==1){const mt=he+Fe/2,Ut=Se;C.translate(mt,Ut),C.rotate(dt),C.scale(Dt,vt),C.translate(-mt,-Ut)}if(Ot){if(k==="karaoke-smooth-plus"){const mt=ee.textEffect||"none";if(tt){const Ut=O.endTime-O.startTime,on=Re-O.startTime,Kn=Math.max(0,Math.min(1,on/Ut)),en=he+Fe*Kn,zn=ee?.textDecoration||"none",Xo=to=>{if(zn!=="none"){C.lineWidth=Math.max(2,3*R),C.strokeStyle=to,C.beginPath();const no=Se+$e*.45;zn.includes("underline")&&(C.moveTo(he,no),C.lineTo(he+Fe,no)),zn.includes("line-through")&&(C.moveTo(he,Se),C.lineTo(he+Fe,Se)),C.stroke()}};C.save(),C.beginPath(),C.rect(he-50,Se-Ie,en-(he-50),Ie*2),C.clip(),C.fillStyle=M,ye(C,O.text,he,Se,mt),Xo(M),C.restore(),C.save(),C.beginPath(),C.rect(en,Se-Ie,he+Fe+50-en,Ie*2),C.clip(),C.fillStyle=ne,C.fillText(O.text,he,Se),Xo(ne),C.restore(),St="rgba(0,0,0,0)"}else C.fillStyle=M,ye(C,O.text,he,Se,mt),St=M}else if(k.includes("gradient")||k.includes("chrome")||k.includes("gold")){const mt=C.createLinearGradient(he,Se-Ie/2,he,Se+Ie/2);k.includes("gold")?(mt.addColorStop(0,"#d4af37"),mt.addColorStop(1,"#C5A028")):k.includes("chrome")?(mt.addColorStop(0,"#ebebeb"),mt.addColorStop(.5,"#616161"),mt.addColorStop(.51,"#ebebeb"),mt.addColorStop(1,"#ebebeb")):(mt.addColorStop(0,M),mt.addColorStop(1,D)),C.fillStyle=mt}if(k.includes("shadow")&&(C.save(),C.fillStyle="#000000",C.fillText(O.text,he+2*R,Se+2*R),C.restore()),k.includes("3d")){const mt=C.fillStyle;C.fillStyle="rgba(0,0,0,0.5)";for(let Ut=1;Ut<=3;Ut++)C.fillText(O.text,he+Ut*R,Se+Ut*R);C.fillStyle=mt}if(k.includes("neon-multi"))C.shadowBlur=10,C.shadowColor="#fff",C.fillText(O.text,he,Se),C.shadowBlur=20,C.shadowColor="#ff00de",C.fillText(O.text,he,Se),C.shadowBlur=35,C.shadowColor="#00ffff",C.fillText(O.text,he,Se);else if(k.includes("cyberpunk"))C.save(),C.fillStyle="#05d9e8",C.fillText(O.text,he-1,Se-1),C.restore(),C.save(),C.fillStyle="#000000",C.fillText(O.text,he+2,Se+2),C.restore(),C.fillStyle="#fcee0a",C.fillText(O.text,he,Se);else if(k.includes("glitch-text")){const mt=(Math.random()-.5)*5,Ut=(Math.random()-.5)*2;C.save(),C.fillStyle="red",C.fillText(O.text,he+mt,Se+Ut),C.restore(),C.save(),C.fillStyle="cyan",C.fillText(O.text,he-mt,Se-Ut),C.restore(),C.fillStyle="#ffffff",C.fillText(O.text,he,Se)}else if(k.includes("retro")||k.includes("vhs")){const mt=Math.sin(Re*5)*2*R,Ut=Math.random()>.95?(Math.random()-.5)*5:0;C.globalCompositeOperation="screen",C.fillStyle="#ff0000",C.fillText(O.text,he-3*R+mt,Se+Ut),C.fillStyle="#00ff00",C.fillText(O.text,he+Ut,Se-mt),C.fillStyle="#0000ff",C.fillText(O.text,he+3*R-mt,Se+Ut)}else if(k.includes("fire")){const mt=Math.abs(Math.sin(Re*15))*5,Ut=Math.sin(Re*20)*1*R;C.shadowBlur=5+mt,C.shadowColor="#ff0000",C.fillStyle="#ff4500",C.fillText(O.text,he,Se+Ut),C.shadowBlur=2,C.shadowColor="#ffff00",C.fillStyle="#ffcc00",C.fillText(O.text,he+Math.sin(Re*25)*1*R,Se-1*R+Ut)}else if(k.includes("typewriter")){const mt=Re-O.startTime,Ut=O.endTime-O.startTime,on=Math.min(1,Math.max(0,mt/Ut)),Kn=Math.floor(O.text.length*on),en=O.text.substring(0,Kn);k.includes("outline")?(C.strokeStyle=M,C.strokeText(en,he,Se)):C.fillText(en,he,Se)}else!k.includes("neon-multi")&&!k.includes("retro")&&!k.includes("vhs")&&!k.includes("fire")&&(k.includes("outline")?(C.strokeStyle=M,C.lineWidth=2*R,C.strokeText(O.text,he,Se)):C.fillText(O.text,he,Se))}else C.fillText(O.text,he,Se);const Fn=ee?.textDecoration||"none";if(Fn!=="none"){if(C.lineWidth=Math.max(2,3*R),C.strokeStyle=St,C.beginPath(),Fn.includes("underline")&&!k.includes("underline")){const mt=Se+$e*.45;C.moveTo(he,mt),C.lineTo(he+Fe,mt)}Fn.includes("line-through")&&(C.moveTo(he,Se),C.lineTo(he+Fe,Se)),C.stroke()}C.restore(),C.restore();let mi=!O.text.endsWith(" ");const ui=/[-‐‑‒–—―]$/,Zt=/^[-‐‑‒–—―]/;ui.test(O.text.trim())&&(mi=!1);const Pn=B[V+1];Pn&&Zt.test(Pn.text.trim())&&(mi=!1),E+=Fe+(mi?A:0)}),C.restore()})},Je=(C,se,ue,me,q,Ie,Re,ee)=>{const be=ve(C,se,q),$e=me-(be.length-1)*Ie/2;be.forEach((Oe,ht)=>{const R=$e+ht*Ie;if(Re==="glass"){const Ue=C.measureText(Oe).width;C.save(),C.fillStyle="rgba(255, 255, 255, 0.1)",C.beginPath(),C.roundRect?C.roundRect(ue-(C.textAlign==="center"?Ue/2:C.textAlign==="right"?Ue:0)-10,R-Ie/2,Ue+20,Ie,8):C.rect(ue-(C.textAlign==="center"?Ue/2:C.textAlign==="right"?Ue:0)-10,R-Ie/2,Ue+20,Ie),C.fill(),C.strokeStyle="rgba(255, 255, 255, 0.2)",C.stroke(),C.restore()}ye(C,Oe,ue,R,Re,ee)})},ge='ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',qe='ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',Ve='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',Ke='"Metal Mania", cursive',nt='"Fredoka One", cursive',it='"Shadows Into Light", cursive',xt='"Dancing Script", cursive',K='"Orbitron", sans-serif',ze='"UnifrakturMaguntia", cursive';let Le=ge;m==="classic"?Le=qe:m==="monospace"?Le=Ve:m==="metal"?Le=Ke:m==="kids"?Le=nt:m==="sad"?Le=it:m==="romantic"?Le=xt:m==="tech"?Le=K:m==="gothic"?Le=ze:m==="custom"&&(Le=T?.fontFamily||ge),x&&(Le="CustomFont, sans-serif"),T&&T.fontFamily!=="sans-serif"&&(Le=T.fontFamily);const ut=t<=o,Me=Math.min(t,o)/1080;if(T&&(T.backgroundSource==="color"||T.backgroundSource==="smart-gradient")?e.fillStyle=T.backgroundColor||"#000000":e.fillStyle="#000000",e.fillRect(0,0,t,o),T?.backgroundSource==="gradient"&&T.backgroundGradient)e.fillStyle=T.backgroundGradient,e.fillRect(0,0,t,o);else if(T?.backgroundSource==="smart-gradient"){const C=T.backgroundColor||"#312e81",se=oe(C),ue=e.createLinearGradient(0,0,t,o);ue.addColorStop(0,C),ue.addColorStop(.5,`rgb(${Math.floor(se.r*.6)}, ${Math.floor(se.g*.6)}, ${Math.floor(se.b*.6)})`),ue.addColorStop(1,"#000000"),e.fillStyle=ue,e.fillRect(0,0,t,o)}else if(T?.backgroundSource==="image"&&T.backgroundImage){const C=g.get("__custom_bg__");C&&ce(C)}else if(T?.backgroundSource==="video"&&T.backgroundVideo){const C=v.get("__custom_bg_video__");C&&ce(C)}if(T&&T.backgroundBlurStrength>0?e.filter=`blur(${T.backgroundBlurStrength}px)`:S&&(e.filter="blur(12px)"),!T||T.backgroundSource==="timeline"||T.backgroundSource==="custom"){const C=T?T.backgroundSource==="timeline":!1;let se=!1;if(C){const q=T?.visualTransitionType||"none",Ie=T?.visualTransitionDuration||1,Re=f.filter(ee=>ee.type==="audio"?!1:l>=ee.startTime&&l=ee.endTime&&l{const $e=(ee.layer||0)-(be.layer||0);return $e!==0?$e:ee.startTime-be.startTime}),Re.length>0&&(Re.forEach(ee=>{const be=ee.layer||0;if(T&&T.layerVisibility?.visual?.[be]===!1)return;const $e=ee.type==="video"?v.get(ee.id):null,Oe=ee.type!=="video"?g.get(ee.id):null;let ht=1;if(q!=="none"){if(l=ee.endTime){let R=!1;if(q==="crossfade"&&(R=f.some(Ue=>Ue.id!==ee.id&&(Ue.layer||0)===(ee.layer||0)&&Ue.startTime>=ee.endTime-.1&&Ue.startTimeee.endTime-Ie){const R=(ee.endTime-l)/Ie;ht=Math.min(ht,Math.max(0,Math.min(1,R)))}}ht>0&&(e.save(),e.globalAlpha=ht,$e?ce($e):Oe&&ce(Oe),e.restore())}),se=!0)}const ue=T?.backgroundSource||"custom",me=ue==="custom"||ue==="timeline"&&f.length===0;if(!se&&d.coverUrl&&me){const q=d.backgroundType==="video"?v.get("background"):null,Ie=g.get("cover");q?ce(q):Ie&&ce(Ie)}}if((T&&T.backgroundBlurStrength>0||S)&&(e.filter="none"),!["just_video","none"].includes(m)&&!T?.useRealColorMedia&&(e.fillStyle=T&&(T.backgroundSource==="color"||T.backgroundSource==="gradient")?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",e.fillRect(0,0,t,o)),T?.enableGradientOverlay){const C=e.createLinearGradient(0,o,0,0);C.addColorStop(0,"rgba(0, 0, 0, 0.95)"),C.addColorStop(.35,"rgba(0, 0, 0, 0.6)"),C.addColorStop(.7,"rgba(0, 0, 0, 0)"),e.fillStyle=C,e.fillRect(0,0,t,o)}if(T?.showVisualization&&G&&G.length>0){e.save();const C=rx(T);cx(e,G,Y||null,t,o,C,l*1e3),e.restore()}if(m==="just_video"||m==="none")return;const L=s.findIndex((C,se)=>{if(C.endTime!==void 0)return l>=C.time&&l=C.time&&(!ue||l0)if(lse.time>l);X=C!==-1?C:s.length-1}const Ee=T?.introMode==="manual"&&T.introText?T.introText:`${d.title} -${d.artist}`;let ke=L===-1&&l<5&&(T?.showIntro??!0)&&(T?.introMode!=="manual"||z)&&(s.length===0||l0)){let C=o/2;T?.contentPosition==="top"?C=o*(.15*(T.marginTopScale??1)):T?.contentPosition==="bottom"&&(C=o*(1-.1*(T.marginBottomScale??1)));let se=0;const ue=["large","large_upper","big_center","metal","kids","sad","romantic","tech","gothic","testing","testing_up","one_line","one_line_up","custom"].includes(m);if(ue||m==="slideshow"||m==="subtitle"){const ee=ke?{text:Ee}:s[L]||s[X];if(ee){e.font=`900 ${He}px ${Le}`;const be=["large_upper","big_center","metal","tech","testing_up","one_line_up"].includes(m)?ee.text.toUpperCase():ee.text,$e=ve(e,be,t*.9);$e.length>1&&(se=($e.length-1)*(He*1.2)/2)}}let me=ue?-1:-2,q=ue?1:2;T?.lyricDisplayMode==="active-only"?(me=0,q=0):T?.lyricDisplayMode==="next-only"?(me=0,q=1):T?.lyricDisplayMode==="previous-next"?(me=-1,q=1):T?.lyricDisplayMode==="all"&&(me=-s.length,q=s.length);const Ie=new Map,Re=new Map;{const ee=Math.max((ut?30:40)*Me,Ae-He);for(let be=me;be<=q;be++){let $e=0,Oe=!1;if(ke&&be===0){const ht=He*1.2,R=et*1.2,We=Ee.split(` -`).length>1;$e=ht+(We?R:0),Oe=!0}else{const ht=X+be;if(ht>=0&&htgt.charAt(0).toUpperCase()+gt.substr(1).toLowerCase()):ft==="sentence"?Ye=Ye.charAt(0).toUpperCase()+Ye.slice(1).toLowerCase():ft==="invert"&&(Ye=Ye.replace(/\w\S*/g,gt=>gt.charAt(0).toLowerCase()+gt.slice(1).toUpperCase())),$e=ve(e,Ye,t*.9).length*(Ue*1.2)}}Re.set(be,$e)}Ie.set(0,C);for(let be=1;be<=q;be++){const $e=Ie.get(be-1)??C,Oe=Re.get(be-1)??0,ht=Re.get(be)??0;Ie.set(be,$e+Oe/2+ee+ht/2)}for(let be=-1;be>=me;be--){const $e=Ie.get(be+1)??C,Oe=Re.get(be+1)??0,ht=Re.get(be)??0;Ie.set(be,$e-Oe/2-ee-ht/2)}}for(let ee=me;ee<=q;ee++){let be=null,$e=!1;if(ke)ee===0&&(be={time:0,text:Ee},$e=!0);else{const Oe=X+ee;Oe>=0&&Oe1+2.70158*Math.pow(vt-1,3)+1.70158*Math.pow(vt-1,2),Dt=vt=>{const Gt=2*Math.PI/3;return vt===0?0:vt===1?1:Math.pow(2,-10*vt)*Math.sin((vt*10-.75)*Gt)+1};if(Xe==="slide")ft=(1-he)*(_e0&&(e.filter=`blur(${A}px)`);const M=$e&&T?.textAnimation||"none";let D=be.text,k=T?.textCase||"none";k==="none"&&$e&&["large_upper","big_center","metal","tech","testing_up","one_line_up"].includes(m)&&(k="upper"),k==="upper"?D=D.toUpperCase():k==="lower"?D=D.toLowerCase():k==="title"?D=D.replace(/\w\S*/g,_e=>_e.charAt(0).toUpperCase()+_e.substr(1).toLowerCase()):k==="sentence"?D=D.charAt(0).toUpperCase()+D.slice(1).toLowerCase():k==="invert"&&(D=D.replace(/\w\S*/g,_e=>_e.charAt(0).toLowerCase()+_e.slice(1).toUpperCase()));let ne=0,B=0,te=1,j=1,we=0;if($e&&M!=="none")if(M==="bounce")B=Math.sin(l*6)*15*Me;else if(M==="pulse"){const _e=1+Math.sin(l*4)*.08;te=_e,j=_e}else if(M==="wave")B=Math.sin(l*4)*20*Me,we=Math.sin(l*4)*.05;else if(M==="glitch")Math.sin(l*10)>.8&&(ne=(Math.random()-.5)*15*Me,B=(Math.random()-.5)*15*Me);else if(M==="shake")ne=(Math.random()-.5)*5*Me,B=(Math.random()-.5)*5*Me;else if(M==="typewriter"){const Ot=Math.floor((l-be.time)*30);D=D.substring(0,Math.max(0,Ot))}else if(M==="wobble"){we=Math.sin(l*5)*.05;const _e=1+Math.sin(l*3)*.05;te=_e,j=_e}else if(M==="breathe"){const _e=1+Math.sin(l*2)*.03;te=_e,j=_e}else if(M==="rotate")we=Math.sin(l*2)*.05;else if(M==="sway")we=Math.sin(l*2)*.08;else if(M==="flicker")e.globalAlpha=Ye*(.8+Math.random()*.2);else if(M==="jello")te=1+Math.sin(l*6)*.1,j=1-Math.sin(l*6)*.1;else if(M==="spin")we=l%2*Math.PI;else if(M==="heartbeat"){const _e=l*1.5%1;(_e<.1||_e>.3&&_e<.4)&&(te=1.1,j=1.1)}else if(M==="tada"){const _e=l*1.5%1;_e<.1?(te=.9,j=.9,we=-.05):_e<.2?(te=1.1,j=1.1,we=.05):(te=1,j=1,we=0)}else M==="swing"&&(we=Math.sin(l*3)*.1);let E=0;Ie.has(ee)?E=Ie.get(ee)+(ee===0?ft:0):(E=m==="subtitle"&&ee===0&&T?.lyricDisplayMode!=="all"?o-140*Me:C+ee*Ae+(ee===0?ft:0),m!=="custom"&&(ee<0?E-=se:ee>0&&(E+=se))),E+=B;let O=t/2;e.textAlign==="left"?O=60*Me:e.textAlign==="right"&&(O=t-60*Me),O+=jt+ne;const V=gt*te,Fe=Et*j,Be=W+we;(V!==1||Fe!==1||Be!==0)&&(e.translate(O,E),e.rotate(Be),e.scale(V,Fe),e.translate(-O,-E));const tt=$e?T?.textEffect||"preset":"none";if(ke&&ee===0&&T?.introMode!=="manual"){const _e=D.split(` -`),Ot=_e[0],Se=_e.slice(1).join(` -`),he=He*1.2,dt=et*1.2,Dt=20*Me;let vt=E;Se&&(vt=E-dt/2-Dt/2);const Gt=E+he/2+Dt/2;if(e.font=`${Ue} ${R} ${He}px ${Le}`,Je(e,Ot,O,vt,t*.9,he,tt,We),Se){const dn=m==="custom"&&T?.fontWeight?T.fontWeight:"400";e.font=`${Ue} ${dn} ${et}px ${Le}`,Je(e,Se,O,Gt,t*.9,dt,tt,We)}}else{const _e=$e?He:et;T&&T.highlightEffect&&T.highlightEffect,$e&&be?fe(e,be,O,E,t*.9,_e*(T?.lyricLineHeight||1.2),l,T,Le,_e,R,Ue,Me):Je(e,D,O,E,t*.9,_e*(T?.lyricLineHeight||1.2),tt,We)}e.restore()}}}if(!["subtitle","just_video","none"].includes(m)){const C=T?T.showTitle||T.showArtist:!0,se=T?T.showCover:!0;if(C||se)if(m==="custom"||m==="default"){const ue=T?.infoPosition||"top-left",me=T?.infoStyle||"classic",q=me==="box",Ie=q?16*Me:12*Me,Re=40*Me*(T?.infoMarginScale??1);let ee="left",be="top";ue.includes("left")?ee="left":ue.includes("right")?ee="right":ee="center",ue.includes("top")?be="top":be="bottom";const $e=T?.infoSizeScale??1,Oe=(me==="minimal"||me==="modern"?0:100*Me)*$e,ht=se&&Oe>0&&d.coverUrl!==null,R=ht?d.backgroundType==="video"?v.get("background"):g.get("cover"):null,Ue=(me==="minimal"?20:me==="modern"||me==="modern_art"?40:28)*Me,We=(me==="minimal"?14:me==="modern"||me==="modern_art"?24:18)*Me,Xe=Ue*$e,Ye=We*$e,ft=T?.infoFontFamily||Le,jt=T?.infoFontWeight||"bold",gt=T?.infoFontStyle||"normal",Et=`${gt} ${jt} ${Xe}px ${ft}`,A=`${gt} ${jt} ${Ye}px ${ft}`,W=20*Me,M=q?24*Me:0,D=T?.infoFontColor||"#ffffff",k=me==="modern"||me==="modern_art"?D:T?.infoFontColor||"#d4d4d8";e.font=Et;const ne=e.measureText(d.title),B=T?.showTitle?ne.width:0;e.font=A;const te=e.measureText(d.artist),j=T?.showArtist?te.width:0;let we=0,E=0;if(ee==="center"){we=Math.max(ht&&R?Oe:0,B,j)+M*2;let he=0;ht&&R&&(he+=Oe),(T?.showTitle??!0)&&(he+=(ht&&R?W:0)+Xe),(T?.showArtist??!0)&&(he+=(ht&&R||(T?.showTitle??!0)?5*Me:0)+Ye),E=he+M*2}else{const Se=Math.max(B,j);we=(ht&&R?Oe+W:0)+Se+M*2;const dt=(T?.showTitle?Xe:0)+(T?.showArtist?Ye+5*Me:0);E=Math.max(dt,ht&&R?Oe:0)+M*2}let O=0,V=0;ee==="left"?O=Re:ee==="right"?O=t-Re:O=t/2,be==="top"?V=Re:V=o-Re;let Fe=0,Be=0;ee==="left"?Fe=O:ee==="right"?Fe=O-we:Fe=O-we/2,be==="top"?Be=V:Be=V-E,q&&(e.save(),e.fillStyle="rgba(0, 0, 0, 0.6)",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=20,e.beginPath(),e.roundRect(Fe,Be,we,E,Ie),e.fill(),e.restore());const tt=Fe+M,St=Be+M,_e=we-M*2,Ot=E-M*2;if(ee==="center"){let Se=St;const he=tt+_e/2;if(e.textAlign="center",be==="top"){if(ht&&R){e.save(),e.beginPath();const dt=he-Oe/2;me==="circle_art"?e.arc(he,Se+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(dt,Se,Oe,Oe,Ie/2),e.clip(),e.drawImage(R,dt,Se,Oe,Oe),e.restore(),Se+=Oe+W}(T?.showTitle??!0)&&(e.fillStyle=D,e.font=Et,e.textBaseline="top",e.fillText(d.title,he,Se),Se+=Xe+5*Me),(T?.showArtist??!0)&&(e.fillStyle=k,e.font=A,e.textBaseline="top",e.fillText(d.artist,he,Se))}else{if(ht&&R){e.save(),e.beginPath();const dt=he-Oe/2;me==="circle_art"?e.arc(he,Se+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(dt,Se,Oe,Oe,Ie/2),e.clip(),e.drawImage(R,dt,Se,Oe,Oe),e.restore(),Se+=Oe+W}(T?.showTitle??!0)&&(e.fillStyle=D,e.font=Et,e.textBaseline="top",e.fillText(d.title,he,Se),Se+=Xe+5*Me),(T?.showArtist??!0)&&(e.fillStyle=k,e.font=A,e.textBaseline="top",e.fillText(d.artist,he,Se))}}else{const Se=ee==="right",he=St+Ot/2;let dt=tt;if(Se&&(dt=tt+_e),ht&&R){const Gt=he-Oe/2,dn=Se?dt-Oe:dt;e.save(),e.beginPath(),me==="circle_art"?e.arc(dn+Oe/2,Gt+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(dn,Gt,Oe,Oe,Ie/2),e.clip(),e.drawImage(R,dn,Gt,Oe,Oe),e.restore(),Se?dt-=Oe+W:dt+=Oe+W}const Dt=(T?.showTitle?Xe:0)+(T?.showArtist?Ye+5*Me:0);let vt=he-Dt/2;e.textAlign=Se?"right":"left",e.textBaseline="top",(T?.showTitle??!0)&&(e.fillStyle=D,e.font=Et,e.fillText(d.title,dt,vt),vt+=Xe+5*Me),(T?.showArtist??!0)&&(e.fillStyle=k,e.font=A,e.fillText(d.artist,dt,vt))}}else if(["big_center","metal","kids","sad","romantic","tech","gothic","testing","testing_up","one_line","one_line_up","slideshow","subtitle"].includes(m)){if(C){e.textAlign="center",e.textBaseline="middle";let ue=80*Me;["testing","testing_up","one_line","one_line_up"].includes(m)&&(ue=120*Me),(T?.showTitle??!0)&&(e.font=`bold ${20*Me}px ${Le}`,e.fillStyle="#ffffff",e.fillText(m==="tech"?d.title.toUpperCase():d.title,t/2,o-ue-30*Me)),(T?.showArtist??!0)&&(e.font=`${16*Me}px ${Le}`,e.fillStyle="#d4d4d8",e.fillText(d.artist,t/2,o-ue))}}else{const ue=40*Me*(T?.infoMarginScale??1),me=t===o,q=(ut?me?110:150:100)*Me,Ie=d.coverUrl?g.get("cover"):null,Re=12*Me;if(ut){const ee=ue*(me?1.5:3),be=t/2,$e=be-q/2,Oe=ee;if(se&&(e.save(),e.beginPath(),e.roundRect($e,Oe,q,q,Re),e.clip(),Ie?e.drawImage(Ie,$e,Oe,q,q):(e.fillStyle="#27272a",e.fillRect($e,Oe,q,q)),e.restore()),C){e.textAlign="center",e.textBaseline="top";const ht=Oe+(se?q+25*Me:0),R=T?.infoFontFamily||Le,Ue=T?.infoFontColor||"#ffffff",We=T?.infoFontColor||"#d4d4d8",Xe=T?.infoFontWeight||"bold",Ye=T?.infoFontStyle||"normal";(T?.showTitle??!0)&&(e.font=`${Ye} ${Xe} ${(me?26:36)*Me}px ${R}`,e.fillStyle=Ue,e.fillText(d.title,be,ht)),(T?.showArtist??!0)&&(e.font=`${Ye} ${Xe} ${(me?18:24)*Me}px ${R}`,e.fillStyle=We,e.fillText(d.artist,be,ht+(T?.showTitle??!0?(me?30:40)*Me:0)))}}else{const ee=ue,be=ue;if(se&&(e.save(),e.beginPath(),e.roundRect(ee,be,q,q,Re),e.clip(),Ie?e.drawImage(Ie,ee,be,q,q):(e.fillStyle="#27272a",e.fillRect(ee,be,q,q)),e.restore()),C){e.textAlign="left",e.textBaseline="top";const $e=T?.infoFontFamily||Le,Oe=T?.infoFontColor||"#ffffff",ht=T?.infoFontColor||"#d4d4d8",R=T?.infoFontWeight||"bold",Ue=T?.infoFontStyle||"normal",We=ee+(se?q+25*Me:0),Xe=28*Me,Ye=be+q/2-Xe;(T?.showTitle??!0)&&(e.font=`${Ue} ${R} ${Xe}px ${$e}`,e.fillStyle=Oe,e.fillText(d.title,We,Ye)),(T?.showArtist??!0)&&(e.font=`${Ue} ${R} ${18*Me}px ${$e}`,e.fillStyle=ht,e.fillText(d.artist,We,Ye+(T?.showTitle??!0?Xe+5*Me:0)))}}}}if(T?.showChannelInfo&&!["subtitle","just_video","none"].includes(m)){const C=T.channelInfoPosition||"bottom-right",se=T.channelInfoStyle||"classic",ue=T.channelInfoSizeScale??1,me=T.channelInfoMarginScale??1,q=g.get("__channel_info__"),Ie=T.channelInfoText;if(!(!q&&!Ie)){if(!(se==="logo"&&!q)){if(!(se==="minimal"&&!Ie)){e.save();const Re=40*Me*me,ee=80*Me*ue,be=se==="modern"||se==="logo"?ee*1.2:ee,$e=20*Me*ue,Oe=g.get("__channel_info_text_svg__"),ht=!!Oe;let R=0,Ue=$e;if(ht&&Oe){Ue=$e*1.5;const D=Oe.width/Oe.height;R=Ue*D}else{const D=T.channelInfoFontWeight||"bold",k=T.channelInfoFontStyle||"normal";e.font=`${k} ${D} ${$e}px ${T.channelInfoFontFamily||"sans-serif"}`,Ie&&se!=="logo"&&(R=e.measureText(Ie).width)}const We=12*Me*ue,Xe=12*Me*ue,Ye=8*Me*ue;let ft=0,jt=0;const gt=!!q&&se!=="minimal",Et=!!Ie&&se!=="logo";se==="modern"?(ft=Math.max(gt?be:0,Et?R+Xe*2:0),jt=(gt?be:0)+(gt&&Et?We:0)+(Et?Ue+Ye*2:0)):se==="box"?(ft=(gt?be:0)+(gt&&Et?We:0)+(Et?R:0)+Xe*2,jt=Math.max(gt?be:0,Et?Ue:0)+Ye*2):se==="minimal"?(ft=Et?R+Xe*2:0,jt=Et?Ue+Ye*2:0):se==="logo"?(ft=be,jt=be):(ft=(gt?be:0)+(gt&&Et?We:0)+(Et?R+Xe*2:0),jt=Math.max(gt?be:0,Et?Ue+Ye*2:0));let A=0,W=0;C.includes("left")?A=Re:C.includes("right")?A=t-Re-ft:C.includes("center")&&(A=(t-ft)/2),C.includes("top")?W=Re:C.includes("bottom")&&(W=o-Re-jt),se==="box"&&(e.fillStyle="rgba(0, 0, 0, 0.4)",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=10,e.roundRect?(e.beginPath(),e.roundRect(A,W,ft,jt,12*Me*ue),e.fill()):e.fillRect(A,W,ft,jt),e.shadowColor="transparent",e.shadowBlur=0);const M=(D,k,ne,B,te)=>{if(se!=="box"&&se!=="minimal"&&(e.fillStyle="rgba(0, 0, 0, 0.2)",e.roundRect?(e.beginPath(),e.roundRect(D,k,ne,B,8*Me*ue),e.fill()):e.fillRect(D,k,ne,B)),ht&&Oe){const j=D+(ne-R)/2,we=k+(B-Ue)/2;e.drawImage(Oe,j,we,R,Ue)}else{e.fillStyle=T.channelInfoFontColor||"#ffffff",e.textAlign="left",e.textBaseline="top",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4;const j=D+(ne-R)/2,we=k+(B-Ue)/2+Ue*.1;e.fillText(te,j,we),e.shadowColor="transparent"}};if(se==="modern"){let D=W;if(gt){const k=A+(ft-be)/2;e.drawImage(q,k,D,be,be),D+=be+We}if(Et){const k=R+Xe*2,ne=Ue+Ye*2,B=A+(ft-k)/2;M(B,D,k,ne,Ie)}}else{const D=C.includes("right");let k=A+(se==="box"?Xe:0);const ne=W+jt/2;if(D&&(se==="classic"||se==="circle")){if(Et){const B=R+Xe*2,te=Ue+Ye*2;M(k,ne-te/2,B,te,Ie),k+=B+We}gt&&(se==="circle"?(e.save(),e.beginPath(),e.arc(k+be/2,ne,be/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(q,k,ne-be/2,be,be),e.restore()):e.drawImage(q,k,ne-be/2,be,be))}else if(gt&&(se==="circle"?(e.save(),e.beginPath(),e.arc(k+be/2,ne,be/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(q,k,ne-be/2,be,be),e.restore()):e.drawImage(q,k,ne-be/2,be,be),k+=be+We),Et){const B=R+(se==="box"?0:Xe*2),te=Ue+(se==="box"?0:Ye*2);se==="box"?ht&&Oe?(e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4,e.drawImage(Oe,k,ne-Ue/2,R,Ue),e.shadowColor="transparent"):(e.fillStyle=T.channelInfoFontColor||"#ffffff",e.textAlign="left",e.textBaseline="middle",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4,e.fillText(Ie,k,ne+Ue*.1),e.shadowColor="transparent"):M(k,ne-te/2,B,te,Ie)}}e.restore()}}}}};var yn;(function(e){e.LOAD="LOAD",e.EXEC="EXEC",e.FFPROBE="FFPROBE",e.WRITE_FILE="WRITE_FILE",e.READ_FILE="READ_FILE",e.DELETE_FILE="DELETE_FILE",e.RENAME="RENAME",e.CREATE_DIR="CREATE_DIR",e.LIST_DIR="LIST_DIR",e.DELETE_DIR="DELETE_DIR",e.ERROR="ERROR",e.DOWNLOAD="DOWNLOAD",e.PROGRESS="PROGRESS",e.LOG="LOG",e.MOUNT="MOUNT",e.UNMOUNT="UNMOUNT"})(yn||(yn={}));const g2=(()=>{let e=0;return()=>e++})(),y2=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),v2=new Error("called FFmpeg.terminate()");class x2{#t=null;#i={};#n={};#o=[];#l=[];loaded=!1;#a=()=>{this.#t&&(this.#t.onmessage=({data:{id:t,type:o,data:l}})=>{switch(o){case yn.LOAD:this.loaded=!0,this.#i[t](l);break;case yn.MOUNT:case yn.UNMOUNT:case yn.EXEC:case yn.FFPROBE:case yn.WRITE_FILE:case yn.READ_FILE:case yn.DELETE_FILE:case yn.RENAME:case yn.CREATE_DIR:case yn.LIST_DIR:case yn.DELETE_DIR:this.#i[t](l);break;case yn.LOG:this.#o.forEach(s=>s(l));break;case yn.PROGRESS:this.#l.forEach(s=>s(l));break;case yn.ERROR:this.#n[t](l);break}delete this.#i[t],delete this.#n[t]})};#e=({type:t,data:o},l=[],s)=>this.#t?new Promise((d,f)=>{const g=g2();this.#t&&this.#t.postMessage({id:g,type:t,data:o},l),this.#i[g]=d,this.#n[g]=f,s?.addEventListener("abort",()=>{f(new DOMException(`Message # ${g} was aborted`,"AbortError"))},{once:!0})}):Promise.reject(y2);on(t,o){t==="log"?this.#o.push(o):t==="progress"&&this.#l.push(o)}off(t,o){t==="log"?this.#o=this.#o.filter(l=>l!==o):t==="progress"&&(this.#l=this.#l.filter(l=>l!==o))}load=({classWorkerURL:t,...o}={},{signal:l}={})=>(this.#t||(this.#t=t?new Worker(new URL(t,import.meta.url),{type:"module"}):new Worker(new URL("/assets/worker-BAOIWoxA.js",import.meta.url),{type:"module"}),this.#a()),this.#e({type:yn.LOAD,data:o},void 0,l));exec=(t,o=-1,{signal:l}={})=>this.#e({type:yn.EXEC,data:{args:t,timeout:o}},void 0,l);ffprobe=(t,o=-1,{signal:l}={})=>this.#e({type:yn.FFPROBE,data:{args:t,timeout:o}},void 0,l);terminate=()=>{const t=Object.keys(this.#n);for(const o of t)this.#n[o](v2),delete this.#n[o],delete this.#i[o];this.#t&&(this.#t.terminate(),this.#t=null,this.loaded=!1)};writeFile=(t,o,{signal:l}={})=>{const s=[];return o instanceof Uint8Array&&s.push(o.buffer),this.#e({type:yn.WRITE_FILE,data:{path:t,data:o}},s,l)};mount=(t,o,l)=>{const s=[];return this.#e({type:yn.MOUNT,data:{fsType:t,options:o,mountPoint:l}},s)};unmount=t=>{const o=[];return this.#e({type:yn.UNMOUNT,data:{mountPoint:t}},o)};readFile=(t,o="binary",{signal:l}={})=>this.#e({type:yn.READ_FILE,data:{path:t,encoding:o}},void 0,l);deleteFile=(t,{signal:o}={})=>this.#e({type:yn.DELETE_FILE,data:{path:t}},void 0,o);rename=(t,o,{signal:l}={})=>this.#e({type:yn.RENAME,data:{oldPath:t,newPath:o}},void 0,l);createDir=(t,{signal:o}={})=>this.#e({type:yn.CREATE_DIR,data:{path:t}},void 0,o);listDir=(t,{signal:o}={})=>this.#e({type:yn.LIST_DIR,data:{path:t}},void 0,o);deleteDir=(t,{signal:o}={})=>this.#e({type:yn.DELETE_DIR,data:{path:t}},void 0,o)}var av;(function(e){e.MEMFS="MEMFS",e.NODEFS="NODEFS",e.NODERAWFS="NODERAWFS",e.IDBFS="IDBFS",e.WORKERFS="WORKERFS",e.PROXYFS="PROXYFS"})(av||(av={}));const b2=new Error("failed to get response body reader"),S2=new Error("failed to complete download"),w2="Content-Length",T2=async(e,t)=>{const o=await fetch(e);let l;try{const s=parseInt(o.headers.get(w2)||"-1"),d=o.body?.getReader();if(!d)throw b2;const f=[];let g=0;for(;;){const{done:x,value:b}=await d.read(),S=b?b.length:0;if(x){if(s!=-1&&s!==g)throw S2;t&&t({url:e,total:s,received:g,delta:S,done:x});break}f.push(b),g+=S,t&&t({url:e,total:s,received:g,delta:S,done:x})}const v=new Uint8Array(g);let m=0;for(const x of f)v.set(x,m),m+=x.length;l=v.buffer}catch(s){console.log("failed to send download progress event: ",s),l=await o.arrayBuffer()}return l},Gs=async(e,t,o=!1,l)=>{const s=o?await T2(e,l):await(await fetch(e)).arrayBuffer(),d=new Blob([s],{type:t});return URL.createObjectURL(d)};let $s=null,xf=!1,Nc=!1;async function ux(e){if($s&&xf)return $s;if(Nc){for(;Nc;)await new Promise(t=>setTimeout(t,100));if($s&&xf)return $s}Nc=!0;try{const t=new x2;if(t.on("log",({message:l})=>{e?.(`[FFmpeg] ${l}`),console.log("[FFmpeg]",l)}),t.on("progress",({progress:l,time:s})=>{e?.(`[FFmpeg Progress] ${(l*100).toFixed(1)}% (${s}s)`)}),typeof window<"u"&&window.crossOriginIsolated){e?.("[FFmpeg] Cross-Origin Isolated: YES. Using Multi-Threaded Core 🚀");const l="https://unpkg.com/@ffmpeg/core-mt@0.12.10/dist/esm";let s,d,f;const g=async(x,b,S)=>{const T=`${x.endsWith("/")?x:`${x}/`}${b}`;try{const F=await fetch(T,{cache:"no-cache",mode:"same-origin"});if(!F.ok)throw new Error(`HTTP ${F.status}`);const z=F.headers.get("Content-Type")||"",G=await F.arrayBuffer(),Y=new Uint8Array(G);if(Y[0]===60||z.includes("text/html")){const oe=new TextDecoder().decode(Y.slice(0,100));throw e?.(`[FFmpeg] Error: Path ${T} returned HTML instead of binary. Check if file exists in public/ffmpeg.`),console.debug(`[FFmpeg] Received HTML: ${oe}...`),new Error(`Server returned HTML (SPA Redirect) at ${T}`)}if(b.endsWith(".wasm")&&(Y[0]!==0||Y[1]!==97||Y[2]!==115||Y[3]!==109))throw new Error("File version mismatch or invalid WASM binary (Check for partial downloads)");return URL.createObjectURL(new Blob([G],{type:S}))}catch(F){throw new Error(`[${b}] ${F.message}`)}},v=window.location.origin,m="/";try{e?.(`[FFmpeg] Initializing (Offline Support: ${navigator.onLine?"OFF":"ACTIVE"})...`);const x=[m.endsWith("/")?`${m}ffmpeg`:`${m}/ffmpeg`,"/ffmpeg","./ffmpeg","ffmpeg",v+"/ffmpeg"].filter((S,_,T)=>T.indexOf(S)===_);let b=!1;for(const S of x)try{e?.(`[FFmpeg] Probing ${S}...`);const _=await g(S,"ffmpeg-core.js","text/javascript"),[T,F]=await Promise.all([g(S,"ffmpeg-core.wasm","application/wasm"),g(S,"ffmpeg-core.worker.js","text/javascript")]);s=_,d=T,f=F,e?.(`[FFmpeg] Success! Core verified at ${S} 🚀`),b=!0;break}catch(_){console.debug(`[FFmpeg] Path ${S} skipped:`,_.message)}if(!b)throw new Error("Could not find valid local binaries")}catch(x){e?.(`[FFmpeg] Local load failed: ${x.message}. Falling back to CDN.`),console.warn("[FFmpeg] Falling back to remote CDN:",x),[s,d,f]=await Promise.all([Gs(`${l}/ffmpeg-core.js`,"text/javascript"),Gs(`${l}/ffmpeg-core.wasm`,"application/wasm"),Gs(`${l}/ffmpeg-core.worker.js`,"text/javascript")])}await t.load({coreURL:s,wasmURL:d,workerURL:f})}else{e?.("[FFmpeg] Cross-Origin Isolated: NO. Using Single-Threaded Core 🐢");const l="https://unpkg.com/@ffmpeg/core@0.12.10/dist/esm";let s,d;const f=async(g,v,m)=>{const b=`${g.endsWith("/")?g:`${g}/`}${v}?v=${Date.now()}`;try{const S=await fetch(b);if(!S.ok||S.headers.get("Content-Type")?.includes("text/html"))throw new Error("404");const _=await S.blob();if((await _.slice(0,10).text()).trim().startsWith("<"))throw new Error("HTML Content");return URL.createObjectURL(new Blob([_],{type:m}))}catch(S){throw S}};try{e?.("[FFmpeg] Searching for local ST core files...");let g=!1;const m=["/ffmpeg","./ffmpeg","ffmpeg",window.location.pathname.replace(/\/[^\/]*$/,"")+"/ffmpeg"];for(const x of m)try{s=await f(x,"ffmpeg-core.js","text/javascript"),d=await f(x,"ffmpeg-core.wasm","application/wasm"),e?.(`[FFmpeg] Success! ST core verified at local ${x} 🐢`),g=!0;break}catch{}if(!g)throw new Error("NotFound")}catch{e?.("[FFmpeg] Local ST core failure. Using CDN."),s=await Gs(`${l}/ffmpeg-core.js`,"text/javascript"),d=await Gs(`${l}/ffmpeg-core.wasm`,"application/wasm")}await t.load({coreURL:s,wasmURL:d})}return $s=t,xf=!0,e?.("[FFmpeg] Loaded successfully"),t}finally{Nc=!1}}function C2(e,t,o){const l=o==="1080p",d={low:l?28:30,med:l?23:25,high:l?18:20}[t];switch(e){case"h265":return{vcodec:"libx265",args:["-crf",d.toString(),"-preset","medium","-tag:v","hvc1"],format:"mp4",ext:"mp4"};case"vp9":return{vcodec:"libvpx-vp9",args:["-crf",d.toString(),"-b:v","0","-deadline","good","-cpu-used","2"],format:"webm",ext:"webm"};case"av1":return{vcodec:"libaom-av1",args:["-crf",(d+10).toString(),"-b:v","0","-cpu-used","4","-strict","experimental"],format:"mp4",ext:"mp4"};default:return{vcodec:"libx264",args:["-crf",d.toString(),"-preset","medium","-profile:v","high","-level","4.2"],format:"mp4",ext:"mp4"}}}async function dx(e){const{canvas:t,audioFile:o,lyrics:l,metadata:s,visualSlides:d,imageMap:f,videoMap:g,preset:v,customFontName:m,renderConfig:x,fps:b,quality:S,codec:_,aspectRatio:T,onProgress:F,onLog:z,abortSignal:G,isFirstSong:Y=!0,isLastSong:oe=!0,startTimeOffset:ce=0}=e;F(0,"Loading FFmpeg...");const ve=await ux(z),ye=()=>G?.aborted===!0||G?.current===!0;if(ye())throw new Error("Render aborted");if(s.coverUrl&&(s.backgroundType==="video"?(z?.("[FFmpeg] Loading video background from metadata..."),await M2("background",s.coverUrl,g)):(z?.("[FFmpeg] Loading cover art from metadata..."),await A2("cover",s.coverUrl,f))),z?.(`[FFmpeg] VideoMap keys: ${Array.from(g.keys()).join(", ")}`),z?.(`[FFmpeg] RenderConfig Source: ${x.backgroundSource}`),g.has("__custom_bg_video__")){const L=g.get("__custom_bg_video__");z?.(`[FFmpeg] Custom Video: ReadyState=${L?.readyState}, Size=${L?.videoWidth}x${L?.videoHeight}, Duration=${L?.duration}`),L&&(L.muted=!0)}else x.backgroundSource==="video"&&z?.("[FFmpeg] WARNING: backgroundSource is 'video' but '__custom_bg_video__' is missing from map!");F(5,"Preparing audio...");const fe=URL.createObjectURL(o),Je=await _2(fe);URL.revokeObjectURL(fe);const ge=Math.ceil(Je*b),qe=t.getContext("2d");if(!qe)throw new Error("Failed to get canvas context");F(10,"Rendering frames...");const Ve=await o.arrayBuffer();await ve.writeFile("audio_src",new Uint8Array(Ve));let Ke=null,nt=44100;if(x.showVisualization)try{z?.("[FFmpeg] Decoding audio for visualization analysis...");const L=new(window.AudioContext||window.webkitAudioContext),X=await L.decodeAudioData(Ve.slice(0));Ke=X.getChannelData(0),nt=X.sampleRate,L.close(),z?.(`[FFmpeg] Audio decoded: ${X.duration.toFixed(1)}s @ ${nt}Hz`)}catch(L){z?.(`[FFmpeg] Warning: Could not decode audio for visualization: ${L.message}`)}const it=Math.max(6,ge.toString().length);for(let L=0;L0,Je,x,oe,Y,ke,He);const Ae=await(await new Promise((ue,me)=>{t.toBlob(q=>q?ue(q):me(new Error("Failed to create blob")),"image/jpeg",S==="high"?.98:S==="med"?.92:.85)})).arrayBuffer(),C=`frame_${L.toString().padStart(it,"0")}.jpg`;await ve.writeFile(C,new Uint8Array(Ae));const se=10+L/ge*70;F(se,`Rendering frame ${L+1}/${ge}`)}if(ye())throw await Ac(ve,ge,it),new Error("Render aborted");F(80,"Encoding video...");const xt=C2(_,S,e.resolution),K=`output.${xt.ext}`,ze=["-framerate",b.toString(),"-i",`frame_%0${it}d.jpg`,"-i","audio_src","-c:v",xt.vcodec,...xt.args,"-c:a","aac","-b:a","192k","-ar","44100","-ac","2","-pix_fmt","yuv420p","-movflags","+faststart","-shortest","-y",K];z?.(`[FFmpeg] Running: ffmpeg ${ze.join(" ")}`);try{await ve.exec(ze)}catch(L){throw console.error("FFmpeg encoding failed:",L),await Ac(ve,ge,it),new Error(`FFmpeg encoding failed: ${L}`)}F(95,"Finalizing...");const Le=await ve.readFile(K),ut=Le instanceof Uint8Array?new Uint8Array(Le):new TextEncoder().encode(Le),Me=new Blob([ut],{type:xt.format==="webm"?"video/webm":"video/mp4"});await Ac(ve,ge,it);try{await ve.deleteFile("audio_src"),await ve.deleteFile(K)}catch{}return F(100,"Complete!"),{blob:Me,duration:Je,format:xt.ext}}async function E2(e,t,o){const l=await ux(t.onLog),s=[];let d=0;for(let S=0;S{o(S,e.length,ce,ve)},startTimeOffset:d}),Y=`segment_${S}.${G.format}`,oe=await G.blob.arrayBuffer();await l.writeFile(Y,new Uint8Array(oe)),s.push(Y),d+=G.duration}if(e.length===1){const S=await l.readFile(s[0]),_=s[0].split(".").pop()||"mp4";await l.deleteFile(s[0]);const T=S instanceof Uint8Array?new Uint8Array(S):new TextEncoder().encode(S);return{blob:new Blob([T],{type:_==="webm"?"video/webm":"video/mp4"}),duration:d,format:_}}o(e.length,e.length,0,"Concatenating tracks...");const f=s.map(S=>`file '${S}'`).join(` -`);await l.writeFile("concat.txt",new TextEncoder().encode(f));const g=s[0].split(".").pop()||"mp4",v=`final_output.${g}`;await l.exec(["-f","concat","-safe","0","-i","concat.txt","-c","copy","-y",v]);const m=await l.readFile(v),x=m instanceof Uint8Array?new Uint8Array(m):new TextEncoder().encode(m),b=new Blob([x],{type:g==="webm"?"video/webm":"video/mp4"});for(const S of s)try{await l.deleteFile(S)}catch{}try{await l.deleteFile("concat.txt"),await l.deleteFile(v)}catch{}return o(e.length,e.length,100,"Complete!"),{blob:b,duration:d,format:g}}async function _2(e){return new Promise((t,o)=>{const l=document.createElement("audio");l.preload="metadata",l.onloadedmetadata=()=>{t(l.duration),URL.revokeObjectURL(e)},l.onerror=()=>{o(new Error("Failed to load audio metadata")),URL.revokeObjectURL(e)},l.src=e})}async function N2(e,t,o,l){const s=[];e.forEach((d,f)=>{let g=-1;if(f==="__custom_bg_video__"){const v=d.duration||1;v>0&&(g=l%v)}else if(f==="background"){const v=d.duration||1;v>0&&(g=o%v)}else{const v=t.find(m=>m.id===f);if(v&&v.type==="video"&&o>=v.startTime&&o0&&x>=b&&(x=x%b),g=x}}if(g>=0){if(d.readyState===0)return;Math.abs(d.currentTime-g)>.05&&s.push(new Promise(v=>{let m=!1;const x=()=>{m||(m=!0,d.removeEventListener("seeked",x),v())};d.addEventListener("seeked",x),d.currentTime=g,setTimeout(()=>{m||(m=!0,d.removeEventListener("seeked",x),v())},500)}))}}),s.length>0&&await Promise.all(s)}async function A2(e,t,o){if(!(o.has(e)&&o.get(e)?.src===t))return new Promise(l=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>{o.set(e,s),l()},s.onerror=()=>{console.warn("Failed to load background image:",t),l()},s.src=t})}async function M2(e,t,o){if(!(o.has(e)&&o.get(e)?.src===t))return new Promise(l=>{const s=document.createElement("video");s.crossOrigin="anonymous",s.muted=!0,s.playsInline=!0,s.preload="auto";let d=!1;const f=()=>{d||(d=!0,o.set(e,s),l())};s.oncanplay=()=>{d||(s.currentTime=.001)},s.onseeked=()=>f(),s.onerror=()=>{console.warn("Failed to load background video:",t),f()},setTimeout(()=>f(),1e4),s.src=t,s.load()})}async function Ac(e,t,o){for(let l=0;l{if(!t.has(e))throw TypeError("Cannot "+o)},$=(e,t,o)=>(mp(e,t,"read from private field"),o?o.call(e):t.get(e)),Vt=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},ti=(e,t,o,l)=>(mp(e,t,"write to private field"),t.set(e,o),o),k2=(e,t,o,l)=>({set _(s){ti(e,t,s)},get _(){return $(e,t,l)}}),Kt=(e,t,o)=>(mp(e,t,"access private method"),o),Qt=new Uint8Array(8),Eo=new DataView(Qt.buffer),Wn=e=>[(e%256+256)%256],un=e=>(Eo.setUint16(0,e,!1),[Qt[0],Qt[1]]),R2=e=>(Eo.setInt16(0,e,!1),[Qt[0],Qt[1]]),fx=e=>(Eo.setUint32(0,e,!1),[Qt[1],Qt[2],Qt[3]]),st=e=>(Eo.setUint32(0,e,!1),[Qt[0],Qt[1],Qt[2],Qt[3]]),z2=e=>(Eo.setInt32(0,e,!1),[Qt[0],Qt[1],Qt[2],Qt[3]]),Zl=e=>(Eo.setUint32(0,Math.floor(e/2**32),!1),Eo.setUint32(4,e,!1),[Qt[0],Qt[1],Qt[2],Qt[3],Qt[4],Qt[5],Qt[6],Qt[7]]),gp=e=>(Eo.setInt16(0,2**8*e,!1),[Qt[0],Qt[1]]),To=e=>(Eo.setInt32(0,2**16*e,!1),[Qt[0],Qt[1],Qt[2],Qt[3]]),bf=e=>(Eo.setInt32(0,2**30*e,!1),[Qt[0],Qt[1],Qt[2],Qt[3]]),Qi=(e,t=!1)=>{let o=Array(e.length).fill(null).map((l,s)=>e.charCodeAt(s));return t&&o.push(0),o},Jc=e=>e&&e[e.length-1],yp=e=>{let t;for(let o of e)(!t||o.presentationTimestamp>t.presentationTimestamp)&&(t=o);return t},Co=(e,t,o=!0)=>{let l=e*t;return o?Math.round(l):l},px=e=>{let t=e*(Math.PI/180),o=Math.cos(t),l=Math.sin(t);return[o,l,0,-l,o,0,0,0,1]},hx=px(0),mx=e=>[To(e[0]),To(e[1]),bf(e[2]),To(e[3]),To(e[4]),bf(e[5]),To(e[6]),To(e[7]),bf(e[8])],ir=e=>!e||typeof e!="object"?e:Array.isArray(e)?e.map(ir):Object.fromEntries(Object.entries(e).map(([t,o])=>[t,ir(o)])),Xa=e=>e>=0&&e<2**32,Jn=(e,t,o)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:o}),Mn=(e,t,o,l,s)=>Jn(e,[Wn(t),fx(o),l??[]],s),I2=e=>{let t=512;return e.fragmented?Jn("ftyp",[Qi("iso5"),st(t),Qi("iso5"),Qi("iso6"),Qi("mp41")]):Jn("ftyp",[Qi("isom"),st(t),Qi("isom"),e.holdsAvc?Qi("avc1"):[],Qi("mp41")])},Hf=e=>({type:"mdat",largeSize:e}),D2=e=>({type:"free",size:e}),Ic=(e,t,o=!1)=>Jn("moov",null,[L2(t,e),...e.map(l=>U2(l,t)),o?pk(e):null]),L2=(e,t)=>{let o=Co(Math.max(0,...t.filter(f=>f.samples.length>0).map(f=>{const g=yp(f.samples);return g.presentationTimestamp+g.duration})),qf),l=Math.max(...t.map(f=>f.id))+1,s=!Xa(e)||!Xa(o),d=s?Zl:st;return Mn("mvhd",+s,0,[d(e),d(e),st(qf),d(o),To(1),gp(1),Array(10).fill(0),mx(hx),Array(24).fill(0),st(l)])},U2=(e,t)=>Jn("trak",null,[F2(e,t),P2(e,t)]),F2=(e,t)=>{let o=yp(e.samples),l=Co(o?o.presentationTimestamp+o.duration:0,qf),s=!Xa(t)||!Xa(l),d=s?Zl:st,f;return e.info.type==="video"?f=typeof e.info.rotation=="number"?px(e.info.rotation):e.info.rotation:f=hx,Mn("tkhd",+s,3,[d(t),d(t),st(e.id),st(0),d(l),Array(8).fill(0),un(0),un(0),gp(e.info.type==="audio"?1:0),un(0),mx(f),To(e.info.type==="video"?e.info.width:0),To(e.info.type==="video"?e.info.height:0)])},P2=(e,t)=>Jn("mdia",null,[B2(e,t),j2(e.info.type==="video"?"vide":"soun"),O2(e)]),B2=(e,t)=>{let o=yp(e.samples),l=Co(o?o.presentationTimestamp+o.duration:0,e.timescale),s=!Xa(t)||!Xa(l),d=s?Zl:st;return Mn("mdhd",+s,0,[d(t),d(t),st(e.timescale),d(l),un(21956),un(0)])},j2=e=>Mn("hdlr",0,0,[Qi("mhlr"),Qi(e),st(0),st(0),st(0),Qi("mp4-muxer-hdlr",!0)]),O2=e=>Jn("minf",null,[e.info.type==="video"?V2():H2(),G2(),Y2(e)]),V2=()=>Mn("vmhd",0,1,[un(0),un(0),un(0),un(0)]),H2=()=>Mn("smhd",0,0,[un(0),un(0)]),G2=()=>Jn("dinf",null,[$2()]),$2=()=>Mn("dref",0,0,[st(1)],[q2()]),q2=()=>Mn("url ",0,1),Y2=e=>{const t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(o=>o.sampleCompositionTimeOffset!==0);return Jn("stbl",null,[J2(e),sk(e),rk(e),ck(e),uk(e),dk(e),t?fk(e):null])},J2=e=>Mn("stsd",0,0,[st(1)],[e.info.type==="video"?K2(Tk[e.info.codec],e):ok(Ek[e.info.codec],e)]),K2=(e,t)=>Jn(e,[Array(6).fill(0),un(1),un(0),un(0),Array(12).fill(0),un(t.info.width),un(t.info.height),st(4718592),st(4718592),st(0),un(1),Array(32).fill(0),un(24),R2(65535)],[Ck[t.info.codec](t),t.info.decoderConfig.colorSpace?Z2(t):null]),X2={bt709:1,bt470bg:5,smpte170m:6},W2={bt709:1,smpte170m:6,"iec61966-2-1":13},Q2={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Z2=e=>Jn("colr",[Qi("nclx"),un(X2[e.info.decoderConfig.colorSpace.primaries]),un(W2[e.info.decoderConfig.colorSpace.transfer]),un(Q2[e.info.decoderConfig.colorSpace.matrix]),Wn((e.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),ek=e=>e.info.decoderConfig&&Jn("avcC",[...new Uint8Array(e.info.decoderConfig.description)]),tk=e=>e.info.decoderConfig&&Jn("hvcC",[...new Uint8Array(e.info.decoderConfig.description)]),nk=e=>{if(!e.info.decoderConfig)return null;let t=e.info.decoderConfig;if(!t.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let o=t.codec.split("."),l=Number(o[1]),s=Number(o[2]),g=(Number(o[3])<<4)+(0<<1)+Number(t.colorSpace.fullRange);return Mn("vpcC",1,0,[Wn(l),Wn(s),Wn(g),Wn(2),Wn(2),Wn(2),un(0)])},ik=()=>{let o=(1<<7)+1;return Jn("av1C",[o,0,0,0])},ok=(e,t)=>Jn(e,[Array(6).fill(0),un(1),un(0),un(0),st(0),un(t.info.numberOfChannels),un(16),un(0),un(0),To(t.info.sampleRate)],[_k[t.info.codec](t)]),lk=e=>{let t=new Uint8Array(e.info.decoderConfig.description);return Mn("esds",0,0,[st(58753152),Wn(32+t.byteLength),un(1),Wn(0),st(75530368),Wn(18+t.byteLength),Wn(64),Wn(21),fx(0),st(130071),st(130071),st(92307584),Wn(t.byteLength),...t,st(109084800),Wn(1),Wn(2)])},ak=e=>{let t=3840,o=0;const l=e.info.decoderConfig?.description;if(l){if(l.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const s=ArrayBuffer.isView(l)?new DataView(l.buffer,l.byteOffset,l.byteLength):new DataView(l);t=s.getUint16(10,!0),o=s.getInt16(14,!0)}return Jn("dOps",[Wn(0),Wn(e.info.numberOfChannels),un(t),st(e.info.sampleRate),gp(o),Wn(0)])},sk=e=>Mn("stts",0,0,[st(e.timeToSampleTable.length),e.timeToSampleTable.map(t=>[st(t.sampleCount),st(t.sampleDelta)])]),rk=e=>{if(e.samples.every(o=>o.type==="key"))return null;let t=[...e.samples.entries()].filter(([,o])=>o.type==="key");return Mn("stss",0,0,[st(t.length),t.map(([o])=>st(o+1))])},ck=e=>Mn("stsc",0,0,[st(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(t=>[st(t.firstChunk),st(t.samplesPerChunk),st(1)])]),uk=e=>Mn("stsz",0,0,[st(0),st(e.samples.length),e.samples.map(t=>st(t.size))]),dk=e=>e.finalizedChunks.length>0&&Jc(e.finalizedChunks).offset>=2**32?Mn("co64",0,0,[st(e.finalizedChunks.length),e.finalizedChunks.map(t=>Zl(t.offset))]):Mn("stco",0,0,[st(e.finalizedChunks.length),e.finalizedChunks.map(t=>st(t.offset))]),fk=e=>Mn("ctts",0,0,[st(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(t=>[st(t.sampleCount),st(t.sampleCompositionTimeOffset)])]),pk=e=>Jn("mvex",null,e.map(hk)),hk=e=>Mn("trex",0,0,[st(e.id),st(1),st(0),st(0),st(0)]),sv=(e,t)=>Jn("moof",null,[mk(e),...t.map(gk)]),mk=e=>Mn("mfhd",0,0,[st(e)]),gx=e=>{let t=0,o=0,l=0,s=0,d=e.type==="delta";return o|=+d,d?t|=1:t|=2,t<<24|o<<16|l<<8|s},gk=e=>Jn("traf",null,[yk(e),vk(e),xk(e)]),yk=e=>{let t=0;t|=8,t|=16,t|=32,t|=131072;let o=e.currentChunk.samples[1]??e.currentChunk.samples[0],l={duration:o.timescaleUnitsToNextSample,size:o.size,flags:gx(o)};return Mn("tfhd",0,t,[st(e.id),st(l.duration),st(l.size),st(l.flags)])},vk=e=>Mn("tfdt",1,0,[Zl(Co(e.currentChunk.startTimestamp,e.timescale))]),xk=e=>{let t=e.currentChunk.samples.map(F=>F.timescaleUnitsToNextSample),o=e.currentChunk.samples.map(F=>F.size),l=e.currentChunk.samples.map(gx),s=e.currentChunk.samples.map(F=>Co(F.presentationTimestamp-F.decodeTimestamp,e.timescale)),d=new Set(t),f=new Set(o),g=new Set(l),v=new Set(s),m=g.size===2&&l[0]!==l[1],x=d.size>1,b=f.size>1,S=!m&&g.size>1,_=v.size>1||[...v].some(F=>F!==0),T=0;return T|=1,T|=4*+m,T|=256*+x,T|=512*+b,T|=1024*+S,T|=2048*+_,Mn("trun",1,T,[st(e.currentChunk.samples.length),st(e.currentChunk.offset-e.currentChunk.moofOffset||0),m?st(l[0]):[],e.currentChunk.samples.map((F,z)=>[x?st(t[z]):[],b?st(o[z]):[],S?st(l[z]):[],_?z2(s[z]):[]])])},bk=e=>Jn("mfra",null,[...e.map(Sk),wk()]),Sk=(e,t)=>Mn("tfra",1,0,[st(e.id),st(63),st(e.finalizedChunks.length),e.finalizedChunks.map(l=>[Zl(Co(l.startTimestamp,e.timescale)),Zl(l.moofOffset),st(t+1),st(1),st(1)])]),wk=()=>Mn("mfro",0,0,[st(0)]),Tk={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Ck={avc:ek,hevc:tk,vp9:nk,av1:ik},Ek={aac:"mp4a",opus:"Opus"},_k={aac:lk,opus:ak},ru=class{},vp=class extends ru{constructor(){super(...arguments),this.buffer=null}},yx=class extends ru{constructor(e){if(super(),this.options=e,typeof e!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(e.onData){if(typeof e.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(e.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(e.chunked!==void 0&&typeof e.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(e.chunkSize!==void 0&&(!Number.isInteger(e.chunkSize)||e.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},Nk=class extends ru{constructor(e,t){if(super(),this.stream=e,this.options=t,!(e instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(t!==void 0&&typeof t!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(t&&t.chunkSize!==void 0&&(!Number.isInteger(t.chunkSize)||t.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},ql,ja,vx=class{constructor(){this.pos=0,Vt(this,ql,new Uint8Array(8)),Vt(this,ja,new DataView($(this,ql).buffer)),this.offsets=new WeakMap}seek(e){this.pos=e}writeU32(e){$(this,ja).setUint32(0,e,!1),this.write($(this,ql).subarray(0,4))}writeU64(e){$(this,ja).setUint32(0,Math.floor(e/2**32),!1),$(this,ja).setUint32(4,e,!1),this.write($(this,ql).subarray(0,8))}writeAscii(e){for(let t=0;to.start-l.start);e.push({start:t[0].start,size:t[0].data.byteLength});for(let o=1;og.start<=t&&tkk){for(let g=0;g<$(this,ji).length-1;g++)$(this,ji)[g].shouldFlush=!0;Kt(this,lr,Xc).call(this)}d.byteLength=e.written[s+1].start;)e.written[s].end=Math.max(e.written[s].end,e.written[s+1].end),e.written.splice(s+1,1)};bp=new WeakSet;bx=function(e){let o={start:Math.floor(e/$(this,qo))*$(this,qo),data:new Uint8Array($(this,qo)),written:[],shouldFlush:!1};return $(this,ji).push(o),$(this,ji).sort((l,s)=>l.start-s.start),$(this,ji).indexOf(o)};lr=new WeakSet;Xc=function(e=!1){for(let t=0;t<$(this,ji).length;t++){let o=$(this,ji)[t];if(!(!o.shouldFlush&&!e)){for(let l of o.written)$(this,or).options.onData?.(o.data.subarray(l.start,l.end),o.start+l.start);$(this,ji).splice(t--,1)}}};var Rk=class extends Sp{constructor(e){super(new yx({onData:(t,o)=>e.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:e.options?.chunkSize}))}},qf=1e3,zk=["avc","hevc","vp9","av1"],Ik=["aac","opus"],Dk=2082844800,Lk=["strict","offset","cross-track-offset"],Ct,kt,Wc,Pi,ci,ei,Ga,Ka,wp,Jl,Kl,ar,Yf,Sx,Jf,wx,Tp,Tx,Kf,Cx,Cp,Ex,Uc,Xf,So,$o,Ep,_x,sr,Qc,Zc,_p,Wa,dr,Fc,Wf,Nx=class{constructor(e){if(Vt(this,Yf),Vt(this,Jf),Vt(this,Tp),Vt(this,Kf),Vt(this,Cp),Vt(this,Uc),Vt(this,So),Vt(this,Ep),Vt(this,sr),Vt(this,Zc),Vt(this,Wa),Vt(this,Fc),Vt(this,Ct,void 0),Vt(this,kt,void 0),Vt(this,Wc,void 0),Vt(this,Pi,void 0),Vt(this,ci,null),Vt(this,ei,null),Vt(this,Ga,Math.floor(Date.now()/1e3)+Dk),Vt(this,Ka,[]),Vt(this,wp,1),Vt(this,Jl,[]),Vt(this,Kl,[]),Vt(this,ar,!1),Kt(this,Yf,Sx).call(this,e),e.video=ir(e.video),e.audio=ir(e.audio),e.fastStart=ir(e.fastStart),this.target=e.target,ti(this,Ct,{firstTimestampBehavior:"strict",...e}),e.target instanceof vp)ti(this,kt,new Ak(e.target));else if(e.target instanceof yx)ti(this,kt,new Sp(e.target));else if(e.target instanceof Nk)ti(this,kt,new Rk(e.target));else throw new Error(`Invalid target: ${e.target}`);Kt(this,Kf,Cx).call(this),Kt(this,Jf,wx).call(this)}addVideoChunk(e,t,o,l){if(!(e instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(t&&typeof t!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(l!==void 0&&!Number.isFinite(l))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let s=new Uint8Array(e.byteLength);e.copyTo(s),this.addVideoChunkRaw(s,e.type,o??e.timestamp,e.duration,t,l)}addVideoChunkRaw(e,t,o,l,s,d){if(!(e instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(o)||o<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(l)||l<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(s&&typeof s!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(d!==void 0&&!Number.isFinite(d))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Kt(this,Fc,Wf).call(this),!$(this,Ct).video)throw new Error("No video track declared.");if(typeof $(this,Ct).fastStart=="object"&&$(this,ci).samples.length===$(this,Ct).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${$(this,Ct).fastStart.expectedVideoChunks}).`);let f=Kt(this,Uc,Xf).call(this,$(this,ci),e,t,o,l,s,d);if($(this,Ct).fastStart==="fragmented"&&$(this,ei)){for(;$(this,Kl).length>0&&$(this,Kl)[0].decodeTimestamp<=f.decodeTimestamp;){let g=$(this,Kl).shift();Kt(this,So,$o).call(this,$(this,ei),g)}f.decodeTimestamp<=$(this,ei).lastDecodeTimestamp?Kt(this,So,$o).call(this,$(this,ci),f):$(this,Jl).push(f)}else Kt(this,So,$o).call(this,$(this,ci),f)}addAudioChunk(e,t,o){if(!(e instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(t&&typeof t!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let l=new Uint8Array(e.byteLength);e.copyTo(l),this.addAudioChunkRaw(l,e.type,o??e.timestamp,e.duration,t)}addAudioChunkRaw(e,t,o,l,s){if(!(e instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(o)||o<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(l)||l<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(s&&typeof s!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Kt(this,Fc,Wf).call(this),!$(this,Ct).audio)throw new Error("No audio track declared.");if(typeof $(this,Ct).fastStart=="object"&&$(this,ei).samples.length===$(this,Ct).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${$(this,Ct).fastStart.expectedAudioChunks}).`);let d=Kt(this,Uc,Xf).call(this,$(this,ei),e,t,o,l,s);if($(this,Ct).fastStart==="fragmented"&&$(this,ci)){for(;$(this,Jl).length>0&&$(this,Jl)[0].decodeTimestamp<=d.decodeTimestamp;){let f=$(this,Jl).shift();Kt(this,So,$o).call(this,$(this,ci),f)}d.decodeTimestamp<=$(this,ci).lastDecodeTimestamp?Kt(this,So,$o).call(this,$(this,ei),d):$(this,Kl).push(d)}else Kt(this,So,$o).call(this,$(this,ei),d)}finalize(){if($(this,ar))throw new Error("Cannot finalize a muxer more than once.");if($(this,Ct).fastStart==="fragmented"){for(let t of $(this,Jl))Kt(this,So,$o).call(this,$(this,ci),t);for(let t of $(this,Kl))Kt(this,So,$o).call(this,$(this,ei),t);Kt(this,Zc,_p).call(this,!1)}else $(this,ci)&&Kt(this,sr,Qc).call(this,$(this,ci)),$(this,ei)&&Kt(this,sr,Qc).call(this,$(this,ei));let e=[$(this,ci),$(this,ei)].filter(Boolean);if($(this,Ct).fastStart==="in-memory"){let t;for(let l=0;l<2;l++){let s=Ic(e,$(this,Ga)),d=$(this,kt).measureBox(s);t=$(this,kt).measureBox($(this,Pi));let f=$(this,kt).pos+d+t;for(let g of $(this,Ka)){g.offset=f;for(let{data:v}of g.samples)f+=v.byteLength,t+=v.byteLength}if(f<2**32)break;t>=2**32&&($(this,Pi).largeSize=!0)}let o=Ic(e,$(this,Ga));$(this,kt).writeBox(o),$(this,Pi).size=t,$(this,kt).writeBox($(this,Pi));for(let l of $(this,Ka))for(let s of l.samples)$(this,kt).write(s.data),s.data=null}else if($(this,Ct).fastStart==="fragmented"){let t=$(this,kt).pos,o=bk(e);$(this,kt).writeBox(o);let l=$(this,kt).pos-t;$(this,kt).seek($(this,kt).pos-4),$(this,kt).writeU32(l)}else{let t=$(this,kt).offsets.get($(this,Pi)),o=$(this,kt).pos-t;$(this,Pi).size=o,$(this,Pi).largeSize=o>=2**32,$(this,kt).patchBox($(this,Pi));let l=Ic(e,$(this,Ga));if(typeof $(this,Ct).fastStart=="object"){$(this,kt).seek($(this,Wc)),$(this,kt).writeBox(l);let s=t-$(this,kt).pos;$(this,kt).writeBox(D2(s))}else $(this,kt).writeBox(l)}Kt(this,Wa,dr).call(this),$(this,kt).finalize(),ti(this,ar,!0)}};Ct=new WeakMap;kt=new WeakMap;Wc=new WeakMap;Pi=new WeakMap;ci=new WeakMap;ei=new WeakMap;Ga=new WeakMap;Ka=new WeakMap;wp=new WeakMap;Jl=new WeakMap;Kl=new WeakMap;ar=new WeakMap;Yf=new WeakSet;Sx=function(e){if(typeof e!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(e.target instanceof ru))throw new TypeError("The target must be provided and an instance of Target.");if(e.video){if(!zk.includes(e.video.codec))throw new TypeError(`Unsupported video codec: ${e.video.codec}`);if(!Number.isInteger(e.video.width)||e.video.width<=0)throw new TypeError(`Invalid video width: ${e.video.width}. Must be a positive integer.`);if(!Number.isInteger(e.video.height)||e.video.height<=0)throw new TypeError(`Invalid video height: ${e.video.height}. Must be a positive integer.`);const t=e.video.rotation;if(typeof t=="number"&&![0,90,180,270].includes(t))throw new TypeError(`Invalid video rotation: ${t}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(t)&&(t.length!==9||t.some(o=>typeof o!="number")))throw new TypeError(`Invalid video transformation matrix: ${t.join()}`);if(e.video.frameRate!==void 0&&(!Number.isInteger(e.video.frameRate)||e.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${e.video.frameRate}. Must be a positive integer.`)}if(e.audio){if(!Ik.includes(e.audio.codec))throw new TypeError(`Unsupported audio codec: ${e.audio.codec}`);if(!Number.isInteger(e.audio.numberOfChannels)||e.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${e.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(e.audio.sampleRate)||e.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${e.audio.sampleRate}. Must be a positive integer.`)}if(e.firstTimestampBehavior&&!Lk.includes(e.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${e.firstTimestampBehavior}`);if(typeof e.fastStart=="object"){if(e.video){if(e.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(e.fastStart.expectedVideoChunks)||e.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(e.audio){if(e.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(e.fastStart.expectedAudioChunks)||e.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(e.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(e.minFragmentDuration!==void 0&&(!Number.isFinite(e.minFragmentDuration)||e.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};Jf=new WeakSet;wx=function(){if($(this,kt).writeBox(I2({holdsAvc:$(this,Ct).video?.codec==="avc",fragmented:$(this,Ct).fastStart==="fragmented"})),ti(this,Wc,$(this,kt).pos),$(this,Ct).fastStart==="in-memory")ti(this,Pi,Hf(!1));else if($(this,Ct).fastStart!=="fragmented"){if(typeof $(this,Ct).fastStart=="object"){let e=Kt(this,Tp,Tx).call(this);$(this,kt).seek($(this,kt).pos+e)}ti(this,Pi,Hf(!0)),$(this,kt).writeBox($(this,Pi))}Kt(this,Wa,dr).call(this)};Tp=new WeakSet;Tx=function(){if(typeof $(this,Ct).fastStart!="object")return;let e=0,t=[$(this,Ct).fastStart.expectedVideoChunks,$(this,Ct).fastStart.expectedAudioChunks];for(let o of t)o&&(e+=8*Math.ceil(2/3*o),e+=4*o,e+=12*Math.ceil(2/3*o),e+=4*o,e+=8*o);return e+=4096,e};Kf=new WeakSet;Cx=function(){if($(this,Ct).video&&ti(this,ci,{id:1,info:{type:"video",codec:$(this,Ct).video.codec,width:$(this,Ct).video.width,height:$(this,Ct).video.height,rotation:$(this,Ct).video.rotation??0,decoderConfig:null},timescale:$(this,Ct).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),$(this,Ct).audio&&(ti(this,ei,{id:$(this,Ct).video?2:1,info:{type:"audio",codec:$(this,Ct).audio.codec,numberOfChannels:$(this,Ct).audio.numberOfChannels,sampleRate:$(this,Ct).audio.sampleRate,decoderConfig:null},timescale:$(this,Ct).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),$(this,Ct).audio.codec==="aac")){let e=Kt(this,Cp,Ex).call(this,2,$(this,Ct).audio.sampleRate,$(this,Ct).audio.numberOfChannels);$(this,ei).info.decoderConfig={codec:$(this,Ct).audio.codec,description:e,numberOfChannels:$(this,Ct).audio.numberOfChannels,sampleRate:$(this,Ct).audio.sampleRate}}};Cp=new WeakSet;Ex=function(e,t,o){let s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(t),d=o,f="";f+=e.toString(2).padStart(5,"0"),f+=s.toString(2).padStart(4,"0"),s===15&&(f+=t.toString(2).padStart(24,"0")),f+=d.toString(2).padStart(4,"0");let g=Math.ceil(f.length/8)*8;f=f.padEnd(g,"0");let v=new Uint8Array(f.length/8);for(let m=0;m=f&&(l=!0,Kt(this,Zc,_p).call(this))}else l=s>=.5}l&&(e.currentChunk&&Kt(this,sr,Qc).call(this,e),e.currentChunk={startTimestamp:t.presentationTimestamp,samples:[]}),e.currentChunk.samples.push(t)};Ep=new WeakSet;_x=function(e,t,o){const l=$(this,Ct).firstTimestampBehavior==="strict",s=o.lastDecodeTimestamp===-1;if(l&&s&&t!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${t}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want. - -If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options. -`);if($(this,Ct).firstTimestampBehavior==="offset"||$(this,Ct).firstTimestampBehavior==="cross-track-offset"){o.firstDecodeTimestamp===void 0&&(o.firstDecodeTimestamp=t);let f;$(this,Ct).firstTimestampBehavior==="offset"?f=o.firstDecodeTimestamp:f=Math.min($(this,ci)?.firstDecodeTimestamp??1/0,$(this,ei)?.firstDecodeTimestamp??1/0),t-=f,e-=f}if(tg&&g.currentChunk);if(t.length===0)return;let o=k2(this,wp)._++;if(o===1){let g=Ic(t,$(this,Ga),!0);$(this,kt).writeBox(g)}let l=$(this,kt).pos,s=sv(o,t);$(this,kt).writeBox(s);{let g=Hf(!1),v=0;for(let x of t)for(let b of x.currentChunk.samples)v+=b.size;let m=$(this,kt).measureBox(g)+v;m>=2**32&&(g.largeSize=!0,m=$(this,kt).measureBox(g)+v),g.size=m,$(this,kt).writeBox(g)}for(let g of t){g.currentChunk.offset=$(this,kt).pos,g.currentChunk.moofOffset=l;for(let v of g.currentChunk.samples)$(this,kt).write(v.data),v.data=null}let d=$(this,kt).pos;$(this,kt).seek($(this,kt).offsets.get(s));let f=sv(o,t);$(this,kt).writeBox(f),$(this,kt).seek(d);for(let g of t)g.finalizedChunks.push(g.currentChunk),$(this,Ka).push(g.currentChunk),g.currentChunk=null;e&&Kt(this,Wa,dr).call(this)};Wa=new WeakSet;dr=function(){$(this,kt)instanceof Sp&&$(this,kt).flush()};Fc=new WeakSet;Wf=function(){if($(this,ar))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};function Np(){return typeof window<"u"&&"VideoEncoder"in window&&"AudioEncoder"in window}async function Qf(e){const t=await e.arrayBuffer(),o=new(window.AudioContext||window.webkitAudioContext),l=await o.decodeAudioData(t);return o.close(),l}async function Ax(e,t,o,l){const s=[];e.forEach((d,f)=>{let g=-1;if(f==="__custom_bg_video__"){const v=d.duration||1;v>0&&(g=(l!==void 0?l:o)%v)}else if(f==="background"){const v=d.duration||1;v>0&&(g=o%v)}else{const v=t.find(m=>m.id===f);if(v&&v.type==="video"&&o>=v.startTime&&o0&&x>=b&&(x=x%b),g=x}}if(g>=0){if(d.readyState===0)return;Math.abs(d.currentTime-g)>.05&&s.push(new Promise(v=>{let m=!1;const x=()=>{m||(m=!0,d.removeEventListener("seeked",x),v())};d.addEventListener("seeked",x),d.currentTime=g,setTimeout(()=>{m||(m=!0,d.removeEventListener("seeked",x),v())},500)}))}}),s.length>0&&await Promise.all(s)}async function Uk(e,t,o){if(!(o.has(e)&&o.get(e)?.src===t))return new Promise(l=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>{o.set(e,s),l()},s.onerror=()=>{console.warn("Failed to load background image:",t),l()},s.src=t})}async function Fk(e,t,o){if(!(o.has(e)&&o.get(e)?.src===t))return new Promise(l=>{const s=document.createElement("video");s.crossOrigin="anonymous",s.muted=!0,s.playsInline=!0,s.preload="auto";let d=!1;const f=()=>{d||(d=!0,o.set(e,s),l())};s.oncanplay=()=>{d||(s.currentTime=.001)},s.onseeked=()=>f(),s.onerror=()=>{console.warn("Failed to load background video:",t),f()},setTimeout(()=>f(),1e4),s.src=t,s.load()})}async function Pk(e){const{canvas:t,audioFile:o,lyrics:l,metadata:s,visualSlides:d,imageMap:f,videoMap:g,preset:v,customFontName:m,renderConfig:x,fps:b,quality:S,onProgress:_,onLog:T,abortSignal:F,isFirstSong:z=!0,isLastSong:G=!0,startTimeOffset:Y=0}=e;if(!Np())throw new Error("WebCodecs API is not supported in this browser.");const oe=()=>F?.aborted===!0||F?.current===!0;_(0,"Initializing WebCodecs..."),T?.("Decoding audio...");const ce=await Qf(o),ve=ce.duration,ye=Math.ceil(ve*b),fe=new Nx({target:new vp,video:{codec:"avc",width:t.width,height:t.height},audio:{codec:"aac",sampleRate:ce.sampleRate,numberOfChannels:ce.numberOfChannels},fastStart:"in-memory"}),qe=(e.resolution==="1080p"?8e6:4e6)*(S==="high"?1.5:S==="low"?.5:1),Ve=new VideoEncoder({output:(X,Ee)=>fe.addVideoChunk(X,Ee),error:X=>{console.error("VideoEncoder error:",X),T?.(`VideoEncoder error: ${X.message}`)}});Ve.configure({codec:"avc1.4d002a",width:t.width,height:t.height,bitrate:qe,framerate:b});const Ke=new AudioEncoder({output:(X,Ee)=>fe.addAudioChunk(X,Ee),error:X=>{console.error("AudioEncoder error:",X),T?.(`AudioEncoder error: ${X.message}`)}});Ke.configure({codec:"mp4a.40.2",sampleRate:ce.sampleRate,numberOfChannels:ce.numberOfChannels,bitrate:128e3}),_(5,"Encoding Audio...");const nt=ce.numberOfChannels,it=ce.sampleRate,xt=it,K=ce.length;for(let X=0;X10;)await new Promise(Ae=>setTimeout(Ae,10))}await Ke.flush(),_(10,"Rendering Frames...");const ze=t.getContext("2d",{desynchronized:!1});if(!ze)throw new Error("No canvas context");const Le=1/b*1e6,ut=x.showVisualization?ce.getChannelData(0):null,Me=ce.sampleRate;for(let X=0;X0,ve,x,G,z,He,et);const Ae=Math.round(X*Le),C=new VideoFrame(t,{timestamp:Ae,duration:Math.round(Le)});Ve.encode(C,{keyFrame:X%(b*2)===0}),C.close();const se=10+X/ye*89;_(se,`Rendering frame ${X}/${ye}`),Ve.encodeQueueSize>5&&await new Promise(ue=>{const me=()=>Ve.encodeQueueSize<=2?ue(null):setTimeout(me,10);me()}),X%2===0&&await new Promise(ue=>setTimeout(ue,0))}_(99,"Finalizing frames..."),await Ve.flush(),fe.finalize();const{buffer:L}=fe.target;return _(100,"Done!"),{blob:new Blob([L],{type:"video/mp4"}),duration:ve,format:"mp4"}}async function Bk(e,t){const{canvas:o,visualSlides:l,imageMap:s,videoMap:d,preset:f,customFontName:g,renderConfig:v,fps:m,quality:x,onProgress:b,onLog:S,abortSignal:_}=t;if(!Np())throw new Error("WebCodecs API is not supported in this browser.");const T=()=>_?.aborted===!0||_?.current===!0;b(0,"Decoding first track...");const F=await Qf(e[0].audioFile),z=F.sampleRate,G=F.numberOfChannels;b(2,"Initializing WebCodecs Playlist Render...");const Y=new Nx({target:new vp,video:{codec:"avc",width:o.width,height:o.height},audio:{codec:"aac",sampleRate:z,numberOfChannels:G},fastStart:"in-memory"}),ve=(t.resolution==="1080p"?8e6:4e6)*(x==="high"?1.5:x==="low"?.5:1),ye=new VideoEncoder({output:(Ve,Ke)=>Y.addVideoChunk(Ve,Ke),error:Ve=>{console.error("VideoEncoder error:",Ve),S?.(`VideoEncoder error: ${Ve.message}`)}});ye.configure({codec:"avc1.4d002a",width:o.width,height:o.height,bitrate:ve,framerate:m});const fe=new AudioEncoder({output:(Ve,Ke)=>Y.addAudioChunk(Ve,Ke),error:Ve=>{console.error("AudioEncoder error:",Ve),S?.(`AudioEncoder error: ${Ve.message}`)}});fe.configure({codec:"mp4a.40.2",sampleRate:z,numberOfChannels:G,bitrate:128e3});let Je=0,ge=0;for(let Ve=0;Ve10&&await new Promise(se=>setTimeout(se,10))}const L=Math.ceil(K*m),X=1/m*1e6,Ee=o.getContext("2d");if(!Ee)throw new Error("No canvas context");for(let ke=0;ke0,K,v,it,nt,Ae,C);const se=Je+Math.round(ke*X),ue=new VideoFrame(o,{timestamp:se,duration:Math.round(X)});ye.encode(ue,{keyFrame:ke%(m*2)===0}),ue.close();const me=ke/L,q=(Ve+me)/e.length*100;b(q,`Song ${Ve+1}/${e.length}: Rendering frame ${ke}/${L}`),ye.encodeQueueSize>5&&await new Promise(Ie=>{const Re=()=>ye.encodeQueueSize<=2?Ie(null):setTimeout(Re,10);Re()}),ke%5===0&&await new Promise(Ie=>setTimeout(Ie,0))}Je+=Math.round(K*1e6)}b(99,"Flushing encoders..."),fe.state!=="closed"&&await fe.flush(),ye.state!=="closed"&&await ye.flush(),Y.finalize();const{buffer:qe}=Y.target;return b(100,"Done!"),{blob:new Blob([qe],{type:"video/mp4"}),duration:ge,format:"mp4"}}function jk(){const{toast:e,confirm:t}=ur(),o=Z.useRef(null),l=Z.useRef(null),s=Z.useRef(null),d=Z.useRef(null),f=Z.useRef(null),g=Z.useRef({aborted:!1}),v=Z.useRef(()=>{});Z.useEffect(()=>{ZM()},[]);const[m,x]=Z.useState(null),[b,S]=Z.useState(0),[_,T]=Z.useState({title:"No Audio Loaded",artist:"Select a file",coverUrl:null}),[F,z]=Z.useState([]),[G,Y]=Z.useState([]),[oe,ce]=Z.useState(0),[ve,ye]=Z.useState(!1),[fe,Je]=Z.useState("off"),[ge,qe]=Z.useState(0),[Ve,Ke]=Z.useState(0),[nt,it]=Z.useState(1),[xt,K]=Z.useState(!1),[ze,Le]=Z.useState(ri.PLAYER),[ut,Me]=Z.useState(!1),[L,X]=Z.useState(!1),[Ee,ke]=Z.useState(!1),[He,et]=Z.useState(!1),[Ae,C]=Z.useState(!1),[se,ue]=Z.useState(0),[me,q]=Z.useState("16:9"),[Ie,Re]=Z.useState("1080p"),[ee,be]=Z.useState("default"),[$e,Oe]=Z.useState(null),[ht,R]=Z.useState(null),[Ue,We]=Z.useState(null),[Xe,Ye]=Z.useState("auto"),[ft,jt]=Z.useState(30),[gt,Et]=Z.useState("med"),[A,W]=Z.useState("mediarecorder"),[M,D]=Z.useState("h264"),[k,ne]=Z.useState(""),[B,te]=Z.useState(!1),[j,we]=Z.useState(!1),[E,O]=Z.useState({backgroundSource:"custom",backgroundColor:"#581c87",backgroundGradient:"linear-gradient(to bottom right, #312e81, #581c87, #000000)",renderMode:"current",textAlign:"center",contentPosition:"center",fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSizeScale:1,fontColor:"#ffffff",textEffect:"preset",textAnimation:"none",transitionEffect:"none",lyricDisplayMode:"all",fontWeight:"bold",fontStyle:"normal",lyricStyleTarget:"active-only",textDecoration:"none",showTitle:!0,showArtist:!0,showCover:!0,showIntro:!0,showLyrics:!0,infoPosition:"top-left",infoStyle:"classic",infoMarginScale:1,backgroundBlurStrength:0,introMode:"auto",introText:"",textCase:"none",highlightEffect:"karaoke",lyricLineHeight:1.3,useRealColorMedia:!1,channelInfoFontWeight:"bold",channelInfoFontStyle:"normal",infoFontWeight:"bold",infoFontStyle:"normal"}),V=Z.useRef(E);Z.useEffect(()=>{V.current=E},[E]);const Fe=Z.useRef(null),Be=Z.useRef(null),tt=E.backgroundBlurStrength>0,St=Z.useMemo(()=>[{label:"VP9 (WebM)",value:"video/webm; codecs=vp9,opus"},{label:"H.264 (MP4)",value:'video/mp4; codecs="avc1.4D401E, mp4a.40.2"'},{label:"AV1 (MP4)",value:'video/mp4; codecs="av01.0.05M.08"'},{label:"AV1 (WebM)",value:"video/webm; codecs=av1"},{label:"H.264 High (MP4)",value:'video/mp4; codecs="avc1.64001E, mp4a.40.2"'}].filter(Q=>MediaRecorder.isTypeSupported(Q.value)),[]),[_e,Ot]=Z.useState([]),[Se,he]=Z.useState(-1),[dt,Dt]=Z.useState(!1),vt=()=>{const I=Ie==="1080p";switch(me){case"9:16":return I?{w:1080,h:1920}:{w:720,h:1280};case"3:4":return I?{w:1080,h:1440}:{w:720,h:960};case"4:3":return I?{w:1440,h:1080}:{w:960,h:720};case"1:1":return I?{w:1080,h:1080}:{w:720,h:720};case"1:2":return I?{w:1080,h:2160}:{w:720,h:1440};case"2:1":return I?{w:2160,h:1080}:{w:1440,h:720};case"2:3":return I?{w:1080,h:1620}:{w:720,h:1080};case"3:2":return I?{w:1620,h:1080}:{w:1080,h:720};case"4:5":return I?{w:1080,h:1350}:{w:720,h:900};case"20:9":return I?{w:2400,h:1080}:{w:1600,h:720};case"21:9":return I?{w:2560,h:1080}:{w:1720,h:720};default:return I?{w:1920,h:1080}:{w:1280,h:720}}},{w:Gt,h:dn}=vt(),[Fn,Si]=Z.useState(!0),[mi,ui]=Z.useState(!0),[Zt,Pn]=Z.useState(!1),mt=Z.useMemo(()=>{const I=E.visualTransitionType||"none",Q=E.visualTransitionDuration||1;return G.filter(ae=>ae.type==="audio"?!1:ge>=ae.startTime&&ge=ae.endTime&&ge{const je=(ae.layer||0)-(Te.layer||0);return je!==0?je:ae.startTime-Te.startTime})},[G,ge,E.visualTransitionType,E.visualTransitionDuration]),Ut=G.filter(I=>I.type==="audio"&&ge>=I.startTime&&geoe===0?F:F.map(I=>({...I,time:I.time+oe,endTime:I.endTime!==void 0?I.endTime+oe:void 0})),[F,oe]),Kn=on.findIndex((I,Q)=>{if(I.endTime!==void 0)return ge>=I.time&&ge=I.time&&(!De||ge{const Q=I.target.files?.[0];if(Q){const De=URL.createObjectURL(Q);x(De);const ae={title:Q.name.replace(/\.[^/.]+$/,""),artist:"Unknown Artist",coverUrl:null};T(ae),Q.type.startsWith("audio/")?Sf(()=>import("./jsmediatags.min-CQERko6n.js").then(Te=>Te.j),[]).then(Te=>{Te.read(Q,{onSuccess:je=>{const{title:ot,artist:_t,picture:bt}=je.tags;let Cn=null;if(bt){const{data:tn,format:Pe}=bt;let Mt="";for(let nn=0;nn{console.log("Error reading tags:",je)}})}):Q.type.startsWith("video/")&&(et(!1),T({...ae,coverUrl:De,backgroundType:"video"})),ce(0),ye(!1),qe(0),he(-1),s.current&&(s.current.scrollTop=0),o.current&&o.current.load()}I.target.value=""},zn=I=>{const Q=I.target.files?.[0];if(Q){const De=URL.createObjectURL(Q),ae=Q.type.startsWith("video/");ae&&et(!1),T(Te=>({...Te,coverUrl:De,backgroundType:ae?"video":"image"}))}I.target.value=""},Xo=async I=>{const Q=I.target.files?.[0];if(Q)try{const De=await Q.text(),ae=Q.name.split(".").pop()?.toLowerCase();let Te=[];ae==="lrc"?Te=El(De):ae==="srt"?Te=_l(De):ae==="ttml"||ae==="xml"?Te=Xl(De):ae==="vtt"&&(Te=Wl(De)),Te.some(je=>je.words&&je.words.length>0)&&(O(je=>({...je,highlightEffect:"karaoke"})),e.success(`${ae?.toUpperCase()} loaded with word-level timing! Karaoke mode enabled.`)),z(Te)}catch(De){console.error("Failed to parse lyrics:",De),e.error("Failed to parse lyric file.")}I.target.value=""};Z.useEffect(()=>{if(Se!==-1&&_e[Se]){const I=_e[Se];z(I.parsedLyrics||[])}},[_e,Se]);const to=async I=>{const Q=I.target.files?.[0];if(Q){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const De=URL.createObjectURL(Q),ae=Q.name.replace(/\.[^/.]+$/,""),Te="CustomFont",je=new FontFace(Te,`url(${De})`);await je.load(),document.fonts.add(je),Oe(ae),O(ot=>({...ot,fontFamily:Te})),e.success(`Loaded font: ${ae}`)}catch(De){console.error("Failed to load font:",De),e.error("Failed to load font file.")}}I.target.value=""},no=async I=>{const Q=I.target.files?.[0];if(Q){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const De=URL.createObjectURL(Q),ae=Q.name.replace(/\.[^/.]+$/,""),Te="ChannelFont",je=new FontFace(Te,`url(${De})`);await je.load(),document.fonts.add(je),R(ae),O(ot=>({...ot,channelInfoFontFamily:Te})),e.success(`Loaded Channel font: ${ae}`)}catch(De){console.error("Failed to load font:",De),e.error("Failed to load channel font file.")}}I.target.value=""},Al=async I=>{const Q=I.target.files?.[0];if(Q){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const De=URL.createObjectURL(Q),ae=Q.name.replace(/\.[^/.]+$/,""),Te="InfoFont",je=new FontFace(Te,`url(${De})`);await je.load(),document.fonts.add(je),We(ae),O(ot=>({...ot,infoFontFamily:Te})),e.success(`Loaded Info font: ${ae}`)}catch(De){console.error("Failed to load font:",De),e.error("Failed to load info font file.")}}I.target.value=""},Ni=Z.useCallback(async(I,Q=!0,De)=>{const ae=De||_e;if(I<0||I>=ae.length)return;const Te=ae[I],je=URL.createObjectURL(Te.audioFile);if(x(je),T({title:Te.metadata.title,artist:Te.metadata.artist,coverUrl:Te.metadata.coverUrl||null,backgroundType:Te.metadata.backgroundType||"image"}),z([]),Te.parsedLyrics&&Te.parsedLyrics.length>0)z(Te.parsedLyrics);else if(Te.lyricFile)try{const ot=await Te.lyricFile.text(),_t=Te.lyricFile.name.split(".").pop()?.toLowerCase();let bt=[];_t==="lrc"?bt=El(ot):_t==="srt"?bt=_l(ot):_t==="ttml"||_t==="xml"?bt=Xl(ot):_t==="vtt"&&(bt=Wl(ot)),z(bt)}catch(ot){console.error("Failed to load lyrics",ot)}ce(0),he(I),s.current&&(s.current.scrollTop=0),Q?setTimeout(()=>{o.current&&(o.current.play().catch(ot=>console.log("Autoplay failed",ot)),ye(!0))},100):(ye(!1),o.current&&(o.current.pause(),o.current.currentTime=0))},[_e]),kn=Z.useCallback(()=>{if(_e.length===0)return;const I=(Se+1)%_e.length;Ni(I)},[_e,Se,Ni]),ta=Z.useCallback(()=>{if(_e.length===0)return;const I=(Se-1+_e.length)%_e.length;Ni(I)},[_e,Se,Ni]),na=()=>{o.current&&(ve?(o.current.pause(),ye(!1)):!m&&_e.length>0?Ni(0):(o.current.play().catch(console.error),ye(!0)))},ii=Z.useCallback(()=>{o.current&&(o.current.pause(),o.current.currentTime=0,ye(!1),qe(0))},[]),_o=()=>{Je(I=>I==="off"?"one":I==="one"?"all":I==="all"?"all_repeat":"off")},fr=()=>{document.fullscreenElement?(document.exitFullscreen(),Me(!1)):(l.current?.requestFullscreen(),Me(!0))},ts=I=>{if(Ae||I&&I.target.closest(".no-minimal-mode-toggle"))return;const Q=!Zt;Pn(Q),Q&&ke(!0),e.success(`Minimal Mode: ${Q?"On":"Off"}`,{id:"minimal-mode"})},pr=()=>{o.current&&(qe(o.current.currentTime),Ae&&ue(o.current.currentTime/Ve*100))},cu=()=>{o.current&&Ke(o.current.duration)},ia=I=>{const Q=parseFloat(I.target.value);o.current&&(o.current.currentTime=Q,qe(Q))},Ml=I=>{if(!Fe.current||Ae||!Ve)return;const Q=Fe.current.getBoundingClientRect(),Te=Math.max(0,Math.min(I-Q.left,Q.width))/Q.width*Ve;o.current&&(o.current.currentTime=Te,qe(Te))},io=I=>{const Q=parseFloat(I.target.value);it(Q),o.current&&(o.current.volume=Q),K(Q===0)},gi=I=>{if(!Be.current)return;const Q=Be.current.getBoundingClientRect(),ae=Math.max(0,Math.min(I-Q.left,Q.width))/Q.width;it(ae),o.current&&(o.current.volume=ae),K(ae===0)},hr=async()=>{if(!o.current||!d.current)return;const I=E.renderMode==="playlist"&&_e.length>0;console.log(`[Render] Starting Export. Mode: ${E.renderMode}, Playlist Items: ${_e.length}, IsPlaylistRender: ${I}`),I?e.success(`Starting Playlist Render (${_e.length} songs)...`):e.success("Starting Single Track Render...");const Q=[];if(I)for(const at of _e){let At=[];if(at.parsedLyrics&&at.parsedLyrics.length>0)At=at.parsedLyrics;else if(at.lyricFile)try{const Qe=await at.lyricFile.text(),vn=at.lyricFile.name.split(".").pop()?.toLowerCase();vn==="lrc"?At=El(Qe):vn==="srt"?At=_l(Qe):vn==="ttml"||vn==="xml"?At=Xl(Qe):vn==="vtt"&&(At=Wl(Qe))}catch(Qe){console.error("Failed to parse lyrics for playlist item",Qe)}const Wt=URL.createObjectURL(at.audioFile);Q.push({audioSrc:Wt,lyrics:At,metadata:at.metadata,isFileSource:!0})}else{if(!m)return;Q.push({audioSrc:m,lyrics:on,metadata:_,isFileSource:!1})}if(Q.length===0)return;const De=I?`Start rendering ALL ${Q.length} songs from the playlist? This will result in one continuous video.`:`Start rendering ${me} (${Ie}) video? This will play the song from start to finish.`;if(!await t(`${De} Please do not switch tabs during rendering.`,"Start Rendering?")){I&&Q.forEach(at=>at.isFileSource&&URL.revokeObjectURL(at.audioSrc));return}te(!1),C(!0),ue(0);const Te={aborted:!1};g.current=Te,ii(),Je("off"),Qn.current&&clearTimeout(Qn.current),X(!1),ke(!0),On.current&&On.current.pause();const je=o.current,ot=ee,_t=new Map,bt=new Map,Cn=new Map,tn=[],Pe=(at,At)=>new Promise(Wt=>{const Qe=new Image;Qe.crossOrigin="anonymous",Qe.onload=()=>{_t.set(at,Qe),Wt()},Qe.onerror=()=>Wt(),Qe.src=At}),Mt=(at,At)=>new Promise(Wt=>{const Qe=document.createElement("video");Qe.crossOrigin="anonymous",Qe.muted=!0,Qe.playsInline=!0,Qe.preload="auto";let vn=!1;const rn=()=>{vn||(vn=!0,bt.set(at,Qe),Wt())};Qe.oncanplay=()=>{vn||(Qe.currentTime=.001)},Qe.onseeked=()=>rn(),Qe.onerror=()=>{console.warn("Failed to load video:",At),rn()},setTimeout(()=>rn(),5e3),Qe.src=At,Qe.load()}),nn=(at,At)=>new Promise(Wt=>{const Qe=document.createElement("audio");Qe.crossOrigin="anonymous",Qe.onloadedmetadata=()=>{Cn.set(at,Qe),Wt()},Qe.onerror=()=>Wt(),Qe.src=At});if(G.forEach(at=>{at.type==="video"?tn.push(Mt(at.id,at.url)):at.type==="audio"||at.type==="audio"?tn.push(nn(at.id,at.url)):tn.push(Pe(at.id,at.url))}),E.showChannelInfo&&(E.channelInfoImage&&tn.push(Pe("__channel_info__",E.channelInfoImage)),E.channelInfoText)){const at=E.channelInfoText.trim();if(//i.test(at))try{const At=document.createElement("div");At.style.position="absolute",At.style.visibility="hidden",At.style.whiteSpace="nowrap",At.style.fontFamily="sans-serif",At.style.fontWeight="bold",At.style.fontSize="100px",At.style.display="inline-flex",At.style.alignItems="center",At.style.gap="0.25em",At.innerHTML=at;const Wt=At.getElementsByTagName("svg");for(let fi=0;fi - -
- - ${at} -
-
- - `,Vi=`data:image/svg+xml;base64,${window.btoa(encodeURIComponent(rn).replace(/%([0-9A-F]{2})/g,function(go,ra){return String.fromCharCode(parseInt(ra,16))}))}`;tn.push(Pe("__channel_info_text_svg__",Vi))}catch(At){console.warn("Failed to process SVG channel info",At)}}if(E.backgroundSource==="image"&&E.backgroundImage&&tn.push(Pe("__custom_bg__",E.backgroundImage)),E.backgroundSource==="video"&&E.backgroundVideo&&tn.push(Mt("__custom_bg_video__",E.backgroundVideo)),await Promise.all(tn),Te.aborted){C(!1),I&&Q.forEach(at=>at.isFileSource&&URL.revokeObjectURL(at.audioSrc));return}const Tn=d.current,P=Tn.getContext("2d"),lt=Tn.captureStream(ft);let wt=null;try{if(je.captureStream)wt=je.captureStream();else if(je.mozCaptureStream)wt=je.mozCaptureStream();else throw new Error("Audio capture not supported")}catch{e.error("Your browser does not support audio capture for recording."),C(!1);return}h2();const Ge=new(window.AudioContext||window.webkitAudioContext),Ft=Ge.createMediaStreamDestination(),pt=Ge.createMediaElementSource(je);pt.connect(Ft);let Ht=null,fn=null,hn=null;E.showVisualization&&(Ht=Ge.createAnalyser(),Ht.fftSize=512,Ht.smoothingTimeConstant=.8,pt.connect(Ht),fn=new Uint8Array(Ht.frequencyBinCount),hn=new Uint8Array(Ht.frequencyBinCount)),bt.forEach(at=>{at.muted=!0,Ge.createMediaElementSource(at).connect(Ft)}),Cn.forEach(at=>{at.muted=!0,Ge.createMediaElementSource(at).connect(Ft)}),Ft.stream.getAudioTracks().length>0?lt.addTrack(Ft.stream.getAudioTracks()[0]):wt&<.addTrack(wt.getAudioTracks()[0]);const In=(()=>{if(Xe!=="auto"&&MediaRecorder.isTypeSupported(Xe))return Xe;const at=["video/webm; codecs=vp9,opus","video/webm; codecs=vp9","video/webm; codecs=av1",'video/mp4; codecs="av01.0.05M.08"','video/mp4; codecs="avc1.4D401E, mp4a.40.2"','video/mp4; codecs="avc1.64001E, mp4a.40.2"',"video/mp4","video/webm"];for(const At of at)if(MediaRecorder.isTypeSupported(At))return At;return"video/webm"})(),yi=Ie==="1080p"?8e6:4e6,di=ft>30?1.5:1,Ai=gt==="high"?2:gt==="low"?.5:1,de=yi*di*Ai,En=new MediaRecorder(lt,{mimeType:In,videoBitsPerSecond:de});f.current=En;const zt=[];En.ondataavailable=at=>{at.data.size>0&&zt.push(at.data)},En.onstop=()=>{if(Te.aborted)console.log("Render aborted");else{const at=new Blob(zt,{type:In}),At=Wt=>{const Qe=URL.createObjectURL(Wt),vn=document.createElement("a");vn.href=Qe;const rn=In.includes("mp4")?"mp4":"webm",Hn=I?`Playlist_${Q.length}_Songs_${me.replace(":","-")}.${rn}`:`${Q[0].metadata.title||"video"}_${me.replace(":","-")}.${rn}`;vn.download=Hn,document.body.appendChild(vn),vn.click(),document.body.removeChild(vn),URL.revokeObjectURL(Qe)};In.includes("webm"),At(at)}Ge.close(),C(!1),S(at=>at+1),I&&Q.forEach(at=>at.isFileSource&&URL.revokeObjectURL(at.audioSrc))};let Dn=0,oo=[],mo=_,Oi=0,Mo=0;const Pt=1e3/ft,Vn=at=>{if(Te.aborted)return;(En.state==="recording"||En.state==="paused")&&requestAnimationFrame(Vn);const At=at-Mo;if(At0){const Qe=Wt/Oi;if(I){const vn=(Dn+Qe)/Q.length*100;ue(vn)}else ue(Qe*100)}bt.forEach((Qe,vn)=>{if(vn==="background"||vn==="__custom_bg_video__"){const rn=Qe.duration||1,Hn=Wt%rn;let Vi=Math.abs(Qe.currentTime-Hn);(Hnrn/2||Vi>.5)&&(Qe.currentTime=Hn),Qe.paused&&Qe.play().catch(()=>{})}else{const rn=G.find(Hn=>Hn.id===vn);if(rn)if(Wt>=rn.startTime&&Wt0&&Vi>=fi&&(Vi=Vi%fi),Math.abs(Qe.playbackRate-Hn)>.01&&(Qe.playbackRate=Hn),Math.abs(Qe.currentTime-Vi)>.5&&(Qe.currentTime=Vi);const go=rn.isMuted!==!1;Qe.muted!==go&&(Qe.muted=go),Qe.paused&&Qe.play().catch(()=>{})}else Qe.paused||Qe.pause(),Qe.muted||(Qe.muted=!0)}}),Cn.forEach((Qe,vn)=>{const rn=G.find(Hn=>Hn.id===vn);if(rn){const Hn=rn.layer||0;if(E.layerVisibility?.audio?.[Hn]!==!1&&Wt>=rn.startTime&&Wt.01&&(Qe.playbackRate=fi),Math.abs(Qe.currentTime-go)>.5&&(Qe.currentTime=go);const ra=rn.isMuted===!0;Qe.muted!==ra&&(Qe.muted=ra),Qe.paused&&Qe.play().catch(()=>{})}else Qe.paused||Qe.pause(),Qe.muted||(Qe.muted=!0)}}),P&&(Ht&&fn&&hn&&(Ht.getByteFrequencyData(fn),Ht.getByteTimeDomainData(hn)),su(P,Tn.width,Tn.height,Wt,oo,mo,G,_t,bt,ot,$e,E.fontSizeScale,E.backgroundBlurStrength>0,Oi,E,E.renderMode==="current"||Dn===Q.length-1,E.renderMode==="current"||Dn===0,fn,hn))},sa=async()=>{if(Te.aborted){En.stop();return}if(Dn>=Q.length){await new Promise(At=>setTimeout(At,500)),En.stop();return}const at=Q[Dn];En.state==="recording"&&En.pause(),oo=at.lyrics,mo=at.metadata,Oi=0,I&&he(Dn),at.metadata.coverUrl&&(at.metadata.backgroundType==="video"?await Mt("background",at.metadata.coverUrl):await Pe("cover",at.metadata.coverUrl)),je.pause(),je.src=at.audioSrc,je.load(),await new Promise(At=>{const Wt=()=>{je.removeEventListener("canplay",Wt),At()};je.addEventListener("canplay",Wt),je.readyState>=3&&Wt()}),Oi=je.duration,En.state==="inactive"?(Ge.state==="suspended"&&await Ge.resume(),En.start(),requestAnimationFrame(Vn)):En.state==="paused"&&En.resume(),await je.play(),await new Promise(At=>{const Wt=()=>{je.removeEventListener("ended",Wt),At()};je.addEventListener("ended",Wt)}),Dn++,await sa()};if(console.log(`[Render] Queue prepared with ${Q.length} items.`),Q.length===0){e.error("Render queue is empty!"),C(!1);return}Dn=0,await sa()},uu=async()=>{if(!d.current)return;const I=E.renderMode==="playlist"&&_e.length>0;console.log(`[FFmpeg Render] Mode: ${E.renderMode}, Playlist: ${_e.length}, IsPlaylist: ${I}`);let Q=null,De=on,ae=_;if(I&&_e.length>0)Q=_e[0].audioFile,De=_e[0].parsedLyrics||[],ae=_e[0].metadata;else if(_e.length>0&&Se>=0)Q=_e[Se].audioFile;else if(m)try{Q=await(await fetch(m)).blob()}catch(P){console.error("FFmpeg: Failed to fetch audio blob",P),e.error("Failed to load audio source for rendering.");return}else{e.error("Please load an audio file first.");return}if(!Q){e.error("No audio file available for FFmpeg export.");return}const Te=`Start FFmpeg rendering at ${Ie} (${me})? This uses frame-by-frame capture for higher quality. Rendering may take several minutes.`;if(!await t(Te,"Start FFmpeg Rendering?"))return;te(!1),C(!0),ue(0),ne("Initializing...");const ot={aborted:!1};g.current=ot,ii();const _t=d.current,{w:bt,h:Cn}=vt();_t.width=bt,_t.height=Cn;const tn=new Map,Pe=new Map,Mt=[],nn=(P,lt)=>new Promise(wt=>{const Ge=new Image;Ge.crossOrigin="anonymous",Ge.onload=()=>{tn.set(P,Ge),wt()},Ge.onerror=()=>wt(),Ge.src=lt}),Tn=(P,lt)=>new Promise(wt=>{const Ge=document.createElement("video");Ge.crossOrigin="anonymous",Ge.muted=!0,Ge.playsInline=!0,Ge.preload="auto";let Ft=!1;const pt=()=>{Ft||(Ft=!0,Pe.set(P,Ge),wt())};Ge.oncanplay=()=>{Ft||(Ge.currentTime=.001)},Ge.onseeked=()=>pt(),Ge.onerror=()=>{console.warn("Failed to load video:",lt),pt()},setTimeout(()=>pt(),5e3),Ge.src=lt,Ge.load()});if(G.forEach(P=>{P.type==="video"?Mt.push(Tn(P.id,P.url)):P.type!=="audio"&&Mt.push(nn(P.id,P.url))}),ae.coverUrl&&(ae.backgroundType==="video"?Mt.push(Tn("background",ae.coverUrl)):Mt.push(nn("cover",ae.coverUrl))),E.backgroundSource==="image"&&E.backgroundImage&&Mt.push(nn("__custom_bg__",E.backgroundImage)),E.backgroundSource==="video"&&E.backgroundVideo&&(On.current&&On.current.currentSrc&&!On.current.error?(Pe.set("__custom_bg_video__",On.current),console.log("WebCodecs: Re-using existing background video element")):Mt.push(Tn("__custom_bg_video__",E.backgroundVideo))),E.backgroundSource==="video"&&E.backgroundVideo&&(On.current&&On.current.currentSrc&&!On.current.error?(Pe.set("__custom_bg_video__",On.current),console.log("FFmpeg: Re-using existing background video element")):Mt.push(Tn("__custom_bg_video__",E.backgroundVideo))),E.showChannelInfo&&E.channelInfoImage&&Mt.push(nn("__channel_info__",E.channelInfoImage)),await Promise.all(Mt),ot.aborted){C(!1);return}try{if(I){const P=[];for(const pt of _e){let Ht=[];if(pt.parsedLyrics&&pt.parsedLyrics.length>0)Ht=pt.parsedLyrics;else if(pt.lyricFile)try{const fn=await pt.lyricFile.text(),hn=pt.lyricFile.name.split(".").pop()?.toLowerCase();hn==="lrc"?Ht=El(fn):hn==="srt"?Ht=_l(fn):hn==="ttml"||hn==="xml"?Ht=Xl(fn):hn==="vtt"&&(Ht=Wl(fn))}catch(fn){console.error("FFmpeg: Failed to parse lyrics for playlist item",fn)}P.push({audioFile:pt.audioFile,lyrics:Ht,metadata:pt.metadata})}const lt=await E2(P,{canvas:_t,visualSlides:G,imageMap:tn,videoMap:Pe,preset:ee,customFontName:$e,renderConfig:E,resolution:Ie,aspectRatio:me,fps:ft,quality:gt,codec:M,onProgress:(pt,Ht)=>{},onLog:pt=>console.log(pt),abortSignal:ot},(pt,Ht,fn,hn)=>{const Ao=(pt+fn/100)/Ht*100;ue(Ao),ne(`Song ${pt+1}/${Ht}: ${hn}`)}),wt=`Playlist_${P.length}_Songs_${me.replace(":","-")}_ffmpeg.${lt.format}`,Ge=URL.createObjectURL(lt.blob),Ft=document.createElement("a");Ft.href=Ge,Ft.download=wt,document.body.appendChild(Ft),Ft.click(),document.body.removeChild(Ft),URL.revokeObjectURL(Ge),e.success(`Playlist exported successfully! (${lt.format.toUpperCase()}, ${Math.round(lt.duration)}s)`)}else{const P=await dx({canvas:_t,audioFile:Q,lyrics:De,metadata:ae,visualSlides:G,imageMap:tn,videoMap:Pe,preset:ee,customFontName:$e,renderConfig:E,resolution:Ie,aspectRatio:me,fps:ft,quality:gt,codec:M,onProgress:(Ft,pt)=>{ue(Ft),ne(pt)},onLog:Ft=>console.log(Ft),abortSignal:ot,isFirstSong:!0,isLastSong:!0}),lt=`${ae.title||"video"}_${me.replace(":","-")}_ffmpeg.${P.format}`,wt=URL.createObjectURL(P.blob),Ge=document.createElement("a");Ge.href=wt,Ge.download=lt,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge),URL.revokeObjectURL(wt),e.success(`Video exported successfully! (${P.format.toUpperCase()}, ${Math.round(P.duration)}s)`)}}catch(P){P.message!=="Render aborted"&&(console.error("FFmpeg render failed:",P),e.error(`FFmpeg render failed: ${P.message}`))}finally{C(!1),ne("")}},ns=async()=>{if(!d.current)return;const I=E.renderMode==="playlist"&&_e.length>0;let Q=null,De=on,ae=_;if(I&&_e.length>0)Q=_e[0].audioFile,De=_e[0].parsedLyrics||[],ae=_e[0].metadata;else if(_e.length>0&&Se>=0)Q=_e[Se].audioFile;else if(m)try{Q=await(await fetch(m)).blob()}catch(P){console.error("WebCodecs: Failed to fetch audio blob",P),e.error("Failed to load audio source for rendering.");return}else{e.error("Please load an audio file first.");return}if(!Q){e.error("No audio file available for export.");return}if(!Np()){e.error("WebCodecs is not supported in this browser.");return}const{w:Te,h:je}=vt(),ot=`Start WebCodecs rendering at ${Ie} @ ${ft}fps? -Resolution: ${Te}x${je} - -This uses hardware acceleration and is very fast.`;if(!await t(ot,"Start WebCodecs Rendering?"))return;te(!1),C(!0),ue(0),ne("Initializing WebCodecs...");const bt={aborted:!1};g.current=bt,ii();const Cn=d.current;Cn.width=Te,Cn.height=je;const tn=new Map,Pe=new Map,Mt=[],nn=(P,lt)=>new Promise(wt=>{const Ge=new Image;Ge.crossOrigin="anonymous",Ge.onload=()=>{tn.set(P,Ge),wt()},Ge.onerror=()=>wt(),Ge.src=lt}),Tn=(P,lt)=>new Promise(wt=>{const Ge=document.createElement("video");Ge.crossOrigin="anonymous",Ge.muted=!0,Ge.playsInline=!0,Ge.preload="auto";let Ft=!1;const pt=()=>{Ft||(Ft=!0,Pe.set(P,Ge),wt())};Ge.oncanplay=()=>{Ft||(Ge.currentTime=.001)},Ge.onseeked=()=>pt(),Ge.onerror=()=>{console.warn("Failed to load video:",lt),pt()},setTimeout(()=>pt(),5e3),Ge.src=lt,Ge.load()});if(G.forEach(P=>{P.type==="video"?Mt.push(Tn(P.id,P.url)):P.type!=="audio"&&Mt.push(nn(P.id,P.url))}),ae.coverUrl&&(ae.backgroundType==="video"?Mt.push(Tn("background",ae.coverUrl)):Mt.push(nn("cover",ae.coverUrl))),E.backgroundSource==="image"&&E.backgroundImage&&Mt.push(nn("__custom_bg__",E.backgroundImage)),E.backgroundSource==="video"&&E.backgroundVideo&&(On.current&&On.current.currentSrc&&!On.current.error?(Pe.set("__custom_bg_video__",On.current),console.log("WebCodecs: Re-using existing background video element")):Mt.push(Tn("__custom_bg_video__",E.backgroundVideo))),E.showChannelInfo&&E.channelInfoImage&&Mt.push(nn("__channel_info__",E.channelInfoImage)),await Promise.all(Mt),bt.aborted){C(!1);return}try{if(I){const P=[];for(const pt of _e){let Ht=[];if(pt.parsedLyrics&&pt.parsedLyrics.length>0)Ht=pt.parsedLyrics;else if(pt.lyricFile)try{const fn=await pt.lyricFile.text(),hn=pt.lyricFile.name.split(".").pop()?.toLowerCase();hn==="lrc"?Ht=El(fn):hn==="srt"?Ht=_l(fn):hn==="ttml"||hn==="xml"?Ht=Xl(fn):hn==="vtt"&&(Ht=Wl(fn))}catch(fn){console.error("WebCodecs: Failed to parse lyrics for playlist item",fn)}P.push({audioFile:pt.audioFile,lyrics:Ht,metadata:pt.metadata})}const lt=await Bk(P,{canvas:Cn,visualSlides:G,imageMap:tn,videoMap:Pe,preset:ee,customFontName:$e,renderConfig:E,resolution:Ie,aspectRatio:me,fps:ft,quality:gt,onProgress:(pt,Ht)=>{ue(pt),ne(Ht)},onLog:pt=>console.log(pt),abortSignal:bt}),wt=`Playlist_${P.length}_Songs_${me.replace(":","-")}_webcodecs.${lt.format}`,Ge=URL.createObjectURL(lt.blob),Ft=document.createElement("a");Ft.href=Ge,Ft.download=wt,document.body.appendChild(Ft),Ft.click(),document.body.removeChild(Ft),URL.revokeObjectURL(Ge),e.success(`Playlist exported successfully! (${lt.format.toUpperCase()}, ${Math.round(lt.duration)}s)`)}else{const P=await Pk({canvas:Cn,audioFile:Q,lyrics:De,metadata:ae,visualSlides:G,imageMap:tn,videoMap:Pe,preset:ee,customFontName:$e,renderConfig:E,resolution:Ie,aspectRatio:me,fps:ft,quality:gt,onProgress:(Ft,pt)=>{ue(Ft),ne(pt)},abortSignal:bt,isFirstSong:!0,isLastSong:!0}),lt=`${ae.title||"video"}_${me.replace(":","-")}_webcodecs.${P.format}`,wt=URL.createObjectURL(P.blob),Ge=document.createElement("a");Ge.href=wt,Ge.download=lt,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge),URL.revokeObjectURL(wt),e.success(`Video exported successfully! (${Math.round(P.duration)}s)`)}}catch(P){P.message!=="Render aborted"&&(console.error("WebCodecs render failed:",P),e.error(`Render failed: ${P.message}`))}finally{C(!1),ne("")}},oa=async()=>{A==="ffmpeg"?await uu():A==="webcodecs"?await ns():await hr()};Z.useEffect(()=>{v.current=oa});const Wo=Z.useCallback(()=>{g.current&&(g.current.aborted=!0),f.current&&f.current.state==="recording"?f.current.stop():C(!1),ii()},[ii]),la=Z.useCallback(()=>{if(s.current){const I=o.current?.currentTime||0;if(Kn===-1&&I<2){s.current.scrollTo({top:0,behavior:"smooth"});return}if(Kn!==-1){const Q=s.current.querySelector('[data-lyric-active="true"]');if(Q){const De=s.current;if(Q.offsetHeight===0)return;const ae=Q.offsetTop,Te=Q.offsetHeight,je=De.clientHeight;let ot=.5;E.contentPosition==="top"&&(ot=.25),E.contentPosition==="bottom"&&(ot=.75);const _t=ae-je*ot+Te/2;De.scrollTo({top:_t,behavior:"smooth"})}}}},[Kn,ee,E.contentPosition,E.marginTopScale,E.marginBottomScale]);Z.useEffect(()=>{la()},[la]),Z.useEffect(()=>{const I=setTimeout(()=>{la()},550);return()=>clearTimeout(I)},[L,Ee,Fn,mi,ze,dt,la]);const Qn=Z.useRef(null),Qo=Z.useCallback(()=>{if(X(!1),Qn.current&&clearTimeout(Qn.current),!Ae){const I=window.setTimeout(()=>{X(!0)},3e3);Qn.current=I}},[Ae]),mr=()=>{Qo()},aa=Z.useRef(0),Zo=I=>{Qo();const Q=Date.now();if(Q-aa.current<300){if(I.target.closest(".no-minimal-mode-toggle"))return;ts(I)}aa.current=Q};Z.useEffect(()=>{const I=Q=>{const De=Q.key.toLowerCase();if([" ","k","s","t","l","r","f","h","g","m","j","d","e","c","x","z","arrowleft","arrowright","arrowup","arrowdown","meta","control","shift","alt","printscreen","fn","+","-","="].includes(De)||Qo(),!(Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement)){if(Ae){De==="escape"&&Wo();return}switch(Q.key.toLowerCase()){case" ":case"k":Q.preventDefault(),na(),e.success(ve?"Paused":"Playing",{id:"play-pause"});break;case"s":Q.preventDefault(),ii(),e.success("Stopped",{id:"stop"});break;case"n":Q.preventDefault(),kn(),e.success("Next Song",{id:"next-song"});break;case"o":Q.preventDefault();const Te=!Zt;Pn(Te),Te&&ke(!0),e.success(`Minimal Mode: ${Te?"On":"Off"}`,{id:"minimal-mode"});break;case"b":Q.preventDefault(),ta(),e.success("Previous Song",{id:"prev-song"});break;case"r":Q.preventDefault(),_o();const je=fe==="off"?"one":fe==="one"?"all":fe==="all"?"all_repeat":"off",ot={off:"Repeat Off",one:"Loop One",all:"Play All (Stop)",all_repeat:"Loop Playlist"};e.success(`Repeat: ${ot[je]}`,{id:"repeat"});break;case"l":Q.preventDefault();const _t=!dt;Dt(_t),_t&&Le(ri.PLAYER);break;case"h":Q.preventDefault();const bt=!Ee;ke(bt),e.success(bt?"HUD: Always Visible":"HUD: Auto-Hide",{id:"hud-mode"});break;case"y":Q.preventDefault(),we(Pt=>!Pt);break;case"g":Q.preventDefault();const Cn=Vf.flatMap(Pt=>Pt.options.map(Vn=>Vn.value)),tn=V.current.lyricDisplayMode,Mt=(Cn.indexOf(tn)+1)%Cn.length,nn=Cn[Mt];O(Pt=>({...Pt,lyricDisplayMode:nn})),e.success(`Lyric Mode: ${nn.replace("-"," ")}`,{id:"lyric-mode"});break;case"c":Q.preventDefault();const Tn=sx,P=V.current.textCase,wt=(Tn.indexOf(P)+1)%Tn.length,Ge=Tn[wt];O(Pt=>({...Pt,textCase:Ge})),e.success(`Text Case: ${Ge}`,{id:"text-case"});break;case"f":fr();break;case"i":Si(Pt=>!Pt);break;case"p":ui(Pt=>!Pt);break;case"d":Q.preventDefault(),te(Pt=>!Pt);break;case"t":dt?(Dt(!1),Le(ri.EDITOR)):Le(Pt=>Pt===ri.PLAYER?ri.EDITOR:ri.PLAYER);break;case"m":Q.preventDefault();const Ft=!xt;K(Ft),e.success(Ft?"Muted":"Unmuted",{id:"mute"});break;case"x":Q.preventDefault();const pt=V.current.highlightEffect==="none";O(Pt=>({...Pt,highlightEffect:Pt.highlightEffect==="none"?"karaoke":"none"})),e.success(`Highlight: ${pt?"On (Karaoke)":"Off"}`,{id:"highlight-toggle"});break;case"z":Q.preventDefault();const Ht=Of.flatMap(Pt=>Pt.options.map(Vn=>Vn.value)),fn=V.current.highlightEffect||"none",hn=Ht.indexOf(fn),In=((hn===-1?0:hn)+1)%Ht.length,yi=Ht[In],di=Rc(yi);O(Pt=>{const Vn={...Pt,highlightEffect:yi};return Vn.useCustomHighlightColors=!1,di&&(Vn.highlightColor=di.color,Vn.highlightBackground=di.bg),Vn}),e.success(`Effect: ${yi.replace(/-/g," ")}`,{id:"highlight-effect"});break;case"j":Q.preventDefault();const de=(gf.indexOf(ee)+1)%gf.length,En=gf[de];be(En);const zt=Yc[En];if(zt){const Pt={fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSizeScale:1,fontColor:"#ffffff",fontWeight:"bold",fontStyle:"normal",textCase:"none",textAlign:"center",contentPosition:"center",textDecoration:"none",textEffect:"preset",textAnimation:"none",highlightEffect:"karaoke",highlightColor:"#fb923c",highlightBackground:"#fb923c",useCustomHighlightColors:!1,lyricStyleTarget:"active-only",transitionEffect:"none"};O(Vn=>({...Vn,...Pt,...zt}))}let Dn=En;for(const Pt of pp){const Vn=Pt.options.find(sa=>sa.value===En);if(Vn){Dn=Vn.label;break}}e.success(`Preset: ${Dn}`,{id:"preset"});break;case"arrowleft":if(Q.preventDefault(),o.current){const Pt=Math.max(0,o.current.currentTime-5);o.current.currentTime=Pt,qe(Pt)}break;case"arrowright":if(Q.preventDefault(),o.current){const Pt=Math.min(Ve,o.current.currentTime+5);o.current.currentTime=Pt,qe(Pt)}break;case"arrowup":Q.preventDefault(),s.current&&s.current.scrollBy({top:-100,behavior:"smooth"});break;case"arrowdown":Q.preventDefault(),s.current&&s.current.scrollBy({top:100,behavior:"smooth"});break;case"+":case"=":Q.preventDefault();const oo=V.current.fontSizeScale,mo=Math.min(oo+.1,3);O(Pt=>({...Pt,fontSizeScale:mo})),e.success(`Font Size: ${(mo*100).toFixed(0)}%`,{id:"font-size"});break;case"-":Q.preventDefault();const Oi=V.current.fontSizeScale,Mo=Math.max(Oi-.1,.1);O(Pt=>({...Pt,fontSizeScale:Mo})),e.success(`Font Size: ${(Mo*100).toFixed(0)}%`,{id:"font-size"});break;case"e":(Q.ctrlKey||Q.metaKey)&&Q.shiftKey&&(Q.preventDefault(),v.current());break}}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[ve,fe,ze,Ae,Qo,Wo,dt,kn,ta,e,Zt,ee,Ee,xt]),Z.useEffect(()=>{let I,Q=0;const De=1e3/30,ae=Te=>{if(o.current&&!o.current.paused&&ve){I=requestAnimationFrame(ae);const je=Te-Q;je>De&&(Q=Te-je%De,qe(o.current.currentTime))}};return ve&&!Ae&&(I=requestAnimationFrame(ae)),()=>{I&&cancelAnimationFrame(I)}},[ve,Ae]);const el=Fn&&(!L||Ee)&&!Ae,No=mi&&(!L||Ee)&&!Ae&&!Zt,ho=mt.length>0?mt[0]:null;ho?`${ho.url}`:_.coverUrl&&`${_.coverUrl}`;const On=Z.useRef(null);return Z.useEffect(()=>{if(mt.forEach(I=>{const Q=I.layer||0;if(E.layerVisibility?.visual?.[Q]!==!1&&I.type==="video"){const De=document.getElementById(`video-preview-${I.id}`);if(De)if(Ae)De.paused||De.pause();else{const ae=I.playbackRate||1;let Te=(ge-I.startTime)*ae+(I.mediaStartOffset||0);const je=I.mediaDuration||De.duration;je&&je>0&&Te>=je&&(Te=Te%je),Math.abs(De.playbackRate-ae)>.01&&(De.playbackRate=ae),Math.abs(De.currentTime-Te)>.2&&(De.currentTime=Te);const ot=I.isMuted!==!1;De.muted!==ot&&(De.muted=ot);const _t=I.volume!==void 0?I.volume:1;Math.abs(De.volume-_t)>.01&&(De.volume=_t),ve&&De.paused?De.play().catch(()=>{}):!ve&&!De.paused&&De.pause()}}}),(_.backgroundType==="video"||E.backgroundSource==="video")&&On.current){const I=On.current;if(Ae)I.paused||I.pause();else{const Q=I.duration||1,De=ge%Q;Math.abs(I.currentTime-De)>.1&&(I.currentTime=De),ve&&I.paused?I.play().catch(()=>{}):!ve&&!I.paused&&I.pause()}}Ut.forEach(I=>{const Q=document.getElementById(`audio-preview-${I.id}`);if(Q){const De=I.playbackRate||1,ae=(ge-I.startTime)*De+(I.mediaStartOffset||0);Math.abs(Q.playbackRate-De)>.01&&(Q.playbackRate=De),Math.abs(Q.currentTime-ae)>.2&&(Q.currentTime=ae);const Te=I.isMuted===!0;Q.muted!==Te&&(Q.muted=Te);const je=I.volume!==void 0?I.volume:1;Math.abs(Q.volume-je)>.01&&(Q.volume=je),ve&&Q.paused?Q.play().catch(()=>{}):!ve&&!Q.paused&&Q.pause()}})},[ge,ve,mt,_,Ut,E.layerVisibility]),u.jsxs("div",{ref:l,onMouseMove:mr,onTouchStart:Zo,onDoubleClick:ts,className:`relative w-full h-[100dvh] bg-black overflow-hidden flex font-sans select-none ${L&&!Ee?"cursor-none":""}`,children:[u.jsx("audio",{ref:o,src:m||void 0,loop:fe==="one",muted:xt,onTimeUpdate:pr,onLoadedMetadata:cu,onEnded:()=>{if(Ae)return;const I=_e.length>0;fe==="one"||(fe==="all_repeat"?I?kn():o.current?.play():fe==="all"&&I&&Se<_e.length-1?kn():ye(!1))},crossOrigin:"anonymous"},b),Ut.map(I=>u.jsx("audio",{id:`audio-preview-${I.id}`,src:I.url,className:"hidden",playsInline:!0},I.id)),u.jsx("canvas",{ref:d,width:Gt,height:dn,className:"absolute top-0 left-0 hidden pointer-events-none opacity-0"}),u.jsxs("div",{className:"absolute inset-0 bg-black overflow-hidden pointer-events-none",children:[E.backgroundSource==="color"&&u.jsx("div",{className:"absolute inset-0",style:{backgroundColor:E.backgroundColor}}),E.backgroundSource==="gradient"&&u.jsx("div",{className:"absolute inset-0",style:{background:E.backgroundGradient}}),E.backgroundSource==="image"&&E.backgroundImage&&u.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${E.backgroundImage})`}}),E.backgroundSource==="video"&&E.backgroundVideo&&u.jsx("video",{ref:On,src:E.backgroundVideo,className:"absolute inset-0 w-full h-full object-cover",muted:!0,loop:!0,playsInline:!0}),E.backgroundSource==="smart-gradient"&&u.jsx("div",{className:"absolute inset-0",style:{background:(()=>{const I=E.backgroundColor||"#312e81",Q=parseInt(I.slice(1,3),16),De=parseInt(I.slice(3,5),16),ae=parseInt(I.slice(5,7),16),Te=`${Q},${De},${ae}`,je=`${Math.floor(Q*.6)},${Math.floor(De*.6)},${Math.floor(ae*.6)}`;return`linear-gradient(to bottom right, rgb(${Te}), rgb(${je}) 50%, #000000)`})()}}),(E.backgroundSource==="timeline"&&G.length===0||E.backgroundSource==="custom")&&_.coverUrl&&(_.backgroundType==="video"?u.jsx("video",{ref:On,src:_.coverUrl,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ${He?"opacity-60":"opacity-0"}`,muted:!0,loop:!Ae,playsInline:!0,preload:"auto",onLoadedData:()=>et(!0)}):u.jsx("div",{className:`absolute inset-0 bg-cover bg-center transition-all duration-700 ease-in-out ${E.backgroundSource==="custom"||mt.length===0?"opacity-60":"opacity-0"}`,style:{backgroundImage:`url(${_.coverUrl})`}})),E.backgroundSource==="color"&&u.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{backgroundColor:E.backgroundColor}}),E.backgroundSource==="gradient"&&u.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{background:E.backgroundGradient}}),E.backgroundSource==="smart-gradient"&&u.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{background:(()=>{const I=E.backgroundColor||"#312e81",Q=parseInt(I.slice(1,3),16),De=parseInt(I.slice(3,5),16),ae=parseInt(I.slice(5,7),16),Te=`${Q},${De},${ae}`,je=`${Math.floor(Q*.6)},${Math.floor(De*.6)},${Math.floor(ae*.6)}`;return`linear-gradient(to bottom right, rgb(${Te}), rgb(${je}) 50%, #000000)`})()}}),!_.coverUrl&&(E.backgroundSource==="timeline"&&G.length===0||E.backgroundSource==="custom")&&u.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-900 via-purple-900 to-black opacity-80"}),u.jsx("div",{className:`absolute inset-0 pointer-events-none ${E.backgroundSource==="timeline"?"opacity-100":"opacity-0"}`,children:E.backgroundSource==="timeline"&&mt.map(I=>{const Q=I.layer||0;if(E.layerVisibility?.visual?.[Q]===!1)return null;const De=E.visualTransitionType||"none",ae=E.visualTransitionDuration||1;let Te=1;if(De!=="none"){if(ge=I.endTime){let je=!1;if(De==="crossfade"&&(je=G.some(ot=>ot.id!==I.id&&(ot.layer||0)===(I.layer||0)&&ot.startTime>=I.endTime-.1&&ot.startTimeI.endTime-ae){const je=(I.endTime-ge)/ae;Te=Math.min(Te,Math.max(0,Math.min(1,je)))}}return u.jsx("div",{className:"absolute inset-0 flex items-center justify-center overflow-hidden",style:{opacity:Te},children:I.type==="video"?u.jsx("video",{id:`video-preview-${I.id}`,src:I.url,className:"w-full h-full object-cover",muted:I.isMuted!==!1,playsInline:!0}):u.jsx("div",{className:"w-full h-full bg-cover bg-center",style:{backgroundImage:`url(${I.url})`}})},I.id)})}),u.jsx("div",{className:"absolute inset-0 bg-black/30 transition-all duration-700",style:{backdropFilter:E.backgroundBlurStrength>0?`blur(${E.backgroundBlurStrength}px)`:tt?"blur(12px)":"none",backgroundColor:E.useRealColorMedia?"transparent":E.backgroundBlurStrength>0||tt?"rgba(0,0,0,0.4)":void 0}}),E.enableGradientOverlay&&u.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/95 via-black/60 to-transparent pointer-events-none z-0"}),!Ae&&u.jsx(m2,{audioElement:o.current,config:E,isPlaying:ve})]}),u.jsxs("div",{className:"relative z-10 flex-1 flex flex-col transition-all duration-500",children:[E.showChannelInfo&&Zt&&u.jsxs("div",{className:`absolute z-[60] flex gap-2 p-6 pointer-events-none transition-all duration-500 - ${E.channelInfoStyle==="modern"?"flex-col items-center":"flex-row items-center"} - ${E.channelInfoStyle==="box"?"bg-black/40 backdrop-blur-md rounded-xl border border-white/10":""} - ${E.channelInfoPosition==="top-left"?"top-0 left-0 items-start text-left":E.channelInfoPosition==="top-right"?"top-0 right-0 items-end text-right":E.channelInfoPosition==="top-center"?"top-0 left-1/2 items-center text-center":E.channelInfoPosition==="bottom-left"?"bottom-0 left-0 items-start text-left":E.channelInfoPosition==="bottom-center"?"bottom-0 left-1/2 items-center text-center":"bottom-0 right-0 items-end text-right"} - `,style:{transform:`${E.channelInfoPosition?.includes("center")?"translateX(-50%)":""} scale(${E.channelInfoSizeScale??1})`,transformOrigin:E.channelInfoPosition?.includes("top")?E.channelInfoPosition?.includes("center")?"top center":E.channelInfoPosition?.includes("left")?"top left":"top right":E.channelInfoPosition?.includes("center")?"bottom center":E.channelInfoPosition?.includes("left")?"bottom left":"bottom right",...E.channelInfoPosition?.includes("center")?E.channelInfoPosition?.includes("top")?{marginTop:`${(E.channelInfoMarginScale??1)*1.5}rem`}:{marginBottom:`${(E.channelInfoMarginScale??1)*1.5}rem`}:{margin:`${(E.channelInfoMarginScale??1)*1.5}rem`}},children:[E.channelInfoImage&&E.channelInfoStyle!=="minimal"&&u.jsx("img",{src:E.channelInfoImage,alt:"Channel",className:`w-20 h-20 object-contain drop-shadow-lg ${E.channelInfoStyle==="circle"?"rounded-full":""}`}),E.channelInfoText&&E.channelInfoStyle!=="logo"&&(()=>{const I=E.channelInfoText.trim();return//i.test(I)?u.jsx("div",{className:`font-bold drop-shadow-md text-lg inline-flex items-center gap-1 - ${E.channelInfoStyle==="minimal"||E.channelInfoStyle==="box"?"":"px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm"} - [&>svg]:w-auto [&>svg]:h-[1.5em]`,style:{fontFamily:E.channelInfoFontFamily,color:E.channelInfoFontColor||"white",fontWeight:E.channelInfoFontWeight||"bold",fontStyle:E.channelInfoFontStyle||"normal"},dangerouslySetInnerHTML:{__html:I}}):u.jsx("p",{className:`font-bold drop-shadow-md text-lg - ${E.channelInfoStyle==="minimal"||E.channelInfoStyle==="box"?"":"px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm"}`,style:{fontFamily:E.channelInfoFontFamily,color:E.channelInfoFontColor||"white",fontWeight:E.channelInfoFontWeight||"bold",fontStyle:E.channelInfoFontStyle||"normal"},children:E.channelInfoText})})()]}),Zt&&u.jsx("div",{className:`absolute z-20 flex flex-col gap-2 p-6 transition-all duration-500 pointer-events-none - ${el?"opacity-100":"opacity-0"} - ${E.infoPosition==="top-left"?"top-0 left-0 items-start text-left":E.infoPosition==="top-right"?"top-0 right-0 items-end text-right":E.infoPosition==="top-center"?"top-0 left-1/2 items-center text-center":E.infoPosition==="bottom-left"?"bottom-0 left-0 items-start text-left":E.infoPosition==="bottom-right"?"bottom-0 right-0 items-end text-right":E.infoPosition==="bottom-center"?"bottom-0 left-1/2 items-center text-center":"top-0 left-0 items-start text-left"} - `,style:{transform:`${E.infoPosition?.includes("center")?"translateX(-50%)":""} scale(${E.infoSizeScale??1})`,transformOrigin:E.infoPosition?.includes("top")?E.infoPosition?.includes("center")?"top center":E.infoPosition?.includes("right")?"top right":"top left":E.infoPosition?.includes("center")?"bottom center":E.infoPosition?.includes("right")?"bottom right":"bottom left",...E.infoPosition?.includes("center")?E.infoPosition?.includes("top")?{marginTop:`${(E.infoMarginScale??1)*1.5}rem`}:{marginBottom:`${(E.infoMarginScale??1)*1.5}rem`}:{margin:`${(E.infoMarginScale??1)*1.5}rem`}},children:u.jsxs("div",{className:` - flex items-center gap-4 pointer-events-auto - ${E.infoPosition?.includes("center")?"flex-col justify-center":""} - ${E.infoPosition?.includes("right")?"flex-row-reverse":"flex-row"} - ${E.infoStyle==="box"?"bg-black/40 backdrop-blur-md p-4 rounded-xl border border-white/10":""} - ${E.infoStyle==="modern"||E.infoStyle==="minimal",""} - `,children:[u.jsxs("div",{className:`relative group shrink-0 transition-opacity duration-300 - ${!E.showCover||E.infoStyle==="minimal"||E.infoStyle==="modern"?"hidden":"block"} - ${E.infoStyle==="circle_art"?"rounded-full":"rounded-md"} - overflow-hidden bg-zinc-800 shadow-lg border border-white/10 - w-12 h-12 md:w-16 md:h-16 - `,children:[_.coverUrl?_.backgroundType==="video"?u.jsx("video",{src:_.coverUrl,className:"w-full h-full object-cover",muted:!0,loop:!0,onMouseOver:I=>I.currentTarget.play(),onMouseOut:I=>I.currentTarget.pause()}):u.jsx("img",{src:_.coverUrl,alt:"Cover",className:"w-full h-full object-cover"}):u.jsx("div",{className:"w-full h-full flex items-center justify-center text-zinc-500",children:u.jsx(Oa,{size:24})}),u.jsxs("label",{className:"absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity",children:[u.jsx(ro,{size:20,className:"text-white"}),u.jsx("input",{type:"file",accept:"image/*,video/*",className:"hidden",onChange:zn})]})]}),u.jsxs("div",{className:`flex flex-col justify-center ${E.infoPosition?.includes("right")?"items-end":E.infoPosition?.includes("center")?"items-center":"items-start"}`,children:[u.jsx("h1",{className:`font-bold drop-shadow-md line-clamp-1 transition-opacity duration-300 - ${E.showTitle?"opacity-100":"opacity-0 h-0 w-0"} - ${E.infoStyle==="minimal"?"text-sm":E.infoStyle==="modern"||E.infoStyle==="modern_art"?"text-xl":"text-lg"} - `,style:{fontFamily:E.infoFontFamily,color:E.infoFontColor||"white",fontWeight:E.infoFontWeight||"bold",fontStyle:E.infoFontStyle||"normal"},children:_.title}),u.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 - ${E.showArtist?"opacity-100":"opacity-0 h-0 w-0"} - `,children:u.jsx("p",{className:`drop-shadow-md - ${E.infoStyle==="minimal"?"text-[10px]":E.infoStyle==="modern"||E.infoStyle==="modern_art"?"text-sm font-medium":"text-xs"} - `,style:{fontFamily:E.infoFontFamily,color:E.infoFontColor||(E.infoStyle==="minimal"?"#a1a1aa":"#d4d4d8"),fontWeight:E.infoFontWeight||"bold",fontStyle:E.infoFontStyle||"normal"},children:_.artist})})]})]})}),u.jsx("div",{className:`transition-all duration-500 ease-in-out overflow-hidden ${el&&!Zt?"max-h-80 md:max-h-40 opacity-100":"max-h-0 opacity-0"}`,children:u.jsxs("div",{className:"p-4 md:p-6 flex flex-col md:flex-row justify-between items-start gap-4 md:gap-0",children:[u.jsx("div",{className:"flex gap-4",children:u.jsxs("div",{className:"flex gap-4 items-center",children:[u.jsxs("div",{className:`relative group w-16 h-16 rounded-md overflow-hidden bg-zinc-800 shadow-lg border border-white/10 shrink-0 transition-opacity duration-300 ${E.showCover?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none w-0 h-0 -ml-4"}`,children:[_.coverUrl?_.backgroundType==="video"?u.jsx("video",{src:_.coverUrl,className:"w-full h-full object-cover",muted:!0,loop:!0,onMouseOver:I=>I.currentTarget.play(),onMouseOut:I=>I.currentTarget.pause()}):u.jsx("img",{src:_.coverUrl,alt:"Cover",className:"w-full h-full object-cover"}):u.jsx("div",{className:"w-full h-full flex items-center justify-center text-zinc-500",children:u.jsx(Oa,{size:24})}),u.jsxs("label",{className:"absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity",children:[u.jsx(ro,{size:20,className:"text-white"}),u.jsx("input",{type:"file",accept:"image/*,video/*",className:"hidden",onChange:zn})]})]}),u.jsxs("div",{children:[u.jsx("h1",{className:`text-xl font-bold text-white drop-shadow-md line-clamp-1 transition-opacity duration-300 ${E.showTitle?"opacity-100":"opacity-0"}`,children:_.title}),u.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 ${E.showArtist?"opacity-100":"opacity-0"}`,children:u.jsx("p",{className:"text-zinc-300 text-sm drop-shadow-md",children:_.artist})})]})]})}),u.jsxs("div",{className:`flex gap-2 flex-wrap ${Zt?"hidden":""}`,children:[u.jsx("a",{href:"https://github.com/dotslashgabut/immersive-audio-player-lyric-video-maker",target:"_blank",rel:"noopener noreferrer",title:"Immersive Audio Player & Lyric Video Maker | GitHub",className:"px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center",children:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#eee",className:"bi bi-github",viewBox:"0 0 16 16",children:u.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"})})}),u.jsx("a",{href:"https://ai.studio/apps/drive/11YaG-jtLXb8BnXM3aMfj7wmKIw-S3mt3?fullscreenApplet=true",target:"_blank",rel:"noopener noreferrer",title:"LyricalEditorPlus - Universal Lyrics/Subtitle Editor",className:"px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center",children:"LyricalEditorPlus"}),u.jsx("a",{href:"https://ai.studio/apps/drive/1M1VfxdBlNB_eOPQqQiHspvVwizaEs0aI?fullscreenApplet=true",target:"_blank",rel:"noopener noreferrer",title:"LyricFlow - Turn Audio into Subtitles",className:"px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center",children:"LyricFlow"}),u.jsx("a",{href:"https://ai.studio/apps/drive/1WKA-bCxzIKD-DcI_pq0HzxN3m1_oNEkg?fullscreenApplet=true",target:"_blank",rel:"noopener noreferrer",title:"LyricalVision - Visualize lyrics with Gemini AI",className:"px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center",children:"LyricalVision"}),u.jsx("button",{onClick:()=>ke(!Ee),className:`p-2 rounded-full transition-colors ${Ee?"bg-purple-600/50 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Bypass Auto-hide (H)",children:Ee?u.jsx(Ys,{size:20}):u.jsx(qs,{size:20})}),u.jsx("button",{onClick:()=>Pn(!Zt),className:`p-2 rounded-full transition-colors ${Zt?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Minimal Mode (O)",children:Zt?u.jsx(tr,{size:20}):u.jsx(mg,{size:20})}),u.jsx("button",{onClick:()=>{const I=!dt;Dt(I),I&&Le(ri.PLAYER)},className:`p-2 rounded-full transition-colors ${dt?"bg-orange-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Toggle Playlist (L)",children:u.jsx(jc,{size:20})}),u.jsx("button",{onClick:()=>{dt&&Dt(!1),Le(ze===ri.PLAYER?ri.EDITOR:ri.PLAYER)},className:`p-2 rounded-full transition-colors ${ze===ri.EDITOR&&!dt?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Toggle Timeline (T)",children:u.jsx(uv,{size:20})}),u.jsx("button",{onMouseDown:I=>{I.stopPropagation(),te(!B)},className:`p-2 rounded-full transition-colors ${B?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Render Settings (D)",children:u.jsx(Js,{size:20})}),u.jsx("button",{onMouseDown:I=>{I.stopPropagation(),we(!j)},className:`p-2 rounded-full transition-colors ${j?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Keyboard Shortcuts (Y)",children:u.jsx(Bc,{size:20})}),u.jsx("button",{onClick:fr,className:"p-2 rounded-full bg-black/30 text-zinc-300 hover:bg-white/10 transition-colors",title:"Fullscreen (F)",children:ut?u.jsx(mg,{size:20}):u.jsx(tr,{size:20})})]})]})}),u.jsx("div",{className:`flex-1 flex justify-center overflow-hidden relative ${E.contentPosition==="top"?"items-start":E.contentPosition==="bottom"?"items-end":"items-center"}`,style:{paddingTop:E.contentPosition==="top"?`${(E.marginTopScale??1)*10}vh`:void 0,paddingBottom:E.contentPosition==="bottom"?`${(E.marginBottomScale??1)*10}vh`:void 0},children:F.length>0?u.jsxs("div",{ref:s,className:`w-full max-w-5xl max-h-full overflow-y-auto no-scrollbar px-4 md:px-6 space-y-4 md:space-y-6 transition-all duration-500 lyrics-root ${E.textAlign==="left"?"text-left":E.textAlign==="right"?"text-right":"text-center"} ${E.showLyrics?"opacity-100":"opacity-0 pointer-events-none"}`,style:{maskImage:(el||No)&&ee!=="subtitle"?"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)":"none"},children:[u.jsx("style",{children:` - .lyrics-root .text-lg { font-size: calc(1.125rem * ${E.fontSizeScale}); line-height: calc(1.75rem * ${E.fontSizeScale} * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-xl { font-size: calc(1.25rem * ${E.fontSizeScale}); line-height: calc(1.75rem * ${E.fontSizeScale} * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-2xl { font-size: calc(1.5rem * ${E.fontSizeScale}); line-height: calc(2rem * ${E.fontSizeScale} * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-3xl { font-size: calc(1.875rem * ${E.fontSizeScale}); line-height: calc(2.25rem * ${E.fontSizeScale} * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-4xl { font-size: calc(2.25rem * ${E.fontSizeScale}); line-height: calc(2.5rem * ${E.fontSizeScale} * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-5xl { font-size: calc(3rem * ${E.fontSizeScale}); line-height: calc(1 * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-6xl { font-size: calc(3.75rem * ${E.fontSizeScale}); line-height: calc(1 * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-7xl { font-size: calc(4.5rem * ${E.fontSizeScale}); line-height: calc(1 * ${E.lyricLineHeight||1.2}); } - .lyrics-root .text-8xl { font-size: calc(6rem * ${E.fontSizeScale}); line-height: calc(1 * ${E.lyricLineHeight||1.2}); } - `}),u.jsx("div",{className:`transition-all duration-500 ${E.contentPosition==="center"?ze===ri.EDITOR||dt?"h-[25vh]":!el&&!No?"h-[50vh]":"h-[40vh]":"h-0"}`}),on.map((I,Q)=>{const De=Q===Kn,ae=ze===ri.EDITOR||dt,Te=["9:16","3:4","1:1","1:2","2:3"].includes(me);if(E.lyricDisplayMode!=="all"){if(E.lyricDisplayMode==="active-only"&&Q!==Kn)return u.jsx("p",{className:"hidden"},Q);if(E.lyricDisplayMode==="next-only"&&(QKn+1))return u.jsx("p",{className:"hidden"},Q);if(E.lyricDisplayMode==="previous-next"&&Math.abs(Q-Kn)>1)return u.jsx("p",{className:"hidden"},Q)}else if(ee==="none"||ee==="just_video")return u.jsx("p",{className:"hidden"},Q);let je="",ot="";const _t=E.transitionEffect;let bt="transition-[color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,text-shadow] duration-500 cursor-pointer whitespace-pre-wrap break-words ";if(De?_t==="slide"?bt+="translate-y-0 opacity-100 ":_t==="zoom"?bt+="scale-100 opacity-100 ":_t==="float"?bt+="translate-y-0 opacity-100 ":_t==="blur"?bt+="blur-0 opacity-100 ":_t==="fade"?bt+="opacity-100 ":_t==="drop"?bt+="trans-drop-enter opacity-100 ":_t==="lightspeed"?bt+="trans-lightspeed-enter opacity-100 ":_t==="roll"?bt+="trans-roll-enter opacity-100 ":_t==="elastic"?bt+="trans-elastic-enter opacity-100 ":_t==="flip"?bt+="trans-flip-enter opacity-100 ":_t==="rotate-in"?bt+="trans-rotate-in-enter opacity-100 ":_t==="spiral"?bt+="trans-spiral-enter opacity-100 ":_t==="shatter"?bt+="trans-shatter-enter opacity-100 ":bt+="opacity-100 ":(_t==="slide"?bt+="translate-y-4 opacity-0 ":_t==="zoom"?bt+="scale-75 opacity-0 ":_t==="float"?bt+="translate-y-8 opacity-0 ":_t==="blur"?bt+="blur-md opacity-0 ":_t==="fade"?bt+="opacity-50 ":_t==="drop"?bt+="trans-drop-exit opacity-0 ":_t==="roll"?bt+="trans-roll-exit opacity-0 ":bt+="opacity-0 ",_t==="none"&&(bt=bt.replace("opacity-0","opacity-50"))),ee==="large"||ee==="large_upper"){const wt=Te?ae?"text-4xl":"text-6xl":ae?"text-6xl":"text-8xl",Ge=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${wt} font-black text-white ${ee==="large_upper"?"uppercase":""} tracking-tight text-left pl-4`,ot=`${Ge} text-zinc-600/40 hover:text-zinc-400 text-left pl-4`}else if(ee==="big_center"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} font-black text-white uppercase tracking-tight text-center`,ot=`${lt} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(ee==="testing_up"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white uppercase tracking-tight text-center`,ot=`${lt} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(ee==="testing"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white tracking-tight text-center`,ot=`${lt} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(ee==="one_line_up"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white uppercase tracking-tight text-center`,ot=`${lt} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(ee==="one_line"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white tracking-tight text-center`,ot=`${lt} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(ee==="metal"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white uppercase tracking-wide text-center drop-shadow-[0_4px_6px_rgba(255,0,0,0.5)]`,ot=`${lt} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(ee==="kids"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-white tracking-wide text-center drop-shadow-[3px_3px_0px_rgba(0,0,0,0.5)]`,ot=`${lt} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(ee==="sad"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-7xl",lt=Te?ae?"text-lg":"text-xl":ae?"text-xl":"text-2xl";je=`${P} text-zinc-200 tracking-wider text-center drop-shadow-md`,ot=`${lt} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(ee==="romantic"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-7xl",lt=Te?ae?"text-lg":"text-xl":ae?"text-xl":"text-2xl";je=`${P} text-pink-100 italic tracking-wide text-center drop-shadow-[0_0_10px_rgba(236,72,153,0.5)]`,ot=`${lt} text-zinc-600/60 hover:text-zinc-400 text-center italic`}else if(ee==="tech"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-cyan-50 font-bold uppercase tracking-widest text-center drop-shadow-[0_0_10px_rgba(34,211,238,0.8)]`,ot=`${lt} text-cyan-900/40 hover:text-cyan-800 text-center uppercase`}else if(ee==="gothic"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-7xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl";je=`${P} text-zinc-300 tracking-normal text-center drop-shadow-[0_4px_10px_rgba(0,0,0,0.9)]`,ot=`${lt} text-zinc-700/60 hover:text-zinc-500 text-center`}else if(ee==="monospace"){const P=Te?ae?"text-2xl":"text-3xl":ae?"text-3xl":"text-5xl",lt=Te?ae?"text-lg":"text-xl":ae?"text-xl":"text-2xl";je=`${P} font-mono font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`,ot=`${lt} font-mono text-zinc-500/60 hover:text-zinc-300 drop-shadow-sm`}else if(ee==="classic"){const P=Te?ae?"text-2xl":"text-3xl":ae?"text-3xl":"text-6xl",lt=Te?ae?"text-lg":"text-xl":ae?"text-xl":"text-2xl";je=`${P} font-serif italic font-bold text-amber-100 drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)]`,ot=`${lt} font-serif text-zinc-500/60 hover:text-zinc-300 italic`}else if(ee==="slideshow"||ee==="just_video")je=`${Te?ae?"text-2xl":"text-3xl":ae?"text-3xl":"text-4xl"} text-white tracking-wide text-center`,ot="hidden";else if(ee==="subtitle"){je=`${Te?ae?"text-2xl":"text-3xl":ae?"text-3xl":"text-4xl"} text-white tracking-wide text-center whitespace-pre-wrap`,ot="hidden";let lt="bottom-16";ae&&No?lt="bottom-[560px]":ae?lt="bottom-[360px]":No&&(lt="bottom-[280px]"),bt=bt.replace("absolute","").replace("transform",""),bt+=`fixed ${lt} left-1/2 -translate-x-1/2 w-full px-8 z-[100] pointer-events-none `}else if(ee==="custom"){const P=Te?ae?"text-4xl":"text-5xl":ae?"text-6xl":"text-8xl",lt=Te?ae?"text-xl":"text-2xl":ae?"text-2xl":"text-3xl",wt=E.textAlign==="center"?"text-center":E.textAlign==="right"?"text-right":"text-left";je=`${P} tracking-tight ${wt}`,ot=`${lt} opacity-40 hover:opacity-100 ${wt}`}else{const P=Te?ae?"text-2xl":"text-3xl":ae?"text-3xl":"text-5xl",lt=Te?ae?"text-lg":"text-xl":ae?"text-xl":"text-2xl";je=`${P} font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`,ot=`${lt} text-zinc-500/60 hover:text-zinc-300 drop-shadow-sm`}const tn=(E.lyricStyleTarget||"active-only")==="all"||De;let Pe={color:E.fontColor,fontWeight:tn?E.fontWeight:void 0,fontStyle:tn?E.fontStyle:void 0,textDecoration:tn?E.textDecoration:void 0,fontFamily:E.fontFamily==="CustomFont"?"CustomFont, sans-serif":E.fontFamily};if((ee==="custom"||ee==="default")&&De&&E.textEffect!=="none"){const P=E.textEffect;P==="glow"?Pe.textShadow=`0 0 10px ${E.fontColor}, 0 0 20px ${E.fontColor}`:P==="neon"?Pe.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${E.fontColor}, 0 0 40px ${E.fontColor}, 0 0 80px ${E.fontColor}`:P==="neon-multi"?Pe.textShadow="0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 35px #00ffff, 0 0 40px #ff00de, 0 0 50px #00ffff":P==="shadow"?Pe.textShadow="3px 3px 6px rgba(0,0,0,0.7)":P==="outline"?Pe.textShadow="-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000":P==="3d"?Pe.textShadow="1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)":P==="emboss"?(Pe.color="#ebebeb",Pe.textShadow="1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)"):P==="gold"?(Pe.background="linear-gradient(to bottom, #d4af37, #C5A028)",Pe.WebkitBackgroundClip="text",Pe.color="transparent"):P==="chrome"?(Pe.background="linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)",Pe.WebkitBackgroundClip="text",Pe.color="transparent"):P==="fire"?(Pe.color="#fff",Pe.textShadow="0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548"):P==="frozen"?(Pe.color="#fff",Pe.textShadow="0 0 5px rgba(255,255,255,0.8), 0 0 10px rgba(255,255,255,0.5), 0 0 20px #03A9F4, 0 0 30px #03A9F4, 0 0 40px #03A9F4"):P==="vhs"?Pe.textShadow="2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)":P==="gradient"?(Pe.background=`linear-gradient(to right, ${E.fontColor}, #ffffff)`,Pe.WebkitBackgroundClip="text",Pe.color="transparent"):P==="rainbow"?(Pe.background="linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)",Pe.WebkitBackgroundClip="text",Pe.color="transparent"):P==="glass"?(Pe.backgroundColor="rgba(255, 255, 255, 0.1)",Pe.backdropFilter="blur(8px)",Pe.padding="0.5rem 1rem",Pe.borderRadius="0.75rem",Pe.border="1px solid rgba(255, 255, 255, 0.2)",Pe.display="inline-block"):P==="mirror"?(Pe.transform="scaleY(1.3) perspective(500px) rotateX(-10deg)",Pe.textShadow="0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)"):P==="retro"?(Pe.fontFamily="'Press Start 2P', cursive",Pe.color="#ff00ff",Pe.textShadow="4px 4px 0px #00ffff"):P==="cyberpunk"?(Pe.color="#fcee0a",Pe.textShadow="2px 2px 0px #000, -1px -1px 0 #05d9e8",Pe.fontFamily="'Orbitron', sans-serif",Pe.letterSpacing="1px"):P==="glitch-text"?(Pe.animation="anim-glitch 0.4s infinite linear",Pe.position="relative"):P==="hologram"?(Pe.color="rgba(0, 255, 255, 0.7)",Pe.textShadow="0 0 5px rgba(0,255,255,0.5), 0 0 10px rgba(0,255,255,0.5)",Pe.backgroundImage="repeating-linear-gradient(0deg, transparent, transparent 2px, #00ffff 3px)",Pe.WebkitBackgroundClip="text"):P==="comic"&&(Pe.fontFamily="'Bangers', cursive",Pe.color="#ffcc00",Pe.textShadow="2px 2px 0px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",Pe.letterSpacing="1px")}let Mt=I.text;const nn=E.textCase;nn==="upper"?Mt=Mt.toUpperCase():nn==="lower"?Mt=Mt.toLowerCase():nn==="title"?Mt=Mt.replace(/\w\S*/g,P=>P.charAt(0).toUpperCase()+P.substr(1).toLowerCase()):nn==="sentence"?Mt=Mt.charAt(0).toUpperCase()+Mt.slice(1).toLowerCase():nn==="invert"&&(Mt=Mt.replace(/\w\S*/g,P=>P.charAt(0).toLowerCase()+P.slice(1).toUpperCase())),Mt=Mt.replace(/\s*([-‐‑‒–—―])\s*/g,"$1"),De&&E.textAnimation==="typewriter"&&(Mt=Mt.substring(0,Math.max(0,Math.floor((ge-I.time)*35))));let Tn=Mt;if(De&&E.highlightEffect!=="none"){const P=E.highlightEffect,lt=I.words&&I.words.length>0;if((P==="karaoke"||P?.startsWith("karaoke-"))&<)Tn=I.words.filter(wt=>wt.text===` -`||wt.text.trim().length>0).map((wt,Ge,Ft)=>{if(wt.text===` -`)return u.jsx("br",{},Ge);let pt=wt.text.trim();if(nn==="upper")pt=pt.toUpperCase();else if(nn==="lower")pt=pt.toLowerCase();else if(nn==="title")pt=pt.replace(/\w\S*/g,zt=>zt.charAt(0).toUpperCase()+zt.substr(1).toLowerCase());else if(nn==="sentence"){const zt=pt.toLowerCase();pt=Ge===0?zt.charAt(0).toUpperCase()+zt.slice(1):zt}else nn==="invert"&&(pt=pt.replace(/\w\S*/g,zt=>zt.charAt(0).toLowerCase()+zt.slice(1).toUpperCase()));const Ht=wt.startTime+oe,fn=wt.endTime+oe,hn=ge>=Ht&&ge=fn,In=/[-‐‑‒–—―]$/,yi=/^[-‐‑‒–—―]/;let di=!pt.endsWith(" ");In.test(pt.trim())&&(di=!1);const Ai=Ft[Ge+1];Ai&&yi.test(Ai.text.trim())&&(di=!1),Ai&&Ai.text===` -`&&(di=!1),Ge===Ft.length-1&&(di=!1);let de={display:"inline-block",transition:"all 0.1s ease"};if(E.textDecoration&&E.textDecoration!=="none"&&(de.textDecoration=E.textDecoration),!hn&&!Ao)P==="karaoke-smooth-white"?(de.opacity=1,de.color="#ffffff"):de.opacity=.5,de.transform="scale(1)";else if(Ao)if(P==="karaoke-fill"){const zt=E.highlightBackground||"#fb923c";de.backgroundColor=zt,de.color="#000",de.padding="2px 6px",de.borderRadius="4px",de.opacity=1}else P==="karaoke-smooth"||P==="karaoke-smooth-white"?(de.color=E.highlightColor||"#fb923c",de.opacity=1):(ee==="custom"&&(de.color=E.fontColor),de.opacity=1);if(hn){const zt=E.highlightColor||"#fb923c",Dn=E.highlightBackground||"#fb923c";if(P==="karaoke-smooth"||P==="karaoke-smooth-white"){const oo=wt.endTime-wt.startTime,mo=ge-Ht,Oi=Math.min(100,Math.max(0,mo/oo*100)),Mo=P==="karaoke-smooth-white"?"#ffffff":E.fontColor||"#ffffff";de.backgroundImage=`linear-gradient(90deg, ${zt} ${Oi}%, ${Mo} ${Oi}%)`,de.backgroundClip="text",de.WebkitBackgroundClip="text",de.color="transparent",de.WebkitTextFillColor="transparent",de.textShadow="none"}else P==="karaoke"||P==="color"?(de.color=zt,de.textShadow=`0 0 10px ${zt}`):P==="karaoke-neon"?(de.color="#fff",de.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${zt}, 0 0 35px ${zt}`):P==="karaoke-scale"?(de.color=zt,de.transform="scale(1.3)"):P==="karaoke-underline"?(de.color=zt,de.textDecoration=(de.textDecoration||"")+" underline",de.textDecorationColor=zt,de.textUnderlineOffset="4px"):P==="karaoke-bounce"?(de.color=zt,de.transform="translateY(-10px)"):P==="karaoke-fill"?(de.backgroundColor=Dn,de.color="#000",de.padding="2px 6px",de.borderRadius="4px"):P==="karaoke-outline"?(de.color="transparent",de.WebkitTextStroke=`2px ${zt}`):P==="karaoke-shadow"?(de.color=zt,de.textShadow="3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000"):P==="karaoke-gradient"?(de.background=`linear-gradient(90deg, ${zt}, ${Dn})`,de.WebkitBackgroundClip="text",de.WebkitTextFillColor="transparent"):P==="karaoke-wave"?(de.color=zt,de.animation="bounce 0.3s ease infinite"):P==="karaoke-pill"?(de.backgroundColor=Dn,de.color="#000",de.padding="4px 16px",de.borderRadius="9999px"):P==="karaoke-box"?(de.backgroundColor=Dn,de.color="#000",de.padding="4px 8px",de.borderRadius="0"):P==="karaoke-rounded"?(de.backgroundColor=Dn,de.color="#000",de.padding="4px 12px",de.padding="4px 12px",de.borderRadius="12px"):P==="karaoke-glass"?(de.backgroundColor="rgba(255, 255, 255, 0.1)",de.color="#fff",de.padding="4px 12px",de.borderRadius="8px",de.backdropFilter="blur(4px)",de.border="1px solid rgba(255, 255, 255, 0.3)",de.boxShadow="0 4px 6px rgba(0, 0, 0, 0.1)"):P==="karaoke-neon-multi"?(de.color="#fff",de.textShadow="0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 35px #00ffff, 0 0 40px #ff00de"):P==="karaoke-soft-glow"?(de.color=zt,de.textShadow=`0 0 5px ${zt}, 0 0 15px ${zt}, 0 0 30px ${zt}`):P==="karaoke-3d"?de.textShadow="1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)":P==="karaoke-emboss"?(de.color="#ebebeb",de.textShadow="1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)"):P==="karaoke-chrome"?(de.background="linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)",de.WebkitBackgroundClip="text",de.color="transparent"):P==="karaoke-gold"?(de.background="linear-gradient(to bottom, #d4af37, #C5A028)",de.WebkitBackgroundClip="text",de.color="transparent"):P==="karaoke-fire"?(de.color="#fff",de.textShadow="0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548"):P==="karaoke-frozen"?(de.color="#fff",de.textShadow="0 0 5px rgba(255,255,255,0.8), 0 0 10px rgba(255,255,255,0.5), 0 0 20px #03A9F4, 0 0 30px #03A9F4"):P==="karaoke-rainbow"?(de.background="linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)",de.WebkitBackgroundClip="text",de.color="transparent"):P==="karaoke-mirror"?(de.transform="scaleY(1.3) perspective(500px) rotateX(-10deg)",de.textShadow="0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)"):P==="karaoke-vhs"?de.textShadow="2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)":P==="karaoke-retro"?(de.fontFamily="'Press Start 2P', cursive",de.color="#ff00ff",de.textShadow="4px 4px 0px #00ffff"):P==="karaoke-cyberpunk"?(de.color="#fcee0a",de.textShadow="2px 2px 0px #000, -1px -1px 0 #05d9e8",de.fontFamily="'Orbitron', sans-serif"):P==="karaoke-hologram"?(de.color="rgba(0, 255, 255, 0.7)",de.textShadow="0 0 5px rgba(0,255,255,0.5)"):P==="karaoke-comic"?(de.fontFamily="'Bangers', cursive",de.color="#ffcc00",de.textShadow="2px 2px 0px #000, -1px -1px 0 #000"):P==="karaoke-glitch-text"?de.animation="anim-glitch 0.4s infinite linear":P==="karaoke-pulse"?de.animation="anim-pulse 1s infinite ease-in-out":P==="karaoke-breathe"?de.animation="anim-breathe 2s infinite ease-in-out":P==="karaoke-float"?de.animation="anim-float 2s infinite ease-in-out":P==="karaoke-sway"?de.animation="anim-sway 2s infinite ease-in-out":P==="karaoke-flicker"?de.animation="anim-flicker 2s infinite linear":P==="karaoke-shake"?de.animation="anim-shake 0.2s infinite linear":P==="karaoke-wobble"?de.animation="anim-wobble 1s infinite ease-in-out":P==="karaoke-jello"?de.animation="anim-jello 1s infinite":P==="karaoke-rubberband"?de.animation="anim-rubberband 1s infinite":P==="karaoke-heartbeat"?de.animation="anim-heartbeat 1.3s infinite ease-in-out":P==="karaoke-flash"?de.animation="anim-flash 1s infinite":P==="karaoke-tada"?de.animation="anim-tada 1s infinite":P==="karaoke-swing"?de.animation="anim-swing 2s infinite":P==="karaoke-rotate"?de.animation="anim-rotate 4s infinite linear":P==="karaoke-spin"?de.animation="anim-rotate 1s infinite linear":P==="karaoke-glitch"?de.animation="anim-glitch 0.3s infinite linear":P==="karaoke-typewriter"?(de.animation="typewriter-reveal 0.5s steps(10, end) forwards",de.whiteSpace="nowrap",de.overflow="hidden",de.display="inline-block",de.verticalAlign="bottom"):P==="karaoke-fade"?de.animation="trans-fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards":P==="karaoke-slide"?de.animation="trans-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards":P==="karaoke-drop"?de.animation="trans-drop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards":P==="karaoke-lightspeed"?de.animation="trans-lightspeed-in 0.5s ease-out forwards":P==="karaoke-roll"?de.animation="trans-roll-in 0.5s ease-out forwards":P==="karaoke-zoom"?de.animation="trans-zoom-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards":P==="karaoke-elastic"?de.animation="trans-elastic-in 0.7s ease-out forwards":P==="karaoke-scale-rotate"?de.animation="trans-scale-rotate-in 0.5s ease-out forwards":P==="karaoke-flip"?de.animation="trans-flip-in 0.5s ease-out forwards":P==="karaoke-rotate-in"?de.animation="trans-rotate-in 0.5s ease-out forwards":P==="karaoke-spiral"?de.animation="trans-spiral-in 0.6s ease-out forwards":P==="karaoke-blur"?de.animation="trans-blur-in 0.4s ease-out forwards":P==="karaoke-shatter"?de.animation="trans-shatter-in 0.5s ease-out forwards":["karaoke-blue","karaoke-purple","karaoke-green","karaoke-pink","karaoke-cyan","karaoke-glow-blue","karaoke-glow-pink"].includes(P||"")&&(de.color=zt,de.textShadow=`0 0 10px ${zt}`,P?.includes("glow")&&(de.textShadow=`0 0 5px ${zt}, 0 0 15px ${zt}, 0 0 30px ${zt}`))}const En=u.jsx("span",{className:"inline-block",style:de,children:pt},Ge);return di?u.jsxs(ep.Fragment,{children:[En," "]},Ge):En});else if(P==="karaoke"||P?.startsWith("karaoke-")){const wt=E.highlightColor||"#fb923c",Ge=E.highlightBackground||"#fb923c";Pe.color=wt,P==="karaoke-neon"&&(Pe.textShadow=`0 0 10px ${wt}, 0 0 20px ${wt}`),P==="karaoke-scale"&&(Pe.transform=(Pe.transform||"")+" scale(1.1)"),P==="karaoke-underline"&&(Pe.textDecoration="underline"),P==="karaoke-bounce"&&(Pe.transform=(Pe.transform||"")+" translateY(-5px)"),P==="karaoke-fill"&&(Pe.backgroundColor=Ge,Pe.color="#000",Pe.padding="4px 12px",Pe.borderRadius="6px"),P==="karaoke-outline"&&(Pe.color="transparent",Pe.WebkitTextStroke=`2px ${wt}`),P==="karaoke-shadow"&&(Pe.textShadow="3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000"),P==="karaoke-gradient"&&(Pe.background=`linear-gradient(90deg, ${wt}, ${Ge})`,Pe.WebkitBackgroundClip="text",Pe.WebkitTextFillColor="transparent"),["karaoke-pill","karaoke-box","karaoke-rounded"].includes(P)&&(Pe.backgroundColor=Ge,Pe.color="#000",Pe.padding="4px 16px",Pe.borderRadius=P==="karaoke-pill"?"9999px":P==="karaoke-rounded"?"12px":"0"),P?.includes("glow")&&(Pe.textShadow=`0 0 10px ${wt}, 0 0 20px ${wt}`)}else P==="scale"?Pe.color=E.highlightColor||"#fb923c":E.highlightEffect==="background"&&(Pe.backgroundColor=(E.highlightBackground||"#fb923c")+"4D",Pe.padding="0 10px",Pe.borderRadius="8px")}return u.jsx("p",{"data-lyric-active":De?"true":"false",className:`${bt} ${De?je:ot}`,onClick:()=>{De&&(navigator.clipboard.writeText(I.text),e.success("Lyric copied to clipboard",1500)),o.current&&!Ae&&(o.current.currentTime=I.time,qe(I.time))},children:u.jsx("span",{className:`inline-block ${De&&E.textAnimation!=="none"&&E.textAnimation!=="typewriter"?`text-anim-${E.textAnimation}`:""}`,children:u.jsx("span",{style:Pe,className:"inline-block",children:Tn})})},Q)}),u.jsx("div",{className:`transition-all duration-500 ${E.contentPosition==="center"?ze===ri.EDITOR||dt?"h-[25vh]":!el&&!No?"h-[50vh]":"h-[40vh]":"h-0"}`})]}):u.jsx("div",{className:"text-center text-zinc-400/50 select-none pointer-events-none",children:!ho&&!m&&_e.length===0&&ee!=="none"&&u.jsxs("div",{className:"flex flex-col items-center gap-4 animate-pulse",children:[u.jsx(Oa,{size:64,className:"opacity-20"}),u.jsx("p",{children:"Load audio & lyrics to start"}),u.jsx("p",{className:"text-xs opacity-50",children:"Shortcuts: Space (Play), S (Stop), R (Repeat), H (Hold UI)"})]})})}),u.jsx("div",{className:`no-minimal-mode-toggle transition-all duration-500 ease-in-out overflow-hidden ${No?"max-h-60 opacity-100 translate-y-0":"max-h-0 opacity-0 translate-y-4"}`,children:u.jsx("div",{className:"bg-gradient-to-t from-black/60 via-black/30 to-transparent p-4 pb-6 lg:p-6 lg:pb-8",children:u.jsxs("div",{className:"max-w-7xl mx-auto space-y-4",children:[u.jsxs("div",{className:"flex items-center gap-3 group",children:[u.jsx("span",{className:"text-xs text-zinc-400 font-mono w-10 text-right",children:wo(ge)}),u.jsxs("div",{ref:Fe,className:"flex-1 h-1 bg-zinc-700/50 rounded-full relative cursor-pointer group-hover:h-2 transition-all touch-none",onPointerDown:I=>{I.currentTarget.setPointerCapture(I.pointerId),Ml(I.clientX)},onPointerMove:I=>{I.buttons===1&&Ml(I.clientX)},children:[u.jsx("div",{className:"absolute top-0 left-0 h-full bg-purple-500 rounded-full pointer-events-none",style:{width:`${ge/Ve*100}%`}}),u.jsx("input",{type:"range",name:"progress",id:"progress-bar","aria-label":"Seek Progress",min:"0",max:Ve||0,value:ge,onChange:ia,disabled:Ae,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-wait pointer-events-none"})]}),u.jsx("span",{className:"text-xs text-zinc-400 font-mono w-10",children:wo(Ve)}),u.jsxs("div",{className:"flex items-center gap-2 pl-4",children:[u.jsx("button",{onClick:()=>K(!xt),className:"text-zinc-400 hover:text-white",children:xt||nt===0?u.jsx(Pa,{size:16}):u.jsx(Tl,{size:16})}),u.jsxs("div",{ref:Be,className:"w-16 h-1 bg-zinc-700/50 rounded-full relative overflow-hidden group/vol cursor-pointer touch-none",onPointerDown:I=>{I.currentTarget.setPointerCapture(I.pointerId),gi(I.clientX)},onPointerMove:I=>{I.buttons===1&&gi(I.clientX)},children:[u.jsx("div",{className:"absolute top-0 left-0 h-full bg-zinc-300 group-hover/vol:bg-purple-400 transition-colors pointer-events-none",style:{width:`${xt?0:nt*100}%`}}),u.jsx("input",{type:"range",name:"volume",id:"volume-control","aria-label":"Volume Control",min:"0",max:"1",step:"0.05",value:xt?0:nt,onChange:io,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer pointer-events-none"})]})]})]}),u.jsxs("div",{className:"flex flex-wrap lg:grid lg:grid-cols-[1fr_auto_1fr] items-center justify-center gap-4",children:[u.jsxs("div",{className:"flex gap-1 justify-center lg:justify-start flex-wrap order-2 lg:order-none w-auto lg:w-full",children:[u.jsxs("label",{className:"p-2 rounded-lg hover:bg-white/10 text-zinc-400 hover:text-white cursor-pointer transition-colors",title:"Load Audio or video",children:[u.jsx(Oa,{size:18}),u.jsx("input",{type:"file",name:"audio-file",id:"audio-file",accept:"audio/*,video/*",className:"hidden",onChange:en,disabled:Ae})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs("label",{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${F.length>0?"text-purple-400":"text-zinc-400 hover:text-white"}`,title:"Load Lyrics (.lrc, .srt, .vtt, .ttml)",children:[u.jsx(Pc,{size:18}),u.jsx("input",{type:"file",name:"lyrics-file",id:"lyrics-file",accept:".lrc,.srt,.ttml,.xml,.vtt",className:"hidden",onChange:Xo,disabled:Ae})]}),F.length>0&&u.jsx("button",{onClick:()=>z([]),className:"p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors",title:"Clear Lyrics",disabled:Ae,children:u.jsx(Bi,{size:14})})]}),u.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9",children:[u.jsxs("span",{className:"text-xs text-zinc-300 w-12 text-center font-mono select-none border-r border-white/10 pr-2 mr-1",children:[oe>0?"+":"",oe.toFixed(1),"s"]}),u.jsxs("div",{className:"flex flex-col -my-1 h-full justify-center",children:[u.jsx("button",{onClick:()=>ce(I=>parseFloat((I+.1).toFixed(1))),className:"text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors",title:"Increase Lyric Offset (+0.1s)",disabled:Ae,children:u.jsx(wf,{size:12})}),u.jsx("button",{onClick:()=>ce(I=>parseFloat((I-.1).toFixed(1))),className:"text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors",title:"Decrease Lyric Offset (-0.1s)",disabled:Ae,children:u.jsx(rr,{size:12})})]})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs("label",{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${$e?"text-purple-400":"text-zinc-400 hover:text-white"}`,title:$e?`Custom Font: ${$e}`:"Load Custom Font (.ttf, .otf, .woff)",children:[u.jsx(Cl,{size:18}),u.jsx("input",{type:"file",name:"font-file",id:"font-file",accept:".ttf,.otf,.woff,.woff2",className:"hidden",onChange:to,disabled:Ae})]}),$e&&u.jsx("button",{onClick:()=>Oe(null),className:"p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors",title:"Reset Default Font",disabled:Ae,children:u.jsx(Bi,{size:14})})]}),u.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9",children:[u.jsxs("span",{className:"text-xs text-zinc-300 w-10 text-center font-mono select-none border-r border-white/10 pr-2 mr-1",children:[Math.round(E.fontSizeScale*100),"%"]}),u.jsxs("div",{className:"flex flex-col -my-1 h-full justify-center",children:[u.jsx("button",{onClick:()=>O(I=>({...I,fontSizeScale:Math.min(I.fontSizeScale+.1,3)})),className:"text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors",title:"Increase Font Size",disabled:Ae,children:u.jsx(wf,{size:12})}),u.jsx("button",{onClick:()=>O(I=>({...I,fontSizeScale:Math.max(I.fontSizeScale-.1,.1)})),className:"text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors",title:"Decrease Font Size",disabled:Ae,children:u.jsx(rr,{size:12})})]})]}),u.jsxs("div",{className:"relative group",children:[u.jsxs("select",{value:ee,onChange:I=>{const Q=I.target.value;be(Q);const De=Yc[Q];if(De){const ae={fontFamily:"sans-serif",fontSizeScale:1,fontColor:"#ffffff",fontWeight:"bold",fontStyle:"normal",textCase:"none",textAlign:"center",contentPosition:"center",textDecoration:"none",textEffect:"preset",textAnimation:"none",highlightEffect:"karaoke",highlightColor:"#fb923c",highlightBackground:"#fb923c",useCustomHighlightColors:!1,lyricStyleTarget:"active-only",transitionEffect:"none"};O(Te=>({...Te,...ae,...De}))}},className:"appearance-none bg-zinc-800/50 border border-white/5 text-zinc-300 text-xs rounded-lg px-3 pr-8 h-9 w-24 focus:outline-none focus:border-purple-500 cursor-pointer",disabled:Ae,title:"Select Visual Preset",name:"preset",id:"preset-select","aria-label":"Visual Preset",children:[u.jsx("option",{value:"custom",className:"bg-zinc-900 font-bold text-purple-400",children:"Custom ✨"}),u.jsx("option",{value:"default",className:"bg-zinc-900",children:"Default"}),u.jsx("option",{value:"large",className:"bg-zinc-900",children:"Big Text"}),u.jsx("option",{value:"large_upper",className:"bg-zinc-900",children:"Big Text (UP)"}),u.jsx("option",{value:"big_center",className:"bg-zinc-900",children:"Big Center"}),u.jsx("option",{value:"metal",className:"bg-zinc-900",children:"Metal"}),u.jsx("option",{value:"kids",className:"bg-zinc-900",children:"Kids"}),u.jsx("option",{value:"sad",className:"bg-zinc-900",children:"Sad"}),u.jsx("option",{value:"romantic",className:"bg-zinc-900",children:"Romantic"}),u.jsx("option",{value:"tech",className:"bg-zinc-900",children:"Tech"}),u.jsx("option",{value:"gothic",className:"bg-zinc-900",children:"Gothic"}),u.jsx("option",{value:"classic",className:"bg-zinc-900",children:"Classic Serif"}),u.jsx("option",{value:"monospace",className:"bg-zinc-900",children:"Monospace"}),u.jsx("option",{value:"testing_up",className:"bg-zinc-900",children:"Testing (UP)"}),u.jsx("option",{value:"testing",className:"bg-zinc-900",children:"Testing"}),u.jsx("option",{value:"one_line_up",className:"bg-zinc-900",children:"One Line (UP)"}),u.jsx("option",{value:"one_line",className:"bg-zinc-900",children:"One Line"}),u.jsx("option",{value:"slideshow",className:"bg-zinc-900",children:"Slideshow"}),u.jsx("option",{value:"just_video",className:"bg-zinc-900",children:"Just Video"}),u.jsx("option",{value:"subtitle",className:"bg-zinc-900",children:"Subtitle"}),u.jsx("option",{value:"none",className:"bg-zinc-900",children:"None"})]}),u.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:u.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:u.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]})]}),u.jsxs("div",{className:"flex items-center gap-4 lg:gap-6 justify-center order-1 lg:order-none w-full lg:w-auto mb-2 lg:mb-0",children:[u.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",onClick:ii,title:"Stop (S)",disabled:Ae,children:u.jsx(_f,{size:20,fill:"currentColor"})}),u.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:Ae||_e.length===0,onClick:ta,title:"Previous Song",children:u.jsx(QS,{size:24})}),u.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:Ae,onClick:()=>o.current&&(o.current.currentTime-=5),title:"Rewind 5s",children:u.jsx(VS,{size:20})}),u.jsx("button",{onClick:na,disabled:Ae,className:"w-14 h-14 flex items-center justify-center bg-white text-black rounded-full hover:scale-105 transition-transform shadow-lg shadow-purple-500/20 disabled:opacity-50 disabled:hover:scale-100",children:ve?u.jsx(dv,{size:28,fill:"currentColor"}):u.jsx(Tf,{size:28,fill:"currentColor",className:"ml-1"})}),u.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:Ae,onClick:()=>o.current&&(o.current.currentTime+=5),title:"Fast Forward 5s",children:u.jsx(sS,{size:20})}),u.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:Ae||_e.length===0,onClick:kn,title:"Next Song",children:u.jsx(ew,{size:24})}),u.jsxs("button",{className:`transition-colors disabled:opacity-50 ${fe!=="off"?"text-green-400 hover:text-green-300":"text-zinc-400 hover:text-white"}`,onClick:_o,title:`Repeat: ${fe==="off"?"Off":fe==="one"?"One":fe==="all"?"Play All (No Repeat)":"Loop All"} (R)`,disabled:Ae,children:[fe==="one"&&u.jsx(BS,{size:20}),fe==="all_repeat"&&u.jsx(gg,{size:20}),fe==="all"&&u.jsx(jc,{size:20}),fe==="off"&&u.jsx(gg,{size:20,className:"opacity-50"})]})]}),u.jsxs("div",{className:"flex items-center gap-1 justify-center lg:justify-end group flex-wrap order-3 lg:order-none w-auto lg:w-full",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx("button",{onClick:()=>O(I=>({...I,backgroundBlurStrength:I.backgroundBlurStrength>0?0:12})),className:`bg-zinc-800/50 border border-white/5 text-[10px] font-mono rounded-lg px-2 h-9 transition-colors disabled:opacity-30 ${tt?"text-purple-400 border-purple-500/50":"text-zinc-300 hover:text-white"}`,title:`Background Blur: ${tt?"On":"Off"}`,disabled:Ae,children:tt?"BLUR":"SHARP"}),u.jsx("button",{onClick:()=>O(I=>({...I,highlightEffect:I.highlightEffect==="none"?"karaoke":"none"})),className:`p-2 rounded-full transition-all ${E.highlightEffect!=="none"?"bg-orange-500 text-white shadow-[0_0_15px_rgba(249,115,22,0.5)]":"hover:bg-zinc-800 text-zinc-400"}`,title:"Toggle Lyric Highlight",children:u.jsx(Cl,{size:20})}),u.jsx("button",{onClick:()=>Re(I=>I==="1080p"?"720p":"1080p"),className:"bg-zinc-800/50 border border-white/5 text-[10px] font-mono text-zinc-300 hover:text-white rounded-lg px-2 h-9 transition-colors disabled:opacity-30",title:"Toggle Resolution (720p / 1080p)",disabled:Ae,children:Ie}),u.jsx("button",{onClick:()=>q(I=>I==="16:9"?"9:16":I==="9:16"?"3:4":I==="3:4"?"1:1":I==="1:1"?"1:2":I==="1:2"?"2:1":I==="2:1"?"2:3":I==="2:3"?"3:2":"16:9"),className:"bg-zinc-800/50 border border-white/5 text-[10px] font-mono text-zinc-300 hover:text-white rounded-lg px-2 h-9 transition-colors disabled:opacity-30",title:"Toggle Aspect Ratio (16:9 / 9:16 / 3:4 / 1:1 / 1:2 / 2:1 / 2:3 / 3:2)",disabled:Ae,children:me})]}),u.jsxs("div",{className:"relative group",children:[u.jsxs("select",{value:A,onChange:I=>W(I.target.value),className:"appearance-none bg-zinc-800/50 border border-white/5 text-zinc-300 text-xs rounded-lg px-3 pr-8 w-26 h-9 focus:outline-none focus:border-purple-500 cursor-pointer text-ellipsis overflow-hidden",disabled:Ae,title:"Select Render Engine",name:"engine",id:"engine-select","aria-label":"Render Engine",children:[u.jsx("option",{value:"mediarecorder",className:"bg-zinc-900",children:"Realtime"}),u.jsx("option",{value:"webcodecs",className:"bg-zinc-900",children:"WebCodecs"}),u.jsx("option",{value:"ffmpeg",className:"bg-zinc-900",children:"FFMPEG"})]}),u.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:u.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:u.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),u.jsxs("div",{className:"relative group",children:[u.jsxs("select",{value:gt,onChange:I=>Et(I.target.value),className:"appearance-none bg-zinc-800/50 border border-white/5 text-zinc-300 text-xs rounded-lg px-3 pr-8 w-18 h-9 focus:outline-none focus:border-purple-500 cursor-pointer",disabled:Ae,title:"Select Quality (Bitrate)",name:"quality",id:"quality-select","aria-label":"Render Quality",children:[u.jsx("option",{value:"low",className:"bg-zinc-900",children:"Low"}),u.jsx("option",{value:"med",className:"bg-zinc-900",children:"Med"}),u.jsx("option",{value:"high",className:"bg-zinc-900",children:"High"})]}),u.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:u.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:u.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),u.jsx("button",{onClick:oa,disabled:Ae||!m,className:"p-2 rounded-lg hover:bg-white/10 text-zinc-400 hover:text-white cursor-pointer transition-colors",title:`Export as Video (${A==="ffmpeg"?"FFmpeg":"MediaRecorder"})`,children:u.jsx(nr,{size:18})})]})]})]})})}),dt?u.jsx("div",{className:"no-minimal-mode-toggle animate-slide-up border-t border-white/10 z-30 shrink-0 w-full max-w-[100vw] overflow-hidden",children:u.jsx(QM,{playlist:_e,setPlaylist:Ot,currentTrackIndex:Se,setCurrentTrackIndex:he,onPlayTrack:Ni,isPlaying:ve,onTogglePlay:na,currentTime:ge,onSeek:I=>{o.current&&!Ae&&(o.current.currentTime=I,qe(I))},onClearPlaylist:()=>{ii(),x(null),z([]),he(-1),T({title:"No Audio Loaded",artist:"Select a file",coverUrl:null,backgroundType:"image"})},onRemoveTrack:I=>{I===Se?(ii(),x(null),z([]),he(-1),T({title:"No Audio Loaded",artist:"Select a file",coverUrl:null,backgroundType:"image"})):IQ-1),Ot(Q=>{const De=[...Q];return De.splice(I,1),De})},onClose:()=>Dt(!1)})}):ze===ri.EDITOR&&u.jsx("div",{className:"no-minimal-mode-toggle animate-slide-up border-t border-white/10 z-30 shrink-0 w-full max-w-[100vw] overflow-hidden",children:u.jsx(Lw,{slides:G,setSlides:Y,currentTime:ge,duration:Ve||60,lyrics:F,onSeek:I=>{o.current&&!Ae&&(o.current.currentTime=I,qe(I))},onClose:()=>Le(ri.PLAYER),renderConfig:E,setRenderConfig:O})})]}),Ae&&u.jsxs("div",{className:"absolute inset-0 z-50 bg-black/90 flex flex-col items-center justify-center p-8 text-center space-y-6",children:[u.jsx("div",{className:A==="ffmpeg"?"animate-pulse":"animate-bounce",children:u.jsx(nr,{size:48,className:A==="ffmpeg"?"text-orange-500":"text-purple-500"})}),u.jsxs("h2",{className:"text-2xl font-bold text-white",children:[A==="ffmpeg"?"FFmpeg Rendering":"Rendering Video"," (",me," ",Ie,")"]}),u.jsx("p",{className:"text-zinc-400 max-w-md",children:A==="ffmpeg"?u.jsxs(u.Fragment,{children:["Frame-by-frame capture using FFmpeg WASM.",u.jsx("br",{}),u.jsx("span",{className:"text-orange-400 font-medium",children:k||"Initializing..."}),u.jsx("br",{}),"This is faster than realtime - no audio playback needed."]}):u.jsxs(u.Fragment,{children:["Rendering in real-time using Canvas 2D engine.",u.jsx("br",{}),"The audio will play during capture.",u.jsx("br",{}),"Please keep this tab active for best performance."]})}),u.jsx("div",{className:"w-full max-w-md h-2 bg-zinc-800 rounded-full overflow-hidden",children:u.jsx("div",{className:`h-full transition-all duration-300 ease-linear ${A==="ffmpeg"?"bg-orange-500":"bg-purple-500"}`,style:{width:`${se}%`}})}),u.jsxs("p",{className:"text-sm font-mono text-zinc-500",children:[Math.round(se),"%"]}),u.jsxs("button",{onClick:Wo,className:"mt-4 px-6 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 hover:text-red-300 rounded-full transition-colors flex items-center gap-2 border border-red-500/50",children:[u.jsx(_f,{size:16,fill:"currentColor"}),"Abort Rendering"]})]}),B&&u.jsx(l2,{config:E,setConfig:O,preset:ee,setPreset:be,onClose:()=>te(!1),isPlaylistMode:dt,hasPlaylist:_e.length>0,onRender:oa,customFontName:$e,onFontUpload:to,onClearCustomFont:()=>{Oe(null),O(I=>({...I,fontFamily:"ui-sans-serif, system-ui, sans-serif"}))},customChannelFontName:ht,onChannelFontUpload:no,onClearChannelCustomFont:()=>{R(null),O(I=>({...I,channelInfoFontFamily:void 0}))},customInfoFontName:Ue,onInfoFontUpload:Al,onClearInfoCustomFont:()=>{We(null),O(I=>({...I,infoFontFamily:void 0}))},resolution:Ie,setResolution:Re,aspectRatio:me,setAspectRatio:q,renderCodec:Xe,setRenderCodec:Ye,supportedCodecs:St,renderQuality:gt,setRenderQuality:Et,renderFps:ft,setRenderFps:jt,renderEngine:A,setRenderEngine:W,ffmpegCodec:M,setFfmpegCodec:D}),j&&u.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>we(!1),children:u.jsxs("div",{className:"no-minimal-mode-toggle bg-zinc-900 border border-white/10 rounded-2xl p-6 max-w-2xl w-full max-h-[80vh] overflow-y-auto shadow-2xl relative",onClick:I=>I.stopPropagation(),children:[u.jsx("button",{onClick:()=>we(!1),className:"absolute top-4 right-4 p-2 rounded-full hover:bg-white/10 text-zinc-400 hover:text-white transition-colors",children:u.jsx(Bi,{size:20})}),u.jsxs("h2",{className:"text-2xl font-bold text-white mb-6 flex items-center gap-2",children:[u.jsx(Bc,{className:"text-purple-500"}),"Keyboard Shortcuts"]}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-12 gap-y-6",children:[u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider",children:"Playback"}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Play / Pause"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Space"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Stop"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"S"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Rewind 5s"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"←"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Forward 5s"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"→"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Repeat Mode"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"R"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Mute"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"M"})]})]}),u.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6",children:"Interface"}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Fullscreen"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"F"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Minimal Mode"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"O"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Hold UI (No Auto-Hide)"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"H"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Header Info"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"I"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Shortcut Info"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Y"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Player"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"P"})]})]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider",children:"Editor & Styles"}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Timeline"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"T"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Playlist"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"L"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Render Settings"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"D"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Export Video"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Ctrl+Shift+E"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Font Size"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"+ / -"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Visual Preset"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"J"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Highight Effect"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Z"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Highlight"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"X"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Text Case"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"C"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Cycle Lyric Mode"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"G"})]})]}),u.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6",children:"Mouse & Touch"}),u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Toggle Minimal Mode"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Double Click / Tap"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Seek to Lyric"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Click Line"})]}),u.jsxs("div",{className:"flex justify-between text-sm",children:[u.jsx("span",{className:"text-zinc-300",children:"Copy Active Lyric"})," ",u.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Click Active Line"})]})]})]})]}),u.jsx("div",{className:"mt-8 pt-6 border-t border-white/5 text-center",children:u.jsx("p",{className:"text-zinc-500 text-sm",children:"Shortcuts are disabled during video rendering."})})]})})]})}const Mx=document.getElementById("root");if(!Mx)throw new Error("Could not find root element to mount to");const Ok=A1.createRoot(Mx);Ok.render(u.jsx(ep.StrictMode,{children:u.jsx(kw,{children:u.jsx(jk,{})})}));export{Vk as c,rv as g};