@ysolve/ocity-heritage-visualizer 1.1.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(B,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],w):(B=typeof globalThis<"u"?globalThis:B||self,w(B.OCityHeritageVisualizer={},B["react/jsx-runtime"],B.React))})(this,function(B,w,y){"use strict";var Lr=Object.defineProperty;var vr=(B,w,y)=>w in B?Lr(B,w,{enumerable:!0,configurable:!0,writable:!0,value:y}):B[w]=y;var De=(B,w,y)=>vr(B,typeof w!="symbol"?w+"":w,y);const It={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_DEBUG_MODE:"false",VITE_DEFAULT_IMAGE_URL:"https://o-city.org/assets/NO_AVAILABLE_IMG-4d02b370.png",VITE_GOOGLE_TRANSLATE_BASE:"https://translate.googleapis.com/translate_a/single",VITE_IMAGE_BASE_URL:"https://eu2.contabostorage.com/7fb97413b6c243adb4347dafa02551a9:ocity/heritage/images/",VITE_QWEN_TTS_API_URL:"https://playground-tts.o-city.org"};function ie(e,t=!0){const n=It[e];if(!n&&t)throw new Error(`❌ Missing required env variable: ${e}`);return n??""}const ae={NODE_ENV:"production",QWEN_TTS_API_URL:ie("VITE_QWEN_TTS_API_URL"),DEBUG_MODE:!1,GOOGLE_TRANSLATE_BASE:ie("VITE_GOOGLE_TRANSLATE_BASE"),IMAGE_BASE_URL:ie("VITE_IMAGE_BASE_URL"),DEFAULT_IMAGE_URL:ie("VITE_DEFAULT_IMAGE_URL")};async function je(e,t){if(!e.trim())return e;try{const n=`${ae.GOOGLE_TRANSLATE_BASE}?client=gtx&sl=auto&tl=${t}&dt=t&q=${encodeURIComponent(e)}`,r=await fetch(n);if(!r.ok)throw new Error(`Error en la traducción: ${r.status}`);const s=await r.json();return s&&Array.isArray(s[0])?s[0].map(o=>o[0]).join(""):e}catch(n){return console.error("Error al traducir:",n),e}}function Te(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Ft(e,t){let n;const r=()=>{if(n)return n;const s=indexedDB.open(e);return s.onupgradeneeded=()=>s.result.createObjectStore(t),n=Te(s),n.then(o=>{o.onclose=()=>n=void 0},()=>{}),n};return(s,o)=>r().then(i=>o(i.transaction(t,s).objectStore(t)))}let _e;function Me(){return _e||(_e=Ft("keyval-store","keyval")),_e}function Dt(e,t=Me()){return t("readonly",n=>Te(n.get(e)))}function jt(e,t,n=Me()){return n("readwrite",r=>(r.put(t,e),Te(r.transaction)))}async function Mt(e){return await Dt(e)??null}async function $t(e,t){await jt(e,t)}function $e(e,t){return function(){return e.apply(t,arguments)}}const{toString:qt}=Object.prototype,{getPrototypeOf:Ae}=Object,{iterator:ce,toStringTag:qe}=Symbol,le=(e=>t=>{const n=qt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>le(t)===e),ue=e=>t=>typeof t===e,{isArray:K}=Array,te=ue("undefined");function zt(e){return e!==null&&!te(e)&&e.constructor!==null&&!te(e.constructor)&&P(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ze=D("ArrayBuffer");function Ht(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ze(e.buffer),t}const Vt=ue("string"),P=ue("function"),He=ue("number"),de=e=>e!==null&&typeof e=="object",Wt=e=>e===!0||e===!1,fe=e=>{if(le(e)!=="object")return!1;const t=Ae(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(qe in e)&&!(ce in e)},Gt=D("Date"),Jt=D("File"),Qt=D("Blob"),Kt=D("FileList"),Xt=e=>de(e)&&P(e.pipe),Zt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||P(e.append)&&((t=le(e))==="formdata"||t==="object"&&P(e.toString)&&e.toString()==="[object FormData]"))},Yt=D("URLSearchParams"),[en,tn,nn,rn]=["ReadableStream","Request","Response","Headers"].map(D),sn=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ne(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),K(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(r=0;r<i;r++)l=o[r],t.call(null,e[l],l,e)}}function Ve(e,t){t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const V=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,We=e=>!te(e)&&e!==V;function Re(){const{caseless:e}=We(this)&&this||{},t={},n=(r,s)=>{const o=e&&Ve(t,s)||s;fe(t[o])&&fe(r)?t[o]=Re(t[o],r):fe(r)?t[o]=Re({},r):K(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&ne(arguments[r],n);return t}const on=(e,t,n,{allOwnKeys:r}={})=>(ne(t,(s,o)=>{n&&P(s)?e[o]=$e(s,n):e[o]=s},{allOwnKeys:r}),e),an=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cn=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ln=(e,t,n,r)=>{let s,o,i;const l={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&Ae(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},un=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},dn=e=>{if(!e)return null;if(K(e))return e;let t=e.length;if(!He(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},fn=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ae(Uint8Array)),pn=(e,t)=>{const r=(e&&e[ce]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},hn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},mn=D("HTMLFormElement"),wn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ge=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),gn=D("RegExp"),Je=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};ne(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},yn=e=>{Je(e,(t,n)=>{if(P(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(P(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},En=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return K(e)?r(e):r(String(e).split(t)),n},Sn=()=>{},bn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Tn(e){return!!(e&&P(e.append)&&e[qe]==="FormData"&&e[ce])}const _n=e=>{const t=new Array(10),n=(r,s)=>{if(de(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=K(r)?[]:{};return ne(r,(i,l)=>{const c=n(i,s+1);!te(c)&&(o[l]=c)}),t[s]=void 0,o}}return r};return n(e,0)},An=D("AsyncFunction"),Rn=e=>e&&(de(e)||P(e))&&P(e.then)&&P(e.catch),Qe=((e,t)=>e?setImmediate:t?((n,r)=>(V.addEventListener("message",({source:s,data:o})=>{s===V&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),V.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",P(V.postMessage)),On=typeof queueMicrotask<"u"?queueMicrotask.bind(V):typeof process<"u"&&process.nextTick||Qe,a={isArray:K,isArrayBuffer:ze,isBuffer:zt,isFormData:Zt,isArrayBufferView:Ht,isString:Vt,isNumber:He,isBoolean:Wt,isObject:de,isPlainObject:fe,isReadableStream:en,isRequest:tn,isResponse:nn,isHeaders:rn,isUndefined:te,isDate:Gt,isFile:Jt,isBlob:Qt,isRegExp:gn,isFunction:P,isStream:Xt,isURLSearchParams:Yt,isTypedArray:fn,isFileList:Kt,forEach:ne,merge:Re,extend:on,trim:sn,stripBOM:an,inherits:cn,toFlatObject:ln,kindOf:le,kindOfTest:D,endsWith:un,toArray:dn,forEachEntry:pn,matchAll:hn,isHTMLForm:mn,hasOwnProperty:Ge,hasOwnProp:Ge,reduceDescriptors:Je,freezeMethods:yn,toObjectSet:En,toCamelCase:wn,noop:Sn,toFiniteNumber:bn,findKey:Ve,global:V,isContextDefined:We,isSpecCompliantForm:Tn,toJSONObject:_n,isAsyncFn:An,isThenable:Rn,setImmediate:Qe,asap:On,isIterable:e=>e!=null&&P(e[ce])};function S(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(S,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Ke=S.prototype,Xe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Xe[e]={value:e}}),Object.defineProperties(S,Xe),Object.defineProperty(Ke,"isAxiosError",{value:!0}),S.from=(e,t,n,r,s,o)=>{const i=Object.create(Ke);return a.toFlatObject(e,i,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),S.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const xn=null;function Oe(e){return a.isPlainObject(e)||a.isArray(e)}function Ze(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ye(e,t,n){return e?e.concat(t).map(function(s,o){return s=Ze(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Cn(e){return a.isArray(e)&&!e.some(Oe)}const Ln=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function pe(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,h){return!a.isUndefined(h[g])});const r=n.metaTokens,s=n.visitor||d,o=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(a.isDate(p))return p.toISOString();if(a.isBoolean(p))return p.toString();if(!c&&a.isBlob(p))throw new S("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(p)||a.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function d(p,g,h){let _=p;if(p&&!h&&typeof p=="object"){if(a.endsWith(g,"{}"))g=r?g:g.slice(0,-2),p=JSON.stringify(p);else if(a.isArray(p)&&Cn(p)||(a.isFileList(p)||a.endsWith(g,"[]"))&&(_=a.toArray(p)))return g=Ze(g),_.forEach(function(T,x){!(a.isUndefined(T)||T===null)&&t.append(i===!0?Ye([g],x,o):i===null?g:g+"[]",u(T))}),!1}return Oe(p)?!0:(t.append(Ye(h,g,o),u(p)),!1)}const f=[],E=Object.assign(Ln,{defaultVisitor:d,convertValue:u,isVisitable:Oe});function R(p,g){if(!a.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(p),a.forEach(p,function(_,A){(!(a.isUndefined(_)||_===null)&&s.call(t,_,a.isString(A)?A.trim():A,g,E))===!0&&R(_,g?g.concat(A):[A])}),f.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return R(e),t}function et(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function xe(e,t){this._pairs=[],e&&pe(e,this,t)}const tt=xe.prototype;tt.append=function(t,n){this._pairs.push([t,n])},tt.toString=function(t){const n=t?function(r){return t.call(this,r,et)}:et;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function vn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function nt(e,t,n){if(!t)return e;const r=n&&n.encode||vn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new xe(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class rt{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const st={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Bn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:xe,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ce=typeof window<"u"&&typeof document<"u",Le=typeof navigator=="object"&&navigator||void 0,kn=Ce&&(!Le||["ReactNative","NativeScript","NS"].indexOf(Le.product)<0),Nn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Pn=Ce&&window.location.href||"http://localhost",N={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ce,hasStandardBrowserEnv:kn,hasStandardBrowserWebWorkerEnv:Nn,navigator:Le,origin:Pn},Symbol.toStringTag,{value:"Module"})),...Bn};function Un(e,t){return pe(e,new N.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return N.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function In(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Fn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function ot(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),c=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,c?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!l):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Fn(s[i])),!l)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(In(r),s,n,0)}),n}return null}function Dn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const re={transitional:st,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(ot(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Un(t,this.formSerializer).toString();if((l=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return pe(l?{"files[]":t}:t,c&&new c,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Dn(t)):t}],transformResponse:[function(t){const n=this.transitional||re.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(l){if(i)throw l.name==="SyntaxError"?S.from(l,S.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:N.classes.FormData,Blob:N.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{re.headers[e]={}});const jn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Mn=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[it]=this[it]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=se(i);r[l]||(Hn(s,i),r[l]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};U.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(U.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(U);function Be(e,t){const n=this||re,r=t||n,s=U.from(r.headers);let o=r.data;return a.forEach(e,function(l){o=l.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function at(e){return!!(e&&e.__CANCEL__)}function X(e,t,n){S.call(this,e??"canceled",S.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(X,S,{__CANCEL__:!0});function ct(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new S("Request failed with status code "+n.status,[S.ERR_BAD_REQUEST,S.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Vn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Wn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[o];i||(i=u),n[s]=c,r[s]=u;let f=o,E=0;for(;f!==s;)E+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const R=d&&u-d;return R?Math.round(E*1e3/R):void 0}}function Gn(e,t){let n=0,r=1e3/t,s,o;const i=(u,d=Date.now())=>{n=d,s=null,o&&(clearTimeout(o),o=null),e.apply(null,u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const me=(e,t,n=3)=>{let r=0;const s=Wn(50,250);return Gn(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,c=i-r,u=s(c),d=i<=l;r=i;const f={loaded:i,total:l,progress:l?i/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l&&d?(l-i)/u:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(f)},n)},lt=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ut=e=>(...t)=>a.asap(()=>e(...t)),Jn=N.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,N.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0,Qn=N.hasStandardBrowserEnv?{write(e,t,n,r,s,o){const i=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Kn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Xn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function dt(e,t,n){let r=!Kn(t);return e&&(r||n==!1)?Xn(e,t):t}const ft=e=>e instanceof U?{...e}:e;function W(e,t){t=t||{};const n={};function r(u,d,f,E){return a.isPlainObject(u)&&a.isPlainObject(d)?a.merge.call({caseless:E},u,d):a.isPlainObject(d)?a.merge({},d):a.isArray(d)?d.slice():d}function s(u,d,f,E){if(a.isUndefined(d)){if(!a.isUndefined(u))return r(void 0,u,f,E)}else return r(u,d,f,E)}function o(u,d){if(!a.isUndefined(d))return r(void 0,d)}function i(u,d){if(a.isUndefined(d)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function l(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(u,d,f)=>s(ft(u),ft(d),f,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(d){const f=c[d]||s,E=f(e[d],t[d],d);a.isUndefined(E)&&f!==l||(n[d]=E)}),n}const pt=e=>{const t=W({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:l}=t;t.headers=i=U.from(i),t.url=nt(dt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(a.isFormData(n)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((c=i.getContentType())!==!1){const[u,...d]=c?c.split(";").map(f=>f.trim()).filter(Boolean):[];i.setContentType([u||"multipart/form-data",...d].join("; "))}}if(N.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&Jn(t.url))){const u=s&&o&&Qn.read(o);u&&i.set(s,u)}return t},Zn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=pt(e);let o=s.data;const i=U.from(s.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:u}=s,d,f,E,R,p;function g(){R&&R(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(d),s.signal&&s.signal.removeEventListener("abort",d)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function _(){if(!h)return;const T=U.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),v={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:T,config:e,request:h};ct(function(I){n(I),g()},function(I){r(I),g()},v),h=null}"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(_)},h.onabort=function(){h&&(r(new S("Request aborted",S.ECONNABORTED,e,h)),h=null)},h.onerror=function(){r(new S("Network Error",S.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let x=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const v=s.transitional||st;s.timeoutErrorMessage&&(x=s.timeoutErrorMessage),r(new S(x,v.clarifyTimeoutError?S.ETIMEDOUT:S.ECONNABORTED,e,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(x,v){h.setRequestHeader(v,x)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),l&&l!=="json"&&(h.responseType=s.responseType),u&&([E,p]=me(u,!0),h.addEventListener("progress",E)),c&&h.upload&&([f,R]=me(c),h.upload.addEventListener("progress",f),h.upload.addEventListener("loadend",R)),(s.cancelToken||s.signal)&&(d=T=>{h&&(r(!T||T.type?new X(null,e,h):T),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(d),s.signal&&(s.signal.aborted?d():s.signal.addEventListener("abort",d)));const A=Vn(s.url);if(A&&N.protocols.indexOf(A)===-1){r(new S("Unsupported protocol "+A+":",S.ERR_BAD_REQUEST,e));return}h.send(o||null)})},Yn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,l();const d=u instanceof Error?u:this.reason;r.abort(d instanceof S?d:new X(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,o(new S(`timeout ${t} of ms exceeded`,S.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:c}=r;return c.unsubscribe=()=>a.asap(l),c}},er=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},tr=async function*(e,t){for await(const n of nr(e))yield*er(n,t)},nr=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},ht=(e,t,n,r)=>{const s=tr(e,t);let o=0,i,l=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await s.next();if(u){l(),c.close();return}let f=d.byteLength;if(n){let E=o+=f;n(E)}c.enqueue(new Uint8Array(d))}catch(u){throw l(u),u}},cancel(c){return l(c),s.return()}},{highWaterMark:2})},we=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",mt=we&&typeof ReadableStream=="function",rr=we&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),wt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},sr=mt&&wt(()=>{let e=!1;const t=new Request(N.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),gt=64*1024,ke=mt&&wt(()=>a.isReadableStream(new Response("").body)),ge={stream:ke&&(e=>e.body)};we&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ge[t]&&(ge[t]=a.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new S(`Response type '${t}' is not supported`,S.ERR_NOT_SUPPORT,r)})})})(new Response);const or=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(N.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await rr(e)).byteLength},ir=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??or(t)},Ne={http:xn,xhr:Zn,fetch:we&&(async e=>{let{url:t,method:n,data:r,signal:s,cancelToken:o,timeout:i,onDownloadProgress:l,onUploadProgress:c,responseType:u,headers:d,withCredentials:f="same-origin",fetchOptions:E}=pt(e);u=u?(u+"").toLowerCase():"text";let R=Yn([s,o&&o.toAbortSignal()],i),p;const g=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let h;try{if(c&&sr&&n!=="get"&&n!=="head"&&(h=await ir(d,r))!==0){let v=new Request(t,{method:"POST",body:r,duplex:"half"}),L;if(a.isFormData(r)&&(L=v.headers.get("content-type"))&&d.setContentType(L),v.body){const[I,z]=lt(h,me(ut(c)));r=ht(v.body,gt,I,z)}}a.isString(f)||(f=f?"include":"omit");const _="credentials"in Request.prototype;p=new Request(t,{...E,signal:R,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:_?f:void 0});let A=await fetch(p,E);const T=ke&&(u==="stream"||u==="response");if(ke&&(l||T&&g)){const v={};["status","statusText","headers"].forEach(m=>{v[m]=A[m]});const L=a.toFiniteNumber(A.headers.get("content-length")),[I,z]=l&<(L,me(ut(l),!0))||[];A=new Response(ht(A.body,gt,I,()=>{z&&z(),g&&g()}),v)}u=u||"text";let x=await ge[a.findKey(ge,u)||"text"](A,e);return!T&&g&&g(),await new Promise((v,L)=>{ct(v,L,{data:x,headers:U.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:p})})}catch(_){throw g&&g(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new S("Network Error",S.ERR_NETWORK,e,p),{cause:_.cause||_}):S.from(_,_&&_.code,e,p)}})};a.forEach(Ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const yt=e=>`- ${e}`,ar=e=>a.isFunction(e)||e===null||e===!1,Et={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;const s={};for(let o=0;o<t;o++){n=e[o];let i;if(r=n,!ar(n)&&(r=Ne[(i=String(n)).toLowerCase()],r===void 0))throw new S(`Unknown adapter '${i}'`);if(r)break;s[i||"#"+o]=r}if(!r){const o=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since :
|
|
4
|
-
`+o.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=W(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ee.assertOptions(r,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:Ee.assertOptions(s,{encode:M.function,serialize:M.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ee.assertOptions(n,{baseUrl:M.spelling("baseURL"),withXsrfToken:M.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=U.concat(i,o);const l=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,l.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let d,f=0,E;if(!c){const p=[St.bind(this),void 0];for(p.unshift.apply(p,l),p.push.apply(p,u),E=p.length,d=Promise.resolve(n);f<E;)d=d.then(p[f++],p[f++]);return d}E=l.length;let R=n;for(f=0;f<E;){const p=l[f++],g=l[f++];try{R=p(R)}catch(h){g.call(this,h);break}}try{d=St.call(this,R)}catch(p){return Promise.reject(p)}for(f=0,E=u.length;f<E;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=W(this.defaults,t);const n=dt(t.baseURL,t.url,t.allowAbsoluteUrls);return nt(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){G.prototype[t]=function(n,r){return this.request(W(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,l){return this.request(W(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}G.prototype[t]=n(),G.prototype[t+"Form"]=n(!0)});let lr=class Ut{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,l){r.reason||(r.reason=new X(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Ut(function(s){t=s}),cancel:t}}};function ur(e){return function(n){return e.apply(null,n)}}function dr(e){return a.isObject(e)&&e.isAxiosError===!0}const Ue={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ue).forEach(([e,t])=>{Ue[t]=e});function _t(e){const t=new G(e),n=$e(G.prototype.request,t);return a.extend(n,G.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return _t(W(e,s))},n}const C=_t(re);C.Axios=G,C.CanceledError=X,C.CancelToken=lr,C.isCancel=at,C.VERSION=bt,C.toFormData=pe,C.AxiosError=S,C.Cancel=C.CanceledError,C.all=function(t){return Promise.all(t)},C.spread=ur,C.isAxiosError=dr,C.mergeConfig=W,C.AxiosHeaders=U,C.formToJSON=e=>ot(a.isHTMLForm(e)?new FormData(e):e),C.getAdapter=Et.getAdapter,C.HttpStatusCode=Ue,C.default=C;const{Axios:Dr,AxiosError:jr,CanceledError:Mr,isCancel:$r,CancelToken:qr,VERSION:zr,all:Hr,Cancel:Vr,isAxiosError:Wr,spread:Gr,toFormData:Jr,AxiosHeaders:Qr,HttpStatusCode:Kr,formToJSON:Xr,getAdapter:Zr,mergeConfig:Yr}=C;class fr{constructor(){De(this,"apiUrl");De(this,"timeout",3e4);this.apiUrl=ae.QWEN_TTS_API_URL}async synthesizeSpeech(t){var n,r,s,o,i,l,c,u,d;try{const{text:f,voice:E="Peter",languageType:R="English",emotion:p,speed:g,pitch:h,purpose:_,preset:A}=t;if(!f||f.trim().length===0)throw new Error("[Qwen TTS] Text cannot be empty");if(f.length>512)throw new Error("[Qwen TTS] Text must not exceed 512 characters (Qwen3-TTS limit)");console.log(`[Qwen TTS] Processing request: text="${f.substring(0,50)}..." voice=${E}`);const T={text:f,voice:E,languageType:R};A&&(T.preset=A,console.log(`[Qwen TTS] Preset: ${A}`)),p&&(T.emotion=p,console.log(`[Qwen TTS] Emotion: ${p}`)),g!==void 0&&(T.speed=g,console.log(`[Qwen TTS] Speed: ${g}`)),h!==void 0&&(T.pitch=h,console.log(`[Qwen TTS] Pitch: ${h}`)),_&&(T.purpose=_,console.log(`[Qwen TTS] Purpose: ${_}`));const x=T;console.log(`[Qwen TTS] Sending request to ${this.apiUrl}/api/v1/tts/audio`);const L=(await C.post(`${this.apiUrl}/api/v1/tts/audio`,x,{headers:{"Content-Type":"application/json"},responseType:"blob",timeout:this.timeout})).data;if(!L||L.size===0)throw new Error("[Qwen TTS] No audio content received from server");return console.log(`[Qwen TTS] Successfully received audio (${L.size} bytes)`),{audio:L,mimeType:"audio/wav"}}catch(f){const E=f instanceof Error?f.message:String(f);if(console.error(`[Qwen TTS] Error: ${E}`),f instanceof C.AxiosError){if(((n=f.response)==null?void 0:n.status)===401||((r=f.response)==null?void 0:r.status)===403)throw new Error("[Qwen TTS] Unauthorized: Invalid credentials or API key on server");if(f.code==="ECONNABORTED")throw new Error("[Qwen TTS] Request timeout: Qwen TTS service not responding");if(((s=f.response)==null?void 0:s.status)===400){const R=((i=(o=f.response)==null?void 0:o.data)==null?void 0:i.message)||"Bad request parameters";throw new Error(`[Qwen TTS] Bad Request: ${R}`)}throw((l=f.response)==null?void 0:l.status)===429?new Error("[Qwen TTS] Rate limit exceeded: Too many requests to Qwen API"):f.code==="ERR_NETWORK"?new Error(`[Qwen TTS] Network error: Cannot reach Qwen TTS service at ${this.apiUrl}`):new Error(`[Qwen TTS] API Error (${(c=f.response)==null?void 0:c.status}): ${((d=(u=f.response)==null?void 0:u.data)==null?void 0:d.message)||E}`)}throw f}}}const pr=new fr;function hr(e){const[t,n]=y.useState({isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0,avatars:e.avatars,error:null}),[r,s]=y.useState(e.autoAdvance||!1),[o,i]=y.useState(!1),[,l]=y.useState(0),c=y.useRef(null),u=y.useRef(null),d=y.useRef(r),f=y.useRef(!1),E=y.useRef(null);y.useEffect(()=>{d.current=r},[r]);const R=m=>{if(e.avatars.length<=1)return 0;const b=e.avatars.length,F=100/b;return Math.min(Math.floor(m/F),b-1)},p=()=>{u.current&&(clearInterval(u.current),u.current=null)},g=()=>{c.current&&(u.current=setInterval(()=>{if(c.current&&c.current.duration){const m=c.current.currentTime,b=c.current.duration,F=m/b*100;n($=>({...$,progress:Math.min(F,100),currentPNGTuber:R(F)}))}},100))},h=()=>{var m;c.current&&!t.isPaused&&(c.current.pause(),p(),n(b=>({...b,isPlaying:!1,isPaused:!0})),(m=e.onPause)==null||m.call(e))},_=async()=>{if(c.current&&t.isPaused)try{await c.current.play(),g(),n(m=>({...m,isPlaying:!0,isPaused:!1}))}catch(m){console.error("Error al reanudar audio:",m),n(b=>({...b,error:{type:"audio",message:"Error al reanudar la reproducción"}}))}},A=()=>x(!0),T=()=>s(m=>!m),x=(m=!1)=>{p(),c.current&&(E.current&&(c.current.removeEventListener("ended",E.current),E.current=null),c.current.removeEventListener("error",v),c.current.removeEventListener("pause",L),c.current.pause(),c.current.currentTime=0,c.current.src="",c.current.load(),c.current=null),n(b=>({...b,isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0})),d.current&&!f.current&&(f.current=!0,l(b=>b+1)),m||setTimeout(()=>{var b;return(b=e.onStop)==null?void 0:b.call(e)},50)},v=()=>{n(m=>({...m,error:{type:"audio",message:"Error al reproducir el audio"}})),x()},L=()=>{c.current&&c.current.currentTime<c.current.duration&&n(m=>({...m,isPlaying:!1,isPaused:!0}))},I=async()=>{if(!e.text.trim()){n(m=>({...m,error:{type:"synthesis",message:"No hay contenido para reproducir"}}));return}f.current=!1,x(!0);try{i(!0),n(Y=>({...Y,isPlaying:!1,progress:0,currentPNGTuber:0,error:null}));const m=e.voiceConfig,b=(m==null?void 0:m.voice)??e.voiceId,F=(m==null?void 0:m.languageType)??e.lang??"Spanish",$=`qwen-${b}-${F}-${(m==null?void 0:m.preset)??""}-${(m==null?void 0:m.emotion)??""}-${(m==null?void 0:m.speed)??""}-${(m==null?void 0:m.pitch)??""}-${e.text}`;let j=await Mt($);j?console.log("[TTS] Cache hit"):(j=(await pr.synthesizeSpeech({text:e.text,voice:b,languageType:F,preset:(m==null?void 0:m.preset)??void 0,emotion:(m==null?void 0:m.emotion)??void 0,speed:(m==null?void 0:m.speed)??void 0,pitch:(m==null?void 0:m.pitch)??void 0,purpose:(m==null?void 0:m.purpose)??void 0})).audio,await $t($,j)),z(j)}catch(m){console.error("Error al reproducir TTS:",m),n(b=>({...b,error:{type:"network",message:`Error en la síntesis: ${m.message}`},isPlaying:!1})),p(),i(!1)}},z=m=>{const b=URL.createObjectURL(m);c.current=new Audio(b);const F=()=>{x(!1),URL.revokeObjectURL(b)};E.current=F,c.current.addEventListener("ended",F),c.current.addEventListener("error",v),c.current.addEventListener("pause",L),c.current.addEventListener("canplaythrough",async()=>{var $;i(!1),n(j=>({...j,isPlaying:!0})),g();try{await(($=c.current)==null?void 0:$.play())}catch(j){console.error("Error al iniciar reproducción:",j),n(Y=>({...Y,error:{type:"audio",message:"Error al iniciar la reproducción"}})),x()}})};return y.useEffect(()=>()=>{p(),c.current&&(c.current.pause(),c.current.src="",c.current.load(),c.current=null)},[]),y.useEffect(()=>{e.voiceId&&(c.current&&(c.current.pause(),c.current.src="",c.current.load(),c.current=null),p(),n(m=>({...m,isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0})))},[e.voiceId]),{...t,play:I,pause:h,resume:_,stop:A,toggleAutoAdvance:T,isAutoAdvancing:r,isLoadingAudio:o,avatars:e.avatars}}const Z={selectorWrapper:"_selectorWrapper_1kmif_1",iconButton:"_iconButton_1kmif_6",dropdown:"_dropdown_1kmif_18",dropdownItem:"_dropdownItem_1kmif_31",active:"_active_1kmif_44"},At=({languages:e,current:t,onChange:n})=>{const[r,s]=y.useState(!1),[o,i]=y.useState(t||e[0].code),l=y.useRef(null);return y.useEffect(()=>{const c=u=>{l.current&&!l.current.contains(u.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),w.jsxs("div",{className:Z.selectorWrapper,ref:l,children:[w.jsx("button",{className:Z.iconButton,title:"Cambiar idioma",onClick:()=>s(!r),children:w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"white",width:"30px",height:"30px",viewBox:"0 0 24 24",children:w.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"})})}),r&&w.jsx("div",{className:Z.dropdown,children:e.map(c=>w.jsx("button",{className:`${Z.dropdownItem} ${c.code===o?Z.active:""}`,onClick:()=>{i(c.code),n==null||n(c.code),s(!1)},children:c.label},c.code))})]})},O={controlsRow:"_controlsRow_8wakc_1",select:"_select_8wakc_9",autoAdvanceButton:"_autoAdvanceButton_8wakc_15",section:"_section_8wakc_26",textarea:"_textarea_8wakc_36",input:"_input_8wakc_46",error:"_error_8wakc_54",buttonPrimary:"_buttonPrimary_8wakc_59",buttonSuccess:"_buttonSuccess_8wakc_69",infoBox:"_infoBox_8wakc_78",viewer:"_viewer_8wakc_86",viewerTopBar:"_viewerTopBar_8wakc_97",topRightControls:"_topRightControls_8wakc_110",itemCounter:"_itemCounter_8wakc_118",iconButton:"_iconButton_8wakc_126",navButton:"_navButton_8wakc_146",navButtonLeft:"_navButtonLeft_8wakc_163",navButtonRight:"_navButtonRight_8wakc_167",backgroundImage:"_backgroundImage_8wakc_171",avatar:"_avatar_8wakc_178",caption:"_caption_8wakc_188",captionTitle:"_captionTitle_8wakc_201",captionText:"_captionText_8wakc_211",loadingOverlay:"_loadingOverlay_8wakc_217",loadingSpinner:"_loadingSpinner_8wakc_232",spin:"_spin_8wakc_251",loadingButton:"_loadingButton_8wakc_242",spinner:"_spinner_8wakc_251",progressBar:"_progressBar_8wakc_264",progressFill:"_progressFill_8wakc_273",playbackControls:"_playbackControls_8wakc_279",playButton:"_playButton_8wakc_292",pauseButton:"_pauseButton_8wakc_293"},mr=[{id:"Ebona",name:"Voz Mujer"},{id:"Bodega",name:"Voz Hombre"},{id:"Peter",name:"Voz Narrador"}],Rt=ae.DEFAULT_IMAGE_URL,wr=({heritageItems:e=[],targetLanguage:t="es",descriptionLength:n="extended",autoAdvance:r=!1,voiceConfigs:s=[],voiceIds:o=[],avatars:i=[]})=>{const[l]=y.useState(e),[c,u]=y.useState(0),[d,f]=y.useState(n),[E,R]=y.useState(t),[p,g]=y.useState(""),[h,_]=y.useState([]),[A,T]=y.useState(0),[x,v]=y.useState(r),[L,I]=y.useState(!1),[z,m]=y.useState(o.length>0?o[0]:""),b=s.length>0?s.map(k=>k.voice):o,F=z||(b.length>0?b[c%b.length]:""),$=s.length>0?s[c%s.length]:void 0,j=i[c%i.length],[Y,Ot]=y.useState(!1),[gr,xt]=y.useState(!1),[yr,Se]=y.useState(!0),J=y.useRef(null),Ct=y.useRef(x),Lt=y.useRef(c),Ie=y.useRef(l),Q=y.useRef(null),be=y.useRef(!1);y.useEffect(()=>{Ct.current=x,Lt.current=c,Ie.current=l},[x,c,l]);const ee=l[c]||{id:"default",name:"Patrimonio Cultural",description:{local:{short:"Ingrese un JSON válido para comenzar",extended:"Ingrese un JSON válido para comenzar"}},imageUrl:""},{isPlaying:H,isPaused:vt,isLoadingAudio:Er,progress:Bt,play:Sr,pause:br,resume:Tr,stop:_r}=hr({text:p,lang:E,voiceConfig:$,onStop:()=>{Se(!0),Ct.current&&Ie.current.length>1&&!be.current&&setTimeout(()=>{I(!0);const k=(Lt.current+1)%Ie.current.length;u(k)},100),be.current=!1},voiceId:F,avatars:[j]});y.useEffect(()=>{if(L&&p&&!p.includes("JSON válido")){const k=setTimeout(()=>{H||kt(),I(!1)},500);return()=>clearTimeout(k)}},[L,p,H]),y.useEffect(()=>{(async()=>{const q=ee.description.local[d];if(q)try{const oe=await je(ee.name,E),Cr=await je(q,E);g(`${oe}. ${Cr}`)}catch(oe){console.error("Error en traducción:",oe),g(`${ee.name}. ${q}`)}})()},[ee,d,E]);const Fe=()=>{Se(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{Se(!1)},4e3)},kt=()=>{if(!p.trim()||p.includes("JSON válido")){alert("No hay contenido para reproducir");return}Sr(),Fe()},Ar=()=>{br()},Rr=()=>{Tr(),Fe()},Nt=()=>{_r(),I(!1),J.current&&clearTimeout(J.current),Q.current&&clearTimeout(Q.current),Se(!0)},Or=()=>{be.current=!0,Nt(),c>0&&u(k=>k-1)},xr=()=>{be.current=!0,Nt(),c<l.length-1&&u(k=>k+1)};y.useEffect(()=>()=>{J.current&&clearTimeout(J.current),Q.current&&clearTimeout(Q.current)},[]),y.useEffect(()=>{if(p){const k=p.split(new RegExp("(?<=[.!?])\\s+","g")).map(q=>q.trim()).filter(q=>q.length>0);_(k),T(0)}},[p]),y.useEffect(()=>{if(!H||h.length===0)return;J.current&&clearTimeout(J.current);const q=1500+h[A].length*50;J.current=setTimeout(()=>{T(oe=>(oe+1)%h.length)},q)},[H,h,A]);const[Pt,Ds]=y.useState(!1);return y.useEffect(()=>{!Pt&&b.length>0&&m(b[c%b.length])},[c,b,Pt]),w.jsxs("div",{children:[ae.DEBUG_MODE,w.jsxs("div",{className:O.viewer,onClick:Fe,children:[w.jsxs("div",{className:O.viewerTopBar,children:[w.jsx("div",{className:O.itemCounter,children:l.length>0?`${c+1}/${l.length}`:"0/0"}),w.jsxs("div",{className:O.topRightControls,children:[w.jsx("button",{onClick:()=>v(!x),className:O.iconButton,title:"Autoplay",style:{backgroundColor:x?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)"},children:w.jsx("svg",{width:"20px",height:"20px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",children:w.jsx("path",{style:{fill:x?"black":"white"},d:"M5.23331,0.493645 C6.8801,-0.113331 8.6808,-0.161915 10.3579,0.355379 C11.4019,0.6773972 12.361984,1.20757325 13.1838415,1.90671757 L13.4526,2.14597 L14.2929,1.30564 C14.8955087,0.703065739 15.9071843,1.0850774 15.994017,1.89911843 L16,2.01275 L16,6.00002 L12.0127,6.00002 C11.1605348,6.00002 10.7153321,5.01450817 11.2294893,4.37749065 L11.3056,4.29291 L12.0372,3.56137 C11.389,2.97184 10.6156,2.52782 9.76845,2.26653 C8.5106,1.87856 7.16008,1.915 5.92498,2.37023 C4.68989,2.82547 3.63877,3.67423 2.93361,4.78573 C2.22844,5.89723 1.90836,7.20978 2.02268,8.52112 C2.13701,9.83246 2.6794,11.0698 3.56627,12.0425 C4.45315,13.0152 5.63528,13.6693 6.93052,13.9039 C8.22576,14.1385 9.56221,13.9407 10.7339,13.3409 C11.9057,12.7412 12.8476,11.7727 13.4147,10.5848 C13.6526,10.0864 14.2495,9.8752 14.748,10.1131 C15.2464,10.351 15.4575,10.948 15.2196,11.4464 C14.4635,13.0302 13.2076,14.3215 11.6453,15.1213 C10.0829,15.921 8.30101,16.1847 6.57402,15.8719 C4.84704,15.559 3.27086,14.687 2.08836,13.39 C0.905861,12.0931 0.182675,10.4433 0.0302394,8.69483 C-0.122195,6.94637 0.304581,5.1963 1.2448,3.7143 C2.18503,2.2323 3.58652,1.10062 5.23331,0.493645 Z M6,5.46077 C6,5.09472714 6.37499031,4.86235811 6.69509872,5.0000726 L6.7678,5.03853 L10.7714,7.57776 C11.0528545,7.75626909 11.0784413,8.14585256 10.8481603,8.36273881 L10.7714,8.42224 L6.7678,10.9615 C6.45867857,11.1575214 6.06160816,10.965274 6.00646097,10.6211914 L6,10.5392 L6,5.46077 Z"})})}),w.jsx(At,{languages:[{code:"es",label:"Español"},{code:"en",label:"English"},{code:"fr",label:"Français"}],current:"es",onChange:k=>R(k)})]})]}),w.jsx("button",{onClick:Or,disabled:l.length===0,className:`${O.navButton} ${O.navButtonLeft}`,title:"Anterior",onMouseOver:()=>Ot(!0),onMouseOut:()=>Ot(!1),children:w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{width:"24px",height:"24px",transition:"transform 0.2s ease-in-out",transform:Y?"scale(1.5)":"scale(1)"},children:w.jsx("path",{d:"M15 18l-6-6 6-6"})})}),w.jsx("button",{onClick:xr,disabled:l.length===0,className:`${O.navButton} ${O.navButtonRight}`,title:"Siguiente",onMouseOver:()=>xt(!0),onMouseOut:()=>xt(!1),children:w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{width:"24px",height:"24px",transition:"transform 0.2s ease-in-out",transform:gr?"scale(1.5)":"scale(1)"},children:w.jsx("path",{d:"M9 6l6 6-6 6"})})}),w.jsx("img",{src:ee.imageUrl||Rt,alt:"Background",className:O.backgroundImage,style:{opacity:H?1:.7},onError:k=>k.currentTarget.src=Rt}),H&&w.jsx(w.Fragment,{children:w.jsx("img",{src:j,alt:"Avatar",className:O.avatar,style:{transform:`scale(${Bt%10<5?4:4.05})`}})}),w.jsxs("div",{className:O.caption,children:[w.jsx("h4",{className:O.captionTitle,children:ee.name}),H&&w.jsx(w.Fragment,{children:w.jsx("p",{className:O.captionText,children:h.length>0&&h[A]})})]}),L&&w.jsxs("div",{className:O.loadingOverlay,children:[w.jsx("div",{className:O.loadingSpinner}),w.jsx("p",{children:"Cargando siguiente patrimonio..."})]}),yr&&w.jsx("div",{className:O.playbackControls,children:Er?w.jsx("button",{disabled:!0,className:O.loadingButton,children:w.jsxs("svg",{className:O.spinner,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[w.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),w.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}):!H&&!vt?w.jsx("button",{onClick:kt,disabled:l.length===0||L,className:O.playButton,children:w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"white",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M9 8.5 L9 15.5 L16 12 Z"})})}):vt?w.jsx("button",{onClick:Rr,className:O.playButton,children:w.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"white",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M9 8.5 L9 15.5 L16 12 Z"})})}):w.jsx("button",{onClick:Ar,className:O.pauseButton,children:w.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"16"}),w.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"16"})]})})}),w.jsx("div",{className:O.progressBar,children:w.jsx("div",{className:O.progressFill,style:{width:`${Bt}%`}})})]})]})};B.LanguageSelector=At,B.LanguageSelectorStyles=Z,B.StoryVisualizer=wr,B.StoryVisualizerStyles=O,B.voices=mr,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(N,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],h):(N=typeof globalThis<"u"?globalThis:N||self,h(N.OCityHeritageVisualizer={},N["react/jsx-runtime"],N.React))})(this,function(N,h,g){"use strict";var Fr=Object.defineProperty;var Dr=(N,h,g)=>h in N?Fr(N,h,{enumerable:!0,configurable:!0,writable:!0,value:g}):N[h]=g;var He=(N,h,g)=>Dr(N,typeof h!="symbol"?h+"":h,g);const qt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_DEBUG_MODE:"false",VITE_DEFAULT_IMAGE_URL:"https://o-city.org/assets/NO_AVAILABLE_IMG-4d02b370.png",VITE_GOOGLE_TRANSLATE_BASE:"https://translate.googleapis.com/translate_a/single",VITE_IMAGE_BASE_URL:"https://eu2.contabostorage.com/7fb97413b6c243adb4347dafa02551a9:ocity/heritage/images/",VITE_QWEN_TTS_API_URL:"http://localhost:3010"};function le(e,t=!0){const n=qt[e];if(!n&&t)throw new Error(`❌ Missing required env variable: ${e}`);return n??""}const ue={NODE_ENV:"production",QWEN_TTS_API_URL:le("VITE_QWEN_TTS_API_URL"),DEBUG_MODE:!1,GOOGLE_TRANSLATE_BASE:le("VITE_GOOGLE_TRANSLATE_BASE"),IMAGE_BASE_URL:le("VITE_IMAGE_BASE_URL"),DEFAULT_IMAGE_URL:le("VITE_DEFAULT_IMAGE_URL")};async function Ve(e,t){if(!e.trim())return e;try{const n=`${ue.GOOGLE_TRANSLATE_BASE}?client=gtx&sl=auto&tl=${t}&dt=t&q=${encodeURIComponent(e)}`,r=await fetch(n);if(!r.ok)throw new Error(`Error en la traducción: ${r.status}`);const s=await r.json();return s&&Array.isArray(s[0])?s[0].map(o=>o[0]).join(""):e}catch(n){return console.error("Error al traducir:",n),e}}function xe(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Ht(e,t){let n;const r=()=>{if(n)return n;const s=indexedDB.open(e);return s.onupgradeneeded=()=>s.result.createObjectStore(t),n=xe(s),n.then(o=>{o.onclose=()=>n=void 0},()=>{}),n};return(s,o)=>r().then(i=>o(i.transaction(t,s).objectStore(t)))}let Oe;function We(){return Oe||(Oe=Ht("keyval-store","keyval")),Oe}function Vt(e,t=We()){return t("readonly",n=>xe(n.get(e)))}function Wt(e,t,n=We()){return n("readwrite",r=>(r.put(t,e),xe(r.transaction)))}async function Gt(e){return await Vt(e)??null}async function Jt(e,t){await Wt(e,t)}function Ge(e,t){return function(){return e.apply(t,arguments)}}const{toString:Qt}=Object.prototype,{getPrototypeOf:Ce}=Object,{iterator:de,toStringTag:Je}=Symbol,fe=(e=>t=>{const n=Qt.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),M=e=>(e=e.toLowerCase(),t=>fe(t)===e),pe=e=>t=>typeof t===e,{isArray:Y}=Array,re=pe("undefined");function Kt(e){return e!==null&&!re(e)&&e.constructor!==null&&!re(e.constructor)&&U(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Qe=M("ArrayBuffer");function Xt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Qe(e.buffer),t}const Zt=pe("string"),U=pe("function"),Ke=pe("number"),he=e=>e!==null&&typeof e=="object",Yt=e=>e===!0||e===!1,me=e=>{if(fe(e)!=="object")return!1;const t=Ce(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Je in e)&&!(de in e)},en=M("Date"),tn=M("File"),nn=M("Blob"),rn=M("FileList"),sn=e=>he(e)&&U(e.pipe),on=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||U(e.append)&&((t=fe(e))==="formdata"||t==="object"&&U(e.toString)&&e.toString()==="[object FormData]"))},an=M("URLSearchParams"),[cn,ln,un,dn]=["ReadableStream","Request","Response","Headers"].map(M),fn=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function se(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Y(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let l;for(r=0;r<i;r++)l=o[r],t.call(null,e[l],l,e)}}function Xe(e,t){t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ze=e=>!re(e)&&e!==G;function ve(){const{caseless:e}=Ze(this)&&this||{},t={},n=(r,s)=>{const o=e&&Xe(t,s)||s;me(t[o])&&me(r)?t[o]=ve(t[o],r):me(r)?t[o]=ve({},r):Y(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&se(arguments[r],n);return t}const pn=(e,t,n,{allOwnKeys:r}={})=>(se(t,(s,o)=>{n&&U(s)?e[o]=Ge(s,n):e[o]=s},{allOwnKeys:r}),e),hn=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),mn=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},wn=(e,t,n,r)=>{let s,o,i;const l={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!l[i]&&(t[i]=e[i],l[i]=!0);e=n!==!1&&Ce(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},gn=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},yn=e=>{if(!e)return null;if(Y(e))return e;let t=e.length;if(!Ke(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},En=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ce(Uint8Array)),Sn=(e,t)=>{const r=(e&&e[de]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},bn=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Tn=M("HTMLFormElement"),_n=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ye=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),An=M("RegExp"),et=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};se(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},Rn=e=>{et(e,(t,n)=>{if(U(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(U(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},xn=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return Y(e)?r(e):r(String(e).split(t)),n},On=()=>{},Cn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function vn(e){return!!(e&&U(e.append)&&e[Je]==="FormData"&&e[de])}const Bn=e=>{const t=new Array(10),n=(r,s)=>{if(he(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=Y(r)?[]:{};return se(r,(i,l)=>{const c=n(i,s+1);!re(c)&&(o[l]=c)}),t[s]=void 0,o}}return r};return n(e,0)},Ln=M("AsyncFunction"),Nn=e=>e&&(he(e)||U(e))&&U(e.then)&&U(e.catch),tt=((e,t)=>e?setImmediate:t?((n,r)=>(G.addEventListener("message",({source:s,data:o})=>{s===G&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),G.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",U(G.postMessage)),Pn=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||tt,a={isArray:Y,isArrayBuffer:Qe,isBuffer:Kt,isFormData:on,isArrayBufferView:Xt,isString:Zt,isNumber:Ke,isBoolean:Yt,isObject:he,isPlainObject:me,isReadableStream:cn,isRequest:ln,isResponse:un,isHeaders:dn,isUndefined:re,isDate:en,isFile:tn,isBlob:nn,isRegExp:An,isFunction:U,isStream:sn,isURLSearchParams:an,isTypedArray:En,isFileList:rn,forEach:se,merge:ve,extend:pn,trim:fn,stripBOM:hn,inherits:mn,toFlatObject:wn,kindOf:fe,kindOfTest:M,endsWith:gn,toArray:yn,forEachEntry:Sn,matchAll:bn,isHTMLForm:Tn,hasOwnProperty:Ye,hasOwnProp:Ye,reduceDescriptors:et,freezeMethods:Rn,toObjectSet:xn,toCamelCase:_n,noop:On,toFiniteNumber:Cn,findKey:Xe,global:G,isContextDefined:Ze,isSpecCompliantForm:vn,toJSONObject:Bn,isAsyncFn:Ln,isThenable:Nn,setImmediate:tt,asap:Pn,isIterable:e=>e!=null&&U(e[de])};function S(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(S,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const nt=S.prototype,rt={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{rt[e]={value:e}}),Object.defineProperties(S,rt),Object.defineProperty(nt,"isAxiosError",{value:!0}),S.from=(e,t,n,r,s,o)=>{const i=Object.create(nt);return a.toFlatObject(e,i,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),S.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const kn=null;function Be(e){return a.isPlainObject(e)||a.isArray(e)}function st(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function ot(e,t,n){return e?e.concat(t).map(function(s,o){return s=st(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Un(e){return a.isArray(e)&&!e.some(Be)}const In=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function we(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,m){return!a.isUndefined(m[y])});const r=n.metaTokens,s=n.visitor||d,o=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(p){if(p===null)return"";if(a.isDate(p))return p.toISOString();if(a.isBoolean(p))return p.toString();if(!c&&a.isBlob(p))throw new S("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(p)||a.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function d(p,y,m){let _=p;if(p&&!m&&typeof p=="object"){if(a.endsWith(y,"{}"))y=r?y:y.slice(0,-2),p=JSON.stringify(p);else if(a.isArray(p)&&Un(p)||(a.isFileList(p)||a.endsWith(y,"[]"))&&(_=a.toArray(p)))return y=st(y),_.forEach(function(T,O){!(a.isUndefined(T)||T===null)&&t.append(i===!0?ot([y],O,o):i===null?y:y+"[]",u(T))}),!1}return Be(p)?!0:(t.append(ot(m,y,o),u(p)),!1)}const f=[],E=Object.assign(In,{defaultVisitor:d,convertValue:u,isVisitable:Be});function x(p,y){if(!a.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+y.join("."));f.push(p),a.forEach(p,function(_,A){(!(a.isUndefined(_)||_===null)&&s.call(t,_,a.isString(A)?A.trim():A,y,E))===!0&&x(_,y?y.concat(A):[A])}),f.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return x(e),t}function it(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Le(e,t){this._pairs=[],e&&we(e,this,t)}const at=Le.prototype;at.append=function(t,n){this._pairs.push([t,n])},at.toString=function(t){const n=t?function(r){return t.call(this,r,it)}:it;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Fn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ct(e,t,n){if(!t)return e;const r=n&&n.encode||Fn;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new Le(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class lt{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Le,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ne=typeof window<"u"&&typeof document<"u",Pe=typeof navigator=="object"&&navigator||void 0,zn=Ne&&(!Pe||["ReactNative","NativeScript","NS"].indexOf(Pe.product)<0),Mn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",$n=Ne&&window.location.href||"http://localhost",P={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ne,hasStandardBrowserEnv:zn,hasStandardBrowserWebWorkerEnv:Mn,navigator:Pe,origin:$n},Symbol.toStringTag,{value:"Module"})),...Dn};function jn(e,t){return we(e,new P.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return P.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function qn(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Hn(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function dt(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),c=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,c?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!l):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Hn(s[i])),!l)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(qn(r),s,n,0)}),n}return null}function Vn(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const oe={transitional:ut,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(dt(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return jn(t,this.formSerializer).toString();if((l=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return we(l?{"files[]":t}:t,c&&new c,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Vn(t)):t}],transformResponse:[function(t){const n=this.transitional||oe.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(l){if(i)throw l.name==="SyntaxError"?S.from(l,S.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{oe.headers[e]={}});const Wn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Gn=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Wn[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ft=Symbol("internals");function ie(e){return e&&String(e).trim().toLowerCase()}function ge(e){return e===!1||e==null?e:a.isArray(e)?e.map(ge):String(e)}function Jn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Qn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ke(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function Kn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Xn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let I=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(l,c,u){const d=ie(c);if(!d)throw new Error("header name must be a non-empty string");const f=a.findKey(s,d);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||c]=ge(l))}const i=(l,c)=>a.forEach(l,(u,d)=>o(u,d,c));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!Qn(t))i(Gn(t),n);else if(a.isObject(t)&&a.isIterable(t)){let l={},c,u;for(const d of t){if(!a.isArray(d))throw TypeError("Object iterator must return a key-value pair");l[u=d[0]]=(c=l[u])?a.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(l,n)}else t!=null&&o(n,t,r);return this}get(t,n){if(t=ie(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Jn(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=ie(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ke(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=ie(i),i){const l=a.findKey(r,i);l&&(!n||ke(r,r[l],l,n))&&(delete r[l],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||ke(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=ge(s),delete n[o];return}const l=t?Kn(o):String(o).trim();l!==o&&delete n[o],n[l]=ge(s),r[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[ft]=this[ft]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=ie(i);r[l]||(Xn(s,i),r[l]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};I.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(I.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(I);function Ue(e,t){const n=this||oe,r=t||n,s=I.from(r.headers);let o=r.data;return a.forEach(e,function(l){o=l.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function pt(e){return!!(e&&e.__CANCEL__)}function ee(e,t,n){S.call(this,e??"canceled",S.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(ee,S,{__CANCEL__:!0});function ht(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new S("Request failed with status code "+n.status,[S.ERR_BAD_REQUEST,S.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Zn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Yn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[o];i||(i=u),n[s]=c,r[s]=u;let f=o,E=0;for(;f!==s;)E+=n[f++],f=f%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const x=d&&u-d;return x?Math.round(E*1e3/x):void 0}}function er(e,t){let n=0,r=1e3/t,s,o;const i=(u,d=Date.now())=>{n=d,s=null,o&&(clearTimeout(o),o=null),e.apply(null,u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const ye=(e,t,n=3)=>{let r=0;const s=Yn(50,250);return er(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,c=i-r,u=s(c),d=i<=l;r=i;const f={loaded:i,total:l,progress:l?i/l:void 0,bytes:c,rate:u||void 0,estimated:u&&l&&d?(l-i)/u:void 0,event:o,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(f)},n)},mt=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},wt=e=>(...t)=>a.asap(()=>e(...t)),tr=P.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,P.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(P.origin),P.navigator&&/(msie|trident)/i.test(P.navigator.userAgent)):()=>!0,nr=P.hasStandardBrowserEnv?{write(e,t,n,r,s,o){const i=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function rr(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sr(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function gt(e,t,n){let r=!rr(t);return e&&(r||n==!1)?sr(e,t):t}const yt=e=>e instanceof I?{...e}:e;function J(e,t){t=t||{};const n={};function r(u,d,f,E){return a.isPlainObject(u)&&a.isPlainObject(d)?a.merge.call({caseless:E},u,d):a.isPlainObject(d)?a.merge({},d):a.isArray(d)?d.slice():d}function s(u,d,f,E){if(a.isUndefined(d)){if(!a.isUndefined(u))return r(void 0,u,f,E)}else return r(u,d,f,E)}function o(u,d){if(!a.isUndefined(d))return r(void 0,d)}function i(u,d){if(a.isUndefined(d)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function l(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(u,d,f)=>s(yt(u),yt(d),f,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(d){const f=c[d]||s,E=f(e[d],t[d],d);a.isUndefined(E)&&f!==l||(n[d]=E)}),n}const Et=e=>{const t=J({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:l}=t;t.headers=i=I.from(i),t.url=ct(gt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(a.isFormData(n)){if(P.hasStandardBrowserEnv||P.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((c=i.getContentType())!==!1){const[u,...d]=c?c.split(";").map(f=>f.trim()).filter(Boolean):[];i.setContentType([u||"multipart/form-data",...d].join("; "))}}if(P.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&tr(t.url))){const u=s&&o&&nr.read(o);u&&i.set(s,u)}return t},or=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=Et(e);let o=s.data;const i=I.from(s.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:u}=s,d,f,E,x,p;function y(){x&&x(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(d),s.signal&&s.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(s.method.toUpperCase(),s.url,!0),m.timeout=s.timeout;function _(){if(!m)return;const T=I.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),L={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:T,config:e,request:m};ht(function(D){n(D),y()},function(D){r(D),y()},L),m=null}"onloadend"in m?m.onloadend=_:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(_)},m.onabort=function(){m&&(r(new S("Request aborted",S.ECONNABORTED,e,m)),m=null)},m.onerror=function(){r(new S("Network Error",S.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let O=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const L=s.transitional||ut;s.timeoutErrorMessage&&(O=s.timeoutErrorMessage),r(new S(O,L.clarifyTimeoutError?S.ETIMEDOUT:S.ECONNABORTED,e,m)),m=null},o===void 0&&i.setContentType(null),"setRequestHeader"in m&&a.forEach(i.toJSON(),function(O,L){m.setRequestHeader(L,O)}),a.isUndefined(s.withCredentials)||(m.withCredentials=!!s.withCredentials),l&&l!=="json"&&(m.responseType=s.responseType),u&&([E,p]=ye(u,!0),m.addEventListener("progress",E)),c&&m.upload&&([f,x]=ye(c),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",x)),(s.cancelToken||s.signal)&&(d=T=>{m&&(r(!T||T.type?new ee(null,e,m):T),m.abort(),m=null)},s.cancelToken&&s.cancelToken.subscribe(d),s.signal&&(s.signal.aborted?d():s.signal.addEventListener("abort",d)));const A=Zn(s.url);if(A&&P.protocols.indexOf(A)===-1){r(new S("Unsupported protocol "+A+":",S.ERR_BAD_REQUEST,e));return}m.send(o||null)})},ir=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,l();const d=u instanceof Error?u:this.reason;r.abort(d instanceof S?d:new ee(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,o(new S(`timeout ${t} of ms exceeded`,S.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),e=null)};e.forEach(u=>u.addEventListener("abort",o));const{signal:c}=r;return c.unsubscribe=()=>a.asap(l),c}},ar=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},cr=async function*(e,t){for await(const n of lr(e))yield*ar(n,t)},lr=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},St=(e,t,n,r)=>{const s=cr(e,t);let o=0,i,l=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await s.next();if(u){l(),c.close();return}let f=d.byteLength;if(n){let E=o+=f;n(E)}c.enqueue(new Uint8Array(d))}catch(u){throw l(u),u}},cancel(c){return l(c),s.return()}},{highWaterMark:2})},Ee=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",bt=Ee&&typeof ReadableStream=="function",ur=Ee&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Tt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},dr=bt&&Tt(()=>{let e=!1;const t=new Request(P.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),_t=64*1024,Ie=bt&&Tt(()=>a.isReadableStream(new Response("").body)),Se={stream:Ie&&(e=>e.body)};Ee&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Se[t]&&(Se[t]=a.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new S(`Response type '${t}' is not supported`,S.ERR_NOT_SUPPORT,r)})})})(new Response);const fr=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(P.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await ur(e)).byteLength},pr=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??fr(t)},Fe={http:kn,xhr:or,fetch:Ee&&(async e=>{let{url:t,method:n,data:r,signal:s,cancelToken:o,timeout:i,onDownloadProgress:l,onUploadProgress:c,responseType:u,headers:d,withCredentials:f="same-origin",fetchOptions:E}=Et(e);u=u?(u+"").toLowerCase():"text";let x=ir([s,o&&o.toAbortSignal()],i),p;const y=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let m;try{if(c&&dr&&n!=="get"&&n!=="head"&&(m=await pr(d,r))!==0){let L=new Request(t,{method:"POST",body:r,duplex:"half"}),B;if(a.isFormData(r)&&(B=L.headers.get("content-type"))&&d.setContentType(B),L.body){const[D,H]=mt(m,ye(wt(c)));r=St(L.body,_t,D,H)}}a.isString(f)||(f=f?"include":"omit");const _="credentials"in Request.prototype;p=new Request(t,{...E,signal:x,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:r,duplex:"half",credentials:_?f:void 0});let A=await fetch(p,E);const T=Ie&&(u==="stream"||u==="response");if(Ie&&(l||T&&y)){const L={};["status","statusText","headers"].forEach(w=>{L[w]=A[w]});const B=a.toFiniteNumber(A.headers.get("content-length")),[D,H]=l&&mt(B,ye(wt(l),!0))||[];A=new Response(St(A.body,_t,D,()=>{H&&H(),y&&y()}),L)}u=u||"text";let O=await Se[a.findKey(Se,u)||"text"](A,e);return!T&&y&&y(),await new Promise((L,B)=>{ht(L,B,{data:O,headers:I.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:p})})}catch(_){throw y&&y(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new S("Network Error",S.ERR_NETWORK,e,p),{cause:_.cause||_}):S.from(_,_&&_.code,e,p)}})};a.forEach(Fe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const At=e=>`- ${e}`,hr=e=>a.isFunction(e)||e===null||e===!1,Rt={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;const s={};for(let o=0;o<t;o++){n=e[o];let i;if(r=n,!hr(n)&&(r=Fe[(i=String(n)).toLowerCase()],r===void 0))throw new S(`Unknown adapter '${i}'`);if(r)break;s[i||"#"+o]=r}if(!r){const o=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since :
|
|
4
|
+
`+o.map(At).join(`
|
|
5
|
+
`):" "+At(o[0]):"as no adapter specified";throw new S("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:Fe};function De(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ee(null,e)}function xt(e){return De(e),e.headers=I.from(e.headers),e.data=Ue.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Rt.getAdapter(e.adapter||oe.adapter)(e).then(function(r){return De(e),r.data=Ue.call(e,e.transformResponse,r),r.headers=I.from(r.headers),r},function(r){return pt(r)||(De(e),r&&r.response&&(r.response.data=Ue.call(e,e.transformResponse,r.response),r.response.headers=I.from(r.response.headers))),Promise.reject(r)})}const Ot="1.10.0",be={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{be[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ct={};be.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ot+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,l)=>{if(t===!1)throw new S(s(i," has been removed"+(n?" in "+n:"")),S.ERR_DEPRECATED);return n&&!Ct[i]&&(Ct[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}},be.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function mr(e,t,n){if(typeof e!="object")throw new S("options must be an object",S.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const l=e[o],c=l===void 0||i(l,o,e);if(c!==!0)throw new S("option "+o+" must be "+c,S.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new S("Unknown option "+o,S.ERR_BAD_OPTION)}}const Te={assertOptions:mr,validators:be},j=Te.validators;let Q=class{constructor(t){this.defaults=t||{},this.interceptors={request:new lt,response:new lt}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
6
|
+
`+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=J(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Te.assertOptions(r,{silentJSONParsing:j.transitional(j.boolean),forcedJSONParsing:j.transitional(j.boolean),clarifyTimeoutError:j.transitional(j.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:Te.assertOptions(s,{encode:j.function,serialize:j.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Te.assertOptions(n,{baseUrl:j.spelling("baseURL"),withXsrfToken:j.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=I.concat(i,o);const l=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(c=c&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let d,f=0,E;if(!c){const p=[xt.bind(this),void 0];for(p.unshift.apply(p,l),p.push.apply(p,u),E=p.length,d=Promise.resolve(n);f<E;)d=d.then(p[f++],p[f++]);return d}E=l.length;let x=n;for(f=0;f<E;){const p=l[f++],y=l[f++];try{x=p(x)}catch(m){y.call(this,m);break}}try{d=xt.call(this,x)}catch(p){return Promise.reject(p)}for(f=0,E=u.length;f<E;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=J(this.defaults,t);const n=gt(t.baseURL,t.url,t.allowAbsoluteUrls);return ct(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){Q.prototype[t]=function(n,r){return this.request(J(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,l){return this.request(J(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Q.prototype[t]=n(),Q.prototype[t+"Form"]=n(!0)});let wr=class jt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,l){r.reason||(r.reason=new ee(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new jt(function(s){t=s}),cancel:t}}};function gr(e){return function(n){return e.apply(null,n)}}function yr(e){return a.isObject(e)&&e.isAxiosError===!0}const ze={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ze).forEach(([e,t])=>{ze[t]=e});function vt(e){const t=new Q(e),n=Ge(Q.prototype.request,t);return a.extend(n,Q.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return vt(J(e,s))},n}const v=vt(oe);v.Axios=Q,v.CanceledError=ee,v.CancelToken=wr,v.isCancel=pt,v.VERSION=Ot,v.toFormData=we,v.AxiosError=S,v.Cancel=v.CanceledError,v.all=function(t){return Promise.all(t)},v.spread=gr,v.isAxiosError=yr,v.mergeConfig=J,v.AxiosHeaders=I,v.formToJSON=e=>dt(a.isHTMLForm(e)?new FormData(e):e),v.getAdapter=Rt.getAdapter,v.HttpStatusCode=ze,v.default=v;const{Axios:Wr,AxiosError:Gr,CanceledError:Jr,isCancel:Qr,CancelToken:Kr,VERSION:Xr,all:Zr,Cancel:Yr,isAxiosError:es,spread:ts,toFormData:ns,AxiosHeaders:rs,HttpStatusCode:ss,formToJSON:os,getAdapter:is,mergeConfig:as}=v;class Er{constructor(){He(this,"apiUrl");He(this,"timeout",3e4);this.apiUrl=ue.QWEN_TTS_API_URL}async synthesizeSpeech(t){var n,r,s,o,i,l,c,u,d;try{const{text:f,voice:E="Peter",languageType:x="English",emotion:p,speed:y,pitch:m,purpose:_,preset:A}=t;if(!f||f.trim().length===0)throw new Error("[Qwen TTS] Text cannot be empty");if(f.length>512)throw new Error("[Qwen TTS] Text must not exceed 512 characters (Qwen3-TTS limit)");console.log(`[Qwen TTS] Processing request: text="${f.substring(0,50)}..." voice=${E}`);const T={text:f,voice:E,languageType:x};A&&(T.preset=A,console.log(`[Qwen TTS] Preset: ${A}`)),p&&(T.emotion=p,console.log(`[Qwen TTS] Emotion: ${p}`)),y!==void 0&&(T.speed=y,console.log(`[Qwen TTS] Speed: ${y}`)),m!==void 0&&(T.pitch=m,console.log(`[Qwen TTS] Pitch: ${m}`)),_&&(T.purpose=_,console.log(`[Qwen TTS] Purpose: ${_}`));const O=T;console.log(`[Qwen TTS] Sending request to ${this.apiUrl}/api/v1/tts/audio`);const B=(await v.post(`${this.apiUrl}/api/v1/tts/audio`,O,{headers:{"Content-Type":"application/json"},responseType:"blob",timeout:this.timeout})).data;if(!B||B.size===0)throw new Error("[Qwen TTS] No audio content received from server");return console.log(`[Qwen TTS] Successfully received audio (${B.size} bytes)`),{audio:B,mimeType:"audio/wav"}}catch(f){const E=f instanceof Error?f.message:String(f);if(console.error(`[Qwen TTS] Error: ${E}`),f instanceof v.AxiosError){if(((n=f.response)==null?void 0:n.status)===401||((r=f.response)==null?void 0:r.status)===403)throw new Error("[Qwen TTS] Unauthorized: Invalid credentials or API key on server");if(f.code==="ECONNABORTED")throw new Error("[Qwen TTS] Request timeout: Qwen TTS service not responding");if(((s=f.response)==null?void 0:s.status)===400){const x=((i=(o=f.response)==null?void 0:o.data)==null?void 0:i.message)||"Bad request parameters";throw new Error(`[Qwen TTS] Bad Request: ${x}`)}throw((l=f.response)==null?void 0:l.status)===429?new Error("[Qwen TTS] Rate limit exceeded: Too many requests to Qwen API"):f.code==="ERR_NETWORK"?new Error(`[Qwen TTS] Network error: Cannot reach Qwen TTS service at ${this.apiUrl}`):new Error(`[Qwen TTS] API Error (${(c=f.response)==null?void 0:c.status}): ${((d=(u=f.response)==null?void 0:u.data)==null?void 0:d.message)||E}`)}throw f}}}const Sr=new Er;function br(e){const[t,n]=g.useState({isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0,avatars:e.avatars,error:null}),[r,s]=g.useState(e.autoAdvance||!1),[o,i]=g.useState(!1),[,l]=g.useState(0),c=g.useRef(null),u=g.useRef(null),d=g.useRef(r),f=g.useRef(!1),E=g.useRef(null);g.useEffect(()=>{d.current=r},[r]);const x=w=>{if(e.avatars.length<=1)return 0;const b=e.avatars.length,z=100/b;return Math.min(Math.floor(w/z),b-1)},p=()=>{u.current&&(clearInterval(u.current),u.current=null)},y=()=>{c.current&&(u.current=setInterval(()=>{if(c.current&&c.current.duration){const w=c.current.currentTime,b=c.current.duration,z=w/b*100;n(q=>({...q,progress:Math.min(z,100),currentPNGTuber:x(z)}))}},100))},m=()=>{var w;c.current&&!t.isPaused&&(c.current.pause(),p(),n(b=>({...b,isPlaying:!1,isPaused:!0})),(w=e.onPause)==null||w.call(e))},_=async()=>{if(c.current&&t.isPaused)try{await c.current.play(),y(),n(w=>({...w,isPlaying:!0,isPaused:!1}))}catch(w){console.error("Error al reanudar audio:",w),n(b=>({...b,error:{type:"audio",message:"Error al reanudar la reproducción"}}))}},A=()=>O(!0),T=()=>s(w=>!w),O=(w=!1)=>{p(),c.current&&(E.current&&(c.current.removeEventListener("ended",E.current),E.current=null),c.current.removeEventListener("error",L),c.current.removeEventListener("pause",B),c.current.pause(),c.current.currentTime=0,c.current.src="",c.current.load(),c.current=null),n(b=>({...b,isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0})),d.current&&!f.current&&(f.current=!0,l(b=>b+1)),w||setTimeout(()=>{var b;return(b=e.onStop)==null?void 0:b.call(e)},50)},L=()=>{n(w=>({...w,error:{type:"audio",message:"Error al reproducir el audio"}})),O()},B=()=>{c.current&&c.current.currentTime<c.current.duration&&n(w=>({...w,isPlaying:!1,isPaused:!0}))},D=async()=>{if(!e.text.trim()){n(w=>({...w,error:{type:"synthesis",message:"No hay contenido para reproducir"}}));return}f.current=!1,O(!0);try{i(!0),n(ne=>({...ne,isPlaying:!1,progress:0,currentPNGTuber:0,error:null}));const w=e.voiceConfig,b=(w==null?void 0:w.voice)??e.voiceId,z=(w==null?void 0:w.languageType)??e.lang??"Spanish",q=`qwen-${b}-${z}-${(w==null?void 0:w.preset)??""}-${(w==null?void 0:w.emotion)??""}-${(w==null?void 0:w.speed)??""}-${(w==null?void 0:w.pitch)??""}-${e.text}`;let $=await Gt(q);$?console.log("[TTS] Cache hit"):($=(await Sr.synthesizeSpeech({text:e.text,voice:b,languageType:z,preset:(w==null?void 0:w.preset)??void 0,emotion:(w==null?void 0:w.emotion)??void 0,speed:(w==null?void 0:w.speed)??void 0,pitch:(w==null?void 0:w.pitch)??void 0,purpose:(w==null?void 0:w.purpose)??void 0})).audio,await Jt(q,$)),H($)}catch(w){console.error("Error al reproducir TTS:",w),n(b=>({...b,error:{type:"network",message:`Error en la síntesis: ${w.message}`},isPlaying:!1})),p(),i(!1)}},H=w=>{const b=URL.createObjectURL(w);c.current=new Audio(b);const z=()=>{O(!1),URL.revokeObjectURL(b)};E.current=z,c.current.addEventListener("ended",z),c.current.addEventListener("error",L),c.current.addEventListener("pause",B),c.current.addEventListener("canplaythrough",async()=>{var q;i(!1),n($=>({...$,isPlaying:!0})),y();try{await((q=c.current)==null?void 0:q.play())}catch($){console.error("Error al iniciar reproducción:",$),n(ne=>({...ne,error:{type:"audio",message:"Error al iniciar la reproducción"}})),O()}})};return g.useEffect(()=>()=>{p(),c.current&&(c.current.pause(),c.current.src="",c.current.load(),c.current=null)},[]),g.useEffect(()=>{e.voiceId&&(c.current&&(c.current.pause(),c.current.src="",c.current.load(),c.current=null),p(),n(w=>({...w,isPlaying:!1,isPaused:!1,progress:0,currentPNGTuber:0})))},[e.voiceId]),{...t,play:D,pause:m,resume:_,stop:A,toggleAutoAdvance:T,isAutoAdvancing:r,isLoadingAudio:o,avatars:e.avatars}}const te={selectorWrapper:"_selectorWrapper_1kmif_1",iconButton:"_iconButton_1kmif_6",dropdown:"_dropdown_1kmif_18",dropdownItem:"_dropdownItem_1kmif_31",active:"_active_1kmif_44"},Bt=({languages:e,current:t,onChange:n})=>{const[r,s]=g.useState(!1),[o,i]=g.useState(t||e[0].code),l=g.useRef(null);return g.useEffect(()=>{const c=u=>{l.current&&!l.current.contains(u.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),h.jsxs("div",{className:te.selectorWrapper,ref:l,children:[h.jsx("button",{className:te.iconButton,title:"Cambiar idioma",onClick:()=>s(!r),children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"white",width:"30px",height:"30px",viewBox:"0 0 24 24",children:h.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"})})}),r&&h.jsx("div",{className:te.dropdown,children:e.map(c=>h.jsx("button",{className:`${te.dropdownItem} ${c.code===o?te.active:""}`,onClick:()=>{i(c.code),n==null||n(c.code),s(!1)},children:c.label},c.code))})]})},R={controlsRow:"_controlsRow_22zwh_1",select:"_select_22zwh_9",autoAdvanceButton:"_autoAdvanceButton_22zwh_15",section:"_section_22zwh_26",textarea:"_textarea_22zwh_36",input:"_input_22zwh_46",error:"_error_22zwh_54",buttonPrimary:"_buttonPrimary_22zwh_59",buttonSuccess:"_buttonSuccess_22zwh_69",infoBox:"_infoBox_22zwh_78",viewer:"_viewer_22zwh_86",viewerTopBar:"_viewerTopBar_22zwh_97",topRightControls:"_topRightControls_22zwh_110",itemCounter:"_itemCounter_22zwh_118",iconButton:"_iconButton_22zwh_126",navButton:"_navButton_22zwh_146",navButtonLeft:"_navButtonLeft_22zwh_163",navButtonRight:"_navButtonRight_22zwh_167",backgroundImage:"_backgroundImage_22zwh_171",avatar:"_avatar_22zwh_178",caption:"_caption_22zwh_188",captionTitle:"_captionTitle_22zwh_201",captionText:"_captionText_22zwh_211",loadingOverlay:"_loadingOverlay_22zwh_217",loadingSpinner:"_loadingSpinner_22zwh_232",spin:"_spin_22zwh_251",loadingButton:"_loadingButton_22zwh_242",spinner:"_spinner_22zwh_251",progressBar:"_progressBar_22zwh_264",progressFill:"_progressFill_22zwh_273",playbackControls:"_playbackControls_22zwh_279",playButton:"_playButton_22zwh_292",pauseButton:"_pauseButton_22zwh_293",elementAudioControl:"_elementAudioControl_22zwh_300",elementAudioButton:"_elementAudioButton_22zwh_313",volumeSlider:"_volumeSlider_22zwh_331"},Tr=[{id:"Ebona",name:"Voz Mujer"},{id:"Bodega",name:"Voz Hombre"},{id:"Peter",name:"Voz Narrador"}],Lt=ue.DEFAULT_IMAGE_URL,_r=({heritageItems:e=[],targetLanguage:t="es",descriptionLength:n="extended",autoAdvance:r=!1,voiceConfigs:s=[],voiceIds:o=[],avatars:i=[]})=>{const[l]=g.useState(e),[c,u]=g.useState(0),[d,f]=g.useState(n),[E,x]=g.useState(t),[p,y]=g.useState(""),[m,_]=g.useState([]),[A,T]=g.useState(0),[O,L]=g.useState(r),[B,D]=g.useState(!1),[H,w]=g.useState(o.length>0?o[0]:""),b=s.length>0?s.map(C=>C.voice):o,z=H||(b.length>0?b[c%b.length]:""),q=s.length>0?s[c%s.length]:void 0,$=i[c%i.length],[ne,Nt]=g.useState(!1),[Ar,Pt]=g.useState(!1),[Rr,_e]=g.useState(!0),K=g.useRef(null),kt=g.useRef(O),Me=g.useRef(c),Ae=g.useRef(l),X=g.useRef(null),Re=g.useRef(!1),k=g.useRef(null),[ae,xr]=g.useState(.3),[$e,ce]=g.useState(!1),Ut=g.useRef(.3);g.useEffect(()=>{kt.current=O,Me.current=c,Ae.current=l},[O,c,l]),g.useEffect(()=>{Ut.current=ae,k.current&&(k.current.volume=ae)},[ae]),g.useEffect(()=>{k.current&&(k.current.pause(),k.current.src="",k.current=null,ce(!1))},[c]);const V=l[c]||{id:"default",name:"Patrimonio Cultural",description:{local:{short:"Ingrese un JSON válido para comenzar",extended:"Ingrese un JSON válido para comenzar"}},imageUrl:""},{isPlaying:W,isPaused:It,isLoadingAudio:Or,progress:Ft,play:Cr,pause:vr,resume:Br,stop:Lr}=br({text:p,lang:E,voiceConfig:q,onStop:()=>{_e(!0),kt.current&&Ae.current.length>1&&!Re.current&&setTimeout(()=>{D(!0);const C=(Me.current+1)%Ae.current.length;u(C)},100),Re.current=!1},voiceId:z,avatars:[$]});g.useEffect(()=>{if(B&&p&&!p.includes("JSON válido")){const C=setTimeout(()=>{W||zt(),D(!1)},500);return()=>clearTimeout(C)}},[B,p,W]),g.useEffect(()=>{(async()=>{var Z;const F=((Z=V.description.english)==null?void 0:Z[d])||V.description.local[d];if(F)try{const qe=await Ve(V.name,E),Ir=await Ve(F,E);y(`${qe}. ${Ir}`)}catch(qe){console.error("Error en traducción:",qe),y(`${V.name}. ${F}`)}})()},[V,d,E]);const je=()=>{_e(!0),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>{_e(!1)},4e3)},Dt=()=>{var Z;if(k.current)return;const C=(Z=Ae.current[Me.current])==null?void 0:Z.audioUrl;if(!C)return;const F=new Audio(C);F.volume=Ut.current,F.loop=!0,k.current=F,F.play().then(()=>ce(!0)).catch(()=>ce(!1))},zt=()=>{if(!p.trim()||p.includes("JSON válido")){alert("No hay contenido para reproducir");return}Dt(),Cr(),je()},Nr=()=>{vr()},Pr=()=>{Dt(),Br(),je()},Mt=()=>{Lr(),D(!1),K.current&&clearTimeout(K.current),X.current&&clearTimeout(X.current),_e(!0)},kr=()=>{Re.current=!0,Mt(),c>0&&u(C=>C-1)},Ur=()=>{Re.current=!0,Mt(),c<l.length-1&&u(C=>C+1)};g.useEffect(()=>()=>{K.current&&clearTimeout(K.current),X.current&&clearTimeout(X.current),k.current&&(k.current.pause(),k.current.src="",k.current=null)},[]),g.useEffect(()=>{if(p){const C=p.split(new RegExp("(?<=[.!?])\\s+","g")).map(F=>F.trim()).filter(F=>F.length>0);_(C),T(0)}},[p]),g.useEffect(()=>{if(!W||m.length===0)return;K.current&&clearTimeout(K.current);const F=1500+m[A].length*50;K.current=setTimeout(()=>{T(Z=>(Z+1)%m.length)},F)},[W,m,A]);const[$t,Qs]=g.useState(!1);return g.useEffect(()=>{!$t&&b.length>0&&w(b[c%b.length])},[c,b,$t]),h.jsxs("div",{children:[ue.DEBUG_MODE,h.jsxs("div",{className:R.viewer,onClick:je,children:[V.audioUrl&&h.jsxs("div",{className:R.elementAudioControl,onClick:C=>C.stopPropagation(),children:[h.jsx("button",{className:R.elementAudioButton,title:$e?"Pausar audio ambiente":"Reproducir audio ambiente",onClick:()=>{k.current&&($e?(k.current.pause(),ce(!1)):k.current.play().then(()=>ce(!0)).catch(()=>{}))},children:$e?h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"white",children:[h.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),h.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}):h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",children:[h.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),h.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),h.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})}),h.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:ae,className:R.volumeSlider,title:`Volumen ambiente: ${Math.round(ae*100)}%`,onChange:C=>xr(parseFloat(C.target.value))})]}),h.jsxs("div",{className:R.viewerTopBar,children:[h.jsx("div",{className:R.itemCounter,children:l.length>0?`${c+1}/${l.length}`:"0/0"}),h.jsxs("div",{className:R.topRightControls,children:[h.jsx("button",{onClick:()=>L(!O),className:R.iconButton,title:"Autoplay",style:{backgroundColor:O?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.7)"},children:h.jsx("svg",{width:"20px",height:"20px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{style:{fill:O?"black":"white"},d:"M5.23331,0.493645 C6.8801,-0.113331 8.6808,-0.161915 10.3579,0.355379 C11.4019,0.6773972 12.361984,1.20757325 13.1838415,1.90671757 L13.4526,2.14597 L14.2929,1.30564 C14.8955087,0.703065739 15.9071843,1.0850774 15.994017,1.89911843 L16,2.01275 L16,6.00002 L12.0127,6.00002 C11.1605348,6.00002 10.7153321,5.01450817 11.2294893,4.37749065 L11.3056,4.29291 L12.0372,3.56137 C11.389,2.97184 10.6156,2.52782 9.76845,2.26653 C8.5106,1.87856 7.16008,1.915 5.92498,2.37023 C4.68989,2.82547 3.63877,3.67423 2.93361,4.78573 C2.22844,5.89723 1.90836,7.20978 2.02268,8.52112 C2.13701,9.83246 2.6794,11.0698 3.56627,12.0425 C4.45315,13.0152 5.63528,13.6693 6.93052,13.9039 C8.22576,14.1385 9.56221,13.9407 10.7339,13.3409 C11.9057,12.7412 12.8476,11.7727 13.4147,10.5848 C13.6526,10.0864 14.2495,9.8752 14.748,10.1131 C15.2464,10.351 15.4575,10.948 15.2196,11.4464 C14.4635,13.0302 13.2076,14.3215 11.6453,15.1213 C10.0829,15.921 8.30101,16.1847 6.57402,15.8719 C4.84704,15.559 3.27086,14.687 2.08836,13.39 C0.905861,12.0931 0.182675,10.4433 0.0302394,8.69483 C-0.122195,6.94637 0.304581,5.1963 1.2448,3.7143 C2.18503,2.2323 3.58652,1.10062 5.23331,0.493645 Z M6,5.46077 C6,5.09472714 6.37499031,4.86235811 6.69509872,5.0000726 L6.7678,5.03853 L10.7714,7.57776 C11.0528545,7.75626909 11.0784413,8.14585256 10.8481603,8.36273881 L10.7714,8.42224 L6.7678,10.9615 C6.45867857,11.1575214 6.06160816,10.965274 6.00646097,10.6211914 L6,10.5392 L6,5.46077 Z"})})}),h.jsx(Bt,{languages:[{code:"es",label:"Español"},{code:"en",label:"English"},{code:"fr",label:"Français"}],current:"es",onChange:C=>x(C)})]})]}),h.jsx("button",{onClick:kr,disabled:l.length===0,className:`${R.navButton} ${R.navButtonLeft}`,title:"Anterior",onMouseOver:()=>Nt(!0),onMouseOut:()=>Nt(!1),children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{width:"24px",height:"24px",transition:"transform 0.2s ease-in-out",transform:ne?"scale(1.5)":"scale(1)"},children:h.jsx("path",{d:"M15 18l-6-6 6-6"})})}),h.jsx("button",{onClick:Ur,disabled:l.length===0,className:`${R.navButton} ${R.navButtonRight}`,title:"Siguiente",onMouseOver:()=>Pt(!0),onMouseOut:()=>Pt(!1),children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{width:"24px",height:"24px",transition:"transform 0.2s ease-in-out",transform:Ar?"scale(1.5)":"scale(1)"},children:h.jsx("path",{d:"M9 6l6 6-6 6"})})}),h.jsx("img",{src:V.imageUrl||Lt,alt:"Background",className:R.backgroundImage,style:{opacity:W?1:.7},onError:C=>C.currentTarget.src=Lt}),W&&h.jsx(h.Fragment,{children:h.jsx("img",{src:$,alt:"Avatar",className:R.avatar,style:{transform:`scale(${Ft%10<5?4:4.05})`}})}),h.jsxs("div",{className:R.caption,children:[h.jsx("h4",{className:R.captionTitle,children:V.name}),W&&h.jsx(h.Fragment,{children:h.jsx("p",{className:R.captionText,children:m.length>0&&m[A]})})]}),B&&h.jsxs("div",{className:R.loadingOverlay,children:[h.jsx("div",{className:R.loadingSpinner}),h.jsx("p",{children:"Cargando siguiente patrimonio..."})]}),Rr&&h.jsx("div",{className:R.playbackControls,children:Or?h.jsx("button",{disabled:!0,className:R.loadingButton,children:h.jsxs("svg",{className:R.spinner,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}):!W&&!It?h.jsx("button",{onClick:zt,disabled:l.length===0||B,className:R.playButton,children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"white",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M9 8.5 L9 15.5 L16 12 Z"})})}):It?h.jsx("button",{onClick:Pr,className:R.playButton,children:h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"white",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M9 8.5 L9 15.5 L16 12 Z"})})}):h.jsx("button",{onClick:Nr,className:R.pauseButton,children:h.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"16"}),h.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"16"})]})})}),h.jsx("div",{className:R.progressBar,children:h.jsx("div",{className:R.progressFill,style:{width:`${Ft}%`}})})]})]})};N.LanguageSelector=Bt,N.LanguageSelectorStyles=te,N.StoryVisualizer=_r,N.StoryVisualizerStyles=R,N.voices=Tr,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
7
7
|
//# sourceMappingURL=ocity-heritage-visualizer.umd.js.map
|