@playpilot/tpi 4.0.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,10 +5,10 @@ var gi=e=>{throw TypeError(e)};var mi=(e,t,n)=>t.has(e)||gi("Cannot "+n);var Cn=
5
5
  opacity: ${l-d*p}`}}function Ft(e,{delay:t=0,duration:n=400,easing:i=si,axis:r="y"}={}){const a=getComputedStyle(e),o=+a.opacity,s=r==="y"?"height":"width",l=parseFloat(a[s]),u=r==="y"?["top","bottom"]:["left","right"],d=u.map(y=>`${y[0].toUpperCase()}${y.slice(1)}`),f=parseFloat(a[`padding${d[0]}`]),_=parseFloat(a[`padding${d[1]}`]),m=parseFloat(a[`margin${d[0]}`]),g=parseFloat(a[`margin${d[1]}`]),v=parseFloat(a[`border${d[0]}Width`]),p=parseFloat(a[`border${d[1]}Width`]);return{delay:t,duration:n,easing:i,css:y=>`overflow: hidden;opacity: ${Math.min(y*20,1)*o};${s}: ${y*l}px;padding-${u[0]}: ${y*f}px;padding-${u[1]}: ${y*_}px;margin-${u[0]}: ${y*m}px;margin-${u[1]}: ${y*g}px;border-${u[0]}-width: ${y*v}px;border-${u[1]}-width: ${y*p}px;min-${s}: 0`}}function al(e,{delay:t=0,duration:n=400,easing:i=si,start:r=0,opacity:a=0}={}){const o=getComputedStyle(e),s=+o.opacity,l=o.transform==="none"?"":o.transform,u=1-r,d=s*(1-a);return{delay:t,duration:n,easing:i,css:(f,_)=>`
6
6
  transform: ${l} scale(${1-u*_});
7
7
  opacity: ${s-d*_}
