@phont-ai/subtitles-core 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +2 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +305 -2
- package/dist/index.d.ts +305 -2
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/dist/phont-subtitles.global.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ze=(n,t)=>{for(var e in t)te(n,e,{get:t[e],enumerable:!0})},Qe=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ke(t))!Je.call(n,s)&&s!==e&&te(n,s,{get:()=>t[s],enumerable:!(i=He(t,s))||i.enumerable});return n};var tn=n=>Qe(te({},"__esModule",{value:!0}),n);var qn={};Ze(qn,{ANIMATION_STYLING:()=>x,ANIMATION_URLS:()=>U,AUTHORED_PLAYBACK_OPTIONS:()=>Te,EMOTION_ANIMATION_URLS:()=>qt,PhontClient:()=>Gt,REFERENCE_GTS:()=>pt,REFERENCE_INTENSITY:()=>ee,RENDERING_CONTROL:()=>p,SubtitleManager:()=>gt,SubtitleStateManager:()=>ft,calculateAnimationParameters:()=>mt,calculateAnimationState:()=>Oe,calculateDynamicWordSpacing:()=>$e,calculateEmphasisMultiplier:()=>se,calculateGTSValues:()=>Nt,calculateJoy:()=>fn,calculateJoyBulge:()=>gn,calculateNormalizedTime:()=>Dn,calculateWeightFromVolume:()=>Yn,calculateWidthFromSpeechRate:()=>Vn,calculateWordEmphasisEffects:()=>le,calculateWordLetterSpacing:()=>$n,capEmotionIntensity:()=>ne,computeProsodyWeight:()=>Ue,createPublishedAnimationResolver:()=>je,decodeAnimationUrl:()=>Wt,ensureFont:()=>de,findSubtitleForWord:()=>$t,generateTextShadow:()=>Xe,getAnimationUrlForEmotion:()=>We,getCombinedBlurAmount:()=>Ye,getFontFamilyCSS:()=>Ut,getJoyAnimationMode:()=>ue,getJoyFilter:()=>bn,getJoyTransform:()=>pn,getMergedSubtitles:()=>At,getMotionBlurAmount:()=>me,getSubtitleAnimations:()=>wt,getSubtitleText:()=>St,getSubtitleTiming:()=>Rn,getSubtitleWords:()=>Xt,getWordEmphasis:()=>ke,hasMergedSubtitles:()=>tt,hockeyStickIntensity:()=>ve,isInEmphasisRange:()=>ie,isInStrongEmphasisRange:()=>ae,meetsEmotionThreshold:()=>cn,preloadAnimationFonts:()=>ze,processEmotionsWithImportance:()=>yt,resolveEffectiveGts:()=>bt,sampleParameterCurve:()=>ct,selectEmotion:()=>Ln,selectFontFamily:()=>Be,shouldUseAngryFont:()=>wn,shouldUseJoyFont:()=>An,shouldUseSadnessFont:()=>vn,splitTextIntoLetters:()=>Un,subtitleManager:()=>we});module.exports=tn(qn);var ft=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,e,i){t!==void 0&&(this.state.soundByteAll=t),e!==void 0&&(this.state.soundByteImportant=e),i!==void 0&&(this.state.soundByteFiltered=i),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,e,i){t!==void 0&&(this.vodState.soundByteAll=t),e!==void 0&&(this.vodState.soundByteImportant=e),i!==void 0&&(this.vodState.soundByteFiltered=i),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,e){this.state.segmentDurations.set(t,e)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var Bt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let e=t||"original";return this._subtitleCache.get(e)}set(t,e){let i=t||"original";this._subtitleCache.set(i,{data:e,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let e=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],i=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],s=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,m=0,u=0;r.forEach(f=>{e.includes(f)&&o++,i.includes(f)&&m++,s.includes(f)&&u++});let l=o/a,d=m/a,c=u/a,C=.1;return l>C&&l>d&&l>c?"de":d>C&&d>l&&d>c?"pl":c>C&&c>l&&c>d?"en-US":null}};var en="phont_session_",nn="phont_current_user";function he(n){return`${en}${n}`}function fe(){try{return localStorage.getItem(nn)}catch(n){return console.error("Failed to get current user:",n),null}}function ge(n){if(!n)return null;try{let t=localStorage.getItem(he(n));if(!t)return null;let e=JSON.parse(t);return!e.sessionId||!e.authToken||!e.username?(console.warn("Invalid session data found in storage"),rn(n),null):e}catch(t){return console.error("Failed to retrieve session:",t),null}}function sn(n){let t=ge(n);return t?t.authToken:null}function an(n){let t=ge(n);return t?t.sessionId:null}function rn(n){if(n)try{localStorage.removeItem(he(n))}catch(t){console.error("Failed to clear session:",t)}}function pe(){let n=fe();return n?sn(n):null}function be(){let n=fe();return n?an(n):null}var ut=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",Ft=class{constructor(t,e){this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=e||null}setPhontClient(t){this.phontClient=t}normalizeSubtitles(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:t&&Array.isArray(t.subtitles)?t.subtitles.length>0&&!Array.isArray(t.subtitles[0])&&typeof t.subtitles[0]=="object"?[t.subtitles]:t.subtitles:[]}normalizeSoundbites(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:[]}async parseHLSMasterManifest(t){try{let e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch master manifest: ${e.status}`);let s=(await e.text()).split(`
|
|
2
|
-
`);for(let r of
|
|
3
|
-
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let m=o.match(/#EXTINF:([0-9.]+)/);if(m){let u=parseFloat(m[1]);s.set(a,u),a++}}return s}catch(e){throw e}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let i=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let s=await this.parseHLSMasterManifest(i),r=await this.parseAudioPlaylist(s);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let e=this._audioPlaylistCache.segmentDurations.get(t);return e!==void 0?e:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let e=await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(e)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let e;if(this.phontClient){if(!ut&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ut||this.phontClient.apiBaseUrl,s=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);e=await s.json()}else{if(!ut)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ut}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);e=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),e}catch{return null}}async fetchSubtitleData(t,e=null){if(this.stateManager.clearVodState(),!!t)try{let i,s;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");s=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let m=r.searchParams.get("lang")||e||void 0,u=r.searchParams.get("model")||void 0;try{i=await this.phontClient.getSubtitleTrack(s,m||null,u||null)}catch(l){let d=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),c=typeof l?.message=="string"?l.message:String(l||""),C=d===404||c.includes("404")||c.includes("Not Found"),f=d===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(C||f)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{s=t;let r=e&&e.trim()||void 0;try{i=await this.phontClient.getSubtitleTrack(s,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),m=typeof a?.message=="string"?a.message:String(a||""),u=o===404||m.includes("404")||m.includes("Not Found"),l=o===400||m.includes("400")||m.includes("Bad Request")||m.includes("HTTP error! status: 400");if(u||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${s} (${u?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:s};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);s=l?l[1]:t.split("/").pop().split("?")[0]}else{if(s=t,!ut&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ut||this.phontClient?.apiBaseUrl,d=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&d.append("lang",e.trim());let c=d.toString();r=c?`${l}/vod-subtitles/${s}?${c}`:`${l}/vod-subtitles/${s}`}let a={"Content-Type":"application/json"},o=pe(),m=be();o&&(a.Authorization=`Bearer ${o}`),m&&(a["X-Session-ID"]=m);let u=await fetch(r,{headers:a,cache:"no-store"});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);i=await u.json()}return this.stateManager.updateVodVideoId(s),{data:i,videoId:s}}catch(i){throw this.stateManager.clearVodState(),i}}};var ye={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Pt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let e=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[i,s]of Object.entries(ye)){let r=i.toLowerCase().replace(/[\s\-_]+/g,"");if(e===r)return s}return null}processSoundbiteAnimations(t){let e=[];if(t.important&&Array.isArray(t.important))for(let i of t.important){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`important_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"important",isActive:!1})}if(e.length===0&&t.all&&Array.isArray(t.all))for(let i of t.all){let s=this.mapEventLabelToAnimation(i.event_label);s&&e.push({id:`all_${i.event_label}_${i.start_time||i.onset}`,eventLabel:i.event_label,animationFile:s,startTime:i.start_time||i.onset,endTime:i.end_time||i.offset,priority:"all",isActive:!1})}return e}mergeAnimations(t){if(t.length===0)return;let e=this.stateManager.state.soundbiteAnimations;t.forEach(i=>{if(i.animationFile==="Laughter"){let s=e.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-i.startTime)<=1);if(s){s.endTime=Math.max(s.endTime,i.endTime);return}}e.push(i)})}getActiveSoundbiteAnimations(t=!1){let e=this.stateManager.state.currentTime,i=2,s=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&e<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:c})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let m=this.mapEventLabelToAnimation(o.event_label);if(m){let u=o.onset??o.start_time??0,l=o.offset??o.end_time??0,c=l-u<i?u+i:l;e>=u&&e<=c&&s.push({id:`vod_${o.event_label}_${u}`,eventLabel:o.event_label,animationFile:m,startTime:u,endTime:c,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:c})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let m of o){let u=this.mapEventLabelToAnimation(m.event_label);if(u){let l=m.start_time??m.onset??0,d=m.end_time??m.offset??0;if(e>=l&&e<=d){let C="all";this.stateManager.state.soundByteImportant?.includes(m)?C="important":this.stateManager.state.soundByteFiltered?.includes(m)&&(C="filtered"),s.push({id:`live_${m.event_label}_${l}`,eventLabel:m.event_label,animationFile:u,startTime:l,endTime:d,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};s.sort((o,m)=>{let u=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=m.eventLabel==="Laughter"?1:r[m.priority]||5;return u-l});let a=s.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let e=s=>Array.isArray(s)?s.length>0&&Array.isArray(s[0])?s.flat():s:[];return t?{all:e(this.stateManager.vodState.soundByteAll||[]),important:e(this.stateManager.vodState.soundByteImportant||[]),filtered:e(this.stateManager.vodState.soundByteFiltered||[])}:{all:e(this.stateManager.state.soundByteAll||[]),important:e(this.stateManager.state.soundByteImportant||[]),filtered:e(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,e=null){let i=[],s=[],r=e??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}return{all:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,e=30){let i=t-e,s=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=i),this.stateManager.state.soundbiteAnimations.length<s&&this.stateManager.notify()}};var Lt=class{constructor(t,e,i){this.stateManager=t,this.fetcher=e,this.soundbiteProcessor=i}processVodData(t,e,i,s){let r=e.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(e?e.split("/").pop()?.split("?")[0]:void 0),m=a.flat().map(f=>({...f,sequence_number:o}));s&&s.length>0&&(m=this._mergeAnimationDataFromOriginal(m,s));let u=this._deduplicateSubtitles(m),{soundByteAll:l,soundByteImportant:d,soundByteFiltered:c}=this._processSoundbites(t.soundbite);if(l.length>0||d.length>0||c.length>0){let f={all:l,important:d,filtered:c},h=this.soundbiteProcessor.processSoundbiteAnimations(f);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...h]}let C=t.language||i||null;this.stateManager.vodState={subtitles:u,url:e,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:d,soundByteFiltered:c,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[VodDataProcessor] Processed VOD data:",{subtitleCount:u.length,firstSubtitle:u[0]?{start_time:u[0].start_time,end_time:u[0].end_time,text:u[0].text,hasWords:!!u[0].words,wordCount:u[0].words?.length||0,emotion:u[0].emotion,animations:u[0].animations}:null,videoId:r,languageCode:i}),this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,e){let i=new Map;for(let s of e){let r=`${s.start_time}-${s.end_time}`;(!i.has(r)||s.animations||s.emotion)&&i.set(r,s)}return t.map(s=>{let r=`${s.start_time}-${s.end_time}`,a=i.get(r);if(!a)return s;let o=s.animations&&typeof s.animations=="object"&&Object.keys(s.animations).length>0,m=s.emotion&&s.emotion!=="none"&&s.emotion!=="neutral",u=typeof s.animation_url=="string"&&s.animation_url.length>0;if(o&&u)return s;let l={...s};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!m&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!u&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let d=new Map;for(let c of a.words)d.set(`${c.start}-${c.end}`,c);l.words=l.words.map(c=>{let C=d.get(`${c.start}-${c.end}`);if(!C||c.animations&&typeof c.animations=="object"&&Object.keys(c.animations).length>0)return c;let h={...c};return C.animations&&Object.keys(C.animations).length>0&&(h.animations=C.animations),!h.emotion&&C.emotion&&(h.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(h.emotion_intensity=C.emotion_intensity)),!h.animation_url&&C.animation_url&&(h.animation_url=C.animation_url),h})}return l})}_deduplicateSubtitles(t){let e=new Map;for(let i of t){let s=`${i.start_time}-${i.end_time}`;(!e.has(s)||i.emotion||i.animations)&&e.set(s,i)}return Array.from(e.values())}_processSoundbites(t){let e=[],i=[],s=[];return t&&(t.all&&Array.isArray(t.all)&&(e=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(i=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(s=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:e,soundByteImportant:i,soundByteFiltered:s}}};var Rt=class{constructor(t,e,i){this.stateManager=t,this.soundbiteProcessor=e,this.liveTimeGenerator=i}async processLiveSegment(t,e,i){this.stateManager.state.processedSequences.add(e),this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=e);let s=await i(e);this.stateManager.state.segmentDurations.set(e,s);let r=this.liveTimeGenerator.getCumulativeDuration(e),a=this._processSubtitles(t.subtitles,e,r),{processedSoundbitesAll:o,processedSoundbitesImportant:m,processedSoundbitesFiltered:u}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,m,u);let l={all:o,important:m,filtered:u},d=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(d),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(c=>c.end_time))),this.stateManager.notify(),t}_processSubtitles(t,e,i){return!t||!Array.isArray(t)?[]:t.map(s=>({...s,sequence_number:e,start_time:s.start_time+i,end_time:s.end_time+i,words:s.words?s.words.map(r=>({...r,start:r.start+i,end:r.end+i})):void 0}))}_processSoundbites(t,e){let i=(t?.all||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),s=(t?.important||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+e,end_time:a.offset+e}));return{processedSoundbitesAll:i,processedSoundbitesImportant:s,processedSoundbitesFiltered:r}}_updateState(t,e,i,s){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...e],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...i],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...s]}};var Dt=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let e=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=e,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(e-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let e=t.src,i=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=e,t.load(),i&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let e=0;for(let i=this.stateManager.state.initialSequenceOffset;i<t;i++){let s=this.stateManager.state.segmentDurations.get(i)||10;e+=s}return e}};var Ot=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,e){if(!t)return null;let s=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(e>=a.start)r.push(a.word);else break;s=r.join(" ")}return{activeSubtitle:t,displayText:s}}getSubtitleAtTime(t){let e=this.stateManager.vodState;if(!e.subtitles||e.subtitles.length===0)return typeof window<"u"&&window.location.search.includes("debug=subtitles")&&console.log("[CurrentSubtitle] No subtitles in vodState:",{hasVodState:!!e,subtitleCount:e?.subtitles?.length||0,vodStateKeys:e?Object.keys(e):[]}),null;let i=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!i&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let s=e.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(typeof window<"u"&&window.location.search.includes("debug=subtitles")&&!s&&t>0&&console.log("[CurrentSubtitle] No subtitle found for time:",{time:t,subtitleCount:e.subtitles.length,firstSubtitle:e.subtitles[0]?{start_time:e.subtitles[0].start_time,end_time:e.subtitles[0].end_time,text:e.subtitles[0].text||e.subtitles[0].words?.map(r=>r.word).join(" ")}:null,lastSubtitle:e.subtitles[e.subtitles.length-1]?{start_time:e.subtitles[e.subtitles.length-1].start_time,end_time:e.subtitles[e.subtitles.length-1].end_time}:null}),s){let r=this._processSubtitleText(s,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,m=e.currentSubtitle!==o||e.currentSubtitleData!==a;return m&&(e.currentSubtitle=o,e.currentSubtitleData=a,e.currentSequence=e.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=e.currentSequence??null),(i||m)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return e.currentSubtitle!==""&&(e.currentSubtitle="",e.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let e=t.subtitles.find(i=>t.currentTime>=i.start_time&&t.currentTime<=i.end_time);if(e){t.currentSequence=e.sequence_number??null;let i=this._processSubtitleText(e,t.currentTime);if(!i)return null;let{activeSubtitle:s,displayText:r}=i;return(t.currentSubtitle!==r||t.currentSubtitleData!==s)&&(t.currentSubtitle=r,t.currentSubtitleData=s,this.stateManager.notify()),this._lastSubtitleData=s,this._lastSubtitleTime=t.currentTime,s}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var rs=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function Se(n){if(n==null)return"original";let t=String(n).trim();return t===""?"original":t.toUpperCase()}var gt=class{constructor(){this.stateManager=new ft,this.cache=new Bt,this.fetcher=new Ft(this.stateManager),this.soundbiteProcessor=new Pt(this.stateManager),this.vodDataProcessor=new Lt(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new Dt(this.stateManager),this.liveDataProcessor=new Rt(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new Ot(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,e="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?e:"none",this.notify()}toggleSoundbites(t,e){t==="all"?this.state.showAllSoundbites=e:t==="important"&&(this.state.showImportantSoundbites=e),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}async fetchSubtitles(t){try{let e=await this.fetcher.fetchSubtitles(t);return e?await this.liveDataProcessor.processLiveSegment(e,t,i=>this.getAudioSegmentDuration(i)):null}catch{return null}}async loadVodSubtitles(t,e=null){return this.fetchSubtitleData(t,e)}_processVodData(t,e,i,s){this.vodDataProcessor.processVodData(t,e,i,s)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,e=30){let i=t-e,s=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=i),this.state.subtitles.length<s&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,e=null){return this.soundbiteProcessor.getActiveSoundbites(t,e)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,e=30){this.soundbiteProcessor.clearOldAnimations(t,e)}getCurrentSpeaker(t=!1,e=null){if(!this.state.isSpeaker)return null;let i=null;if(t?i=this.vodState.currentSubtitleData:i=this.state.currentSubtitleData,!i||!i.words)return null;let s=i?.speaker;return s||null}async fetchSubtitleData(t,e=null,i=null){if(!e&&t){let s=new URLSearchParams(t.split("?")[1]||"");e=s.get("lang")||null,i||(i=s.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let s=await this.fetcher.fetchSubtitleData(t,e),{data:r,videoId:a}=s,o=r?.language||e||null;console.log("[SubtitleManager] Fetched subtitle data:",{hasData:!!r,hasSubtitles:!!r?.subtitles,subtitleCount:r?.subtitles?.length||0,videoId:a,url:t,translation_provider:r?.translation_provider||"deepl",translation_model:r?.translation_model||"none",language:o||"ORIGINAL",usingLLM:r?.translation_provider==="phont"});let m=Se(o??e),u=i?`${m}_${i}`:m,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(u,l),(!e||String(e).trim()==="")&&this.cache._subtitleCache.set("original",l);let c;if(!!e&&String(e).trim()!==""){let f=this.cache._subtitleCache.get("original");f?.data?.subtitles&&(c=Array.isArray(f.data.subtitles)?f.data.subtitles.flat():[])}console.log("[SubtitleManager] Processing VOD data..."),this._processVodData(r,t,o,c),console.log("[SubtitleManager] VOD data processed. State:",{subtitleCount:this.state.subtitles.length,vodSubtitleCount:this.vodState.subtitles?.length||0,currentSequence:this.state.currentSequence})}catch(s){let r=s?.status||s?.response?.status,a=r===404||typeof s?.message=="string"&&s.message.includes("404")||typeof s?.message=="string"&&s.message.includes("Not Found"),o=r===400||typeof s?.message=="string"&&s.message.includes("400")||typeof s?.message=="string"&&s.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:s?.message,url:t,languageCode:e}):console.error("[SubtitleManager] Error loading subtitles:",s),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:e,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,e,i=null){if(!e)return;let s=Se(t);if(this.cache._loadingLanguages.has(s))return;let r=i?`${s}_${i}`:s,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(s);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let m=new URLSearchParams;t&&m.append("lang",t),i&&m.append("model",i);let u=m.toString(),l=`${o}/vod-subtitles/${e}${u?`?${u}`:""}`,d=!1;try{await this.fetchSubtitleData(l,t,i),d=!0}catch(c){if(c?.status===404||typeof c?.message=="string"&&c.message.includes("404"))if(t!==null)d=!0;else throw c;else throw c}if(!d)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,e,i)}finally{this.cache._loadingLanguages.delete(s)}}_loadCachedSubtitles(t,e,i){let s=t?.language||i||null,r;if(!!i&&String(i).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,e,s,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},we=new gt;function on(n,t=!1){if(!n)return[];try{return n.split("|").map(e=>{let[i,s]=e.split(","),r=t||typeof s=="string"&&(s.startsWith("#")||s.startsWith("%23")),a;return r?a=s.replace(/%23/g,"#"):a=parseFloat(s),{time:parseFloat(i),value:a}})}catch(e){return console.error("Error decoding points:",e),[]}}function ln(n){if(!n)return"";if(n.includes("://"))try{let t=new URL(n);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=n.indexOf("?");return t!==-1?n.substring(t+1):n}return n.startsWith("?")?n.slice(1):n}function Wt(n){try{let t=ln(n),e=new URLSearchParams(t),i={parameterStates:{}};if(e.has("name")&&(i.name=e.get("name")||void 0),e.has("user")&&(i.userName=e.get("user")||void 0),e.has("duration")&&(i.duration=parseFloat(e.get("duration")||"0")),e.has("mode")&&(i.animationMode=e.get("mode")||void 0),e.has("text")&&(i.text=e.get("text")||void 0),e.get("format")==="normalized"&&(i.format="normalized"),e.has("font"))try{let r=JSON.parse(e.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?i.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:i.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(e.has("bg"))try{i.backgroundStyle=JSON.parse(e.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of e.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),m=on(a,o);if(m.length>0){let u=o?"#000000":0;i.parameterStates[r]={points:m,currentValue:m[0]?.value||u}}}return i}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function ve(n){if(n===0)return 0;let t=4,e;if(n<=.7){let i=Math.log(1+.5*(Math.exp(t)-1))/t;e=Math.pow(n/.7,.5)*i}else{let i=(n-.7)/.3,s=Math.log(1+.5*(Math.exp(t)-1))/t;e=s+i*(1-s)}return(Math.exp(t*e)-1)/(Math.exp(t)-1)}function jt(n){if(typeof n!="string")return{r:0,g:0,b:0};let t=n.replace("#","").padStart(6,"0"),e=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}function xe(n,t,e){let i=s=>{let r=Math.round(Math.max(0,Math.min(255,s))).toString(16);return r.length===1?"0"+r:r};return"#"+i(n)+i(t)+i(e)}function Ae(n,t,e){let i=jt(n),s=jt(t),r=Math.max(0,Math.min(1,e)),a=i.r+(s.r-i.r)*r,o=i.g+(s.g-i.g)*r,m=i.b+(s.b-i.b)*r;return xe(a,o,m)}function un(n,t,e){if(e===0)return n;let i=jt(n),s=jt(t),r=i.r+(s.r-i.r)*e,a=i.g+(s.g-i.g)*e,o=i.b+(s.b-i.b)*e;return xe(r,a,o)}function ct(n,t,e,i=!1,s=null){if(!n||n.length===0)return null;let r=i?t:t*e,a=null,o=null;for(let m=0;m<n.length;m++){let u=n[m],l=u.time!==void 0?u.time:Array.isArray(u)?u[0]:0;if(l!==void 0&&l<=r&&(a=u),l!==void 0&&l>=r&&!o){o=u;break}}if(!a&&n[0])return(n[0].value!==void 0?n[0].value:Array.isArray(n[0])?n[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let m=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,u=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,d=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(m===u||l===null||d===null)return l??null;let c=(r-m)/(u-m),C=s==="color"||s==="shadowColor"||s==="outlineColor"||s==="outline2Color"||s==="outline3Color"||s==="outlineShadowColor"||s==="glowColor";if(C&&(typeof l=="string"||typeof d=="string"))return Ae(typeof l=="string"?l:"#000000",typeof d=="string"?d:"#000000",c);if(!C&&(typeof l=="string"||typeof d=="string")){let f=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),h=typeof d=="string"&&(d.startsWith("#")||/^[0-9a-f]{6}$/i.test(d));if(f&&h){let g=l.startsWith("#")?l:`#${l}`,_=d.startsWith("#")?d:`#${d}`;return Ae(g,_,c)}return d??null}return l+(d-l)*c}return null}var ee=.7,pt=.7,Te={rawMode:!0};function mt(n,t,e,i,s=null,{rawMode:r=!1}={}){if(!n||!n.parameterStates)return null;let a=r?1:t*i/(ee*pt),o=n.duration||2,u=n.format==="normalized"?e:e*o,l=!0,d=n.parameterStates||{},c=(A,B,$=!0,q=null)=>{let ht=q??a,at=ct(d[A]?.points,u,o,l);return at==null?B:$?ht===0?B:B+(at-B)*ht:at},C=c("scale",1),f=c("skew",0),h=c("stretch",1),g=c("translateX",0),_=c("translateY",0),b=c("weight",500),E=c("width",100),y=(n.fontData||{}).style?.fontFamily||"Roboto Flex",D=n.text||"Hello",R=(A,B)=>{let $=ct(d[A]?.points,u,o,l,A);if($==null)return B;let q=typeof $=="string"?$.startsWith("#")?$:`#${$}`:`#${Math.round($).toString(16).padStart(6,"0")}`;return a===0?B:un(B,q,a)},k=R("color","#ffffff"),P=c("opacity",1),I=c("shadowX",0),T=c("shadowY",0),H=c("shadowBlur",4),et=c("shadowOpacity",.5),O=R("shadowColor","#000000"),vt=c("outlineWidth",0),Ht=R("outlineColor","#000000"),W=A=>d[A]?.points?.length>0,dt=W("stretchX")?c("stretchX",1):void 0,xt=W("outline2Width")?c("outline2Width",0):void 0,Tt=W("outline2Color")?R("outline2Color","#000000"):void 0,Mt=W("outline3Width")?c("outline3Width",0):void 0,_t=W("outline3Color")?R("outline3Color","#000000"):void 0,S=W("outlineShadowWidth")?c("outlineShadowWidth",0):void 0,X=W("outlineShadowColor")?R("outlineShadowColor","#000000"):void 0,j=W("outlineShadowBlur")?c("outlineShadowBlur",0):void 0,v=W("glowIntensity")?c("glowIntensity",0):void 0,L=W("glowColor")?R("glowColor","#ffffff"):void 0,N=W("snakeWave")?c("snakeWave",0):void 0,nt=W("karaoke")?c("karaoke",0):void 0,Y=1-.5*Math.min(1,Math.max(0,i)),V=c("blur",0,!0,r?1:a*Y),Ct=ct(d.thinStroke?.points,u,o,l),K=ct(d.ascenderHeight?.points,u,o,l),it={};Ct!=null&&typeof Ct=="number"&&(it.YOPQ=Ct),K!=null&&typeof K=="number"&&(it.YTAS=K),b!=null&&(it.wght=b),E!=null&&(it.wdth=E);let J=[];if(I!==0||T!==0||H!==4||et!==.5){let A=typeof O=="string"?O:"#000000",B=parseInt(A.slice(1,3),16),$=parseInt(A.slice(3,5),16),q=parseInt(A.slice(5,7),16);J.push(`${I}px ${T}px ${H}px rgba(${B}, ${$}, ${q}, ${et})`)}else if(O&&typeof O=="string"&&O!=="#000000"){let A=O.startsWith("#")?O:`#${O}`,B=parseInt(A.slice(1,3),16)||0,$=parseInt(A.slice(3,5),16)||0,q=parseInt(A.slice(5,7),16)||0;J.push(`3px 2px 4px rgba(${B}, ${$}, ${q}, 0.5)`)}if(v!=null&&v>0){let A=typeof L=="string"?L:"#ffffff";J.push(`0 0 ${v}px ${A}`),J.push(`0 0 ${v*2}px ${A}`),J.push(`0 0 ${v*4}px ${A}`)}let Kt=J.length>0?J.join(", "):"",lt=0;if(d.joy?.points&&d.joy.points.length>0)for(let A of d.joy.points){let B=Array.isArray(A)?A[1]:A.y??A.value??0;typeof B=="number"&&B>lt&&(lt=B)}let Et=c("joy",0,!1),Jt=r?Et:Math.min(1,lt*a),Z=c("fear",0),Q=c("standardEmphasis",0,!1),st=c("strongEmphasis",0,!1),M={rawIntensity:t,scaleFactor:a,scale:C,slant:f,stretchY:h,translateX:g,translateY:_,weight:b,width:E,fontFamily:y,textColor:k,opacity:P,textShadow:Kt,blur:V,outlineWidth:vt,outlineColor:Ht,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:it,text:D,joy:Jt,fear:Z,standardEmphasis:Q,strongEmphasis:st,joyWaveProgress:u/o*1.5};return dt!==void 0&&(M.stretchX=dt),xt!==void 0&&(M.outline2Width=xt),Tt!==void 0&&(M.outline2Color=Tt),Mt!==void 0&&(M.outline3Width=Mt),_t!==void 0&&(M.outline3Color=_t),S!==void 0&&(M.outlineShadowWidth=S),X!==void 0&&(M.outlineShadowColor=X),j!==void 0&&(M.outlineShadowBlur=j),v!==void 0&&(M.glowIntensity=v),L!==void 0&&(M.glowColor=L),N!==void 0&&(M.snakeWave=N),nt!==void 0&&(M.karaoke=nt),M}var x={fontSize:54,opacity:1,weight:400,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:4,color:"rgba(0, 0, 0, 0.4)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:1.25,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function bt(n,t,e){let i=Math.max(0,Math.min(1,n)),s=e??t;if(typeof s=="number"&&Number.isFinite(s)){let r=Math.max(0,Math.min(1,s));return Math.min(1,Math.max(0,r*(i/pt)))}return i}function Nt(n){let t=.2+.8*n,e=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*n;return{gts:n,maxExpression:t,threshold:e,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function cn(n,t){return n>=t}function ne(n,t){if(t<=.2)return 0;let e=n*t;return n>.1&&console.log(`[GTS Scaling] Raw: ${n.toFixed(3)} \xD7 maxExpression: ${t.toFixed(3)} = Final: ${e.toFixed(3)} | Match check: ${n.toFixed(3)} === ${e.toFixed(3)}? ${n===e}`),e}function se(n){let{minThreshold:t,maxThreshold:e}=p.emphasis;return n<t||n>=e?0:(n-t)/(e-t)}function ie(n){return n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold}function ae(n){return n>=p.strongEmphasis.minThreshold}function mn(n){n=Math.max(0,Math.min(1,n));let r=1-n,a=r*r,o=a*r,m=n*n,u=m*n;return o*0+3*a*n*.42+3*r*m*.58+u*1}var Me=new WeakMap,re={joy:1,social_positive:1,anger:-1,screaming:-1};function oe(n,t,e,i){let s=typeof e=="string"?e.toLowerCase():"";if(s==="joy")return dn(n,t,i);let r=Math.sign(t);return r!==0?r:s in re?re[s]:i}function dn(n,t,e){let i=Math.sign(t);if(n){let s=Me.get(n);if(s!==void 0)return s;let r=i!==0?i:_e(e);return Me.set(n,r),r}return i!==0?i:_e(e)}function _e(n){return n!==0?n:re.joy}function Cn(n,t,e=1,i=0,s=null,r=""){let a=n?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:m,scaleDownFrames:u,fps:l}=p.emphasis;if(!n||!ie(a))return null;let d=t-n.start,c=s?n.start+s:n.end,C=c-n.start;if(d<0||t>=c)return null;let f=Math.max(0,Math.min(1,d/C)),h=0;f<.5?h=f*2:h=2-f*2,h=h*h*(3-2*h);let g=se(a),_=.55,b=3*_,F=oe(n,i,r,0)*b*h*e*g,y=140*h*e*g,D=1+o*_*h*e*g,R=f<1;return{scaleMultiplier:D,slantAdditive:F,weightBoost:y,scaleProgress:h,gtsMultiplier:e,emphasis:a,emphasisMultiplier:g,elapsed:d,scaleActive:R}}function hn(n,t,e={},i=1,s=null,r=0,a=""){let o=a==="anger"||a==="screaming",m=p.strongEmphasis,u=.7,l=s?n.start+s:n.end;if(t<n.start)return null;let d=n.emphasis||0;if(!ae(d))return null;let c=m.fadeOutTailDuration,C=l+c;if(t>=C)return null;let f=l-n.start,h=Math.max(0,Math.min(1,(t-n.start)/f)),g=1,_=t>=l;if(_){let T=(t-l)/c;g=1-mn(T),h=1}let b=0;h<.5?b=h*2:b=2-h*2;let E=b*b*(3-2*b),F=(d-m.minThreshold)/(1-m.minThreshold),y=E*F*i,D=y;y<.1&&(y=0);let R=oe(n,r,a,-1),k,P;if(o)k={scale:1+y*(m.maxScale-1)*u,rotation:y*m.maxRotation*u,translateY:-y*m.maxTranslateY*u,translateX:y*m.maxTranslateX*u,skewX:R*y*m.maxSkew*u,stretchY:1},P={brightness:1+y*m.maxBrightness*u,contrast:1+y*m.maxContrast*u,shadowBlur:y*m.maxShadowBlur*u,shadowOpacity:y*m.shadowOpacity*u,zIndex:Math.round(y*m.maxZIndex*u)};else{let et=E*20*Math.max(.2,F*i)*u,O=oe(n,r,a,1);k={scale:1+y*.15*u,rotation:0,translateY:0,translateX:0,skewX:O*et,stretchY:1},P={brightness:1+y*.2*u,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(k.scale=1+(k.scale-1)*g,k.rotation=k.rotation*g,k.translateX=k.translateX*g,k.translateY=k.translateY*g,k.skewX=k.skewX*g,P.brightness=1+(P.brightness-1)*g,P.contrast=1+(P.contrast-1)*g,P.shadowBlur=P.shadowBlur*g,P.shadowOpacity=P.shadowOpacity*g,P.zIndex=Math.round(P.zIndex*g),y=y*g);let I=280*y*i;return{emphasis:y,rawEmphasis:D,...k,...P,weightBoost:I,shadowOffsetX:y*m.shadowOffsetX,shadowOffsetY:y*m.shadowOffsetY,gtsMultiplier:i,emphasisMultiplier:F,fadeFactor:g,isInTail:_}}function le({word:n,currentTime:t,maxExpression:e,emotionAnimationDuration:i,wordBaseSlant:s,isActive:r,wordEmotion:a=""}){let o=r?Cn(n,t,e,s,i,a):null,m=hn(n,t,{},e,i,s,a);return{emphasisEffect:o,strongEmphasisData:m}}function Ee(n){let t=2*Math.PI/3;return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n*10-.75)*t)+1}function Ie(n){return 1-(1-n)*(1-n)}function ue(n){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:e}=p.joy;return n<=t?"letter":n>=e?"letter-bulge":"letter"}function fn(n,t,e,i=1){let s=p.joy.letterWave,r=e<=6,a,o,m;r?(a=1.5/Math.max(1,e),o=2.5/Math.max(1,e),m=a+o):(a=s.innerWidthRatio,o=s.outerWidthRatio,m=a+o);let u=t/Math.max(1,e-1),l=n;r&&e<=3?l=Math.min(1.2,n*1.25):r&&(l=Math.min(1.1,n*1.1));let d=l*(1+m),c=u-d,C=a+o,f=o*.3;if(c>f||c<-C)return null;let h=0;if(c>0&&c<=f)h=(1-c/f)*.15;else if(c<=0&&c>=-a){let y=Math.abs(c)/Math.max(a,.01);h=Ee(y)}else if(c<-a){let D=(Math.abs(c)-a)/Math.max(o,.01);h=Ie(1-D)}if(h<=.01)return null;let g=h*i,b=1-t%2*.15,E={scale:1+g*(s.maxScale-1)*b,rotation:g*s.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*s.maxTranslateY*b,skewX:-g*s.maxSkew*.5,stretchY:1},F={brightness:1+g*s.maxBrightness,contrast:1+g*s.maxContrast,shadowBlur:g*s.maxShadowBlur,shadowOpacity:g*s.shadowOpacity,zIndex:Math.round(g*s.maxZIndex)};return{pressure:g,...E,...F,shadowOffsetX:g*3,shadowOffsetY:g*3}}function gn(n,t,e,i=1){let s=p.joy.letterBulge,r=s.innerWidthRatio,a=s.outerWidthRatio,o=r+a,m=e>1?t/Math.max(1,e-1):0,u=n*(1+o),l=m-u,d=a*.35,c=o;if(l>d||l<-c)return null;let C=0;if(l>0&&l<=d)C=(1-l/Math.max(d,1e-4))*.18;else if(l<=0&&l>=-r){let D=Math.abs(l)/Math.max(r,1e-4);C=Ee(D)}else if(l<-r){let R=(Math.abs(l)-r)/Math.max(a,1e-4);C=Ie(1-R)}if(C<=.01)return null;let f=C*i,h=Math.min(1,f*.85),g=1,_=t%3===0?1:-1,b=Math.max(1-s.maxCompressionX,1-h*s.maxCompressionX),E=1+h*s.maxStretchY,F={scale:1+h*(s.maxScale-1),stretchY:E,stretchX:b,rotation:h*s.maxRotation*g,translateX:h*s.maxTranslateX*_,translateY:-h*s.maxTranslateY,skewX:h*s.maxSkew*g},y={brightness:1+h*s.maxBrightness,contrast:1+h*s.maxContrast,shadowBlur:h*s.maxShadowBlur,shadowOpacity:h*s.shadowOpacity,zIndex:Math.round(h*s.maxZIndex)};return{pressure:h,bulgeIntensity:h,...F,...y,shadowOffsetX:h*1.8,shadowOffsetY:h*3}}function pn(n){if(!n)return"";let t=n.scale||1,e=n.stretchX||1,i=n.rotation||0,s=n.translateX||0,r=n.translateY||0,a=n.skewX||0,o=n.stretchY||1;return`scaleX(${e}) scale(${t}) scaleY(${o}) rotate(${i}deg) skewX(${a}deg) translate(${s}px, ${r}px)`}function bn(n){if(!n)return"";let t=n.brightness||1,e=n.contrast||1,i=n.shadowBlur||0,s=n.shadowOpacity||0,r=n.shadowOffsetX||0,a=n.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),e!==1&&o.push(`contrast(${e})`),i>0&&s>0&&o.push(`drop-shadow(${r}px ${a}px ${i}px rgba(255, 255, 255, ${s}))`),o.join(" ")}var yn=["anger","fear","sadness","joy"];function Sn(n){return yn.includes(n.toLowerCase())}function yt(n){return n.map(([t,e])=>{let i=Sn(t),s=i?1.5:1,r=e*s;return[t,e,r,s,i]})}function ke(n){if(!n)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=n.confidence_word||0,e=n.emphasis||0;return{confidence:t,emphasis:e,hasEmphasis:e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold,hasStrongEmphasis:e>=p.strongEmphasis.minThreshold}}function St(n){return n&&(n.subtitle||n.text)||""}function Xt(n){return!n||!n.words?[]:Array.isArray(n.words)?n.words:[]}function wt(n){return!n||!n.animations?{}:typeof n.animations=="object"?n.animations:{}}function tt(n){return!!n&&Array.isArray(n.merged_subtitles)&&n.merged_subtitles.length>0}function At(n){return tt(n)?(n.merged_subtitles||[]).filter(t=>t!=null):[]}function $t(n,t){return!n||!t?null:n.find(e=>e&&t.start<e.end_time&&t.end>e.start_time)||null}function Be(n,t,e=null,i=null){if((i?.name==="children"||i?.name==="hello-kitty")&&e&&i.fonts?.[e])return i.fonts[e];let s=p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold;return s?x.angryFont:r?x.joyFont:a?x.sadnessFont:x.defaultFont}function Ut(n,t,e=null,i=null){let s=Be(n,t,e,i),r="sans-serif";return s==="Cormorant"&&(r="serif"),`"${s}", ${r}`}function wn(n,t){return p.emotion.angryEmotions.includes(n)&&t>=p.emotion.angryFontThreshold}function An(n,t){return p.emotion.joyEmotions.includes(n)&&t>=p.emotion.joyFontThreshold}function vn(n,t){return p.emotion.sadnessEmotions.includes(n)&&t>=p.emotion.sadnessFontThreshold}var Le='"Roboto Flex", "Roboto", sans-serif',Fe=new Map,xn={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function Yt(n){if(typeof n!="string")return"";let t=n.trim().toLowerCase();return t?xn[t]||t:""}function ce(n){if(typeof n!="string"||n.length===0)return null;let t=Fe.get(n);if(t)return t;try{let e=Wt(n);return Fe.set(n,e),e}catch(e){return console.error("[calculateAnimationState] Failed to decode animation URL:",e),null}}function Tn(n){if(!n||n.length===0)return null;let t=n.filter(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(e=>e.start_time)),end:Math.max(...t.map(e=>e.end_time))}}function Mn(n,t){return n.find(e=>e&&typeof e.start_time=="number"&&typeof e.end_time=="number"&&t>=e.start_time&&t<=e.end_time)||null}function Vt(n){return n&&typeof n.animation_url=="string"&&n.animation_url.length>0?n.animation_url:null}function Re(n,t){if(!n)return{emotion:"none",intensity:0};let e=wt(n),i=Object.entries(e).filter(([,a])=>typeof a=="number"&&a>t);if(i.length>0){let a=yt(i).sort((o,m)=>m[2]-o[2])[0];return{emotion:Yt(a[0])||"none",intensity:a[1]}}let s=Yt(n.emotion),r=typeof n.emotion_intensity=="number"?n.emotion_intensity:0;return!s||s==="none"||r<=0?Vt(n)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:s,intensity:r}}function _n(n){let t={...n};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function Pe(n,t,e,i){let{minWordDisplayTime:s,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,m=Math.max(0,n.end-n.start),u=Math.max(m,s);if(!i)return n.start+u;let l=typeof t.end_time=="number"?t.end_time:n.end,d=l-n.end,c=!1;if(e!=null&&e>l?(d=e-n.end,c=d>=o):e==null?(c=!0,d=1/0):c=d>=a,c){let f=d===1/0?s+r:n.end+d-n.start-.1,g=m<s?f:Math.min(s+r,f);u=Math.max(u,g)}return n.start+u}function En(n,t,e){if(!n||n.length===0)return{opacities:[],currentWordIndex:-1};let i=n.findIndex(a=>t>=a.start&&t<a.animationEnd),s=n.reduce((a,o,m)=>t>=o.animationEnd?m:a,-1);return{opacities:n.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||s!==-1&&o<=s?1:e?0:.3),currentWordIndex:i}}function De(n){if(!n)return x.defaultFont;let t=n.match(/["']?([^"',]+)["']?/),e=(t?t[1]:n).trim(),i=e.toLowerCase();return i.includes("bricolage")?"Bricolage Grotesque":i.includes("rakkas")?x.angryFont:i.includes("parkinsans")?x.joyFont:i.includes("cormorant")?x.sadnessFont:i.includes("roboto")?x.defaultFont:e}function In(n,t,e){let i={text:"",fontSize:x.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:Le,startTime:0,endTime:0,duration:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return i;let s=e.maxExpression??1,r=e.threshold??.2,a=e.isRTL??!1,o=s<=.2,m=Nt((s-.2)/.8).gts,u=n.start_time,l=n.end_time,d=Math.max(.01,l-u),c=Math.max(0,Math.min(1,(t-u)/d)),C=Re(n,r),f=o?"none":C.emotion,h=o?0:Math.max(0,C.intensity),g=ce(Vt(n)),_=bt(m,n.gts,void 0),b=g?mt(g,h,c,_,d):null,E=b?.fontFamily?`"${De(b.fontFamily)}", sans-serif`:Ut(f,s),F={fontSize:x.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??x.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?_n(F):F,text:St(n),emotion:f,emotionIntensity:h,fontFamily:E,startTime:u,endTime:l,duration:d,isActive:t>=u&&t<l}}function kn(n,t,e){let i=e.maxExpression??1,s=e.threshold??.2,r=e.isRTL??!1,a=e.nextSegmentStartTime??null,o=e.extendedEndTime??null,m=e.transparentUntilSpoken??!1,u=i<=.2,l=Nt((i-.2)/.8).gts,d={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:Le,startTime:0,endTime:0,isActive:!1};if(!n||typeof n.start_time!="number"||typeof n.end_time!="number")return d;let c=tt(n)?At(n):[n],C=Tn(c),f=Mn(c,t);if(!f&&o!=null&&t>n.end_time&&t<=o&&(f=c[c.length-1]||null),!f&&C&&t>=C.start&&t<=C.end&&(f=[...c].filter(S=>S&&t>=S.start_time).sort((S,X)=>X.start_time-S.start_time)[0]||null),f==null)return d;let h=f,g=Re(h,s),_=u?"none":g.emotion,b=u?0:Math.max(0,g.intensity),E=h.start_time,F=h.end_time,y=Math.max(.01,F-E),D=Math.max(0,Math.min(1,(t-E)/y)),R=tt(n)?null:ce(Vt(h)),k=h.gts??n.gts,P=bt(l,k,void 0),I=R?mt(R,b,D,P,y):null,T={fontSize:x.fontSize,scale:I?.scale??(_==="none"?1:1+b*.16),opacity:I?.opacity??1,slant:I?.slant??0,weight:I?.weight??400,width:I?.width??100,textColor:I?.textColor??x.textColor,translateX:I?.translateX??0,translateY:I?.translateY??0,stretchY:I?.stretchY??1,textShadow:I?.textShadow??"",blur:I?.blur??0,outlineWidth:I?.outlineWidth??0,outlineColor:I?.outlineColor??"#000000",fontVariationAxes:I?.fontVariationAxes??{}},H=Xt(n).flatMap(S=>{let X=String(S?.word??""),j=X.trim();if(!j.includes(" "))return[S];let v=j.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,v.length),nt=X.startsWith(" ");return v.map((Y,V)=>({...S,word:(V===0&&nt?" ":"")+Y,start:(S.start??0)+V*N,end:(S.start??0)+(V+1)*N}))}),et=null;if(tt(n)&&C?.end){let S=H[H.length-1],X=Pe(S,n,a,!0),j=o??X,{minWordDisplayTime:v,breathingRoomDuration:L}=p.timing,N=v+L,Y=(H.length>0?Math.min(...H.map(V=>V.start)):C.start)+N;et=Math.max(C.end,j,Y)}let O=H.map((S,X)=>{let j=X===H.length-1,v=Pe(S,n,a,j);return{...S,animationEnd:tt(n)&&et?Math.max(v,et):v}}),{currentWordIndex:vt,opacities:Ht}=En(O,t,m),W=O.map((S,X)=>{let j=t>=S.start&&t<S.end,v=_,L=b,N=b,nt=tt(n)?At(n):null,Y=nt?$t(nt,S):h;if(Y){let rt=wt(Y),kt=Object.entries(rt).filter(([,G])=>typeof G=="number"&&G>s),Zt=Object.entries(rt).filter(([,G])=>typeof G=="number");if(Zt.length>0)N=[...Zt].sort((ot,Qt)=>Qt[1]-ot[1])[0][1];else{let G=Yt(Y.emotion),ot=typeof Y.emotion_intensity=="number"?Y.emotion_intensity:0;G&&ot>0&&(v=G,N=ot,L=ot)}if(kt.length>0){let G=yt(kt).sort((ot,Qt)=>Qt[2]-ot[2]);v=Yt(G[0][0])||"none",L=G[0][1]}else Zt.length>0&&(v="none",L=0)}u?(v="none",L=0):L===N&&L!==0&&(L=ne(L,i));let V=Math.max(.01,(S.end??0)-(S.start??0)),Ct=Math.max(0,Math.min(1,(t-S.start)/V)),K=ce(Vt(Y)),it=N>0?N:K?Math.max(1,b||0):0,J=bt(l,k,S.gts),w=K?mt(K,it,Ct,J,V):null,Kt=De(K?.fontData?.style?.fontFamily),lt=(K?.parameterStates?.standardEmphasis?.points?.length??0)>0,Et=(K?.parameterStates?.strongEmphasis?.points?.length??0)>0,Jt=lt||Et,Z=j?w?.standardEmphasis??0:0,Q=j?w?.strongEmphasis??0:0,st=null,M=null;if(Jt){let rt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:0;if(lt&&(st={scaleMultiplier:1+.272*Z*i,slantAdditive:rt*4.25*Z*i,weightBoost:250*Z*i,scaleProgress:Z,gtsMultiplier:i,emphasis:Z,emphasisMultiplier:Z,elapsed:0,scaleActive:Z>0}),Et&&!r){let kt=(w?.slant??0)>0?1:(w?.slant??0)<0?-1:1;M={emphasis:Q,rawEmphasis:Q,scale:1+Q*.38,skewX:kt*Q*30*i,weightBoost:400*Q*i,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+Q*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:i,emphasisMultiplier:Q,fadeFactor:1,isInTail:!1}}}else{let rt=le({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:i,emotionAnimationDuration:V,wordBaseSlant:w?.slant||0,isActive:j,wordEmotion:v});st=rt.emphasisEffect,M=r?null:rt.strongEmphasisData}let A=Ht[X]??1,B=(w?.opacity??T.opacity??1)*A,q=(w?.scale??T.scale??1)*(st?.scaleMultiplier||1),ht=(w?.slant??T.slant??0)+(st?.slantAdditive||0),at=q,Ce=st?.weightBoost||0;M&&(ht+=M.skewX||0,Ce+=M.weightBoost||0,at=q*(M.scale||1));let z={...T,fontSize:x.fontSize,scale:at,slant:ht,stretchY:w?.stretchY??T.stretchY??1,weight:(w?.weight??T.weight??400)+Ce,width:w?.width??T.width??100,textColor:w?.textColor??T.textColor??x.textColor,opacity:B,translateX:w?.translateX??T.translateX??0,translateY:w?.translateY??T.translateY??0,textShadow:w?.textShadow??T.textShadow??"",blur:w?.blur??T.blur??0,outlineWidth:w?.outlineWidth??T.outlineWidth??0,outlineColor:w?.outlineColor??T.outlineColor??"#000000",letterShake:w?.fear??0,fontVariationAxes:{...T.fontVariationAxes,...w?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:w?.joy??0,urlFear:w?.fear??0,urlJoyProgress:w?.joyWaveProgress??0};r&&(z.translateX=-z.translateX,z.rotation=z.rotation?-z.rotation:0,z.slant=-z.slant,z.skewX!==void 0&&(z.skewX=-z.skewX));let It=v==="joy"?ue(O.length):null,Ge=It&&(It==="letter"||It==="letter-bulge")?Math.min(1.5,Math.max(0,(t-E)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:j,emotion:v,emotionIntensity:L,originalEmotionIntensity:N,fontFamily:Kt,emphasis:S.emphasis||0,emphasisEffect:st,strongEmphasis:M,animationParameters:z,joyAnimationMode:It,joyProgress:Ge}}),dt=o??F,xt=C?Math.max(C.end,dt):null,Tt=C&&t>=C.start&&t<=(xt||C.end),Mt=t>=E&&t<dt,_t=C?!!Tt:Mt;return{text:St(n),words:W,currentWordIndex:vt,emotion:_,emotionIntensity:b,fontFamily:Ut(_,i),startTime:C?.start||E,endTime:C?.end||F,isActive:_t}}function Oe(n,t,e,i){let s=typeof e=="string"?e:"word",r=typeof e=="string"?i||{}:e||{};return s==="sentence"?In(n,t,r):kn(n,t,r)}var U=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],qt={joy:U[0],anger:U[11],sadness:U[5],fear:U[4],disgust:U[7],surprise:U[6],social_positive:U[1],social_negative:U[7],lust:U[11],calmness:U[1],screaming:U[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function We(n){return qt[n.toLowerCase()]||qt.none}function je(n,{ttlMs:t=300*1e3}={}){let e=new Map,i=new Map,s=new Map;function r(l){let d=s.get(l);return!d||Date.now()-d>t}async function a(l="default"){if(!r(l)&&e.has(l))return e.get(l);if(i.has(l))return i.get(l);let d=(async()=>{try{let c=await n(l),C=new Map;if(Array.isArray(c))for(let f of c)f.emotion&&f.url&&f.is_active&&C.set(f.emotion.toLowerCase(),f.url);return e.set(l,C),s.set(l,Date.now()),C}catch(c){return console.warn("[publishedAnimationResolver] Failed to fetch active animations:",c?.message),e.get(l)||new Map}finally{i.delete(l)}})();return i.set(l,d),d}async function o(l,d="default"){return l&&(await a(d)).get(l.toLowerCase())||null}function m(l,d="default"){if(!l)return null;let c=e.get(d);return(!c||r(d))&&a(d),c?.get(l.toLowerCase())||null}function u(){e.clear(),i.clear(),s.clear()}return{prefetch:a,get:o,getSync:m,invalidate:u}}var Bn=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],Ne=["anger","fear","sadness","joy","disgust"];function Fn(n){let t=n.toLowerCase();return Ne.includes(t)?1.5:1}function Pn(n){return n.map(([t,e])=>{let i=Fn(t),s=e*i,r=Ne.includes(t.toLowerCase());return[t,e,s,i,r]})}function Ln(n,t=.2){if(!n||typeof n!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let e=Object.entries(n).filter(([u,l])=>Bn.includes(u.toLowerCase())&&typeof l=="number"&&l>t);if(e.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let s=Pn(e).sort(([,,u],[,,l])=>l-u),[r,a,,o,m]=s[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:s,importanceFactor:o,isCore:m}}function Rn(n){if(!n)return{startTime:0,endTime:0,duration:.01};let t=n.start_time||0,e=n.end_time||0;return{startTime:t,endTime:e,duration:Math.max(.01,e-t)}}function Dn(n,t,e){return Math.max(0,Math.min(1,(n-t)/e))}function On(n,t=.9){if(!n||!n.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let e=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),s=parseInt(n.slice(5,7),16);return`rgba(${e}, ${i}, ${s}, ${t})`}function Xe(n,t="",e="",i=1){return n&&n!=="#000000"&&n!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${On(n,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var Wn={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function jn(n){return x.fontSpacingAdjustments[n]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function $e(n=1,t="",e=1,i=""){let{min:s,max:r}=x.wordSpacing,a=parseFloat(s),o=parseFloat(r),u=jn(t).wordSpacingMultiplier;if(n<=1)return`${(a*u).toFixed(3)}em`;let l=Math.max(...Object.values(Wn)),d=Math.min(1,(n-1)/(l-1)),c=Math.pow(d,2),f=(a+(o-a)*c)*u;return i==="anger"||i==="screaming"?`${(f*.6).toFixed(3)}em`:`${f.toFixed(3)}em`}var Nn=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function Xn(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0;return Math.abs(t)%1e3/1e3}function Ue(n,t,e){if(!n)return 1;let i=(n.word||n.text||"").trim();if(!i)return 1;let s=i.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!s)return 1;if(Nn.has(s)||s.length<=2)return 0;let r=Math.min(1,s.length/7),a=Xn(s);return .5*r+.5*a<.55?0:1}function $n({strongEmphasisData:n,emphasisEffect:t,wordLetterShakeIntensity:e,wordFontFamily:i,currentTime:s,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:m=1,fontSize:u=16}){let l=new Array(m).fill(0);return l}function Un(n){return n.split("").map((t,e)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:e}))}function me(n,{minDeviation:t=.02,maxBlur:e=1.5,multiplier:i=1.5}={}){let s=Math.abs((n??1)-1);return s<=t?0:Math.min(e,s*i)}function Ye(n=0,t=1,e=1){let i=1-.5*Math.min(1,Math.max(0,e??0)),s=me(t)*i;return(n??0)+s}function zt(n,t,e,i,s){let a=(Math.max(t,Math.min(e,n))-t)/(e-t);return i+a*(s-i)}function Yn(n,t,e=null,i){if(!t)return i||400;let{min:s,max:r,default:a}=t;if(typeof n!="number"||isNaN(n))return i||a;let o,m;if(e?.mapping?.volume?(o=e.mapping.volume.min,m=e.mapping.volume.max):(o=s,m=r),i!==void 0){let u=(m-o)/4,l=zt(n,0,1,-u,u);return Math.round(Math.max(s,Math.min(r,i+l)))}return Math.round(zt(n,0,1,o,m))}function Vn(n,t,e){if(!t)return e||100;let{min:i,max:s,default:r}=t;if(typeof n!="number"||isNaN(n))return e||r;if(e!==void 0){let a=(s-i)/4,o=zt(1-n,0,1,-a,a);return Math.round(Math.max(i,Math.min(s,e+o)))}return Math.round(zt(1-n,0,1,i,s))}var Ve={},qe={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function de(n){if(!n)return;let t=n.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||Ve[t]||(Ve[t]=!0,typeof document>"u"))return;let e=qe[t],i=document.createElement("link");i.rel="stylesheet",i.href=e?`https://fonts.googleapis.com/css2?${e}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(i)}function ze(){Object.keys(qe).forEach(n=>de(n))}var Gt=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,e={}){let i=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,s=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...e.headers};s&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(i,{...e,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let u=await a.clone().json();if(u.message)o=u.message;else if(u.error)o=u.error;else if(Array.isArray(u.detail)){let l=u.detail.map(d=>{let c=Array.isArray(d.loc)?d.loc.filter(C=>C!=="body").join("."):"";return c?`${c}: ${d.msg||"invalid"}`:d.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof u.detail=="string"&&(o=u.detail)}catch{try{let u=await a.clone().text();u&&(o=u)}catch{}}let m=new Error(o);throw m.status=a.status,m.response=a,m}return a}async login(t,e){let s=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:e})})).json();if(!s.session_id||!s.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=s.auth_token,this.sessionId=s.session_id,s}async register(t,e,i,s){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:e,password:i,company:s.company,first_name:s.first_name,last_name:s.last_name})})).json()}async getSubtitleTrack(t,e,i){let s=new URLSearchParams;e&&typeof e=="string"&&e.trim()&&s.append("lang",e.trim()),i&&typeof i=="string"&&i.trim()&&s.append("model",i.trim());let r=s.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,e=10){return(await this.request(`/vods?skip=${t}&limit=${e}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};0&&(module.exports={ANIMATION_STYLING,ANIMATION_URLS,AUTHORED_PLAYBACK_OPTIONS,EMOTION_ANIMATION_URLS,PhontClient,REFERENCE_GTS,REFERENCE_INTENSITY,RENDERING_CONTROL,SubtitleManager,SubtitleStateManager,calculateAnimationParameters,calculateAnimationState,calculateDynamicWordSpacing,calculateEmphasisMultiplier,calculateGTSValues,calculateJoy,calculateJoyBulge,calculateNormalizedTime,calculateWeightFromVolume,calculateWidthFromSpeechRate,calculateWordEmphasisEffects,calculateWordLetterSpacing,capEmotionIntensity,computeProsodyWeight,createPublishedAnimationResolver,decodeAnimationUrl,ensureFont,findSubtitleForWord,generateTextShadow,getAnimationUrlForEmotion,getCombinedBlurAmount,getFontFamilyCSS,getJoyAnimationMode,getJoyFilter,getJoyTransform,getMergedSubtitles,getMotionBlurAmount,getSubtitleAnimations,getSubtitleText,getSubtitleTiming,getSubtitleWords,getWordEmphasis,hasMergedSubtitles,hockeyStickIntensity,isInEmphasisRange,isInStrongEmphasisRange,meetsEmotionThreshold,preloadAnimationFonts,processEmotionsWithImportance,resolveEffectiveGts,sampleParameterCurve,selectEmotion,selectFontFamily,shouldUseAngryFont,shouldUseJoyFont,shouldUseSadnessFont,splitTextIntoLetters,subtitleManager});
|
|
1
|
+
"use strict";var me=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var kn=Object.prototype.hasOwnProperty;var Fn=(e,t)=>{for(var n in t)me(e,n,{get:t[n],enumerable:!0})},Pn=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ln(t))!kn.call(e,i)&&i!==n&&me(e,i,{get:()=>t[i],enumerable:!(s=In(t,i))||s.enumerable});return e};var Bn=e=>Pn(me({},"__esModule",{value:!0}),e);var _i={};Fn(_i,{ANIMATION_STYLING:()=>w,ANIMATION_URLS:()=>U,AUTHORED_PLAYBACK_OPTIONS:()=>ze,EMOTION_ANIMATION_URLS:()=>Zt,NORMAL_ANIMATION_EMOTIONS:()=>Te,PhontClient:()=>re,REFERENCE_GTS:()=>yt,REFERENCE_INTENSITY:()=>fe,RENDERING_CONTROL:()=>p,SubtitleManager:()=>bt,SubtitleStateManager:()=>pt,buildSequentialExpressiveSchedule:()=>Ie,calculateAnimationParameters:()=>dt,calculateAnimationState:()=>an,calculateDynamicWordSpacing:()=>xe,calculateEmphasisMultiplier:()=>ge,calculateGTSValues:()=>qt,calculateJoy:()=>Hn,calculateJoyBulge:()=>Jn,calculateNormalizedTime:()=>pi,calculatePerWordSpacing:()=>mn,calculateWeightFromVolume:()=>Ti,calculateWidthFromSpeechRate:()=>Mi,calculateWordEmphasisEffects:()=>ve,calculateWordExpressiveProgress:()=>Sn,calculateWordLetterSpacing:()=>Ai,capEmotionIntensity:()=>he,clampAnimationIntensity:()=>Qt,clearSegmentAnimationFields:()=>Ee,clearWordAnimationFields:()=>_e,computeProsodyWeight:()=>An,createBitmovinLiveSegmentSource:()=>$e,createHlsLiveSegmentSource:()=>Ue,createLiveSegmentSource:()=>st,createPublishedAnimationResolver:()=>ln,createShakaLiveSegmentSource:()=>Xe,decodeAnimationUrl:()=>Yt,ensureFont:()=>ke,findSubtitleForWord:()=>Gt,generateTextShadow:()=>cn,getAnimationUrlForEmotion:()=>on,getCombinedBlurAmount:()=>xn,getCurrentAuthToken:()=>Dt,getCurrentSessionId:()=>Ot,getFontFamilyCSS:()=>Kt,getJoyAnimationMode:()=>we,getJoyFilter:()=>Qn,getJoyTransform:()=>Zn,getManualAnimationsStorageKey:()=>ee,getManualSoundbitesStorageKey:()=>ne,getMergedSubtitles:()=>xt,getMotionBlurAmount:()=>Le,getSegmentAnimationPreviewTime:()=>vn,getSubtitleAnimations:()=>At,getSubtitleText:()=>wt,getSubtitleTiming:()=>gi,getSubtitleWords:()=>zt,getWordAnimationPreviewTime:()=>wn,getWordEmphasis:()=>Ze,getWordExpressiveDuration:()=>Tt,hasMergedSubtitles:()=>Q,hasSegmentAnimationOverride:()=>te,hasWordAnimationOverride:()=>Ct,hockeyStickIntensity:()=>Ve,isInEmphasisRange:()=>pe,isInStrongEmphasisRange:()=>be,isNormalAnimationEmotion:()=>Me,isSubtitleDebugEnabled:()=>Ce,isWordAnimationOverlapAllowed:()=>ie,logSubtitleData:()=>$t,meetsEmotionThreshold:()=>Vn,preloadAnimationFonts:()=>_n,processEmotionsWithImportance:()=>vt,readManualAnimationsPreference:()=>hn,readManualSoundbitesPreference:()=>pn,resetSubtitleToNormal:()=>Cn,resolveEffectiveGts:()=>St,resolveWordAnimationSource:()=>dn,sampleParameterCurve:()=>mt,scaleAuthorAnimationIntensities:()=>yn,selectEmotion:()=>hi,selectFontFamily:()=>Qe,shouldUseAngryFont:()=>ni,shouldUseJoyFont:()=>ii,shouldUseSadnessFont:()=>si,splitTextIntoLetters:()=>xi,subtitleHasAnyAnimationOverride:()=>fn,subtitleManager:()=>je,writeManualAnimationsPreference:()=>gn,writeManualSoundbitesPreference:()=>bn});module.exports=Bn(_i);var pt=class{constructor(){this.subscribers=new Set,this.state={videoTimeSeed:null,isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,currentTime:0,liveStartTime:null,liveCurrentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}notify(){this.subscribers.forEach(t=>t(this.state))}getState(){return{...this.state}}getVodState(){return{...this.vodState}}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleSoundbites(t,n){t==="all"?this.state.showAllSoundbites=n:t==="important"&&(this.state.showImportantSoundbites=n),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateCurrentTime(t){this.state.currentTime=t,this.notify()}updateSubtitles(t){this.state.subtitles=t,this.notify()}updateCurrentSubtitleData(t){this.state.currentSubtitleData=t,this.notify()}updateSoundbites(t,n,s){t!==void 0&&(this.state.soundByteAll=t),n!==void 0&&(this.state.soundByteImportant=n),s!==void 0&&(this.state.soundByteFiltered=s),this.notify()}updateSoundbiteAnimations(t){this.state.soundbiteAnimations=t,this.notify()}updateVodSubtitles(t){this.vodState.subtitles=t,this.notify()}updateVodLanguage(t){this.vodState.currentLanguage=t,this.notify()}updateVodVideoId(t){this.vodState.videoId=t,this.notify()}updateVodSoundbites(t,n,s){t!==void 0&&(this.vodState.soundByteAll=t),n!==void 0&&(this.vodState.soundByteImportant=n),s!==void 0&&(this.vodState.soundByteFiltered=s),this.notify()}updateLiveStartTime(t){this.state.liveStartTime=t,this.notify()}updateLiveCurrentTime(t){this.state.liveCurrentTime=t,this.notify()}updateVideoTimeSeed(t){this.state.videoTimeSeed=t,this.notify()}markSequenceProcessed(t){this.state.processedSequences.add(t)}isSequenceProcessed(t){return this.state.processedSequences.has(t)}setInitialSequenceOffset(t){this.state.initialSequenceOffset=t}setSegmentDuration(t,n){this.state.segmentDurations.set(t,n)}getSegmentDuration(t){return this.state.segmentDurations.get(t)}updateCurrentSequence(t){this.state.currentSequence=t,this.notify()}reset(){this.state={isVisible:!0,isKaraokeMode:!1,currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,liveStartTime:null,liveCurrentTime:0,showAllSoundbites:!0,showImportantSoundbites:!1,isClosedCaptionsEnabled:!1,videoTimeSeed:null,isSpeaker:!1,animationMode:"Sentence",currentTime:0,soundbiteAnimations:[],showSoundbiteAnimations:!0,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.notify()}clearLiveState(){this.state.subtitles=[],this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.processedSequences=new Set,this.state.initialSequenceOffset=null,this.state.lastEndTime=0,this.state.segmentDurations=new Map,this.state.soundByteAll=[],this.state.soundByteImportant=[],this.state.soundByteFiltered=[],this.state.liveStartTime=null,this.state.liveCurrentTime=0,this.state.videoTimeSeed=null,this.notify()}clearVodState(){this.vodState={subtitles:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:null,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}};var Bt=class{constructor(){this._subtitleCache=new Map,this._loadingLanguages=new Set}get(t){let n=t||"original";return this._subtitleCache.get(n)}set(t,n){let s=t||"original";this._subtitleCache.set(s,{data:n,timestamp:Date.now()})}isLoading(t){return this._loadingLanguages.has(t)}startLoading(t){this._loadingLanguages.add(t)}finishLoading(t){this._loadingLanguages.delete(t)}clear(){this._subtitleCache.clear()}detectLanguageFromText(t){if(!t)return null;let n=["der","die","das","und","in","den","von","mit","sich","auf","f\xFCr","ist","im","ein","auch","als","an","nach","wie","bei","es","nur","oder","aber","vor","durch","k\xF6nnen","schon","wenn","haben","ihre","dann","unter","wir","soll","sein","einer","mir","\xFCber","so","keine","heute","seine","dem","muss","wird","doch","kann","gegen","vom","alle","m\xFCssen"],s=["i","w","na","z","do","\u017Ce","a","o","u","za","od","po","przez","nad","pod","przed","mi\u0119dzy","obok","ko\u0142o","przy","bez","dla","ku","przeciw","wobec","wzgl\u0119dem","wed\u0142ug","dzi\u0119ki","wbrew","mimo","opr\xF3cz","zamiast","jako","jak","gdy","gdy\u017C","bo","ale","lecz","jednak","natomiast","za\u015B","wi\u0119c","zatem","dlatego","przeto","tote\u017C","zreszt\u0105","poza","tym","bowiem","albowiem","poniewa\u017C","skoro","je\u015Bli","gdyby","cho\u0107","chocia\u017C"],i=["the","and","to","of","a","in","is","it","you","that","he","was","for","on","are","as","with","his","they","at","be","this","have","from","or","one","had","by","word","but","not","what","all","were","we","when","your","can","said","there","use","an","each","which","she","do","how","their","if","will","up","other","about","out","many","then","them","these","so","some","her","would","make","like","into","him","time","has","two","more","go","no","way","could","my","than","first","been","call","who","its","now","find","long","down","day","did","get","come","made","may","part"],r=t.toLowerCase().split(/\s+/),a=r.length;if(a===0)return null;let o=0,c=0,m=0;r.forEach(h=>{n.includes(h)&&o++,s.includes(h)&&c++,i.includes(h)&&m++});let l=o/a,d=c/a,u=m/a,C=.1;return l>C&&l>d&&l>u?"de":d>C&&d>l&&d>u?"pl":u>C&&u>l&&u>d?"en-US":null}};var Dn="phont_session_",On="phont_current_user";function Pe(e){return`${Dn}${e}`}function Be(){try{return localStorage.getItem(On)}catch(e){return console.error("Failed to get current user:",e),null}}function De(e){if(!e)return null;try{let t=localStorage.getItem(Pe(e));if(!t)return null;let n=JSON.parse(t);return!n.sessionId||!n.authToken||!n.username?(console.warn("Invalid session data found in storage"),Nn(e),null):n}catch(t){return console.error("Failed to retrieve session:",t),null}}function Rn(e){let t=De(e);return t?t.authToken:null}function Wn(e){let t=De(e);return t?t.sessionId:null}function Nn(e){if(e)try{localStorage.removeItem(Pe(e))}catch(t){console.error("Failed to clear session:",t)}}function Dt(){let e=Be();return e?Rn(e):null}function Ot(){let e=Be();return e?Wn(e):null}var ct=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"",jn=process.env.NEXT_PUBLIC_SUBTITLE_SOURCE||"api";function de(){return jn==="sidecar"}var Rt=class{constructor(t,n){this._liveMasterUrl=null;this.stateManager=t,this._audioPlaylistCache=null,this.phontClient=n||null}setPhontClient(t){this.phontClient=t}setLiveMasterUrl(t){this._liveMasterUrl=t}normalizeSubtitles(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:t&&Array.isArray(t.subtitles)?t.subtitles.length>0&&!Array.isArray(t.subtitles[0])&&typeof t.subtitles[0]=="object"?[t.subtitles]:t.subtitles:[]}normalizeSoundbites(t){return Array.isArray(t)?t.length>0&&!Array.isArray(t[0])&&typeof t[0]=="object"?[t]:t:[]}async parseHLSMasterManifest(t){try{let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch master manifest: ${n.status}`);let i=(await n.text()).split(`
|
|
2
|
+
`);for(let r of i)if(r.includes("#EXT-X-MEDIA:TYPE=AUDIO")&&r.includes("URI=")){let a=r.match(/URI="([^"]+)"/);if(a){let o=a[1];return o.startsWith("http")?o:`${t.substring(0,t.lastIndexOf("/"))}/${o}`}}throw new Error("No audio stream found in manifest")}catch(n){throw n}}async parseHLSMasterManifestForSubtitles(t){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch master manifest: ${n.status}`);let i=(await n.text()).split(`
|
|
3
|
+
`);for(let r of i)if(r.includes("#EXT-X-MEDIA:TYPE=SUBTITLES")&&r.includes("URI=")){let a=r.match(/URI="([^"]+)"/);if(a){let o=a[1];return o.startsWith("http")?o:`${t.substring(0,t.lastIndexOf("/"))}/${o}`}}throw new Error("No SUBTITLES rendition found in master manifest")}_getSidecarStreamInfo(t){let n=t.lastIndexOf("/"),s=t.substring(0,n),r=t.substring(n+1).replace(/_phont\.m3u8$/,"");return{base:s,streamId:r}}async parseAudioPlaylist(t){try{let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch audio playlist: ${n.status}`);let s=await n.text(),i=new Map,r=s.split(`
|
|
4
|
+
`),a=0;for(let o of r)if(o.startsWith("#EXT-X-MEDIA-SEQUENCE:")){a=parseInt(o.split(":")[1]);break}for(let o of r)if(o.startsWith("#EXTINF:")){let c=o.match(/#EXTINF:([0-9.]+)/);if(c){let m=parseFloat(c[1]);i.set(a,m),a++}}return i}catch(n){throw n}}async getAudioSegmentDuration(t){try{if(!this._audioPlaylistCache||Date.now()-this._audioPlaylistCache.timestamp>this._audioPlaylistCache.ttl){let s=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!s)throw new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let i=de()?await this.parseHLSMasterManifestForSubtitles(s):await this.parseHLSMasterManifest(s),r=await this.parseAudioPlaylist(i);this._audioPlaylistCache={segmentDurations:r,timestamp:Date.now(),ttl:3e4}}let n=this._audioPlaylistCache.segmentDurations.get(t);return n!==void 0?n:10}catch{return 10}}clearAudioPlaylistCache(){this._audioPlaylistCache=null}async getInitialLiveSequenceNumber(){try{let t=process.env.NEXT_PUBLIC_API_LIVE_URL;if(!t)throw console.error("[SubtitleFetcher] NEXT_PUBLIC_API_LIVE_URL not configured"),new Error("NEXT_PUBLIC_API_LIVE_URL not configured");let n=de()?await this.parseHLSMasterManifestForSubtitles(t):await this.parseHLSMasterManifest(t),r=(await this.parseAudioPlaylist(n)).keys().next();return!r.done&&typeof r.value=="number"?r.value:(console.warn("[SubtitleFetcher] No segments found in playlist, falling back to 0"),null)}catch(t){return console.error("[SubtitleFetcher] Failed to get initial sequence number:",t),null}}async fetchSubtitles(t){try{if(this.stateManager.isSequenceProcessed(t))return this.stateManager.state.subtitles;let n;if(this._liveMasterUrl!==null||de()){let i=this._liveMasterUrl||process.env.NEXT_PUBLIC_API_LIVE_URL;if(!i)throw new Error("Live master URL not configured. Call subtitleManager.setLiveMasterUrl(url) or set NEXT_PUBLIC_API_LIVE_URL.");let{base:r,streamId:a}=this._getSidecarStreamInfo(i),o=`${r}/${a}_subtitle${t}.json`,c=await fetch(o);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);n={subtitles:(await c.json()).cues||[],soundbite:void 0}}else if(this.phontClient){if(!ct&&!this.phontClient.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide apiBaseUrl to PhontClient.");let i=ct||this.phontClient.apiBaseUrl,r=await fetch(`${i}/subtitles/${t}`,{headers:{"Content-Type":"application/json",...this.phontClient.getAuthHeaders()}});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);n=await r.json()}else{if(!ct)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let i=await fetch(`${ct}/subtitles/${t}`,{headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);n=await i.json()}return this.stateManager.markSequenceProcessed(t),this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t),n}catch{return null}}async fetchSubtitleData(t,n=null){if(this.stateManager.clearVodState(),!!t)try{let s,i;if(this.phontClient)if(t.startsWith("http")){let r=new URL(t),a=r.pathname.split("/"),o=a.indexOf("vod-subtitles");i=o>=0&&a[o+1]?a[o+1]:t.split("/").pop().split("?")[0];let c=r.searchParams.get("lang")||n||void 0,m=r.searchParams.get("model")||void 0;try{s=await this.phontClient.getSubtitleTrack(i,c||null,m||null)}catch(l){let d=l?.status||l?.response?.status||(l?.response&&typeof l.response=="object"&&"status"in l.response?l.response.status:null),u=typeof l?.message=="string"?l.message:String(l||""),C=d===404||u.includes("404")||u.includes("Not Found"),h=d===400||u.includes("400")||u.includes("Bad Request")||u.includes("HTTP error! status: 400");if(C||h)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${i} (${C?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:i};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",l),l}}else{i=t;let r=n&&n.trim()||void 0;try{s=await this.phontClient.getSubtitleTrack(i,r)}catch(a){let o=a?.status||a?.response?.status||(a?.response&&typeof a.response=="object"&&"status"in a.response?a.response.status:null),c=typeof a?.message=="string"?a.message:String(a||""),m=o===404||c.includes("404")||c.includes("Not Found"),l=o===400||c.includes("400")||c.includes("Bad Request")||c.includes("HTTP error! status: 400");if(m||l)return console.warn(`[SubtitleFetcher] Subtitles not available for VOD: ${i} (${m?"404":"400"}) - This VOD may not have subtitles available`),{data:{subtitles:[]},videoId:i};throw console.error("[SubtitleFetcher] Error fetching from PhontClient:",a),a}}else{let r;if(t.startsWith("http")){r=t;let l=t.match(/\/vod-subtitles\/([^/?]+)/);i=l?l[1]:t.split("/").pop().split("?")[0]}else{if(i=t,!ct&&!this.phontClient?.apiBaseUrl)throw new Error("API base URL is not configured. Set NEXT_PUBLIC_API_SUB_BASE_URL or provide PhontClient with apiBaseUrl.");let l=ct||this.phontClient?.apiBaseUrl,d=new URLSearchParams;n&&typeof n=="string"&&n.trim()&&d.append("lang",n.trim());let u=d.toString();r=u?`${l}/vod-subtitles/${i}?${u}`:`${l}/vod-subtitles/${i}`}let a={"Content-Type":"application/json"},o=Dt(),c=Ot();o&&(a.Authorization=`Bearer ${o}`),c&&(a["X-Session-ID"]=c);let m=await fetch(r,{headers:a,cache:"no-store"});if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);s=await m.json()}return this.stateManager.updateVodVideoId(i),{data:s,videoId:i}}catch(s){throw this.stateManager.clearVodState(),s}}};var Oe={"Camera clicking":"CameraClicking.json","Camera click":"CameraClicking.json","Camera shutter":"CameraClicking.json","Single-lens reflex camera":"CameraClicking.json",Breaking:"Crack.json","Smash, crash":"Crack.json","Trickle, dribble":"Crack.json",Crackle:"Crack.json",Shatter:"Crack.json",Crack:"Crack.json","Burst, pop":"Crack.json",Splinter:"Crack.json","Glass Shatter":"Crack.json",Siren:"Siren.json","Glass shatter":"Siren.json","Emergency vehicle":"Siren.json","Civil defense siren":"Siren.json","Fire alarm":"Siren.json","Police car (siren)":"Siren.json","Fire engine, fire truck (siren)":"Siren.json",Alarm:"Siren.json","Car alarm":"Siren.json","Ambulance (siren)":"Siren.json","Smoke detector, smoke alarm":"Siren.json",Vibration:"Vibration.json",Engine:"EngineSound.json","Engine sound":"EngineSound.json","Accelerating, revving, vroom":"EngineSound.json",Vehicle:"EngineSound.json",Gunshot:"Gunshot.json","Gunshot, gunfire":"Gunshot.json",Gunfire:"Gunshot.json","Machine gun":"Gunshot.json",Knocking:"Knocking.json",Knock:"Knocking.json","Door knock":"Knocking.json",Banging:"Knocking.json","Mines Exploading":"MinesExploading.json",Explosion:"MinesExploading.json",Explode:"MinesExploading.json",Bomb:"MinesExploading.json",Blast:"MinesExploading.json","Crowd Cheering":"CrowdCheering.json","Crowd cheering":"CrowdCheering.json",Cheering:"CrowdCheering.json",Cheer:"CrowdCheering.json",Applause:"CrowdCheering.json",Clapping:"CrowdCheering.json",Crowd:"CrowdCheering.json",Screaming:"Screaming.json",Scream:"Screaming.json",Shriek:"Screaming.json",Yell:"Screaming.json",Laughter:"Laughter"};var Wt=class{constructor(t){this.stateManager=t,this.activeSoundbiteSession=null}mapEventLabelToAnimation(t){if(!t)return null;let n=t.toLowerCase().replace(/[\s\-_]+/g,"");for(let[s,i]of Object.entries(Oe)){let r=s.toLowerCase().replace(/[\s\-_]+/g,"");if(n===r)return i}return null}processSoundbiteAnimations(t){let n=[];if(t.important&&Array.isArray(t.important))for(let s of t.important){let i=this.mapEventLabelToAnimation(s.event_label);i&&n.push({id:`important_${s.event_label}_${s.start_time||s.onset}`,eventLabel:s.event_label,animationFile:i,startTime:s.start_time||s.onset,endTime:s.end_time||s.offset,priority:"important",isActive:!1})}if(n.length===0&&t.all&&Array.isArray(t.all))for(let s of t.all){let i=this.mapEventLabelToAnimation(s.event_label);i&&n.push({id:`all_${s.event_label}_${s.start_time||s.onset}`,eventLabel:s.event_label,animationFile:i,startTime:s.start_time||s.onset,endTime:s.end_time||s.offset,priority:"all",isActive:!1})}return n}mergeAnimations(t){if(t.length===0)return;let n=this.stateManager.state.soundbiteAnimations;t.forEach(s=>{if(s.animationFile==="Laughter"){let i=n.find(r=>r.animationFile==="Laughter"&&Math.abs(r.endTime-s.startTime)<=1);if(i){i.endTime=Math.max(i.endTime,s.endTime);return}}n.push(s)})}getActiveSoundbiteAnimations(t=!1){let n=this.stateManager.state.currentTime,s=2,i=[];if(this.activeSoundbiteSession){let{extendedEndTime:o}=this.activeSoundbiteSession;if(o!==void 0&&n<o)return[this.activeSoundbiteSession];this.activeSoundbiteSession=null}if(t){if(this.stateManager.vodState.soundByteImportant&&this.stateManager.vodState.soundByteImportant.length>0)for(let o of this.stateManager.vodState.soundByteImportant){let c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;n>=m&&n<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"important",isActive:!0,extendedEndTime:u})}}if(this.stateManager.vodState.soundByteAll&&this.stateManager.vodState.soundByteAll.length>0)for(let o of this.stateManager.vodState.soundByteAll){let c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;n>=m&&n<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"all",isActive:!0,extendedEndTime:u})}}if(this.stateManager.vodState.soundByteFiltered&&this.stateManager.vodState.soundByteFiltered.length>0)for(let o of this.stateManager.vodState.soundByteFiltered){let c=this.mapEventLabelToAnimation(o.event_label);if(c){let m=o.onset??o.start_time??0,l=o.offset??o.end_time??0,u=l-m<s?m+s:l;n>=m&&n<=u&&i.push({id:`vod_${o.event_label}_${m}`,eventLabel:o.event_label,animationFile:c,startTime:m,endTime:u,originalEndTime:l,priority:"filtered",isActive:!0,extendedEndTime:u})}}}else{let o=[...this.stateManager.state.soundByteImportant||[],...this.stateManager.state.soundByteAll||[],...this.stateManager.state.soundByteFiltered||[]];for(let c of o){let m=this.mapEventLabelToAnimation(c.event_label);if(m){let l=c.start_time??c.onset??0,d=c.end_time??c.offset??0;if(n>=l&&n<=d){let C="all";this.stateManager.state.soundByteImportant?.includes(c)?C="important":this.stateManager.state.soundByteFiltered?.includes(c)&&(C="filtered"),i.push({id:`live_${c.event_label}_${l}`,eventLabel:c.event_label,animationFile:m,startTime:l,endTime:d,priority:C,isActive:!0})}}}}let r={Laughter:1,important:2,all:3,filtered:4};i.sort((o,c)=>{let m=o.eventLabel==="Laughter"?1:r[o.priority]||5,l=c.eventLabel==="Laughter"?1:r[c.priority]||5;return m-l});let a=i.slice(0,1);return a.length>0&&(this.activeSoundbiteSession=a[0]),a}getAllSoundbiteData(t=!1){let n=i=>Array.isArray(i)?i.length>0&&Array.isArray(i[0])?i.flat():i:[];return t?{all:n(this.stateManager.vodState.soundByteAll||[]),important:n(this.stateManager.vodState.soundByteImportant||[]),filtered:n(this.stateManager.vodState.soundByteFiltered||[])}:{all:n(this.stateManager.state.soundByteAll||[]),important:n(this.stateManager.state.soundByteImportant||[]),filtered:n(this.stateManager.state.soundByteFiltered||[])}}getActiveSoundbites(t=!1,n=null){let s=[],i=[],r=n??this.stateManager.state.currentTime;if(this.stateManager.state.showAllSoundbites)if(t){let a=this.stateManager.vodState.soundByteAll.filter(o=>r>=o.onset&&r<=o.offset);s.push(...a)}else{let a=this.stateManager.state.soundByteAll.filter(o=>r>=o.start_time&&r<=o.end_time);s.push(...a)}if(this.stateManager.state.showImportantSoundbites)if(t){let a=this.stateManager.vodState.soundByteImportant.filter(o=>r>=o.onset&&r<=o.offset);i.push(...a)}else{let a=this.stateManager.state.soundByteImportant.filter(o=>r>=o.start_time&&r<=o.end_time);i.push(...a)}return{all:s.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time)),important:i.sort((a,o)=>(a.onset||a.start_time)-(o.onset||o.start_time))}}hasActiveAnimations(){return this.stateManager.state.soundbiteAnimations.some(t=>t.isActive)}clearSoundbiteAnimations(){this.stateManager.state.soundbiteAnimations=[],this.stateManager.notify()}clearOldAnimations(t,n=30){let s=t-n,i=this.stateManager.state.soundbiteAnimations.length;this.stateManager.state.soundbiteAnimations=this.stateManager.state.soundbiteAnimations.filter(r=>r.endTime>=s),this.stateManager.state.soundbiteAnimations.length<i&&this.stateManager.notify()}};var Nt=class{constructor(t,n,s){this.stateManager=t,this.fetcher=n,this.soundbiteProcessor=s}processVodData(t,n,s,i){let r=n.split("/").pop()?.split("?")[0],a=this.fetcher.normalizeSubtitles(t),o=t.sequence_number||t.vod_id||(n?n.split("/").pop()?.split("?")[0]:void 0),c=a.flat().map(h=>({...h,sequence_number:o}));i&&i.length>0&&(c=this._mergeAnimationDataFromOriginal(c,i));let m=this._deduplicateSubtitles(c),{soundByteAll:l,soundByteImportant:d,soundByteFiltered:u}=this._processSoundbites(t.soundbite);if(l.length>0||d.length>0||u.length>0){let h={all:l,important:d,filtered:u},f=this.soundbiteProcessor.processSoundbiteAnimations(h);this.stateManager.state.soundbiteAnimations=[...this.stateManager.state.soundbiteAnimations,...f]}let C=t.language||s||null;this.stateManager.vodState={subtitles:m,url:n,currentSubtitle:"",currentSubtitleData:null,currentSequence:o,soundByteAll:l,soundByteImportant:d,soundByteFiltered:u,currentLanguage:C,videoId:r,translation_provider:t.translation_provider||null,translation_model:t.translation_model||null,stylesheet:t.stylesheet||null},this.stateManager.notify()}_mergeAnimationDataFromOriginal(t,n){let s=new Map;for(let i of n){let r=`${i.start_time}-${i.end_time}`;(!s.has(r)||i.animations||i.emotion)&&s.set(r,i)}return t.map(i=>{let r=`${i.start_time}-${i.end_time}`,a=s.get(r);if(!a)return i;let o=i.animations&&typeof i.animations=="object"&&Object.keys(i.animations).length>0,c=i.emotion&&i.emotion!=="none"&&i.emotion!=="neutral",m=typeof i.animation_url=="string"&&i.animation_url.length>0;if(o&&m)return i;let l={...i};if(!o&&a.animations&&typeof a.animations=="object"&&Object.keys(a.animations).length>0&&(l.animations=a.animations),!c&&a.emotion&&(l.emotion=a.emotion,typeof a.emotion_intensity=="number"&&(l.emotion_intensity=a.emotion_intensity)),!m&&typeof a.animation_url=="string"&&a.animation_url.length>0&&(l.animation_url=a.animation_url),l.words&&Array.isArray(l.words)&&a.words&&Array.isArray(a.words)){let d=new Map;for(let u of a.words)d.set(`${u.start}-${u.end}`,u);l.words=l.words.map(u=>{let C=d.get(`${u.start}-${u.end}`);if(!C||u.animations&&typeof u.animations=="object"&&Object.keys(u.animations).length>0)return u;let f={...u};return C.animations&&Object.keys(C.animations).length>0&&(f.animations=C.animations),!f.emotion&&C.emotion&&(f.emotion=C.emotion,typeof C.emotion_intensity=="number"&&(f.emotion_intensity=C.emotion_intensity)),!f.animation_url&&C.animation_url&&(f.animation_url=C.animation_url),f})}return l})}_deduplicateSubtitles(t){let n=new Map;for(let s of t){let i=`${s.start_time}-${s.end_time}`;(!n.has(i)||s.emotion||s.animations)&&n.set(i,s)}return Array.from(n.values())}_processSoundbites(t){let n=[],s=[],i=[];return t&&(t.all&&Array.isArray(t.all)&&(n=this.fetcher.normalizeSoundbites(t.all).flatMap(a=>a.map(o=>({...o})))),t.important&&Array.isArray(t.important)&&(s=this.fetcher.normalizeSoundbites(t.important).flatMap(a=>a.map(o=>({...o})))),t.filtered&&Array.isArray(t.filtered)&&(i=this.fetcher.normalizeSoundbites(t.filtered).flatMap(a=>a.map(o=>({...o}))))),{soundByteAll:n,soundByteImportant:s,soundByteFiltered:i}}};var jt=class{constructor(t,n,s){this.stateManager=t,this.soundbiteProcessor=n,this.liveTimeGenerator=s}async processLiveSegment(t,n,s){this.stateManager.state.processedSequences.add(n),this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=s);let i=this.stateManager.state.videoTimeSeed;this.stateManager.state.initialSequenceOffset===null&&(this.stateManager.state.initialSequenceOffset=n);let r=s-i,a=this._processSubtitles(t.subtitles,n,r),{processedSoundbitesAll:o,processedSoundbitesImportant:c,processedSoundbitesFiltered:m}=this._processSoundbites(t.soundbite,r);this._updateState(a,o,c,m);let l={all:o,important:c,filtered:m},d=this.soundbiteProcessor.processSoundbiteAnimations(l);return this.soundbiteProcessor.mergeAnimations(d),a.length>0&&(this.stateManager.state.lastEndTime=Math.max(...a.map(u=>u.end_time))),this.stateManager.notify(),t}_processSubtitles(t,n,s){return!t||!Array.isArray(t)?[]:t.map(i=>({...i,sequence_number:n,start_time:i.start_time+s,end_time:i.end_time+s,words:i.words?i.words.map(r=>({...r,start:r.start+s,end:r.end+s})):void 0}))}_processSoundbites(t,n){let s=(t?.all||[]).map(a=>({...a,start_time:a.onset+n,end_time:a.offset+n})),i=(t?.important||[]).map(a=>({...a,start_time:a.onset+n,end_time:a.offset+n})),r=(t?.filtered||[]).map(a=>({...a,start_time:a.onset+n,end_time:a.offset+n}));return{processedSoundbitesAll:s,processedSoundbitesImportant:i,processedSoundbitesFiltered:r}}_updateState(t,n,s,i){this.stateManager.state.subtitles=[...this.stateManager.state.subtitles,...t],this.stateManager.state.soundByteAll=[...this.stateManager.state.soundByteAll,...n],this.stateManager.state.soundByteImportant=[...this.stateManager.state.soundByteImportant,...s],this.stateManager.state.soundByteFiltered=[...this.stateManager.state.soundByteFiltered,...i]}};var Ut=class{constructor(t){this.stateManager=t,this.liveTimingInterval=null,this.pausedAt=null}updateLiveTime(t=null){let n=Date.now();this.stateManager.state.liveStartTime===null?(this.stateManager.state.liveStartTime=n,this.stateManager.state.liveCurrentTime=0):this.stateManager.state.liveCurrentTime=(n-this.stateManager.state.liveStartTime)/1e3,t!==null?(this.stateManager.state.videoTimeSeed===null&&(this.stateManager.state.videoTimeSeed=t),this.stateManager.state.currentTime=t-this.stateManager.state.videoTimeSeed):this.stateManager.state.currentTime=this.stateManager.state.liveCurrentTime,this.stateManager.notify()}startLiveTiming(){this.liveTimingInterval&&clearInterval(this.liveTimingInterval),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.updateLiveTime(),this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}stopLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null)}pauseLiveTiming(){this.liveTimingInterval&&(clearInterval(this.liveTimingInterval),this.liveTimingInterval=null,this.pausedAt=Date.now())}resumeLiveTiming(){if(!this.liveTimingInterval&&this.pausedAt&&this.stateManager.state.liveStartTime){let t=Date.now()-this.pausedAt;this.stateManager.state.liveStartTime+=t,this.pausedAt=null,this.liveTimingInterval=setInterval(()=>{this.updateLiveTime()},100)}}resetLiveStream(t){if(this.stopLiveTiming(),this.stateManager.state.liveStartTime=null,this.stateManager.state.liveCurrentTime=0,this.pausedAt=null,this.stateManager.state.subtitles=[],this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.state.processedSequences=new Set,this.stateManager.state.initialSequenceOffset=null,this.stateManager.state.lastEndTime=0,this.stateManager.state.segmentDurations=new Map,this.stateManager.state.soundByteAll=[],this.stateManager.state.soundByteImportant=[],this.stateManager.state.soundByteFiltered=[],t&&t.src){let n=t.src,s=!t.paused;t.src="",t.load(),setTimeout(()=>{t.src=n,t.load(),s&&t.play()},400)}this.stateManager.notify()}getLiveTime(){return this.stateManager.state.liveCurrentTime}getCumulativeDuration(t){let n=0;for(let s=this.stateManager.state.initialSequenceOffset;s<t;s++){let i=this.stateManager.state.segmentDurations.get(s)||10;n+=i}return n}};var Xt=class{constructor(t){this.stateManager=t,this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}_processSubtitleText(t,n){if(!t)return null;let i=t.subtitle??t.text??"";if(this.stateManager.state.isKaraokeMode&&Array.isArray(t.words)&&t.words.length>0){let r=[];for(let a of t.words)if(n>=a.start)r.push(a.word);else break;i=r.join(" ")}return{activeSubtitle:t,displayText:i}}getSubtitleAtTime(t){let n=this.stateManager.vodState;if(!n.subtitles||n.subtitles.length===0)return null;let s=!this._vodLastSubtitleTime||Math.abs(t-this._vodLastSubtitleTime)>=.1;if(!s&&this._vodLastSubtitleData&&t>=this._vodLastSubtitleData.start_time&&t<=this._vodLastSubtitleData.end_time)return this._vodLastSubtitleTime=t,this._vodLastSubtitleData;let i=n.subtitles.find(r=>t>=r.start_time&&t<=r.end_time);if(i){let r=this._processSubtitleText(i,t);if(!r)return null;let{activeSubtitle:a,displayText:o}=r,c=n.currentSubtitle!==o||n.currentSubtitleData!==a;return c&&(n.currentSubtitle=o,n.currentSubtitleData=a,n.currentSequence=n.url?.split("/").pop()||"vod",this.stateManager.state.currentSubtitle=o,this.stateManager.state.currentSubtitleData=a,this.stateManager.state.currentSequence=n.currentSequence??null),(s||c)&&this.stateManager.notify(),this._vodLastSubtitleData=a,this._vodLastSubtitleTime=t,a}return n.currentSubtitle!==""&&(n.currentSubtitle="",n.currentSubtitleData=null,this.stateManager.state.currentSubtitle="",this.stateManager.state.currentSubtitleData=null,this.stateManager.notify()),this._vodLastSubtitleData=null,this._vodLastSubtitleTime=t,null}getLiveSubtitleAtTime(){let t=this.stateManager.state;if(!t.subtitles||t.subtitles.length===0)return null;let n=t.subtitles.find(s=>t.currentTime>=s.start_time&&t.currentTime<=s.end_time);if(n){t.currentSequence=n.sequence_number??null;let s=this._processSubtitleText(n,t.currentTime);if(!s)return null;let{activeSubtitle:i,displayText:r}=s;return(t.currentSubtitle!==r||t.currentSubtitleData!==i)&&(t.currentSubtitle=r,t.currentSubtitleData=i,this.stateManager.notify()),this._lastSubtitleData=i,this._lastSubtitleTime=t.currentTime,i}return t.currentSubtitle!==""&&(t.currentSubtitle="",t.currentSubtitleData=null,this.stateManager.notify()),null}clearCache(){this._vodLastSubtitleData=null,this._vodLastSubtitleTime=0,this._lastSubtitleData=null,this._lastSubtitleTime=0}};var Re=new Set;function Ce(){if(typeof window>"u")return!1;let e=window.location.search;if(e.includes("debug=subtitles")||e.includes("stage_debug=subtitles"))return!0;try{return localStorage.getItem("phont_debug_subtitles")==="1"}catch{return!1}}function We(e){if(!e||typeof e!="object")return null;let t=e.subtitles;return Array.isArray(t)?t.flatMap(n=>Array.isArray(n)?n:[n]).length:null}function Un(){if(window.__phontSubtitleDebug)return window.__phontSubtitleDebug;let e={enabled:!0,last:null,dumpLast(){let t=e.last;if(!t)return console.warn("[vod-subtitles] No fetch recorded yet."),null;let n=We(t.raw),s=n!=null?`${n} segments`:"see payload";return console.log(`%c[vod-subtitles] ${s}`,"font-weight:bold;font-size:12px",t.raw),t},async copyLast(){let t=e.last;if(!t)throw new Error("No subtitle fetch recorded yet.");let n=JSON.stringify(t.raw,null,2);try{await navigator.clipboard.writeText(n),console.info("[vod-subtitles] Copied JSON to clipboard.")}catch{console.log(n)}return n}};return window.__phontSubtitleDebug=e,e}function $t(e,t){if(!Ce()||typeof window>"u")return;let n=`${t?.vodId??""}|${t?.url??""}`;if(Re.has(n))return;Re.add(n);let s={at:new Date().toISOString(),vodId:t?.vodId??null,url:t?.url,raw:e},i=Un();i.last=s;let r=We(e),a=r!=null?`${r} segments`:"see payload";console.log(`%c[vod-subtitles] Core GET /vod-subtitles \u2014 full response (${a})`,"font-weight:bold;font-size:12px",t?.vodId||t?.url?{vodId:t.vodId,url:t.url}:void 0,e)}var Xi=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";function Ne(e){if(e==null)return"original";let t=String(e).trim();return t===""?"original":t.toUpperCase()}var bt=class{constructor(){this.stateManager=new pt,this.cache=new Bt,this.fetcher=new Rt(this.stateManager),this.soundbiteProcessor=new Wt(this.stateManager),this.vodDataProcessor=new Nt(this.stateManager,this.fetcher,this.soundbiteProcessor),this.liveTimeGenerator=new Ut(this.stateManager),this.liveDataProcessor=new jt(this.stateManager,this.soundbiteProcessor,this.liveTimeGenerator),this.currentSubtitle=new Xt(this.stateManager)}setPhontClient(t){this.fetcher&&typeof this.fetcher.setPhontClient=="function"&&this.fetcher.setPhontClient(t)}get state(){return this.stateManager.state}set state(t){this.stateManager.state=t}get vodState(){return this.stateManager.vodState}set vodState(t){this.stateManager.vodState=t}get subscribers(){return this.stateManager.subscribers}subscribe(t){return this.stateManager.subscribe(t)}notify(){this.stateManager.notify()}toggleSubtitles(t){this.state.isVisible=t,this.notify()}toggleClosedCaptions(t){this.state.isClosedCaptionsEnabled=t,this.state.showSoundbiteAnimations=t,this.notify()}toggleKaraoke(t){this.state.isKaraokeMode=t,t&&(this.state.animationMode="Sentence"),this.notify()}toggleSpeaker(t){this.state.isSpeaker=t,this.notify()}toggleBackgroundEffect(t,n="blur"){this.state.isBackgroundEffectEnabled=t,this.state.backgroundEffect=t?n:"none",this.notify()}toggleSoundbites(t,n){t==="all"?this.state.showAllSoundbites=n:t==="important"&&(this.state.showImportantSoundbites=n),this.notify()}toggleSoundbiteAnimations(t){this.state.showSoundbiteAnimations=t,this.notify()}mapEventLabelToAnimation(t){return this.soundbiteProcessor.mapEventLabelToAnimation(t)}processSoundbiteAnimations(t){return this.soundbiteProcessor.processSoundbiteAnimations(t)}setAnimationMode(t){this.state.animationMode=t,t==="Word"&&(this.state.isKaraokeMode=!1),this.notify()}toggleTransition(t){this.state.transition=t,this.notify()}updateSubtitle(t){this.state.currentSubtitle=t,this.notify()}updateLiveTime(t=null){return this.liveTimeGenerator.updateLiveTime(t)}startLiveTiming(){this.liveTimeGenerator.startLiveTiming()}stopLiveTiming(){this.liveTimeGenerator.stopLiveTiming()}pauseLiveTiming(){this.liveTimeGenerator.pauseLiveTiming()}resumeLiveTiming(){this.liveTimeGenerator.resumeLiveTiming()}resetLiveStream(t){this.fetcher._audioPlaylistCache=null,this.liveTimeGenerator.resetLiveStream(t)}getLiveTime(){return this.liveTimeGenerator.getLiveTime()}getState(){return{...this.state}}reset(){this.stopLiveTiming(),this.state={isVisible:!0,isKaraokeMode:!1,isSpeaker:!1,animationMode:"Sentence",currentSubtitle:"",currentSequence:null,subtitles:[],currentSubtitleData:null,videoTimeSeed:null,currentTime:0,liveStartTime:null,liveCurrentTime:0,lastEndTime:0,processedSequences:new Set,initialSequenceOffset:null,segmentDurations:new Map,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],showAllSoundbites:!0,showImportantSoundbites:!1,soundbiteAnimations:[],showSoundbiteAnimations:!1,isClosedCaptionsEnabled:!1,isBackgroundEffectEnabled:!1,backgroundEffect:"none",backgroundOpacity:.7,transition:!1},this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[]},this.notify()}resetControls(){this.state.isVisible=!0,this.state.isKaraokeMode=!1,this.state.isSpeaker=!1,this.state.animationMode="Sentence",this.state.isBackgroundEffectEnabled=!1,this.state.backgroundEffect="none",this.state.backgroundOpacity=.7,this.state.showAllSoundbites=!0,this.state.showImportantSoundbites=!1,this.state.soundbites={all:!0,important:!1},this.state.showSoundbiteAnimations=!0,this.state.isClosedCaptionsEnabled=!1,this.state.transition=!1,this.notify()}getCumulativeDuration(t){return this.liveTimeGenerator.getCumulativeDuration(t)}normalizeSubtitles(t){return this.fetcher.normalizeSubtitles(t)}normalizeSoundbites(t){return this.fetcher.normalizeSoundbites(t)}async getAudioSegmentDuration(t){return this.fetcher.getAudioSegmentDuration(t)}setLiveMasterUrl(t){this.fetcher.setLiveMasterUrl(t)}async getInitialLiveSequenceNumber(){return this.fetcher.getInitialLiveSequenceNumber()}recordSegmentDuration(t,n){typeof n!="number"||!isFinite(n)||n<=0||this.stateManager.setSegmentDuration(t,n)}recordInitialSequenceOffset(t){typeof t!="number"||!isFinite(t)||this.stateManager.state.initialSequenceOffset===null&&this.stateManager.setInitialSequenceOffset(t)}async fetchSubtitles(t,n){try{let s=await this.fetcher.fetchSubtitles(t);return s?typeof n!="number"||!isFinite(n)?(console.warn(`[SubtitleManager] fetchSubtitles(sn=${t}) called without fragStart; skipping live processing`),null):await this.liveDataProcessor.processLiveSegment(s,t,n):null}catch{return null}}updateLiveTimeFromVideo(t){if(typeof t!="number"||!isFinite(t))return;let n=this.stateManager.state,s=n.videoTimeSeed;if(s===null)return;let i=t-s;Math.abs(n.liveCurrentTime-i)>.001&&(n.liveCurrentTime=i,n.currentTime=i,this.stateManager.notify())}async loadVodSubtitles(t,n=null){return this.fetchSubtitleData(t,n)}_processVodData(t,n,s,i){this.vodDataProcessor.processVodData(t,n,s,i)}getSubtitleForTime(t){return this.currentSubtitle.getSubtitleAtTime(t)}getLiveSubtitleForTime(){return this.currentSubtitle.getLiveSubtitleAtTime()}getCurrentSubtitleData(){return this.state.currentSubtitleData}updateBackgroundOpacity(t){this.state.backgroundOpacity=t,this.notify()}clearOldSubtitles(t,n=30){let s=t-n,i=this.state.subtitles.length;this.state.subtitles=this.state.subtitles.filter(r=>r.end_time>=s),this.state.subtitles.length<i&&this.notify()}getQueueStatus(){return{totalSubtitles:this.state.subtitles.length,lastEndTime:this.state.lastEndTime,processedSequences:Array.from(this.state.processedSequences),currentSequence:this.state.currentSequence}}setCurrentTime(t){this.state.currentTime=t}getActiveSoundbites(t=!1,n=null){return this.soundbiteProcessor.getActiveSoundbites(t,n)}getAllSoundbiteData(t=!1){return this.soundbiteProcessor.getAllSoundbiteData(t)}getActiveSoundbiteAnimations(t=!1){return this.soundbiteProcessor.getActiveSoundbiteAnimations(t)}hasActiveAnimations(){return this.soundbiteProcessor.hasActiveAnimations()}clearSoundbiteAnimations(){this.soundbiteProcessor.clearSoundbiteAnimations()}clearOldAnimations(t,n=30){this.soundbiteProcessor.clearOldAnimations(t,n)}getCurrentSpeaker(t=!1,n=null){if(!this.state.isSpeaker)return null;let s=null;if(t?s=this.vodState.currentSubtitleData:s=this.state.currentSubtitleData,!s||!s.words)return null;let i=s?.speaker;return i||null}async fetchSubtitleData(t,n=null,s=null){if(!n&&t){let i=new URLSearchParams(t.split("?")[1]||"");n=i.get("lang")||null,s||(s=i.get("model")||null)}if(this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:n,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify(),!!t)try{let i=await this.fetcher.fetchSubtitleData(t,n),{data:r,videoId:a}=i,o=r?.language||n||null;$t(r,{vodId:a,url:t});let c=Ne(o??n),m=s?`${c}_${s}`:c,l={data:r,url:t,timestamp:Date.now()};this.cache._subtitleCache.set(m,l),(!n||String(n).trim()==="")&&this.cache._subtitleCache.set("original",l);let u;if(!!n&&String(n).trim()!==""){let h=this.cache._subtitleCache.get("original");h?.data?.subtitles&&(u=Array.isArray(h.data.subtitles)?h.data.subtitles.flat():[])}this._processVodData(r,t,o,u)}catch(i){let r=i?.status||i?.response?.status,a=r===404||typeof i?.message=="string"&&i.message.includes("404")||typeof i?.message=="string"&&i.message.includes("Not Found"),o=r===400||typeof i?.message=="string"&&i.message.includes("400")||typeof i?.message=="string"&&i.message.includes("Bad Request");a?console.warn("[SubtitleManager] Subtitles not found (404) - VOD may not have subtitles available"):o?console.error("[SubtitleManager] Bad request (400) when loading subtitles. This may be due to invalid parameters (e.g., empty language code).",{error:i?.message,url:t,languageCode:n}):console.error("[SubtitleManager] Error loading subtitles:",i),this.vodState={subtitles:null,url:null,currentSubtitle:"",currentSubtitleData:null,currentSequence:null,soundByteAll:[],soundByteImportant:[],soundByteFiltered:[],currentLanguage:n,videoId:null},this.state.currentSubtitle="",this.state.currentSubtitleData=null,this.state.currentSequence=null,this.notify()}}async switchSubtitleLanguage(t,n,s=null){if(!n)return;let i=Ne(t);if(this.cache._loadingLanguages.has(i))return;let r=s?`${i}_${s}`:i,a=this.cache._subtitleCache.get(r);if(a&&a.data){this._loadCachedSubtitles(a.data,a.url,t);return}this.cache._loadingLanguages.add(i);try{let o=process.env.NEXT_PUBLIC_API_SUB_BASE_URL||"";if(!o)throw new Error("NEXT_PUBLIC_API_SUB_BASE_URL not configured. Use PhontClient with apiBaseUrl instead.");let c=new URLSearchParams;t&&c.append("lang",t),s&&c.append("model",s);let m=c.toString(),l=`${o}/vod-subtitles/${n}${m?`?${m}`:""}`,d=!1;try{await this.fetchSubtitleData(l,t,s),d=!0}catch(u){if(u?.status===404||typeof u?.message=="string"&&u.message.includes("404"))if(t!==null)d=!0;else throw u;else throw u}if(!d)throw new Error("Both endpoints failed")}catch{t!==null&&await this.switchSubtitleLanguage(null,n,s)}finally{this.cache._loadingLanguages.delete(i)}}_loadCachedSubtitles(t,n,s){let i=t?.language||s||null,r;if(!!s&&String(s).trim()!==""){let o=this.cache._subtitleCache.get("original");o?.data?.subtitles&&(r=Array.isArray(o.data.subtitles)?o.data.subtitles.flat():[])}this._processVodData(t,n,i,r)}getCurrentSubtitleLanguage(){return this.vodState.currentLanguage??null}clearSubtitleCache(){this.cache._subtitleCache.clear()}clearAudioPlaylistCache(){this.fetcher._audioPlaylistCache=null}updateState(){this.notify()}},je=new bt;function st(){let e=new Set,t=new Set,n=[],s=new Set,i=!1,r=!1;return{source:{onSegmentLoaded(o){return r?()=>{}:(e.add(o),()=>e.delete(o))},onInitialPlaylist(o){return r?()=>{}:(t.add(o),()=>t.delete(o))},destroy(){if(!r){r=!0;for(let o of n)try{o()}catch{}n.length=0,e.clear(),t.clear(),s.clear()}}},emitSegment(o){r||!o||typeof o.sn!="number"||s.has(o.sn)||(s.add(o.sn),e.forEach(c=>{try{c(o)}catch(m){console.warn("[LiveSegmentSource] listener error:",m)}}))},emitInitial(o){r||i||!o||!Array.isArray(o.fragments)||o.fragments.length===0||(i=!0,t.forEach(c=>{try{c(o)}catch(m){console.warn("[LiveSegmentSource] listener error:",m)}}))},addTeardown(o){n.push(o)}}}function Ue(e,t){let{source:n,emitSegment:s,emitInitial:i,addTeardown:r}=st(),a=(l,d)=>{let u=d&&d.frag;u&&(u.type!=="main"&&u.type!=="audio"||typeof u.sn=="number"&&s({sn:u.sn,duration:u.duration||0,start:typeof u.start=="number"?u.start:0,uri:u.url,type:u.type}))},o=l=>{if(!l||!Array.isArray(l.fragments)||l.fragments.length===0)return null;let d=l.fragments.filter(u=>typeof u.sn=="number").map(u=>({sn:u.sn,duration:u.duration||0,start:typeof u.start=="number"?u.start:0,uri:u.url,type:u.type||"main"}));return d.length===0?null:{startSn:d[0].sn,fragments:d,playlistUri:l.url}},c=(l,d)=>{let u=o(d&&d.details);u&&i(u)},m=(l,d)=>{let u=o(d&&d.details);u&&i(u)};return e.on(t.Events.FRAG_LOADED,a),e.on(t.Events.LEVEL_LOADED,c),e.on(t.Events.AUDIO_TRACK_LOADED,m),r(()=>{try{e.off(t.Events.FRAG_LOADED,a)}catch{}try{e.off(t.Events.LEVEL_LOADED,c)}catch{}try{e.off(t.Events.AUDIO_TRACK_LOADED,m)}catch{}}),n}function Xe(e,t){let{source:n}=st();throw new Error("[ShakaLiveSegmentSource] not implemented yet \u2014 see file header for outline")}function $e(e){let{source:t}=st();throw new Error("[BitmovinLiveSegmentSource] not implemented yet \u2014 see file header for outline")}function Xn(e,t=!1){if(!e)return[];try{return e.split("|").map(n=>{let[s,i]=n.split(","),r=t||typeof i=="string"&&(i.startsWith("#")||i.startsWith("%23")),a;return r?a=i.replace(/%23/g,"#"):a=parseFloat(i),{time:parseFloat(s),value:a}})}catch(n){return console.error("Error decoding points:",n),[]}}function $n(e){if(!e)return"";if(e.includes("://"))try{let t=new URL(e);return t.search.startsWith("?")?t.search.slice(1):t.search}catch{let t=e.indexOf("?");return t!==-1?e.substring(t+1):e}return e.startsWith("?")?e.slice(1):e}function Yt(e){try{let t=$n(e),n=new URLSearchParams(t),s={parameterStates:{}};if(n.has("name")&&(s.name=n.get("name")||void 0),n.has("user")&&(s.userName=n.get("user")||void 0),n.has("duration")&&(s.duration=parseFloat(n.get("duration")||"0")),n.has("mode")&&(s.animationMode=n.get("mode")||void 0),n.has("text")&&(s.text=n.get("text")||void 0),n.get("format")==="normalized"&&(s.format="normalized"),n.has("font"))try{let r=JSON.parse(n.get("font")||"{}");r&&typeof r=="object"&&(r.style||r.config||r.fontId?s.fontData={style:r.style,config:r.config||null,fontId:r.fontId||null,fontName:r.fontName||null}:s.fontData={style:r,config:null})}catch(r){console.warn("Failed to parse font data:",r)}if(n.has("bg"))try{s.backgroundStyle=JSON.parse(n.get("bg")||"{}")}catch(r){console.warn("Failed to parse background style:",r)}for(let[r,a]of n.entries())if(!["name","user","duration","mode","text","font","bg","v","c","m","p","format"].includes(r)&&(a.includes("|")||a.includes(","))){let o=r==="color"||r==="shadowColor"||r==="outlineColor"||a.includes("%23"),c=Xn(a,o);if(c.length>0){let m=o?"#000000":0;s.parameterStates[r]={points:c,currentValue:c[0]?.value||m}}}return s}catch(t){throw console.error("Error decoding animation URL:",t),new Error("Failed to decode animation URL. The link may be invalid or corrupted.")}}function Ve(e){if(e===0)return 0;let t=4,n;if(e<=.7){let s=Math.log(1+.5*(Math.exp(t)-1))/t;n=Math.pow(e/.7,.5)*s}else{let s=(e-.7)/.3,i=Math.log(1+.5*(Math.exp(t)-1))/t;n=i+s*(1-i)}return(Math.exp(t*n)-1)/(Math.exp(t)-1)}function Vt(e){if(typeof e!="string")return{r:0,g:0,b:0};let t=e.replace("#","").padStart(6,"0"),n=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:{r:0,g:0,b:0}}function qe(e,t,n){let s=i=>{let r=Math.round(Math.max(0,Math.min(255,i))).toString(16);return r.length===1?"0"+r:r};return"#"+s(e)+s(t)+s(n)}function Ye(e,t,n){let s=Vt(e),i=Vt(t),r=Math.max(0,Math.min(1,n)),a=s.r+(i.r-s.r)*r,o=s.g+(i.g-s.g)*r,c=s.b+(i.b-s.b)*r;return qe(a,o,c)}function Yn(e,t,n){if(n===0)return e;let s=Vt(e),i=Vt(t),r=s.r+(i.r-s.r)*n,a=s.g+(i.g-s.g)*n,o=s.b+(i.b-s.b)*n;return qe(r,a,o)}function mt(e,t,n,s=!1,i=null){if(!e||e.length===0)return null;let r=s?t:t*n,a=null,o=null;for(let c=0;c<e.length;c++){let m=e[c],l=m.time!==void 0?m.time:Array.isArray(m)?m[0]:0;if(l!==void 0&&l<=r&&(a=m),l!==void 0&&l>=r&&!o){o=m;break}}if(!a&&e[0])return(e[0].value!==void 0?e[0].value:Array.isArray(e[0])?e[0][1]:null)??null;if(!o&&a)return(a.value!==void 0?a.value:Array.isArray(a)?a[1]:null)??null;if(a&&o){let c=a.time!==void 0?a.time??0:Array.isArray(a)?a[0]:0,m=o.time!==void 0?o.time??0:Array.isArray(o)?o[0]:0,l=a.value!==void 0?a.value:Array.isArray(a)?a[1]:null,d=o.value!==void 0?o.value:Array.isArray(o)?o[1]:null;if(c===m||l===null||d===null)return l??null;let u=(r-c)/(m-c),C=i==="color"||i==="shadowColor"||i==="outlineColor"||i==="outline2Color"||i==="outline3Color"||i==="outlineShadowColor"||i==="glowColor";if(C&&(typeof l=="string"||typeof d=="string"))return Ye(typeof l=="string"?l:"#000000",typeof d=="string"?d:"#000000",u);if(!C&&(typeof l=="string"||typeof d=="string")){let h=typeof l=="string"&&(l.startsWith("#")||/^[0-9a-f]{6}$/i.test(l)),f=typeof d=="string"&&(d.startsWith("#")||/^[0-9a-f]{6}$/i.test(d));if(h&&f){let g=l.startsWith("#")?l:`#${l}`,E=d.startsWith("#")?d:`#${d}`;return Ye(g,E,u)}return d??null}return l+(d-l)*u}return null}var fe=.7,yt=.7,ze={rawMode:!0};function dt(e,t,n,s,i=null,{rawMode:r=!1}={}){if(!e||!e.parameterStates)return null;let a=r?1:t*s/(fe*yt),o=e.duration||2,m=e.format==="normalized"?n:n*o,l=!0,d=e.parameterStates||{},u=(M,D,Y=!0,Z=null)=>{let gt=Z??a,at=mt(d[M]?.points,m,o,l);return at==null?D:Y?gt===0?D:D+(at-D)*gt:at},C=u("scale",1),h=u("skew",0),f=u("stretch",1),g=u("translateX",0),E=u("translateY",0),b=u("weight",500),I=u("width",100),y=(e.fontData||{}).style?.fontFamily||"Roboto Flex",O=e.text||"Hello",B=(M,D)=>{let Y=mt(d[M]?.points,m,o,l,M);if(Y==null)return D;let Z=typeof Y=="string"?Y.startsWith("#")?Y:`#${Y}`:`#${Math.round(Y).toString(16).padStart(6,"0")}`;return a===0?D:Yn(D,Z,a)},L=B("color","#ffffff"),F=u("opacity",1),_=u("shadowX",0),x=u("shadowY",0),z=u("shadowBlur",4),K=u("shadowOpacity",.5),tt=B("shadowColor","#000000"),Mt=u("outlineWidth",0),ae=B("outlineColor","#000000"),R=M=>d[M]?.points?.length>0,ft=R("stretchX")?u("stretchX",1):void 0,_t=R("outline2Width")?u("outline2Width",0):void 0,Et=R("outline2Color")?B("outline2Color","#000000"):void 0,It=R("outline3Width")?u("outline3Width",0):void 0,Lt=R("outline3Color")?B("outline3Color","#000000"):void 0,S=R("outlineShadowWidth")?u("outlineShadowWidth",0):void 0,j=R("outlineShadowColor")?B("outlineShadowColor","#000000"):void 0,W=R("outlineShadowBlur")?u("outlineShadowBlur",0):void 0,A=R("glowIntensity")?u("glowIntensity",0):void 0,P=R("glowColor")?B("glowColor","#ffffff"):void 0,N=R("snakeWave")?u("snakeWave",0):void 0,et=R("karaoke")?u("karaoke",0):void 0,X=1-.5*Math.min(1,Math.max(0,s)),$=u("blur",0,!0,r?1:a*X),ht=mt(d.thinStroke?.points,m,o,l),G=mt(d.ascenderHeight?.points,m,o,l),rt={};ht!=null&&typeof ht=="number"&&(rt.YOPQ=ht),G!=null&&typeof G=="number"&&(rt.YTAS=G),b!=null&&(rt.wght=b),I!=null&&(rt.wdth=I);let nt=[];if((_!==0||x!==0||z!==4||K!==.5)&&K>0){let M=typeof tt=="string"?tt:"#000000",D=parseInt(M.slice(1,3),16),Y=parseInt(M.slice(3,5),16),Z=parseInt(M.slice(5,7),16);nt.push(`${_}px ${x}px ${z}px rgba(${D}, ${Y}, ${Z}, ${K})`)}if(A!=null&&A>0){let M=typeof P=="string"?P:"#ffffff";nt.push(`0 0 ${A}px ${M}`),nt.push(`0 0 ${A*2}px ${M}`),nt.push(`0 0 ${A*4}px ${M}`)}let oe=nt.length>0?nt.join(", "):"",ut=0;if(d.joy?.points&&d.joy.points.length>0)for(let M of d.joy.points){let D=Array.isArray(M)?M[1]:M.y??M.value??0;typeof D=="number"&&D>ut&&(ut=D)}let kt=u("joy",0,!1),le=r?kt:Math.min(1,ut*a),H=u("fear",0),J=u("standardEmphasis",0,!1),it=u("strongEmphasis",0,!1),T={rawIntensity:t,scaleFactor:a,scale:C,slant:h,stretchY:f,translateX:g,translateY:E,weight:b,width:I,fontFamily:y,textColor:L,opacity:F,textShadow:oe,shadowX:_,shadowY:x,blur:$,outlineWidth:Mt,outlineColor:ae,letterSpacing:`${Math.max(0,(C-1)*.02)}em`,fontVariationAxes:rt,text:O,joy:le,fear:H,standardEmphasis:J,strongEmphasis:it,joyWaveProgress:m/o*1.5};return ft!==void 0&&(T.stretchX=ft),_t!==void 0&&(T.outline2Width=_t),Et!==void 0&&(T.outline2Color=Et),It!==void 0&&(T.outline3Width=It),Lt!==void 0&&(T.outline3Color=Lt),S!==void 0&&(T.outlineShadowWidth=S),j!==void 0&&(T.outlineShadowColor=j),W!==void 0&&(T.outlineShadowBlur=W),A!==void 0&&(T.glowIntensity=A),P!==void 0&&(T.glowColor=P),N!==void 0&&(T.snakeWave=N),et!==void 0&&(T.karaoke=et),T}var w={fontSize:54,opacity:1,weight:500,slant:0,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,defaultFont:"Roboto Flex",angryFont:"Rakkas",joyFont:"Parkinsans",sadnessFont:"Cormorant",shadow:{offsetX:3,offsetY:2,blur:7,color:"rgba(0, 0, 0, 0.95)"},angryFontStyle:{color:"rgba(255, 255, 255, 1.0)",strokeColor:"none",strokeWidth:0,shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowBlurMin:.8,shadowBlurMax:4,shadowOpacityMin:.2,shadowOpacityMax:.9,shadowColor:"rgba(255, 50, 50, 0.9)"},disgustEmotion:{shadowOffsetX:3,shadowOffsetY:2,shadowBlur:4,shadowColor:"rgba(100, 180, 50, 0.9)"},transition:{duration:0,easing:"linear"},lineHeight:1.2,letterSpacing:"normal",wordSpacing:{min:"0.25em",max:"2.0em"},fontSpacingAdjustments:{"Roboto Flex":{letterSpacing:"normal",wordSpacingMultiplier:1},Parkinsans:{letterSpacing:"0em",wordSpacingMultiplier:1.1,fontSizeOffset:-5},"Bricolage Grotesque":{letterSpacing:"normal",wordSpacingMultiplier:1,fontSizeOffset:0},Rakkas:{letterSpacing:"normal",wordSpacingMultiplier:1},Cormorant:{letterSpacing:"normal",wordSpacingMultiplier:1}},position:{bottom:"10%",horizontalAlign:"center"},wordAnimation:{minDisplayTime:1,allowOverlap:!0},subtitleBackground:{background:"#000000",border:"none",borderRadius:0,boxShadow:"none",backdropFilter:"none",paddingX:12,paddingY:8}};var p={modes:{word:"Word",sentence:"Sentence"},timing:{minWordDisplayTime:.85,breathingRoomDuration:1.5,breathingRoomMinGap:1,breathingRoomLargeGap:1.5,breathingRoomSafetyBuffer:.1,breathingRoomNoNextHold:4,fadeOutDuration:.25,timeRangeTolerance:.05},emotion:{defaultThreshold:.4,maxThreshold:.6,angryFontThreshold:.7,angryEmotions:["anger","screaming"],joyFontThreshold:.7,joyEmotions:["joy"],sadnessFontThreshold:.7,sadnessEmotions:["sadness"]},emphasis:{minThreshold:.5,maxThreshold:.7,scaleMultiplier:.45,scaleUpFrames:6,scaleDownFrames:6,fps:60},strongEmphasis:{minThreshold:.7,maxScale:1.08,maxRotation:.05,maxTranslateY:1,maxTranslateX:0,maxSkew:3,maxBrightness:.32,maxContrast:.22,maxShadowBlur:18,shadowOpacity:.35,shadowOffsetX:4,shadowOffsetY:4,maxZIndex:8,outwardPushTranslateX:0,outwardPushRotation:1.5,outwardPushSkew:1.4,fadeOutTailDuration:.12},fear:{},joy:{maxWordsForLetterAnimation:1,minWordsForWordAnimation:2,letterWave:{innerWidthRatio:.12,outerWidthRatio:.12,maxScale:1.28,maxRotation:4,maxTranslateY:3,maxTranslateX:0,maxSkew:6,maxBrightness:.25,maxContrast:.15,maxShadowBlur:12,shadowOpacity:.25,maxZIndex:10},letterBulge:{innerWidthRatio:.14,outerWidthRatio:.14,maxScale:1.06,maxStretchY:.22,maxCompressionX:.12,maxTranslateY:2.5,maxTranslateX:.8,maxSkew:3,maxRotation:2,maxBrightness:.18,maxContrast:.1,maxShadowBlur:6,shadowOpacity:.22,maxZIndex:12},wordLevel:{duration:.6,easeType:"easeOutElastic",maxScale:1.08,maxRotation:2,maxTranslateY:2,maxTranslateX:0,maxSkew:2,maxBrightness:.2,maxContrast:.1,maxShadowBlur:8,shadowOpacity:.2,maxZIndex:5,transitionDuration:200}},debug:{showBorders:!1,showTimings:!1,logRendering:!1}};function St(e,t,n){let s=Math.max(0,Math.min(1,e)),i=n??t;if(typeof i=="number"&&Number.isFinite(i)){let r=Math.max(0,Math.min(1,i));return Math.min(1,Math.max(0,r*(s/yt)))}return s}function qt(e){let t=.2+.8*e,n=p.emotion.maxThreshold-(p.emotion.maxThreshold-p.emotion.defaultThreshold)*e;return{gts:e,maxExpression:t,threshold:n,shouldEnableAngryFont:t>=p.emotion.angryFontThreshold}}function Vn(e,t){return e>=t}function he(e,t){return t<=.2?0:e*t}function ge(e){let{minThreshold:t,maxThreshold:n}=p.emphasis;return e<t||e>=n?0:(e-t)/(n-t)}function pe(e){return e>=p.emphasis.minThreshold&&e<p.emphasis.maxThreshold}function be(e){return e>=p.strongEmphasis.minThreshold}function qn(e){e=Math.max(0,Math.min(1,e));let r=1-e,a=r*r,o=a*r,c=e*e,m=c*e;return o*0+3*a*e*.42+3*r*c*.58+m*1}var Ge=new WeakMap,ye={joy:1,social_positive:1,anger:-1,screaming:-1};function Se(e,t,n,s){let i=typeof n=="string"?n.toLowerCase():"";if(i==="joy")return zn(e,t,s);let r=Math.sign(t);return r!==0?r:i in ye?ye[i]:s}function zn(e,t,n){let s=Math.sign(t);if(e){let i=Ge.get(e);if(i!==void 0)return i;let r=s!==0?s:Ke(n);return Ge.set(e,r),r}return s!==0?s:Ke(n)}function Ke(e){return e!==0?e:ye.joy}function Gn(e,t,n=1,s=0,i=null,r=""){let a=e?.emphasis||0,{scaleMultiplier:o,scaleUpFrames:c,scaleDownFrames:m,fps:l}=p.emphasis;if(!e||!pe(a))return null;let d=t-e.start,u=i?e.start+i:e.end,C=u-e.start;if(d<0||t>=u)return null;let h=Math.max(0,Math.min(1,d/C)),f=0;h<.5?f=h*2:f=2-h*2,f=f*f*(3-2*f);let g=ge(a),E=.55,b=3*E,k=Se(e,s,r,0)*b*f*n*g,y=140*f*n*g,O=1+o*E*f*n*g,B=h<1;return{scaleMultiplier:O,slantAdditive:k,weightBoost:y,scaleProgress:f,gtsMultiplier:n,emphasis:a,emphasisMultiplier:g,elapsed:d,scaleActive:B}}function Kn(e,t,n={},s=1,i=null,r=0,a=""){let o=a==="anger"||a==="screaming",c=p.strongEmphasis,m=.7,l=i?e.start+i:e.end;if(t<e.start)return null;let d=e.emphasis||0;if(!be(d))return null;let u=c.fadeOutTailDuration,C=l+u;if(t>=C)return null;let h=l-e.start,f=Math.max(0,Math.min(1,(t-e.start)/h)),g=1,E=t>=l;if(E){let x=(t-l)/u;g=1-qn(x),f=1}let b=0;f<.5?b=f*2:b=2-f*2;let I=b*b*(3-2*b),k=(d-c.minThreshold)/(1-c.minThreshold),y=I*k*s,O=y;y<.1&&(y=0);let B=Se(e,r,a,-1),L,F;if(o)L={scale:1+y*(c.maxScale-1)*m,rotation:y*c.maxRotation*m,translateY:-y*c.maxTranslateY*m,translateX:y*c.maxTranslateX*m,skewX:B*y*c.maxSkew*m,stretchY:1},F={brightness:1+y*c.maxBrightness*m,contrast:1+y*c.maxContrast*m,shadowBlur:y*c.maxShadowBlur*m,shadowOpacity:y*c.shadowOpacity*m,zIndex:Math.round(y*c.maxZIndex*m)};else{let K=I*20*Math.max(.2,k*s)*m,tt=Se(e,r,a,1);L={scale:1+y*.15*m,rotation:0,translateY:0,translateX:0,skewX:tt*K,stretchY:1},F={brightness:1+y*.2*m,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0}}g<1&&(L.scale=1+(L.scale-1)*g,L.rotation=L.rotation*g,L.translateX=L.translateX*g,L.translateY=L.translateY*g,L.skewX=L.skewX*g,F.brightness=1+(F.brightness-1)*g,F.contrast=1+(F.contrast-1)*g,F.shadowBlur=F.shadowBlur*g,F.shadowOpacity=F.shadowOpacity*g,F.zIndex=Math.round(F.zIndex*g),y=y*g);let _=280*y*s;return{emphasis:y,rawEmphasis:O,...L,...F,weightBoost:_,shadowOffsetX:y*c.shadowOffsetX,shadowOffsetY:y*c.shadowOffsetY,gtsMultiplier:s,emphasisMultiplier:k,fadeFactor:g,isInTail:E}}function ve({word:e,currentTime:t,maxExpression:n,emotionAnimationDuration:s,wordBaseSlant:i,isActive:r,wordEmotion:a=""}){let o=r?Gn(e,t,n,i,s,a):null,c=Kn(e,t,{},n,s,i,a);return{emphasisEffect:o,strongEmphasisData:c}}function He(e){let t=2*Math.PI/3;return e===0?0:e===1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*t)+1}function Je(e){return 1-(1-e)*(1-e)}function we(e){let{maxWordsForLetterAnimation:t,minWordsForWordAnimation:n}=p.joy;return e<=t?"letter":e>=n?"letter-bulge":"letter"}function Hn(e,t,n,s=1){let i=p.joy.letterWave,r=n<=6,a,o,c;r?(a=1.5/Math.max(1,n),o=2.5/Math.max(1,n),c=a+o):(a=i.innerWidthRatio,o=i.outerWidthRatio,c=a+o);let m=t/Math.max(1,n-1),l=e;r&&n<=3?l=Math.min(1.2,e*1.25):r&&(l=Math.min(1.1,e*1.1));let d=l*(1+c),u=m-d,C=a+o,h=o*.3;if(u>h||u<-C)return null;let f=0;if(u>0&&u<=h)f=(1-u/h)*.15;else if(u<=0&&u>=-a){let y=Math.abs(u)/Math.max(a,.01);f=He(y)}else if(u<-a){let O=(Math.abs(u)-a)/Math.max(o,.01);f=Je(1-O)}if(f<=.01)return null;let g=f*s,b=1-t%2*.15,I={scale:1+g*(i.maxScale-1)*b,rotation:g*i.maxRotation*(t%3===0?1:-1),translateX:0,translateY:-g*i.maxTranslateY*b,skewX:-g*i.maxSkew*.5,stretchY:1},k={brightness:1+g*i.maxBrightness,contrast:1+g*i.maxContrast,shadowBlur:g*i.maxShadowBlur,shadowOpacity:g*i.shadowOpacity,zIndex:Math.round(g*i.maxZIndex)};return{pressure:g,...I,...k,shadowOffsetX:g*3,shadowOffsetY:g*3}}function Jn(e,t,n,s=1){let i=p.joy.letterBulge,r=i.innerWidthRatio,a=i.outerWidthRatio,o=r+a,c=n>1?t/Math.max(1,n-1):0,m=e*(1+o),l=c-m,d=a*.35,u=o;if(l>d||l<-u)return null;let C=0;if(l>0&&l<=d)C=(1-l/Math.max(d,1e-4))*.18;else if(l<=0&&l>=-r){let O=Math.abs(l)/Math.max(r,1e-4);C=He(O)}else if(l<-r){let B=(Math.abs(l)-r)/Math.max(a,1e-4);C=Je(1-B)}if(C<=.01)return null;let h=C*s,f=Math.min(1,h*.85),g=1,E=t%3===0?1:-1,b=Math.max(1-i.maxCompressionX,1-f*i.maxCompressionX),I=1+f*i.maxStretchY,k={scale:1+f*(i.maxScale-1),stretchY:I,stretchX:b,rotation:f*i.maxRotation*g,translateX:f*i.maxTranslateX*E,translateY:-f*i.maxTranslateY,skewX:f*i.maxSkew*g},y={brightness:1+f*i.maxBrightness,contrast:1+f*i.maxContrast,shadowBlur:f*i.maxShadowBlur,shadowOpacity:f*i.shadowOpacity,zIndex:Math.round(f*i.maxZIndex)};return{pressure:f,bulgeIntensity:f,...k,...y,shadowOffsetX:f*1.8,shadowOffsetY:f*3}}function Zn(e){if(!e)return"";let t=e.scale||1,n=e.stretchX||1,s=e.rotation||0,i=e.translateX||0,r=e.translateY||0,a=e.skewX||0,o=e.stretchY||1;return`scaleX(${n}) scale(${t}) scaleY(${o}) rotate(${s}deg) skewX(${a}deg) translate(${i}px, ${r}px)`}function Qn(e){if(!e)return"";let t=e.brightness||1,n=e.contrast||1,s=e.shadowBlur||0,i=e.shadowOpacity||0,r=e.shadowOffsetX||0,a=e.shadowOffsetY||0,o=[];return t!==1&&o.push(`brightness(${t})`),n!==1&&o.push(`contrast(${n})`),s>0&&i>0&&o.push(`drop-shadow(${r}px ${a}px ${s}px rgba(255, 255, 255, ${i}))`),o.join(" ")}var ti=["anger","fear","sadness","joy"];function ei(e){return ti.includes(e.toLowerCase())}function vt(e){return e.map(([t,n])=>{let s=ei(t),i=s?1.5:1,r=n*i;return[t,n,r,i,s]})}function Ze(e){if(!e)return{confidence:0,emphasis:0,hasEmphasis:!1,hasStrongEmphasis:!1};let t=e.confidence_word||0,n=e.emphasis||0;return{confidence:t,emphasis:n,hasEmphasis:n>=p.emphasis.minThreshold&&n<p.emphasis.maxThreshold,hasStrongEmphasis:n>=p.strongEmphasis.minThreshold}}function wt(e){return e&&(e.subtitle||e.text)||""}function zt(e){return!e||!e.words?[]:Array.isArray(e.words)?e.words:[]}function At(e){return!e||!e.animations?{}:typeof e.animations=="object"?e.animations:{}}function Q(e){return!!e&&Array.isArray(e.merged_subtitles)&&e.merged_subtitles.length>0}function xt(e){return Q(e)?(e.merged_subtitles||[]).filter(t=>t!=null):[]}function Gt(e,t){return!e||!t?null:e.find(n=>n&&t.start<n.end_time&&t.end>n.start_time)||null}function Qe(e,t,n=null,s=null){if((s?.name==="children"||s?.name==="hello-kitty")&&n&&s.fonts?.[n])return s.fonts[n];let i=p.emotion.angryEmotions.includes(e)&&t>=p.emotion.angryFontThreshold,r=p.emotion.joyEmotions.includes(e)&&t>=p.emotion.joyFontThreshold,a=p.emotion.sadnessEmotions.includes(e)&&t>=p.emotion.sadnessFontThreshold;return i?w.angryFont:r?w.joyFont:a?w.sadnessFont:w.defaultFont}function Kt(e,t,n=null,s=null){let i=Qe(e,t,n,s),r="sans-serif";return i==="Cormorant"&&(r="serif"),`"${i}", ${r}`}function ni(e,t){return p.emotion.angryEmotions.includes(e)&&t>=p.emotion.angryFontThreshold}function ii(e,t){return p.emotion.joyEmotions.includes(e)&&t>=p.emotion.joyFontThreshold}function si(e,t){return p.emotion.sadnessEmotions.includes(e)&&t>=p.emotion.sadnessFontThreshold}var nn='"Roboto Flex", "Roboto", sans-serif',tn=new Map,ri={excitement:"joy",happy:"joy",happiness:"joy",angry:"anger",frustrated:"anger",positive:"social_positive",negative:"social_negative",neutrality:"neutral"};function Ht(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase();return t?ri[t]||t:""}function Ae(e){if(typeof e!="string"||e.length===0)return null;let t=tn.get(e);if(t)return t;try{let n=Yt(e);return tn.set(e,n),n}catch(n){return console.error("[calculateAnimationState] Failed to decode animation URL:",n),null}}function ai(e){if(!e||e.length===0)return null;let t=e.filter(n=>n&&typeof n.start_time=="number"&&typeof n.end_time=="number");return t.length===0?null:{start:Math.min(...t.map(n=>n.start_time)),end:Math.max(...t.map(n=>n.end_time))}}function oi(e,t){return e.find(n=>n&&typeof n.start_time=="number"&&typeof n.end_time=="number"&&t>=n.start_time&&t<=n.end_time)||null}function Jt(e){return e&&typeof e.animation_url=="string"&&e.animation_url.length>0?e.animation_url:null}function sn(e,t){if(!e)return{emotion:"none",intensity:0};let n=At(e),s=Object.entries(n).filter(([,a])=>typeof a=="number"&&a>t);if(s.length>0){let a=vt(s).sort((o,c)=>c[2]-o[2])[0];return{emotion:Ht(a[0])||"none",intensity:a[1]}}let i=Ht(e.emotion),r=typeof e.emotion_intensity=="number"?e.emotion_intensity:0;return!i||i==="none"||r<=0?Jt(e)?{emotion:"none",intensity:1}:{emotion:"none",intensity:0}:{emotion:i,intensity:r}}function li(e){let t={...e};return typeof t.translateX=="number"&&(t.translateX=-t.translateX),typeof t.rotation=="number"&&(t.rotation=-t.rotation),typeof t.slant=="number"&&(t.slant=-t.slant),typeof t.skewX=="number"&&(t.skewX=-t.skewX),t}function en(e,t,n,s){let{minWordDisplayTime:i,breathingRoomDuration:r,breathingRoomMinGap:a,breathingRoomLargeGap:o}=p.timing,c=Math.max(0,e.end-e.start),m=Math.max(c,i);if(!s)return e.start+m;let l=typeof t.end_time=="number"?t.end_time:e.end,d=l-e.end,u=!1;if(n!=null&&n>l?(d=n-e.end,u=d>=o):n==null?(u=!0,d=1/0):u=d>=a,u){let h=d===1/0?i+r:e.end+d-e.start-.1,g=c<i?h:Math.min(i+r,h);m=Math.max(m,g)}return e.start+m}function ui(e,t,n){if(!e||e.length===0)return{opacities:[],currentWordIndex:-1};let s=e.findIndex(a=>t>=a.start&&t<a.animationEnd),i=e.reduce((a,o,c)=>t>=o.animationEnd?c:a,-1);return{opacities:e.map((a,o)=>t>=a.start&&t<a.end||t>=a.end||i!==-1&&o<=i?1:n?0:.3),currentWordIndex:s}}function rn(e){if(!e)return w.defaultFont;let t=e.match(/["']?([^"',]+)["']?/),n=(t?t[1]:e).trim(),s=n.toLowerCase();return s.includes("bricolage")?"Bricolage Grotesque":s.includes("rakkas")?w.angryFont:s.includes("parkinsans")?w.joyFont:s.includes("cormorant")?w.sadnessFont:s.includes("roboto")?w.defaultFont:n}function ci(e,t,n){let s={text:"",fontSize:w.fontSize,scale:1,opacity:1,slant:0,weight:400,width:100,textColor:"rgba(255,255,255,1.0)",translateX:0,translateY:0,stretchY:1,emotion:"none",emotionIntensity:0,fontFamily:nn,startTime:0,endTime:0,duration:0,isActive:!1};if(!e||typeof e.start_time!="number"||typeof e.end_time!="number")return s;let i=n.maxExpression??1,r=n.threshold??.2,a=n.isRTL??!1,o=i<=.2,c=qt((i-.2)/.8).gts,m=e.start_time,l=e.end_time,d=Math.max(.01,l-m),u=Math.max(0,Math.min(1,(t-m)/d)),C=sn(e,r),h=o?"none":C.emotion,f=o?0:Math.max(0,C.intensity),g=Ae(Jt(e)),E=St(c,e.gts,void 0),b=g?dt(g,f,u,E,d):null,I=b?.fontFamily?`"${rn(b.fontFamily)}", sans-serif`:Kt(h,i),k={fontSize:w.fontSize,scale:b?.scale??1,opacity:b?.opacity??1,slant:b?.slant??0,weight:b?.weight??400,width:b?.width??100,textColor:b?.textColor??w.textColor,translateX:b?.translateX??0,translateY:b?.translateY??0,stretchY:b?.stretchY??1,fontVariationAxes:b?.fontVariationAxes??{},letterShake:b?.fear??0};return{...a?li(k):k,text:wt(e),emotion:h,emotionIntensity:f,fontFamily:I,startTime:m,endTime:l,duration:d,isActive:t>=m&&t<l}}function mi(e,t,n){let s=n.maxExpression??1,i=n.threshold??.2,r=n.isRTL??!1,a=n.nextSegmentStartTime??null,o=n.extendedEndTime??null,c=n.transparentUntilSpoken??!1,m=s<=.2,l=qt((s-.2)/.8).gts,d={text:"",words:[],currentWordIndex:-1,emotion:"none",emotionIntensity:0,fontFamily:nn,startTime:0,endTime:0,isActive:!1};if(!e||typeof e.start_time!="number"||typeof e.end_time!="number")return d;let u=Q(e)?xt(e):[e],C=ai(u),h=oi(u,t);if(!h&&o!=null&&t>e.end_time&&t<=o&&(h=u[u.length-1]||null),!h&&C&&t>=C.start&&t<=C.end&&(h=[...u].filter(S=>S&&t>=S.start_time).sort((S,j)=>j.start_time-S.start_time)[0]||null),h==null)return d;let f=h,g=sn(f,i),E=m?"none":g.emotion,b=m?0:Math.max(0,g.intensity),I=f.start_time,k=f.end_time,y=Math.max(.01,k-I),O=Math.max(0,Math.min(1,(t-I)/y)),B=Q(e)?null:Ae(Jt(f)),L=f.gts??e.gts,F=St(l,L,void 0),_=B?dt(B,b,O,F,y):null,x={fontSize:w.fontSize,scale:_?.scale??(E==="none"?1:1+b*.16),opacity:_?.opacity??1,slant:_?.slant??0,weight:_?.weight??400,width:_?.width??100,textColor:_?.textColor??w.textColor,translateX:_?.translateX??0,translateY:_?.translateY??0,stretchY:_?.stretchY??1,textShadow:_?.textShadow??"",blur:_?.blur??0,outlineWidth:_?.outlineWidth??0,outlineColor:_?.outlineColor??"#000000",fontVariationAxes:_?.fontVariationAxes??{}},z=zt(e).flatMap(S=>{let j=String(S?.word??""),W=j.trim();if(!W.includes(" "))return[S];let A=W.split(/\s+/),N=((S.end??0)-(S.start??0))/Math.max(1,A.length),et=j.startsWith(" ");return A.map((X,$)=>({...S,word:($===0&&et?" ":"")+X,start:(S.start??0)+$*N,end:(S.start??0)+($+1)*N}))}),K=null;if(Q(e)&&C?.end){let S=z[z.length-1],j=en(S,e,a,!0),W=o??j,{minWordDisplayTime:A,breathingRoomDuration:P}=p.timing,N=A+P,X=(z.length>0?Math.min(...z.map($=>$.start)):C.start)+N;K=Math.max(C.end,W,X)}let tt=z.map((S,j)=>{let W=j===z.length-1,A=en(S,e,a,W);return{...S,animationEnd:Q(e)&&K?Math.max(A,K):A}}),{currentWordIndex:Mt,opacities:ae}=ui(tt,t,c),R=tt.map((S,j)=>{let W=t>=S.start&&t<S.end,A=E,P=b,N=b,et=Q(e)?xt(e):null,X=et?Gt(et,S):f;if(X){let ot=At(X),Pt=Object.entries(ot).filter(([,q])=>typeof q=="number"&&q>i),ue=Object.entries(ot).filter(([,q])=>typeof q=="number");if(ue.length>0)N=[...ue].sort((lt,ce)=>ce[1]-lt[1])[0][1];else{let q=Ht(X.emotion),lt=typeof X.emotion_intensity=="number"?X.emotion_intensity:0;q&<>0&&(A=q,N=lt,P=lt)}if(Pt.length>0){let q=vt(Pt).sort((lt,ce)=>ce[2]-lt[2]);A=Ht(q[0][0])||"none",P=q[0][1]}else ue.length>0&&(A="none",P=0)}m?(A="none",P=0):P===N&&P!==0&&(P=he(P,s));let $=Math.max(.01,(S.end??0)-(S.start??0)),ht=Math.max(0,Math.min(1,(t-S.start)/$)),G=Ae(Jt(X)),rt=N>0?N:G?Math.max(1,b||0):0,nt=St(l,L,S.gts),v=G?dt(G,rt,ht,nt,$):null,oe=rn(G?.fontData?.style?.fontFamily),ut=(G?.parameterStates?.standardEmphasis?.points?.length??0)>0,kt=(G?.parameterStates?.strongEmphasis?.points?.length??0)>0,le=ut||kt,H=W?v?.standardEmphasis??0:0,J=W?v?.strongEmphasis??0:0,it=null,T=null;if(le){let ot=(v?.slant??0)>0?1:(v?.slant??0)<0?-1:0;if(ut&&(it={scaleMultiplier:1+.272*H*s,slantAdditive:ot*4.25*H*s,weightBoost:250*H*s,scaleProgress:H,gtsMultiplier:s,emphasis:H,emphasisMultiplier:H,elapsed:0,scaleActive:H>0}),kt&&!r){let Pt=(v?.slant??0)>0?1:(v?.slant??0)<0?-1:1;T={emphasis:J,rawEmphasis:J,scale:1+J*.38,skewX:Pt*J*30*s,weightBoost:400*J*s,rotation:0,translateX:0,translateY:0,stretchY:1,brightness:1+J*.35,contrast:1,shadowBlur:0,shadowOpacity:0,zIndex:0,shadowOffsetX:0,shadowOffsetY:0,gtsMultiplier:s,emphasisMultiplier:J,fadeFactor:1,isInTail:!1}}}else{let ot=ve({word:{...S,emphasis:S.emphasis||0},currentTime:t,maxExpression:s,emotionAnimationDuration:$,wordBaseSlant:v?.slant||0,isActive:W,wordEmotion:A});it=ot.emphasisEffect,T=r?null:ot.strongEmphasisData}let M=ae[j]??1,D=(v?.opacity??x.opacity??1)*M,Z=(v?.scale??x.scale??1)*(it?.scaleMultiplier||1),gt=(v?.slant??x.slant??0)+(it?.slantAdditive||0),at=Z,Fe=it?.weightBoost||0;T&&(gt+=T.skewX||0,Fe+=T.weightBoost||0,at=Z*(T.scale||1));let V={...x,fontSize:w.fontSize,scale:at,slant:gt,stretchY:v?.stretchY??x.stretchY??1,weight:(v?.weight??x.weight??400)+Fe,width:v?.width??x.width??100,textColor:v?.textColor??x.textColor??w.textColor,opacity:D,translateX:v?.translateX??x.translateX??0,translateY:v?.translateY??x.translateY??0,textShadow:v?.textShadow??x.textShadow??"",blur:v?.blur??x.blur??0,outlineWidth:v?.outlineWidth??x.outlineWidth??0,outlineColor:v?.outlineColor??x.outlineColor??"#000000",letterShake:v?.fear??0,fontVariationAxes:{...x.fontVariationAxes,...v?.fontVariationAxes??{}},letterSpacingOffsets:[],urlJoy:v?.joy??0,urlFear:v?.fear??0,urlJoyProgress:v?.joyWaveProgress??0};r&&(V.translateX=-V.translateX,V.rotation=V.rotation?-V.rotation:0,V.slant=-V.slant,V.skewX!==void 0&&(V.skewX=-V.skewX));let Ft=A==="joy"?we(tt.length):null,En=Ft&&(Ft==="letter"||Ft==="letter-bulge")?Math.min(1.5,Math.max(0,(t-I)/Math.max(y,p.timing.minWordDisplayTime))):null;return{word:S.word||"",start:S.start,end:S.end,animationEnd:S.animationEnd||S.end,isActive:W,emotion:A,emotionIntensity:P,originalEmotionIntensity:N,fontFamily:oe,emphasis:S.emphasis||0,emphasisEffect:it,strongEmphasis:T,animationParameters:V,joyAnimationMode:Ft,joyProgress:En}}),ft=o??k,_t=C?Math.max(C.end,ft):null,Et=C&&t>=C.start&&t<=(_t||C.end),It=t>=I&&t<ft,Lt=C?!!Et:It;return{text:wt(e),words:R,currentWordIndex:Mt,emotion:E,emotionIntensity:b,fontFamily:Kt(E,s),startTime:C?.start||I,endTime:C?.end||k,isActive:Lt}}function an(e,t,n,s){let i=typeof n=="string"?n:"word",r=typeof n=="string"?s||{}:n||{};return i==="sentence"?ci(e,t,r):mi(e,t,r)}var U=["https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=sentence&text=Hahaha%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Bricolage+Grotesque%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22opsz%5C%22+12%22%7D%2C%22fontId%22%3A%22bricolage-grotesque%22%2C%22fontName%22%3A%22Bricolage+Grotesque%22%7D&skew=0%2C0%7C0.7357142857142855%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.7428571428571429%2C1%7C1.5%2C0&scale=0%2C1%7C0.7928571428571429%2C1.1214285714285714%7C1.5%2C1&standardEmphasis=0%2C0%7C0.33571428571428574%2C1%7C1.2857142857142856%2C1%7C1.2857142857142856%2C1%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.7714285714285714%2C0%7C1.5%2C0&weight=0%2C500%7C0.2%2C660%7C0.42857142857142855%2C500%7C0.6857142857142857%2C648.5714285714286%7C0.8999999999999998%2C522.8571428571429%7C1.2071428571428573%2C694.2857142857143%7C1.5%2C500&width=0%2C100%7C0.7785714285714287%2C127.14285714285714%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0%2C1%7C0.0071428571428571435%2C1%7C0.13571428571428568%2C1%7C1.342857142857143%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0%2C0%7C0.2857142857142857%2C0%7C0.29285714285714287%2C0%7C1.3357142857142856%2C0%7C1.5%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.5625%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.5625%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708602&m=1764708602","https://stage-dev.phont.ai/playground/shared?name=Celebration&user=Ray&duration=1&mode=sentence&text=Goal%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.24761904761904763%2C1.8071428571428572%7C0.6666666666666666%2C1.7214285714285715%7C1%2C1&fear=0%2C0%7C0.4%2C3%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.6047619047619047%2C0%7C0.6047619047619047%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.48571428571428565%2C200%7C0.48571428571428565%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.10952380952380952%2C36%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763670460&m=1763670460","https://stage-dev.phont.ai/playground/shared?name=Yes+Or+No%3F&user=Freddi&duration=1.5&mode=word&text=Yes+or+No%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4714285714285714%2C11.142857142857146%7C1.1071428571428572%2C-3.4285714285714306%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.3857142857142857%2C1.1214285714285714%7C1.0857142857142859%2C0.8857142857142857%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C568.5714285714287%7C0.0071428571428571435%2C545.7142857142858%7C0.47857142857142854%2C842.8571428571429%7C1.5%2C500&width=0%2C129.28571428571428%7C0.7642857142857142%2C180.71428571428572%7C1.5%2C140&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.75%2C79%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C1.125%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C1.125%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672900&m=1764709250","https://stage-dev.phont.ai/playground/shared?name=Right+Now+%28Stern%3F%29&user=Freddi&duration=1&mode=word&text=Too+funny%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.29523809523809524%2C1.2714285714285714%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0.009523809523809525%2C100%7C0.23333333333333334%2C900%7C0.3380952380952381%2C900%7C1%2C500&width=0%2C92.85714285714286%7C0.26666666666666666%2C200%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763671538&m=1764709016","https://stage-dev.phont.ai/playground/shared?name=Uh+Oh&user=Freddi&duration=1&mode=word&text=Oh+no%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.5095238095238095%2C-22.285714285714285%7C1%2C0&stretch=0%2C1%7C0.4857142857142857%2C0.95%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0.014285714285714285%2C0.2%7C0.45714285714285713%2C0.08571428571428572%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.5%2C700%7C1%2C500&width=0%2C100%7C0.5285714285714286%2C170%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=2&c=1763672318&m=1764708871","https://stage-dev.phont.ai/playground/shared?name=Stay+Quiet&user=That+hurts.&duration=2&mode=sentence&text=That+hurts.&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Cormorant%5C%22%2C+serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22cormorant%22%2C%22fontName%22%3A%22Cormorant%22%7D&skew=0%2C0%7C1.3714285714285712%2C12%7C2%2C0.8571428571428541&stretch=0%2C1%7C2%2C0.8428571428571429%7C2%2C0.5%7C2%2C0.5%7C2%2C0.5&fear=0%2C0%7C2%2C0&joy=0%2C0%7C1%2C0%7C2%2C0&scale=0%2C1.1857142857142857%7C1.838095238095238%2C0.8214285714285714%7C2%2C0.7785714285714286&standardEmphasis=0%2C0%7C1%2C0%7C2%2C0&strongEmphasis=0%2C0%7C1%2C0%7C2%2C0&translateX=0%2C0%7C1%2C0%7C2%2C0&translateY=0%2C0%7C1%2C0%7C2%2C0&weight=0%2C500%7C1.6857142857142855%2C100%7C2%2C100&width=0%2C100%7C1%2C100%7C2%2C100&ascenderHeight=0%2C750%7C1%2C750%7C2%2C750&thinStroke=0%2C79%7C1%2C79%7C2%2C79&opacity=0%2C1%7C0.2%2C1%7C1.4571428571428566%2C1%7C2%2C0.7%7C2%2C0.7&shadowX=0%2C0%7C1%2C0%7C2%2C0&shadowY=0%2C0%7C1%2C0%7C2%2C0&shadowBlur=0%2C4%7C1%2C4%7C2%2C4&shadowOpacity=0%2C0.5%7C1%2C0.5%7C2%2C0.5&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C1%2C%23ffffff%7C2%2C%23ffffff&blur=0%2C0%7C1%2C0%7C2%2C1.4285714285714284&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=3&c=1763712680&m=1764709124","https://stage-dev.phont.ai/playground/shared?name=No+way%21&user=Zaeem&duration=1&mode=word&text=No+wayy%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C0.49523809523809526%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5%2C1%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.49047619047619045%2C1.2285714285714286%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.46190476190476193%2C-11.42857142857143%7C1%2C0&weight=0%2C420%7C0.49523809523809526%2C625.7142857142857%7C1%2C431.42857142857144&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.5%2C0%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&color=0%2C%23ffffff%7C0.5%2C%23ffffff%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&v=1&c=1763713104&m=1763713104","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1.5&mode=word&text=Gross%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.4642857142857143%2C20.57142857142857%7C0.9214285714285715%2C20.57142857142857%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.7714285714285714%2C3.8571428571428568%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C0.7285714285714285%2C1.1642857142857141%7C1.5%2C1&standardEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&strongEmphasis=0%2C0%7C0.75%2C0%7C1.5%2C0&translateX=0%2C0%7C0.7428571428571429%2C-31.42857142857143%7C0.8142857142857143%2C-28.57142857142857%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C0.7142857142857142%2C225.71428571428572%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7642857142857142%2C131.85714285714286%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C0%7C0%2C0%7C0.7357142857142857%2C10%7C1.5%2C0%7C1.5%2C0&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&shadowColor=0%2C%23000000%7C0.7571428571428571%2C%2300a331%7C0.7571428571428571%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764710072&m=1764710072","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Fuck%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.21428571428571427%2C-14.571428571428573%7C1%2C0&stretch=0%2C1%7C0.24285714285714285%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5190476190476191%2C0%7C0.5190476190476191%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C0.2571428571428571%2C1.6142857142857143%7C1%2C1&standardEmphasis=0%2C0%7C0.19047619047619047%2C1%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.06190476190476191%2C11.42857142857143%7C0.12857142857142856%2C2.857142857142847%7C0.20476190476190476%2C5.714285714285722%7C0.2904761904761905%2C2.857142857142847%7C0.3619047619047619%2C8.57142857142857%7C0.43333333333333335%2C-14.285714285714292%7C0.46190476190476193%2C14.285714285714278%7C0.580952380952381%2C-11.42857142857143%7C0.6333333333333333%2C-5.714285714285722%7C0.680952380952381%2C0%7C0.7380952380952381%2C0%7C0.7952380952380952%2C5.714285714285722%7C0.9%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.10952380952380952%2C17.142857142857153%7C0.19047619047619047%2C-2.857142857142861%7C0.24285714285714285%2C14.285714285714278%7C0.3%2C-2.857142857142861%7C0.3952380952380952%2C17.142857142857153%7C0.4857142857142857%2C-11.42857142857143%7C0.5238095238095238%2C8.57142857142857%7C0.5857142857142857%2C8.57142857142857%7C0.6523809523809524%2C2.857142857142847%7C0.7333333333333333%2C5.714285714285722%7C1%2C0&weight=0%2C100%7C0.1761904761904762%2C671.4285714285714%7C1%2C100%7C1%2C100&width=0%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.49047619047619045%2C1%7C1%2C1&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.2571428571428571%2C5.714285714285715%7C1%2C0&shadowBlur=0%2C4%7C0.20476190476190476%2C12.142857142857142%7C1%2C4&shadowOpacity=0%2C0%7C0%2C0%7C0.23333333333333334%2C0.4%7C0.9571428571428572%2C0%7C0.9571428571428572%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.2714285714285714%2C%23fe3434%7C1%2C%23ffffff&blur=0%2C0%7C0.5%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708688&m=1764708688","https://stage-dev.phont.ai/playground/shared?name=Shared+Animation&user=Freddi&duration=1&mode=sentence&text=Why+me%3F&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Roboto+Flex%5C%22%2C+%5C%22Roboto%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%2C+%5C%22wdth%5C%22+100%2C+%5C%22YOPQ%5C%22+79%2C+%5C%22YTAS%5C%22+750%22%7D%2C%22fontId%22%3A%22roboto-flex%22%2C%22fontName%22%3A%22Roboto+Flex%22%7D&skew=0%2C0%7C0.2904761904761905%2C14.57142857142857%7C1%2C0&stretch=0%2C1%7C0.20476190476190476%2C1.7000000000000002%7C1%2C1&fear=0%2C0%7C0.18571428571428572%2C4.714285714285714%7C0.5%2C0%7C0.7952380952380952%2C5.142857142857143%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&translateX=0%2C0%7C0.12857142857142856%2C-2.857142857142861%7C0.21428571428571427%2C8.57142857142857%7C0.3%2C-14.285714285714292%7C0.5%2C0%7C0.5761904761904761%2C17.142857142857153%7C0.6904761904761905%2C2.857142857142847%7C0.7571428571428571%2C-2.857142857142861%7C0.8571428571428571%2C-5.714285714285722%7C0.9238095238095239%2C5.714285714285722%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C0.3142857142857143%2C317.1428571428571%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.5%2C79%7C1%2C79&opacity=0%2C1%7C0.052380952380952375%2C0%7C0.13333333333333333%2C0.7%7C0.18571428571428572%2C0.24285714285714285%7C0.2428571428571428%2C0.9285714285714286%7C0.30952380952380953%2C0.1%7C0.38571428571428573%2C0.9285714285714286%7C0.4619047619047619%2C0.22857142857142856%7C0.6190476190476191%2C0.9857142857142858%7C0.7190476190476188%2C0.5714285714285714%7C0.8%2C0.9857142857142858%7C0.9761904761904759%2C1%7C0.9761904761904759%2C1%7C1%2C0&shadowX=0%2C0%7C0.5%2C0%7C1%2C0&shadowY=0%2C0%7C0.19047619047619047%2C7.142857142857139%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.34285714285714286%7C0.1761904761904762%2C0.4142857142857143%7C1%2C0.3142857142857143&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&color=0%2C%23ffffff%7C0.5%2C%231d00f5%7C1%2C%23ffffff&blur=0%2C0%7C0.08095238095238096%2C1.7142857142857144%7C0.22857142857142856%2C0.8571428571428572%7C0.35714285714285715%2C1.7142857142857144%7C0.5%2C0%7C0.7142857142857143%2C0.8571428571428572%7C1%2C0&outlineWidth=0%2C0%7C0.75%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&v=1&c=1764708747&m=1764708747","https://stage-dev.phont.ai/playground/shared?name=Heartbeat&user=Ray&duration=1.5&mode=word&text=Heartbeat&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Parkinsans%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22%5C%22wght%5C%22+400%22%7D%2C%22fontId%22%3A%22parkinsans%22%2C%22fontName%22%3A%22Parkinsans%22%7D&skew=0%2C0%7C1.5%2C0&stretch=0%2C1%7C0.75%2C1%7C1.5%2C1&fear=0%2C0%7C0.75%2C0%7C1.5%2C0&joy=0%2C0%7C0.75%2C0%7C1.5%2C0&scale=0%2C1%7C1.5%2C1&standardEmphasis=0%2C0%7C0.7785714285714287%2C0.8571428571428571%7C1.5%2C0&strongEmphasis=0%2C0%7C0.6285714285714286%2C0%7C0.6285714285714286%2C0%7C1.5%2C0&translateX=0%2C0%7C0.75%2C0%7C1.5%2C0&translateY=0%2C0%7C0.75%2C0%7C1.5%2C0&weight=0%2C500%7C1.5%2C500&width=0%2C100%7C0.75%2C100%7C1.5%2C100&ascenderHeight=0%2C750%7C0.75%2C750%7C1.5%2C750&thinStroke=0%2C79%7C0.7142857142857142%2C135%7C1.5%2C79&opacity=0%2C1%7C0.75%2C1%7C1.5%2C1&shadowX=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowY=0%2C0%7C0.75%2C0%7C1.5%2C0&shadowBlur=0%2C4%7C0.75%2C4%7C1.5%2C4&shadowOpacity=0%2C0.5%7C0.75%2C0.5%7C1.5%2C0.5&color=0%2C%23ffffff%7C0.75%2C%23ffffff%7C1.5%2C%23ffffff&blur=0%2C0%7C0.7428571428571429%2C0%7C0.7428571428571429%2C0%7C1.5%2C0&shadowColor=0%2C%23000000%7C0.75%2C%23000000%7C1.5%2C%23000000&outlineWidth=0%2C0%7C1.3785714285714286%2C0%7C1.5%2C0&outlineColor=0%2C%23000000%7C0.75%2C%23ff0000%7C1.5%2C%23000000&v=1&c=1763751279&m=1763751279","https://stage-dev.phont.ai/playground/shared?name=Hold+on%21&user=Freddi&duration=1&mode=word&text=Hold+on%21&font=%7B%22style%22%3A%7B%22fontFamily%22%3A%22%5C%22Rakkas%5C%22%2C+sans-serif%22%2C%22fontWeight%22%3A400%2C%22fontStretch%22%3A%22100%25%22%2C%22fontVariationSettings%22%3A%22normal%22%7D%2C%22fontId%22%3A%22rakkas%22%2C%22fontName%22%3A%22Rakkas%22%7D&skew=0%2C0%7C0.5095238095238095%2C-8.57142857142857%7C1%2C0&stretch=0%2C1%7C0.5285714285714286%2C1.4857142857142858%7C0.5380952380952381%2C1.4857142857142858%7C1%2C1&fear=0%2C0%7C0.5%2C0%7C1%2C0&joy=0%2C0%7C0.5%2C0%7C1%2C0&scale=0%2C1%7C1%2C1&standardEmphasis=0%2C0%7C0.5%2C0%7C1%2C0&strongEmphasis=0%2C0%7C0.419047619047619%2C0%7C0.419047619047619%2C0%7C1%2C0&translateX=0%2C0%7C0.5%2C0%7C1%2C0&translateY=0%2C0%7C0.5%2C0%7C1%2C0&weight=0%2C500%7C1%2C500&width=0%2C100%7C0.5%2C100%7C1%2C100&ascenderHeight=0%2C750%7C0.5%2C750%7C1%2C750&thinStroke=0%2C79%7C0.4761904761904761%2C135%7C1%2C79&opacity=0%2C1%7C0.5%2C1%7C1%2C1&shadowX=0%2C0%7C0.49523809523809526%2C5.714285714285715%7C1%2C0&shadowY=0%2C0%7C0.49523809523809526%2C4.285714285714285%7C1%2C0&shadowBlur=0%2C4%7C0.5%2C4%7C1%2C4&shadowOpacity=0%2C0.5%7C0.5%2C0.5%7C1%2C0.5&shadowColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&color=0%2C%23ffffff%7C0.55%2C%23ff0000%7C1%2C%23ffffff&blur=0%2C0%7C0.49523809523809526%2C0%7C0.49523809523809526%2C0%7C1%2C0&outlineWidth=0%2C0%7C0.919047619047619%2C0%7C1%2C0&outlineColor=0%2C%23000000%7C0.55%2C%23ff0000%7C1%2C%23000000&v=2&c=1763751592&m=1764709466"],Zt={joy:U[0],anger:U[11],sadness:U[5],fear:U[4],disgust:U[7],surprise:U[6],social_positive:U[1],social_negative:U[7],lust:U[11],calmness:U[1],screaming:U[8],neutral:"?scale=0,1|1,1",karaoke:"?scale=0,1|1,1&color=0,#c8c8ff|0.5,#c8c8ff|1,#c8c8ff",none:"?scale=0,1|1,1"};function on(e){return Zt[e.toLowerCase()]||Zt.none}function ln(e,{ttlMs:t=300*1e3}={}){let n=new Map,s=new Map,i=new Map;function r(l){let d=i.get(l);return!d||Date.now()-d>t}async function a(l="default"){if(!r(l)&&n.has(l))return n.get(l);if(s.has(l))return s.get(l);let d=(async()=>{try{let u=await e(l),C=new Map;if(Array.isArray(u))for(let h of u)h.emotion&&h.url&&h.is_active&&C.set(h.emotion.toLowerCase(),h.url);return n.set(l,C),i.set(l,Date.now()),C}catch(u){console.warn("[publishedAnimationResolver] Failed to fetch active animations:",u?.message);let C=n.get(l)||new Map;return n.set(l,C),i.set(l,Date.now()),C}finally{s.delete(l)}})();return s.set(l,d),d}async function o(l,d="default"){return l&&(await a(d)).get(l.toLowerCase())||null}function c(l,d="default"){if(!l)return null;let u=n.get(d);return(!n.has(d)||r(d))&&(s.has(d)||a(d)),u?.get(l.toLowerCase())||null}function m(){n.clear(),s.clear(),i.clear()}return{prefetch:a,get:o,getSync:c,invalidate:m}}var di=["anger","joy","sadness","fear","screaming","neutral","none","disgust","social_positive","surprise","social_negative","lust","calmness"],un=["anger","fear","sadness","joy","disgust"];function Ci(e){let t=e.toLowerCase();return un.includes(t)?1.5:1}function fi(e){return e.map(([t,n])=>{let s=Ci(t),i=n*s,r=un.includes(t.toLowerCase());return[t,n,i,s,r]})}function hi(e,t=.2){if(!e||typeof e!="object")return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let n=Object.entries(e).filter(([m,l])=>di.includes(m.toLowerCase())&&typeof l=="number"&&l>t);if(n.length===0)return{emotion:"none",intensity:0,allEmotions:[],importanceFactor:1,isCore:!1};let i=fi(n).sort(([,,m],[,,l])=>l-m),[r,a,,o,c]=i[0];return{emotion:r.toLowerCase(),intensity:a,allEmotions:i,importanceFactor:o,isCore:c}}function gi(e){if(!e)return{startTime:0,endTime:0,duration:.01};let t=e.start_time||0,n=e.end_time||0;return{startTime:t,endTime:n,duration:Math.max(.01,n-t)}}function pi(e,t,n){return Math.max(0,Math.min(1,(e-t)/n))}function bi(e,t=.9){if(!e||!e.startsWith("#"))return`rgba(0, 0, 0, ${t})`;let n=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${n}, ${s}, ${i}, ${t})`}function cn(e,t="",n="",s=1){return e&&e!=="#000000"&&e!=="rgba(0, 0, 0, 1)"?`3px 2px 4px ${bi(e,.9)}`:"3px 2px 4px rgba(0, 0, 0, 0.4)"}var yi={screaming:1.5,anger:1.2,social_positive:1.05,surprise:1.03};function Si(e){return w.fontSpacingAdjustments[e]||{letterSpacing:"normal",wordSpacingMultiplier:1}}function xe(e=1,t="",n=1,s=""){let{min:i,max:r}=w.wordSpacing,a=parseFloat(i),o=parseFloat(r),m=Si(t).wordSpacingMultiplier;if(e<=1)return`${(a*m).toFixed(3)}em`;let l=Math.max(...Object.values(yi)),d=Math.min(1,(e-1)/(l-1)),u=Math.pow(d,2),h=(a+(o-a)*u)*m;return s==="anger"||s==="screaming"?`${(h*.6).toFixed(3)}em`:`${h.toFixed(3)}em`}function mn(e=1,t="",n=1,s=""){let i=parseFloat(w.wordSpacing.min),r=parseFloat(xe(e,t,n,s)),a=Math.max(0,e-1)*.12;return`${Math.min(r,i+a).toFixed(3)}em`}function Ct(e){return e?typeof e.animation_url=="string"&&e.animation_url.length>0||typeof e.emotion=="string"&&e.emotion.trim()!==""&&e.emotion.toLowerCase()!=="none"||typeof e.emotion_intensity=="number":!1}function dn(e,t){let n=Ct(e),s=typeof e?.animation_url=="string"&&e.animation_url.length>0?e.animation_url:typeof t?.animation_url=="string"&&t.animation_url.length>0?t.animation_url:null,i=typeof e?.emotion=="string"&&e.emotion.trim()!==""?e.emotion:typeof t?.emotion=="string"&&t.emotion.trim()!==""?t.emotion:null,r=typeof e?.emotion_intensity=="number"?e.emotion_intensity:typeof t?.emotion_intensity=="number"?t.emotion_intensity:null;return{animationUrl:s,emotion:i,emotionIntensity:r,hasWordOverride:n}}var Te=new Set(["none","neutral"]);function Me(e){return e?Te.has(e.toString().toLowerCase().trim()):!0}function te(e){if(!e)return!1;if(typeof e.animation_url=="string"&&e.animation_url.length>0)return!0;let t=(e.emotion??"").toString().toLowerCase().trim();return!t||Me(t)?!1:typeof e.emotion_intensity=="number"}function _e(e){let t={...e};return delete t.animation_url,delete t.emotion,delete t.emotion_intensity,t}function Ee(e){let t={...e,emotion:"none",emotion_intensity:0};return delete t.animation_url,t}function Cn(e){let t=Ee({...e});return Array.isArray(e.words)&&(t.words=e.words.map(n=>_e({...n}))),t}function fn(e){return e?te(e)?!0:(e.words||[]).some(t=>Ct(t)):!1}function ee(e){return e?`phont:manual-animations:${e}`:null}function hn(e){let t=ee(e);if(!t||typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="1"}catch{return!1}}function gn(e,t){let n=ee(e);if(!(!n||typeof window>"u"))try{t?window.localStorage.setItem(n,"1"):window.localStorage.removeItem(n)}catch{}}function ne(e){return e?`phont:manual-soundbites:${e}`:null}function pn(e){let t=ne(e);if(!t||typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="1"}catch{return!1}}function bn(e,t){let n=ne(e);if(!(!n||typeof window>"u"))try{t?window.localStorage.setItem(n,"1"):window.localStorage.removeItem(n)}catch{}}function Qt(e){return Math.max(0,Math.min(1,Math.round(e*1e3)/1e3))}function yn(e,t){let n=0,s=0;for(let i of e)if(te(i)&&typeof i.emotion_intensity=="number"&&(i.emotion_intensity=Qt(i.emotion_intensity*t),n++),!!Array.isArray(i.words))for(let r of i.words)Ct(r)&&typeof r.emotion_intensity=="number"&&(r.emotion_intensity=Qt(r.emotion_intensity*t),s++);return{segmentCount:n,wordCount:s}}function Tt(e){let t=Math.max(0,e.end-e.start);return Math.max(t,p.timing.minWordDisplayTime)}function Ie(e,t){let n=new Array(e.length).fill(null),s=-1/0;for(let i=0;i<e.length;i++){let r=e[i];if(t&&!t(r,i))continue;let a=Tt(r),o=Math.max(r.start,s);n[i]={expressiveStart:o,expressiveDuration:a},s=o+a}return n}function ie(){return w.wordAnimation?.allowOverlap!==!1}function Sn(e,t,n,s=ie()){let i=Tt(t);if(s)return Math.max(0,Math.min(1,(e-t.start)/i));if(!n)return 0;let r=n.expressiveStart,a=n.expressiveDuration;if(e<r)return 0;let o=e-r;return o>=a?0:Math.max(0,Math.min(1,o/a))}function vn(e,t){let n=typeof e=="number"?e:0;return n+Math.max(0,(typeof t=="number"?t:n)-n)/2}function wn(e,t,n){if(!Array.isArray(e)||t<0||t>=e.length)return null;let s=e[t];if(!s||typeof s.start!="number")return null;let i=Tt(s);if(n?.allowOverlap??ie())return s.start+i/2;let o=Ie(e,n?.shouldAnimate)[t];return o?o.expressiveStart+o.expressiveDuration/2:s.start+i/2}var vi=new Set(["a","an","the","in","on","at","to","for","of","with","by","from","up","about","into","over","after","as","and","but","or","nor","so","yet","if","than","that","is","am","are","was","were","be","been","being","has","have","had","do","does","did","will","would","shall","should","may","might","can","could","i","me","my","we","us","our","you","your","he","him","his","she","her","it","its","they","them","their","this","these","those","not","n't","no","just","then","also","too","very","all","each","every","some","any"]);function wi(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return Math.abs(t)%1e3/1e3}function An(e,t,n){if(!e)return 1;let s=(e.word||e.text||"").trim();if(!s)return 1;let i=s.replace(/[^\p{L}\p{N}']/gu,"").toLowerCase();if(!i)return 1;if(vi.has(i)||i.length<=2)return 0;let r=Math.min(1,i.length/7),a=wi(i);return .5*r+.5*a<.55?0:1}function Ai({strongEmphasisData:e,emphasisEffect:t,wordLetterShakeIntensity:n,wordFontFamily:s,currentTime:i,word:r,emotionAnimationDuration:a,wordEmotion:o="",totalLetters:c=1,fontSize:m=16}){let l=new Array(c).fill(0);return l}function xi(e){return e.split("").map((t,n)=>({char:t===" "?"\xA0":t,isSpace:t===" ",index:n}))}function Le(e,{minDeviation:t=.02,maxBlur:n=1.5,multiplier:s=1.5}={}){let i=Math.abs((e??1)-1);return i<=t?0:Math.min(n,i*s)}function xn(e=0,t=1,n=1){let s=1-.5*Math.min(1,Math.max(0,n??0)),i=Le(t)*s;return(e??0)+i}function se(e,t,n,s,i){let a=(Math.max(t,Math.min(n,e))-t)/(n-t);return s+a*(i-s)}function Ti(e,t,n=null,s){if(!t)return s||400;let{min:i,max:r,default:a}=t;if(typeof e!="number"||isNaN(e))return s||a;let o,c;if(n?.mapping?.volume?(o=n.mapping.volume.min,c=n.mapping.volume.max):(o=i,c=r),s!==void 0){let m=(c-o)/4,l=se(e,0,1,-m,m);return Math.round(Math.max(i,Math.min(r,s+l)))}return Math.round(se(e,0,1,o,c))}function Mi(e,t,n){if(!t)return n||100;let{min:s,max:i,default:r}=t;if(typeof e!="number"||isNaN(e))return n||r;if(n!==void 0){let a=(i-s)/4,o=se(1-e,0,1,-a,a);return Math.round(Math.max(s,Math.min(i,n+o)))}return Math.round(se(1-e,0,1,s,i))}var Tn={},Mn={"Roboto Flex":"family=Roboto+Flex:opsz,wdth,wght,YOPQ,YTAS@8..144,25..151,100..1000,25..125,649..854&display=swap",Rakkas:"family=Rakkas&display=swap",Parkinsans:"family=Parkinsans:wght@300..800&display=swap","Bricolage Grotesque":"family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,200..800&display=swap",Cormorant:"family=Cormorant:wght@300..700&display=block"};function ke(e){if(!e)return;let t=e.replace(/["']/g,"").split(",")[0].trim();if(!t||t==="sans-serif"||t==="serif"||Tn[t]||(Tn[t]=!0,typeof document>"u"))return;let n=Mn[t],s=document.createElement("link");s.rel="stylesheet",s.href=n?`https://fonts.googleapis.com/css2?${n}`:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@100..900&display=swap`,document.head.appendChild(s)}function _n(){Object.keys(Mn).forEach(e=>ke(e))}var re=class{constructor(t){if(this.apiKey=t.apiKey,this.authToken=t.authToken,this.sessionId=t.sessionId,!t.apiBaseUrl)throw new Error("PhontClient: apiBaseUrl is required. Please provide it in the options or set NEXT_PUBLIC_API_SUB_BASE_URL environment variable.");this.apiBaseUrl=t.apiBaseUrl}getAuthHeaders(){let t={};return this.apiKey?t["X-API-Key"]=this.apiKey:this.authToken&&this.sessionId&&(t.Authorization=`Bearer ${this.authToken}`,t["X-Session-ID"]=this.sessionId),t}async request(t,n={}){let s=t.startsWith("http")?t:`${this.apiBaseUrl}${t}`,i=!t.includes("/login")&&!t.includes("/register"),r={"Content-Type":"application/json",...this.getAuthHeaders(),...n.headers};i&&!this.apiKey&&(!this.authToken||!this.sessionId)&&console.warn(`PhontClient: Making request to ${t} without authentication. This may fail.`);let a=await fetch(s,{...n,headers:r});if(!a.ok){let o=`HTTP error! status: ${a.status}`;try{let m=await a.clone().json();if(m.message)o=m.message;else if(m.error)o=m.error;else if(Array.isArray(m.detail)){let l=m.detail.map(d=>{let u=Array.isArray(d.loc)?d.loc.filter(C=>C!=="body").join("."):"";return u?`${u}: ${d.msg||"invalid"}`:d.msg||"invalid"});l.length&&(o=l.join("; "))}else typeof m.detail=="string"&&(o=m.detail)}catch{try{let m=await a.clone().text();m&&(o=m)}catch{}}let c=new Error(o);throw c.status=a.status,c.response=a,c}return a}async login(t,n){let i=await(await this.request("/login",{method:"POST",body:JSON.stringify({identifier:t,password:n})})).json();if(!i.session_id||!i.auth_token)throw new Error("Invalid response from server: missing session_id or auth_token");return this.authToken=i.auth_token,this.sessionId=i.session_id,i}async register(t,n,s,i){return(await this.request("/register",{method:"POST",body:JSON.stringify({username:t,email:n,password:s,company:i.company,first_name:i.first_name,last_name:i.last_name})})).json()}async getSubtitleTrack(t,n,s){let i=new URLSearchParams;n&&typeof n=="string"&&n.trim()&&i.append("lang",n.trim()),s&&typeof s=="string"&&s.trim()&&i.append("model",s.trim());let r=i.toString(),a=r?`/vod-subtitles/${t}?${r}`:`/vod-subtitles/${t}`;return(await this.request(a)).json()}async getVod(t){return(await this.request(`/vods/${t}`)).json()}async listVods(t=0,n=10){return(await this.request(`/vods?skip=${t}&limit=${n}`)).json()}async createVod(t){return(await this.request("/vods",{method:"POST",body:JSON.stringify(t)})).json()}async deleteVod(t){await this.request(`/vods/${t}`,{method:"DELETE"})}async getVodStatus(t){return(await this.request(`/vods/status/${t}`)).json()}setCredentials(t){t.apiKey!==void 0&&(this.apiKey=t.apiKey),t.authToken!==void 0&&(this.authToken=t.authToken),t.sessionId!==void 0&&(this.sessionId=t.sessionId)}clearCredentials(){this.apiKey=void 0,this.authToken=void 0,this.sessionId=void 0}};0&&(module.exports={ANIMATION_STYLING,ANIMATION_URLS,AUTHORED_PLAYBACK_OPTIONS,EMOTION_ANIMATION_URLS,NORMAL_ANIMATION_EMOTIONS,PhontClient,REFERENCE_GTS,REFERENCE_INTENSITY,RENDERING_CONTROL,SubtitleManager,SubtitleStateManager,buildSequentialExpressiveSchedule,calculateAnimationParameters,calculateAnimationState,calculateDynamicWordSpacing,calculateEmphasisMultiplier,calculateGTSValues,calculateJoy,calculateJoyBulge,calculateNormalizedTime,calculatePerWordSpacing,calculateWeightFromVolume,calculateWidthFromSpeechRate,calculateWordEmphasisEffects,calculateWordExpressiveProgress,calculateWordLetterSpacing,capEmotionIntensity,clampAnimationIntensity,clearSegmentAnimationFields,clearWordAnimationFields,computeProsodyWeight,createBitmovinLiveSegmentSource,createHlsLiveSegmentSource,createLiveSegmentSource,createPublishedAnimationResolver,createShakaLiveSegmentSource,decodeAnimationUrl,ensureFont,findSubtitleForWord,generateTextShadow,getAnimationUrlForEmotion,getCombinedBlurAmount,getCurrentAuthToken,getCurrentSessionId,getFontFamilyCSS,getJoyAnimationMode,getJoyFilter,getJoyTransform,getManualAnimationsStorageKey,getManualSoundbitesStorageKey,getMergedSubtitles,getMotionBlurAmount,getSegmentAnimationPreviewTime,getSubtitleAnimations,getSubtitleText,getSubtitleTiming,getSubtitleWords,getWordAnimationPreviewTime,getWordEmphasis,getWordExpressiveDuration,hasMergedSubtitles,hasSegmentAnimationOverride,hasWordAnimationOverride,hockeyStickIntensity,isInEmphasisRange,isInStrongEmphasisRange,isNormalAnimationEmotion,isSubtitleDebugEnabled,isWordAnimationOverlapAllowed,logSubtitleData,meetsEmotionThreshold,preloadAnimationFonts,processEmotionsWithImportance,readManualAnimationsPreference,readManualSoundbitesPreference,resetSubtitleToNormal,resolveEffectiveGts,resolveWordAnimationSource,sampleParameterCurve,scaleAuthorAnimationIntensities,selectEmotion,selectFontFamily,shouldUseAngryFont,shouldUseJoyFont,shouldUseSadnessFont,splitTextIntoLetters,subtitleHasAnyAnimationOverride,subtitleManager,writeManualAnimationsPreference,writeManualSoundbitesPreference});
|