1import{ac as O,ei as Z,ae as N,eo as J,ej as X,ep as Y,B as j,D,k as G,P as ee,bu as te,l as ne,aM as oe,ck as re,f as se,E as ae,V as ie,c as b,K as d,Z as $,b as le,a as Q,b0 as ce,L as _,W as ue,d as de,m as E,o as P,bz as fe}from"./CsY_hDvl.js";function pe(t){const n=new URLSearchParams;return n.set("platform","web"),n.set("language",t.language),t.userId!=null&&n.set("userId",String(t.userId)),t.embed===!0&&n.set("embed","true"),n.toString()}function me(t,n){const r=new URLSearchParams(t),l=n?.trim();return l&&new URLSearchParams(l).forEach((c,i)=>{r.set(i,c)}),r.toString()}const ye=O({data:J(t=>t===""?null:t,X([N().min(1),Y()])),reason:N().nullable().optional(),info:O({entitlementFromCache:Z().optional()}).passthrough().optional()});async function ge(t){const n=j(),r=`${D(n)}api/v3/contents/${t}/check-access`;try{const l=await $fetch(r,{method:"POST",credentials:"include"}),c=ye.safeParse(l);return c.success?c.data.data:void 0}catch{return}}function ve(t){const n=j();return`${D(n)}api/v3/contents/${t}/direct-download`}function he(t){const n=document.createElement("a");n.href=t,n.rel="noopener",n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}async function we(t){if(typeof window>"u")return"error";const n=ve(t);try{const r=await fetch(n,{method:"HEAD",credentials:"include"});return r.status===403?"forbidden":r.status===404?"not_found":r.ok?(he(n),"success"):"error"}catch{return"error"}}let T=null;function be(){if(typeof window>"u")return Promise.resolve(void 0);const t=window.avvpl;if(t)return Promise.resolve(t);if(T)return T;const{getPlayerSettings:n}=G(),r=n;if(!r?.js)return Promise.reject(new Error("js not configured"));const l=r.version?.trim()||new Date().toISOString().slice(0,10),c=m=>l?`${m}${m.includes("?")?"&":"?"}v=${encodeURIComponent(l)}`:m,i=c(r.js),k=r.css&&c(r.css);return T=new Promise((m,v)=>{let u=0;const f=()=>{const a=window.avvpl;if(a){m(a);return}u<100?(u++,setTimeout(f,100)):v(new Error("avvpl not available after loading script"))};if(k){const a=document.createElement("link");a.rel="stylesheet",a.href=k,document.head.appendChild(a)}const p=document.createElement("script");p.src=i,p.async=!0,p.onload=()=>f(),p.onerror=()=>v(new Error(`Failed to load Agamo player script: ${i}`)),document.head.appendChild(p)}),T}const _e=["src"],Pe={key:1,class:"absolute inset-0 z-10 flex items-center justify-center bg-Background-Neutral/40",role:"status","aria-live":"polite"},ke={key:2,class:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 bg-Background-Neutral/60 px-4",role:"alert"},Se={key:3,role:"alert",class:"pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center px-4"},Ae={class:"max-w-sm rounded bg-Background-Neutral px-4 py-3 text-center text-base font-medium text-Text-Label-inverse"},Te=["id"],xe=ee({__name:"AgamoPlayer",props:{id:{type:String,required:!0},authorizationCode:{type:String,default:""},settingsQuery:{type:String,default:""},placeholder:{type:String,default:""}},setup(t){const{getAgamo:n}=te(),r=j(),l=G(),c=ne(),i=t,k=E(()=>pe({language:l.getCurrentLanguageAbbreviation??"en",userId:c.getUser?.id??null})),m=`player_container_${i.id}`,v=E(()=>{const e=`${D(r)}api/v3/contents/${i.id}/player-settings`,o=me(k.value,i.settingsQuery);return o?`${e}?${o}`:e}),I=n?.licenceKey,{t:S}=oe(),u=_(),f=_(null),p=_(null);let a;const A=_(!1),y=_(!1);let g=!1,x=!1,h=0,R=0,B=0;function L(e=d(u)){e?.resize?.(),typeof window<"u"&&window.dispatchEvent(new Event("resize"))}function F(){L()}const M=fe(()=>{F()},200);re(p,e=>{const o=e[0];if(!o)return;const{width:s,height:w}=o.contentRect;s===R&&w===B||(R=s,B=w,M())});const V=E(()=>{const e=i.authorizationCode;return typeof e=="string"&&e.length>0?`authorization_code=${e}`:null});async function H(e,o){const s=o?.contentId??i.id;if(!s)return;const w=await ge(s);w!==void 0&&typeof e.setAccessToken=="function"&&e.setAccessToken(w)}function z(e){f.value=e,a&&clearTimeout(a),a=setTimeout(()=>{f.value=null,a=void 0},5e3)}async function K(){f.value=null;const e=await we(i.id);if(e==="not_found"){z(S("playerPage.download.notAvailable"));return}if(e==="forbidden"){z(S("playerPage.download.forbidden"));return}e==="error"&&z(S("playerPage.download.error"))}function q(e){e.on?.("newAccessToken",o=>{H(e,o)}),e.on?.("click",o=>
1{o==="download"&&K()})}function C(e=d(u)){e===d(u)&&(u.value=void 0),e?.remove?.()}async function U(){if(x||!g)return;const e=++h;x=!0,A.value=!0,y.value=!1;try{const o=await be();if(!g||e!==h)return;if(!o?.setupPlayer){y.value=!0;return}C();const s=o.setupPlayer({id:m,configUrl:v.value,playerLicenceKey:I??void 0,streamAccessQueryParameters:V.value});if(!g||e!==h){C(s);return}if(!s){y.value=!0;return}u.value=s,q(s),await ue(),g&&e===h&&u.value===s&&L(s)}catch(o){console.error("Agamo player setup failed:",o),y.value=!0}finally{A.value=!1,x=!1}}function W(){U()}return se(()=>{g=!0,U()}),ae(v,(e,o)=>{e!==o&&U()}),ie(()=>{g=!1,h+=1,a&&clearTimeout(a),C()}),(e,o)=>{const s=de;return P(),b("div",{ref_key:"rootRef",ref:p,class:"relative size-full min-h-0 min-w-0 overflow-hidden rounded-[inherit]"},[t.placeholder&&(d(A)||d(y))?(P(),b("img",{key:0,src:t.placeholder,alt:"",class:"absolute inset-0 size-full object-cover"},null,8,_e)):$("",!0),d(A)?(P(),b("div",Pe)):d(y)?(P(),b("div",ke,[le(s,{type:"primary",size:"medium",label:e.$t("playerPage.player.retry"),onClick:W},null,8,["label"])])):$("",!0),d(f)?(P(),b("div",Se,[Q("p",Ae,ce(d(f)),1)])):$("",!0),Q("div",{id:`player_container_${t.id}`,class:"size-full min-h-0 min-w-0 overflow-hidden rounded-[inherit]"},null,8,Te)],512)}}}),ze=Object.assign(xe,{__name:"PlayerAgamoPlayer"}),Ue=Object.freeze(Object.defineProperty({__proto__:null,default:ze},Symbol.toStringTag,{value:"Module"}));export{Ue as A,ze as _,pe as b,ye as c,me as m};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.