import{u as N,z as _,a$ as E,b0 as I,b1 as T,j as e,b2 as V,R as w,aF as k,b3 as z,o as C,p as A,O as f,Q as x,Z as h,b4 as P,ar as D,e as M}from"./app-BgLa5dit.js";import{P as K,M as W}from"./CanLAf7a.chunk.js";import{H as S}from"./DnrOMuWH.chunk.js";import{C as F}from"./CULwvqVp.chunk.js";import"./B0KtsevF.chunk.js";import"./IEOSPmnY.chunk.js";import"./C8_78Eqq.chunk.js";import"./Bkj-W53y.chunk.js";import"./KIVqng-q.chunk.js";import"./DIopWku2.chunk.js";import"./VIUZq4Vp.chunk.js";import"./B3xA170I.chunk.js";import"./t8cVFCZO.chunk.js";import"./Cu2-dDll.chunk.js";import"./kOrk-qeI.chunk.js";const O="_container_xmv3v_1",q="_close_xmv3v_4",B="_drag_xmv3v_13",c={container:O,close:q,drag:B},d=270,b=480,R=15;function de(t){const[n,l]=N("pip:pos",{right:15,bottom:15},{storage:_.SessionStorage});function i(r){let s=n.right-r.delta.x,o=n.bottom-r.delta.y;window.innerHeight-n.bottom-d+r.delta.y<R&&(o=window.innerHeight-d-R),s<-240&&(s=-240),o<-135&&(o=-135),s>window.innerWidth-b/2&&(s=window.innerWidth-b/2),o>window.innerHeight-d/2&&(o=window.innerHeight-d/2),l({right:s,bottom:o})}const g=E(I,{activationConstraint:{distance:10}}),m=T(g);return e.jsx(V,{onDragEnd:i,sensors:m,children:e.jsx(G,{...t,pos:n})})}function G(t){var v,j;const[n,l]=w.useState(!1),i=k(),{attributes:g,listeners:m,setNodeRef:r,transform:s}=z({id:"pip"}),o={right:`${t.pos.right}px`,bottom:`${t.pos.bottom}px`,width:`${b}px`,height:`${d}px`,transform:s?`translate3d(${s.x}px, ${s.y}px, 0)`:""},a=C(A.getAssemblyLineVideo(t.videoId)),y=C(K.createViewKey(t.videoId,W.MasterObject));function p(){return!y.hasCompleted||!a.hasCompleted}function L(){var u;return(u=a.data.regions)==null?void 0:u.map(H=>M.mapContentRegionToLabel(H)).join(" / ")}w.useEffect(()=>{n&&p()&&l(!1)},[p()]),w.useEffect(()=>()=>{i==null||i.resetPlayer()},[]);function $(u){l(!0),i&&i.setPlayerRef(u)}return e.jsx("div",{className:`${c.container} position-fixed box-shadow rounded-3 bg-white overflow-hidden`,style:o,children:y.hasError||a.hasError?e.jsxs("div",{className:"d-flex align-items-center justify-content-center h-100 text-center px-3",children:[e.jsx(f,{ref:r,...m,...g,onClick:t.close,className:`${c.drag} d-flex align-items-center justify-content-center rounded-circle box-shadow`,children:e.jsx(x,{svg:S,size:h.Large})}),(v=a.data.regions)!=null&&v.length?e.jsxs("p",{children:["This video cannot be viewed from your account. Please log into an account for one of the following regions: ",L()]}):e.jsx("p",{children:"This video cannot be viewed from your account because it has not been added to any libraries yet."}),e.jsx(f,{onClick:t.close,className:`${c.close} d-flex align-items-center justify-content-center rounded-circle box-shadow`,children:e.jsx(x,{svg:P,size:h.Large})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:n?"d-none":"d-flex align-items-center justify-content-center h-100",children:e.jsx(D,{})}),!p()&&e.jsxs("div",{className:n?"":"d-none",children:[e.jsx(f,{ref:r,...m,...g,onClick:t.close,className:`${c.drag} d-flex align-items-center justify-content-center rounded-circle box-shadow`,children:e.jsx(x,{svg:S,size:h.Large})}),e.jsx(F,{viewKey:(j=y.data)==null?void 0:j.viewKey,playerApi:new URL(ClickView.Config.Urls.PlayerApi),hotkeyElQuerySelector:"body",onReady:$,eventLogging:!1,autoplay:!0}),e.jsx(f,{onClick:t.close,className:`${c.close} d-flex align-items-center justify-content-center rounded-circle box-shadow`,children:e.jsx(x,{svg:P,size:h.Large})})]})]})})}export{de as PictureInPictureView};
//# sourceMappingURL=Z6f496UF.chunk.js.map