8
- `}}Ea();var ol=Ne('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M14 2L2 14M2 2L14 14" stroke="currentColor" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Rr(e){var t=ol();k(e,t)}function ci(e,t){ae(t,!0);const n=N(t,"size",3,"margin(2)"),i=N(t,"onclick",3,()=>null),r=zo(t,["$$slots","$$events","$$legacy","children","size","onclick"]);var a=Be(),o=ne(a);Io(o,()=>t.href?"a":"button",!1,(s,l)=>{let u;L(()=>{u=jo(s,u,{role:t.href?"link":"button",onclick:i(),class:"button",...r},"svelte-1qqv88o",s.namespaceURI===Zi,s.nodeName.includes("-")),bn(s,"--size",n())});var d=Be(),f=ne(d);Ct(f,()=>t.children??st),k(l,d)}),k(e,a),oe()}function ll(e){P(e,e.v+1)}function sl(e){let t=0,n=Ee(0),i;return()=>{Ka()&&(c(n),pn(()=>(t===0&&(i=Ke(()=>e(()=>ll(n)))),t+=1,()=>{Fn().then(()=>{t-=1,t===0&&(i==null||i(),i=void 0)})})))}}var Ut,zt;class cl{constructor(t,n){Pn(this,Ut);Pn(this,zt);jn(this,Ut,t),jn(this,zt,sl(n))}get current(){return Cn(this,zt).call(this),Cn(this,Ut).call(this)}}Ut=new WeakMap,zt=new WeakMap;const ul=/\(.+\)/;class dl extends cl{constructor(t,n){let i=ul.test(t)?t:`(${t})`;const r=window.matchMedia(i);super(()=>r.matches,a=>yo(r,"change",a))}}const ui=new dl("(prefers-reduced-motion: reduce)");var fl=(e,t)=>t()(),vl=I('<div class="modal svelte-aqwna4"><div class="dialog svelte-aqwna4" role="dialog" aria-labelledby="title" data-view-transition-new=""><div class="close svelte-aqwna4"><!></div> <!></div> <div class="backdrop svelte-aqwna4"></div></div>');function qr(e,t){ae(t,!0);const n=N(t,"onclose",3,()=>null),i=N(t,"onscroll",3,()=>null);yr("scope","modal"),Je(()=>{const f=document.body.style.overflowY;return document.body.style.overflowY="hidden",()=>document.body.style.overflowY=f||""});function r(f){return ui.current?Ht(f,{duration:0}):window.innerWidth<600?Sn(f,{duration:250,y:window.innerHeight}):al(f,{duration:150,start:.85})}var a=vl();ce("keydown",pe,({key:f})=>{f==="Escape"&&n()()});var o=b(a),s=b(o),l=b(s);ci(l,{onclick:()=>n()(),children:(f,_)=>{Rr(f)},$$slots:{default:!0}});var u=E(s,2);Ct(u,()=>t.children);var d=E(o,2);d.__click=[fl,n],ce("scroll",o,function(...f){var _;(_=i())==null||_.apply(this,f)}),je(7,o,()=>r),je(7,a,()=>Ht,()=>({duration:150})),k(e,a),oe()}fe(["click"]);const _l=[{slug:"100",name:"All",categories:{movie:100,series:100,documentary:100,kids:100,cinema:100,podcasts:100}},{slug:"999",name:"Unscripted",categories:{},media_format:"video"},{slug:"900",name:"Independent",categories:{},media_format:"video"},{slug:"113",name:"Game Show",categories:{series:36,kids:28},media_format:"video"},{slug:"112",name:"Film Noir",categories:{movie:37},media_format:"video"},{slug:"212",name:"Entertainment",categories:{kids:80,series:42,movie:42},media_format:"video"},{slug:"120",name:"News",categories:{series:26,documentary:36,kids:38},media_format:"video"},{slug:"208",name:"Short",categories:{movie:21,documentary:30,kids:36},media_format:"video"},{slug:"902",name:"Bollywood",categories:{},media_format:"video"},{slug:"240",name:"Concert",categories:{movie:45},media_format:"video"},{slug:"901",name:"Arthouse",categories:{},media_format:"video"},{slug:"903",name:"Alternate Version",categories:{},media_format:"video"},{slug:"121",name:"Reality TV",categories:{series:24},media_format:"video"},{slug:"202",name:"Culture",categories:{kids:40,documentary:84,series:44},media_format:"video"},{slug:"107",name:"Drama",categories:{series:82,movie:82,cinema:88,documentary:44},media_format:"video"},{slug:"105",name:"Crime",categories:{series:84,documentary:86,cinema:64,movie:84},media_format:"video"},{slug:"128",name:"Western",categories:{movie:12,series:12,documentary:24},media_format:"video"},{slug:"127",name:"Thriller",categories:{series:70,documentary:28,cinema:80,movie:70},media_format:"video"},{slug:"102",name:"Animation",categories:{series:50,cinema:50,kids:90,documentary:48,movie:50},media_format:"video"},{slug:"119",name:"Mystery",categories:{movie:76,cinema:70,kids:26,documentary:38,series:76},media_format:"video"},{slug:"227",name:"Science",categories:{series:22,kids:46,documentary:74},media_format:"video"},{slug:"108",name:"Nature",categories:{kids:48,documentary:76,series:28},media_format:"video"},{slug:"116",name:"War",categories:{movie:14,documentary:68,series:14,cinema:66},media_format:"video"},{slug:"123",name:"Sci-Fi",categories:{series:72,movie:72,cinema:68,kids:70,documentary:32},media_format:"video"},{slug:"106",name:"Documentary",categories:{kids:50},media_format:"video"},{slug:"232",name:"Stand-up",categories:{movie:18,series:18},media_format:"video"},{slug:"126",name:"Talk Show",categories:{kids:34,series:16},media_format:"video"},{slug:"111",name:"Fantasy",categories:{kids:78,cinema:74,documentary:42,movie:38,series:38},media_format:"video"},{slug:"114",name:"History",categories:{movie:35,kids:44,cinema:10,series:80,documentary:90},media_format:"video"},{slug:"109",name:"Adventure",categories:{kids:88,cinema:86,documentary:82,series:88,movie:88},media_format:"video"},{slug:"101",name:"Action",categories:{documentary:50,kids:86,series:90,cinema:90,movie:90},media_format:"video"},{slug:"124",name:"Horror",categories:{cinema:76,documentary:40,series:78,movie:80},media_format:"video"},{slug:"115",name:"Comedy",categories:{cinema:84,documentary:46,series:86,kids:82,movie:86},media_format:"video"},{slug:"104",name:"Biography",categories:{series:46,documentary:88,cinema:10,movie:46},media_format:"video"},{slug:"118",name:"Music",categories:{kids:72,cinema:9,documentary:78,movie:32,series:32},media_format:"video"},{slug:"125",name:"Sport",categories:{cinema:7,kids:68,series:20,documentary:70,movie:20},media_format:"video"},{slug:"122",name:"Romance",categories:{documentary:34,cinema:78,movie:74,series:74},media_format:"video"},{slug:"103",name:"Kids",categories:{kids:76},media_format:"video"},{slug:"222",name:"Lifestyle",categories:{documentary:80,kids:74,series:34},media_format:"video"},{slug:"117",name:"Musical",categories:{kids:30,movie:78,cinema:8,series:30},media_format:"video"},{slug:"129",name:"Anime",categories:{cinema:5,movie:48,kids:84,series:48},media_format:"video"},{slug:"110",name:"Family",categories:{series:40,cinema:40,movie:40},media_format:"video"}];var hl=I('<div class="genre svelte-1ebula3"> </div>'),gl=(e,t)=>P(t,!0),ml=I('<button class="genre expand svelte-1ebula3"> </button>'),pl=I("<!> <!>",1);function yl(e,t){ae(t,!0);let n=U(!1);const i=K(()=>c(n)?t.genres:[t.genres[0]]);var r=pl(),a=ne(r);at(a,17,()=>c(i),bt,(l,u)=>{var d=Be();const f=K(()=>{var g;return(g=_l.find(v=>v.slug===c(u)))==null?void 0:g.name});var _=ne(d);{var m=g=>{var v=hl(),p=b(v);L(()=>G(p,ke(c(f)))),k(g,v)};q(_,g=>{c(f)&&g(m)})}k(l,d)});var o=E(a,2);{var s=l=>{var u=ml();u.__click=[gl,n];var d=b(u);L(()=>G(d,`+${t.genres.length-1}`)),k(l,u)};q(o,l=>{!c(n)&&t.genres.length>1&&l(s)})}k(e,r),oe()}fe(["click"]);function wl(e){let t=[];for(const n of e){let i=n;const r=t.find(s=>s.name===i.name),a=r==null?void 0:r.extra_info.category,o=i.extra_info.category;(a==="RENT"&&o==="BUY"||a==="BUY"&&o==="RENT")&&(t=t.filter(s=>s.name!==i.name),i={...i,extra_info:{...i.extra_info,category:"TVOD"}}),t.push(i)}return t}function xe(e,t=1){e.role="heading",e.ariaLevel=t.toString()}var kl=Ne('<svg width="6" height="12" viewBox="0 0 6 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 11L5 6L0 1" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function bl(e){var t=kl();k(e,t)}function Bt(e){return e?e.replace("/src/img",""):null}var xl=(e,t,n)=>t(n()),Sl=I('<div class="arrow svelte-g63n1y"><!></div>'),El=I('<a target="_blank" class="playlink svelte-g63n1y" rel="sponsored"><img alt="" height="32" width="32" class="svelte-g63n1y"> <div><span class="name svelte-g63n1y"> </span> <div class="category svelte-g63n1y"> </div></div> <!></a>'),Tl=I('<div class="playlink empty svelte-g63n1y"> </div>'),Il=I('<div class="heading svelte-g63n1y"> </div> <div class="playlinks svelte-g63n1y"><!> <!></div>',1);function Al(e,t){ae(t,!0);const n=N(t,"list",3,!1),i=oo("scope")==="modal",r=K(()=>t.playlinks.filter(v=>!!v.logo_url)),a=K(()=>wl(c(r))),o={SVOD:ke("Stream"),BUY:ke("Buy"),RENT:ke("Rent"),TVOD:ke("Rent Or Buy")};function s(v){be(i?ye.TitleModalPlaylinkClick:ye.TitlePopoverPlaylinkClick,t.title,{playlink:v})}var l=Il(),u=ne(l),d=b(u);L(()=>G(d,ke("Where To Stream Online"))),Jt(u,(v,p)=>xe==null?void 0:xe(v,p),()=>3);var f=E(u,2),_=b(f);at(_,17,()=>c(a),bt,(v,p)=>{let y=()=>c(p).name,w=()=>c(p).url,S=()=>c(p).logo_url,j=()=>c(p).highlighted,x=()=>c(p).cta_text,T=()=>c(p).extra_info.category;var H=El();H.__click=[xl,s,y];var M=b(H);L(()=>ue(M,"src",Bt(S())));var C=E(M,2),D=b(C),A=b(D),F=E(D,2),O=b(F);L(()=>G(O,x()||o[T()]||ke("Stream")));var z=E(C,2);{var B=V=>{var W=Sl(),J=b(W);bl(J),k(V,W)};q(z,V=>{n()&&V(B)})}L(()=>{ue(H,"href",w()),ue(H,"data-playlink",y()),se(H,"highlighted",j()&&x()),G(A,y())}),k(v,H)});var m=E(_,2);{var g=v=>{var p=Tl(),y=b(p);L(()=>G(y,ke("Title Unavailable"))),k(v,p)};q(m,v=>{t.playlinks.length||v(g)})}L(()=>se(f,"list",n())),k(e,l),oe()}fe(["click"]);var Cl=(e,t)=>P(t,!0),Pl=I('<button class="show-more svelte-1u3je71">Show more</button>'),jl=I('<div class="paragraph svelte-1u3je71" role="paragraph"> </div>'),Ml=I('<div><span class="paragraph svelte-1u3je71" role="paragraph"> <!> <!></span> <!></div>');function Nl(e,t){ae(t,!0);const n=N(t,"blurb",3,""),i=N(t,"limit",3,200);let r=U(!1);const a=K(()=>t.text.slice(0,i()));var o=Ml(),s=b(o),l=b(s),u=E(l);{var d=v=>{var p=Fe("...");k(v,p)};q(u,v=>{!c(r)&&t.text.length>i()&&v(d)})}var f=E(u,2);{var _=v=>{var p=Pl();p.__click=[Cl,r],k(v,p)};q(f,v=>{!c(r)&&(t.text.length>i()||n())&&v(_)})}var m=E(s,2);{var g=v=>{var p=jl(),y=b(p);L(()=>G(y,n())),k(v,p)};q(m,v=>{c(r)&&v(g)})}L(()=>G(l,c(r)?t.text:c(a))),k(e,o),oe()}fe(["click"]);var Ll=Ne('<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 0.351929L9.163 4.72803L14 5.43408L10.5 8.8385L11.326 13.648L7 11.3761L2.674 13.648L3.5 8.8385L0 5.43408L4.837 4.72803L7 0.351929Z" fill="#F6C045"></path></svg>');function Hr(e){var t=Ll();k(e,t)}var Ol=I('<div class="top svelte-1026zg0"><img class="poster svelte-1026zg0"></div>'),Dl=I("<div> </div>"),Rl=I('<img alt="" class="svelte-1026zg0">'),ql=I('<div class="content svelte-1026zg0" data-playpilot-link-injections-title=""><div class="header svelte-1026zg0"><!> <div class="heading svelte-1026zg0" id="title"> </div> <div class="info svelte-1026zg0"><div class="imdb svelte-1026zg0"><!> </div> <!> <div> </div> <div class="capitalize svelte-1026zg0"> </div> <!></div></div> <div class="main"><!> <!></div></div> <div class="background svelte-1026zg0"><!></div>',1);function Fr(e,t){ae(t,!0);const n=N(t,"small",3,!1),i=N(t,"compact",3,!1);let r=U(!1),a=U(!1),o=U(!1);var s=ql(),l=ne(s),u=b(l),d=b(u);{var f=B=>{var V=Ol(),W=b(V);L(()=>ue(W,"src",Bt(t.title.standing_poster))),L(()=>{ue(W,"alt",`Movie poster for '${t.title.title??""}'`),se(W,"loaded",c(r))}),ce("load",W,()=>P(r,!0)),k(B,V)};q(d,B=>{i()||B(f)})}var _=E(d,2),m=b(_);Jt(_,(B,V)=>xe==null?void 0:xe(B,V),()=>2);var g=E(_,2),v=b(g),p=b(v);Hr(p);var y=E(p),w=E(v,2);yl(w,{get genres(){return t.title.genres}});var S=E(w,2),j=b(S),x=E(S,2),T=b(x);L(()=>G(T,ke(`Type: ${t.title.type}`)));var H=E(x,2);{var M=B=>{var V=Dl(),W=b(V);L(()=>G(W,`${t.title.length??""} ${ke("Minutes")??""}`)),k(B,V)};q(H,B=>{!n()&&t.title.length&&B(M)})}var C=E(u,2),D=b(C);Al(D,{get playlinks(){return t.title.providers},get title(){return t.title},list:!0});var A=E(D,2);{var F=B=>{Nl(B,{get text(){return t.title.description},get blurb(){return t.title.blurb}})};q(A,B=>{n()||B(F)})}var O=E(l,2),z=b(O);Sr(z,()=>c(o),B=>{var V=Rl();L(()=>ue(V,"src",Bt(c(o)?t.title.standing_poster:t.title.medium_poster))),L(()=>{se(V,"loaded",c(a)),se(V,"blur",c(o))}),ce("load",V,()=>P(a,!0)),ce("error",V,()=>P(o,!0)),k(B,V)}),L(()=>{se(l,"small",n()),se(l,"compact",i()),se(_,"truncate",n()),G(m,t.title.title),G(y,` ${t.title.imdb_score??""}`),G(j,t.title.year),se(O,"faded",i())}),k(e,s),oe()}function Hl(e,t){ae(t,!0),be(ye.TitleModalView,t.title);let n=!1;function i(){n||(be(ye.TitleModalScroll,t.title),n=!0)}qr(e,{get onclose(){return t.onclose},onscroll:i,children:(r,a)=>{Fr(r,{get title(){return t.title}})},$$slots:{default:!0}}),oe()}var Fl=I('<div class="popover svelte-tb2xdq" tabindex="-1" aria-hidden="true"><div class="dialog svelte-tb2xdq" data-view-transition-old=""><!></div></div>');function Bl(e,t){ae(t,!0);let n=N(t,"maxHeight",15);yr("scope","popover");let i=U(null),r=U(!1);Je(async()=>{await Fn(),a(),await Fn(),o()});function a(){if(!c(i))return;const{top:f,right:_,bottom:m,height:g}=c(i).getBoundingClientRect(),v=s();P(r,X(f-v<0&&window.innerHeight-m>f+g));const p=window.innerWidth-_-v;_+v>window.innerWidth&&(c(i).style.left=`${p}px`)}function o(){if(!c(i))return;const{top:f,height:_}=c(i).getBoundingClientRect(),m=s(),g=c(r)?window.innerHeight-f-m:f+_-m;n(Math.min(g,window.innerHeight*.8))}function s(){return parseFloat(getComputedStyle(document.documentElement).fontSize)}var l=Fl(),u=b(l),d=b(u);Ct(d,()=>t.children),Qt(l,f=>P(i,f),()=>c(i)),L(()=>{se(l,"flip",c(r)),bn(l,"--max-height",n()?n()+"px":null)}),je(7,u,()=>Sn,()=>({duration:ui.current?0:100,y:10})),k(e,l),oe()}var Vl=I('<div class="title-popover svelte-d86q0q" data-playpilot-title-popover="" role="region" aria-labelledby="title"><!></div>');function Ul(e,t){ae(t,!0);let n=U(0),i=U(null);be(ye.TitlePopoverView,t.title),Je(r);function r(){const s=t.event.target;if(!(s!=null&&s.getClientRects))return;const l=Array.from(s.getClientRects()),d=l.map(_=>_.x).map(_=>Math.abs(_-t.event.clientX)),f=l[d.indexOf(Math.min(...d))];c(i).style.top=f.top+window.scrollY+"px",c(i).style.left=f.left+window.scrollX+"px",c(i).style.height=f.height+"px"}var a=Vl(),o=b(a);Bl(o,{get maxHeight(){return c(n)},set maxHeight(s){P(n,X(s))},children:(s,l)=>{var u=K(()=>!!c(n)&&c(n)<250);Fr(s,{get title(){return t.title},small:!0,get compact(){return c(u)}})},$$slots:{default:!0}}),Qt(a,s=>P(i,s),()=>c(i)),k(e,a),oe()}var zl=e=>e.stopPropagation(),Wl=(e,t,n,i)=>t(e,c(n).title_details,c(i)),Kl=I(' <span class="svelte-pfvkex"><button class="svelte-pfvkex"> </button></span>',1),Yl=(e,t,n,i)=>t(c(n).title_details,i()),Zl=I('<!> <a target="_blank"> </a>',1),Gl=I(" <!>.",1),Xl=I("<!> <br>",1),Jl=I(" <br>",1),Ql=I('<span class="svelte-pfvkex"><!></span>'),$l=I('<p class="svelte-pfvkex"></p>');function es(e,t){ae(t,!0);const n=N(t,"onclickmodal",3,()=>null);function i(l,u){be(ye.AfterArticlePlaylinkClick,l,{playlink:u})}function r(l,u,d){be(ye.AfterArticleModalButtonClick,u),n()(l,d)}var a=Be(),o=ne(a);{var s=l=>{var u=$l();at(u,21,()=>t.linkInjections,bt,(d,f)=>{var _=Ql();const m=K(()=>{const{key:w,title:S,title_details:j,after_article_style:x}=c(f);return{key:w,title:S,title_details:j,after_article_style:x}}),g=K(()=>{var w;return((w=c(m).title_details)==null?void 0:w.providers)||[]});var v=b(_);{var p=w=>{var S=Xl(),j=ne(S);{var x=H=>{var M=Kl(),C=ne(M);L(()=>G(C,`"${c(m).title??""}" ${ke("Is Available To Stream")??""} `));var D=E(C);D.__click=[zl];var A=b(D);A.__click=[Wl,r,m,f];var F=b(A);L(()=>G(F,ke("View Streaming Options"))),k(H,M)},T=H=>{var M=Gl(),C=ne(M);L(()=>G(C,`"${c(m).title??""}" ${ke("Is Available To Stream On")??""} `));var D=E(C);at(D,17,()=>c(g),bt,(A,F,O)=>{let z=()=>c(F).name,B=()=>c(F).url;var V=Zl(),W=ne(V);{var J=de=>{var Ae=Fe();L(()=>G(Ae,O===c(g).length-1?`, ${ke("And")}`:",")),k(de,Ae)};q(W,de=>{O&&de(J)})}var ee=E(W,2);ee.__click=[Yl,i,m,z];var re=b(ee);L(()=>{ue(ee,"href",B()),G(re,z())}),k(A,V)}),k(H,M)};q(j,H=>{c(m).after_article_style==="modal_button"?H(x):H(T,!1)})}k(w,S)},y=w=>{var S=Jl(),j=ne(S);L(()=>G(j,`"${c(m).title??""}" ${ke("Title Unavailable Suffix")??""} `)),k(w,S)};q(v,w=>{c(g).length?w(p):w(y,!1)})}L(()=>ue(_,"data-playpilot-injection-key",c(m).key)),k(d,_)}),k(l,u)};q(o,l=>{t.linkInjections.length&&l(s)})}k(e,a),oe()}fe(["click"]);function ts(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function di(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||""}function Mi(e,t,n=[]){var a,o;const i=document.createTreeWalker(t);let r;for(;(r=i.nextNode())&&!((a=r.nodeValue)!=null&&a.includes(e)&&!n.includes(((o=r.parentNode)==null?void 0:o.nodeName)||"")););return r}function Ni(e){const t=e.parentNode;return t?t.nodeName==="A"||!!t.closest("a"):!1}function ns(e,t,n,i){const r=ts(t),a=di(t),o=e.slice(0,i),s=e.slice(i),l=/[-/\\^$*+?.()|[\]{}]/g,u=new RegExp(`${a.replace(l,"\\$&")}|${r.replace(l,"\\$&")}`),d=s.replace(u,n);return o+d}function is(e,t,n,i){return e.substring(0,n)+t+e.substring(i)}function Te(e){return di(e).toLowerCase().replace(/\s+/g,"")}function Br(e,t,n){const r=e.indexOf(t),a=Math.floor((n-t.length)/2);let o=Math.max(0,r-a),s=o+n;s>e.length&&(s=e.length,o=Math.max(0,s-n));let l=e.slice(o,s).trim();return o>0&&(l="…"+l),s<e.length&&(l+="…"),l}function rs(e,t,n){const i=e.nodeType===Node.TEXT_NODE&&e.parentNode?e.parentElement:e;if(!i||!e.textContent)return{before:"",after:""};const r=i.innerText.indexOf(e.textContent),a=Li(i.innerText.slice(0,t+r)),o=i.innerText.slice(n+r),s=Li(Oi(a,2)),l=Oi(o,2);return{before:s,after:l}}function Li(e){return e.split("").reverse().join("")}function Oi(e,t=1){const n=e.match(/[^\s]+/g);return n?n.slice(0,t).join(" ").replace(/[.,!?;:]+$/u,""):""}function as(e,t){let n=0,i=0;for(;(i=e.indexOf(t,i))!==-1;)n++,i+=t.length;return n}function os(e,t,n){const i=[];let r=0;for(;r<=e.length;){const a=t?e.indexOf(t,r):r;if(a===-1&&t)break;const o=t?a+t.length:a,s=n?e.indexOf(n,o):e.length;if(n&&s===-1)break;const l=e.slice(o,s);i.push({match:l,index:o}),r=n?s+n.length:e.length+1}return i}function ls(e,t,n,i){const a=os(e,n,i).filter(({match:s})=>di(s).includes(t));return a.length?a.reduce((s,l)=>!s||l.match.length<s.match.length?l:s):null}function ss(e){var t,n;return{leadingSpaces:((t=e.match(/^\s*/))==null?void 0:t[0].length)||0,trailingSpaces:((n=e.match(/\s*$/))==null?void 0:n[0].length)||0}}function Vr(e){return e.ctrlKey||e.metaKey||e.button!==0}function cs(e,t){if(!document.startViewTransition||!t){e();return}document.startViewTransition(()=>{const n=document.querySelector("[data-view-transition-old]");if(!n)return;const i=window.getComputedStyle(n).getPropertyValue("view-transition-name");n.style.viewTransitionName="none",e();const r=document.querySelector("[data-view-transition-new]");r&&(r.style.viewTransitionName=i)})}const xt="data-playpilot-injection-key",dn=`[${xt}]`;let fn=null,ut=null,Nt=null,Lt=null;function Ur(e,t=""){const n=[],i=[e];for(;i.length>0;){const r=i.pop();if(n.includes(r)||t&&r.matches(t)||/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|H1)$/.test(r.tagName)||r.offsetWidth<=1)continue;const a=Array.from(r.childNodes).some(l=>{var u;return l.nodeType===Node.TEXT_NODE&&((u=l.nodeValue)==null?void 0:u.trim())!==""});if(a&&r.tagName==="LI"){const l=r.closest("ul, ol");l&&!n.includes(l)&&n.push(l);continue}const o=r.tagName==="P"&&!!r.textContent;if(a||o){n.push(r);continue}const s=Array.from(r.children);for(let l=s.length-1;l>=0;l--)i.push(s[l])}return n}function Vt(){var t;const e=(t=window.PlayPilotLinkInjections)==null?void 0:t.selector;if(e){const n=e.replace(/(:)/g,"\\$1"),i=document.querySelector(n);if(i)return i}return document.querySelector("article")||document.querySelector("main")||document.body}function us(e,t={aiInjections:[],manualInjections:[]}){fi();const n=ps(t);if(!n)return[];const i=Te(e.map(l=>l.innerText).join(" ")),r=ys(n),a=r.filter(l=>i.includes(Te(l.sentence))),o={};for(const l of a){const u=e.findIndex(S=>Te(S.innerText).includes(Te(l.sentence))),d=e[u];if(!d)continue;const f=Mi(l.title,d,["A"]);if(!(f!=null&&f.nodeValue)||Ni(f)){const S=Mi(l.title,d);if(S&&Ni(S)){o[l.key]="Given text is already inside of a link.";continue}}const{injectionElement:_,linkElement:m}=ds(l),{phrase_before:g,phrase_after:v}=l;let p=-1,y=!1;if(as(Te(d.innerText),Te(l.title))===1&&(p=d.innerHTML.indexOf(l.title)),p===-1&&(g||v)){const S=[g,l.title,v].filter(Boolean).join(" ");if(p=d.innerHTML.indexOf(S),p===-1){const j=ls(d.innerHTML,l.title,g||"",v||"");if(j){const{leadingSpaces:x,trailingSpaces:T}=ss(j.match);m.innerHTML=j.match.trim();const H=j.index+x,M=j.index+j.match.length-T;d.innerHTML=is(d.innerHTML,_.outerHTML,H,M),p=j.index,y=!0}}}if(p===-1&&(f!=null&&f.nodeValue)){const S=d.innerHTML.indexOf(f.nodeValue),j=d.innerHTML.indexOf(l.sentence);p=Math.max(S,j,0)}p!==-1&&(y||(d.innerHTML=ns(d.innerHTML,l.title,_.outerHTML,p)))}vs(r),fs();const s=ws(n);return s.length&&hs(e,s),n.filter(l=>l.title_details).map((l,u)=>{const d=l.duplicate??(!l.manual&&ks(l,u,n)),f=document.querySelector(`[${xt}="${l.key}"]`),_=En(l)&&!l.inactive&&!l.after_article&&!f,m=!!e.find(v=>Te(v.innerText).includes(Te(l.sentence))),g=_?o[l.key]||(m?"The link failed to inject for unknown reasons.":"Given sentence was not found in the article."):"";return{...l,inactive:l.inactive??!1,duplicate:d,failed:_,failed_message:g}})}function ds(e){const t=document.createElement("span");t.dataset.playpilotInjectionKey=e.key;const n=document.createElement("a");return n.innerText=e.title,n.href=e.playpilot_url,n.target="_blank",n.rel="noopener nofollow noreferrer",t.insertAdjacentElement("beforeend",n),{injectionElement:t,linkElement:n}}function fs(){const e=Array.from(document.querySelectorAll(`${dn} a`)),t=["--playpilot-injection-text-color","--playpilot-injection-text-color-hover","--playpilot-injection-font-weight","--playpilot-injection-font-weight-headings","--playpilot-injection-text-decoration","--playpilot-injection-text-decoration-hover","--playpilot-injection-background-color","--playpilot-injection-background-color-hover"];e.forEach(n=>{t.forEach(i=>{getComputedStyle(n).getPropertyValue(i)&&(n.dataset.usedCssVariables=`${n.dataset.usedCssVariables||""} ${i}`)})})}function vs(e){window.addEventListener("click",n=>{if(Vr(n))return;const i=n.target;if(!(i!=null&&i.parentElement))return;const r=i.parentElement.getAttribute(xt);if(!r)return;const a=e.find(o=>r===o.key);a&&(n.preventDefault(),cs(()=>{vn(!1),zr(n,a)},!ui.current&&window.innerWidth>=600&&!window.matchMedia("(pointer: coarse)").matches))}),window.addEventListener("mousemove",n=>{if(!ut)return;const i=n.target;i.hasAttribute("data-playpilot-title-popover")||i.closest("[data-playpilot-title-popover]")||i.hasAttribute(xt)||i.closest(dn)||vn()}),Array.from(document.querySelectorAll(dn)).forEach(n=>{const i=n.dataset.playpilotInjectionKey,r=e.find(a=>i===a.key);r&&(n.addEventListener("mouseenter",a=>{ut||_s(a,r)}),n.addEventListener("mouseleave",()=>fn=null))})}function zr(e,t){Vr(e)||Lt||(e.preventDefault(),Lt=Xt(Hl,{target:Xr(),props:{title:t.title_details,onclose:Wr}}))}function Wr(e=!0){Lt&&(kn(Lt,{outro:e}),Lt=null)}function _s(e,t){if(window.matchMedia("(pointer: coarse)").matches)return;ut&&vn();const n=e.currentTarget;fn=n,setTimeout(()=>{fn===n&&(ut=Xt(Ul,{target:Xr(),props:{event:e,title:t.title_details}}))},100)}function vn(e=!0){ut&&(kn(ut,{outro:e}),fn=null,ut=null)}function hs(e,t){var o,s;if(Nt||!t.length)return;const n=document.createElement("div"),i=(o=window.PlayPilotLinkInjections)==null?void 0:o.after_article_selector,r=(i?document.querySelector(i):null)||e[e.length-1],a=((s=window.PlayPilotLinkInjections)==null?void 0:s.after_article_insert_position)||"afterend";n.dataset.playpilotAfterArticlePlaylinks="true",r.insertAdjacentElement(a,n),Nt=Xt(es,{target:n,props:{linkInjections:t,onclickmodal:(l,u)=>zr(l,u)}})}function gs(){var e;Nt&&(kn(Nt),(e=document.querySelector("[data-playpilot-after-article-playlinks]"))==null||e.remove(),Nt=null)}function fi(){document.querySelectorAll(dn).forEach(t=>ms(t.getAttribute(xt)||"")),gs(),Wr(!1),vn(!1)}function ms(e){var i;const t=document.querySelector(`[${xt}="${e}"]`);if(!t)return;const n=(i=t.querySelector("a"))==null?void 0:i.innerHTML;t.outerHTML=n||""}function ps({aiInjections:e,manualInjections:t}){return[...t.map(n=>({...n,manual:!0})),...e]}function Kr(e){return{aiInjections:e.filter(t=>!t.manual),manualInjections:e.filter(t=>t.manual)}}function Yr(e){return!e.inactive&&!e.removed&&!e.duplicate&&!!e.title_details&&En(e)}function En(e){return e.in_text||e.in_text===void 0?!0:!!e.after_article}function ys(e){return Zr(e).filter(t=>t.in_text!==!1&&Yr(t))}function ws(e){return Zr(e).filter(t=>t.after_article===!0&&Yr(t))}function Zr(e){return e.filter(t=>t.removed||t.inactive?!1:t.manual&&!t.removed&&!t.inactive?!0:!e.some(n=>n.manual&&(n.removed||n.inactive)&&Gr(n,t)))}function ks(e,t,n){return n.some((i,r)=>t!==r&&i.manual&&Gr(i,e))}function Gr(e,t){return e.title===t.title&&Te(e.sentence)===Te(t.sentence)}function Xr(){return document.querySelector("[data-playpilot-link-injections]")||document.body}function bs(){const e=Vt();return{heading:xs(e),modified_time:Ss(e),published_time:Es(e)}}function xs(e){const t=e.querySelector("h1")||document.querySelector("h1");return(t==null?void 0:t.innerText.trim())||null}function Ss(e){const t=document.querySelector('meta[property*="modified_time"]')||e.querySelector('[itemprop="dateModified"]')||document.querySelector('[itemprop="dateModified"]')||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?Jr(n):null}function Es(e){const t=document.querySelector('meta[property*="published_time"]')||e.querySelector('[itemprop="datePublished"]')||document.querySelector('[itemprop="datePublished"]')||e.querySelector("time")||document.querySelector("time")||e.querySelector("[datetime]")||document.querySelector("[datetime]")||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?Jr(n):null}function Jr(e){try{return new Date(e).toISOString()}catch{return null}}let On=null;async function Tn(e,{url:t=ai(),hash:n=nl(e),params:i={}}={}){const r=new Headers({"Content-Type":"application/json"}),a=In(),o=Lr()?await Nr():!1,s=Dr(),l=bs();if(!a)throw new Error("No token was provided");const u=await fetch(xn+`/external-pages/?api-token=${a}&include_title_details=true${o?"&editorial_mode_enabled=true":""}&language=${s}`,{headers:r,method:"POST",body:JSON.stringify({hash:n,url:t,metadata:l,page_text:e,...i})});if(!u.ok)throw u;return await u.json()}async function Di(e,{requireCompletedResult:t=!1,pollInterval:n=3e3,maxTries:i=600,onpoll:r=()=>null}={}){let a=0;On&&clearTimeout(On);const o=async(s,l)=>{let u;try{if(u=await Tn(e),t&&u.automation_enabled&&u.ai_running)throw new Error;u.link_injections=Ri(u.link_injections||[]),u.ai_injections=Ri(u.ai_injections||[]),s(u);return}catch{if(a++,a>=i){i>1&&console.error("Max poll limit exceeded. Please return later."),s();return}u&&r(u),On=setTimeout(()=>o(s),n)}};return new Promise(o)}async function Ts(e,t){var o;const n=(o=window.PlayPilotLinkInjections)==null?void 0:o.selector,r=e.filter(s=>s.manual).map(s=>({sid:s.sid,title:s.title,sentence:s.sentence,phrase_before:s.phrase_before,phrase_after:s.phrase_after,playpilot_url:s.playpilot_url,after_article:!!s.after_article,after_article_style:s.after_article_style||null,in_text:s.in_text??!0,inactive:!!s.inactive,removed:!!s.removed}));if(!await Tn(t,{params:{private_token:li(),link_injections:r,text_selector:n}}))throw new Error("saveLinkInjections response was faulty");return e}async function Is(){const e=new Headers({"Content-Type":"application/json"}),t=In();if(!t)throw new Error("No token was provided");const n=await fetch(xn+`/domains/config?api-token=${t}`,{headers:e});if(!n.ok)throw n;try{return await n.json()||null}catch{return null}}function Ri(e){return e.map(t=>({...t,key:Qr(t.sid)}))}function Qr(e){return e+"-"+Or()}function In(){var e;return(e=window.PlayPilotLinkInjections)==null?void 0:e.token}function As(){const e=navigator.userAgent.toLowerCase();return/bot|crawl|spider|google|baidu|bing|msn|teoma|slurp|yandex|facebookexternalhit|facebot/i.test(e)}var Cs=Ne('<svg width="8" height="4" viewBox="0 0 8 4" fill="none" class="svelte-by11ix"><path d="M1 0.5L4 3.5L7 0.5" stroke="currentColor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ps(e,t){const n=N(t,"expanded",3,!1);var i=Cs();L(()=>se(i,"expanded",n())),k(e,i)}var js=Ne('<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="17" r="1" fill="var(--playpilot-warning)"></circle><path d="M12 10L12 14" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M3.44722 18.1056L10.2111 4.57771C10.9482 3.10361 13.0518 3.10362 13.7889 4.57771L20.5528 18.1056C21.2177 19.4354 20.2507 21 18.7639 21H5.23607C3.7493 21 2.78231 19.4354 3.44722 18.1056Z" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ms(e){var t=js();k(e,t)}function Ns(e,t,n){t(!t()),n()(t())}var Ls=I('<button class="switch svelte-91s87b"><div class="label svelte-91s87b"><!></div> <div class="track svelte-91s87b"><div class="knob svelte-91s87b"></div></div></button>');function Wn(e,t){ae(t,!0);let n=N(t,"active",15),i=N(t,"fullwidth",3,!1),r=N(t,"label",3,""),a=N(t,"onclick",3,()=>null);var o=Ls();o.__click=[Ns,n,a];var s=b(o),l=b(s);Ct(l,()=>t.children),L(()=>{ue(o,"aria-label",`Toggle ${r()??""} ${(n()?"off":"on")??""}`),se(o,"active",n()),se(o,"fullwidth",i())}),k(e,o),oe()}fe(["click"]);var Os=I('<input type="text" autocomplete="off" class="svelte-1vrer3i">');function vi(e,t){let n=N(t,"value",15),i=N(t,"label",3,""),r=N(t,"name",3,""),a=N(t,"readonly",3,!1),o=N(t,"oninput",3,()=>null);var s=Os();s.__input=function(...l){var u;(u=o())==null||u.apply(this,l)},L(()=>{ue(s,"name",r()),ue(s,"aria-label",i()),ue(s,"placeholder",i()),s.readOnly=a()}),qo(s,n),k(e,s)}fe(["input"]);var Ds=Ne('<path d="M13.5833 13.6667L4.41667 13.6667M5.5 1.5H12.5C13.9001 1.5 14.6002 1.5 15.135 1.77248C15.6054 2.01217 15.9878 2.39462 16.2275 2.86502C16.5 3.3998 16.5 4.09987 16.5 5.5V12.5C16.5 13.9001 16.5 14.6002 16.2275 15.135C15.9878 15.6054 15.6054 15.9878 15.135 16.2275C14.6002 16.5 13.9001 16.5 12.5 16.5H5.5C4.09987 16.5 3.3998 16.5 2.86502 16.2275C2.39462 15.9878 2.01217 15.6054 1.77248 15.135C1.5 14.6002 1.5 13.9001 1.5 12.5V5.5C1.5 4.09987 1.5 3.3998 1.77248 2.86502C2.01217 2.39462 2.39462 2.01217 2.86502 1.77248C3.3998 1.5 4.09987 1.5 5.5 1.5Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Rs=Ne('<path d="M13.5833 8.58342H4.41667M5.5 1.50009H12.5C13.9001 1.50009 14.6002 1.50009 15.135 1.77258C15.6054 2.01226 15.9878 2.39471 16.2275 2.86512C16.5 3.39989 16.5 4.09996 16.5 5.50009V12.5001C16.5 13.9002 16.5 14.6003 16.2275 15.1351C15.9878 15.6055 15.6054 15.9879 15.135 16.2276C14.6002 16.5001 13.9001 16.5001 12.5 16.5001H5.5C4.09987 16.5001 3.3998 16.5001 2.86502 16.2276C2.39462 15.9879 2.01217 15.6055 1.77248 15.1351C1.5 14.6003 1.5 13.9002 1.5 12.5001V5.50009C1.5 4.09996 1.5 3.39989 1.77248 2.86512C2.01217 2.39471 2.39462 2.01226 2.86502 1.77258C3.3998 1.50009 4.09987 1.50009 5.5 1.50009Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),qs=Ne('<svg width="18" height="18" viewBox="0 0 18 18" fill="none"><!></svg>');function qi(e,t){const n=N(t,"align",3,"bottom");var i=qs(),r=b(i);{var a=s=>{var l=Ds();k(s,l)},o=s=>{var l=Be(),u=ne(l);{var d=f=>{var _=Rs();k(f,_)};q(u,f=>{n()==="center"&&f(d)},!0)}k(s,l)};q(r,s=>{n()==="bottom"?s(a):s(o,!1)})}k(e,i)}var Hs=I("<div><!></div>");function _t(e,t){ae(t,!0);const n=N(t,"type",3,"error"),i=N(t,"fixed",3,!1);var r=Hs(),a=b(r);Ct(a,()=>t.children),L(()=>{Mo(r,`alert ${n()??""} svelte-df5n87`),se(r,"fixed",i())}),k(e,r),oe()}var Fs=I("<!> In-text Playlink",1),Bs=I("<!> Bottom Playlink",1),Vs=I('<div class="alert svelte-1shw34x"><!></div>'),Us=(e,t)=>t().after_article_style="playlinks",zs=(e,t)=>t().after_article_style="modal_button",Ws=I('<div><div class="label svelte-1shw34x">Bottom playlinks style</div> <div class="group svelte-1shw34x" role="listbox" tabindex="0" aria-label="Playlink type"><button role="option" id="playlinks-in-text" class="svelte-1shw34x">Playlinks sentence</button> <button role="option" id="playlinks-after-article" class="svelte-1shw34x">Modal button</button> <div class="active-marker svelte-1shw34x"></div></div></div>'),Ks=I('<div class="switches svelte-1shw34x"><!> <!></div> <!> <!>',1);function Ys(e,t){ae(t,!0);const n=N(t,"linkInjection",7),i=K(()=>n().after_article_style==="modal_button");var r=Ks(),a=ne(r),o=b(a),s=K(()=>n().in_text??!0);Wn(o,{fullwidth:!0,get active(){return c(s)},onclick:g=>{n().in_text=g,n().manual=!0},label:"In-text Playlink",children:(g,v)=>{var p=Fs(),y=ne(p);qi(y,{align:"center"}),k(g,p)},$$slots:{default:!0}});var l=E(o,2),u=K(()=>n().after_article??!1);Wn(l,{fullwidth:!0,get active(){return c(u)},onclick:g=>{n().after_article=g,n().manual=!0},label:"Bottom Playlink",children:(g,v)=>{var p=Bs(),y=ne(p);qi(y,{align:"bottom"}),k(g,p)},$$slots:{default:!0}});var d=E(a,2);{var f=g=>{var v=Vs(),p=b(v);_t(p,{type:"warning",children:(y,w)=>{var S=Fe("At least one layout option must be selected for the playlink to be visible.");k(y,S)},$$slots:{default:!0}}),je(3,v,()=>Ft,()=>({duration:200})),k(g,v)};q(d,g=>{En(n())||g(f)})}var _=E(d,2);{var m=g=>{var v=Ws(),p=E(b(v),2),y=b(p);y.__click=[Us,n];var w=E(y,2);w.__click=[zs,n];var S=E(w,2);L(()=>{ue(p,"aria-activedescendant",`playlinks-${(c(i)?"after-article":"in-text")??""}`),ue(y,"aria-selected",!c(i)||null),se(y,"active",!c(i)),ue(w,"aria-selected",c(i)||null),se(w,"active",c(i)),se(S,"right",c(i))}),je(3,v,()=>Ft,()=>({duration:100})),k(g,v)};q(_,g=>{n().after_article&&g(m)})}k(e,r),oe()}fe(["click"]);var Zs=Ne('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.99984 10.8333C10.4601 10.8333 10.8332 10.4602 10.8332 10C10.8332 9.53977 10.4601 9.16668 9.99984 9.16668C9.5396 9.16668 9.1665 9.53977 9.1665 10C9.1665 10.4602 9.5396 10.8333 9.99984 10.8333Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 5.00001C10.4601 5.00001 10.8332 4.62691 10.8332 4.16668C10.8332 3.70644 10.4601 3.33334 9.99984 3.33334C9.5396 3.33334 9.1665 3.70644 9.1665 4.16668C9.1665 4.62691 9.5396 5.00001 9.99984 5.00001Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 16.6667C10.4601 16.6667 10.8332 16.2936 10.8332 15.8333C10.8332 15.3731 10.4601 15 9.99984 15C9.5396 15 9.1665 15.3731 9.1665 15.8333C9.1665 16.2936 9.5396 16.6667 9.99984 16.6667Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Gs(e){var t=Zs();k(e,t)}var Xs=(e,t)=>P(t,!c(t)),Js=I('<div class="content svelte-zpsd2z"><!></div>'),Qs=I('<div class="context-menu svelte-zpsd2z"><button class="svelte-zpsd2z"><!></button> <!></div>');function $s(e,t){ae(t,!0);let n=U(!1),i=U(null);function r(d){var _;const f=d.target;f===c(i)||(_=c(i))!=null&&_.contains(f)||P(n,!1)}var a=Qs();ce("click",pe,r);var o=b(a);o.__click=[Xs,n];var s=b(o);Gs(s),Qt(o,d=>P(i,d),()=>c(i));var l=E(o,2);{var u=d=>{var f=Js(),_=b(f);Ct(_,()=>t.children),je(1,f,()=>Sn,()=>({duration:150,y:5})),k(d,f)};q(l,d=>{c(n)&&d(u)})}L(()=>{ue(o,"aria-label",t.ariaLabel),ue(o,"aria-expanded",c(n))}),k(e,a),oe()}fe(["click"]);function ec(e,t,n,i){var r,a;c(t)&&(be(ye.ManualReport,n.linkInjection.title_details,{report_reason:c(t),sid:n.linkInjection.sid,title:n.linkInjection.title,sentence:n.linkInjection.sentence,failed:(r=n.linkInjection.failed)==null?void 0:r.toString(),failed_message:n.linkInjection.failed_message,manual:(a=n.linkInjection.manual)==null?void 0:a.toString()}),P(i,!0),setTimeout(n.onclose,3e3))}var tc=(e,t,n)=>P(t,X(n())),nc=I('<option class="svelte-o5qkco"> </option>'),ic=I('<div class="sent svelte-o5qkco">Report has been sent, thank you! Closing window...</div>'),rc=I('<button class="submit svelte-o5qkco">Send report</button>'),ac=I('<div class="form svelte-o5qkco"><div class="heading svelte-o5qkco">Report issue</div> <div class="info svelte-o5qkco"><div><strong class="svelte-o5qkco">Title</strong> </div> <div><strong class="svelte-o5qkco">Sentence</strong> </div></div> <label for="reason">What would you like to report?</label> <select id="reason" name="reason" class="svelte-o5qkco"><option class="svelte-o5qkco">Select an issue...</option><!></select> <div><!></div></div>');function oc(e,t){ae(t,!0);const n=[{value:"failed_injection",label:"The link failed to appear on the page."},{value:"layout_issue",label:"The link is breaking the layout or formatting of my page."},{value:"wrong_content",label:"The link points to the wrong movie or show."},{value:"inappropriate_title",label:"The link points to an inappropriate movie or show."},{value:"broken_link",label:"The link is broken or leads to an error page."},{value:"other",label:"My issue is not listed, but please have a look regardless."}];let i=U(""),r=U(!1);qr(e,{get onclose(){return t.onclose},children:(a,o)=>{var s=ac(),l=b(s);Jt(l,(x,T)=>xe==null?void 0:xe(x,T),()=>2);var u=E(l,2),d=b(u),f=E(b(d)),_=E(d,2),m=E(b(_));L(()=>G(m,`:
9
- ${Br(t.linkInjection.sentence,t.linkInjection.title,100)??""}`));var g=E(u,4),v=b(g);v.value=((v.__value="")==null,"");var p=E(v);at(p,17,()=>n,bt,(x,T)=>{let H=()=>c(T).value,M=()=>c(T).label;var C=nc(),D={};C.__click=[tc,i,H];var A=b(C);L(()=>{D!==(D=H())&&(C.value=(C.__value=H())==null?"":H()),G(A,M())}),k(x,C)});var y=E(g,2),w=b(y);{var S=x=>{var T=ic();je(1,T,()=>Ht,()=>({duration:200})),k(x,T)},j=x=>{var T=rc();T.__click=[ec,i,t,r],L(()=>T.disabled=!c(i)),k(x,T)};q(w,x=>{c(r)?x(S):x(j,!1)})}L(()=>G(f,`: ${t.linkInjection.title??""}`)),Fo(g,()=>c(i),x=>P(i,x)),k(a,s)},$$slots:{default:!0}}),oe()}fe(["click"]);function lc(e,t,n){requestAnimationFrame(()=>t());const i=e.target;if(["BUTTON","INPUT"].includes(i.nodeName)||i.closest("button")||i.closest("input"))return;const r=n()[0];r&&r.scrollIntoView({behavior:"smooth"})}function sc(e,t){const n=Xt(oc,{target:document.body,props:{linkInjection:t(),onclose:()=>kn(n)}})}var cc=(e,t)=>P(t,!c(t)),uc=I('<button class="expand-sentence svelte-lo6h85"> </button>'),dc=I('<button class="context-menu-action svelte-lo6h85">Remove</button> <button class="context-menu-action svelte-lo6h85">Report issue</button>',1),fc=(e,t)=>P(t,!c(t)),vc=I('<div class="warning svelte-lo6h85" aria-label="Invalid playlink settings"><!></div>'),_c=I('<div class="actions svelte-lo6h85"><button class="expand svelte-lo6h85" aria-label="Expand"><!></button> <!> <!></div>'),hc=I('<div class="expanded svelte-lo6h85"><div class="label svelte-lo6h85">Link URL</div> <!> <div class="label offset svelte-lo6h85">Layout options</div> <div class="type-select svelte-lo6h85"><!></div></div>'),gc=I('<div class="item svelte-lo6h85"><div class="header svelte-lo6h85"><img class="poster svelte-lo6h85" alt="" width="32" height="48"> <div class="info svelte-lo6h85"><div class="title svelte-lo6h85"> </div> <div class="sentence svelte-lo6h85"><!> <!></div></div> <div class="context-menu svelte-lo6h85"><!></div></div> <div class="content svelte-lo6h85"><!> <!></div></div>');function mc(e,t){ae(t,!0);const n=N(t,"linkInjection",15),i=N(t,"onremove",3,()=>null),r=N(t,"onhighlight",3,()=>null),a=K(()=>n()||{}),o=K(()=>c(a).key),s=K(()=>c(a).sentence),l=K(()=>c(a).title_details),u=K(()=>c(a).failed),d=K(()=>c(a).failed_message),f=K(()=>c(a).inactive),_=K(()=>c(l)),m=K(()=>Br(n().sentence,n().title,60));let g=U(!1),v=U(!1),p=U(!1),y=U(null);Je(()=>{c(u)&&be(ye.InjectionFailed,c(_),{phrase:n().title,sentence:c(s)})});function w(Q=!0){j().forEach(le=>{le.classList.toggle("playpilot-injection-highlight",Q)})}function S(Q){let te=Q.target,le=te==null?void 0:te.dataset.playpilotInjectionKey;te&&!le&&(te=te.closest(`[data-playpilot-injection-key="${c(o)}"]`),le=te==null?void 0:te.dataset.playpilotInjectionKey),P(p,le===c(o)),c(y)&&c(p)&&r()(c(y))}function j(){const Q=Array.from(document.querySelectorAll(`[data-playpilot-injection-key="${c(o)}"]`));return Q.length?Q:Ur(Vt()).filter(te=>Te(te.innerText).includes(Te(n().sentence)))||[]}var x=gc();ce("mouseover",pe,S),x.__click=[lc,w,j];var T=b(x),H=b(T);L(()=>ue(H,"src",Bt(c(_).standing_poster)));var M=E(H,2),C=b(M),D=b(C),A=E(C,2),F=b(A);To(F,()=>(c(v)?c(s):c(m)).replace(n().title,`<em>${n().title}</em>`));var O=E(F,2);{var z=Q=>{var te=uc();te.__click=[cc,v];var le=b(te);L(()=>G(le,c(v)?"Less":"More")),k(Q,te)};q(O,Q=>{c(m).length<c(s).length&&Q(z)})}var B=E(M,2),V=b(B);$s(V,{ariaLabel:"More options",children:(Q,te)=>{var le=dc(),Ce=ne(le);Ce.__click=function(...ot){var R;(R=i())==null||R.apply(this,ot)};var Qe=E(Ce,2);Qe.__click=[sc,n],k(Q,le)},$$slots:{default:!0}});var W=E(T,2),J=b(W);{var ee=Q=>{_t(Q,{children:(te,le)=>{var Ce=Fe();L(()=>G(Ce,c(d))),k(te,Ce)},$$slots:{default:!0}})},re=Q=>{var te=_c(),le=b(te);le.__click=[fc,g];var Ce=b(le);Ps(Ce,{get expanded(){return c(g)}});var Qe=E(le,2);{var ot=ve=>{var Se=vc(),Le=b(Se);Ms(Le),je(3,Se,()=>Ht,()=>({duration:100})),k(ve,Se)};q(Qe,ve=>{En(n())||ve(ot)})}var R=E(Qe,2),Y=K(()=>c(f)?"Inactive":"Visible"),_e=K(()=>!n().inactive);Wn(R,{get label(){return c(Y)},get active(){return c(_e)},onclick:ve=>{n(n().inactive=!ve,!0),n(n().manual=!0,!0)},children:(ve,Se)=>{var Le=Fe();L(()=>G(Le,c(f)?"Inactive":"Visible")),k(ve,Le)},$$slots:{default:!0}}),L(()=>ue(le,"aria-expanded",c(g))),k(Q,te)};q(J,Q=>{c(u)?Q(ee):Q(re,!1)})}var de=E(J,2);{var Ae=Q=>{var te=hc(),le=E(b(te),2);vi(le,{oninput:()=>n(n().manual=!0,!0),label:"Playlink URL",get value(){return n().playpilot_url},set value(ot){n(n().playpilot_url=ot,!0)}});var Ce=E(le,4),Qe=b(Ce);Ys(Qe,{get linkInjection(){return n()}}),je(3,te,()=>Ft,()=>({duration:100})),k(Q,te)};q(de,Q=>{c(g)&&Q(Ae)})}Qt(x,Q=>P(y,Q),()=>c(y)),L(()=>{se(x,"highlighted",c(p)),se(x,"inactive",c(f)),G(D,c(_).title)}),ce("mouseenter",x,()=>w(!0)),ce("mouseleave",x,()=>w(!1)),ce("error",H,({target:Q})=>Q.src=Pr),je(6,x,()=>Ft,()=>({duration:200})),k(e,x),oe()}fe(["click"]);var pc=I('<button class="drag-handle svelte-19mcc5g" aria-label="Move editor"></button>');function yc(e,t){ae(t,!0);let n=N(t,"element",7),i=N(t,"position",23,()=>({x:0,y:0})),r=N(t,"limit",19,()=>({x:0,y:0})),a=N(t,"onchange",3,()=>null),o=!1,s={x:0,y:0},l=i();Je(()=>{u(i().x,i().y)});function u(v,p){const y=window.innerWidth,w=window.innerHeight,S=n().clientWidth,j=n().clientHeight;v=Math.min(Math.max(v,r().x),y-S-r().x),p=Math.min(Math.max(p,r().y),w-j-r().y),n().style.right=v+"px",n().style.bottom=Math.max(p,r().y)+"px",i({x:v,y:p}),a()(i())}function d(v){var p,y;return{x:v.pageX||((p=v.touches)==null?void 0:p[0].pageX)||0,y:v.pageY||((y=v.touches)==null?void 0:y[0].pageY)||0}}function f(v){o=!0,s=d(v),l=i()}function _(v){if(!o)return;const p=d(v),y=p.x-s.x,w=p.y-s.y,S=l.x-y,j=l.y-w;u(S,j)}function m(){o&&(o=!1)}var g=pc();ce("mousemove",pe,_),ce("touchmove",pe,_,void 0,!0),ce("mouseup",pe,m),ce("touchend",pe,m),ce("resize",pe,()=>u(i().x,i().y)),g.__mousedown=f,g.__touchstart=f,k(e,g),oe()}fe(["mousedown","touchstart"]);var wc=I('<button class="resize-handle svelte-sxkuxk" aria-label="Move editor"></button>');function kc(e,t){ae(t,!0);let n=N(t,"element",7),i=N(t,"height",7,200),r=N(t,"onchange",3,()=>null);const a=16;let o=!1,s=0,l=i();Je(()=>{i()&&u(i())});function u(v){const p=window.getComputedStyle(n()).minHeight||"0",y=Math.max(parseInt(p),Math.min(v,m()));n().style.height=`${y}px`,i(y),r()(y)}function d(v){var p,y;o=!0,s=v.pageY||((y=(p=v.touches)==null?void 0:p[0])==null?void 0:y.pageY)||0,l=n().clientHeight}function f(v){var S,j;if(!o)return;const p=v.pageY||((j=(S=v.touches)==null?void 0:S[0])==null?void 0:j.pageY)||0,y=s-p,w=l+y;u(w)}function _(){o=!1}function m(){const v=window.innerHeight-n().getBoundingClientRect().bottom;return Math.max(window.innerHeight-a*2-v,0)}var g=wc();ce("mousemove",pe,f),ce("touchmove",pe,f,void 0,!0),ce("mouseup",pe,_),ce("touchend",pe,_),ce("resize",pe,()=>{i()&&u(i())}),g.__mousedown=d,g.__touchstart=d,k(e,g),oe()}fe(["mousedown","touchstart"]);var bc=Ne('<svg width="4" height="8" viewBox="0 0 4 8" fill="none"><path d="M3.5 7L0.5 4L3.5 1" stroke="currentcolor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function xc(e){var t=bc();k(e,t)}async function Sc(e){const t=new Headers({"Content-Type":"application/json"}),n=In();if(!n)throw new Error("No token was provided");const i=await fetch(xn+`/search/titles/?api-token=${n}&query=${e}`,{headers:t});if(!i.ok)throw i;return await i.json()}var Ec=Ne('<svg viewBox="0 -960 960 960" width="18" height="18"><path fill="currentColor" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"></path></svg>');function Tc(e){var t=Ec();k(e,t)}var Ic=I("<div> </div>"),Ac=e=>e.stopImmediatePropagation(),Cc=I('<button class="item svelte-rjq94e"><img class="poster svelte-rjq94e" alt="" width="28" height="42"> <div class="content"><div class="name svelte-rjq94e"> </div> <div class="meta svelte-rjq94e"><div class="imdb svelte-rjq94e"><!> </div> <div> </div> <div> </div> <!></div></div> <a target="_blank" class="open-in-new-tab svelte-rjq94e"><!></a></button>');function Hi(e,t){ae(t,!0);const n=N(t,"hoverable",3,!0),i=N(t,"onclick",3,()=>null);var r=Cc();r.__click=function(...x){var T;(T=i())==null||T.apply(this,x)};var a=b(r);L(()=>ue(a,"src",Bt(t.title.standing_poster)));var o=E(a,2),s=b(o),l=b(s),u=E(s,2),d=b(u),f=b(d);Hr(f);var _=E(f),m=E(d,2),g=b(m),v=E(m,2),p=b(v),y=E(v,2);{var w=x=>{var T=Ic(),H=b(T);L(()=>G(H,`${t.title.length??""} min`)),k(x,T)};q(y,x=>{t.title.length&&x(w)})}var S=E(o,2);S.__click=[Ac];var j=b(S);Tc(j),L(()=>{se(r,"hoverable",n()),G(l,t.title.title),G(_,` ${t.title.imdb_score??""}`),G(g,t.title.year),G(p,t.title.type),ue(S,"href",`${Cr}/${t.title.type??""}/${t.title.slug??""}`)}),ce("error",a,({target:x})=>x.src=Pr),k(e,r),oe()}fe(["click"]);var Pc=I('<em class="empty svelte-1olb8n0">No results found</em>'),jc=I('<div class="results svelte-1olb8n0" data-testid="search-results"></div>'),Mc=I('<div class="selected svelte-1olb8n0"><!></div>'),Nc=I('<div class="search svelte-1olb8n0"><!> <!> <!></div>');function Lc(e,t){ae(t,!0);let n=N(t,"onselect",3,()=>null),i=N(t,"query",15),r=U(X([])),a=U(null),o=U(!1);mn(()=>{i()&&s(i())});async function s(v){P(o,!0);try{P(r,X(await Sc(v)))}finally{P(o,!1)}}function l(v){i(v.title),P(a,X(v)),n()(v)}var u=Nc(),d=b(u);vi(d,{oninput:()=>P(a,null),name:"search",label:"Search...",get value(){return i()},set value(v){i(v)}});var f=E(d,2);{var _=v=>{var p=jc();at(p,21,()=>c(r),y=>y.sid,(y,w)=>{Hi(y,{get title(){return c(w)},onclick:()=>l(c(w))})},y=>{var w=Be(),S=ne(w);{var j=x=>{var T=Pc();k(x,T)};q(S,x=>{c(o)||x(j)})}k(y,w)}),k(v,p)};q(f,v=>{i()&&!c(a)&&v(_)})}var m=E(f,2);{var g=v=>{var p=Mc(),y=b(p);Hi(y,{get title(){return c(a)},hoverable:!1}),k(v,p)};q(m,v=>{c(a)&&v(g)})}k(e,u),oe()}function Oc(e,t=e.anchorNode){if(!e.anchorNode||!t)return{start:-1,end:-1};const n=e.toString().trim(),i=e.toString().search(/\S/);if(e.anchorNode===t&&t.nodeType===Node.TEXT_NODE){const u=Math.min(e.anchorOffset,e.focusOffset)+i;return{start:u,end:u+n.length}}const r=e.getRangeAt(0),a=r.cloneRange();a.selectNodeContents(t),a.setEnd(r.startContainer,r.startOffset);const s=a.toString().length+i,l=s+n.length;return{start:s,end:l}}function Dc(e,t,n,i,r,a,o,s){if(!c(t)||!c(n))return;const l=c(n).type==="movie"?"movie":"show",u=Cr+`/${l}/${c(n).slug}`,d={sid:c(n).sid,title:c(t),sentence:c(i),phrase_before:c(r),phrase_after:c(a),playpilot_url:u,key:Qr(c(n).sid),title_details:c(n),manual:!0};o.onsave(d),s()()}var Rc=I('<div class="error svelte-1i8p6op"><!></div>'),qc=I('<label for="text" class="svelte-1i8p6op">Paired title</label> <!>',1),Hc=I('<section class="layout svelte-1i8p6op"><div class="header svelte-1i8p6op"><!> <div class="heading svelte-1i8p6op">Add Playlink manually</div></div> <p class="svelte-1i8p6op">Highlight the text section in your post that you want to turn into a Playlink.</p> <label for="text" class="svelte-1i8p6op">Selected text</label> <!> <!> <!> <button class="save svelte-1i8p6op">Add playlink</button></section>');function Fc(e,t){ae(t,!0);const n=N(t,"pageText",3,""),i=N(t,"onclose",3,()=>null);let r=U(""),a=U(""),o=U(null),s=U(""),l=U(""),u=U(""),d=U("");Je(f);function f(){const C=window.getSelection();if(!(C!=null&&C.anchorNode)||C.anchorNode.parentElement&&!Vt().contains(C.anchorNode.parentElement))return;const D=C.toString().trim();if(!D)return;P(u,""),P(r,X(D));const A=C.getRangeAt(0).cloneContents();if(Array.from(A.childNodes).filter(ee=>{var re;return(re=ee.textContent)==null?void 0:re.trim()}).find(ee=>{var re;return ee.nodeName==="A"||((re=ee.querySelector)==null?void 0:re.call(ee,"a"))})){P(u,"Selection is or contains a link. Injections can not be created around already existing links.");return}P(d,X(c(r)));const{node:O,sentence:z}=_(C,D);if(!O)return;P(a,X(z));const{start:B,end:V}=Oc(C,O);(ee=>(P(l,X(ee.before)),P(s,X(ee.after))))(rs(O,B,V)),z.includes(c(l))||P(l,""),z.includes(c(s))||P(s,"");const W=C.getRangeAt(0).commonAncestorContainer.textContent,J=Te(n());(!W||!J.includes(Te(W)))&&P(u,"Selection was not inside of given content")}function _(C,D){const A=C.getRangeAt(0),F=Vt();let O=A.startContainer;for(;(O.textContent||"").length<=D.length*3&&O.parentNode&&O.parentNode.textContent!==F.textContent;)O=O.parentNode;if(!O||!O.textContent)return{node:null,sentence:""};const z=O.textContent,B=m(O,A.startContainer,A.startOffset),V=m(O,A.endContainer,A.endOffset),W=z.slice(0,B).lastIndexOf("."),J=z.slice(V).match(/[.!?]/),ee=J?V+J.index:z.length,re=W===-1?0:W+1,de=ee,Ae=z.slice(re,de+1).trim();return{node:O,sentence:Ae}}function m(C,D,A){let F=0;const O=C,z=B=>{var V;if(B===D)return F+=A,!0;B.nodeType===Node.TEXT_NODE&&(F+=((V=B.textContent)==null?void 0:V.length)||0);for(let W=B.firstChild;W;W=W.nextSibling)if(z(W))return!0;return!1};return z(O),F}function g(C){var D,A;P(o,X(C)),(A=(D=window.getSelection())==null?void 0:D.removeAllRanges)==null||A.call(D)}var v=Hc();ce("mouseup",pe,f);var p=b(v),y=b(p);ci(y,{get onclick(){return i()},size:"24px",children:(C,D)=>{xc(C)},$$slots:{default:!0}});var w=E(y,2);Jt(w,(C,D)=>xe==null?void 0:xe(C,D),()=>2);var S=E(p,6);vi(S,{get value(){return c(r)},label:"Select text on the page",name:"selected-text",readonly:!0});var j=E(S,2);{var x=C=>{var D=Rc(),A=b(D);_t(A,{children:(F,O)=>{var z=Fe();L(()=>G(z,c(u))),k(F,z)},$$slots:{default:!0}}),k(C,D)};q(j,C=>{c(u)&&C(x)})}var T=E(j,2);{var H=C=>{var D=qc(),A=E(ne(D),2);Sr(A,()=>c(a)+c(r),F=>{Lc(F,{onselect:g,get query(){return c(d)},set query(O){P(d,X(O))}})}),k(C,D)};q(T,C=>{c(u)||C(H)})}var M=E(T,2);M.__click=[Dc,r,o,a,l,s,t,i],L(()=>M.disabled=!c(r)||!c(o)),k(e,v),oe()}fe(["click"]);const Kn="PlayPilotEditorialSessionId",$r=5e3,Bc=$r*2;async function Vc(e){const{automation_enabled:t,injections_enabled:n,session_id:i,session_last_ping:r}=await Tn(e),a=ta(i||null,r||null),o={automation_enabled:t,injections_enabled:n,session_id:i,session_last_ping:r};return a?await ea(e):o}async function ea(e){const t=na(),n=new Date(Date.now()).toISOString(),i={session_id:t,session_last_ping:n.toString()},{automation_enabled:r,injections_enabled:a}=await Tn(e,{params:i});return{automation_enabled:r,injections_enabled:a,...i}}function ta(e,t){if(!e||!t)return!0;const n=Date.now(),i=new Date(t),r=na();return n-i.getTime()>Bc?!0:r===e}function na(){return sessionStorage.getItem(Kn)||Uc()}function Uc(){const e=sessionStorage.getItem(Kn)||Or();return sessionStorage.setItem(Kn,e),e}function zc(e,t,n){ea(t()),n()()}var Wc=I('<p class="svelte-2m2urs"><strong>Someone else is currently editing this document.</strong> Wait for them to exit the page or take over edit permissions, preventing them from making more changes.</p> <button class="button svelte-2m2urs">Take over editing</button>',1),Kc=I('<div class="alert svelte-2m2urs"><!></div>');function Yc(e,t){ae(t,!0);const n=N(t,"pageText",3,""),i=N(t,"onpoll",3,()=>null),r=N(t,"onallow",3,()=>null),a=N(t,"ondisallow",3,()=>null),o=N(t,"ontakeover",3,()=>null);let s=null,l=U(!0);Je(()=>(u(),()=>{s&&clearInterval(s)}));function u(){d(),s=setInterval(d,$r)}async function d(){const g=await Vc(n());g&&(P(l,X(ta(g.session_id||null,g.session_last_ping||null))),c(l)?r()():a()(),i()({injectionsEnabled:!!g.injections_enabled,automationEnabled:!!g.automation_enabled}))}var f=Be(),_=ne(f);{var m=g=>{var v=Kc(),p=b(v);_t(p,{type:"warning",children:(y,w)=>{var S=Wc(),j=E(ne(S),2);j.__click=[zc,n,o],k(y,S)},$$slots:{default:!0}}),k(g,v)};q(_,g=>{c(l)||g(m)})}k(e,f),oe()}fe(["click"]);var Zc=Ne('<svg width="24px" height="24px" viewBox="0 0 64 64" stroke-width="3" stroke="currentColor" fill="none"><circle cx="34.52" cy="11.43" r="5.82"></circle><circle cx="53.63" cy="31.6" r="5.82"></circle><circle cx="34.52" cy="50.57" r="5.82"></circle><circle cx="15.16" cy="42.03" r="5.82"></circle><circle cx="15.16" cy="19.27" r="5.82"></circle><circle cx="34.51" cy="29.27" r="4.7"></circle><line x1="20.17" y1="16.3" x2="28.9" y2="12.93"></line><line x1="38.6" y1="15.59" x2="49.48" y2="27.52"></line><line x1="50.07" y1="36.2" x2="38.67" y2="46.49"></line><line x1="18.36" y1="24.13" x2="30.91" y2="46.01"></line><line x1="20.31" y1="44.74" x2="28.7" y2="48.63"></line><line x1="17.34" y1="36.63" x2="31.37" y2="16.32"></line><line x1="20.52" y1="21.55" x2="30.34" y2="27.1"></line><line x1="39.22" y1="29.8" x2="47.81" y2="30.45"></line><line x1="34.51" y1="33.98" x2="34.52" y2="44.74"></line></svg>');function Gc(e){var t=Zc();k(e,t)}var Xc=I('<strong class="svelte-1kpafo0">AI processing is disabled.</strong> Enable AI from the <a href="https://partner.playpilot.net" class="svelte-1kpafo0">Partner Portal</a>',1),Jc=I('<span class="svelte-1kpafo0">.</span>'),Qc=I(`<strong class="svelte-1kpafo0">AI links are currently processing.</strong> This can take several minutes. We'll insert all found injections once ready. <div class="message svelte-1kpafo0"> <span class="ellipses svelte-1kpafo0"></span></div> <div class="loading-bar svelte-1kpafo0"><div class="loading-bar-progress svelte-1kpafo0"><div class="loading-bar-fill svelte-1kpafo0" data-testid="loading-bar"></div></div> <div class="loading-bar-label svelte-1kpafo0"> </div></div>`,1),$c=(e,t)=>P(t,!0),eu=I('<p class="svelte-1kpafo0"><strong class="svelte-1kpafo0">AI has finished processing.</strong> <br class="svelte-1kpafo0"> <!></p> <button class="dismiss svelte-1kpafo0">Dismiss</button>',1),tu=I('<div class="animator svelte-1kpafo0" data-test-id="animator"></div>'),nu=I('<div class="ai-indicator svelte-1kpafo0" data-testid="ai-indicator"><div class="content svelte-1kpafo0"><div class="icon svelte-1kpafo0"><!></div> <div class="svelte-1kpafo0"><!></div></div> <div class="border svelte-1kpafo0"><!></div></div>');function iu(e,t){const n=N(t,"aiRunning",3,!1),i=N(t,"automationEnabled",3,!1),r=N(t,"message",3,""),a=N(t,"percentage",3,0),o=N(t,"aiInjectionsCount",3,0),s=o();let l=U(!1);var u=Be(),d=ne(u);{var f=_=>{var m=nu(),g=b(m),v=b(g),p=b(v);Gc(p);var y=E(v,2),w=b(y);{var S=M=>{var C=Xc();k(M,C)},j=M=>{var C=Be(),D=ne(C);{var A=O=>{var z=Qc(),B=E(ne(z),2),V=b(B),W=E(V);at(W,20,()=>({length:3}),bt,(te,le)=>{var Ce=Jc();k(te,Ce)});var J=E(B,2),ee=b(J),re=b(ee);const de=K(()=>`${Math.max(a(),3)??""}%`);L(()=>bn(re,"width",c(de)));var Ae=E(ee,2),Q=b(Ae);L(()=>G(Q,`${Math.floor(a())??""}%`)),L(()=>G(V,`${r()??""} `)),k(O,z)},F=O=>{var z=eu(),B=ne(z),V=E(b(B),4);{var W=re=>{var de=Fe("No new injections where found.");k(re,de)},J=re=>{var de=Fe();L(()=>G(de,`${o()??""} Injections where found and added to the page.`)),k(re,de)};q(V,re=>{s===o()?re(W):re(J,!1)})}var ee=E(B,2);ee.__click=[$c,l],k(O,z)};q(D,O=>{n()?O(A):O(F,!1)},!0)}k(M,C)};q(w,M=>{i()?M(j,!1):M(S)})}var x=E(g,2),T=b(x);{var H=M=>{var C=tu();k(M,C)};q(T,M=>{n()&&M(H)})}L(()=>se(m,"running",n())),k(_,m)};q(d,_=>{c(l)||_(f)})}k(e,u)}fe(["click"]);async function ru(e,t,n,i,r,a,o){try{P(t,!0),P(n,!1),i(await Ts(i(),r())),P(a,X(c(o)))}catch{P(n,!0)}finally{P(t,!1)}}var au=I('<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:400,600,700">'),ou=I('<div class="handles svelte-11aj6xq"><div class="handle svelte-11aj6xq"><!></div> <div class="handle svelte-11aj6xq"><!></div></div>'),lu=I('<div class="loading svelte-11aj6xq">Loading...</div>'),su=I('<div class="bubble svelte-11aj6xq"> </div> <!>',1),cu=I(`<strong>Playlinks are currently not published.</strong> Visitors to this page will not see any of the injected links.
10
- Publish playlinks from the <a href="https://partner.playpilot.net">Partner Portal.</a>`,1),uu=I('<div class="alert svelte-11aj6xq"><!></div>'),du=I('<div class="error svelte-11aj6xq"><!></div>'),fu=I('<div class="empty svelte-11aj6xq">No links available. Add links manually by clicking the + button and select text to add a link to.</div>'),vu=I('<button class="save svelte-11aj6xq"> </button>'),_u=I('<!> <!> <div class="items svelte-11aj6xq"></div> <!>',1),hu=I("<!> <!> <!>",1),gu=I('<div class="panel playpilot-styled-scrollbar svelte-11aj6xq"><!></div>'),mu=I('<section class="editor playpilot-styled-scrollbar svelte-11aj6xq"><!> <header class="header svelte-11aj6xq"><div class="heading svelte-11aj6xq">Playlinks</div> <!></header> <!> <!></section>');function pu(e,t){ae(t,!0);let n=N(t,"linkInjections",15),i=N(t,"pageText",3,""),r=N(t,"loading",3,!1),a=N(t,"injectionsEnabled",7,!1),o=N(t,"aiStatus",23,()=>({})),s=N(t,"onreinitialize",3,()=>null);const l="editor-position",u="editor-height",d=JSON.parse(localStorage.getItem(l)||'{ "x": 0, "y": 0 }'),f=parseInt(localStorage.getItem(u)||"0");let _=U(null),m=U(!1),g=U(!1),v=U(!1),p=U(!0),y=U(0),w=U("");const S=K(()=>on(o().automationEnabled,!1)),j=K(()=>on(o().aiRunning,!1)),x=K(()=>JSON.stringify(n())),T=K(()=>!c(j)&&c(p)),H=K(()=>c(w)&&c(w)!==c(x)),M=K(()=>n().filter(R=>R.title_details&&!R.removed&&!R.duplicate&&(R.manual||!R.manual&&!R.failed))),C=K(()=>A(c(M))),D=K(()=>!r()&&Ke(()=>o().aiRunning));mn(()=>{r()||Ke(()=>{requestAnimationFrame(()=>P(w,X(c(x)))),V()})});function A(R){return R.sort((Y,_e)=>Y.failed!==_e.failed?Y.failed?1:-1:Y.title_details.title.localeCompare(_e.title_details.title))}function F(R,Y){localStorage.setItem(R,Y)}function O(R){const Y=n().findIndex(_e=>_e.key===R);n(n()[Y].manual=!0,!0),n(n()[Y].removed=!0,!0),n([...n()])}function z(R){if(!c(_))return;const Y=R.offsetTop,_e=Y+R.offsetHeight,ve=c(_).scrollTop,Se=ve+c(_).clientHeight;Y>=ve&&_e<=Se||c(_).scrollTo({top:Y-c(_).clientHeight/2,behavior:"smooth"})}function B(R){const Y=R.target;P(y,X(Y.scrollTop))}function V(){const R={total:n().length,failed_automatic:n().filter(Y=>Y.failed&&!Y.manual).length,failed_manual:n().filter(Y=>Y.failed&&Y.manual).length,final_injected:c(M).length};be(ye.TotalInjectionsCount,null,R)}var W=mu();wo(R=>{var Y=au();k(R,Y)});var J=b(W);{var ee=R=>{var Y=ou(),_e=b(Y),ve=b(_e);kc(ve,{get element(){return c(_)},height:f,onchange:Ze=>F(u,JSON.stringify(Ze))});var Se=E(_e,2),Le=b(Se);yc(Le,{get element(){return c(_)},position:d,limit:{x:16,y:16},onchange:Ze=>F(l,JSON.stringify(Ze))}),k(R,Y)};q(J,R=>{c(_)&&!r()&&R(ee)})}var re=E(J,2),de=b(re);Jt(de,R=>xe==null?void 0:xe(R));var Ae=E(de,2);{var Q=R=>{var Y=lu();k(R,Y)},te=R=>{var Y=Be(),_e=ne(Y);{var ve=Se=>{var Le=su(),Ze=ne(Le),Oe=b(Ze),$t=E(Ze,2);ci($t,{onclick:()=>P(m,!0),size:"24px","aria-label":"Add manual injection",children:(en,_i)=>{var tn=Fe("+");k(en,tn)},$$slots:{default:!0}}),L(()=>{ue(Ze,"aria-label",`${c(M).length??""} found playlinks`),G(Oe,c(M).length)}),k(Se,Le)};q(_e,Se=>{c(T)&&Se(ve)},!0)}k(R,Y)};q(Ae,R=>{r()?R(Q):R(te,!1)})}var le=E(re,2);{var Ce=R=>{var Y=hu(),_e=ne(Y);Yc(_e,{get pageText(){return i()},onallow:()=>P(p,!0),ondisallow:()=>P(p,!1),get ontakeover(){return s()},onpoll:Oe=>{a(Oe.injectionsEnabled),o().automationEnabled=Oe.automationEnabled}});var ve=E(_e,2);{var Se=Oe=>{iu(Oe,Ko(o,{get aiInjectionsCount(){return Kr(n()).aiInjections.length}}))};q(ve,Oe=>{c(p)&&(c(D)||!c(S))&&Oe(Se)})}var Le=E(ve,2);{var Ze=Oe=>{var $t=_u(),en=ne($t);{var _i=he=>{var ge=uu(),$e=b(ge);_t($e,{type:"warning",children:(lt,oa)=>{var An=cu();k(lt,An)},$$slots:{default:!0}}),k(he,ge)};q(en,he=>{a()||he(_i)})}var tn=E(en,2);{var ia=he=>{var ge=du(),$e=b(ge);_t($e,{children:(lt,oa)=>{var An=Fe("Something went wrong, check your links below.");k(lt,An)},$$slots:{default:!0}}),je(7,ge,()=>Ft,()=>({duration:150})),k(he,ge)};q(tn,he=>{c(v)&&he(ia)})}var hi=E(tn,2);at(hi,21,()=>c(C),he=>he.key,(he,ge)=>{const $e=K(()=>n().findIndex(lt=>lt.key===c(ge).key));mc(he,{onremove:()=>O(c(ge).key),onhighlight:z,get linkInjection(){return n()[c($e)]},set linkInjection(lt){n(n()[c($e)]=lt,!0)}})},he=>{var ge=fu();k(he,ge)});var ra=E(hi,2);{var aa=he=>{var ge=vu();ge.__click=[ru,g,v,n,i,w,x];var $e=b(ge);L(()=>{ge.disabled=c(g),G($e,c(g)?"Saving...":"Save links")}),je(1,ge,()=>Ht,()=>({duration:100})),k(he,ge)};q(ra,he=>{c(H)&&n().length&&c(p)&&he(aa)})}k(Oe,$t)};q(Le,Oe=>{c(T)&&Oe(Ze)})}k(R,Y)};q(le,R=>{r()||R(Ce)})}var Qe=E(le,2);{var ot=R=>{var Y=gu(),_e=b(Y);Fc(_e,{get pageText(){return i()},onclose:()=>P(m,!1),onsave:ve=>n().push(ve)}),L(()=>bn(Y,"top",`${c(y)??""}px`)),je(3,Y,()=>Sn,()=>({x:Math.min(window.innerWidth,320),duration:200,opacity:1})),k(R,Y)};q(Qe,R=>{c(m)&&R(ot)})}Qt(W,R=>P(_,R),()=>c(_)),L(()=>{se(W,"panel-open",c(m)),se(W,"loading",r())}),ce("scroll",W,B),k(e,W),oe()}fe(["click"]);var yu=Ne('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 57.48 62.96"><defs><style>.playpilot-logo{fill:url(#playpilot-linear-gradient);}</style><linearGradient id="playpilot-linear-gradient" x1="-90.03" y1="-40.23" x2="-34.8" y2="-101.48" gradientTransform="translate(74.02 108.65)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#de00b9"></stop><stop offset="0.99" stop-color="#ff557b"></stop></linearGradient></defs><path class="playpilot-logo" d="M57.48,31.48C57.48,22.17,20.85,2.19,9.2.18,7.42-.12,3.78-.37,1.36,2.25-4.32,8.39,9.62,21.5,9.62,31.48S-4.32,54.57,1.36,60.72c2.42,2.61,6.06,2.37,7.84,2.06C20.85,60.78,57.48,40.79,57.48,31.48Z"></path></svg>');function wu(e){var t=yu();k(e,t)}var ku=I('<div class="trigger svelte-qee95d"><button type="button" class="button svelte-qee95d" title="Show PlayPilot TPI editor"><!></button> <button type="button" class="button close svelte-qee95d" title="Close PlayPilot TPI"><!></button></div>');function bu(e,t){var n=ku(),i=b(n);i.__click=function(...s){var l;(l=t.onclick)==null||l.apply(this,s)};var r=b(i);wu(r);var a=E(i,2);a.__click=function(...s){var l;(l=t.onclose)==null||l.apply(this,s)};var o=b(a);Rr(o),k(e,n)}fe(["click"]);var xu=I('<div class="playpilot-link-injections svelte-13rmd3g" data-playpilot-link-injections=""><!> <!></div>');function Su(e,t){ae(t,!0);let n=U(null),i=U(X([])),r=U(null),a=U(X(Lr())),o=U(!!li()),s=U(!1),l=U(!0),u=U(!0),d=U(X([]));const f=K(()=>c(r)||{}),_=K(()=>on(c(f).ai_injections,()=>[],!0)),m=K(()=>on(c(f).link_injections,()=>[],!0)),g=K(()=>c(i).map(A=>A.innerText).join(`
8
+ `}}Ea();var ol=Ne('<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M14 2L2 14M2 2L14 14" stroke="currentColor" stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Rr(e){var t=ol();k(e,t)}function ci(e,t){ae(t,!0);const n=N(t,"size",3,"margin(2)"),i=N(t,"onclick",3,()=>null),r=zo(t,["$$slots","$$events","$$legacy","children","size","onclick"]);var a=Be(),o=ne(a);Io(o,()=>t.href?"a":"button",!1,(s,l)=>{let u;L(()=>{u=jo(s,u,{role:t.href?"link":"button",onclick:i(),class:"button",...r},"svelte-1qqv88o",s.namespaceURI===Zi,s.nodeName.includes("-")),bn(s,"--size",n())});var d=Be(),f=ne(d);Ct(f,()=>t.children??st),k(l,d)}),k(e,a),oe()}function ll(e){P(e,e.v+1)}function sl(e){let t=0,n=Ee(0),i;return()=>{Ka()&&(c(n),pn(()=>(t===0&&(i=Ke(()=>e(()=>ll(n)))),t+=1,()=>{Fn().then(()=>{t-=1,t===0&&(i==null||i(),i=void 0)})})))}}var Ut,zt;class cl{constructor(t,n){Pn(this,Ut);Pn(this,zt);jn(this,Ut,t),jn(this,zt,sl(n))}get current(){return Cn(this,zt).call(this),Cn(this,Ut).call(this)}}Ut=new WeakMap,zt=new WeakMap;const ul=/\(.+\)/;class dl extends cl{constructor(t,n){let i=ul.test(t)?t:`(${t})`;const r=window.matchMedia(i);super(()=>r.matches,a=>yo(r,"change",a))}}const ui=new dl("(prefers-reduced-motion: reduce)");var fl=(e,t)=>t()(),vl=I('<div class="modal svelte-aqwna4"><div class="dialog svelte-aqwna4" role="dialog" aria-labelledby="title" data-view-transition-new=""><div class="close svelte-aqwna4"><!></div> <!></div> <div class="backdrop svelte-aqwna4"></div></div>');function qr(e,t){ae(t,!0);const n=N(t,"onclose",3,()=>null),i=N(t,"onscroll",3,()=>null);yr("scope","modal"),Je(()=>{const f=document.body.style.overflowY;return document.body.style.overflowY="hidden",()=>document.body.style.overflowY=f||""});function r(f){return ui.current?Ht(f,{duration:0}):window.innerWidth<600?Sn(f,{duration:250,y:window.innerHeight}):al(f,{duration:150,start:.85})}var a=vl();ce("keydown",pe,({key:f})=>{f==="Escape"&&n()()});var o=b(a),s=b(o),l=b(s);ci(l,{onclick:()=>n()(),children:(f,_)=>{Rr(f)},$$slots:{default:!0}});var u=E(s,2);Ct(u,()=>t.children);var d=E(o,2);d.__click=[fl,n],ce("scroll",o,function(...f){var _;(_=i())==null||_.apply(this,f)}),je(7,o,()=>r),je(7,a,()=>Ht,()=>({duration:150})),k(e,a),oe()}fe(["click"]);const _l=[{slug:"100",name:"All",categories:{movie:100,series:100,documentary:100,kids:100,cinema:100,podcasts:100}},{slug:"999",name:"Unscripted",categories:{},media_format:"video"},{slug:"900",name:"Independent",categories:{},media_format:"video"},{slug:"113",name:"Game Show",categories:{series:36,kids:28},media_format:"video"},{slug:"112",name:"Film Noir",categories:{movie:37},media_format:"video"},{slug:"212",name:"Entertainment",categories:{kids:80,series:42,movie:42},media_format:"video"},{slug:"120",name:"News",categories:{series:26,documentary:36,kids:38},media_format:"video"},{slug:"208",name:"Short",categories:{movie:21,documentary:30,kids:36},media_format:"video"},{slug:"902",name:"Bollywood",categories:{},media_format:"video"},{slug:"240",name:"Concert",categories:{movie:45},media_format:"video"},{slug:"901",name:"Arthouse",categories:{},media_format:"video"},{slug:"903",name:"Alternate Version",categories:{},media_format:"video"},{slug:"121",name:"Reality TV",categories:{series:24},media_format:"video"},{slug:"202",name:"Culture",categories:{kids:40,documentary:84,series:44},media_format:"video"},{slug:"107",name:"Drama",categories:{series:82,movie:82,cinema:88,documentary:44},media_format:"video"},{slug:"105",name:"Crime",categories:{series:84,documentary:86,cinema:64,movie:84},media_format:"video"},{slug:"128",name:"Western",categories:{movie:12,series:12,documentary:24},media_format:"video"},{slug:"127",name:"Thriller",categories:{series:70,documentary:28,cinema:80,movie:70},media_format:"video"},{slug:"102",name:"Animation",categories:{series:50,cinema:50,kids:90,documentary:48,movie:50},media_format:"video"},{slug:"119",name:"Mystery",categories:{movie:76,cinema:70,kids:26,documentary:38,series:76},media_format:"video"},{slug:"227",name:"Science",categories:{series:22,kids:46,documentary:74},media_format:"video"},{slug:"108",name:"Nature",categories:{kids:48,documentary:76,series:28},media_format:"video"},{slug:"116",name:"War",categories:{movie:14,documentary:68,series:14,cinema:66},media_format:"video"},{slug:"123",name:"Sci-Fi",categories:{series:72,movie:72,cinema:68,kids:70,documentary:32},media_format:"video"},{slug:"106",name:"Documentary",categories:{kids:50},media_format:"video"},{slug:"232",name:"Stand-up",categories:{movie:18,series:18},media_format:"video"},{slug:"126",name:"Talk Show",categories:{kids:34,series:16},media_format:"video"},{slug:"111",name:"Fantasy",categories:{kids:78,cinema:74,documentary:42,movie:38,series:38},media_format:"video"},{slug:"114",name:"History",categories:{movie:35,kids:44,cinema:10,series:80,documentary:90},media_format:"video"},{slug:"109",name:"Adventure",categories:{kids:88,cinema:86,documentary:82,series:88,movie:88},media_format:"video"},{slug:"101",name:"Action",categories:{documentary:50,kids:86,series:90,cinema:90,movie:90},media_format:"video"},{slug:"124",name:"Horror",categories:{cinema:76,documentary:40,series:78,movie:80},media_format:"video"},{slug:"115",name:"Comedy",categories:{cinema:84,documentary:46,series:86,kids:82,movie:86},media_format:"video"},{slug:"104",name:"Biography",categories:{series:46,documentary:88,cinema:10,movie:46},media_format:"video"},{slug:"118",name:"Music",categories:{kids:72,cinema:9,documentary:78,movie:32,series:32},media_format:"video"},{slug:"125",name:"Sport",categories:{cinema:7,kids:68,series:20,documentary:70,movie:20},media_format:"video"},{slug:"122",name:"Romance",categories:{documentary:34,cinema:78,movie:74,series:74},media_format:"video"},{slug:"103",name:"Kids",categories:{kids:76},media_format:"video"},{slug:"222",name:"Lifestyle",categories:{documentary:80,kids:74,series:34},media_format:"video"},{slug:"117",name:"Musical",categories:{kids:30,movie:78,cinema:8,series:30},media_format:"video"},{slug:"129",name:"Anime",categories:{cinema:5,movie:48,kids:84,series:48},media_format:"video"},{slug:"110",name:"Family",categories:{series:40,cinema:40,movie:40},media_format:"video"}];var hl=I('<div class="genre svelte-1ebula3"> </div>'),gl=(e,t)=>P(t,!0),ml=I('<button class="genre expand svelte-1ebula3"> </button>'),pl=I("<!> <!>",1);function yl(e,t){ae(t,!0);let n=U(!1);const i=K(()=>c(n)?t.genres:[t.genres[0]]);var r=pl(),a=ne(r);at(a,17,()=>c(i),bt,(l,u)=>{var d=Be();const f=K(()=>{var g;return(g=_l.find(v=>v.slug===c(u)))==null?void 0:g.name});var _=ne(d);{var m=g=>{var v=hl(),p=b(v);L(()=>G(p,ke(c(f)))),k(g,v)};q(_,g=>{c(f)&&g(m)})}k(l,d)});var o=E(a,2);{var s=l=>{var u=ml();u.__click=[gl,n];var d=b(u);L(()=>G(d,`+${t.genres.length-1}`)),k(l,u)};q(o,l=>{!c(n)&&t.genres.length>1&&l(s)})}k(e,r),oe()}fe(["click"]);function wl(e){let t=[];for(const n of e){let i=n;const r=t.find(s=>s.name===i.name),a=r==null?void 0:r.extra_info.category,o=i.extra_info.category;(a==="RENT"&&o==="BUY"||a==="BUY"&&o==="RENT")&&(t=t.filter(s=>s.name!==i.name),i={...i,extra_info:{...i.extra_info,category:"TVOD"}}),t.push(i)}return t}function xe(e,t=1){e.role="heading",e.ariaLevel=t.toString()}var kl=Ne('<svg width="6" height="12" viewBox="0 0 6 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 11L5 6L0 1" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function bl(e){var t=kl();k(e,t)}function Bt(e){return e?e.replace("/src/img",""):null}var xl=(e,t,n)=>t(n()),Sl=I('<div class="arrow svelte-g63n1y"><!></div>'),El=I('<a target="_blank" class="playlink svelte-g63n1y" rel="sponsored"><img alt="" height="32" width="32" class="svelte-g63n1y"> <div><span class="name svelte-g63n1y"> </span> <div class="category svelte-g63n1y"> </div></div> <!></a>'),Tl=I('<div class="playlink empty svelte-g63n1y"> </div>'),Il=I('<div class="heading svelte-g63n1y"> </div> <div class="playlinks svelte-g63n1y"><!> <!></div>',1);function Al(e,t){ae(t,!0);const n=N(t,"list",3,!1),i=oo("scope")==="modal",r=K(()=>t.playlinks.filter(v=>!!v.logo_url)),a=K(()=>wl(c(r))),o={SVOD:ke("Stream"),BUY:ke("Buy"),RENT:ke("Rent"),TVOD:ke("Rent Or Buy")};function s(v){be(i?ye.TitleModalPlaylinkClick:ye.TitlePopoverPlaylinkClick,t.title,{playlink:v})}var l=Il(),u=ne(l),d=b(u);L(()=>G(d,ke("Where To Stream Online"))),Jt(u,(v,p)=>xe==null?void 0:xe(v,p),()=>3);var f=E(u,2),_=b(f);at(_,17,()=>c(a),bt,(v,p)=>{let y=()=>c(p).name,w=()=>c(p).url,S=()=>c(p).logo_url,j=()=>c(p).highlighted,x=()=>c(p).cta_text,T=()=>c(p).extra_info.category;var H=El();H.__click=[xl,s,y];var M=b(H);L(()=>ue(M,"src",Bt(S())));var C=E(M,2),D=b(C),A=b(D),F=E(D,2),O=b(F);L(()=>G(O,x()||o[T()]||ke("Stream")));var z=E(C,2);{var B=V=>{var W=Sl(),J=b(W);bl(J),k(V,W)};q(z,V=>{n()&&V(B)})}L(()=>{ue(H,"href",w()),ue(H,"data-playlink",y()),se(H,"highlighted",j()&&x()),G(A,y())}),k(v,H)});var m=E(_,2);{var g=v=>{var p=Tl(),y=b(p);L(()=>G(y,ke("Title Unavailable"))),k(v,p)};q(m,v=>{t.playlinks.length||v(g)})}L(()=>se(f,"list",n())),k(e,l),oe()}fe(["click"]);var Cl=(e,t)=>P(t,!0),Pl=I('<button class="show-more svelte-1u3je71">Show more</button>'),jl=I('<div class="paragraph svelte-1u3je71" role="paragraph"> </div>'),Ml=I('<div><span class="paragraph svelte-1u3je71" role="paragraph"> <!> <!></span> <!></div>');function Nl(e,t){ae(t,!0);const n=N(t,"blurb",3,""),i=N(t,"limit",3,200);let r=U(!1);const a=K(()=>t.text.slice(0,i()));var o=Ml(),s=b(o),l=b(s),u=E(l);{var d=v=>{var p=Fe("...");k(v,p)};q(u,v=>{!c(r)&&t.text.length>i()&&v(d)})}var f=E(u,2);{var _=v=>{var p=Pl();p.__click=[Cl,r],k(v,p)};q(f,v=>{!c(r)&&(t.text.length>i()||n())&&v(_)})}var m=E(s,2);{var g=v=>{var p=jl(),y=b(p);L(()=>G(y,n())),k(v,p)};q(m,v=>{c(r)&&v(g)})}L(()=>G(l,c(r)?t.text:c(a))),k(e,o),oe()}fe(["click"]);var Ll=Ne('<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 0.351929L9.163 4.72803L14 5.43408L10.5 8.8385L11.326 13.648L7 11.3761L2.674 13.648L3.5 8.8385L0 5.43408L4.837 4.72803L7 0.351929Z" fill="#F6C045"></path></svg>');function Hr(e){var t=Ll();k(e,t)}var Ol=I('<div class="top svelte-1026zg0"><img class="poster svelte-1026zg0"></div>'),Dl=I("<div> </div>"),Rl=I('<img alt="" class="svelte-1026zg0">'),ql=I('<div class="content svelte-1026zg0" data-playpilot-link-injections-title=""><div class="header svelte-1026zg0"><!> <div class="heading svelte-1026zg0" id="title"> </div> <div class="info svelte-1026zg0"><div class="imdb svelte-1026zg0"><!> </div> <!> <div> </div> <div class="capitalize svelte-1026zg0"> </div> <!></div></div> <div class="main"><!> <!></div></div> <div class="background svelte-1026zg0"><!></div>',1);function Fr(e,t){ae(t,!0);const n=N(t,"small",3,!1),i=N(t,"compact",3,!1);let r=U(!1),a=U(!1),o=U(!1);var s=ql(),l=ne(s),u=b(l),d=b(u);{var f=B=>{var V=Ol(),W=b(V);L(()=>ue(W,"src",Bt(t.title.standing_poster))),L(()=>{ue(W,"alt",`Movie poster for '${t.title.title??""}'`),se(W,"loaded",c(r))}),ce("load",W,()=>P(r,!0)),k(B,V)};q(d,B=>{i()||B(f)})}var _=E(d,2),m=b(_);Jt(_,(B,V)=>xe==null?void 0:xe(B,V),()=>2);var g=E(_,2),v=b(g),p=b(v);Hr(p);var y=E(p),w=E(v,2);yl(w,{get genres(){return t.title.genres}});var S=E(w,2),j=b(S),x=E(S,2),T=b(x);L(()=>G(T,ke(`Type: ${t.title.type}`)));var H=E(x,2);{var M=B=>{var V=Dl(),W=b(V);L(()=>G(W,`${t.title.length??""} ${ke("Minutes")??""}`)),k(B,V)};q(H,B=>{!n()&&t.title.length&&B(M)})}var C=E(u,2),D=b(C);Al(D,{get playlinks(){return t.title.providers},get title(){return t.title},list:!0});var A=E(D,2);{var F=B=>{Nl(B,{get text(){return t.title.description},get blurb(){return t.title.blurb}})};q(A,B=>{n()||B(F)})}var O=E(l,2),z=b(O);Sr(z,()=>c(o),B=>{var V=Rl();L(()=>ue(V,"src",Bt(c(o)?t.title.standing_poster:t.title.medium_poster))),L(()=>{se(V,"loaded",c(a)),se(V,"blur",c(o))}),ce("load",V,()=>P(a,!0)),ce("error",V,()=>P(o,!0)),k(B,V)}),L(()=>{se(l,"small",n()),se(l,"compact",i()),se(_,"truncate",n()),G(m,t.title.title),G(y,` ${t.title.imdb_score??""}`),G(j,t.title.year),se(O,"faded",i())}),k(e,s),oe()}function Hl(e,t){ae(t,!0),be(ye.TitleModalView,t.title);let n=!1;function i(){n||(be(ye.TitleModalScroll,t.title),n=!0)}qr(e,{get onclose(){return t.onclose},onscroll:i,children:(r,a)=>{Fr(r,{get title(){return t.title}})},$$slots:{default:!0}}),oe()}var Fl=I('<div class="popover svelte-tb2xdq" tabindex="-1" aria-hidden="true"><div class="dialog svelte-tb2xdq" data-view-transition-old=""><!></div></div>');function Bl(e,t){ae(t,!0);let n=N(t,"maxHeight",15);yr("scope","popover");let i=U(null),r=U(!1);Je(async()=>{await Fn(),a(),await Fn(),o()});function a(){if(!c(i))return;const{top:f,right:_,bottom:m,height:g}=c(i).getBoundingClientRect(),v=s();P(r,X(f-v<0&&window.innerHeight-m>f+g));const p=window.innerWidth-_-v;_+v>window.innerWidth&&(c(i).style.left=`${p}px`)}function o(){if(!c(i))return;const{top:f,height:_}=c(i).getBoundingClientRect(),m=s(),g=c(r)?window.innerHeight-f-m:f+_-m;n(Math.min(g,window.innerHeight*.8))}function s(){return parseFloat(getComputedStyle(document.documentElement).fontSize)}var l=Fl(),u=b(l),d=b(u);Ct(d,()=>t.children),Qt(l,f=>P(i,f),()=>c(i)),L(()=>{se(l,"flip",c(r)),bn(l,"--max-height",n()?n()+"px":null)}),je(7,u,()=>Sn,()=>({duration:ui.current?0:100,y:10})),k(e,l),oe()}var Vl=I('<div class="title-popover svelte-d86q0q" data-playpilot-title-popover="" role="region" aria-labelledby="title"><!></div>');function Ul(e,t){ae(t,!0);let n=U(0),i=U(null);be(ye.TitlePopoverView,t.title),Je(r);function r(){const s=t.event.target;if(!(s!=null&&s.getClientRects))return;const l=Array.from(s.getClientRects()),d=l.map(_=>_.x).map(_=>Math.abs(_-t.event.clientX)),f=l[d.indexOf(Math.min(...d))];c(i).style.top=f.top+window.scrollY+"px",c(i).style.left=f.left+window.scrollX+"px",c(i).style.height=f.height+"px"}var a=Vl(),o=b(a);Bl(o,{get maxHeight(){return c(n)},set maxHeight(s){P(n,X(s))},children:(s,l)=>{var u=K(()=>!!c(n)&&c(n)<250);Fr(s,{get title(){return t.title},small:!0,get compact(){return c(u)}})},$$slots:{default:!0}}),Qt(a,s=>P(i,s),()=>c(i)),k(e,a),oe()}var zl=e=>e.stopPropagation(),Wl=(e,t,n,i)=>t(e,c(n).title_details,c(i)),Kl=I(' <span class="svelte-pfvkex"><button class="svelte-pfvkex"> </button></span>',1),Yl=(e,t,n,i)=>t(c(n).title_details,i()),Zl=I('<!> <a target="_blank"> </a>',1),Gl=I(" <!>.",1),Xl=I("<!> <br>",1),Jl=I(" <br>",1),Ql=I('<span class="svelte-pfvkex"><!></span>'),$l=I('<p class="svelte-pfvkex"></p>');function es(e,t){ae(t,!0);const n=N(t,"onclickmodal",3,()=>null);function i(l,u){be(ye.AfterArticlePlaylinkClick,l,{playlink:u})}function r(l,u,d){be(ye.AfterArticleModalButtonClick,u),n()(l,d)}var a=Be(),o=ne(a);{var s=l=>{var u=$l();at(u,21,()=>t.linkInjections,bt,(d,f)=>{var _=Ql();const m=K(()=>{const{key:w,title:S,title_details:j,after_article_style:x}=c(f);return{key:w,title:S,title_details:j,after_article_style:x}}),g=K(()=>{var w;return((w=c(m).title_details)==null?void 0:w.providers)||[]});var v=b(_);{var p=w=>{var S=Xl(),j=ne(S);{var x=H=>{var M=Kl(),C=ne(M);L(()=>G(C,`"${c(m).title??""}" ${ke("Is Available To Stream")??""} `));var D=E(C);D.__click=[zl];var A=b(D);A.__click=[Wl,r,m,f];var F=b(A);L(()=>G(F,ke("View Streaming Options"))),k(H,M)},T=H=>{var M=Gl(),C=ne(M);L(()=>G(C,`"${c(m).title??""}" ${ke("Is Available To Stream On")??""} `));var D=E(C);at(D,17,()=>c(g),bt,(A,F,O)=>{let z=()=>c(F).name,B=()=>c(F).url;var V=Zl(),W=ne(V);{var J=de=>{var Ae=Fe();L(()=>G(Ae,O===c(g).length-1?`, ${ke("And")}`:",")),k(de,Ae)};q(W,de=>{O&&de(J)})}var ee=E(W,2);ee.__click=[Yl,i,m,z];var re=b(ee);L(()=>{ue(ee,"href",B()),G(re,z())}),k(A,V)}),k(H,M)};q(j,H=>{c(m).after_article_style==="modal_button"?H(x):H(T,!1)})}k(w,S)},y=w=>{var S=Jl(),j=ne(S);L(()=>G(j,`"${c(m).title??""}" ${ke("Title Unavailable Suffix")??""} `)),k(w,S)};q(v,w=>{c(g).length?w(p):w(y,!1)})}L(()=>ue(_,"data-playpilot-injection-key",c(m).key)),k(d,_)}),k(l,u)};q(o,l=>{t.linkInjections.length&&l(s)})}k(e,a),oe()}fe(["click"]);function ts(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function di(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||""}function Mi(e,t,n=[]){var a,o;const i=document.createTreeWalker(t);let r;for(;(r=i.nextNode())&&!((a=r.nodeValue)!=null&&a.includes(e)&&!n.includes(((o=r.parentNode)==null?void 0:o.nodeName)||"")););return r}function Ni(e){const t=e.parentNode;return t?t.nodeName==="A"||!!t.closest("a"):!1}function ns(e,t,n,i){const r=ts(t),a=di(t),o=e.slice(0,i),s=e.slice(i),l=/[-/\\^$*+?.()|[\]{}]/g,u=new RegExp(`${a.replace(l,"\\$&")}|${r.replace(l,"\\$&")}`),d=s.replace(u,n);return o+d}function is(e,t,n,i){return e.substring(0,n)+t+e.substring(i)}function Te(e){return di(e).toLowerCase().replace(/\s+/g,"")}function Br(e,t,n){const r=e.indexOf(t),a=Math.floor((n-t.length)/2);let o=Math.max(0,r-a),s=o+n;s>e.length&&(s=e.length,o=Math.max(0,s-n));let l=e.slice(o,s).trim();return o>0&&(l="…"+l),s<e.length&&(l+="…"),l}function rs(e,t,n){const i=e.nodeType===Node.TEXT_NODE&&e.parentNode?e.parentElement:e;if(!i||!e.textContent)return{before:"",after:""};const r=i.innerText.indexOf(e.textContent),a=Li(i.innerText.slice(0,t+r)),o=i.innerText.slice(n+r),s=Li(Oi(a,2)),l=Oi(o,2);return{before:s,after:l}}function Li(e){return e.split("").reverse().join("")}function Oi(e,t=1){const n=e.match(/[^\s]+/g);return n?n.slice(0,t).join(" ").replace(/[.,!?;:]+$/u,""):""}function as(e,t){let n=0,i=0;for(;(i=e.indexOf(t,i))!==-1;)n++,i+=t.length;return n}function os(e,t,n){const i=[];let r=0;for(;r<=e.length;){const a=t?e.indexOf(t,r):r;if(a===-1&&t)break;const o=t?a+t.length:a,s=n?e.indexOf(n,o):e.length;if(n&&s===-1)break;const l=e.slice(o,s);i.push({match:l,index:o}),r=n?s+n.length:e.length+1}return i}function ls(e,t,n,i){const a=os(e,n,i).filter(({match:s})=>di(s).includes(t));return a.length?a.reduce((s,l)=>!s||l.match.length<s.match.length?l:s):null}function ss(e){var t,n;return{leadingSpaces:((t=e.match(/^\s*/))==null?void 0:t[0].length)||0,trailingSpaces:((n=e.match(/\s*$/))==null?void 0:n[0].length)||0}}function Vr(e){return e.ctrlKey||e.metaKey||e.button!==0}function cs(e,t){if(!document.startViewTransition||!t){e();return}document.startViewTransition(()=>{const n=document.querySelector("[data-view-transition-old]");if(!n)return;const i=window.getComputedStyle(n).getPropertyValue("view-transition-name");n.style.viewTransitionName="none",e();const r=document.querySelector("[data-view-transition-new]");r&&(r.style.viewTransitionName=i)})}const xt="data-playpilot-injection-key",dn=`[${xt}]`;let fn=null,ut=null,Nt=null,Lt=null;function Ur(e,t=""){const n=[],i=[e];for(;i.length>0;){const r=i.pop();if(n.includes(r)||t&&r.matches(t)||/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|H1)$/.test(r.tagName)||r.offsetWidth<=1)continue;const a=Array.from(r.childNodes).some(l=>{var u;return l.nodeType===Node.TEXT_NODE&&((u=l.nodeValue)==null?void 0:u.trim())!==""});if(a&&r.tagName==="LI"){const l=r.closest("ul, ol");l&&!n.includes(l)&&n.push(l);continue}const o=r.tagName==="P"&&!!r.textContent;if(a||o){n.push(r);continue}const s=Array.from(r.children);for(let l=s.length-1;l>=0;l--)i.push(s[l])}return n}function Vt(){var t;const e=(t=window.PlayPilotLinkInjections)==null?void 0:t.selector;if(e){const n=e.replace(/(:)/g,"\\$1"),i=document.querySelector(n);if(i)return i}return document.querySelector("article")||document.querySelector("main")||document.body}function us(e,t={aiInjections:[],manualInjections:[]}){fi();const n=ps(t);if(!n)return[];const i=Te(e.map(l=>l.innerText).join(" ")),r=ys(n),a=r.filter(l=>i.includes(Te(l.sentence))),o={};for(const l of a){const u=e.findIndex(S=>Te(S.innerText).includes(Te(l.sentence))),d=e[u];if(!d)continue;const f=Mi(l.title,d,["A"]);if(!(f!=null&&f.nodeValue)||Ni(f)){const S=Mi(l.title,d);if(S&&Ni(S)){o[l.key]="Given text is already inside of a link.";continue}}const{injectionElement:_,linkElement:m}=ds(l),{phrase_before:g,phrase_after:v}=l;let p=-1,y=!1;if(as(Te(d.innerText),Te(l.title))===1&&(p=d.innerHTML.indexOf(l.title)),p===-1&&(g||v)){const S=[g,l.title,v].filter(Boolean).join(" ");if(p=d.innerHTML.indexOf(S),p===-1){const j=ls(d.innerHTML,l.title,g||"",v||"");if(j){const{leadingSpaces:x,trailingSpaces:T}=ss(j.match);m.innerHTML=j.match.trim();const H=j.index+x,M=j.index+j.match.length-T;d.innerHTML=is(d.innerHTML,_.outerHTML,H,M),p=j.index,y=!0}}}if(p===-1&&(f!=null&&f.nodeValue)){const S=d.innerHTML.indexOf(f.nodeValue),j=d.innerHTML.indexOf(l.sentence);p=Math.max(S,j,0)}p!==-1&&(y||(d.innerHTML=ns(d.innerHTML,l.title,_.outerHTML,p)))}vs(r),fs();const s=ws(n);return s.length&&hs(e,s),n.filter(l=>l.title_details).map((l,u)=>{const d=l.duplicate??(!l.manual&&ks(l,u,n)),f=document.querySelector(`[${xt}="${l.key}"]`),_=En(l)&&!l.inactive&&!l.after_article&&!f,m=!!e.find(v=>Te(v.innerText).includes(Te(l.sentence))),g=_?o[l.key]||(m?"The link failed to inject for unknown reasons.":"Given sentence was not found in the article."):"";return{...l,inactive:l.inactive??!1,duplicate:d,failed:_,failed_message:g}})}function ds(e){const t=document.createElement("span");t.dataset.playpilotInjectionKey=e.key;const n=document.createElement("a");return n.innerText=e.title,n.href=e.playpilot_url,n.target="_blank",n.rel="noopener nofollow noreferrer",t.insertAdjacentElement("beforeend",n),{injectionElement:t,linkElement:n}}function fs(){const e=Array.from(document.querySelectorAll(`${dn} a`)),t=["--playpilot-injection-text-color","--playpilot-injection-text-color-hover","--playpilot-injection-font-weight","--playpilot-injection-font-weight-headings","--playpilot-injection-text-decoration","--playpilot-injection-text-decoration-hover","--playpilot-injection-background-color","--playpilot-injection-background-color-hover"];e.forEach(n=>{t.forEach(i=>{getComputedStyle(n).getPropertyValue(i)&&(n.dataset.usedCssVariables=`${n.dataset.usedCssVariables||""} ${i}`)})})}function vs(e){window.addEventListener("click",n=>{if(Vr(n))return;const i=n.target;if(!(i!=null&&i.parentElement))return;const r=i.parentElement.getAttribute(xt);if(!r)return;const a=e.find(o=>r===o.key);a&&(n.preventDefault(),cs(()=>{vn(!1),zr(n,a)},!ui.current&&window.innerWidth>=600&&!window.matchMedia("(pointer: coarse)").matches))}),window.addEventListener("mousemove",n=>{if(!ut)return;const i=n.target;i.hasAttribute("data-playpilot-title-popover")||i.closest("[data-playpilot-title-popover]")||i.hasAttribute(xt)||i.closest(dn)||vn()}),Array.from(document.querySelectorAll(dn)).forEach(n=>{const i=n.dataset.playpilotInjectionKey,r=e.find(a=>i===a.key);r&&(n.addEventListener("mouseenter",a=>{ut||_s(a,r)}),n.addEventListener("mouseleave",()=>fn=null))})}function zr(e,t){Vr(e)||Lt||(e.preventDefault(),Lt=Xt(Hl,{target:Xr(),props:{title:t.title_details,onclose:Wr}}))}function Wr(e=!0){Lt&&(kn(Lt,{outro:e}),Lt=null)}function _s(e,t){if(window.matchMedia("(pointer: coarse)").matches)return;ut&&vn();const n=e.currentTarget;fn=n,setTimeout(()=>{fn===n&&(ut=Xt(Ul,{target:Xr(),props:{event:e,title:t.title_details}}))},100)}function vn(e=!0){ut&&(kn(ut,{outro:e}),fn=null,ut=null)}function hs(e,t){var o,s;if(Nt||!t.length)return;const n=document.createElement("div"),i=(o=window.PlayPilotLinkInjections)==null?void 0:o.after_article_selector,r=(i?document.querySelector(i):null)||e[e.length-1],a=((s=window.PlayPilotLinkInjections)==null?void 0:s.after_article_insert_position)||"afterend";n.dataset.playpilotAfterArticlePlaylinks="true",r.insertAdjacentElement(a,n),Nt=Xt(es,{target:n,props:{linkInjections:t,onclickmodal:(l,u)=>zr(l,u)}})}function gs(){var e;Nt&&(kn(Nt),(e=document.querySelector("[data-playpilot-after-article-playlinks]"))==null||e.remove(),Nt=null)}function fi(){document.querySelectorAll(dn).forEach(t=>ms(t.getAttribute(xt)||"")),gs(),Wr(!1),vn(!1)}function ms(e){var i;const t=document.querySelector(`[${xt}="${e}"]`);if(!t)return;const n=(i=t.querySelector("a"))==null?void 0:i.innerHTML;t.outerHTML=n||""}function ps({aiInjections:e,manualInjections:t}){return[...t.map(n=>({...n,manual:!0})),...e]}function Kr(e){return{aiInjections:e.filter(t=>!t.manual),manualInjections:e.filter(t=>t.manual)}}function Yr(e){return!e.inactive&&!e.removed&&!e.duplicate&&!!e.title_details&&En(e)}function En(e){return e.in_text||e.in_text===void 0?!0:!!e.after_article}function ys(e){return Zr(e).filter(t=>t.in_text!==!1&&Yr(t))}function ws(e){return Zr(e).filter(t=>t.after_article===!0&&Yr(t))}function Zr(e){return e.filter(t=>t.removed||t.inactive?!1:t.manual&&!t.removed&&!t.inactive?!0:!e.some(n=>n.manual&&(n.removed||n.inactive)&&Gr(n,t)))}function ks(e,t,n){return n.some((i,r)=>t!==r&&i.manual&&Gr(i,e))}function Gr(e,t){return e.title===t.title&&Te(e.sentence)===Te(t.sentence)}function Xr(){return document.querySelector("[data-playpilot-link-injections]")||document.body}function bs(){const e=Vt();return{content_heading:xs(e),content_modified_time:Ss(e),content_published_time:Es(e)}}function xs(e){const t=e.querySelector("h1")||document.querySelector("h1");return(t==null?void 0:t.innerText.trim())||null}function Ss(e){const t=document.querySelector('meta[property*="modified_time"]')||e.querySelector('[itemprop="dateModified"]')||document.querySelector('[itemprop="dateModified"]')||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?Jr(n):null}function Es(e){const t=document.querySelector('meta[property*="published_time"]')||e.querySelector('[itemprop="datePublished"]')||document.querySelector('[itemprop="datePublished"]')||e.querySelector("time")||document.querySelector("time")||e.querySelector("[datetime]")||document.querySelector("[datetime]")||null,n=(t==null?void 0:t.getAttribute("content"))||(t==null?void 0:t.getAttribute("datetime"))||(t==null?void 0:t.innerText);return n?Jr(n):null}function Jr(e){try{return new Date(e).toISOString()}catch{return null}}let On=null;async function Tn(e,{url:t=ai(),hash:n=nl(e),params:i={}}={}){const r=new Headers({"Content-Type":"application/json"}),a=In(),o=Lr()?await Nr():!1,s=Dr(),l=bs();if(!a)throw new Error("No token was provided");const u=await fetch(xn+`/external-pages/?api-token=${a}&include_title_details=true${o?"&editorial_mode_enabled=true":""}&language=${s}`,{headers:r,method:"POST",body:JSON.stringify({hash:n,url:t,metadata:l,page_text:e,...i})});if(!u.ok)throw u;return await u.json()}async function Di(e,{requireCompletedResult:t=!1,pollInterval:n=3e3,maxTries:i=600,onpoll:r=()=>null}={}){let a=0;On&&clearTimeout(On);const o=async(s,l)=>{let u;try{if(u=await Tn(e),t&&u.ai_enabled&&u.ai_running)throw new Error;u.manual_injections=Ri(u.manual_injections||[]),u.ai_injections=Ri(u.ai_injections||[]),s(u);return}catch{if(a++,a>=i){i>1&&console.error("Max poll limit exceeded. Please return later."),s();return}u&&r(u),On=setTimeout(()=>o(s),n)}};return new Promise(o)}async function Ts(e,t){var o;const n=(o=window.PlayPilotLinkInjections)==null?void 0:o.selector,r=e.filter(s=>s.manual).map(s=>({sid:s.sid,title:s.title,sentence:s.sentence,phrase_before:s.phrase_before,phrase_after:s.phrase_after,playpilot_url:s.playpilot_url,after_article:!!s.after_article,after_article_style:s.after_article_style||null,in_text:s.in_text??!0,inactive:!!s.inactive,removed:!!s.removed}));if(!await Tn(t,{params:{private_token:li(),manual_injections:r,content_text_selector:n}}))throw new Error("saveLinkInjections response was faulty");return e}async function Is(){const e=new Headers({"Content-Type":"application/json"}),t=In();if(!t)throw new Error("No token was provided");const n=await fetch(xn+`/domains/config?api-token=${t}`,{headers:e});if(!n.ok)throw n;try{return await n.json()||null}catch{return null}}function Ri(e){return e.map(t=>({...t,key:Qr(t.sid)}))}function Qr(e){return e+"-"+Or()}function In(){var e;return(e=window.PlayPilotLinkInjections)==null?void 0:e.token}function As(){const e=navigator.userAgent.toLowerCase();return/bot|crawl|spider|google|baidu|bing|msn|teoma|slurp|yandex|facebookexternalhit|facebot/i.test(e)}var Cs=Ne('<svg width="8" height="4" viewBox="0 0 8 4" fill="none" class="svelte-by11ix"><path d="M1 0.5L4 3.5L7 0.5" stroke="currentColor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ps(e,t){const n=N(t,"expanded",3,!1);var i=Cs();L(()=>se(i,"expanded",n())),k(e,i)}var js=Ne('<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="17" r="1" fill="var(--playpilot-warning)"></circle><path d="M12 10L12 14" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M3.44722 18.1056L10.2111 4.57771C10.9482 3.10361 13.0518 3.10362 13.7889 4.57771L20.5528 18.1056C21.2177 19.4354 20.2507 21 18.7639 21H5.23607C3.7493 21 2.78231 19.4354 3.44722 18.1056Z" stroke="var(--playpilot-warning)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Ms(e){var t=js();k(e,t)}function Ns(e,t,n){t(!t()),n()(t())}var Ls=I('<button class="switch svelte-91s87b"><div class="label svelte-91s87b"><!></div> <div class="track svelte-91s87b"><div class="knob svelte-91s87b"></div></div></button>');function Wn(e,t){ae(t,!0);let n=N(t,"active",15),i=N(t,"fullwidth",3,!1),r=N(t,"label",3,""),a=N(t,"onclick",3,()=>null);var o=Ls();o.__click=[Ns,n,a];var s=b(o),l=b(s);Ct(l,()=>t.children),L(()=>{ue(o,"aria-label",`Toggle ${r()??""} ${(n()?"off":"on")??""}`),se(o,"active",n()),se(o,"fullwidth",i())}),k(e,o),oe()}fe(["click"]);var Os=I('<input type="text" autocomplete="off" class="svelte-1vrer3i">');function vi(e,t){let n=N(t,"value",15),i=N(t,"label",3,""),r=N(t,"name",3,""),a=N(t,"readonly",3,!1),o=N(t,"oninput",3,()=>null);var s=Os();s.__input=function(...l){var u;(u=o())==null||u.apply(this,l)},L(()=>{ue(s,"name",r()),ue(s,"aria-label",i()),ue(s,"placeholder",i()),s.readOnly=a()}),qo(s,n),k(e,s)}fe(["input"]);var Ds=Ne('<path d="M13.5833 13.6667L4.41667 13.6667M5.5 1.5H12.5C13.9001 1.5 14.6002 1.5 15.135 1.77248C15.6054 2.01217 15.9878 2.39462 16.2275 2.86502C16.5 3.3998 16.5 4.09987 16.5 5.5V12.5C16.5 13.9001 16.5 14.6002 16.2275 15.135C15.9878 15.6054 15.6054 15.9878 15.135 16.2275C14.6002 16.5 13.9001 16.5 12.5 16.5H5.5C4.09987 16.5 3.3998 16.5 2.86502 16.2275C2.39462 15.9878 2.01217 15.6054 1.77248 15.135C1.5 14.6002 1.5 13.9001 1.5 12.5V5.5C1.5 4.09987 1.5 3.3998 1.77248 2.86502C2.01217 2.39462 2.39462 2.01217 2.86502 1.77248C3.3998 1.5 4.09987 1.5 5.5 1.5Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),Rs=Ne('<path d="M13.5833 8.58342H4.41667M5.5 1.50009H12.5C13.9001 1.50009 14.6002 1.50009 15.135 1.77258C15.6054 2.01226 15.9878 2.39471 16.2275 2.86512C16.5 3.39989 16.5 4.09996 16.5 5.50009V12.5001C16.5 13.9002 16.5 14.6003 16.2275 15.1351C15.9878 15.6055 15.6054 15.9879 15.135 16.2276C14.6002 16.5001 13.9001 16.5001 12.5 16.5001H5.5C4.09987 16.5001 3.3998 16.5001 2.86502 16.2276C2.39462 15.9879 2.01217 15.6055 1.77248 15.1351C1.5 14.6003 1.5 13.9002 1.5 12.5001V5.50009C1.5 4.09996 1.5 3.39989 1.77248 2.86512C2.01217 2.39471 2.39462 2.01226 2.86502 1.77258C3.3998 1.50009 4.09987 1.50009 5.5 1.50009Z" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path>'),qs=Ne('<svg width="18" height="18" viewBox="0 0 18 18" fill="none"><!></svg>');function qi(e,t){const n=N(t,"align",3,"bottom");var i=qs(),r=b(i);{var a=s=>{var l=Ds();k(s,l)},o=s=>{var l=Be(),u=ne(l);{var d=f=>{var _=Rs();k(f,_)};q(u,f=>{n()==="center"&&f(d)},!0)}k(s,l)};q(r,s=>{n()==="bottom"?s(a):s(o,!1)})}k(e,i)}var Hs=I("<div><!></div>");function _t(e,t){ae(t,!0);const n=N(t,"type",3,"error"),i=N(t,"fixed",3,!1);var r=Hs(),a=b(r);Ct(a,()=>t.children),L(()=>{Mo(r,`alert ${n()??""} svelte-df5n87`),se(r,"fixed",i())}),k(e,r),oe()}var Fs=I("<!> In-text Playlink",1),Bs=I("<!> Bottom Playlink",1),Vs=I('<div class="alert svelte-1shw34x"><!></div>'),Us=(e,t)=>t().after_article_style="playlinks",zs=(e,t)=>t().after_article_style="modal_button",Ws=I('<div><div class="label svelte-1shw34x">Bottom playlinks style</div> <div class="group svelte-1shw34x" role="listbox" tabindex="0" aria-label="Playlink type"><button role="option" id="playlinks-in-text" class="svelte-1shw34x">Playlinks sentence</button> <button role="option" id="playlinks-after-article" class="svelte-1shw34x">Modal button</button> <div class="active-marker svelte-1shw34x"></div></div></div>'),Ks=I('<div class="switches svelte-1shw34x"><!> <!></div> <!> <!>',1);function Ys(e,t){ae(t,!0);const n=N(t,"linkInjection",7),i=K(()=>n().after_article_style==="modal_button");var r=Ks(),a=ne(r),o=b(a),s=K(()=>n().in_text??!0);Wn(o,{fullwidth:!0,get active(){return c(s)},onclick:g=>{n().in_text=g,n().manual=!0},label:"In-text Playlink",children:(g,v)=>{var p=Fs(),y=ne(p);qi(y,{align:"center"}),k(g,p)},$$slots:{default:!0}});var l=E(o,2),u=K(()=>n().after_article??!1);Wn(l,{fullwidth:!0,get active(){return c(u)},onclick:g=>{n().after_article=g,n().manual=!0},label:"Bottom Playlink",children:(g,v)=>{var p=Bs(),y=ne(p);qi(y,{align:"bottom"}),k(g,p)},$$slots:{default:!0}});var d=E(a,2);{var f=g=>{var v=Vs(),p=b(v);_t(p,{type:"warning",children:(y,w)=>{var S=Fe("At least one layout option must be selected for the playlink to be visible.");k(y,S)},$$slots:{default:!0}}),je(3,v,()=>Ft,()=>({duration:200})),k(g,v)};q(d,g=>{En(n())||g(f)})}var _=E(d,2);{var m=g=>{var v=Ws(),p=E(b(v),2),y=b(p);y.__click=[Us,n];var w=E(y,2);w.__click=[zs,n];var S=E(w,2);L(()=>{ue(p,"aria-activedescendant",`playlinks-${(c(i)?"after-article":"in-text")??""}`),ue(y,"aria-selected",!c(i)||null),se(y,"active",!c(i)),ue(w,"aria-selected",c(i)||null),se(w,"active",c(i)),se(S,"right",c(i))}),je(3,v,()=>Ft,()=>({duration:100})),k(g,v)};q(_,g=>{n().after_article&&g(m)})}k(e,r),oe()}fe(["click"]);var Zs=Ne('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.99984 10.8333C10.4601 10.8333 10.8332 10.4602 10.8332 10C10.8332 9.53977 10.4601 9.16668 9.99984 9.16668C9.5396 9.16668 9.1665 9.53977 9.1665 10C9.1665 10.4602 9.5396 10.8333 9.99984 10.8333Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 5.00001C10.4601 5.00001 10.8332 4.62691 10.8332 4.16668C10.8332 3.70644 10.4601 3.33334 9.99984 3.33334C9.5396 3.33334 9.1665 3.70644 9.1665 4.16668C9.1665 4.62691 9.5396 5.00001 9.99984 5.00001Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.99984 16.6667C10.4601 16.6667 10.8332 16.2936 10.8332 15.8333C10.8332 15.3731 10.4601 15 9.99984 15C9.5396 15 9.1665 15.3731 9.1665 15.8333C9.1665 16.2936 9.5396 16.6667 9.99984 16.6667Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function Gs(e){var t=Zs();k(e,t)}var Xs=(e,t)=>P(t,!c(t)),Js=I('<div class="content svelte-zpsd2z"><!></div>'),Qs=I('<div class="context-menu svelte-zpsd2z"><button class="svelte-zpsd2z"><!></button> <!></div>');function $s(e,t){ae(t,!0);let n=U(!1),i=U(null);function r(d){var _;const f=d.target;f===c(i)||(_=c(i))!=null&&_.contains(f)||P(n,!1)}var a=Qs();ce("click",pe,r);var o=b(a);o.__click=[Xs,n];var s=b(o);Gs(s),Qt(o,d=>P(i,d),()=>c(i));var l=E(o,2);{var u=d=>{var f=Js(),_=b(f);Ct(_,()=>t.children),je(1,f,()=>Sn,()=>({duration:150,y:5})),k(d,f)};q(l,d=>{c(n)&&d(u)})}L(()=>{ue(o,"aria-label",t.ariaLabel),ue(o,"aria-expanded",c(n))}),k(e,a),oe()}fe(["click"]);function ec(e,t,n,i){var r,a;c(t)&&(be(ye.ManualReport,n.linkInjection.title_details,{report_reason:c(t),sid:n.linkInjection.sid,title:n.linkInjection.title,sentence:n.linkInjection.sentence,failed:(r=n.linkInjection.failed)==null?void 0:r.toString(),failed_message:n.linkInjection.failed_message,manual:(a=n.linkInjection.manual)==null?void 0:a.toString()}),P(i,!0),setTimeout(n.onclose,3e3))}var tc=(e,t,n)=>P(t,X(n())),nc=I('<option class="svelte-o5qkco"> </option>'),ic=I('<div class="sent svelte-o5qkco">Report has been sent, thank you! Closing window...</div>'),rc=I('<button class="submit svelte-o5qkco">Send report</button>'),ac=I('<div class="form svelte-o5qkco"><div class="heading svelte-o5qkco">Report issue</div> <div class="info svelte-o5qkco"><div><strong class="svelte-o5qkco">Title</strong> </div> <div><strong class="svelte-o5qkco">Sentence</strong> </div></div> <label for="reason">What would you like to report?</label> <select id="reason" name="reason" class="svelte-o5qkco"><option class="svelte-o5qkco">Select an issue...</option><!></select> <div><!></div></div>');function oc(e,t){ae(t,!0);const n=[{value:"failed_injection",label:"The link failed to appear on the page."},{value:"layout_issue",label:"The link is breaking the layout or formatting of my page."},{value:"wrong_content",label:"The link points to the wrong movie or show."},{value:"inappropriate_title",label:"The link points to an inappropriate movie or show."},{value:"broken_link",label:"The link is broken or leads to an error page."},{value:"other",label:"My issue is not listed, but please have a look regardless."}];let i=U(""),r=U(!1);qr(e,{get onclose(){return t.onclose},children:(a,o)=>{var s=ac(),l=b(s);Jt(l,(x,T)=>xe==null?void 0:xe(x,T),()=>2);var u=E(l,2),d=b(u),f=E(b(d)),_=E(d,2),m=E(b(_));L(()=>G(m,`:
9
+ ${Br(t.linkInjection.sentence,t.linkInjection.title,100)??""}`));var g=E(u,4),v=b(g);v.value=((v.__value="")==null,"");var p=E(v);at(p,17,()=>n,bt,(x,T)=>{let H=()=>c(T).value,M=()=>c(T).label;var C=nc(),D={};C.__click=[tc,i,H];var A=b(C);L(()=>{D!==(D=H())&&(C.value=(C.__value=H())==null?"":H()),G(A,M())}),k(x,C)});var y=E(g,2),w=b(y);{var S=x=>{var T=ic();je(1,T,()=>Ht,()=>({duration:200})),k(x,T)},j=x=>{var T=rc();T.__click=[ec,i,t,r],L(()=>T.disabled=!c(i)),k(x,T)};q(w,x=>{c(r)?x(S):x(j,!1)})}L(()=>G(f,`: ${t.linkInjection.title??""}`)),Fo(g,()=>c(i),x=>P(i,x)),k(a,s)},$$slots:{default:!0}}),oe()}fe(["click"]);function lc(e,t,n){requestAnimationFrame(()=>t());const i=e.target;if(["BUTTON","INPUT"].includes(i.nodeName)||i.closest("button")||i.closest("input"))return;const r=n()[0];r&&r.scrollIntoView({behavior:"smooth"})}function sc(e,t){const n=Xt(oc,{target:document.body,props:{linkInjection:t(),onclose:()=>kn(n)}})}var cc=(e,t)=>P(t,!c(t)),uc=I('<button class="expand-sentence svelte-lo6h85"> </button>'),dc=I('<button class="context-menu-action svelte-lo6h85">Remove</button> <button class="context-menu-action svelte-lo6h85">Report issue</button>',1),fc=(e,t)=>P(t,!c(t)),vc=I('<div class="warning svelte-lo6h85" aria-label="Invalid playlink settings"><!></div>'),_c=I('<div class="actions svelte-lo6h85"><button class="expand svelte-lo6h85" aria-label="Expand"><!></button> <!> <!></div>'),hc=I('<div class="expanded svelte-lo6h85"><div class="label svelte-lo6h85">Link URL</div> <!> <div class="label offset svelte-lo6h85">Layout options</div> <div class="type-select svelte-lo6h85"><!></div></div>'),gc=I('<div class="item svelte-lo6h85"><div class="header svelte-lo6h85"><img class="poster svelte-lo6h85" alt="" width="32" height="48"> <div class="info svelte-lo6h85"><div class="title svelte-lo6h85"> </div> <div class="sentence svelte-lo6h85"><!> <!></div></div> <div class="context-menu svelte-lo6h85"><!></div></div> <div class="content svelte-lo6h85"><!> <!></div></div>');function mc(e,t){ae(t,!0);const n=N(t,"linkInjection",15),i=N(t,"onremove",3,()=>null),r=N(t,"onhighlight",3,()=>null),a=K(()=>n()||{}),o=K(()=>c(a).key),s=K(()=>c(a).sentence),l=K(()=>c(a).title_details),u=K(()=>c(a).failed),d=K(()=>c(a).failed_message),f=K(()=>c(a).inactive),_=K(()=>c(l)),m=K(()=>Br(n().sentence,n().title,60));let g=U(!1),v=U(!1),p=U(!1),y=U(null);Je(()=>{c(u)&&be(ye.InjectionFailed,c(_),{phrase:n().title,sentence:c(s)})});function w(Q=!0){j().forEach(le=>{le.classList.toggle("playpilot-injection-highlight",Q)})}function S(Q){let te=Q.target,le=te==null?void 0:te.dataset.playpilotInjectionKey;te&&!le&&(te=te.closest(`[data-playpilot-injection-key="${c(o)}"]`),le=te==null?void 0:te.dataset.playpilotInjectionKey),P(p,le===c(o)),c(y)&&c(p)&&r()(c(y))}function j(){const Q=Array.from(document.querySelectorAll(`[data-playpilot-injection-key="${c(o)}"]`));return Q.length?Q:Ur(Vt()).filter(te=>Te(te.innerText).includes(Te(n().sentence)))||[]}var x=gc();ce("mouseover",pe,S),x.__click=[lc,w,j];var T=b(x),H=b(T);L(()=>ue(H,"src",Bt(c(_).standing_poster)));var M=E(H,2),C=b(M),D=b(C),A=E(C,2),F=b(A);To(F,()=>(c(v)?c(s):c(m)).replace(n().title,`<em>${n().title}</em>`));var O=E(F,2);{var z=Q=>{var te=uc();te.__click=[cc,v];var le=b(te);L(()=>G(le,c(v)?"Less":"More")),k(Q,te)};q(O,Q=>{c(m).length<c(s).length&&Q(z)})}var B=E(M,2),V=b(B);$s(V,{ariaLabel:"More options",children:(Q,te)=>{var le=dc(),Ce=ne(le);Ce.__click=function(...ot){var R;(R=i())==null||R.apply(this,ot)};var Qe=E(Ce,2);Qe.__click=[sc,n],k(Q,le)},$$slots:{default:!0}});var W=E(T,2),J=b(W);{var ee=Q=>{_t(Q,{children:(te,le)=>{var Ce=Fe();L(()=>G(Ce,c(d))),k(te,Ce)},$$slots:{default:!0}})},re=Q=>{var te=_c(),le=b(te);le.__click=[fc,g];var Ce=b(le);Ps(Ce,{get expanded(){return c(g)}});var Qe=E(le,2);{var ot=ve=>{var Se=vc(),Le=b(Se);Ms(Le),je(3,Se,()=>Ht,()=>({duration:100})),k(ve,Se)};q(Qe,ve=>{En(n())||ve(ot)})}var R=E(Qe,2),Y=K(()=>c(f)?"Inactive":"Visible"),_e=K(()=>!n().inactive);Wn(R,{get label(){return c(Y)},get active(){return c(_e)},onclick:ve=>{n(n().inactive=!ve,!0),n(n().manual=!0,!0)},children:(ve,Se)=>{var Le=Fe();L(()=>G(Le,c(f)?"Inactive":"Visible")),k(ve,Le)},$$slots:{default:!0}}),L(()=>ue(le,"aria-expanded",c(g))),k(Q,te)};q(J,Q=>{c(u)?Q(ee):Q(re,!1)})}var de=E(J,2);{var Ae=Q=>{var te=hc(),le=E(b(te),2);vi(le,{oninput:()=>n(n().manual=!0,!0),label:"Playlink URL",get value(){return n().playpilot_url},set value(ot){n(n().playpilot_url=ot,!0)}});var Ce=E(le,4),Qe=b(Ce);Ys(Qe,{get linkInjection(){return n()}}),je(3,te,()=>Ft,()=>({duration:100})),k(Q,te)};q(de,Q=>{c(g)&&Q(Ae)})}Qt(x,Q=>P(y,Q),()=>c(y)),L(()=>{se(x,"highlighted",c(p)),se(x,"inactive",c(f)),G(D,c(_).title)}),ce("mouseenter",x,()=>w(!0)),ce("mouseleave",x,()=>w(!1)),ce("error",H,({target:Q})=>Q.src=Pr),je(6,x,()=>Ft,()=>({duration:200})),k(e,x),oe()}fe(["click"]);var pc=I('<button class="drag-handle svelte-19mcc5g" aria-label="Move editor"></button>');function yc(e,t){ae(t,!0);let n=N(t,"element",7),i=N(t,"position",23,()=>({x:0,y:0})),r=N(t,"limit",19,()=>({x:0,y:0})),a=N(t,"onchange",3,()=>null),o=!1,s={x:0,y:0},l=i();Je(()=>{u(i().x,i().y)});function u(v,p){const y=window.innerWidth,w=window.innerHeight,S=n().clientWidth,j=n().clientHeight;v=Math.min(Math.max(v,r().x),y-S-r().x),p=Math.min(Math.max(p,r().y),w-j-r().y),n().style.right=v+"px",n().style.bottom=Math.max(p,r().y)+"px",i({x:v,y:p}),a()(i())}function d(v){var p,y;return{x:v.pageX||((p=v.touches)==null?void 0:p[0].pageX)||0,y:v.pageY||((y=v.touches)==null?void 0:y[0].pageY)||0}}function f(v){o=!0,s=d(v),l=i()}function _(v){if(!o)return;const p=d(v),y=p.x-s.x,w=p.y-s.y,S=l.x-y,j=l.y-w;u(S,j)}function m(){o&&(o=!1)}var g=pc();ce("mousemove",pe,_),ce("touchmove",pe,_,void 0,!0),ce("mouseup",pe,m),ce("touchend",pe,m),ce("resize",pe,()=>u(i().x,i().y)),g.__mousedown=f,g.__touchstart=f,k(e,g),oe()}fe(["mousedown","touchstart"]);var wc=I('<button class="resize-handle svelte-sxkuxk" aria-label="Move editor"></button>');function kc(e,t){ae(t,!0);let n=N(t,"element",7),i=N(t,"height",7,200),r=N(t,"onchange",3,()=>null);const a=16;let o=!1,s=0,l=i();Je(()=>{i()&&u(i())});function u(v){const p=window.getComputedStyle(n()).minHeight||"0",y=Math.max(parseInt(p),Math.min(v,m()));n().style.height=`${y}px`,i(y),r()(y)}function d(v){var p,y;o=!0,s=v.pageY||((y=(p=v.touches)==null?void 0:p[0])==null?void 0:y.pageY)||0,l=n().clientHeight}function f(v){var S,j;if(!o)return;const p=v.pageY||((j=(S=v.touches)==null?void 0:S[0])==null?void 0:j.pageY)||0,y=s-p,w=l+y;u(w)}function _(){o=!1}function m(){const v=window.innerHeight-n().getBoundingClientRect().bottom;return Math.max(window.innerHeight-a*2-v,0)}var g=wc();ce("mousemove",pe,f),ce("touchmove",pe,f,void 0,!0),ce("mouseup",pe,_),ce("touchend",pe,_),ce("resize",pe,()=>{i()&&u(i())}),g.__mousedown=d,g.__touchstart=d,k(e,g),oe()}fe(["mousedown","touchstart"]);var bc=Ne('<svg width="4" height="8" viewBox="0 0 4 8" fill="none"><path d="M3.5 7L0.5 4L3.5 1" stroke="currentcolor" stroke-width="0.9975" stroke-linecap="round" stroke-linejoin="round"></path></svg>');function xc(e){var t=bc();k(e,t)}async function Sc(e){const t=new Headers({"Content-Type":"application/json"}),n=In();if(!n)throw new Error("No token was provided");const i=await fetch(xn+`/search/titles/?api-token=${n}&query=${e}`,{headers:t});if(!i.ok)throw i;return await i.json()}var Ec=Ne('<svg viewBox="0 -960 960 960" width="18" height="18"><path fill="currentColor" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"></path></svg>');function Tc(e){var t=Ec();k(e,t)}var Ic=I("<div> </div>"),Ac=e=>e.stopImmediatePropagation(),Cc=I('<button class="item svelte-rjq94e"><img class="poster svelte-rjq94e" alt="" width="28" height="42"> <div class="content"><div class="name svelte-rjq94e"> </div> <div class="meta svelte-rjq94e"><div class="imdb svelte-rjq94e"><!> </div> <div> </div> <div> </div> <!></div></div> <a target="_blank" class="open-in-new-tab svelte-rjq94e"><!></a></button>');function Hi(e,t){ae(t,!0);const n=N(t,"hoverable",3,!0),i=N(t,"onclick",3,()=>null);var r=Cc();r.__click=function(...x){var T;(T=i())==null||T.apply(this,x)};var a=b(r);L(()=>ue(a,"src",Bt(t.title.standing_poster)));var o=E(a,2),s=b(o),l=b(s),u=E(s,2),d=b(u),f=b(d);Hr(f);var _=E(f),m=E(d,2),g=b(m),v=E(m,2),p=b(v),y=E(v,2);{var w=x=>{var T=Ic(),H=b(T);L(()=>G(H,`${t.title.length??""} min`)),k(x,T)};q(y,x=>{t.title.length&&x(w)})}var S=E(o,2);S.__click=[Ac];var j=b(S);Tc(j),L(()=>{se(r,"hoverable",n()),G(l,t.title.title),G(_,` ${t.title.imdb_score??""}`),G(g,t.title.year),G(p,t.title.type),ue(S,"href",`${Cr}/${t.title.type??""}/${t.title.slug??""}`)}),ce("error",a,({target:x})=>x.src=Pr),k(e,r),oe()}fe(["click"]);var Pc=I('<em class="empty svelte-1olb8n0">No results found</em>'),jc=I('<div class="results svelte-1olb8n0" data-testid="search-results"></div>'),Mc=I('<div class="selected svelte-1olb8n0"><!></div>'),Nc=I('<div class="search svelte-1olb8n0"><!> <!> <!></div>');function Lc(e,t){ae(t,!0);let n=N(t,"onselect",3,()=>null),i=N(t,"query",15),r=U(X([])),a=U(null),o=U(!1);mn(()=>{i()&&s(i())});async function s(v){P(o,!0);try{P(r,X(await Sc(v)))}finally{P(o,!1)}}function l(v){i(v.title),P(a,X(v)),n()(v)}var u=Nc(),d=b(u);vi(d,{oninput:()=>P(a,null),name:"search",label:"Search...",get value(){return i()},set value(v){i(v)}});var f=E(d,2);{var _=v=>{var p=jc();at(p,21,()=>c(r),y=>y.sid,(y,w)=>{Hi(y,{get title(){return c(w)},onclick:()=>l(c(w))})},y=>{var w=Be(),S=ne(w);{var j=x=>{var T=Pc();k(x,T)};q(S,x=>{c(o)||x(j)})}k(y,w)}),k(v,p)};q(f,v=>{i()&&!c(a)&&v(_)})}var m=E(f,2);{var g=v=>{var p=Mc(),y=b(p);Hi(y,{get title(){return c(a)},hoverable:!1}),k(v,p)};q(m,v=>{c(a)&&v(g)})}k(e,u),oe()}function Oc(e,t=e.anchorNode){if(!e.anchorNode||!t)return{start:-1,end:-1};const n=e.toString().trim(),i=e.toString().search(/\S/);if(e.anchorNode===t&&t.nodeType===Node.TEXT_NODE){const u=Math.min(e.anchorOffset,e.focusOffset)+i;return{start:u,end:u+n.length}}const r=e.getRangeAt(0),a=r.cloneRange();a.selectNodeContents(t),a.setEnd(r.startContainer,r.startOffset);const s=a.toString().length+i,l=s+n.length;return{start:s,end:l}}function Dc(e,t,n,i,r,a,o,s){if(!c(t)||!c(n))return;const l=c(n).type==="movie"?"movie":"show",u=Cr+`/${l}/${c(n).slug}`,d={sid:c(n).sid,title:c(t),sentence:c(i),phrase_before:c(r),phrase_after:c(a),playpilot_url:u,key:Qr(c(n).sid),title_details:c(n),manual:!0};o.onsave(d),s()()}var Rc=I('<div class="error svelte-1i8p6op"><!></div>'),qc=I('<label for="text" class="svelte-1i8p6op">Paired title</label> <!>',1),Hc=I('<section class="layout svelte-1i8p6op"><div class="header svelte-1i8p6op"><!> <div class="heading svelte-1i8p6op">Add Playlink manually</div></div> <p class="svelte-1i8p6op">Highlight the text section in your post that you want to turn into a Playlink.</p> <label for="text" class="svelte-1i8p6op">Selected text</label> <!> <!> <!> <button class="save svelte-1i8p6op">Add playlink</button></section>');function Fc(e,t){ae(t,!0);const n=N(t,"pageText",3,""),i=N(t,"onclose",3,()=>null);let r=U(""),a=U(""),o=U(null),s=U(""),l=U(""),u=U(""),d=U("");Je(f);function f(){const C=window.getSelection();if(!(C!=null&&C.anchorNode)||C.anchorNode.parentElement&&!Vt().contains(C.anchorNode.parentElement))return;const D=C.toString().trim();if(!D)return;P(u,""),P(r,X(D));const A=C.getRangeAt(0).cloneContents();if(Array.from(A.childNodes).filter(ee=>{var re;return(re=ee.textContent)==null?void 0:re.trim()}).find(ee=>{var re;return ee.nodeName==="A"||((re=ee.querySelector)==null?void 0:re.call(ee,"a"))})){P(u,"Selection is or contains a link. Injections can not be created around already existing links.");return}P(d,X(c(r)));const{node:O,sentence:z}=_(C,D);if(!O)return;P(a,X(z));const{start:B,end:V}=Oc(C,O);(ee=>(P(l,X(ee.before)),P(s,X(ee.after))))(rs(O,B,V)),z.includes(c(l))||P(l,""),z.includes(c(s))||P(s,"");const W=C.getRangeAt(0).commonAncestorContainer.textContent,J=Te(n());(!W||!J.includes(Te(W)))&&P(u,"Selection was not inside of given content")}function _(C,D){const A=C.getRangeAt(0),F=Vt();let O=A.startContainer;for(;(O.textContent||"").length<=D.length*3&&O.parentNode&&O.parentNode.textContent!==F.textContent;)O=O.parentNode;if(!O||!O.textContent)return{node:null,sentence:""};const z=O.textContent,B=m(O,A.startContainer,A.startOffset),V=m(O,A.endContainer,A.endOffset),W=z.slice(0,B).lastIndexOf("."),J=z.slice(V).match(/[.!?]/),ee=J?V+J.index:z.length,re=W===-1?0:W+1,de=ee,Ae=z.slice(re,de+1).trim();return{node:O,sentence:Ae}}function m(C,D,A){let F=0;const O=C,z=B=>{var V;if(B===D)return F+=A,!0;B.nodeType===Node.TEXT_NODE&&(F+=((V=B.textContent)==null?void 0:V.length)||0);for(let W=B.firstChild;W;W=W.nextSibling)if(z(W))return!0;return!1};return z(O),F}function g(C){var D,A;P(o,X(C)),(A=(D=window.getSelection())==null?void 0:D.removeAllRanges)==null||A.call(D)}var v=Hc();ce("mouseup",pe,f);var p=b(v),y=b(p);ci(y,{get onclick(){return i()},size:"24px",children:(C,D)=>{xc(C)},$$slots:{default:!0}});var w=E(y,2);Jt(w,(C,D)=>xe==null?void 0:xe(C,D),()=>2);var S=E(p,6);vi(S,{get value(){return c(r)},label:"Select text on the page",name:"selected-text",readonly:!0});var j=E(S,2);{var x=C=>{var D=Rc(),A=b(D);_t(A,{children:(F,O)=>{var z=Fe();L(()=>G(z,c(u))),k(F,z)},$$slots:{default:!0}}),k(C,D)};q(j,C=>{c(u)&&C(x)})}var T=E(j,2);{var H=C=>{var D=qc(),A=E(ne(D),2);Sr(A,()=>c(a)+c(r),F=>{Lc(F,{onselect:g,get query(){return c(d)},set query(O){P(d,X(O))}})}),k(C,D)};q(T,C=>{c(u)||C(H)})}var M=E(T,2);M.__click=[Dc,r,o,a,l,s,t,i],L(()=>M.disabled=!c(r)||!c(o)),k(e,v),oe()}fe(["click"]);const Kn="PlayPilotEditorialSessionId",$r=5e3,Bc=$r*2;async function Vc(e){const{ai_enabled:t,injections_enabled:n,session_id:i,session_last_ping:r}=await Tn(e),a=ta(i||null,r||null),o={ai_enabled:t,injections_enabled:n,session_id:i,session_last_ping:r};return a?await ea(e):o}async function ea(e){const t=na(),n=new Date(Date.now()).toISOString(),i={session_id:t,session_last_ping:n.toString()},{ai_enabled:r,injections_enabled:a}=await Tn(e,{params:i});return{ai_enabled:r,injections_enabled:a,...i}}function ta(e,t){if(!e||!t)return!0;const n=Date.now(),i=new Date(t),r=na();return n-i.getTime()>Bc?!0:r===e}function na(){return sessionStorage.getItem(Kn)||Uc()}function Uc(){const e=sessionStorage.getItem(Kn)||Or();return sessionStorage.setItem(Kn,e),e}function zc(e,t,n){ea(t()),n()()}var Wc=I('<p class="svelte-2m2urs"><strong>Someone else is currently editing this document.</strong> Wait for them to exit the page or take over edit permissions, preventing them from making more changes.</p> <button class="button svelte-2m2urs">Take over editing</button>',1),Kc=I('<div class="alert svelte-2m2urs"><!></div>');function Yc(e,t){ae(t,!0);const n=N(t,"pageText",3,""),i=N(t,"onpoll",3,()=>null),r=N(t,"onallow",3,()=>null),a=N(t,"ondisallow",3,()=>null),o=N(t,"ontakeover",3,()=>null);let s=null,l=U(!0);Je(()=>(u(),()=>{s&&clearInterval(s)}));function u(){d(),s=setInterval(d,$r)}async function d(){const g=await Vc(n());g&&(P(l,X(ta(g.session_id||null,g.session_last_ping||null))),c(l)?r()():a()(),i()({injectionsEnabled:!!g.injections_enabled,aiEnabled:!!g.ai_enabled}))}var f=Be(),_=ne(f);{var m=g=>{var v=Kc(),p=b(v);_t(p,{type:"warning",children:(y,w)=>{var S=Wc(),j=E(ne(S),2);j.__click=[zc,n,o],k(y,S)},$$slots:{default:!0}}),k(g,v)};q(_,g=>{c(l)||g(m)})}k(e,f),oe()}fe(["click"]);var Zc=Ne('<svg width="24px" height="24px" viewBox="0 0 64 64" stroke-width="3" stroke="currentColor" fill="none"><circle cx="34.52" cy="11.43" r="5.82"></circle><circle cx="53.63" cy="31.6" r="5.82"></circle><circle cx="34.52" cy="50.57" r="5.82"></circle><circle cx="15.16" cy="42.03" r="5.82"></circle><circle cx="15.16" cy="19.27" r="5.82"></circle><circle cx="34.51" cy="29.27" r="4.7"></circle><line x1="20.17" y1="16.3" x2="28.9" y2="12.93"></line><line x1="38.6" y1="15.59" x2="49.48" y2="27.52"></line><line x1="50.07" y1="36.2" x2="38.67" y2="46.49"></line><line x1="18.36" y1="24.13" x2="30.91" y2="46.01"></line><line x1="20.31" y1="44.74" x2="28.7" y2="48.63"></line><line x1="17.34" y1="36.63" x2="31.37" y2="16.32"></line><line x1="20.52" y1="21.55" x2="30.34" y2="27.1"></line><line x1="39.22" y1="29.8" x2="47.81" y2="30.45"></line><line x1="34.51" y1="33.98" x2="34.52" y2="44.74"></line></svg>');function Gc(e){var t=Zc();k(e,t)}var Xc=I('<strong class="svelte-1kpafo0">AI processing is disabled.</strong> Enable AI from the <a href="https://partner.playpilot.net" class="svelte-1kpafo0">Partner Portal</a>',1),Jc=I('<span class="svelte-1kpafo0">.</span>'),Qc=I(`<strong class="svelte-1kpafo0">AI links are currently processing.</strong> This can take several minutes. We'll insert all found injections once ready. <div class="message svelte-1kpafo0"> <span class="ellipses svelte-1kpafo0"></span></div> <div class="loading-bar svelte-1kpafo0"><div class="loading-bar-progress svelte-1kpafo0"><div class="loading-bar-fill svelte-1kpafo0" data-testid="loading-bar"></div></div> <div class="loading-bar-label svelte-1kpafo0"> </div></div>`,1),$c=(e,t)=>P(t,!0),eu=I('<p class="svelte-1kpafo0"><strong class="svelte-1kpafo0">AI has finished processing.</strong> <br class="svelte-1kpafo0"> <!></p> <button class="dismiss svelte-1kpafo0">Dismiss</button>',1),tu=I('<div class="animator svelte-1kpafo0" data-test-id="animator"></div>'),nu=I('<div class="ai-indicator svelte-1kpafo0" data-testid="ai-indicator"><div class="content svelte-1kpafo0"><div class="icon svelte-1kpafo0"><!></div> <div class="svelte-1kpafo0"><!></div></div> <div class="border svelte-1kpafo0"><!></div></div>');function iu(e,t){const n=N(t,"aiRunning",3,!1),i=N(t,"aiEnabled",3,!1),r=N(t,"message",3,""),a=N(t,"percentage",3,0),o=N(t,"aiInjectionsCount",3,0),s=o();let l=U(!1);var u=Be(),d=ne(u);{var f=_=>{var m=nu(),g=b(m),v=b(g),p=b(v);Gc(p);var y=E(v,2),w=b(y);{var S=M=>{var C=Xc();k(M,C)},j=M=>{var C=Be(),D=ne(C);{var A=O=>{var z=Qc(),B=E(ne(z),2),V=b(B),W=E(V);at(W,20,()=>({length:3}),bt,(te,le)=>{var Ce=Jc();k(te,Ce)});var J=E(B,2),ee=b(J),re=b(ee);const de=K(()=>`${Math.max(a(),3)??""}%`);L(()=>bn(re,"width",c(de)));var Ae=E(ee,2),Q=b(Ae);L(()=>G(Q,`${Math.floor(a())??""}%`)),L(()=>G(V,`${r()??""} `)),k(O,z)},F=O=>{var z=eu(),B=ne(z),V=E(b(B),4);{var W=re=>{var de=Fe("No new injections where found.");k(re,de)},J=re=>{var de=Fe();L(()=>G(de,`${o()??""} Injections where found and added to the page.`)),k(re,de)};q(V,re=>{s===o()?re(W):re(J,!1)})}var ee=E(B,2);ee.__click=[$c,l],k(O,z)};q(D,O=>{n()?O(A):O(F,!1)},!0)}k(M,C)};q(w,M=>{i()?M(j,!1):M(S)})}var x=E(g,2),T=b(x);{var H=M=>{var C=tu();k(M,C)};q(T,M=>{n()&&M(H)})}L(()=>se(m,"running",n())),k(_,m)};q(d,_=>{c(l)||_(f)})}k(e,u)}fe(["click"]);async function ru(e,t,n,i,r,a,o){try{P(t,!0),P(n,!1),i(await Ts(i(),r())),P(a,X(c(o)))}catch{P(n,!0)}finally{P(t,!1)}}var au=I('<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:400,600,700">'),ou=I('<div class="handles svelte-11aj6xq"><div class="handle svelte-11aj6xq"><!></div> <div class="handle svelte-11aj6xq"><!></div></div>'),lu=I('<div class="loading svelte-11aj6xq">Loading...</div>'),su=I('<div class="bubble svelte-11aj6xq"> </div> <!>',1),cu=I(`<strong>Playlinks are currently not published.</strong> Visitors to this page will not see any of the injected links.
10
+ Publish playlinks from the <a href="https://partner.playpilot.net">Partner Portal.</a>`,1),uu=I('<div class="alert svelte-11aj6xq"><!></div>'),du=I('<div class="error svelte-11aj6xq"><!></div>'),fu=I('<div class="empty svelte-11aj6xq">No links available. Add links manually by clicking the + button and select text to add a link to.</div>'),vu=I('<button class="save svelte-11aj6xq"> </button>'),_u=I('<!> <!> <div class="items svelte-11aj6xq"></div> <!>',1),hu=I("<!> <!> <!>",1),gu=I('<div class="panel playpilot-styled-scrollbar svelte-11aj6xq"><!></div>'),mu=I('<section class="editor playpilot-styled-scrollbar svelte-11aj6xq"><!> <header class="header svelte-11aj6xq"><div class="heading svelte-11aj6xq">Playlinks</div> <!></header> <!> <!></section>');function pu(e,t){ae(t,!0);let n=N(t,"linkInjections",15),i=N(t,"pageText",3,""),r=N(t,"loading",3,!1),a=N(t,"injectionsEnabled",7,!1),o=N(t,"aiStatus",23,()=>({})),s=N(t,"onreinitialize",3,()=>null);const l="editor-position",u="editor-height",d=JSON.parse(localStorage.getItem(l)||'{ "x": 0, "y": 0 }'),f=parseInt(localStorage.getItem(u)||"0");let _=U(null),m=U(!1),g=U(!1),v=U(!1),p=U(!0),y=U(0),w=U("");const S=K(()=>on(o().aiEnabled,!1)),j=K(()=>on(o().aiRunning,!1)),x=K(()=>JSON.stringify(n())),T=K(()=>!c(j)&&c(p)),H=K(()=>c(w)&&c(w)!==c(x)),M=K(()=>n().filter(R=>R.title_details&&!R.removed&&!R.duplicate&&(R.manual||!R.manual&&!R.failed))),C=K(()=>A(c(M))),D=K(()=>!r()&&Ke(()=>o().aiRunning));mn(()=>{r()||Ke(()=>{requestAnimationFrame(()=>P(w,X(c(x)))),V()})});function A(R){return R.sort((Y,_e)=>Y.failed!==_e.failed?Y.failed?1:-1:Y.title_details.title.localeCompare(_e.title_details.title))}function F(R,Y){localStorage.setItem(R,Y)}function O(R){const Y=n().findIndex(_e=>_e.key===R);n(n()[Y].manual=!0,!0),n(n()[Y].removed=!0,!0),n([...n()])}function z(R){if(!c(_))return;const Y=R.offsetTop,_e=Y+R.offsetHeight,ve=c(_).scrollTop,Se=ve+c(_).clientHeight;Y>=ve&&_e<=Se||c(_).scrollTo({top:Y-c(_).clientHeight/2,behavior:"smooth"})}function B(R){const Y=R.target;P(y,X(Y.scrollTop))}function V(){const R={total:n().length,failed_automatic:n().filter(Y=>Y.failed&&!Y.manual).length,failed_manual:n().filter(Y=>Y.failed&&Y.manual).length,final_injected:c(M).length};be(ye.TotalInjectionsCount,null,R)}var W=mu();wo(R=>{var Y=au();k(R,Y)});var J=b(W);{var ee=R=>{var Y=ou(),_e=b(Y),ve=b(_e);kc(ve,{get element(){return c(_)},height:f,onchange:Ze=>F(u,JSON.stringify(Ze))});var Se=E(_e,2),Le=b(Se);yc(Le,{get element(){return c(_)},position:d,limit:{x:16,y:16},onchange:Ze=>F(l,JSON.stringify(Ze))}),k(R,Y)};q(J,R=>{c(_)&&!r()&&R(ee)})}var re=E(J,2),de=b(re);Jt(de,R=>xe==null?void 0:xe(R));var Ae=E(de,2);{var Q=R=>{var Y=lu();k(R,Y)},te=R=>{var Y=Be(),_e=ne(Y);{var ve=Se=>{var Le=su(),Ze=ne(Le),Oe=b(Ze),$t=E(Ze,2);ci($t,{onclick:()=>P(m,!0),size:"24px","aria-label":"Add manual injection",children:(en,_i)=>{var tn=Fe("+");k(en,tn)},$$slots:{default:!0}}),L(()=>{ue(Ze,"aria-label",`${c(M).length??""} found playlinks`),G(Oe,c(M).length)}),k(Se,Le)};q(_e,Se=>{c(T)&&Se(ve)},!0)}k(R,Y)};q(Ae,R=>{r()?R(Q):R(te,!1)})}var le=E(re,2);{var Ce=R=>{var Y=hu(),_e=ne(Y);Yc(_e,{get pageText(){return i()},onallow:()=>P(p,!0),ondisallow:()=>P(p,!1),get ontakeover(){return s()},onpoll:Oe=>{a(Oe.injectionsEnabled),o().aiEnabled=Oe.aiEnabled}});var ve=E(_e,2);{var Se=Oe=>{iu(Oe,Ko(o,{get aiInjectionsCount(){return Kr(n()).aiInjections.length}}))};q(ve,Oe=>{c(p)&&(c(D)||!c(S))&&Oe(Se)})}var Le=E(ve,2);{var Ze=Oe=>{var $t=_u(),en=ne($t);{var _i=he=>{var ge=uu(),$e=b(ge);_t($e,{type:"warning",children:(lt,oa)=>{var An=cu();k(lt,An)},$$slots:{default:!0}}),k(he,ge)};q(en,he=>{a()||he(_i)})}var tn=E(en,2);{var ia=he=>{var ge=du(),$e=b(ge);_t($e,{children:(lt,oa)=>{var An=Fe("Something went wrong, check your links below.");k(lt,An)},$$slots:{default:!0}}),je(7,ge,()=>Ft,()=>({duration:150})),k(he,ge)};q(tn,he=>{c(v)&&he(ia)})}var hi=E(tn,2);at(hi,21,()=>c(C),he=>he.key,(he,ge)=>{const $e=K(()=>n().findIndex(lt=>lt.key===c(ge).key));mc(he,{onremove:()=>O(c(ge).key),onhighlight:z,get linkInjection(){return n()[c($e)]},set linkInjection(lt){n(n()[c($e)]=lt,!0)}})},he=>{var ge=fu();k(he,ge)});var ra=E(hi,2);{var aa=he=>{var ge=vu();ge.__click=[ru,g,v,n,i,w,x];var $e=b(ge);L(()=>{ge.disabled=c(g),G($e,c(g)?"Saving...":"Save links")}),je(1,ge,()=>Ht,()=>({duration:100})),k(he,ge)};q(ra,he=>{c(H)&&n().length&&c(p)&&he(aa)})}k(Oe,$t)};q(Le,Oe=>{c(T)&&Oe(Ze)})}k(R,Y)};q(le,R=>{r()||R(Ce)})}var Qe=E(le,2);{var ot=R=>{var Y=gu(),_e=b(Y);Fc(_e,{get pageText(){return i()},onclose:()=>P(m,!1),onsave:ve=>n().push(ve)}),L(()=>bn(Y,"top",`${c(y)??""}px`)),je(3,Y,()=>Sn,()=>({x:Math.min(window.innerWidth,320),duration:200,opacity:1})),k(R,Y)};q(Qe,R=>{c(m)&&R(ot)})}Qt(W,R=>P(_,R),()=>c(_)),L(()=>{se(W,"panel-open",c(m)),se(W,"loading",r())}),ce("scroll",W,B),k(e,W),oe()}fe(["click"]);var yu=Ne('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 57.48 62.96"><defs><style>.playpilot-logo{fill:url(#playpilot-linear-gradient);}</style><linearGradient id="playpilot-linear-gradient" x1="-90.03" y1="-40.23" x2="-34.8" y2="-101.48" gradientTransform="translate(74.02 108.65)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#de00b9"></stop><stop offset="0.99" stop-color="#ff557b"></stop></linearGradient></defs><path class="playpilot-logo" d="M57.48,31.48C57.48,22.17,20.85,2.19,9.2.18,7.42-.12,3.78-.37,1.36,2.25-4.32,8.39,9.62,21.5,9.62,31.48S-4.32,54.57,1.36,60.72c2.42,2.61,6.06,2.37,7.84,2.06C20.85,60.78,57.48,40.79,57.48,31.48Z"></path></svg>');function wu(e){var t=yu();k(e,t)}var ku=I('<div class="trigger svelte-qee95d"><button type="button" class="button svelte-qee95d" title="Show PlayPilot TPI editor"><!></button> <button type="button" class="button close svelte-qee95d" title="Close PlayPilot TPI"><!></button></div>');function bu(e,t){var n=ku(),i=b(n);i.__click=function(...s){var l;(l=t.onclick)==null||l.apply(this,s)};var r=b(i);wu(r);var a=E(i,2);a.__click=function(...s){var l;(l=t.onclose)==null||l.apply(this,s)};var o=b(a);Rr(o),k(e,n)}fe(["click"]);var xu=I('<div class="playpilot-link-injections svelte-13rmd3g" data-playpilot-link-injections=""><!> <!></div>');function Su(e,t){ae(t,!0);let n=U(null),i=U(X([])),r=U(null),a=U(X(Lr())),o=U(!!li()),s=U(!1),l=U(!0),u=U(!0),d=U(X([]));const f=K(()=>c(r)||{}),_=K(()=>on(c(f).ai_injections,()=>[],!0)),m=K(()=>on(c(f).manual_injections,()=>[],!0)),g=K(()=>c(i).map(A=>A.innerText).join(`
11
11
 
