gearboxdownloadmodal 9.5.13 → 9.5.14
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.
- package/dist/index.es.js +90 -89
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -89,7 +89,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof e.getDerivedStat
|
|
|
89
89
|
transform: rotate(360deg);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
`}),A.jsx("p",{style:{color:"#475569",fontSize:"14px",fontWeight:500},children:"Compressing your playable..."})]}):A.jsxs("p",{style:{color:"#475569",fontSize:"14px",lineHeight:"1.625",marginBottom:"2rem"},children:[!c&&a==="Flex"&&A.jsx(A.Fragment,{children:"Compress your playable automatically to meet the size requirements, or Go Back to edit your content manually to reduce the file size."}),!c&&a!=="Flex"&&A.jsx(A.Fragment,{children:"Go Back to reduce your playable's content to meet the size requirements, or click Continue to download anyway"}),c&&A.jsxs(A.Fragment,{children:["Your playable is now under ",Ca," MB and ready to export"]})]}),A.jsxs("div",{style:{display:"flex",gap:"0.75rem",width:"100%"},children:[!p&&A.jsx("button",{onClick:d,style:{flex:1,paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",backgroundColor:"white",border:"2px solid #e2e8f0",color:"#334155",borderRadius:"0.75rem",fontWeight:600,fontSize:"16px",transition:"all 0.2s ease",cursor:"pointer"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#f8fafc",S.currentTarget.style.borderColor="#cbd5e1"},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="white",S.currentTarget.style.borderColor="#e2e8f0"},children:"Go Back"}),!p&&A.jsxs("button",{onClick:()=>{a==="Flex"&&!c?I():e(!1)},style:{flex:1,paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",color:"white",borderRadius:"0.75rem",fontWeight:600,fontSize:"16px",transition:"all 0.2s ease",border:"none",cursor:"pointer",backgroundColor:C,boxShadow:"none"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=E},onMouseLeave:S=>{S.currentTarget.style.backgroundColor=C},children:[a==="Flex"&&p&&!c&&"Compressing...",a==="Flex"&&!p&&!c&&M<2&&"Compress Now",a==="Flex"&&!p&&!c&&M>=2&&"Continue",a!=="Flex"&&!p&&c&&"Export",a!=="Flex"&&"Continue"]})]})]})]})},ic=({onClose:e,url:i,typeOfProduct:t="Playable"})=>{const a=t&&Ai[t]?Ai[t]:Ai.Playable;return A.jsxs("div",{style:{position:"fixed",top:0,left:0,zIndex:50,display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"#00000080"},children:[A.jsx("div",{onClick:e,style:{position:"absolute",zIndex:30,height:"100%",width:"100%"}}),A.jsxs("div",{style:{position:"absolute",zIndex:50,display:"flex",height:"max-content",width:500,flexDirection:"column",gap:"5px",borderRadius:"8px",backgroundColor:"white",padding:"20px"},children:[A.jsx("h1",{style:{textAlign:"center",fontSize:"18px",lineHeight:"24px",minHeight:"48px"},children:A.jsx("a",{style:{fontSize:"12px",display:"block",fontWeight:"normal",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},href:i,children:i})}),A.jsxs("div",{style:{display:"flex",gap:"5px"},children:[A.jsx("button",{onClick:e,style:{flex:1,cursor:"pointer",borderRadius:"4px",borderWidth:"1px",borderColor:"#666666",padding:"2px",fontWeight:"bold"},children:"Close"}),A.jsx("button",{style:{flex:1,cursor:"pointer",borderRadius:"4px",borderWidth:"1px",borderColor:a,backgroundColor:a,padding:"2px",fontWeight:"bold",color:"white"},onClick:async o=>{o.preventDefault(),o.stopPropagation(),e()},children:"Copy"})]})]})]})},ec=({visible:e,closeModal:i,versionId:t,selectedVersionIds:a,gameId:o,versionName:r,playableId:s,typeOfProduct:n,api:l,user:m,title:q,iframeUrl:p,handleDownloadError:u,fetchFileUrl:c,copyLinkUrl:K,fusionData:d,onNameChange:I})=>{const[C,E]=Z.useState(window.innerWidth),[M,J]=Z.useState(!1),[S,b]=Z.useState(p),[w,Q]=Z.useState(!1),[T,X]=Z.useState(!0),[B,v]=Z.useState(null),[P,y]=Z.useState(""),[L,Y]=Z.useState("Loading..."),[g,W]=Z.useState("Loading..."),[f,V]=Z.useState("game"),[h,R]=Zi(ye),[G,U]=Zi(ia);ls(n,l,y,c,d);const D=async()=>{let F=await sn(l,n,t);if(!F){pt("Networks not found");return}F=F.map(j=>(j.name=j.id,j)),R(F),U(F.map(j=>j.id).filter(j=>j!=="default")),le(t,"preview",null,null,!1).then(j=>{J(!0),b(c+"/"+j.url),(n==="Flex"||n==="Ready"||n==="Playable"||n==="Fusion")&&(j.size>=5?Q(!0):Q(!1),v(j.size)),X(!1)})};return Z.useEffect(()=>{e?M||(D(),J(!0)):(J(!1),b(""))},[e]),Z.useEffect(()=>{const F=()=>{E(window.innerWidth)};return window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F)}},[]),T&&e?A.jsx(A.Fragment,{children:A.jsx(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i(),n==="Flex"&&X(!0)},style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"0.75rem",backgroundColor:"white",zIndex:50,height:C>1440?"700px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",maxWidth:"95vw",maxHeight:"95vh",overflow:"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:A.jsx("div",{style:{display:"flex",height:C>1440?"700px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",alignItems:"center",justifyContent:"center"},children:A.jsx("img",{style:{width:"100px",height:"100px"},src:Qe,alt:"pf-logo-gif"})})})}):T&&n==="Flex"?null:A.jsxs("div",{onMouseDown:F=>{F.stopPropagation()},onMouseUp:F=>{F.stopPropagation()},children:[w&&e&&A.jsx($u,{setIsExceedingFileSizeAccepted:Q,closeModal:i,setLoading:X,typeOfProduct:n,versionId:t,fileSize:B,setFileSize:v,user:m,compressApi:l.includes(".com")?"https://compress.playablefactory.com":"https://compress.playablefactory.app",producerApi:l.includes(".com")?"https://compress.playablefactory.com":"https://compress.playablefactory.app",api:l}),!w&&A.jsxs(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i(),n==="Flex"&&X(!0)},style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"0.75rem",backgroundColor:"white",zIndex:50,height:C>1440?"650px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",maxWidth:"95vw",maxHeight:"95vh",overflow:C<768?"auto":"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:[A.jsx("div",{style:{position:"absolute",top:"1.25rem",right:"1.25rem",zIndex:50},children:A.jsx("button",{onClick:()=>{i(),n==="Flex"&&X(!0)},style:{padding:"0.5rem",borderRadius:"9999px",transition:"background-color 0.2s",backgroundColor:"transparent"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor="#F3F4F6"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent"},children:A.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[A.jsx("path",{d:"M18 6 6 18"}),A.jsx("path",{d:"m6 6 12 12"})]})})}),A.jsxs(zo,{children:[a&&a.length>0?A.jsx(au,{selectedVersionIds:a,api:l,fetchFileUrl:c}):M?A.jsx(Sq,{versionName:r,versionId:t,playableId:s||"",typeOfProduct:n,iframeUrl:S,api:l,fetchFileUrl:c,copyLinkUrl:K,setSafariCopyLink:y,iosLink:L,androidLink:g,urlType:f,onNameChange:I}):A.jsx(A.Fragment,{children:A.jsx("div",{style:{display:"flex",width:"300px",flexDirection:"column",justifyContent:"center",alignItems:"center",padding:"5px",height:C>1440?"650px":"625px",borderRadius:"0px 0px 0px 16px",marginTop:"20px"},children:A.jsx("img",{width:"75px",height:"75px",src:Qe,alt:"pf-logo-gif"})})}),A.jsx(tu,{visible:e,versionId:t,playableId:s,gameId:o,typeOfProduct:n,api:l,user:m,title:q,handleDownloadError:u,fetchFileUrl:c,fileSize:B,setFileSize:v,setSafariCopyLink:y,iosLink:L,androidLink:g,setIosLink:Y,setAndroidLink:W,urlType:f,setUrlType:V,selectedVersionIds:a})]}),A.jsx(Aa,{}),P&&A.jsx(ic,{onClose:()=>{xe(P),y("")},url:P,typeOfProduct:n})]})]})},zn=({children:e,className:i,onClickDownload:t,downloading:a,disabled:o,variant:r="primary",isCopied:s=!1})=>A.jsx("button",{style:{backgroundImage:r==="secondary"?"":"linear-gradient(to right, #06b6d4, #14b8a6)"},onClick:t,className:i,disabled:a||o,children:s?A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:A.jsx("polyline",{points:"20 6 9 17 4 12"})}):e}),Tn=({checked:e,id:i,checkedColor:t,className:a})=>{const[o,r]=Z.useState(e);Z.useEffect(()=>{r(e)},[e]);const s=()=>{r(!o)};return A.jsx("div",{style:{display:"inline-flex",alignItems:"center"},children:A.jsxs("label",{onClick:s,style:{position:"relative",display:"flex",cursor:"pointer",alignItems:"center"},htmlFor:i,children:[A.jsx("input",{type:"checkbox",className:` rounded-md ${a} ${o?t??"bg-cyan-500":"bg-slate-700"}`,style:{border:"0px",position:"relative",height:"20px",width:"20px",cursor:"pointer",appearance:"none",transition:"all 200ms ease-in-out",opacity:1},id:i,checked:o,onChange:s}),A.jsxs("div",{style:{pointerEvents:"none",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"white",opacity:o?1:0,transition:"opacity ease-in-out"},children:[A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{height:"14px",width:"14px"},viewBox:"0 0 20 20",fill:"white",stroke:"white",strokeWidth:"1",children:A.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})," "]})]})})};function tc({api:e,downloadState:i,user:t,typeOfProduct:a,handleDownloadError:o,shouldDownloadMultipleIds:r,game:s,fetchFileUrl:n,urlType:l,isMoloco:m,setCdnModal:q,generateCDN:p,setDownloadingMolocoHtml:u,setDownloadingMoloco:c,urls:K,versionId:d,isTest:I,isGoogle:C,submitCustomUrls:E,selectedGtmThresholds:M}){return async(S,b,w)=>{if(console.log("downloadids",r),console.log("selectedGtmThresholds",M),i==null||i(!0),a==="Flex"&&t.flex===!1&&t.customer!=="playableFactoryInternal"){o("|ACCESS|"),i==null||i(!1);return}if(r&&r.length>0&&b==="download")try{if(!s||!s._id)throw new Error("Game data is required for multi-version download");let T;M&&(M==null?void 0:M.length)>0&&(T=M==null?void 0:M.map(Y=>Y.toString()+" click"));const X=await It(e,s._id,{networks:[S],versions:r,interactions:T}),B=n+"/"+X.url,P=await(await fetch(B)).blob(),y=window.URL.createObjectURL(P),L=document.createElement("a");return L.href=y,L.download=X.url.split("/").pop()||"download.zip",document.body.appendChild(L),L.click(),window.URL.revokeObjectURL(y),document.body.removeChild(L),i==null||i(!1),X.url}catch(T){console.log("multi-version single network download error",T),i==null||i(!1),o(T.message,T);return}const Q={molocoGenerateHtml:!1,urlType:l,responsiveType:"responsive"};if(m?b==="copy"?(u==null||u(!0),b="download",Q.molocoGenerateHtml=!0):c==null||c(!0):C&&(Q.responsiveType=w),S==="cdn"){q(!0),await p(!0),i==null||i(!1);return}if(S==="adikteev"&&(b="copy"),!!d)return new Promise((T,X)=>{le(d,S,E?K:null,b,I,Q).then(B=>{i==null||i(!1),T(B),u==null||u(!1),c==null||c(!1)}).catch(B=>{i==null||i(!1),o(B.message,B),X(B),u==null||u(!1),c==null||c(!1)})})}}const ac=({id:e,imageUrl:i,handleCardClick:t,selected:a,name:o,networkVersionSize:r,fileSizeLoading:s,showCheckBox:n,typeOfProduct:l,versionId:m,api:q,handleDownloadError:p,fetchFileUrl:u,urls:c,game:K,setIsConfirmActive:d,creditDownload:I,getDownloadCount:C,disabled:E,user:M,setSafariCopyLink:J,isTest:S,urlType:b,setCdnModal:w,generateCDN:Q,cdnUrl:T,selectedVersionIds:X,downloadableVersionIds:B,setDownloadableVersionIds:v,selectedGtmThresholds:P})=>{const[y,L]=Z.useState(!1),[Y,g]=Z.useState(""),[W,f]=Z.useState(!1),[V,h]=Z.useState(!1);Z.useState(!1);const[R,G]=Z.useState("download"),[U,D]=Z.useState(!1),[F,j]=Z.useState(!1);Z.useState(!1),Z.useState(!1);const[H,$]=Z.useState(!1),[ii,di]=Zi(ye),[x,hi]=Zi(ue),z=l==="Playable"?x:!0,ri=()=>{t(e)},gi=o==="moloco"||o==="molocoV2",yi=o==="google",N=ii.find(_=>_.name===o),O=tc({api:q,shouldDownloadMultipleIds:B,downloadState:L,handleDownloadError:p,user:M,typeOfProduct:l,game:K,fetchFileUrl:u,urlType:b,urls:c,selectedGtmThresholds:P,isMoloco:gi,isGoogle:yi,setCdnModal:w,setDownloadingMoloco:D,setDownloadingMolocoHtml:j,versionId:m,generateCDN:Q,submitCustomUrls:z,isTest:S});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",cursor:"pointer",pointerEvents:"auto"},className:`gap-3 rounded-xl h-[6.2rem] transition-all border ${a?"border-cyan-500/50 hover:border-cyan-400/50":"border-slate-700/50 hover:border-slate-600"}`,onClick:ri,children:[A.jsxs("div",{className:"mt-4 justify-between px-4",style:{display:"flex"},children:[A.jsx("p",{className:"justify-start text-white font-medium",children:N!=null&&N.name?N.name[0].toUpperCase()+N.name.slice(1):""}),A.jsx(Tn,{checked:a,id:e})]}),A.jsxs("div",{className:"px-4 gap-2",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:[A.jsx(zn,{className:"flex h-10 items-center justify-center border-0 duration-200 w-full rounded-xl text-white font-medium text-xs hover:shadow-lg hover:shadow-cyan-500/25 transition-all ",downloading:y,onClickDownload:async _=>{_.stopPropagation(),console.log("user in onclickdownload",M),g("download");const qi=c.iosUrl,ni=c.googleUrl;o==="cdn"&&I&&I.willSpendCredit&&!T||o!=="cdn"&&I&&I.willSpendCredit?(d(!0),G("download"),f(!0)):["Playable","Flex","Ready"].includes(l)&&(!qi||!ni)?(d(!0),h(!0)):(h(!1),f(!1),await O(o,"download"))},children:y?A.jsx(Ke,{}):A.jsxs("div",{className:"flex flex-row gap-1",children:[A.jsx(ct,{className:"w-5 h-5"}),A.jsx("p",{className:"text-sm ",children:"Download"})]})}),N&&N.downloadType.includes("copy")&&A.jsx(zn,{className:"flex items-center justify-center rounded-xl border-0 text-sm font-medium transition-all duration-200 bg-slate-700 hover:bg-slate-600 w-[4.2rem] h-10 text-white ",variant:"secondary",onClickDownload:async _=>{if(_.stopPropagation(),H)return;g("copyLink");const qi=c.iosUrl,ni=c.googleUrl;I&&(I!=null&&I.willSpendCredit)?(G("copy"),d(!0),f(!0)):l!=="Import"&&(!qi||!ni)?(d(!0),h(!0)):(f(!1),h(!1),await O(o,"copy"),$(!0),setTimeout(()=>$(!1),2e3))},disabled:E,isCopied:H,children:A.jsx(_a,{className:"h-5 w-5 ",style:{color:"#a9b4c2"}})})]})]}),W&&A.jsx(Te,{creditConfirmType:R,handleCopyLink:async()=>{h(!1),d(!1),await O(o,"copy")},download:async()=>{h(!1),d(!1),await O(o,"download")},onClose:()=>{f(!1),d(!1)},getDownloadCount:C,typeOfProduct:l})]})},Bn=({...e})=>A.jsx("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 1920 1920",xmlns:"http://www.w3.org/2000/svg",...e,children:A.jsx("path",{d:"M1827.701 303.065 698.835 1431.801 92.299 825.266 0 917.564 698.835 1616.4 1919.869 395.234z",fillRule:"evenodd"})}),oc=({networksVersionTotalSize:e,typeOfProduct:i,onClickMultiDownload:t,multiDownloading:a,selectedCount:o=0})=>A.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",position:"sticky",bottom:"1rem",zIndex:10,width:"100%"},children:a?A.jsx("div",{style:{display:"flex",width:"auto",minWidth:"12rem",height:"2.5rem",borderRadius:"0.5rem",alignItems:"center",justifyContent:"center",padding:"0 1.5rem"},children:A.jsx(Ke,{})}):A.jsxs("button",{style:{backgroundImage:"linear-gradient(to right, #06b6d4, #14b8a6)"},onClick:t,className:`flex items-center gap-2 px-8 py-3 rounded-xl -mb-4\r
|
|
92
|
+
`}),A.jsx("p",{style:{color:"#475569",fontSize:"14px",fontWeight:500},children:"Compressing your playable..."})]}):A.jsxs("p",{style:{color:"#475569",fontSize:"14px",lineHeight:"1.625",marginBottom:"2rem"},children:[!c&&a==="Flex"&&A.jsx(A.Fragment,{children:"Compress your playable automatically to meet the size requirements, or Go Back to edit your content manually to reduce the file size."}),!c&&a!=="Flex"&&A.jsx(A.Fragment,{children:"Go Back to reduce your playable's content to meet the size requirements, or click Continue to download anyway"}),c&&A.jsxs(A.Fragment,{children:["Your playable is now under ",Ca," MB and ready to export"]})]}),A.jsxs("div",{style:{display:"flex",gap:"0.75rem",width:"100%"},children:[!p&&A.jsx("button",{onClick:d,style:{flex:1,paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",backgroundColor:"white",border:"2px solid #e2e8f0",color:"#334155",borderRadius:"0.75rem",fontWeight:600,fontSize:"16px",transition:"all 0.2s ease",cursor:"pointer"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#f8fafc",S.currentTarget.style.borderColor="#cbd5e1"},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="white",S.currentTarget.style.borderColor="#e2e8f0"},children:"Go Back"}),!p&&A.jsxs("button",{onClick:()=>{a==="Flex"&&!c?I():e(!1)},style:{flex:1,paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.75rem",paddingBottom:"0.75rem",color:"white",borderRadius:"0.75rem",fontWeight:600,fontSize:"16px",transition:"all 0.2s ease",border:"none",cursor:"pointer",backgroundColor:C,boxShadow:"none"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=E},onMouseLeave:S=>{S.currentTarget.style.backgroundColor=C},children:[a==="Flex"&&p&&!c&&"Compressing...",a==="Flex"&&!p&&!c&&M<2&&"Compress Now",a==="Flex"&&!p&&!c&&M>=2&&"Continue",a!=="Flex"&&!p&&c&&"Export",a!=="Flex"&&"Continue"]})]})]})]})},ic=({onClose:e,url:i,typeOfProduct:t="Playable"})=>{const a=t&&Ai[t]?Ai[t]:Ai.Playable;return A.jsxs("div",{style:{position:"fixed",top:0,left:0,zIndex:50,display:"flex",height:"100%",width:"100%",alignItems:"center",justifyContent:"center",backgroundColor:"#00000080"},children:[A.jsx("div",{onClick:e,style:{position:"absolute",zIndex:30,height:"100%",width:"100%"}}),A.jsxs("div",{style:{position:"absolute",zIndex:50,display:"flex",height:"max-content",width:500,flexDirection:"column",gap:"5px",borderRadius:"8px",backgroundColor:"white",padding:"20px"},children:[A.jsx("h1",{style:{textAlign:"center",fontSize:"18px",lineHeight:"24px",minHeight:"48px"},children:A.jsx("a",{style:{fontSize:"12px",display:"block",fontWeight:"normal",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},href:i,children:i})}),A.jsxs("div",{style:{display:"flex",gap:"5px"},children:[A.jsx("button",{onClick:e,style:{flex:1,cursor:"pointer",borderRadius:"4px",borderWidth:"1px",borderColor:"#666666",padding:"2px",fontWeight:"bold"},children:"Close"}),A.jsx("button",{style:{flex:1,cursor:"pointer",borderRadius:"4px",borderWidth:"1px",borderColor:a,backgroundColor:a,padding:"2px",fontWeight:"bold",color:"white"},onClick:async o=>{o.preventDefault(),o.stopPropagation(),e()},children:"Copy"})]})]})]})},ec=({visible:e,closeModal:i,versionId:t,selectedVersionIds:a,gameId:o,versionName:r,playableId:s,typeOfProduct:n,api:l,user:m,title:q,iframeUrl:p,handleDownloadError:u,fetchFileUrl:c,copyLinkUrl:K,fusionData:d,onNameChange:I})=>{const[C,E]=Z.useState(window.innerWidth),[M,J]=Z.useState(!1),[S,b]=Z.useState(p),[w,Q]=Z.useState(!1),[T,X]=Z.useState(!0),[B,v]=Z.useState(null),[P,y]=Z.useState(""),[L,Y]=Z.useState("Loading..."),[g,W]=Z.useState("Loading..."),[f,V]=Z.useState("game"),[h,R]=Zi(ye),[G,U]=Zi(ia);ls(n,l,y,c,d);const D=async()=>{let F=await sn(l,n,t);if(!F){pt("Networks not found");return}F=F.map(j=>(j.name=j.id,j)),R(F),U(F.map(j=>j.id).filter(j=>j!=="default")),le(t,"preview",null,null,!1).then(j=>{J(!0),b(c+"/"+j.url),(n==="Flex"||n==="Ready"||n==="Playable"||n==="Fusion")&&(j.size>=5?Q(!0):Q(!1),v(j.size)),X(!1)})};return Z.useEffect(()=>{e?M||(D(),J(!0)):(J(!1),b(""))},[e]),Z.useEffect(()=>{const F=()=>{E(window.innerWidth)};return window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F)}},[]),T&&e?A.jsx(A.Fragment,{children:A.jsx(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i(),n==="Flex"&&X(!0)},style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"0.75rem",backgroundColor:"white",zIndex:50,height:C>1440?"700px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",maxWidth:"95vw",maxHeight:"95vh",overflow:"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:A.jsx("div",{style:{display:"flex",height:C>1440?"700px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",alignItems:"center",justifyContent:"center"},children:A.jsx("img",{style:{width:"100px",height:"100px"},src:Qe,alt:"pf-logo-gif"})})})}):T&&n==="Flex"?null:A.jsxs("div",{onMouseDown:F=>{F.stopPropagation()},onMouseUp:F=>{F.stopPropagation()},children:[w&&e&&A.jsx($u,{setIsExceedingFileSizeAccepted:Q,closeModal:i,setLoading:X,typeOfProduct:n,versionId:t,fileSize:B,setFileSize:v,user:m,compressApi:l.includes(".com")?"https://compress.playablefactory.com":"https://compress.playablefactory.app",producerApi:l.includes(".com")?"https://compress.playablefactory.com":"https://compress.playablefactory.app",api:l}),!w&&A.jsxs(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i(),n==="Flex"&&X(!0)},style:{content:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"0.75rem",backgroundColor:"white",zIndex:50,height:C>1440?"650px":C<768?"90vh":"650px",width:C>1440?"965px":C<768?"95vw":"970px",maxWidth:"95vw",maxHeight:"95vh",overflow:C<768?"auto":"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:[A.jsx("div",{style:{position:"absolute",top:"1.25rem",right:"1.25rem",zIndex:50},children:A.jsx("button",{onClick:()=>{i(),n==="Flex"&&X(!0)},style:{padding:"0.5rem",borderRadius:"9999px",transition:"background-color 0.2s",backgroundColor:"transparent"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor="#F3F4F6"},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent"},children:A.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[A.jsx("path",{d:"M18 6 6 18"}),A.jsx("path",{d:"m6 6 12 12"})]})})}),A.jsxs(zo,{children:[a&&a.length>0?A.jsx(au,{selectedVersionIds:a,api:l,fetchFileUrl:c}):M?A.jsx(Sq,{versionName:r,versionId:t,playableId:s||"",typeOfProduct:n,iframeUrl:S,api:l,fetchFileUrl:c,copyLinkUrl:K,setSafariCopyLink:y,iosLink:L,androidLink:g,urlType:f,onNameChange:I}):A.jsx(A.Fragment,{children:A.jsx("div",{style:{display:"flex",width:"300px",flexDirection:"column",justifyContent:"center",alignItems:"center",padding:"5px",height:C>1440?"650px":"625px",borderRadius:"0px 0px 0px 16px",marginTop:"20px"},children:A.jsx("img",{width:"75px",height:"75px",src:Qe,alt:"pf-logo-gif"})})}),A.jsx(tu,{visible:e,versionId:t,playableId:s,gameId:o,typeOfProduct:n,api:l,user:m,title:q,handleDownloadError:u,fetchFileUrl:c,fileSize:B,setFileSize:v,setSafariCopyLink:y,iosLink:L,androidLink:g,setIosLink:Y,setAndroidLink:W,urlType:f,setUrlType:V,selectedVersionIds:a})]}),A.jsx(Aa,{}),P&&A.jsx(ic,{onClose:()=>{xe(P),y("")},url:P,typeOfProduct:n})]})]})},zn=({children:e,className:i,onClickDownload:t,downloading:a,disabled:o,variant:r="primary",isCopied:s=!1})=>A.jsx("button",{style:{backgroundImage:r==="secondary"?"":"linear-gradient(to right, #06b6d4, #14b8a6)"},onClick:t,className:i,disabled:a||o,children:s?A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:A.jsx("polyline",{points:"20 6 9 17 4 12"})}):e}),Tn=({checked:e,id:i,checkedColor:t,className:a})=>{const[o,r]=Z.useState(e);Z.useEffect(()=>{r(e)},[e]);const s=()=>{r(!o)};return A.jsx("div",{style:{display:"inline-flex",alignItems:"center"},children:A.jsxs("label",{onClick:s,style:{position:"relative",display:"flex",cursor:"pointer",alignItems:"center"},htmlFor:i,children:[A.jsx("input",{type:"checkbox",className:` rounded-md ${a} ${o?t??"bg-cyan-500":"bg-slate-700"}`,style:{border:"0px",position:"relative",height:"20px",width:"20px",cursor:"pointer",appearance:"none",transition:"all 200ms ease-in-out",opacity:1},id:i,checked:o,onChange:s}),A.jsxs("div",{style:{pointerEvents:"none",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"white",opacity:o?1:0,transition:"opacity ease-in-out"},children:[A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{height:"14px",width:"14px"},viewBox:"0 0 20 20",fill:"white",stroke:"white",strokeWidth:"1",children:A.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})," "]})]})})};function tc({api:e,downloadState:i,user:t,typeOfProduct:a,handleDownloadError:o,shouldDownloadMultipleIds:r,game:s,fetchFileUrl:n,urlType:l,isMoloco:m,setCdnModal:q,generateCDN:p,setDownloadingMolocoHtml:u,setDownloadingMoloco:c,urls:K,versionId:d,isTest:I,isGoogle:C,submitCustomUrls:E,selectedGtmThresholds:M}){return async(S,b,w)=>{if(console.log("downloadids",r),console.log("selectedGtmThresholds",M),i==null||i(!0),a==="Flex"&&t.flex===!1&&t.customer!=="playableFactoryInternal"){o("|ACCESS|"),i==null||i(!1);return}if(r&&r.length>0&&b==="download")try{if(!s||!s._id)throw new Error("Game data is required for multi-version download");let T;M&&(M==null?void 0:M.length)>0&&(T=M==null?void 0:M.map(Y=>Y.toString()+" click"));const X=await It(e,s._id,{networks:[S],versions:r,interactions:T}),B=n+"/"+X.url,P=await(await fetch(B)).blob(),y=window.URL.createObjectURL(P),L=document.createElement("a");return L.href=y,L.download=X.url.split("/").pop()||"download.zip",document.body.appendChild(L),L.click(),window.URL.revokeObjectURL(y),document.body.removeChild(L),i==null||i(!1),X.url}catch(T){console.log("multi-version single network download error",T),i==null||i(!1),o(T.message,T);return}const Q={molocoGenerateHtml:!1,urlType:l,responsiveType:"responsive"};if(m?b==="copy"?(u==null||u(!0),b="download",Q.molocoGenerateHtml=!0):c==null||c(!0):C&&(Q.responsiveType=w),S==="cdn"){q(!0),await p(!0),i==null||i(!1);return}if(S==="adikteev"&&(b="copy"),!!d)return new Promise((T,X)=>{le(d,S,E?K:null,b,I,Q).then(B=>{i==null||i(!1),T(B),u==null||u(!1),c==null||c(!1)}).catch(B=>{i==null||i(!1),o(B.message,B),X(B),u==null||u(!1),c==null||c(!1)})})}}const ac=({id:e,imageUrl:i,handleCardClick:t,selected:a,name:o,networkVersionSize:r,fileSizeLoading:s,showCheckBox:n,typeOfProduct:l,versionId:m,api:q,handleDownloadError:p,fetchFileUrl:u,urls:c,game:K,setIsConfirmActive:d,creditDownload:I,getDownloadCount:C,disabled:E,user:M,setSafariCopyLink:J,isTest:S,urlType:b,setCdnModal:w,generateCDN:Q,cdnUrl:T,selectedVersionIds:X,downloadableVersionIds:B,setDownloadableVersionIds:v,selectedGtmThresholds:P})=>{const[y,L]=Z.useState(!1),[Y,g]=Z.useState(""),[W,f]=Z.useState(!1),[V,h]=Z.useState(!1);Z.useState(!1);const[R,G]=Z.useState("download"),[U,D]=Z.useState(!1),[F,j]=Z.useState(!1);Z.useState(!1),Z.useState(!1);const[H,$]=Z.useState(!1),[ii,di]=Zi(ye),[x,hi]=Zi(ue),z=l==="Playable"?x:!0,ri=()=>{t(e)},gi=o==="moloco"||o==="molocoV2",yi=o==="google",N=ii.find(_=>_.name===o),O=tc({api:q,shouldDownloadMultipleIds:B,downloadState:L,handleDownloadError:p,user:M,typeOfProduct:l,game:K,fetchFileUrl:u,urlType:b,urls:c,selectedGtmThresholds:P,isMoloco:gi,isGoogle:yi,setCdnModal:w,setDownloadingMoloco:D,setDownloadingMolocoHtml:j,versionId:m,generateCDN:Q,submitCustomUrls:z,isTest:S});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",cursor:"pointer",pointerEvents:"auto"},className:`gap-3 w-58 rounded-xl h-[6.2rem] transition-all border ${a?"border-cyan-500/50 hover:border-cyan-400/50":"border-slate-700/50 hover:border-slate-600"}`,onClick:ri,children:[A.jsxs("div",{className:"mt-4 justify-between px-4",style:{display:"flex"},children:[A.jsx("p",{className:"justify-start text-white font-medium",children:N!=null&&N.name?N.name[0].toUpperCase()+N.name.slice(1):""}),A.jsx(Tn,{checked:a,id:e})]}),A.jsxs("div",{className:"px-4 gap-2",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:[A.jsx(zn,{className:"flex h-10 items-center justify-center border-0 duration-200 w-full rounded-xl text-white font-medium text-xs hover:shadow-lg hover:shadow-cyan-500/25 transition-all ",downloading:y,onClickDownload:async _=>{_.stopPropagation(),console.log("user in onclickdownload",M),g("download");const qi=c.iosUrl,ni=c.googleUrl;o==="cdn"&&I&&I.willSpendCredit&&!T||o!=="cdn"&&I&&I.willSpendCredit?(d(!0),G("download"),f(!0)):["Playable","Flex","Ready"].includes(l)&&(!qi||!ni)?(d(!0),h(!0)):(h(!1),f(!1),await O(o,"download"))},children:y?A.jsx(Ke,{}):A.jsxs("div",{className:"flex flex-row gap-1",children:[A.jsx(ct,{className:"w-5 h-5"}),A.jsx("p",{className:"text-sm ",children:"Download"})]})}),N&&N.downloadType.includes("copy")&&A.jsx(zn,{className:"flex items-center justify-center rounded-xl border-0 text-sm font-medium transition-all duration-200 bg-slate-700 hover:bg-slate-600 w-[4.2rem] h-10 text-white ",variant:"secondary",onClickDownload:async _=>{if(_.stopPropagation(),H)return;g("copyLink");const qi=c.iosUrl,ni=c.googleUrl;I&&(I!=null&&I.willSpendCredit)?(G("copy"),d(!0),f(!0)):l!=="Import"&&(!qi||!ni)?(d(!0),h(!0)):(f(!1),h(!1),await O(o,"copy"),$(!0),setTimeout(()=>$(!1),2e3))},disabled:E,isCopied:H,children:A.jsx(_a,{className:"h-5 w-5 ",style:{color:"#a9b4c2"}})})]})]}),W&&A.jsx(Te,{creditConfirmType:R,handleCopyLink:async()=>{h(!1),d(!1),await O(o,"copy")},download:async()=>{h(!1),d(!1),await O(o,"download")},onClose:()=>{f(!1),d(!1)},getDownloadCount:C,typeOfProduct:l})]})},Bn=({...e})=>A.jsx("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 1920 1920",xmlns:"http://www.w3.org/2000/svg",...e,children:A.jsx("path",{d:"M1827.701 303.065 698.835 1431.801 92.299 825.266 0 917.564 698.835 1616.4 1919.869 395.234z",fillRule:"evenodd"})}),oc=({networksVersionTotalSize:e,typeOfProduct:i,onClickMultiDownload:t,multiDownloading:a,selectedCount:o=0})=>A.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",position:"sticky",bottom:"1rem",zIndex:10,width:"100%"},children:a?A.jsx("div",{style:{display:"flex",width:"auto",minWidth:"12rem",height:"2.5rem",borderRadius:"0.5rem",alignItems:"center",justifyContent:"center",padding:"0 1.5rem"},children:A.jsx(Ke,{})}):A.jsxs("button",{style:{backgroundImage:"linear-gradient(to right, #06b6d4, #14b8a6)"},onClick:t,className:`flex items-center gap-2 px-8 py-3 rounded-xl -mb-4\r
|
|
93
93
|
text-white font-medium text-base drop-shadow-xl \r
|
|
94
|
-
hover:shadow-lg hover:shadow-cyan-500/25 transition-all`,children:[A.jsx(ct,{className:"w-4 h-4"}),"Download Selected (",o,")"]})}),rc=({playable:e,creditDownload:i,visible:t,versionId:a,typeOfProduct:o,api:r,user:s,handleDownloadError:n,fetchFileUrl:l,urls:m,game:q,getDownloadCount:p,disabled:u,setSafariCopyLink:c,isTest:K,urlType:d,cdnModal:I,setCdnModal:C,cdnUrl:E,setCdnUrl:M,customer:J,selectedVersionIds:S,downloadableVersionIds:b,setDownloadableVersionIds:w,selectedGtmThresholds:Q})=>{const[T,X]=Z.useState([]),[B,v]=Z.useState([]),[P,y]=Z.useState(!1),[L,Y]=Z.useState(""),[g,W]=Z.useState(!1),[f,V]=Z.useState(!1),[h,R]=Z.useState("download"),[G,U]=Z.useState(!1),[D,F]=Z.useState(!1),[j,H]=Z.useState(!1),[$,ii]=Zi(_t),[di,x]=Zi($t),[hi]=Zi(ye),[z,ri]=Zi(ue),gi=o==="Playable"?z:!0,[yi,N]=Z.useState(!1),O=async(si=!1)=>{si&&E||j||(H(!0),le(a,"cdn",gi?m:null,null,!1,{}).then(oi=>{M(oi.url),H(!1)}).catch(oi=>{n(oi.message,oi),H(!1)}))},_=async si=>{if(si==="adikteev"||si==="cdn")return;const oi=[...T];if(T.includes(si)){const Ci=oi.findIndex(mi=>mi===si);oi.splice(Ci,1),X(oi)}else oi.push(si),X([...T,si]);hi.filter(Ci=>[...oi].includes(Ci.id)).map(Ci=>Ci.name)},qi=async()=>new Promise(async(si,oi)=>{const Ci=hi.filter(mi=>[...T].includes(mi.id)).map(mi=>mi.name);if(W(!0),S&&S.length>0)try{if(!q||!q._id)throw new Error("Game data is required for multi-version download");const mi=await It(r,q._id,{networks:Ci,versions:S}),_i=l+"/"+mi.url,No=await(await fetch(_i)).blob(),he=window.URL.createObjectURL(No),Ze=document.createElement("a");Ze.href=he,Ze.download=mi.url.split("/").pop()||"download.zip",document.body.appendChild(Ze),Ze.click(),window.URL.revokeObjectURL(he),document.body.removeChild(Ze),W(!1),si(mi.url)}catch(mi){console.log("multi-version download error",mi),W(!1),n(mi.message,mi),oi(mi)}else ns(a,m,Ci,{urlType:d}).then(mi=>{W(!1),si(mi)}).catch(mi=>{console.log("get multi download err"),W(!1),n(mi.message,mi),oi(mi)})}),ni=async()=>{m.iosUrl,m.googleUrl,i&&i.willSpendCredit?(V(!0),R("download"),U(!0)):(U(!1),await qi())},Yi=Z.useCallback(()=>hi.filter(oi=>{var Ci;return S&&S.length>0?!0:i&&((Ci=i==null?void 0:i.networks)==null?void 0:Ci.length)>0?typeof oi=="string"?i==null?void 0:i.networks.includes(oi):i==null?void 0:i.networks.includes(oi.name):o==="Import"?e==null?void 0:e.networks.filter(mi=>mi.status==="paid").some(mi=>mi.name===oi.name):oi?!0:e==null?void 0:e.networks.includes(oi)}).filter(oi=>oi.name==="voodoo"?s.customer==="customer:20":!0).filter(oi=>oi.id!=="adikteev"&&oi.id!=="cdn").map(oi=>oi.id),[yi,S,hi,i,o,e,q,s.customer]);return Z.useEffect(()=>{const si=Yi();X(yi?si:[])},[yi,S,hi,i,o,e,q,s.customer]),A.jsxs("div",{className:"h-full",style:{position:"relative",flex:1,display:"flex",flexDirection:"column",paddingRight:o==="Flex"?"0.25rem":void 0},children:[A.jsxs("div",{className:"flex items-center justify-between mb-4 mx-2",children:[A.jsx("h3",{className:"text-lg font-semibold text-white",children:"Ad Networks"}),A.jsxs("button",{onClick:()=>{N(!yi)},className:"flex items-center gap-1.5 px-4 mr-5 py-2.5 rounded-lg bg-slate-800 text-slate-300 hover:bg-slate-700 hover:text-white transition-all text-sm font-medium",children:[yi?A.jsx(Bn,{className:"w-4 h-4",fill:"#ffffff"}):A.jsx(Bn,{className:"w-4 h-4",fill:"#ffffff"}),yi?"Deselect All":"Select All"]})]}),A.jsx("div",{className:"h-full",style:{flex:1,padding:"1.5rem",paddingTop:"0",paddingBottom:"1.5rem"},children:A.jsx("div",{className:"h-full w-full grid grid-cols-3 gap-4",children:t&&hi.filter(si=>{var oi;if(S&&S.length>0)return!0;if(i&&((oi=i==null?void 0:i.networks)==null?void 0:oi.length)>0)return typeof si=="string"?i==null?void 0:i.networks.includes(si):i==null?void 0:i.networks.includes(si.name);if(o==="Import")return e==null?void 0:e.networks.filter(Ci=>Ci.status==="paid").some(Ci=>Ci.name===si.name);if(!si)e==null||e.networks.includes(si);else return si}).filter(si=>si.name==="voodoo"?s.customer==="customer:20":!0).map(si=>{let oi=si.imageSrc;if(si.name==="web"){let Ci="web_"+o.toLowerCase()+".png";oi=oi.replace("web.png",Ci)}return A.jsx(ac,{id:si.id,name:si.name,imageUrl:oi,selected:T.includes(si.id),handleCardClick:_,networkVersionSize:B,fileSizeLoading:P,showCheckBox:si.id!=="adikteev"&&si.id!=="cdn",typeOfProduct:o,versionId:a,api:r,handleDownloadError:n,fetchFileUrl:l,urls:m,game:q,creditDownload:i,setIsConfirmActive:V,getDownloadCount:p,disabled:u,user:s,setSafariCopyLink:c,isTest:K,urlType:d,setCdnModal:C,generateCDN:O,cdnUrl:E,selectedVersionIds:S,downloadableVersionIds:b,setDownloadableVersionIds:w,selectedGtmThresholds:Q},si.id)})})}),T.length>0&&A.jsx(oc,{onClickMultiDownload:ni,networksVersionTotalSize:L,typeOfProduct:o,multiDownloading:g,selectedCount:T.length}),I&&A.jsx(un,{onClose:()=>{C(!1),p()},versionId:a,urls:m,handleDownloadError:n,cdnUrl:E,setCdnUrl:M,generateCDN:async()=>{if(!j){if(!(i!=null&&i.willSpendCredit)){O();return}if(s.customer==="playableFactoryInternal"){O();return}F(!0)}},cdnUploading:j,typeOfProduct:o}),di&&A.jsx(cn,{onClose:()=>{x(!1)},url:$,typeOfProduct:o}),D&&A.jsx(Te,{width:"100%",height:"100%",creditConfirmType:h,handleCopyLink:async()=>{},download:async()=>{U(!1),F(!1),O()},onClose:()=>{U(!1),F(!1),H(!1)},getDownloadCount:p,typeOfProduct:o}),G&&A.jsx(Te,{creditConfirmType:h,handleCopyLink:async()=>{},download:async()=>{U(!1),V(!1),await qi()},onClose:()=>{U(!1),V(!1)},getDownloadCount:p,typeOfProduct:o})]})},fn=["web","adcolony","applovin","chartboost","crossinstall","fb","google","google360","ironsource","lifestreet","liftoff","mobvista","nucleo","tapjoy","toutiao","unity","vungle","moloco","cdn"],sc=({playableId:e,versionId:i,gameId:t,typeOfProduct:a,visible:o,api:r,user:s,title:n,handleDownloadError:l,fetchFileUrl:m,fileSize:q,setFileSize:p,setSafariCopyLink:u,iosLink:c,androidLink:K,setIosLink:d,setAndroidLink:I,urlType:C,setUrlType:E,selectedVersionIds:M,downloadableVersionIds:J,setDownloadableVersionIds:S,selectedGtmThresholds:b})=>{const[w,Q]=Z.useState(null),[T,X]=Z.useState(null),[B,v]=Z.useState(null),[P,y]=Z.useState(!1),[L,Y]=Z.useState(!0),[g,W]=Z.useState(window.innerWidth),[f,V]=Z.useState(!1),[h,R]=Z.useState(!1),[G,U]=Z.useState("");Zi(_t),Zi($t);const[D,F]=Zi(ia);Zi(ue),Z.useEffect(()=>{!G&&a!=="Fusion"&&ms(i).then(z=>{z!=null&&z.exist&&U(z.uploadPath)})},[G]),Z.useEffect(()=>{const z=()=>{W(window.innerWidth)};return window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z)}},[]);const j=async()=>{y(!0);const z=await $a(e,r);return z!=null&&z.networks||(z.networks=fn),Q(z),z},H=async(z,ri)=>{var gi,yi;try{let N;if(a==="Playable"||a==="Ready"){const O=await dn(i,r);if(O){d(O.iosLink),I(O.androidLink),y(!1);return}if(z&&(z.iosUrl||z.googleUrl)){d(z.iosUrl),I(z.googleUrl),y(!1);return}if(ri&&ri.html){const _=`${m}/${ri.html}?t=${Date.now()}`;let qi=await fetch(_).then(si=>si.text());const ni=((gi=qi.match(/var\s+iosLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:gi.at(1))||"";d(ni);const Yi=((yi=qi.match(/var\s+androidLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:yi.at(1))||"";I(Yi),y(!1)}else I(""),d(""),y(!1)}else if(a==="Flex"){const O=await hn(i,r);if(O.googleUrl||O.iosUrl){I(O.googleUrl),d(O.iosUrl),y(!1);return}z&&(z.iosUrl||z.googleUrl)?(d(z.iosUrl),I(z.googleUrl),y(!1)):(I(""),d(""),y(!1))}else a==="Fusion"&&(z&&(z.iosUrl||z.googleUrl)?(d(z.iosUrl),I(z.googleUrl),y(!1)):(I(""),d(""),y(!1)))}catch(N){l(N.response.data.error.msg)}},$=async()=>{y(!0);let z;a==="Flex"?z=await In({_id:i},r):a==="Ready"&&(z=await Sn({_id:i},r)),z&&(["admin","pm","tester","sales"].includes(s.role)?v({...z,networks:D}):(console.log("result",z),a==="Ready"&&!z.canDownload?v({...z,networks:fn}):(console.log("result",z),v({...z,networks:z.networks})))),y(!1)},ii=async()=>await Kn(t,r),[di,x]=Z.useState(null),hi=async z=>await Cn(z,r);return Z.useEffect(()=>{o||(Q(null),X(null),v(null),p(null),x(null)),o&&(a==="Playable"?ii().then(z=>{X(z),z&&hi(z.customer).then(ri=>{x(ri||null)}),j().then(ri=>{H(null,ri)}),Y(!1)}):a==="Ready"?$().then(z=>{j().then(ri=>{H(null,ri),Y(!1),ri!=null&&ri.customer&&hi(ri.customer).then(gi=>{x(gi||null)})})}):a==="Flex"?$().then(z=>{Y(!1),ii().then(ri=>{o&&(H(ri,null),Y(!1),X(ri),ri&&hi(ri.customer).then(gi=>{x(gi||null)}))})}):a==="Import"?Zn(i,r).then(z=>{Q(z),d(z.iosUrl||""),I(z.googleUrl||""),y(!1),Y(!1)}):a==="Fusion"&&(Y(!1),ii().then(z=>{o&&(H(z,null),Y(!1),X({...z,networks:D.filter(ri=>ri!=="cdn")}),z&&hi(z.customer).then(ri=>{x(ri||null)}))})))},[t,e,i,o]),A.jsx("div",{className:"p-4 rounded-xl bg-slate-800/50 border border-slate-700/50 h-fit",children:A.jsx("div",{className:"flex w-[42rem]",style:{position:"relative",display:"flex",flex:1,flexDirection:"column",borderRadius:"rounded",paddingTop:"0px"},children:P?A.jsx("div",{style:{height:"100%",width:"100%",display:"flex",justifyContent:"center"},children:A.jsx(Ke,{isNetworksLoading:!0,isLight:!1})}):(w||B)&&!P&&A.jsx(rc,{playable:w,creditDownload:B,visible:o,versionId:i,typeOfProduct:a,api:r,user:s,handleDownloadError:l,fetchFileUrl:m,urls:{iosUrl:c,googleUrl:K},game:T,getDownloadCount:$,disabled:L,setSafariCopyLink:u,isTest:f,urlType:C,cdnModal:h,setCdnModal:R,cdnUrl:G,setCdnUrl:U,customer:di??void 0,selectedVersionIds:M,downloadableVersionIds:J,setDownloadableVersionIds:S,selectedGtmThresholds:b})})})};function nc({versionData:e,onSelectStateChange:i}){const[t,a]=Z.useState(!0);return Z.useEffect(()=>{i==null||i({id:e.versionId,state:t})},[t]),A.jsxs("div",{className:"overflow-x-hidden flex items-start justify-start gap-2 flex-row w-full h-full px-3 py-3 rounded-lg text-base font-medium transition-all bg-slate-800 text-slate-300 border border-slate-700 hover:border-slate-600 hover:text-white",children:[A.jsx(Tn,{checked:t,id:e.versionId+"checkbox",className:"rounded-full border border-slate-800/50",checkedColor:"bg-emerald-500"},e.versionId+"checkbox"),A.jsx("button",{onClick:()=>{a(!t)},className:"w-full -mt-[0.05rem]",children:A.jsx("p",{className:" text-white w-full truncate pr-8 text-start items-start",children:e.versionName})},e.versionId)]})}const lc=({selectedVersionIds:e,api:i,fetchFileUrl:t,downloadableVersionIds:a,setDownloadableVersionIds:o})=>{const[r,s]=Z.useState([]);Z.useEffect(()=>{const l=e.map(q=>({versionId:q,versionName:"Loading...",size:null,status:"loading"}));s(l),(async()=>{try{const q=await kn(i,!1,e);s(p=>p.map(u=>{const c=q.find(K=>K._id===u.versionId);return{...u,versionName:(c==null?void 0:c.name)||`Version ${u.versionId}`}})),e.forEach(async p=>{try{const u=await le(p,"preview",null,null,!1);s(c=>c.map(K=>K.versionId===p?{...K,size:u.size,status:u.size>=5?"exceeded":"ok"}:K))}catch(u){console.error(`Error checking version ${p}:`,u),s(c=>c.map(K=>K.versionId===p?{...K,status:"ok"}:K))}})}catch(q){console.error("Error fetching version names:",q)}})()},[e,i]);const n=Z.useCallback(l=>{if(l.state){const m=[...a,l.id];o(Array.from(new Set(m)))}else{const m=(a==null?void 0:a.filter(q=>q!=l.id))||[];o(m)}},[a,o]);return A.jsx("div",{className:"border-slate-700/50 bg-slate-800/50 w-64 border-r pt-4",style:{display:"flex",flexDirection:"column",height:"100%",padding:"0.75rem",overflowY:"auto"},children:A.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:r.map(l=>A.jsx(nc,{versionData:l,onSelectStateChange:n},l.versionId))})})},mc=({downloadableVersionIds:e,selectedGtmThresholds:i})=>{const[t,a]=Z.useState(e.length*(i.length>0?i.length:1));return Z.useEffect(()=>{a(e.length*(i.length>0?i.length:1))},[e,i]),A.jsx("div",{className:"sticky top-0 z-50 flex flex-col w-full justify-between gap-1 bg-slate-900 px-4 py-4",children:A.jsx("div",{className:"flex items-center justify-between",children:A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("h2",{className:"text-[1.4rem] font-bold bg-clip-text text-transparent py-1",style:{backgroundImage:"linear-gradient(to right, #22d3ee, #2dd4bf)"},children:"Export Playables"}),t>0&&A.jsxs("span",{className:"px-2.5 py-1 rounded-full bg-cyan-500/20 border border-cyan-500/40 text-xs text-cyan-400 font-semibold",children:[t," variations"]})]})})})},Ac=({selectedGtmThresholds:e,setSelectedGtmThresholds:i})=>A.jsxs("div",{className:"p-4 rounded-xl bg-slate-800/50 border border-slate-700/50 transition-all duration-300",children:[A.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:"Market Direction"}),A.jsxs("div",{className:"space-y-2",children:[A.jsx("p",{className:"text-sm text-slate-400",children:"Go to market after"}),A.jsx("div",{className:"grid grid-cols-3 gap-2",children:[2,4,10].map(t=>{const a=e.includes(t);return A.jsxs("button",{onClick:()=>{i(o=>a?o.filter(r=>r!==t):[...o,t])},className:`px-3 py-2 rounded-lg text-base font-medium transition-all ${a?"bg-cyan-500 text-white border border-cyan-400":"bg-slate-800 text-slate-300 border border-slate-700 hover:border-slate-600 hover:text-white"}`,children:[t," clicks"]},t)})})]})]}),qc=({gearboxAINetworkComponent:e,selectedGtmThresholds:i,setSelectedGtmThresholds:t,downloadableVersionIds:a})=>A.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[A.jsx(mc,{downloadableVersionIds:a,selectedGtmThresholds:i}),A.jsx("div",{className:"h-0.5 w-full bg-slate-800"}),A.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 custom-scrollbar",children:[A.jsx(Ac,{selectedGtmThresholds:i,setSelectedGtmThresholds:t}),e]})]}),pc=({versionList:e})=>A.jsxs("div",{className:"flex flex-col",children:[A.jsx("div",{className:"sticky top-0 z-50 flex flex-col w-full justify-between gap-1 bg-slate-800/50 border-slate-700/50 border-b border-r px-4 py-4",children:A.jsx("div",{className:"flex items-center justify-between pb-6",children:A.jsx("div",{className:"flex items-center gap-3",children:A.jsx("h2",{className:"text-base text-white font-medium py-1 ",children:"Select Versions"})})})}),e]}),cI="",uc=({visible:e,closeModal:i,versionId:t,selectedVersionIds:a,gameId:o,versionName:r,playableId:s,api:n,user:l,title:m,iframeUrl:q,handleDownloadError:p,fetchFileUrl:u,copyLinkUrl:c,onNameChange:K})=>{ls("Playable",n,"",c,void 0);const[d,I]=Z.useState(window.innerWidth),[C,E]=Z.useState(!1),[M,J]=Z.useState(q);Z.useState(!1),Z.useState(!1);const[S,b]=Z.useState(null),[w,Q]=Z.useState(""),[T,X]=Z.useState("Loading..."),[B,v]=Z.useState("Loading..."),[P,y]=Z.useState("game"),[L,Y]=Zi(ye),[g,W]=Zi(ia),[f,V]=Z.useState(a||[]),[h,R]=Z.useState([]);Z.useRef(null);const G=async()=>{let U=await nn(n);if(!U){pt("Networks not found");return}U=U.map(D=>(D.name=D.id,D)),Y(U),W(U.map(D=>D.id).filter(D=>D!=="default"))};return Z.useEffect(()=>{e?C||(G(),E(!0)):(E(!1),J(""))},[e]),Z.useEffect(()=>{const U=()=>{I(window.innerWidth)};return window.addEventListener("resize",U),()=>{window.removeEventListener("resize",U)}},[]),A.jsx("div",{className:"BPL TRPBASO",onMouseDown:U=>{U.stopPropagation()},onMouseUp:U=>{U.stopPropagation()},children:A.jsx(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i()},className:"bg-slate-900 max-h-[75vh] rounded-2xl border border-slate-700/50 shadow-2xl shadow-black/50 overflow-hidden",overlayClassName:"ReactModal__Overlay",bodyOpenClassName:"React_aimodal",closeTimeoutMS:1e3,style:{content:{position:"absolute",left:"50%",top:"50%",zIndex:50,maxHeight:"95vh",overflow:d<768?"auto":"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:A.jsxs("div",{className:"tw-container",children:[A.jsx("div",{className:"",style:{position:"absolute",top:"0.8rem",right:"1.25rem",zIndex:9999},children:A.jsx("button",{onClick:()=>{i()},style:{padding:"0.5rem",borderRadius:"9999px",transition:"background-color 0.2s",backgroundColor:"transparent"},onMouseEnter:U=>{U.currentTarget.style.backgroundColor="#F3F4F6"},onMouseLeave:U=>{U.currentTarget.style.backgroundColor="transparent"},children:A.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#1e293b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[A.jsx("path",{d:"M18 6 6 18"}),A.jsx("path",{d:"m6 6 12 12"})]})})}),A.jsxs(zo,{children:[A.jsx(pc,{versionList:A.jsx(lc,{selectedVersionIds:a,api:n,fetchFileUrl:u,downloadableVersionIds:f,setDownloadableVersionIds:V})}),A.jsx(qc,{downloadableVersionIds:f,selectedGtmThresholds:h,setSelectedGtmThresholds:R,gearboxAINetworkComponent:A.jsx(sc,{visible:e,versionId:t,playableId:s,gameId:o,typeOfProduct:"Playable",api:n,user:l,title:m,handleDownloadError:p,fetchFileUrl:u,fileSize:S,setFileSize:b,setSafariCopyLink:Q,iosLink:T,androidLink:B,setIosLink:X,setAndroidLink:v,urlType:P,setUrlType:y,selectedVersionIds:a,downloadableVersionIds:f,setDownloadableVersionIds:V,selectedGtmThresholds:h})})]}),A.jsx(Aa,{})]})})})};se.DownloadModal=ec,se.GearboxAIDownloadModal=uc,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|
|
94
|
+
hover:shadow-lg hover:shadow-cyan-500/25 transition-all`,children:[A.jsx(ct,{className:"w-4 h-4"}),"Download Selected (",o,")"]})}),rc=({playable:e,creditDownload:i,visible:t,versionId:a,typeOfProduct:o,api:r,user:s,handleDownloadError:n,fetchFileUrl:l,urls:m,game:q,getDownloadCount:p,disabled:u,setSafariCopyLink:c,isTest:K,urlType:d,cdnModal:I,setCdnModal:C,cdnUrl:E,setCdnUrl:M,customer:J,selectedVersionIds:S,downloadableVersionIds:b,setDownloadableVersionIds:w,selectedGtmThresholds:Q})=>{const[T,X]=Z.useState([]),[B,v]=Z.useState([]),[P,y]=Z.useState(!1),[L,Y]=Z.useState(""),[g,W]=Z.useState(!1),[f,V]=Z.useState(!1),[h,R]=Z.useState("download"),[G,U]=Z.useState(!1),[D,F]=Z.useState(!1),[j,H]=Z.useState(!1),[$,ii]=Zi(_t),[di,x]=Zi($t),[hi]=Zi(ye),[z,ri]=Zi(ue),gi=o==="Playable"?z:!0,[yi,N]=Z.useState(!1),O=async(si=!1)=>{si&&E||j||(H(!0),le(a,"cdn",gi?m:null,null,!1,{}).then(oi=>{M(oi.url),H(!1)}).catch(oi=>{n(oi.message,oi),H(!1)}))},_=async si=>{if(si==="adikteev"||si==="cdn")return;const oi=[...T];if(T.includes(si)){const Ci=oi.findIndex(mi=>mi===si);oi.splice(Ci,1),X(oi)}else oi.push(si),X([...T,si]);hi.filter(Ci=>[...oi].includes(Ci.id)).map(Ci=>Ci.name)},qi=async()=>new Promise(async(si,oi)=>{const Ci=hi.filter(mi=>[...T].includes(mi.id)).map(mi=>mi.name);if(W(!0),S&&S.length>0)try{if(!q||!q._id)throw new Error("Game data is required for multi-version download");const mi=await It(r,q._id,{networks:Ci,versions:S}),_i=l+"/"+mi.url,No=await(await fetch(_i)).blob(),he=window.URL.createObjectURL(No),Ze=document.createElement("a");Ze.href=he,Ze.download=mi.url.split("/").pop()||"download.zip",document.body.appendChild(Ze),Ze.click(),window.URL.revokeObjectURL(he),document.body.removeChild(Ze),W(!1),si(mi.url)}catch(mi){console.log("multi-version download error",mi),W(!1),n(mi.message,mi),oi(mi)}else ns(a,m,Ci,{urlType:d}).then(mi=>{W(!1),si(mi)}).catch(mi=>{console.log("get multi download err"),W(!1),n(mi.message,mi),oi(mi)})}),ni=async()=>{m.iosUrl,m.googleUrl,i&&i.willSpendCredit?(V(!0),R("download"),U(!0)):(U(!1),await qi())},Yi=Z.useCallback(()=>hi.filter(oi=>{var Ci;return S&&S.length>0?!0:i&&((Ci=i==null?void 0:i.networks)==null?void 0:Ci.length)>0?typeof oi=="string"?i==null?void 0:i.networks.includes(oi):i==null?void 0:i.networks.includes(oi.name):o==="Import"?e==null?void 0:e.networks.filter(mi=>mi.status==="paid").some(mi=>mi.name===oi.name):oi?!0:e==null?void 0:e.networks.includes(oi)}).filter(oi=>oi.name==="voodoo"?s.customer==="customer:20":!0).filter(oi=>oi.id!=="adikteev"&&oi.id!=="cdn").map(oi=>oi.id),[yi,S,hi,i,o,e,q,s.customer]);return Z.useEffect(()=>{const si=Yi();X(yi?si:[])},[yi,S,hi,i,o,e,q,s.customer]),A.jsxs("div",{className:"h-full",style:{position:"relative",flex:1,display:"flex",flexDirection:"column",paddingRight:o==="Flex"?"0.25rem":void 0},children:[A.jsxs("div",{className:"flex items-center justify-between mb-4 mx-2",children:[A.jsx("h3",{className:"text-lg font-semibold text-white",children:"Ad Networks"}),A.jsxs("button",{onClick:()=>{N(!yi)},className:"flex items-center gap-1.5 px-4 mr-5 py-2.5 rounded-lg bg-slate-800 text-slate-300 hover:bg-slate-700 hover:text-white transition-all text-sm font-medium",children:[yi?A.jsx(Bn,{className:"w-4 h-4",fill:"#ffffff"}):A.jsx(Bn,{className:"w-4 h-4",fill:"#ffffff"}),yi?"Deselect All":"Select All"]})]}),A.jsx("div",{className:"h-full",style:{flex:1,padding:"1.5rem",paddingTop:"0",paddingBottom:"1.5rem"},children:A.jsx("div",{className:"h-full w-full grid grid-cols-3 gap-4",children:t&&hi.filter(si=>{var oi;if(S&&S.length>0)return!0;if(i&&((oi=i==null?void 0:i.networks)==null?void 0:oi.length)>0)return typeof si=="string"?i==null?void 0:i.networks.includes(si):i==null?void 0:i.networks.includes(si.name);if(o==="Import")return e==null?void 0:e.networks.filter(Ci=>Ci.status==="paid").some(Ci=>Ci.name===si.name);if(!si)e==null||e.networks.includes(si);else return si}).filter(si=>si.name==="voodoo"?s.customer==="customer:20":!0).map(si=>{let oi=si.imageSrc;if(si.name==="web"){let Ci="web_"+o.toLowerCase()+".png";oi=oi.replace("web.png",Ci)}return A.jsx(ac,{id:si.id,name:si.name,imageUrl:oi,selected:T.includes(si.id),handleCardClick:_,networkVersionSize:B,fileSizeLoading:P,showCheckBox:si.id!=="adikteev"&&si.id!=="cdn",typeOfProduct:o,versionId:a,api:r,handleDownloadError:n,fetchFileUrl:l,urls:m,game:q,creditDownload:i,setIsConfirmActive:V,getDownloadCount:p,disabled:u,user:s,setSafariCopyLink:c,isTest:K,urlType:d,setCdnModal:C,generateCDN:O,cdnUrl:E,selectedVersionIds:S,downloadableVersionIds:b,setDownloadableVersionIds:w,selectedGtmThresholds:Q},si.id)})})}),T.length>0&&A.jsx(oc,{onClickMultiDownload:ni,networksVersionTotalSize:L,typeOfProduct:o,multiDownloading:g,selectedCount:T.length}),I&&A.jsx(un,{onClose:()=>{C(!1),p()},versionId:a,urls:m,handleDownloadError:n,cdnUrl:E,setCdnUrl:M,generateCDN:async()=>{if(!j){if(!(i!=null&&i.willSpendCredit)){O();return}if(s.customer==="playableFactoryInternal"){O();return}F(!0)}},cdnUploading:j,typeOfProduct:o}),di&&A.jsx(cn,{onClose:()=>{x(!1)},url:$,typeOfProduct:o}),D&&A.jsx(Te,{width:"100%",height:"100%",creditConfirmType:h,handleCopyLink:async()=>{},download:async()=>{U(!1),F(!1),O()},onClose:()=>{U(!1),F(!1),H(!1)},getDownloadCount:p,typeOfProduct:o}),G&&A.jsx(Te,{creditConfirmType:h,handleCopyLink:async()=>{},download:async()=>{U(!1),V(!1),await qi()},onClose:()=>{U(!1),V(!1)},getDownloadCount:p,typeOfProduct:o})]})},fn=["web","adcolony","applovin","chartboost","crossinstall","fb","google","google360","ironsource","lifestreet","liftoff","mobvista","nucleo","tapjoy","toutiao","unity","vungle","moloco","cdn"],sc=({playableId:e,versionId:i,gameId:t,typeOfProduct:a,visible:o,api:r,user:s,title:n,handleDownloadError:l,fetchFileUrl:m,fileSize:q,setFileSize:p,setSafariCopyLink:u,iosLink:c,androidLink:K,setIosLink:d,setAndroidLink:I,urlType:C,setUrlType:E,selectedVersionIds:M,downloadableVersionIds:J,setDownloadableVersionIds:S,selectedGtmThresholds:b})=>{const[w,Q]=Z.useState(null),[T,X]=Z.useState(null),[B,v]=Z.useState(null),[P,y]=Z.useState(!1),[L,Y]=Z.useState(!0),[g,W]=Z.useState(window.innerWidth),[f,V]=Z.useState(!1),[h,R]=Z.useState(!1),[G,U]=Z.useState("");Zi(_t),Zi($t);const[D,F]=Zi(ia);Zi(ue),Z.useEffect(()=>{!G&&a!=="Fusion"&&ms(i).then(z=>{z!=null&&z.exist&&U(z.uploadPath)})},[G]),Z.useEffect(()=>{const z=()=>{W(window.innerWidth)};return window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z)}},[]);const j=async()=>{y(!0);const z=await $a(e,r);return z!=null&&z.networks||(z.networks=fn),Q(z),z},H=async(z,ri)=>{var gi,yi;try{let N;if(a==="Playable"||a==="Ready"){const O=await dn(i,r);if(O){d(O.iosLink),I(O.androidLink),y(!1);return}if(z&&(z.iosUrl||z.googleUrl)){d(z.iosUrl),I(z.googleUrl),y(!1);return}if(ri&&ri.html){const _=`${m}/${ri.html}?t=${Date.now()}`;let qi=await fetch(_).then(si=>si.text());const ni=((gi=qi.match(/var\s+iosLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:gi.at(1))||"";d(ni);const Yi=((yi=qi.match(/var\s+androidLink\s*=\s*['|"](https?[^\s'"]+)['|"]/))==null?void 0:yi.at(1))||"";I(Yi),y(!1)}else I(""),d(""),y(!1)}else if(a==="Flex"){const O=await hn(i,r);if(O.googleUrl||O.iosUrl){I(O.googleUrl),d(O.iosUrl),y(!1);return}z&&(z.iosUrl||z.googleUrl)?(d(z.iosUrl),I(z.googleUrl),y(!1)):(I(""),d(""),y(!1))}else a==="Fusion"&&(z&&(z.iosUrl||z.googleUrl)?(d(z.iosUrl),I(z.googleUrl),y(!1)):(I(""),d(""),y(!1)))}catch(N){l(N.response.data.error.msg)}},$=async()=>{y(!0);let z;a==="Flex"?z=await In({_id:i},r):a==="Ready"&&(z=await Sn({_id:i},r)),z&&(["admin","pm","tester","sales"].includes(s.role)?v({...z,networks:D}):(console.log("result",z),a==="Ready"&&!z.canDownload?v({...z,networks:fn}):(console.log("result",z),v({...z,networks:z.networks})))),y(!1)},ii=async()=>await Kn(t,r),[di,x]=Z.useState(null),hi=async z=>await Cn(z,r);return Z.useEffect(()=>{o||(Q(null),X(null),v(null),p(null),x(null)),o&&(a==="Playable"?ii().then(z=>{X(z),z&&hi(z.customer).then(ri=>{x(ri||null)}),j().then(ri=>{H(null,ri)}),Y(!1)}):a==="Ready"?$().then(z=>{j().then(ri=>{H(null,ri),Y(!1),ri!=null&&ri.customer&&hi(ri.customer).then(gi=>{x(gi||null)})})}):a==="Flex"?$().then(z=>{Y(!1),ii().then(ri=>{o&&(H(ri,null),Y(!1),X(ri),ri&&hi(ri.customer).then(gi=>{x(gi||null)}))})}):a==="Import"?Zn(i,r).then(z=>{Q(z),d(z.iosUrl||""),I(z.googleUrl||""),y(!1),Y(!1)}):a==="Fusion"&&(Y(!1),ii().then(z=>{o&&(H(z,null),Y(!1),X({...z,networks:D.filter(ri=>ri!=="cdn")}),z&&hi(z.customer).then(ri=>{x(ri||null)}))})))},[t,e,i,o]),A.jsx("div",{className:"p-4 rounded-xl bg-slate-800/50 border border-slate-700/50 h-fit",children:A.jsx("div",{className:"flex w-[42rem]",style:{position:"relative",display:"flex",flex:1,flexDirection:"column",borderRadius:"rounded",paddingTop:"0px"},children:P?A.jsx("div",{style:{height:"100%",width:"100%",display:"flex",justifyContent:"center"},children:A.jsx(Ke,{isNetworksLoading:!0,isLight:!1})}):(w||B)&&!P&&A.jsx(rc,{playable:w,creditDownload:B,visible:o,versionId:i,typeOfProduct:a,api:r,user:s,handleDownloadError:l,fetchFileUrl:m,urls:{iosUrl:c,googleUrl:K},game:T,getDownloadCount:$,disabled:L,setSafariCopyLink:u,isTest:f,urlType:C,cdnModal:h,setCdnModal:R,cdnUrl:G,setCdnUrl:U,customer:di??void 0,selectedVersionIds:M,downloadableVersionIds:J,setDownloadableVersionIds:S,selectedGtmThresholds:b})})})};function nc({versionData:e,onSelectStateChange:i}){const[t,a]=Z.useState(!0);return Z.useEffect(()=>{i==null||i({id:e.versionId,state:t})},[t]),A.jsxs("div",{className:"overflow-x-hidden flex items-start justify-start gap-2 flex-row w-full h-full px-3 py-3 rounded-lg text-base font-medium transition-all bg-slate-800 text-slate-300 border border-slate-700 hover:border-slate-600 hover:text-white",children:[A.jsx(Tn,{checked:t,id:e.versionId+"checkbox",className:"rounded-full border border-slate-800/50",checkedColor:"bg-emerald-500"},e.versionId+"checkbox"),A.jsx("button",{onClick:()=>{a(!t)},className:"w-full -mt-[0.05rem]",children:A.jsx("p",{className:" text-white w-full truncate pr-8 text-start items-start",children:e.versionName})},e.versionId)]})}const lc=({selectedVersionIds:e,api:i,fetchFileUrl:t,downloadableVersionIds:a,setDownloadableVersionIds:o})=>{const[r,s]=Z.useState([]);Z.useEffect(()=>{const l=e.map(q=>({versionId:q,versionName:"Loading...",size:null,status:"loading"}));s(l),(async()=>{try{const q=await kn(i,!1,e);s(p=>p.map(u=>{const c=q.find(K=>K._id===u.versionId);return{...u,versionName:(c==null?void 0:c.name)||`Version ${u.versionId}`}})),e.forEach(async p=>{try{const u=await le(p,"preview",null,null,!1);s(c=>c.map(K=>K.versionId===p?{...K,size:u.size,status:u.size>=5?"exceeded":"ok"}:K))}catch(u){console.error(`Error checking version ${p}:`,u),s(c=>c.map(K=>K.versionId===p?{...K,status:"ok"}:K))}})}catch(q){console.error("Error fetching version names:",q)}})()},[e,i]);const n=Z.useCallback(l=>{if(l.state){const m=[...a,l.id];o(Array.from(new Set(m)))}else{const m=(a==null?void 0:a.filter(q=>q!=l.id))||[];o(m)}},[a,o]);return A.jsx("div",{className:"border-slate-700/50 bg-slate-800/50 w-64 border-r pt-4",style:{display:"flex",flexDirection:"column",height:"100%",padding:"0.75rem",overflowY:"auto"},children:A.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:r.map(l=>A.jsx(nc,{versionData:l,onSelectStateChange:n},l.versionId))})})},mc=({downloadableVersionIds:e,selectedGtmThresholds:i})=>{const[t,a]=Z.useState(e.length*(i.length>0?i.length:1));return Z.useEffect(()=>{a(e.length*(i.length>0?i.length:1))},[e,i]),A.jsx("div",{className:"sticky top-0 z-50 flex flex-col w-full justify-between gap-1 bg-slate-900 px-4 py-4",children:A.jsx("div",{className:"flex items-center justify-between",children:A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("h2",{className:"text-[1.4rem] font-bold bg-clip-text text-transparent py-1",style:{backgroundImage:"linear-gradient(to right, #22d3ee, #2dd4bf)"},children:"Export Playables"}),t>0&&A.jsxs("span",{className:"px-2.5 py-1 rounded-full bg-cyan-500/20 border border-cyan-500/40 text-xs text-cyan-400 font-semibold",children:[t," variations"]})]})})})},Ac=({selectedGtmThresholds:e,setSelectedGtmThresholds:i})=>A.jsxs("div",{className:"p-4 rounded-xl bg-slate-800/50 border border-slate-700/50 transition-all duration-300",children:[A.jsx("h3",{className:"text-base font-semibold text-white mb-3",children:"Market Direction"}),A.jsxs("div",{className:"space-y-2",children:[A.jsx("p",{className:"text-sm text-slate-400",children:"Go to market after"}),A.jsx("div",{className:"grid grid-cols-3 gap-2",children:[2,4,10].map(t=>{const a=e.includes(t);return A.jsxs("button",{onClick:()=>{i(o=>a?o.filter(r=>r!==t):[...o,t])},className:`px-3 py-2 rounded-lg text-base font-medium transition-all ${a?"bg-cyan-500 text-white border border-cyan-400":"bg-slate-800 text-slate-300 border border-slate-700 hover:border-slate-600 hover:text-white"}`,children:[t," clicks"]},t)})})]})]}),qc=({gearboxAINetworkComponent:e,selectedGtmThresholds:i,setSelectedGtmThresholds:t,downloadableVersionIds:a})=>A.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[A.jsx(mc,{downloadableVersionIds:a,selectedGtmThresholds:i}),A.jsx("div",{className:"h-0.5 w-full bg-slate-800"}),A.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 custom-scrollbar",children:[A.jsx(Ac,{selectedGtmThresholds:i,setSelectedGtmThresholds:t}),e]})]}),pc=({versionList:e})=>A.jsxs("div",{className:"flex flex-col",children:[A.jsx("div",{className:"sticky top-0 z-50 flex flex-col w-full justify-between gap-1 bg-slate-800/50 border-slate-700/50 border-b border-r px-4 py-4",children:A.jsx("div",{className:"flex items-center justify-between pb-6",children:A.jsx("div",{className:"flex items-center gap-3",children:A.jsx("h2",{className:"text-base text-white font-medium py-1 ",children:"Select Versions"})})})}),e]}),cI="",uc=({visible:e,closeModal:i,versionId:t,selectedVersionIds:a,gameId:o,versionName:r,playableId:s,api:n,user:l,title:m,iframeUrl:q,handleDownloadError:p,fetchFileUrl:u,copyLinkUrl:c,onNameChange:K})=>{ls("Playable",n,"",c,void 0);const[d,I]=Z.useState(window.innerWidth),[C,E]=Z.useState(!1),[M,J]=Z.useState(q);Z.useState(!1),Z.useState(!1);const[S,b]=Z.useState(null),[w,Q]=Z.useState(""),[T,X]=Z.useState("Loading..."),[B,v]=Z.useState("Loading..."),[P,y]=Z.useState("game"),[L,Y]=Zi(ye),[g,W]=Zi(ia),[f,V]=Z.useState(a||[]),[h,R]=Z.useState([]);Z.useRef(null),Z.useEffect(()=>{V(a||[])},[a]);const G=async()=>{let U=await nn(n);if(!U){pt("Networks not found");return}U=U.map(D=>(D.name=D.id,D)),Y(U),W(U.map(D=>D.id).filter(D=>D!=="default"))};return Z.useEffect(()=>{e?C||(G(),E(!0)):(E(!1),J(""))},[e]),Z.useEffect(()=>{const U=()=>{I(window.innerWidth)};return window.addEventListener("resize",U),()=>{window.removeEventListener("resize",U)}},[]),A.jsx("div",{className:"BPL TRPBASO",onMouseDown:U=>{U.stopPropagation()},onMouseUp:U=>{U.stopPropagation()},children:A.jsx(lt,{isOpen:e,ariaHideApp:!1,onRequestClose:()=>{i()},className:"bg-slate-900 max-h-[75vh] rounded-2xl border border-slate-700/50 shadow-2xl shadow-black/50 overflow-hidden",overlayClassName:"ReactModal__Overlay",bodyOpenClassName:"React_aimodal",closeTimeoutMS:1e3,style:{content:{position:"absolute",left:"50%",top:"50%",zIndex:50,maxHeight:"95vh",overflow:d<768?"auto":"hidden",paddingTop:"0px"},overlay:{position:"fixed",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,top:0,left:0,right:0,bottom:0}},contentLabel:"Playable Editing Download Modal",shouldCloseOnOverlayClick:!0,children:A.jsxs("div",{className:"tw-container",children:[A.jsx("div",{className:"",style:{position:"absolute",top:"0.8rem",right:"1.25rem",zIndex:9999},children:A.jsx("button",{onClick:()=>{i()},style:{padding:"0.5rem",borderRadius:"9999px",transition:"background-color 0.2s",backgroundColor:"transparent"},onMouseEnter:U=>{U.currentTarget.style.backgroundColor="#F3F4F6"},onMouseLeave:U=>{U.currentTarget.style.backgroundColor="transparent"},children:A.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#1e293b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[A.jsx("path",{d:"M18 6 6 18"}),A.jsx("path",{d:"m6 6 12 12"})]})})}),A.jsxs(zo,{children:[A.jsx(pc,{versionList:A.jsx(lc,{selectedVersionIds:a,api:n,fetchFileUrl:u,downloadableVersionIds:f,setDownloadableVersionIds:V})}),A.jsx(qc,{downloadableVersionIds:f,selectedGtmThresholds:h,setSelectedGtmThresholds:R,gearboxAINetworkComponent:A.jsx(sc,{visible:e,versionId:t,playableId:s,gameId:o,typeOfProduct:"Playable",api:n,user:l,title:m,handleDownloadError:p,fetchFileUrl:u,fileSize:S,setFileSize:b,setSafariCopyLink:Q,iosLink:T,androidLink:B,setIosLink:X,setAndroidLink:v,urlType:P,setUrlType:y,selectedVersionIds:a,downloadableVersionIds:f,setDownloadableVersionIds:V,selectedGtmThresholds:h})})]}),A.jsx(Aa,{})]})})})};se.DownloadModal=ec,se.GearboxAIDownloadModal=uc,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|
|
95
95
|
//# sourceMappingURL=index.umd.js.map
|