diff --git "a/assets/index-CbUtqinI.js" "b/assets/index-CbUtqinI.js" new file mode 100644--- /dev/null +++ "b/assets/index-CbUtqinI.js" @@ -0,0 +1,225 @@ +(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 u of s)if(u.type==="childList")for(const p of u.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&l(p)}).observe(document,{childList:!0,subtree:!0});function o(s){const u={};return s.integrity&&(u.integrity=s.integrity),s.referrerPolicy&&(u.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?u.credentials="include":s.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function l(s){if(s.ep)return;s.ep=!0;const u=o(s);fetch(s.href,u)}})();var gk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd={exports:{}},zs={};var V0;function s1(){if(V0)return zs;V0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(l,s,u){var p=null;if(u!==void 0&&(p=""+u),s.key!==void 0&&(p=""+s.key),"key"in s){u={};for(var g in s)g!=="key"&&(u[g]=s[g])}else u=s;return s=u.ref,{$$typeof:e,type:l,key:p,ref:s!==void 0?s:null,props:u}}return zs.Fragment=t,zs.jsx=o,zs.jsxs=o,zs}var $0;function r1(){return $0||($0=1,Xd.exports=s1()),Xd.exports}var d=r1(),Wd={exports:{}},zt={};var q0;function c1(){if(q0)return zt;q0=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"),u=Symbol.for("react.consumer"),p=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 A(L){return L===null||typeof L!="object"?null:(L=S&&L[S]||L["@@iterator"],typeof L=="function"?L:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,I={};function $(L,le,we){this.props=L,this.context=le,this.refs=I,this.updater=we||E}$.prototype.isReactComponent={},$.prototype.setState=function(L,le){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,le,"setState")},$.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function oe(){}oe.prototype=$.prototype;function se(L,le,we){this.props=L,this.context=le,this.refs=I,this.updater=we||E}var fe=se.prototype=new oe;fe.constructor=se,j(fe,$.prototype),fe.isPureReactComponent=!0;var De=Array.isArray;function be(){}var ye={H:null,A:null,T:null,S:null},tt=Object.prototype.hasOwnProperty;function Ne(L,le,we){var Ce=we.ref;return{$$typeof:e,type:L,key:le,ref:Ce!==void 0?Ce:null,props:we}}function Xe(L,le){return Ne(L.type,le,L.props)}function $e(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Ze(L){var le={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(we){return le[we]})}var gt=/\/+/g;function xt(L,le){return typeof L=="object"&&L!==null&&L.key!=null?Ze(""+L.key):le.toString(36)}function Nt(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(be,be):(L.status="pending",L.then(function(le){L.status==="pending"&&(L.status="fulfilled",L.value=le)},function(le){L.status==="pending"&&(L.status="rejected",L.reason=le)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function G(L,le,we,Ce,Ke){var C=typeof L;(C==="undefined"||C==="boolean")&&(L=null);var B=!1;if(L===null)B=!0;else switch(C){case"bigint":case"string":case"number":B=!0;break;case"object":switch(L.$$typeof){case e:case t:B=!0;break;case x:return B=L._init,G(B(L._payload),le,we,Ce,Ke)}}if(B)return Ke=Ke(L),B=Ce===""?"."+xt(L,0):Ce,De(Ke)?(we="",B!=null&&(we=B.replace(gt,"$&/")+"/"),G(Ke,le,we,"",function(Pe){return Pe})):Ke!=null&&($e(Ke)&&(Ke=Xe(Ke,we+(Ke.key==null||L&&L.key===Ke.key?"":(""+Ke.key).replace(gt,"$&/")+"/")+B)),le.push(Ke)),1;B=0;var ne=Ce===""?".":Ce+":";if(De(L))for(var ae=0;ae>>1,ut=G[Ye];if(0>>1;Yes(we,ie))Ces(Ke,we)?(G[Ye]=Ke,G[Ce]=ie,Ye=Ce):(G[Ye]=we,G[le]=ie,Ye=le);else if(Ces(Ke,ie))G[Ye]=Ke,G[Ce]=ie,Ye=Ce;else break e}}return Ee}function s(G,Ee){var ie=G.sortIndex-Ee.sortIndex;return ie!==0?ie:G.id-Ee.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var p=Date,g=p.now();e.unstable_now=function(){return p.now()-g}}var v=[],m=[],x=1,b=null,S=3,A=!1,E=!1,j=!1,I=!1,$=typeof setTimeout=="function"?setTimeout:null,oe=typeof clearTimeout=="function"?clearTimeout:null,se=typeof setImmediate<"u"?setImmediate:null;function fe(G){for(var Ee=o(m);Ee!==null;){if(Ee.callback===null)l(m);else if(Ee.startTime<=G)l(m),Ee.sortIndex=Ee.expirationTime,t(v,Ee);else break;Ee=o(m)}}function De(G){if(j=!1,fe(G),!E)if(o(v)!==null)E=!0,be||(be=!0,Ze());else{var Ee=o(m);Ee!==null&&Nt(De,Ee.startTime-G)}}var be=!1,ye=-1,tt=5,Ne=-1;function Xe(){return I?!0:!(e.unstable_now()-NeG&&Xe());){var Ye=b.callback;if(typeof Ye=="function"){b.callback=null,S=b.priorityLevel;var ut=Ye(b.expirationTime<=G);if(G=e.unstable_now(),typeof ut=="function"){b.callback=ut,fe(G),Ee=!0;break t}b===o(v)&&l(v),fe(G)}else l(v);b=o(v)}if(b!==null)Ee=!0;else{var L=o(m);L!==null&&Nt(De,L.startTime-G),Ee=!1}}break e}finally{b=null,S=ie,A=!1}Ee=void 0}}finally{Ee?Ze():be=!1}}}var Ze;if(typeof se=="function")Ze=function(){se($e)};else if(typeof MessageChannel<"u"){var gt=new MessageChannel,xt=gt.port2;gt.port1.onmessage=$e,Ze=function(){xt.postMessage(null)}}else Ze=function(){$($e,0)};function Nt(G,Ee){ye=$(function(){G(e.unstable_now())},Ee)}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(G){G.callback=null},e.unstable_forceFrameRate=function(G){0>G||125Ye?(G.sortIndex=ie,t(m,G),o(v)===null&&G===o(m)&&(j?(oe(ye),ye=-1):j=!0,Nt(De,ie-Ye))):(G.sortIndex=ut,t(v,G),E||A||(E=!0,be||(be=!0,Ze()))),G},e.unstable_shouldYield=Xe,e.unstable_wrapCallback=function(G){var Ee=S;return function(){var ie=S;S=Ee;try{return G.apply(this,arguments)}finally{S=ie}}}})(ef)),ef}var K0;function d1(){return K0||(K0=1,Zd.exports=u1()),Zd.exports}var tf={exports:{}},si={};var X0;function f1(){if(X0)return si;X0=1;var e=Vf();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(),tf.exports=f1(),tf.exports}var Q0;function h1(){if(Q0)return Ds;Q0=1;var e=d1(),t=Vf(),o=p1();function l(n){var i="https://react.dev/errors/"+n;if(1ut||(n.current=Ye[ut],Ye[ut]=null,ut--)}function we(n,i){ut++,Ye[ut]=n.current,n.current=i}var Ce=L(null),Ke=L(null),C=L(null),B=L(null);function ne(n,i){switch(we(C,i),we(Ke,n),we(Ce,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?p0(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=p0(i),n=h0(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}le(Ce),we(Ce,n)}function ae(){le(Ce),le(Ke),le(C)}function Pe(n){n.memoizedState!==null&&we(B,n);var i=Ce.current,a=h0(i,n.type);i!==a&&(we(Ke,n),we(Ce,a))}function P(n){Ke.current===n&&(le(Ce),le(Ke)),B.current===n&&(le(B),Ms._currentValue=ie)}var Be,Re;function xe(n){if(Be===void 0)try{throw Error()}catch(a){var i=a.stack.trim().match(/\n( *(at )?)/);Be=i&&i[1]||"",Re=-1)":-1h||D[r]!==X[h]){var ge=` +`+D[r].replace(" at new "," at ");return n.displayName&&ge.includes("")&&(ge=ge.replace("",n.displayName)),ge}while(1<=r&&0<=h);break}}}finally{pe=!1,Error.prepareStackTrace=a}return(a=n?n.displayName||n.name:"")?xe(a):""}function et(n,i){switch(n.tag){case 26:case 27:case 5:return xe(n.type);case 16:return xe("Lazy");case 13:return n.child!==i&&i!==null?xe("Suspense Fallback"):xe("Suspense");case 19:return xe("SuspenseList");case 0:case 15:return Oe(n.type,!1);case 11:return Oe(n.type.render,!1);case 1:return Oe(n.type,!0);case 31:return xe("Activity");default:return""}}function z(n){try{var i="",a=null;do i+=et(n,a),a=n,n=n.return;while(n);return i}catch(r){return` +Error generating stack: `+r.message+` +`+r.stack}}var Ve=Object.prototype.hasOwnProperty,at=e.unstable_scheduleCallback,U=e.unstable_cancelCallback,Z=e.unstable_shouldYield,ce=e.unstable_requestPaint,Ae=e.unstable_now,ve=e.unstable_getCurrentPriorityLevel,Me=e.unstable_ImmediatePriority,ue=e.unstable_UserBlockingPriority,Ge=e.unstable_NormalPriority,w=e.unstable_LowPriority,M=e.unstable_IdlePriority,R=e.log,V=e.unstable_setDisableYieldValue,Y=null,he=null;function de(n){if(typeof R=="function"&&V(n),he&&typeof he.setStrictMode=="function")try{he.setStrictMode(Y,n)}catch{}}var Le=Math.clz32?Math.clz32:_,ke=Math.log,Ie=Math.LN2;function _(n){return n>>>=0,n===0?32:31-(ke(n)/Ie|0)|0}var st=256,wt=262144,Dt=4194304;function Mt(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 ot(n,i,a){var r=n.pendingLanes;if(r===0)return 0;var h=0,y=n.suspendedLanes,T=n.pingedLanes;n=n.warmLanes;var N=r&134217727;return N!==0?(r=N&~y,r!==0?h=Mt(r):(T&=N,T!==0?h=Mt(T):a||(a=N&~n,a!==0&&(h=Mt(a))))):(N=r&~y,N!==0?h=Mt(N):T!==0?h=Mt(T):a||(a=r&~n,a!==0&&(h=Mt(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 Wt(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function me(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 Ue(){var n=Dt;return Dt<<=1,(Dt&62914560)===0&&(Dt=4194304),n}function mt(n){for(var i=[],a=0;31>a;a++)i.push(n);return i}function yt(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 T=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,D=n.expirationTimes,X=n.hiddenUpdates;for(a=T&~a;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var ea=/[\n"\\]/g;function qn(n){return n.replace(ea,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Vo(n,i,a,r,h,y,T,N){n.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?n.type=T:n.removeAttribute("type"),i!=null?T==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+ui(i)):n.value!==""+ui(i)&&(n.value=""+ui(i)):T!=="submit"&&T!=="reset"||n.removeAttribute("value"),i!=null?ta(n,T,ui(i)):a!=null?ta(n,T,ui(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=""+ui(N):n.removeAttribute("name")}function lr(n,i,a,r,h,y,T,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)){Ka(n);return}a=a!=null?""+ui(a):"",i=i!=null?""+ui(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,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(n.name=T),Ka(n)}function ta(n,i,a){i==="number"&&Go(n.ownerDocument)===n||n.defaultValue===""+a||(n.defaultValue=""+a)}function $o(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"),it=!1;if(F)try{var bt={};Object.defineProperty(bt,"passive",{get:function(){it=!0}}),window.addEventListener("test",bt,bt),window.removeEventListener("test",bt,bt)}catch{it=!1}var qe=null,Ut=null,pt=null;function sn(){if(pt)return pt;var n,i=Ut,a=i.length,r,h="value"in qe?qe.value:qe.textContent,y=h.length;for(n=0;n=Xa),bp=" ",Sp=!1;function Tp(n,i){switch(n){case"keyup":return Mx.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wp(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ia=!1;function Rx(n,i){switch(n){case"compositionend":return wp(i);case"keypress":return i.which!==32?null:(Sp=!0,bp);case"textInput":return n=i.data,n===bp&&Sp?null:n;default:return null}}function Ix(n,i){if(ia)return n==="compositionend"||!nu&&Tp(n,i)?(n=sn(),pt=Ut=qe=null,ia=!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=Rp(a)}}function zp(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?zp(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Dp(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=Go(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=Go(n.document)}return i}function lu(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 Ox=F&&"documentMode"in document&&11>=document.documentMode,oa=null,au=null,es=null,su=!1;function Lp(n,i,a){var r=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;su||oa==null||oa!==Go(r)||(r=oa,"selectionStart"in r&&lu(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}),es&&Za(es,r)||(es=r,r=Jr(au,"onSelect"),0>=T,h-=T,lo=1<<32-Le(i)+h|a<Ft?(qt=ht,ht=null):qt=ht.sibling;var tn=ee(q,ht,K[Ft],Te);if(tn===null){ht===null&&(ht=qt);break}n&&ht&&tn.alternate===null&&i(q,ht),O=y(tn,O,Ft),en===null?St=tn:en.sibling=tn,en=tn,ht=qt}if(Ft===K.length)return a(q,ht),Kt&&To(q,Ft),St;if(ht===null){for(;FtFt?(qt=ht,ht=null):qt=ht.sibling;var ml=ee(q,ht,tn.value,Te);if(ml===null){ht===null&&(ht=qt);break}n&&ht&&ml.alternate===null&&i(q,ht),O=y(ml,O,Ft),en===null?St=ml:en.sibling=ml,en=ml,ht=qt}if(tn.done)return a(q,ht),Kt&&To(q,Ft),St;if(ht===null){for(;!tn.done;Ft++,tn=K.next())tn=_e(q,tn.value,Te),tn!==null&&(O=y(tn,O,Ft),en===null?St=tn:en.sibling=tn,en=tn);return Kt&&To(q,Ft),St}for(ht=r(ht);!tn.done;Ft++,tn=K.next())tn=re(ht,q,Ft,tn.value,Te),tn!==null&&(n&&tn.alternate!==null&&ht.delete(tn.key===null?Ft:tn.key),O=y(tn,O,Ft),en===null?St=tn:en.sibling=tn,en=tn);return n&&ht.forEach(function(a1){return i(q,a1)}),Kt&&To(q,Ft),St}function gn(q,O,K,Te){if(typeof K=="object"&&K!==null&&K.type===j&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case A:e:{for(var St=K.key;O!==null;){if(O.key===St){if(St=K.type,St===j){if(O.tag===7){a(q,O.sibling),Te=h(O,K.props.children),Te.return=q,q=Te;break e}}else if(O.elementType===St||typeof St=="object"&&St!==null&&St.$$typeof===tt&&zl(St)===O.type){a(q,O.sibling),Te=h(O,K.props),as(Te,K),Te.return=q,q=Te;break e}a(q,O);break}else i(q,O);O=O.sibling}K.type===j?(Te=Al(K.props.children,q.mode,Te,K.key),Te.return=q,q=Te):(Te=dr(K.type,K.key,K.props,null,q.mode,Te),as(Te,K),Te.return=q,q=Te)}return T(q);case E:e:{for(St=K.key;O!==null;){if(O.key===St)if(O.tag===4&&O.stateNode.containerInfo===K.containerInfo&&O.stateNode.implementation===K.implementation){a(q,O.sibling),Te=h(O,K.children||[]),Te.return=q,q=Te;break e}else{a(q,O);break}else i(q,O);O=O.sibling}Te=hu(K,q.mode,Te),Te.return=q,q=Te}return T(q);case tt:return K=zl(K),gn(q,O,K,Te)}if(Nt(K))return ct(q,O,K,Te);if(Ze(K)){if(St=Ze(K),typeof St!="function")throw Error(l(150));return K=St.call(K),_t(q,O,K,Te)}if(typeof K.then=="function")return gn(q,O,vr(K),Te);if(K.$$typeof===se)return gn(q,O,hr(q,K),Te);xr(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,O!==null&&O.tag===6?(a(q,O.sibling),Te=h(O,K),Te.return=q,q=Te):(a(q,O),Te=pu(K,q.mode,Te),Te.return=q,q=Te),T(q)):a(q,O)}return function(q,O,K,Te){try{ls=0;var St=gn(q,O,K,Te);return ma=null,St}catch(ht){if(ht===ha||ht===gr)throw ht;var en=_i(29,ht,null,q.mode);return en.lanes=Te,en.return=q,en}}}var Ll=oh(!0),lh=oh(!1),Qo=!1;function _u(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Nu(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 Zo(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function el(n,i,a){var r=n.updateQueue;if(r===null)return null;if(r=r.shared,(ln&2)!==0){var h=r.pending;return h===null?i.next=i:(i.next=h.next,h.next=i),r.pending=i,i=ur(n),jp(n,null,a),i}return cr(n,r,i,a),ur(n)}function ss(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,Jt(n,a)}}function Au(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 T={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?h=y=T:y=y.next=T,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 Mu=!1;function rs(){if(Mu){var n=pa;if(n!==null)throw n}}function cs(n,i,a,r){Mu=!1;var h=n.updateQueue;Qo=!1;var y=h.firstBaseUpdate,T=h.lastBaseUpdate,N=h.shared.pending;if(N!==null){h.shared.pending=null;var D=N,X=D.next;D.next=null,T===null?y=X:T.next=X,T=D;var ge=n.alternate;ge!==null&&(ge=ge.updateQueue,N=ge.lastBaseUpdate,N!==T&&(N===null?ge.firstBaseUpdate=X:N.next=X,ge.lastBaseUpdate=D))}if(y!==null){var _e=h.baseState;T=0,ge=X=D=null,N=y;do{var ee=N.lane&-536870913,re=ee!==N.lane;if(re?($t&ee)===ee:(r&ee)===ee){ee!==0&&ee===fa&&(Mu=!0),ge!==null&&(ge=ge.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var ct=n,_t=N;ee=i;var gn=a;switch(_t.tag){case 1:if(ct=_t.payload,typeof ct=="function"){_e=ct.call(gn,_e,ee);break e}_e=ct;break e;case 3:ct.flags=ct.flags&-65537|128;case 0:if(ct=_t.payload,ee=typeof ct=="function"?ct.call(gn,_e,ee):ct,ee==null)break e;_e=b({},_e,ee);break e;case 2:Qo=!0}}ee=N.callback,ee!==null&&(n.flags|=64,re&&(n.flags|=8192),re=h.callbacks,re===null?h.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:N.tag,payload:N.payload,callback:N.callback,next:null},ge===null?(X=ge=re,D=_e):ge=ge.next=re,T|=ee;if(N=N.next,N===null){if(N=h.shared.pending,N===null)break;re=N,N=re.next,re.next=null,h.lastBaseUpdate=re,h.shared.pending=null}}while(!0);ge===null&&(D=_e),h.baseState=D,h.firstBaseUpdate=X,h.lastBaseUpdate=ge,y===null&&(h.shared.lanes=0),ll|=T,n.lanes=T,n.memoizedState=_e}}function ah(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function sh(n,i){var a=n.callbacks;if(a!==null)for(n.callbacks=null,n=0;ny?y:8;var T=G.T,N={};G.T=N,Ju(n,!1,i,a);try{var D=h(),X=G.S;if(X!==null&&X(N,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var ge=Kx(D,r);fs(n,i,ge,Ri(n))}else fs(n,i,r,Ri(n))}catch(_e){fs(n,i,{then:function(){},status:"rejected",reason:_e},Ri())}finally{Ee.p=y,T!==null&&N.types!==null&&(T.types=N.types),G.T=T}}function tb(){}function qu(n,i,a,r){if(n.tag!==5)throw Error(l(476));var h=Bh(n).queue;Ph(n,h,i,ie,a===null?tb:function(){return Oh(n),a(r)})}function Bh(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_o,lastRenderedState:ie},next:null};var a={};return i.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_o,lastRenderedState:a},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function Oh(n){var i=Bh(n);i.next===null&&(i=n.alternate.memoizedState),fs(n,i.next.queue,{},Ri())}function Yu(){return ei(Ms)}function Hh(){return zn().memoizedState}function jh(){return zn().memoizedState}function nb(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var a=Ri();n=Zo(a);var r=el(i,n,a);r!==null&&(Si(r,i,a),ss(r,i,a)),i={cache:Tu()},n.payload=i;return}i=i.return}}function ib(n,i,a){var r=Ri();a={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Mr(n)?Vh(i,a):(a=du(n,i,a,r),a!==null&&(Si(a,n,r),$h(a,i,r)))}function Gh(n,i,a){var r=Ri();fs(n,i,a,r)}function fs(n,i,a,r){var h={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Mr(n))Vh(i,h);else{var y=n.alternate;if(n.lanes===0&&(y===null||y.lanes===0)&&(y=i.lastRenderedReducer,y!==null))try{var T=i.lastRenderedState,N=y(T,a);if(h.hasEagerState=!0,h.eagerState=N,Ei(N,T))return cr(n,i,h,0),yn===null&&rr(),!1}catch{}if(a=du(n,i,h,r),a!==null)return Si(a,n,r),$h(a,i,r),!0}return!1}function Ju(n,i,a,r){if(r={lane:2,revertLane:_d(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Mr(n)){if(i)throw Error(l(479))}else i=du(n,a,r,2),i!==null&&Si(i,n,2)}function Mr(n){var i=n.alternate;return n===Lt||i!==null&&i===Lt}function Vh(n,i){ya=Tr=!0;var a=n.pending;a===null?i.next=i:(i.next=a.next,a.next=i),n.pending=i}function $h(n,i,a){if((a&4194048)!==0){var r=i.lanes;r&=n.pendingLanes,a|=r,i.lanes=a,Jt(n,a)}}var ps={readContext:ei,use:Er,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useLayoutEffect:Mn,useInsertionEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useSyncExternalStore:Mn,useId:Mn,useHostTransitionStatus:Mn,useFormState:Mn,useActionState:Mn,useOptimistic:Mn,useMemoCache:Mn,useCacheRefresh:Mn};ps.useEffectEvent=Mn;var qh={readContext:ei,use:Er,useCallback:function(n,i){return fi().memoizedState=[n,i===void 0?null:i],n},useContext:ei,useEffect:Mh,useImperativeHandle:function(n,i,a){a=a!=null?a.concat([n]):null,Nr(4194308,4,zh.bind(null,i,n),a)},useLayoutEffect:function(n,i){return Nr(4194308,4,n,i)},useInsertionEffect:function(n,i){Nr(4,2,n,i)},useMemo:function(n,i){var a=fi();i=i===void 0?null:i;var r=n();if(Ul){de(!0);try{n()}finally{de(!1)}}return a.memoizedState=[r,i],r},useReducer:function(n,i,a){var r=fi();if(a!==void 0){var h=a(i);if(Ul){de(!0);try{a(i)}finally{de(!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=ib.bind(null,Lt,n),[r.memoizedState,n]},useRef:function(n){var i=fi();return n={current:n},i.memoizedState=n},useState:function(n){n=Hu(n);var i=n.queue,a=Gh.bind(null,Lt,i);return i.dispatch=a,[n.memoizedState,a]},useDebugValue:Vu,useDeferredValue:function(n,i){var a=fi();return $u(a,n,i)},useTransition:function(){var n=Hu(!1);return n=Ph.bind(null,Lt,n.queue,!0,!1),fi().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,a){var r=Lt,h=fi();if(Kt){if(a===void 0)throw Error(l(407));a=a()}else{if(a=i(),yn===null)throw Error(l(349));($t&127)!==0||ph(r,i,a)}h.memoizedState=a;var y={value:a,getSnapshot:i};return h.queue=y,Mh(mh.bind(null,r,y,n),[n]),r.flags|=2048,xa(9,{destroy:void 0},hh.bind(null,r,y,a,i),null),a},useId:function(){var n=fi(),i=yn.identifierPrefix;if(Kt){var a=ao,r=lo;a=(r&~(1<<32-Le(r)-1)).toString(32)+a,i="_"+i+"R_"+a,a=wr++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof r.is=="string"?T.createElement("select",{is:r.is}):T.createElement("select"),r.multiple?y.multiple=!0:r.size&&(y.size=r.size);break;default:y=typeof r.is=="string"?T.createElement(h,{is:r.is}):T.createElement(h)}}y[Je]=i,y[Ct]=r;e:for(T=i.child;T!==null;){if(T.tag===5||T.tag===6)y.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===i)break e;for(;T.sibling===null;){if(T.return===null||T.return===i)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}i.stateNode=y;e:switch(ni(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&&Ao(i)}}return wn(i),rd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,a),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==r&&Ao(i);else{if(typeof r!="string"&&i.stateNode===null)throw Error(l(166));if(n=C.current,ua(i)){if(n=i.stateNode,a=i.memoizedProps,r=null,h=Zn,h!==null)switch(h.tag){case 27:case 5:r=h.memoizedProps}n[Je]=i,n=!!(n.nodeValue===a||r!==null&&r.suppressHydrationWarning===!0||d0(n.nodeValue,a)),n||Xo(i,!0)}else n=Kr(n).createTextNode(r),n[Je]=i,i.stateNode=n}return wn(i),null;case 31:if(a=i.memoizedState,n===null||n.memoizedState!==null){if(r=ua(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[Je]=i}else Ml(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;wn(i),n=!1}else a=vu(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=a),n=!0;if(!n)return i.flags&256?(Ai(i),i):(Ai(i),null);if((i.flags&128)!==0)throw Error(l(558))}return wn(i),null;case 13:if(r=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(h=ua(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[Je]=i}else Ml(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;wn(i),h=!1}else h=vu(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=h),h=!0;if(!h)return i.flags&256?(Ai(i),i):(Ai(i),null)}return Ai(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),Dr(i,i.updateQueue),wn(i),null);case 4:return ae(),n===null&&kd(i.stateNode.containerInfo),wn(i),null;case 10:return Co(i.type),wn(i),null;case 19:if(le(In),r=i.memoizedState,r===null)return wn(i),null;if(h=(i.flags&128)!==0,y=r.rendering,y===null)if(h)ms(r,!1);else{if(kn!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(y=Sr(n),y!==null){for(i.flags|=128,ms(r,!1),n=y.updateQueue,i.updateQueue=n,Dr(i,n),i.subtreeFlags=0,n=a,a=i.child;a!==null;)Gp(a,n),a=a.sibling;return we(In,In.current&1|2),Kt&&To(i,r.treeForkCount),i.child}n=n.sibling}r.tail!==null&&Ae()>Br&&(i.flags|=128,h=!0,ms(r,!1),i.lanes=4194304)}else{if(!h)if(n=Sr(y),n!==null){if(i.flags|=128,h=!0,n=n.updateQueue,i.updateQueue=n,Dr(i,n),ms(r,!0),r.tail===null&&r.tailMode==="hidden"&&!y.alternate&&!Kt)return wn(i),null}else 2*Ae()-r.renderingStartTime>Br&&a!==536870912&&(i.flags|=128,h=!0,ms(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=Ae(),n.sibling=null,a=In.current,we(In,h?a&1|2:a&1),Kt&&To(i,r.treeForkCount),n):(wn(i),null);case 22:case 23:return Ai(i),Ru(),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&&(wn(i),i.subtreeFlags&6&&(i.flags|=8192)):wn(i),a=i.updateQueue,a!==null&&Dr(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&&le(Il),null;case 24:return a=null,n!==null&&(a=n.memoizedState.cache),i.memoizedState.cache!==a&&(i.flags|=2048),Co(Pn),wn(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function rb(n,i){switch(gu(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return Co(Pn),ae(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return P(i),null;case 31:if(i.memoizedState!==null){if(Ai(i),i.alternate===null)throw Error(l(340));Ml()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(Ai(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ml()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return le(In),null;case 4:return ae(),null;case 10:return Co(i.type),null;case 22:case 23:return Ai(i),Ru(),n!==null&&le(Il),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return Co(Pn),null;case 25:return null;default:return null}}function gm(n,i){switch(gu(i),i.tag){case 3:Co(Pn),ae();break;case 26:case 27:case 5:P(i);break;case 4:ae();break;case 31:i.memoizedState!==null&&Ai(i);break;case 13:Ai(i);break;case 19:le(In);break;case 10:Co(i.type);break;case 22:case 23:Ai(i),Ru(),n!==null&&le(Il);break;case 24:Co(Pn)}}function gs(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,T=a.inst;r=y(),T.destroy=r}a=a.next}while(a!==h)}}catch(N){dn(i,i.return,N)}}function il(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 T=r.inst,N=T.destroy;if(N!==void 0){T.destroy=void 0,h=i;var D=a,X=N;try{X()}catch(ge){dn(h,D,ge)}}}r=r.next}while(r!==y)}}catch(ge){dn(i,i.return,ge)}}function ym(n){var i=n.updateQueue;if(i!==null){var a=n.stateNode;try{sh(i,a)}catch(r){dn(n,n.return,r)}}}function vm(n,i,a){a.props=Fl(n.type,n.memoizedProps),a.state=n.memoizedState;try{a.componentWillUnmount()}catch(r){dn(n,i,r)}}function ys(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){dn(n,i,h)}}function so(n,i){var a=n.ref,r=n.refCleanup;if(a!==null)if(typeof r=="function")try{r()}catch(h){dn(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){dn(n,i,h)}else a.current=null}function xm(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){dn(n,n.return,h)}}function cd(n,i,a){try{var r=n.stateNode;kb(r,n.type,a,i),r[Ct]=i}catch(h){dn(n,n.return,h)}}function bm(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&ul(n.type)||n.tag===4}function ud(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||bm(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&&ul(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 dd(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=nt));else if(r!==4&&(r===27&&ul(n.type)&&(a=n.stateNode,i=null),n=n.child,n!==null))for(dd(n,i,a),n=n.sibling;n!==null;)dd(n,i,a),n=n.sibling}function Lr(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&&ul(n.type)&&(a=n.stateNode),n=n.child,n!==null))for(Lr(n,i,a),n=n.sibling;n!==null;)Lr(n,i,a),n=n.sibling}function Sm(n){var i=n.stateNode,a=n.memoizedProps;try{for(var r=n.type,h=i.attributes;h.length;)i.removeAttributeNode(h[0]);ni(i,r,a),i[Je]=n,i[Ct]=a}catch(y){dn(n,n.return,y)}}var Mo=!1,Hn=!1,fd=!1,Tm=typeof WeakSet=="function"?WeakSet:Set,Yn=null;function cb(n,i){if(n=n.containerInfo,zd=nc,n=Dp(n),lu(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 T=0,N=-1,D=-1,X=0,ge=0,_e=n,ee=null;t:for(;;){for(var re;_e!==a||h!==0&&_e.nodeType!==3||(N=T+h),_e!==y||r!==0&&_e.nodeType!==3||(D=T+r),_e.nodeType===3&&(T+=_e.nodeValue.length),(re=_e.firstChild)!==null;)ee=_e,_e=re;for(;;){if(_e===n)break t;if(ee===a&&++X===h&&(N=T),ee===y&&++ge===r&&(D=T),(re=_e.nextSibling)!==null)break;_e=ee,ee=_e.parentNode}_e=re}a=N===-1||D===-1?null:{start:N,end:D}}else a=null}a=a||{start:0,end:0}}else a=null;for(Dd={focusedElem:n,selectionRange:a},nc=!1,Yn=i;Yn!==null;)if(i=Yn,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Yn=n;else for(;Yn!==null;){switch(i=Yn,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"))),ni(y,r,a),y[Je]=n,_n(y),r=y;break e;case"link":var T=A0("link","href",h).get(r+(a.href||""));if(T){for(var N=0;Ngn&&(T=gn,gn=_t,_t=T);var q=Ip(N,_t),O=Ip(N,gn);if(q&&O&&(re.rangeCount!==1||re.anchorNode!==q.node||re.anchorOffset!==q.offset||re.focusNode!==O.node||re.focusOffset!==O.offset)){var K=_e.createRange();K.setStart(q.node,q.offset),re.removeAllRanges(),_t>gn?(re.addRange(K),re.extend(O.node,O.offset)):(K.setEnd(O.node,O.offset),re.addRange(K))}}}}for(_e=[],re=N;re=re.parentNode;)re.nodeType===1&&_e.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<_e.length;N++){var Te=_e[N];Te.element.scrollLeft=Te.left,Te.element.scrollTop=Te.top}}nc=!!zd,Dd=zd=null}finally{ln=h,Ee.p=r,G.T=a}}n.current=i,Vn=2}}function Km(){if(Vn===2){Vn=0;var n=sl,i=Ca,a=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||a){a=G.T,G.T=null;var r=Ee.p;Ee.p=2;var h=ln;ln|=4;try{wm(n,i.alternate,i)}finally{ln=h,Ee.p=r,G.T=a}}Vn=3}}function Xm(){if(Vn===4||Vn===3){Vn=0,ce();var n=sl,i=Ca,a=Do,r=Um;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?Vn=5:(Vn=0,Ca=sl=null,Wm(n,n.pendingLanes));var h=n.pendingLanes;if(h===0&&(al=null),Rn(a),i=i.stateNode,he&&typeof he.onCommitFiberRoot=="function")try{he.onCommitFiberRoot(Y,i,void 0,(i.current.flags&128)===128)}catch{}if(r!==null){i=G.T,h=Ee.p,Ee.p=2,G.T=null;try{for(var y=n.onRecoverableError,T=0;Ta?32:a,G.T=null,a=xd,xd=null;var y=sl,T=Do;if(Vn=0,Ca=sl=null,Do=0,(ln&6)!==0)throw Error(l(331));var N=ln;if(ln|=4,zm(y.current),km(y,y.current,T,a),ln=N,ws(0,!1),he&&typeof he.onPostCommitFiberRoot=="function")try{he.onPostCommitFiberRoot(Y,y)}catch{}return!0}finally{Ee.p=h,G.T=r,Wm(n,i)}}function Zm(n,i,a){i=Ui(a,i),i=Qu(n.stateNode,i,2),n=el(n,i,2),n!==null&&(yt(n,2),ro(n))}function dn(n,i,a){if(n.tag===3)Zm(n,n,a);else for(;i!==null;){if(i.tag===3){Zm(i,n,a);break}else if(i.tag===1){var r=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(al===null||!al.has(r))){n=Ui(a,n),a=em(2),r=el(i,a,2),r!==null&&(tm(a,r,i,n),yt(r,2),ro(r));break}}i=i.return}}function wd(n,i,a){var r=n.pingCache;if(r===null){r=n.pingCache=new fb;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)||(md=!0,h.add(a),n=yb.bind(null,n,i,a),i.then(n,n))}function yb(n,i,a){var r=n.pingCache;r!==null&&r.delete(i),n.pingedLanes|=n.suspendedLanes&a,n.warmLanes&=~a,yn===n&&($t&a)===a&&(kn===4||kn===3&&($t&62914560)===$t&&300>Ae()-Pr?(ln&2)===0&&Ea(n,0):gd|=a,wa===$t&&(wa=0)),ro(n)}function e0(n,i){i===0&&(i=Ue()),n=Nl(n,i),n!==null&&(yt(n,i),ro(n))}function vb(n){var i=n.memoizedState,a=0;i!==null&&(a=i.retryLane),e0(n,a)}function xb(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),e0(n,a)}function bb(n,i){return at(n,i)}var $r=null,Na=null,Cd=!1,qr=!1,Ed=!1,cl=0;function ro(n){n!==Na&&n.next===null&&(Na===null?$r=Na=n:Na=Na.next=n),qr=!0,Cd||(Cd=!0,Tb())}function ws(n,i){if(!Ed&&qr){Ed=!0;do for(var a=!1,r=$r;r!==null;){if(n!==0){var h=r.pendingLanes;if(h===0)var y=0;else{var T=r.suspendedLanes,N=r.pingedLanes;y=(1<<31-Le(42|n)+1)-1,y&=h&~(T&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,o0(r,y))}else y=$t,y=ot(r,r===yn?y:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(y&3)===0||Wt(r,y)||(a=!0,o0(r,y));r=r.next}while(a);Ed=!1}}function Sb(){t0()}function t0(){qr=Cd=!1;var n=0;cl!==0&&Ib()&&(n=cl);for(var i=Ae(),a=null,r=$r;r!==null;){var h=r.next,y=n0(r,i);y===0?(r.next=null,a===null?$r=h:a.next=h,h===null&&(Na=a)):(a=r,(n!==0||(y&3)!==0)&&(qr=!0)),r=h}Vn!==0&&Vn!==5||ws(n),cl!==0&&(cl=0)}function n0(n,i){for(var a=n.suspendedLanes,r=n.pingedLanes,h=n.expirationTimes,y=n.pendingLanes&-62914561;0N)break;var ge=D.transferSize,_e=D.initiatorType;ge&&f0(_e)&&(D=D.responseEnd,T+=ge*(D"u"?null:document;function C0(n,i,a){var r=Aa;if(r&&typeof i=="string"&&i){var h=qn(i);h='link[rel="'+n+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),w0.has(h)||(w0.add(h),n={rel:n,crossOrigin:a,href:i},r.querySelector(h)===null&&(i=r.createElement("link"),ni(i,"link",n),_n(i),r.head.appendChild(i)))}}function Hb(n){Lo.D(n),C0("dns-prefetch",n,null)}function jb(n,i){Lo.C(n,i),C0("preconnect",n,i)}function Gb(n,i,a){Lo.L(n,i,a);var r=Aa;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=Ma(n);break;case"script":y=ka(n)}ji.has(y)||(n=b({rel:"preload",href:i==="image"&&a&&a.imageSrcSet?void 0:n,as:i},a),ji.set(y,n),r.querySelector(h)!==null||i==="style"&&r.querySelector(Ns(y))||i==="script"&&r.querySelector(As(y))||(i=r.createElement("link"),ni(i,"link",n),_n(i),r.head.appendChild(i)))}}function Vb(n,i){Lo.m(n,i);var a=Aa;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=ka(n)}if(!ji.has(y)&&(n=b({rel:"modulepreload",href:n},i),ji.set(y,n),a.querySelector(h)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(As(y)))return}r=a.createElement("link"),ni(r,"link",n),_n(r),a.head.appendChild(r)}}}function $b(n,i,a){Lo.S(n,i,a);var r=Aa;if(r&&n){var h=wi(r).hoistableStyles,y=Ma(n);i=i||"default";var T=h.get(y);if(!T){var N={loading:0,preload:null};if(T=r.querySelector(Ns(y)))N.loading=5;else{n=b({rel:"stylesheet",href:n,"data-precedence":i},a),(a=ji.get(y))&&Hd(n,a);var D=T=r.createElement("link");_n(D),ni(D,"link",n),D._p=new Promise(function(X,ge){D.onload=X,D.onerror=ge}),D.addEventListener("load",function(){N.loading|=1}),D.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Wr(T,i,r)}T={type:"stylesheet",instance:T,count:1,state:N},h.set(y,T)}}}function qb(n,i){Lo.X(n,i);var a=Aa;if(a&&n){var r=wi(a).hoistableScripts,h=ka(n),y=r.get(h);y||(y=a.querySelector(As(h)),y||(n=b({src:n,async:!0},i),(i=ji.get(h))&&jd(n,i),y=a.createElement("script"),_n(y),ni(y,"link",n),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},r.set(h,y))}}function Yb(n,i){Lo.M(n,i);var a=Aa;if(a&&n){var r=wi(a).hoistableScripts,h=ka(n),y=r.get(h);y||(y=a.querySelector(As(h)),y||(n=b({src:n,async:!0,type:"module"},i),(i=ji.get(h))&&jd(n,i),y=a.createElement("script"),_n(y),ni(y,"link",n),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},r.set(h,y))}}function E0(n,i,a,r){var h=(h=C.current)?Xr(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=Ma(a.href),a=wi(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=Ma(a.href);var y=wi(h).hoistableStyles,T=y.get(n);if(T||(h=h.ownerDocument||h,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(n,T),(y=h.querySelector(Ns(n)))&&!y._p&&(T.instance=y,T.state.loading=5),ji.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},ji.set(n,a),y||Jb(h,n,a,T.state))),i&&r===null)throw Error(l(528,""));return T}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=ka(a),a=wi(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 Ma(n){return'href="'+qn(n)+'"'}function Ns(n){return'link[rel="stylesheet"]['+n+"]"}function _0(n){return b({},n,{"data-precedence":n.precedence,precedence:null})}function Jb(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}),ni(i,"link",a),_n(i),n.head.appendChild(i))}function ka(n){return'[src="'+qn(n)+'"]'}function As(n){return"script[async]"+n}function N0(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,_n(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"),_n(r),ni(r,"style",h),Wr(r,a.precedence,n),i.instance=r;case"stylesheet":h=Ma(a.href);var y=n.querySelector(Ns(h));if(y)return i.state.loading|=4,i.instance=y,_n(y),y;r=_0(a),(h=ji.get(h))&&Hd(r,h),y=(n.ownerDocument||n).createElement("link"),_n(y);var T=y;return T._p=new Promise(function(N,D){T.onload=N,T.onerror=D}),ni(y,"link",r),i.state.loading|=4,Wr(y,a.precedence,n),i.instance=y;case"script":return y=ka(a.src),(h=n.querySelector(As(y)))?(i.instance=h,_n(h),h):(r=a,(h=ji.get(y))&&(r=b({},a),jd(r,h)),n=n.ownerDocument||n,h=n.createElement("script"),_n(h),ni(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,Wr(r,a.precedence,n));return i.instance}function Wr(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,T=0;T title"):null)}function Kb(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 k0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function Xb(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=Ma(r.href),y=i.querySelector(Ns(h));if(y){i=y._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=Zr.bind(n),i.then(n,n)),a.state.loading|=4,a.instance=y,_n(y);return}y=i.ownerDocument||i,r=_0(r),(h=ji.get(h))&&Hd(r,h),y=y.createElement("link"),_n(y);var T=y;T._p=new Promise(function(N,D){T.onload=N,T.onerror=D}),ni(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=Zr.bind(n),i.addEventListener("load",a),i.addEventListener("error",a))}}var Gd=0;function Wb(n,i){return n.stylesheets&&n.count===0&&tc(n,n.stylesheets),0Gd?50:800)+i);return n.unsuspend=a,function(){n.unsuspend=null,clearTimeout(r),clearTimeout(h)}}:null}function Zr(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)tc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var ec=null;function tc(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,ec=new Map,i.forEach(Qb,n),ec=null,Zr.call(n))}function Qb(n,i){if(!(i.state.loading&4)){var a=ec.get(n);if(a)var r=a.get(null);else{a=new Map,ec.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(),Qd.exports=h1(),Qd.exports}var g1=m1();const y1=Qy(g1),v1="modulepreload",x1=function(e){return"/"+e},eg={},ff=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 p=document.querySelector("meta[property=csp-nonce]"),g=p?.nonce||p?.getAttribute("nonce");s=v(o.map(m=>{if(m=x1(m),m in eg)return;eg[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":v1,x||(S.as="script"),S.crossOrigin="",S.href=m,g&&S.setAttribute("nonce",g),document.head.appendChild(S),x)return new Promise((A,E)=>{S.addEventListener("load",A),S.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(p){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=p,window.dispatchEvent(g),!g.defaultPrevented)throw p}return s.then(p=>{for(const g of p||[])g.status==="rejected"&&u(g.reason);return t().catch(u)})};const b1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),S1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,o,l)=>l?l.toUpperCase():o.toLowerCase()),tg=e=>{const t=S1(e);return t.charAt(0).toUpperCase()+t.slice(1)},Zy=(...e)=>e.filter((t,o,l)=>!!t&&t.trim()!==""&&l.indexOf(t)===o).join(" ").trim(),T1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var w1={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 C1=Q.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:s="",children:u,iconNode:p,...g},v)=>Q.createElement("svg",{ref:v,...w1,width:t,height:t,stroke:e,strokeWidth:l?Number(o)*24/Number(t):o,className:Zy("lucide",s),...!u&&!T1(g)&&{"aria-hidden":"true"},...g},[...p.map(([m,x])=>Q.createElement(m,x)),...Array.isArray(u)?u:[u]]));const ft=(e,t)=>{const o=Q.forwardRef(({className:l,...s},u)=>Q.createElement(C1,{ref:u,iconNode:t,className:Zy(`lucide-${b1(tg(e))}`,`lucide-${e}`,l),...s}));return o.displayName=tg(e),o};const E1=[["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"}]],ng=ft("align-vertical-justify-center",E1);const _1=[["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"}]],N1=ft("align-vertical-justify-end",_1);const A1=[["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"}]],M1=ft("align-vertical-justify-start",A1);const k1=[["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"}]],nf=ft("bold",k1);const R1=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],I1=ft("check",R1);const z1=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qs=ft("chevron-down",z1);const D1=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],pf=ft("chevron-up",D1);const L1=[["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"}]],U1=ft("circle-alert",L1);const F1=[["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"}]],P1=ft("clipboard",F1);const B1=[["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"}]],O1=ft("copy",B1);const H1=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],j1=ft("disc",H1);const G1=[["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"}]],V1=ft("download",G1);const $1=[["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"}]],Bs=ft("eye-off",$1);const q1=[["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"}]],Os=ft("eye",q1);const Y1=[["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"}]],J1=ft("fast-forward",Y1);const K1=[["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"}]],X1=ft("file-down",K1);const W1=[["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"}]],Ac=ft("file-text",W1);const Q1=[["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"}]],ev=ft("film",Q1);const Z1=[["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"}]],eS=ft("folder",Z1);const tS=[["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"}]],cc=ft("grip-horizontal",tS);const nS=[["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"}]],ig=ft("image",nS);const iS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],oS=ft("info",iS);const lS=[["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"}]],of=ft("italic",lS);const aS=[["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"}]],sS=ft("key",aS);const rS=[["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"}]],Mc=ft("keyboard",rS);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"}]],kc=ft("list-music",cS);const uS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],og=ft("loader-circle",uS);const dS=[["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"}]],$s=ft("maximize",dS);const fS=[["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"}]],lg=ft("minimize",fS);const pS=[["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"}]],La=ft("music",pS);const hS=[["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"}]],mS=ft("palette",hS);const gS=[["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"}]],yS=ft("panels-top-left",gS);const vS=[["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"}]],tv=ft("pause",vS);const xS=[["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"}]],hf=ft("play",xS);const bS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],nv=ft("plus",bS);const SS=[["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"}]],TS=ft("redo-2",SS);const wS=[["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"}]],CS=ft("repeat-1",wS);const ES=[["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"}]],ag=ft("repeat",ES);const _S=[["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"}]],NS=ft("rewind",_S);const AS=[["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"}]],mf=ft("rotate-ccw",AS);const MS=[["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"}]],kS=ft("scissors",MS);const RS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],IS=ft("search",RS);const zS=[["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"}]],xc=ft("settings",zS);const DS=[["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"}]],LS=ft("shuffle",DS);const US=[["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"}]],FS=ft("skip-back",US);const PS=[["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"}]],BS=ft("skip-forward",PS);const OS=[["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"}]],gf=ft("sparkles",OS);const HS=[["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"}]],jS=ft("split",HS);const GS=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],yf=ft("square",GS);const VS=[["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"}]],$S=ft("strikethrough",VS);const qS=[["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"}]],Ba=ft("trash-2",qS);const YS=[["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"}]],JS=ft("triangle-alert",YS);const KS=[["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"}]],yl=ft("type",KS);const XS=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],WS=ft("underline",XS);const QS=[["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"}]],ZS=ft("undo-2",QS);const eT=[["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"}]],fo=ft("upload",eT);const tT=[["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"}]],nT=ft("user",tT);const iT=[["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"}]],qs=ft("video",iT);const oT=[["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"}]],gl=ft("volume-2",oT);const lT=[["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"}]],Ia=ft("volume-x",lT);const aT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zi=ft("x",aT);const sT=[["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"}]],rT=ft("zoom-in",sT);const cT=[["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"}]],uT=ft("zoom-out",cT);var ii=(e=>(e.PLAYER="PLAYER",e.EDITOR="EDITOR",e))(ii||{});const qf=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")},Hs=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},uo=e=>{const t=Math.floor(e/60),o=Math.floor(e%60);return`${t}:${o.toString().padStart(2,"0")}`},vl=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(u=>{const p=[...u.matchAll(l)];if(p.length>0){let g=u.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{De&&m.push({text:De,startTime:I,endTime:0}),be{const S=parseInt(b[1],10),A=parseInt(b[2],10),E=b[4];let j=S*60+A;E&&(E.length===2?j+=parseInt(E,10)/100:(E.length,j+=parseInt(E,10)/1e3)),o.push({time:j,text:x,words:m})})}}),o.sort((u,p)=>u.time-p.time)},xl=e=>{const o=e.replace(/\r\n/g,` +`).replace(/\r/g,` +`).split(` + +`),l=[],s=/(\d{2}):(\d{2}):(\d{2}),(\d{3})/,u=p=>{const g=p.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(p=>{const g=p.split(` +`);if(g.length>=3){const v=g[1],x=g.slice(2).join(" ").trim(),b=qf(x),S=v.split(" --> ");if(S.length>=2){const A=u(S[0]),E=u(S[1]);A!==null&&b&&l.push({time:A,text:b,endTime:E!==null?E:void 0})}}}),l},$l=e=>{const t=[];try{const l=new DOMParser().parseFromString(e,"text/xml"),u=Array.from(l.getElementsByTagName("*")).filter(v=>v.localName==="p"),p=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)):Hs(m)},g=(v,m)=>{if(v.hasAttribute(m))return v.getAttribute(m);for(let x=0;xoe.localName==="span");for(let oe=0;oe<$.length;oe++){const se=$[oe],fe=g(se,"begin"),De=g(se,"end"),be=se.textContent?.replace(/\s+/g," ");if(fe&&De&&be&&be.length>0){const ye=p(fe),tt=p(De);ye!==void 0&&tt!==void 0&&j.push({text:be,startTime:ye,endTime:tt})}}A!==void 0&&t.push({time:A,text:S,endTime:E,words:j.length>0?j:void 0})}}}catch(o){console.error("Failed to parse TTML",o)}return t.sort((o,l)=>o.time-l.time)},dT=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[]},ql=e=>{const o=e.replace(/\r\n/g,` +`).replace(/\r/g,` +`).split(` +`),l=[],s=/(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})/,u=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 p=0;for(o[0]&&o[0].startsWith("WEBVTT")&&(p=1);p")){const v=g.split("-->");if(v.length>=2){const m=v[0].trim(),x=v[1].trim().split(" ")[0],b=u(m),S=u(x);if(b!==null){p++;let A=[];for(;p"))break;A.push(o[p]),p++}if(p"),A.length>0){const E=A.join(" ").trim(),j=/<(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})>/g;let I;const $=[...E.matchAll(j)];if($.length>0){I=[],$.forEach((fe,De)=>{const be=fe[1]?parseInt(fe[1].replace(":",""),10):0,ye=parseInt(fe[2],10),tt=parseInt(fe[3],10),Ne=parseInt(fe[4],10),Xe=be*3600+ye*60+tt+Ne/1e3,$e=(fe.index||0)+fe[0].length;let Ze=E.length;De+1<$.length&&(Ze=$[De+1].index||E.length);const gt=E.substring($e,Ze);if(De===0&&(fe.index||0)>0){const xt=E.substring(0,fe.index);xt.trim()&&I.push({text:xt.trim(),startTime:b,endTime:Xe})}gt&&I.push({text:gt,startTime:Xe,endTime:0})});for(let fe=0;fe/g,"").replace(/\s+/g," ").trim(),se=qf(oe);l.push({time:b,text:se,endTime:S!==null?S:void 0,words:I&&I.length>0?I:void 0})}continue}}}p++}return l},fT=({toast:e,onRemove:t})=>{const[o,l]=Q.useState(!1);Q.useEffect(()=>{const g=setTimeout(()=>{s()},e.duration||500);return()=>clearTimeout(g)},[]);const s=()=>{l(!0),setTimeout(t,300)},u=()=>{switch(e.type){case"success":return d.jsx(I1,{size:18,className:"text-green-400"});case"error":return d.jsx(U1,{size:18,className:"text-red-400"});default:return d.jsx(oS,{size:18,className:"text-blue-400"})}},p=()=>{switch(e.type){case"success":return"border-green-500/30";case"error":return"border-red-500/30";default:return"border-blue-500/30"}};return d.jsxs("div",{className:` + flex items-center gap-3 bg-zinc-900/60 backdrop-blur-xl border ${p()} + 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:[d.jsx("div",{className:"shrink-0",children:u()}),d.jsx("p",{className:"text-sm font-medium flex-1",children:e.message}),d.jsx("button",{onClick:s,className:"text-zinc-500 hover:text-white transition-colors",children:d.jsx(zi,{size:16})})]})},pT=({toasts:e,removeToast:t})=>d.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-3 pointer-events-none",children:e.map(o=>d.jsx("div",{className:"pointer-events-auto",children:d.jsx(fT,{toast:o,onRemove:()=>t(o.id)})},o.id))}),hT=({isOpen:e,message:t,onConfirm:o,onCancel:l,title:s="Confirm Action"})=>{const[u,p]=Q.useState(!1);return Q.useEffect(()=>{e?p(!0):setTimeout(()=>p(!1),300)},[e]),Q.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&&!u?null:d.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:[d.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm transition-opacity",onClick:l}),d.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:[d.jsx("div",{className:"p-6",children:d.jsxs("div",{className:"flex items-start gap-4",children:[d.jsx("div",{className:"p-3 bg-orange-500/10 rounded-full shrink-0",children:d.jsx(JS,{className:"text-orange-500",size:24})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h3",{className:"text-lg font-bold text-white mb-2",children:s}),d.jsx("p",{className:"text-zinc-400 text-sm leading-relaxed",children:t})]}),d.jsx("button",{onClick:l,className:"text-zinc-500 hover:text-white transition-colors",children:d.jsx(zi,{size:20})})]})}),d.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 bg-zinc-950/50 border-t border-white/5",children:[d.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"}),d.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"})]})]})]})},iv=Q.createContext(void 0),er=()=>{const e=Q.useContext(iv);if(!e)throw new Error("useUI must be used within a UIProvider");return e},mT=({children:e})=>{const[t,o]=Q.useState([]),l=Q.useCallback((b,S,A)=>{let E,j;typeof A=="number"?E=A:typeof A=="object"&&(E=A.duration,j=A.id);const I=j||Math.random().toString(36).substr(2,9);o($=>[...$.filter(se=>se.id!==I),{id:I,type:b,message:S,duration:E}])},[]),s=Q.useCallback(b=>{o(S=>S.filter(A=>A.id!==b))},[]),u={success:(b,S)=>l("success",b,S),error:(b,S)=>l("error",b,S),info:(b,S)=>l("info",b,S)},[p,g]=Q.useState({isOpen:!1,message:"",title:"",resolve:null}),v=Q.useCallback((b,S="Confirm Action")=>new Promise(A=>{g({isOpen:!0,message:b,title:S,resolve:A})}),[]),m=Q.useCallback(()=>{p.resolve&&p.resolve(!0),g(b=>({...b,isOpen:!1,resolve:null}))},[p]),x=Q.useCallback(()=>{p.resolve&&p.resolve(!1),g(b=>({...b,isOpen:!1,resolve:null}))},[p]);return d.jsxs(iv.Provider,{value:{toast:u,confirm:v},children:[e,d.jsx(pT,{toasts:t,removeToast:s}),d.jsx(hT,{isOpen:p.isOpen,message:p.message,title:p.title,onConfirm:m,onCancel:x})]})},uc=e=>e>=150?.5:e>=100?1:e>=60?2:e>=40?5:e>=25?10:15,gT=(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")}`},sg=10,yT=50,cn={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},vT=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}),xT=({value:e,onChange:t})=>{const[o,l]=Q.useState(e.toString());Q.useEffect(()=>{const p=parseFloat(o);!isNaN(p)&&Math.abs(p-e)<.001||l(e.toString())},[e]);const s=()=>{const p=parseFloat(o);o===""||isNaN(p)?l(e.toString()):t(p)},u=p=>{const g=parseFloat(o),v=isNaN(g)?e:g,m=Math.round((v+p)*100)/100;m<.05||(t(m),l(m.toString()))};return d.jsxs("div",{className:"flex items-center bg-zinc-900 rounded border border-zinc-700 h-[18px]",children:[d.jsx("button",{onClick:()=>u(-.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:d.jsx(Qs,{size:10})}),d.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:p=>{/^\d*\.?\d*$/.test(p.target.value)&&l(p.target.value)},onBlur:s,onKeyDown:p=>{p.stopPropagation(),p.key==="ArrowUp"&&(p.preventDefault(),u(.05)),p.key==="ArrowDown"&&(p.preventDefault(),u(-.05)),p.key==="Enter"&&p.currentTarget.blur()}}),d.jsx("button",{onClick:()=>u(.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:d.jsx(pf,{size:10})})]})},bT=({slides:e,setSlides:t,currentTime:o,duration:l,lyrics:s,onSeek:u,onClose:p,renderConfig:g,setRenderConfig:v})=>{const{confirm:m,toast:x}=er(),b=Q.useRef(null),S=Q.useRef(null),A=Q.useRef(null),[E,j]=Q.useState(40),[I,$]=Q.useState([]),[oe,se]=Q.useState(null),[fe,De]=Q.useState([]),[be,ye]=Q.useState(null),[tt,Ne]=Q.useState(!1),[Xe,$e]=Q.useState(null),[Ze,gt]=Q.useState([{slides:e,selection:[]}]),[xt,Nt]=Q.useState(0),G=Q.useRef(!1),[Ee,ie]=Q.useState([]);Q.useEffect(()=>{if(G.current){G.current=!1;return}if(be||tt)return;const w=Ze[xt],M={slides:e,selection:I};if(JSON.stringify(w)!==JSON.stringify(M)){const R=Ze.slice(0,xt+1);R.push(M),R.length>yT?(R.shift(),gt(R)):(gt(R),Nt(xt+1))}},[e,I,Ze,xt,be,tt]);const Ye=xt>0,ut=xt{if(xt>0){const w=xt-1;Nt(w),G.current=!0,t(Ze[w].slides),$(Ze[w].selection)}},[t,$,Ze,xt]),le=Q.useCallback(()=>{if(xtw.endTime)),Ce=Math.max(l,60,we),Ke=Ce*E,C=Q.useCallback(()=>{if(I.length===0)return;const w=e.filter(M=>I.includes(M.id));De(w),x.success(`Copied ${w.length} items`)},[I,e,x]),B=Q.useCallback(()=>{if(I.length===0)return;const w=e.filter(M=>I.includes(M.id));De(w),t(M=>M.filter(R=>!I.includes(R.id))),$([]),x.success(`Cut ${w.length} items`)},[I,e,t,x]),ne=Q.useRef(e),ae=Q.useRef(E);Q.useEffect(()=>{ne.current=e,ae.current=E},[e,E]);const Pe=Q.useCallback(()=>{if(fe.length===0)return;const w=Math.min(...fe.map(V=>V.startTime)),M=o-w,R=fe.map(V=>({...V,id:Math.random().toString(36).substr(2,9),startTime:V.startTime+M,endTime:V.endTime+M}));t(V=>[...V,...R].sort((Y,he)=>Y.startTime-he.startTime)),$(R.map(V=>V.id)),x.success(`Pasted ${R.length} items`)},[fe,o,t,x]),P=Q.useCallback(()=>{const w=e.filter(Y=>I.includes(Y.id)&&o>Y.startTime&&o{const he=o,de={...Y,id:Math.random().toString(36).substr(2,9),endTime:he},Le=he-Y.startTime,ke={...Y,id:Math.random().toString(36).substr(2,9),startTime:he,mediaStartOffset:(Y.mediaStartOffset||0)+Le};R.push(Y.id),M.push(de,ke),V.push(ke.id)}),t(Y=>[...Y.filter(de=>!R.includes(de.id)),...M].sort((de,Le)=>de.startTime-Le.startTime)),$(V),x.success(`Split ${w.length} items`)},[e,I,o,t,x]),Be=async w=>{if(w.target.files&&w.target.files.length>0){const M=Array.from(w.target.files),R=M.every(Y=>Y.type.startsWith("image/")),V=[];if(R){const Y=M.length,he=o,Le=Math.max(0,l-he)/Y,ke=Math.max(3,Le);M.forEach((Ie,_)=>{const st=URL.createObjectURL(Ie),wt=he+_*ke,Dt=wt+ke;V.push({id:Math.random().toString(36).substr(2,9),url:st,type:"image",startTime:wt,endTime:Dt,name:Ie.name,layer:0})})}else{let Y=o;for(const he of M){const de=he.type.startsWith("image/")?"image":he.type.startsWith("video/")?"video":"audio";let Le=5;if(de!=="image"){const Ie=await vT(he);Ie>0&&(Le=Ie)}const ke=URL.createObjectURL(he);V.push({id:Math.random().toString(36).substr(2,9),url:ke,type:de,startTime:Y,endTime:Y+Le,mediaDuration:de!=="image"?Le:void 0,name:he.name,isMuted:de==="video",volume:de==="video"||de==="audio"?1:void 0,layer:0}),Y+=Le}}t(Y=>[...Y,...V].sort((he,de)=>he.startTime-de.startTime)),w.target.value=""}},Re=w=>{t(M=>M.filter(R=>R.id!==w))},xe=async w=>{w.stopPropagation(),e.length!==0&&await m("Are you sure you want to remove all visual slides?","Remove All Slides")&&t([])},pe=(w,M,R)=>{if(w.stopPropagation(),w.preventDefault(),b.current?.focus(),w.shiftKey&&oe){const ke=e.findIndex(_=>_.id===oe),Ie=e.findIndex(_=>_.id===M);if(ke!==-1&&Ie!==-1){const _=Math.min(ke,Ie),st=Math.max(ke,Ie),wt=e.slice(_,st+1).map(Dt=>Dt.id);$(Dt=>{const Mt=new Set([...Dt,...wt]);return Array.from(Mt)})}}else w.ctrlKey||w.metaKey?($(ke=>ke.includes(M)?ke.filter(Ie=>Ie!==M):[...ke,M]),se(M)):(I.includes(M)||$([M]),se(M));const V=e.find(ke=>ke.id===M);if(!V)return;const Y=I.includes(M),he=w.ctrlKey||w.metaKey||w.shiftKey;let de=[];if(!he&&!Y)de=[M];else if(he){if(de=[M],(w.ctrlKey||w.metaKey)&&!Y)de=[...I,M];else if((w.ctrlKey||w.metaKey)&&Y){de=I.filter(ke=>ke!==M);return}}else de=I;const Le={};e.forEach(ke=>{de.includes(ke.id)&&(Le[ke.id]={start:ke.startTime,end:ke.endTime})}),Le[M]||(Le[M]={start:V.startTime,end:V.endTime}),ye({id:M,type:R,startX:w.clientX,initialStart:V.startTime,initialEnd:V.endTime,initialMap:Le}),window.addEventListener("mousemove",ce),window.addEventListener("mouseup",Ae)},Oe=w=>{w.button===0&&(w.stopPropagation(),b.current?.focus(),$([]),Ne(!0),z(w.clientX),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",at))},et=w=>{if(w.button!==0)return;b.current?.focus();const M=w.clientX,R=w.clientY,V=A.current?.getBoundingClientRect();if(!V)return;const Y=M-V.left,he=R-V.top;let de=!1;const Le=Ie=>{const _=Math.sqrt(Math.pow(Ie.clientX-M,2)+Math.pow(Ie.clientY-R,2));if(!de&&_>5&&(de=!0,$e({x:Y,y:he,w:0,h:0})),de&&A.current){const st=A.current.getBoundingClientRect(),wt=Ie.clientX-st.left,Dt=Ie.clientY-st.top;$e(Jt=>{if(!Jt)return null;const Dn=wt-Y,Gn=Dt-he;return{x:Dn>0?Y:wt,y:Gn>0?he:Dt,w:Math.abs(Dn),h:Math.abs(Gn)}});const Mt=[],ot=ne.current,Wt=ae.current,me=Math.min(Y,wt),Ue=Math.min(he,Dt),mt=Math.abs(wt-Y),yt=Math.abs(Dt-he),dt=me+mt,Ot=Ue+yt;ot.forEach(Jt=>{const Dn=Jt.startTime*Wt+96,Gn=Jt.endTime*Wt+96;let Rn=0,ci=0;const Ti=Jt.layer||0;Jt.type==="audio"?Ti===0?(Rn=cn.AUDIO_L1_TOP,ci=cn.AUDIO_L1_TOP+cn.AUDIO_L1_HEIGHT):(Rn=cn.AUDIO_L2_TOP,ci=cn.AUDIO_L2_TOP+cn.AUDIO_L2_HEIGHT):Ti===0?(Rn=cn.VISUAL_L1_TOP,ci=cn.VISUAL_L1_TOP+cn.VISUAL_L1_HEIGHT):(Rn=cn.VISUAL_L2_TOP,ci=cn.VISUAL_L2_TOP+cn.VISUAL_L2_HEIGHT);const Wn=meDn,Je=UeRn;Wn&&Je&&Mt.push(Jt.id)}),$(Mt)}},ke=Ie=>{de||($([]),z(Ie.clientX)),$e(null),window.removeEventListener("mousemove",Le),window.removeEventListener("mouseup",ke)};window.addEventListener("mousemove",Le),window.addEventListener("mouseup",ke)},z=w=>{if(!A.current)return;const M=A.current.getBoundingClientRect(),R=w-M.left-96;let V=Math.max(0,Math.min(R/E,Ce));V=Z(V),u(V)},Ve=w=>{z(w.clientX)},at=()=>{Ne(!1),window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",at)},U=w=>{const M=w.target;if(!(M.tagName==="INPUT"||M.tagName==="TEXTAREA"||M.isContentEditable)){if((w.ctrlKey||w.metaKey)&&w.key==="z"&&!w.shiftKey){w.preventDefault(),L();return}if((w.ctrlKey||w.metaKey)&&(w.key==="y"||w.key==="z"&&w.shiftKey)){w.preventDefault(),le();return}if((w.ctrlKey||w.metaKey)&&w.key==="c"){w.preventDefault(),C();return}if((w.ctrlKey||w.metaKey)&&w.key==="x"){w.preventDefault(),B();return}if((w.ctrlKey||w.metaKey)&&w.key==="v"){w.preventDefault(),Pe();return}if(w.key.toLowerCase()==="x"&&!w.ctrlKey&&!w.metaKey||(w.ctrlKey||w.metaKey)&&w.key==="k"){w.preventDefault(),w.stopPropagation(),P();return}if((w.key==="Delete"||w.key==="Backspace")&&I.length>0&&(w.preventDefault(),t(R=>R.filter(V=>!I.includes(V.id))),$([])),I.length>0&&(w.key==="ArrowLeft"||w.key==="ArrowRight")){w.preventDefault(),w.stopPropagation();const R=w.key==="ArrowRight"?.01:-.01,V=e.find(Y=>Y.id===I[0]);if(V){const Y=Math.max(0,V.startTime+R);u(Y)}t(Y=>Y.map(de=>{if(I.includes(de.id)){const Le=de.endTime-de.startTime;let ke=de.startTime+R;return ke=Math.max(0,ke),{...de,startTime:ke,endTime:ke+Le}}return de}).sort((de,Le)=>de.startTime-Le.startTime))}}},Z=(w,M=[])=>{const R=sg/E,V=[0,l,o],Y=uc(E),he=Math.round(w/Y)*Y;V.push(he),e.forEach(ke=>{M.includes(ke.id)||(V.push(ke.startTime),V.push(ke.endTime))}),s.forEach(ke=>{V.push(ke.time)});let de=w,Le=R;for(const ke of V){const Ie=Math.abs(ke-w);Ie{ye(M=>{if(!M)return null;const V=(w.clientX-M.startX)/E;let Y=[];return t(he=>{if(M.type==="move"){const de=Object.keys(M.initialMap),Le=Object.values(M.initialMap),ke=Math.min(...Le.map(yt=>yt.start)),Ie=Math.max(...Le.map(yt=>yt.end)),_=M.initialMap[M.id],st=[{type:"drag-start",initVal:_.start,ref:"start"},{type:"drag-end",initVal:_.end,ref:"end"},{type:"group-start",initVal:ke,ref:"start"},{type:"group-end",initVal:Ie,ref:"end"}],wt=sg/E,Dt=[0,l,o],Mt=uc(E);e.forEach(yt=>{de.includes(yt.id)||(Dt.push(yt.startTime),Dt.push(yt.endTime))}),s.forEach(yt=>{Dt.push(yt.time)});let ot=V,Wt=wt,me=!1,Ue=-1;st.forEach(yt=>{const dt=yt.initVal+V;for(const Dn of Dt){const Gn=Math.abs(Dn-dt);Gn{const dt=M.initialMap[yt.id];if(dt){const Ot=dt.end-dt.start;let Jt=yt.layer||0;const Dn=A.current?.getBoundingClientRect();if(Dn){const Gn=w.clientY-Dn.top,Rn=(ci,Ti,Wn)=>ci>=Ti-10&&ci<=Ti+Wn+10;yt.type==="audio"?Rn(Gn,cn.AUDIO_L1_TOP,cn.AUDIO_L1_HEIGHT)?Jt=0:Rn(Gn,cn.AUDIO_L2_TOP,cn.AUDIO_L2_HEIGHT)&&(Jt=1):Rn(Gn,cn.VISUAL_L1_TOP,cn.VISUAL_L1_HEIGHT)?Jt=0:Rn(Gn,cn.VISUAL_L2_TOP,cn.VISUAL_L2_HEIGHT)&&(Jt=1)}return{...yt,startTime:dt.start+mt,endTime:dt.start+mt+Ot,layer:Jt}}return yt})}else if(M.type==="resize-start"){let de=M.initialStart+V;const Le=Z(de,[M.id]);Math.abs(Le-de)>1e-4&&(Y=[Le]),de=Le;const ke=.5,Ie=M.initialEnd;return de=Math.max(0,Math.min(de,Ie-ke)),de===0&&(Y=[0]),he.map(_=>_.id!==M.id?_:{..._,startTime:de})}else{let de=M.initialEnd+V;const Le=Z(de,[M.id]);Math.abs(Le-de)>1e-4&&(Y=[Le]),de=Le;const ke=.5,Ie=M.initialStart;return de=Math.max(Ie+ke,de),he.map(_=>_.id!==M.id?_:{..._,endTime:de})}}),ie(Y),M})},Ae=w=>{be&&be.type==="move"&&Math.abs(w.clientX-be.startX)<5&&!w.ctrlKey&&!w.metaKey&&!w.shiftKey&&$([be.id]),ye(null),ie([]),window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",Ae),t(M=>[...M].sort((R,V)=>R.startTime-V.startTime))},ve=()=>j(w=>Math.min(200,w+10)),Me=()=>j(w=>Math.max(10,w-10)),ue=(w,M)=>{v(R=>{const V=R.layerVisibility?.[w]||{},Y={...V,[M]:V[M]===!1};return{...R,layerVisibility:{...R.layerVisibility,[w]:Y,...w==="visual"?{audio:R.layerVisibility?.audio||{}}:{visual:R.layerVisibility?.visual||{}}}}})},Ge=(w,M)=>g.layerVisibility?.[w]?.[M]!==!1;return d.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:w=>w.currentTarget.focus(),onKeyDown:U,children:[d.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:[d.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[d.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap",children:[d.jsx(ev,{size:16,className:"text-purple-400"}),"Timeline"]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.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:[d.jsx(nv,{size:14})," Import Media",d.jsx("input",{type:"file",name:"import-media",id:"import-media",className:"hidden",accept:"image/*,video/*,audio/*",multiple:!0,onChange:Be})]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:Me,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white",title:"Zoom Out",children:d.jsx(uT,{size:14})}),d.jsxs("div",{className:"text-[10px] text-zinc-500 font-mono min-w-[50px] text-center",children:[E,"px/s"]}),d.jsx("button",{onClick:ve,className:"p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white",title:"Zoom In",children:d.jsx(rT,{size:14})})]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:L,disabled:!Ye,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:d.jsx(ZS,{size:14})}),d.jsx("button",{onClick:le,disabled:!ut,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:d.jsx(TS,{size:14})})]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:C,disabled:I.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:d.jsx(O1,{size:14})}),d.jsx("button",{onClick:B,disabled:I.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:d.jsx(kS,{size:14})}),d.jsx("button",{onClick:Pe,disabled:fe.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:d.jsx(P1,{size:14})})]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsx("div",{className:"flex items-center gap-1",children:d.jsx("button",{onClick:P,disabled:I.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:d.jsx(jS,{size:14})})}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>{e.length>0&&I.length===e.length?$([]):$(e.map(w=>w.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"}),I.length===1&&d.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800 rounded px-1 border border-zinc-700",children:[d.jsx("span",{className:"text-[10px] text-zinc-500 px-1",children:"Dur:"}),d.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 w=e.find(M=>M.id===I[0]);return w?uo(w.endTime-w.startTime):"00:00"})(),onBlur:w=>{const R=w.target.value.split(":");if(R.length===2){const Y=parseInt(R[0])||0,he=parseInt(R[1])||0,de=Y*60+he;de>0&&t(Le=>Le.map(ke=>ke.id===I[0]?{...ke,endTime:ke.startTime+de}:ke))}const V=e.find(Y=>Y.id===I[0]);V&&(w.target.value=uo(V.endTime-V.startTime))},onKeyDown:w=>{w.key==="Enter"&&w.currentTarget.blur()}},I[0])]}),I.length===1&&(()=>{const w=e.find(M=>M.id===I[0]);return w&&(w.type==="video"||w.type==="audio")?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 rounded px-2 border border-zinc-700 h-[22px]",children:[d.jsx("span",{className:"text-[10px] text-zinc-500",children:"Vol:"}),d.jsxs("div",{className:"flex items-center gap-1 w-20",children:[d.jsx("button",{onClick:()=>{t(M=>M.map(R=>R.id===w.id?{...R,isMuted:!R.isMuted}:R))},className:"p-0.5 hover:bg-zinc-700 rounded cursor-pointer text-zinc-400 hover:text-white",title:w.isMuted!==!1?"Unmute":"Mute",children:w.isMuted!==!1?d.jsx(Ia,{size:10}):d.jsx(gl,{size:10})}),d.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:w.volume!==void 0?w.volume:1,onChange:M=>{const R=parseFloat(M.target.value);t(V=>V.map(Y=>Y.id===w.id?{...Y,volume:R,isMuted:R===0}:Y))}})]}),d.jsxs("span",{className:"text-[9px] text-zinc-400 w-6 text-right",children:[Math.round((w.volume||1)*100),"%"]})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("span",{className:"text-[10px] text-zinc-500",children:"Spd:"}),d.jsx(xT,{value:w.playbackRate||1,onChange:M=>{t(R=>R.map(V=>V.id===w.id?{...V,playbackRate:M}:V))}})]})]}):null})()]})]}),d.jsxs("div",{className:"flex gap-2 shrink-0",children:[d.jsx("button",{onClick:xe,className:"p-1 hover:bg-red-900/50 text-zinc-500 hover:text-red-200 rounded transition-colors",title:"Clear All Slides",children:d.jsx(Ba,{size:14})}),d.jsx("div",{className:"w-px h-4 bg-zinc-700 mx-1 self-center"}),d.jsx("button",{onClick:p,className:"p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors",title:"Close Timeline",children:d.jsx(zi,{size:14})})]})]}),d.jsx("div",{ref:S,onWheel:w=>{S.current&&w.shiftKey&&(w.preventDefault(),S.current.scrollLeft+=w.deltaY)},className:"flex-1 overflow-x-auto overflow-y-auto relative bg-zinc-950 scroll-smooth custom-scrollbar cursor-default",children:d.jsxs("div",{ref:A,className:"relative",style:{width:`${Ke+96}px`,minWidth:"100%",height:"max(100%, 280px)"},onMouseDown:et,children:[Xe&&d.jsx("div",{className:"absolute border border-purple-500 bg-purple-500/20 z-50 pointer-events-none",style:{left:Xe.x,top:Xe.y,width:Xe.w,height:Xe.h}}),Ee.map((w,M)=>d.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:w*E}},`snap-${M}`)),d.jsxs("div",{className:"absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none z-0",children:[(()=>{const w=uc(E);return Array.from({length:Math.ceil(Ke/(E*w))}).map((M,R)=>d.jsx("div",{className:"absolute top-0 bottom-0 border-l border-white/5",style:{left:R*w*E}},R))})(),l>0&&d.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*E},children:d.jsx("span",{className:"text-[9px] text-red-900/50 bg-black/50 px-1 whitespace-nowrap",children:"End"})})]}),d.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:Oe,children:[d.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"}),d.jsx("div",{className:"relative flex-1",children:(()=>{const w=uc(E);return Array.from({length:Math.ceil(Ke/(E*w))}).map((M,R)=>{const V=R*w;return V>Ce?null:d.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:V*E,width:w*E},children:gT(V,w)},R)})})()})]}),d.jsx("div",{className:"absolute top-6 bottom-0 w-px bg-red-500 z-50 pointer-events-none",style:{left:"96px",transform:`translateX(${o*E}px)`,willChange:"transform"},children:d.jsx("div",{className:"absolute -top-1.5 -left-1.5 w-3 h-3 bg-red-500 rotate-45 transform origin-center shadow-sm"})}),d.jsxs("div",{className:"absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20",style:{top:cn.VISUAL_L1_TOP,height:cn.VISUAL_L1_HEIGHT},children:[d.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:[d.jsx("span",{children:"Visual 1"}),d.jsx("button",{onClick:w=>{w.stopPropagation(),ue("visual",0)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Ge("visual",0)?d.jsx(Os,{size:12}):d.jsx(Bs,{size:12,className:"text-zinc-600"})})]}),d.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ge("visual",0)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(w=>w.type!=="audio"&&(w.layer===0||w.layer===void 0)).map(w=>d.jsxs("div",{style:{left:w.startTime*E,width:Math.max(10,(w.endTime-w.startTime)*E)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move + ${be?.id===w.id||I.includes(w.id)?"border-purple-400 z-30 shadow-xl opacity-90":"border-zinc-600 hover:border-zinc-400 z-10 hover:z-20"} + ${I.includes(w.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} + `,onMouseDown:M=>pe(M,w.id,"move"),children:[w.type==="video"?d.jsx("video",{src:w.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",muted:!0}):d.jsx("img",{src:w.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",draggable:!1,alt:w.name}),d.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-end",children:d.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:w.name})}),(be?.id===w.id||I.includes(w.id))&&d.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:uo(w.startTime)}),w.type==="video"&&w.mediaDuration&&w.endTime-w.startTime>w.mediaDuration+.1&&d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id&&V.mediaDuration?{...V,endTime:V.startTime+V.mediaDuration}:V))},className:"absolute top-1 left-1 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:d.jsx(mf,{size:10})}),w.type==="video"&&d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id?{...V,isMuted:!V.isMuted}:V))},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:w.isMuted!==!1?"Unmute":"Mute",children:w.isMuted!==!1?d.jsx(Ia,{size:10}):d.jsx(gl,{size:10})}),d.jsx("button",{onClick:M=>{M.stopPropagation(),Re(w.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:d.jsx(zi,{size:10})}),d.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:M=>pe(M,w.id,"resize-start"),children:d.jsx(cc,{size:10,className:"text-white/70 rotate-90"})}),d.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:M=>pe(M,w.id,"resize-end"),children:d.jsx(cc,{size:10,className:"text-white/70 rotate-90"})})]},w.id))})]}),d.jsxs("div",{className:"absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20",style:{top:cn.VISUAL_L2_TOP,height:cn.VISUAL_L2_HEIGHT},children:[d.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:[d.jsx("span",{children:"Visual 2"}),d.jsx("button",{onClick:w=>{w.stopPropagation(),ue("visual",1)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Ge("visual",1)?d.jsx(Os,{size:12}):d.jsx(Bs,{size:12,className:"text-zinc-600"})})]}),d.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ge("visual",1)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(w=>w.type!=="audio"&&w.layer===1).map(w=>d.jsxs("div",{style:{left:w.startTime*E,width:Math.max(10,(w.endTime-w.startTime)*E)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move + ${be?.id===w.id||I.includes(w.id)?"border-purple-400 z-30 shadow-xl opacity-90":"border-zinc-600 hover:border-zinc-400 z-10 hover:z-20"} + ${I.includes(w.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} + `,onMouseDown:M=>pe(M,w.id,"move"),children:[w.type==="video"?d.jsx("video",{src:w.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",muted:!0}):d.jsx("img",{src:w.url,className:"w-full h-full object-cover opacity-60 pointer-events-none",draggable:!1,alt:w.name}),d.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-end",children:d.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:w.name})}),(be?.id===w.id||I.includes(w.id))&&d.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:uo(w.startTime)}),w.type==="video"&&w.mediaDuration&&w.endTime-w.startTime>w.mediaDuration+.1&&d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id&&V.mediaDuration?{...V,endTime:V.startTime+V.mediaDuration}:V))},className:"absolute top-1 left-1 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:d.jsx(mf,{size:10})}),w.type==="video"&&d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id?{...V,isMuted:!V.isMuted}:V))},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:w.isMuted!==!1?d.jsx(Ia,{size:10}):d.jsx(gl,{size:10})}),d.jsx("button",{onClick:M=>{M.stopPropagation(),Re(w.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:d.jsx(zi,{size:10})}),d.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:M=>pe(M,w.id,"resize-start"),children:d.jsx(cc,{size:10,className:"text-white/70 rotate-90"})}),d.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:M=>pe(M,w.id,"resize-end"),children:d.jsx(cc,{size:10,className:"text-white/70 rotate-90"})})]},w.id))})]}),d.jsxs("div",{className:"absolute left-0 right-0 overflow-hidden",style:{top:cn.LYRICS_TOP,height:cn.LYRICS_HEIGHT},children:[d.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:d.jsx("span",{children:"Lyrics"})}),d.jsx("div",{className:"absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none",children:s.map((w,M)=>d.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:w.time*E},title:`${uo(w.time)} - ${w.text}`,onClick:R=>{R.stopPropagation(),u(w.time)},children:[d.jsx("span",{className:"mr-1 text-zinc-600 font-mono text-[9px]",children:uo(w.time)}),w.text]},M))})]}),d.jsxs("div",{className:"absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40",style:{top:cn.AUDIO_L1_TOP,height:cn.AUDIO_L1_HEIGHT},children:[d.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:[d.jsx("span",{children:"Audio 1"}),d.jsx("button",{onClick:w=>{w.stopPropagation(),ue("audio",0)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Ge("audio",0)?d.jsx(Os,{size:12}):d.jsx(Bs,{size:12,className:"text-zinc-600"})})]}),d.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ge("audio",0)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(w=>w.type==="audio"&&(w.layer===0||w.layer===void 0)).map(w=>d.jsxs("div",{style:{left:w.startTime*E,width:Math.max(10,(w.endTime-w.startTime)*E)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move + ${be?.id===w.id||I.includes(w.id)?"border-emerald-400 z-30 shadow-xl opacity-90":"border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20"} + ${I.includes(w.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} + `,onMouseDown:M=>pe(M,w.id,"move"),children:[d.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-30",children:d.jsx(gl,{size:16,className:"text-emerald-200"})}),d.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-center",children:d.jsx("span",{className:"text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1",children:w.name})}),(be?.id===w.id||I.includes(w.id))&&d.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:uo(w.startTime)}),d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id?{...V,isMuted:!V.isMuted}:V))},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:w.isMuted===!0?"Unmute":"Mute",children:w.isMuted===!0?d.jsx(Ia,{size:10}):d.jsx(gl,{size:10})}),d.jsx("button",{onClick:M=>{M.stopPropagation(),Re(w.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:d.jsx(zi,{size:10})}),d.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:M=>pe(M,w.id,"resize-start")}),d.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:M=>pe(M,w.id,"resize-end")})]},w.id))})]}),d.jsxs("div",{className:"absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40",style:{top:cn.AUDIO_L2_TOP,height:cn.AUDIO_L2_HEIGHT},children:[d.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:[d.jsx("span",{children:"Audio 2"}),d.jsx("button",{onClick:w=>{w.stopPropagation(),ue("audio",1)},className:"p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors",children:Ge("audio",1)?d.jsx(Os,{size:12}):d.jsx(Bs,{size:12,className:"text-zinc-600"})})]}),d.jsx("div",{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ge("audio",1)?"":"opacity-30 grayscale pointer-events-none"}`,children:e.filter(w=>w.type==="audio"&&w.layer===1).map(w=>d.jsxs("div",{style:{left:w.startTime*E,width:Math.max(10,(w.endTime-w.startTime)*E)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move + ${be?.id===w.id||I.includes(w.id)?"border-emerald-400 z-30 shadow-xl opacity-90":"border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20"} + ${I.includes(w.id)?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} + `,onMouseDown:M=>pe(M,w.id,"move"),children:[d.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-30",children:d.jsx(gl,{size:16,className:"text-emerald-200"})}),d.jsx("div",{className:"absolute inset-0 p-1 pointer-events-none flex flex-col justify-center",children:d.jsx("span",{className:"text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1",children:w.name})}),(be?.id===w.id||I.includes(w.id))&&d.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:uo(w.startTime)}),d.jsx("button",{onClick:M=>{M.stopPropagation(),t(R=>R.map(V=>V.id===w.id?{...V,isMuted:!V.isMuted}:V))},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:w.isMuted===!0?"Unmute":"Mute",children:w.isMuted===!0?d.jsx(Ia,{size:10}):d.jsx(gl,{size:10})}),d.jsx("button",{onClick:M=>{M.stopPropagation(),Re(w.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:d.jsx(zi,{size:10})}),d.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:M=>pe(M,w.id,"resize-start")}),d.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:M=>pe(M,w.id,"resize-end")})]},w.id))})]})]})})]})};var ST={};let TT,wT;function CT(){return{geminiUrl:TT,vertexUrl:wT}}function ET(e,t,o,l){var s,u;if(!e?.baseUrl){const p=CT();return t?(s=p.vertexUrl)!==null&&s!==void 0?s:o:(u=p.geminiUrl)!==null&&u!==void 0?u:l}return e.baseUrl}class Bo{}function Qe(e,t){const o=/\{([^}]+)\}/g;return e.replace(o,(l,s)=>{if(Object.prototype.hasOwnProperty.call(t,s)){const u=t[s];return u!=null?String(u):""}else throw new Error(`Key '${s}' not found in valueMap.`)})}function f(e,t,o){for(let u=0;u({}));else throw new Error(`Value must be a list given an array path ${p}`);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 _T(e,t){for(const[o,l]of Object.entries(t)){const s=o.split("."),u=l.split("."),p=new Set;let g=-1;for(let v=0;vg)for(let v=g;v=t.length||typeof e!="object"||e===null)return;const u=t[l];if(u.endsWith("[]")){const p=u.slice(0,-2),g=e;if(p in g&&Array.isArray(g[p]))for(const v of g[p])vf(v,t,o,l+1,s)}else if(u==="*"){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const p=e,g=Object.keys(p).filter(m=>!m.startsWith("_")&&!s.has(m)),v={};for(const m of g)v[m]=p[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);f(p,b,x)}for(const m of g)delete p[m]}}else{const p=e;u in p&&vf(p[u],t,o,l+1,s)}}function Yf(e){if(typeof e!="string")throw new Error("fromImageBytes must be a string");return e}function NT(e){const t={},o=c(e,["operationName"]);o!=null&&f(t,["operationName"],o);const l=c(e,["resourceName"]);return l!=null&&f(t,["_url","resourceName"],l),t}function AT(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response","generateVideoResponse"]);return p!=null&&f(t,["response"],kT(p)),t}function MT(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response"]);return p!=null&&f(t,["response"],RT(p)),t}function kT(e){const t={},o=c(e,["generatedSamples"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(p=>IT(p))),f(t,["generatedVideos"],u)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&f(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&f(t,["raiMediaFilteredReasons"],s),t}function RT(e){const t={},o=c(e,["videos"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(p=>zT(p))),f(t,["generatedVideos"],u)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&f(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&f(t,["raiMediaFilteredReasons"],s),t}function IT(e){const t={},o=c(e,["video"]);return o!=null&&f(t,["video"],BT(o)),t}function zT(e){const t={},o=c(e,["_self"]);return o!=null&&f(t,["video"],OT(o)),t}function DT(e){const t={},o=c(e,["operationName"]);return o!=null&&f(t,["_url","operationName"],o),t}function LT(e){const t={},o=c(e,["operationName"]);return o!=null&&f(t,["_url","operationName"],o),t}function UT(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response"]);return p!=null&&f(t,["response"],FT(p)),t}function FT(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&f(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&f(t,["documentName"],s),t}function ov(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response"]);return p!=null&&f(t,["response"],PT(p)),t}function PT(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&f(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&f(t,["documentName"],s),t}function BT(e){const t={},o=c(e,["uri"]);o!=null&&f(t,["uri"],o);const l=c(e,["encodedVideo"]);l!=null&&f(t,["videoBytes"],Yf(l));const s=c(e,["encoding"]);return s!=null&&f(t,["mimeType"],s),t}function OT(e){const t={},o=c(e,["gcsUri"]);o!=null&&f(t,["uri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&f(t,["videoBytes"],Yf(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}var rg;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(rg||(rg={}));var cg;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(cg||(cg={}));var ug;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(ug||(ug={}));var Cn;(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"})(Cn||(Cn={}));var dg;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(dg||(dg={}));var fg;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(fg||(fg={}));var pg;(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"})(pg||(pg={}));var hg;(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"})(hg||(hg={}));var mg;(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"})(mg||(mg={}));var gg;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH",e.MINIMAL="MINIMAL"})(gg||(gg={}));var yg;(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"})(yg||(yg={}));var vg;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})(vg||(vg={}));var xg;(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"})(xg||(xg={}));var bg;(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"})(bg||(bg={}));var Sg;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(Sg||(Sg={}));var Tg;(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"})(Tg||(Tg={}));var wg;(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"})(wg||(wg={}));var Cg;(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"})(Cg||(Cg={}));var Eg;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Eg||(Eg={}));var Rc;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(Rc||(Rc={}));var _g;(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"})(_g||(_g={}));var Ng;(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"})(Ng||(Ng={}));var Ag;(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"})(Ag||(Ag={}));var xf;(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"})(xf||(xf={}));var Mg;(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"})(Mg||(Mg={}));var kg;(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"})(kg||(kg={}));var Rg;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(Rg||(Rg={}));var Ig;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(Ig||(Ig={}));var zg;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(zg||(zg={}));var Dg;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Dg||(Dg={}));var Lg;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})(Lg||(Lg={}));var Ug;(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"})(Ug||(Ug={}));var Fg;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(Fg||(Fg={}));var Pg;(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"})(Pg||(Pg={}));var Bg;(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"})(Bg||(Bg={}));var Og;(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"})(Og||(Og={}));var Hg;(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"})(Hg||(Hg={}));var jg;(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"})(jg||(jg={}));var Gg;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(Gg||(Gg={}));var Vg;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(Vg||(Vg={}));var $g;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})($g||($g={}));var qg;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(qg||(qg={}));var Yg;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING"})(Yg||(Yg={}));var Jg;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(Jg||(Jg={}));var Kg;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(Kg||(Kg={}));var Xg;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED"})(Xg||(Xg={}));var Wg;(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"})(Wg||(Wg={}));var Qg;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(Qg||(Qg={}));var Zg;(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"})(Zg||(Zg={}));var ey;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(ey||(ey={}));var ty;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(ty||(ty={}));var ny;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(ny||(ny={}));var iy;(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"})(iy||(iy={}));var oy;(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"})(oy||(oy={}));var ly;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(ly||(ly={}));var Ua;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(Ua||(Ua={}));class bf{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 Ls{get text(){var t,o,l,s,u,p,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=(p=(u=this.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&v!==void 0?v:[]){for(const[A,E]of Object.entries(S))A!=="text"&&A!=="thought"&&A!=="thoughtSignature"&&(E!==null||E!==void 0)&&b.push(A);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,u,p,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=(p=(u=this.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&v!==void 0?v:[]){for(const[S,A]of Object.entries(b))S!=="inlineData"&&(A!==null||A!==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,u,p,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=(p=(u=this.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.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,u,p,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=(p=(u=this.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.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,u,p,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=(p=(u=this.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.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 ay{}class sy{}class HT{}class jT{}class GT{}class VT{}class ry{}class cy{}class uy{}class $T{}class Ic{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new Ic;let s;const u=t;return o?s=MT(u):s=AT(u),Object.assign(l,s),l}}class dy{}class fy{}class py{}class hy{}class qT{}class YT{}class JT{}class Jf{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new Jf,u=UT(t);return Object.assign(l,u),l}}class KT{}class XT{}class WT{}class my{}class QT{get text(){var t,o,l;let s="",u=!1;const p=[];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&&p.push(v);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;u=!0,s+=g.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?s:void 0}get data(){var t,o,l;let s="";const u=[];for(const p 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(p))g!=="inlineData"&&v!==null&&u.push(g);p.inlineData&&typeof p.inlineData.data=="string"&&(s+=atob(p.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} 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 ZT{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Kf{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const l=new Kf,u=ov(t);return Object.assign(l,u),l}}function nn(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 lv(e,t){const o=nn(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 av(e){return Array.isArray(e)?e.map(t=>zc(t)):[zc(e)]}function zc(e){if(typeof e=="object"&&e!==null)return e;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function sv(e){const t=zc(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function rv(e){const t=zc(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function gy(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 cv(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("PartListUnion is required");return Array.isArray(e)?e.map(t=>gy(t)):[gy(e)]}function Sf(e){return e!=null&&typeof e=="object"&&"parts"in e&&Array.isArray(e.parts)}function yy(e){return e!=null&&typeof e=="object"&&"functionCall"in e}function vy(e){return e!=null&&typeof e=="object"&&"functionResponse"in e}function ri(e){if(e==null)throw new Error("ContentUnion is required");return Sf(e)?e:{role:"user",parts:cv(e)}}function Xf(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(o=>{const l=ri(o);return l.parts&&l.parts.length>0&&l.parts[0].text!==void 0?[l.parts[0].text]:[]});if(e.isVertexAI()){const o=ri(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=>ri(o)):[ri(t)]}function $i(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("contents are required");if(!Array.isArray(e)){if(yy(e)||vy(e))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[ri(e)]}const t=[],o=[],l=Sf(e[0]);for(const s of e){const u=Sf(s);if(u!=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(u)t.push(s);else{if(yy(s)||vy(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:cv(o)}),t}function ew(e,t){e.includes("null")&&(t.nullable=!0);const o=e.filter(l=>l!=="null");if(o.length===1)t.type=Object.values(Cn).includes(o[0].toUpperCase())?o[0].toUpperCase():Cn.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const l of o)t.anyOf.push({type:Object.values(Cn).includes(l.toUpperCase())?l.toUpperCase():Cn.TYPE_UNSPECIFIED})}}function Oa(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 u=e.anyOf;u!=null&&u.length==2&&(u[0].type==="null"?(t.nullable=!0,e=u[1]):u[1].type==="null"&&(t.nullable=!0,e=u[0])),e.type instanceof Array&&ew(e.type,t);for(const[p,g]of Object.entries(e))if(g!=null)if(p=="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(Cn).includes(g.toUpperCase())?g.toUpperCase():Cn.TYPE_UNSPECIFIED}else if(o.includes(p))t[p]=Oa(g);else if(l.includes(p)){const v=[];for(const m of g){if(m.type=="null"){t.nullable=!0;continue}v.push(Oa(m))}t[p]=v}else if(s.includes(p)){const v={};for(const[m,x]of Object.entries(g))v[m]=Oa(x);t[p]=v}else{if(p==="additionalProperties")continue;t[p]=g}return t}function Wf(e){return Oa(e)}function Qf(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 Zf(e){if("multiSpeakerVoiceConfig"in e)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function $a(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=Oa(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Oa(t.response));return e}function qa(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 tw(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 Oo(e,t){if(typeof t!="string")throw new Error("name must be a string");return tw(e,t,"cachedContents")}function uv(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 bl(e){return Yf(e)}function nw(e){return e!=null&&typeof e=="object"&&"name"in e}function iw(e){return e!=null&&typeof e=="object"&&"video"in e}function ow(e){return e!=null&&typeof e=="object"&&"uri"in e}function dv(e){var t;let o;if(nw(e)&&(o=e.name),!(ow(e)&&(o=e.uri,o===void 0))&&!(iw(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 fv(e,t){let o;return e.isVertexAI()?o=t?"publishers/google/models":"models":o=t?"models":"tunedModels",o}function pv(e){for(const t of["models","tunedModels","publisherModels"])if(lw(e,t))return e[t];return[]}function lw(e,t){return e!==null&&typeof e=="object"&&t in e}function aw(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 sw(e,t={}){const o=[],l=new Set;for(const s of e){const u=s.name;if(l.has(u))throw new Error(`Duplicate function name ${u} found in MCP tools. Please ensure function names are unique.`);l.add(u);const p=aw(s,t);p.functionDeclarations&&o.push(...p.functionDeclarations)}return{functionDeclarations:o}}function hv(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 rw(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 mv(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 u=!1;for(const p of s){if(typeof p!="object"||p===null)continue;const v=p.response;if(typeof v!="object"||v===null)continue;if(v.embedding!==void 0){u=!0;break}}return u&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function Ya(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 gv(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 cw(e){const t={},o=c(e,["responsesFile"]);o!=null&&f(t,["fileName"],o);const l=c(e,["inlinedResponses","inlinedResponses"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>Gw(p))),f(t,["inlinedResponses"],u)}const s=c(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["inlinedEmbedContentResponses"],u)}return t}function uw(e){const t={},o=c(e,["predictionsFormat"]);o!=null&&f(t,["format"],o);const l=c(e,["gcsDestination","outputUriPrefix"]);l!=null&&f(t,["gcsUri"],l);const s=c(e,["bigqueryDestination","outputUri"]);return s!=null&&f(t,["bigqueryUri"],s),t}function dw(e){const t={},o=c(e,["format"]);o!=null&&f(t,["predictionsFormat"],o);const l=c(e,["gcsUri"]);l!=null&&f(t,["gcsDestination","outputUriPrefix"],l);const s=c(e,["bigqueryUri"]);if(s!=null&&f(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 bc(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata","displayName"]);l!=null&&f(t,["displayName"],l);const s=c(e,["metadata","state"]);s!=null&&f(t,["state"],gv(s));const u=c(e,["metadata","createTime"]);u!=null&&f(t,["createTime"],u);const p=c(e,["metadata","endTime"]);p!=null&&f(t,["endTime"],p);const g=c(e,["metadata","updateTime"]);g!=null&&f(t,["updateTime"],g);const v=c(e,["metadata","model"]);v!=null&&f(t,["model"],v);const m=c(e,["metadata","output"]);return m!=null&&f(t,["dest"],cw(mv(m))),t}function Tf(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["displayName"]);l!=null&&f(t,["displayName"],l);const s=c(e,["state"]);s!=null&&f(t,["state"],gv(s));const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["createTime"]);p!=null&&f(t,["createTime"],p);const g=c(e,["startTime"]);g!=null&&f(t,["startTime"],g);const v=c(e,["endTime"]);v!=null&&f(t,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&f(t,["updateTime"],m);const x=c(e,["model"]);x!=null&&f(t,["model"],x);const b=c(e,["inputConfig"]);b!=null&&f(t,["src"],fw(b));const S=c(e,["outputConfig"]);S!=null&&f(t,["dest"],uw(mv(S)));const A=c(e,["completionStats"]);return A!=null&&f(t,["completionStats"],A),t}function fw(e){const t={},o=c(e,["instancesFormat"]);o!=null&&f(t,["format"],o);const l=c(e,["gcsSource","uris"]);l!=null&&f(t,["gcsUri"],l);const s=c(e,["bigquerySource","inputUri"]);return s!=null&&f(t,["bigqueryUri"],s),t}function pw(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&&f(o,["fileName"],l);const s=c(t,["inlinedRequests"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>jw(e,p))),f(o,["requests","requests"],u)}return o}function hw(e){const t={},o=c(e,["format"]);o!=null&&f(t,["instancesFormat"],o);const l=c(e,["gcsUri"]);l!=null&&f(t,["gcsSource","uris"],l);const s=c(e,["bigqueryUri"]);if(s!=null&&f(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 mw(e){const t={},o=c(e,["data"]);if(o!=null&&f(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&&f(t,["mimeType"],l),t}function gw(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function yw(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function vw(e){const t={},o=c(e,["content"]);o!=null&&f(t,["content"],o);const l=c(e,["citationMetadata"]);l!=null&&f(t,["citationMetadata"],xw(l));const s=c(e,["tokenCount"]);s!=null&&f(t,["tokenCount"],s);const u=c(e,["finishReason"]);u!=null&&f(t,["finishReason"],u);const p=c(e,["avgLogprobs"]);p!=null&&f(t,["avgLogprobs"],p);const g=c(e,["groundingMetadata"]);g!=null&&f(t,["groundingMetadata"],g);const v=c(e,["index"]);v!=null&&f(t,["index"],v);const m=c(e,["logprobsResult"]);m!=null&&f(t,["logprobsResult"],m);const x=c(e,["safetyRatings"]);if(x!=null){let S=x;Array.isArray(S)&&(S=S.map(A=>A)),f(t,["safetyRatings"],S)}const b=c(e,["urlContextMetadata"]);return b!=null&&f(t,["urlContextMetadata"],b),t}function xw(e){const t={},o=c(e,["citationSources"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),f(t,["citations"],l)}return t}function yv(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>Xw(u))),f(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&f(t,["role"],l),t}function bw(e,t){const o={},l=c(e,["displayName"]);if(t!==void 0&&l!=null&&f(t,["batch","displayName"],l),c(e,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function Sw(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&f(t,["displayName"],l);const s=c(e,["dest"]);return t!==void 0&&s!=null&&f(t,["outputConfig"],dw(rw(s))),o}function xy(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["src"]);s!=null&&f(o,["batch","inputConfig"],pw(e,hv(e,s)));const u=c(t,["config"]);return u!=null&&bw(u,o),o}function Tw(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["model"],nn(e,l));const s=c(t,["src"]);s!=null&&f(o,["inputConfig"],hw(hv(e,s)));const u=c(t,["config"]);return u!=null&&Sw(u,o),o}function ww(e,t){const o={},l=c(e,["displayName"]);return t!==void 0&&l!=null&&f(t,["batch","displayName"],l),o}function Cw(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["src"]);s!=null&&f(o,["batch","inputConfig"],Rw(e,s));const u=c(t,["config"]);return u!=null&&ww(u,o),o}function Ew(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function _w(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function Nw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["name"]);l!=null&&f(t,["name"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);return u!=null&&f(t,["error"],u),t}function Aw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["name"]);l!=null&&f(t,["name"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);return u!=null&&f(t,["error"],u),t}function Mw(e,t){const o={},l=c(t,["contents"]);if(l!=null){let u=Xf(e,l);Array.isArray(u)&&(u=u.map(p=>p)),f(o,["requests[]","request","content"],u)}const s=c(t,["config"]);return s!=null&&(f(o,["_self"],kw(s,o)),_T(o,{"requests[].*":"requests[].request.*"})),o}function kw(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&f(t,["requests[]","taskType"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&f(t,["requests[]","title"],s);const u=c(e,["outputDimensionality"]);if(t!==void 0&&u!=null&&f(t,["requests[]","outputDimensionality"],u),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 Rw(e,t){const o={},l=c(t,["fileName"]);l!=null&&f(o,["file_name"],l);const s=c(t,["inlinedRequests"]);return s!=null&&f(o,["requests"],Mw(e,s)),o}function Iw(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&&f(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function zw(e){const t={},o=c(e,["id"]);o!=null&&f(t,["id"],o);const l=c(e,["args"]);l!=null&&f(t,["args"],l);const s=c(e,["name"]);if(s!=null&&f(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 Dw(e){const t={},o=c(e,["mode"]);o!=null&&f(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&f(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function Lw(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&f(o,["systemInstruction"],yv(ri(s)));const u=c(t,["temperature"]);u!=null&&f(l,["temperature"],u);const p=c(t,["topP"]);p!=null&&f(l,["topP"],p);const g=c(t,["topK"]);g!=null&&f(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&f(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&f(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&f(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&f(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&f(l,["logprobs"],S);const A=c(t,["presencePenalty"]);A!=null&&f(l,["presencePenalty"],A);const E=c(t,["frequencyPenalty"]);E!=null&&f(l,["frequencyPenalty"],E);const j=c(t,["seed"]);j!=null&&f(l,["seed"],j);const I=c(t,["responseMimeType"]);I!=null&&f(l,["responseMimeType"],I);const $=c(t,["responseSchema"]);$!=null&&f(l,["responseSchema"],Wf($));const oe=c(t,["responseJsonSchema"]);if(oe!=null&&f(l,["responseJsonSchema"],oe),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 se=c(t,["safetySettings"]);if(o!==void 0&&se!=null){let gt=se;Array.isArray(gt)&&(gt=gt.map(xt=>Ww(xt))),f(o,["safetySettings"],gt)}const fe=c(t,["tools"]);if(o!==void 0&&fe!=null){let gt=qa(fe);Array.isArray(gt)&&(gt=gt.map(xt=>Zw($a(xt)))),f(o,["tools"],gt)}const De=c(t,["toolConfig"]);if(o!==void 0&&De!=null&&f(o,["toolConfig"],Qw(De)),c(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const be=c(t,["cachedContent"]);o!==void 0&&be!=null&&f(o,["cachedContent"],Oo(e,be));const ye=c(t,["responseModalities"]);ye!=null&&f(l,["responseModalities"],ye);const tt=c(t,["mediaResolution"]);tt!=null&&f(l,["mediaResolution"],tt);const Ne=c(t,["speechConfig"]);if(Ne!=null&&f(l,["speechConfig"],Qf(Ne)),c(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Xe=c(t,["thinkingConfig"]);Xe!=null&&f(l,["thinkingConfig"],Xe);const $e=c(t,["imageConfig"]);$e!=null&&f(l,["imageConfig"],Hw($e));const Ze=c(t,["enableEnhancedCivicAnswers"]);return Ze!=null&&f(l,["enableEnhancedCivicAnswers"],Ze),l}function Uw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(m=>vw(m))),f(t,["candidates"],v)}const s=c(e,["modelVersion"]);s!=null&&f(t,["modelVersion"],s);const u=c(e,["promptFeedback"]);u!=null&&f(t,["promptFeedback"],u);const p=c(e,["responseId"]);p!=null&&f(t,["responseId"],p);const g=c(e,["usageMetadata"]);return g!=null&&f(t,["usageMetadata"],g),t}function Fw(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function Pw(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Ya(e,l)),o}function Bw(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&&f(t,["enableWidget"],o),t}function Ow(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&&f(t,["timeRangeFilter"],o),t}function Hw(e){const t={},o=c(e,["aspectRatio"]);o!=null&&f(t,["aspectRatio"],o);const l=c(e,["imageSize"]);if(l!=null&&f(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 jw(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["request","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let g=$i(s);Array.isArray(g)&&(g=g.map(v=>yv(v))),f(o,["request","contents"],g)}const u=c(t,["metadata"]);u!=null&&f(o,["metadata"],u);const p=c(t,["config"]);return p!=null&&f(o,["request","generationConfig"],Lw(e,p,c(o,["request"],{}))),o}function Gw(e){const t={},o=c(e,["response"]);o!=null&&f(t,["response"],Uw(o));const l=c(e,["error"]);return l!=null&&f(t,["error"],l),t}function Vw(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);if(t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),c(e,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function $w(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);t!==void 0&&s!=null&&f(t,["_query","pageToken"],s);const u=c(e,["filter"]);return t!==void 0&&u!=null&&f(t,["_query","filter"],u),o}function qw(e){const t={},o=c(e,["config"]);return o!=null&&Vw(o,t),t}function Yw(e){const t={},o=c(e,["config"]);return o!=null&&$w(o,t),t}function Jw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["operations"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>bc(p))),f(t,["batchJobs"],u)}return t}function Kw(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["batchPredictionJobs"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>Tf(p))),f(t,["batchJobs"],u)}return t}function Xw(e){const t={},o=c(e,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&f(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&f(t,["executableCode"],s);const u=c(e,["fileData"]);u!=null&&f(t,["fileData"],Iw(u));const p=c(e,["functionCall"]);p!=null&&f(t,["functionCall"],zw(p));const g=c(e,["functionResponse"]);g!=null&&f(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&f(t,["inlineData"],mw(v));const m=c(e,["text"]);m!=null&&f(t,["text"],m);const x=c(e,["thought"]);x!=null&&f(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&f(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&f(t,["videoMetadata"],S),t}function Ww(e){const t={},o=c(e,["category"]);if(o!=null&&f(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&&f(t,["threshold"],l),t}function Qw(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&f(t,["functionCallingConfig"],Dw(o));const l=c(e,["retrievalConfig"]);return l!=null&&f(t,["retrievalConfig"],l),t}function Zw(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),f(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&&f(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&f(t,["computerUse"],s);const u=c(e,["fileSearch"]);u!=null&&f(t,["fileSearch"],u);const p=c(e,["codeExecution"]);if(p!=null&&f(t,["codeExecution"],p),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&f(t,["googleMaps"],Bw(g));const v=c(e,["googleSearch"]);v!=null&&f(t,["googleSearch"],Ow(v));const m=c(e,["urlContext"]);return m!=null&&f(t,["urlContext"],m),t}var Po;(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"})(Po||(Po={}));class Kl{constructor(t,o,l,s){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(t,l,s)}init(t,o,l){var s,u;this.nameInternal=t,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o?.sdkHttpResponse,this.idxInternal=0;let p={config:{}};!l||Object.keys(l).length===0?p={config:{}}:typeof l=="object"?p=Object.assign({},l):p=l,p.config&&(p.config.pageToken=o.nextPageToken),this.paramsInternal=p,this.pageInternalSize=(u=(s=p.config)===null||s===void 0?void 0:s.pageSize)!==null&&u!==void 0?u: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 eC extends Bo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Kl(Po.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=xy(this.apiClient,t),l=o._url,s=Qe("{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 A=b.request;A.systemInstruction=S,b.request=A}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 u=this.getGcsUri(t),p=this.getBigqueryUri(t);if(u)u.endsWith(".jsonl")?l.dest=`${u.slice(0,-6)}/dest`:l.dest=`${u}_dest_${s}`;else if(p)l.dest=`${p}_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,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=Tw(this.apiClient,t);return g=Qe("batchPredictionJobs",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>Tf(x))}else{const m=xy(this.apiClient,t);return g=Qe("{model}:batchGenerateContent",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>bc(x))}}async createEmbeddingsInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=Cw(this.apiClient,t);return u=Qe("{model}:asyncBatchEmbedContent",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=>bc(v))}}async get(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=Pw(this.apiClient,t);return g=Qe("batchPredictionJobs/{name}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>Tf(x))}else{const m=Fw(this.apiClient,t);return g=Qe("batches/{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>bc(x))}}async cancel(t){var o,l,s,u;let p="",g={};if(this.apiClient.isVertexAI()){const v=yw(this.apiClient,t);p=Qe("batchPredictionJobs/{name}:cancel",v._url),g=v._query,delete v._url,delete v._query,await this.apiClient.request({path:p,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=gw(this.apiClient,t);p=Qe("batches/{name}:cancel",v._url),g=v._query,delete v._url,delete v._query,await this.apiClient.request({path:p,queryParams:g,body:JSON.stringify(v),httpMethod:"POST",httpOptions:(s=t.config)===null||s===void 0?void 0:s.httpOptions,abortSignal:(u=t.config)===null||u===void 0?void 0:u.abortSignal})}}async listInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=Yw(t);return g=Qe("batchPredictionJobs",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=Kw(x),S=new my;return Object.assign(S,b),S})}else{const m=qw(t);return g=Qe("batches",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=Jw(x),S=new my;return Object.assign(S,b),S})}}async delete(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=_w(this.apiClient,t);return g=Qe("batchPredictionJobs/{name}",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>Aw(x))}else{const m=Ew(this.apiClient,t);return g=Qe("batches/{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>Nw(x))}}}function tC(e){const t={},o=c(e,["data"]);if(o!=null&&f(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&&f(t,["mimeType"],l),t}function by(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>CC(u))),f(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&f(t,["role"],l),t}function nC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&f(t,["ttl"],l);const s=c(e,["expireTime"]);t!==void 0&&s!=null&&f(t,["expireTime"],s);const u=c(e,["displayName"]);t!==void 0&&u!=null&&f(t,["displayName"],u);const p=c(e,["contents"]);if(t!==void 0&&p!=null){let x=$i(p);Array.isArray(x)&&(x=x.map(b=>by(b))),f(t,["contents"],x)}const g=c(e,["systemInstruction"]);t!==void 0&&g!=null&&f(t,["systemInstruction"],by(ri(g)));const v=c(e,["tools"]);if(t!==void 0&&v!=null){let x=v;Array.isArray(x)&&(x=x.map(b=>_C(b))),f(t,["tools"],x)}const m=c(e,["toolConfig"]);if(t!==void 0&&m!=null&&f(t,["toolConfig"],EC(m)),c(e,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function iC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&f(t,["ttl"],l);const s=c(e,["expireTime"]);t!==void 0&&s!=null&&f(t,["expireTime"],s);const u=c(e,["displayName"]);t!==void 0&&u!=null&&f(t,["displayName"],u);const p=c(e,["contents"]);if(t!==void 0&&p!=null){let b=$i(p);Array.isArray(b)&&(b=b.map(S=>S)),f(t,["contents"],b)}const g=c(e,["systemInstruction"]);t!==void 0&&g!=null&&f(t,["systemInstruction"],ri(g));const v=c(e,["tools"]);if(t!==void 0&&v!=null){let b=v;Array.isArray(b)&&(b=b.map(S=>NC(S))),f(t,["tools"],b)}const m=c(e,["toolConfig"]);t!==void 0&&m!=null&&f(t,["toolConfig"],m);const x=c(e,["kmsKeyName"]);return t!==void 0&&x!=null&&f(t,["encryption_spec","kmsKeyName"],x),o}function oC(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["model"],lv(e,l));const s=c(t,["config"]);return s!=null&&nC(s,o),o}function lC(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["model"],lv(e,l));const s=c(t,["config"]);return s!=null&&iC(s,o),o}function aC(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Oo(e,l)),o}function sC(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Oo(e,l)),o}function rC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function cC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function uC(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&&f(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function dC(e){const t={},o=c(e,["id"]);o!=null&&f(t,["id"],o);const l=c(e,["args"]);l!=null&&f(t,["args"],l);const s=c(e,["name"]);if(s!=null&&f(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 fC(e){const t={},o=c(e,["mode"]);o!=null&&f(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&f(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function pC(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&&f(t,["description"],o);const l=c(e,["name"]);l!=null&&f(t,["name"],l);const s=c(e,["parameters"]);s!=null&&f(t,["parameters"],s);const u=c(e,["parametersJsonSchema"]);u!=null&&f(t,["parametersJsonSchema"],u);const p=c(e,["response"]);p!=null&&f(t,["response"],p);const g=c(e,["responseJsonSchema"]);return g!=null&&f(t,["responseJsonSchema"],g),t}function hC(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Oo(e,l)),o}function mC(e,t){const o={},l=c(t,["name"]);return l!=null&&f(o,["_url","name"],Oo(e,l)),o}function gC(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&&f(t,["enableWidget"],o),t}function yC(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&&f(t,["timeRangeFilter"],o),t}function vC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),o}function xC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),o}function bC(e){const t={},o=c(e,["config"]);return o!=null&&vC(o,t),t}function SC(e){const t={},o=c(e,["config"]);return o!=null&&xC(o,t),t}function TC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["cachedContents"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["cachedContents"],u)}return t}function wC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["cachedContents"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["cachedContents"],u)}return t}function CC(e){const t={},o=c(e,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&f(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&f(t,["executableCode"],s);const u=c(e,["fileData"]);u!=null&&f(t,["fileData"],uC(u));const p=c(e,["functionCall"]);p!=null&&f(t,["functionCall"],dC(p));const g=c(e,["functionResponse"]);g!=null&&f(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&f(t,["inlineData"],tC(v));const m=c(e,["text"]);m!=null&&f(t,["text"],m);const x=c(e,["thought"]);x!=null&&f(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&f(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&f(t,["videoMetadata"],S),t}function EC(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&f(t,["functionCallingConfig"],fC(o));const l=c(e,["retrievalConfig"]);return l!=null&&f(t,["retrievalConfig"],l),t}function _C(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),f(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&&f(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&f(t,["computerUse"],s);const u=c(e,["fileSearch"]);u!=null&&f(t,["fileSearch"],u);const p=c(e,["codeExecution"]);if(p!=null&&f(t,["codeExecution"],p),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&f(t,["googleMaps"],gC(g));const v=c(e,["googleSearch"]);v!=null&&f(t,["googleSearch"],yC(v));const m=c(e,["urlContext"]);return m!=null&&f(t,["urlContext"],m),t}function NC(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>pC(S))),f(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&f(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&f(t,["googleSearchRetrieval"],s);const u=c(e,["computerUse"]);if(u!=null&&f(t,["computerUse"],u),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const p=c(e,["codeExecution"]);p!=null&&f(t,["codeExecution"],p);const g=c(e,["enterpriseWebSearch"]);g!=null&&f(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&f(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&f(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&f(t,["urlContext"],x),t}function AC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&f(t,["ttl"],l);const s=c(e,["expireTime"]);return t!==void 0&&s!=null&&f(t,["expireTime"],s),o}function MC(e,t){const o={},l=c(e,["ttl"]);t!==void 0&&l!=null&&f(t,["ttl"],l);const s=c(e,["expireTime"]);return t!==void 0&&s!=null&&f(t,["expireTime"],s),o}function kC(e,t){const o={},l=c(t,["name"]);l!=null&&f(o,["_url","name"],Oo(e,l));const s=c(t,["config"]);return s!=null&&AC(s,o),o}function RC(e,t){const o={},l=c(t,["name"]);l!=null&&f(o,["_url","name"],Oo(e,l));const s=c(t,["config"]);return s!=null&&MC(s,o),o}class IC extends Bo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Kl(Po.PAGED_ITEM_CACHED_CONTENTS,l=>this.listInternal(l),await this.listInternal(o),o)}async create(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=lC(this.apiClient,t);return g=Qe("cachedContents",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>x)}else{const m=oC(this.apiClient,t);return g=Qe("cachedContents",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>x)}}async get(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=mC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>x)}else{const m=hC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>x)}}async delete(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=sC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=cC(x),S=new py;return Object.assign(S,b),S})}else{const m=aC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=rC(x),S=new py;return Object.assign(S,b),S})}}async update(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=RC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>x)}else{const m=kC(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>x)}}async listInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=SC(t);return g=Qe("cachedContents",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=wC(x),S=new hy;return Object.assign(S,b),S})}else{const m=bC(t);return g=Qe("cachedContents",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=TC(x),S=new hy;return Object.assign(S,b),S})}}}function Dc(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 kt(e){return this instanceof kt?(this.v=e,this):new kt(e)}function Qi(e,t,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var l=o.apply(e,t||[]),s,u=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",p),s[Symbol.asyncIterator]=function(){return this},s;function p(A){return function(E){return Promise.resolve(E).then(A,b)}}function g(A,E){l[A]&&(s[A]=function(j){return new Promise(function(I,$){u.push([A,j,I,$])>1||v(A,j)})},E&&(s[A]=E(s[A])))}function v(A,E){try{m(l[A](E))}catch(j){S(u[0][3],j)}}function m(A){A.value instanceof kt?Promise.resolve(A.value.v).then(x,b):S(u[0][2],A)}function x(A){v("next",A)}function b(A){v("throw",A)}function S(A,E){A(E),u.shift(),u.length&&v(u[0][0],u[0][1])}}function Zi(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 Sy=="function"?Sy(e):e[Symbol.iterator](),o={},l("next"),l("throw"),l("return"),o[Symbol.asyncIterator]=function(){return this},o);function l(u){o[u]=e[u]&&function(p){return new Promise(function(g,v){p=e[u](p),s(g,v,p.done,p.value)})}}function s(u,p,g,v){Promise.resolve(v).then(function(m){u({value:m,done:g})},p)}}function zC(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:vv(o)}function vv(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 DC(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 Ty(e){if(e===void 0||e.length===0)return[];const t=[],o=e.length;let l=0;for(;l{var u,p,g;const v=await s,m=(p=(u=v.candidates)===null||u===void 0?void 0:u[0])===null||p===void 0?void 0:p.content,x=v.automaticFunctionCallingHistory,b=this.getHistory(!0).length;let S=[];x!=null&&(S=(g=x.slice(b))!==null&&g!==void 0?g:[]);const A=m?[m]:[];this.recordHistory(l,A,S)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),s}async sendMessageStream(t){var o;await this.sendPromise;const l=ri(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 u=await s;return this.processStreamResponse(u,l)}getHistory(t=!1){const o=t?Ty(this.history):this.history;return structuredClone(o)}processStreamResponse(t,o){return Qi(this,arguments,function*(){var s,u,p,g,v,m;const x=[];try{for(var b=!0,S=Zi(t),A;A=yield kt(S.next()),s=A.done,!s;b=!0){g=A.value,b=!1;const E=g;if(zC(E)){const j=(m=(v=E.candidates)===null||v===void 0?void 0:v[0])===null||m===void 0?void 0:m.content;j!==void 0&&x.push(j)}yield yield kt(E)}}catch(E){u={error:E}}finally{try{!b&&!s&&(p=S.return)&&(yield kt(p.call(S)))}finally{if(u)throw u.error}}this.recordHistory(o,x)})}recordHistory(t,o,l){let s=[];o.length>0&&o.every(u=>u.role!==void 0)?s=o:s.push({role:"model",parts:[]}),l&&l.length>0?this.history.push(...Ty(l)):this.history.push(t),this.history.push(...s)}}class Vc extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,Vc.prototype)}}function FC(e){const t={},o=c(e,["file"]);return o!=null&&f(t,["file"],o),t}function PC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function BC(e){const t={},o=c(e,["name"]);return o!=null&&f(t,["_url","file"],dv(o)),t}function OC(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function HC(e){const t={},o=c(e,["name"]);return o!=null&&f(t,["_url","file"],dv(o)),t}function jC(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),o}function GC(e){const t={},o=c(e,["config"]);return o!=null&&jC(o,t),t}function VC(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["files"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["files"],u)}return t}class $C extends Bo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Kl(Po.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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=GC(t);return u=Qe("files",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=VC(v),x=new KT;return Object.assign(x,m),x})}}async createInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=FC(t);return u=Qe("upload/v1beta/files",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=PC(v),x=new XT;return Object.assign(x,m),x})}}async get(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=HC(t);return u=Qe("files/{file}",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=BC(t);return u=Qe("files/{file}",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=OC(v),x=new WT;return Object.assign(x,m),x})}}}function Sc(e){const t={},o=c(e,["data"]);if(o!=null&&f(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&&f(t,["mimeType"],l),t}function qC(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>rE(u))),f(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&f(t,["role"],l),t}function YC(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&&f(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function JC(e){const t={},o=c(e,["id"]);o!=null&&f(t,["id"],o);const l=c(e,["args"]);l!=null&&f(t,["args"],l);const s=c(e,["name"]);if(s!=null&&f(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 KC(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&&f(t,["description"],o);const l=c(e,["name"]);l!=null&&f(t,["name"],l);const s=c(e,["parameters"]);s!=null&&f(t,["parameters"],s);const u=c(e,["parametersJsonSchema"]);u!=null&&f(t,["parametersJsonSchema"],u);const p=c(e,["response"]);p!=null&&f(t,["response"],p);const g=c(e,["responseJsonSchema"]);return g!=null&&f(t,["responseJsonSchema"],g),t}function XC(e){const t={},o=c(e,["modelSelectionConfig"]);o!=null&&f(t,["modelConfig"],o);const l=c(e,["responseJsonSchema"]);l!=null&&f(t,["responseJsonSchema"],l);const s=c(e,["audioTimestamp"]);s!=null&&f(t,["audioTimestamp"],s);const u=c(e,["candidateCount"]);u!=null&&f(t,["candidateCount"],u);const p=c(e,["enableAffectiveDialog"]);p!=null&&f(t,["enableAffectiveDialog"],p);const g=c(e,["frequencyPenalty"]);g!=null&&f(t,["frequencyPenalty"],g);const v=c(e,["logprobs"]);v!=null&&f(t,["logprobs"],v);const m=c(e,["maxOutputTokens"]);m!=null&&f(t,["maxOutputTokens"],m);const x=c(e,["mediaResolution"]);x!=null&&f(t,["mediaResolution"],x);const b=c(e,["presencePenalty"]);b!=null&&f(t,["presencePenalty"],b);const S=c(e,["responseLogprobs"]);S!=null&&f(t,["responseLogprobs"],S);const A=c(e,["responseMimeType"]);A!=null&&f(t,["responseMimeType"],A);const E=c(e,["responseModalities"]);E!=null&&f(t,["responseModalities"],E);const j=c(e,["responseSchema"]);j!=null&&f(t,["responseSchema"],j);const I=c(e,["routingConfig"]);I!=null&&f(t,["routingConfig"],I);const $=c(e,["seed"]);$!=null&&f(t,["seed"],$);const oe=c(e,["speechConfig"]);oe!=null&&f(t,["speechConfig"],oe);const se=c(e,["stopSequences"]);se!=null&&f(t,["stopSequences"],se);const fe=c(e,["temperature"]);fe!=null&&f(t,["temperature"],fe);const De=c(e,["thinkingConfig"]);De!=null&&f(t,["thinkingConfig"],De);const be=c(e,["topK"]);be!=null&&f(t,["topK"],be);const ye=c(e,["topP"]);if(ye!=null&&f(t,["topP"],ye),c(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function WC(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&&f(t,["enableWidget"],o),t}function QC(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&&f(t,["timeRangeFilter"],o),t}function ZC(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&f(t,["setup","generationConfig"],l);const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig","responseModalities"],s);const u=c(e,["temperature"]);t!==void 0&&u!=null&&f(t,["setup","generationConfig","temperature"],u);const p=c(e,["topP"]);t!==void 0&&p!=null&&f(t,["setup","generationConfig","topP"],p);const g=c(e,["topK"]);t!==void 0&&g!=null&&f(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&f(t,["setup","generationConfig","speechConfig"],Zf(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&f(t,["setup","generationConfig","thinkingConfig"],S);const A=c(e,["enableAffectiveDialog"]);t!==void 0&&A!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],A);const E=c(e,["systemInstruction"]);t!==void 0&&E!=null&&f(t,["setup","systemInstruction"],qC(ri(E)));const j=c(e,["tools"]);if(t!==void 0&&j!=null){let be=qa(j);Array.isArray(be)&&(be=be.map(ye=>uE($a(ye)))),f(t,["setup","tools"],be)}const I=c(e,["sessionResumption"]);t!==void 0&&I!=null&&f(t,["setup","sessionResumption"],cE(I));const $=c(e,["inputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","inputAudioTranscription"],$);const oe=c(e,["outputAudioTranscription"]);t!==void 0&&oe!=null&&f(t,["setup","outputAudioTranscription"],oe);const se=c(e,["realtimeInputConfig"]);t!==void 0&&se!=null&&f(t,["setup","realtimeInputConfig"],se);const fe=c(e,["contextWindowCompression"]);t!==void 0&&fe!=null&&f(t,["setup","contextWindowCompression"],fe);const De=c(e,["proactivity"]);if(t!==void 0&&De!=null&&f(t,["setup","proactivity"],De),c(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function eE(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&f(t,["setup","generationConfig"],XC(l));const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig","responseModalities"],s);const u=c(e,["temperature"]);t!==void 0&&u!=null&&f(t,["setup","generationConfig","temperature"],u);const p=c(e,["topP"]);t!==void 0&&p!=null&&f(t,["setup","generationConfig","topP"],p);const g=c(e,["topK"]);t!==void 0&&g!=null&&f(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&f(t,["setup","generationConfig","speechConfig"],Zf(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&f(t,["setup","generationConfig","thinkingConfig"],S);const A=c(e,["enableAffectiveDialog"]);t!==void 0&&A!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],A);const E=c(e,["systemInstruction"]);t!==void 0&&E!=null&&f(t,["setup","systemInstruction"],ri(E));const j=c(e,["tools"]);if(t!==void 0&&j!=null){let ye=qa(j);Array.isArray(ye)&&(ye=ye.map(tt=>dE($a(tt)))),f(t,["setup","tools"],ye)}const I=c(e,["sessionResumption"]);t!==void 0&&I!=null&&f(t,["setup","sessionResumption"],I);const $=c(e,["inputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","inputAudioTranscription"],$);const oe=c(e,["outputAudioTranscription"]);t!==void 0&&oe!=null&&f(t,["setup","outputAudioTranscription"],oe);const se=c(e,["realtimeInputConfig"]);t!==void 0&&se!=null&&f(t,["setup","realtimeInputConfig"],se);const fe=c(e,["contextWindowCompression"]);t!==void 0&&fe!=null&&f(t,["setup","contextWindowCompression"],fe);const De=c(e,["proactivity"]);t!==void 0&&De!=null&&f(t,["setup","proactivity"],De);const be=c(e,["explicitVadSignal"]);return t!==void 0&&be!=null&&f(t,["setup","explicitVadSignal"],be),o}function tE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["setup","model"],nn(e,l));const s=c(t,["config"]);return s!=null&&f(o,["config"],ZC(s,o)),o}function nE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["setup","model"],nn(e,l));const s=c(t,["config"]);return s!=null&&f(o,["config"],eE(s,o)),o}function iE(e){const t={},o=c(e,["musicGenerationConfig"]);return o!=null&&f(t,["musicGenerationConfig"],o),t}function oE(e){const t={},o=c(e,["weightedPrompts"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),f(t,["weightedPrompts"],l)}return t}function lE(e){const t={},o=c(e,["media"]);if(o!=null){let m=av(o);Array.isArray(m)&&(m=m.map(x=>Sc(x))),f(t,["mediaChunks"],m)}const l=c(e,["audio"]);l!=null&&f(t,["audio"],Sc(rv(l)));const s=c(e,["audioStreamEnd"]);s!=null&&f(t,["audioStreamEnd"],s);const u=c(e,["video"]);u!=null&&f(t,["video"],Sc(sv(u)));const p=c(e,["text"]);p!=null&&f(t,["text"],p);const g=c(e,["activityStart"]);g!=null&&f(t,["activityStart"],g);const v=c(e,["activityEnd"]);return v!=null&&f(t,["activityEnd"],v),t}function aE(e){const t={},o=c(e,["media"]);if(o!=null){let m=av(o);Array.isArray(m)&&(m=m.map(x=>x)),f(t,["mediaChunks"],m)}const l=c(e,["audio"]);l!=null&&f(t,["audio"],rv(l));const s=c(e,["audioStreamEnd"]);s!=null&&f(t,["audioStreamEnd"],s);const u=c(e,["video"]);u!=null&&f(t,["video"],sv(u));const p=c(e,["text"]);p!=null&&f(t,["text"],p);const g=c(e,["activityStart"]);g!=null&&f(t,["activityStart"],g);const v=c(e,["activityEnd"]);return v!=null&&f(t,["activityEnd"],v),t}function sE(e){const t={},o=c(e,["setupComplete"]);o!=null&&f(t,["setupComplete"],o);const l=c(e,["serverContent"]);l!=null&&f(t,["serverContent"],l);const s=c(e,["toolCall"]);s!=null&&f(t,["toolCall"],s);const u=c(e,["toolCallCancellation"]);u!=null&&f(t,["toolCallCancellation"],u);const p=c(e,["usageMetadata"]);p!=null&&f(t,["usageMetadata"],fE(p));const g=c(e,["goAway"]);g!=null&&f(t,["goAway"],g);const v=c(e,["sessionResumptionUpdate"]);v!=null&&f(t,["sessionResumptionUpdate"],v);const m=c(e,["voiceActivityDetectionSignal"]);return m!=null&&f(t,["voiceActivityDetectionSignal"],m),t}function rE(e){const t={},o=c(e,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&f(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&f(t,["executableCode"],s);const u=c(e,["fileData"]);u!=null&&f(t,["fileData"],YC(u));const p=c(e,["functionCall"]);p!=null&&f(t,["functionCall"],JC(p));const g=c(e,["functionResponse"]);g!=null&&f(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&f(t,["inlineData"],Sc(v));const m=c(e,["text"]);m!=null&&f(t,["text"],m);const x=c(e,["thought"]);x!=null&&f(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&f(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&f(t,["videoMetadata"],S),t}function cE(e){const t={},o=c(e,["handle"]);if(o!=null&&f(t,["handle"],o),c(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function uE(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),f(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&&f(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&f(t,["computerUse"],s);const u=c(e,["fileSearch"]);u!=null&&f(t,["fileSearch"],u);const p=c(e,["codeExecution"]);if(p!=null&&f(t,["codeExecution"],p),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&f(t,["googleMaps"],WC(g));const v=c(e,["googleSearch"]);v!=null&&f(t,["googleSearch"],QC(v));const m=c(e,["urlContext"]);return m!=null&&f(t,["urlContext"],m),t}function dE(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>KC(S))),f(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&f(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&f(t,["googleSearchRetrieval"],s);const u=c(e,["computerUse"]);if(u!=null&&f(t,["computerUse"],u),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const p=c(e,["codeExecution"]);p!=null&&f(t,["codeExecution"],p);const g=c(e,["enterpriseWebSearch"]);g!=null&&f(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&f(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&f(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&f(t,["urlContext"],x),t}function fE(e){const t={},o=c(e,["promptTokenCount"]);o!=null&&f(t,["promptTokenCount"],o);const l=c(e,["cachedContentTokenCount"]);l!=null&&f(t,["cachedContentTokenCount"],l);const s=c(e,["candidatesTokenCount"]);s!=null&&f(t,["responseTokenCount"],s);const u=c(e,["toolUsePromptTokenCount"]);u!=null&&f(t,["toolUsePromptTokenCount"],u);const p=c(e,["thoughtsTokenCount"]);p!=null&&f(t,["thoughtsTokenCount"],p);const g=c(e,["totalTokenCount"]);g!=null&&f(t,["totalTokenCount"],g);const v=c(e,["promptTokensDetails"]);if(v!=null){let A=v;Array.isArray(A)&&(A=A.map(E=>E)),f(t,["promptTokensDetails"],A)}const m=c(e,["cacheTokensDetails"]);if(m!=null){let A=m;Array.isArray(A)&&(A=A.map(E=>E)),f(t,["cacheTokensDetails"],A)}const x=c(e,["candidatesTokensDetails"]);if(x!=null){let A=x;Array.isArray(A)&&(A=A.map(E=>E)),f(t,["responseTokensDetails"],A)}const b=c(e,["toolUsePromptTokensDetails"]);if(b!=null){let A=b;Array.isArray(A)&&(A=A.map(E=>E)),f(t,["toolUsePromptTokensDetails"],A)}const S=c(e,["trafficType"]);return S!=null&&f(t,["trafficType"],S),t}function pE(e){const t={},o=c(e,["data"]);if(o!=null&&f(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&&f(t,["mimeType"],l),t}function hE(e){const t={},o=c(e,["content"]);o!=null&&f(t,["content"],o);const l=c(e,["citationMetadata"]);l!=null&&f(t,["citationMetadata"],mE(l));const s=c(e,["tokenCount"]);s!=null&&f(t,["tokenCount"],s);const u=c(e,["finishReason"]);u!=null&&f(t,["finishReason"],u);const p=c(e,["avgLogprobs"]);p!=null&&f(t,["avgLogprobs"],p);const g=c(e,["groundingMetadata"]);g!=null&&f(t,["groundingMetadata"],g);const v=c(e,["index"]);v!=null&&f(t,["index"],v);const m=c(e,["logprobsResult"]);m!=null&&f(t,["logprobsResult"],m);const x=c(e,["safetyRatings"]);if(x!=null){let S=x;Array.isArray(S)&&(S=S.map(A=>A)),f(t,["safetyRatings"],S)}const b=c(e,["urlContextMetadata"]);return b!=null&&f(t,["urlContextMetadata"],b),t}function mE(e){const t={},o=c(e,["citationSources"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>s)),f(t,["citations"],l)}return t}function gE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let u=$i(s);Array.isArray(u)&&(u=u.map(p=>p)),f(o,["contents"],u)}return o}function yE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["tokensInfo"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(u=>u)),f(t,["tokensInfo"],s)}return t}function vE(e){const t={},o=c(e,["values"]);o!=null&&f(t,["values"],o);const l=c(e,["statistics"]);return l!=null&&f(t,["statistics"],xE(l)),t}function xE(e){const t={},o=c(e,["truncated"]);o!=null&&f(t,["truncated"],o);const l=c(e,["token_count"]);return l!=null&&f(t,["tokenCount"],l),t}function $c(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>A_(u))),f(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&f(t,["role"],l),t}function bE(e){const t={},o=c(e,["controlType"]);o!=null&&f(t,["controlType"],o);const l=c(e,["enableControlImageComputation"]);return l!=null&&f(t,["computeControl"],l),t}function SE(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 TE(e,t){const o={},l=c(e,["systemInstruction"]);t!==void 0&&l!=null&&f(t,["systemInstruction"],ri(l));const s=c(e,["tools"]);if(t!==void 0&&s!=null){let p=s;Array.isArray(p)&&(p=p.map(g=>Tv(g))),f(t,["tools"],p)}const u=c(e,["generationConfig"]);return t!==void 0&&u!=null&&f(t,["generationConfig"],p_(u)),o}function wE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let p=$i(s);Array.isArray(p)&&(p=p.map(g=>$c(g))),f(o,["contents"],p)}const u=c(t,["config"]);return u!=null&&SE(u),o}function CE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let p=$i(s);Array.isArray(p)&&(p=p.map(g=>g)),f(o,["contents"],p)}const u=c(t,["config"]);return u!=null&&TE(u,o),o}function EE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["totalTokens"]);l!=null&&f(t,["totalTokens"],l);const s=c(e,["cachedContentTokenCount"]);return s!=null&&f(t,["cachedContentTokenCount"],s),t}function _E(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["totalTokens"]);return l!=null&&f(t,["totalTokens"],l),t}function NE(e,t){const o={},l=c(t,["model"]);return l!=null&&f(o,["_url","name"],nn(e,l)),o}function AE(e,t){const o={},l=c(t,["model"]);return l!=null&&f(o,["_url","name"],nn(e,l)),o}function ME(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function kE(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}function RE(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&f(t,["parameters","storageUri"],l);const s=c(e,["negativePrompt"]);t!==void 0&&s!=null&&f(t,["parameters","negativePrompt"],s);const u=c(e,["numberOfImages"]);t!==void 0&&u!=null&&f(t,["parameters","sampleCount"],u);const p=c(e,["aspectRatio"]);t!==void 0&&p!=null&&f(t,["parameters","aspectRatio"],p);const g=c(e,["guidanceScale"]);t!==void 0&&g!=null&&f(t,["parameters","guidanceScale"],g);const v=c(e,["seed"]);t!==void 0&&v!=null&&f(t,["parameters","seed"],v);const m=c(e,["safetyFilterLevel"]);t!==void 0&&m!=null&&f(t,["parameters","safetySetting"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&f(t,["parameters","personGeneration"],x);const b=c(e,["includeSafetyAttributes"]);t!==void 0&&b!=null&&f(t,["parameters","includeSafetyAttributes"],b);const S=c(e,["includeRaiReason"]);t!==void 0&&S!=null&&f(t,["parameters","includeRaiReason"],S);const A=c(e,["language"]);t!==void 0&&A!=null&&f(t,["parameters","language"],A);const E=c(e,["outputMimeType"]);t!==void 0&&E!=null&&f(t,["parameters","outputOptions","mimeType"],E);const j=c(e,["outputCompressionQuality"]);t!==void 0&&j!=null&&f(t,["parameters","outputOptions","compressionQuality"],j);const I=c(e,["addWatermark"]);t!==void 0&&I!=null&&f(t,["parameters","addWatermark"],I);const $=c(e,["labels"]);t!==void 0&&$!=null&&f(t,["labels"],$);const oe=c(e,["editMode"]);t!==void 0&&oe!=null&&f(t,["parameters","editMode"],oe);const se=c(e,["baseSteps"]);return t!==void 0&&se!=null&&f(t,["parameters","editConfig","baseSteps"],se),o}function IE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["prompt"]);s!=null&&f(o,["instances[0]","prompt"],s);const u=c(t,["referenceImages"]);if(u!=null){let g=u;Array.isArray(g)&&(g=g.map(v=>D_(v))),f(o,["instances[0]","referenceImages"],g)}const p=c(t,["config"]);return p!=null&&RE(p,o),o}function zE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(u=>qc(u))),f(t,["generatedImages"],s)}return t}function DE(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&f(t,["requests[]","taskType"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&f(t,["requests[]","title"],s);const u=c(e,["outputDimensionality"]);if(t!==void 0&&u!=null&&f(t,["requests[]","outputDimensionality"],u),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 LE(e,t){const o={},l=c(e,["taskType"]);t!==void 0&&l!=null&&f(t,["instances[]","task_type"],l);const s=c(e,["title"]);t!==void 0&&s!=null&&f(t,["instances[]","title"],s);const u=c(e,["outputDimensionality"]);t!==void 0&&u!=null&&f(t,["parameters","outputDimensionality"],u);const p=c(e,["mimeType"]);t!==void 0&&p!=null&&f(t,["instances[]","mimeType"],p);const g=c(e,["autoTruncate"]);return t!==void 0&&g!=null&&f(t,["parameters","autoTruncate"],g),o}function UE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let g=Xf(e,s);Array.isArray(g)&&(g=g.map(v=>v)),f(o,["requests[]","content"],g)}const u=c(t,["config"]);u!=null&&DE(u,o);const p=c(t,["model"]);return p!==void 0&&f(o,["requests[]","model"],nn(e,p)),o}function FE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let p=Xf(e,s);Array.isArray(p)&&(p=p.map(g=>g)),f(o,["instances[]","content"],p)}const u=c(t,["config"]);return u!=null&&LE(u,o),o}function PE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["embeddings"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["embeddings"],u)}const s=c(e,["metadata"]);return s!=null&&f(t,["metadata"],s),t}function BE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["predictions[]","embeddings"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>vE(p))),f(t,["embeddings"],u)}const s=c(e,["metadata"]);return s!=null&&f(t,["metadata"],s),t}function OE(e){const t={},o=c(e,["endpoint"]);o!=null&&f(t,["name"],o);const l=c(e,["deployedModelId"]);return l!=null&&f(t,["deployedModelId"],l),t}function HE(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&&f(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function jE(e){const t={},o=c(e,["id"]);o!=null&&f(t,["id"],o);const l=c(e,["args"]);l!=null&&f(t,["args"],l);const s=c(e,["name"]);if(s!=null&&f(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 GE(e){const t={},o=c(e,["mode"]);o!=null&&f(t,["mode"],o);const l=c(e,["allowedFunctionNames"]);if(l!=null&&f(t,["allowedFunctionNames"],l),c(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function VE(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&&f(t,["description"],o);const l=c(e,["name"]);l!=null&&f(t,["name"],l);const s=c(e,["parameters"]);s!=null&&f(t,["parameters"],s);const u=c(e,["parametersJsonSchema"]);u!=null&&f(t,["parametersJsonSchema"],u);const p=c(e,["response"]);p!=null&&f(t,["response"],p);const g=c(e,["responseJsonSchema"]);return g!=null&&f(t,["responseJsonSchema"],g),t}function $E(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&f(o,["systemInstruction"],$c(ri(s)));const u=c(t,["temperature"]);u!=null&&f(l,["temperature"],u);const p=c(t,["topP"]);p!=null&&f(l,["topP"],p);const g=c(t,["topK"]);g!=null&&f(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&f(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&f(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&f(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&f(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&f(l,["logprobs"],S);const A=c(t,["presencePenalty"]);A!=null&&f(l,["presencePenalty"],A);const E=c(t,["frequencyPenalty"]);E!=null&&f(l,["frequencyPenalty"],E);const j=c(t,["seed"]);j!=null&&f(l,["seed"],j);const I=c(t,["responseMimeType"]);I!=null&&f(l,["responseMimeType"],I);const $=c(t,["responseSchema"]);$!=null&&f(l,["responseSchema"],Wf($));const oe=c(t,["responseJsonSchema"]);if(oe!=null&&f(l,["responseJsonSchema"],oe),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 se=c(t,["safetySettings"]);if(o!==void 0&&se!=null){let gt=se;Array.isArray(gt)&&(gt=gt.map(xt=>L_(xt))),f(o,["safetySettings"],gt)}const fe=c(t,["tools"]);if(o!==void 0&&fe!=null){let gt=qa(fe);Array.isArray(gt)&&(gt=gt.map(xt=>j_($a(xt)))),f(o,["tools"],gt)}const De=c(t,["toolConfig"]);if(o!==void 0&&De!=null&&f(o,["toolConfig"],H_(De)),c(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const be=c(t,["cachedContent"]);o!==void 0&&be!=null&&f(o,["cachedContent"],Oo(e,be));const ye=c(t,["responseModalities"]);ye!=null&&f(l,["responseModalities"],ye);const tt=c(t,["mediaResolution"]);tt!=null&&f(l,["mediaResolution"],tt);const Ne=c(t,["speechConfig"]);if(Ne!=null&&f(l,["speechConfig"],Qf(Ne)),c(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Xe=c(t,["thinkingConfig"]);Xe!=null&&f(l,["thinkingConfig"],Xe);const $e=c(t,["imageConfig"]);$e!=null&&f(l,["imageConfig"],v_($e));const Ze=c(t,["enableEnhancedCivicAnswers"]);return Ze!=null&&f(l,["enableEnhancedCivicAnswers"],Ze),l}function qE(e,t,o){const l={},s=c(t,["systemInstruction"]);o!==void 0&&s!=null&&f(o,["systemInstruction"],ri(s));const u=c(t,["temperature"]);u!=null&&f(l,["temperature"],u);const p=c(t,["topP"]);p!=null&&f(l,["topP"],p);const g=c(t,["topK"]);g!=null&&f(l,["topK"],g);const v=c(t,["candidateCount"]);v!=null&&f(l,["candidateCount"],v);const m=c(t,["maxOutputTokens"]);m!=null&&f(l,["maxOutputTokens"],m);const x=c(t,["stopSequences"]);x!=null&&f(l,["stopSequences"],x);const b=c(t,["responseLogprobs"]);b!=null&&f(l,["responseLogprobs"],b);const S=c(t,["logprobs"]);S!=null&&f(l,["logprobs"],S);const A=c(t,["presencePenalty"]);A!=null&&f(l,["presencePenalty"],A);const E=c(t,["frequencyPenalty"]);E!=null&&f(l,["frequencyPenalty"],E);const j=c(t,["seed"]);j!=null&&f(l,["seed"],j);const I=c(t,["responseMimeType"]);I!=null&&f(l,["responseMimeType"],I);const $=c(t,["responseSchema"]);$!=null&&f(l,["responseSchema"],Wf($));const oe=c(t,["responseJsonSchema"]);oe!=null&&f(l,["responseJsonSchema"],oe);const se=c(t,["routingConfig"]);se!=null&&f(l,["routingConfig"],se);const fe=c(t,["modelSelectionConfig"]);fe!=null&&f(l,["modelConfig"],fe);const De=c(t,["safetySettings"]);if(o!==void 0&&De!=null){let G=De;Array.isArray(G)&&(G=G.map(Ee=>Ee)),f(o,["safetySettings"],G)}const be=c(t,["tools"]);if(o!==void 0&&be!=null){let G=qa(be);Array.isArray(G)&&(G=G.map(Ee=>Tv($a(Ee)))),f(o,["tools"],G)}const ye=c(t,["toolConfig"]);o!==void 0&&ye!=null&&f(o,["toolConfig"],ye);const tt=c(t,["labels"]);o!==void 0&&tt!=null&&f(o,["labels"],tt);const Ne=c(t,["cachedContent"]);o!==void 0&&Ne!=null&&f(o,["cachedContent"],Oo(e,Ne));const Xe=c(t,["responseModalities"]);Xe!=null&&f(l,["responseModalities"],Xe);const $e=c(t,["mediaResolution"]);$e!=null&&f(l,["mediaResolution"],$e);const Ze=c(t,["speechConfig"]);Ze!=null&&f(l,["speechConfig"],Qf(Ze));const gt=c(t,["audioTimestamp"]);gt!=null&&f(l,["audioTimestamp"],gt);const xt=c(t,["thinkingConfig"]);xt!=null&&f(l,["thinkingConfig"],xt);const Nt=c(t,["imageConfig"]);if(Nt!=null&&f(l,["imageConfig"],x_(Nt)),c(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return l}function wy(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let p=$i(s);Array.isArray(p)&&(p=p.map(g=>$c(g))),f(o,["contents"],p)}const u=c(t,["config"]);return u!=null&&f(o,["generationConfig"],$E(e,u,o)),o}function Cy(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["contents"]);if(s!=null){let p=$i(s);Array.isArray(p)&&(p=p.map(g=>g)),f(o,["contents"],p)}const u=c(t,["config"]);return u!=null&&f(o,["generationConfig"],qE(e,u,o)),o}function Ey(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(m=>hE(m))),f(t,["candidates"],v)}const s=c(e,["modelVersion"]);s!=null&&f(t,["modelVersion"],s);const u=c(e,["promptFeedback"]);u!=null&&f(t,["promptFeedback"],u);const p=c(e,["responseId"]);p!=null&&f(t,["responseId"],p);const g=c(e,["usageMetadata"]);return g!=null&&f(t,["usageMetadata"],g),t}function _y(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["candidates"]);if(l!=null){let m=l;Array.isArray(m)&&(m=m.map(x=>x)),f(t,["candidates"],m)}const s=c(e,["createTime"]);s!=null&&f(t,["createTime"],s);const u=c(e,["modelVersion"]);u!=null&&f(t,["modelVersion"],u);const p=c(e,["promptFeedback"]);p!=null&&f(t,["promptFeedback"],p);const g=c(e,["responseId"]);g!=null&&f(t,["responseId"],g);const v=c(e,["usageMetadata"]);return v!=null&&f(t,["usageMetadata"],v),t}function YE(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&&f(t,["parameters","sampleCount"],l);const s=c(e,["aspectRatio"]);t!==void 0&&s!=null&&f(t,["parameters","aspectRatio"],s);const u=c(e,["guidanceScale"]);if(t!==void 0&&u!=null&&f(t,["parameters","guidanceScale"],u),c(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const p=c(e,["safetyFilterLevel"]);t!==void 0&&p!=null&&f(t,["parameters","safetySetting"],p);const g=c(e,["personGeneration"]);t!==void 0&&g!=null&&f(t,["parameters","personGeneration"],g);const v=c(e,["includeSafetyAttributes"]);t!==void 0&&v!=null&&f(t,["parameters","includeSafetyAttributes"],v);const m=c(e,["includeRaiReason"]);t!==void 0&&m!=null&&f(t,["parameters","includeRaiReason"],m);const x=c(e,["language"]);t!==void 0&&x!=null&&f(t,["parameters","language"],x);const b=c(e,["outputMimeType"]);t!==void 0&&b!=null&&f(t,["parameters","outputOptions","mimeType"],b);const S=c(e,["outputCompressionQuality"]);if(t!==void 0&&S!=null&&f(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 A=c(e,["imageSize"]);if(t!==void 0&&A!=null&&f(t,["parameters","sampleImageSize"],A),c(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function JE(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&f(t,["parameters","storageUri"],l);const s=c(e,["negativePrompt"]);t!==void 0&&s!=null&&f(t,["parameters","negativePrompt"],s);const u=c(e,["numberOfImages"]);t!==void 0&&u!=null&&f(t,["parameters","sampleCount"],u);const p=c(e,["aspectRatio"]);t!==void 0&&p!=null&&f(t,["parameters","aspectRatio"],p);const g=c(e,["guidanceScale"]);t!==void 0&&g!=null&&f(t,["parameters","guidanceScale"],g);const v=c(e,["seed"]);t!==void 0&&v!=null&&f(t,["parameters","seed"],v);const m=c(e,["safetyFilterLevel"]);t!==void 0&&m!=null&&f(t,["parameters","safetySetting"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&f(t,["parameters","personGeneration"],x);const b=c(e,["includeSafetyAttributes"]);t!==void 0&&b!=null&&f(t,["parameters","includeSafetyAttributes"],b);const S=c(e,["includeRaiReason"]);t!==void 0&&S!=null&&f(t,["parameters","includeRaiReason"],S);const A=c(e,["language"]);t!==void 0&&A!=null&&f(t,["parameters","language"],A);const E=c(e,["outputMimeType"]);t!==void 0&&E!=null&&f(t,["parameters","outputOptions","mimeType"],E);const j=c(e,["outputCompressionQuality"]);t!==void 0&&j!=null&&f(t,["parameters","outputOptions","compressionQuality"],j);const I=c(e,["addWatermark"]);t!==void 0&&I!=null&&f(t,["parameters","addWatermark"],I);const $=c(e,["labels"]);t!==void 0&&$!=null&&f(t,["labels"],$);const oe=c(e,["imageSize"]);t!==void 0&&oe!=null&&f(t,["parameters","sampleImageSize"],oe);const se=c(e,["enhancePrompt"]);return t!==void 0&&se!=null&&f(t,["parameters","enhancePrompt"],se),o}function KE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["prompt"]);s!=null&&f(o,["instances[0]","prompt"],s);const u=c(t,["config"]);return u!=null&&YE(u,o),o}function XE(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["prompt"]);s!=null&&f(o,["instances[0]","prompt"],s);const u=c(t,["config"]);return u!=null&&JE(u,o),o}function WE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>c_(p))),f(t,["generatedImages"],u)}const s=c(e,["positivePromptSafetyAttributes"]);return s!=null&&f(t,["positivePromptSafetyAttributes"],bv(s)),t}function QE(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>qc(p))),f(t,["generatedImages"],u)}const s=c(e,["positivePromptSafetyAttributes"]);return s!=null&&f(t,["positivePromptSafetyAttributes"],Sv(s)),t}function ZE(e,t){const o={},l=c(e,["numberOfVideos"]);if(t!==void 0&&l!=null&&f(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&&f(t,["parameters","durationSeconds"],s),c(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const u=c(e,["aspectRatio"]);t!==void 0&&u!=null&&f(t,["parameters","aspectRatio"],u);const p=c(e,["resolution"]);t!==void 0&&p!=null&&f(t,["parameters","resolution"],p);const g=c(e,["personGeneration"]);if(t!==void 0&&g!=null&&f(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&&f(t,["parameters","negativePrompt"],v);const m=c(e,["enhancePrompt"]);if(t!==void 0&&m!=null&&f(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&&f(t,["instances[0]","lastFrame"],Yc(x));const b=c(e,["referenceImages"]);if(t!==void 0&&b!=null){let S=b;Array.isArray(S)&&(S=S.map(A=>tN(A))),f(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 e_(e,t){const o={},l=c(e,["numberOfVideos"]);t!==void 0&&l!=null&&f(t,["parameters","sampleCount"],l);const s=c(e,["outputGcsUri"]);t!==void 0&&s!=null&&f(t,["parameters","storageUri"],s);const u=c(e,["fps"]);t!==void 0&&u!=null&&f(t,["parameters","fps"],u);const p=c(e,["durationSeconds"]);t!==void 0&&p!=null&&f(t,["parameters","durationSeconds"],p);const g=c(e,["seed"]);t!==void 0&&g!=null&&f(t,["parameters","seed"],g);const v=c(e,["aspectRatio"]);t!==void 0&&v!=null&&f(t,["parameters","aspectRatio"],v);const m=c(e,["resolution"]);t!==void 0&&m!=null&&f(t,["parameters","resolution"],m);const x=c(e,["personGeneration"]);t!==void 0&&x!=null&&f(t,["parameters","personGeneration"],x);const b=c(e,["pubsubTopic"]);t!==void 0&&b!=null&&f(t,["parameters","pubsubTopic"],b);const S=c(e,["negativePrompt"]);t!==void 0&&S!=null&&f(t,["parameters","negativePrompt"],S);const A=c(e,["enhancePrompt"]);t!==void 0&&A!=null&&f(t,["parameters","enhancePrompt"],A);const E=c(e,["generateAudio"]);t!==void 0&&E!=null&&f(t,["parameters","generateAudio"],E);const j=c(e,["lastFrame"]);t!==void 0&&j!=null&&f(t,["instances[0]","lastFrame"],eo(j));const I=c(e,["referenceImages"]);if(t!==void 0&&I!=null){let se=I;Array.isArray(se)&&(se=se.map(fe=>nN(fe))),f(t,["instances[0]","referenceImages"],se)}const $=c(e,["mask"]);t!==void 0&&$!=null&&f(t,["instances[0]","mask"],eN($));const oe=c(e,["compressionQuality"]);return t!==void 0&&oe!=null&&f(t,["parameters","compressionQuality"],oe),o}function t_(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response","generateVideoResponse"]);return p!=null&&f(t,["response"],l_(p)),t}function n_(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response"]);return p!=null&&f(t,["response"],a_(p)),t}function i_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["prompt"]);s!=null&&f(o,["instances[0]","prompt"],s);const u=c(t,["image"]);u!=null&&f(o,["instances[0]","image"],Yc(u));const p=c(t,["video"]);p!=null&&f(o,["instances[0]","video"],wv(p));const g=c(t,["source"]);g!=null&&s_(g,o);const v=c(t,["config"]);return v!=null&&ZE(v,o),o}function o_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["prompt"]);s!=null&&f(o,["instances[0]","prompt"],s);const u=c(t,["image"]);u!=null&&f(o,["instances[0]","image"],eo(u));const p=c(t,["video"]);p!=null&&f(o,["instances[0]","video"],Cv(p));const g=c(t,["source"]);g!=null&&r_(g,o);const v=c(t,["config"]);return v!=null&&e_(v,o),o}function l_(e){const t={},o=c(e,["generatedSamples"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(p=>d_(p))),f(t,["generatedVideos"],u)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&f(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&f(t,["raiMediaFilteredReasons"],s),t}function a_(e){const t={},o=c(e,["videos"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(p=>f_(p))),f(t,["generatedVideos"],u)}const l=c(e,["raiMediaFilteredCount"]);l!=null&&f(t,["raiMediaFilteredCount"],l);const s=c(e,["raiMediaFilteredReasons"]);return s!=null&&f(t,["raiMediaFilteredReasons"],s),t}function s_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&f(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&f(t,["instances[0]","image"],Yc(s));const u=c(e,["video"]);return t!==void 0&&u!=null&&f(t,["instances[0]","video"],wv(u)),o}function r_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&f(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&f(t,["instances[0]","image"],eo(s));const u=c(e,["video"]);return t!==void 0&&u!=null&&f(t,["instances[0]","video"],Cv(u)),o}function c_(e){const t={},o=c(e,["_self"]);o!=null&&f(t,["image"],b_(o));const l=c(e,["raiFilteredReason"]);l!=null&&f(t,["raiFilteredReason"],l);const s=c(e,["_self"]);return s!=null&&f(t,["safetyAttributes"],bv(s)),t}function qc(e){const t={},o=c(e,["_self"]);o!=null&&f(t,["image"],xv(o));const l=c(e,["raiFilteredReason"]);l!=null&&f(t,["raiFilteredReason"],l);const s=c(e,["_self"]);s!=null&&f(t,["safetyAttributes"],Sv(s));const u=c(e,["prompt"]);return u!=null&&f(t,["enhancedPrompt"],u),t}function u_(e){const t={},o=c(e,["_self"]);o!=null&&f(t,["mask"],xv(o));const l=c(e,["labels"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(u=>u)),f(t,["labels"],s)}return t}function d_(e){const t={},o=c(e,["video"]);return o!=null&&f(t,["video"],Q_(o)),t}function f_(e){const t={},o=c(e,["_self"]);return o!=null&&f(t,["video"],Z_(o)),t}function p_(e){const t={},o=c(e,["modelSelectionConfig"]);o!=null&&f(t,["modelConfig"],o);const l=c(e,["responseJsonSchema"]);l!=null&&f(t,["responseJsonSchema"],l);const s=c(e,["audioTimestamp"]);s!=null&&f(t,["audioTimestamp"],s);const u=c(e,["candidateCount"]);u!=null&&f(t,["candidateCount"],u);const p=c(e,["enableAffectiveDialog"]);p!=null&&f(t,["enableAffectiveDialog"],p);const g=c(e,["frequencyPenalty"]);g!=null&&f(t,["frequencyPenalty"],g);const v=c(e,["logprobs"]);v!=null&&f(t,["logprobs"],v);const m=c(e,["maxOutputTokens"]);m!=null&&f(t,["maxOutputTokens"],m);const x=c(e,["mediaResolution"]);x!=null&&f(t,["mediaResolution"],x);const b=c(e,["presencePenalty"]);b!=null&&f(t,["presencePenalty"],b);const S=c(e,["responseLogprobs"]);S!=null&&f(t,["responseLogprobs"],S);const A=c(e,["responseMimeType"]);A!=null&&f(t,["responseMimeType"],A);const E=c(e,["responseModalities"]);E!=null&&f(t,["responseModalities"],E);const j=c(e,["responseSchema"]);j!=null&&f(t,["responseSchema"],j);const I=c(e,["routingConfig"]);I!=null&&f(t,["routingConfig"],I);const $=c(e,["seed"]);$!=null&&f(t,["seed"],$);const oe=c(e,["speechConfig"]);oe!=null&&f(t,["speechConfig"],oe);const se=c(e,["stopSequences"]);se!=null&&f(t,["stopSequences"],se);const fe=c(e,["temperature"]);fe!=null&&f(t,["temperature"],fe);const De=c(e,["thinkingConfig"]);De!=null&&f(t,["thinkingConfig"],De);const be=c(e,["topK"]);be!=null&&f(t,["topK"],be);const ye=c(e,["topP"]);if(ye!=null&&f(t,["topP"],ye),c(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function h_(e,t){const o={},l=c(t,["model"]);return l!=null&&f(o,["_url","name"],nn(e,l)),o}function m_(e,t){const o={},l=c(t,["model"]);return l!=null&&f(o,["_url","name"],nn(e,l)),o}function g_(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&&f(t,["enableWidget"],o),t}function y_(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&&f(t,["timeRangeFilter"],o),t}function v_(e){const t={},o=c(e,["aspectRatio"]);o!=null&&f(t,["aspectRatio"],o);const l=c(e,["imageSize"]);if(l!=null&&f(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 x_(e){const t={},o=c(e,["aspectRatio"]);o!=null&&f(t,["aspectRatio"],o);const l=c(e,["imageSize"]);l!=null&&f(t,["imageSize"],l);const s=c(e,["outputMimeType"]);s!=null&&f(t,["imageOutputOptions","mimeType"],s);const u=c(e,["outputCompressionQuality"]);return u!=null&&f(t,["imageOutputOptions","compressionQuality"],u),t}function b_(e){const t={},o=c(e,["bytesBase64Encoded"]);o!=null&&f(t,["imageBytes"],bl(o));const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function xv(e){const t={},o=c(e,["gcsUri"]);o!=null&&f(t,["gcsUri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&f(t,["imageBytes"],bl(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function Yc(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&&f(t,["bytesBase64Encoded"],bl(o));const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function eo(e){const t={},o=c(e,["gcsUri"]);o!=null&&f(t,["gcsUri"],o);const l=c(e,["imageBytes"]);l!=null&&f(t,["bytesBase64Encoded"],bl(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function S_(e,t,o){const l={},s=c(t,["pageSize"]);o!==void 0&&s!=null&&f(o,["_query","pageSize"],s);const u=c(t,["pageToken"]);o!==void 0&&u!=null&&f(o,["_query","pageToken"],u);const p=c(t,["filter"]);o!==void 0&&p!=null&&f(o,["_query","filter"],p);const g=c(t,["queryBase"]);return o!==void 0&&g!=null&&f(o,["_url","models_url"],fv(e,g)),l}function T_(e,t,o){const l={},s=c(t,["pageSize"]);o!==void 0&&s!=null&&f(o,["_query","pageSize"],s);const u=c(t,["pageToken"]);o!==void 0&&u!=null&&f(o,["_query","pageToken"],u);const p=c(t,["filter"]);o!==void 0&&p!=null&&f(o,["_query","filter"],p);const g=c(t,["queryBase"]);return o!==void 0&&g!=null&&f(o,["_url","models_url"],fv(e,g)),l}function w_(e,t){const o={},l=c(t,["config"]);return l!=null&&S_(e,l,o),o}function C_(e,t){const o={},l=c(t,["config"]);return l!=null&&T_(e,l,o),o}function E_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["_self"]);if(s!=null){let u=pv(s);Array.isArray(u)&&(u=u.map(p=>wf(p))),f(t,["models"],u)}return t}function __(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["_self"]);if(s!=null){let u=pv(s);Array.isArray(u)&&(u=u.map(p=>Cf(p))),f(t,["models"],u)}return t}function N_(e){const t={},o=c(e,["maskMode"]);o!=null&&f(t,["maskMode"],o);const l=c(e,["segmentationClasses"]);l!=null&&f(t,["maskClasses"],l);const s=c(e,["maskDilation"]);return s!=null&&f(t,["dilation"],s),t}function wf(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["displayName"]);l!=null&&f(t,["displayName"],l);const s=c(e,["description"]);s!=null&&f(t,["description"],s);const u=c(e,["version"]);u!=null&&f(t,["version"],u);const p=c(e,["_self"]);p!=null&&f(t,["tunedModelInfo"],G_(p));const g=c(e,["inputTokenLimit"]);g!=null&&f(t,["inputTokenLimit"],g);const v=c(e,["outputTokenLimit"]);v!=null&&f(t,["outputTokenLimit"],v);const m=c(e,["supportedGenerationMethods"]);m!=null&&f(t,["supportedActions"],m);const x=c(e,["temperature"]);x!=null&&f(t,["temperature"],x);const b=c(e,["maxTemperature"]);b!=null&&f(t,["maxTemperature"],b);const S=c(e,["topP"]);S!=null&&f(t,["topP"],S);const A=c(e,["topK"]);A!=null&&f(t,["topK"],A);const E=c(e,["thinking"]);return E!=null&&f(t,["thinking"],E),t}function Cf(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["displayName"]);l!=null&&f(t,["displayName"],l);const s=c(e,["description"]);s!=null&&f(t,["description"],s);const u=c(e,["versionId"]);u!=null&&f(t,["version"],u);const p=c(e,["deployedModels"]);if(p!=null){let b=p;Array.isArray(b)&&(b=b.map(S=>OE(S))),f(t,["endpoints"],b)}const g=c(e,["labels"]);g!=null&&f(t,["labels"],g);const v=c(e,["_self"]);v!=null&&f(t,["tunedModelInfo"],V_(v));const m=c(e,["defaultCheckpointId"]);m!=null&&f(t,["defaultCheckpointId"],m);const x=c(e,["checkpoints"]);if(x!=null){let b=x;Array.isArray(b)&&(b=b.map(S=>S)),f(t,["checkpoints"],b)}return t}function A_(e){const t={},o=c(e,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&f(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&f(t,["executableCode"],s);const u=c(e,["fileData"]);u!=null&&f(t,["fileData"],HE(u));const p=c(e,["functionCall"]);p!=null&&f(t,["functionCall"],jE(p));const g=c(e,["functionResponse"]);g!=null&&f(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&f(t,["inlineData"],pE(v));const m=c(e,["text"]);m!=null&&f(t,["text"],m);const x=c(e,["thought"]);x!=null&&f(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&f(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&f(t,["videoMetadata"],S),t}function M_(e){const t={},o=c(e,["productImage"]);return o!=null&&f(t,["image"],eo(o)),t}function k_(e,t){const o={},l=c(e,["numberOfImages"]);t!==void 0&&l!=null&&f(t,["parameters","sampleCount"],l);const s=c(e,["baseSteps"]);t!==void 0&&s!=null&&f(t,["parameters","baseSteps"],s);const u=c(e,["outputGcsUri"]);t!==void 0&&u!=null&&f(t,["parameters","storageUri"],u);const p=c(e,["seed"]);t!==void 0&&p!=null&&f(t,["parameters","seed"],p);const g=c(e,["safetyFilterLevel"]);t!==void 0&&g!=null&&f(t,["parameters","safetySetting"],g);const v=c(e,["personGeneration"]);t!==void 0&&v!=null&&f(t,["parameters","personGeneration"],v);const m=c(e,["addWatermark"]);t!==void 0&&m!=null&&f(t,["parameters","addWatermark"],m);const x=c(e,["outputMimeType"]);t!==void 0&&x!=null&&f(t,["parameters","outputOptions","mimeType"],x);const b=c(e,["outputCompressionQuality"]);t!==void 0&&b!=null&&f(t,["parameters","outputOptions","compressionQuality"],b);const S=c(e,["enhancePrompt"]);t!==void 0&&S!=null&&f(t,["parameters","enhancePrompt"],S);const A=c(e,["labels"]);return t!==void 0&&A!=null&&f(t,["labels"],A),o}function R_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["source"]);s!=null&&z_(s,o);const u=c(t,["config"]);return u!=null&&k_(u,o),o}function I_(e){const t={},o=c(e,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>qc(s))),f(t,["generatedImages"],l)}return t}function z_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&f(t,["instances[0]","prompt"],l);const s=c(e,["personImage"]);t!==void 0&&s!=null&&f(t,["instances[0]","personImage","image"],eo(s));const u=c(e,["productImages"]);if(t!==void 0&&u!=null){let p=u;Array.isArray(p)&&(p=p.map(g=>M_(g))),f(t,["instances[0]","productImages"],p)}return o}function D_(e){const t={},o=c(e,["referenceImage"]);o!=null&&f(t,["referenceImage"],eo(o));const l=c(e,["referenceId"]);l!=null&&f(t,["referenceId"],l);const s=c(e,["referenceType"]);s!=null&&f(t,["referenceType"],s);const u=c(e,["maskImageConfig"]);u!=null&&f(t,["maskImageConfig"],N_(u));const p=c(e,["controlImageConfig"]);p!=null&&f(t,["controlImageConfig"],bE(p));const g=c(e,["styleImageConfig"]);g!=null&&f(t,["styleImageConfig"],g);const v=c(e,["subjectImageConfig"]);return v!=null&&f(t,["subjectImageConfig"],v),t}function bv(e){const t={},o=c(e,["safetyAttributes","categories"]);o!=null&&f(t,["categories"],o);const l=c(e,["safetyAttributes","scores"]);l!=null&&f(t,["scores"],l);const s=c(e,["contentType"]);return s!=null&&f(t,["contentType"],s),t}function Sv(e){const t={},o=c(e,["safetyAttributes","categories"]);o!=null&&f(t,["categories"],o);const l=c(e,["safetyAttributes","scores"]);l!=null&&f(t,["scores"],l);const s=c(e,["contentType"]);return s!=null&&f(t,["contentType"],s),t}function L_(e){const t={},o=c(e,["category"]);if(o!=null&&f(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&&f(t,["threshold"],l),t}function U_(e){const t={},o=c(e,["image"]);return o!=null&&f(t,["image"],eo(o)),t}function F_(e,t){const o={},l=c(e,["mode"]);t!==void 0&&l!=null&&f(t,["parameters","mode"],l);const s=c(e,["maxPredictions"]);t!==void 0&&s!=null&&f(t,["parameters","maxPredictions"],s);const u=c(e,["confidenceThreshold"]);t!==void 0&&u!=null&&f(t,["parameters","confidenceThreshold"],u);const p=c(e,["maskDilation"]);t!==void 0&&p!=null&&f(t,["parameters","maskDilation"],p);const g=c(e,["binaryColorThreshold"]);t!==void 0&&g!=null&&f(t,["parameters","binaryColorThreshold"],g);const v=c(e,["labels"]);return t!==void 0&&v!=null&&f(t,["labels"],v),o}function P_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["source"]);s!=null&&O_(s,o);const u=c(t,["config"]);return u!=null&&F_(u,o),o}function B_(e){const t={},o=c(e,["predictions"]);if(o!=null){let l=o;Array.isArray(l)&&(l=l.map(s=>u_(s))),f(t,["generatedMasks"],l)}return t}function O_(e,t){const o={},l=c(e,["prompt"]);t!==void 0&&l!=null&&f(t,["instances[0]","prompt"],l);const s=c(e,["image"]);t!==void 0&&s!=null&&f(t,["instances[0]","image"],eo(s));const u=c(e,["scribbleImage"]);return t!==void 0&&u!=null&&f(t,["instances[0]","scribble"],U_(u)),o}function H_(e){const t={},o=c(e,["functionCallingConfig"]);o!=null&&f(t,["functionCallingConfig"],GE(o));const l=c(e,["retrievalConfig"]);return l!=null&&f(t,["retrievalConfig"],l),t}function j_(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),f(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&&f(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&f(t,["computerUse"],s);const u=c(e,["fileSearch"]);u!=null&&f(t,["fileSearch"],u);const p=c(e,["codeExecution"]);if(p!=null&&f(t,["codeExecution"],p),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&f(t,["googleMaps"],g_(g));const v=c(e,["googleSearch"]);v!=null&&f(t,["googleSearch"],y_(v));const m=c(e,["urlContext"]);return m!=null&&f(t,["urlContext"],m),t}function Tv(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let b=o;Array.isArray(b)&&(b=b.map(S=>VE(S))),f(t,["functionDeclarations"],b)}const l=c(e,["retrieval"]);l!=null&&f(t,["retrieval"],l);const s=c(e,["googleSearchRetrieval"]);s!=null&&f(t,["googleSearchRetrieval"],s);const u=c(e,["computerUse"]);if(u!=null&&f(t,["computerUse"],u),c(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const p=c(e,["codeExecution"]);p!=null&&f(t,["codeExecution"],p);const g=c(e,["enterpriseWebSearch"]);g!=null&&f(t,["enterpriseWebSearch"],g);const v=c(e,["googleMaps"]);v!=null&&f(t,["googleMaps"],v);const m=c(e,["googleSearch"]);m!=null&&f(t,["googleSearch"],m);const x=c(e,["urlContext"]);return x!=null&&f(t,["urlContext"],x),t}function G_(e){const t={},o=c(e,["baseModel"]);o!=null&&f(t,["baseModel"],o);const l=c(e,["createTime"]);l!=null&&f(t,["createTime"],l);const s=c(e,["updateTime"]);return s!=null&&f(t,["updateTime"],s),t}function V_(e){const t={},o=c(e,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&f(t,["baseModel"],o);const l=c(e,["createTime"]);l!=null&&f(t,["createTime"],l);const s=c(e,["updateTime"]);return s!=null&&f(t,["updateTime"],s),t}function $_(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&f(t,["displayName"],l);const s=c(e,["description"]);t!==void 0&&s!=null&&f(t,["description"],s);const u=c(e,["defaultCheckpointId"]);return t!==void 0&&u!=null&&f(t,["defaultCheckpointId"],u),o}function q_(e,t){const o={},l=c(e,["displayName"]);t!==void 0&&l!=null&&f(t,["displayName"],l);const s=c(e,["description"]);t!==void 0&&s!=null&&f(t,["description"],s);const u=c(e,["defaultCheckpointId"]);return t!==void 0&&u!=null&&f(t,["defaultCheckpointId"],u),o}function Y_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","name"],nn(e,l));const s=c(t,["config"]);return s!=null&&$_(s,o),o}function J_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["config"]);return s!=null&&q_(s,o),o}function K_(e,t){const o={},l=c(e,["outputGcsUri"]);t!==void 0&&l!=null&&f(t,["parameters","storageUri"],l);const s=c(e,["safetyFilterLevel"]);t!==void 0&&s!=null&&f(t,["parameters","safetySetting"],s);const u=c(e,["personGeneration"]);t!==void 0&&u!=null&&f(t,["parameters","personGeneration"],u);const p=c(e,["includeRaiReason"]);t!==void 0&&p!=null&&f(t,["parameters","includeRaiReason"],p);const g=c(e,["outputMimeType"]);t!==void 0&&g!=null&&f(t,["parameters","outputOptions","mimeType"],g);const v=c(e,["outputCompressionQuality"]);t!==void 0&&v!=null&&f(t,["parameters","outputOptions","compressionQuality"],v);const m=c(e,["enhanceInputImage"]);t!==void 0&&m!=null&&f(t,["parameters","upscaleConfig","enhanceInputImage"],m);const x=c(e,["imagePreservationFactor"]);t!==void 0&&x!=null&&f(t,["parameters","upscaleConfig","imagePreservationFactor"],x);const b=c(e,["labels"]);t!==void 0&&b!=null&&f(t,["labels"],b);const S=c(e,["numberOfImages"]);t!==void 0&&S!=null&&f(t,["parameters","sampleCount"],S);const A=c(e,["mode"]);return t!==void 0&&A!=null&&f(t,["parameters","mode"],A),o}function X_(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["_url","model"],nn(e,l));const s=c(t,["image"]);s!=null&&f(o,["instances[0]","image"],eo(s));const u=c(t,["upscaleFactor"]);u!=null&&f(o,["parameters","upscaleConfig","upscaleFactor"],u);const p=c(t,["config"]);return p!=null&&K_(p,o),o}function W_(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["predictions"]);if(l!=null){let s=l;Array.isArray(s)&&(s=s.map(u=>qc(u))),f(t,["generatedImages"],s)}return t}function Q_(e){const t={},o=c(e,["uri"]);o!=null&&f(t,["uri"],o);const l=c(e,["encodedVideo"]);l!=null&&f(t,["videoBytes"],bl(l));const s=c(e,["encoding"]);return s!=null&&f(t,["mimeType"],s),t}function Z_(e){const t={},o=c(e,["gcsUri"]);o!=null&&f(t,["uri"],o);const l=c(e,["bytesBase64Encoded"]);l!=null&&f(t,["videoBytes"],bl(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function eN(e){const t={},o=c(e,["image"]);o!=null&&f(t,["_self"],eo(o));const l=c(e,["maskMode"]);return l!=null&&f(t,["maskMode"],l),t}function tN(e){const t={},o=c(e,["image"]);o!=null&&f(t,["image"],Yc(o));const l=c(e,["referenceType"]);return l!=null&&f(t,["referenceType"],l),t}function nN(e){const t={},o=c(e,["image"]);o!=null&&f(t,["image"],eo(o));const l=c(e,["referenceType"]);return l!=null&&f(t,["referenceType"],l),t}function wv(e){const t={},o=c(e,["uri"]);o!=null&&f(t,["uri"],o);const l=c(e,["videoBytes"]);l!=null&&f(t,["encodedVideo"],bl(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["encoding"],s),t}function Cv(e){const t={},o=c(e,["uri"]);o!=null&&f(t,["gcsUri"],o);const l=c(e,["videoBytes"]);l!=null&&f(t,["bytesBase64Encoded"],bl(l));const s=c(e,["mimeType"]);return s!=null&&f(t,["mimeType"],s),t}function iN(e,t){const o={},l=c(e,["displayName"]);return t!==void 0&&l!=null&&f(t,["displayName"],l),o}function oN(e){const t={},o=c(e,["config"]);return o!=null&&iN(o,t),t}function lN(e,t){const o={},l=c(e,["force"]);return t!==void 0&&l!=null&&f(t,["_query","force"],l),o}function aN(e){const t={},o=c(e,["name"]);o!=null&&f(t,["_url","name"],o);const l=c(e,["config"]);return l!=null&&lN(l,t),t}function sN(e){const t={},o=c(e,["name"]);return o!=null&&f(t,["_url","name"],o),t}function rN(e,t){const o={},l=c(e,["customMetadata"]);if(t!==void 0&&l!=null){let u=l;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["customMetadata"],u)}const s=c(e,["chunkingConfig"]);return t!==void 0&&s!=null&&f(t,["chunkingConfig"],s),o}function cN(e){const t={},o=c(e,["name"]);o!=null&&f(t,["name"],o);const l=c(e,["metadata"]);l!=null&&f(t,["metadata"],l);const s=c(e,["done"]);s!=null&&f(t,["done"],s);const u=c(e,["error"]);u!=null&&f(t,["error"],u);const p=c(e,["response"]);return p!=null&&f(t,["response"],dN(p)),t}function uN(e){const t={},o=c(e,["fileSearchStoreName"]);o!=null&&f(t,["_url","file_search_store_name"],o);const l=c(e,["fileName"]);l!=null&&f(t,["fileName"],l);const s=c(e,["config"]);return s!=null&&rN(s,t),t}function dN(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["parent"]);l!=null&&f(t,["parent"],l);const s=c(e,["documentName"]);return s!=null&&f(t,["documentName"],s),t}function fN(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),o}function pN(e){const t={},o=c(e,["config"]);return o!=null&&fN(o,t),t}function hN(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["fileSearchStores"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["fileSearchStores"],u)}return t}function Ev(e,t){const o={},l=c(e,["mimeType"]);t!==void 0&&l!=null&&f(t,["mimeType"],l);const s=c(e,["displayName"]);t!==void 0&&s!=null&&f(t,["displayName"],s);const u=c(e,["customMetadata"]);if(t!==void 0&&u!=null){let g=u;Array.isArray(g)&&(g=g.map(v=>v)),f(t,["customMetadata"],g)}const p=c(e,["chunkingConfig"]);return t!==void 0&&p!=null&&f(t,["chunkingConfig"],p),o}function mN(e){const t={},o=c(e,["fileSearchStoreName"]);o!=null&&f(t,["_url","file_search_store_name"],o);const l=c(e,["config"]);return l!=null&&Ev(l,t),t}function gN(e){const t={},o=c(e,["sdkHttpResponse"]);return o!=null&&f(t,["sdkHttpResponse"],o),t}const yN="Content-Type",vN="X-Server-Timeout",xN="User-Agent",Ef="x-goog-api-client",bN="1.34.0",SN=`google-genai-sdk/${bN}`,TN="v1beta1",wN="v1beta";class CN{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:TN,s.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(s.apiVersion=(l=this.clientOptions.apiVersion)!==null&&l!==void 0?l:wN,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[p,g]of Object.entries(t.queryParams))s.searchParams.append(p,String(g));let u={};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 u.body=t.body;return u=await this.includeExtraHttpOptionsToRequestInit(u,o,s.toString(),t.abortSignal),this.unaryApiCall(s,u,t.httpMethod)}patchHttpOptions(t,o){const l=JSON.parse(JSON.stringify(t));for(const[s,u]of Object.entries(o))typeof u=="object"?l[s]=Object.assign(Object.assign({},l[s]),u):u!==void 0&&(l[s]=u);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 u={};return u.body=t.body,u=await this.includeExtraHttpOptionsToRequestInit(u,o,s.toString(),t.abortSignal),this.streamApiCall(s,u,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,o,l,s){if(o&&o.timeout||s){const u=new AbortController,p=u.signal;if(o.timeout&&o?.timeout>0){const g=setTimeout(()=>u.abort(),o.timeout);g&&typeof g.unref=="function"&&g.unref()}s&&s.addEventListener("abort",()=>{u.abort()}),t.signal=p}return o&&o.extraBody!==null&&EN(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 Ny(s),new bf(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 Ny(s),this.processStreamResponse(s))).catch(s=>{throw s instanceof Error?s:new Error(JSON.stringify(s))})}processStreamResponse(t){return Qi(this,arguments,function*(){var l;const s=(l=t?.body)===null||l===void 0?void 0:l.getReader(),u=new TextDecoder("utf-8");if(!s)throw new Error("Response body is empty");try{let p="";const g="data:",v=[` + +`,"\r\r",`\r +\r +`];for(;;){const{done:m,value:x}=yield kt(s.read());if(m){if(p.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const b=u.decode(x,{stream:!0});try{const E=JSON.parse(b);if("error"in E){const j=JSON.parse(JSON.stringify(E.error)),I=j.status,$=j.code,oe=`got status: ${I}. ${JSON.stringify(E)}`;if($>=400&&$<600)throw new Vc({message:oe,status:$})}}catch(E){if(E.name==="ApiError")throw E}p+=b;let S=-1,A=0;for(;;){S=-1,A=0;for(const I of v){const $=p.indexOf(I);$!==-1&&(S===-1||${throw new Error(`exception ${l} sending request`)})}getDefaultHeaders(){const t={},o=SN+" "+this.clientOptions.userAgentExtra;return t[xN]=o,t[Ef]=o,t[yN]="application/json",t}async getHeadersInternal(t,o){const l=new Headers;if(t&&t.headers){for(const[s,u]of Object.entries(t.headers))l.append(s,u);t.timeout&&t.timeout>0&&l.append(vN,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 u=this.clientOptions.uploader,p=await u.stat(t);s.sizeBytes=String(p.size);const g=(l=o?.mimeType)!==null&&l!==void 0?l:p.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=Qe("upload/v1beta/files",v._url),b=await this.fetchUploadUrl(x,s.sizeBytes,s.mimeType,m,v,o?.httpOptions);return u.upload(t,b,this)}async uploadFileToFileSearchStore(t,o,l){var s;const u=this.clientOptions.uploader,p=await u.stat(o),g=String(p.size),v=(s=l?.mimeType)!==null&&s!==void 0?s:p.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&&Ev(l,b);const S=await this.fetchUploadUrl(m,g,v,x,b,l?.httpOptions);return u.uploadToFileSearchStore(o,S,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,o,l,s,u,p){var g;let v={};p?v=p: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(u),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 Ny(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 Vc({message:s,status:o}):new Error(s)}}function EN(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 u=JSON.parse(e.body);if(typeof u=="object"&&u!==null&&!Array.isArray(u))o=u;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(u,p){const g=Object.assign({},u);for(const v in p)if(Object.prototype.hasOwnProperty.call(p,v)){const m=p[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 _N="mcp_used/unknown";let NN=!1;function _v(e){for(const t of e)if(AN(t)||typeof t=="object"&&"inputSchema"in t)return!0;return NN}function Nv(e){var t;const o=(t=e[Ef])!==null&&t!==void 0?t:"";e[Ef]=(o+` ${_N}`).trimStart()}function AN(e){return e!==null&&typeof e=="object"&&e instanceof ep}function MN(e){return Qi(this,arguments,function*(o,l=100){let s,u=0;for(;u0)return;const u={},p=[];for(const x of this.mcpClients)try{for(var g=!0,v=(o=void 0,Zi(MN(x))),m;m=await v.next(),t=m.done,!t;g=!0){s=m.value,g=!1;const b=s;p.push(b);const S=b.name;if(u[S])throw new Error(`Duplicate function name ${S} found in MCP tools. Please ensure function names are unique.`);u[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=p,this.functionNameToMcpClient=u}async tool(){return await this.initialize(),sw(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 u;this.config.timeout&&(u={timeout:this.config.timeout});const p=await s.callTool({name:l.name,arguments:l.args},void 0,u);o.push({functionResponse:{name:l.name,response:p.isError?{error:p}:p}})}return o}}async function kN(e,t,o){const l=new ZT;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 RN{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(),u=this.apiClient.getApiVersion(),p=DN(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),v=`${s}/ws/google.ai.generativelanguage.${u}.GenerativeService.BidiGenerateMusic?key=${g}`;let m=()=>{};const x=new Promise(se=>{m=se}),b=t.callbacks,S=function(){m({})},A=this.apiClient,E={onopen:S,onmessage:se=>{kN(A,b.onmessage,se)},onerror:(o=b?.onerror)!==null&&o!==void 0?o:function(se){},onclose:(l=b?.onclose)!==null&&l!==void 0?l:function(se){}},j=this.webSocketFactory.create(v,zN(p),E);j.connect(),await x;const oe={setup:{model:nn(this.apiClient,t.model)}};return j.send(JSON.stringify(oe)),new IN(j,this.apiClient)}}class IN{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=oE(t);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const o=iE(t);this.conn.send(JSON.stringify(o))}sendPlaybackControl(t){const o={playbackControl:t};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(Ua.PLAY)}pause(){this.sendPlaybackControl(Ua.PAUSE)}stop(){this.sendPlaybackControl(Ua.STOP)}resetContext(){this.sendPlaybackControl(Ua.RESET_CONTEXT)}close(){this.conn.close()}}function zN(e){const t={};return e.forEach((o,l)=>{t[l]=o}),t}function DN(e){const t=new Headers;for(const[o,l]of Object.entries(e))t.append(o,l);return t}const LN="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function UN(e,t,o){const l=new QT;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 u=JSON.parse(s);if(e.isVertexAI()){const p=sE(u);Object.assign(l,p)}else Object.assign(l,u);t(l)}class FN{constructor(t,o,l){this.apiClient=t,this.auth=o,this.webSocketFactory=l,this.music=new RN(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var o,l,s,u,p,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&&_v(t.config.tools)&&Nv(b);const S=HN(b);if(this.apiClient.isVertexAI())x=`${v}/ws/google.cloud.aiplatform.${m}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(S,x);else{const Ne=this.apiClient.getApiKey();let Xe="BidiGenerateContent",$e="key";Ne?.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."),Xe="BidiGenerateContentConstrained",$e="access_token"),x=`${v}/ws/google.ai.generativelanguage.${m}.GenerativeService.${Xe}?${$e}=${Ne}`}let A=()=>{};const E=new Promise(Ne=>{A=Ne}),j=t.callbacks,I=function(){var Ne;(Ne=j?.onopen)===null||Ne===void 0||Ne.call(j),A({})},$=this.apiClient,oe={onopen:I,onmessage:Ne=>{UN($,j.onmessage,Ne)},onerror:(o=j?.onerror)!==null&&o!==void 0?o:function(Ne){},onclose:(l=j?.onclose)!==null&&l!==void 0?l:function(Ne){}},se=this.webSocketFactory.create(x,ON(S),oe);se.connect(),await E;let fe=nn(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&fe.startsWith("publishers/")){const Ne=this.apiClient.getProject(),Xe=this.apiClient.getLocation();fe=`projects/${Ne}/locations/${Xe}/`+fe}let De={};this.apiClient.isVertexAI()&&((s=t.config)===null||s===void 0?void 0:s.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[Rc.AUDIO]}:t.config.responseModalities=[Rc.AUDIO]),!((u=t.config)===null||u===void 0)&&u.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 be=(g=(p=t.config)===null||p===void 0?void 0:p.tools)!==null&&g!==void 0?g:[],ye=[];for(const Ne of be)if(this.isCallableTool(Ne)){const Xe=Ne;ye.push(await Xe.tool())}else ye.push(Ne);ye.length>0&&(t.config.tools=ye);const tt={model:fe,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?De=nE(this.apiClient,tt):De=tE(this.apiClient,tt),delete De.config,se.send(JSON.stringify(De)),new BN(se,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const PN={turnComplete:!0};class BN{constructor(t,o){this.conn=t,this.apiClient=o}tLiveClientContent(t,o){if(o.turns!==null&&o.turns!==void 0){let l=[];try{l=$i(o.turns),t.isVertexAI()||(l=l.map(s=>$c(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 u of l){if(typeof u!="object"||u===null||!("name"in u)||!("response"in u))throw new Error(`Could not parse function response, type '${typeof u}'.`);if(!t.isVertexAI()&&!("id"in u))throw new Error(LN)}return{toolResponse:{functionResponses:l}}}sendClientContent(t){t=Object.assign(Object.assign({},PN),t);const o=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(o))}sendRealtimeInput(t){let o={};this.apiClient.isVertexAI()?o={realtimeInput:aE(t)}:o={realtimeInput:lE(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 ON(e){const t={};return e.forEach((o,l)=>{t[l]=o}),t}function HN(e){const t=new Headers;for(const[o,l]of Object.entries(e))t.append(o,l);return t}const Ay=10;function My(e){var t,o,l;if(!((t=e?.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let s=!1;for(const p of(o=e?.tools)!==null&&o!==void 0?o:[])if(Ha(p)){s=!0;break}if(!s)return!0;const u=(l=e?.automaticFunctionCalling)===null||l===void 0?void 0:l.maximumRemoteCalls;return u&&(u<0||!Number.isInteger(u))||u==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:",u),!0):!1}function Ha(e){return"callTool"in e&&typeof e.callTool=="function"}function jN(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=>Ha(s)))!==null&&l!==void 0?l:!1}function ky(e){var t;const o=[];return!((t=e?.config)===null||t===void 0)&&t.tools&&e.config.tools.forEach((l,s)=>{if(Ha(l))return;const u=l;u.functionDeclarations&&u.functionDeclarations.length>0&&o.push(s)}),o}function Ry(e){var t;return!(!((t=e?.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}class GN extends Bo{constructor(t){super(),this.apiClient=t,this.generateContent=async o=>{var l,s,u,p,g;const v=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!jN(o)||My(o.config))return await this.generateContentInternal(v);const m=ky(o);if(m.length>0){const j=m.map(I=>`tools[${I}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${j}.`)}let x,b;const S=$i(v.contents),A=(u=(s=(l=v.config)===null||l===void 0?void 0:l.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&u!==void 0?u:Ay;let E=0;for(;E{var l,s,u,p,g;if(this.maybeMoveToResponseJsonSchem(o),My(o.config)){const b=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(b)}const v=ky(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=(u=(s=(l=o?.config)===null||l===void 0?void 0:l.toolConfig)===null||s===void 0?void 0:s.functionCallingConfig)===null||u===void 0?void 0:u.streamFunctionCallArguments,x=(g=(p=o?.config)===null||p===void 0?void 0:p.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 u;const p=[];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"?u=v?.safetyAttributes:p.push(v);let g;return u?g={generatedImages:p,positivePromptSafetyAttributes:u,sdkHttpResponse:l.sdkHttpResponse}:g={generatedImages:p,sdkHttpResponse:l.sdkHttpResponse},g}),this.list=async o=>{var l;const p={config:Object.assign(Object.assign({},{queryBase:!0}),o?.config)};if(this.apiClient.isVertexAI()&&!p.config.queryBase){if(!((l=p.config)===null||l===void 0)&&l.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");p.config.filter="labels.tune-type:*"}return new Kl(Po.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(p),p)},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,u,p,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}:!((p=(u=o.source)===null||u===void 0?void 0:u.video)===null||p===void 0)&&p.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 u=(o=t.config)===null||o===void 0?void 0:o.tools;if(!u)return t;const p=await Promise.all(u.map(async v=>Ha(v)?await v.tool():v)),g={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:p})};if(g.config.tools=p,t.config&&t.config.tools&&_v(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()),Nv(m),g.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:m})}return g}async initAfcToolsMap(t){var o,l,s;const u=new Map;for(const p of(l=(o=t.config)===null||o===void 0?void 0:o.tools)!==null&&l!==void 0?l:[])if(Ha(p)){const g=p,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(u.has(m.name))throw new Error(`Duplicate tool declaration name: ${m.name}`);u.set(m.name,g)}}return u}async processAfcStream(t){var o,l,s;const u=(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:Ay;let p=!1,g=0;const v=await this.initAfcToolsMap(t);return(function(m,x,b){return Qi(this,arguments,function*(){for(var S,A,E,j,I,$;g0){p=!0;const Ne=new Ls;Ne.candidates=[{content:{role:"user",parts:ye}}],yield yield kt(Ne);const Xe=[];Xe.push(...tt),Xe.push({role:"user",parts:ye});const $e=$i(b.contents).concat(Xe);b.contents=$e}else break}})})(this,v,t)}async generateContentInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=Cy(this.apiClient,t);return g=Qe("{model}:generateContent",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=_y(x),S=new Ls;return Object.assign(S,b),S})}else{const m=wy(this.apiClient,t);return g=Qe("{model}:generateContent",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=Ey(x),S=new Ls;return Object.assign(S,b),S})}}async generateContentStreamInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=Cy(this.apiClient,t);return g=Qe("{model}:streamGenerateContent?alt=sse",m._url),v=m._query,delete m._url,delete m._query,p=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}),p.then(function(b){return Qi(this,arguments,function*(){var S,A,E,j;try{for(var I=!0,$=Zi(b),oe;oe=yield kt($.next()),S=oe.done,!S;I=!0){j=oe.value,I=!1;const se=j,fe=_y(yield kt(se.json()));fe.sdkHttpResponse={headers:se.headers};const De=new Ls;Object.assign(De,fe),yield yield kt(De)}}catch(se){A={error:se}}finally{try{!I&&!S&&(E=$.return)&&(yield kt(E.call($)))}finally{if(A)throw A.error}}})})}else{const m=wy(this.apiClient,t);return g=Qe("{model}:streamGenerateContent?alt=sse",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}),p.then(function(b){return Qi(this,arguments,function*(){var S,A,E,j;try{for(var I=!0,$=Zi(b),oe;oe=yield kt($.next()),S=oe.done,!S;I=!0){j=oe.value,I=!1;const se=j,fe=Ey(yield kt(se.json()));fe.sdkHttpResponse={headers:se.headers};const De=new Ls;Object.assign(De,fe),yield yield kt(De)}}catch(se){A={error:se}}finally{try{!I&&!S&&(E=$.return)&&(yield kt(E.call($)))}finally{if(A)throw A.error}}})})}}async embedContent(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=FE(this.apiClient,t);return g=Qe("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=BE(x),S=new ay;return Object.assign(S,b),S})}else{const m=UE(this.apiClient,t);return g=Qe("{model}:batchEmbedContents",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=PE(x),S=new ay;return Object.assign(S,b),S})}}async generateImagesInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=XE(this.apiClient,t);return g=Qe("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=QE(x),S=new sy;return Object.assign(S,b),S})}else{const m=KE(this.apiClient,t);return g=Qe("{model}:predict",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=WE(x),S=new sy;return Object.assign(S,b),S})}}async editImageInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI()){const g=IE(this.apiClient,t);return u=Qe("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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 HT;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,u="",p={};if(this.apiClient.isVertexAI()){const g=X_(this.apiClient,t);return u=Qe("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=W_(v),x=new jT;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,u="",p={};if(this.apiClient.isVertexAI()){const g=R_(this.apiClient,t);return u=Qe("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=I_(v),x=new GT;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,u="",p={};if(this.apiClient.isVertexAI()){const g=P_(this.apiClient,t);return u=Qe("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=B_(v),x=new VT;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,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=m_(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>Cf(x))}else{const m=h_(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>wf(x))}}async listInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=C_(this.apiClient,t);return g=Qe("{models_url}",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=__(x),S=new ry;return Object.assign(S,b),S})}else{const m=w_(this.apiClient,t);return g=Qe("{models_url}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=E_(x),S=new ry;return Object.assign(S,b),S})}}async update(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=J_(this.apiClient,t);return g=Qe("{model}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>Cf(x))}else{const m=Y_(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>wf(x))}}async delete(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=AE(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=kE(x),S=new cy;return Object.assign(S,b),S})}else{const m=NE(this.apiClient,t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=ME(x),S=new cy;return Object.assign(S,b),S})}}async countTokens(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=CE(this.apiClient,t);return g=Qe("{model}:countTokens",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=_E(x),S=new uy;return Object.assign(S,b),S})}else{const m=wE(this.apiClient,t);return g=Qe("{model}:countTokens",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=EE(x),S=new uy;return Object.assign(S,b),S})}}async computeTokens(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI()){const g=gE(this.apiClient,t);return u=Qe("{model}:computeTokens",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=yE(v),x=new $T;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,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=o_(this.apiClient,t);return g=Qe("{model}:predictLongRunning",m._url),v=m._query,delete m._url,delete m._query,p=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()),p.then(x=>{const b=n_(x),S=new Ic;return Object.assign(S,b),S})}else{const m=i_(this.apiClient,t);return g=Qe("{model}:predictLongRunning",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p.then(x=>{const b=t_(x),S=new Ic;return Object.assign(S,b),S})}}}class VN extends Bo{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 u;l&&"httpOptions"in l&&(u=l.httpOptions);const p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:s,config:{httpOptions:u}});return o._fromAPIResponse({apiResponse:p,_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 u;l&&"httpOptions"in l&&(u=l.httpOptions);const p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:s,config:{httpOptions:u}});return o._fromAPIResponse({apiResponse:p,_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,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=LT(t);return g=Qe("{operationName}",m._url),v=m._query,delete m._url,delete m._query,p=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()),p}else{const m=DT(t);return g=Qe("{operationName}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json()),p}}async fetchPredictVideosOperationInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI()){const g=NT(t);return u=Qe("{resourceName}:fetchPredictOperation",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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 $N(e){const t={},o=c(e,["data"]);if(o!=null&&f(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&&f(t,["mimeType"],l),t}function qN(e){const t={},o=c(e,["parts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>tA(u))),f(t,["parts"],s)}const l=c(e,["role"]);return l!=null&&f(t,["role"],l),t}function YN(e,t,o){const l={},s=c(t,["expireTime"]);o!==void 0&&s!=null&&f(o,["expireTime"],s);const u=c(t,["newSessionExpireTime"]);o!==void 0&&u!=null&&f(o,["newSessionExpireTime"],u);const p=c(t,["uses"]);o!==void 0&&p!=null&&f(o,["uses"],p);const g=c(t,["liveConnectConstraints"]);o!==void 0&&g!=null&&f(o,["bidiGenerateContentSetup"],eA(e,g));const v=c(t,["lockAdditionalFields"]);return o!==void 0&&v!=null&&f(o,["fieldMask"],v),l}function JN(e,t){const o={},l=c(t,["config"]);return l!=null&&f(o,["config"],YN(e,l,o)),o}function KN(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&&f(t,["fileUri"],o);const l=c(e,["mimeType"]);return l!=null&&f(t,["mimeType"],l),t}function XN(e){const t={},o=c(e,["id"]);o!=null&&f(t,["id"],o);const l=c(e,["args"]);l!=null&&f(t,["args"],l);const s=c(e,["name"]);if(s!=null&&f(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 WN(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&&f(t,["enableWidget"],o),t}function QN(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&&f(t,["timeRangeFilter"],o),t}function ZN(e,t){const o={},l=c(e,["generationConfig"]);t!==void 0&&l!=null&&f(t,["setup","generationConfig"],l);const s=c(e,["responseModalities"]);t!==void 0&&s!=null&&f(t,["setup","generationConfig","responseModalities"],s);const u=c(e,["temperature"]);t!==void 0&&u!=null&&f(t,["setup","generationConfig","temperature"],u);const p=c(e,["topP"]);t!==void 0&&p!=null&&f(t,["setup","generationConfig","topP"],p);const g=c(e,["topK"]);t!==void 0&&g!=null&&f(t,["setup","generationConfig","topK"],g);const v=c(e,["maxOutputTokens"]);t!==void 0&&v!=null&&f(t,["setup","generationConfig","maxOutputTokens"],v);const m=c(e,["mediaResolution"]);t!==void 0&&m!=null&&f(t,["setup","generationConfig","mediaResolution"],m);const x=c(e,["seed"]);t!==void 0&&x!=null&&f(t,["setup","generationConfig","seed"],x);const b=c(e,["speechConfig"]);t!==void 0&&b!=null&&f(t,["setup","generationConfig","speechConfig"],Zf(b));const S=c(e,["thinkingConfig"]);t!==void 0&&S!=null&&f(t,["setup","generationConfig","thinkingConfig"],S);const A=c(e,["enableAffectiveDialog"]);t!==void 0&&A!=null&&f(t,["setup","generationConfig","enableAffectiveDialog"],A);const E=c(e,["systemInstruction"]);t!==void 0&&E!=null&&f(t,["setup","systemInstruction"],qN(ri(E)));const j=c(e,["tools"]);if(t!==void 0&&j!=null){let be=qa(j);Array.isArray(be)&&(be=be.map(ye=>iA($a(ye)))),f(t,["setup","tools"],be)}const I=c(e,["sessionResumption"]);t!==void 0&&I!=null&&f(t,["setup","sessionResumption"],nA(I));const $=c(e,["inputAudioTranscription"]);t!==void 0&&$!=null&&f(t,["setup","inputAudioTranscription"],$);const oe=c(e,["outputAudioTranscription"]);t!==void 0&&oe!=null&&f(t,["setup","outputAudioTranscription"],oe);const se=c(e,["realtimeInputConfig"]);t!==void 0&&se!=null&&f(t,["setup","realtimeInputConfig"],se);const fe=c(e,["contextWindowCompression"]);t!==void 0&&fe!=null&&f(t,["setup","contextWindowCompression"],fe);const De=c(e,["proactivity"]);if(t!==void 0&&De!=null&&f(t,["setup","proactivity"],De),c(e,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return o}function eA(e,t){const o={},l=c(t,["model"]);l!=null&&f(o,["setup","model"],nn(e,l));const s=c(t,["config"]);return s!=null&&f(o,["config"],ZN(s,o)),o}function tA(e){const t={},o=c(e,["mediaResolution"]);o!=null&&f(t,["mediaResolution"],o);const l=c(e,["codeExecutionResult"]);l!=null&&f(t,["codeExecutionResult"],l);const s=c(e,["executableCode"]);s!=null&&f(t,["executableCode"],s);const u=c(e,["fileData"]);u!=null&&f(t,["fileData"],KN(u));const p=c(e,["functionCall"]);p!=null&&f(t,["functionCall"],XN(p));const g=c(e,["functionResponse"]);g!=null&&f(t,["functionResponse"],g);const v=c(e,["inlineData"]);v!=null&&f(t,["inlineData"],$N(v));const m=c(e,["text"]);m!=null&&f(t,["text"],m);const x=c(e,["thought"]);x!=null&&f(t,["thought"],x);const b=c(e,["thoughtSignature"]);b!=null&&f(t,["thoughtSignature"],b);const S=c(e,["videoMetadata"]);return S!=null&&f(t,["videoMetadata"],S),t}function nA(e){const t={},o=c(e,["handle"]);if(o!=null&&f(t,["handle"],o),c(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function iA(e){const t={},o=c(e,["functionDeclarations"]);if(o!=null){let x=o;Array.isArray(x)&&(x=x.map(b=>b)),f(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&&f(t,["googleSearchRetrieval"],l);const s=c(e,["computerUse"]);s!=null&&f(t,["computerUse"],s);const u=c(e,["fileSearch"]);u!=null&&f(t,["fileSearch"],u);const p=c(e,["codeExecution"]);if(p!=null&&f(t,["codeExecution"],p),c(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=c(e,["googleMaps"]);g!=null&&f(t,["googleMaps"],WN(g));const v=c(e,["googleSearch"]);v!=null&&f(t,["googleSearch"],QN(v));const m=c(e,["urlContext"]);return m!=null&&f(t,["urlContext"],m),t}function oA(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(u=>`${o}.${u}`);t.push(...s)}else t.push(o)}return t.join(",")}function lA(e,t){let o=null;const l=e.bidiGenerateContentSetup;if(typeof l=="object"&&l!==null&&"setup"in l){const u=l.setup;typeof u=="object"&&u!==null?(e.bidiGenerateContentSetup=u,o=u):delete e.bidiGenerateContentSetup}else l!==void 0&&delete e.bidiGenerateContentSetup;const s=e.fieldMask;if(o){const u=oA(o);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)u?e.fieldMask=u:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&s!==null&&Array.isArray(s)&&s.length>0){const p=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];s.length>0&&(g=s.map(m=>p.includes(m)?`generationConfig.${m}`:m));const v=[];u&&v.push(u),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 aA extends Bo{constructor(t){super(),this.apiClient=t}async create(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=JN(this.apiClient,t);u=Qe("auth_tokens",g._url),p=g._query,delete g.config,delete g._url,delete g._query;const v=lA(g,t.config);return s=this.apiClient.request({path:u,queryParams:p,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 sA(e,t){const o={},l=c(e,["force"]);return t!==void 0&&l!=null&&f(t,["_query","force"],l),o}function rA(e){const t={},o=c(e,["name"]);o!=null&&f(t,["_url","name"],o);const l=c(e,["config"]);return l!=null&&sA(l,t),t}function cA(e){const t={},o=c(e,["name"]);return o!=null&&f(t,["_url","name"],o),t}function uA(e,t){const o={},l=c(e,["pageSize"]);t!==void 0&&l!=null&&f(t,["_query","pageSize"],l);const s=c(e,["pageToken"]);return t!==void 0&&s!=null&&f(t,["_query","pageToken"],s),o}function dA(e){const t={},o=c(e,["parent"]);o!=null&&f(t,["_url","parent"],o);const l=c(e,["config"]);return l!=null&&uA(l,t),t}function fA(e){const t={},o=c(e,["sdkHttpResponse"]);o!=null&&f(t,["sdkHttpResponse"],o);const l=c(e,["nextPageToken"]);l!=null&&f(t,["nextPageToken"],l);const s=c(e,["documents"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(p=>p)),f(t,["documents"],u)}return t}class pA extends Bo{constructor(t){super(),this.apiClient=t,this.list=async o=>new Kl(Po.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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=cA(t);return u=Qe("{name}",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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="",u={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const p=rA(t);s=Qe("{name}",p._url),u=p._query,delete p._url,delete p._query,await this.apiClient.request({path:s,queryParams:u,body:JSON.stringify(p),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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=dA(t);return u=Qe("{parent}/documents",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=fA(v),x=new qT;return Object.assign(x,m),x})}}}class hA extends Bo{constructor(t,o=new pA(t)){super(),this.apiClient=t,this.documents=o,this.list=async(l={})=>new Kl(Po.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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=oN(t);return u=Qe("fileSearchStores",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=sN(t);return u=Qe("{name}",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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="",u={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const p=aN(t);s=Qe("{name}",p._url),u=p._query,delete p._url,delete p._query,await this.apiClient.request({path:s,queryParams:u,body:JSON.stringify(p),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,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=pN(t);return u=Qe("fileSearchStores",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=hN(v),x=new YT;return Object.assign(x,m),x})}}async uploadToFileSearchStoreInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=mN(t);return u=Qe("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=gN(v),x=new JT;return Object.assign(x,m),x})}}async importFile(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=uN(t);return u=Qe("{file_search_store_name}:importFile",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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 Jf;return Object.assign(x,m),x})}}}let Av=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return Av=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 mA=()=>Av();function _f(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const Nf=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 qi extends Error{}class hi extends qi{constructor(t,o,l,s){super(`${hi.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 Jc({message:l,cause:Nf(o)});const u=o;return t===400?new kv(t,u,l,s):t===401?new Rv(t,u,l,s):t===403?new Iv(t,u,l,s):t===404?new zv(t,u,l,s):t===409?new Dv(t,u,l,s):t===422?new Lv(t,u,l,s):t===429?new Uv(t,u,l,s):t>=500?new Fv(t,u,l,s):new hi(t,u,l,s)}}class Af extends hi{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class Jc extends hi{constructor({message:t,cause:o}){super(void 0,void 0,t||"Connection error.",void 0),o&&(this.cause=o)}}class Mv extends Jc{constructor({message:t}={}){super({message:t??"Request timed out."})}}class kv extends hi{}class Rv extends hi{}class Iv extends hi{}class zv extends hi{}class Dv extends hi{}class Lv extends hi{}class Uv extends hi{}class Fv extends hi{}const gA=/^[a-z][a-z0-9+.-]*:/i,yA=e=>gA.test(e);let Mf=e=>(Mf=Array.isArray,Mf(e));const vA=Mf;let xA=vA;const Iy=xA;function bA(e){if(!e)return!0;for(const t in e)return!1;return!0}function SA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const TA=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new qi(`${e} must be an integer`);if(t<0)throw new qi(`${e} must be a positive integer`);return t},wA=e=>{try{return JSON.parse(e)}catch{return}};const CA=e=>new Promise(t=>setTimeout(t,e));const za="0.0.1";function EA(){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 _A=()=>{var e,t,o,l,s;const u=EA();if(u==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":za,"X-Stainless-OS":Dy(Deno.build.os),"X-Stainless-Arch":zy(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":za,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(u==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":za,"X-Stainless-OS":Dy((o=globalThis.process.platform)!==null&&o!==void 0?o:"unknown"),"X-Stainless-Arch":zy((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 p=NA();return p?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":za,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${p.browser}`,"X-Stainless-Runtime-Version":p.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":za,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function NA(){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,u=l[2]||0,p=l[3]||0;return{browser:t,version:`${s}.${u}.${p}`}}}return null}const zy=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",Dy=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 dc;const AA=()=>dc??(dc=_A());function MA(){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 Pv(...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 kA(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Pv({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 Bv(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 RA(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 IA=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});const Ov=()=>{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 lf(e,t,o){return Ov(),new File(e,t??"unknown_file",o)}function zA(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 DA=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function";const Hv=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",LA=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&Hv(e),UA=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function FA(e,t,o){if(Ov(),e=await e,LA(e))return e instanceof File?e:lf([await e.arrayBuffer()],e.name);if(UA(e)){const s=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),lf(await kf(s),t,o)}const l=await kf(e);if(t||(t=zA(e)),!o?.type){const s=l.find(u=>typeof u=="object"&&"type"in u&&u.type);typeof s=="string"&&(o=Object.assign(Object.assign({},o),{type:s}))}return lf(l,t,o)}async function kf(e){var t,o,l,s,u;let p=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)p.push(e);else if(Hv(e))p.push(e instanceof Blob?e:await e.arrayBuffer());else if(DA(e))try{for(var g=!0,v=Zi(e),m;m=await v.next(),t=m.done,!t;g=!0){s=m.value,g=!1;const x=s;p.push(...await kf(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=(u=e?.constructor)===null||u===void 0?void 0:u.name;throw new Error(`Unexpected data type: ${typeof e}${x?`; constructor: ${x}`:""}${PA(e)}`)}return p}function PA(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(o=>`"${o}"`).join(", ")}]`}class jv{constructor(t){this._client=t}}jv._key=[];function Gv(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Ly=Object.freeze(Object.create(null)),BA=(e=Gv)=>(function(o,...l){if(o.length===1)return o[0];let s=!1;const u=[],p=o.reduce((x,b,S)=>{var A,E,j;/[?#]/.test(b)&&(s=!0);const I=l[S];let $=(s?encodeURIComponent:e)(""+I);return S!==l.length&&(I==null||typeof I=="object"&&I.toString===((j=Object.getPrototypeOf((E=Object.getPrototypeOf((A=I.hasOwnProperty)!==null&&A!==void 0?A:Ly))!==null&&E!==void 0?E:Ly))===null||j===void 0?void 0:j.toString))&&($=I+"",u.push({start:x.length+b.length,length:$.length,error:`Value of type ${Object.prototype.toString.call(I).slice(8,-1)} is not a valid path parameter`})),x+b+(S===l.length?"":$)},""),g=p.split(/[?#]/,1)[0],v=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let m;for(;(m=v.exec(g))!==null;)u.push({start:m.index,length:m[0].length,error:`Value "${m[0]}" can't be safely passed as a path parameter`});if(u.sort((x,b)=>x.start-b.start),u.length>0){let x=0;const b=u.reduce((S,A)=>{const E=" ".repeat(A.start-x),j="^".repeat(A.length);return x=A.start+A.length,S+E+j},"");throw new qi(`Path parameters result in path with invalid segments: +${u.map(S=>S.error).join(` +`)} +${p} +${b}`)}return p}),fc=BA(Gv);class Vv extends jv{create(t,o){var l;const{api_version:s=this._client.apiVersion}=t,u=Dc(t,["api_version"]);if("model"in u&&"agent_config"in u)throw new qi("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in u&&"generation_config"in u)throw new qi("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(fc`/${s}/interactions`,Object.assign(Object.assign({body:u},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(fc`/${s}/interactions/${t}`,l)}cancel(t,o={},l){const{api_version:s=this._client.apiVersion}=o??{};return this._client.post(fc`/${s}/interactions/${t}/cancel`,l)}get(t,o={},l){var s;const u=o??{},{api_version:p=this._client.apiVersion}=u,g=Dc(u,["api_version"]);return this._client.get(fc`/${p}/interactions/${t}`,Object.assign(Object.assign({query:g},l),{stream:(s=o?.stream)!==null&&s!==void 0?s:!1}))}}Vv._key=Object.freeze(["interactions"]);class $v extends Vv{}function OA(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 pc;function tp(e){let t;return(pc??(t=new globalThis.TextEncoder,pc=t.encode.bind(t)))(e)}let hc;function Uy(e){let t;return(hc??(t=new globalThis.TextDecoder,hc=t.decode.bind(t)))(e)}class Kc{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"?tp(t):t;this.buffer=OA([this.buffer,o]);const l=[];let s;for(;(s=HA(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(Uy(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const u=this.carriageReturnIndex!==null?s.preceding-1:s.preceding,p=Uy(this.buffer.subarray(0,u));l.push(p),this.buffer=this.buffer.subarray(s.index),this.carriageReturnIndex=null}return l}flush(){return this.buffer.length?this.decode(` +`):[]}}Kc.NEWLINE_CHARS=new Set([` +`,"\r"]);Kc.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function HA(e,t){for(let s=t??0;s{if(e){if(SA(Lc,e))return e;pi(o).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Lc))}`)}};function js(){}function mc(e,t,o){return!t||Lc[e]>Lc[o]?js:t[e].bind(t)}const GA={error:js,warn:js,info:js,debug:js};let Py=new WeakMap;function pi(e){var t;const o=e.logger,l=(t=e.logLevel)!==null&&t!==void 0?t:"off";if(!o)return GA;const s=Py.get(o);if(s&&s[0]===l)return s[1];const u={error:mc("error",o,l),warn:mc("warn",o,l),info:mc("info",o,l),debug:mc("debug",o,l)};return Py.set(o,[l,u]),u}const Ol=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 Fa{constructor(t,o,l){this.iterator=t,this.controller=o,this.client=l}static fromSSEResponse(t,o,l){let s=!1;const u=l?pi(l):console;function p(){return Qi(this,arguments,function*(){var v,m,x,b;if(s)throw new qi("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let S=!1;try{try{for(var A=!0,E=Zi(VA(t,o)),j;j=yield kt(E.next()),v=j.done,!v;A=!0){b=j.value,A=!1;const I=b;if(!S)if(I.data.startsWith("[DONE]")){S=!0;continue}else try{yield yield kt(JSON.parse(I.data))}catch($){throw u.error("Could not parse message into JSON:",I.data),u.error("From chunk:",I.raw),$}}}catch(I){m={error:I}}finally{try{!A&&!v&&(x=E.return)&&(yield kt(x.call(E)))}finally{if(m)throw m.error}}S=!0}catch(I){if(_f(I))return yield kt(void 0);throw I}finally{S||o.abort()}})}return new Fa(p,o,l)}static fromReadableStream(t,o,l){let s=!1;function u(){return Qi(this,arguments,function*(){var v,m,x,b;const S=new Kc,A=Bv(t);try{for(var E=!0,j=Zi(A),I;I=yield kt(j.next()),v=I.done,!v;E=!0){b=I.value,E=!1;const $=b;for(const oe of S.decode($))yield yield kt(oe)}}catch($){m={error:$}}finally{try{!E&&!v&&(x=j.return)&&(yield kt(x.call(j)))}finally{if(m)throw m.error}}for(const $ of S.flush())yield yield kt($)})}function p(){return Qi(this,arguments,function*(){var v,m,x,b;if(s)throw new qi("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let S=!1;try{try{for(var A=!0,E=Zi(u()),j;j=yield kt(E.next()),v=j.done,!v;A=!0){b=j.value,A=!1;const I=b;S||I&&(yield yield kt(JSON.parse(I)))}}catch(I){m={error:I}}finally{try{!A&&!v&&(x=E.return)&&(yield kt(x.call(E)))}finally{if(m)throw m.error}}S=!0}catch(I){if(_f(I))return yield kt(void 0);throw I}finally{S||o.abort()}})}return new Fa(p,o,l)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],o=[],l=this.iterator(),s=u=>({next:()=>{if(u.length===0){const p=l.next();t.push(p),o.push(p)}return u.shift()}});return[new Fa(()=>s(t),this.controller,this.client),new Fa(()=>s(o),this.controller,this.client)]}toReadableStream(){const t=this;let o;return Pv({async start(){o=t[Symbol.asyncIterator]()},async pull(l){try{const{value:s,done:u}=await o.next();if(u)return l.close();const p=tp(JSON.stringify(s)+` +`);l.enqueue(p)}catch(s){l.error(s)}},async cancel(){var l;await((l=o.return)===null||l===void 0?void 0:l.call(o))}})}}function VA(e,t){return Qi(this,arguments,function*(){var l,s,u,p;if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new qi("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 qi("Attempted to iterate over a response with no body");const g=new qA,v=new Kc,m=Bv(e.body);try{for(var x=!0,b=Zi($A(m)),S;S=yield kt(b.next()),l=S.done,!l;x=!0){p=S.value,x=!1;const A=p;for(const E of v.decode(A)){const j=g.decode(E);j&&(yield yield kt(j))}}}catch(A){s={error:A}}finally{try{!x&&!l&&(u=b.return)&&(yield kt(u.call(b)))}finally{if(s)throw s.error}}for(const A of v.flush()){const E=g.decode(A);E&&(yield yield kt(E))}})}function $A(e){return Qi(this,arguments,function*(){var o,l,s,u;let p=new Uint8Array;try{for(var g=!0,v=Zi(e),m;m=yield kt(v.next()),o=m.done,!o;g=!0){u=m.value,g=!1;const x=u;if(x==null)continue;const b=x instanceof ArrayBuffer?new Uint8Array(x):typeof x=="string"?tp(x):x;let S=new Uint8Array(p.length+b.length);S.set(p),S.set(b,p.length),p=S;let A;for(;(A=jA(p))!==-1;)yield yield kt(p.slice(0,A)),p=p.slice(A)}}catch(x){l={error:x}}finally{try{!g&&!o&&(s=v.return)&&(yield kt(s.call(v)))}finally{if(l)throw l.error}}p.length>0&&(yield yield kt(p))})}class qA{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 u={event:this.event,data:this.data.join(` +`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],u}if(this.chunks.push(t),t.startsWith(":"))return null;let[o,l,s]=YA(t,":");return s.startsWith(" ")&&(s=s.substring(1)),o==="event"?this.event=s:o==="data"&&this.data.push(s),null}}function YA(e,t){const o=e.indexOf(t);return o!==-1?[e.substring(0,o),t,e.substring(o+t.length)]:[e,"",""]}async function JA(e,t){const{response:o,requestLogID:l,retryOfRequestLogID:s,startTime:u}=t,p=await(async()=>{var g;if(t.options.stream)return pi(e).debug("response",o.status,o.url,o.headers,o.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(o,t.controller,e):Fa.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 pi(e).debug(`[${l}] response parsed`,Ol({retryOfRequestLogID:s,url:o.url,status:o.status,body:p,durationMs:Date.now()-u})),p}class np extends Promise{constructor(t,o,l=JA){super(s=>{s(null)}),this.responsePromise=o,this.parseResponse=l,this.client=t}_thenUnwrap(t){return new np(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 qv=Symbol("brand.privateNullableHeaders");function*KA(e){if(!e)return;if(qv in e){const{values:l,nulls:s}=e;yield*l.entries();for(const u of s)yield[u,null];return}let t=!1,o;e instanceof Headers?o=e.entries():Iy(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 u=Iy(l[1])?l[1]:[l[1]];let p=!1;for(const g of u)g!==void 0&&(t&&!p&&(p=!0,yield[s,null]),yield[s,g])}}const Us=e=>{const t=new Headers,o=new Set;for(const l of e){const s=new Set;for(const[u,p]of KA(l)){const g=u.toLowerCase();s.has(g)||(t.delete(u),s.add(g)),p===null?(t.delete(u),o.add(g)):(t.append(u,p),o.delete(g))}}return{[qv]:!0,values:t,nulls:o}};const af=e=>{var t,o,l,s,u,p;if(typeof globalThis.process<"u")return(l=(o=(t=ST)===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(p=(u=(s=globalThis.Deno.env)===null||s===void 0?void 0:s.get)===null||u===void 0?void 0:u.call(s,e))===null||p===void 0?void 0:p.trim()};var Yv;class Xc{constructor(t){var o,l,s,u,p,g,v,{baseURL:m=af("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:x=(o=af("GEMINI_API_KEY"))!==null&&o!==void 0?o:null,apiVersion:b="v1beta"}=t,S=Dc(t,["baseURL","apiKey","apiVersion"]);const A=Object.assign(Object.assign({apiKey:x,apiVersion:b},S),{baseURL:m||"https://generativelanguage.googleapis.com"});this.baseURL=A.baseURL,this.timeout=(l=A.timeout)!==null&&l!==void 0?l:Xc.DEFAULT_TIMEOUT,this.logger=(s=A.logger)!==null&&s!==void 0?s:console;const E="warn";this.logLevel=E,this.logLevel=(p=(u=Fy(A.logLevel,"ClientOptions.logLevel",this))!==null&&u!==void 0?u:Fy(af("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&p!==void 0?p:E,this.fetchOptions=A.fetchOptions,this.maxRetries=(g=A.maxRetries)!==null&&g!==void 0?g:2,this.fetch=(v=A.fetch)!==null&&v!==void 0?v:MA(),this.encoder=IA,this._options=A,this.apiKey=x,this.apiVersion=b,this.clientAdapter=A.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=Us([t.headers]);if(!(o.values.has("authorization")||o.values.has("x-goog-api-key"))){if(this.apiKey)return Us([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Us([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 qi(`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 ${za}`}defaultIdempotencyKey(){return`stainless-node-retry-${mA()}`}makeStatusError(t,o,l,s){return hi.generate(t,o,l,s)}buildURL(t,o,l){const s=!this.baseURLOverridden()&&l||this.baseURL,u=yA(t)?new URL(t):new URL(s+(s.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),p=this.defaultQuery();return bA(p)||(o=Object.assign(Object.assign({},p),o)),typeof o=="object"&&o&&!Array.isArray(o)&&(u.search=this.stringifyQuery(o)),u.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 np(this,this.makeRequest(t,o,void 0))}async makeRequest(t,o,l){var s,u,p;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"),A=l===void 0?"":`, retryOf: ${l}`,E=Date.now();if(pi(this).debug(`[${S}] sending request`,Ol({retryOfRequestLogID:l,method:g.method,url:x,options:g,headers:m.headers})),!((u=g.signal)===null||u===void 0)&&u.aborted)throw new Af;const j=new AbortController,I=await this.fetchWithTimeout(x,m,b,j).catch(Nf),$=Date.now();if(I instanceof globalThis.Error){const se=`retrying, ${o} attempts remaining`;if(!((p=g.signal)===null||p===void 0)&&p.aborted)throw new Af;const fe=_f(I)||/timed? ?out/i.test(String(I)+("cause"in I?String(I.cause):""));if(o)return pi(this).info(`[${S}] connection ${fe?"timed out":"failed"} - ${se}`),pi(this).debug(`[${S}] connection ${fe?"timed out":"failed"} (${se})`,Ol({retryOfRequestLogID:l,url:x,durationMs:$-E,message:I.message})),this.retryRequest(g,o,l??S);throw pi(this).info(`[${S}] connection ${fe?"timed out":"failed"} - error; no more retries left`),pi(this).debug(`[${S}] connection ${fe?"timed out":"failed"} (error; no more retries left)`,Ol({retryOfRequestLogID:l,url:x,durationMs:$-E,message:I.message})),fe?new Mv:new Jc({cause:I})}const oe=`[${S}${A}] ${m.method} ${x} ${I.ok?"succeeded":"failed"} with status ${I.status} in ${$-E}ms`;if(!I.ok){const se=await this.shouldRetry(I);if(o&&se){const Ne=`retrying, ${o} attempts remaining`;return await RA(I.body),pi(this).info(`${oe} - ${Ne}`),pi(this).debug(`[${S}] response error (${Ne})`,Ol({retryOfRequestLogID:l,url:I.url,status:I.status,headers:I.headers,durationMs:$-E})),this.retryRequest(g,o,l??S,I.headers)}const fe=se?"error; no more retries left":"error; not retryable";pi(this).info(`${oe} - ${fe}`);const De=await I.text().catch(Ne=>Nf(Ne).message),be=wA(De),ye=be?void 0:De;throw pi(this).debug(`[${S}] response error (${fe})`,Ol({retryOfRequestLogID:l,url:I.url,status:I.status,headers:I.headers,message:ye,durationMs:Date.now()-E})),this.makeStatusError(I.status,be,ye,I.headers)}return pi(this).info(oe),pi(this).debug(`[${S}] response start`,Ol({retryOfRequestLogID:l,url:I.url,status:I.status,headers:I.headers,durationMs:$-E})),{response:I,options:g,controller:j,requestLogID:S,retryOfRequestLogID:l,startTime:E}}async fetchWithTimeout(t,o,l,s){const u=o||{},{signal:p,method:g}=u,v=Dc(u,["signal","method"]);p&&p.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 u;let p;const g=s?.get("retry-after-ms");if(g){const m=parseFloat(g);Number.isNaN(m)||(p=m)}const v=s?.get("retry-after");if(v&&!p){const m=parseFloat(v);Number.isNaN(m)?p=Date.parse(v)-Date.now():p=m*1e3}if(!(p&&0<=p&&p<60*1e3)){const m=(u=t.maxRetries)!==null&&u!==void 0?u:this.maxRetries;p=this.calculateDefaultRetryTimeoutMillis(o,m)}return await CA(p),this.makeRequest(t,o-1,l)}calculateDefaultRetryTimeoutMillis(t,o){const u=o-t,p=Math.min(.5*Math.pow(2,u),8),g=1-Math.random()*.25;return p*g*1e3}async buildRequest(t,{retryCount:o=0}={}){var l,s,u;const p=Object.assign({},t),{method:g,path:v,query:m,defaultBaseURL:x}=p,b=this.buildURL(v,m,x);"timeout"in p&&TA("timeout",p.timeout),p.timeout=(l=p.timeout)!==null&&l!==void 0?l:this.timeout;const{bodyHeaders:S,body:A}=this.buildBody({options:p}),E=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:E},p.signal&&{signal:p.signal}),globalThis.ReadableStream&&A instanceof globalThis.ReadableStream&&{duplex:"half"}),A&&{body:A}),(s=this.fetchOptions)!==null&&s!==void 0?s:{}),(u=p.fetchOptions)!==null&&u!==void 0?u:{}),url:b,timeout:p.timeout}}async buildHeaders({options:t,method:o,bodyHeaders:l,retryCount:s}){let u={};this.idempotencyHeader&&o!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),u[this.idempotencyHeader]=t.idempotencyKey);const p=await this.authHeaders(t);let g=Us([u,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))}:{}),AA()),this._options.defaultHeaders,l,t.headers,p]);return this.validateHeaders(g),g.values}buildBody({options:{body:t,headers:o}}){if(!t)return{bodyHeaders:void 0,body:void 0};const l=Us([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:kA(t)}:this.encoder({body:t,headers:l})}}Xc.DEFAULT_TIMEOUT=6e4;class Xn extends Xc{constructor(){super(...arguments),this.interactions=new $v(this)}}Yv=Xn;Xn.GeminiNextGenAPIClient=Yv;Xn.GeminiNextGenAPIClientError=qi;Xn.APIError=hi;Xn.APIConnectionError=Jc;Xn.APIConnectionTimeoutError=Mv;Xn.APIUserAbortError=Af;Xn.NotFoundError=zv;Xn.ConflictError=Dv;Xn.RateLimitError=Uv;Xn.BadRequestError=kv;Xn.AuthenticationError=Rv;Xn.InternalServerError=Fv;Xn.PermissionDeniedError=Iv;Xn.UnprocessableEntityError=Lv;Xn.toFile=FA;Xn.Interactions=$v;function XA(e,t){const o={},l=c(e,["name"]);return l!=null&&f(o,["_url","name"],l),o}function WA(e,t){const o={},l=c(e,["name"]);return l!=null&&f(o,["_url","name"],l),o}function QA(e,t){const o={},l=c(e,["sdkHttpResponse"]);return l!=null&&f(o,["sdkHttpResponse"],l),o}function ZA(e,t){const o={},l=c(e,["sdkHttpResponse"]);return l!=null&&f(o,["sdkHttpResponse"],l),o}function eM(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&&f(t,["displayName"],s),c(e,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const u=c(e,["epochCount"]);t!==void 0&&u!=null&&f(t,["tuningTask","hyperparameters","epochCount"],u);const p=c(e,["learningRateMultiplier"]);if(p!=null&&f(l,["tuningTask","hyperparameters","learningRateMultiplier"],p),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&&f(t,["tuningTask","hyperparameters","batchSize"],g);const v=c(e,["learningRate"]);if(t!==void 0&&v!=null&&f(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 tM(e,t,o){const l={};let s=c(o,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const A=c(e,["validationDataset"]);t!==void 0&&A!=null&&f(t,["supervisedTuningSpec"],By(A))}else if(s==="PREFERENCE_TUNING"){const A=c(e,["validationDataset"]);t!==void 0&&A!=null&&f(t,["preferenceOptimizationSpec"],By(A))}const u=c(e,["tunedModelDisplayName"]);t!==void 0&&u!=null&&f(t,["tunedModelDisplayName"],u);const p=c(e,["description"]);t!==void 0&&p!=null&&f(t,["description"],p);let g=c(o,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const A=c(e,["epochCount"]);t!==void 0&&A!=null&&f(t,["supervisedTuningSpec","hyperParameters","epochCount"],A)}else if(g==="PREFERENCE_TUNING"){const A=c(e,["epochCount"]);t!==void 0&&A!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],A)}let v=c(o,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const A=c(e,["learningRateMultiplier"]);t!==void 0&&A!=null&&f(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],A)}else if(v==="PREFERENCE_TUNING"){const A=c(e,["learningRateMultiplier"]);t!==void 0&&A!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],A)}let m=c(o,["config","method"]);if(m===void 0&&(m="SUPERVISED_FINE_TUNING"),m==="SUPERVISED_FINE_TUNING"){const A=c(e,["exportLastCheckpointOnly"]);t!==void 0&&A!=null&&f(t,["supervisedTuningSpec","exportLastCheckpointOnly"],A)}else if(m==="PREFERENCE_TUNING"){const A=c(e,["exportLastCheckpointOnly"]);t!==void 0&&A!=null&&f(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],A)}let x=c(o,["config","method"]);if(x===void 0&&(x="SUPERVISED_FINE_TUNING"),x==="SUPERVISED_FINE_TUNING"){const A=c(e,["adapterSize"]);t!==void 0&&A!=null&&f(t,["supervisedTuningSpec","hyperParameters","adapterSize"],A)}else if(x==="PREFERENCE_TUNING"){const A=c(e,["adapterSize"]);t!==void 0&&A!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],A)}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&&f(t,["labels"],b);const S=c(e,["beta"]);return t!==void 0&&S!=null&&f(t,["preferenceOptimizationSpec","hyperParameters","beta"],S),l}function nM(e,t){const o={},l=c(e,["baseModel"]);l!=null&&f(o,["baseModel"],l);const s=c(e,["preTunedModel"]);s!=null&&f(o,["preTunedModel"],s);const u=c(e,["trainingDataset"]);u!=null&&pM(u);const p=c(e,["config"]);return p!=null&&eM(p,o),o}function iM(e,t){const o={},l=c(e,["baseModel"]);l!=null&&f(o,["baseModel"],l);const s=c(e,["preTunedModel"]);s!=null&&f(o,["preTunedModel"],s);const u=c(e,["trainingDataset"]);u!=null&&hM(u,o,t);const p=c(e,["config"]);return p!=null&&tM(p,o,t),o}function oM(e,t){const o={},l=c(e,["name"]);return l!=null&&f(o,["_url","name"],l),o}function lM(e,t){const o={},l=c(e,["name"]);return l!=null&&f(o,["_url","name"],l),o}function aM(e,t,o){const l={},s=c(e,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const u=c(e,["pageToken"]);t!==void 0&&u!=null&&f(t,["_query","pageToken"],u);const p=c(e,["filter"]);return t!==void 0&&p!=null&&f(t,["_query","filter"],p),l}function sM(e,t,o){const l={},s=c(e,["pageSize"]);t!==void 0&&s!=null&&f(t,["_query","pageSize"],s);const u=c(e,["pageToken"]);t!==void 0&&u!=null&&f(t,["_query","pageToken"],u);const p=c(e,["filter"]);return t!==void 0&&p!=null&&f(t,["_query","filter"],p),l}function rM(e,t){const o={},l=c(e,["config"]);return l!=null&&aM(l,o),o}function cM(e,t){const o={},l=c(e,["config"]);return l!=null&&sM(l,o),o}function uM(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&f(o,["sdkHttpResponse"],l);const s=c(e,["nextPageToken"]);s!=null&&f(o,["nextPageToken"],s);const u=c(e,["tunedModels"]);if(u!=null){let p=u;Array.isArray(p)&&(p=p.map(g=>Jv(g))),f(o,["tuningJobs"],p)}return o}function dM(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&f(o,["sdkHttpResponse"],l);const s=c(e,["nextPageToken"]);s!=null&&f(o,["nextPageToken"],s);const u=c(e,["tuningJobs"]);if(u!=null){let p=u;Array.isArray(p)&&(p=p.map(g=>Rf(g))),f(o,["tuningJobs"],p)}return o}function fM(e,t){const o={},l=c(e,["name"]);l!=null&&f(o,["model"],l);const s=c(e,["name"]);return s!=null&&f(o,["endpoint"],s),o}function pM(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(u=>u)),f(o,["examples","examples"],s)}return o}function hM(e,t,o){const l={};let s=c(o,["config","method"]);if(s===void 0&&(s="SUPERVISED_FINE_TUNING"),s==="SUPERVISED_FINE_TUNING"){const p=c(e,["gcsUri"]);t!==void 0&&p!=null&&f(t,["supervisedTuningSpec","trainingDatasetUri"],p)}else if(s==="PREFERENCE_TUNING"){const p=c(e,["gcsUri"]);t!==void 0&&p!=null&&f(t,["preferenceOptimizationSpec","trainingDatasetUri"],p)}let u=c(o,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const p=c(e,["vertexDatasetResource"]);t!==void 0&&p!=null&&f(t,["supervisedTuningSpec","trainingDatasetUri"],p)}else if(u==="PREFERENCE_TUNING"){const p=c(e,["vertexDatasetResource"]);t!==void 0&&p!=null&&f(t,["preferenceOptimizationSpec","trainingDatasetUri"],p)}if(c(e,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return l}function Jv(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&f(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&f(o,["name"],s);const u=c(e,["state"]);u!=null&&f(o,["state"],uv(u));const p=c(e,["createTime"]);p!=null&&f(o,["createTime"],p);const g=c(e,["tuningTask","startTime"]);g!=null&&f(o,["startTime"],g);const v=c(e,["tuningTask","completeTime"]);v!=null&&f(o,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&f(o,["updateTime"],m);const x=c(e,["description"]);x!=null&&f(o,["description"],x);const b=c(e,["baseModel"]);b!=null&&f(o,["baseModel"],b);const S=c(e,["_self"]);return S!=null&&f(o,["tunedModel"],fM(S)),o}function Rf(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&f(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&f(o,["name"],s);const u=c(e,["state"]);u!=null&&f(o,["state"],uv(u));const p=c(e,["createTime"]);p!=null&&f(o,["createTime"],p);const g=c(e,["startTime"]);g!=null&&f(o,["startTime"],g);const v=c(e,["endTime"]);v!=null&&f(o,["endTime"],v);const m=c(e,["updateTime"]);m!=null&&f(o,["updateTime"],m);const x=c(e,["error"]);x!=null&&f(o,["error"],x);const b=c(e,["description"]);b!=null&&f(o,["description"],b);const S=c(e,["baseModel"]);S!=null&&f(o,["baseModel"],S);const A=c(e,["tunedModel"]);A!=null&&f(o,["tunedModel"],A);const E=c(e,["preTunedModel"]);E!=null&&f(o,["preTunedModel"],E);const j=c(e,["supervisedTuningSpec"]);j!=null&&f(o,["supervisedTuningSpec"],j);const I=c(e,["preferenceOptimizationSpec"]);I!=null&&f(o,["preferenceOptimizationSpec"],I);const $=c(e,["tuningDataStats"]);$!=null&&f(o,["tuningDataStats"],$);const oe=c(e,["encryptionSpec"]);oe!=null&&f(o,["encryptionSpec"],oe);const se=c(e,["partnerModelTuningSpec"]);se!=null&&f(o,["partnerModelTuningSpec"],se);const fe=c(e,["customBaseModel"]);fe!=null&&f(o,["customBaseModel"],fe);const De=c(e,["experiment"]);De!=null&&f(o,["experiment"],De);const be=c(e,["labels"]);be!=null&&f(o,["labels"],be);const ye=c(e,["outputUri"]);ye!=null&&f(o,["outputUri"],ye);const tt=c(e,["pipelineJob"]);tt!=null&&f(o,["pipelineJob"],tt);const Ne=c(e,["serviceAccount"]);Ne!=null&&f(o,["serviceAccount"],Ne);const Xe=c(e,["tunedModelDisplayName"]);Xe!=null&&f(o,["tunedModelDisplayName"],Xe);const $e=c(e,["veoTuningSpec"]);return $e!=null&&f(o,["veoTuningSpec"],$e),o}function mM(e,t){const o={},l=c(e,["sdkHttpResponse"]);l!=null&&f(o,["sdkHttpResponse"],l);const s=c(e,["name"]);s!=null&&f(o,["name"],s);const u=c(e,["metadata"]);u!=null&&f(o,["metadata"],u);const p=c(e,["done"]);p!=null&&f(o,["done"],p);const g=c(e,["error"]);return g!=null&&f(o,["error"],g),o}function By(e,t){const o={},l=c(e,["gcsUri"]);l!=null&&f(o,["validationDatasetUri"],l);const s=c(e,["vertexDatasetResource"]);return s!=null&&f(o,["validationDatasetUri"],s),o}class gM extends Bo{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Kl(Po.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 u=Object.assign(Object.assign({},o),{preTunedModel:s});return u.baseModel=void 0,await this.tuneInternal(u)}else{const s=Object.assign({},o);return await this.tuneInternal(s)}else{const s=Object.assign({},o),u=await this.tuneMldevInternal(s);let p="";return u.metadata!==void 0&&u.metadata.tunedModel!==void 0?p=u.metadata.tunedModel:u.name!==void 0&&u.name.includes("/operations/")&&(p=u.name.split("/operations/")[0]),{name:p,state:xf.JOB_STATE_QUEUED}}}}async getInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=lM(t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>Rf(x))}else{const m=oM(t);return g=Qe("{name}",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>Jv(x))}}async listInternal(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=cM(t);return g=Qe("tuningJobs",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=dM(x),S=new dy;return Object.assign(S,b),S})}else{const m=rM(t);return g=Qe("tunedModels",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=uM(x),S=new dy;return Object.assign(S,b),S})}}async cancel(t){var o,l,s,u;let p,g="",v={};if(this.apiClient.isVertexAI()){const m=WA(t);return g=Qe("{name}:cancel",m._url),v=m._query,delete m._url,delete m._query,p=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})),p.then(x=>{const b=ZA(x),S=new fy;return Object.assign(S,b),S})}else{const m=XA(t);return g=Qe("{name}:cancel",m._url),v=m._query,delete m._url,delete m._query,p=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:(u=t.config)===null||u===void 0?void 0:u.abortSignal}).then(x=>x.json().then(b=>{const S=b;return S.sdkHttpResponse={headers:x.headers},S})),p.then(x=>{const b=QA(x),S=new fy;return Object.assign(S,b),S})}}async tuneInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI()){const g=iM(t,t);return u=Qe("tuningJobs",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=>Rf(v))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var o,l;let s,u="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=nM(t);return u=Qe("tunedModels",g._url),p=g._query,delete g._url,delete g._query,s=this.apiClient.request({path:u,queryParams:p,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=>mM(v))}}}class yM{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 vM=1024*1024*8,xM=3,bM=1e3,SM=2,Uc="x-goog-upload-status";async function TM(e,t,o){var l;const s=await Kv(e,t,o),u=await s?.json();if(((l=s?.headers)===null||l===void 0?void 0:l[Uc])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return u.file}async function wM(e,t,o){var l;const s=await Kv(e,t,o),u=await s?.json();if(((l=s?.headers)===null||l===void 0?void 0:l[Uc])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const p=ov(u),g=new Kf;return Object.assign(g,p),g}async function Kv(e,t,o){var l,s;let u=0,p=0,g=new bf(new Response),v="upload";for(u=e.size;p=u&&(v+=", finalize");let b=0,S=bM;for(;bsetTimeout(t,e))}class _M{async upload(t,o,l){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await TM(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 wM(t,o,l)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await CM(t)}}class NM{create(t,o,l){return new AM(t,o,l)}}class AM{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 Oy="x-goog-api-key";class MM{constructor(t){this.apiKey=t}async addAuthHeaders(t,o){if(t.get(Oy)===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(Oy,this.apiKey)}}}const kM="gl-node/";class RM{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 Xn({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=ET(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 MM(this.apiKey);this.apiClient=new CN({auth:s,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:kM+"web",uploader:new _M,downloader:new yM}),this.models=new GN(this.apiClient),this.live=new FN(this.apiClient,s,new NM),this.batches=new eC(this.apiClient),this.chats=new LC(this.models,this.apiClient),this.caches=new IC(this.apiClient),this.files=new $C(this.apiClient),this.operations=new VN(this.apiClient),this.authTokens=new aA(this.apiClient),this.tunings=new gM(this.apiClient),this.fileSearchStores=new hA(this.apiClient)}}const IM=e=>new RM({apiKey:e}),zM={type:Cn.OBJECT,properties:{segments:{type:Cn.ARRAY,items:{type:Cn.OBJECT,properties:{startTime:{type:Cn.STRING,description:"Absolute timestamp in MM:SS.mmm format (e.g. '01:05.300'). Cumulative from start."},endTime:{type:Cn.STRING,description:"Absolute timestamp in MM:SS.mmm format."},text:{type:Cn.STRING,description:"Transcribed text. Exact words spoken. No hallucinations. Must include every single word."}},required:["startTime","endTime","text"]}}},required:["segments"]},DM={type:Cn.OBJECT,properties:{segments:{type:Cn.ARRAY,items:{type:Cn.OBJECT,properties:{startTime:{type:Cn.STRING},endTime:{type:Cn.STRING},text:{type:Cn.STRING},words:{type:Cn.ARRAY,items:{type:Cn.OBJECT,properties:{text:{type:Cn.STRING,description:"The single word, or character (for Chinese), or linguistic unit."},startTime:{type:Cn.STRING,description:"Start time of the word"},endTime:{type:Cn.STRING,description:"End time of the word"}},required:["text","startTime","endTime"]}}},required:["startTime","endTime","text","words"]}}},required:["segments"]};function gc(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 p=t.split(":");if(p.length===3){const g=parseInt(p[0],10)||0,v=parseInt(p[1],10)||0,m=p[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(p.length===2){const g=parseInt(p[0],10)||0,v=p[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),u=Math.round(o%1*1e3);return`${String(l).padStart(2,"0")}:${String(s).padStart(2,"0")}.${String(u).padStart(3,"0")}`}function LM(e){const t=e.trim();try{const p=JSON.parse(t);if(p.segments&&Array.isArray(p.segments))return p;if(Array.isArray(p))return{segments:p}}catch{}const o=t.lastIndexOf("}");if(o!==-1){const p=["]}","}","]}"];for(const v of p)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 u;for(;(u=s.exec(t))!==null;){const p=u[3]!==void 0?u[3]:u[4];let g=p;try{g=JSON.parse(`"${p.replace(/"/g,'\\"')}"`)}catch{g=p.replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}l.push({startTime:u[1],endTime:u[2],text:g})}if(l.length>0)return{segments:l};throw new Error("Response structure invalid and could not be repaired.")}async function UM(e,t,o,l,s,u="line"){try{const p=IM(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="";u==="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: ${u.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:u==="word"?DM:zM,temperature:.1};g&&(b.thinkingConfig={thinkingBudget:1024});const S=new Promise(($,oe)=>{s?.aborted&&oe(new DOMException("Aborted","AbortError")),s?.addEventListener("abort",()=>oe(new DOMException("Aborted","AbortError")))});let E=(await Promise.race([p.models.generateContent({model:e,contents:[{parts:[{inlineData:{data:t,mimeType:o}},{text:x}]}],config:b}),S])).text;if(!E)throw new Error("Empty response from model");return E=E.trim(),E.startsWith("```json")?E=E.replace(/^```json\s*/,"").replace(/\s*```$/,""):E.startsWith("```")&&(E=E.replace(/^```\s*/,"").replace(/\s*```$/,"")),(LM(E).segments||[]).map($=>({startTime:gc(String($.startTime)),endTime:gc(String($.endTime)),text:String($.text),words:$.words?$.words.map(oe=>({text:String(oe.text),startTime:gc(String(oe.startTime)),endTime:gc(String(oe.endTime))})):void 0}))}catch(p){throw p.name==="AbortError"?p:(console.error(`Error with ${e}:`,p),new Error(p.message||"Transcription failed"))}}const FM=({playlist:e,setPlaylist:t,currentTrackIndex:o,setCurrentTrackIndex:l,onPlayTrack:s,isPlaying:u,onTogglePlay:p,onSeek:g,onClearPlaylist:v,onRemoveTrack:m,currentTime:x,onClose:b})=>{const{confirm:S}=er(),A=Q.useRef(null),E=Q.useRef(new Map),j=U=>{const Z=Math.floor(U/60).toString().padStart(2,"0"),ce=(U%60).toFixed(2).padStart(5,"0");return`[${Z}:${ce}]`},[I,$]=Q.useState(null),[oe,se]=Q.useState({key:null,direction:"asc"}),[fe,De]=Q.useState(new Set),[be,ye]=Q.useState(new Set),[tt,Ne]=Q.useState(localStorage.getItem("gemini_api_key")||""),[Xe,$e]=Q.useState("gemini-2.5-flash"),[Ze,gt]=Q.useState("line"),[xt,Nt]=Q.useState(!1),G=Q.useRef(null),[Ee,ie]=Q.useState(null);Q.useEffect(()=>{tt&&localStorage.setItem("gemini_api_key",tt)},[tt]);const Ye=o>=0?e[o]:null,ut=Ye?.parsedLyrics||[],L=Q.useMemo(()=>Ye?ut.findIndex((U,Z)=>{if(U.endTime!==void 0)return x>=U.time&&x=U.time&&(!ce||x{if(L!==-1){const U=document.getElementById(`lyric-active-${o}`);U&&U.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})}},[L,o]);const le=U=>{if(e.length===0)return;const Z=o>=0?e[o]:null,ce=[...e];let Ae="asc";if(U==="random"){se({key:"random",direction:"asc"});for(let ve=ce.length-1;ve>0;ve--){const Me=Math.floor(Math.random()*(ve+1));[ce[ve],ce[Me]]=[ce[Me],ce[ve]]}}else{oe.key===U&&oe.direction==="asc"&&(Ae="desc"),se({key:U,direction:Ae});const ve=Ae==="asc"?1:-1;U==="filename"?ce.sort((Me,ue)=>ve*Me.audioFile.name.localeCompare(ue.audioFile.name)):U==="artist"?ce.sort((Me,ue)=>ve*(Me.metadata.artist||"").localeCompare(ue.metadata.artist||"")):U==="title"?ce.sort((Me,ue)=>ve*(Me.metadata.title||"").localeCompare(ue.metadata.title||"")):U==="album"&&ce.sort((Me,ue)=>ve*(Me.metadata.album||"").localeCompare(ue.metadata.album||""))}if(t(ce),Z){const ve=ce.findIndex(Me=>Me.id===Z.id);ve!==-1&&l(ve)}},we=Q.useCallback(U=>{I!==null&&U.key==="Delete"?(U.preventDefault(),U.stopPropagation(),m?m(I):t(Z=>{const ce=[...Z];return ce.splice(I,1),ce}),I>=e.length-1&&$(e.length>1?e.length-2:null)):U.key==="ArrowDown"&&e.length>0?(U.preventDefault(),U.stopPropagation(),$(Z=>Z===null?0:Math.min(Z+1,e.length-1))):U.key==="ArrowUp"&&e.length>0?(U.preventDefault(),U.stopPropagation(),$(Z=>Z===null?0:Math.max(Z-1,0))):U.key==="Enter"&&I!==null?(U.preventDefault(),U.stopPropagation(),s(I)):U.key==="Escape"&&$(null)},[I,e.length,t,s]);Q.useEffect(()=>{const U=A.current;if(U)return U.addEventListener("keydown",we),()=>U.removeEventListener("keydown",we)},[we]),Q.useEffect(()=>{I!==null&&I>=e.length&&$(e.length>0?e.length-1:null)},[e.length,I]);const Ce=async U=>{const Z=new Map;U.forEach(Me=>{const ue=Me.name.split(".").pop()?.toLowerCase(),w=(Me.webkitRelativePath||Me.name).replace(/\.[^/.]+$/,"");Z.has(w)||Z.set(w,{});const M=Z.get(w);["mp3","wav","ogg","flac","m4a","mp4","webm","ogg","mkv","mov","avi","m4v"].includes(ue||"")?M.audio=Me:["lrc","srt","ttml","xml","json","vtt"].includes(ue||"")&&(M.lyric=Me)});const ce=[],Ae=async(Me,ue)=>new Promise(Ge=>{if(Me.type.startsWith("video/")){Ge({title:ue,artist:"Unknown Artist",coverUrl:URL.createObjectURL(Me),backgroundType:"video"});return}ff(()=>import("./jsmediatags.min--h8asrzE.js").then(w=>w.j),[]).then(w=>{w.read(Me,{onSuccess:M=>{const{title:R,artist:V,album:Y,picture:he}=M.tags;let de=null;if(he){const{data:Le,format:ke}=he;let Ie="";for(let _=0;_{Ge({title:ue,artist:"Unknown Artist",coverUrl:null})}})}).catch(()=>{Ge({title:ue,artist:"Unknown Artist",coverUrl:null})})}),ve=async Me=>{try{const ue=await Me.text(),Ge=Me.name.split(".").pop()?.toLowerCase();if(Ge==="lrc")return vl(ue);if(Ge==="srt")return xl(ue);if(Ge==="ttml"||Ge==="xml")return $l(ue);if(Ge==="vtt")return ql(ue);if(Ge==="json")return dT(ue)}catch(ue){console.error("Failed to parse lyrics",ue)}return[]};for(const[Me,ue]of Z.entries())if(ue.audio){const Ge=await Ae(ue.audio,Me),w=Math.random().toString(36).substr(2,9);let M=[];ue.lyric&&(M=await ve(ue.lyric)),ce.push({id:w,audioFile:ue.audio,lyricFile:ue.lyric,parsedLyrics:M,metadata:Ge,duration:0})}if(ce.length>0){const Me=[...e,...ce];t(Me),s(0,!1,Me)}},Ke=async U=>{if(U.target.files&&U.target.files.length>0){const Z=Array.from(U.target.files);await Ce(Z),U.target.value=""}},[C,B]=Q.useState(!1),ne=U=>{U.preventDefault(),U.stopPropagation(),B(!0)},ae=U=>{U.preventDefault(),U.stopPropagation(),B(!1)},Pe=async U=>{if(U.preventDefault(),U.stopPropagation(),B(!1),U.dataTransfer.files&&U.dataTransfer.files.length>0){const Z=Array.from(U.dataTransfer.files);await Ce(Z)}},P=U=>{m?m(U):t(Z=>{const ce=[...Z];return ce.splice(U,1),ce})},Be=U=>new Promise((Z,ce)=>{const Ae=new FileReader;Ae.readAsDataURL(U),Ae.onload=()=>{const ve=Ae.result.split(",")[1];Z(ve)},Ae.onerror=ve=>ce(ve)}),Re=async U=>{if(!navigator.onLine){alert("Unable to transcribe: No internet connection.");return}if(fe.has(U.id)){const ve=E.current.get(U.id);ve&&ve.abort();return}const Z=tt||"PLACEHOLDER_API_KEY";if(Z.trim().length<39){alert(`Invalid API Key length (${Z.trim().length}). It must be at least 39 characters.`),Nt(!0);return}De(ve=>new Set(ve).add(U.id));const ce=new AbortController;E.current.set(U.id,ce);const Ae=19.5*1024*1024;if(U.audioFile.size>Ae){alert(`File is too large (${(U.audioFile.size/1024/1024).toFixed(1)}MB). Gemini inline audio limit is ~20MB. + +Please convert to MP3/M4A or use a smaller file.`),De(ve=>{const Me=new Set(ve);return Me.delete(U.id),Me}),E.current.delete(U.id);return}try{const ve=await Be(U.audioFile);let Me=U.duration||0;if(Me===0)try{Me=await new Promise(w=>{const M=new Audio(URL.createObjectURL(U.audioFile));M.onloadedmetadata=()=>{w(M.duration),URL.revokeObjectURL(M.src)},M.onerror=()=>{URL.revokeObjectURL(M.src),w(0)}})}catch(w){console.warn("Could not determine duration for AI validation",w)}let Ge=(await UM(Xe,ve,U.audioFile.type,Z,ce.signal,Ze)).map(w=>({time:Hs(w.startTime),text:w.text,endTime:Hs(w.endTime),words:w.words?w.words.map(M=>({text:M.text,startTime:Hs(M.startTime),endTime:Hs(M.endTime)})):void 0}));Me>0&&(Ge=Ge.filter(w=>w.time=0)),t(w=>w.map(M=>M.id===U.id?{...M,parsedLyrics:Ge.sort((R,V)=>R.time-V.time),duration:Me>0?Me:M.duration}:M))}catch(ve){if(ve.name==="AbortError")console.log("Transcription aborted via user action.");else{console.error("Transcription failed:",ve);let Me="Transcription failed. Please check your API key or file format.";if(!navigator.onLine)Me="Connection lost. Please check your internet connection.";else if(ve.message){const ue=ve.message.toLowerCase();ue.includes("fetch")||ue.includes("network")||ue.includes("failed to connect")?Me="Network error. Please check your connection.":(ue.includes("api key")||ve.message.includes("400")||ve.message.includes("401")||ve.message.includes("403"))&&(Me="API Key Error: Please check if your key is valid and has credits.")}alert(Me)}}finally{E.current.delete(U.id),De(ve=>{const Me=new Set(ve);return Me.delete(U.id),Me})}},xe=async U=>{if(!navigator.onLine){alert("No internet connection.");return}ye(Z=>new Set(Z).add(U.id));try{const Z=await ff(()=>import("./index.min-CWwwZ6-a.js").then(Ge=>Ge.i),[]);let ce;const Ae=Z.default||Z;console.log("SyncLyrics Module:",Z);const ve=["musixmatch","lrclib","netease"];if(typeof Ae=="function"&&Ae.prototype&&Ae.prototype.getLyrics){console.log("Detected Class usage");const Ge=new Ae({sources:ve});ce=w=>Ge.getLyrics(w)}else if(Ae.getLyrics&&typeof Ae.getLyrics=="function")console.log("Detected Instance usage"),ce=Ge=>Ae.getLyrics(Ge);else if(Ae.SyncLyrics){console.log("Detected Mod.SyncLyrics export");const Ge=Ae.SyncLyrics;if(typeof Ge=="function"&&Ge.prototype&&Ge.prototype.getLyrics){console.log("Using SyncLyrics as Class");const w=new Ge({sources:ve});ce=M=>w.getLyrics(M)}else if(typeof Ge=="function")console.log("Using SyncLyrics as Function"),ce=Ge;else throw new Error("Mod.SyncLyrics found but is not a function or class.")}else if(typeof Ae=="function")console.log("Detected Function usage"),ce=Ae;else throw new Error(`Could not find suitable search function. Mod type: ${typeof Ae}. Keys: ${typeof Ae=="object"?JSON.stringify(Object.keys(Ae)):"N/A"}`);const Me={track:U.metadata.title,artist:U.metadata.artist,album:U.metadata.album,sources:ve};console.log("Searching lyrics with options:",Me);const ue=await ce(Me);if(ue&&typeof ue=="string")pe(ue,U);else{console.warn("npm package returned no result. Attempting fallback to LrcLib.net API directly...");let Ge=U.duration||0;if(Ge===0)try{Ge=await new Promise(V=>{const Y=new Audio(URL.createObjectURL(U.audioFile));Y.onloadedmetadata=()=>{const he=Y.duration;URL.revokeObjectURL(Y.src),V(he)},Y.onerror=()=>V(0)})}catch(V){console.warn("Could not determine duration for search",V)}const w=new URLSearchParams({artist_name:U.metadata.artist,track_name:U.metadata.title,album_name:U.metadata.album||"",duration:Ge.toString()}),M=await fetch(`https://lrclib.net/api/get?${w.toString()}`);if(!M.ok){const V=await fetch(`https://lrclib.net/api/search?q=${encodeURIComponent(U.metadata.title+" "+U.metadata.artist)}`);if(V.ok){const Y=await V.json();if(Array.isArray(Y)&&Y.length>0){const he=Y.find(de=>de.syncedLyrics);if(he){pe(he.syncedLyrics,U);return}else if(Y[0].plainLyrics){pe(Y[0].plainLyrics,U);return}}}throw new Error("No lyrics found in fallback source.")}const R=await M.json();R.syncedLyrics?pe(R.syncedLyrics,U):R.plainLyrics?pe(R.plainLyrics,U):alert("No lyrics found.")}}catch(Z){console.error("Search failed:",Z),Z.message?.includes("CORS")||Z.message?.includes("etwork")||Z.message?.includes("Failed to fetch")?alert(`Network Error: Could not connect to lyric services. +(Possible CORS blocking in browser).`):alert("Search failed: "+Z.message)}finally{ye(Z=>{const ce=new Set(Z);return ce.delete(U.id),ce})}},pe=(U,Z)=>{let ce=vl(U);if(ce.length===0&&(ce=xl(U)),ce.length>0){const Ae=ce.some(ve=>ve.words&&ve.words.length>0);console.log(Ae?"Word-level (enhanced) lyrics found!":"Line-level lyrics found."),t(ve=>ve.map(Me=>Me.id===Z.id?{...Me,parsedLyrics:ce,lyricFile:new File([U],`synched-lyrics${Ae?".lrc-enhanced":".lrc"}`,{type:"text/plain"})}:Me))}else alert("Lyrics found but could not be parsed.")},Oe=(U,Z,ce)=>{const Ae=new Blob([U],{type:"application/octet-stream"}),ve=URL.createObjectURL(Ae),Me=document.createElement("a");Me.href=ve,Me.download=Z,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),URL.revokeObjectURL(ve)},et=async(U,Z)=>{const ce=U.parsedLyrics||[];if(ce.length===0)return;let Ae="";const ve=Z==="lrc-enhanced"?"lrc":Z,Me=`${U.metadata.title||"lyrics"}.${ve}`;let ue=U.duration||0;if(ue===0)try{ue=await new Promise(w=>{const M=new Audio(URL.createObjectURL(U.audioFile));M.onloadedmetadata=()=>{w(M.duration),URL.revokeObjectURL(M.src)},M.onerror=()=>w(0)})}catch(w){console.warn("Could not determine duration for export check",w)}const Ge=ce.map(w=>({...w,words:w.words?w.words.filter(M=>M.text.trim().length>0).map(M=>({...M})):void 0}));for(let w=0;w0?ue:M.time+5),M.words&&M.words.length>0)for(let V=0;Vw.text).join(` +`);else if(Z==="json")Ae=JSON.stringify(Ge,null,2);else if(Z==="srt"){const w=M=>{const R=Math.floor(M/3600).toString().padStart(2,"0"),V=Math.floor(M%3600/60).toString().padStart(2,"0"),Y=Math.floor(M%60).toString().padStart(2,"0"),he=Math.floor(M%1*1e3).toString().padStart(3,"0");return`${R}:${V}:${Y},${he}`};Ae=Ge.map((M,R)=>{const V=w(M.time),Y=M.endTime!==void 0&&M.endTime>M.time?M.endTime:M.time+2,he=w(Y);return`${R+1} +${V} --> ${he} +${M.text} +`}).join(` +`)}else if(Z==="lrc"){const w=[],M=R=>{const V=Math.floor(R/60).toString().padStart(2,"0"),Y=(R%60).toFixed(2).padStart(5,"0");return`[${V}:${Y}]`};for(let R=0;R0)||de<=ue)&&(Y?Y.time>de&&w.push(`${M(de)}`):w.push(`${M(de)}`))}Ae=w.join(` +`)}else if(Z==="lrc-enhanced"){const w=[],M=V=>{const Y=Math.floor(V/60).toString().padStart(2,"0"),he=(V%60).toFixed(2).padStart(5,"0");return`[${Y}:${he}]`},R=V=>{const Y=Math.floor(V/60).toString().padStart(2,"0"),he=(V%60).toFixed(2).padStart(5,"0");return`<${Y}:${he}>`};for(let V=0;V0?Y.words.forEach((_,st)=>{const wt=_.text.replace(/[ \t]+/g," ").trim().replace(/\n/g,"\\n");de+=`${R(_.startTime)}${wt}`,st0)||ke<=ue)&&(he?he.time>ke&&w.push(`${M(ke)}`):w.push(`${M(ke)}`))}Ae=w.join(` +`)}else if(Z==="ttml"){const w=M=>{const R=Math.floor(M/3600).toString().padStart(2,"0"),V=Math.floor(M%3600/60).toString().padStart(2,"0"),Y=Math.floor(M%60).toString().padStart(2,"0"),he=Math.floor(M%1*1e3).toString().padStart(3,"0");return`${R}:${V}:${Y}.${he}`};Ae=` + + +
`,Ge.forEach(M=>{const R=w(M.time),V=M.endTime!==void 0&&M.endTime>M.time?M.endTime:M.time+3,Y=w(V);Ae+=` +

`,M.words&&M.words.length>0?M.words.forEach(he=>{if(!he.text.trim())return;const de=w(he.startTime);let Le=he.endTime;(Le===void 0||Le<=he.startTime)&&(Le=he.startTime+.5);const ke=w(Le);let Ie=he.text.replace(/[ \t]+/g," ").trim();Ie.endsWith("-")||(Ie+=" "),Ae+=` + ${Ie}`}):Ae+=` + ${M.text.replace(/-\s+/g,"-").replace(/[ \t]+/g," ").trim()}`,Ae+=` +

`}),Ae+=` +
+ +
`}else if(Z==="vtt"){const w=M=>{const R=Math.floor(M/3600).toString().padStart(2,"0"),V=Math.floor(M%3600/60).toString().padStart(2,"0"),Y=Math.floor(M%60).toString().padStart(2,"0"),he=Math.floor(M%1*1e3).toString().padStart(3,"0");return`${R}:${V}:${Y}.${he}`};Ae=`WEBVTT + +`,Ge.forEach(M=>{const R=w(M.time),V=M.endTime!==void 0&&M.endTime>M.time?M.endTime:M.time+2,Y=w(V);let he=M.text.trim();if(M.words&&M.words.length>0){const de=M.words.map(Le=>`<${w(Le.startTime)}>${Le.text.trim()}`).join(" ");de.length>0&&(he=de)}Ae+=`${R} --> ${Y} +${he} + +`})}Oe(Ae,Me)},z=async()=>{if(e.length===0)return;const U=async ce=>new Promise(Ae=>{const ve=new Audio(URL.createObjectURL(ce));ve.onloadedmetadata=()=>{Ae(ve.duration),URL.revokeObjectURL(ve.src)},ve.onerror=()=>{Ae(0),URL.revokeObjectURL(ve.src)}});let Z=`#EXTM3U +`;for(const ce of e){let Ae=ce.duration||0;if(Ae===0)try{Ae=await U(ce.audioFile)}catch(w){console.error("Failed to get duration for export",w)}const ve=Math.round(Ae),Me=(ce.metadata.artist||"Unknown Artist").replace(/[\r\n]/g,""),ue=(ce.metadata.title||"Unknown Title").replace(/[\r\n]/g,"");Z+=`#EXTINF:${ve},${Me} - ${ue} +`;const Ge=ce.audioFile.webkitRelativePath||ce.audioFile.name;Z+=`${Ge} +`}Oe(Z,"playlist.m3u8")},Ve=async U=>{await S("Are you sure you want to clear the lyric timeline?","Clear Lyrics")&&t(Z=>Z.map(ce=>ce.id===U.id?{...ce,parsedLyrics:[],lyricFile:void 0}:ce))},at=async U=>{const Z=U.target.files?.[0];if(!(!Z||!Ee)){try{const ce=await Z.text(),Ae=Z.name.split(".").pop()?.toLowerCase();let ve=[];Ae==="lrc"?ve=vl(ce):Ae==="srt"?ve=xl(ce):Ae==="ttml"||Ae==="xml"?ve=$l(ce):Ae==="vtt"&&(ve=ql(ce)),ve.length>0?t(Me=>Me.map(ue=>ue.id===Ee?{...ue,lyricFile:Z,parsedLyrics:ve}:ue)):alert("Could not parse lyrics. Ensure file is .lrc, .srt, or .vtt")}catch(ce){console.error("Failed to load lyrics",ce),alert("Failed to load lyrics file.")}ie(null),U.target.value=""}};return d.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 ${C?"bg-zinc-800 border-orange-500":""}`,onDragOver:ne,onDragLeave:ae,onDrop:Pe,children:[C&&d.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-zinc-900/90 backdrop-blur-sm pointer-events-none",children:d.jsxs("div",{className:"flex flex-col items-center gap-4 text-orange-500 animate-pulse",children:[d.jsx(fo,{size:48}),d.jsx("h3",{className:"text-xl font-bold",children:"Drop Audio & Lyrics Here"}),d.jsx("p",{className:"text-sm text-zinc-400",children:"Supported formats: MP3, WAV, FLAC, Video (MP4/WebM), LRC, SRT, VTT"})]})}),d.jsx("input",{type:"file",name:"manual-lyric-upload",id:"manual-lyric-upload",ref:G,className:"hidden",accept:".lrc,.srt,.ttml,.xml,.vtt",onChange:at}),d.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:[d.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[d.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap",children:[d.jsx(kc,{size:16,className:"text-orange-400"}),"Playlist"]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex bg-orange-600 rounded overflow-hidden",children:[d.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:[d.jsx(nv,{size:14})," Add Files",d.jsx("input",{type:"file",name:"add-files",id:"add-files",className:"hidden",accept:"audio/*,video/*,.lrc,.srt,.ttml,.xml,.vtt",multiple:!0,onChange:Ke})]}),d.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:[d.jsx(eS,{size:14}),d.jsx("input",{type:"file",name:"add-folder",id:"add-folder",className:"hidden",multiple:!0,webkitdirectory:"",onChange:Ke})]})]}),d.jsx("div",{className:"w-px h-4 bg-zinc-700"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>le("filename"),className:`p-1 rounded transition-colors ${oe.key==="filename"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Filename ${oe.key==="filename"?oe.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:d.jsx(Ac,{size:14,className:oe.key==="filename"&&oe.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),d.jsx("button",{onClick:()=>le("artist"),className:`p-1 rounded transition-colors ${oe.key==="artist"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Artist ${oe.key==="artist"?oe.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:d.jsx(nT,{size:14,className:oe.key==="artist"&&oe.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),d.jsx("button",{onClick:()=>le("title"),className:`p-1 rounded transition-colors ${oe.key==="title"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Title ${oe.key==="title"?oe.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:d.jsx(La,{size:14,className:oe.key==="title"&&oe.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),d.jsx("button",{onClick:()=>le("album"),className:`p-1 rounded transition-colors ${oe.key==="album"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:`Sort by Album ${oe.key==="album"?oe.direction==="asc"?"(A-Z)":"(Z-A)":""}`,children:d.jsx(j1,{size:14,className:oe.key==="album"&&oe.direction==="desc"?"rotate-180 transition-transform":"transition-transform"})}),d.jsx("button",{onClick:()=>le("random"),className:`p-1 rounded transition-colors ${oe.key==="random"?"bg-zinc-700 text-white":"hover:bg-zinc-700 text-zinc-400 hover:text-white"}`,title:"Shuffle",children:d.jsx(LS,{size:14})})]})]}),d.jsxs("div",{className:"flex gap-2 shrink-0 items-center",children:[d.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded px-1",children:[d.jsx("button",{onClick:()=>Nt(!xt),className:`p-1 rounded transition-colors ${xt?"text-orange-400":"text-zinc-500 hover:text-zinc-300"}`,title:"Gemini API Key",children:d.jsx(sS,{size:14})}),xt&&d.jsx("input",{type:tt?"password":"text",name:"api-key","aria-label":"Gemini API Key",value:tt,onChange:U=>Ne(U.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})]}),d.jsx("div",{className:"relative group",children:d.jsxs("select",{value:Xe,onChange:U=>$e(U.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:[d.jsx("option",{value:"gemini-2.5-flash",children:"Gemini 2.5 Flash"}),d.jsx("option",{value:"gemini-3-flash-preview",children:"Gemini 3.0 Flash Preview"})]})}),d.jsx("div",{className:"relative group",children:d.jsxs("select",{value:Ze,onChange:U=>gt(U.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:[d.jsx("option",{value:"line",children:"Line"}),d.jsx("option",{value:"word",children:"Word"})]})}),d.jsx("button",{onClick:z,className:"p-1 hover:bg-zinc-700 text-zinc-500 hover:text-white rounded transition-colors",title:"Export Playlist (.m3u8)",children:d.jsx(X1,{size:14})}),d.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:d.jsx(Ba,{size:14})}),d.jsx("div",{className:"w-px h-4 bg-zinc-700 mx-1 self-center"}),d.jsx("button",{onClick:b,className:"p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors",title:"Close Playlist",children:d.jsx(zi,{size:14})})]})]}),d.jsx("div",{ref:A,tabIndex:0,onMouseEnter:()=>A.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?d.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-zinc-500 text-xs",children:[d.jsx(kc,{size:32,className:"mb-2 opacity-50"}),d.jsx("p",{children:"Playlist is empty"}),d.jsx("p",{className:"opacity-50",children:"Add audio files (matches .lrc/.srt/.ttml by name)"})]}):e.map((U,Z)=>{const ce=Z===o,Ae=Z===I,ve=U.parsedLyrics||[],Me=ce?ve.findIndex((ue,Ge)=>{if(ue.endTime!==void 0)return x>=ue.time&&x=ue.time&&(!w||x$(Z),className:`group relative flex gap-2 p-1.5 rounded-md border transition-all cursor-pointer + ${ce?"bg-zinc-800 border-orange-500/50 shadow-lg":"bg-zinc-900/50 border-zinc-800 hover:bg-zinc-800 hover:border-zinc-700"} + ${Ae?"ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950":""} + `,children:[d.jsxs("div",{className:"flex flex-col gap-1 shrink-0 w-48",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:ue=>{ue.stopPropagation(),ce?p():s(Z)},className:`p-1.5 rounded-full transition-colors flex-shrink-0 + ${ce?"bg-orange-500 text-white":"bg-zinc-800 text-zinc-400 hover:bg-zinc-700 hover:text-white"} + `,children:ce?u?d.jsx(tv,{size:14}):d.jsx(hf,{size:14}):d.jsx(hf,{size:14})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:`text-xs font-medium truncate ${ce?"text-orange-100":"text-zinc-300"}`,title:U.audioFile.name,children:U.metadata.title}),d.jsx("div",{className:"text-[9px] text-zinc-500 truncate",title:U.metadata.artist,children:U.metadata.artist})]})]}),d.jsxs("div",{className:"ml-8 flex items-center gap-2",children:[d.jsxs("span",{className:"text-[8px] text-zinc-600",children:[(U.audioFile.size/1024/1024).toFixed(1),"MB"]}),U.lyricFile?d.jsxs("div",{className:"flex items-center gap-0.5 text-[8px] px-1 rounded bg-blue-900/30 text-blue-300/80",title:U.lyricFile.name,children:[d.jsx(Ac,{size:7}),d.jsx("span",{className:"truncate max-w-[80px]",children:U.lyricFile.name})]}):d.jsx("span",{className:"text-[8px] text-zinc-700 italic",children:"No Lyrics"})]})]}),d.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:ve.length>0?d.jsx("div",{className:"relative h-full min-w-max flex items-center px-1",children:ve.map((ue,Ge)=>{const w=Ge===Me;return d.jsxs("div",{id:w?`lyric-active-${Z}`: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 + ${w?"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:`${j(ue.time)} - ${ue.text}`,onClick:M=>{M.stopPropagation(),Z!==o?(s(Z),setTimeout(()=>g(ue.time),150)):g(ue.time)},children:[d.jsx("span",{className:`font-mono text-[8px] ${w?"text-orange-200":"text-zinc-500"}`,children:j(ue.time)}),d.jsx("span",{className:`truncate max-w-[120px] ${w?"text-white font-medium":"text-zinc-400"}`,children:ue.text||"♪"})]},Ge)})}):d.jsx("div",{className:"h-full flex items-center justify-center text-zinc-700 text-[9px] italic",children:"No lyric timeline"})}),d.jsxs("div",{className:"flex items-center gap-1 shrink-0 px-1",children:[d.jsx("button",{onClick:ue=>{ue.stopPropagation(),ie(U.id),G.current&&(G.current.value=""),G.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:d.jsx(fo,{size:14})}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),xe(U)},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 ${be.has(U.id)?"animate-pulse":""}`,title:"Search Lyrics (Online)",disabled:be.has(U.id),children:be.has(U.id)?d.jsx(og,{size:14,className:"animate-spin"}):d.jsx(IS,{size:14})}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),Re(U)},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 ${fe.has(U.id)?"text-red-400 border-red-500/50 hover:bg-red-900/30":""}`,title:fe.has(U.id)?"Stop Transcription":"AI Sync Transcribe",children:fe.has(U.id)?d.jsxs(d.Fragment,{children:[d.jsx(og,{size:14,className:"animate-spin group-hover/btn:hidden"}),d.jsx(yf,{size:14,className:"hidden group-hover/btn:block fill-current"})]}):d.jsx(gf,{size:14})}),ve.length>0&&d.jsxs("div",{className:"flex items-center gap-0.5 bg-zinc-800/50 rounded p-0.5 border border-zinc-700/50",children:[d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"txt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download TXT",children:"TXT"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"lrc")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download LRC",children:"LRC"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"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"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"srt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download SRT",children:"SRT"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"vtt")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download VTT",children:"VTT"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"ttml")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download TTML",children:"TTML"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),et(U,"json")},className:"p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold",title:"Download JSON",children:"JSON"}),d.jsx("div",{className:"w-px h-3 bg-zinc-700 mx-0.5"}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),Ve(U)},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"})]})]}),d.jsx("button",{onClick:ue=>{ue.stopPropagation(),P(Z)},className:"p-1 text-zinc-600 hover:text-red-400 hover:bg-red-900/20 rounded self-start",title:"Remove Track",children:d.jsx(Ba,{size:12})})]},U.id)})})]})},ip=[{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"}]}],PM=()=>{const e=new Set;if(ip.forEach(g=>{g.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"&&e.add(m)})}),e.size===0)return;const l=`https://fonts.googleapis.com/css2?${Array.from(e).map(g=>`family=${g.replace(/ /g,"+")}:wght@400;700`).join("&")}&display=swap`;if(document.getElementById("google-fonts-loader"))return;const s=document.createElement("link");s.id="google-fonts-loader",s.rel="stylesheet",s.href=l,document.head.appendChild(s);const u=document.createElement("link");u.rel="preconnect",u.href="https://fonts.googleapis.com",document.head.appendChild(u);const p=document.createElement("link");p.rel="preconnect",p.href="https://fonts.gstatic.com",p.crossOrigin="anonymous",document.head.appendChild(p)},BM=e=>{const t=`google-font-${e.replace(/\s+/g,"-").toLowerCase()}`;if(document.getElementById(t))return;const o=document.createElement("link");o.id=t,o.rel="stylesheet",o.href=`https://fonts.googleapis.com/css2?family=${e.replace(/\s+/g,"+")}:wght@400;700&display=swap`,document.head.appendChild(o)},op=[{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"}]}],Fc={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"}},sf=op.flatMap(e=>e.options.map(t=>t.value)),rf=({onApply:e,placeholder:t="Google Font Name"})=>{const{toast:o}=er(),[l,s]=Q.useState(""),u=()=>{if(!l.trim())return;const p=l.trim().replace(/['"]/g,"").replace(/\s+/g," ");BM(p),e(p),o.success(`Loaded & Applied: ${p}`),s("")};return d.jsxs("div",{className:"flex gap-2 mt-2 items-center",children:[d.jsx("span",{className:"text-[10px] text-zinc-500 font-bold uppercase whitespace-nowrap",children:"Google Font:"}),d.jsx("input",{type:"text",name:"google-font-name","aria-label":"Google Font Name",value:l,onChange:p=>s(p.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:p=>{p.key==="Enter"&&u()}}),d.jsx("button",{onClick:u,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"})]})},Hy={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},jy=[{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"}]}],Gy=[{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"}]}],Vy=[{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"}]}],$y=[{label:"Visual Transition",options:[{label:"None (Cut)",value:"none"},{label:"Crossfade",value:"crossfade"},{label:"Fade Through Black",value:"fade-to-black"}]}],If=[{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"}]}],Tc=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},qy=[{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"}]}],zf=[{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"}]}],Xv=["none","upper","lower","title","sentence","invert"],Yy=[{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"}]}],Jy=[{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"}]}],OM=[{label:"Frame Rate",options:[{label:"24 FPS (Cinematic)",value:"24"},{label:"30 FPS (Standard)",value:"30"},{label:"60 FPS (Smooth)",value:"60"}]}],Gi=({value:e,onChange:t,groups:o})=>{const[l,s]=Q.useState(!1),[u,p]=Q.useState(e);Q.useEffect(()=>{l||p(e)},[e,l]);const g=b=>{for(const S of o){const A=S.options.find(E=>E.value===b);if(A)return A.label}return b},v=b=>{t(b)},m=()=>{l&&t(u),s(!1)},x=b=>{t(b),p(b),s(!1)};return d.jsxs("div",{className:"space-y-2 relative",onMouseLeave:m,children:[d.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:[d.jsx("span",{className:"truncate",children:g(e)}),d.jsx(Qs,{size:14,className:`transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&d.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=>d.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5 last:border-0",children:[d.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:b.label}),d.jsx("div",{className:"grid grid-cols-1 gap-0.5",children:b.options.map(S=>d.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))})]})},HM=(e,t,o)=>{if(e==="CustomFont"&&o)return o;for(const l of t){const s=l.options.find(u=>u.value===e);if(s)return s.label}return"Select Font"},cf=({value:e,onChange:t,customFontName:o,groups:l=ip})=>{const[s,u]=Q.useState(!1),[p,g]=Q.useState(e);Q.useEffect(()=>{s||g(e)},[e,s]);const v=b=>{t(b)},m=()=>{s&&t(p)},x=b=>{t(b),g(b),u(!1)};return d.jsxs("div",{className:"space-y-2",onMouseLeave:m,children:[d.jsxs("button",{onClick:()=>u(!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:[d.jsx("span",{className:"truncate",style:{fontFamily:e},children:HM(e,l,o)}),d.jsx(Qs,{size:14,className:`transition-transform duration-200 ${s?"rotate-180":""}`})]}),s&&d.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&&d.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5",children:[d.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:"Custom"}),d.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:d.jsxs("span",{style:{fontFamily:"CustomFont"},children:["✨ ",o]})})]}),l.map(b=>d.jsxs("div",{className:"px-2 py-1.5 border-b border-white/5 last:border-0",children:[d.jsx("div",{className:"text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2",children:b.label}),d.jsx("div",{className:"grid grid-cols-1 gap-0.5",children:b.options.map(S=>d.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:d.jsx("span",{style:{fontFamily:S.value},children:S.label})},S.value))})]},b.label))]})]})},jM=Object.values(Fc).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},[]),Ky=[{label:"Visual Presets",options:jM},...ip],GM=({config:e,setConfig:t,preset:o,setPreset:l,onClose:s,isPlaylistMode:u,hasPlaylist:p,onRender:g,customFontName:v,onFontUpload:m,onClearCustomFont:x,resolution:b,setResolution:S,aspectRatio:A,setAspectRatio:E,renderCodec:j,setRenderCodec:I,supportedCodecs:$,renderQuality:oe,setRenderQuality:se,renderFps:fe,setRenderFps:De,renderEngine:be,setRenderEngine:ye,ffmpegCodec:tt,setFfmpegCodec:Ne,customChannelFontName:Xe,onChannelFontUpload:$e,onClearChannelCustomFont:Ze,customInfoFontName:gt,onInfoFontUpload:xt,onClearInfoCustomFont:Nt})=>{const{toast:G,confirm:Ee}=er(),[ie,Ye]=Q.useState([]),ut=(z,Ve)=>{ie.includes(z)||Ye(U=>[z,...U]);const at=z.includes(" ")?`'${z}'`:z;P(Ve,at)},L=$f.useMemo(()=>ie.length===0?Ky:[{label:"Loaded Google Fonts",options:ie.map(Ve=>({label:Ve,value:Ve.includes(" ")?`'${Ve}'`:Ve}))},...Ky],[ie]),le=Q.useRef(null),we=Q.useRef(null),Ce=Q.useRef(null),Ke=Q.useRef(null),C=Q.useRef(null),B=Q.useRef(null),ne=Q.useRef(null),[ae,Pe]=Q.useState(!1),P=(z,Ve)=>{let at={...e,[z]:Ve};if(z==="highlightEffect"){const Z=Tc(Ve);at.useCustomHighlightColors=!1,Z?(at.highlightColor=Z.color,at.highlightBackground=Z.bg):(at.highlightColor="#fb923c",at.highlightBackground="#fb923c")}else if(z==="useCustomHighlightColors"&&Ve===!1){const U=e.highlightEffect,Z=Tc(U);Z?(at.highlightColor=Z.color,at.highlightBackground=Z.bg):(at.highlightColor="#fb923c",at.highlightBackground="#fb923c")}t(at)},Be=z=>{l(z);const Ve=Fc[z];Ve&&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"},...Ve})},Re=z=>{const Ve=z.target.files?.[0];if(Ve){const at=new FileReader;at.onload=U=>{U.target?.result&&P("channelInfoImage",U.target.result)},at.readAsDataURL(Ve)}z.target.value=""},xe=z=>{const Ve=z.target.files?.[0];if(Ve){const at=new FileReader;at.onload=U=>{U.target?.result&&P("backgroundImage",U.target.result)},at.readAsDataURL(Ve)}z.target.value=""},pe=async()=>{await Ee("Reset all render settings, including styles and watermark, to default values?","Reset All Settings")&&(t(Hy),l("default"),S("1080p"),E("16:9"),I("auto"),De(30),se("med"),ye("mediarecorder"),Ne("h264"),C.current&&(C.current.value=""),B.current&&(B.current.value=""),x(),Ze&&Ze(),Nt&&Nt(),e.channelInfoFontFamily==="ChannelFont"&&Ce.current&&(Ce.current.value=""),e.infoFontFamily==="InfoFont"&&Ke.current&&(Ke.current.value=""),G.success("All settings have been reset to default."))},Oe=()=>{const z=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),Ve={...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,preset:o,resolution:b,aspectRatio:A,renderCodec:j,renderFps:fe,renderQuality:oe,renderEngine:be,ffmpegCodec:tt,customFontName:v,customChannelFontName:Xe,customInfoFontName:gt,channelInfoFontWeight:e.channelInfoFontWeight,channelInfoFontStyle:e.channelInfoFontStyle,infoFontWeight:e.infoFontWeight,infoFontStyle:e.infoFontStyle};Ve.backgroundSource!=="image"&&(Ve.backgroundImage=void 0),Ve.showChannelInfo||(Ve.channelInfoImage=void 0);try{const at=JSON.stringify(Ve,null,2),U=new Blob([at],{type:"application/json"}),Z=URL.createObjectURL(U),ce=document.createElement("a");ce.setAttribute("href",Z),ce.setAttribute("download",`render_settings_${z}.json`),document.body.appendChild(ce),ce.click(),ce.remove(),URL.revokeObjectURL(Z)}catch(at){console.error("Export failed:",at),G.error("Failed to export settings.")}},et=z=>{const Ve=z.target.files?.[0];if(!Ve)return;const at=new FileReader;at.onload=U=>{try{const Z=JSON.parse(U.target?.result);if(Z&&typeof Z=="object"){const{resolution:ce,aspectRatio:Ae,renderCodec:ve,renderFps:Me,renderQuality:ue,renderEngine:Ge,ffmpegCodec:w,preset:M,customFontName:R,customChannelFontName:V,customInfoFontName:Y,channelInfoFontWeight:he,channelInfoFontStyle:de,infoFontWeight:Le,infoFontStyle:ke,...Ie}=Z,_={...Hy,...Ie};if(he&&(_.channelInfoFontWeight=he),de&&(_.channelInfoFontStyle=de),Le&&(_.infoFontWeight=Le),ke&&(_.infoFontStyle=ke),["backgroundBlurStrength","fontSizeScale","infoMarginScale","infoSizeScale","channelInfoSizeScale","channelInfoMarginScale","visualTransitionDuration","lyricLineHeight","marginTopScale","marginBottomScale"].forEach(Mt=>{_[Mt]!==void 0&&(_[Mt]=Number(_[Mt]))}),_.useCustomHighlightColors!==void 0&&(_.useCustomHighlightColors=!!_.useCustomHighlightColors),_.useRealColorMedia!==void 0&&(_.useRealColorMedia=!!_.useRealColorMedia),_.showChannelInfo!==void 0&&(_.showChannelInfo=!!_.showChannelInfo),_.showIntro!==void 0&&(_.showIntro=!!_.showIntro),_.showTitle!==void 0&&(_.showTitle=!!_.showTitle),_.showArtist!==void 0&&(_.showArtist=!!_.showArtist),_.showCover!==void 0&&(_.showCover=!!_.showCover),_.showLyrics!==void 0&&(_.showLyrics=!!_.showLyrics),_.highlightEffect&&(!_.highlightColor||!_.highlightBackground)){const Mt=Tc(_.highlightEffect);Mt&&(_.highlightColor||(_.highlightColor=Mt.color),_.highlightBackground||(_.highlightBackground=Mt.bg))}const wt=(Mt,ot)=>ot.some(Wt=>Wt.options.some(me=>me.value===Mt));_.textEffect&&!wt(_.textEffect,jy)&&(_.textEffect="shadow"),_.textAnimation&&!wt(_.textAnimation,Gy)&&(_.textAnimation="none"),_.transitionEffect&&!wt(_.transitionEffect,Vy)&&(_.transitionEffect="none"),_.visualTransitionType&&!wt(_.visualTransitionType,$y)&&(_.visualTransitionType="none"),_.highlightEffect&&!wt(_.highlightEffect,If)&&(_.highlightEffect="karaoke"),_.backgroundSource&&!wt(_.backgroundSource,qy)&&(_.backgroundSource="custom"),["current","playlist"].includes(_.renderMode)||(_.renderMode="current"),["left","center","right"].includes(_.textAlign)||(_.textAlign="center"),["top","center","bottom"].includes(_.contentPosition)||(_.contentPosition="center"),_.marginTopScale===void 0||isNaN(_.marginTopScale)?_.marginTopScale=1:_.marginTopScale=Math.max(0,Math.min(5,_.marginTopScale)),_.marginBottomScale===void 0||isNaN(_.marginBottomScale)?_.marginBottomScale=1:_.marginBottomScale=Math.max(0,Math.min(5,_.marginBottomScale)),_.lyricDisplayMode&&!wt(_.lyricDisplayMode,zf)&&(_.lyricDisplayMode="all"),["normal","bold"].includes(_.fontWeight)||(_.fontWeight="bold"),["normal","italic"].includes(_.fontStyle)||(_.fontStyle="normal"),["none","underline","line-through"].includes(_.textDecoration)||(_.textDecoration="none"),Xv.includes(_.textCase)||(_.textCase="none"),["auto","manual"].includes(_.introMode)||(_.introMode="auto"),_.lyricStyleTarget&&!["active-only","all"].includes(_.lyricStyleTarget)&&(_.lyricStyleTarget="active-only");const Dt=["top-left","top-right","bottom-left","bottom-right","top-center","bottom-center"];_.infoPosition&&!Dt.includes(_.infoPosition)&&(_.infoPosition="top-left"),_.infoStyle&&!wt(_.infoStyle,Yy)&&(_.infoStyle="classic"),_.channelInfoPosition&&!Dt.includes(_.channelInfoPosition)&&(_.channelInfoPosition="bottom-right"),_.channelInfoStyle&&!wt(_.channelInfoStyle,Jy)&&(_.channelInfoStyle="classic"),t(_),ce&&S(ce),Ae&&E(Ae),ve&&I(ve),Me&&De(Number(Me)),ue&&se(ue),Ge&&ye(Ge),w&&Ne(w),l(M||"custom"),R&&R!==v?G.success(`Settings loaded. Note: Config used font "${R}".`):V||Y?G.success(`Settings loaded. Custom fonts referenced: ${[V,Y].filter(Boolean).join(", ")}`):G.success("Settings loaded successfully!")}}catch(Z){console.error(Z),G.error("Failed to parse settings file. Please ensure it is a valid JSON file.")}},at.readAsText(Ve),z.target.value=""};return Q.useEffect(()=>{const z=Ve=>{le.current&&!le.current.contains(Ve.target)&&s()};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[s]),d.jsxs("div",{ref:le,onMouseDown:z=>z.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:[d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(xc,{size:18,className:"text-purple-400"}),d.jsx("h2",{className:"font-bold text-zinc-200",children:"Render Settings"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{ref:ne,type:"file",name:"import-settings",id:"import-settings",accept:".json,.txt",className:"hidden",onChange:et}),d.jsx("button",{onClick:()=>ne.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",title:"Import Settings",children:d.jsx(fo,{size:16})}),d.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:d.jsx(V1,{size:16})}),d.jsx("div",{className:"w-px h-4 bg-white/10 mx-1"}),d.jsx("button",{onClick:pe,className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",title:"Reset to Default",children:d.jsx(mf,{size:16})}),d.jsx("button",{onClick:s,className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",children:d.jsx(zi,{size:20})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4 space-y-6 custom-scrollbar",children:[d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(gf,{size:14})," Visual Preset"]}),d.jsx(Gi,{value:o,onChange:z=>Be(z),groups:op})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(qs,{size:14})," Render Scope"]}),d.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("renderMode","playlist"),disabled:!p,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"})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(ig,{size:14})," Background Source"]}),d.jsx(Gi,{value:e.backgroundSource,onChange:z=>{z==="gradient"&&!e.backgroundGradient?(l("custom"),t({...e,backgroundSource:"gradient",backgroundGradient:"linear-gradient(to bottom right, #312e81, #581c87, #000000)"})):z==="smart-gradient"&&(!e.backgroundColor||e.backgroundColor==="#000000")?(l("custom"),t({...e,backgroundSource:"smart-gradient",backgroundColor:"#581c87"})):z==="color"&&!e.backgroundColor?(l("custom"),t({...e,backgroundSource:"color",backgroundColor:"#000000"})):P("backgroundSource",z)},groups:qy}),e.backgroundSource==="smart-gradient"&&d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"smart-bg-color","aria-label":"Smart Gradient Base Color",value:e.backgroundColor,onChange:z=>P("backgroundColor",z.target.value),className:"w-10 h-10 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[d.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Pick Base Color"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-[10px] text-zinc-500",children:"Hex:"}),d.jsx("input",{type:"text",name:"smart-bg-hex","aria-label":"Smart Gradient Base Color Hex",value:e.backgroundColor,onChange:z=>P("backgroundColor",z.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"&&d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"solid-bg-color","aria-label":"Background Color",value:e.backgroundColor,onChange:z=>P("backgroundColor",z.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("input",{type:"text",name:"solid-bg-hex","aria-label":"Background Color Hex",value:e.backgroundColor,onChange:z=>P("backgroundColor",z.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"&&d.jsx("input",{type:"text",name:"custom-gradient","aria-label":"Custom CSS Gradient",value:e.backgroundGradient,onChange:z=>P("backgroundGradient",z.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"&&d.jsx("div",{className:"space-y-3 animate-in slide-in-from-top-1 fade-in duration-200",children:d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Custom Background Image"}),d.jsx("input",{ref:B,type:"file",name:"bg-image-upload",id:"bg-image-upload",accept:"image/*",onChange:xe,className:"hidden"}),e.backgroundImage?d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10",children:[d.jsx("div",{className:"w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5",children:d.jsx("img",{src:e.backgroundImage,alt:"Background",className:"w-full h-full object-cover"})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-xs text-zinc-300 truncate",children:"Image Loaded"}),d.jsx("button",{onClick:()=>P("backgroundImage",void 0),className:"text-[10px] text-red-400 hover:text-red-300",children:"Remove"})]}),d.jsx("button",{onClick:()=>B.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white",children:d.jsx(xc,{size:14})})]}):d.jsxs("button",{onClick:()=>B.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:[d.jsx(fo,{size:14}),d.jsx("span",{className:"text-xs",children:"Upload Background"})]})]})})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(mS,{size:14})," Background Effects"]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex bg-zinc-800 p-1 rounded-lg border border-white/5",children:[d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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&&d.jsxs("div",{className:"space-y-1.5 animate-in slide-in-from-top-2 fade-in duration-200",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Blur Intensity"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[e.backgroundBlurStrength,"px"]})]}),d.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:d.jsx("input",{type:"range",name:"blur-strength","aria-label":"Blur Intensity",min:"1",max:"64",step:"1",value:e.backgroundBlurStrength,onChange:z=>P("backgroundBlurStrength",parseInt(z.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"})})]})]}),d.jsxs("label",{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:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Real Color Media Source"}),d.jsx("span",{className:"text-[10px] text-zinc-500",children:"Disable dark dimming effect on background"})]}),d.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[d.jsx("input",{type:"checkbox",name:"real-color-media",checked:e.useRealColorMedia??!1,onChange:z=>P("useRealColorMedia",z.target.checked),className:"sr-only peer"}),d.jsx("div",{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"})]})]}),d.jsxs("label",{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:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Black Gradient Overlay"}),d.jsx("span",{className:"text-[10px] text-zinc-500",children:"Fade bottom to top (readability)"})]}),d.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[d.jsx("input",{type:"checkbox",name:"gradient-overlay",checked:e.enableGradientOverlay??!1,onChange:z=>P("enableGradientOverlay",z.target.checked),className:"sr-only peer"}),d.jsx("div",{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"})]})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(Ac,{size:14})," Lyric Display Mode"]}),d.jsx(Gi,{value:e.lyricDisplayMode,onChange:z=>P("lyricDisplayMode",z),groups:zf})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(gf,{size:14})," Highlight Effect"]}),d.jsx(Gi,{value:e.highlightEffect||"none",onChange:z=>{P("highlightEffect",z)},groups:If}),e.highlightEffect&&e.highlightEffect!=="none"&&d.jsxs("div",{className:"mt-2 space-y-2 animate-in slide-in-from-top-2",children:[d.jsxs("button",{onClick:()=>P("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:[d.jsx("span",{children:"Custom Colors"}),d.jsx("div",{className:`w-8 h-4 rounded-full p-0.5 transition-colors ${e.useCustomHighlightColors?"bg-purple-500":"bg-zinc-600"}`,children:d.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&&d.jsxs("div",{className:"grid grid-cols-2 gap-3 animate-in fade-in duration-200",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-[10px] text-zinc-400 font-bold uppercase",children:"Text/Glow Color"}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"highlight-color","aria-label":"Highlight Text Color",value:e.highlightColor||"#fb923c",onChange:z=>P("highlightColor",z.target.value),className:"w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("input",{type:"text",name:"highlight-color-hex","aria-label":"Highlight Text Color Hex",value:e.highlightColor||"#fb923c",onChange:z=>P("highlightColor",z.target.value),className:"bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase"})]})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsx("label",{className:"text-[10px] text-zinc-400 font-bold uppercase",children:"Back/Shape Color"}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"highlight-bg-color","aria-label":"Highlight Background Color",value:e.highlightBackground||"#fb923c",onChange:z=>P("highlightBackground",z.target.value),className:"w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("input",{type:"text",name:"highlight-bg-hex","aria-label":"Highlight Background Color Hex",value:e.highlightBackground||"#fb923c",onChange:z=>P("highlightBackground",z.target.value),className:"bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase"})]})]})]})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(yS,{size:14})," Visible Elements"]}),d.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(z=>d.jsxs("label",{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:[d.jsx("span",{className:"text-xs text-zinc-300",children:z.label}),d.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[d.jsx("input",{type:"checkbox",name:z.key,checked:e[z.key],onChange:Ve=>P(z.key,Ve.target.checked),className:"sr-only peer"}),d.jsx("div",{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"})]})]},z.key))})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(yl,{size:14})," Intro Settings"]}),d.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Intro Text"}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 rounded-md p-1 border border-white/5",children:[d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"&&d.jsxs("div",{className:"space-y-1 animate-in slide-in-from-top-1 fade-in duration-200",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 uppercase font-bold",children:"Custom Intro Content"}),d.jsx("textarea",{name:"intro-text","aria-label":"Intro Text",value:e.introText,onChange:z=>P("introText",z.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]"})]})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(ig,{size:14})," Channel Info / Watermark"]}),d.jsxs("div",{className:"bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3",children:[d.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[d.jsx("span",{className:"text-xs text-zinc-300 font-medium",children:"Show Channel Info"}),d.jsxs("div",{className:"relative inline-flex items-center cursor-pointer",children:[d.jsx("input",{type:"checkbox",name:"show-channel-info",checked:e.showChannelInfo??!1,onChange:z=>P("showChannelInfo",z.target.checked),className:"sr-only peer"}),d.jsx("div",{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"})]})]}),e.showChannelInfo&&d.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:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Channel Logo / Image"}),d.jsx("input",{ref:C,type:"file",name:"channel-image-upload",id:"channel-image-upload",accept:"image/*",onChange:Re,className:"hidden"}),e.channelInfoImage?d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10",children:[d.jsx("div",{className:"w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5",children:d.jsx("img",{src:e.channelInfoImage,alt:"Channel",className:"w-full h-full object-cover"})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"text-xs text-zinc-300 truncate",children:"Image Loaded"}),d.jsx("button",{onClick:()=>P("channelInfoImage",void 0),className:"text-[10px] text-red-400 hover:text-red-300",children:"Remove"})]}),d.jsx("button",{onClick:()=>C.current?.click(),className:"p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white",children:d.jsx(xc,{size:14})})]}):d.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:[d.jsx(fo,{size:14}),d.jsx("span",{className:"text-xs",children:"Upload Image"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Channel Name / SVG Code"}),d.jsx("textarea",{name:"channel-info-text","aria-label":"Channel Info Text",value:e.channelInfoText??"",onChange:z=>P("channelInfoText",z.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})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Position"}),d.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),d.jsx(Gi,{value:e.channelInfoStyle||"classic",onChange:z=>P("channelInfoStyle",z),groups:Jy})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Edge Margin"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.channelInfoMarginScale??1).toFixed(1),"x"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx($s,{size:12})}),d.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:z=>P("channelInfoMarginScale",parseFloat(z.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Size"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.channelInfoSizeScale??1).toFixed(1),"x"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx($s,{size:12})}),d.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:z=>P("channelInfoSizeScale",parseFloat(z.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),d.jsx(cf,{value:e.channelInfoFontFamily||"sans-serif",onChange:z=>P("channelInfoFontFamily",z),customFontName:Xe||null,groups:L}),d.jsx(rf,{onApply:z=>ut(z,"channelInfoFontFamily"),placeholder:"Channel Font (e.g. Oswald)"}),d.jsx("input",{ref:Ce,type:"file",name:"channel-font-upload",id:"channel-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:$e,className:"hidden"}),Xe?d.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:[d.jsx("span",{className:"text-[10px] text-purple-300 font-medium truncate flex-1",children:Xe}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:Ze,className:"text-zinc-500 hover:text-red-400",children:d.jsx(Ba,{size:12})})]}):d.jsxs("button",{onClick:()=>Ce.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:[d.jsx(fo,{size:10}),d.jsx("span",{className:"text-[10px]",children:"Upload Font"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Style"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>P("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:d.jsx(nf,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(of,{size:14})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Color"}),d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"channel-font-color","aria-label":"Channel Font Color",value:e.channelInfoFontColor||"#ffffff",onChange:z=>P("channelInfoFontColor",z.target.value),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("span",{className:"text-[10px] text-zinc-400 font-mono uppercase",children:e.channelInfoFontColor||"#ffffff"})]})]})]})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(La,{size:14})," Song Info Design"]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Position"}),d.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})}),d.jsx("button",{onClick:()=>P("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:d.jsx("div",{className:"w-2 h-2 bg-current rounded-sm"})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),d.jsx(Gi,{value:e.infoStyle||"classic",onChange:z=>P("infoStyle",z),groups:Yy})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Edge Margin"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.infoMarginScale??1).toFixed(1),"x"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx($s,{size:12})}),d.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:z=>P("infoMarginScale",parseFloat(z.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Info Size"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.infoSizeScale??1).toFixed(1),"x"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx(yl,{size:12})}),d.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:z=>P("infoSizeScale",parseFloat(z.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),d.jsx(cf,{value:e.infoFontFamily||"sans-serif",onChange:z=>P("infoFontFamily",z),customFontName:gt||null,groups:L}),d.jsx(rf,{onApply:z=>ut(z,"infoFontFamily"),placeholder:"Info Font (e.g. Roboto)"}),d.jsx("input",{ref:Ke,type:"file",name:"info-font-upload",id:"info-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:xt,className:"hidden"}),gt?d.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:[d.jsx("span",{className:"text-[10px] text-purple-300 font-medium truncate flex-1",children:gt}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:Nt,className:"text-zinc-500 hover:text-red-400",children:d.jsx(Ba,{size:12})})]}):d.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:[d.jsx(fo,{size:10}),d.jsx("span",{className:"text-[10px]",children:"Upload Font"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Style"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>P("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:d.jsx(nf,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(of,{size:14})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Color"}),d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"info-font-color","aria-label":"Song Info Text Color",value:e.infoFontColor||"#ffffff",onChange:z=>P("infoFontColor",z.target.value),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("span",{className:"text-[10px] text-zinc-400 font-mono uppercase",children:e.infoFontColor||"#ffffff"})]})]})]})]}),d.jsxs("section",{className:"space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(yl,{size:14})," Typography & Style"]}),d.jsxs("div",{className:"space-y-4 pt-1",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Alignment"}),d.jsx("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:["left","center","right"].map(z=>d.jsx("button",{onClick:()=>P("textAlign",z),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${e.textAlign===z?"bg-zinc-600 text-white shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:z},z))})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Vertical Position"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>P("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:d.jsx(M1,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(ng,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(N1,{size:14})})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Top Margin"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.marginTopScale??1).toFixed(1),"x"]})]}),d.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:d.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:z=>P("marginTopScale",parseFloat(z.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"})})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Bottom Margin"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.marginBottomScale??1).toFixed(1),"x"]})]}),d.jsx("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:d.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:z=>P("marginBottomScale",parseFloat(z.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"})})]})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Style"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>P("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:d.jsx(nf,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(of,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx(WS,{size:14})}),d.jsx("button",{onClick:()=>P("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:d.jsx($S,{size:14})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Apply Style To"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Case"}),d.jsxs("div",{className:"grid grid-cols-3 gap-1 bg-zinc-800 rounded-lg p-1",children:[d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"}),d.jsx("button",{onClick:()=>P("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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Family"}),d.jsx(cf,{value:e.fontFamily,onChange:z=>P("fontFamily",z),customFontName:v,groups:L}),d.jsx(rf,{onApply:z=>ut(z,"fontFamily"),placeholder:"Lyrics Font (e.g. Pacifico)"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Custom Font File"}),d.jsx("input",{ref:we,type:"file",name:"main-font-upload",id:"main-font-upload",accept:".ttf,.otf,.woff,.woff2",onChange:m,className:"hidden"}),v?d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-3 py-2",children:[d.jsx(yl,{size:14,className:"text-purple-400 shrink-0"}),d.jsx("span",{className:"text-xs text-purple-300 font-medium truncate flex-1",children:v}),d.jsx("button",{onClick:()=>{P("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"}),d.jsx("button",{onClick:x,className:"p-1 text-zinc-500 hover:text-red-400 transition-colors",title:"Remove custom font",children:d.jsx(Ba,{size:14})})]}):d.jsxs("button",{onClick:()=>we.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:[d.jsx(fo,{size:14}),d.jsx("span",{className:"text-xs",children:"Upload Custom Font (.ttf, .otf, .woff2)"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Font Size"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.fontSizeScale*100).toFixed(0),"%"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx(yl,{size:12})}),d.jsx("input",{type:"range",name:"font-size","aria-label":"Font Size",min:"0.1",max:"3.0",step:"0.1",value:e.fontSizeScale,onChange:z=>P("fontSizeScale",parseFloat(z.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"}),d.jsx("span",{className:"text-zinc-300",children:d.jsx(yl,{size:16})})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Current Line Height"}),d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[(e.lyricLineHeight||1.3).toFixed(1),"x"]})]}),d.jsxs("div",{className:"flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5",children:[d.jsx("span",{className:"text-zinc-500",children:d.jsx(ng,{size:12})}),d.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:z=>P("lyricLineHeight",parseFloat(z.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"&&d.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."}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Color"}),d.jsxs("div",{className:"flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5",children:[d.jsx("input",{type:"color",name:"main-font-color","aria-label":"Main Font Color",value:e.fontColor,onChange:z=>P("fontColor",z.target.value),className:"w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0"}),d.jsx("input",{type:"text",name:"main-font-hex","aria-label":"Main Font Color Hex",value:e.fontColor,onChange:z=>P("fontColor",z.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Effect"}),d.jsx(Gi,{value:e.textEffect,onChange:z=>P("textEffect",z),groups:jy})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Text Animation"}),d.jsx(Gi,{value:e.textAnimation,onChange:z=>P("textAnimation",z),groups:Gy})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Transition"}),d.jsx(Gi,{value:e.transitionEffect,onChange:z=>P("transitionEffect",z),groups:Vy})]}),d.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-white/5",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Visual Transition (Images/Video)"}),e.visualTransitionDuration&&d.jsxs("span",{className:"text-[10px] text-zinc-400 font-mono",children:[e.visualTransitionDuration.toFixed(1),"s"]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(Gi,{value:e.visualTransitionType||"none",onChange:z=>P("visualTransitionType",z),groups:$y})}),e.visualTransitionType&&e.visualTransitionType!=="none"&&d.jsx("div",{className:"w-1/3 flex items-center bg-zinc-800 border border-white/10 rounded-lg px-2",children:d.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:z=>P("visualTransitionDuration",parseFloat(z.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"})})]})]}),d.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-3",children:[d.jsxs("h3",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2",children:[d.jsx(qs,{size:14})," Output Settings"]}),d.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Resolution"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:[d.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"}),d.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"})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"FPS"}),d.jsx(Gi,{value:String(fe),onChange:z=>De(parseInt(z)),groups:OM})]})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Aspect Ratio"}),d.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(z=>d.jsx("button",{onClick:()=>E(z),className:`py-1.5 rounded-md text-[10px] font-mono transition-all border ${A===z?"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:z},z))})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Render Engine"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1 gap-1",children:[d.jsx("button",{onClick:()=>ye("mediarecorder"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${be==="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"}),d.jsx("button",{onClick:()=>ye("webcodecs"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${be==="webcodecs"?"bg-blue-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,title:"Uses WebCodecs API. Hardware accelerated rendering. Fastest option.",children:"WebCodecs 🚀"}),d.jsx("button",{onClick:()=>ye("ffmpeg"),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${be==="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 ⚡"})]}),d.jsx("p",{className:"text-[9px] text-zinc-600 ml-1 leading-tight",children:be==="mediarecorder"?"Realtime recording. Fast but quality depends on browser.":be==="webcodecs"?"Hardware accelerated (GPU). Very fast export with simple MP4.":"Software rendering. High compatiblity but slower."})]}),be==="mediarecorder"&&d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Video Codec"}),d.jsx(Gi,{value:j,onChange:z=>I(z),groups:[{label:"Format",options:[{label:"Auto Select (Best)",value:"auto"},...$]}]})]}),be==="ffmpeg"&&d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"FFmpeg Codec"}),d.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(z=>d.jsxs("button",{onClick:()=>Ne(z.value),className:`py-2 px-2 rounded-md text-[10px] font-medium transition-all border text-left ${tt===z.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:z.desc,children:[d.jsx("div",{className:"font-bold",children:z.label}),d.jsx("div",{className:"text-[8px] opacity-75",children:z.desc})]},z.value))})]}),be==="webcodecs"&&d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Video Codec"}),d.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)"})]}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsx("label",{className:"text-[10px] text-zinc-500 font-bold uppercase ml-1",children:"Render Quality (Bitrate)"}),d.jsxs("div",{className:"flex bg-zinc-800 rounded-lg p-1",children:[d.jsx("button",{onClick:()=>se("low"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${oe==="low"?"bg-zinc-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"Low"}),d.jsx("button",{onClick:()=>se("med"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${oe==="med"?"bg-zinc-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"Medium"}),d.jsx("button",{onClick:()=>se("high"),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${oe==="high"?"bg-purple-600 text-white":"text-zinc-500 hover:text-zinc-300"}`,children:"High"})]})]})]}),d.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[d.jsxs("p",{className:"text-[10px] text-zinc-500 italic leading-relaxed",children:[d.jsx("span",{className:"text-purple-400 font-bold",children:"*Tip:"})," You can backup your current configuration using the ",d.jsx("span",{className:"text-zinc-300",children:"Export"})," button above."]}),d.jsxs("button",{onClick:()=>Pe(!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:[d.jsx(Mc,{size:14})," View Keyboard Shortcuts"]})]})]}),ae&&d.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:()=>Pe(!1),children:d.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:z=>z.stopPropagation(),children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/10 bg-zinc-800/50",children:[d.jsxs("h3",{className:"font-bold text-white flex items-center gap-2",children:[d.jsx(Mc,{size:18,className:"text-purple-400"}),"Keyboard Shortcuts"]}),d.jsx("button",{onClick:()=>Pe(!1),className:"p-1.5 hover:bg-white/10 rounded-full text-zinc-400 hover:text-white transition-colors",children:d.jsx(zi,{size:18})})]}),d.jsxs("div",{className:"p-4 overflow-y-auto space-y-6 custom-scrollbar",children:[d.jsxs("div",{className:"space-y-3",children:[d.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Media Controls"}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Play / Pause"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Stop"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Next Song"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Prev Song"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Repeat Mode"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Mute / Unmute"})," ",d.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"})]})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"View & Appearance"}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Fullscreen"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Playlist Mode"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Timeline / Edit"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Info"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Player"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Auto-Hide HUD"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Minimal Mode"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Lyric Display Mode"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Text Case"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Render Settings"})," ",d.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"})]})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Visual Effects"}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Highlight On/Off"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Next Highlight Effect"})," ",d.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"})]})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("h4",{className:"text-xs font-bold text-zinc-500 uppercase tracking-wider",children:"Adjustment & Export"}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Presets"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Font Size"})," ",d.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.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Seek +/- 5s"})," ",d.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"})]}),d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsx("span",{className:"text-zinc-300",children:"Scroll Lyrics"})," ",d.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"})]}),d.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:[d.jsx("span",{className:"text-purple-300 font-medium",children:"Quick Export"}),d.jsxs("div",{className:"flex gap-1 items-center",children:[d.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"}),d.jsx("span",{className:"text-zinc-500 text-[10px]",children:"+"}),d.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"}),d.jsx("span",{className:"text-zinc-500 text-[10px]",children:"+"}),d.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"})]})]})]})]})]}),d.jsx("div",{className:"p-4 border-t border-white/10 bg-zinc-900/50 text-center",children:d.jsxs("p",{className:"text-[10px] text-zinc-500",children:["Press ",d.jsx("kbd",{className:"font-mono text-zinc-400",children:"Esc"})," to close"]})})]})})]}),d.jsxs("div",{className:"p-4 border-t border-white/10 bg-zinc-900/50 space-y-3",children:[d.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:[d.jsx(qs,{size:16})," Start Render"]}),d.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."})]})]})},Wc=(e,t,o,l,s,u,p,g,v,m,x,b,S,A,E,j=!0,I=!0)=>{const $=C=>{const B=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(C);return B?{r:parseInt(B[1],16),g:parseInt(B[2],16),b:parseInt(B[3],16)}:{r:255,g:255,b:255}},oe=C=>{let B=0,ne=0;if(C instanceof ImageBitmap?(B=C.width,ne=C.height):C instanceof HTMLVideoElement?(B=C.videoWidth,ne=C.videoHeight):(B=C.width,ne=C.height),B&&ne){const ae=Math.max(t/B,o/ne),Pe=t/2-B/2*ae,P=o/2-ne/2*ae;e.drawImage(C,Pe,P,B*ae,ne*ae)}},se=(C,B,ne)=>{if(B.includes(` +`))return B.split(` +`).flatMap(Re=>se(C,Re,ne));const ae=B.split(" ");let Pe=[],P=ae[0]||"";for(let Re=1;Re{if(Pe==="vhs"&&C instanceof CanvasRenderingContext2D)C.save(),C.globalCompositeOperation="screen",C.fillStyle="#ff0000",C.fillText(B,ne-2,ae),C.fillStyle="#00ff00",C.fillText(B,ne,ae),C.fillStyle="#0000ff",C.fillText(B,ne+2,ae),C.restore();else if(Pe==="3d"){const Be=C.fillStyle;C.fillStyle="rgba(0,0,0,0.5)";for(let Re=1;Re<=4;Re++)C.fillText(B,ne+Re,ae+Re);C.fillStyle=Be,C.fillText(B,ne,ae)}else if(Pe==="neon"){const Be=C.fillStyle;C.shadowColor=Be,C.shadowBlur=20,C.fillText(B,ne,ae),C.shadowBlur=40,C.fillText(B,ne,ae)}else if(Pe==="outline")C.strokeText(B,ne,ae),C.fillText(B,ne,ae);else if(Pe==="gradient"){const Be=C.createLinearGradient(ne,ae-20,ne,ae+20);Be.addColorStop(0,C.fillStyle),Be.addColorStop(1,"#ffffff"),C.fillStyle=Be,C.fillText(B,ne,ae)}else if(Pe==="fire")C.save(),C.shadowBlur=5,C.shadowColor="#ff0000",C.fillStyle="#ff4500",C.fillText(B,ne,ae),C.shadowBlur=2,C.shadowColor="#ffff00",C.fillStyle="#ffcc00",C.fillText(B,ne+1,ae-1),C.restore();else if(Pe==="emboss")C.fillStyle="rgba(255,255,255,0.7)",C.fillText(B,ne-1,ae-1),C.fillStyle="rgba(0,0,0,0.7)",C.fillText(B,ne+1,ae+1),C.fillStyle="rgba(128,128,128,0.5)",C.fillText(B,ne,ae);else if(Pe==="mirror")C.fillText(B,ne,ae),C.save(),C.translate(ne,ae),C.scale(1,-1),C.translate(-ne,-ae),C.globalAlpha*=.2,C.fillText(B,ne,ae-40),C.restore();else if(Pe==="neon-multi")C.fillStyle,C.shadowBlur=10,C.shadowColor="#fff",C.fillText(B,ne,ae),C.shadowBlur=20,C.shadowColor="#ff00de",C.fillText(B,ne,ae),C.shadowBlur=35,C.shadowColor="#00ffff",C.fillText(B,ne,ae);else if(Pe==="gold"){const Be=C.createLinearGradient(ne,ae-20,ne,ae+20);Be.addColorStop(0,"#d4af37"),Be.addColorStop(1,"#C5A028"),C.fillStyle=Be,C.fillText(B,ne,ae)}else if(Pe==="chrome"){const Be=C.createLinearGradient(ne,ae-20,ne,ae+20);Be.addColorStop(0,"#ebebeb"),Be.addColorStop(.5,"#616161"),Be.addColorStop(.51,"#ebebeb"),Be.addColorStop(1,"#ebebeb"),C.fillStyle=Be,C.fillText(B,ne,ae)}else if(Pe==="frozen")C.shadowColor="#03A9F4",C.shadowBlur=20,C.fillStyle="#ffffff",C.fillText(B,ne,ae);else if(Pe==="rainbow"){const Be=C.createLinearGradient(ne-100,ae,ne+100,ae);Be.addColorStop(0,"violet"),Be.addColorStop(.16,"indigo"),Be.addColorStop(.32,"blue"),Be.addColorStop(.48,"green"),Be.addColorStop(.64,"yellow"),Be.addColorStop(.8,"orange"),Be.addColorStop(1,"red"),C.fillStyle=Be,C.fillText(B,ne,ae)}else if(Pe==="retro")C.fillStyle="#ff00ff",C.shadowColor="#00ffff",C.shadowBlur=0,C.shadowOffsetX=4,C.shadowOffsetY=4,C.fillText(B,ne,ae);else if(Pe==="cyberpunk")C.save(),C.fillStyle="#05d9e8",C.fillText(B,ne-1,ae-1),C.restore(),C.save(),C.fillStyle="#000000",C.fillText(B,ne+2,ae+2),C.restore(),C.save(),C.fillStyle="#fcee0a",C.fillText(B,ne,ae),C.restore();else if(Pe==="glitch-text"){const Be=(Math.random()-.5)*5,Re=(Math.random()-.5)*2;C.save(),C.fillStyle="red",C.fillText(B,ne+Be,ae+Re),C.restore(),C.save(),C.fillStyle="cyan",C.fillText(B,ne-Be,ae-Re),C.restore(),C.fillStyle="#ffffff",C.fillText(B,ne,ae)}else Pe==="hologram"?(C.fillStyle="rgba(0, 255, 255, 0.7)",C.shadowColor="rgba(0,255,255,0.5)",C.shadowBlur=10,C.fillText(B,ne,ae)):(Pe==="comic"&&(C.lineWidth=3,C.strokeStyle="#000000",C.strokeText(B,ne,ae),C.fillStyle="#ffcc00"),C.fillText(B,ne,ae));if(P&&P!=="none"){const Re=C.measureText(B).width;let xe=ne;if(C.textAlign==="center"?xe=ne-Re/2:C.textAlign==="right"&&(xe=ne-Re),C.save(),C.beginPath(),C.lineWidth=Math.max(2,4*ie),C.strokeStyle=C.fillStyle,P.includes("line-through")&&(C.moveTo(xe,ae),C.lineTo(xe+Re,ae)),P.includes("underline")){const pe=C.font.match(/(\d+(\.\d+)?)px/),Oe=pe?parseFloat(pe[1]):50,et=ae+Oe*.4;C.moveTo(xe,et),C.lineTo(xe+Re,et)}C.stroke(),C.restore()}},De=(C,B,ne,ae,Pe,P,Be,Re,xe,pe,Oe,et,z)=>{const Ve=Re?.textCase||"none",at=(Y,he)=>{if(!Y)return Y;if(Ve==="upper")return Y.toUpperCase();if(Ve==="lower")return Y.toLowerCase();if(Ve==="title")return Y.replace(/\w\S*/g,de=>de.charAt(0).toUpperCase()+de.substr(1).toLowerCase());if(Ve==="sentence"){const de=Y.toLowerCase();return he?de.charAt(0).toUpperCase()+de.slice(1):de}return Ve==="invert"?Y.replace(/\w\S*/g,de=>de.charAt(0).toLowerCase()+de.slice(1).toUpperCase()):Y};let U=B.words||[];if(U.length===0){const Y=B.text.split(` +`);U=[],Y.forEach((he,de)=>{const Le=he.split(" ").map(ke=>({text:ke,startTime:B.time,endTime:B.endTime||B.time+3}));U.push(...Le),deY.text===` +`||Y.text.trim().length>0).map((Y,he)=>({...Y,text:Y.text===` +`?` +`:at(Y.text,he===0).trim()}));(Re?.highlightEffect?.includes("cyberpunk")||Re?.textEffect==="cyberpunk")&&(xe="'Orbitron', sans-serif"),C.font=`${et} ${Oe} ${pe}px ${xe}`;const ce=[];let Ae=[],ve=0,Me=.3;["default","custom"].includes(m)?Me=.25:m==="monospace"&&(Me=.5);const ue=C.measureText("M").width*Me;Z.forEach((Y,he)=>{if(Y.text===` +`){Ae.length>0&&ce.push(Ae),Ae=[],ve=0;return}const de=C.measureText(Y.text).width;let ke=!Y.text.endsWith(" ");const Ie=/[-‐‑‒–—―]$/,_=/^[-‐‑‒–—―]/;Ie.test(Y.text.trim())&&(ke=!1);const st=Z[he+1];st&&(_.test(st.text.trim())||st.text===` +`)&&(ke=!1);const wt=ke?ue:0;ve+de>Pe&&Ae.length>0&&(ce.push(Ae),Ae=[],ve=0),Ae.push(Y),ve+=de+wt}),Ae.length>0&&ce.push(Ae);const Ge=ae-(ce.length-1)*P/2;let w=Re.highlightColor||"#fb923c",M=Re.highlightBackground||"#ffffff";const R=Re.highlightEffect||"none";Re.useCustomHighlightColors||(R.includes("blue")||R.includes("cyan")?(w="#3b82f6",M="#3b82f6"):R.includes("purple")?(w="#a855f7",M="#a855f7"):R.includes("green")?(w="#22c55e",M="#22c55e"):R.includes("pink")?(w="#ec4899",M="#ec4899"):R.includes("neon")?(w="#ffffff",M="#ffffff"):R.includes("gold")?(w="#FFD700",M="#B8860B"):R.includes("chrome")?(w="#E0E0E0",M="#757575"):R.includes("fire")?(w="#FF4500",M="#FF0000"):R.includes("glass")?(w="#ffffff",M="rgba(255,255,255,0.1)"):R==="karaoke"&&(w="#fb923c",M="#fb923c"));let V=Re.fontColor||"#ffffff";Re.highlightEffect==="karaoke-smooth-white"&&(V="#ffffff"),ce.forEach((Y,he)=>{const de=Ge+he*P;let Le=0;Y.forEach((Ie,_)=>{if(Le+=C.measureText(Ie.text).width,_{const st=C.measureText(Ie.text).width,wt=Be>=Ie.startTime,Dt=Be>=Ie.startTime&&Be.3&&Bt<.45)&&(yt=1.15,dt=1.15)}else if(R.includes("flash"))Ot=.5+Math.sin(Be*10)*.5;else if(R.includes("tada")){const Bt=Be*2%1;Bt<.1?(mt=-.05,yt=.9):Bt<.2&&(mt=.05,yt=1.1)}else R.includes("swing")?mt=Math.sin(Be*4)*.15:R.includes("glitch")&&Math.sin(Be*15)>.8&&(Ue+=(Math.random()-.5)*10,me+=(Math.random()-.5)*10);const Ct=.3;if(Je1-Math.pow(1-bn,3))(Bt);if(R.includes("fade"))Ot=Bt;else if(R.includes("slide"))me+=(1-Ht)*30*z,Ot=Ht;else if(R.includes("drop"))me-=(1-Ht)*50*z,Ot=Ht;else if(R.includes("zoom")||R.includes("scale")){const bn=.5+.5*Ht;yt*=bn,dt*=bn}else if(R.includes("elastic")){const bn=Bt===0?0:Bt===1?1:Math.pow(2,-10*Bt)*Math.sin((Bt*10-.75)*(2*Math.PI)/3)+1;yt*=bn,dt*=bn}else if(R.includes("flip"))dt*=Ht;else if(R.includes("rotate-in"))mt+=(1-Ht)*-1,Ot=Ht;else if(R.includes("roll"))Ue-=(1-Ht)*50*z,mt-=(1-Ht)*Math.PI,Ot=Ht;else if(R.includes("lightspeed"))Ue+=(1-Ht)*100*z,Ot=Ht;else if(R.includes("blur"))Jt=(1-Ht)*10,Ot=Ht;else if(R.includes("shatter")){const bn=1+(1-Ht)*2;yt*=bn,dt*=bn,Jt=(1-Ht)*10,Ot=Ht}else R.includes("spiral")&&(yt*=Ht,dt*=Ht,mt+=(1-Ht)*Math.PI*2)}else R.includes("scale")&&(yt*=1.3,dt*=1.3)}if(C.save(),Ot<1&&(C.globalAlpha*=Ot),Jt>0&&(C.filter=`blur(${Jt}px)`),mt!==0||yt!==1||dt!==1){const Je=Ue+st/2,Ct=me;C.translate(Je,Ct),C.rotate(mt),C.scale(yt,dt),C.translate(-Je,-Ct)}if(Wt){if(R==="karaoke-smooth-plus"){const Je=Re.textEffect||"none";if(Dt){const Ct=Ie.endTime-Ie.startTime,Bt=Be-Ie.startTime,li=Math.max(0,Math.min(1,Bt/Ct)),Ht=Ue+st*li,bn=Re?.textDecoration||"none",Sl=to=>{if(bn!=="none"){C.lineWidth=Math.max(2,3*z),C.strokeStyle=to,C.beginPath();const Ho=me+pe*.45;bn.includes("underline")&&(C.moveTo(Ue,Ho),C.lineTo(Ue+st,Ho)),bn.includes("line-through")&&(C.moveTo(Ue,me),C.lineTo(Ue+st,me)),C.stroke()}};C.save(),C.beginPath(),C.rect(Ue-50,me-P,Ht-(Ue-50),P*2),C.clip(),C.fillStyle=w,fe(C,Ie.text,Ue,me,Je),Sl(w),C.restore(),C.save(),C.beginPath(),C.rect(Ht,me-P,Ue+st+50-Ht,P*2),C.clip(),C.fillStyle=V,C.fillText(Ie.text,Ue,me),Sl(V),C.restore(),Mt="rgba(0,0,0,0)"}else C.fillStyle=w,fe(C,Ie.text,Ue,me,Je),Mt=w}else if(R.includes("gradient")||R.includes("chrome")||R.includes("gold")){const Je=C.createLinearGradient(Ue,me-P/2,Ue,me+P/2);R.includes("gold")?(Je.addColorStop(0,"#d4af37"),Je.addColorStop(1,"#C5A028")):R.includes("chrome")?(Je.addColorStop(0,"#ebebeb"),Je.addColorStop(.5,"#616161"),Je.addColorStop(.51,"#ebebeb"),Je.addColorStop(1,"#ebebeb")):(Je.addColorStop(0,w),Je.addColorStop(1,M)),C.fillStyle=Je}if(R.includes("shadow")&&(C.save(),C.fillStyle="#000000",C.fillText(Ie.text,Ue+2*z,me+2*z),C.restore()),R.includes("3d")){const Je=C.fillStyle;C.fillStyle="rgba(0,0,0,0.5)";for(let Ct=1;Ct<=3;Ct++)C.fillText(Ie.text,Ue+Ct*z,me+Ct*z);C.fillStyle=Je}if(R.includes("neon-multi"))C.shadowBlur=10,C.shadowColor="#fff",C.fillText(Ie.text,Ue,me),C.shadowBlur=20,C.shadowColor="#ff00de",C.fillText(Ie.text,Ue,me),C.shadowBlur=35,C.shadowColor="#00ffff",C.fillText(Ie.text,Ue,me);else if(R.includes("cyberpunk"))C.save(),C.fillStyle="#05d9e8",C.fillText(Ie.text,Ue-1,me-1),C.restore(),C.save(),C.fillStyle="#000000",C.fillText(Ie.text,Ue+2,me+2),C.restore(),C.fillStyle="#fcee0a",C.fillText(Ie.text,Ue,me);else if(R.includes("glitch-text")){const Je=(Math.random()-.5)*5,Ct=(Math.random()-.5)*2;C.save(),C.fillStyle="red",C.fillText(Ie.text,Ue+Je,me+Ct),C.restore(),C.save(),C.fillStyle="cyan",C.fillText(Ie.text,Ue-Je,me-Ct),C.restore(),C.fillStyle="#ffffff",C.fillText(Ie.text,Ue,me)}else if(R.includes("retro")||R.includes("vhs")){const Je=Math.sin(Be*5)*2*z,Ct=Math.random()>.95?(Math.random()-.5)*5:0;C.globalCompositeOperation="screen",C.fillStyle="#ff0000",C.fillText(Ie.text,Ue-3*z+Je,me+Ct),C.fillStyle="#00ff00",C.fillText(Ie.text,Ue+Ct,me-Je),C.fillStyle="#0000ff",C.fillText(Ie.text,Ue+3*z-Je,me+Ct)}else if(R.includes("fire")){const Je=Math.abs(Math.sin(Be*15))*5,Ct=Math.sin(Be*20)*1*z;C.shadowBlur=5+Je,C.shadowColor="#ff0000",C.fillStyle="#ff4500",C.fillText(Ie.text,Ue,me+Ct),C.shadowBlur=2,C.shadowColor="#ffff00",C.fillStyle="#ffcc00",C.fillText(Ie.text,Ue+Math.sin(Be*25)*1*z,me-1*z+Ct)}else if(R.includes("typewriter")){const Je=Be-Ie.startTime,Ct=Ie.endTime-Ie.startTime,Bt=Math.min(1,Math.max(0,Je/Ct)),li=Math.floor(Ie.text.length*Bt),Ht=Ie.text.substring(0,li);R.includes("outline")?(C.strokeStyle=w,C.strokeText(Ht,Ue,me)):C.fillText(Ht,Ue,me)}else!R.includes("neon-multi")&&!R.includes("retro")&&!R.includes("vhs")&&!R.includes("fire")&&(R.includes("outline")?(C.strokeStyle=w,C.lineWidth=2*z,C.strokeText(Ie.text,Ue,me)):C.fillText(Ie.text,Ue,me))}else C.fillText(Ie.text,Ue,me);const Dn=Re?.textDecoration||"none";if(Dn!=="none"){if(C.lineWidth=Math.max(2,3*z),C.strokeStyle=Mt,C.beginPath(),Dn.includes("underline")&&!R.includes("underline")){const Je=me+pe*.45;C.moveTo(Ue,Je),C.lineTo(Ue+st,Je)}Dn.includes("line-through")&&(C.moveTo(Ue,me),C.lineTo(Ue+st,me)),C.stroke()}C.restore(),C.restore();let Rn=!Ie.text.endsWith(" ");const ci=/[-‐‑‒–—―]$/,Ti=/^[-‐‑‒–—―]/;ci.test(Ie.text.trim())&&(Rn=!1);const Wn=Y[_+1];Wn&&Ti.test(Wn.text.trim())&&(Rn=!1),ke+=st+(Rn?ue:0)}),C.restore()})},be=(C,B,ne,ae,Pe,P,Be,Re)=>{const xe=se(C,B,Pe),pe=ae-(xe.length-1)*P/2;xe.forEach((Oe,et)=>{const z=pe+et*P;if(Be==="glass"){const Ve=C.measureText(Oe).width;C.save(),C.fillStyle="rgba(255, 255, 255, 0.1)",C.beginPath(),C.roundRect?C.roundRect(ne-(C.textAlign==="center"?Ve/2:C.textAlign==="right"?Ve:0)-10,z-P/2,Ve+20,P,8):C.rect(ne-(C.textAlign==="center"?Ve/2:C.textAlign==="right"?Ve:0)-10,z-P/2,Ve+20,P),C.fill(),C.strokeStyle="rgba(255, 255, 255, 0.2)",C.stroke(),C.restore()}fe(C,Oe,ne,z,Be,Re)})},ye='ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',tt='ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',Ne='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',Xe='"Metal Mania", cursive',$e='"Fredoka One", cursive',Ze='"Shadows Into Light", cursive',gt='"Dancing Script", cursive',xt='"Orbitron", sans-serif',Nt='"UnifrakturMaguntia", cursive';let G=ye;m==="classic"?G=tt:m==="monospace"?G=Ne:m==="metal"?G=Xe:m==="kids"?G=$e:m==="sad"?G=Ze:m==="romantic"?G=gt:m==="tech"?G=xt:m==="gothic"?G=Nt:m==="custom"&&(G=E?.fontFamily||ye),x&&(G="CustomFont, sans-serif"),E&&E.fontFamily!=="sans-serif"&&(G=E.fontFamily);const Ee=t<=o,ie=Math.min(t,o)/1080;if(E&&(E.backgroundSource==="color"||E.backgroundSource==="smart-gradient")?e.fillStyle=E.backgroundColor||"#000000":e.fillStyle="#000000",e.fillRect(0,0,t,o),E?.backgroundSource==="gradient"&&E.backgroundGradient)e.fillStyle=E.backgroundGradient,e.fillRect(0,0,t,o);else if(E?.backgroundSource==="smart-gradient"){const C=E.backgroundColor||"#312e81",B=$(C),ne=e.createLinearGradient(0,0,t,o);ne.addColorStop(0,C),ne.addColorStop(.5,`rgb(${Math.floor(B.r*.6)}, ${Math.floor(B.g*.6)}, ${Math.floor(B.b*.6)})`),ne.addColorStop(1,"#000000"),e.fillStyle=ne,e.fillRect(0,0,t,o)}else if(E?.backgroundSource==="image"&&E.backgroundImage){const C=g.get("__custom_bg__");C&&oe(C)}if(E&&E.backgroundBlurStrength>0?e.filter=`blur(${E.backgroundBlurStrength}px)`:S&&(e.filter="blur(12px)"),!E||E.backgroundSource==="timeline"||E.backgroundSource==="custom"){const C=E?E.backgroundSource==="timeline":!1;let B=!1;if(C){const ne=E?.visualTransitionType||"none",ae=E?.visualTransitionDuration||1,Pe=p.filter(P=>P.type==="audio"?!1:l>=P.startTime&&l=P.endTime&&l{const Re=(P.layer||0)-(Be.layer||0);return Re!==0?Re:P.startTime-Be.startTime}),Pe.length>0&&(Pe.forEach(P=>{const Be=P.layer||0;if(E&&E.layerVisibility?.visual?.[Be]===!1)return;const Re=P.type==="video"?v.get(P.id):null,xe=P.type!=="video"?g.get(P.id):null;let pe=1;if(ne!=="none"){if(l=P.endTime){let Oe=!1;if(ne==="crossfade"&&(Oe=p.some(et=>et.id!==P.id&&(et.layer||0)===(P.layer||0)&&et.startTime>=P.endTime-.1&&et.startTimeP.endTime-ae){const Oe=(P.endTime-l)/ae;pe=Math.min(pe,Math.max(0,Math.min(1,Oe)))}}pe>0&&(e.save(),e.globalAlpha=pe,Re?oe(Re):xe&&oe(xe),e.restore())}),B=!0)}if(!B&&u.coverUrl&&(p.length===0||!C)){const ne=u.backgroundType==="video"?v.get("background"):null,ae=g.get("cover");ne?oe(ne):ae&&oe(ae)}}if((E&&E.backgroundBlurStrength>0||S)&&(e.filter="none"),!["just_video","none"].includes(m)&&!E?.useRealColorMedia&&(e.fillStyle=E&&(E.backgroundSource==="color"||E.backgroundSource==="gradient")?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",e.fillRect(0,0,t,o)),E?.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(m==="just_video"||m==="none")return;const Ye=s.findIndex((C,B)=>{if(C.endTime!==void 0)return l>=C.time&&l=C.time&&(!ne||l0)if(lB.time>l);ut=C!==-1?C:s.length-1}const L=E?.introMode==="manual"&&E.introText?E.introText:`${u.title} +${u.artist}`;let le=Ye===-1&&l<5&&(E?.showIntro??!0)&&(E?.introMode!=="manual"||I)&&(s.length===0||l0)){let C=o/2;E?.contentPosition==="top"?C=o*(.15*(E.marginTopScale??1)):E?.contentPosition==="bottom"&&(C=o*(1-.1*(E.marginBottomScale??1)));let B=0;const ne=["large","large_upper","big_center","metal","kids","sad","romantic","tech","gothic","testing","testing_up","one_line","one_line_up","custom"].includes(m);if(ne||m==="slideshow"||m==="subtitle"){const Re=le?{text:L}:s[Ye]||s[ut];if(Re){e.font=`900 ${we}px ${G}`;const xe=["large_upper","big_center","metal","tech","testing_up","one_line_up"].includes(m)?Re.text.toUpperCase():Re.text,pe=se(e,xe,t*.9);pe.length>1&&(B=(pe.length-1)*(we*1.2)/2)}}let ae=ne?-1:-2,Pe=ne?1:2;E?.lyricDisplayMode==="active-only"?(ae=0,Pe=0):E?.lyricDisplayMode==="next-only"?(ae=0,Pe=1):E?.lyricDisplayMode==="previous-next"?(ae=-1,Pe=1):E?.lyricDisplayMode==="all"&&(ae=-s.length,Pe=s.length);const P=new Map,Be=new Map;{const Re=Math.max((Ee?30:40)*ie,Ke-we);for(let xe=ae;xe<=Pe;xe++){let pe=0,Oe=!1;if(le&&xe===0){const et=we*1.2,z=Ce*1.2,at=L.split(` +`).length>1;pe=et+(at?z:0),Oe=!0}else{const et=ut+xe;if(et>=0&&etve.charAt(0).toUpperCase()+ve.substr(1).toLowerCase()):ce==="sentence"?Z=Z.charAt(0).toUpperCase()+Z.slice(1).toLowerCase():ce==="invert"&&(Z=Z.replace(/\w\S*/g,ve=>ve.charAt(0).toLowerCase()+ve.slice(1).toUpperCase())),pe=se(e,Z,t*.9).length*(Ve*1.2)}}Be.set(xe,pe)}P.set(0,C);for(let xe=1;xe<=Pe;xe++){const pe=P.get(xe-1)??C,Oe=Be.get(xe-1)??0,et=Be.get(xe)??0;P.set(xe,pe+Oe/2+Re+et/2)}for(let xe=-1;xe>=ae;xe--){const pe=P.get(xe+1)??C,Oe=Be.get(xe+1)??0,et=Be.get(xe)??0;P.set(xe,pe-Oe/2-Re-et/2)}}for(let Re=ae;Re<=Pe;Re++){let xe=null,pe=!1;if(le)Re===0&&(xe={time:0,text:L},pe=!0);else{const Oe=ut+Re;Oe>=0&&Oe1+2.70158*Math.pow(dt-1,3)+1.70158*Math.pow(dt-1,2),yt=dt=>{const Ot=2*Math.PI/3;return dt===0?0:dt===1?1:Math.pow(2,-10*dt)*Math.sin((dt*10-.75)*Ot)+1};if(U==="slide")ce=(1-Ue)*(ot0&&(e.filter=`blur(${ue}px)`);const w=pe&&E?.textAnimation||"none";let M=xe.text,R=E?.textCase||"none";R==="none"&&pe&&["large_upper","big_center","metal","tech","testing_up","one_line_up"].includes(m)&&(R="upper"),R==="upper"?M=M.toUpperCase():R==="lower"?M=M.toLowerCase():R==="title"?M=M.replace(/\w\S*/g,ot=>ot.charAt(0).toUpperCase()+ot.substr(1).toLowerCase()):R==="sentence"?M=M.charAt(0).toUpperCase()+M.slice(1).toLowerCase():R==="invert"&&(M=M.replace(/\w\S*/g,ot=>ot.charAt(0).toLowerCase()+ot.slice(1).toUpperCase()));let V=0,Y=0,he=1,de=1,Le=0;if(pe&&w!=="none")if(w==="bounce")Y=Math.sin(l*6)*15*ie;else if(w==="pulse"){const ot=1+Math.sin(l*4)*.08;he=ot,de=ot}else if(w==="wave")Y=Math.sin(l*4)*20*ie,Le=Math.sin(l*4)*.05;else if(w==="glitch")Math.sin(l*10)>.8&&(V=(Math.random()-.5)*15*ie,Y=(Math.random()-.5)*15*ie);else if(w==="shake")V=(Math.random()-.5)*5*ie,Y=(Math.random()-.5)*5*ie;else if(w==="typewriter"){const Wt=Math.floor((l-xe.time)*30);M=M.substring(0,Math.max(0,Wt))}else if(w==="wobble"){Le=Math.sin(l*5)*.05;const ot=1+Math.sin(l*3)*.05;he=ot,de=ot}else if(w==="breathe"){const ot=1+Math.sin(l*2)*.03;he=ot,de=ot}else if(w==="rotate")Le=Math.sin(l*2)*.05;else if(w==="sway")Le=Math.sin(l*2)*.08;else if(w==="flicker")e.globalAlpha=Z*(.8+Math.random()*.2);else if(w==="jello")he=1+Math.sin(l*6)*.1,de=1-Math.sin(l*6)*.1;else if(w==="spin")Le=l%2*Math.PI;else if(w==="heartbeat"){const ot=l*1.5%1;(ot<.1||ot>.3&&ot<.4)&&(he=1.1,de=1.1)}else if(w==="tada"){const ot=l*1.5%1;ot<.1?(he=.9,de=.9,Le=-.05):ot<.2?(he=1.1,de=1.1,Le=.05):(he=1,de=1,Le=0)}else w==="swing"&&(Le=Math.sin(l*3)*.1);let ke=0;P.has(Re)?ke=P.get(Re)+(Re===0?ce:0):(ke=m==="subtitle"&&Re===0&&E?.lyricDisplayMode!=="all"?o-140*ie:C+Re*Ke+(Re===0?ce:0),m!=="custom"&&(Re<0?ke-=B:Re>0&&(ke+=B))),ke+=Y;let Ie=t/2;e.textAlign==="left"?Ie=60*ie:e.textAlign==="right"&&(Ie=t-60*ie),Ie+=Ae+V;const _=ve*he,st=Me*de,wt=Ge+Le;(_!==1||st!==1||wt!==0)&&(e.translate(Ie,ke),e.rotate(wt),e.scale(_,st),e.translate(-Ie,-ke));const Dt=pe?E?.textEffect||"preset":"none";if(le&&Re===0&&E?.introMode!=="manual"){const ot=M.split(` +`),Wt=ot[0],me=ot.slice(1).join(` +`),Ue=we*1.2,mt=Ce*1.2,yt=20*ie;let dt=ke;me&&(dt=ke-mt/2-yt/2);const Ot=ke+Ue/2+yt/2;if(e.font=`${Ve} ${z} ${we}px ${G}`,be(e,Wt,Ie,dt,t*.9,Ue,Dt,at),me){const Jt=m==="custom"&&E?.fontWeight?E.fontWeight:"400";e.font=`${Ve} ${Jt} ${Ce}px ${G}`,be(e,me,Ie,Ot,t*.9,mt,Dt,at)}}else{const ot=pe?we:Ce;E&&E.highlightEffect&&E.highlightEffect,pe&&xe?De(e,xe,Ie,ke,t*.9,ot*(E?.lyricLineHeight||1.2),l,E,G,ot,z,Ve,ie):be(e,M,Ie,ke,t*.9,ot*(E?.lyricLineHeight||1.2),Dt,at)}e.restore()}}}if(!["subtitle","just_video","none"].includes(m)){const C=E?E.showTitle||E.showArtist:!0,B=E?E.showCover:!0;if(C||B)if(m==="custom"||m==="default"){const ne=E?.infoPosition||"top-left",ae=E?.infoStyle||"classic",Pe=ae==="box",P=Pe?16*ie:12*ie,Be=40*ie*(E?.infoMarginScale??1);let Re="left",xe="top";ne.includes("left")?Re="left":ne.includes("right")?Re="right":Re="center",ne.includes("top")?xe="top":xe="bottom";const pe=E?.infoSizeScale??1,Oe=(ae==="minimal"||ae==="modern"?0:100*ie)*pe,et=B&&Oe>0&&u.coverUrl!==null,z=et?u.backgroundType==="video"?v.get("background"):g.get("cover"):null,Ve=(ae==="minimal"?20:ae==="modern"||ae==="modern_art"?40:28)*ie,at=(ae==="minimal"?14:ae==="modern"||ae==="modern_art"?24:18)*ie,U=Ve*pe,Z=at*pe,ce=E?.infoFontFamily||G,Ae=E?.infoFontWeight||"bold",ve=E?.infoFontStyle||"normal",Me=`${ve} ${Ae} ${U}px ${ce}`,ue=`${ve} ${Ae} ${Z}px ${ce}`,Ge=20*ie,w=Pe?24*ie:0,M=E?.infoFontColor||"#ffffff",R=ae==="modern"||ae==="modern_art"?M:E?.infoFontColor||"#d4d4d8";e.font=Me;const V=e.measureText(u.title),Y=E?.showTitle?V.width:0;e.font=ue;const he=e.measureText(u.artist),de=E?.showArtist?he.width:0;let Le=0,ke=0;if(Re==="center"){Le=Math.max(et&&z?Oe:0,Y,de)+w*2;let Ue=0;et&&z&&(Ue+=Oe),(E?.showTitle??!0)&&(Ue+=(et&&z?Ge:0)+U),(E?.showArtist??!0)&&(Ue+=(et&&z||(E?.showTitle??!0)?5*ie:0)+Z),ke=Ue+w*2}else{const me=Math.max(Y,de);Le=(et&&z?Oe+Ge:0)+me+w*2;const mt=(E?.showTitle?U:0)+(E?.showArtist?Z+5*ie:0);ke=Math.max(mt,et&&z?Oe:0)+w*2}let Ie=0,_=0;Re==="left"?Ie=Be:Re==="right"?Ie=t-Be:Ie=t/2,xe==="top"?_=Be:_=o-Be;let st=0,wt=0;Re==="left"?st=Ie:Re==="right"?st=Ie-Le:st=Ie-Le/2,xe==="top"?wt=_:wt=_-ke,Pe&&(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(st,wt,Le,ke,P),e.fill(),e.restore());const Dt=st+w,Mt=wt+w,ot=Le-w*2,Wt=ke-w*2;if(Re==="center"){let me=Mt;const Ue=Dt+ot/2;if(e.textAlign="center",xe==="top"){if(et&&z){e.save(),e.beginPath();const mt=Ue-Oe/2;ae==="circle_art"?e.arc(Ue,me+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(mt,me,Oe,Oe,P/2),e.clip(),e.drawImage(z,mt,me,Oe,Oe),e.restore(),me+=Oe+Ge}(E?.showTitle??!0)&&(e.fillStyle=M,e.font=Me,e.textBaseline="top",e.fillText(u.title,Ue,me),me+=U+5*ie),(E?.showArtist??!0)&&(e.fillStyle=R,e.font=ue,e.textBaseline="top",e.fillText(u.artist,Ue,me))}else{if(et&&z){e.save(),e.beginPath();const mt=Ue-Oe/2;ae==="circle_art"?e.arc(Ue,me+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(mt,me,Oe,Oe,P/2),e.clip(),e.drawImage(z,mt,me,Oe,Oe),e.restore(),me+=Oe+Ge}(E?.showTitle??!0)&&(e.fillStyle=M,e.font=Me,e.textBaseline="top",e.fillText(u.title,Ue,me),me+=U+5*ie),(E?.showArtist??!0)&&(e.fillStyle=R,e.font=ue,e.textBaseline="top",e.fillText(u.artist,Ue,me))}}else{const me=Re==="right",Ue=Mt+Wt/2;let mt=Dt;if(me&&(mt=Dt+ot),et&&z){const Ot=Ue-Oe/2,Jt=me?mt-Oe:mt;e.save(),e.beginPath(),ae==="circle_art"?e.arc(Jt+Oe/2,Ot+Oe/2,Oe/2,0,Math.PI*2):e.roundRect(Jt,Ot,Oe,Oe,P/2),e.clip(),e.drawImage(z,Jt,Ot,Oe,Oe),e.restore(),me?mt-=Oe+Ge:mt+=Oe+Ge}const yt=(E?.showTitle?U:0)+(E?.showArtist?Z+5*ie:0);let dt=Ue-yt/2;e.textAlign=me?"right":"left",e.textBaseline="top",(E?.showTitle??!0)&&(e.fillStyle=M,e.font=Me,e.fillText(u.title,mt,dt),dt+=U+5*ie),(E?.showArtist??!0)&&(e.fillStyle=R,e.font=ue,e.fillText(u.artist,mt,dt))}}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 ne=80*ie;["testing","testing_up","one_line","one_line_up"].includes(m)&&(ne=120*ie),(E?.showTitle??!0)&&(e.font=`bold ${20*ie}px ${G}`,e.fillStyle="#ffffff",e.fillText(m==="tech"?u.title.toUpperCase():u.title,t/2,o-ne-30*ie)),(E?.showArtist??!0)&&(e.font=`${16*ie}px ${G}`,e.fillStyle="#d4d4d8",e.fillText(u.artist,t/2,o-ne))}}else{const ne=40*ie*(E?.infoMarginScale??1),ae=t===o,Pe=(Ee?ae?110:150:100)*ie,P=u.coverUrl?g.get("cover"):null,Be=12*ie;if(Ee){const Re=ne*(ae?1.5:3),xe=t/2,pe=xe-Pe/2,Oe=Re;if(B&&(e.save(),e.beginPath(),e.roundRect(pe,Oe,Pe,Pe,Be),e.clip(),P?e.drawImage(P,pe,Oe,Pe,Pe):(e.fillStyle="#27272a",e.fillRect(pe,Oe,Pe,Pe)),e.restore()),C){e.textAlign="center",e.textBaseline="top";const et=Oe+(B?Pe+25*ie:0),z=E?.infoFontFamily||G,Ve=E?.infoFontColor||"#ffffff",at=E?.infoFontColor||"#d4d4d8",U=E?.infoFontWeight||"bold",Z=E?.infoFontStyle||"normal";(E?.showTitle??!0)&&(e.font=`${Z} ${U} ${(ae?26:36)*ie}px ${z}`,e.fillStyle=Ve,e.fillText(u.title,xe,et)),(E?.showArtist??!0)&&(e.font=`${Z} ${U} ${(ae?18:24)*ie}px ${z}`,e.fillStyle=at,e.fillText(u.artist,xe,et+(E?.showTitle??!0?(ae?30:40)*ie:0)))}}else{const Re=ne,xe=ne;if(B&&(e.save(),e.beginPath(),e.roundRect(Re,xe,Pe,Pe,Be),e.clip(),P?e.drawImage(P,Re,xe,Pe,Pe):(e.fillStyle="#27272a",e.fillRect(Re,xe,Pe,Pe)),e.restore()),C){e.textAlign="left",e.textBaseline="top";const pe=E?.infoFontFamily||G,Oe=E?.infoFontColor||"#ffffff",et=E?.infoFontColor||"#d4d4d8",z=E?.infoFontWeight||"bold",Ve=E?.infoFontStyle||"normal",at=Re+(B?Pe+25*ie:0),U=28*ie,Z=xe+Pe/2-U;(E?.showTitle??!0)&&(e.font=`${Ve} ${z} ${U}px ${pe}`,e.fillStyle=Oe,e.fillText(u.title,at,Z)),(E?.showArtist??!0)&&(e.font=`${Ve} ${z} ${18*ie}px ${pe}`,e.fillStyle=et,e.fillText(u.artist,at,Z+(E?.showTitle??!0?U+5*ie:0)))}}}}if(E?.showChannelInfo&&!["subtitle","just_video","none"].includes(m)){const C=E.channelInfoPosition||"bottom-right",B=E.channelInfoStyle||"classic",ne=E.channelInfoSizeScale??1,ae=E.channelInfoMarginScale??1,Pe=g.get("__channel_info__"),P=E.channelInfoText;if(!(!Pe&&!P)){if(!(B==="logo"&&!Pe)){if(!(B==="minimal"&&!P)){e.save();const Be=40*ie*ae,Re=80*ie*ne,xe=B==="modern"||B==="logo"?Re*1.2:Re,pe=20*ie*ne,Oe=g.get("__channel_info_text_svg__"),et=!!Oe;let z=0,Ve=pe;if(et&&Oe){Ve=pe*1.5;const M=Oe.width/Oe.height;z=Ve*M}else{const M=E.channelInfoFontWeight||"bold",R=E.channelInfoFontStyle||"normal";e.font=`${R} ${M} ${pe}px ${E.channelInfoFontFamily||"sans-serif"}`,P&&B!=="logo"&&(z=e.measureText(P).width)}const at=12*ie*ne,U=12*ie*ne,Z=8*ie*ne;let ce=0,Ae=0;const ve=!!Pe&&B!=="minimal",Me=!!P&&B!=="logo";B==="modern"?(ce=Math.max(ve?xe:0,Me?z+U*2:0),Ae=(ve?xe:0)+(ve&&Me?at:0)+(Me?Ve+Z*2:0)):B==="box"?(ce=(ve?xe:0)+(ve&&Me?at:0)+(Me?z:0)+U*2,Ae=Math.max(ve?xe:0,Me?Ve:0)+Z*2):B==="minimal"?(ce=Me?z+U*2:0,Ae=Me?Ve+Z*2:0):B==="logo"?(ce=xe,Ae=xe):(ce=(ve?xe:0)+(ve&&Me?at:0)+(Me?z+U*2:0),Ae=Math.max(ve?xe:0,Me?Ve+Z*2:0));let ue=0,Ge=0;C.includes("left")?ue=Be:C.includes("right")?ue=t-Be-ce:C.includes("center")&&(ue=(t-ce)/2),C.includes("top")?Ge=Be:C.includes("bottom")&&(Ge=o-Be-Ae),B==="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(ue,Ge,ce,Ae,12*ie*ne),e.fill()):e.fillRect(ue,Ge,ce,Ae),e.shadowColor="transparent",e.shadowBlur=0);const w=(M,R,V,Y,he)=>{if(B!=="box"&&B!=="minimal"&&(e.fillStyle="rgba(0, 0, 0, 0.2)",e.roundRect?(e.beginPath(),e.roundRect(M,R,V,Y,8*ie*ne),e.fill()):e.fillRect(M,R,V,Y)),et&&Oe){const de=M+(V-z)/2,Le=R+(Y-Ve)/2;e.drawImage(Oe,de,Le,z,Ve)}else{e.fillStyle=E.channelInfoFontColor||"#ffffff",e.textAlign="left",e.textBaseline="top",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4;const de=M+(V-z)/2,Le=R+(Y-Ve)/2+Ve*.1;e.fillText(he,de,Le),e.shadowColor="transparent"}};if(B==="modern"){let M=Ge;if(ve){const R=ue+(ce-xe)/2;e.drawImage(Pe,R,M,xe,xe),M+=xe+at}if(Me){const R=z+U*2,V=Ve+Z*2,Y=ue+(ce-R)/2;w(Y,M,R,V,P)}}else{const M=C.includes("right");let R=ue+(B==="box"?U:0);const V=Ge+Ae/2;if(M&&(B==="classic"||B==="circle")){if(Me){const Y=z+U*2,he=Ve+Z*2;w(R,V-he/2,Y,he,P),R+=Y+at}ve&&(B==="circle"?(e.save(),e.beginPath(),e.arc(R+xe/2,V,xe/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(Pe,R,V-xe/2,xe,xe),e.restore()):e.drawImage(Pe,R,V-xe/2,xe,xe))}else if(ve&&(B==="circle"?(e.save(),e.beginPath(),e.arc(R+xe/2,V,xe/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(Pe,R,V-xe/2,xe,xe),e.restore()):e.drawImage(Pe,R,V-xe/2,xe,xe),R+=xe+at),Me){const Y=z+(B==="box"?0:U*2),he=Ve+(B==="box"?0:Z*2);B==="box"?et&&Oe?(e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4,e.drawImage(Oe,R,V-Ve/2,z,Ve),e.shadowColor="transparent"):(e.fillStyle=E.channelInfoFontColor||"#ffffff",e.textAlign="left",e.textBaseline="middle",e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=4,e.fillText(P,R,V+Ve*.1),e.shadowColor="transparent"):w(R,V-he/2,Y,he,P)}}e.restore()}}}}};var fn;(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"})(fn||(fn={}));const VM=(()=>{let e=0;return()=>e++})(),$M=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),qM=new Error("called FFmpeg.terminate()");class YM{#t=null;#i={};#n={};#o=[];#l=[];loaded=!1;#a=()=>{this.#t&&(this.#t.onmessage=({data:{id:t,type:o,data:l}})=>{switch(o){case fn.LOAD:this.loaded=!0,this.#i[t](l);break;case fn.MOUNT:case fn.UNMOUNT:case fn.EXEC:case fn.FFPROBE:case fn.WRITE_FILE:case fn.READ_FILE:case fn.DELETE_FILE:case fn.RENAME:case fn.CREATE_DIR:case fn.LIST_DIR:case fn.DELETE_DIR:this.#i[t](l);break;case fn.LOG:this.#o.forEach(s=>s(l));break;case fn.PROGRESS:this.#l.forEach(s=>s(l));break;case fn.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((u,p)=>{const g=VM();this.#t&&this.#t.postMessage({id:g,type:t,data:o},l),this.#i[g]=u,this.#n[g]=p,s?.addEventListener("abort",()=>{p(new DOMException(`Message # ${g} was aborted`,"AbortError"))},{once:!0})}):Promise.reject($M);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:fn.LOAD,data:o},void 0,l));exec=(t,o=-1,{signal:l}={})=>this.#e({type:fn.EXEC,data:{args:t,timeout:o}},void 0,l);ffprobe=(t,o=-1,{signal:l}={})=>this.#e({type:fn.FFPROBE,data:{args:t,timeout:o}},void 0,l);terminate=()=>{const t=Object.keys(this.#n);for(const o of t)this.#n[o](qM),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:fn.WRITE_FILE,data:{path:t,data:o}},s,l)};mount=(t,o,l)=>{const s=[];return this.#e({type:fn.MOUNT,data:{fsType:t,options:o,mountPoint:l}},s)};unmount=t=>{const o=[];return this.#e({type:fn.UNMOUNT,data:{mountPoint:t}},o)};readFile=(t,o="binary",{signal:l}={})=>this.#e({type:fn.READ_FILE,data:{path:t,encoding:o}},void 0,l);deleteFile=(t,{signal:o}={})=>this.#e({type:fn.DELETE_FILE,data:{path:t}},void 0,o);rename=(t,o,{signal:l}={})=>this.#e({type:fn.RENAME,data:{oldPath:t,newPath:o}},void 0,l);createDir=(t,{signal:o}={})=>this.#e({type:fn.CREATE_DIR,data:{path:t}},void 0,o);listDir=(t,{signal:o}={})=>this.#e({type:fn.LIST_DIR,data:{path:t}},void 0,o);deleteDir=(t,{signal:o}={})=>this.#e({type:fn.DELETE_DIR,data:{path:t}},void 0,o)}var Xy;(function(e){e.MEMFS="MEMFS",e.NODEFS="NODEFS",e.NODERAWFS="NODERAWFS",e.IDBFS="IDBFS",e.WORKERFS="WORKERFS",e.PROXYFS="PROXYFS"})(Xy||(Xy={}));const JM=new Error("failed to get response body reader"),KM=new Error("failed to complete download"),XM="Content-Length",WM=async(e,t)=>{const o=await fetch(e);let l;try{const s=parseInt(o.headers.get(XM)||"-1"),u=o.body?.getReader();if(!u)throw JM;const p=[];let g=0;for(;;){const{done:x,value:b}=await u.read(),S=b?b.length:0;if(x){if(s!=-1&&s!==g)throw KM;t&&t({url:e,total:s,received:g,delta:S,done:x});break}p.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 p)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},Fs=async(e,t,o=!1,l)=>{const s=o?await WM(e,l):await(await fetch(e)).arrayBuffer(),u=new Blob([s],{type:t});return URL.createObjectURL(u)};let Ps=null,uf=!1,yc=!1;async function Wv(e){if(Ps&&uf)return Ps;if(yc){for(;yc;)await new Promise(t=>setTimeout(t,100));if(Ps&&uf)return Ps}yc=!0;try{const t=new YM;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.6/dist/esm";let s,u,p;const g=async(x,b,S)=>{const E=`${x.endsWith("/")?x:`${x}/`}${b}`;try{const j=await fetch(E,{cache:"no-cache",mode:"same-origin"});if(!j.ok)throw new Error(`HTTP ${j.status}`);const I=j.headers.get("Content-Type")||"",$=await j.arrayBuffer(),oe=new Uint8Array($);if(oe[0]===60||I.includes("text/html")){const se=new TextDecoder().decode(oe.slice(0,100));throw e?.(`[FFmpeg] Error: Path ${E} returned HTML instead of binary. Check if file exists in public/ffmpeg.`),console.debug(`[FFmpeg] Received HTML: ${se}...`),new Error(`Server returned HTML (SPA Redirect) at ${E}`)}if(b.endsWith(".wasm")&&(oe[0]!==0||oe[1]!==97||oe[2]!==115||oe[3]!==109))throw new Error("File version mismatch or invalid WASM binary (Check for partial downloads)");return URL.createObjectURL(new Blob([$],{type:S}))}catch(j){throw new Error(`[${b}] ${j.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,A,E)=>E.indexOf(S)===A);let b=!1;for(const S of x)try{e?.(`[FFmpeg] Probing ${S}...`);const A=await g(S,"ffmpeg-core.js","text/javascript"),[E,j]=await Promise.all([g(S,"ffmpeg-core.wasm","application/wasm"),g(S,"ffmpeg-core.worker.js","text/javascript")]);s=A,u=E,p=j,e?.(`[FFmpeg] Success! Core verified at ${S} 🚀`),b=!0;break}catch(A){console.debug(`[FFmpeg] Path ${S} skipped:`,A.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,u,p]=await Promise.all([Fs(`${l}/ffmpeg-core.js`,"text/javascript"),Fs(`${l}/ffmpeg-core.wasm`,"application/wasm"),Fs(`${l}/ffmpeg-core.worker.js`,"text/javascript")])}await t.load({coreURL:s,wasmURL:u,workerURL:p})}else{e?.("[FFmpeg] Cross-Origin Isolated: NO. Using Single-Threaded Core 🐢");const l="https://unpkg.com/@ffmpeg/core@0.12.6/dist/esm";let s,u;const p=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 A=await S.blob();if((await A.slice(0,10).text()).trim().startsWith("<"))throw new Error("HTML Content");return URL.createObjectURL(new Blob([A],{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 p(x,"ffmpeg-core.js","text/javascript"),u=await p(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 Fs(`${l}/ffmpeg-core.js`,"text/javascript"),u=await Fs(`${l}/ffmpeg-core.wasm`,"application/wasm")}await t.load({coreURL:s,wasmURL:u})}return Ps=t,uf=!0,e?.("[FFmpeg] Loaded successfully"),t}finally{yc=!1}}function QM(e,t,o){const l=o==="1080p",u={low:l?28:30,med:l?23:25,high:l?18:20}[t];switch(e){case"h265":return{vcodec:"libx265",args:["-crf",u.toString(),"-preset","medium","-tag:v","hvc1"],format:"mp4",ext:"mp4"};case"vp9":return{vcodec:"libvpx-vp9",args:["-crf",u.toString(),"-b:v","0","-deadline","good","-cpu-used","2"],format:"webm",ext:"webm"};case"av1":return{vcodec:"libaom-av1",args:["-crf",(u+10).toString(),"-b:v","0","-cpu-used","4","-strict","experimental"],format:"mp4",ext:"mp4"};default:return{vcodec:"libx264",args:["-crf",u.toString(),"-preset","medium","-profile:v","high","-level","4.2"],format:"mp4",ext:"mp4"}}}async function Qv(e){const{canvas:t,audioFile:o,lyrics:l,metadata:s,visualSlides:u,imageMap:p,videoMap:g,preset:v,customFontName:m,renderConfig:x,fps:b,quality:S,codec:A,aspectRatio:E,onProgress:j,onLog:I,abortSignal:$,isFirstSong:oe=!0,isLastSong:se=!0}=e;j(0,"Loading FFmpeg...");const fe=await Wv(I),De=()=>$?.aborted===!0||$?.current===!0;if(De())throw new Error("Render aborted");s.coverUrl&&(s.backgroundType==="video"?(I?.("[FFmpeg] Loading video background..."),await i2("background",s.coverUrl,g)):(I?.("[FFmpeg] Loading cover art..."),await n2("cover",s.coverUrl,p))),j(5,"Preparing audio...");const be=URL.createObjectURL(o),ye=await e2(be);URL.revokeObjectURL(be);const tt=Math.ceil(ye*b),Ne=t.getContext("2d");if(!Ne)throw new Error("Failed to get canvas context");j(10,"Rendering frames...");const Xe=await o.arrayBuffer();await fe.writeFile("audio_src",new Uint8Array(Xe));const $e=Math.max(6,tt.toString().length);for(let ie=0;ie0,ye,x,se,oe);const L=await(await new Promise((Ce,Ke)=>{t.toBlob(C=>C?Ce(C):Ke(new Error("Failed to create blob")),"image/jpeg",S==="high"?.98:S==="med"?.92:.85)})).arrayBuffer(),le=`frame_${ie.toString().padStart($e,"0")}.jpg`;await fe.writeFile(le,new Uint8Array(L));const we=10+ie/tt*70;j(we,`Rendering frame ${ie+1}/${tt}`)}if(De())throw await vc(fe,tt,$e),new Error("Render aborted");j(80,"Encoding video...");const Ze=QM(A,S,e.resolution),gt=`output.${Ze.ext}`,xt=["-framerate",b.toString(),"-i",`frame_%0${$e}d.jpg`,"-i","audio_src","-c:v",Ze.vcodec,...Ze.args,"-c:a","aac","-b:a","192k","-ar","44100","-ac","2","-pix_fmt","yuv420p","-movflags","+faststart","-shortest","-y",gt];I?.(`[FFmpeg] Running: ffmpeg ${xt.join(" ")}`);try{await fe.exec(xt)}catch(ie){throw console.error("FFmpeg encoding failed:",ie),await vc(fe,tt,$e),new Error(`FFmpeg encoding failed: ${ie}`)}j(95,"Finalizing...");const Nt=await fe.readFile(gt),G=Nt instanceof Uint8Array?new Uint8Array(Nt):new TextEncoder().encode(Nt),Ee=new Blob([G],{type:Ze.format==="webm"?"video/webm":"video/mp4"});await vc(fe,tt,$e);try{await fe.deleteFile("audio_src"),await fe.deleteFile(gt)}catch{}return j(100,"Complete!"),{blob:Ee,duration:ye,format:Ze.ext}}async function ZM(e,t,o){const l=await Wv(t.onLog),s=[];let u=0;for(let S=0;S{o(S,e.length,fe,De)}}),oe=`segment_${S}.${$.format}`,se=await $.blob.arrayBuffer();await l.writeFile(oe,new Uint8Array(se)),s.push(oe),u+=$.duration}if(e.length===1){const S=await l.readFile(s[0]),A=s[0].split(".").pop()||"mp4";await l.deleteFile(s[0]);const E=S instanceof Uint8Array?new Uint8Array(S):new TextEncoder().encode(S);return{blob:new Blob([E],{type:A==="webm"?"video/webm":"video/mp4"}),duration:u,format:A}}o(e.length,e.length,0,"Concatenating tracks...");const p=s.map(S=>`file '${S}'`).join(` +`);await l.writeFile("concat.txt",new TextEncoder().encode(p));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:u,format:g}}async function e2(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 t2(e,t,o){const l=[];e.forEach((s,u)=>{let p=-1;if(u==="background"){const g=s.duration||1;g>0&&(p=o%g)}else{const g=t.find(v=>v.id===u);if(g&&g.type==="video"&&o>=g.startTime&&o0&&m>=x&&(m=m%x),p=m}}if(p>=0){if(s.readyState===0)return;Math.abs(s.currentTime-p)>.05&&l.push(new Promise(g=>{let v=!1;const m=()=>{v||(v=!0,s.removeEventListener("seeked",m),g())};s.addEventListener("seeked",m),s.currentTime=p,setTimeout(()=>{v||(v=!0,s.removeEventListener("seeked",m),g())},500)}))}}),l.length>0&&await Promise.all(l)}async function n2(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 i2(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 u=!1;const p=()=>{u||(u=!0,o.set(e,s),l())};s.oncanplay=()=>{u||(s.currentTime=.001)},s.onseeked=()=>p(),s.onerror=()=>{console.warn("Failed to load background video:",t),p()},setTimeout(()=>p(),1e4),s.src=t,s.load()})}async function vc(e,t,o){for(let l=0;l{if(!t.has(e))throw TypeError("Cannot "+o)},H=(e,t,o)=>(lp(e,t,"read from private field"),o?o.call(e):t.get(e)),Pt=(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)},Kn=(e,t,o,l)=>(lp(e,t,"write to private field"),t.set(e,o),o),o2=(e,t,o,l)=>({set _(s){Kn(e,t,s)},get _(){return H(e,t,l)}}),Yt=(e,t,o)=>(lp(e,t,"access private method"),o),Xt=new Uint8Array(8),mo=new DataView(Xt.buffer),$n=e=>[(e%256+256)%256],an=e=>(mo.setUint16(0,e,!1),[Xt[0],Xt[1]]),l2=e=>(mo.setInt16(0,e,!1),[Xt[0],Xt[1]]),Zv=e=>(mo.setUint32(0,e,!1),[Xt[1],Xt[2],Xt[3]]),lt=e=>(mo.setUint32(0,e,!1),[Xt[0],Xt[1],Xt[2],Xt[3]]),a2=e=>(mo.setInt32(0,e,!1),[Xt[0],Xt[1],Xt[2],Xt[3]]),Jl=e=>(mo.setUint32(0,Math.floor(e/2**32),!1),mo.setUint32(4,e,!1),[Xt[0],Xt[1],Xt[2],Xt[3],Xt[4],Xt[5],Xt[6],Xt[7]]),ap=e=>(mo.setInt16(0,2**8*e,!1),[Xt[0],Xt[1]]),po=e=>(mo.setInt32(0,2**16*e,!1),[Xt[0],Xt[1],Xt[2],Xt[3]]),df=e=>(mo.setInt32(0,2**30*e,!1),[Xt[0],Xt[1],Xt[2],Xt[3]]),Vi=(e,t=!1)=>{let o=Array(e.length).fill(null).map((l,s)=>e.charCodeAt(s));return t&&o.push(0),o},Pc=e=>e&&e[e.length-1],sp=e=>{let t;for(let o of e)(!t||o.presentationTimestamp>t.presentationTimestamp)&&(t=o);return t},ho=(e,t,o=!0)=>{let l=e*t;return o?Math.round(l):l},ex=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]},tx=ex(0),nx=e=>[po(e[0]),po(e[1]),df(e[2]),po(e[3]),po(e[4]),df(e[5]),po(e[6]),po(e[7]),df(e[8])],Ys=e=>!e||typeof e!="object"?e:Array.isArray(e)?e.map(Ys):Object.fromEntries(Object.entries(e).map(([t,o])=>[t,Ys(o)])),Ga=e=>e>=0&&e<2**32,jn=(e,t,o)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:o}),En=(e,t,o,l,s)=>jn(e,[$n(t),Zv(o),l??[]],s),s2=e=>{let t=512;return e.fragmented?jn("ftyp",[Vi("iso5"),lt(t),Vi("iso5"),Vi("iso6"),Vi("mp41")]):jn("ftyp",[Vi("isom"),lt(t),Vi("isom"),e.holdsAvc?Vi("avc1"):[],Vi("mp41")])},Df=e=>({type:"mdat",largeSize:e}),r2=e=>({type:"free",size:e}),wc=(e,t,o=!1)=>jn("moov",null,[c2(t,e),...e.map(l=>u2(l,t)),o?H2(e):null]),c2=(e,t)=>{let o=ho(Math.max(0,...t.filter(p=>p.samples.length>0).map(p=>{const g=sp(p.samples);return g.presentationTimestamp+g.duration})),Ff),l=Math.max(...t.map(p=>p.id))+1,s=!Ga(e)||!Ga(o),u=s?Jl:lt;return En("mvhd",+s,0,[u(e),u(e),lt(Ff),u(o),po(1),ap(1),Array(10).fill(0),nx(tx),Array(24).fill(0),lt(l)])},u2=(e,t)=>jn("trak",null,[d2(e,t),f2(e,t)]),d2=(e,t)=>{let o=sp(e.samples),l=ho(o?o.presentationTimestamp+o.duration:0,Ff),s=!Ga(t)||!Ga(l),u=s?Jl:lt,p;return e.info.type==="video"?p=typeof e.info.rotation=="number"?ex(e.info.rotation):e.info.rotation:p=tx,En("tkhd",+s,3,[u(t),u(t),lt(e.id),lt(0),u(l),Array(8).fill(0),an(0),an(0),ap(e.info.type==="audio"?1:0),an(0),nx(p),po(e.info.type==="video"?e.info.width:0),po(e.info.type==="video"?e.info.height:0)])},f2=(e,t)=>jn("mdia",null,[p2(e,t),h2(e.info.type==="video"?"vide":"soun"),m2(e)]),p2=(e,t)=>{let o=sp(e.samples),l=ho(o?o.presentationTimestamp+o.duration:0,e.timescale),s=!Ga(t)||!Ga(l),u=s?Jl:lt;return En("mdhd",+s,0,[u(t),u(t),lt(e.timescale),u(l),an(21956),an(0)])},h2=e=>En("hdlr",0,0,[Vi("mhlr"),Vi(e),lt(0),lt(0),lt(0),Vi("mp4-muxer-hdlr",!0)]),m2=e=>jn("minf",null,[e.info.type==="video"?g2():y2(),v2(),S2(e)]),g2=()=>En("vmhd",0,1,[an(0),an(0),an(0),an(0)]),y2=()=>En("smhd",0,0,[an(0),an(0)]),v2=()=>jn("dinf",null,[x2()]),x2=()=>En("dref",0,0,[lt(1)],[b2()]),b2=()=>En("url ",0,1),S2=e=>{const t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(o=>o.sampleCompositionTimeOffset!==0);return jn("stbl",null,[T2(e),L2(e),U2(e),F2(e),P2(e),B2(e),t?O2(e):null])},T2=e=>En("stsd",0,0,[lt(1)],[e.info.type==="video"?w2(W2[e.info.codec],e):I2(Z2[e.info.codec],e)]),w2=(e,t)=>jn(e,[Array(6).fill(0),an(1),an(0),an(0),Array(12).fill(0),an(t.info.width),an(t.info.height),lt(4718592),lt(4718592),lt(0),an(1),Array(32).fill(0),an(24),l2(65535)],[Q2[t.info.codec](t),t.info.decoderConfig.colorSpace?N2(t):null]),C2={bt709:1,bt470bg:5,smpte170m:6},E2={bt709:1,smpte170m:6,"iec61966-2-1":13},_2={rgb:0,bt709:1,bt470bg:5,smpte170m:6},N2=e=>jn("colr",[Vi("nclx"),an(C2[e.info.decoderConfig.colorSpace.primaries]),an(E2[e.info.decoderConfig.colorSpace.transfer]),an(_2[e.info.decoderConfig.colorSpace.matrix]),$n((e.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),A2=e=>e.info.decoderConfig&&jn("avcC",[...new Uint8Array(e.info.decoderConfig.description)]),M2=e=>e.info.decoderConfig&&jn("hvcC",[...new Uint8Array(e.info.decoderConfig.description)]),k2=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 En("vpcC",1,0,[$n(l),$n(s),$n(g),$n(2),$n(2),$n(2),an(0)])},R2=()=>{let o=(1<<7)+1;return jn("av1C",[o,0,0,0])},I2=(e,t)=>jn(e,[Array(6).fill(0),an(1),an(0),an(0),lt(0),an(t.info.numberOfChannels),an(16),an(0),an(0),po(t.info.sampleRate)],[ek[t.info.codec](t)]),z2=e=>{let t=new Uint8Array(e.info.decoderConfig.description);return En("esds",0,0,[lt(58753152),$n(32+t.byteLength),an(1),$n(0),lt(75530368),$n(18+t.byteLength),$n(64),$n(21),Zv(0),lt(130071),lt(130071),lt(92307584),$n(t.byteLength),...t,lt(109084800),$n(1),$n(2)])},D2=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",[$n(0),$n(e.info.numberOfChannels),an(t),lt(e.info.sampleRate),ap(o),$n(0)])},L2=e=>En("stts",0,0,[lt(e.timeToSampleTable.length),e.timeToSampleTable.map(t=>[lt(t.sampleCount),lt(t.sampleDelta)])]),U2=e=>{if(e.samples.every(o=>o.type==="key"))return null;let t=[...e.samples.entries()].filter(([,o])=>o.type==="key");return En("stss",0,0,[lt(t.length),t.map(([o])=>lt(o+1))])},F2=e=>En("stsc",0,0,[lt(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(t=>[lt(t.firstChunk),lt(t.samplesPerChunk),lt(1)])]),P2=e=>En("stsz",0,0,[lt(0),lt(e.samples.length),e.samples.map(t=>lt(t.size))]),B2=e=>e.finalizedChunks.length>0&&Pc(e.finalizedChunks).offset>=2**32?En("co64",0,0,[lt(e.finalizedChunks.length),e.finalizedChunks.map(t=>Jl(t.offset))]):En("stco",0,0,[lt(e.finalizedChunks.length),e.finalizedChunks.map(t=>lt(t.offset))]),O2=e=>En("ctts",0,0,[lt(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(t=>[lt(t.sampleCount),lt(t.sampleCompositionTimeOffset)])]),H2=e=>jn("mvex",null,e.map(j2)),j2=e=>En("trex",0,0,[lt(e.id),lt(1),lt(0),lt(0),lt(0)]),Wy=(e,t)=>jn("moof",null,[G2(e),...t.map(V2)]),G2=e=>En("mfhd",0,0,[lt(e)]),ix=e=>{let t=0,o=0,l=0,s=0,u=e.type==="delta";return o|=+u,u?t|=1:t|=2,t<<24|o<<16|l<<8|s},V2=e=>jn("traf",null,[$2(e),q2(e),Y2(e)]),$2=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:ix(o)};return En("tfhd",0,t,[lt(e.id),lt(l.duration),lt(l.size),lt(l.flags)])},q2=e=>En("tfdt",1,0,[Jl(ho(e.currentChunk.startTimestamp,e.timescale))]),Y2=e=>{let t=e.currentChunk.samples.map(j=>j.timescaleUnitsToNextSample),o=e.currentChunk.samples.map(j=>j.size),l=e.currentChunk.samples.map(ix),s=e.currentChunk.samples.map(j=>ho(j.presentationTimestamp-j.decodeTimestamp,e.timescale)),u=new Set(t),p=new Set(o),g=new Set(l),v=new Set(s),m=g.size===2&&l[0]!==l[1],x=u.size>1,b=p.size>1,S=!m&&g.size>1,A=v.size>1||[...v].some(j=>j!==0),E=0;return E|=1,E|=4*+m,E|=256*+x,E|=512*+b,E|=1024*+S,E|=2048*+A,En("trun",1,E,[lt(e.currentChunk.samples.length),lt(e.currentChunk.offset-e.currentChunk.moofOffset||0),m?lt(l[0]):[],e.currentChunk.samples.map((j,I)=>[x?lt(t[I]):[],b?lt(o[I]):[],S?lt(l[I]):[],A?a2(s[I]):[]])])},J2=e=>jn("mfra",null,[...e.map(K2),X2()]),K2=(e,t)=>En("tfra",1,0,[lt(e.id),lt(63),lt(e.finalizedChunks.length),e.finalizedChunks.map(l=>[Jl(ho(l.startTimestamp,e.timescale)),Jl(l.moofOffset),lt(t+1),lt(1),lt(1)])]),X2=()=>En("mfro",0,0,[lt(0)]),W2={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},Q2={avc:A2,hevc:M2,vp9:k2,av1:R2},Z2={aac:"mp4a",opus:"Opus"},ek={aac:z2,opus:D2},Qc=class{},rp=class extends Qc{constructor(){super(...arguments),this.buffer=null}},ox=class extends Qc{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.")}},tk=class extends Qc{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")}},Hl,Da,lx=class{constructor(){this.pos=0,Pt(this,Hl,new Uint8Array(8)),Pt(this,Da,new DataView(H(this,Hl).buffer)),this.offsets=new WeakMap}seek(e){this.pos=e}writeU32(e){H(this,Da).setUint32(0,e,!1),this.write(H(this,Hl).subarray(0,4))}writeU64(e){H(this,Da).setUint32(0,Math.floor(e/2**32),!1),H(this,Da).setUint32(4,e,!1),this.write(H(this,Hl).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&&tok){for(let g=0;g=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)};up=new WeakSet;sx=function(e){let o={start:Math.floor(e/H(this,Fo))*H(this,Fo),data:new Uint8Array(H(this,Fo)),written:[],shouldFlush:!1};return H(this,Di).push(o),H(this,Di).sort((l,s)=>l.start-s.start),H(this,Di).indexOf(o)};Ks=new WeakSet;Oc=function(e=!1){for(let t=0;te.stream.write({type:"write",data:t,position:o}),chunked:!0,chunkSize:e.options?.chunkSize}))}},Ff=1e3,ak=["avc","hevc","vp9","av1"],sk=["aac","opus"],rk=2082844800,ck=["strict","offset","cross-track-offset"],Tt,At,Hc,Ii,oi,Jn,Pa,ja,fp,Gl,Vl,Xs,Pf,rx,Bf,cx,pp,ux,Of,dx,hp,fx,_c,Hf,co,Uo,mp,px,Ws,jc,Gc,gp,Va,tr,Nc,jf,hx=class{constructor(e){if(Pt(this,Pf),Pt(this,Bf),Pt(this,pp),Pt(this,Of),Pt(this,hp),Pt(this,_c),Pt(this,co),Pt(this,mp),Pt(this,Ws),Pt(this,Gc),Pt(this,Va),Pt(this,Nc),Pt(this,Tt,void 0),Pt(this,At,void 0),Pt(this,Hc,void 0),Pt(this,Ii,void 0),Pt(this,oi,null),Pt(this,Jn,null),Pt(this,Pa,Math.floor(Date.now()/1e3)+rk),Pt(this,ja,[]),Pt(this,fp,1),Pt(this,Gl,[]),Pt(this,Vl,[]),Pt(this,Xs,!1),Yt(this,Pf,rx).call(this,e),e.video=Ys(e.video),e.audio=Ys(e.audio),e.fastStart=Ys(e.fastStart),this.target=e.target,Kn(this,Tt,{firstTimestampBehavior:"strict",...e}),e.target instanceof rp)Kn(this,At,new nk(e.target));else if(e.target instanceof ox)Kn(this,At,new dp(e.target));else if(e.target instanceof tk)Kn(this,At,new lk(e.target));else throw new Error(`Invalid target: ${e.target}`);Yt(this,Of,dx).call(this),Yt(this,Bf,cx).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,u){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(u!==void 0&&!Number.isFinite(u))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Yt(this,Nc,jf).call(this),!H(this,Tt).video)throw new Error("No video track declared.");if(typeof H(this,Tt).fastStart=="object"&&H(this,oi).samples.length===H(this,Tt).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${H(this,Tt).fastStart.expectedVideoChunks}).`);let p=Yt(this,_c,Hf).call(this,H(this,oi),e,t,o,l,s,u);if(H(this,Tt).fastStart==="fragmented"&&H(this,Jn)){for(;H(this,Vl).length>0&&H(this,Vl)[0].decodeTimestamp<=p.decodeTimestamp;){let g=H(this,Vl).shift();Yt(this,co,Uo).call(this,H(this,Jn),g)}p.decodeTimestamp<=H(this,Jn).lastDecodeTimestamp?Yt(this,co,Uo).call(this,H(this,oi),p):H(this,Gl).push(p)}else Yt(this,co,Uo).call(this,H(this,oi),p)}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(Yt(this,Nc,jf).call(this),!H(this,Tt).audio)throw new Error("No audio track declared.");if(typeof H(this,Tt).fastStart=="object"&&H(this,Jn).samples.length===H(this,Tt).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${H(this,Tt).fastStart.expectedAudioChunks}).`);let u=Yt(this,_c,Hf).call(this,H(this,Jn),e,t,o,l,s);if(H(this,Tt).fastStart==="fragmented"&&H(this,oi)){for(;H(this,Gl).length>0&&H(this,Gl)[0].decodeTimestamp<=u.decodeTimestamp;){let p=H(this,Gl).shift();Yt(this,co,Uo).call(this,H(this,oi),p)}u.decodeTimestamp<=H(this,oi).lastDecodeTimestamp?Yt(this,co,Uo).call(this,H(this,Jn),u):H(this,Vl).push(u)}else Yt(this,co,Uo).call(this,H(this,Jn),u)}finalize(){if(H(this,Xs))throw new Error("Cannot finalize a muxer more than once.");if(H(this,Tt).fastStart==="fragmented"){for(let t of H(this,Gl))Yt(this,co,Uo).call(this,H(this,oi),t);for(let t of H(this,Vl))Yt(this,co,Uo).call(this,H(this,Jn),t);Yt(this,Gc,gp).call(this,!1)}else H(this,oi)&&Yt(this,Ws,jc).call(this,H(this,oi)),H(this,Jn)&&Yt(this,Ws,jc).call(this,H(this,Jn));let e=[H(this,oi),H(this,Jn)].filter(Boolean);if(H(this,Tt).fastStart==="in-memory"){let t;for(let l=0;l<2;l++){let s=wc(e,H(this,Pa)),u=H(this,At).measureBox(s);t=H(this,At).measureBox(H(this,Ii));let p=H(this,At).pos+u+t;for(let g of H(this,ja)){g.offset=p;for(let{data:v}of g.samples)p+=v.byteLength,t+=v.byteLength}if(p<2**32)break;t>=2**32&&(H(this,Ii).largeSize=!0)}let o=wc(e,H(this,Pa));H(this,At).writeBox(o),H(this,Ii).size=t,H(this,At).writeBox(H(this,Ii));for(let l of H(this,ja))for(let s of l.samples)H(this,At).write(s.data),s.data=null}else if(H(this,Tt).fastStart==="fragmented"){let t=H(this,At).pos,o=J2(e);H(this,At).writeBox(o);let l=H(this,At).pos-t;H(this,At).seek(H(this,At).pos-4),H(this,At).writeU32(l)}else{let t=H(this,At).offsets.get(H(this,Ii)),o=H(this,At).pos-t;H(this,Ii).size=o,H(this,Ii).largeSize=o>=2**32,H(this,At).patchBox(H(this,Ii));let l=wc(e,H(this,Pa));if(typeof H(this,Tt).fastStart=="object"){H(this,At).seek(H(this,Hc)),H(this,At).writeBox(l);let s=t-H(this,At).pos;H(this,At).writeBox(r2(s))}else H(this,At).writeBox(l)}Yt(this,Va,tr).call(this),H(this,At).finalize(),Kn(this,Xs,!0)}};Tt=new WeakMap;At=new WeakMap;Hc=new WeakMap;Ii=new WeakMap;oi=new WeakMap;Jn=new WeakMap;Pa=new WeakMap;ja=new WeakMap;fp=new WeakMap;Gl=new WeakMap;Vl=new WeakMap;Xs=new WeakMap;Pf=new WeakSet;rx=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 Qc))throw new TypeError("The target must be provided and an instance of Target.");if(e.video){if(!ak.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(!sk.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&&!ck.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.")};Bf=new WeakSet;cx=function(){if(H(this,At).writeBox(s2({holdsAvc:H(this,Tt).video?.codec==="avc",fragmented:H(this,Tt).fastStart==="fragmented"})),Kn(this,Hc,H(this,At).pos),H(this,Tt).fastStart==="in-memory")Kn(this,Ii,Df(!1));else if(H(this,Tt).fastStart!=="fragmented"){if(typeof H(this,Tt).fastStart=="object"){let e=Yt(this,pp,ux).call(this);H(this,At).seek(H(this,At).pos+e)}Kn(this,Ii,Df(!0)),H(this,At).writeBox(H(this,Ii))}Yt(this,Va,tr).call(this)};pp=new WeakSet;ux=function(){if(typeof H(this,Tt).fastStart!="object")return;let e=0,t=[H(this,Tt).fastStart.expectedVideoChunks,H(this,Tt).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};Of=new WeakSet;dx=function(){if(H(this,Tt).video&&Kn(this,oi,{id:1,info:{type:"video",codec:H(this,Tt).video.codec,width:H(this,Tt).video.width,height:H(this,Tt).video.height,rotation:H(this,Tt).video.rotation??0,decoderConfig:null},timescale:H(this,Tt).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),H(this,Tt).audio&&(Kn(this,Jn,{id:H(this,Tt).video?2:1,info:{type:"audio",codec:H(this,Tt).audio.codec,numberOfChannels:H(this,Tt).audio.numberOfChannels,sampleRate:H(this,Tt).audio.sampleRate,decoderConfig:null},timescale:H(this,Tt).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),H(this,Tt).audio.codec==="aac")){let e=Yt(this,hp,fx).call(this,2,H(this,Tt).audio.sampleRate,H(this,Tt).audio.numberOfChannels);H(this,Jn).info.decoderConfig={codec:H(this,Tt).audio.codec,description:e,numberOfChannels:H(this,Tt).audio.numberOfChannels,sampleRate:H(this,Tt).audio.sampleRate}}};hp=new WeakSet;fx=function(e,t,o){let s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(t),u=o,p="";p+=e.toString(2).padStart(5,"0"),p+=s.toString(2).padStart(4,"0"),s===15&&(p+=t.toString(2).padStart(24,"0")),p+=u.toString(2).padStart(4,"0");let g=Math.ceil(p.length/8)*8;p=p.padEnd(g,"0");let v=new Uint8Array(p.length/8);for(let m=0;m=p&&(l=!0,Yt(this,Gc,gp).call(this))}else l=s>=.5}l&&(e.currentChunk&&Yt(this,Ws,jc).call(this,e),e.currentChunk={startTimestamp:t.presentationTimestamp,samples:[]}),e.currentChunk.samples.push(t)};mp=new WeakSet;px=function(e,t,o){const l=H(this,Tt).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(H(this,Tt).firstTimestampBehavior==="offset"||H(this,Tt).firstTimestampBehavior==="cross-track-offset"){o.firstDecodeTimestamp===void 0&&(o.firstDecodeTimestamp=t);let p;H(this,Tt).firstTimestampBehavior==="offset"?p=o.firstDecodeTimestamp:p=Math.min(H(this,oi)?.firstDecodeTimestamp??1/0,H(this,Jn)?.firstDecodeTimestamp??1/0),t-=p,e-=p}if(tg&&g.currentChunk);if(t.length===0)return;let o=o2(this,fp)._++;if(o===1){let g=wc(t,H(this,Pa),!0);H(this,At).writeBox(g)}let l=H(this,At).pos,s=Wy(o,t);H(this,At).writeBox(s);{let g=Df(!1),v=0;for(let x of t)for(let b of x.currentChunk.samples)v+=b.size;let m=H(this,At).measureBox(g)+v;m>=2**32&&(g.largeSize=!0,m=H(this,At).measureBox(g)+v),g.size=m,H(this,At).writeBox(g)}for(let g of t){g.currentChunk.offset=H(this,At).pos,g.currentChunk.moofOffset=l;for(let v of g.currentChunk.samples)H(this,At).write(v.data),v.data=null}let u=H(this,At).pos;H(this,At).seek(H(this,At).offsets.get(s));let p=Wy(o,t);H(this,At).writeBox(p),H(this,At).seek(u);for(let g of t)g.finalizedChunks.push(g.currentChunk),H(this,ja).push(g.currentChunk),g.currentChunk=null;e&&Yt(this,Va,tr).call(this)};Va=new WeakSet;tr=function(){H(this,At)instanceof dp&&H(this,At).flush()};Nc=new WeakSet;jf=function(){if(H(this,Xs))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};function yp(){return typeof window<"u"&&"VideoEncoder"in window&&"AudioEncoder"in window}async function Gf(e){const t=await e.arrayBuffer(),o=new(window.AudioContext||window.webkitAudioContext),l=await o.decodeAudioData(t);return o.close(),l}async function mx(e,t,o){const l=[];e.forEach((s,u)=>{let p=-1;if(u==="background"){const g=s.duration||1;g>0&&(p=o%g)}else{const g=t.find(v=>v.id===u);if(g&&g.type==="video"&&o>=g.startTime&&o0&&m>=x&&(m=m%x),p=m}}if(p>=0){if(s.readyState===0)return;Math.abs(s.currentTime-p)>.05&&l.push(new Promise(g=>{let v=!1;const m=()=>{v||(v=!0,s.removeEventListener("seeked",m),g())};s.addEventListener("seeked",m),s.currentTime=p,setTimeout(()=>{v||(v=!0,s.removeEventListener("seeked",m),g())},500)}))}}),l.length>0&&await Promise.all(l)}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 dk(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 u=!1;const p=()=>{u||(u=!0,o.set(e,s),l())};s.oncanplay=()=>{u||(s.currentTime=.001)},s.onseeked=()=>p(),s.onerror=()=>{console.warn("Failed to load background video:",t),p()},setTimeout(()=>p(),1e4),s.src=t,s.load()})}async function fk(e){const{canvas:t,audioFile:o,lyrics:l,metadata:s,visualSlides:u,imageMap:p,videoMap:g,preset:v,customFontName:m,renderConfig:x,fps:b,quality:S,onProgress:A,onLog:E,abortSignal:j,isFirstSong:I=!0,isLastSong:$=!0}=e;if(!yp())throw new Error("WebCodecs API is not supported in this browser.");const oe=()=>j?.aborted===!0||j?.current===!0;A(0,"Initializing WebCodecs..."),E?.("Decoding audio...");const se=await Gf(o),fe=se.duration,De=Math.ceil(fe*b),be=new hx({target:new rp,video:{codec:"avc",width:t.width,height:t.height},audio:{codec:"aac",sampleRate:se.sampleRate,numberOfChannels:se.numberOfChannels},fastStart:"in-memory"}),Ne=(e.resolution==="1080p"?8e6:4e6)*(S==="high"?1.5:S==="low"?.5:1),Xe=new VideoEncoder({output:(Ye,ut)=>be.addVideoChunk(Ye,ut),error:Ye=>{console.error("VideoEncoder error:",Ye),E?.(`VideoEncoder error: ${Ye.message}`)}});Xe.configure({codec:"avc1.4d002a",width:t.width,height:t.height,bitrate:Ne,framerate:b});const $e=new AudioEncoder({output:(Ye,ut)=>be.addAudioChunk(Ye,ut),error:Ye=>{console.error("AudioEncoder error:",Ye),E?.(`AudioEncoder error: ${Ye.message}`)}});$e.configure({codec:"mp4a.40.2",sampleRate:se.sampleRate,numberOfChannels:se.numberOfChannels,bitrate:128e3}),A(5,"Encoding Audio...");const Ze=se.numberOfChannels,gt=se.sampleRate,xt=gt,Nt=se.length;for(let Ye=0;Ye10;)await new Promise(Ce=>setTimeout(Ce,10))}await $e.flush(),A(10,"Rendering Frames...");const G=t.getContext("2d",{desynchronized:!1});if(!G)throw new Error("No canvas context");const Ee=1/b*1e6;for(let Ye=0;Ye0,fe,x,$,I);const L=Math.round(Ye*Ee),le=new VideoFrame(t,{timestamp:L,duration:Math.round(Ee)});Xe.encode(le,{keyFrame:Ye%(b*2)===0}),le.close();const we=10+Ye/De*89;A(we,`Rendering frame ${Ye}/${De}`),Xe.encodeQueueSize>5&&await new Promise(Ce=>{const Ke=()=>Xe.encodeQueueSize<=2?Ce(null):setTimeout(Ke,10);Ke()}),Ye%2===0&&await new Promise(Ce=>setTimeout(Ce,0))}A(99,"Finalizing frames..."),await Xe.flush(),be.finalize();const{buffer:ie}=be.target;return A(100,"Done!"),{blob:new Blob([ie],{type:"video/mp4"}),duration:fe,format:"mp4"}}async function pk(e,t){const{canvas:o,visualSlides:l,imageMap:s,videoMap:u,preset:p,customFontName:g,renderConfig:v,fps:m,quality:x,onProgress:b,onLog:S,abortSignal:A}=t;if(!yp())throw new Error("WebCodecs API is not supported in this browser.");const E=()=>A?.aborted===!0||A?.current===!0;b(0,"Decoding first track...");const j=await Gf(e[0].audioFile),I=j.sampleRate,$=j.numberOfChannels;b(2,"Initializing WebCodecs Playlist Render...");const oe=new hx({target:new rp,video:{codec:"avc",width:o.width,height:o.height},audio:{codec:"aac",sampleRate:I,numberOfChannels:$},fastStart:"in-memory"}),De=(t.resolution==="1080p"?8e6:4e6)*(x==="high"?1.5:x==="low"?.5:1),be=new VideoEncoder({output:($e,Ze)=>oe.addVideoChunk($e,Ze),error:$e=>{console.error("VideoEncoder error:",$e),S?.(`VideoEncoder error: ${$e.message}`)}});be.configure({codec:"avc1.4d002a",width:o.width,height:o.height,bitrate:De,framerate:m});const ye=new AudioEncoder({output:($e,Ze)=>oe.addAudioChunk($e,Ze),error:$e=>{console.error("AudioEncoder error:",$e),S?.(`AudioEncoder error: ${$e.message}`)}});ye.configure({codec:"mp4a.40.2",sampleRate:I,numberOfChannels:$,bitrate:128e3});let tt=0,Ne=0;for(let $e=0;$e10&&await new Promise(ae=>setTimeout(ae,10))}const L=Math.ceil(G*m),le=1/m*1e6,we=o.getContext("2d");if(!we)throw new Error("No canvas context");for(let Ce=0;Ce0,G,v,xt,gt);const C=tt+Math.round(Ce*le),B=new VideoFrame(o,{timestamp:C,duration:Math.round(le)});be.encode(B,{keyFrame:Ce%(m*2)===0}),B.close();const ne=Ce/L,ae=($e+ne)/e.length*100;b(ae,`Song ${$e+1}/${e.length}: Rendering frame ${Ce}/${L}`),be.encodeQueueSize>5&&await new Promise(Pe=>{const P=()=>be.encodeQueueSize<=2?Pe(null):setTimeout(P,10);P()}),Ce%5===0&&await new Promise(Pe=>setTimeout(Pe,0))}tt+=Math.round(G*1e6)}b(99,"Flushing encoders..."),ye.state!=="closed"&&await ye.flush(),be.state!=="closed"&&await be.flush(),oe.finalize();const{buffer:Xe}=oe.target;return b(100,"Done!"),{blob:new Blob([Xe],{type:"video/mp4"}),duration:Ne,format:"mp4"}}function hk(){const{toast:e,confirm:t}=er(),o=Q.useRef(null),l=Q.useRef(null),s=Q.useRef(null),u=Q.useRef(null),p=Q.useRef(null),g=Q.useRef({aborted:!1}),v=Q.useRef(()=>{});Q.useEffect(()=>{PM()},[]);const[m,x]=Q.useState(null),[b,S]=Q.useState(0),[A,E]=Q.useState({title:"No Audio Loaded",artist:"Select a file",coverUrl:null}),[j,I]=Q.useState([]),[$,oe]=Q.useState([]),[se,fe]=Q.useState(0),[De,be]=Q.useState(!1),[ye,tt]=Q.useState("off"),[Ne,Xe]=Q.useState(0),[$e,Ze]=Q.useState(0),[gt,xt]=Q.useState(1),[Nt,G]=Q.useState(!1),[Ee,ie]=Q.useState(ii.PLAYER),[Ye,ut]=Q.useState(!1),[L,le]=Q.useState(!1),[we,Ce]=Q.useState(!1),[Ke,C]=Q.useState(!1),[B,ne]=Q.useState(!1),[ae,Pe]=Q.useState(0),[P,Be]=Q.useState("16:9"),[Re,xe]=Q.useState("1080p"),[pe,Oe]=Q.useState("default"),[et,z]=Q.useState(null),[Ve,at]=Q.useState(null),[U,Z]=Q.useState(null),[ce,Ae]=Q.useState("auto"),[ve,Me]=Q.useState(30),[ue,Ge]=Q.useState("med"),[w,M]=Q.useState("mediarecorder"),[R,V]=Q.useState("h264"),[Y,he]=Q.useState(""),[de,Le]=Q.useState(!1),[ke,Ie]=Q.useState(!1),[_,st]=Q.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"}),wt=Q.useRef(_);Q.useEffect(()=>{wt.current=_},[_]);const Dt=Q.useRef(null),Mt=Q.useRef(null),ot=_.backgroundBlurStrength>0,Wt=Q.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(J=>MediaRecorder.isTypeSupported(J.value)),[]),[me,Ue]=Q.useState([]),[mt,yt]=Q.useState(-1),[dt,Ot]=Q.useState(!1),Jt=()=>{const k=Re==="1080p";switch(P){case"9:16":return k?{w:1080,h:1920}:{w:720,h:1280};case"3:4":return k?{w:1080,h:1440}:{w:720,h:960};case"4:3":return k?{w:1440,h:1080}:{w:960,h:720};case"1:1":return k?{w:1080,h:1080}:{w:720,h:720};case"1:2":return k?{w:1080,h:2160}:{w:720,h:1440};case"2:1":return k?{w:2160,h:1080}:{w:1440,h:720};case"2:3":return k?{w:1080,h:1620}:{w:720,h:1080};case"3:2":return k?{w:1620,h:1080}:{w:1080,h:720};case"4:5":return k?{w:1080,h:1350}:{w:720,h:900};case"20:9":return k?{w:2400,h:1080}:{w:1600,h:720};case"21:9":return k?{w:2560,h:1080}:{w:1720,h:720};default:return k?{w:1920,h:1080}:{w:1280,h:720}}},{w:Dn,h:Gn}=Jt(),[Rn,ci]=Q.useState(!0),[Ti,Wn]=Q.useState(!0),[Je,Ct]=Q.useState(!1),Bt=Q.useMemo(()=>{const k=_.visualTransitionType||"none",J=_.visualTransitionDuration||1;return $.filter(W=>W.type==="audio"?!1:Ne>=W.startTime&&Ne=W.endTime&&Ne{const je=(W.layer||0)-(Se.layer||0);return je!==0?je:W.startTime-Se.startTime})},[$,Ne,_.visualTransitionType,_.visualTransitionDuration]),li=$.filter(k=>k.type==="audio"&&Ne>=k.startTime&&Nese===0?j:j.map(k=>({...k,time:k.time+se,endTime:k.endTime!==void 0?k.endTime+se:void 0})),[j,se]),bn=Ht.findIndex((k,J)=>{if(k.endTime!==void 0)return Ne>=k.time&&Ne=k.time&&(!Fe||Ne{const J=k.target.files?.[0];if(J){const Fe=URL.createObjectURL(J);x(Fe);const W={title:J.name.replace(/\.[^/.]+$/,""),artist:"Unknown Artist",coverUrl:null};E(W),J.type.startsWith("audio/")?ff(()=>import("./jsmediatags.min--h8asrzE.js").then(Se=>Se.j),[]).then(Se=>{Se.read(J,{onSuccess:je=>{const{title:nt,artist:Et,picture:vt}=je.tags;let Sn=null;if(vt){const{data:Zt,format:He}=vt;let Rt="";for(let Qt=0;Qt{console.log("Error reading tags:",je)}})}):J.type.startsWith("video/")&&(C(!1),E({...W,coverUrl:Fe,backgroundType:"video"})),fe(0),be(!1),Xe(0),yt(-1),s.current&&(s.current.scrollTop=0),o.current&&o.current.load()}k.target.value=""},to=k=>{const J=k.target.files?.[0];if(J){const Fe=URL.createObjectURL(J),W=J.type.startsWith("video/");W&&C(!1),E(Se=>({...Se,coverUrl:Fe,backgroundType:W?"video":"image"}))}k.target.value=""},Ho=async k=>{const J=k.target.files?.[0];if(J)try{const Fe=await J.text(),W=J.name.split(".").pop()?.toLowerCase();let Se=[];W==="lrc"?Se=vl(Fe):W==="srt"?Se=xl(Fe):W==="ttml"||W==="xml"?Se=$l(Fe):W==="vtt"&&(Se=ql(Fe)),Se.some(je=>je.words&&je.words.length>0)&&(st(je=>({...je,highlightEffect:"karaoke"})),e.success(`${W?.toUpperCase()} loaded with word-level timing! Karaoke mode enabled.`)),I(Se)}catch(Fe){console.error("Failed to parse lyrics:",Fe),e.error("Failed to parse lyric file.")}k.target.value=""};Q.useEffect(()=>{if(mt!==-1&&me[mt]){const k=me[mt];I(k.parsedLyrics||[])}},[me,mt]);const go=async k=>{const J=k.target.files?.[0];if(J){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const Fe=URL.createObjectURL(J),W=J.name.replace(/\.[^/.]+$/,""),Se="CustomFont",je=new FontFace(Se,`url(${Fe})`);await je.load(),document.fonts.add(je),z(W),st(nt=>({...nt,fontFamily:Se})),e.success(`Loaded font: ${W}`)}catch(Fe){console.error("Failed to load font:",Fe),e.error("Failed to load font file.")}}k.target.value=""},jo=async k=>{const J=k.target.files?.[0];if(J){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const Fe=URL.createObjectURL(J),W=J.name.replace(/\.[^/.]+$/,""),Se="ChannelFont",je=new FontFace(Se,`url(${Fe})`);await je.load(),document.fonts.add(je),at(W),st(nt=>({...nt,channelInfoFontFamily:Se})),e.success(`Loaded Channel font: ${W}`)}catch(Fe){console.error("Failed to load font:",Fe),e.error("Failed to load channel font file.")}}k.target.value=""},Tl=async k=>{const J=k.target.files?.[0];if(J){if(!window.FontFace||!document.fonts){e.error("Custom fonts are not supported in this browser.");return}try{const Fe=URL.createObjectURL(J),W=J.name.replace(/\.[^/.]+$/,""),Se="InfoFont",je=new FontFace(Se,`url(${Fe})`);await je.load(),document.fonts.add(je),Z(W),st(nt=>({...nt,infoFontFamily:Se})),e.success(`Loaded Info font: ${W}`)}catch(Fe){console.error("Failed to load font:",Fe),e.error("Failed to load info font file.")}}k.target.value=""},wi=Q.useCallback(async(k,J=!0,Fe)=>{const W=Fe||me;if(k<0||k>=W.length)return;const Se=W[k],je=URL.createObjectURL(Se.audioFile);if(x(je),E({title:Se.metadata.title,artist:Se.metadata.artist,coverUrl:Se.metadata.coverUrl||null,backgroundType:Se.metadata.backgroundType||"image"}),I([]),Se.parsedLyrics&&Se.parsedLyrics.length>0)I(Se.parsedLyrics);else if(Se.lyricFile)try{const nt=await Se.lyricFile.text(),Et=Se.lyricFile.name.split(".").pop()?.toLowerCase();let vt=[];Et==="lrc"?vt=vl(nt):Et==="srt"?vt=xl(nt):Et==="ttml"||Et==="xml"?vt=$l(nt):Et==="vtt"&&(vt=ql(nt)),I(vt)}catch(nt){console.error("Failed to load lyrics",nt)}fe(0),yt(k),s.current&&(s.current.scrollTop=0),J?setTimeout(()=>{o.current&&(o.current.play().catch(nt=>console.log("Autoplay failed",nt)),be(!0))},100):(be(!1),o.current&&(o.current.pause(),o.current.currentTime=0))},[me]),_n=Q.useCallback(()=>{if(me.length===0)return;const k=(mt+1)%me.length;wi(k)},[me,mt,wi]),Xl=Q.useCallback(()=>{if(me.length===0)return;const k=(mt-1+me.length)%me.length;wi(k)},[me,mt,wi]),Wl=()=>{o.current&&(De?(o.current.pause(),be(!1)):!m&&me.length>0?wi(0):(o.current.play().catch(console.error),be(!0)))},Qn=Q.useCallback(()=>{o.current&&(o.current.pause(),o.current.currentTime=0,be(!1),Xe(0))},[]),yo=()=>{tt(k=>k==="off"?"one":k==="one"?"all":k==="all"?"all_repeat":"off")},nr=()=>{document.fullscreenElement?(document.exitFullscreen(),ut(!1)):(l.current?.requestFullscreen(),ut(!0))},Ja=k=>{if(k&&k.target.closest(".no-minimal-mode-toggle"))return;const J=!Je;Ct(J),J&&Ce(!0),e.success(`Minimal Mode: ${J?"On":"Off"}`,{id:"minimal-mode"})},ir=()=>{o.current&&(Xe(o.current.currentTime),B&&Pe(o.current.currentTime/$e*100))},Zc=()=>{o.current&&Ze(o.current.duration)},Ql=k=>{const J=parseFloat(k.target.value);o.current&&(o.current.currentTime=J,Xe(J))},wl=k=>{if(!Dt.current||B||!$e)return;const J=Dt.current.getBoundingClientRect(),Se=Math.max(0,Math.min(k-J.left,J.width))/J.width*$e;o.current&&(o.current.currentTime=Se,Xe(Se))},Yi=k=>{const J=parseFloat(k.target.value);xt(J),o.current&&(o.current.volume=J),G(J===0)},ui=k=>{if(!Mt.current)return;const J=Mt.current.getBoundingClientRect(),W=Math.max(0,Math.min(k-J.left,J.width))/J.width;xt(W),o.current&&(o.current.volume=W),G(W===0)},or=async()=>{if(!o.current||!u.current)return;const k=_.renderMode==="playlist"&&me.length>0,J=[];if(k)for(const ze of me){let rt=[];if(ze.parsedLyrics&&ze.parsedLyrics.length>0)rt=ze.parsedLyrics;else if(ze.lyricFile)try{const We=await ze.lyricFile.text(),xn=ze.lyricFile.name.split(".").pop()?.toLowerCase();xn==="lrc"?rt=vl(We):xn==="srt"?rt=xl(We):xn==="ttml"||xn==="xml"?rt=$l(We):xn==="vtt"&&(rt=ql(We))}catch(We){console.error("Failed to parse lyrics for playlist item",We)}const Vt=URL.createObjectURL(ze.audioFile);J.push({audioSrc:Vt,lyrics:rt,metadata:ze.metadata,isFileSource:!0})}else{if(!m)return;J.push({audioSrc:m,lyrics:Ht,metadata:A,isFileSource:!1})}if(J.length===0)return;const Fe=k?`Start rendering ALL ${J.length} songs from the playlist? This will result in one continuous video.`:`Start rendering ${P} (${Re}) video? This will play the song from start to finish.`;if(!await t(`${Fe} Please do not switch tabs during rendering.`,"Start Rendering?")){k&&J.forEach(ze=>ze.isFileSource&&URL.revokeObjectURL(ze.audioSrc));return}Le(!1),ne(!0),Pe(0);const Se={aborted:!1};g.current=Se,Qn(),tt("off"),qn.current&&clearTimeout(qn.current),le(!1),Ce(!0),Cl.current&&Cl.current.pause();const je=o.current,nt=pe,Et=new Map,vt=new Map,Sn=new Map,Zt=[],He=(ze,rt)=>new Promise(Vt=>{const We=new Image;We.crossOrigin="anonymous",We.onload=()=>{Et.set(ze,We),Vt()},We.onerror=()=>Vt(),We.src=rt}),Rt=(ze,rt)=>new Promise(Vt=>{const We=document.createElement("video");We.crossOrigin="anonymous",We.muted=!0,We.playsInline=!0,We.preload="auto";let xn=!1;const on=()=>{xn||(xn=!0,vt.set(ze,We),Vt())};We.oncanplay=()=>{xn||(We.currentTime=.001)},We.onseeked=()=>on(),We.onerror=()=>{console.warn("Failed to load video:",rt),on()},setTimeout(()=>on(),5e3),We.src=rt,We.load()}),Qt=(ze,rt)=>new Promise(Vt=>{const We=document.createElement("audio");We.crossOrigin="anonymous",We.onloadedmetadata=()=>{Sn.set(ze,We),Vt()},We.onerror=()=>Vt(),We.src=rt});if($.forEach(ze=>{ze.type==="video"?Zt.push(Rt(ze.id,ze.url)):ze.type==="audio"||ze.type==="audio"?Zt.push(Qt(ze.id,ze.url)):Zt.push(He(ze.id,ze.url))}),_.showChannelInfo&&(_.channelInfoImage&&Zt.push(He("__channel_info__",_.channelInfoImage)),_.channelInfoText)){const ze=_.channelInfoText.trim();if(//i.test(ze))try{const rt=document.createElement("div");rt.style.position="absolute",rt.style.visibility="hidden",rt.style.whiteSpace="nowrap",rt.style.fontFamily="sans-serif",rt.style.fontWeight="bold",rt.style.fontSize="100px",rt.style.display="inline-flex",rt.style.alignItems="center",rt.style.gap="0.25em",rt.innerHTML=ze;const Vt=rt.getElementsByTagName("svg");for(let ai=0;ai + +
+ + ${ze} +
+
+ + `,Ci=`data:image/svg+xml;base64,${window.btoa(encodeURIComponent(on).replace(/%([0-9A-F]{2})/g,function(Yo,na){return String.fromCharCode(parseInt(na,16))}))}`;Zt.push(He("__channel_info_text_svg__",Ci))}catch(rt){console.warn("Failed to process SVG channel info",rt)}}if(_.backgroundSource==="image"&&_.backgroundImage&&Zt.push(He("__custom_bg__",_.backgroundImage)),await Promise.all(Zt),Se.aborted){ne(!1),k&&J.forEach(ze=>ze.isFileSource&&URL.revokeObjectURL(ze.audioSrc));return}const An=u.current,F=An.getContext("2d"),it=An.captureStream(ve);let bt=null;try{if(je.captureStream)bt=je.captureStream();else if(je.mozCaptureStream)bt=je.mozCaptureStream();else throw new Error("Audio capture not supported")}catch{e.error("Your browser does not support audio capture for recording."),ne(!1);return}const qe=new(window.AudioContext||window.webkitAudioContext),Ut=qe.createMediaStreamDestination();qe.createMediaElementSource(je).connect(Ut),vt.forEach(ze=>{ze.muted=!0,qe.createMediaElementSource(ze).connect(Ut)}),Sn.forEach(ze=>{ze.muted=!0,qe.createMediaElementSource(ze).connect(Ut)}),Ut.stream.getAudioTracks().length>0?it.addTrack(Ut.stream.getAudioTracks()[0]):bt&&it.addTrack(bt.getAudioTracks()[0]);const rn=(()=>{if(ce!=="auto"&&MediaRecorder.isTypeSupported(ce))return ce;const ze=["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 rt of ze)if(MediaRecorder.isTypeSupported(rt))return rt;return"video/webm"})(),vn=Re==="1080p"?8e6:4e6,io=ve>30?1.5:1,Ln=ue==="high"?2:ue==="low"?.5:1,di=vn*io*Ln,pn=new MediaRecorder(it,{mimeType:rn,videoBitsPerSecond:di});p.current=pn;const mi=[];pn.ondataavailable=ze=>{ze.data.size>0&&mi.push(ze.data)},pn.onstop=()=>{if(Se.aborted)console.log("Render aborted");else{const ze=new Blob(mi,{type:rn}),rt=Vt=>{const We=URL.createObjectURL(Vt),xn=document.createElement("a");xn.href=We;const on=rn.includes("mp4")?"mp4":"webm",Fn=k?`Playlist_${J.length}_Songs_${P.replace(":","-")}.${on}`:`${J[0].metadata.title||"video"}_${P.replace(":","-")}.${on}`;xn.download=Fn,document.body.appendChild(xn),xn.click(),document.body.removeChild(xn),URL.revokeObjectURL(We)};rn.includes("webm"),rt(ze)}qe.close(),ne(!1),S(ze=>ze+1),k&&J.forEach(ze=>ze.isFileSource&&URL.revokeObjectURL(ze.audioSrc))};let te=0,gi=[],It=A,Un=0,Ji=0;const oo=1e3/ve,xo=ze=>{if(Se.aborted)return;(pn.state==="recording"||pn.state==="paused")&&requestAnimationFrame(xo);const rt=ze-Ji;if(rt0){const We=Vt/Un;if(k){const xn=(te+We)/J.length*100;Pe(xn)}else Pe(We*100)}vt.forEach((We,xn)=>{if(xn==="background"){const on=We.duration||1,Fn=Vt%on;let Ci=Math.abs(We.currentTime-Fn);(Fnon/2||Ci>.5)&&(We.currentTime=Fn),We.paused&&We.play().catch(()=>{})}else{const on=$.find(Fn=>Fn.id===xn);if(on)if(Vt>=on.startTime&&Vt0&&Ci>=ai&&(Ci=Ci%ai),Math.abs(We.playbackRate-Fn)>.01&&(We.playbackRate=Fn),Math.abs(We.currentTime-Ci)>.5&&(We.currentTime=Ci);const Yo=on.isMuted!==!1;We.muted!==Yo&&(We.muted=Yo),We.paused&&We.play().catch(()=>{})}else We.paused||We.pause(),We.muted||(We.muted=!0)}}),Sn.forEach((We,xn)=>{const on=$.find(Fn=>Fn.id===xn);if(on){const Fn=on.layer||0;if(_.layerVisibility?.audio?.[Fn]!==!1&&Vt>=on.startTime&&Vt.01&&(We.playbackRate=ai),Math.abs(We.currentTime-Yo)>.5&&(We.currentTime=Yo);const na=on.isMuted===!0;We.muted!==na&&(We.muted=na),We.paused&&We.play().catch(()=>{})}else We.paused||We.pause(),We.muted||(We.muted=!0)}}),F&&Wc(F,An.width,An.height,Vt,gi,It,$,Et,vt,nt,et,_.fontSizeScale,_.backgroundBlurStrength>0,Un,_,_.renderMode==="current"||te===J.length-1,_.renderMode==="current"||te===0)},bo=async()=>{if(Se.aborted){pn.stop();return}if(te>=J.length){await new Promise(rt=>setTimeout(rt,500)),pn.stop();return}const ze=J[te];pn.state==="recording"&&pn.pause(),gi=ze.lyrics,It=ze.metadata,Un=0,k&&yt(te),ze.metadata.coverUrl&&(ze.metadata.backgroundType==="video"?await Rt("background",ze.metadata.coverUrl):await He("cover",ze.metadata.coverUrl)),je.pause(),je.src=ze.audioSrc,je.load(),await new Promise(rt=>{const Vt=()=>{je.removeEventListener("canplay",Vt),rt()};je.addEventListener("canplay",Vt),je.readyState>=3&&Vt()}),Un=je.duration,pn.state==="inactive"?(qe.state==="suspended"&&await qe.resume(),pn.start(),requestAnimationFrame(xo)):pn.state==="paused"&&pn.resume(),await je.play(),await new Promise(rt=>{const Vt=()=>{je.removeEventListener("ended",Vt),rt()};je.addEventListener("ended",Vt)}),te++,await bo()};await bo()},eu=async()=>{if(!u.current)return;const k=_.renderMode==="playlist"&&me.length>0;let J=null,Fe=Ht,W=A;if(k&&me.length>0)J=me[0].audioFile,Fe=me[0].parsedLyrics||[],W=me[0].metadata;else if(me.length>0&&mt>=0)J=me[mt].audioFile;else if(m)try{J=await(await fetch(m)).blob()}catch(F){console.error("FFmpeg: Failed to fetch audio blob",F),e.error("Failed to load audio source for rendering.");return}else{e.error("Please load an audio file first.");return}if(!J){e.error("No audio file available for FFmpeg export.");return}const Se=`Start FFmpeg rendering at ${Re} (${P})? This uses frame-by-frame capture for higher quality. Rendering may take several minutes.`;if(!await t(Se,"Start FFmpeg Rendering?"))return;Le(!1),ne(!0),Pe(0),he("Initializing...");const nt={aborted:!1};g.current=nt,Qn();const Et=u.current,{w:vt,h:Sn}=Jt();Et.width=vt,Et.height=Sn;const Zt=new Map,He=new Map,Rt=[],Qt=(F,it)=>new Promise(bt=>{const qe=new Image;qe.crossOrigin="anonymous",qe.onload=()=>{Zt.set(F,qe),bt()},qe.onerror=()=>bt(),qe.src=it}),An=(F,it)=>new Promise(bt=>{const qe=document.createElement("video");qe.crossOrigin="anonymous",qe.muted=!0,qe.playsInline=!0,qe.preload="auto";let Ut=!1;const pt=()=>{Ut||(Ut=!0,He.set(F,qe),bt())};qe.oncanplay=()=>{Ut||(qe.currentTime=.001)},qe.onseeked=()=>pt(),qe.onerror=()=>{console.warn("Failed to load video:",it),pt()},setTimeout(()=>pt(),5e3),qe.src=it,qe.load()});if($.forEach(F=>{F.type==="video"?Rt.push(An(F.id,F.url)):F.type!=="audio"&&Rt.push(Qt(F.id,F.url))}),W.coverUrl&&(W.backgroundType==="video"?Rt.push(An("background",W.coverUrl)):Rt.push(Qt("cover",W.coverUrl))),_.backgroundSource==="image"&&_.backgroundImage&&Rt.push(Qt("__custom_bg__",_.backgroundImage)),_.showChannelInfo&&_.channelInfoImage&&Rt.push(Qt("__channel_info__",_.channelInfoImage)),await Promise.all(Rt),nt.aborted){ne(!1);return}try{if(k){const F=[];for(const pt of me){let sn=[];if(pt.parsedLyrics&&pt.parsedLyrics.length>0)sn=pt.parsedLyrics;else if(pt.lyricFile)try{const rn=await pt.lyricFile.text(),vn=pt.lyricFile.name.split(".").pop()?.toLowerCase();vn==="lrc"?sn=vl(rn):vn==="srt"?sn=xl(rn):vn==="ttml"||vn==="xml"?sn=$l(rn):vn==="vtt"&&(sn=ql(rn))}catch(rn){console.error("FFmpeg: Failed to parse lyrics for playlist item",rn)}F.push({audioFile:pt.audioFile,lyrics:sn,metadata:pt.metadata})}const it=await ZM(F,{canvas:Et,visualSlides:$,imageMap:Zt,videoMap:He,preset:pe,customFontName:et,renderConfig:_,resolution:Re,aspectRatio:P,fps:ve,quality:ue,codec:R,onProgress:(pt,sn)=>{},onLog:pt=>console.log(pt),abortSignal:nt},(pt,sn,rn,vn)=>{const io=(pt+rn/100)/sn*100;Pe(io),he(`Song ${pt+1}/${sn}: ${vn}`)}),bt=`Playlist_${F.length}_Songs_${P.replace(":","-")}_ffmpeg.${it.format}`,qe=URL.createObjectURL(it.blob),Ut=document.createElement("a");Ut.href=qe,Ut.download=bt,document.body.appendChild(Ut),Ut.click(),document.body.removeChild(Ut),URL.revokeObjectURL(qe),e.success(`Playlist exported successfully! (${it.format.toUpperCase()}, ${Math.round(it.duration)}s)`)}else{const F=await Qv({canvas:Et,audioFile:J,lyrics:Fe,metadata:W,visualSlides:$,imageMap:Zt,videoMap:He,preset:pe,customFontName:et,renderConfig:_,resolution:Re,aspectRatio:P,fps:ve,quality:ue,codec:R,onProgress:(Ut,pt)=>{Pe(Ut),he(pt)},onLog:Ut=>console.log(Ut),abortSignal:nt,isFirstSong:!0,isLastSong:!0}),it=`${W.title||"video"}_${P.replace(":","-")}_ffmpeg.${F.format}`,bt=URL.createObjectURL(F.blob),qe=document.createElement("a");qe.href=bt,qe.download=it,document.body.appendChild(qe),qe.click(),document.body.removeChild(qe),URL.revokeObjectURL(bt),e.success(`Video exported successfully! (${F.format.toUpperCase()}, ${Math.round(F.duration)}s)`)}}catch(F){F.message!=="Render aborted"&&(console.error("FFmpeg render failed:",F),e.error(`FFmpeg render failed: ${F.message}`))}finally{ne(!1),he("")}},Ka=async()=>{if(!u.current)return;const k=_.renderMode==="playlist"&&me.length>0;let J=null,Fe=Ht,W=A;if(k&&me.length>0)J=me[0].audioFile,Fe=me[0].parsedLyrics||[],W=me[0].metadata;else if(me.length>0&&mt>=0)J=me[mt].audioFile;else if(m)try{J=await(await fetch(m)).blob()}catch(F){console.error("WebCodecs: Failed to fetch audio blob",F),e.error("Failed to load audio source for rendering.");return}else{e.error("Please load an audio file first.");return}if(!J){e.error("No audio file available for export.");return}if(!yp()){e.error("WebCodecs is not supported in this browser.");return}const{w:Se,h:je}=Jt(),nt=`Start WebCodecs rendering at ${Re} @ ${ve}fps? +Resolution: ${Se}x${je} + +This uses hardware acceleration and is very fast.`;if(!await t(nt,"Start WebCodecs Rendering?"))return;Le(!1),ne(!0),Pe(0),he("Initializing WebCodecs...");const vt={aborted:!1};g.current=vt,Qn();const Sn=u.current;Sn.width=Se,Sn.height=je;const Zt=new Map,He=new Map,Rt=[],Qt=(F,it)=>new Promise(bt=>{const qe=new Image;qe.crossOrigin="anonymous",qe.onload=()=>{Zt.set(F,qe),bt()},qe.onerror=()=>bt(),qe.src=it}),An=(F,it)=>new Promise(bt=>{const qe=document.createElement("video");qe.crossOrigin="anonymous",qe.muted=!0,qe.playsInline=!0,qe.preload="auto";let Ut=!1;const pt=()=>{Ut||(Ut=!0,He.set(F,qe),bt())};qe.oncanplay=()=>{Ut||(qe.currentTime=.001)},qe.onseeked=()=>pt(),qe.onerror=()=>{console.warn("Failed to load video:",it),pt()},setTimeout(()=>pt(),5e3),qe.src=it,qe.load()});if($.forEach(F=>{F.type==="video"?Rt.push(An(F.id,F.url)):F.type!=="audio"&&Rt.push(Qt(F.id,F.url))}),W.coverUrl&&(W.backgroundType==="video"?Rt.push(An("background",W.coverUrl)):Rt.push(Qt("cover",W.coverUrl))),_.backgroundSource==="image"&&_.backgroundImage&&Rt.push(Qt("__custom_bg__",_.backgroundImage)),_.showChannelInfo&&_.channelInfoImage&&Rt.push(Qt("__channel_info__",_.channelInfoImage)),await Promise.all(Rt),vt.aborted){ne(!1);return}try{if(k){const F=[];for(const pt of me){let sn=[];if(pt.parsedLyrics&&pt.parsedLyrics.length>0)sn=pt.parsedLyrics;else if(pt.lyricFile)try{const rn=await pt.lyricFile.text(),vn=pt.lyricFile.name.split(".").pop()?.toLowerCase();vn==="lrc"?sn=vl(rn):vn==="srt"?sn=xl(rn):vn==="ttml"||vn==="xml"?sn=$l(rn):vn==="vtt"&&(sn=ql(rn))}catch(rn){console.error("WebCodecs: Failed to parse lyrics for playlist item",rn)}F.push({audioFile:pt.audioFile,lyrics:sn,metadata:pt.metadata})}const it=await pk(F,{canvas:Sn,visualSlides:$,imageMap:Zt,videoMap:He,preset:pe,customFontName:et,renderConfig:_,resolution:Re,aspectRatio:P,fps:ve,quality:ue,onProgress:(pt,sn)=>{Pe(pt),he(sn)},onLog:pt=>console.log(pt),abortSignal:vt}),bt=`Playlist_${F.length}_Songs_${P.replace(":","-")}_webcodecs.${it.format}`,qe=URL.createObjectURL(it.blob),Ut=document.createElement("a");Ut.href=qe,Ut.download=bt,document.body.appendChild(Ut),Ut.click(),document.body.removeChild(Ut),URL.revokeObjectURL(qe),e.success(`Playlist exported successfully! (${it.format.toUpperCase()}, ${Math.round(it.duration)}s)`)}else{const F=await fk({canvas:Sn,audioFile:J,lyrics:Fe,metadata:W,visualSlides:$,imageMap:Zt,videoMap:He,preset:pe,customFontName:et,renderConfig:_,resolution:Re,aspectRatio:P,fps:ve,quality:ue,onProgress:(Ut,pt)=>{Pe(Ut),he(pt)},abortSignal:vt,isFirstSong:!0,isLastSong:!0}),it=`${W.title||"video"}_${P.replace(":","-")}_webcodecs.${F.format}`,bt=URL.createObjectURL(F.blob),qe=document.createElement("a");qe.href=bt,qe.download=it,document.body.appendChild(qe),qe.click(),document.body.removeChild(qe),URL.revokeObjectURL(bt),e.success(`Video exported successfully! (${Math.round(F.duration)}s)`)}}catch(F){F.message!=="Render aborted"&&(console.error("WebCodecs render failed:",F),e.error(`Render failed: ${F.message}`))}finally{ne(!1),he("")}},Zl=async()=>{w==="ffmpeg"?await eu():w==="webcodecs"?await Ka():await or()};Q.useEffect(()=>{v.current=Zl});const Go=Q.useCallback(()=>{g.current&&(g.current.aborted=!0),p.current&&p.current.state==="recording"?p.current.stop():ne(!1),Qn()},[Qn]),ea=Q.useCallback(()=>{if(s.current){const k=o.current?.currentTime||0;if(bn===-1&&k<2){s.current.scrollTo({top:0,behavior:"smooth"});return}if(bn!==-1){const J=s.current.querySelector('[data-lyric-active="true"]');if(J){const Fe=s.current;if(J.offsetHeight===0)return;const W=J.offsetTop,Se=J.offsetHeight,je=Fe.clientHeight;let nt=.5;_.contentPosition==="top"&&(nt=.25),_.contentPosition==="bottom"&&(nt=.75);const Et=W-je*nt+Se/2;Fe.scrollTo({top:Et,behavior:"smooth"})}}}},[bn,pe,_.contentPosition,_.marginTopScale,_.marginBottomScale]);Q.useEffect(()=>{ea()},[ea]),Q.useEffect(()=>{const k=setTimeout(()=>{ea()},550);return()=>clearTimeout(k)},[L,we,Rn,Ti,Ee,dt,ea]);const qn=Q.useRef(null),Vo=Q.useCallback(()=>{if(le(!1),qn.current&&clearTimeout(qn.current),!B){const k=window.setTimeout(()=>{le(!0)},3e3);qn.current=k}},[B]),lr=()=>{Vo()},ta=Q.useRef(0),$o=k=>{Vo();const J=Date.now();if(J-ta.current<300){if(k.target.closest(".no-minimal-mode-toggle"))return;Ja(k)}ta.current=J};Q.useEffect(()=>{const k=J=>{const Fe=J.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(Fe)||Vo(),!(J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement)){if(B){Fe==="escape"&&Go();return}switch(J.key.toLowerCase()){case" ":case"k":J.preventDefault(),Wl(),e.success(De?"Paused":"Playing",{id:"play-pause"});break;case"s":J.preventDefault(),Qn(),e.success("Stopped",{id:"stop"});break;case"n":J.preventDefault(),_n(),e.success("Next Song",{id:"next-song"});break;case"o":J.preventDefault();const Se=!Je;Ct(Se),Se&&Ce(!0),e.success(`Minimal Mode: ${Se?"On":"Off"}`,{id:"minimal-mode"});break;case"b":J.preventDefault(),Xl(),e.success("Previous Song",{id:"prev-song"});break;case"r":J.preventDefault(),yo();const je=ye==="off"?"one":ye==="one"?"all":ye==="all"?"all_repeat":"off",nt={off:"Repeat Off",one:"Loop One",all:"Play All (Stop)",all_repeat:"Loop Playlist"};e.success(`Repeat: ${nt[je]}`,{id:"repeat"});break;case"l":J.preventDefault();const Et=!dt;Ot(Et),Et&&ie(ii.PLAYER);break;case"h":J.preventDefault();const vt=!we;Ce(vt),e.success(vt?"HUD: Always Visible":"HUD: Auto-Hide",{id:"hud-mode"});break;case"y":J.preventDefault(),Ie(ze=>!ze);break;case"g":J.preventDefault();const Sn=zf.flatMap(ze=>ze.options.map(rt=>rt.value)),Zt=wt.current.lyricDisplayMode,Rt=(Sn.indexOf(Zt)+1)%Sn.length,Qt=Sn[Rt];st(ze=>({...ze,lyricDisplayMode:Qt})),e.success(`Lyric Mode: ${Qt.replace("-"," ")}`,{id:"lyric-mode"});break;case"c":J.preventDefault();const An=Xv,F=wt.current.textCase,bt=(An.indexOf(F)+1)%An.length,qe=An[bt];st(ze=>({...ze,textCase:qe})),e.success(`Text Case: ${qe}`,{id:"text-case"});break;case"f":nr();break;case"i":ci(ze=>!ze);break;case"p":Wn(ze=>!ze);break;case"d":J.preventDefault(),Le(ze=>!ze);break;case"t":dt?(Ot(!1),ie(ii.EDITOR)):ie(ze=>ze===ii.PLAYER?ii.EDITOR:ii.PLAYER);break;case"m":J.preventDefault();const Ut=!Nt;G(Ut),e.success(Ut?"Muted":"Unmuted",{id:"mute"});break;case"x":J.preventDefault();const pt=wt.current.highlightEffect==="none";st(ze=>({...ze,highlightEffect:ze.highlightEffect==="none"?"karaoke":"none"})),e.success(`Highlight: ${pt?"On (Karaoke)":"Off"}`,{id:"highlight-toggle"});break;case"z":J.preventDefault();const sn=If.flatMap(ze=>ze.options.map(rt=>rt.value)),rn=wt.current.highlightEffect||"none",vn=sn.indexOf(rn),Ln=((vn===-1?0:vn)+1)%sn.length,di=sn[Ln],pn=Tc(di);st(ze=>{const rt={...ze,highlightEffect:di};return rt.useCustomHighlightColors=!1,pn&&(rt.highlightColor=pn.color,rt.highlightBackground=pn.bg),rt}),e.success(`Effect: ${di.replace(/-/g," ")}`,{id:"highlight-effect"});break;case"j":J.preventDefault();const te=(sf.indexOf(pe)+1)%sf.length,gi=sf[te];Oe(gi);const It=Fc[gi];if(It){const ze={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"};st(rt=>({...rt,...ze,...It}))}let Un=gi;for(const ze of op){const rt=ze.options.find(Vt=>Vt.value===gi);if(rt){Un=rt.label;break}}e.success(`Preset: ${Un}`,{id:"preset"});break;case"arrowleft":if(J.preventDefault(),o.current){const ze=Math.max(0,o.current.currentTime-5);o.current.currentTime=ze,Xe(ze)}break;case"arrowright":if(J.preventDefault(),o.current){const ze=Math.min($e,o.current.currentTime+5);o.current.currentTime=ze,Xe(ze)}break;case"arrowup":J.preventDefault(),s.current&&s.current.scrollBy({top:-100,behavior:"smooth"});break;case"arrowdown":J.preventDefault(),s.current&&s.current.scrollBy({top:100,behavior:"smooth"});break;case"+":case"=":J.preventDefault();const Ji=wt.current.fontSizeScale,oo=Math.min(Ji+.1,3);st(ze=>({...ze,fontSizeScale:oo})),e.success(`Font Size: ${(oo*100).toFixed(0)}%`,{id:"font-size"});break;case"-":J.preventDefault();const xo=wt.current.fontSizeScale,bo=Math.max(xo-.1,.1);st(ze=>({...ze,fontSizeScale:bo})),e.success(`Font Size: ${(bo*100).toFixed(0)}%`,{id:"font-size"});break;case"e":(J.ctrlKey||J.metaKey)&&J.shiftKey&&(J.preventDefault(),v.current());break}}};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[De,ye,Ee,B,Vo,Go,dt,_n,Xl,e,Je,pe,we,Nt]),Q.useEffect(()=>{let k,J=0;const Fe=1e3/30,W=Se=>{if(o.current&&!o.current.paused&&De){k=requestAnimationFrame(W);const je=Se-J;je>Fe&&(J=Se-je%Fe,Xe(o.current.currentTime))}};return De&&!B&&(k=requestAnimationFrame(W)),()=>{k&&cancelAnimationFrame(k)}},[De,B]);const qo=Rn&&(!L||we)&&!B,vo=Ti&&(!L||we)&&!B&&!Je,no=Bt.length>0?Bt[0]:null;no?`${no.url}`:A.coverUrl&&`${A.coverUrl}`;const Cl=Q.useRef(null);return Q.useEffect(()=>{if(Bt.forEach(k=>{const J=k.layer||0;if(_.layerVisibility?.visual?.[J]!==!1&&k.type==="video"){const Fe=document.getElementById(`video-preview-${k.id}`);if(Fe)if(B)Fe.paused||Fe.pause();else{const W=k.playbackRate||1;let Se=(Ne-k.startTime)*W+(k.mediaStartOffset||0);const je=k.mediaDuration||Fe.duration;je&&je>0&&Se>=je&&(Se=Se%je),Math.abs(Fe.playbackRate-W)>.01&&(Fe.playbackRate=W),Math.abs(Fe.currentTime-Se)>.2&&(Fe.currentTime=Se);const nt=k.isMuted!==!1;Fe.muted!==nt&&(Fe.muted=nt);const Et=k.volume!==void 0?k.volume:1;Math.abs(Fe.volume-Et)>.01&&(Fe.volume=Et),De&&Fe.paused?Fe.play().catch(()=>{}):!De&&!Fe.paused&&Fe.pause()}}}),A.backgroundType==="video"&&Cl.current){const k=Cl.current;if(B)k.paused||k.pause();else{const J=k.duration||1,Fe=Ne%J;Math.abs(k.currentTime-Fe)>.1&&(k.currentTime=Fe),De&&k.paused?k.play().catch(()=>{}):!De&&!k.paused&&k.pause()}}li.forEach(k=>{const J=document.getElementById(`audio-preview-${k.id}`);if(J){const Fe=k.playbackRate||1,W=(Ne-k.startTime)*Fe+(k.mediaStartOffset||0);Math.abs(J.playbackRate-Fe)>.01&&(J.playbackRate=Fe),Math.abs(J.currentTime-W)>.2&&(J.currentTime=W);const Se=k.isMuted===!0;J.muted!==Se&&(J.muted=Se);const je=k.volume!==void 0?k.volume:1;Math.abs(J.volume-je)>.01&&(J.volume=je),De&&J.paused?J.play().catch(()=>{}):!De&&!J.paused&&J.pause()}})},[Ne,De,Bt,A,li,_.layerVisibility]),d.jsxs("div",{ref:l,onMouseMove:lr,onTouchStart:$o,onDoubleClick:Ja,className:`relative w-full h-[100dvh] bg-black overflow-hidden flex font-sans select-none ${L&&!we?"cursor-none":""}`,children:[d.jsx("audio",{ref:o,src:m||void 0,loop:ye==="one",muted:Nt,onTimeUpdate:ir,onLoadedMetadata:Zc,onEnded:()=>{if(B)return;const k=me.length>0;ye==="one"||(ye==="all_repeat"?k?_n():o.current?.play():ye==="all"&&k&&mtd.jsx("audio",{id:`audio-preview-${k.id}`,src:k.url,className:"hidden",playsInline:!0},k.id)),d.jsx("canvas",{ref:u,width:Dn,height:Gn,className:"absolute top-0 left-0 hidden pointer-events-none opacity-0"}),d.jsxs("div",{className:"absolute inset-0 bg-black overflow-hidden pointer-events-none",children:[_.backgroundSource==="color"&&d.jsx("div",{className:"absolute inset-0",style:{backgroundColor:_.backgroundColor}}),_.backgroundSource==="gradient"&&d.jsx("div",{className:"absolute inset-0",style:{background:_.backgroundGradient}}),_.backgroundSource==="image"&&_.backgroundImage&&d.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${_.backgroundImage})`}}),_.backgroundSource==="smart-gradient"&&d.jsx("div",{className:"absolute inset-0",style:{background:(()=>{const k=_.backgroundColor||"#312e81",J=parseInt(k.slice(1,3),16),Fe=parseInt(k.slice(3,5),16),W=parseInt(k.slice(5,7),16),Se=`${J},${Fe},${W}`,je=`${Math.floor(J*.6)},${Math.floor(Fe*.6)},${Math.floor(W*.6)}`;return`linear-gradient(to bottom right, rgb(${Se}), rgb(${je}) 50%, #000000)`})()}}),(_.backgroundSource==="timeline"||_.backgroundSource==="custom")&&A.coverUrl&&$.length===0&&(A.backgroundType==="video"?d.jsx("video",{ref:Cl,src:A.coverUrl,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ${Ke?"opacity-60":"opacity-0"}`,muted:!0,loop:!B,playsInline:!0,preload:"auto",onLoadedData:()=>C(!0)}):d.jsx("div",{className:`absolute inset-0 bg-cover bg-center transition-all duration-700 ease-in-out ${_.backgroundSource==="custom"||Bt.length===0?"opacity-60":"opacity-0"}`,style:{backgroundImage:`url(${A.coverUrl})`}})),_.backgroundSource==="color"&&d.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{backgroundColor:_.backgroundColor}}),_.backgroundSource==="gradient"&&d.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{background:_.backgroundGradient}}),_.backgroundSource==="smart-gradient"&&d.jsx("div",{className:"absolute inset-0 transition-all duration-500",style:{background:(()=>{const k=_.backgroundColor||"#312e81",J=parseInt(k.slice(1,3),16),Fe=parseInt(k.slice(3,5),16),W=parseInt(k.slice(5,7),16),Se=`${J},${Fe},${W}`,je=`${Math.floor(J*.6)},${Math.floor(Fe*.6)},${Math.floor(W*.6)}`;return`linear-gradient(to bottom right, rgb(${Se}), rgb(${je}) 50%, #000000)`})()}}),!A.coverUrl&&Bt.length===0&&(_.backgroundSource==="timeline"||_.backgroundSource==="custom")&&$.length===0&&d.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-900 via-purple-900 to-black opacity-80"}),d.jsx("div",{className:`absolute inset-0 pointer-events-none ${_.backgroundSource==="timeline"?"opacity-100":"opacity-0"}`,children:_.backgroundSource==="timeline"&&Bt.map(k=>{const J=k.layer||0;if(_.layerVisibility?.visual?.[J]===!1)return null;const Fe=_.visualTransitionType||"none",W=_.visualTransitionDuration||1;let Se=1;if(Fe!=="none"){if(Ne=k.endTime){let je=!1;if(Fe==="crossfade"&&(je=$.some(nt=>nt.id!==k.id&&(nt.layer||0)===(k.layer||0)&&nt.startTime>=k.endTime-.1&&nt.startTimek.endTime-W){const je=(k.endTime-Ne)/W;Se=Math.min(Se,Math.max(0,Math.min(1,je)))}}return d.jsx("div",{className:"absolute inset-0 flex items-center justify-center overflow-hidden",style:{opacity:Se},children:k.type==="video"?d.jsx("video",{id:`video-preview-${k.id}`,src:k.url,className:"w-full h-full object-cover",muted:k.isMuted!==!1,playsInline:!0}):d.jsx("div",{className:"w-full h-full bg-cover bg-center",style:{backgroundImage:`url(${k.url})`}})},k.id)})}),d.jsx("div",{className:"absolute inset-0 bg-black/30 transition-all duration-700",style:{backdropFilter:_.backgroundBlurStrength>0?`blur(${_.backgroundBlurStrength}px)`:ot?"blur(12px)":"none",backgroundColor:_.useRealColorMedia?"transparent":_.backgroundBlurStrength>0||ot?"rgba(0,0,0,0.4)":void 0}}),_.enableGradientOverlay&&d.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/95 via-black/60 to-transparent pointer-events-none z-0"})]}),d.jsxs("div",{className:"relative z-10 flex-1 flex flex-col transition-all duration-500",children:[_.showChannelInfo&&Je&&d.jsxs("div",{className:`absolute z-[60] flex gap-2 p-6 pointer-events-none transition-all duration-500 + ${_.channelInfoStyle==="modern"?"flex-col items-center":"flex-row items-center"} + ${_.channelInfoStyle==="box"?"bg-black/40 backdrop-blur-md rounded-xl border border-white/10":""} + ${_.channelInfoPosition==="top-left"?"top-0 left-0 items-start text-left":_.channelInfoPosition==="top-right"?"top-0 right-0 items-end text-right":_.channelInfoPosition==="top-center"?"top-0 left-1/2 items-center text-center":_.channelInfoPosition==="bottom-left"?"bottom-0 left-0 items-start text-left":_.channelInfoPosition==="bottom-center"?"bottom-0 left-1/2 items-center text-center":"bottom-0 right-0 items-end text-right"} + `,style:{transform:`${_.channelInfoPosition?.includes("center")?"translateX(-50%)":""} scale(${_.channelInfoSizeScale??1})`,transformOrigin:_.channelInfoPosition?.includes("top")?_.channelInfoPosition?.includes("center")?"top center":_.channelInfoPosition?.includes("left")?"top left":"top right":_.channelInfoPosition?.includes("center")?"bottom center":_.channelInfoPosition?.includes("left")?"bottom left":"bottom right",..._.channelInfoPosition?.includes("center")?_.channelInfoPosition?.includes("top")?{marginTop:`${(_.channelInfoMarginScale??1)*1.5}rem`}:{marginBottom:`${(_.channelInfoMarginScale??1)*1.5}rem`}:{margin:`${(_.channelInfoMarginScale??1)*1.5}rem`}},children:[_.channelInfoImage&&_.channelInfoStyle!=="minimal"&&d.jsx("img",{src:_.channelInfoImage,alt:"Channel",className:`w-20 h-20 object-contain drop-shadow-lg ${_.channelInfoStyle==="circle"?"rounded-full":""}`}),_.channelInfoText&&_.channelInfoStyle!=="logo"&&(()=>{const k=_.channelInfoText.trim();return//i.test(k)?d.jsx("div",{className:`font-bold drop-shadow-md text-lg inline-flex items-center gap-1 + ${_.channelInfoStyle==="minimal"||_.channelInfoStyle==="box"?"":"px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm"} + [&>svg]:w-auto [&>svg]:h-[1.5em]`,style:{fontFamily:_.channelInfoFontFamily,color:_.channelInfoFontColor||"white",fontWeight:_.channelInfoFontWeight||"bold",fontStyle:_.channelInfoFontStyle||"normal"},dangerouslySetInnerHTML:{__html:k}}):d.jsx("p",{className:`font-bold drop-shadow-md text-lg + ${_.channelInfoStyle==="minimal"||_.channelInfoStyle==="box"?"":"px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm"}`,style:{fontFamily:_.channelInfoFontFamily,color:_.channelInfoFontColor||"white",fontWeight:_.channelInfoFontWeight||"bold",fontStyle:_.channelInfoFontStyle||"normal"},children:_.channelInfoText})})()]}),Je&&d.jsx("div",{className:`absolute z-20 flex flex-col gap-2 p-6 transition-all duration-500 pointer-events-none + ${qo?"opacity-100":"opacity-0"} + ${_.infoPosition==="top-left"?"top-0 left-0 items-start text-left":_.infoPosition==="top-right"?"top-0 right-0 items-end text-right":_.infoPosition==="top-center"?"top-0 left-1/2 items-center text-center":_.infoPosition==="bottom-left"?"bottom-0 left-0 items-start text-left":_.infoPosition==="bottom-right"?"bottom-0 right-0 items-end text-right":_.infoPosition==="bottom-center"?"bottom-0 left-1/2 items-center text-center":"top-0 left-0 items-start text-left"} + `,style:{transform:`${_.infoPosition?.includes("center")?"translateX(-50%)":""} scale(${_.infoSizeScale??1})`,transformOrigin:_.infoPosition?.includes("top")?_.infoPosition?.includes("center")?"top center":_.infoPosition?.includes("right")?"top right":"top left":_.infoPosition?.includes("center")?"bottom center":_.infoPosition?.includes("right")?"bottom right":"bottom left",..._.infoPosition?.includes("center")?_.infoPosition?.includes("top")?{marginTop:`${(_.infoMarginScale??1)*1.5}rem`}:{marginBottom:`${(_.infoMarginScale??1)*1.5}rem`}:{margin:`${(_.infoMarginScale??1)*1.5}rem`}},children:d.jsxs("div",{className:` + flex items-center gap-4 pointer-events-auto + ${_.infoPosition?.includes("center")?"flex-col justify-center":""} + ${_.infoPosition?.includes("right")?"flex-row-reverse":"flex-row"} + ${_.infoStyle==="box"?"bg-black/40 backdrop-blur-md p-4 rounded-xl border border-white/10":""} + ${_.infoStyle==="modern"||_.infoStyle==="minimal",""} + `,children:[d.jsxs("div",{className:`relative group shrink-0 transition-opacity duration-300 + ${!_.showCover||_.infoStyle==="minimal"||_.infoStyle==="modern"?"hidden":"block"} + ${_.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:[A.coverUrl?A.backgroundType==="video"?d.jsx("video",{src:A.coverUrl,className:"w-full h-full object-cover",muted:!0,loop:!0,onMouseOver:k=>k.currentTarget.play(),onMouseOut:k=>k.currentTarget.pause()}):d.jsx("img",{src:A.coverUrl,alt:"Cover",className:"w-full h-full object-cover"}):d.jsx("div",{className:"w-full h-full flex items-center justify-center text-zinc-500",children:d.jsx(La,{size:24})}),d.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:[d.jsx(fo,{size:20,className:"text-white"}),d.jsx("input",{type:"file",accept:"image/*,video/*",className:"hidden",onChange:to})]})]}),d.jsxs("div",{className:`flex flex-col justify-center ${_.infoPosition?.includes("right")?"items-end":_.infoPosition?.includes("center")?"items-center":"items-start"}`,children:[d.jsx("h1",{className:`font-bold drop-shadow-md line-clamp-1 transition-opacity duration-300 + ${_.showTitle?"opacity-100":"opacity-0 h-0 w-0"} + ${_.infoStyle==="minimal"?"text-sm":_.infoStyle==="modern"||_.infoStyle==="modern_art"?"text-xl":"text-lg"} + `,style:{fontFamily:_.infoFontFamily,color:_.infoFontColor||"white",fontWeight:_.infoFontWeight||"bold",fontStyle:_.infoFontStyle||"normal"},children:A.title}),d.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 + ${_.showArtist?"opacity-100":"opacity-0 h-0 w-0"} + `,children:d.jsx("p",{className:`drop-shadow-md + ${_.infoStyle==="minimal"?"text-[10px]":_.infoStyle==="modern"||_.infoStyle==="modern_art"?"text-sm font-medium":"text-xs"} + `,style:{fontFamily:_.infoFontFamily,color:_.infoFontColor||(_.infoStyle==="minimal"?"#a1a1aa":"#d4d4d8"),fontWeight:_.infoFontWeight||"bold",fontStyle:_.infoFontStyle||"normal"},children:A.artist})})]})]})}),d.jsx("div",{className:`transition-all duration-500 ease-in-out overflow-hidden ${qo&&!Je?"max-h-80 md:max-h-40 opacity-100":"max-h-0 opacity-0"}`,children:d.jsxs("div",{className:"p-4 md:p-6 flex flex-col md:flex-row justify-between items-start gap-4 md:gap-0",children:[d.jsx("div",{className:"flex gap-4",children:d.jsxs("div",{className:"flex gap-4 items-center",children:[d.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 ${_.showCover?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none w-0 h-0 -ml-4"}`,children:[A.coverUrl?A.backgroundType==="video"?d.jsx("video",{src:A.coverUrl,className:"w-full h-full object-cover",muted:!0,loop:!0,onMouseOver:k=>k.currentTarget.play(),onMouseOut:k=>k.currentTarget.pause()}):d.jsx("img",{src:A.coverUrl,alt:"Cover",className:"w-full h-full object-cover"}):d.jsx("div",{className:"w-full h-full flex items-center justify-center text-zinc-500",children:d.jsx(La,{size:24})}),d.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:[d.jsx(fo,{size:20,className:"text-white"}),d.jsx("input",{type:"file",accept:"image/*,video/*",className:"hidden",onChange:to})]})]}),d.jsxs("div",{children:[d.jsx("h1",{className:`text-xl font-bold text-white drop-shadow-md line-clamp-1 transition-opacity duration-300 ${_.showTitle?"opacity-100":"opacity-0"}`,children:A.title}),d.jsx("div",{className:`flex items-center gap-2 transition-opacity duration-300 ${_.showArtist?"opacity-100":"opacity-0"}`,children:d.jsx("p",{className:"text-zinc-300 text-sm drop-shadow-md",children:A.artist})})]})]})}),d.jsxs("div",{className:`flex gap-2 flex-wrap ${Je?"hidden":""}`,children:[d.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:d.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:d.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"})})}),d.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"}),d.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"}),d.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"}),d.jsx("button",{onClick:()=>Ce(!we),className:`p-2 rounded-full transition-colors ${we?"bg-purple-600/50 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Bypass Auto-hide (H)",children:we?d.jsx(Os,{size:20}):d.jsx(Bs,{size:20})}),d.jsx("button",{onClick:()=>Ct(!Je),className:`p-2 rounded-full transition-colors ${Je?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Minimal Mode (O)",children:Je?d.jsx($s,{size:20}):d.jsx(lg,{size:20})}),d.jsx("button",{onClick:()=>{const k=!dt;Ot(k),k&&ie(ii.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:d.jsx(kc,{size:20})}),d.jsx("button",{onClick:()=>{dt&&Ot(!1),ie(Ee===ii.PLAYER?ii.EDITOR:ii.PLAYER)},className:`p-2 rounded-full transition-colors ${Ee===ii.EDITOR&&!dt?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Toggle Timeline (T)",children:d.jsx(ev,{size:20})}),d.jsx("button",{onMouseDown:k=>{k.stopPropagation(),Le(!de)},className:`p-2 rounded-full transition-colors ${de?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Render Settings (D)",children:d.jsx(xc,{size:20})}),d.jsx("button",{onMouseDown:k=>{k.stopPropagation(),Ie(!ke)},className:`p-2 rounded-full transition-colors ${ke?"bg-purple-600 text-white":"bg-black/30 text-zinc-300 hover:bg-white/10"}`,title:"Keyboard Shortcuts (Y)",children:d.jsx(Mc,{size:20})}),d.jsx("button",{onClick:nr,className:"p-2 rounded-full bg-black/30 text-zinc-300 hover:bg-white/10 transition-colors",title:"Fullscreen (F)",children:Ye?d.jsx(lg,{size:20}):d.jsx($s,{size:20})})]})]})}),d.jsx("div",{className:`flex-1 flex justify-center overflow-hidden relative ${_.contentPosition==="top"?"items-start":_.contentPosition==="bottom"?"items-end":"items-center"}`,style:{paddingTop:_.contentPosition==="top"?`${(_.marginTopScale??1)*10}vh`:void 0,paddingBottom:_.contentPosition==="bottom"?`${(_.marginBottomScale??1)*10}vh`:void 0},children:j.length>0?d.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 ${_.textAlign==="left"?"text-left":_.textAlign==="right"?"text-right":"text-center"} ${_.showLyrics?"opacity-100":"opacity-0 pointer-events-none"}`,style:{maskImage:(qo||vo)&&pe!=="subtitle"?"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)":"none"},children:[d.jsx("style",{children:` + .lyrics-root .text-lg { font-size: calc(1.125rem * ${_.fontSizeScale}); line-height: calc(1.75rem * ${_.fontSizeScale} * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-xl { font-size: calc(1.25rem * ${_.fontSizeScale}); line-height: calc(1.75rem * ${_.fontSizeScale} * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-2xl { font-size: calc(1.5rem * ${_.fontSizeScale}); line-height: calc(2rem * ${_.fontSizeScale} * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-3xl { font-size: calc(1.875rem * ${_.fontSizeScale}); line-height: calc(2.25rem * ${_.fontSizeScale} * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-4xl { font-size: calc(2.25rem * ${_.fontSizeScale}); line-height: calc(2.5rem * ${_.fontSizeScale} * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-5xl { font-size: calc(3rem * ${_.fontSizeScale}); line-height: calc(1 * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-6xl { font-size: calc(3.75rem * ${_.fontSizeScale}); line-height: calc(1 * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-7xl { font-size: calc(4.5rem * ${_.fontSizeScale}); line-height: calc(1 * ${_.lyricLineHeight||1.2}); } + .lyrics-root .text-8xl { font-size: calc(6rem * ${_.fontSizeScale}); line-height: calc(1 * ${_.lyricLineHeight||1.2}); } + `}),d.jsx("div",{className:`transition-all duration-500 ${_.contentPosition==="center"?Ee===ii.EDITOR||dt?"h-[25vh]":!qo&&!vo?"h-[50vh]":"h-[40vh]":"h-0"}`}),Ht.map((k,J)=>{const Fe=J===bn,W=Ee===ii.EDITOR||dt,Se=["9:16","3:4","1:1","1:2","2:3"].includes(P);if(_.lyricDisplayMode!=="all"){if(_.lyricDisplayMode==="active-only"&&J!==bn)return d.jsx("p",{className:"hidden"},J);if(_.lyricDisplayMode==="next-only"&&(Jbn+1))return d.jsx("p",{className:"hidden"},J);if(_.lyricDisplayMode==="previous-next"&&Math.abs(J-bn)>1)return d.jsx("p",{className:"hidden"},J)}else if(pe==="none"||pe==="just_video")return d.jsx("p",{className:"hidden"},J);let je="",nt="";const Et=_.transitionEffect;let vt="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(Fe?Et==="slide"?vt+="translate-y-0 opacity-100 ":Et==="zoom"?vt+="scale-100 opacity-100 ":Et==="float"?vt+="translate-y-0 opacity-100 ":Et==="blur"?vt+="blur-0 opacity-100 ":Et==="fade"?vt+="opacity-100 ":Et==="drop"?vt+="trans-drop-enter opacity-100 ":Et==="lightspeed"?vt+="trans-lightspeed-enter opacity-100 ":Et==="roll"?vt+="trans-roll-enter opacity-100 ":Et==="elastic"?vt+="trans-elastic-enter opacity-100 ":Et==="flip"?vt+="trans-flip-enter opacity-100 ":Et==="rotate-in"?vt+="trans-rotate-in-enter opacity-100 ":Et==="spiral"?vt+="trans-spiral-enter opacity-100 ":Et==="shatter"?vt+="trans-shatter-enter opacity-100 ":vt+="opacity-100 ":(Et==="slide"?vt+="translate-y-4 opacity-0 ":Et==="zoom"?vt+="scale-75 opacity-0 ":Et==="float"?vt+="translate-y-8 opacity-0 ":Et==="blur"?vt+="blur-md opacity-0 ":Et==="fade"?vt+="opacity-50 ":Et==="drop"?vt+="trans-drop-exit opacity-0 ":Et==="roll"?vt+="trans-roll-exit opacity-0 ":vt+="opacity-0 ",Et==="none"&&(vt=vt.replace("opacity-0","opacity-50"))),pe==="large"||pe==="large_upper"){const bt=Se?W?"text-4xl":"text-6xl":W?"text-6xl":"text-8xl",qe=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${bt} font-black text-white ${pe==="large_upper"?"uppercase":""} tracking-tight text-left pl-4`,nt=`${qe} text-zinc-600/40 hover:text-zinc-400 text-left pl-4`}else if(pe==="big_center"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} font-black text-white uppercase tracking-tight text-center`,nt=`${it} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(pe==="testing_up"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white uppercase tracking-tight text-center`,nt=`${it} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(pe==="testing"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white tracking-tight text-center`,nt=`${it} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(pe==="one_line_up"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white uppercase tracking-tight text-center`,nt=`${it} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(pe==="one_line"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white tracking-tight text-center`,nt=`${it} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(pe==="metal"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white uppercase tracking-wide text-center drop-shadow-[0_4px_6px_rgba(255,0,0,0.5)]`,nt=`${it} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(pe==="kids"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-white tracking-wide text-center drop-shadow-[3px_3px_0px_rgba(0,0,0,0.5)]`,nt=`${it} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(pe==="sad"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-7xl",it=Se?W?"text-lg":"text-xl":W?"text-xl":"text-2xl";je=`${F} text-zinc-200 tracking-wider text-center drop-shadow-md`,nt=`${it} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(pe==="romantic"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-7xl",it=Se?W?"text-lg":"text-xl":W?"text-xl":"text-2xl";je=`${F} text-pink-100 italic tracking-wide text-center drop-shadow-[0_0_10px_rgba(236,72,153,0.5)]`,nt=`${it} text-zinc-600/60 hover:text-zinc-400 text-center italic`}else if(pe==="tech"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-cyan-50 font-bold uppercase tracking-widest text-center drop-shadow-[0_0_10px_rgba(34,211,238,0.8)]`,nt=`${it} text-cyan-900/40 hover:text-cyan-800 text-center uppercase`}else if(pe==="gothic"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-7xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl";je=`${F} text-zinc-300 tracking-normal text-center drop-shadow-[0_4px_10px_rgba(0,0,0,0.9)]`,nt=`${it} text-zinc-700/60 hover:text-zinc-500 text-center`}else if(pe==="monospace"){const F=Se?W?"text-2xl":"text-3xl":W?"text-3xl":"text-5xl",it=Se?W?"text-lg":"text-xl":W?"text-xl":"text-2xl";je=`${F} font-mono font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`,nt=`${it} font-mono text-zinc-500/60 hover:text-zinc-300 drop-shadow-sm`}else if(pe==="classic"){const F=Se?W?"text-2xl":"text-3xl":W?"text-3xl":"text-6xl",it=Se?W?"text-lg":"text-xl":W?"text-xl":"text-2xl";je=`${F} font-serif italic font-bold text-amber-100 drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)]`,nt=`${it} font-serif text-zinc-500/60 hover:text-zinc-300 italic`}else if(pe==="slideshow"||pe==="just_video")je=`${Se?W?"text-2xl":"text-3xl":W?"text-3xl":"text-4xl"} text-white tracking-wide text-center`,nt="hidden";else if(pe==="subtitle"){je=`${Se?W?"text-2xl":"text-3xl":W?"text-3xl":"text-4xl"} text-white tracking-wide text-center whitespace-pre-wrap`,nt="hidden";let it="bottom-16";W&&vo?it="bottom-[560px]":W?it="bottom-[360px]":vo&&(it="bottom-[280px]"),vt=vt.replace("absolute","").replace("transform",""),vt+=`fixed ${it} left-1/2 -translate-x-1/2 w-full px-8 z-[100] pointer-events-none `}else if(pe==="custom"){const F=Se?W?"text-4xl":"text-5xl":W?"text-6xl":"text-8xl",it=Se?W?"text-xl":"text-2xl":W?"text-2xl":"text-3xl",bt=_.textAlign==="center"?"text-center":_.textAlign==="right"?"text-right":"text-left";je=`${F} tracking-tight ${bt}`,nt=`${it} opacity-40 hover:opacity-100 ${bt}`}else{const F=Se?W?"text-2xl":"text-3xl":W?"text-3xl":"text-5xl",it=Se?W?"text-lg":"text-xl":W?"text-xl":"text-2xl";je=`${F} font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`,nt=`${it} text-zinc-500/60 hover:text-zinc-300 drop-shadow-sm`}const Zt=(_.lyricStyleTarget||"active-only")==="all"||Fe;let He={color:_.fontColor,fontWeight:Zt?_.fontWeight:void 0,fontStyle:Zt?_.fontStyle:void 0,textDecoration:Zt?_.textDecoration:void 0,fontFamily:_.fontFamily==="CustomFont"?"CustomFont, sans-serif":_.fontFamily};if((pe==="custom"||pe==="default")&&Fe&&_.textEffect!=="none"){const F=_.textEffect;F==="glow"?He.textShadow=`0 0 10px ${_.fontColor}, 0 0 20px ${_.fontColor}`:F==="neon"?He.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${_.fontColor}, 0 0 40px ${_.fontColor}, 0 0 80px ${_.fontColor}`:F==="neon-multi"?He.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":F==="shadow"?He.textShadow="3px 3px 6px rgba(0,0,0,0.7)":F==="outline"?He.textShadow="-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000":F==="3d"?He.textShadow="1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)":F==="emboss"?(He.color="#ebebeb",He.textShadow="1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)"):F==="gold"?(He.background="linear-gradient(to bottom, #d4af37, #C5A028)",He.WebkitBackgroundClip="text",He.color="transparent"):F==="chrome"?(He.background="linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)",He.WebkitBackgroundClip="text",He.color="transparent"):F==="fire"?(He.color="#fff",He.textShadow="0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548"):F==="frozen"?(He.color="#fff",He.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"):F==="vhs"?He.textShadow="2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)":F==="gradient"?(He.background=`linear-gradient(to right, ${_.fontColor}, #ffffff)`,He.WebkitBackgroundClip="text",He.color="transparent"):F==="rainbow"?(He.background="linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)",He.WebkitBackgroundClip="text",He.color="transparent"):F==="glass"?(He.backgroundColor="rgba(255, 255, 255, 0.1)",He.backdropFilter="blur(8px)",He.padding="0.5rem 1rem",He.borderRadius="0.75rem",He.border="1px solid rgba(255, 255, 255, 0.2)",He.display="inline-block"):F==="mirror"?(He.transform="scaleY(1.3) perspective(500px) rotateX(-10deg)",He.textShadow="0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)"):F==="retro"?(He.fontFamily="'Press Start 2P', cursive",He.color="#ff00ff",He.textShadow="4px 4px 0px #00ffff"):F==="cyberpunk"?(He.color="#fcee0a",He.textShadow="2px 2px 0px #000, -1px -1px 0 #05d9e8",He.fontFamily="'Orbitron', sans-serif",He.letterSpacing="1px"):F==="glitch-text"?(He.animation="anim-glitch 0.4s infinite linear",He.position="relative"):F==="hologram"?(He.color="rgba(0, 255, 255, 0.7)",He.textShadow="0 0 5px rgba(0,255,255,0.5), 0 0 10px rgba(0,255,255,0.5)",He.backgroundImage="repeating-linear-gradient(0deg, transparent, transparent 2px, #00ffff 3px)",He.WebkitBackgroundClip="text"):F==="comic"&&(He.fontFamily="'Bangers', cursive",He.color="#ffcc00",He.textShadow="2px 2px 0px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000",He.letterSpacing="1px")}let Rt=k.text;const Qt=_.textCase;Qt==="upper"?Rt=Rt.toUpperCase():Qt==="lower"?Rt=Rt.toLowerCase():Qt==="title"?Rt=Rt.replace(/\w\S*/g,F=>F.charAt(0).toUpperCase()+F.substr(1).toLowerCase()):Qt==="sentence"?Rt=Rt.charAt(0).toUpperCase()+Rt.slice(1).toLowerCase():Qt==="invert"&&(Rt=Rt.replace(/\w\S*/g,F=>F.charAt(0).toLowerCase()+F.slice(1).toUpperCase())),Rt=Rt.replace(/\s*([-‐‑‒–—―])\s*/g,"$1"),Fe&&_.textAnimation==="typewriter"&&(Rt=Rt.substring(0,Math.max(0,Math.floor((Ne-k.time)*35))));let An=Rt;if(Fe&&_.highlightEffect!=="none"){const F=_.highlightEffect,it=k.words&&k.words.length>0;if((F==="karaoke"||F?.startsWith("karaoke-"))&&it)An=k.words.filter(bt=>bt.text===` +`||bt.text.trim().length>0).map((bt,qe,Ut)=>{if(bt.text===` +`)return d.jsx("br",{},qe);let pt=bt.text.trim();if(Qt==="upper")pt=pt.toUpperCase();else if(Qt==="lower")pt=pt.toLowerCase();else if(Qt==="title")pt=pt.replace(/\w\S*/g,It=>It.charAt(0).toUpperCase()+It.substr(1).toLowerCase());else if(Qt==="sentence"){const It=pt.toLowerCase();pt=qe===0?It.charAt(0).toUpperCase()+It.slice(1):It}else Qt==="invert"&&(pt=pt.replace(/\w\S*/g,It=>It.charAt(0).toLowerCase()+It.slice(1).toUpperCase()));const sn=bt.startTime+se,rn=bt.endTime+se,vn=Ne>=sn&&Ne=rn,Ln=/[-‐‑‒–—―]$/,di=/^[-‐‑‒–—―]/;let pn=!pt.endsWith(" ");Ln.test(pt.trim())&&(pn=!1);const mi=Ut[qe+1];mi&&di.test(mi.text.trim())&&(pn=!1),mi&&mi.text===` +`&&(pn=!1),qe===Ut.length-1&&(pn=!1);let te={display:"inline-block",transition:"all 0.1s ease"};if(_.textDecoration&&_.textDecoration!=="none"&&(te.textDecoration=_.textDecoration),!vn&&!io)F==="karaoke-smooth-white"?(te.opacity=1,te.color="#ffffff"):te.opacity=.5,te.transform="scale(1)";else if(io)if(F==="karaoke-fill"){const It=_.highlightBackground||"#fb923c";te.backgroundColor=It,te.color="#000",te.padding="2px 6px",te.borderRadius="4px",te.opacity=1}else F==="karaoke-smooth"||F==="karaoke-smooth-white"?(te.color=_.highlightColor||"#fb923c",te.opacity=1):(pe==="custom"&&(te.color=_.fontColor),te.opacity=1);if(vn){const It=_.highlightColor||"#fb923c",Un=_.highlightBackground||"#fb923c";if(F==="karaoke-smooth"||F==="karaoke-smooth-white"){const Ji=bt.endTime-bt.startTime,oo=Ne-sn,xo=Math.min(100,Math.max(0,oo/Ji*100)),bo=F==="karaoke-smooth-white"?"#ffffff":_.fontColor||"#ffffff";te.backgroundImage=`linear-gradient(90deg, ${It} ${xo}%, ${bo} ${xo}%)`,te.backgroundClip="text",te.WebkitBackgroundClip="text",te.color="transparent",te.WebkitTextFillColor="transparent",te.textShadow="none"}else F==="karaoke"||F==="color"?(te.color=It,te.textShadow=`0 0 10px ${It}`):F==="karaoke-neon"?(te.color="#fff",te.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${It}, 0 0 35px ${It}`):F==="karaoke-scale"?(te.color=It,te.transform="scale(1.3)"):F==="karaoke-underline"?(te.color=It,te.textDecoration=(te.textDecoration||"")+" underline",te.textDecorationColor=It,te.textUnderlineOffset="4px"):F==="karaoke-bounce"?(te.color=It,te.transform="translateY(-10px)"):F==="karaoke-fill"?(te.backgroundColor=Un,te.color="#000",te.padding="2px 6px",te.borderRadius="4px"):F==="karaoke-outline"?(te.color="transparent",te.WebkitTextStroke=`2px ${It}`):F==="karaoke-shadow"?(te.color=It,te.textShadow="3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000"):F==="karaoke-gradient"?(te.background=`linear-gradient(90deg, ${It}, ${Un})`,te.WebkitBackgroundClip="text",te.WebkitTextFillColor="transparent"):F==="karaoke-wave"?(te.color=It,te.animation="bounce 0.3s ease infinite"):F==="karaoke-pill"?(te.backgroundColor=Un,te.color="#000",te.padding="4px 16px",te.borderRadius="9999px"):F==="karaoke-box"?(te.backgroundColor=Un,te.color="#000",te.padding="4px 8px",te.borderRadius="0"):F==="karaoke-rounded"?(te.backgroundColor=Un,te.color="#000",te.padding="4px 12px",te.padding="4px 12px",te.borderRadius="12px"):F==="karaoke-glass"?(te.backgroundColor="rgba(255, 255, 255, 0.1)",te.color="#fff",te.padding="4px 12px",te.borderRadius="8px",te.backdropFilter="blur(4px)",te.border="1px solid rgba(255, 255, 255, 0.3)",te.boxShadow="0 4px 6px rgba(0, 0, 0, 0.1)"):F==="karaoke-neon-multi"?(te.color="#fff",te.textShadow="0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 35px #00ffff, 0 0 40px #ff00de"):F==="karaoke-soft-glow"?(te.color=It,te.textShadow=`0 0 5px ${It}, 0 0 15px ${It}, 0 0 30px ${It}`):F==="karaoke-3d"?te.textShadow="1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)":F==="karaoke-emboss"?(te.color="#ebebeb",te.textShadow="1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)"):F==="karaoke-chrome"?(te.background="linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)",te.WebkitBackgroundClip="text",te.color="transparent"):F==="karaoke-gold"?(te.background="linear-gradient(to bottom, #d4af37, #C5A028)",te.WebkitBackgroundClip="text",te.color="transparent"):F==="karaoke-fire"?(te.color="#fff",te.textShadow="0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548"):F==="karaoke-frozen"?(te.color="#fff",te.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"):F==="karaoke-rainbow"?(te.background="linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)",te.WebkitBackgroundClip="text",te.color="transparent"):F==="karaoke-mirror"?(te.transform="scaleY(1.3) perspective(500px) rotateX(-10deg)",te.textShadow="0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)"):F==="karaoke-vhs"?te.textShadow="2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)":F==="karaoke-retro"?(te.fontFamily="'Press Start 2P', cursive",te.color="#ff00ff",te.textShadow="4px 4px 0px #00ffff"):F==="karaoke-cyberpunk"?(te.color="#fcee0a",te.textShadow="2px 2px 0px #000, -1px -1px 0 #05d9e8",te.fontFamily="'Orbitron', sans-serif"):F==="karaoke-hologram"?(te.color="rgba(0, 255, 255, 0.7)",te.textShadow="0 0 5px rgba(0,255,255,0.5)"):F==="karaoke-comic"?(te.fontFamily="'Bangers', cursive",te.color="#ffcc00",te.textShadow="2px 2px 0px #000, -1px -1px 0 #000"):F==="karaoke-glitch-text"?te.animation="anim-glitch 0.4s infinite linear":F==="karaoke-pulse"?te.animation="anim-pulse 1s infinite ease-in-out":F==="karaoke-breathe"?te.animation="anim-breathe 2s infinite ease-in-out":F==="karaoke-float"?te.animation="anim-float 2s infinite ease-in-out":F==="karaoke-sway"?te.animation="anim-sway 2s infinite ease-in-out":F==="karaoke-flicker"?te.animation="anim-flicker 2s infinite linear":F==="karaoke-shake"?te.animation="anim-shake 0.2s infinite linear":F==="karaoke-wobble"?te.animation="anim-wobble 1s infinite ease-in-out":F==="karaoke-jello"?te.animation="anim-jello 1s infinite":F==="karaoke-rubberband"?te.animation="anim-rubberband 1s infinite":F==="karaoke-heartbeat"?te.animation="anim-heartbeat 1.3s infinite ease-in-out":F==="karaoke-flash"?te.animation="anim-flash 1s infinite":F==="karaoke-tada"?te.animation="anim-tada 1s infinite":F==="karaoke-swing"?te.animation="anim-swing 2s infinite":F==="karaoke-rotate"?te.animation="anim-rotate 4s infinite linear":F==="karaoke-spin"?te.animation="anim-rotate 1s infinite linear":F==="karaoke-glitch"?te.animation="anim-glitch 0.3s infinite linear":F==="karaoke-typewriter"?(te.animation="typewriter-reveal 0.5s steps(10, end) forwards",te.whiteSpace="nowrap",te.overflow="hidden",te.display="inline-block",te.verticalAlign="bottom"):F==="karaoke-fade"?te.animation="trans-fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards":F==="karaoke-slide"?te.animation="trans-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards":F==="karaoke-drop"?te.animation="trans-drop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards":F==="karaoke-lightspeed"?te.animation="trans-lightspeed-in 0.5s ease-out forwards":F==="karaoke-roll"?te.animation="trans-roll-in 0.5s ease-out forwards":F==="karaoke-zoom"?te.animation="trans-zoom-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards":F==="karaoke-elastic"?te.animation="trans-elastic-in 0.7s ease-out forwards":F==="karaoke-scale-rotate"?te.animation="trans-scale-rotate-in 0.5s ease-out forwards":F==="karaoke-flip"?te.animation="trans-flip-in 0.5s ease-out forwards":F==="karaoke-rotate-in"?te.animation="trans-rotate-in 0.5s ease-out forwards":F==="karaoke-spiral"?te.animation="trans-spiral-in 0.6s ease-out forwards":F==="karaoke-blur"?te.animation="trans-blur-in 0.4s ease-out forwards":F==="karaoke-shatter"?te.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(F||"")&&(te.color=It,te.textShadow=`0 0 10px ${It}`,F?.includes("glow")&&(te.textShadow=`0 0 5px ${It}, 0 0 15px ${It}, 0 0 30px ${It}`))}const gi=d.jsx("span",{className:"inline-block",style:te,children:pt},qe);return pn?d.jsxs($f.Fragment,{children:[gi," "]},qe):gi});else if(F==="karaoke"||F?.startsWith("karaoke-")){const bt=_.highlightColor||"#fb923c",qe=_.highlightBackground||"#fb923c";He.color=bt,F==="karaoke-neon"&&(He.textShadow=`0 0 10px ${bt}, 0 0 20px ${bt}`),F==="karaoke-scale"&&(He.transform=(He.transform||"")+" scale(1.1)"),F==="karaoke-underline"&&(He.textDecoration="underline"),F==="karaoke-bounce"&&(He.transform=(He.transform||"")+" translateY(-5px)"),F==="karaoke-fill"&&(He.backgroundColor=qe,He.color="#000",He.padding="4px 12px",He.borderRadius="6px"),F==="karaoke-outline"&&(He.color="transparent",He.WebkitTextStroke=`2px ${bt}`),F==="karaoke-shadow"&&(He.textShadow="3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000"),F==="karaoke-gradient"&&(He.background=`linear-gradient(90deg, ${bt}, ${qe})`,He.WebkitBackgroundClip="text",He.WebkitTextFillColor="transparent"),["karaoke-pill","karaoke-box","karaoke-rounded"].includes(F)&&(He.backgroundColor=qe,He.color="#000",He.padding="4px 16px",He.borderRadius=F==="karaoke-pill"?"9999px":F==="karaoke-rounded"?"12px":"0"),F?.includes("glow")&&(He.textShadow=`0 0 10px ${bt}, 0 0 20px ${bt}`)}else F==="scale"?He.color=_.highlightColor||"#fb923c":_.highlightEffect==="background"&&(He.backgroundColor=(_.highlightBackground||"#fb923c")+"4D",He.padding="0 10px",He.borderRadius="8px")}return d.jsx("p",{"data-lyric-active":Fe?"true":"false",className:`${vt} ${Fe?je:nt}`,onClick:()=>{Fe&&(navigator.clipboard.writeText(k.text),e.success("Lyric copied to clipboard",1500)),o.current&&!B&&(o.current.currentTime=k.time,Xe(k.time))},children:d.jsx("span",{className:`inline-block ${Fe&&_.textAnimation!=="none"&&_.textAnimation!=="typewriter"?`text-anim-${_.textAnimation}`:""}`,children:d.jsx("span",{style:He,className:"inline-block",children:An})})},J)}),d.jsx("div",{className:`transition-all duration-500 ${_.contentPosition==="center"?Ee===ii.EDITOR||dt?"h-[25vh]":!qo&&!vo?"h-[50vh]":"h-[40vh]":"h-0"}`})]}):d.jsx("div",{className:"text-center text-zinc-400/50 select-none pointer-events-none",children:!no&&!m&&me.length===0&&pe!=="none"&&d.jsxs("div",{className:"flex flex-col items-center gap-4 animate-pulse",children:[d.jsx(La,{size:64,className:"opacity-20"}),d.jsx("p",{children:"Load audio & lyrics to start"}),d.jsx("p",{className:"text-xs opacity-50",children:"Shortcuts: Space (Play), S (Stop), R (Repeat), H (Hold UI)"})]})})}),d.jsx("div",{className:`no-minimal-mode-toggle transition-all duration-500 ease-in-out overflow-hidden ${vo?"max-h-60 opacity-100 translate-y-0":"max-h-0 opacity-0 translate-y-4"}`,children:d.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:d.jsxs("div",{className:"max-w-7xl mx-auto space-y-4",children:[d.jsxs("div",{className:"flex items-center gap-3 group",children:[d.jsx("span",{className:"text-xs text-zinc-400 font-mono w-10 text-right",children:uo(Ne)}),d.jsxs("div",{ref:Dt,className:"flex-1 h-1 bg-zinc-700/50 rounded-full relative cursor-pointer group-hover:h-2 transition-all touch-none",onPointerDown:k=>{k.currentTarget.setPointerCapture(k.pointerId),wl(k.clientX)},onPointerMove:k=>{k.buttons===1&&wl(k.clientX)},children:[d.jsx("div",{className:"absolute top-0 left-0 h-full bg-purple-500 rounded-full pointer-events-none",style:{width:`${Ne/$e*100}%`}}),d.jsx("input",{type:"range",name:"progress",id:"progress-bar","aria-label":"Seek Progress",min:"0",max:$e||0,value:Ne,onChange:Ql,disabled:B,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-wait pointer-events-none"})]}),d.jsx("span",{className:"text-xs text-zinc-400 font-mono w-10",children:uo($e)}),d.jsxs("div",{className:"flex items-center gap-2 pl-4",children:[d.jsx("button",{onClick:()=>G(!Nt),className:"text-zinc-400 hover:text-white",children:Nt||gt===0?d.jsx(Ia,{size:16}):d.jsx(gl,{size:16})}),d.jsxs("div",{ref:Mt,className:"w-16 h-1 bg-zinc-700/50 rounded-full relative overflow-hidden group/vol cursor-pointer touch-none",onPointerDown:k=>{k.currentTarget.setPointerCapture(k.pointerId),ui(k.clientX)},onPointerMove:k=>{k.buttons===1&&ui(k.clientX)},children:[d.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:`${Nt?0:gt*100}%`}}),d.jsx("input",{type:"range",name:"volume",id:"volume-control","aria-label":"Volume Control",min:"0",max:"1",step:"0.05",value:Nt?0:gt,onChange:Yi,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer pointer-events-none"})]})]})]}),d.jsxs("div",{className:"flex flex-wrap lg:grid lg:grid-cols-[1fr_auto_1fr] items-center justify-center gap-4",children:[d.jsxs("div",{className:"flex gap-1 justify-center lg:justify-start flex-wrap order-2 lg:order-none w-auto lg:w-full",children:[d.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:[d.jsx(La,{size:18}),d.jsx("input",{type:"file",name:"audio-file",id:"audio-file",accept:"audio/*,video/*",className:"hidden",onChange:Sl,disabled:B})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs("label",{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${j.length>0?"text-purple-400":"text-zinc-400 hover:text-white"}`,title:"Load Lyrics (.lrc, .srt, .vtt, .ttml)",children:[d.jsx(Ac,{size:18}),d.jsx("input",{type:"file",name:"lyrics-file",id:"lyrics-file",accept:".lrc,.srt,.ttml,.xml,.vtt",className:"hidden",onChange:Ho,disabled:B})]}),j.length>0&&d.jsx("button",{onClick:()=>I([]),className:"p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors",title:"Clear Lyrics",disabled:B,children:d.jsx(zi,{size:14})})]}),d.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9",children:[d.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:[se>0?"+":"",se.toFixed(1),"s"]}),d.jsxs("div",{className:"flex flex-col -my-1 h-full justify-center",children:[d.jsx("button",{onClick:()=>fe(k=>parseFloat((k+.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:B,children:d.jsx(pf,{size:12})}),d.jsx("button",{onClick:()=>fe(k=>parseFloat((k-.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:B,children:d.jsx(Qs,{size:12})})]})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs("label",{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${et?"text-purple-400":"text-zinc-400 hover:text-white"}`,title:et?`Custom Font: ${et}`:"Load Custom Font (.ttf, .otf, .woff)",children:[d.jsx(yl,{size:18}),d.jsx("input",{type:"file",name:"font-file",id:"font-file",accept:".ttf,.otf,.woff,.woff2",className:"hidden",onChange:go,disabled:B})]}),et&&d.jsx("button",{onClick:()=>z(null),className:"p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors",title:"Reset Default Font",disabled:B,children:d.jsx(zi,{size:14})})]}),d.jsxs("div",{className:"flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9",children:[d.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(_.fontSizeScale*100),"%"]}),d.jsxs("div",{className:"flex flex-col -my-1 h-full justify-center",children:[d.jsx("button",{onClick:()=>st(k=>({...k,fontSizeScale:Math.min(k.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:B,children:d.jsx(pf,{size:12})}),d.jsx("button",{onClick:()=>st(k=>({...k,fontSizeScale:Math.max(k.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:B,children:d.jsx(Qs,{size:12})})]})]}),d.jsxs("div",{className:"relative group",children:[d.jsxs("select",{value:pe,onChange:k=>{const J=k.target.value;Oe(J);const Fe=Fc[J];if(Fe){const W={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"};st(Se=>({...Se,...W,...Fe}))}},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:B,title:"Select Visual Preset",name:"preset",id:"preset-select","aria-label":"Visual Preset",children:[d.jsx("option",{value:"custom",className:"bg-zinc-900 font-bold text-purple-400",children:"Custom ✨"}),d.jsx("option",{value:"default",className:"bg-zinc-900",children:"Default"}),d.jsx("option",{value:"large",className:"bg-zinc-900",children:"Big Text"}),d.jsx("option",{value:"large_upper",className:"bg-zinc-900",children:"Big Text (UP)"}),d.jsx("option",{value:"big_center",className:"bg-zinc-900",children:"Big Center"}),d.jsx("option",{value:"metal",className:"bg-zinc-900",children:"Metal"}),d.jsx("option",{value:"kids",className:"bg-zinc-900",children:"Kids"}),d.jsx("option",{value:"sad",className:"bg-zinc-900",children:"Sad"}),d.jsx("option",{value:"romantic",className:"bg-zinc-900",children:"Romantic"}),d.jsx("option",{value:"tech",className:"bg-zinc-900",children:"Tech"}),d.jsx("option",{value:"gothic",className:"bg-zinc-900",children:"Gothic"}),d.jsx("option",{value:"classic",className:"bg-zinc-900",children:"Classic Serif"}),d.jsx("option",{value:"monospace",className:"bg-zinc-900",children:"Monospace"}),d.jsx("option",{value:"testing_up",className:"bg-zinc-900",children:"Testing (UP)"}),d.jsx("option",{value:"testing",className:"bg-zinc-900",children:"Testing"}),d.jsx("option",{value:"one_line_up",className:"bg-zinc-900",children:"One Line (UP)"}),d.jsx("option",{value:"one_line",className:"bg-zinc-900",children:"One Line"}),d.jsx("option",{value:"slideshow",className:"bg-zinc-900",children:"Slideshow"}),d.jsx("option",{value:"just_video",className:"bg-zinc-900",children:"Just Video"}),d.jsx("option",{value:"subtitle",className:"bg-zinc-900",children:"Subtitle"}),d.jsx("option",{value:"none",className:"bg-zinc-900",children:"None"})]}),d.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:d.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:d.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]})]}),d.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:[d.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",onClick:Qn,title:"Stop (S)",disabled:B,children:d.jsx(yf,{size:20,fill:"currentColor"})}),d.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:B||me.length===0,onClick:Xl,title:"Previous Song",children:d.jsx(FS,{size:24})}),d.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:B,onClick:()=>o.current&&(o.current.currentTime-=5),title:"Rewind 5s",children:d.jsx(NS,{size:20})}),d.jsx("button",{onClick:Wl,disabled:B,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:De?d.jsx(tv,{size:28,fill:"currentColor"}):d.jsx(hf,{size:28,fill:"currentColor",className:"ml-1"})}),d.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:B,onClick:()=>o.current&&(o.current.currentTime+=5),title:"Fast Forward 5s",children:d.jsx(J1,{size:20})}),d.jsx("button",{className:"text-zinc-400 hover:text-white transition-colors disabled:opacity-50",disabled:B||me.length===0,onClick:_n,title:"Next Song",children:d.jsx(BS,{size:24})}),d.jsxs("button",{className:`transition-colors disabled:opacity-50 ${ye!=="off"?"text-green-400 hover:text-green-300":"text-zinc-400 hover:text-white"}`,onClick:yo,title:`Repeat: ${ye==="off"?"Off":ye==="one"?"One":ye==="all"?"Play All (No Repeat)":"Loop All"} (R)`,disabled:B,children:[ye==="one"&&d.jsx(CS,{size:20}),ye==="all_repeat"&&d.jsx(ag,{size:20}),ye==="all"&&d.jsx(kc,{size:20}),ye==="off"&&d.jsx(ag,{size:20,className:"opacity-50"})]})]}),d.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:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{onClick:()=>st(k=>({...k,backgroundBlurStrength:k.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 ${ot?"text-purple-400 border-purple-500/50":"text-zinc-300 hover:text-white"}`,title:`Background Blur: ${ot?"On":"Off"}`,disabled:B,children:ot?"BLUR":"SHARP"}),d.jsx("button",{onClick:()=>st(k=>({...k,highlightEffect:k.highlightEffect==="none"?"karaoke":"none"})),className:`p-2 rounded-full transition-all ${_.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:d.jsx(yl,{size:20})}),d.jsx("button",{onClick:()=>xe(k=>k==="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:B,children:Re}),d.jsx("button",{onClick:()=>Be(k=>k==="16:9"?"9:16":k==="9:16"?"3:4":k==="3:4"?"1:1":k==="1:1"?"1:2":k==="1:2"?"2:1":k==="2:1"?"2:3":k==="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:B,children:P})]}),d.jsxs("div",{className:"relative group",children:[d.jsxs("select",{value:w,onChange:k=>M(k.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:B,title:"Select Render Engine",name:"engine",id:"engine-select","aria-label":"Render Engine",children:[d.jsx("option",{value:"mediarecorder",className:"bg-zinc-900",children:"Realtime"}),d.jsx("option",{value:"webcodecs",className:"bg-zinc-900",children:"WebCodecs"}),d.jsx("option",{value:"ffmpeg",className:"bg-zinc-900",children:"FFMPEG"})]}),d.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:d.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:d.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),d.jsxs("div",{className:"relative group",children:[d.jsxs("select",{value:ue,onChange:k=>Ge(k.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:B,title:"Select Quality (Bitrate)",name:"quality",id:"quality-select","aria-label":"Render Quality",children:[d.jsx("option",{value:"low",className:"bg-zinc-900",children:"Low"}),d.jsx("option",{value:"med",className:"bg-zinc-900",children:"Med"}),d.jsx("option",{value:"high",className:"bg-zinc-900",children:"High"})]}),d.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500",children:d.jsx("svg",{className:"fill-current h-3 w-3",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:d.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),d.jsx("button",{onClick:Zl,disabled:B||!m,className:"p-2 rounded-lg hover:bg-white/10 text-zinc-400 hover:text-white cursor-pointer transition-colors",title:`Export as Video (${w==="ffmpeg"?"FFmpeg":"MediaRecorder"})`,children:d.jsx(qs,{size:18})})]})]})]})})}),dt?d.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:d.jsx(FM,{playlist:me,setPlaylist:Ue,currentTrackIndex:mt,setCurrentTrackIndex:yt,onPlayTrack:wi,isPlaying:De,onTogglePlay:Wl,currentTime:Ne,onSeek:k=>{o.current&&!B&&(o.current.currentTime=k,Xe(k))},onClearPlaylist:()=>{Qn(),x(null),I([]),yt(-1),E({title:"No Audio Loaded",artist:"Select a file",coverUrl:null,backgroundType:"image"})},onRemoveTrack:k=>{k===mt?(Qn(),x(null),I([]),yt(-1),E({title:"No Audio Loaded",artist:"Select a file",coverUrl:null,backgroundType:"image"})):kJ-1),Ue(J=>{const Fe=[...J];return Fe.splice(k,1),Fe})},onClose:()=>Ot(!1)})}):Ee===ii.EDITOR&&d.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:d.jsx(bT,{slides:$,setSlides:oe,currentTime:Ne,duration:$e||60,lyrics:j,onSeek:k=>{o.current&&!B&&(o.current.currentTime=k,Xe(k))},onClose:()=>ie(ii.PLAYER),renderConfig:_,setRenderConfig:st})})]}),B&&d.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:[d.jsx("div",{className:w==="ffmpeg"?"animate-pulse":"animate-bounce",children:d.jsx(qs,{size:48,className:w==="ffmpeg"?"text-orange-500":"text-purple-500"})}),d.jsxs("h2",{className:"text-2xl font-bold text-white",children:[w==="ffmpeg"?"FFmpeg Rendering":"Rendering Video"," (",P," ",Re,")"]}),d.jsx("p",{className:"text-zinc-400 max-w-md",children:w==="ffmpeg"?d.jsxs(d.Fragment,{children:["Frame-by-frame capture using FFmpeg WASM.",d.jsx("br",{}),d.jsx("span",{className:"text-orange-400 font-medium",children:Y||"Initializing..."}),d.jsx("br",{}),"This is faster than realtime - no audio playback needed."]}):d.jsxs(d.Fragment,{children:["Rendering in real-time using Canvas 2D engine.",d.jsx("br",{}),"The audio will play during capture.",d.jsx("br",{}),"Please keep this tab active for best performance."]})}),d.jsx("div",{className:"w-full max-w-md h-2 bg-zinc-800 rounded-full overflow-hidden",children:d.jsx("div",{className:`h-full transition-all duration-300 ease-linear ${w==="ffmpeg"?"bg-orange-500":"bg-purple-500"}`,style:{width:`${ae}%`}})}),d.jsxs("p",{className:"text-sm font-mono text-zinc-500",children:[Math.round(ae),"%"]}),d.jsxs("button",{onClick:Go,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:[d.jsx(yf,{size:16,fill:"currentColor"}),"Abort Rendering"]})]}),de&&d.jsx(GM,{config:_,setConfig:st,preset:pe,setPreset:Oe,onClose:()=>Le(!1),isPlaylistMode:dt,hasPlaylist:me.length>0,onRender:Zl,customFontName:et,onFontUpload:go,onClearCustomFont:()=>{z(null),st(k=>({...k,fontFamily:"ui-sans-serif, system-ui, sans-serif"}))},customChannelFontName:Ve,onChannelFontUpload:jo,onClearChannelCustomFont:()=>{at(null),st(k=>({...k,channelInfoFontFamily:void 0}))},customInfoFontName:U,onInfoFontUpload:Tl,onClearInfoCustomFont:()=>{Z(null),st(k=>({...k,infoFontFamily:void 0}))},resolution:Re,setResolution:xe,aspectRatio:P,setAspectRatio:Be,renderCodec:ce,setRenderCodec:Ae,supportedCodecs:Wt,renderQuality:ue,setRenderQuality:Ge,renderFps:ve,setRenderFps:Me,renderEngine:w,setRenderEngine:M,ffmpegCodec:R,setFfmpegCodec:V}),ke&&d.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:()=>Ie(!1),children:d.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:k=>k.stopPropagation(),children:[d.jsx("button",{onClick:()=>Ie(!1),className:"absolute top-4 right-4 p-2 rounded-full hover:bg-white/10 text-zinc-400 hover:text-white transition-colors",children:d.jsx(zi,{size:20})}),d.jsxs("h2",{className:"text-2xl font-bold text-white mb-6 flex items-center gap-2",children:[d.jsx(Mc,{className:"text-purple-500"}),"Keyboard Shortcuts"]}),d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-12 gap-y-6",children:[d.jsxs("div",{className:"space-y-4",children:[d.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider",children:"Playback"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Play / Pause"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Space"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Stop"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"S"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Rewind 5s"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"←"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Forward 5s"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"→"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Repeat Mode"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"R"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Mute"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"M"})]})]}),d.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6",children:"Interface"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Fullscreen"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"F"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Minimal Mode"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"O"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Hold UI (No Auto-Hide)"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"H"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Header Info"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"I"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Shortcut Info"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Y"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Player"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"P"})]})]})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider",children:"Editor & Styles"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Timeline"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"T"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Playlist"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"L"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Render Settings"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"D"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Export Video"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Ctrl+Shift+E"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Font Size"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"+ / -"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Visual Preset"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"J"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Highight Effect"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Z"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Highlight"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"X"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Text Case"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"C"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Cycle Lyric Mode"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"G"})]})]}),d.jsx("h3",{className:"text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6",children:"Mouse & Touch"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Toggle Minimal Mode"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Double Click / Tap"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Seek to Lyric"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Click Line"})]}),d.jsxs("div",{className:"flex justify-between text-sm",children:[d.jsx("span",{className:"text-zinc-300",children:"Copy Active Lyric"})," ",d.jsx("span",{className:"font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded",children:"Click Active Line"})]})]})]})]}),d.jsx("div",{className:"mt-8 pt-6 border-t border-white/5 text-center",children:d.jsx("p",{className:"text-zinc-500 text-sm",children:"Shortcuts are disabled during video rendering."})})]})})]})}const gx=document.getElementById("root");if(!gx)throw new Error("Could not find root element to mount to");const mk=y1.createRoot(gx);mk.render(d.jsx($f.StrictMode,{children:d.jsx(mT,{children:d.jsx(hk,{})})}));export{gk as c,Qy as g};