12
- `));mn(()=>{c(a)&&!c(l)&&p()}),Je(()=>{if(!As())return(async()=>(await v(),be(ye.ArticlePageView)))(),()=>fi()});async function v(){P(l,!0),c(a)&&P(s,X(await Nr()));try{const A=await Is(),F=ai();if(P(u,!!(A!=null&&A.exclude_urls_pattern&&F.match(new RegExp(A.exclude_urls_pattern)))),c(u))return;A!=null&&A.custom_style&&x(A.custom_style||""),S((A==null?void 0:A.html_selector)||"",(A==null?void 0:A.exclude_elements_selector)||"")}catch(A){be(ye.FetchingConfigFailed),console.error("TPI Config failed to fetch",A);return}try{if(P(r,X(await Di(c(g),{maxTries:1}))),P(l,!1),!c(r))return;if(Jo({organizationSid:c(r).organization_sid,domainSid:c(r).domain_sid}),!c(r).ai_running||!c(r).automation_enabled){w({aiInjections:c(_),manualInjections:c(m)});return}if(!c(a))return;P(r,X(await Di(c(g),{requireCompletedResult:!0,onpoll:A=>P(r,X(A))}))),w({aiInjections:c(_),manualInjections:c(m)})}catch(A){console.error(A),be(ye.InjectionError,null,{message:A.message})}}function p(){w(Kr(c(d)))}function y(){P(a,!1),requestAnimationFrame(()=>{P(a,!0),v()})}function w(A={aiInjections:c(_),manualInjections:c(m)}){const F=us(c(i),A);JSON.stringify(F)!==JSON.stringify(c(d))&&P(d,X(F));const O=F.filter(z=>!z.failed);O.length&&(c(a)||be(ye.ArticleInjected,null,{manual:O.filter(z=>z.manual).length,ai:O.filter(z=>!z.manual).length}))}function S(A,F){A&&(window.PlayPilotLinkInjections.selector=A),P(n,X(Vt())),P(i,X(Ur(c(n),F)))}function j(){P(a,!0),el(),v()}function x(A){const F="playpilot-custom-style",O=document.getElementById(F),z=O||document.createElement("style");z.textContent=`[data-playpilot-link-injections] { ${A} }`,z.id=F,O||document.body.appendChild(z)}var T=xu(),H=b(T);{var M=A=>{bu(A,{onclick:j,onclose:()=>{P(o,!1),$o()}})};q(H,A=>{!c(u)&&c(o)&&!c(a)&&A(M)})}var C=E(H,2);{var D=A=>{var F=Be(),O=ne(F);Yo(O,{onerror:B=>be(ye.EditorError,null,{message:B.message}),failed:B=>{_t(B,{fixed:!0,children:(V,W)=>{var J=Fe("An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!");k(V,J)},$$slots:{default:!0}})}},B=>{var V=K(()=>{var J;return(J=c(r))==null?void 0:J.injections_enabled}),W=K(()=>{var J,ee,re,de,Ae;return{automationEnabled:(J=c(r))==null?void 0:J.automation_enabled,aiRunning:((ee=c(r))==null?void 0:ee.ai_running)&&((re=c(r))==null?void 0:re.automation_enabled),message:(de=c(r))==null?void 0:de.ai_progress_message,percentage:(Ae=c(r))==null?void 0:Ae.ai_progress_percentage}});pu(B,{get pageText(){return c(g)},get loading(){return c(l)},onreinitialize:y,get injectionsEnabled(){return c(V)},get aiStatus(){return c(W)},get linkInjections(){return c(d)},set linkInjections(J){P(d,X(J))}})}),k(A,F)};q(C,A=>{!c(u)&&c(a)&&c(s)&&A(D)})}k(e,T),oe()}window.PlayPilotLinkInjections={token:"",editorial_token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,app:null,initialize(e={token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,editorial_token:""}){if(!e.token){console.error("An API token is required.");return}this.token=e.token,this.editorial_token=e.editorial_token,this.selector=e.selector,this.after_article_selector=e.after_article_selector,this.after_article_insert_position=e.after_article_insert_position,this.language=e.language,this.organization_sid=e.organization_sid,this.domain_sid=e.domain_sid,this.app&&this.destroy();const t=document.createElement("div");t.id="playpilot-link-injection",document.body.insertAdjacentElement("beforeend",t),this.app=Xt(Su,{target:t})},destroy(){if(!this.app)return;this.app=null;const e=document.getElementById("playpilot-link-injection");e&&e.remove(),fi()}};
12
+ `));mn(()=>{c(a)&&!c(l)&&p()}),Je(()=>{if(!As())return(async()=>(await v(),be(ye.ArticlePageView)))(),()=>fi()});async function v(){P(l,!0),c(a)&&P(s,X(await Nr()));try{const A=await Is(),F=ai();if(P(u,!!(A!=null&&A.exclude_urls_pattern&&F.match(new RegExp(A.exclude_urls_pattern)))),c(u))return;A!=null&&A.custom_style&&x(A.custom_style||""),S((A==null?void 0:A.html_selector)||"",(A==null?void 0:A.exclude_elements_selector)||"")}catch(A){be(ye.FetchingConfigFailed),console.error("TPI Config failed to fetch",A);return}try{if(P(r,X(await Di(c(g),{maxTries:1}))),P(l,!1),!c(r))return;if(Jo({organizationSid:c(r).organization_sid,domainSid:c(r).domain_sid}),!c(r).ai_running||!c(r).ai_enabled){w({aiInjections:c(_),manualInjections:c(m)});return}if(!c(a))return;P(r,X(await Di(c(g),{requireCompletedResult:!0,onpoll:A=>P(r,X(A))}))),w({aiInjections:c(_),manualInjections:c(m)})}catch(A){console.error(A),be(ye.InjectionError,null,{message:A.message})}}function p(){w(Kr(c(d)))}function y(){P(a,!1),requestAnimationFrame(()=>{P(a,!0),v()})}function w(A={aiInjections:c(_),manualInjections:c(m)}){const F=us(c(i),A);JSON.stringify(F)!==JSON.stringify(c(d))&&P(d,X(F));const O=F.filter(z=>!z.failed);O.length&&(c(a)||be(ye.ArticleInjected,null,{manual:O.filter(z=>z.manual).length,ai:O.filter(z=>!z.manual).length}))}function S(A,F){A&&(window.PlayPilotLinkInjections.selector=A),P(n,X(Vt())),P(i,X(Ur(c(n),F)))}function j(){P(a,!0),el(),v()}function x(A){const F="playpilot-custom-style",O=document.getElementById(F),z=O||document.createElement("style");z.textContent=`[data-playpilot-link-injections] { ${A} }`,z.id=F,O||document.body.appendChild(z)}var T=xu(),H=b(T);{var M=A=>{bu(A,{onclick:j,onclose:()=>{P(o,!1),$o()}})};q(H,A=>{!c(u)&&c(o)&&!c(a)&&A(M)})}var C=E(H,2);{var D=A=>{var F=Be(),O=ne(F);Yo(O,{onerror:B=>be(ye.EditorError,null,{message:B.message}),failed:B=>{_t(B,{fixed:!0,children:(V,W)=>{var J=Fe("An error has occured in the PlayPilot Linkinjections editor view. We've been notified and will investigate!");k(V,J)},$$slots:{default:!0}})}},B=>{var V=K(()=>{var J;return(J=c(r))==null?void 0:J.injections_enabled}),W=K(()=>{var J,ee,re,de,Ae;return{aiEnabled:(J=c(r))==null?void 0:J.ai_enabled,aiRunning:((ee=c(r))==null?void 0:ee.ai_running)&&((re=c(r))==null?void 0:re.ai_enabled),message:(de=c(r))==null?void 0:de.ai_progress_message,percentage:(Ae=c(r))==null?void 0:Ae.ai_progress_percentage}});pu(B,{get pageText(){return c(g)},get loading(){return c(l)},onreinitialize:y,get injectionsEnabled(){return c(V)},get aiStatus(){return c(W)},get linkInjections(){return c(d)},set linkInjections(J){P(d,X(J))}})}),k(A,F)};q(C,A=>{!c(u)&&c(a)&&c(s)&&A(D)})}k(e,T),oe()}window.PlayPilotLinkInjections={token:"",editorial_token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,app:null,initialize(e={token:"",selector:"",after_article_selector:"",after_article_insert_position:"",language:null,organization_sid:null,domain_sid:null,editorial_token:""}){if(!e.token){console.error("An API token is required.");return}this.token=e.token,this.editorial_token=e.editorial_token,this.selector=e.selector,this.after_article_selector=e.after_article_selector,this.after_article_insert_position=e.after_article_insert_position,this.language=e.language,this.organization_sid=e.organization_sid,this.domain_sid=e.domain_sid,this.app&&this.destroy();const t=document.createElement("div");t.id="playpilot-link-injection",document.body.insertAdjacentElement("beforeend",t),this.app=Xt(Su,{target:t})},destroy(){if(!this.app)return;this.app=null;const e=document.getElementById("playpilot-link-injection");e&&e.remove(),fi()}};
13
13
 
