fansunited-management-components 1.56.0-RC14 → 1.56.0-RC15

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/index.es.js CHANGED
@@ -37316,7 +37316,7 @@ const Gz = (e) => {
37316
37316
  return;
37317
37317
  }
37318
37318
  if (w(!1), Q === "goto") {
37319
- e.fetchEntityById(ve.id), F("on_create"), e.toggleModal();
37319
+ e.fetchEntityById(ve.data.id), F("on_create"), e.toggleModal();
37320
37320
  return;
37321
37321
  }
37322
37322
  F("on_create");
@@ -37570,7 +37570,7 @@ const Gz = (e) => {
37570
37570
  ) }) : /* @__PURE__ */ l.jsx(l.Fragment, {})
37571
37571
  ] }) }),
37572
37572
  /* @__PURE__ */ l.jsxs(Ss, { children: [
37573
- /* @__PURE__ */ l.jsx(je, { variant: "solid", color: "primary", loading: y, disabled: !R || p, onClick: () => oe("goto"), children: e.labels.createAndGoTo }),
37573
+ /* @__PURE__ */ l.jsx(je, { variant: "outlined", color: "primary", loading: y, disabled: !R || p, onClick: () => oe("goto"), children: e.labels.createAndGoTo }),
37574
37574
  /* @__PURE__ */ l.jsx(
37575
37575
  je,
37576
37576
  {
package/index.umd.js CHANGED
@@ -2495,4 +2495,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2495
2495
  data-widget-mode="${v}"`,B=`<div
2496
2496
  data-component="fu-widget"
2497
2497
  data-content-type="list"${b}${x}${S}${C}${A}${E}${k}
2498
- ></div>`,G=({title:F})=>l.jsx(p.Tooltip,{title:F,sx:{maxWidth:300},children:l.jsx(ar,{color:"primary"})}),O=()=>l.jsxs(p.Card,{sx:{pb:1,mb:3},children:[l.jsx(on,{label:t.classicQuizURL,placeholder:"",defaultValue:i,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.quizzesInfoMessage}),onChange:F=>o(F.target.value)}),l.jsx(on,{label:t.eitherOrURL,placeholder:"",defaultValue:a,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.eitherOrsInfoMessage}),onChange:F=>c(F.target.value)}),l.jsx(on,{label:t.pollURL,placeholder:"",defaultValue:s,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.pollsInfoMessage}),onChange:F=>u(F.target.value)})]}),T=()=>l.jsxs(p.Card,{sx:{pb:1,mb:3},children:[l.jsx(Tu,{label:t.itemsPerPage,description:t.itemsPerPageDescription,defaultValue:f,onChange:F=>d(F||null),size:"md"}),l.jsx(Tu,{label:t.itemsPerRow,description:t.itemsPerRowDescription,defaultValue:h,onChange:F=>g(F||null),size:"md"}),l.jsxs(p.FormControl,{sx:()=>({marginBottom:"16px"}),children:[l.jsx(p.FormLabel,{color:"primary",children:t.mode}),l.jsx(p.Select,{defaultValue:v,onChange:(F,H)=>m(H),children:ON.map((F,H)=>l.jsx(p.Option,{value:F,children:RN[F]},`basic-select-${F}-${H}`))}),l.jsx(p.FormHelperText,{children:t.modeDescription})]})]});return l.jsxs(p.Box,{mt:1,children:[T(),l.jsx(pi,{defaultValue:n,label:t.configureURLs,labelPosition:"end",description:"",descriptionColor:"neutral",disabled:!1,onChange:F=>{F===!1&&(o(""),c(""),u("")),r(F)}}),n&&O(),l.jsxs(p.Box,{position:"relative",mb:1,children:[l.jsx(p.Textarea,{value:B,minRows:"5",maxRows:"20",readOnly:!0,onMouseDown:F=>F.preventDefault(),sx:{cursor:"default","&:hover":{cursor:"default"},"& textarea":{cursor:"default"}}}),l.jsx(p.Tooltip,{title:t.copyToClipboard,children:l.jsx(p.Button,{onClick:()=>{navigator.clipboard.writeText(B)},sx:{position:"absolute",top:"10px",right:"10px",zIndex:1},variant:"soft",color:"neutral",children:l.jsx(Me.ContentCopy,{})})})]}),l.jsx(p.Alert,{variant:"outlined",color:"primary",startDecorator:l.jsx(ar,{}),sx:{mb:1,width:"fit-content"},children:l.jsxs(p.Typography,{color:"primary",fontSize:14,fontWeight:500,children:[t.divElementTextInfo,l.jsx(p.Link,{href:"https://docs.fansunitedmedia.com/docs/user-centric-widgets#/",underline:"always",target:"_blank",rel:"noopener noreferrer",children:"User-centric widgets"})]})})]})},yb=e=>(e==null?void 0:e.map(t=>({id:t.id,value:t.nickname?t.nickname:t.name||`No name ${t.id.slice(0,5)}`,label:t.nickname?t.nickname:t.name||`No name ${t.id.slice(0,5)}`,avatar:t.avatar})))||[],LN=({labels:e,ids:t,onChange:n})=>{const[r,i]=y.useState([]),[o,a]=y.useState([]),[c,s]=y.useState(""),[u,f]=y.useState("name"),[d,h]=y.useState(!1),[g,v]=y.useState(!1),{sdk:m}=Ye(),b=!0,x=()=>v(!g),S=(A,E)=>{i(E);const k=E.map(B=>B.id);n(k&&k.length?k:null)},C=3;y.useEffect(()=>{!c&&t&&t.length&&m.profile.getByIds(t,void 0,b).then(A=>{i(yb(A))}).catch(A=>{x(),console.error(A),i([])})},[]);const I=y.useMemo(()=>sr((A,E)=>{h(!0),m.profile.getByIds(E==="id"?[A]:[],E==="name"?A:void 0,b).then(k=>{a([...yb(k)]),h(!1)}).catch(k=>{console.error(k),x(),a([]),h(!1)})},300),[]);y.useEffect(()=>{if(!c||c.length<C){a([]);return}return I(c,u),()=>I.cancel()},[c,I,u]);const w=(A,E)=>A.map((k,B)=>{var G;return l.jsx(p.Chip,{variant:"solid",endDecorator:l.jsx(p.ChipDelete,{color:"danger",sx:{marginRight:.5},variant:"plain",onClick:O=>E({index:B}).onClick(O),children:l.jsx(Me.Close,{fontSize:"small"})}),sx:{marginLeft:"3px",marginY:"1px",backgroundColor:"#e0f3ff",padding:"2px",borderRadius:4,"&:hover":{cursor:"default"}},children:l.jsxs(p.Box,{display:"flex",alignItems:"center",mr:1,children:[l.jsx(p.Avatar,{sx:{width:"1.5rem",height:" 1.5rem",mr:.5,borderRadius:"0.75rem"},src:(G=k.avatar)!=null?G:Oe.avatar}),l.jsx(p.Typography,{children:k.label})]})},k.id)});return l.jsxs(l.Fragment,{children:[l.jsx(p.Box,{sx:{marginBottom:"16px"},children:l.jsx(p.Autocomplete,{forcePopupIcon:!1,multiple:!0,loading:d,disableClearable:!0,slotProps:{input:{sx:{"&::placeholder":{fontSize:"14px"}}},root:{sx:{boxShadow:"none",backgroundColor:"white",minHeight:38}}},isOptionEqualToValue:(A,E)=>A.id===E.id,endDecorator:l.jsxs(l.Fragment,{children:[d&&l.jsx(p.CircularProgress,{size:"sm",sx:{bgcolor:"primary",marginRight:2}}),l.jsx(p.Divider,{orientation:"vertical"}),l.jsxs(p.Select,{variant:"plain",value:u,onChange:(A,E)=>f(E),slotProps:{listbox:{variant:"outlined"}},sx:{mr:-1.5,"&:hover":{bgcolor:"transparent"}},children:[l.jsx(p.Option,{value:"name",children:e.searchByName}),l.jsx(p.Option,{value:"id",children:e.searchById})]})]}),placeholder:r.length>0?"":e.excludedProfilesPlaceholder,options:o,filterOptions:A=>A.filter(E=>!r.some(k=>k.value===E.value)),onInputChange:(A,E)=>{s(E)},onChange:S,getOptionKey:A=>A.id,value:r,renderTags:w,renderOption:(A,E)=>{var k;return l.jsx(p.AutocompleteOption,J($({},A),{children:l.jsxs(p.Box,{display:"flex",alignItems:"center",mr:1,children:[l.jsx(p.Avatar,{sx:{width:"1.5rem",height:" 1.5rem",mr:.5,borderRadius:"0.75rem"},src:(k=E.avatar)!=null?k:Oe.avatar}),l.jsx(p.Typography,{children:E.label})]})}))}})}),l.jsx(Ke,{showToast:g,message:e.searchProfilesErrorMessage,color:"danger",hideToast:x})]})},BN=({value:e,sx:t,tooltipPlacement:n})=>{const r=s=>{const u=Math.abs(s);return u>=1e9?(s/1e9).toFixed(1)+"b":u>=1e6?(s/1e6).toFixed(1)+"m":u>=1e3?(s/1e3).toFixed(1)+"k":s.toString()},i=s=>new Intl.NumberFormat("en-US").format(s),o=Math.abs(e)>=1e3,a=r(e),c=i(e);return o?l.jsx(p.Tooltip,{title:c,placement:n,arrow:!0,children:l.jsx(p.Typography,{sx:t,children:a})}):l.jsx(p.Typography,{sx:t,children:a})},$N=(e,t,n,r)=>{if(e&&e.length===0){n([]);return}t.football.getPlayers({playerIds:e}).then(i=>{const o=i.data.map(a=>xb(a));n(o)}).catch(i=>{console.error("Error fetching players by ID:",i),r()})},xb=e=>{var t,n,r,i,o;return{id:e.id,name:e.name,avatar:((t=e.assets)==null?void 0:t.headshot)||Oe.avatar,countryName:((n=e.country)==null?void 0:n.name)||"Unknown",countryFlag:((i=(r=e.country)==null?void 0:r.assets)==null?void 0:i.flag)||Oe.flag,teams:((o=e.teams)==null?void 0:o.map(a=>{var c;return{id:a.id,name:a.name,logo:((c=a.assets)==null?void 0:c.logo)||Oe.team}}))||[]}},FN=({player:e,onRemove:t})=>l.jsx(p.Tooltip,{title:l.jsxs(p.Box,{sx:{p:1},children:[l.jsx(p.Typography,{level:"body-sm",fontWeight:"bold",children:e.name}),l.jsxs(p.Typography,{level:"body-xs",sx:{display:"flex",alignItems:"center",gap:.5,mt:.5},children:[l.jsx("img",{src:e.countryFlag,alt:e.countryName,width:16,height:12,loading:"lazy"}),e.countryName]}),e.teams&&e.teams.length>0&&l.jsxs(p.Box,{sx:{mt:.5},children:[l.jsx(p.Typography,{level:"body-xs",sx:{mb:.5},children:"Teams:"}),l.jsx(p.Box,{sx:{display:"flex",flexDirection:"column",gap:.25},children:e.teams.map((n,r)=>l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[l.jsx("img",{src:n.logo,alt:n.name,width:16,height:16,style:{borderRadius:"2px"},loading:"lazy"}),l.jsx(p.Typography,{level:"body-xs",children:n.name})]},r))})]})]}),placement:"left",variant:"solid",sx:{"--Tooltip-radius":"8px",maxWidth:300,bgcolor:"background.level1"},children:l.jsxs(p.Box,{sx:{display:"inline-flex",alignItems:"center",gap:.5,backgroundColor:"#e0f3ff",borderRadius:"50px",padding:"2px 8px 2px 2px",margin:"2px",position:"relative","&:hover":{backgroundColor:"#d0e8ff",cursor:"default"}},children:[l.jsx(p.Avatar,{src:e.avatar,alt:e.name,size:"sm",sx:{width:24,height:24,border:"1px solid #fff"}}),l.jsx(p.Typography,{level:"body-sm",sx:{fontSize:"12px",maxWidth:80,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),l.jsx(p.IconButton,{size:"sm",variant:"plain",color:"danger",onClick:t,sx:{minHeight:16,minWidth:16,padding:0,ml:.5,"&:hover":{backgroundColor:"rgba(255, 0, 0, 0.1)"}},children:l.jsx(Me.Close,{sx:{fontSize:12}})})]})}),NN=({labels:e,teamIds:t,selectedPlayers:n,onChangePlayers:r})=>{const[i,o]=y.useState([]),[a,c]=y.useState([]),[s,u]=y.useState([]),[f,d]=y.useState(!1),[h,g]=y.useState(""),[v,m]=y.useState(!1),{sdk:b}=Ye(),x=()=>m(!v),S=t&&t.length>0,C=(k,B)=>{o(B),r(B)},I=()=>_(this,null,function*(){if(S){d(!0);try{const k=t.map(O=>b.football.getTeamById(O)),B=yield Promise.all(k),G=[];B.forEach(O=>{if(O.squad&&O.squad.length>0){const T=O.squad.map(F=>{var H,j,N,M,V;return{id:F.id,name:F.name,avatar:((H=F.assets)==null?void 0:H.headshot)||Oe.avatar,countryName:((j=F.country)==null?void 0:j.name)||"Unknown",countryFlag:((M=(N=F.country)==null?void 0:N.assets)==null?void 0:M.flag)||Oe.flag,teams:[{id:O.id,name:O.name,logo:((V=O.assets)==null?void 0:V.logo)||Oe.team}]}}).sort((F,H)=>F.name.localeCompare(H.name));G.push(...T)}}),u(G),c(G)}catch(k){console.error("Error fetching team players:",k),x()}finally{d(!1)}}}),w=k=>{if(!k){c(s);return}const B=s.filter(G=>G.name.toLowerCase().includes(k.toLowerCase()));c(B)};y.useEffect(()=>{$N(n,b,o,x)},[n]),y.useEffect(()=>{S&&I()},[t]);const A=y.useMemo(()=>sr(k=>{if(!S){if(!k||k.length<2){c([]),d(!1);return}d(!0),b.football.getPlayers({name:k,sortField:"name",sortOrder:"asc"}).then(B=>{const G=B.data.map(O=>xb(O));c(G),d(!1)}).catch(B=>{console.error("Error searching players:",B),c([]),d(!1),x()})}},300),[b,S]);y.useEffect(()=>(S?w(h):A(h),()=>{S||A.cancel()}),[h,S]);const E=(k,B)=>k.map((G,O)=>l.jsx(FN,{player:G,onRemove:()=>{const T=B({index:O});T.onClick&&T.onClick({})}},G.id));return l.jsxs(l.Fragment,{children:[l.jsx(p.Autocomplete,{forcePopupIcon:S,multiple:!0,loading:f,slotProps:{input:{sx:{"&::placeholder":{fontSize:"14px"}}},root:{sx:{boxShadow:"none",backgroundColor:"white",minHeight:38,flexWrap:"wrap"}},noOptions:{sx:{}}},isOptionEqualToValue:(k,B)=>k.id===B.id,endDecorator:f?l.jsx(p.CircularProgress,{size:"sm",sx:{bgcolor:"primary"}}):null,placeholder:i.length>0?"":e==null?void 0:e.searchPlayersPlaceholder,options:a,filterSelectedOptions:!0,onInputChange:(k,B)=>{g(B)},onChange:C,getOptionKey:k=>typeof k=="string"?k:k.id,getOptionLabel:k=>typeof k=="string"?k:k.name,value:i,renderTags:E,limitTags:1,renderOption:(k,B)=>{const G={props:k};return l.jsxs(p.AutocompleteOption,J($({},k),{sx:{display:"flex",alignItems:"center",gap:1},children:[l.jsx(p.Avatar,{src:B.avatar,alt:B.name,size:"sm",sx:{width:32,height:32}}),l.jsxs(p.Box,{sx:{flexGrow:1},children:[l.jsx(p.Typography,{level:"body-sm",fontWeight:"bold",children:B.name}),l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[l.jsx("img",{src:B.countryFlag,alt:B.countryName,width:16,height:12,loading:"lazy"}),l.jsx(p.Typography,{level:"body-xs",color:"neutral",children:B.countryName})]})]})]}),`player-option-${B.id}-${G}`)}}),l.jsx(Ke,{showToast:v,message:e.getPlayersErrorMessage,color:"danger",hideToast:x})]})},zN=(e,t={})=>{const{enabled:n=!0}=t,{sdk:r}=Ye(),[i,o]=y.useState(null),[a,c]=y.useState(!1),[s,u]=y.useState(null),[f,d]=y.useState(null),h=y.useMemo(()=>$({},e),[JSON.stringify(e)]),g=y.useCallback(()=>_(this,null,function*(){var v,m;c(!0),u(null);try{const b=yield r.football.getMatches(h);o(b.data),d((m=(v=b.meta)==null?void 0:v.pagination)!=null?m:null)}catch(b){u(b),o([]),d(null)}finally{c(!1)}}),[r,h]);return y.useEffect(()=>{n&&g()},[g,n]),{matches:i,loading:a,error:s,meta:f,refetch:g}},Cb=$e(l.jsx("path",{d:"M4.25 5.61C6.57 8.59 10 13 10 13v5c0 1.1.9 2 2 2s2-.9 2-2v-5s3.43-4.41 5.75-7.39c.51-.66.04-1.61-.8-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAltRounded"),wb=$e(l.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.89-2-2-2m0 16H5V7h14zm-5.5-6c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5.67-1.5 1.5-1.5 1.5.67 1.5 1.5M12 9c-2.73 0-5.06 1.66-6 4 .94 2.34 3.27 4 6 4s5.06-1.66 6-4c-.94-2.34-3.27-4-6-4m0 6.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"PreviewRounded"),ur=We("MuiStep",["root","indicator","horizontal","vertical","active","completed","disabled"]),Ci=We("MuiStepIndicator",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","horizontal","vertical"]),jN=$e(l.jsx("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6z"}),"KeyboardArrowLeft"),UN=$e(l.jsx("path",{d:"M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z"}),"KeyboardArrowRight"),Sb=$e(l.jsx("path",{d:"M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp");class VN{constructor(){X(this,"id","");X(this,"title","");X(this,"alternative_title",null);X(this,"description",null);X(this,"type",null);X(this,"auth_requirement",null);X(this,"rules",null);X(this,"ad_content",null);X(this,"labels",null);X(this,"branding",null);X(this,"embed_code",null);X(this,"custom_fields",null);X(this,"images",null);X(this,"status","");X(this,"flags",[]);X(this,"context",null);X(this,"options",[]);X(this,"related",[]);X(this,"multiple_choice",!1);X(this,"max_multiple_choice_options",null);X(this,"participation_count",0);X(this,"preferences_enabled",!1);X(this,"max_attempts",1);X(this,"external_activity",null)}}const HN=e=>{const[t,n]=y.useState(!1),[r,i]=y.useState(""),o=e.generatedEntity,a=d=>{const h=new VN;return h.title=d.question||"",h.status="INACTIVE",h.options=(d.options||[]).map(g=>({title:g,description:"",images:{main:"",mobile:"",cover:""},embed_code:null,preference_mappings:[]})),h},c=d=>{i(d.id);const h=a(d);e.setPollRequestBody(h)},s=()=>{if(!o)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noPreviewAvailable})});const d=()=>l.jsxs(p.Table,{variant:"outlined",size:"sm",sx:{width:"100%",maxWidth:"100%","& > thead > tr > th:first-child, & > tbody > tr > td:first-child":{textAlign:"left"},"--TableCell-paddingX":"0.5rem",cursor:"default","& > tbody > tr:hover":{backgroundColor:"transparent"},"& > thead > tr > th":{backgroundColor:"#fff",verticalAlign:"middle"},"& > thead > tr > th, & > tbody > tr > td":{textAlign:"right"}},children:[l.jsx("thead",{children:l.jsx("tr",{children:l.jsx("th",{children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.questions})})})}),l.jsx("tbody",{children:o.questions.map((g,v)=>{var m;return l.jsx("tr",{children:l.jsx("td",{children:l.jsxs(p.Typography,{level:"body-sm",children:[g.question," ",l.jsx(p.Typography,{children:(m=g.options)==null?void 0:m.map((b,x)=>l.jsx(p.Chip,{color:b.correct?"success":"neutral",variant:b.correct?"solid":"outlined",sx:{mr:1},size:"sm",children:b.option},`question-option-${x}`))})]})})},`question-${v}`)})})]}),h=()=>{const g=o.questions||[],v=m=>!m&&m!==0?"neutral":m>=5?"success":m>=4?"primary":m>=3?"warning":"neutral";return l.jsx(p.Box,{component:"ul",sx:{listStyle:"none",m:0,p:0,ml:0,pl:0,marginBlockStart:0,marginBlockEnd:0,marginInlineStart:0,marginInlineEnd:0,paddingInlineStart:0,display:"flex",flexDirection:"column",gap:1},children:g.map((m,b)=>{const x=r===m.id;return l.jsx(p.Box,{component:"li",children:l.jsx(p.Sheet,{variant:"outlined",sx:{p:1,borderRadius:"sm",cursor:"pointer",bgcolor:x?"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))":"background.body",borderColor:x?"primary.solidBg":void 0,"&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},"&:hover .pollOptionChipNeutral":{backgroundColor:"background.level1",borderColor:"neutral.outlinedBorder"}},onClick:()=>c(m),role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),c(m))},children:l.jsxs(p.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1},children:[l.jsx(p.Radio,{name:"selectedPollSuggestion",value:m.id,checked:x,onChange:()=>c(m),size:"sm"}),l.jsxs(p.Box,{sx:{flex:1,minWidth:0},children:[l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[m.category_name?l.jsx(p.Tooltip,{title:e.labels.category,children:l.jsx(p.Chip,{size:"sm",variant:"outlined",color:"neutral",children:m.category_name})}):null,l.jsx(p.Box,{sx:{flex:1}}),m.engagement_score?l.jsx(p.Tooltip,{title:e.labels.engagementScore,children:l.jsx(p.Chip,{size:"sm",variant:"solid",color:v(m.engagement_score),children:m.engagement_score})}):l.jsx(l.Fragment,{})]}),l.jsx(p.Typography,{level:"body-sm",fontWeight:600,sx:{mb:.5},children:m.question}),l.jsx(p.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:(m.options||[]).map((S,C)=>l.jsx(p.Chip,{className:x?void 0:"pollOptionChipNeutral",variant:x?"soft":"outlined",color:x?"primary":"neutral",size:"sm",sx:{mr:.5,mb:.5},children:S},`poll-suggestion-opt-${C}`))})]})]})})},`poll-suggestion-${m.id||b}`)})})};return e.entityType==="poll"?l.jsx(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",p:1,maxHeight:"300px",my:.5},children:h()}):l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[l.jsxs(p.Box,{role:"button",tabIndex:0,onClick:()=>n(!t),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),n(v=>!v))},sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"}},children:[l.jsx(p.Typography,{level:"body-sm",sx:{flexGrow:1},children:o.title}),l.jsx(p.Tooltip,{title:t?"":e.labels.expand,children:l.jsx(p.IconButton,{"aria-label":"expand row",variant:"plain",color:"neutral",size:"sm",sx:{"&:hover":{backgroundColor:"background.surface"}},children:t?l.jsx(Sb,{}):l.jsx(bs,{})})})]}),l.jsx(p.Box,{sx:{display:t?"block":"none",p:1},children:t?d():null})]})},u=()=>!e.matches||e.matches.length===0?l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noMatchesFound})}):l.jsx(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:e.matches.map(d=>{var h,g,v,m,b,x,S,C,I,w,A,E,k,B,G,O,T,F,H,j,N,M,V,W;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{onClick:()=>e.setSelectedMatchId(d.id),onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),e.setSelectedMatchId(d.id))},role:"button",tabIndex:0,sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},backgroundColor:e.selectedMatchId===d.id?"rgba(0,0,0,0.04)":"transparent"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedMatch",value:d.id,checked:e.selectedMatchId===d.id,onChange:Z=>e.setSelectedMatchId(Z.target.value),sx:{mr:1}}),l.jsx(p.Tooltip,{title:(((g=(h=d.context)==null?void 0:h.competition)==null?void 0:g.name)||"Competition with no name")+((b=(m=(v=d.context)==null?void 0:v.competition)==null?void 0:m.country)!=null&&b.name?` (${d.context.competition.country.name})`:""),children:l.jsx(p.Avatar,{src:((C=(S=(x=d.context)==null?void 0:x.competition)==null?void 0:S.assets)==null?void 0:C.logo)||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(d.kickoffAt).format("HH:mm DD.MM.YYYY"),"]"]}),(I=d.homeTeam)!=null&&I.code?l.jsx(p.Tooltip,{title:d.homeTeam.name,children:l.jsxs(p.Box,{display:"flex",gap:.5,alignItems:"center",minWidth:"60px",justifyContent:"flex-end",children:[l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.homeTeam.id)?700:400,children:d.homeTeam.code||d.homeTeam.name}),l.jsx(p.Avatar,{src:((w=d.homeTeam.assets)==null?void 0:w.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})]})}):l.jsxs(l.Fragment,{children:[l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.homeTeam.id)?700:400,children:d.homeTeam.code||d.homeTeam.name}),l.jsx(p.Avatar,{src:((A=d.homeTeam.assets)==null?void 0:A.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})]}),((k=(E=d==null?void 0:d.scores)==null?void 0:E.ftScore)==null?void 0:k.homeGoals)!==null&&((G=(B=d==null?void 0:d.scores)==null?void 0:B.ftScore)==null?void 0:G.awayGoals)!==null?l.jsx(p.Chip,{variant:"outlined",children:((F=(T=(O=d.scores)==null?void 0:O.ftScore)==null?void 0:T.homeGoals)!=null?F:"")+":"+((N=(j=(H=d.scores)==null?void 0:H.ftScore)==null?void 0:j.awayGoals)!=null?N:"")}):" : ",(M=d.awayTeam)!=null&&M.code?l.jsx(p.Tooltip,{title:d.awayTeam.name,children:l.jsxs(p.Box,{display:"flex",gap:.5,alignItems:"center",children:[l.jsx(p.Avatar,{src:((V=d.awayTeam.assets)==null?void 0:V.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})," ",l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.awayTeam.id)?700:400,children:d.awayTeam.code||d.awayTeam.name})]})}):l.jsxs(l.Fragment,{children:[l.jsx(p.Avatar,{src:((W=d.awayTeam.assets)==null?void 0:W.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}}),l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.awayTeam.id)?700:400,children:d.awayTeam.code||d.awayTeam.name})]})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`search-matches-custom-${d.id}`)})}),f=()=>l.jsxs(l.Fragment,{children:[l.jsx(p.Typography,{level:"body-xs",children:e.pagination?`${e.labels.page} ${e.pagination.currentPage} ${e.labels.of} ${e.pagination.numberOfPages} • ${e.pagination.totalItems} ${e.labels.total}`:""}),l.jsxs(p.Box,{sx:{display:"flex",gap:1},children:[l.jsx(p.IconButton,{size:"sm",color:"neutral",variant:"outlined",disabled:!e.pagination||e.pagination&&e.pagination.currentPage<=1,onClick:()=>e.setPage(d=>Math.max(1,d-1)),sx:{bgcolor:"background.surface"},children:l.jsx(jN,{})}),l.jsx(p.IconButton,{size:"sm",color:"neutral",variant:"outlined",disabled:!e.pagination||e.pagination&&e.pagination.currentPage>=e.pagination.numberOfPages,onClick:()=>e.setPage(d=>e.pagination?Math.min(e.pagination.numberOfPages,d+1):d+1),sx:{bgcolor:"background.surface"},children:l.jsx(UN,{})})]})]});return e.loading?l.jsx(p.Box,{sx:{height:240},children:l.jsx(hi,{my:0})}):l.jsxs(l.Fragment,{children:[e.step==="search"?u():s(),l.jsxs(p.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[l.jsx(p.Button,{size:"sm",color:"primary",variant:"outlined",disabled:!e.selectedMatchId,onClick:e.onGenerate,children:e.step==="search"?e.labels.generate:e.labels.regenerate}),e.step==="search"?f():l.jsx(l.Fragment,{})]})]})},Nu=ft(Date.now()).format("YYYY-MM-DD"),Ib=e=>{const t=e==null?void 0:e.toLowerCase();return t&&Ti[t]?Ti[t].key:"en"},Ab=e=>({fromDate:"",toDate:Nu,competitionIds:e&&e.length?e:void 0,teamIds:void 0,sortOrder:"desc",status:"finished"}),WN=e=>{var le;const[t,n]=y.useState(Ib(e.defaultLanguage)),[r,i]=y.useState(Ab(e.competitionsScope)),[o,a]=y.useState(1),[c,s]=y.useState(""),[u,f]=y.useState(!1),[d,h]=y.useState("search"),[g,v]=y.useState(!1),[m,b]=y.useState(null),[x,S]=y.useState(null),[C,I]=y.useState(!1),[w,A]=y.useState(!1),[E,k]=y.useState(""),[B,G]=y.useState(!1),[O,T]=y.useState(""),[F,H]=y.useState("danger"),j=10,N=y.useMemo(()=>{const st=r,{fromDate:q,toDate:se}=st,me=Qe(st,["fromDate","toDate"]),Ee=$({},me);if(q&&(Ee.fromDate=`${q}T00:00:00Z`),se){const qe=ft().add(1,"minute").format("THH:mm:ss")+"Z";Ee.toDate=se+qe}return J($({},Ee),{page:o,limit:j})},[r,o]),M=y.useMemo(()=>!(!m||e.entityType==="poll"&&!x),[m,e.entityType,x]);y.useEffect(()=>()=>{n(Ib),i(Ab(e.competitionsScope)),a(1),s(""),f(!1),h("search"),b(null)},[]);const{https:V}=Ye(),{matches:W,loading:Z,meta:D}=zN(N,{enabled:u}),L=()=>{T(""),G(!1)},U=q=>{let se="",me="danger";switch(q){case"on_generate_failed":se=e.labels.onEntityGenerateErrorMessage;break;case"on_create":se=e.labels.onEntityCreateMessage,me="success";break;case"on_create_failed":se=e.labels.onEntityCreateErrorMessage;break}H(me),T(se),G(!0)},Y=q=>{var me;const se=q.map(Ee=>Ee.id);i(Ee=>J($({},Ee),{teamIds:se||void 0})),a(1),f(!0),e.entityType==="poll"&&(q.length===0?(k(""),A(!1)):k(((me=q[q.length-1])==null?void 0:me.label)||""))},re=q=>{const{name:se,value:me}=q.target;i(Ee=>J($({},Ee),{[se]:me})),f(!0)},ce=()=>_(this,null,function*(){v(!0),e.entityType==="poll"&&S(null);let q=null;switch(e.entityType){case"classic_quiz":q=yield V.generatePostMatchQuiz({sportType:"football",lang:t,eventId:c});break;case"poll":const me=w?E:"";q=yield V.generatePostMatchPoll({targetParticipant:me,lang:t,eventId:c});break}if(!(q!=null&&q.ok)){const me=yield q==null?void 0:q.json();console.error("Failed to generate AI content",me),v(!1),U("on_generate_failed");return}const se=yield q==null?void 0:q.json();if(e.entityType==="poll"){const me=se;me.questions.sort((Ee,st)=>st.engagement_score-Ee.engagement_score),b(me)}else b(se);v(!1),h("preview")}),oe=q=>_(this,null,function*(){I(!0);let se=null;switch(e.entityType){case"classic_quiz":const Ee=m;se=yield V.createClassicQuiz(Ee);break;case"poll":se=yield V.createPoll(x);break}const me=yield se==null?void 0:se.json();if(!(se!=null&&se.ok)){console.error("Failed to create content",me),I(!1),U("on_create_failed");return}if(I(!1),q==="goto"){e.fetchEntityById(me.id),U("on_create"),e.toggleModal();return}U("on_create")}),ee=()=>e.entityType==="poll"?l.jsx(p.Checkbox,{disabled:!r.teamIds||r.teamIds.length===0||!!m,checked:w,size:"sm",onChange:q=>{A(q.target.checked)},label:e.labels.useFramingGuidelinesLabel}):l.jsx(l.Fragment,{});return l.jsx(p.Modal,{open:e.isOpen,onClose:()=>{g||C||e.toggleModal()},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.ModalDialog,{sx:{backgroundColor:"white",minWidth:"50%",height:900},children:[l.jsx(p.DialogTitle,{children:e.labels.generateFootballPostMatchModalTitle}),l.jsx(p.Divider,{}),l.jsx(p.DialogContent,{sx:{overflowX:"hidden"},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.FormControl,{size:"sm",sx:{mb:2},children:[l.jsx(p.FormLabel,{children:e.labels.language}),l.jsx(p.Select,{value:t,onChange:(q,se)=>se&&n(se),indicator:null,disabled:!!m,startDecorator:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[t]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[t]||"gb").toLowerCase()}.png`,alt:((le=Object.values(Ie).find(q=>q.key===t))==null?void 0:le.name)||"Language"}),sx:{minWidth:220,minHeight:38},children:Object.values(Ie).map(q=>l.jsxs(p.Option,{value:q.key,label:q.name,children:[l.jsx(p.ListItemDecorator,{children:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[q.key]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[q.key]||"gb").toLowerCase()}.png`,alt:q.name})}),q.name]},q.key))}),l.jsx(p.FormHelperText,{children:e.labels.targetLanguageDescription})]}),l.jsxs(l.Fragment,{children:[l.jsx(zm,{labels:{teamsSelectionPlaceholder:e.labels.teamsSelectionPlaceholder||"",searchTeamsErrorMessage:e.labels.searchTeamsErrorMessage},ids:r.teamIds||[],onChange:Y,scope:e.competitionsScope,readOnly:!!m,AdditionalCheckbox:ee()}),l.jsxs(p.Grid,{container:!0,spacing:2,minWidth:"100%",columns:{xs:0,sm:0,md:12},children:[l.jsx(p.Grid,{xs:6,children:l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.fromDate}),l.jsx(p.Input,{name:"fromDate",type:"date",readOnly:!!m,defaultValue:r.fromDate,onChange:re,sx:{backgroundColor:"#fff",borderRadius:"md",minHeight:"36px"},slotProps:{input:{max:Nu}}})]})}),l.jsx(p.Grid,{xs:6,children:l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.toDate}),l.jsx(p.Input,{name:"toDate",type:"date",defaultValue:r.toDate,readOnly:!!m,onChange:re,sx:{backgroundColor:"#fff",borderRadius:"md",minHeight:"36px"},slotProps:{input:{max:Nu}}})]})})]})]}),l.jsxs(p.Stepper,{sx:{my:2,width:"100%","--StepIndicator-size":"3rem","--Step-connectorInset":"0px",[`& .${Ci.root}`]:{borderWidth:3},[`& .${ur.root}::after`]:{height:3},[`& .${ur.completed}`]:{[`& .${Ci.root}`]:{borderColor:"primary.300",color:"primary.300"},"&::after":{bgcolor:"primary.300"}},[`& .${ur.active}`]:{[`& .${Ci.root}`]:{borderColor:"currentColor"}},[`& .${ur.disabled} *`]:{color:"neutral.outlinedDisabledColor"}},children:[l.jsx(p.Step,{active:d==="search",orientation:"vertical",indicator:l.jsx(p.Tooltip,{title:d==="preview"?e.labels.searchMatchTooltip:"",placement:"right",children:l.jsx(p.StepIndicator,{variant:d==="search"?"solid":"outlined",color:"primary",onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&d==="preview"&&(q.preventDefault(),b(null),h("search"))},sx:$({cursor:d==="preview"?"pointer":"default"},d==="preview"&&{animation:"pulse 2s infinite","@keyframes pulse":{"0%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0.7)"},"70%":{boxShadow:"0 0 0 10px rgba(25, 118, 210, 0)"},"100%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0)"}},"&:hover":{animation:"none",boxShadow:"0 0 0 4px rgba(25, 118, 210, 0.3)"}}),role:"button",tabIndex:d==="preview"?0:-1,children:l.jsx(Cb,{})})}),children:l.jsx(p.Typography,{sx:$({textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},d==="preview"&&{cursor:"pointer"}),onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&d==="preview"&&(q.preventDefault(),b(null),h("search"))},role:"button",tabIndex:d==="preview"?0:-1,children:e.labels.searchMatch})}),l.jsx(p.Step,{orientation:"vertical",active:d==="preview",disabled:d!=="preview",indicator:l.jsx(p.StepIndicator,{variant:d==="preview"?"solid":"outlined",color:"primary",children:l.jsx(wb,{})}),children:l.jsx(p.Typography,{sx:{textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},children:e.labels.preview})})]}),u?l.jsx(p.Sheet,{variant:"outlined",sx:{p:1,borderRadius:"sm",bgcolor:"background.surface"},children:l.jsx(HN,{step:d,loading:Z||g,matches:W,selectedMatchId:c,generatedEntity:m,labels:e.labels,pagination:D,teamIdsFilter:r.teamIds,setPollRequestBody:S,setPage:a,setSelectedMatchId:s,onGenerate:ce,entityType:e.entityType,setGeneratedEntity:b})}):l.jsx(l.Fragment,{})]})}),l.jsxs(p.DialogActions,{children:[l.jsx(p.Button,{variant:"solid",color:"primary",loading:C,disabled:!M||g,onClick:()=>oe("goto"),children:e.labels.createAndGoTo}),l.jsx(p.Button,{variant:"solid",color:"primary",loading:C,disabled:!M||g,onClick:()=>oe("continue"),children:e.labels.createAndContinue}),l.jsx(p.Button,{disabled:g||C,variant:"plain",color:"neutral",onClick:q=>{q.stopPropagation(),e.toggleModal()},children:e.labels.close})]})]}),l.jsx(Ke,{showToast:B,color:F,message:O,hideToast:L})]})})},GN=e=>{const[t,n]=y.useState(!1),r=e.generatedEntity,i=()=>{if(!r)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noPreviewAvailable})});const a=()=>l.jsxs(p.Table,{variant:"outlined",size:"sm",sx:{width:"100%",maxWidth:"100%","& > thead > tr > th:first-child, & > tbody > tr > td:first-child":{textAlign:"left"},"--TableCell-paddingX":"0.5rem",cursor:"default","& > tbody > tr:hover":{backgroundColor:"transparent"},"& > thead > tr > th":{backgroundColor:"#fff",verticalAlign:"middle"},"& > thead > tr > th, & > tbody > tr > td":{textAlign:"right"}},children:[l.jsx("thead",{children:l.jsx("tr",{children:l.jsx("th",{children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.questions})})})}),l.jsx("tbody",{children:r.questions.map((c,s)=>{var u;return l.jsx("tr",{children:l.jsx("td",{children:l.jsxs(p.Typography,{level:"body-sm",children:[c.question," ",l.jsx(p.Typography,{children:(u=c.options)==null?void 0:u.map((f,d)=>l.jsx(p.Chip,{color:f.correct?"success":"neutral",variant:f.correct?"solid":"outlined",sx:{mr:1},size:"sm",children:f.option},`question-option-${d}`))})]})})},`question-${s}`)})})]});return l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[l.jsxs(p.Box,{role:"button",tabIndex:0,onClick:()=>n(!t),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(s=>!s))},sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"}},children:[l.jsx(p.Typography,{level:"body-sm",sx:{flexGrow:1},children:r.title}),l.jsx(p.Tooltip,{title:t?"":e.labels.expand,children:l.jsx(p.IconButton,{"aria-label":"expand row",variant:"plain",color:"neutral",size:"sm",sx:{"&:hover":{backgroundColor:"background.surface"}},children:t?l.jsx(Sb,{}):l.jsx(bs,{})})})]}),l.jsx(p.Box,{sx:{display:t?"block":"none",p:1},children:t?a():null})]})},o=()=>{if(!e.races||e.races.length===0)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noRacesFound})});const a=e.races.filter(s=>s.status==="Completed"),c=e.races.filter(s=>s.status==="Scheduled");return l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[a.map(s=>{var u;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{onClick:()=>e.setSelectedRaceId(s.id.toString()),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),e.setSelectedRaceId(s.id.toString()))},role:"button",tabIndex:0,sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},backgroundColor:e.selectedRaceId===s.id.toString()?"rgba(0,0,0,0.04)":"transparent"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedRace",value:s.id.toString(),checked:e.selectedRaceId===s.id.toString(),onChange:f=>e.setSelectedRaceId(f.target.value),sx:{mr:1}}),l.jsx(p.Tooltip,{title:s.competition.name+((u=s.competition.location)!=null&&u.country?` (${s.competition.location.country})`:""),children:l.jsx(p.Avatar,{src:s.circuit.image||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(s.date).format("HH:mm DD.MM.YYYY"),"]"]}),l.jsx(p.Typography,{level:"body-sm",fontWeight:600,children:s.competition.name}),l.jsx(p.Typography,{level:"body-sm",children:s.circuit.name}),l.jsx(p.Chip,{variant:"solid",color:"success",size:"sm",children:s.status})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`completed-race-${s.id}`)}),c.map(s=>{var u;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",opacity:.6,cursor:"not-allowed"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedRace",value:s.id.toString(),disabled:!0,sx:{mr:1}}),l.jsx(p.Tooltip,{title:s.competition.name+((u=s.competition.location)!=null&&u.country?` (${s.competition.location.country})`:""),children:l.jsx(p.Avatar,{src:s.circuit.image||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(s.date).format("HH:mm DD.MM.YYYY"),"]"]}),l.jsx(p.Typography,{level:"body-sm",children:s.competition.name}),l.jsx(p.Typography,{level:"body-sm",children:s.circuit.name}),l.jsx(p.Chip,{variant:"outlined",color:"neutral",size:"sm",children:s.status})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`scheduled-race-${s.id}`)})]})};return e.loading?l.jsx(p.Box,{sx:{height:240},children:l.jsx(hi,{my:0})}):l.jsxs(l.Fragment,{children:[e.step==="search"?o():i(),l.jsx(p.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:l.jsx(p.Button,{size:"sm",color:"primary",variant:"outlined",disabled:!e.selectedRaceId,onClick:e.onGenerate,children:e.step==="search"?e.labels.generate:e.labels.regenerate})})]})},Tb=e=>{const t=e==null?void 0:e.toLowerCase();return t&&Ti[t]?Ti[t].key:"en"},Ns=()=>new Date().getFullYear(),YN=()=>{const e=Ns();return[e,e-1,e-2]},KN={Login:gM,InformationInput:on,RichText:bc,HeaderButtons:HP,MarketSelection:PM,Accordion:_T,DynamicFields:sD,BasicSelect:DT,BooleanSwitch:pi,Branding:zP,ProfileSearchSelect:JL,RangeCalendar:oD,CompetitionSearchSelect:QL,Related:MM,Images:WR,Duration:iD,DatePickerComponent:co,Flags:jR,Spinner:hi,Tags:jm,Toast:Ke,AdContent:PT,Match:DM,Winners:NB,CompetitionsSearchSelect:qL,TeamsSearchSelect:zm,CustomSelect:qM,Schedule:VM,NoPermissionCard:aD,CustomFlatpickrCalendar:tu,ContextSelectFilter:jB,NumberInput:Tu,EntityContext:y$,MiniGamesImages:C$,AuthRequirement:w$,SortableList:fN,ItemsPerPageFilter:hN,ImageCard:mo,RelatedRelationship:EN,ExportUsersLeads:kN,SignOutButton:gg,BasicSortableList:PN,WidgetEmbedCode:DN,WidgetListEmbedCode:MN,AdvancedProfileSearchSelect:LN,FormatNumber:BN,PlayersSearchSelect:NN,GenerateFootballPostMatchModal:WN,GenerateFormula1PostEventModal:e=>{var M,V;const[t,n]=y.useState(Tb(e.defaultLanguage)),[r,i]=y.useState(Ns()),[o,a]=y.useState([]),[c,s]=y.useState(!1),[u,f]=y.useState(""),[d,h]=y.useState("search"),[g,v]=y.useState(!1),[m,b]=y.useState(null),[x,S]=y.useState(!1),[C,I]=y.useState(!1),[w,A]=y.useState(""),[E,k]=y.useState("danger"),B=y.useMemo(()=>!!m,[m]);y.useEffect(()=>{e.isOpen?F(Ns()):(n(Tb(e.defaultLanguage)),i(Ns()),a([]),f(""),h("search"),b(null))},[e.isOpen]);const{https:G}=Ye(),O=()=>{A(""),I(!1)},T=W=>{let Z="",D="danger";switch(W){case"on_generate_failed":Z=e.labels.onEntityGenerateErrorMessage;break;case"on_create":Z=e.labels.onEntityCreateMessage,D="success";break;case"on_create_failed":Z=e.labels.onEntityCreateErrorMessage;break;case"fetch_races_failed":Z=e.labels.fetchRacesErrorMessage;break}k(D),A(Z),I(!0)},F=W=>_(this,null,function*(){s(!0);const Z=yield G.apiSports.getRaces(W),D=yield Z.json();Z.ok||(console.error("Error fetching races:",D),s(!1),a([]),T("fetch_races_failed")),a(D.response||[]),s(!1)}),H=W=>{i(W),f(""),F(W)},j=()=>_(this,null,function*(){v(!0);const W=yield G.generatePostMatchQuiz({sportType:"formula1",lang:t,eventId:u});if(!(W!=null&&W.ok)){const D=yield W==null?void 0:W.json();console.error("Failed to generate AI content",D),v(!1),T("on_generate_failed");return}const Z=yield W==null?void 0:W.json();b(Z),v(!1),h("preview")}),N=()=>_(this,null,function*(){S(!0);let W=null;const Z=m;if(W=yield G.createClassicQuiz(Z),!(W!=null&&W.ok)){const D=yield W==null?void 0:W.json();console.error("Failed to create content",D),S(!1),T("on_create_failed");return}S(!1),T("on_create")});return l.jsx(p.Modal,{open:e.isOpen,onClose:()=>{g||x||e.toggleModal()},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.ModalDialog,{sx:{backgroundColor:"white",minWidth:"50%",height:900},children:[l.jsx(p.DialogTitle,{children:e.labels.generateFormulaOnePostEventModalTitle}),l.jsx(p.Divider,{}),l.jsx(p.DialogContent,{sx:{overflowX:"hidden"},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2,mb:2},children:[l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.language}),l.jsx(p.Select,{value:t,onChange:(W,Z)=>Z&&n(Z),indicator:null,disabled:!!m,startDecorator:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[t]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[t]||"gb").toLowerCase()}.png`,alt:((M=Object.values(Ie).find(W=>W.key===t))==null?void 0:M.name)||"Language"}),sx:{minHeight:38},children:Object.values(Ie).map(W=>l.jsxs(p.Option,{value:W.key,label:W.name,children:[l.jsx(p.ListItemDecorator,{children:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[W.key]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[W.key]||"gb").toLowerCase()}.png`,alt:W.name})}),W.name]},W.key))}),l.jsx(p.FormHelperText,{children:e.labels.targetLanguageDescription})]}),l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.season}),l.jsx(p.Select,{value:r,onChange:(W,Z)=>Z&&H(Z),disabled:!!m,sx:{minHeight:38},children:YN().map(W=>l.jsx(p.Option,{value:W,children:W},W))}),l.jsx(p.FormHelperText,{children:e.labels.seasonDescription})]})]}),l.jsxs(p.Stepper,{sx:{my:2,width:"100%","--StepIndicator-size":"3rem","--Step-connectorInset":"0px",[`& .${Ci.root}`]:{borderWidth:3},[`& .${ur.root}::after`]:{height:3},[`& .${ur.completed}`]:{[`& .${Ci.root}`]:{borderColor:"primary.300",color:"primary.300"},"&::after":{bgcolor:"primary.300"}},[`& .${ur.active}`]:{[`& .${Ci.root}`]:{borderColor:"currentColor"}},[`& .${ur.disabled} *`]:{color:"neutral.outlinedDisabledColor"}},children:[l.jsx(p.Step,{active:d==="search",orientation:"vertical",indicator:l.jsx(p.Tooltip,{title:d==="preview"?(V=e.labels)==null?void 0:V.searchRaceTooltip:"",placement:"right",children:l.jsx(p.StepIndicator,{variant:d==="search"?"solid":"outlined",color:"primary",onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&d==="preview"&&(W.preventDefault(),b(null),h("search"))},sx:$({cursor:d==="preview"?"pointer":"default"},d==="preview"&&{animation:"pulse 2s infinite","@keyframes pulse":{"0%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0.7)"},"70%":{boxShadow:"0 0 0 10px rgba(25, 118, 210, 0)"},"100%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0)"}},"&:hover":{animation:"none",boxShadow:"0 0 0 4px rgba(25, 118, 210, 0.3)"}}),role:"button",tabIndex:d==="preview"?0:-1,children:l.jsx(Cb,{})})}),children:l.jsx(p.Typography,{sx:$({textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},d==="preview"&&{cursor:"pointer"}),onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&d==="preview"&&(W.preventDefault(),b(null),h("search"))},role:"button",tabIndex:d==="preview"?0:-1,children:e.labels.searchRace})}),l.jsx(p.Step,{orientation:"vertical",active:d==="preview",disabled:d!=="preview",indicator:l.jsx(p.StepIndicator,{variant:d==="preview"?"solid":"outlined",color:"primary",children:l.jsx(wb,{})}),children:l.jsx(p.Typography,{sx:{textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},children:e.labels.preview})})]}),l.jsx(p.Sheet,{variant:"outlined",sx:{mt:2,p:1,borderRadius:"sm",bgcolor:"background.surface"},children:l.jsx(GN,{step:d,loading:c||g,races:o,selectedRaceId:u,generatedEntity:m,labels:e.labels,setSelectedRaceId:f,onGenerate:j,setGeneratedEntity:b})})]})}),l.jsxs(p.DialogActions,{children:[l.jsx(p.Button,{variant:"solid",color:"primary",loading:x,disabled:!B||g,onClick:N,children:e.labels.create}),l.jsx(p.Button,{disabled:g||x,variant:"plain",color:"neutral",onClick:W=>{W.stopPropagation(),e.toggleModal()},children:e.labels.close})]})]}),l.jsx(Ke,{showToast:C,color:E,message:w,hideToast:O})]})})}},Eb=y.createContext(null),QN=({children:e})=>l.jsx(Eb.Provider,{value:KN,children:e}),qN=()=>{const e=y.useContext(Eb);if(!e)throw new Error("useComponentContext must be used within a ComponentProvider");return e},kb=425,_b=1024;return{APIProvider:US,AuthProvider:VS,AuthContext:Kf,ComponentProvider:QN,useComponentContext:qN,useAPIContext:Ye,useIsMobile:()=>{const[e,t]=y.useState(window.innerWidth<=_b),[n,r]=y.useState(window.innerWidth<=kb);return y.useLayoutEffect(()=>{const i=()=>{t(window.innerWidth<=_b),r(window.innerWidth<=kb)};return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),{isMobile:e,isPhone:n}},constants:{supportedLanguages:Ie,languagesMap:Ti}}});
2498
+ ></div>`,G=({title:F})=>l.jsx(p.Tooltip,{title:F,sx:{maxWidth:300},children:l.jsx(ar,{color:"primary"})}),O=()=>l.jsxs(p.Card,{sx:{pb:1,mb:3},children:[l.jsx(on,{label:t.classicQuizURL,placeholder:"",defaultValue:i,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.quizzesInfoMessage}),onChange:F=>o(F.target.value)}),l.jsx(on,{label:t.eitherOrURL,placeholder:"",defaultValue:a,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.eitherOrsInfoMessage}),onChange:F=>c(F.target.value)}),l.jsx(on,{label:t.pollURL,placeholder:"",defaultValue:s,required:!1,size:"md",endDecorator:l.jsx(G,{title:t.pollsInfoMessage}),onChange:F=>u(F.target.value)})]}),T=()=>l.jsxs(p.Card,{sx:{pb:1,mb:3},children:[l.jsx(Tu,{label:t.itemsPerPage,description:t.itemsPerPageDescription,defaultValue:f,onChange:F=>d(F||null),size:"md"}),l.jsx(Tu,{label:t.itemsPerRow,description:t.itemsPerRowDescription,defaultValue:h,onChange:F=>g(F||null),size:"md"}),l.jsxs(p.FormControl,{sx:()=>({marginBottom:"16px"}),children:[l.jsx(p.FormLabel,{color:"primary",children:t.mode}),l.jsx(p.Select,{defaultValue:v,onChange:(F,H)=>m(H),children:ON.map((F,H)=>l.jsx(p.Option,{value:F,children:RN[F]},`basic-select-${F}-${H}`))}),l.jsx(p.FormHelperText,{children:t.modeDescription})]})]});return l.jsxs(p.Box,{mt:1,children:[T(),l.jsx(pi,{defaultValue:n,label:t.configureURLs,labelPosition:"end",description:"",descriptionColor:"neutral",disabled:!1,onChange:F=>{F===!1&&(o(""),c(""),u("")),r(F)}}),n&&O(),l.jsxs(p.Box,{position:"relative",mb:1,children:[l.jsx(p.Textarea,{value:B,minRows:"5",maxRows:"20",readOnly:!0,onMouseDown:F=>F.preventDefault(),sx:{cursor:"default","&:hover":{cursor:"default"},"& textarea":{cursor:"default"}}}),l.jsx(p.Tooltip,{title:t.copyToClipboard,children:l.jsx(p.Button,{onClick:()=>{navigator.clipboard.writeText(B)},sx:{position:"absolute",top:"10px",right:"10px",zIndex:1},variant:"soft",color:"neutral",children:l.jsx(Me.ContentCopy,{})})})]}),l.jsx(p.Alert,{variant:"outlined",color:"primary",startDecorator:l.jsx(ar,{}),sx:{mb:1,width:"fit-content"},children:l.jsxs(p.Typography,{color:"primary",fontSize:14,fontWeight:500,children:[t.divElementTextInfo,l.jsx(p.Link,{href:"https://docs.fansunitedmedia.com/docs/user-centric-widgets#/",underline:"always",target:"_blank",rel:"noopener noreferrer",children:"User-centric widgets"})]})})]})},yb=e=>(e==null?void 0:e.map(t=>({id:t.id,value:t.nickname?t.nickname:t.name||`No name ${t.id.slice(0,5)}`,label:t.nickname?t.nickname:t.name||`No name ${t.id.slice(0,5)}`,avatar:t.avatar})))||[],LN=({labels:e,ids:t,onChange:n})=>{const[r,i]=y.useState([]),[o,a]=y.useState([]),[c,s]=y.useState(""),[u,f]=y.useState("name"),[d,h]=y.useState(!1),[g,v]=y.useState(!1),{sdk:m}=Ye(),b=!0,x=()=>v(!g),S=(A,E)=>{i(E);const k=E.map(B=>B.id);n(k&&k.length?k:null)},C=3;y.useEffect(()=>{!c&&t&&t.length&&m.profile.getByIds(t,void 0,b).then(A=>{i(yb(A))}).catch(A=>{x(),console.error(A),i([])})},[]);const I=y.useMemo(()=>sr((A,E)=>{h(!0),m.profile.getByIds(E==="id"?[A]:[],E==="name"?A:void 0,b).then(k=>{a([...yb(k)]),h(!1)}).catch(k=>{console.error(k),x(),a([]),h(!1)})},300),[]);y.useEffect(()=>{if(!c||c.length<C){a([]);return}return I(c,u),()=>I.cancel()},[c,I,u]);const w=(A,E)=>A.map((k,B)=>{var G;return l.jsx(p.Chip,{variant:"solid",endDecorator:l.jsx(p.ChipDelete,{color:"danger",sx:{marginRight:.5},variant:"plain",onClick:O=>E({index:B}).onClick(O),children:l.jsx(Me.Close,{fontSize:"small"})}),sx:{marginLeft:"3px",marginY:"1px",backgroundColor:"#e0f3ff",padding:"2px",borderRadius:4,"&:hover":{cursor:"default"}},children:l.jsxs(p.Box,{display:"flex",alignItems:"center",mr:1,children:[l.jsx(p.Avatar,{sx:{width:"1.5rem",height:" 1.5rem",mr:.5,borderRadius:"0.75rem"},src:(G=k.avatar)!=null?G:Oe.avatar}),l.jsx(p.Typography,{children:k.label})]})},k.id)});return l.jsxs(l.Fragment,{children:[l.jsx(p.Box,{sx:{marginBottom:"16px"},children:l.jsx(p.Autocomplete,{forcePopupIcon:!1,multiple:!0,loading:d,disableClearable:!0,slotProps:{input:{sx:{"&::placeholder":{fontSize:"14px"}}},root:{sx:{boxShadow:"none",backgroundColor:"white",minHeight:38}}},isOptionEqualToValue:(A,E)=>A.id===E.id,endDecorator:l.jsxs(l.Fragment,{children:[d&&l.jsx(p.CircularProgress,{size:"sm",sx:{bgcolor:"primary",marginRight:2}}),l.jsx(p.Divider,{orientation:"vertical"}),l.jsxs(p.Select,{variant:"plain",value:u,onChange:(A,E)=>f(E),slotProps:{listbox:{variant:"outlined"}},sx:{mr:-1.5,"&:hover":{bgcolor:"transparent"}},children:[l.jsx(p.Option,{value:"name",children:e.searchByName}),l.jsx(p.Option,{value:"id",children:e.searchById})]})]}),placeholder:r.length>0?"":e.excludedProfilesPlaceholder,options:o,filterOptions:A=>A.filter(E=>!r.some(k=>k.value===E.value)),onInputChange:(A,E)=>{s(E)},onChange:S,getOptionKey:A=>A.id,value:r,renderTags:w,renderOption:(A,E)=>{var k;return l.jsx(p.AutocompleteOption,J($({},A),{children:l.jsxs(p.Box,{display:"flex",alignItems:"center",mr:1,children:[l.jsx(p.Avatar,{sx:{width:"1.5rem",height:" 1.5rem",mr:.5,borderRadius:"0.75rem"},src:(k=E.avatar)!=null?k:Oe.avatar}),l.jsx(p.Typography,{children:E.label})]})}))}})}),l.jsx(Ke,{showToast:g,message:e.searchProfilesErrorMessage,color:"danger",hideToast:x})]})},BN=({value:e,sx:t,tooltipPlacement:n})=>{const r=s=>{const u=Math.abs(s);return u>=1e9?(s/1e9).toFixed(1)+"b":u>=1e6?(s/1e6).toFixed(1)+"m":u>=1e3?(s/1e3).toFixed(1)+"k":s.toString()},i=s=>new Intl.NumberFormat("en-US").format(s),o=Math.abs(e)>=1e3,a=r(e),c=i(e);return o?l.jsx(p.Tooltip,{title:c,placement:n,arrow:!0,children:l.jsx(p.Typography,{sx:t,children:a})}):l.jsx(p.Typography,{sx:t,children:a})},$N=(e,t,n,r)=>{if(e&&e.length===0){n([]);return}t.football.getPlayers({playerIds:e}).then(i=>{const o=i.data.map(a=>xb(a));n(o)}).catch(i=>{console.error("Error fetching players by ID:",i),r()})},xb=e=>{var t,n,r,i,o;return{id:e.id,name:e.name,avatar:((t=e.assets)==null?void 0:t.headshot)||Oe.avatar,countryName:((n=e.country)==null?void 0:n.name)||"Unknown",countryFlag:((i=(r=e.country)==null?void 0:r.assets)==null?void 0:i.flag)||Oe.flag,teams:((o=e.teams)==null?void 0:o.map(a=>{var c;return{id:a.id,name:a.name,logo:((c=a.assets)==null?void 0:c.logo)||Oe.team}}))||[]}},FN=({player:e,onRemove:t})=>l.jsx(p.Tooltip,{title:l.jsxs(p.Box,{sx:{p:1},children:[l.jsx(p.Typography,{level:"body-sm",fontWeight:"bold",children:e.name}),l.jsxs(p.Typography,{level:"body-xs",sx:{display:"flex",alignItems:"center",gap:.5,mt:.5},children:[l.jsx("img",{src:e.countryFlag,alt:e.countryName,width:16,height:12,loading:"lazy"}),e.countryName]}),e.teams&&e.teams.length>0&&l.jsxs(p.Box,{sx:{mt:.5},children:[l.jsx(p.Typography,{level:"body-xs",sx:{mb:.5},children:"Teams:"}),l.jsx(p.Box,{sx:{display:"flex",flexDirection:"column",gap:.25},children:e.teams.map((n,r)=>l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[l.jsx("img",{src:n.logo,alt:n.name,width:16,height:16,style:{borderRadius:"2px"},loading:"lazy"}),l.jsx(p.Typography,{level:"body-xs",children:n.name})]},r))})]})]}),placement:"left",variant:"solid",sx:{"--Tooltip-radius":"8px",maxWidth:300,bgcolor:"background.level1"},children:l.jsxs(p.Box,{sx:{display:"inline-flex",alignItems:"center",gap:.5,backgroundColor:"#e0f3ff",borderRadius:"50px",padding:"2px 8px 2px 2px",margin:"2px",position:"relative","&:hover":{backgroundColor:"#d0e8ff",cursor:"default"}},children:[l.jsx(p.Avatar,{src:e.avatar,alt:e.name,size:"sm",sx:{width:24,height:24,border:"1px solid #fff"}}),l.jsx(p.Typography,{level:"body-sm",sx:{fontSize:"12px",maxWidth:80,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),l.jsx(p.IconButton,{size:"sm",variant:"plain",color:"danger",onClick:t,sx:{minHeight:16,minWidth:16,padding:0,ml:.5,"&:hover":{backgroundColor:"rgba(255, 0, 0, 0.1)"}},children:l.jsx(Me.Close,{sx:{fontSize:12}})})]})}),NN=({labels:e,teamIds:t,selectedPlayers:n,onChangePlayers:r})=>{const[i,o]=y.useState([]),[a,c]=y.useState([]),[s,u]=y.useState([]),[f,d]=y.useState(!1),[h,g]=y.useState(""),[v,m]=y.useState(!1),{sdk:b}=Ye(),x=()=>m(!v),S=t&&t.length>0,C=(k,B)=>{o(B),r(B)},I=()=>_(this,null,function*(){if(S){d(!0);try{const k=t.map(O=>b.football.getTeamById(O)),B=yield Promise.all(k),G=[];B.forEach(O=>{if(O.squad&&O.squad.length>0){const T=O.squad.map(F=>{var H,j,N,M,V;return{id:F.id,name:F.name,avatar:((H=F.assets)==null?void 0:H.headshot)||Oe.avatar,countryName:((j=F.country)==null?void 0:j.name)||"Unknown",countryFlag:((M=(N=F.country)==null?void 0:N.assets)==null?void 0:M.flag)||Oe.flag,teams:[{id:O.id,name:O.name,logo:((V=O.assets)==null?void 0:V.logo)||Oe.team}]}}).sort((F,H)=>F.name.localeCompare(H.name));G.push(...T)}}),u(G),c(G)}catch(k){console.error("Error fetching team players:",k),x()}finally{d(!1)}}}),w=k=>{if(!k){c(s);return}const B=s.filter(G=>G.name.toLowerCase().includes(k.toLowerCase()));c(B)};y.useEffect(()=>{$N(n,b,o,x)},[n]),y.useEffect(()=>{S&&I()},[t]);const A=y.useMemo(()=>sr(k=>{if(!S){if(!k||k.length<2){c([]),d(!1);return}d(!0),b.football.getPlayers({name:k,sortField:"name",sortOrder:"asc"}).then(B=>{const G=B.data.map(O=>xb(O));c(G),d(!1)}).catch(B=>{console.error("Error searching players:",B),c([]),d(!1),x()})}},300),[b,S]);y.useEffect(()=>(S?w(h):A(h),()=>{S||A.cancel()}),[h,S]);const E=(k,B)=>k.map((G,O)=>l.jsx(FN,{player:G,onRemove:()=>{const T=B({index:O});T.onClick&&T.onClick({})}},G.id));return l.jsxs(l.Fragment,{children:[l.jsx(p.Autocomplete,{forcePopupIcon:S,multiple:!0,loading:f,slotProps:{input:{sx:{"&::placeholder":{fontSize:"14px"}}},root:{sx:{boxShadow:"none",backgroundColor:"white",minHeight:38,flexWrap:"wrap"}},noOptions:{sx:{}}},isOptionEqualToValue:(k,B)=>k.id===B.id,endDecorator:f?l.jsx(p.CircularProgress,{size:"sm",sx:{bgcolor:"primary"}}):null,placeholder:i.length>0?"":e==null?void 0:e.searchPlayersPlaceholder,options:a,filterSelectedOptions:!0,onInputChange:(k,B)=>{g(B)},onChange:C,getOptionKey:k=>typeof k=="string"?k:k.id,getOptionLabel:k=>typeof k=="string"?k:k.name,value:i,renderTags:E,limitTags:1,renderOption:(k,B)=>{const G={props:k};return l.jsxs(p.AutocompleteOption,J($({},k),{sx:{display:"flex",alignItems:"center",gap:1},children:[l.jsx(p.Avatar,{src:B.avatar,alt:B.name,size:"sm",sx:{width:32,height:32}}),l.jsxs(p.Box,{sx:{flexGrow:1},children:[l.jsx(p.Typography,{level:"body-sm",fontWeight:"bold",children:B.name}),l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[l.jsx("img",{src:B.countryFlag,alt:B.countryName,width:16,height:12,loading:"lazy"}),l.jsx(p.Typography,{level:"body-xs",color:"neutral",children:B.countryName})]})]})]}),`player-option-${B.id}-${G}`)}}),l.jsx(Ke,{showToast:v,message:e.getPlayersErrorMessage,color:"danger",hideToast:x})]})},zN=(e,t={})=>{const{enabled:n=!0}=t,{sdk:r}=Ye(),[i,o]=y.useState(null),[a,c]=y.useState(!1),[s,u]=y.useState(null),[f,d]=y.useState(null),h=y.useMemo(()=>$({},e),[JSON.stringify(e)]),g=y.useCallback(()=>_(this,null,function*(){var v,m;c(!0),u(null);try{const b=yield r.football.getMatches(h);o(b.data),d((m=(v=b.meta)==null?void 0:v.pagination)!=null?m:null)}catch(b){u(b),o([]),d(null)}finally{c(!1)}}),[r,h]);return y.useEffect(()=>{n&&g()},[g,n]),{matches:i,loading:a,error:s,meta:f,refetch:g}},Cb=$e(l.jsx("path",{d:"M4.25 5.61C6.57 8.59 10 13 10 13v5c0 1.1.9 2 2 2s2-.9 2-2v-5s3.43-4.41 5.75-7.39c.51-.66.04-1.61-.8-1.61H5.04c-.83 0-1.3.95-.79 1.61"}),"FilterAltRounded"),wb=$e(l.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.89-2-2-2m0 16H5V7h14zm-5.5-6c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5.67-1.5 1.5-1.5 1.5.67 1.5 1.5M12 9c-2.73 0-5.06 1.66-6 4 .94 2.34 3.27 4 6 4s5.06-1.66 6-4c-.94-2.34-3.27-4-6-4m0 6.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"PreviewRounded"),ur=We("MuiStep",["root","indicator","horizontal","vertical","active","completed","disabled"]),Ci=We("MuiStepIndicator",["root","colorPrimary","colorNeutral","colorDanger","colorSuccess","colorWarning","colorContext","variantPlain","variantOutlined","variantSoft","variantSolid","horizontal","vertical"]),jN=$e(l.jsx("path",{d:"M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6z"}),"KeyboardArrowLeft"),UN=$e(l.jsx("path",{d:"M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z"}),"KeyboardArrowRight"),Sb=$e(l.jsx("path",{d:"M7.41 15.41 12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp");class VN{constructor(){X(this,"id","");X(this,"title","");X(this,"alternative_title",null);X(this,"description",null);X(this,"type",null);X(this,"auth_requirement",null);X(this,"rules",null);X(this,"ad_content",null);X(this,"labels",null);X(this,"branding",null);X(this,"embed_code",null);X(this,"custom_fields",null);X(this,"images",null);X(this,"status","");X(this,"flags",[]);X(this,"context",null);X(this,"options",[]);X(this,"related",[]);X(this,"multiple_choice",!1);X(this,"max_multiple_choice_options",null);X(this,"participation_count",0);X(this,"preferences_enabled",!1);X(this,"max_attempts",1);X(this,"external_activity",null)}}const HN=e=>{const[t,n]=y.useState(!1),[r,i]=y.useState(""),o=e.generatedEntity,a=d=>{const h=new VN;return h.title=d.question||"",h.status="INACTIVE",h.options=(d.options||[]).map(g=>({title:g,description:"",images:{main:"",mobile:"",cover:""},embed_code:null,preference_mappings:[]})),h},c=d=>{i(d.id);const h=a(d);e.setPollRequestBody(h)},s=()=>{if(!o)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noPreviewAvailable})});const d=()=>l.jsxs(p.Table,{variant:"outlined",size:"sm",sx:{width:"100%",maxWidth:"100%","& > thead > tr > th:first-child, & > tbody > tr > td:first-child":{textAlign:"left"},"--TableCell-paddingX":"0.5rem",cursor:"default","& > tbody > tr:hover":{backgroundColor:"transparent"},"& > thead > tr > th":{backgroundColor:"#fff",verticalAlign:"middle"},"& > thead > tr > th, & > tbody > tr > td":{textAlign:"right"}},children:[l.jsx("thead",{children:l.jsx("tr",{children:l.jsx("th",{children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.questions})})})}),l.jsx("tbody",{children:o.questions.map((g,v)=>{var m;return l.jsx("tr",{children:l.jsx("td",{children:l.jsxs(p.Typography,{level:"body-sm",children:[g.question," ",l.jsx(p.Typography,{children:(m=g.options)==null?void 0:m.map((b,x)=>l.jsx(p.Chip,{color:b.correct?"success":"neutral",variant:b.correct?"solid":"outlined",sx:{mr:1},size:"sm",children:b.option},`question-option-${x}`))})]})})},`question-${v}`)})})]}),h=()=>{const g=o.questions||[],v=m=>!m&&m!==0?"neutral":m>=5?"success":m>=4?"primary":m>=3?"warning":"neutral";return l.jsx(p.Box,{component:"ul",sx:{listStyle:"none",m:0,p:0,ml:0,pl:0,marginBlockStart:0,marginBlockEnd:0,marginInlineStart:0,marginInlineEnd:0,paddingInlineStart:0,display:"flex",flexDirection:"column",gap:1},children:g.map((m,b)=>{const x=r===m.id;return l.jsx(p.Box,{component:"li",children:l.jsx(p.Sheet,{variant:"outlined",sx:{p:1,borderRadius:"sm",cursor:"pointer",bgcolor:x?"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))":"background.body",borderColor:x?"primary.solidBg":void 0,"&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},"&:hover .pollOptionChipNeutral":{backgroundColor:"background.level1",borderColor:"neutral.outlinedBorder"}},onClick:()=>c(m),role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),c(m))},children:l.jsxs(p.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1},children:[l.jsx(p.Radio,{name:"selectedPollSuggestion",value:m.id,checked:x,onChange:()=>c(m),size:"sm"}),l.jsxs(p.Box,{sx:{flex:1,minWidth:0},children:[l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[m.category_name?l.jsx(p.Tooltip,{title:e.labels.category,children:l.jsx(p.Chip,{size:"sm",variant:"outlined",color:"neutral",children:m.category_name})}):null,l.jsx(p.Box,{sx:{flex:1}}),m.engagement_score?l.jsx(p.Tooltip,{title:e.labels.engagementScore,children:l.jsx(p.Chip,{size:"sm",variant:"solid",color:v(m.engagement_score),children:m.engagement_score})}):l.jsx(l.Fragment,{})]}),l.jsx(p.Typography,{level:"body-sm",fontWeight:600,sx:{mb:.5},children:m.question}),l.jsx(p.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:(m.options||[]).map((S,C)=>l.jsx(p.Chip,{className:x?void 0:"pollOptionChipNeutral",variant:x?"soft":"outlined",color:x?"primary":"neutral",size:"sm",sx:{mr:.5,mb:.5},children:S},`poll-suggestion-opt-${C}`))})]})]})})},`poll-suggestion-${m.id||b}`)})})};return e.entityType==="poll"?l.jsx(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",p:1,maxHeight:"300px",my:.5},children:h()}):l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[l.jsxs(p.Box,{role:"button",tabIndex:0,onClick:()=>n(!t),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),n(v=>!v))},sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"}},children:[l.jsx(p.Typography,{level:"body-sm",sx:{flexGrow:1},children:o.title}),l.jsx(p.Tooltip,{title:t?"":e.labels.expand,children:l.jsx(p.IconButton,{"aria-label":"expand row",variant:"plain",color:"neutral",size:"sm",sx:{"&:hover":{backgroundColor:"background.surface"}},children:t?l.jsx(Sb,{}):l.jsx(bs,{})})})]}),l.jsx(p.Box,{sx:{display:t?"block":"none",p:1},children:t?d():null})]})},u=()=>!e.matches||e.matches.length===0?l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noMatchesFound})}):l.jsx(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:e.matches.map(d=>{var h,g,v,m,b,x,S,C,I,w,A,E,k,B,G,O,T,F,H,j,N,M,V,W;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{onClick:()=>e.setSelectedMatchId(d.id),onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),e.setSelectedMatchId(d.id))},role:"button",tabIndex:0,sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},backgroundColor:e.selectedMatchId===d.id?"rgba(0,0,0,0.04)":"transparent"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedMatch",value:d.id,checked:e.selectedMatchId===d.id,onChange:Z=>e.setSelectedMatchId(Z.target.value),sx:{mr:1}}),l.jsx(p.Tooltip,{title:(((g=(h=d.context)==null?void 0:h.competition)==null?void 0:g.name)||"Competition with no name")+((b=(m=(v=d.context)==null?void 0:v.competition)==null?void 0:m.country)!=null&&b.name?` (${d.context.competition.country.name})`:""),children:l.jsx(p.Avatar,{src:((C=(S=(x=d.context)==null?void 0:x.competition)==null?void 0:S.assets)==null?void 0:C.logo)||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(d.kickoffAt).format("HH:mm DD.MM.YYYY"),"]"]}),(I=d.homeTeam)!=null&&I.code?l.jsx(p.Tooltip,{title:d.homeTeam.name,children:l.jsxs(p.Box,{display:"flex",gap:.5,alignItems:"center",minWidth:"60px",justifyContent:"flex-end",children:[l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.homeTeam.id)?700:400,children:d.homeTeam.code||d.homeTeam.name}),l.jsx(p.Avatar,{src:((w=d.homeTeam.assets)==null?void 0:w.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})]})}):l.jsxs(l.Fragment,{children:[l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.homeTeam.id)?700:400,children:d.homeTeam.code||d.homeTeam.name}),l.jsx(p.Avatar,{src:((A=d.homeTeam.assets)==null?void 0:A.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})]}),((k=(E=d==null?void 0:d.scores)==null?void 0:E.ftScore)==null?void 0:k.homeGoals)!==null&&((G=(B=d==null?void 0:d.scores)==null?void 0:B.ftScore)==null?void 0:G.awayGoals)!==null?l.jsx(p.Chip,{variant:"outlined",children:((F=(T=(O=d.scores)==null?void 0:O.ftScore)==null?void 0:T.homeGoals)!=null?F:"")+":"+((N=(j=(H=d.scores)==null?void 0:H.ftScore)==null?void 0:j.awayGoals)!=null?N:"")}):" : ",(M=d.awayTeam)!=null&&M.code?l.jsx(p.Tooltip,{title:d.awayTeam.name,children:l.jsxs(p.Box,{display:"flex",gap:.5,alignItems:"center",children:[l.jsx(p.Avatar,{src:((V=d.awayTeam.assets)==null?void 0:V.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}})," ",l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.awayTeam.id)?700:400,children:d.awayTeam.code||d.awayTeam.name})]})}):l.jsxs(l.Fragment,{children:[l.jsx(p.Avatar,{src:((W=d.awayTeam.assets)==null?void 0:W.logo)||Oe.team,sx:{width:"20px",height:"20px"},slotProps:{img:{loading:"lazy"}}}),l.jsx(p.Typography,{fontWeight:e.teamIdsFilter&&e.teamIdsFilter.includes(d.awayTeam.id)?700:400,children:d.awayTeam.code||d.awayTeam.name})]})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`search-matches-custom-${d.id}`)})}),f=()=>l.jsxs(l.Fragment,{children:[l.jsx(p.Typography,{level:"body-xs",children:e.pagination?`${e.labels.page} ${e.pagination.currentPage} ${e.labels.of} ${e.pagination.numberOfPages} • ${e.pagination.totalItems} ${e.labels.total}`:""}),l.jsxs(p.Box,{sx:{display:"flex",gap:1},children:[l.jsx(p.IconButton,{size:"sm",color:"neutral",variant:"outlined",disabled:!e.pagination||e.pagination&&e.pagination.currentPage<=1,onClick:()=>e.setPage(d=>Math.max(1,d-1)),sx:{bgcolor:"background.surface"},children:l.jsx(jN,{})}),l.jsx(p.IconButton,{size:"sm",color:"neutral",variant:"outlined",disabled:!e.pagination||e.pagination&&e.pagination.currentPage>=e.pagination.numberOfPages,onClick:()=>e.setPage(d=>e.pagination?Math.min(e.pagination.numberOfPages,d+1):d+1),sx:{bgcolor:"background.surface"},children:l.jsx(UN,{})})]})]});return e.loading?l.jsx(p.Box,{sx:{height:240},children:l.jsx(hi,{my:0})}):l.jsxs(l.Fragment,{children:[e.step==="search"?u():s(),l.jsxs(p.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[l.jsx(p.Button,{size:"sm",color:"primary",variant:"outlined",disabled:!e.selectedMatchId,onClick:e.onGenerate,children:e.step==="search"?e.labels.generate:e.labels.regenerate}),e.step==="search"?f():l.jsx(l.Fragment,{})]})]})},Nu=ft(Date.now()).format("YYYY-MM-DD"),Ib=e=>{const t=e==null?void 0:e.toLowerCase();return t&&Ti[t]?Ti[t].key:"en"},Ab=e=>({fromDate:"",toDate:Nu,competitionIds:e&&e.length?e:void 0,teamIds:void 0,sortOrder:"desc",status:"finished"}),WN=e=>{var le;const[t,n]=y.useState(Ib(e.defaultLanguage)),[r,i]=y.useState(Ab(e.competitionsScope)),[o,a]=y.useState(1),[c,s]=y.useState(""),[u,f]=y.useState(!1),[d,h]=y.useState("search"),[g,v]=y.useState(!1),[m,b]=y.useState(null),[x,S]=y.useState(null),[C,I]=y.useState(!1),[w,A]=y.useState(!1),[E,k]=y.useState(""),[B,G]=y.useState(!1),[O,T]=y.useState(""),[F,H]=y.useState("danger"),j=10,N=y.useMemo(()=>{const st=r,{fromDate:q,toDate:se}=st,me=Qe(st,["fromDate","toDate"]),Ee=$({},me);if(q&&(Ee.fromDate=`${q}T00:00:00Z`),se){const qe=ft().add(1,"minute").format("THH:mm:ss")+"Z";Ee.toDate=se+qe}return J($({},Ee),{page:o,limit:j})},[r,o]),M=y.useMemo(()=>!(!m||e.entityType==="poll"&&!x),[m,e.entityType,x]);y.useEffect(()=>()=>{n(Ib),i(Ab(e.competitionsScope)),a(1),s(""),f(!1),h("search"),b(null)},[]);const{https:V}=Ye(),{matches:W,loading:Z,meta:D}=zN(N,{enabled:u}),L=()=>{T(""),G(!1)},U=q=>{let se="",me="danger";switch(q){case"on_generate_failed":se=e.labels.onEntityGenerateErrorMessage;break;case"on_create":se=e.labels.onEntityCreateMessage,me="success";break;case"on_create_failed":se=e.labels.onEntityCreateErrorMessage;break}H(me),T(se),G(!0)},Y=q=>{var me;const se=q.map(Ee=>Ee.id);i(Ee=>J($({},Ee),{teamIds:se||void 0})),a(1),f(!0),e.entityType==="poll"&&(q.length===0?(k(""),A(!1)):k(((me=q[q.length-1])==null?void 0:me.label)||""))},re=q=>{const{name:se,value:me}=q.target;i(Ee=>J($({},Ee),{[se]:me})),f(!0)},ce=()=>_(this,null,function*(){v(!0),e.entityType==="poll"&&S(null);let q=null;switch(e.entityType){case"classic_quiz":q=yield V.generatePostMatchQuiz({sportType:"football",lang:t,eventId:c});break;case"poll":const me=w?E:"";q=yield V.generatePostMatchPoll({targetParticipant:me,lang:t,eventId:c});break}if(!(q!=null&&q.ok)){const me=yield q==null?void 0:q.json();console.error("Failed to generate AI content",me),v(!1),U("on_generate_failed");return}const se=yield q==null?void 0:q.json();if(e.entityType==="poll"){const me=se;me.questions.sort((Ee,st)=>st.engagement_score-Ee.engagement_score),b(me)}else b(se);v(!1),h("preview")}),oe=q=>_(this,null,function*(){I(!0);let se=null;switch(e.entityType){case"classic_quiz":const Ee=m;se=yield V.createClassicQuiz(Ee);break;case"poll":se=yield V.createPoll(x);break}const me=yield se==null?void 0:se.json();if(!(se!=null&&se.ok)){console.error("Failed to create content",me),I(!1),U("on_create_failed");return}if(I(!1),q==="goto"){e.fetchEntityById(me.data.id),U("on_create"),e.toggleModal();return}U("on_create")}),ee=()=>e.entityType==="poll"?l.jsx(p.Checkbox,{disabled:!r.teamIds||r.teamIds.length===0||!!m,checked:w,size:"sm",onChange:q=>{A(q.target.checked)},label:e.labels.useFramingGuidelinesLabel}):l.jsx(l.Fragment,{});return l.jsx(p.Modal,{open:e.isOpen,onClose:()=>{g||C||e.toggleModal()},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.ModalDialog,{sx:{backgroundColor:"white",minWidth:"50%",height:900},children:[l.jsx(p.DialogTitle,{children:e.labels.generateFootballPostMatchModalTitle}),l.jsx(p.Divider,{}),l.jsx(p.DialogContent,{sx:{overflowX:"hidden"},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.FormControl,{size:"sm",sx:{mb:2},children:[l.jsx(p.FormLabel,{children:e.labels.language}),l.jsx(p.Select,{value:t,onChange:(q,se)=>se&&n(se),indicator:null,disabled:!!m,startDecorator:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[t]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[t]||"gb").toLowerCase()}.png`,alt:((le=Object.values(Ie).find(q=>q.key===t))==null?void 0:le.name)||"Language"}),sx:{minWidth:220,minHeight:38},children:Object.values(Ie).map(q=>l.jsxs(p.Option,{value:q.key,label:q.name,children:[l.jsx(p.ListItemDecorator,{children:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[q.key]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[q.key]||"gb").toLowerCase()}.png`,alt:q.name})}),q.name]},q.key))}),l.jsx(p.FormHelperText,{children:e.labels.targetLanguageDescription})]}),l.jsxs(l.Fragment,{children:[l.jsx(zm,{labels:{teamsSelectionPlaceholder:e.labels.teamsSelectionPlaceholder||"",searchTeamsErrorMessage:e.labels.searchTeamsErrorMessage},ids:r.teamIds||[],onChange:Y,scope:e.competitionsScope,readOnly:!!m,AdditionalCheckbox:ee()}),l.jsxs(p.Grid,{container:!0,spacing:2,minWidth:"100%",columns:{xs:0,sm:0,md:12},children:[l.jsx(p.Grid,{xs:6,children:l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.fromDate}),l.jsx(p.Input,{name:"fromDate",type:"date",readOnly:!!m,defaultValue:r.fromDate,onChange:re,sx:{backgroundColor:"#fff",borderRadius:"md",minHeight:"36px"},slotProps:{input:{max:Nu}}})]})}),l.jsx(p.Grid,{xs:6,children:l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.toDate}),l.jsx(p.Input,{name:"toDate",type:"date",defaultValue:r.toDate,readOnly:!!m,onChange:re,sx:{backgroundColor:"#fff",borderRadius:"md",minHeight:"36px"},slotProps:{input:{max:Nu}}})]})})]})]}),l.jsxs(p.Stepper,{sx:{my:2,width:"100%","--StepIndicator-size":"3rem","--Step-connectorInset":"0px",[`& .${Ci.root}`]:{borderWidth:3},[`& .${ur.root}::after`]:{height:3},[`& .${ur.completed}`]:{[`& .${Ci.root}`]:{borderColor:"primary.300",color:"primary.300"},"&::after":{bgcolor:"primary.300"}},[`& .${ur.active}`]:{[`& .${Ci.root}`]:{borderColor:"currentColor"}},[`& .${ur.disabled} *`]:{color:"neutral.outlinedDisabledColor"}},children:[l.jsx(p.Step,{active:d==="search",orientation:"vertical",indicator:l.jsx(p.Tooltip,{title:d==="preview"?e.labels.searchMatchTooltip:"",placement:"right",children:l.jsx(p.StepIndicator,{variant:d==="search"?"solid":"outlined",color:"primary",onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&d==="preview"&&(q.preventDefault(),b(null),h("search"))},sx:$({cursor:d==="preview"?"pointer":"default"},d==="preview"&&{animation:"pulse 2s infinite","@keyframes pulse":{"0%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0.7)"},"70%":{boxShadow:"0 0 0 10px rgba(25, 118, 210, 0)"},"100%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0)"}},"&:hover":{animation:"none",boxShadow:"0 0 0 4px rgba(25, 118, 210, 0.3)"}}),role:"button",tabIndex:d==="preview"?0:-1,children:l.jsx(Cb,{})})}),children:l.jsx(p.Typography,{sx:$({textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},d==="preview"&&{cursor:"pointer"}),onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&d==="preview"&&(q.preventDefault(),b(null),h("search"))},role:"button",tabIndex:d==="preview"?0:-1,children:e.labels.searchMatch})}),l.jsx(p.Step,{orientation:"vertical",active:d==="preview",disabled:d!=="preview",indicator:l.jsx(p.StepIndicator,{variant:d==="preview"?"solid":"outlined",color:"primary",children:l.jsx(wb,{})}),children:l.jsx(p.Typography,{sx:{textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},children:e.labels.preview})})]}),u?l.jsx(p.Sheet,{variant:"outlined",sx:{p:1,borderRadius:"sm",bgcolor:"background.surface"},children:l.jsx(HN,{step:d,loading:Z||g,matches:W,selectedMatchId:c,generatedEntity:m,labels:e.labels,pagination:D,teamIdsFilter:r.teamIds,setPollRequestBody:S,setPage:a,setSelectedMatchId:s,onGenerate:ce,entityType:e.entityType,setGeneratedEntity:b})}):l.jsx(l.Fragment,{})]})}),l.jsxs(p.DialogActions,{children:[l.jsx(p.Button,{variant:"outlined",color:"primary",loading:C,disabled:!M||g,onClick:()=>oe("goto"),children:e.labels.createAndGoTo}),l.jsx(p.Button,{variant:"solid",color:"primary",loading:C,disabled:!M||g,onClick:()=>oe("continue"),children:e.labels.createAndContinue}),l.jsx(p.Button,{disabled:g||C,variant:"plain",color:"neutral",onClick:q=>{q.stopPropagation(),e.toggleModal()},children:e.labels.close})]})]}),l.jsx(Ke,{showToast:B,color:F,message:O,hideToast:L})]})})},GN=e=>{const[t,n]=y.useState(!1),r=e.generatedEntity,i=()=>{if(!r)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noPreviewAvailable})});const a=()=>l.jsxs(p.Table,{variant:"outlined",size:"sm",sx:{width:"100%",maxWidth:"100%","& > thead > tr > th:first-child, & > tbody > tr > td:first-child":{textAlign:"left"},"--TableCell-paddingX":"0.5rem",cursor:"default","& > tbody > tr:hover":{backgroundColor:"transparent"},"& > thead > tr > th":{backgroundColor:"#fff",verticalAlign:"middle"},"& > thead > tr > th, & > tbody > tr > td":{textAlign:"right"}},children:[l.jsx("thead",{children:l.jsx("tr",{children:l.jsx("th",{children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.questions})})})}),l.jsx("tbody",{children:r.questions.map((c,s)=>{var u;return l.jsx("tr",{children:l.jsx("td",{children:l.jsxs(p.Typography,{level:"body-sm",children:[c.question," ",l.jsx(p.Typography,{children:(u=c.options)==null?void 0:u.map((f,d)=>l.jsx(p.Chip,{color:f.correct?"success":"neutral",variant:f.correct?"solid":"outlined",sx:{mr:1},size:"sm",children:f.option},`question-option-${d}`))})]})})},`question-${s}`)})})]});return l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[l.jsxs(p.Box,{role:"button",tabIndex:0,onClick:()=>n(!t),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n(s=>!s))},sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"}},children:[l.jsx(p.Typography,{level:"body-sm",sx:{flexGrow:1},children:r.title}),l.jsx(p.Tooltip,{title:t?"":e.labels.expand,children:l.jsx(p.IconButton,{"aria-label":"expand row",variant:"plain",color:"neutral",size:"sm",sx:{"&:hover":{backgroundColor:"background.surface"}},children:t?l.jsx(Sb,{}):l.jsx(bs,{})})})]}),l.jsx(p.Box,{sx:{display:t?"block":"none",p:1},children:t?a():null})]})},o=()=>{if(!e.races||e.races.length===0)return l.jsx(p.Box,{sx:{height:240,display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(p.Typography,{level:"body-sm",children:e.labels.noRacesFound})});const a=e.races.filter(s=>s.status==="Completed"),c=e.races.filter(s=>s.status==="Scheduled");return l.jsxs(p.Sheet,{sx:{overflowY:"auto",borderRadius:"sm",maxHeight:"300px",my:.5},children:[a.map(s=>{var u;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{onClick:()=>e.setSelectedRaceId(s.id.toString()),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),e.setSelectedRaceId(s.id.toString()))},role:"button",tabIndex:0,sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",cursor:"pointer","&:hover":{backgroundColor:"var(--joy-palette-neutral-softBg, rgba(0,0,0,0.04))"},backgroundColor:e.selectedRaceId===s.id.toString()?"rgba(0,0,0,0.04)":"transparent"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedRace",value:s.id.toString(),checked:e.selectedRaceId===s.id.toString(),onChange:f=>e.setSelectedRaceId(f.target.value),sx:{mr:1}}),l.jsx(p.Tooltip,{title:s.competition.name+((u=s.competition.location)!=null&&u.country?` (${s.competition.location.country})`:""),children:l.jsx(p.Avatar,{src:s.circuit.image||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(s.date).format("HH:mm DD.MM.YYYY"),"]"]}),l.jsx(p.Typography,{level:"body-sm",fontWeight:600,children:s.competition.name}),l.jsx(p.Typography,{level:"body-sm",children:s.circuit.name}),l.jsx(p.Chip,{variant:"solid",color:"success",size:"sm",children:s.status})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`completed-race-${s.id}`)}),c.map(s=>{var u;return l.jsxs(y.Fragment,{children:[l.jsxs(p.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:1,fontSize:"xs",p:1,borderRadius:"sm",opacity:.6,cursor:"not-allowed"},children:[l.jsx(p.Radio,{size:"sm",name:"selectedRace",value:s.id.toString(),disabled:!0,sx:{mr:1}}),l.jsx(p.Tooltip,{title:s.competition.name+((u=s.competition.location)!=null&&u.country?` (${s.competition.location.country})`:""),children:l.jsx(p.Avatar,{src:s.circuit.image||Oe.competition,sx:{width:"15px",height:"15px"},slotProps:{img:{loading:"lazy"}}})}),l.jsxs(p.Typography,{level:"body-sm",children:["[",ft(s.date).format("HH:mm DD.MM.YYYY"),"]"]}),l.jsx(p.Typography,{level:"body-sm",children:s.competition.name}),l.jsx(p.Typography,{level:"body-sm",children:s.circuit.name}),l.jsx(p.Chip,{variant:"outlined",color:"neutral",size:"sm",children:s.status})]}),l.jsx(p.Divider,{sx:{my:.5}})]},`scheduled-race-${s.id}`)})]})};return e.loading?l.jsx(p.Box,{sx:{height:240},children:l.jsx(hi,{my:0})}):l.jsxs(l.Fragment,{children:[e.step==="search"?o():i(),l.jsx(p.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:l.jsx(p.Button,{size:"sm",color:"primary",variant:"outlined",disabled:!e.selectedRaceId,onClick:e.onGenerate,children:e.step==="search"?e.labels.generate:e.labels.regenerate})})]})},Tb=e=>{const t=e==null?void 0:e.toLowerCase();return t&&Ti[t]?Ti[t].key:"en"},Ns=()=>new Date().getFullYear(),YN=()=>{const e=Ns();return[e,e-1,e-2]},KN={Login:gM,InformationInput:on,RichText:bc,HeaderButtons:HP,MarketSelection:PM,Accordion:_T,DynamicFields:sD,BasicSelect:DT,BooleanSwitch:pi,Branding:zP,ProfileSearchSelect:JL,RangeCalendar:oD,CompetitionSearchSelect:QL,Related:MM,Images:WR,Duration:iD,DatePickerComponent:co,Flags:jR,Spinner:hi,Tags:jm,Toast:Ke,AdContent:PT,Match:DM,Winners:NB,CompetitionsSearchSelect:qL,TeamsSearchSelect:zm,CustomSelect:qM,Schedule:VM,NoPermissionCard:aD,CustomFlatpickrCalendar:tu,ContextSelectFilter:jB,NumberInput:Tu,EntityContext:y$,MiniGamesImages:C$,AuthRequirement:w$,SortableList:fN,ItemsPerPageFilter:hN,ImageCard:mo,RelatedRelationship:EN,ExportUsersLeads:kN,SignOutButton:gg,BasicSortableList:PN,WidgetEmbedCode:DN,WidgetListEmbedCode:MN,AdvancedProfileSearchSelect:LN,FormatNumber:BN,PlayersSearchSelect:NN,GenerateFootballPostMatchModal:WN,GenerateFormula1PostEventModal:e=>{var M,V;const[t,n]=y.useState(Tb(e.defaultLanguage)),[r,i]=y.useState(Ns()),[o,a]=y.useState([]),[c,s]=y.useState(!1),[u,f]=y.useState(""),[d,h]=y.useState("search"),[g,v]=y.useState(!1),[m,b]=y.useState(null),[x,S]=y.useState(!1),[C,I]=y.useState(!1),[w,A]=y.useState(""),[E,k]=y.useState("danger"),B=y.useMemo(()=>!!m,[m]);y.useEffect(()=>{e.isOpen?F(Ns()):(n(Tb(e.defaultLanguage)),i(Ns()),a([]),f(""),h("search"),b(null))},[e.isOpen]);const{https:G}=Ye(),O=()=>{A(""),I(!1)},T=W=>{let Z="",D="danger";switch(W){case"on_generate_failed":Z=e.labels.onEntityGenerateErrorMessage;break;case"on_create":Z=e.labels.onEntityCreateMessage,D="success";break;case"on_create_failed":Z=e.labels.onEntityCreateErrorMessage;break;case"fetch_races_failed":Z=e.labels.fetchRacesErrorMessage;break}k(D),A(Z),I(!0)},F=W=>_(this,null,function*(){s(!0);const Z=yield G.apiSports.getRaces(W),D=yield Z.json();Z.ok||(console.error("Error fetching races:",D),s(!1),a([]),T("fetch_races_failed")),a(D.response||[]),s(!1)}),H=W=>{i(W),f(""),F(W)},j=()=>_(this,null,function*(){v(!0);const W=yield G.generatePostMatchQuiz({sportType:"formula1",lang:t,eventId:u});if(!(W!=null&&W.ok)){const D=yield W==null?void 0:W.json();console.error("Failed to generate AI content",D),v(!1),T("on_generate_failed");return}const Z=yield W==null?void 0:W.json();b(Z),v(!1),h("preview")}),N=()=>_(this,null,function*(){S(!0);let W=null;const Z=m;if(W=yield G.createClassicQuiz(Z),!(W!=null&&W.ok)){const D=yield W==null?void 0:W.json();console.error("Failed to create content",D),S(!1),T("on_create_failed");return}S(!1),T("on_create")});return l.jsx(p.Modal,{open:e.isOpen,onClose:()=>{g||x||e.toggleModal()},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.ModalDialog,{sx:{backgroundColor:"white",minWidth:"50%",height:900},children:[l.jsx(p.DialogTitle,{children:e.labels.generateFormulaOnePostEventModalTitle}),l.jsx(p.Divider,{}),l.jsx(p.DialogContent,{sx:{overflowX:"hidden"},children:l.jsxs(l.Fragment,{children:[l.jsxs(p.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2,mb:2},children:[l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.language}),l.jsx(p.Select,{value:t,onChange:(W,Z)=>Z&&n(Z),indicator:null,disabled:!!m,startDecorator:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[t]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[t]||"gb").toLowerCase()}.png`,alt:((M=Object.values(Ie).find(W=>W.key===t))==null?void 0:M.name)||"Language"}),sx:{minHeight:38},children:Object.values(Ie).map(W=>l.jsxs(p.Option,{value:W.key,label:W.name,children:[l.jsx(p.ListItemDecorator,{children:l.jsx("img",{loading:"lazy",width:"20",srcSet:`https://flagcdn.com/w40/${(Gn[W.key]||"gb").toLowerCase()}.png 2x`,src:`https://flagcdn.com/w20/${(Gn[W.key]||"gb").toLowerCase()}.png`,alt:W.name})}),W.name]},W.key))}),l.jsx(p.FormHelperText,{children:e.labels.targetLanguageDescription})]}),l.jsxs(p.FormControl,{size:"sm",children:[l.jsx(p.FormLabel,{children:e.labels.season}),l.jsx(p.Select,{value:r,onChange:(W,Z)=>Z&&H(Z),disabled:!!m,sx:{minHeight:38},children:YN().map(W=>l.jsx(p.Option,{value:W,children:W},W))}),l.jsx(p.FormHelperText,{children:e.labels.seasonDescription})]})]}),l.jsxs(p.Stepper,{sx:{my:2,width:"100%","--StepIndicator-size":"3rem","--Step-connectorInset":"0px",[`& .${Ci.root}`]:{borderWidth:3},[`& .${ur.root}::after`]:{height:3},[`& .${ur.completed}`]:{[`& .${Ci.root}`]:{borderColor:"primary.300",color:"primary.300"},"&::after":{bgcolor:"primary.300"}},[`& .${ur.active}`]:{[`& .${Ci.root}`]:{borderColor:"currentColor"}},[`& .${ur.disabled} *`]:{color:"neutral.outlinedDisabledColor"}},children:[l.jsx(p.Step,{active:d==="search",orientation:"vertical",indicator:l.jsx(p.Tooltip,{title:d==="preview"?(V=e.labels)==null?void 0:V.searchRaceTooltip:"",placement:"right",children:l.jsx(p.StepIndicator,{variant:d==="search"?"solid":"outlined",color:"primary",onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&d==="preview"&&(W.preventDefault(),b(null),h("search"))},sx:$({cursor:d==="preview"?"pointer":"default"},d==="preview"&&{animation:"pulse 2s infinite","@keyframes pulse":{"0%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0.7)"},"70%":{boxShadow:"0 0 0 10px rgba(25, 118, 210, 0)"},"100%":{boxShadow:"0 0 0 0 rgba(25, 118, 210, 0)"}},"&:hover":{animation:"none",boxShadow:"0 0 0 4px rgba(25, 118, 210, 0.3)"}}),role:"button",tabIndex:d==="preview"?0:-1,children:l.jsx(Cb,{})})}),children:l.jsx(p.Typography,{sx:$({textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},d==="preview"&&{cursor:"pointer"}),onClick:()=>{d==="preview"&&(b(null),h("search"))},onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&d==="preview"&&(W.preventDefault(),b(null),h("search"))},role:"button",tabIndex:d==="preview"?0:-1,children:e.labels.searchRace})}),l.jsx(p.Step,{orientation:"vertical",active:d==="preview",disabled:d!=="preview",indicator:l.jsx(p.StepIndicator,{variant:d==="preview"?"solid":"outlined",color:"primary",children:l.jsx(wb,{})}),children:l.jsx(p.Typography,{sx:{textTransform:"uppercase",fontWeight:"lg",fontSize:"0.75rem"},children:e.labels.preview})})]}),l.jsx(p.Sheet,{variant:"outlined",sx:{mt:2,p:1,borderRadius:"sm",bgcolor:"background.surface"},children:l.jsx(GN,{step:d,loading:c||g,races:o,selectedRaceId:u,generatedEntity:m,labels:e.labels,setSelectedRaceId:f,onGenerate:j,setGeneratedEntity:b})})]})}),l.jsxs(p.DialogActions,{children:[l.jsx(p.Button,{variant:"solid",color:"primary",loading:x,disabled:!B||g,onClick:N,children:e.labels.create}),l.jsx(p.Button,{disabled:g||x,variant:"plain",color:"neutral",onClick:W=>{W.stopPropagation(),e.toggleModal()},children:e.labels.close})]})]}),l.jsx(Ke,{showToast:C,color:E,message:w,hideToast:O})]})})}},Eb=y.createContext(null),QN=({children:e})=>l.jsx(Eb.Provider,{value:KN,children:e}),qN=()=>{const e=y.useContext(Eb);if(!e)throw new Error("useComponentContext must be used within a ComponentProvider");return e},kb=425,_b=1024;return{APIProvider:US,AuthProvider:VS,AuthContext:Kf,ComponentProvider:QN,useComponentContext:qN,useAPIContext:Ye,useIsMobile:()=>{const[e,t]=y.useState(window.innerWidth<=_b),[n,r]=y.useState(window.innerWidth<=kb);return y.useLayoutEffect(()=>{const i=()=>{t(window.innerWidth<=_b),r(window.innerWidth<=kb)};return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]),{isMobile:e,isPhone:n}},constants:{supportedLanguages:Ie,languagesMap:Ti}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fansunited-management-components",
3
- "version": "1.56.0-RC14",
3
+ "version": "1.56.0-RC15",
4
4
  "main": "index.es.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.es.d.ts",