@banou/stub 0.0.81 → 0.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{B as e,K as t,P as n,Z as r,a as i,bt as a,c as o,ft as s,i as c,m as l,n as u,o as d,q as f,s as p,t as m,tt as h}from"./lib-track-languages-DeHLRrle.js";import{M as g,f as _,j as v}from"./lib-intl-_4f6zNc2.js";import{V as y,W as ee,ft as b,ht as te,pt as x,r as S,ut as C}from"./lib-chapters-EBYXcEml-0fd33E6j.js";var w={type:`conjunction`,style:`narrow`},ne=_(),T=e=>e.flatMap(e=>e.type===v.argument?[{type:v.literal,value:`⁨`},e,{type:v.literal,value:`⁩`}]:e.type===v.tag?[{...e,children:T(e.children)}]:e.type===v.select||e.type===v.plural?[{...e,options:Object.fromEntries(Object.entries(e.options).map(([e,t])=>[e,{...t,value:T(t.value)}]))}]:[e]),re=(e,t=` · `)=>{let n=e.filter(e=>!!e);return(f(E.locale)?n.map(e=>`\u2068${e}\u2069`):n).join(t)},ie=e=>{try{return T(g(e))}catch{return e}},ae=(e,t,n)=>ee({locale:t,defaultLocale:e===`en`?t:`en`,messages:n},ne),E=ae(`en`,`en`,{}),D=e=>typeof e==`object`?`time`in e?E.formatTime(e.time,{hour:`2-digit`,minute:`2-digit`}):`list`in e?E.formatList(e.list.map(e=>String(D(e))),e.join===`and`?{type:`conjunction`}:w):O(e):e,O=e=>{if(typeof e==`string`)return e;let t={id:e.message,defaultMessage:e.message};return E.formatMessage(t,e.values&&Object.fromEntries(Object.entries(e.values).map(([e,t])=>[e,D(t)])))},oe=/* #__PURE__ */ Object.assign({"../locales/ar.json":()=>import(`./lib-ar-CgLEvHKh.js`).then(e=>e.default),"../locales/cs.json":()=>import(`./lib-cs-z6-m52XC.js`).then(e=>e.default),"../locales/de.json":()=>import(`./lib-de-DRvwZR3H.js`).then(e=>e.default),"../locales/el.json":()=>import(`./lib-el-PAakHtET.js`).then(e=>e.default),"../locales/es-419.json":()=>import(`./lib-es-419-BJv0wjV_.js`).then(e=>e.default),"../locales/fr.json":()=>import(`./lib-fr-OiId2v-H.js`).then(e=>e.default),"../locales/he.json":()=>import(`./lib-he-B2_LeVeD.js`).then(e=>e.default),"../locales/hi.json":()=>import(`./lib-hi-DPwXz8H3.js`).then(e=>e.default),"../locales/hu.json":()=>import(`./lib-hu-BdzB_JPB.js`).then(e=>e.default),"../locales/id.json":()=>import(`./lib-id-BW-jdZEK.js`).then(e=>e.default),"../locales/it.json":()=>import(`./lib-it-BBrmPXkE.js`).then(e=>e.default),"../locales/ja.json":()=>import(`./lib-ja-fXiouS2g.js`).then(e=>e.default),"../locales/ko.json":()=>import(`./lib-ko-KBHBgIBH.js`).then(e=>e.default),"../locales/ms.json":()=>import(`./lib-ms-CxfGSa1W.js`).then(e=>e.default),"../locales/nl.json":()=>import(`./lib-nl-DkimY56E.js`).then(e=>e.default),"../locales/pl.json":()=>import(`./lib-pl-DYs8R_wN.js`).then(e=>e.default),"../locales/pt-BR.json":()=>import(`./lib-pt-BR-rY35hakH.js`).then(e=>e.default),"../locales/ro.json":()=>import(`./lib-ro-kvvaEZ3M.js`).then(e=>e.default),"../locales/ru.json":()=>import(`./lib-ru-02Njkw2V.js`).then(e=>e.default),"../locales/sv.json":()=>import(`./lib-sv-CIevMFTp.js`).then(e=>e.default),"../locales/th.json":()=>import(`./lib-th-CmBMfZ3-.js`).then(e=>e.default),"../locales/tr.json":()=>import(`./lib-tr-BfUJOedF.js`).then(e=>e.default),"../locales/uk.json":()=>import(`./lib-uk-BiGFd-3R.js`).then(e=>e.default),"../locales/vi.json":()=>import(`./lib-vi-DtAr1nx5.js`).then(e=>e.default),"../locales/zh-Hans.json":()=>import(`./lib-zh-Hans-h0aj_oyp.js`).then(e=>e.default),"../locales/zh-Hant.json":()=>import(`./lib-zh-Hant-CPR3PIcu.js`).then(e=>e.default)}),se=async({language:e=r(),languages:n,catalogues:i=oe,html:a=globalThis.document?.documentElement}={})=>{let o=e===`en`?{}:await i[`../locales/${e}.json`]?.().catch(()=>void 0),s=o?e:`en`,c=o&&f(s)?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,ie(t)])):o??{};return E=ae(s,t(s,n),c),a&&(a.lang=s,f(s)?a.dir=`rtl`:a.removeAttribute(`dir`)),E},ce=e=>{let t=e[0];for(let n of e)t&&n.id.startsWith(`${t.id}-`)&&(t=n);return t},le=(e,t)=>F(e)?ce(I(e)?.handleUrisValues.filter(e=>e.origin===t)??[]):M(e)&&k(e).origin===t?k(e):void 0,k=e=>{let[t,n]=e.split(`:`);return{origin:t,id:n}},ue=(e,t)=>{let n=e.split(`,`).filter(Boolean).map(e=>k(e));return t?n.find(({origin:e})=>e===t):n},A=({origin:e,id:t})=>`${e}:${t}`,j=e=>e.join(`,`),M=e=>{let t=e.split(`:`).filter(e=>e.length);if(t[1]?.includes(`,`))throw Error(`Invalid uri: ${e}, contains "," character in id`);return t.length===2},de=/[,/()]/,N=e=>{let t=e.indexOf(`:`);return t>0&&!de.test(e.slice(t+1))},fe=e=>e.split(`,`).every(M),P=/ag:\((.*)\)(?:-(.*))?/,F=e=>{if(!e?.startsWith(`ag:`))return!1;let t=e.match(P);if(!t)return!1;let n=t?.[1];return!n||fe(n)},pe=e=>F(e)||!N(e)||!M(e)?e:_e([e]),me=(e,t,n)=>{if(!e||!t||e===t||!F(e)||!F(t)||!be(e,t))return!1;if(t===n)return!0;let r=I(e)?.handleUris??[],i=I(t)?.handleUris??[];return r.length>i.length},he=e=>{if(!e||M(e)||F(e))return e;try{let t=decodeURIComponent(e);return M(t)||F(t)?t:e}catch{return e}},ge=e=>{let t=he(e);return t&&pe(t)},_e=(e,t)=>`ag:(${ve(e)})${t?`-${t}`:``}`,ve=(e,t=!0)=>t?ve(ue(Array.isArray(e)?e.join(`,`):e).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin)).map(A),!1):encodeURI(Array.isArray(e)?e.join(`,`):e),I=e=>{if(typeof e!=`string`)return;let t=e.match(P);if(!t)return;let n=ue(t[1]).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin));return t&&{uri:`ag:(${j(n.map(A))})`,origin:`ag`,id:`(${j(n.map(A))})`,handleUris:n.map(A),handleUrisString:j(n.map(A)),handleUrisValues:n,episodeId:t[2]}},ye=e=>F(e)?[...new Set(I(e)?.handleUrisValues.map(e=>e.origin)??[])]:M(e)?[k(e).origin]:[],be=(e,t)=>{let n=I(e),r=I(t);return!n||!r?!1:n.handleUris.some(e=>r.handleUris.some(t=>e===t))};x();var L=`stub.player.autoplay`,xe=()=>h.getItem(L)!==`off`,R=e=>{try{e?h.removeItem(L):h.setItem(L,`off`)}catch{}},Se=e=>h.watch(L,e),z=(e,...t)=>{e.postMessage(...t)},B=`stub:embed-tracks`,V=`stub:embed-tracks?`,H=`stub:embed-track-pick`,Ce=[`subtitles`,`audio`],we=(e,t,n=window)=>{let r=()=>z(n.parent,{type:B,tracks:e},n.location.origin),i=e=>{if(e.source!==n.parent||e.origin!==n.location.origin)return;let{type:i,kind:a,id:o}=e.data??{};i===V&&r(),i===H&&t(a,o)};return n.addEventListener(`message`,i),n.parent!==n&&r(),()=>n.removeEventListener(`message`,i)},Te=(e,t=window)=>{let n=/* @__PURE__ */ new Set,r,i=i=>{if(i.source!==e.contentWindow||i.origin!==t.location.origin)return;let{type:a,tracks:o}=i.data??{};if(a===B){r=o;for(let e of n)e(o)}},a=n=>{e.contentWindow&&z(e.contentWindow,n,t.location.origin)},o=()=>a({type:V});return t.addEventListener(`message`,i),e.addEventListener(`load`,o),{onTracks:e=>(n.add(e),r&&e(r),()=>{n.delete(e)}),select:(e,t)=>a({type:H,kind:e,id:t}),dispose:()=>{t.removeEventListener(`message`,i),e.removeEventListener(`load`,o)}}},Ee=(e,t)=>{let[n,r]=b(e);return C(()=>(r(e()),t(()=>r(e()))),[]),n},De=[`amazon.co.jp`,`www.amazon.co.jp`,`watch.amazon.co.jp`,`amazon.com`,`www.amazon.com`,`watch.amazon.com`,`amazon.co.uk`,`www.amazon.co.uk`,`watch.amazon.co.uk`,`amazon.de`,`www.amazon.de`,`watch.amazon.de`,`primevideo.com`,`www.primevideo.com`,`app.primevideo.com`,`media-amazon.com`,`ssl-images-amazon.com`,`aiv-cdn.net`,`pv-cdn.net`,`aiv-delivery.net`,`a2z.com`,`prime-video.amazon.dev`],Oe={US:`amazon.com`,PR:`amazon.com`,GU:`amazon.com`,VI:`amazon.com`,AS:`amazon.com`,MP:`amazon.com`,UM:`amazon.com`,GB:`amazon.co.uk`,DE:`amazon.de`,AT:`amazon.de`,JP:`amazon.co.jp`},U=e=>Oe[e]??`primevideo.com`,W=e=>URL.parse(e)?.hostname.replace(/^(www|watch|app)\./,``),ke=e=>W(e)===U(l()),Ae=e=>e===`amazon.co.jp`,je=`https://www.amazon.co.jp/ap/signin?${new URLSearchParams({"openid.return_to":`https://www.amazon.co.jp/gp/video/storefront`,"openid.identity":`http://specs.openid.net/auth/2.0/identifier_select`,"openid.assoc_handle":`jpflex`,"openid.mode":`checkid_setup`,"openid.claimed_id":`http://specs.openid.net/auth/2.0/identifier_select`,"openid.ns":`http://specs.openid.net/auth/2.0`})}`,Me=e=>e===`amazon.co.jp`?je:e===`primevideo.com`?`https://www.primevideo.com/auth-redirect?signin=1&returnUrl=%2Fstorefront`:`https://www.${e}/gp/video/auth-redirect?signin=1&returnUrl=%2Fgp%2Fvideo%2Fstorefront`,Ne=`a[data-csa-c-content-id="nav_ya_signin"], [data-testid="pv-nav-sign-in"]`,Pe=async e=>await e.locator(`#nav-link-accountList, #pv-footer`).exists()&&!await e.locator(`a[data-csa-c-content-id="nav_ya_signin"], [data-testid="pv-nav-sign-in"]`).exists(),G=1,Fe=6e3,Ie=1,K=10,Le=120,Re=e=>e.title===`Preview`,q=e=>e!==void 0&&Number.isFinite(e)&&e>0,J=(e,t)=>{let n=e[S(e).lastIndexOf(`ending`)];return n&&{ending:n,after:t-n.end}},ze=e=>S(e).includes(`ending`),Be=e=>q(e)&&e>=60?e-30:void 0,Ve=(e,t)=>{if(!q(t))return;let n=J(e,t);if(n&&n.after<K)return n.ending.start-G;if(n&&n.after<=Le)return n.ending.end-G;let r=e.findLast(e=>Re(e)&&t-e.end<K);return r&&r.start-G},He=(e,t)=>{let n=q(t)?J(e,t):void 0;return n&&n.after<K?e.filter(e=>e!==n.ending):e},Ue=e=>{let t,n,r=0,i=()=>clearTimeout(t),a=(o,{paused:s,time:c,rate:l,at:u},d)=>{i();let f=S(o),p=o.filter((e,t)=>f[t]),m=p.find(({start:e,end:t})=>e-G<=c&&c<t);(m?m.end!==n?.end||!d&&c<r-Ie:!d)&&(n=m&&{end:m.end,at:u}),d||(r=c);let h=!s&&l>0,g=m&&n?Math.min(n.at+Fe-u,h?(m.end-c)/l*1e3:1/0):0;e(g>0);let _=h?p.find(({start:e})=>e-G>c):void 0,v=g>0?g:_&&(_.start-G-c)/l*1e3;if(v===void 0)return;let y=Math.ceil(v);t=setTimeout(()=>a(o,{paused:s,rate:l,time:h?c+y/1e3*l:c,at:u+y},!0),y)};return{hear:(e,t)=>a(e,t,!1),stop:i}};x();var We=e=>`https://static.crunchyroll.com/skip-events/production/${e}.json`,Y=e=>{try{return new URL(e).pathname.match(/\/watch\/([A-Z0-9]+)(?:\/|$)/)?.[1]}catch{return}},Ge=[[`intro`,`Opening`],[`recap`,`Recap`],[`credits`,`Ending`],[`preview`,`Preview`]],Ke=`Episode`,qe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Je=(e,t)=>{if(!qe(e))return[];let n=t!==void 0&&Number.isFinite(t)&&t>0?t:1/0,r=Ge.flatMap(([t,r])=>{let i=e[t];if(!qe(i))return[];let{start:a,end:o}=i;if(typeof a!=`number`||typeof o!=`number`||!Number.isFinite(a)||!Number.isFinite(o))return[];let s={start:Math.max(0,a),end:Math.min(o,n),title:r};return s.end>s.start?[s]:[]}).sort((e,t)=>e.start-t.start),i=[],a=0;for(let e of r){let t=Math.max(e.start,a);e.end<=t||(t>a&&i.push({start:a,end:t,title:Ke}),i.push({start:t,end:e.end,title:e.title}),a=e.end)}return i.length&&n!==1/0&&a<n&&i.push({start:a,end:n,title:Ke}),i},Ye=/* @__PURE__ */ new Set([403,404]),Xe=async(t,n=e)=>{let r=await n(We(t));if(!r.ok){if(await r.body?.cancel().catch(()=>{}),Ye.has(r.status))return{};throw Error(`${We(t)} answered ${r.status}`)}return r.json()},Ze=e=>{let[t,n]=b();return C(()=>{if(n(e?.duration),!e)return;let t=()=>n(e.duration);return e.addEventListener(`durationchange`,t),e.addEventListener(`loadedmetadata`,t),()=>{e.removeEventListener(`durationchange`,t),e.removeEventListener(`loadedmetadata`,t)}},[e]),t},Qe=[],$e=e=>{let[t,n]=b();return C(()=>{if(!e)return;let t=!1;return Xe(e).then(r=>{t||n({episodeId:e,events:r})},e=>{t||console.warn(`[cr] skip events unavailable:`,e)}),()=>{t=!0}},[e]),e&&t?.episodeId===e?t.events:void 0},et=(e,t)=>{let n=$e(Y(e)),r=Ze(t);return te(()=>{let e=He(Je(n,r),r);return e.length?e:Qe},[n,r])};x();var tt=`stub:embed-fullscreen`,nt=`stub:embed-fullscreen?`,rt=`stub:embed-fullscreen-request`,it=(e,t,n,r)=>{let i=i=>{let a=i.target;i.key!==`f`||i.repeat||i.ctrlKey||i.metaKey||i.altKey||a?.isContentEditable||/^(input|textarea|select)$/i.test(a?.tagName??``)||(e.fullscreenElement?e.exitFullscreen().catch(()=>{}):(n?.blur(),n?.focus(),t.requestFullscreen().then(r,()=>{})))};return e.addEventListener(`keydown`,i),()=>e.removeEventListener(`keydown`,i)},at=(e,t,n=window)=>{let{document:r}=n;if(!r.fullscreenEnabled)return()=>{};let i=it(r,t,e),a=()=>{e.contentWindow&&z(e.contentWindow,{type:tt,active:!!r.fullscreenElement},n.location.origin)},o=i=>{if(i.source!==e.contentWindow||i.origin!==n.location.origin)return;let o=i.data?.type;o===nt?a():o===rt&&(r.fullscreenElement?r.exitFullscreen():t.requestFullscreen()).catch(()=>{})};return n.addEventListener(`message`,o),r.addEventListener(`fullscreenchange`,a),a(),()=>{i(),n.removeEventListener(`message`,o),r.removeEventListener(`fullscreenchange`,a)}},ot=(e,t=window)=>{let n=()=>z(t.parent,{type:rt},t.location.origin),r=r=>{if(r.source!==t.parent||r.origin!==t.location.origin)return;let{type:i,active:a}=r.data??{};i===tt&&typeof a==`boolean`&&e({active:a,request:n})};return t.addEventListener(`message`,r),t.parent!==t&&z(t.parent,{type:nt},t.location.origin),()=>t.removeEventListener(`message`,r)},st=()=>{let[e,t]=b();return C(()=>ot(t),[]),e};x();var ct=`stub:embed-episode`,lt=`stub:embed-episode?`,ut=`stub:embed-episode-request`,dt=(e,t,n,r=window)=>{let i=t.previous||!1,a=t.next||!1,o=()=>{e.contentWindow&&z(e.contentWindow,{type:ct,previous:i,next:a},r.location.origin)},s=t=>{if(t.source!==e.contentWindow||t.origin!==r.location.origin)return;let{type:s,direction:c}=t.data??{};s===lt?o():s===ut&&(c===`previous`&&i||c===`next`&&a)&&n(c)};return r.addEventListener(`message`,s),o(),()=>r.removeEventListener(`message`,s)},ft=e=>typeof e==`string`||typeof e==`boolean`,pt=(e,t,n)=>e?{...typeof e==`string`&&e?{title:e}:{},request:()=>z(n.parent,{type:ut,direction:t},n.location.origin)}:null,mt=(e,t=window)=>{let n=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let{type:r,previous:i,next:a}=n.data??{};r===ct&&ft(i)&&ft(a)&&e(i||a?{previous:pt(i,`previous`,t),next:pt(a,`next`,t)}:void 0)};return t.addEventListener(`message`,n),t.parent!==t&&z(t.parent,{type:lt},t.location.origin),()=>t.removeEventListener(`message`,n)},ht=(e=window)=>{let[t,n]=b(void 0);return C(()=>mt(n,e),[e]),t};x();var gt=`stub:embed-subtitles`,X=`stub:embed-subtitles?`,_t=`stub:embed-subtitles-load`,Z=`stub:embed-subtitles-loaded`,vt=(e,t,n=window)=>{let r=!1,i=t?.tracks??[],a=()=>{e.contentWindow&&z(e.contentWindow,{type:gt,tracks:i},n.location.origin)},o=i=>{if(i.source!==e.contentWindow||i.origin!==n.location.origin)return;let{type:o,requestId:s,id:c}=i.data??{};o===X?a():o===_t&&typeof s==`string`&&typeof c==`string`&&(t?t.load(c).then(t=>{!r&&e.contentWindow&&z(e.contentWindow,{type:Z,requestId:s,text:t},n.location.origin)},t=>{if(!r&&e.contentWindow){let r=t instanceof Error?t.message:String(t);z(e.contentWindow,{type:Z,requestId:s,error:r},n.location.origin)}}):e.contentWindow&&z(e.contentWindow,{type:Z,requestId:s,error:`External subtitles unavailable`},n.location.origin))};return n.addEventListener(`message`,o),a(),()=>{r=!0,n.removeEventListener(`message`,o)}},yt=e=>!!(e&&typeof e==`object`&&typeof e.id==`string`&&typeof e.language==`string`&&typeof e.label==`string`&&typeof e.format==`string`),bt=(e,t=window)=>{let n=0,r=/* @__PURE__ */ new Map,i=e=>new Promise((i,a)=>{let o=`sub-${++n}`;r.set(o,{trackId:e,resolve:i,reject:a}),z(t.parent,{type:_t,requestId:o,id:e},t.location.origin)}),a=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let a=n.data??{};if(a.type===gt&&Array.isArray(a.tracks)){let t=a.tracks.filter(yt),n=new Set(t.map(e=>e.id));for(let[e,t]of[...r.entries()])n.has(t.trackId)||(r.delete(e),t.reject(/* @__PURE__ */ Error(`External subtitle track was removed`)));e(t.length?t.map(e=>({...e,load:()=>i(e.id)})):void 0)}else if(a.type===Z&&typeof a.requestId==`string`){let e=r.get(a.requestId);if(!e)return;r.delete(a.requestId),typeof a.text==`string`?e.resolve(a.text):e.reject(Error(typeof a.error==`string`?a.error:`External subtitle load failed`))}};return t.addEventListener(`message`,a),t.parent!==t&&z(t.parent,{type:X},t.location.origin),()=>{t.removeEventListener(`message`,a);for(let e of r.values())e.reject(/* @__PURE__ */ Error(`External subtitle host disconnected`));r.clear()}},xt=(e=window)=>{let[t,n]=b(void 0);return C(()=>bt(n,e),[e]),t},Q=`stub:embed-language-picked`,St=()=>Object.fromEntries([u,c,m].flatMap(e=>{let t=h.getItem(e);return t===null?[]:[[e,t]]})),Ct=e=>o(t=>e.get(t)),wt=(e,t=window)=>{let n=n=>{if(n.source!==e.contentWindow||n.origin!==t.location.origin)return;let{type:r,kind:a,language:o,on:s}=n.data??{};r===Q&&(a===`audio`&&typeof o==`string`&&d(o),a===`subtitles`&&(typeof o==`string`||o===null)&&p(o),a===`always-subtitles`&&typeof s==`boolean`&&i(s),a===`autoplay`&&typeof s==`boolean`&&R(s))};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)},Tt=(e,t,n=window)=>{n.parent!==n&&z(n.parent,{type:Q,kind:e,language:t},n.location.origin)},Et=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Q,kind:`always-subtitles`,on:e},t.location.origin)},Dt=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Q,kind:`autoplay`,on:e},t.location.origin)},Ot=`stub:embed-relay-tried`,kt=`triedRelays`,$=/* @__PURE__ */ new Map,At=e=>e.split(`-`)[0],jt=e=>{let t=$.get(At(e));return t?.length?{[kt]:t.join(`,`)}:{}},Mt=e=>e.get(kt)?.split(`,`).filter(Boolean)??[],Nt=(e,t,n=window)=>{let r=r=>{if(r.source!==e.contentWindow||r.origin!==n.location.origin)return;let{type:i,relay:a}=r.data??{};if(i!==Ot||typeof a!=`string`)return;let o=At(t),s=$.get(o)??[];s.includes(a)||$.set(o,[...s,a])};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)},Pt=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Ot,relay:e},t.location.origin)},Ft=`stub:embed-unplayable`,It=(e,t,n=window)=>{let r=r=>{r.source===e.contentWindow&&r.origin===n.location.origin&&r.data?.type===Ft&&t()};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)},Lt=(e=window)=>{e.parent!==e&&z(e.parent,{type:Ft},e.location.origin)},Rt=`stub:embed-title`,zt=`stub:embed-title?`,Bt=(e,t,n=window)=>{let r=()=>{e.contentWindow&&z(e.contentWindow,{type:Rt,title:t},n.location.origin)},i=t=>{t.source===e.contentWindow&&t.origin===n.location.origin&&t.data?.type===zt&&r()};return n.addEventListener(`message`,i),r(),()=>n.removeEventListener(`message`,i)},Vt=(e,t=window)=>{let n=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let{type:r,title:i}=n.data??{};r===Rt&&typeof i==`string`&&e(i)};return t.addEventListener(`message`,n),t.parent!==t&&z(t.parent,{type:zt},t.location.origin),()=>t.removeEventListener(`message`,n)},Ht=5e3,Ut=async(e,t)=>{let r=await s.fetch(`${n}/auth/v1/token`,{method:`POST`,headers:{authorization:`Basic ${btoa(`cr_web:`)}`,"content-type":`application/x-www-form-urlencoded`},body:`grant_type=client_id&device_id=${crypto.randomUUID()}`,relay:t}),i=a(r),{access_token:o}=await r.json();if(!i||!o)throw Error(`Crunchyroll token through ${i}: ${r.status}`);let c=await s.fetch(`${n}/content/v2/cms/objects/${e}?ratings=true&locale=en-US`,{headers:{authorization:`Bearer ${o}`},relay:{id:i}});if(!c.ok&&c.status!==404)throw Error(`Crunchyroll episode through ${i}: ${c.status}`);return{relay:i,episode:c}},Wt=async(e,t)=>{let{relay:n,episode:r}=await Ut(e,t);return{relay:n,listed:r.ok}},Gt=async e=>{let t=Y(e);if(!t)return;let{episode:n}=await Ut(t,{});if(!n.ok)return;let{data:r}=await n.json(),i=r?.[0]?.episode_metadata?.duration_ms;return typeof i==`number`&&Number.isFinite(i)&&i>0?i/1e3:void 0},Kt=async(e,t)=>{let n=Y(e);if(!n)return[];let r=async()=>{let e=[];for(;;){let{relay:r,listed:i}=await Wt(n,{exclude:[...t,...e]});if(i)return e;if(t.includes(r)||e.includes(r))return[];e.push(r)}},i,a=new Promise(e=>{i=setTimeout(e,Ht,[])});return Promise.race([r().catch(()=>[]),a]).finally(()=>clearTimeout(i))},qt=y`
1
+ import{B as e,K as t,P as n,Z as r,a as i,bt as a,c as o,ft as s,i as c,m as l,n as u,o as d,q as f,s as p,t as m,tt as h}from"./lib-track-languages-DnB3w_Os.js";import{M as g,f as _,j as v}from"./lib-intl-_4f6zNc2.js";import{V as y,W as ee,ft as b,ht as te,pt as x,r as S,ut as C}from"./lib-chapters-EBYXcEml-0fd33E6j.js";var w={type:`conjunction`,style:`narrow`},ne=_(),T=e=>e.flatMap(e=>e.type===v.argument?[{type:v.literal,value:`⁨`},e,{type:v.literal,value:`⁩`}]:e.type===v.tag?[{...e,children:T(e.children)}]:e.type===v.select||e.type===v.plural?[{...e,options:Object.fromEntries(Object.entries(e.options).map(([e,t])=>[e,{...t,value:T(t.value)}]))}]:[e]),re=(e,t=` · `)=>{let n=e.filter(e=>!!e);return(f(E.locale)?n.map(e=>`\u2068${e}\u2069`):n).join(t)},ie=e=>{try{return T(g(e))}catch{return e}},ae=(e,t,n)=>ee({locale:t,defaultLocale:e===`en`?t:`en`,messages:n},ne),E=ae(`en`,`en`,{}),D=e=>typeof e==`object`?`time`in e?E.formatTime(e.time,{hour:`2-digit`,minute:`2-digit`}):`list`in e?E.formatList(e.list.map(e=>String(D(e))),e.join===`and`?{type:`conjunction`}:w):O(e):e,O=e=>{if(typeof e==`string`)return e;let t={id:e.message,defaultMessage:e.message};return E.formatMessage(t,e.values&&Object.fromEntries(Object.entries(e.values).map(([e,t])=>[e,D(t)])))},oe=/* #__PURE__ */ Object.assign({"../locales/ar.json":()=>import(`./lib-ar-CgLEvHKh.js`).then(e=>e.default),"../locales/cs.json":()=>import(`./lib-cs-z6-m52XC.js`).then(e=>e.default),"../locales/de.json":()=>import(`./lib-de-DRvwZR3H.js`).then(e=>e.default),"../locales/el.json":()=>import(`./lib-el-PAakHtET.js`).then(e=>e.default),"../locales/es-419.json":()=>import(`./lib-es-419-BJv0wjV_.js`).then(e=>e.default),"../locales/fr.json":()=>import(`./lib-fr-OiId2v-H.js`).then(e=>e.default),"../locales/he.json":()=>import(`./lib-he-B2_LeVeD.js`).then(e=>e.default),"../locales/hi.json":()=>import(`./lib-hi-DPwXz8H3.js`).then(e=>e.default),"../locales/hu.json":()=>import(`./lib-hu-BdzB_JPB.js`).then(e=>e.default),"../locales/id.json":()=>import(`./lib-id-BW-jdZEK.js`).then(e=>e.default),"../locales/it.json":()=>import(`./lib-it-BBrmPXkE.js`).then(e=>e.default),"../locales/ja.json":()=>import(`./lib-ja-fXiouS2g.js`).then(e=>e.default),"../locales/ko.json":()=>import(`./lib-ko-KBHBgIBH.js`).then(e=>e.default),"../locales/ms.json":()=>import(`./lib-ms-CxfGSa1W.js`).then(e=>e.default),"../locales/nl.json":()=>import(`./lib-nl-DkimY56E.js`).then(e=>e.default),"../locales/pl.json":()=>import(`./lib-pl-DYs8R_wN.js`).then(e=>e.default),"../locales/pt-BR.json":()=>import(`./lib-pt-BR-rY35hakH.js`).then(e=>e.default),"../locales/ro.json":()=>import(`./lib-ro-kvvaEZ3M.js`).then(e=>e.default),"../locales/ru.json":()=>import(`./lib-ru-02Njkw2V.js`).then(e=>e.default),"../locales/sv.json":()=>import(`./lib-sv-CIevMFTp.js`).then(e=>e.default),"../locales/th.json":()=>import(`./lib-th-CmBMfZ3-.js`).then(e=>e.default),"../locales/tr.json":()=>import(`./lib-tr-BfUJOedF.js`).then(e=>e.default),"../locales/uk.json":()=>import(`./lib-uk-BiGFd-3R.js`).then(e=>e.default),"../locales/vi.json":()=>import(`./lib-vi-DtAr1nx5.js`).then(e=>e.default),"../locales/zh-Hans.json":()=>import(`./lib-zh-Hans-h0aj_oyp.js`).then(e=>e.default),"../locales/zh-Hant.json":()=>import(`./lib-zh-Hant-CPR3PIcu.js`).then(e=>e.default)}),se=async({language:e=r(),languages:n,catalogues:i=oe,html:a=globalThis.document?.documentElement}={})=>{let o=e===`en`?{}:await i[`../locales/${e}.json`]?.().catch(()=>void 0),s=o?e:`en`,c=o&&f(s)?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,ie(t)])):o??{};return E=ae(s,t(s,n),c),a&&(a.lang=s,f(s)?a.dir=`rtl`:a.removeAttribute(`dir`)),E},ce=e=>{let t=e[0];for(let n of e)t&&n.id.startsWith(`${t.id}-`)&&(t=n);return t},le=(e,t)=>F(e)?ce(I(e)?.handleUrisValues.filter(e=>e.origin===t)??[]):M(e)&&k(e).origin===t?k(e):void 0,k=e=>{let[t,n]=e.split(`:`);return{origin:t,id:n}},ue=(e,t)=>{let n=e.split(`,`).filter(Boolean).map(e=>k(e));return t?n.find(({origin:e})=>e===t):n},A=({origin:e,id:t})=>`${e}:${t}`,j=e=>e.join(`,`),M=e=>{let t=e.split(`:`).filter(e=>e.length);if(t[1]?.includes(`,`))throw Error(`Invalid uri: ${e}, contains "," character in id`);return t.length===2},de=/[,/()]/,N=e=>{let t=e.indexOf(`:`);return t>0&&!de.test(e.slice(t+1))},fe=e=>e.split(`,`).every(M),P=/ag:\((.*)\)(?:-(.*))?/,F=e=>{if(!e?.startsWith(`ag:`))return!1;let t=e.match(P);if(!t)return!1;let n=t?.[1];return!n||fe(n)},pe=e=>F(e)||!N(e)||!M(e)?e:_e([e]),me=(e,t,n)=>{if(!e||!t||e===t||!F(e)||!F(t)||!be(e,t))return!1;if(t===n)return!0;let r=I(e)?.handleUris??[],i=I(t)?.handleUris??[];return r.length>i.length},he=e=>{if(!e||M(e)||F(e))return e;try{let t=decodeURIComponent(e);return M(t)||F(t)?t:e}catch{return e}},ge=e=>{let t=he(e);return t&&pe(t)},_e=(e,t)=>`ag:(${ve(e)})${t?`-${t}`:``}`,ve=(e,t=!0)=>t?ve(ue(Array.isArray(e)?e.join(`,`):e).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin)).map(A),!1):encodeURI(Array.isArray(e)?e.join(`,`):e),I=e=>{if(typeof e!=`string`)return;let t=e.match(P);if(!t)return;let n=ue(t[1]).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin));return t&&{uri:`ag:(${j(n.map(A))})`,origin:`ag`,id:`(${j(n.map(A))})`,handleUris:n.map(A),handleUrisString:j(n.map(A)),handleUrisValues:n,episodeId:t[2]}},ye=e=>F(e)?[...new Set(I(e)?.handleUrisValues.map(e=>e.origin)??[])]:M(e)?[k(e).origin]:[],be=(e,t)=>{let n=I(e),r=I(t);return!n||!r?!1:n.handleUris.some(e=>r.handleUris.some(t=>e===t))};x();var L=`stub.player.autoplay`,xe=()=>h.getItem(L)!==`off`,R=e=>{try{e?h.removeItem(L):h.setItem(L,`off`)}catch{}},Se=e=>h.watch(L,e),z=(e,...t)=>{e.postMessage(...t)},B=`stub:embed-tracks`,V=`stub:embed-tracks?`,H=`stub:embed-track-pick`,Ce=[`subtitles`,`audio`],we=(e,t,n=window)=>{let r=()=>z(n.parent,{type:B,tracks:e},n.location.origin),i=e=>{if(e.source!==n.parent||e.origin!==n.location.origin)return;let{type:i,kind:a,id:o}=e.data??{};i===V&&r(),i===H&&t(a,o)};return n.addEventListener(`message`,i),n.parent!==n&&r(),()=>n.removeEventListener(`message`,i)},Te=(e,t=window)=>{let n=/* @__PURE__ */ new Set,r,i=i=>{if(i.source!==e.contentWindow||i.origin!==t.location.origin)return;let{type:a,tracks:o}=i.data??{};if(a===B){r=o;for(let e of n)e(o)}},a=n=>{e.contentWindow&&z(e.contentWindow,n,t.location.origin)},o=()=>a({type:V});return t.addEventListener(`message`,i),e.addEventListener(`load`,o),{onTracks:e=>(n.add(e),r&&e(r),()=>{n.delete(e)}),select:(e,t)=>a({type:H,kind:e,id:t}),dispose:()=>{t.removeEventListener(`message`,i),e.removeEventListener(`load`,o)}}},Ee=(e,t)=>{let[n,r]=b(e);return C(()=>(r(e()),t(()=>r(e()))),[]),n},De=[`amazon.co.jp`,`www.amazon.co.jp`,`watch.amazon.co.jp`,`amazon.com`,`www.amazon.com`,`watch.amazon.com`,`amazon.co.uk`,`www.amazon.co.uk`,`watch.amazon.co.uk`,`amazon.de`,`www.amazon.de`,`watch.amazon.de`,`primevideo.com`,`www.primevideo.com`,`app.primevideo.com`,`media-amazon.com`,`ssl-images-amazon.com`,`aiv-cdn.net`,`pv-cdn.net`,`aiv-delivery.net`,`a2z.com`,`prime-video.amazon.dev`],Oe={US:`amazon.com`,PR:`amazon.com`,GU:`amazon.com`,VI:`amazon.com`,AS:`amazon.com`,MP:`amazon.com`,UM:`amazon.com`,GB:`amazon.co.uk`,DE:`amazon.de`,AT:`amazon.de`,JP:`amazon.co.jp`},U=e=>Oe[e]??`primevideo.com`,W=e=>URL.parse(e)?.hostname.replace(/^(www|watch|app)\./,``),ke=e=>W(e)===U(l()),Ae=e=>e===`amazon.co.jp`,je=`https://www.amazon.co.jp/ap/signin?${new URLSearchParams({"openid.return_to":`https://www.amazon.co.jp/gp/video/storefront`,"openid.identity":`http://specs.openid.net/auth/2.0/identifier_select`,"openid.assoc_handle":`jpflex`,"openid.mode":`checkid_setup`,"openid.claimed_id":`http://specs.openid.net/auth/2.0/identifier_select`,"openid.ns":`http://specs.openid.net/auth/2.0`})}`,Me=e=>e===`amazon.co.jp`?je:e===`primevideo.com`?`https://www.primevideo.com/auth-redirect?signin=1&returnUrl=%2Fstorefront`:`https://www.${e}/gp/video/auth-redirect?signin=1&returnUrl=%2Fgp%2Fvideo%2Fstorefront`,Ne=`a[data-csa-c-content-id="nav_ya_signin"], [data-testid="pv-nav-sign-in"]`,Pe=async e=>await e.locator(`#nav-link-accountList, #pv-footer`).exists()&&!await e.locator(`a[data-csa-c-content-id="nav_ya_signin"], [data-testid="pv-nav-sign-in"]`).exists(),G=1,Fe=6e3,Ie=1,K=10,Le=120,Re=e=>e.title===`Preview`,q=e=>e!==void 0&&Number.isFinite(e)&&e>0,J=(e,t)=>{let n=e[S(e).lastIndexOf(`ending`)];return n&&{ending:n,after:t-n.end}},ze=e=>S(e).includes(`ending`),Be=e=>q(e)&&e>=60?e-30:void 0,Ve=(e,t)=>{if(!q(t))return;let n=J(e,t);if(n&&n.after<K)return n.ending.start-G;if(n&&n.after<=Le)return n.ending.end-G;let r=e.findLast(e=>Re(e)&&t-e.end<K);return r&&r.start-G},He=(e,t)=>{let n=q(t)?J(e,t):void 0;return n&&n.after<K?e.filter(e=>e!==n.ending):e},Ue=e=>{let t,n,r=0,i=()=>clearTimeout(t),a=(o,{paused:s,time:c,rate:l,at:u},d)=>{i();let f=S(o),p=o.filter((e,t)=>f[t]),m=p.find(({start:e,end:t})=>e-G<=c&&c<t);(m?m.end!==n?.end||!d&&c<r-Ie:!d)&&(n=m&&{end:m.end,at:u}),d||(r=c);let h=!s&&l>0,g=m&&n?Math.min(n.at+Fe-u,h?(m.end-c)/l*1e3:1/0):0;e(g>0);let _=h?p.find(({start:e})=>e-G>c):void 0,v=g>0?g:_&&(_.start-G-c)/l*1e3;if(v===void 0)return;let y=Math.ceil(v);t=setTimeout(()=>a(o,{paused:s,rate:l,time:h?c+y/1e3*l:c,at:u+y},!0),y)};return{hear:(e,t)=>a(e,t,!1),stop:i}};x();var We=e=>`https://static.crunchyroll.com/skip-events/production/${e}.json`,Y=e=>{try{return new URL(e).pathname.match(/\/watch\/([A-Z0-9]+)(?:\/|$)/)?.[1]}catch{return}},Ge=[[`intro`,`Opening`],[`recap`,`Recap`],[`credits`,`Ending`],[`preview`,`Preview`]],Ke=`Episode`,qe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Je=(e,t)=>{if(!qe(e))return[];let n=t!==void 0&&Number.isFinite(t)&&t>0?t:1/0,r=Ge.flatMap(([t,r])=>{let i=e[t];if(!qe(i))return[];let{start:a,end:o}=i;if(typeof a!=`number`||typeof o!=`number`||!Number.isFinite(a)||!Number.isFinite(o))return[];let s={start:Math.max(0,a),end:Math.min(o,n),title:r};return s.end>s.start?[s]:[]}).sort((e,t)=>e.start-t.start),i=[],a=0;for(let e of r){let t=Math.max(e.start,a);e.end<=t||(t>a&&i.push({start:a,end:t,title:Ke}),i.push({start:t,end:e.end,title:e.title}),a=e.end)}return i.length&&n!==1/0&&a<n&&i.push({start:a,end:n,title:Ke}),i},Ye=/* @__PURE__ */ new Set([403,404]),Xe=async(t,n=e)=>{let r=await n(We(t));if(!r.ok){if(await r.body?.cancel().catch(()=>{}),Ye.has(r.status))return{};throw Error(`${We(t)} answered ${r.status}`)}return r.json()},Ze=e=>{let[t,n]=b();return C(()=>{if(n(e?.duration),!e)return;let t=()=>n(e.duration);return e.addEventListener(`durationchange`,t),e.addEventListener(`loadedmetadata`,t),()=>{e.removeEventListener(`durationchange`,t),e.removeEventListener(`loadedmetadata`,t)}},[e]),t},Qe=[],$e=e=>{let[t,n]=b();return C(()=>{if(!e)return;let t=!1;return Xe(e).then(r=>{t||n({episodeId:e,events:r})},e=>{t||console.warn(`[cr] skip events unavailable:`,e)}),()=>{t=!0}},[e]),e&&t?.episodeId===e?t.events:void 0},et=(e,t)=>{let n=$e(Y(e)),r=Ze(t);return te(()=>{let e=He(Je(n,r),r);return e.length?e:Qe},[n,r])};x();var tt=`stub:embed-fullscreen`,nt=`stub:embed-fullscreen?`,rt=`stub:embed-fullscreen-request`,it=(e,t,n,r)=>{let i=i=>{let a=i.target;i.key!==`f`||i.repeat||i.ctrlKey||i.metaKey||i.altKey||a?.isContentEditable||/^(input|textarea|select)$/i.test(a?.tagName??``)||(e.fullscreenElement?e.exitFullscreen().catch(()=>{}):(n?.blur(),n?.focus(),t.requestFullscreen().then(r,()=>{})))};return e.addEventListener(`keydown`,i),()=>e.removeEventListener(`keydown`,i)},at=(e,t,n=window)=>{let{document:r}=n;if(!r.fullscreenEnabled)return()=>{};let i=it(r,t,e),a=()=>{e.contentWindow&&z(e.contentWindow,{type:tt,active:!!r.fullscreenElement},n.location.origin)},o=i=>{if(i.source!==e.contentWindow||i.origin!==n.location.origin)return;let o=i.data?.type;o===nt?a():o===rt&&(r.fullscreenElement?r.exitFullscreen():t.requestFullscreen()).catch(()=>{})};return n.addEventListener(`message`,o),r.addEventListener(`fullscreenchange`,a),a(),()=>{i(),n.removeEventListener(`message`,o),r.removeEventListener(`fullscreenchange`,a)}},ot=(e,t=window)=>{let n=()=>z(t.parent,{type:rt},t.location.origin),r=r=>{if(r.source!==t.parent||r.origin!==t.location.origin)return;let{type:i,active:a}=r.data??{};i===tt&&typeof a==`boolean`&&e({active:a,request:n})};return t.addEventListener(`message`,r),t.parent!==t&&z(t.parent,{type:nt},t.location.origin),()=>t.removeEventListener(`message`,r)},st=()=>{let[e,t]=b();return C(()=>ot(t),[]),e};x();var ct=`stub:embed-episode`,lt=`stub:embed-episode?`,ut=`stub:embed-episode-request`,dt=(e,t,n,r=window)=>{let i=t.previous||!1,a=t.next||!1,o=()=>{e.contentWindow&&z(e.contentWindow,{type:ct,previous:i,next:a},r.location.origin)},s=t=>{if(t.source!==e.contentWindow||t.origin!==r.location.origin)return;let{type:s,direction:c}=t.data??{};s===lt?o():s===ut&&(c===`previous`&&i||c===`next`&&a)&&n(c)};return r.addEventListener(`message`,s),o(),()=>r.removeEventListener(`message`,s)},ft=e=>typeof e==`string`||typeof e==`boolean`,pt=(e,t,n)=>e?{...typeof e==`string`&&e?{title:e}:{},request:()=>z(n.parent,{type:ut,direction:t},n.location.origin)}:null,mt=(e,t=window)=>{let n=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let{type:r,previous:i,next:a}=n.data??{};r===ct&&ft(i)&&ft(a)&&e(i||a?{previous:pt(i,`previous`,t),next:pt(a,`next`,t)}:void 0)};return t.addEventListener(`message`,n),t.parent!==t&&z(t.parent,{type:lt},t.location.origin),()=>t.removeEventListener(`message`,n)},ht=(e=window)=>{let[t,n]=b(void 0);return C(()=>mt(n,e),[e]),t};x();var gt=`stub:embed-subtitles`,X=`stub:embed-subtitles?`,_t=`stub:embed-subtitles-load`,Z=`stub:embed-subtitles-loaded`,vt=(e,t,n=window)=>{let r=!1,i=t?.tracks??[],a=()=>{e.contentWindow&&z(e.contentWindow,{type:gt,tracks:i},n.location.origin)},o=i=>{if(i.source!==e.contentWindow||i.origin!==n.location.origin)return;let{type:o,requestId:s,id:c}=i.data??{};o===X?a():o===_t&&typeof s==`string`&&typeof c==`string`&&(t?t.load(c).then(t=>{!r&&e.contentWindow&&z(e.contentWindow,{type:Z,requestId:s,text:t},n.location.origin)},t=>{if(!r&&e.contentWindow){let r=t instanceof Error?t.message:String(t);z(e.contentWindow,{type:Z,requestId:s,error:r},n.location.origin)}}):e.contentWindow&&z(e.contentWindow,{type:Z,requestId:s,error:`External subtitles unavailable`},n.location.origin))};return n.addEventListener(`message`,o),a(),()=>{r=!0,n.removeEventListener(`message`,o)}},yt=e=>!!(e&&typeof e==`object`&&typeof e.id==`string`&&typeof e.language==`string`&&typeof e.label==`string`&&typeof e.format==`string`),bt=(e,t=window)=>{let n=0,r=/* @__PURE__ */ new Map,i=e=>new Promise((i,a)=>{let o=`sub-${++n}`;r.set(o,{trackId:e,resolve:i,reject:a}),z(t.parent,{type:_t,requestId:o,id:e},t.location.origin)}),a=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let a=n.data??{};if(a.type===gt&&Array.isArray(a.tracks)){let t=a.tracks.filter(yt),n=new Set(t.map(e=>e.id));for(let[e,t]of[...r.entries()])n.has(t.trackId)||(r.delete(e),t.reject(/* @__PURE__ */ Error(`External subtitle track was removed`)));e(t.length?t.map(e=>({...e,load:()=>i(e.id)})):void 0)}else if(a.type===Z&&typeof a.requestId==`string`){let e=r.get(a.requestId);if(!e)return;r.delete(a.requestId),typeof a.text==`string`?e.resolve(a.text):e.reject(Error(typeof a.error==`string`?a.error:`External subtitle load failed`))}};return t.addEventListener(`message`,a),t.parent!==t&&z(t.parent,{type:X},t.location.origin),()=>{t.removeEventListener(`message`,a);for(let e of r.values())e.reject(/* @__PURE__ */ Error(`External subtitle host disconnected`));r.clear()}},xt=(e=window)=>{let[t,n]=b(void 0);return C(()=>bt(n,e),[e]),t},Q=`stub:embed-language-picked`,St=()=>Object.fromEntries([u,c,m].flatMap(e=>{let t=h.getItem(e);return t===null?[]:[[e,t]]})),Ct=e=>o(t=>e.get(t)),wt=(e,t=window)=>{let n=n=>{if(n.source!==e.contentWindow||n.origin!==t.location.origin)return;let{type:r,kind:a,language:o,on:s}=n.data??{};r===Q&&(a===`audio`&&typeof o==`string`&&d(o),a===`subtitles`&&(typeof o==`string`||o===null)&&p(o),a===`always-subtitles`&&typeof s==`boolean`&&i(s),a===`autoplay`&&typeof s==`boolean`&&R(s))};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)},Tt=(e,t,n=window)=>{n.parent!==n&&z(n.parent,{type:Q,kind:e,language:t},n.location.origin)},Et=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Q,kind:`always-subtitles`,on:e},t.location.origin)},Dt=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Q,kind:`autoplay`,on:e},t.location.origin)},Ot=`stub:embed-relay-tried`,kt=`triedRelays`,$=/* @__PURE__ */ new Map,At=e=>e.split(`-`)[0],jt=e=>{let t=$.get(At(e));return t?.length?{[kt]:t.join(`,`)}:{}},Mt=e=>e.get(kt)?.split(`,`).filter(Boolean)??[],Nt=(e,t,n=window)=>{let r=r=>{if(r.source!==e.contentWindow||r.origin!==n.location.origin)return;let{type:i,relay:a}=r.data??{};if(i!==Ot||typeof a!=`string`)return;let o=At(t),s=$.get(o)??[];s.includes(a)||$.set(o,[...s,a])};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)},Pt=(e,t=window)=>{t.parent!==t&&z(t.parent,{type:Ot,relay:e},t.location.origin)},Ft=`stub:embed-unplayable`,It=(e,t,n=window)=>{let r=r=>{r.source===e.contentWindow&&r.origin===n.location.origin&&r.data?.type===Ft&&t()};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)},Lt=(e=window)=>{e.parent!==e&&z(e.parent,{type:Ft},e.location.origin)},Rt=`stub:embed-title`,zt=`stub:embed-title?`,Bt=(e,t,n=window)=>{let r=()=>{e.contentWindow&&z(e.contentWindow,{type:Rt,title:t},n.location.origin)},i=t=>{t.source===e.contentWindow&&t.origin===n.location.origin&&t.data?.type===zt&&r()};return n.addEventListener(`message`,i),r(),()=>n.removeEventListener(`message`,i)},Vt=(e,t=window)=>{let n=n=>{if(n.source!==t.parent||n.origin!==t.location.origin)return;let{type:r,title:i}=n.data??{};r===Rt&&typeof i==`string`&&e(i)};return t.addEventListener(`message`,n),t.parent!==t&&z(t.parent,{type:zt},t.location.origin),()=>t.removeEventListener(`message`,n)},Ht=5e3,Ut=async(e,t)=>{let r=await s.fetch(`${n}/auth/v1/token`,{method:`POST`,headers:{authorization:`Basic ${btoa(`cr_web:`)}`,"content-type":`application/x-www-form-urlencoded`},body:`grant_type=client_id&device_id=${crypto.randomUUID()}`,relay:t}),i=a(r),{access_token:o}=await r.json();if(!i||!o)throw Error(`Crunchyroll token through ${i}: ${r.status}`);let c=await s.fetch(`${n}/content/v2/cms/objects/${e}?ratings=true&locale=en-US`,{headers:{authorization:`Bearer ${o}`},relay:{id:i}});if(!c.ok&&c.status!==404)throw Error(`Crunchyroll episode through ${i}: ${c.status}`);return{relay:i,episode:c}},Wt=async(e,t)=>{let{relay:n,episode:r}=await Ut(e,t);return{relay:n,listed:r.ok}},Gt=async e=>{let t=Y(e);if(!t)return;let{episode:n}=await Ut(t,{});if(!n.ok)return;let{data:r}=await n.json(),i=r?.[0]?.episode_metadata?.duration_ms;return typeof i==`number`&&Number.isFinite(i)&&i>0?i/1e3:void 0},Kt=async(e,t)=>{let n=Y(e);if(!n)return[];let r=async()=>{let e=[];for(;;){let{relay:r,listed:i}=await Wt(n,{exclude:[...t,...e]});if(i)return e;if(t.includes(r)||e.includes(r))return[];e.push(r)}},i,a=new Promise(e=>{i=setTimeout(e,Ht,[])});return Promise.race([r().catch(()=>[]),a]).finally(()=>clearTimeout(i))},qt=y`
2
2
  @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,500;1,600;1,700;1,800;1,900&family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
3
3
 
4
4
  body {