14
14
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "4.0.2",
3
+ "version": "5.0.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
package/src/lib/api.ts CHANGED
@@ -70,9 +70,9 @@ export async function pollLinkInjections(
70
70
  try {
71
71
  response = await fetchLinkInjections(pageText)
72
72
 
73
- if (requireCompletedResult && (response.automation_enabled && response.ai_running)) throw new Error
73
+ if (requireCompletedResult && (response.ai_enabled && response.ai_running)) throw new Error
74
74
 
75
- response.link_injections = insertRandomKeys(response.link_injections || [])
75
+ response.manual_injections = insertRandomKeys(response.manual_injections || [])
76
76
  response.ai_injections = insertRandomKeys(response.ai_injections || [])
77
77
 
78
78
  resolve(response)
@@ -118,8 +118,8 @@ export async function saveLinkInjections(linkInjections: LinkInjection[], pageTe
118
118
  const response = await fetchLinkInjections(pageText, {
119
119
  params: {
120
120
  private_token: getAuthToken(),
121
- link_injections: newLinkInjections,
122
- text_selector: selector,
121
+ manual_injections: newLinkInjections,
122
+ content_text_selector: selector,
123
123
  },
124
124
  })
125
125
 
package/src/lib/meta.ts CHANGED
@@ -8,9 +8,9 @@ export function getPageMetaData(): ArticleMetaData {
8
8
  const parent = getLinkInjectionsParentElement()
9
9
 
10
10
  return {
11
- heading: getPageHeading(parent),
12
- modified_time: getPageModifiedTime(parent),
13
- published_time: getPagePublishedTime(parent),
11
+ content_heading: getPageHeading(parent),
12
+ content_modified_time: getPageModifiedTime(parent),
13
+ content_published_time: getPagePublishedTime(parent),
14
14
  }
15
15
  }
16
16
 
@@ -9,17 +9,17 @@ export const sessionPeriodMilliseconds = sessionPollPeriodMilliseconds * 2
9
9
  /**
10
10
  * Fetch link injections and infer if the current session is allowed to edit. If they are, we make an additional request
11
11
  * where we save the session.
12
- * Along with that, we also return automation_enabled and injections_enabled as they are used to update the state of
12
+ * Along with that, we also return ai_enabled and injections_enabled as they are used to update the state of
13
13
  * the current editing session.
14
14
  * @param pageText Despite not being used, the request still requires a valid pageText string
15
15
  */
16
16
  export async function fetchAsSession(pageText: string): Promise<SessionResponse> {
17
- const { automation_enabled, injections_enabled, session_id, session_last_ping } = await fetchLinkInjections(pageText)
17
+ const { ai_enabled, injections_enabled, session_id, session_last_ping } = await fetchLinkInjections(pageText)
18
18
 
19
19
  const isCurrentlyAllowToEdit = isAllowedToEdit(session_id || null, session_last_ping || null)
20
20
 
21
21
  const response = {
22
- automation_enabled,
22
+ ai_enabled,
23
23
  injections_enabled,
24
24
  session_id,
25
25
  session_last_ping,
@@ -44,10 +44,10 @@ export async function saveCurrentSession(pageText: string): Promise<SessionRespo
44
44
  session_last_ping: now.toString(),
45
45
  }
46
46
 
47
- const { automation_enabled, injections_enabled } = await fetchLinkInjections(pageText, { params })
47
+ const { ai_enabled, injections_enabled } = await fetchLinkInjections(pageText, { params })
48
48
 
49
49
  return {
50
- automation_enabled,
50
+ ai_enabled,
51
51
  injections_enabled,
52
52
  ...params,
53
53
  }
@@ -24,14 +24,13 @@ export type LinkInjectionRanges = Record<string, { elementIndex: number, from: n
24
24
 
25
25
  export type LinkInjectionResponse = {
26
26
  injections_ready: boolean
27
- page_updated: boolean
28
- automation_enabled: boolean
27
+ ai_enabled: boolean
29
28
  injections_enabled: boolean
30
29
  ai_running: boolean
31
30
  ai_injections: LinkInjection[] | null
32
31
  ai_progress_message: string
33
32
  ai_progress_percentage: number
34
- link_injections: LinkInjection[] | null
33
+ manual_injections: LinkInjection[] | null
35
34
  organization_sid?: string
36
35
  domain_sid?: string
37
36
  session_id?: string | null
@@ -44,7 +43,7 @@ export type LinkInjectionTypes = {
44
43
  }
45
44
 
46
45
  export type ArticleMetaData = {
47
- heading: string | null
48
- modified_time: string | null
49
- published_time: string | null
46
+ content_heading: string | null
47
+ content_modified_time: string | null
48
+ content_published_time: string | null
50
49
  }
@@ -3,12 +3,11 @@ import type { LinkInjectionResponse } from "./injection"
3
3
  export type SessionResponse = Omit<
4
4
  LinkInjectionResponse,
5
5
  'injections_ready' |
6
- 'page_updated' |
7
6
  'ai_running' |
8
7
  'ai_progress_message' |
9
8
  'ai_progress_percentage' |
10
9
  'ai_injections' |
11
10
  'organization_sid' |
12
11
  'domain_sid' |
13
- 'link_injections'
12
+ 'manual_injections'
14
13
  >
@@ -24,7 +24,7 @@
24
24
  let linkInjections: LinkInjection[] = $state([])
25
25
 
26
26
  // @ts-ignore It's ok if the response is empty
27
- const { ai_injections: aiInjections = [], link_injections: manualInjections = [] } = $derived(response || {})
27
+ const { ai_injections: aiInjections = [], manual_injections: manualInjections = [] } = $derived(response || {})
28
28
 
29
29
  const pageText = $derived(elements.map(element => element.innerText).join('\n\n'))
30
30
 
@@ -81,7 +81,7 @@
81
81
 
82
82
  // We only show results once they are fully processed. We only inject if AI is no longer running, or isn't
83
83
  // meant to run to begin with.
84
- if (!response.ai_running || !response.automation_enabled) {
84
+ if (!response.ai_running || !response.ai_enabled) {
85
85
  inject({ aiInjections, manualInjections })
86
86
  return
87
87
  }
@@ -174,8 +174,8 @@
174
174
  onreinitialize={reinitializeEditor}
175
175
  injectionsEnabled={response?.injections_enabled}
176
176
  aiStatus={{
177
- automationEnabled: response?.automation_enabled,
178
- aiRunning: response?.ai_running && response?.automation_enabled,
177
+ aiEnabled: response?.ai_enabled,
178
+ aiRunning: response?.ai_running && response?.ai_enabled,
179
179
  message: response?.ai_progress_message,
180
180
  percentage: response?.ai_progress_percentage,
181
181
  }} />
@@ -3,13 +3,13 @@
3
3
 
4
4
  interface Props {
5
5
  aiRunning?: boolean
6
- automationEnabled?: boolean
6
+ aiEnabled?: boolean
7
7
  message?: string
8
8
  percentage?: number
9
9
  aiInjectionsCount?: number
10
10
  }
11
11
 
12
- const { aiRunning = false, automationEnabled = false, message = '', percentage = 0, aiInjectionsCount = 0 }: Props = $props()
12
+ const { aiRunning = false, aiEnabled = false, message = '', percentage = 0, aiInjectionsCount = 0 }: Props = $props()
13
13
 
14
14
  const initialAIInjectionsCount = aiInjectionsCount
15
15
 
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
 
26
26
  <div>
27
- {#if !automationEnabled}
27
+ {#if !aiEnabled}
28
28
  <strong>AI processing is disabled.</strong> Enable AI from the <a href="https://partner.playpilot.net">Partner Portal</a>
29
29
  {:else if aiRunning}
30
30
  <strong>AI links are currently processing.</strong> This can take several minutes. We'll insert all found injections once ready.
@@ -23,7 +23,7 @@
23
23
  loading?: boolean,
24
24
  injectionsEnabled?: boolean,
25
25
  aiStatus?: {
26
- automationEnabled?: boolean,
26
+ aiEnabled?: boolean,
27
27
  aiRunning?: boolean,
28
28
  message?: string,
29
29
  percentage?: number
@@ -54,7 +54,7 @@
54
54
  let scrollDistance = $state(0)
55
55
  let initialStateString = $state('')
56
56
 
57
- const { automationEnabled = false, aiRunning = false } = $derived(aiStatus)
57
+ const { aiEnabled = false, aiRunning = false } = $derived(aiStatus)
58
58
  const linkInjectionsString = $derived(JSON.stringify(linkInjections))
59
59
  const showControls = $derived(!aiRunning && allowEditing)
60
60
  const hasChanged = $derived(initialStateString && initialStateString !== linkInjectionsString)
@@ -183,10 +183,10 @@
183
183
  ontakeover={onreinitialize}
184
184
  onpoll={(updated) => {
185
185
  injectionsEnabled = updated.injectionsEnabled
186
- aiStatus.automationEnabled = updated.automationEnabled
186
+ aiStatus.aiEnabled = updated.aiEnabled
187
187
  }} />
188
188
 
189
- {#if allowEditing && (initialAiRunning || !automationEnabled)}
189
+ {#if allowEditing && (initialAiRunning || !aiEnabled)}
190
190
  <AIIndicator {...aiStatus} aiInjectionsCount={separateLinkInjectionTypes(linkInjections).aiInjections.length} />
191
191
  {/if}
192
192
 
@@ -6,7 +6,7 @@
6
6
  interface Props {
7
7
  pageText?: string,
8
8
  // eslint-disable-next-line no-unused-vars
9
- onpoll?: ({ injectionsEnabled, automationEnabled }: { injectionsEnabled: boolean, automationEnabled: boolean }) => void,
9
+ onpoll?: ({ injectionsEnabled, aiEnabled }: { injectionsEnabled: boolean, aiEnabled: boolean }) => void,
10
10
  onallow?: () => void,
11
11
  ondisallow?: () => void,
12
12
  ontakeover?: () => void,
@@ -46,7 +46,7 @@
46
46
  if (isEditingAllowed) onallow()
47
47
  else ondisallow()
48
48
 
49
- onpoll({ injectionsEnabled: !!result.injections_enabled, automationEnabled: !!result.automation_enabled })
49
+ onpoll({ injectionsEnabled: !!result.injections_enabled, aiEnabled: !!result.ai_enabled })
50
50
  }
51
51
 
52
52
  function takeOverEditing(): void {
@@ -41,9 +41,9 @@ describe('$lib/api', () => {
41
41
  hash: 'some-hash',
42
42
  url: 'https://some-url',
43
43
  metadata: {
44
- heading: null,
45
- modified_time: null,
46
- published_time: null,
44
+ content_heading: null,
45
+ content_modified_time: null,
46
+ content_published_time: null,
47
47
  },
48
48
  page_text: 'Some text',
49
49
  }),
@@ -128,7 +128,7 @@ describe('$lib/api', () => {
128
128
 
129
129
  describe('pollLinkInjections', () => {
130
130
  it('Should poll endpoint while results are not yet ready when requireCompletedResults is true', async () => {
131
- fakeFetch({ response: { automation_enabled: true, ai_running: true } })
131
+ fakeFetch({ response: { ai_enabled: true, ai_running: true } })
132
132
 
133
133
  pollLinkInjections('Some text', { requireCompletedResult: true, pollInterval: 500 })
134
134
 
@@ -142,7 +142,7 @@ describe('$lib/api', () => {
142
142
  })
143
143
 
144
144
  it('Should call given onpoll function when polling', async () => {
145
- fakeFetch({ response: { automation_enabled: true, ai_running: true } })
145
+ fakeFetch({ response: { ai_enabled: true, ai_running: true } })
146
146
 
147
147
  const onpoll = vi.fn()
148
148
  pollLinkInjections('Some text', { requireCompletedResult: true, pollInterval: 500, onpoll })
@@ -159,7 +159,7 @@ describe('$lib/api', () => {
159
159
  })
160
160
 
161
161
  it('Should stop polling if replacements are ready', async () => {
162
- const response = { automation_enabled: true, ai_running: false, link_injections: [{ title: 'value' }] }
162
+ const response = { ai_enabled: true, ai_running: false, manual_injections: [{ title: 'value' }] }
163
163
  fakeFetch({ response })
164
164
 
165
165
  const result = await pollLinkInjections('Some text', { requireCompletedResult: true, pollInterval: 500 })
@@ -172,7 +172,7 @@ describe('$lib/api', () => {
172
172
  })
173
173
 
174
174
  it('Should stop polling if max limit was exceeded', async () => {
175
- fakeFetch({ response: { automation_enabled: true, ai_running: true } })
175
+ fakeFetch({ response: { ai_enabled: true, ai_running: true } })
176
176
 
177
177
  await pollLinkInjections('Some text', { requireCompletedResult: true, pollInterval: 200, maxTries: 2 })
178
178
 
@@ -191,11 +191,11 @@ describe('$lib/api', () => {
191
191
  expect(global.fetch).toHaveBeenCalledTimes(2)
192
192
  })
193
193
 
194
- it('Should return empty array if link_injections are null', async () => {
195
- fakeFetch({ response: { link_injections: null, ai_injections: null } })
194
+ it('Should return empty array if manual_injections are null', async () => {
195
+ fakeFetch({ response: { manual_injections: null, ai_injections: null } })
196
196
 
197
197
  const result = await pollLinkInjections('Some text')
198
- expect(result).toEqual(expect.objectContaining({ link_injections: [], ai_injections: [] }))
198
+ expect(result).toEqual(expect.objectContaining({ manual_injections: [], ai_injections: [] }))
199
199
  })
200
200
  })
201
201
 
@@ -88,7 +88,7 @@ describe('$routes/+page.svelte', () => {
88
88
  window.PlayPilotLinkInjections = { editorial_token: 'some-token' }
89
89
 
90
90
  // @ts-ignore
91
- vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_running: true, injections_ready: true, page_updated: false, automation_enabled: true, injections_enabled: true, ai_injections: [], link_injections: [] })
91
+ vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_running: true, injections_ready: true, ai_enabled: true, injections_enabled: true, ai_injections: [], manual_injections: [] })
92
92
 
93
93
  render(page)
94
94
 
@@ -98,14 +98,14 @@ describe('$routes/+page.svelte', () => {
98
98
  })
99
99
  })
100
100
 
101
- it('Should continue response while in editorial mode and ai_running and automation_enabled are true', async () => {
101
+ it('Should continue response while in editorial mode and ai_running and ai_enabled are true', async () => {
102
102
  // @ts-ignore
103
103
  window.PlayPilotLinkInjections = { editorial_token: 'some-token' }
104
104
 
105
105
  // @ts-ignore
106
106
  vi.mocked(pollLinkInjections).mockImplementationOnce(async () => {
107
107
  await new Promise(res => setTimeout(res, 100))
108
- return { ai_injections: [], link_injections: [], ai_running: true, automation_enabled: true }
108
+ return { ai_injections: [], manual_injections: [], ai_running: true, ai_enabled: true }
109
109
  })
110
110
 
111
111
  render(page)
@@ -113,7 +113,7 @@ describe('$routes/+page.svelte', () => {
113
113
  // @ts-ignore
114
114
  vi.mocked(pollLinkInjections).mockImplementationOnce(async () => {
115
115
  await new Promise(res => setTimeout(res, 100))
116
- return { ai_injections: ['a'], link_injections: ['b'], ai_running: true, automation_enabled: true }
116
+ return { ai_injections: ['a'], manual_injections: ['b'], ai_running: true, ai_enabled: true }
117
117
  })
118
118
 
119
119
  await waitFor(() => {
@@ -124,14 +124,14 @@ describe('$routes/+page.svelte', () => {
124
124
  expect(injectLinksInDocument).toHaveBeenCalledOnce()
125
125
  })
126
126
 
127
- it('Should not continue response while in editorial mode but ai_running or automation_enabled are not true', async () => {
127
+ it('Should not continue response while in editorial mode but ai_running or ai_enabled are not true', async () => {
128
128
  // @ts-ignore
129
129
  window.PlayPilotLinkInjections = { editorial_token: 'some-token' }
130
130
 
131
131
  // @ts-ignore
132
132
  vi.mocked(pollLinkInjections).mockImplementationOnce(async () => {
133
133
  await new Promise(res => setTimeout(res, 100))
134
- return { ai_injections: [], link_injections: [], ai_running: false, automation_enabled: false }
134
+ return { ai_injections: [], manual_injections: [], ai_running: false, ai_enabled: false }
135
135
  })
136
136
 
137
137
  render(page)
@@ -141,11 +141,11 @@ describe('$routes/+page.svelte', () => {
141
141
  expect(pollLinkInjections).toHaveBeenCalledTimes(1)
142
142
  })
143
143
 
144
- it('Should not continue response or inject while not in editorial mode and ai_running and automation_enabled are true', async () => {
144
+ it('Should not continue response or inject while not in editorial mode and ai_running and ai_enabled are true', async () => {
145
145
  // @ts-ignore
146
146
  vi.mocked(pollLinkInjections).mockImplementationOnce(async () => {
147
147
  await new Promise(res => setTimeout(res, 100))
148
- return { ai_injections: [], link_injections: [], ai_running: true, automation_enabled: true }
148
+ return { ai_injections: [], manual_injections: [], ai_running: true, ai_enabled: true }
149
149
  })
150
150
 
151
151
  render(page)
@@ -160,7 +160,7 @@ describe('$routes/+page.svelte', () => {
160
160
  // @ts-ignore
161
161
  vi.mocked(pollLinkInjections).mockImplementationOnce(async () => {
162
162
  await new Promise(res => setTimeout(res, 100))
163
- return { ai_injections: [], link_injections: [], ai_running: false, automation_enabled: true }
163
+ return { ai_injections: [], manual_injections: [], ai_running: false, ai_enabled: true }
164
164
  })
165
165
 
166
166
  render(page)
@@ -283,7 +283,7 @@ describe('$routes/+page.svelte', () => {
283
283
 
284
284
  it('Should set tracking sids after response is fetched', async () => {
285
285
  // @ts-ignore
286
- vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [], link_injections: [], domain_sid: 'some-domain', organization_sid: 'some-organization' })
286
+ vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [], manual_injections: [], domain_sid: 'some-domain', organization_sid: 'some-organization' })
287
287
 
288
288
  render(page)
289
289
 
@@ -305,7 +305,7 @@ describe('$routes/+page.svelte', () => {
305
305
 
306
306
  it('Should track injection event when injections are injected', async () => {
307
307
  // @ts-ignore
308
- vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [generateInjection('a', 'b')], link_injections: [{ ...generateInjection('a', 'b'), manual: true }] })
308
+ vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [generateInjection('a', 'b')], manual_injections: [{ ...generateInjection('a', 'b'), manual: true }] })
309
309
  vi.mocked(injectLinksInDocument).mockReturnValueOnce([generateInjection('a', 'b'), { ...generateInjection('a', 'b'), manual: true }])
310
310
 
311
311
  render(page)
@@ -320,7 +320,7 @@ describe('$routes/+page.svelte', () => {
320
320
 
321
321
  it('Should not track injection event when no injections were successful', async () => {
322
322
  // @ts-ignore
323
- vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [generateInjection('a', 'b')], link_injections: [{ ...generateInjection('a', 'b'), manual: true }] })
323
+ vi.mocked(pollLinkInjections).mockResolvedValueOnce({ ai_injections: [generateInjection('a', 'b')], manual_injections: [{ ...generateInjection('a', 'b'), manual: true }] })
324
324
  vi.mocked(injectLinksInDocument).mockReturnValueOnce([{ ...generateInjection('a', 'b'), manual: true, failed: true }])
325
325
 
326
326
  render(page)
@@ -11,8 +11,8 @@ describe('AIIndicator.svelte', () => {
11
11
  expect(queryByTestId('loading-bar')).not.toBeTruthy()
12
12
  })
13
13
 
14
- it('Should show running when aiRunning and automationEnabled are true', () => {
15
- const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, automationEnabled: true })
14
+ it('Should show running when aiRunning and aiEnabled are true', () => {
15
+ const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, aiEnabled: true })
16
16
 
17
17
  expect(getByText('AI links are currently processing.', { exact: false })).toBeTruthy()
18
18
  expect(getByTestId('loading-bar')).toBeTruthy()
@@ -26,34 +26,34 @@ describe('AIIndicator.svelte', () => {
26
26
  })
27
27
 
28
28
  it('Should show given message if aiRunning is true', () => {
29
- const { getByText } = render(AIIndicator, { aiRunning: true, automationEnabled: true, message: 'Some message' })
29
+ const { getByText } = render(AIIndicator, { aiRunning: true, aiEnabled: true, message: 'Some message' })
30
30
 
31
31
  expect(getByText('Some message')).toBeTruthy()
32
32
  })
33
33
 
34
34
  it('Should set progress bar to given progress percentage', () => {
35
- const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, automationEnabled: true, percentage: 25 })
35
+ const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, aiEnabled: true, percentage: 25 })
36
36
 
37
37
  expect(getByTestId('loading-bar').style.width).toBe('25%')
38
38
  expect(getByText('25%')).toBeTruthy()
39
39
  })
40
40
 
41
41
  it('Should floor the percentage label if a decimal is given', () => {
42
- const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, automationEnabled: true, percentage: 25.55 })
42
+ const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, aiEnabled: true, percentage: 25.55 })
43
43
 
44
44
  expect(getByTestId('loading-bar').style.width).toBe('25.55%')
45
45
  expect(getByText('25%')).toBeTruthy()
46
46
  })
47
47
 
48
48
  it('Should limit progress to minimum value in loading bar style only', () => {
49
- const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, automationEnabled: true, percentage: 0 })
49
+ const { getByText, getByTestId } = render(AIIndicator, { aiRunning: true, aiEnabled: true, percentage: 0 })
50
50
 
51
51
  expect(getByTestId('loading-bar').style.width).toBe('3%')
52
52
  expect(getByText('0%')).toBeTruthy()
53
53
  })
54
54
 
55
55
  it('Should show message after aiInjectionsCount has changed and aiRunning is false', async () => {
56
- const { getByText, rerender } = render(AIIndicator, { aiRunning: true, automationEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
56
+ const { getByText, rerender } = render(AIIndicator, { aiRunning: true, aiEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
57
57
  rerender({ aiRunning: false, aiInjectionsCount: 5 })
58
58
 
59
59
  await waitFor(() => {
@@ -63,7 +63,7 @@ describe('AIIndicator.svelte', () => {
63
63
  })
64
64
 
65
65
  it('Should show message after aiInjectionsCount has changed and aiRunning is false but no new injections were found', async () => {
66
- const { getByText, rerender } = render(AIIndicator, { aiRunning: true, automationEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
66
+ const { getByText, rerender } = render(AIIndicator, { aiRunning: true, aiEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
67
67
  rerender({ aiRunning: false, aiInjectionsCount: 0 })
68
68
 
69
69
  await waitFor(() => {
@@ -73,7 +73,7 @@ describe('AIIndicator.svelte', () => {
73
73
  })
74
74
 
75
75
  it('Should dismiss entire element when dismiss button is pressed', async () => {
76
- const { getByText, rerender, queryByTestId } = render(AIIndicator, { aiRunning: true, automationEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
76
+ const { getByText, rerender, queryByTestId } = render(AIIndicator, { aiRunning: true, aiEnabled: true, message: 'Some message', aiInjectionsCount: 0 })
77
77
  rerender({ aiRunning: false, aiInjectionsCount: 5 })
78
78
 
79
79
  expect(queryByTestId('ai-indicator')).toBeTruthy()
@@ -38,7 +38,7 @@ describe('Session.svelte', () => {
38
38
  })
39
39
 
40
40
  it('Should not show alert and call given onallow function when user is allowed to edit', async () => {
41
- vi.mocked(fetchAsSession).mockResolvedValueOnce({ automation_enabled: true, injections_enabled: true })
41
+ vi.mocked(fetchAsSession).mockResolvedValueOnce({ ai_enabled: true, injections_enabled: true })
42
42
  vi.mocked(isAllowedToEdit).mockReturnValueOnce(true)
43
43
 
44
44
  const { queryByText } = render(Session, { onallow, ondisallow })
@@ -52,7 +52,7 @@ describe('Session.svelte', () => {
52
52
  })
53
53
 
54
54
  it('Should show alert and call given ondisallow function if user is not allowed to edit', async () => {
55
- vi.mocked(fetchAsSession).mockResolvedValueOnce({ automation_enabled: true, injections_enabled: true })
55
+ vi.mocked(fetchAsSession).mockResolvedValueOnce({ ai_enabled: true, injections_enabled: true })
56
56
  vi.mocked(isAllowedToEdit).mockReturnValueOnce(false)
57
57
 
58
58
  const { getByText } = render(Session, { onallow, ondisallow })
@@ -65,7 +65,7 @@ describe('Session.svelte', () => {
65
65
  })
66
66
 
67
67
  it('Should call given ontakeover function when button is alert is clicked', async () => {
68
- vi.mocked(fetchAsSession).mockResolvedValueOnce({ automation_enabled: true, injections_enabled: true })
68
+ vi.mocked(fetchAsSession).mockResolvedValueOnce({ ai_enabled: true, injections_enabled: true })
69
69
  vi.mocked(isAllowedToEdit).mockReturnValueOnce(false)
70
70
 
71
71
  const ontakeover = vi.fn()