UNPKG

@getontime/cli

Version:
3 lines (2 loc) 10.2 kB
import{r as p,j as r,a7 as xe}from"./vendor-DFNUfA2K.js";import{P as be,T as m,a as v,b as C,u as Se,c as Te,d as Ce,L as ke,e as Me,f as Pe,g as Oe,h as Ne,i as h,O as ze}from"./index-BNit4nUw.js";import{M as Fe}from"./MultiPartProgressBar-BiSyJr2f.js";import{E as je}from"./EmptyPage-dVRQ987V.js";import{T as W}from"./TitleCard-Bnxx8KS3.js";import{V as Ve}from"./ViewLogo-BhUYUzFU.js";import{m as I,O as y,a as A,i as u,g,b as _,c as De,V as Le}from"./ViewParamsEditor-C6i_vUmm.js";import{u as Ee}from"./useWindowTitle-Bgl000Se.js";import{a as He,S as Be}from"./viewLoader.utils-CeLIIcNn.js";import{g as We}from"./presentation.utils-C6tDFxNi.js";import{g as Ie,h as Ae,s as Re}from"./common.options-CwGs4uxL.js";import{v as Ze}from"./validateEvent-d8SZfbc8.js";import{i as _e}from"./playbackstate-DRK4geZP.js";import{u as $e}from"./useCustomFields-C60U2vqf.js";import{u as Ue}from"./useProjectData-BfKJevmX.js";import"./getProgress-Dgt_8BYF.js";import"./Empty-BLJKwoJq.js";import"./Select-Bp_h4xvR.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="fce65494-aa55-4869-ab4c-78a1f8437907",e._sentryDebugIdIdentifier="sentry-dbid-fce65494-aa55-4869-ab4c-78a1f8437907")}catch{}})();const Ke=(e,o,t)=>{for(;e<o;){const i=Math.floor((e+o)/2);if(i===e)break;t(i)?e=i:o=i}return e};function R({children:e,mode:o="multi",min:t=16,max:i=256,...n}){const d=p.useRef(null),a=p.useCallback(()=>{const s=d.current;return s?s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth:!1},[]),l=p.useCallback(()=>{const s=d.current;if(!s)return;const c=s.style.visibility;s.style.visibility="hidden";const f=Ke(t,i+1,w=>(s.style.fontSize=`${w}px`,!a()));s.style.fontSize=`${f}px`,s.style.visibility=c},[a,t,i]);return p.useEffect(()=>{const s=d.current;if(!s)return;l();const c=new ResizeObserver(l);return c.observe(s),()=>c.disconnect()},[e,o,l]),r.jsx("div",{ref:d,style:{whiteSpace:o==="single"?"nowrap":"normal"},...n,children:e})}const Qe=[{value:"no-overrides",label:"No Overrides"},{value:m.CountUp,label:"Count Up"},{value:m.CountDown,label:"Count Down"},{value:m.Clock,label:"Clock"}],qe=(e,o)=>{const t=I(o,[{value:"title",label:"Title"},{value:"note",label:"Note"}]),i=I(o,[{value:"title",label:"Title"},{value:"note",label:"Note"}]);return[{title:y.ClockOptions,collapsible:!0,options:[Ie(e)]},{title:y.TimerOptions,collapsible:!0,options:[Ae,Re,{id:"timerType",title:"Timer type",description:"Override the timer type",type:"option",values:Qe,defaultValue:"no-overrides"},{id:"freezeOvertime",title:"Freeze Overtime",description:"If active, the timer will not count into negative numbers",type:"boolean",defaultValue:!1},{id:"freezeMessage",title:"Freeze Message",description:"An optional message to show when the timer is in overtime (must be set in combination with Freeze Overtime)",type:"string",defaultValue:"",placeholder:"e.g. Time is up!"},{id:"hidePhase",title:"Hide progress styles",description:"Whether to suppress the progress styles (warning, danger and overtime)",type:"boolean",defaultValue:!1}]},{title:y.DataSources,collapsible:!0,options:[{id:"main",title:"Main text",description:"Select the data source for the main text",type:"option",values:t,defaultValue:"Title"},{id:"secondary-src",title:"Secondary text",description:"Select the data source for the secondary text",type:"option",values:i,defaultValue:""}]},{title:y.ElementVisibility,collapsible:!0,options:[{id:"hideClock",title:"Hide Time Now",description:"Hides the Time Now field",type:"boolean",defaultValue:!1},{id:"hideCards",title:"Hide Cards",description:"Hides the Now and Next cards",type:"boolean",defaultValue:!1},{id:"hideProgress",title:"Hide progress bar",description:"Hides the progress bar",type:"boolean",defaultValue:!1},{id:"hideMessage",title:"Hide Timer Message",description:"Prevents displaying fullscreen messages in the timer",type:"boolean",defaultValue:!1},{id:"hideSecondary",title:"Hide Auxiliary timer / Secondary message",description:"Prevents the screen from displaying the secondary timer field",type:"boolean",defaultValue:!1},{id:"hideLogo",title:"Hide the project logo",description:"Prevents the screen from displaying the given project logo",type:"boolean",defaultValue:!1}]},{title:y.StyleOverride,collapsible:!0,options:[{id:"font",title:"Font",description:"Font family, will use the fonts available in the system",type:"string",placeholder:"Open Sans (default)"},{id:"keyColour",title:"Key Colour",description:"Background or key colour for entire view. Default: #101010",type:"colour",defaultValue:"101010"},{id:"textColour",title:"Text Colour",description:"Text colour. Default: #f6f6f6",type:"colour",defaultValue:"f6f6f6"}]}]};function Ge(e,o){const t=n=>(o==null?void 0:o.get(n))??e.get(n),i=Ze(t("timerType"),m.None);return{hideClock:u(t("hideClock")),hideCards:u(t("hideCards")),hideProgress:u(t("hideProgress")),hideMessage:u(t("hideMessage")),hideSecondary:u(t("hideSecondary")),hideLogo:u(t("hideLogo")),hideTimerSeconds:u(t("hideTimerSeconds")),removeLeadingZeros:!u(t("showLeadingZeros")),mainSource:t("main"),secondarySource:t("secondary-src"),timerType:i===m.None?void 0:i,freezeOvertime:u(t("freezeOvertime")),freezeMessage:t("freezeMessage")??"",hidePhase:u(t("hidePhase")),font:t("font")??void 0,keyColour:A(t("keyColour")),textColour:A(t("textColour"))}}function Je(){const[e]=xe(),o=p.use(be);return p.useMemo(()=>{const i=o?new URLSearchParams(o.search):void 0;return Ge(e,i)},[o,e])}function Xe(e){return e.text!==""&&e.visible}function Ye(e){return e===C.Play||e===C.Roll}function et(e,o){return(e??0)+(o??0)}function tt(e){return e!==m.None&&e!==m.Clock}function ot(e){return e!==m.Clock}const Z={4:28,5:28,6:25,8:20,9:20};function it(e,o){const t=e.length;let i=100/(t-1)*1.25;Z[t]&&(i=Z[t]);let n=i*.2;return o&&(i*=.6,o.length>25&&(n=100/(o.length-1)*1.8)),{timerFontSize:i,externalFontSize:n}}function st(e,o,t,i,n,d){return d?{showEndMessage:!1,showFinished:!1,showWarning:!1,showDanger:!1}:e===m.CountDown||o?{showEndMessage:i&&n!=="",showFinished:t===v.Overtime,showWarning:t===v.Warning,showDanger:t===v.Danger}:{showEndMessage:!1,showFinished:!1,showWarning:!1,showDanger:!1}}function rt(e,o,t,i,n,d){if(!d){if(e.timer.secondarySource==="aux1"||e.timer.secondarySource==="aux2"||e.timer.secondarySource==="aux3")return _(o,m.CountDown,t,{removeSeconds:i,removeLeadingZero:n});if(e.timer.secondarySource==="secondary"&&e.secondary)return e.secondary}}function nt(e,o,t,i,n,d){if(n===C.Stop)return{showNow:!1,nowMain:void 0,nowSecondary:void 0,showNext:!1,nextMain:void 0,nextSecondary:void 0};const a=_e(n)&&d!==v.Pending,l=a?g(e,t??"title"):void 0,s=a?g(e,i):void 0,c=a?g(o,t??"title"):g(e,t??"title"),f=a?g(o,i):g(e,i);return{showNow:!!l||!!s,nowMain:l,nowSecondary:s,showNext:!!c||!!f,nextMain:c,nextSecondary:f}}function at(){const e=Se(c=>c.mirror),{data:o,status:t}=Ue(),{data:i,status:n}=Te(),{data:d,status:a}=Ce(),{data:l,status:s}=$e();return{data:{customFields:l,projectData:o,isMirrored:e,settings:d,viewSettings:i},status:He([t,n,a,s])}}function Pt(){const{data:e,status:o}=at();return Ee("Timer"),o==="pending"?r.jsx(ke,{}):o==="error"?r.jsx(je,{text:"There was an error fetching data, please refresh the page."}):r.jsx(lt,{...e})}function lt({customFields:e,projectData:o,isMirrored:t,settings:i,viewSettings:n}){const{eventNext:d,eventNow:a,message:l,time:s,clock:c,timerTypeNow:f,countToEndNow:w,auxTimer:x}=Me(),{hideClock:$,hideCards:U,hideProgress:K,hideMessage:Q,hideSecondary:q,hideLogo:G,hideTimerSeconds:k,removeLeadingZeros:M,mainSource:J,secondarySource:X,timerType:P,freezeOvertime:O,freezeMessage:N,hidePhase:Y,font:z,keyColour:F,textColour:j}=Je(),{getLocalizedString:V}=Pe(),D=V("common.minutes"),b=P??f,L=Xe(l.timer),{showEndMessage:ee,showFinished:S,showWarning:te,showDanger:oe}=st(f,w,s.phase,O,N,Y),E=Ye(s.playback),ie=!$&&ot(b),se=!K&&tt(b),{showNow:re,nowMain:ne,nowSecondary:ae,showNext:le,nextMain:de,nextSecondary:ce}=nt(a,d,J,X,s.playback,s.phase),ue=et(s.duration,s.addedTime),me=Oe(c),fe=De(O,f,w,c,s,P),H=_(fe,b,D,{removeSeconds:k,removeLeadingZero:M}),he=l.timer.secondarySource==="aux1"?x.aux1:l.timer.secondarySource==="aux2"?x.aux2:l.timer.secondarySource==="aux3"?x.aux3:null,T=rt(l,he,D,k,M,q),pe=We(n,j,te,oe),{timerFontSize:ge,externalFontSize:ye}=it(H,T),we={...F&&{"--timer-bg":F},...j&&{"--timer-colour":pe},...z&&{"--timer-font":z}},B=Ne(i==null?void 0:i.timeFormat),ve=p.useMemo(()=>qe(B,e),[e,B]);return r.jsxs("div",{"data-testid":"timer-view",className:h(["stage-timer",t&&"mirror",S&&"stage-timer--finished"]),style:we,children:[!G&&(o==null?void 0:o.logo)&&r.jsx(Ve,{name:o.logo,className:"logo"}),r.jsx(Le,{target:ze.Timer,viewOptions:ve}),r.jsx("div",{className:h(["blackout",l.timer.blackout&&"blackout--active"])}),!Q&&r.jsx("div",{className:h(["message-overlay",L&&"message-overlay--active"]),children:r.jsx(R,{mode:"multi",min:32,max:256,className:h(["message",l.timer.blink&&"blink"]),children:l.timer.text})}),ie&&r.jsxs("div",{className:"clock-container",children:[r.jsx("div",{className:"label",children:V("common.time_now")}),r.jsx(Be,{time:me,className:"clock"})]}),r.jsxs("div",{className:h(["timer-container",l.timer.blink&&!L&&"blink"]),children:[ee?r.jsx(R,{mode:"multi",min:64,max:256,className:"end-message",children:N}):r.jsx("div",{className:h(["timer",!E&&"timer--paused",S&&"timer--finished"]),style:{fontSize:`${ge}vw`},"data-phase":s.phase,children:H}),r.jsx("div",{className:h(["secondary",!T&&"secondary--hidden"]),style:{fontSize:`${ye}vw`},children:T})]}),se&&r.jsx(Fe,{className:h(["progress-container",!E&&"progress-container--paused"]),now:s.current,complete:ue,normalColor:n.normalColor,warning:a==null?void 0:a.timeWarning,warningColor:n.warningColor,danger:a==null?void 0:a.timeDanger,dangerColor:n.dangerColor,hideOvertime:!S}),!U&&r.jsxs(r.Fragment,{children:[re&&r.jsx(W,{className:"event now",label:"now",title:ne,secondary:ae}),le&&r.jsx(W,{className:"event next",label:"next",title:de,secondary:ce})]})]})}export{Pt as default}; //# sourceMappingURL=Timer-DIm2brUR.js.map