import{Cd as N,Dd as l,Ia as T,Na as P,Sa as s,Tc as A,Uc as C,Xc as L,Yc as S,b as E,gb as b,h as p,kb as y,mb as _}from"./chunk-RISKGE32.js";import"./chunk-6O6MLDWR.js";import{a as f,l as g}from"./chunk-F4AZU7R4.js";import"./chunk-GQY3J744.js";import{f as c,g as m,i as n,n as d}from"./chunk-CLPINNGF.js";d();m();function h(){return p.on("subscriptionupdate",async e=>{!e||L(e)||S(e)||e.productId!=="none"&&l({id:"subscription-expired",duration:5e3,showOnMobile:!1,timeSensitive:!0,priority:100,render:({dismiss:t})=>n(_,{removeNotification:t},n(b,null,"Your subscription has expired!",n("br",null),"Please renew"," ",n(y,{href:g(`onboarding/sso/?extensionId=${c.runtime.id}&source=subscription_ended_notification`,f.onboardingUrl),target:"_blank",rel:"noopener noreferrer"},"here")))})})}async function I(e){return s("PLAYABLE_CONTENT_UPDATED",async({changed:t})=>{let i=t;if(!i||e?.disabled)return;await new Promise(o=>setTimeout(o,1e3)),(await T(i)).length===0&&!window.location.href.endsWith(".pdf")?l({id:"pill_player-ocr-recommendation",priority:151,duration:0,showOnMobile:!0,timeSensitive:!0}):N("pill_player-ocr-recommendation")})}var O=async()=>{let e=null,t=[],i=await s("PLAYABLE_CONTENT_UPDATED",async({changed:r})=>{e?.id!==r.id&&(e=r,e.metadata.source!==r.metadata.source&&(t.length=0))}),u=E(1),o=await P.registerHook("PLAYBACK_STATE_CHANGED",r=>u(async({state:a})=>{e&&(a==="playing"&&!t.includes("extension_usage_widget_listened_to_page")?(t.push("extension_usage_widget_listened_to_page"),C({triggeredFrom:e.metadata.source,isSelection:e.metadata.source==="Selection Player"})):a==="playing"&&t.includes("extension_usage_widget_listened_to_page")&&t.includes("ended")?(t.push("extension_usage_widget_relistened_to_page"),A({triggeredFrom:e.metadata.source,isSelection:e.metadata.source==="Selection Player"})):a==="ended"&&t.push("ended"))},r));return()=>{o(),i()}};async function D(e){let t=[h(),await I(e),await O()];return()=>{t.forEach(i=>i())}}export{D as default};
//# sourceMappingURL=init-ZGLO74Q6.js.map
