UNPKG

@getontime/cli

Version:
2 lines 101 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./StyleEditor-fQAOer4u.js","./vendor-DFNUfA2K.js","./vendor-4xP-6xVS.css","./StyleEditor-Bie84LSc.css","./RundownExport-Dz40gwc-.js","./EditorUtils-QotOv0b5.js","./index-BNit4nUw.js","./index-tI0w5dSe.css","./EditorUtils-BXko-IuN.css","./ProtectRoute-CmcGN6gV.js","./ProtectRoute-GSFobmAo.css","./useRundown-DgZv-crd.js","./useProjectData-BfKJevmX.js","./useProjectData-Cw1aXCwD.css","./GroupEditor-Fr9zvH2i.js","./TimeInput-BWc6ixac.js","./parseUserTime-COEUAmmZ.js","./TimeInput-BrVdiuOQ.css","./dateConfig-B62K3AL_.js","./validateEvent-d8SZfbc8.js","./isNewLatest-Bui5Tm3U.js","./editorSettings-CK-Psf7E.js","./editorSettings-BqHbWs9b.css","./useCustomFields-C60U2vqf.js","./Select-Bp_h4xvR.js","./Select-DdMiS_36.css","./Tooltip-CMnbeNS3.js","./Tooltip-CKb7gU2M.css","./DropdownMenu-BV41kjSA.js","./DropdownMenu-ByBDeesm.css","./offset-DC4blUxG.js","./GroupEditor-CBhgzn1f.css","./Empty-BLJKwoJq.js","./Empty-DvR62o5B.css","./useFollowComponent-2C-gde3X.js","./RundownExport-D4xWhbXq.css","./TimerControlExport-BYJGGnXs.js","./useReport-C6WYCwpP.js","./Editor.module-DvV2efYs.js","./Editor-B_NlyOLw.css","./TimerControlExport-D8kqHQB0.css","./MessageControlExport-PVFSIYCo.js","./MessageControlExport-DPgqVb-4.css"])))=>i.map(i=>d[i]); import{r as x,j as e,ac as es,e as z,k as yt,ad as de,ae as Ps,af as Es,ag as Qe,ah as he,S as me,aa as et,ai as Os,x as ts,aj as Ns,ak as Tt,f as Rs,N as ss,A as Ts,al as Is,am as Fs,an as Je,ao as As,C as Re,ap as It,aq as Ls,ar as $s,as as Ft,at as Vs,a7 as ns,au as Ws,_ as tt,t as wt,av as Us,v as Ms,L as qs,I as zs,l as Bs}from"./vendor-DFNUfA2K.js";import{P as Ks}from"./ProtectRoute-CmcGN6gV.js";import{i as ye,N as St,Q as Gs,R as Hs,S as Xe,j as Ys,U as Qs,V as Ce,W as Ye,X as E,Y as Ae,Z as Pe,_ as O,$ as X,a0 as G,a1 as pt,a2 as Js,a3 as Xs,a4 as Ct,a5 as Zs,a6 as rs,a7 as T,B as p,a8 as re,a9 as we,aa as Te,ab as ge,ac as oe,ad as M,ae as q,af as L,ag as $,ah as _t,ai as J,aj as fe,ak as st,al as en,am as tn,an as kt,g as ke,ao as Dt,ap as Pt,aq as is,ar as ae,O as Se,as as sn,at as At,au as as,av as ls,aw as nt,w as Fe,ax as nn,ay as rn,az as os,aA as an,aB as ln,aC as on,aD as cs,aE as cn,aF as gt,T as Be,aG as dn,aH as ds,aI as Lt,aJ as un,aK as hn,aL as mn,aM as xn,aN as $t,aO as Vt,aP as Le,aQ as jn,aR as pn,d as gn,aS as fn,K as vn,c as bn,aT as yn,aU as wn,aV as Wt,aW as Sn,aX as Ut,aY as Cn,aZ as _n}from"./index-BNit4nUw.js";import{I as je,C as kn,u as Dn}from"./useWindowTitle-Bgl000Se.js";import{e as Pn,u as rt,T as Q,t as ot,a as En,b as On,d as Nn,c as Rn,f as Tn,g as In,S as Fn,h as An,M as it,D as Ln}from"./DropdownMenu-BV41kjSA.js";import{S as be,u as $n,a as Vn,b as Wn,c as ct}from"./useProjectData-BfKJevmX.js";import{i as us,R as hs,s as Un,G as Mn,a as qn,O as zn,T as Bn}from"./OverviewWrapper-qXI8MQqb.js";import{c as Kn,d as Gn,e as Hn,i as Ze,f as Yn,g as Qn,h as Jn,j as Xn,k as Zn}from"./useRundown-DgZv-crd.js";import{S as te}from"./Select-Bp_h4xvR.js";import{u as at,p as er,e as tr,d as sr}from"./useCustomFields-C60U2vqf.js";import{u as nr,d as rr}from"./useReport-C6WYCwpP.js";import{T as ft,u as ms,e as Ue}from"./editorSettings-CK-Psf7E.js";import{S as ir,L as ar,T as lr}from"./EditorUtils-QotOv0b5.js";import{T as xs}from"./Tooltip-CMnbeNS3.js";import{A as js,T as Me}from"./TimeInput-BWc6ixac.js";import{T as Mt,E as dt}from"./validateEvent-d8SZfbc8.js";import{p as qe}from"./parseUserTime-COEUAmmZ.js";import{S as or,P as cr,O as dr,M as ur,C as hr}from"./TimeElements-DystPWQS.js";import{s as ut}from"./Editor.module-DvV2efYs.js";import"./offset-DC4blUxG.js";import"./playbackstate-DRK4geZP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="c4e5130c-03e3-41f4-bfbc-134efb9b356b",t._sentryDebugIdIdentifier="sentry-dbid-c4e5130c-03e3-41f4-bfbc-134efb9b356b")}catch{}})();function mr(t){return t.trim().replaceAll(" ","_")}const xr={worksheet:"event schedule",flag:"flag",timeStart:"time start",linkStart:"link start",timeEnd:"time end",duration:"duration",cue:"cue",title:"title",countToEnd:"count to end",skip:"skip",note:"notes",colour:"colour",endAction:"end action",timerType:"timer type",timeWarning:"warning time",timeDanger:"danger time",custom:{},entryId:"id"},jr=(t,s,n={})=>{const{isDisabled:r=!1}=n,i=x.useCallback(a=>{a.key===s&&!a.repeat&&!r&&(a.preventDefault(),t())},[t,r,s]);x.useEffect(()=>(document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}),[i])},pr="_link_70oau_17",gr="_inline_70oau_27",qt={link:pr,inline:gr};function ee(t){const{href:s,inline:n,children:r}=t,i=a=>{a.preventDefault(),St(s)};return e.jsxs("a",{href:"#!",target:"_blank",rel:"noreferrer",className:ye([qt.link,n&&qt.inline]),onClick:i,children:[r," ",e.jsx(es,{style:{fontSize:"1em"}})]})}async function fr(){const t=await z.get(Gs);return{url:t.data.html_url,version:t.data.tag_name}}const zt={url:"",version:"",hasUpdates:!1};function ps(){const{data:t,status:s,isFetching:n,isError:r,refetch:i}=yt({queryKey:Qs,queryFn:fr,placeholderData:(l,h)=>l,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1,staleTime:Ys,enabled:Xe}),a=(t==null?void 0:t.version)&&!t.version.includes(Hs);return{data:t?{...t,hasUpdates:a}:zt,placeholder:zt,status:s,isFetching:n,isError:r,refetch:i}}function vr(){const{data:t,isError:s}=ps();return s?e.jsxs(Ce,{children:[`You are currently using Ontime version ${Ye}`,e.jsx(E,{children:`Could not fetch version information: ${s}`})]}):t.hasUpdates?e.jsxs(Ce,{children:[`You are currently using Ontime version ${Ye}.`,e.jsx("br",{}),e.jsx("br",{}),`A new version ${t.version} is available.`," ",e.jsx("br",{}),Ae?"You can restart your stage to get the latest available version.":e.jsx(ee,{href:t.url,children:"Please visit the release page to download"})]}):e.jsx(Ce,{children:`You are currently using the latest version of Ontime: ${Ye}`})}function br(){return e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:"About Ontime"}),e.jsxs(O,{children:[e.jsxs(X,{children:[e.jsx(G,{children:"Ontime"}),e.jsxs(Ce,{children:["Free, open-source software for managing rundowns and event timers",e.jsx(ee,{href:pt,children:"www.getontime.no"})]}),e.jsxs(Ce,{children:["Considering sponsoring our work",e.jsx(ee,{href:Js,children:"GitHub Sponsors"}),e.jsx(ee,{href:Xs,children:"Buy Me a Coffee"})]}),e.jsxs(Ce,{children:["If you are looking for an online version of Ontime, consider trying out our cloud service",e.jsx(ee,{href:pt,children:"www.getontime.no"})]})]}),e.jsx(G,{children:"Current version"}),e.jsx(vr,{}),e.jsx(G,{children:"Links"}),e.jsx(ee,{href:Ct,children:"Read the docs"}),e.jsx(ee,{href:Zs,children:"Follow the project on GitHub"}),e.jsx(ee,{href:rs,children:"Discord server"})]})]})}function ne(t,s){const n=x.useRef(null);return x.useEffect(()=>{s&&n.current&&s===t&&n.current.scrollIntoView({behavior:"smooth",block:"center"})},[s,t]),n}const yr="https://docs.getontime.no/api/protocols/osc/";function wr({enabledAutomations:t,enabledOscIn:s,oscPortIn:n}){var w,v,b;const{handleSubmit:r,reset:i,register:a,setError:o,watch:l,setValue:h,formState:{errors:c,isSubmitting:d,isDirty:m,isValid:u}}=de({mode:"onChange",defaultValues:{enabledAutomations:t,enabledOscIn:s,oscPortIn:n},resetOptions:{keepDirtyValues:!1}}),f=async C=>{try{await Pn(C),i(C)}catch(F){const k=$(F);o("root",{message:k})}},j=()=>{i({enabledAutomations:t,enabledOscIn:s,oscPortIn:n})},g=!d&&m&&u;return e.jsxs(X,{children:[e.jsxs(G,{children:["Automation settings",e.jsxs(T,{children:[e.jsx(p,{variant:"ghosted",onClick:j,disabled:!g,children:"Revert to saved"}),e.jsx(p,{variant:"primary",type:"submit",form:"automation-settings-form",disabled:!g,loading:d,children:"Save"})]})]}),(c==null?void 0:c.root)&&e.jsx(E,{children:c.root.message}),e.jsx(re,{}),e.jsx(O,{children:e.jsxs(je,{children:[e.jsx("p",{children:"Control Ontime and share its data with external systems in your workflow."}),e.jsx("p",{children:"- Automations allow Ontime to send its data on lifecycle triggers."}),e.jsx("p",{children:"- OSC Input tells Ontime to listen to messages on the specific port."}),e.jsx("br",{}),e.jsx(ee,{href:yr,children:"See the docs"})]})}),e.jsxs(O,{as:"form",id:"automation-settings-form",onSubmit:r(f),onKeyDown:C=>we(C,j),children:[e.jsx(Te,{isLoading:!1}),e.jsx(ge,{children:"Automation"}),e.jsx(oe,{children:e.jsxs(M,{children:[e.jsx(q,{title:"Enable automations",description:"Allow Ontime to send messages on lifecycle triggers",error:(w=c.enabledAutomations)==null?void 0:w.message}),e.jsx(be,{size:"large",checked:l("enabledAutomations"),onCheckedChange:C=>h("enabledAutomations",C,{shouldDirty:!0,shouldValidate:!0})})]})}),e.jsx(ge,{children:"OSC Input"}),e.jsxs(oe,{children:[Ae&&e.jsx(je,{children:"For security reasons OSC integrations are not available in the cloud service."}),e.jsxs(M,{children:[e.jsx(q,{title:"OSC input",description:"Allow control of Ontime through OSC",error:(v=c.enabledOscIn)==null?void 0:v.message}),e.jsx(be,{size:"large",checked:l("enabledOscIn"),onCheckedChange:C=>h("enabledOscIn",C,{shouldDirty:!0,shouldValidate:!0})})]}),e.jsxs(M,{children:[e.jsx(q,{title:"Listen on port",description:"Port for incoming OSC. Default: 8888",error:(b=c.oscPortIn)==null?void 0:b.message}),e.jsx(L,{id:"oscPortIn",placeholder:"8888",maxLength:5,style:{textAlign:"right",width:"5rem"},type:"number",fluid:!0,...a("oscPortIn",{required:{value:!0,message:"Required field"},max:{value:65535,message:"Port must be within range 1024 - 65535"},min:{value:1024,message:"Port must be within range 1024 - 65535"},pattern:{value:us,message:"Value should be numeric"}})})]})]})]})]})}const Sr=["{{human.clock}}","{{human.duration}}","{{human.expectedEnd}}","{{human.runningTimer}}","{{human.elapsedTime}}","{{human.startedAt}}"],Cr=["{{clock}}","{{timer.addedTime}}","{{timer.current}}","{{timer.duration}}","{{timer.elapsed}}","{{timer.expectedFinish}}","{{timer.secondaryTimer}}","{{timer.startedAt}}","{{rundown.selectedEventIndex}}","{{rundown.numEvents}}","{{rundown.plannedStart}}","{{rundown.plannedEnd}}","{{rundown.actualStart}}","{{offset.absolute}}","{{offset.relative}}","{{offset.expectedRundownEnd}}","{{offset.expectedGroupEnd}}","{{offset.expectedFlagStart}}"],_r=["{{eventNow.id}}","{{eventNow.cue}}","{{eventNow.title}}","{{eventNow.note}}","{{eventNow.timeStart}}","{{eventNow.timeEnd}}","{{eventNow.duration}}","{{eventNow.colour}}","{{eventNow.delay}}"],kr=["{{eventNext.id}}","{{eventNext.cue}}","{{eventNext.title}}","{{eventNext.note}}","{{eventNext.timeStart}}","{{eventNext.timeEnd}}","{{eventNext.duration}}","{{eventNext.colour}}","{{eventNext.delay}}"];function Dr(t){return[...Sr,...Cr,..._r,...Object.entries(t).map(([s])=>`{{eventNow.custom.${s}}}`),...kr,...Object.entries(t).map(([s])=>`{{eventNext.custom.${s}}}`)]}function Pr(t,s){if(t===s)return"";if(t.endsWith("{{")&&s.startsWith("{{"))return s.substring(2);if(t.endsWith("{")&&s.startsWith("{{"))return s.substring(1);for(let n=0;n<s.length;n++){const r=s.substring(0,n+1);if(t.endsWith(r))return s.substring(n+1)}return""}function Er(t){const s=t.lastIndexOf("{{");return s!==-1?t.slice(s):""}const Or="_wrapper_11839_17",Nr="_suggestions_11839_21",Bt={wrapper:Or,suggestions:Nr},Rr=x.forwardRef(function(s,n){const{value:r,onChange:i,...a}=s,{data:o}=at(),l=Ps(()=>j(!1)),h=x.useMemo(()=>Dr(o),[o]),[c,d]=x.useState(r||""),[m,u]=x.useState([]),[f,j]=x.useState(!1),g=b=>{const C=Er(b);return h.filter(F=>F.startsWith(C))},w=b=>{d(b.target.value),b.target.value.endsWith("{")?(j(!0),u(g(b.target.value))):b.target.value===""||b.target.value.endsWith("}}")?j(!1):f&&u(g(b.target.value)),i==null||i(b)},v=b=>{d(C=>{const F=Pr(C,b);return C+F}),j(!1)};return e.jsxs("div",{className:Bt.wrapper,ref:Es(l,n),children:[e.jsx(L,{value:c,...a,onChange:w,fluid:!0}),f&&m.length>0&&e.jsx("ul",{className:Bt.suggestions,children:m.map(b=>e.jsx("li",{onClick:()=>v(b),children:b},b))})]})}),vt=[{id:1,label:"On Load",value:"onLoad"},{id:2,label:"On Start",value:"onStart"},{id:3,label:"On Pause",value:"onPause"},{id:4,label:"On Stop",value:"onStop"},{id:5,label:"Every second",value:"onClock"},{id:6,label:"On Timer Update",value:"onUpdate"},{id:7,label:"On Finish",value:"onFinish"},{id:8,label:"On Warning",value:"onWarning"},{id:9,label:"On Danger",value:"onDanger"}];function Kt(t){return Object.hasOwn(t,"id")}const Tr=[{value:"eventNow.id",label:"ID"},{value:"eventNow.title",label:"Title"},{value:"eventNow.cue",label:"Cue"},{value:"eventNow.countToEnd",label:"Count to end"},{value:"eventNow.note",label:"Note"},{value:"eventNow.colour",label:"Colour"}],Ir=[{value:"eventNext.id",label:"Next ID"},{value:"eventNext.title",label:"Next Title"},{value:"eventNext.cue",label:"Next Cue"}];function Fr(t){return[...Tr,...Object.entries(t).map(([s,{label:n}])=>({value:`eventNow.custom.${s}`,label:`Custom: ${n}`})),...Ir,...Object.entries(t).map(([s,{label:n}])=>({value:`eventNext.custom.${s}`,label:`Next custom: ${n}`}))]}function Ar(t){const s={},n=[];for(let r=0;r<t.length;r++){const i=t[r];Object.hasOwn(s,i.trigger)||(s[i.trigger]=[]),s[i.trigger].includes(i.automationId)?n.push(r):s[i.trigger].push(i.automationId)}return n.length>0?n:void 0}const Lr="_outerColumn_dem8v_17",$r="_innerColumn_dem8v_25",Vr="_ruleSection_dem8v_31",Wr="_titleSection_dem8v_37",Ur="_filterSection_dem8v_38",Mr="_oscSection_dem8v_39",qr="_httpSection_dem8v_40",zr="_actionSection_dem8v_41",Br="_test_dem8v_95",Kr="_outputCard_dem8v_99",le={outerColumn:Lr,innerColumn:$r,ruleSection:Vr,titleSection:Wr,filterSection:Ur,oscSection:Mr,httpSection:qr,actionSection:zr,test:Br,outputCard:Kr};function Gr({index:t,register:s,setValue:n,rowErrors:r,value:i,children:a,watch:o}){var d,m,u,f,j;const[l,h]=x.useState(i),c=g=>{n(`outputs.${t}.action`,g,{shouldDirty:!0}),h(g)};return e.jsxs("div",{className:le.actionSection,children:[e.jsxs("label",{children:["Action",e.jsx(te,{onValueChange:g=>{c(g)},value:o(`outputs.${t}.action`),options:[{value:"aux1-pause",label:"Aux 1: pause"},{value:"aux2-pause",label:"Aux 2: pause"},{value:"aux3-pause",label:"Aux 3: pause"},{value:"aux1-start",label:"Aux 1: start"},{value:"aux2-start",label:"Aux 2: start"},{value:"aux3-start",label:"Aux 3: start"},{value:"aux1-stop",label:"Aux 1: stop"},{value:"aux2-stop",label:"Aux 2: stop"},{value:"aux3-stop",label:"Aux 3: stop"},{value:"aux1-set",label:"Aux 1: set"},{value:"aux2-set",label:"Aux 2: set"},{value:"aux3-set",label:"Aux 3: set"},{value:"message-set",label:"Primary Message: set"},{value:"message-secondary",label:"Secondary Message: source"}]}),e.jsx(E,{children:(d=r==null?void 0:r.action)==null?void 0:d.message})]}),l.startsWith("aux")&&l.endsWith("set")&&e.jsxs("label",{children:["New time",e.jsx(L,{...s(`outputs.${t}.time`,{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"eg: 10m5s"}),e.jsx(E,{children:(m=r==null?void 0:r.time)==null?void 0:m.message})]}),l==="message-set"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Text (leave empty for no change)",e.jsx(L,{...s(`outputs.${t}.text`),fluid:!0,placeholder:"eg: Timer is finished"}),e.jsx(E,{children:(u=r==null?void 0:r.text)==null?void 0:u.message})]}),e.jsxs("label",{children:["Visibility",e.jsx(te,{onValueChange:g=>{const w=g==="untouched"?void 0:g;n(`outputs.${t}.visible`,w,{shouldDirty:!0})},value:o(`outputs.${t}.visible`)===void 0?"untouched":o(`outputs.${t}.visible`),options:[{value:"untouched",label:"Untouched"},{value:!0,label:"Show"},{value:!1,label:"Hide"}]}),e.jsx(E,{children:(f=r==null?void 0:r.visible)==null?void 0:f.message})]})]}),l==="message-secondary"&&e.jsxs("label",{children:["Timer secondary source",e.jsx(te,{onValueChange:g=>{n(`outputs.${t}.secondarySource`,g,{shouldDirty:!0})},value:o(`outputs.${t}.secondarySource`),options:[{value:null,label:"Select secondary source",disabled:!0},{value:"aux1",label:"Auxiliary timer 1"},{value:"aux2",label:"Auxiliary timer 2"},{value:"aux3",label:"Auxiliary timer 3"},{value:"external",label:"External"},{value:"null",label:"None"}]}),e.jsx(E,{children:(j=r==null?void 0:r.secondarySource)==null?void 0:j.message})]}),e.jsx("div",{className:le.test,children:a})]})}const Hr="https://docs.getontime.no/api/automation/#using-variables-in-automation";function Yr({automation:t,onClose:s}){var H;const n=Kt(t),{data:r}=at(),{refetch:i}=rt(),a=x.useMemo(()=>Fr(r),[r]),{control:o,handleSubmit:l,getValues:h,register:c,setError:d,setFocus:m,setValue:u,watch:f,formState:{errors:j,isSubmitting:g,isDirty:w,isValid:v}}=de({mode:"onChange",defaultValues:{title:(t==null?void 0:t.title)??"",filterRule:(t==null?void 0:t.filterRule)??"all",filters:(t==null?void 0:t.filters)??[],outputs:(t==null?void 0:t.outputs)??[]},resetOptions:{keepDirtyValues:!0}}),{fields:b,append:C,remove:F}=Qe({name:"filters",control:o}),{fields:k,append:N,remove:R}=Qe({name:"outputs",control:o});x.useEffect(()=>{m("title")},[m]);const y=()=>{C({field:"",operator:"equals",value:""})},B=()=>{N({type:"osc",targetIP:"",targetPort:void 0,address:"",args:""})},se=()=>{N({type:"http",url:""})},ue=()=>{N({type:"ontime",action:"aux1-start"})},I=async A=>{try{const S=h(`outputs.${A}`);if(!S.targetIP||!S.targetPort||!S.address)return;await ot({type:"osc",targetIP:S.targetIP,targetPort:S.targetPort,address:S.address,args:S.args})}catch{}},W=async A=>{try{const S=h(`outputs.${A}`);if(!S.url)return;await ot({type:"http",url:S.url})}catch{}},P=async A=>{try{const S=h(`outputs.${A}`);await ot({...S,type:"ontime"})}catch{}},V=async A=>{Kt(t)?await S(t.id,{id:t.id,...A}):await _(A),i();async function S(U,Z){try{await En(U,Z),s()}catch(ce){d("root",{message:$(ce)})}}async function _(U){try{await On(U),s()}catch(Z){d("root",{message:$(Z)})}}},D=!g&&w&&v;return e.jsxs(_t,{as:"form",name:"automation-form",onSubmit:l(V),className:le.outerColumn,onKeyDown:A=>we(A,s),children:[e.jsx(G,{children:n?"Edit automation":"Create automation"}),e.jsxs("div",{className:le.innerSection,children:[e.jsx("h3",{children:"Automation options"}),e.jsxs("div",{className:le.titleSection,children:[e.jsxs("label",{children:["Title",e.jsx(L,{...c("title",{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"Load preset"})]}),e.jsx(E,{children:(H=j.title)==null?void 0:H.message})]})]}),e.jsxs("div",{className:le.innerSection,children:[e.jsx("h3",{children:"Filters (optional)"}),e.jsxs("div",{className:le.ruleSection,children:[e.jsxs("label",{children:["Trigger outputs if",e.jsx(hs,{orientation:"horizontal",value:f("filterRule"),onValueChange:A=>u("filterRule",A,{shouldDirty:!0}),items:[{value:"all",label:"All filters pass"},{value:"any",label:"Any filter passes"}]})]}),b.map((A,S)=>{var U,Z,ce,Ee,Ve,We;const _=`filters.${S}.field.${A.id}`;return e.jsxs("div",{className:le.filterSection,children:[e.jsxs("label",{children:["Runtime data source",e.jsx(te,{value:f(`filters.${S}.field`),onValueChange:_e=>u(`filters.${S}.field`,_e,{shouldDirty:!0}),options:a.map(({value:_e,label:Y})=>({value:_e,label:Y})),"aria-label":"Event field"}),e.jsx(E,{children:(ce=(Z=(U=j.filters)==null?void 0:U[S])==null?void 0:Z.field)==null?void 0:ce.message})]}),e.jsxs("label",{children:["Matching condition",e.jsx(te,{value:f(`filters.${S}.operator`),onValueChange:_e=>u(`filters.${S}.operator`,_e,{shouldDirty:!0}),options:[{value:"equals",label:"equals"},{value:"not_equals",label:"not equals"},{value:"contains",label:"contains"}],"aria-label":"Operator"}),e.jsx(E,{children:(We=(Ve=(Ee=j.filters)==null?void 0:Ee[S])==null?void 0:Ve.operator)==null?void 0:We.message})]}),e.jsxs("label",{children:["Value to match",e.jsx(L,{...c(`filters.${S}.value`),fluid:!0,placeholder:"<empty / no value>"})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsx("div",{children:e.jsx(J,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>F(S),children:e.jsx(he,{})})})]})]},_)}),e.jsx("div",{children:e.jsxs(p,{type:"submit",onClick:y,children:["Add filter ",e.jsx(me,{})]})})]})]}),e.jsxs("div",{className:le.innerColumn,children:[e.jsx("h3",{children:"Outputs"}),e.jsxs(je,{children:["Automation outputs can be used to send data from Ontime to external software.",e.jsx(ee,{href:Hr,children:"See the documentation for templates"})]}),k.map((A,S)=>{var _,U,Z,ce,Ee,Ve,We,_e;if(Kn(A)){const Y=(_=j.outputs)==null?void 0:_[S];return e.jsxs("div",{className:le.outputCard,children:[e.jsx(Q,{children:"OSC"}),e.jsxs("div",{className:le.oscSection,children:[e.jsxs("label",{children:["Target IP",e.jsx(L,{...c(`outputs.${S}.targetIP`,{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"127.0.0.1"}),e.jsx(E,{children:(U=Y==null?void 0:Y.targetIP)==null?void 0:U.message})]}),e.jsxs("label",{children:["Target Port",e.jsx(L,{...c(`outputs.${S}.targetPort`,{required:{value:!0,message:"Required field"},setValueAs:Rt=>Rt===""?0:Number(Rt),max:{value:65535,message:"Port must be within range 1024 - 65535"},min:{value:1024,message:"Port must be within range 1024 - 65535"}}),fluid:!0,type:"number",maxLength:5,placeholder:"8000"}),e.jsx(E,{children:(Z=Y==null?void 0:Y.targetPort)==null?void 0:Z.message})]}),e.jsxs("label",{children:["Address",e.jsx(L,{...c(`outputs.${S}.address`),fluid:!0,placeholder:"/cue/start"}),e.jsx(E,{children:(ce=Y==null?void 0:Y.address)==null?void 0:ce.message})]}),e.jsxs("label",{children:["Arguments",e.jsx(Rr,{...c(`outputs.${S}.args`),value:A.args,placeholder:"1"}),e.jsx(E,{children:(Ee=Y==null?void 0:Y.args)==null?void 0:Ee.message})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsxs(T,{relation:"inner",children:[e.jsx(p,{variant:"ghosted-white",onClick:()=>I(S),children:"Test"}),e.jsx(J,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>R(S),children:e.jsx(he,{})})]})]})]})]},A.id)}if(Gn(A)){const Y=(Ve=j.outputs)==null?void 0:Ve[S];return e.jsxs("div",{className:le.outputCard,children:[e.jsx(Q,{children:"HTTP"}),e.jsxs("div",{className:le.httpSection,children:[e.jsxs("label",{children:["Target URL",e.jsx(L,{...c(`outputs.${S}.url`,{required:{value:!0,message:"Required field"},pattern:{value:Un,message:"HTTP messages should target http:// or https://"}}),fluid:!0,placeholder:"http://127.0.0.1/start/1"}),e.jsx(E,{children:(We=Y==null?void 0:Y.url)==null?void 0:We.message})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsxs(T,{relation:"inner",children:[e.jsx(p,{variant:"ghosted-white",onClick:()=>W(S),children:"Test"}),e.jsx(J,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>R(S),children:e.jsx(he,{})})]})]})]})]},A.id)}if(Hn(A)){const Y=(_e=j.outputs)==null?void 0:_e[S];return e.jsxs("div",{className:le.outputCard,children:[e.jsx(Q,{children:"Ontime action"}),e.jsxs(Gr,{value:A.action,index:S,register:c,rowErrors:Y,setValue:u,watch:f,children:[e.jsx("span",{children:" "}),e.jsxs(T,{relation:"inner",children:[e.jsx(p,{variant:"ghosted-white",onClick:()=>P(S),children:"Test"}),e.jsx(J,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>R(S),children:e.jsx(he,{})})]})]})]},A.id)}return null}),e.jsxs(T,{relation:"inner",children:[e.jsxs(p,{onClick:B,children:["OSC ",e.jsx(me,{})]}),e.jsxs(p,{onClick:se,children:["HTTP ",e.jsx(me,{})]}),e.jsxs(p,{onClick:ue,children:["Ontime action ",e.jsx(me,{})]})]})]}),e.jsxs(T,{align:"end",children:[(j==null?void 0:j.root)&&e.jsx(E,{children:j.root.message}),e.jsx(p,{onClick:s,children:"Cancel"}),e.jsx(p,{variant:"primary",type:"submit",disabled:!D,loading:g,children:"Save"})]})]})}const Gt={title:"",filterRule:"all",filters:[],outputs:[]};function Qr(t){const{automations:s}=t,{refetch:n}=rt(),[r,i]=x.useState(null),[a,o]=x.useState(null),l=async c=>{try{o(null),await Nn(c)}catch(d){o($(d))}finally{n()}},h=Object.keys(s);return e.jsxs(X,{children:[e.jsxs(G,{children:["Manage automations",e.jsxs(p,{type:"submit",disabled:!!r,onClick:()=>i(Gt),children:["New ",e.jsx(me,{})]})]}),e.jsx(re,{}),r!==null&&e.jsx(Yr,{automation:r,onClose:()=>i(null)}),e.jsxs(fe,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"45%"},children:"Title"}),e.jsx("th",{style:{width:"15%"},children:"Trigger rule"}),e.jsx("th",{style:{width:"15%"},children:"Filters"}),e.jsx("th",{style:{width:"15%"},children:"Outputs"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[h.length===0&&e.jsx(st,{handleClick:r?void 0:()=>i(Gt)}),h.map(c=>Object.hasOwn(s,c)?e.jsxs(x.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s[c].title}),e.jsx("td",{children:e.jsx(Q,{children:s[c].filterRule})}),e.jsx("td",{children:s[c].filters.length}),e.jsx("td",{children:s[c].outputs.length}),e.jsxs(T,{align:"end",relation:"inner",as:"td",children:[e.jsx(J,{variant:"ghosted-white","aria-label":"Edit entry",onClick:()=>i(s[c]),children:e.jsx(et,{})}),e.jsx(J,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:()=>l(c),children:e.jsx(he,{})})]})]}),a&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(E,{children:a})})})]},c):null)]})]})]})}function gs({automations:t,initialId:s,initialTitle:n,initialAutomationId:r,initialTrigger:i,onCancel:a,postSubmit:o}){var F,k,N,R;const{handleSubmit:l,register:h,setFocus:c,setError:d,watch:m,setValue:u,formState:{errors:f,isSubmitting:j,isValid:g,isDirty:w}}=de({defaultValues:{title:n,trigger:i??vt[0].value,automationId:r??((F=t==null?void 0:t[Object.keys(t)[0]])==null?void 0:F.id)},resetOptions:{keepDirtyValues:!0}});x.useEffect(()=>{c("title")},[c]);const v=async y=>{if(s){try{await Rn(s,{id:s,...y}),o()}catch(B){d("root",{message:`Failed to save changes to trigger ${$(B)}`})}return}try{await Tn(y),o()}catch(B){d("root",{message:`Failed to save trigger ${$(B)}`})}},b=Object.keys(t).map(y=>({value:y,label:t[y].title})),C=w&&g;return e.jsxs(_t,{as:"form",name:"trigger-form",onSubmit:l(v),onKeyDown:y=>we(y,a),children:[e.jsx(G,{children:s?"Edit trigger":"Create trigger"}),e.jsxs("label",{children:["Title",e.jsx(L,{...h("title",{required:{value:!0,message:"Required field"}}),fluid:!0,defaultValue:n}),e.jsx(E,{children:(k=f.title)==null?void 0:k.message})]}),e.jsxs("label",{children:["Lifecycle trigger",e.jsx(te,{value:m("trigger"),onValueChange:y=>u("trigger",y,{shouldDirty:!0}),options:vt.map(y=>({value:y.value,label:y.label})),"aria-label":"Lifecycle trigger"}),e.jsx(E,{children:(N=f.trigger)==null?void 0:N.message})]}),e.jsxs("label",{children:["Automation title",e.jsx(te,{value:m("automationId"),onValueChange:y=>u("automationId",y,{shouldDirty:!0}),options:b,"aria-label":"Automation title"}),e.jsx(E,{children:(R=f.automationId)==null?void 0:R.message})]}),e.jsxs(T,{align:"end",children:[e.jsx(p,{disabled:j,onClick:a,children:"Cancel"}),e.jsx(p,{type:"submit",variant:"primary",disabled:!C,loading:j,children:"Save"})]})]})}function Jr(t){var m,u;const{automations:s,id:n,title:r,trigger:i,automationId:a,duplicate:o,handleDelete:l,postSubmit:h}=t,[c,d]=x.useState(!1);return c?e.jsx("tr",{children:e.jsx("td",{colSpan:99,children:e.jsx(gs,{automations:s,initialId:n,initialTitle:r,initialTrigger:i,initialAutomationId:a,onCancel:()=>d(!1),postSubmit:()=>{d(!1),h()}})})}):e.jsxs("tr",{"data-warn":o,children:[e.jsxs(T,{as:"td",relation:"inner",children:[o&&e.jsx(Os,{color:"#FFBC56"}),r]}),e.jsx("td",{children:e.jsx(Q,{children:(m=vt.find(f=>f.value===i))==null?void 0:m.label})}),e.jsx("td",{children:e.jsx(Q,{children:(u=s==null?void 0:s[a])==null?void 0:u.title})}),e.jsxs(T,{align:"end",relation:"inner",as:"td",children:[e.jsx(J,{variant:"ghosted-white","aria-label":"Edit entry",onClick:()=>d(!0),children:e.jsx(et,{})}),e.jsx(J,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:l,children:e.jsx(he,{})})]})]})}function Xr(t){const{triggers:s,automations:n}=t,[r,i]=x.useState(!1),{refetch:a}=rt(),[o,l]=x.useState(null),h=async u=>{try{await In(u)}catch(f){l($(f))}finally{a()}},c=()=>{i(!1),a()},d=x.useMemo(()=>Ar(s),[s]),m=Object.keys(n).length>0;return e.jsxs(X,{children:[e.jsxs(G,{children:["Manage triggers",e.jsxs(p,{type:"submit",form:"trigger-form",disabled:!m,loading:!1,onClick:()=>i(!0),children:["New ",e.jsx(me,{})]})]}),e.jsx(re,{}),e.jsxs(O,{children:[d&&e.jsx(E,{children:"You have created multiple links between the same trigger and automation which can performance issues."}),r&&e.jsx(gs,{automations:n,onCancel:()=>i(!1),postSubmit:c}),e.jsxs(fe,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"35%"},children:"Title"}),e.jsx("th",{style:{width:"25%"},children:"Lifecycle trigger"}),e.jsx("th",{style:{width:"25%"},children:"Automation"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[!r&&s.length===0&&e.jsx(st,{label:"Create an automation to attach triggers to",handleClick:m?()=>i(!0):void 0}),s.map((u,f)=>e.jsxs(x.Fragment,{children:[e.jsx(Jr,{automations:n,id:u.id,title:u.title,trigger:u.trigger,automationId:u.automationId,duplicate:d==null?void 0:d.includes(f),handleDelete:()=>h(u.id),postSubmit:c}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(E,{children:o})})})]},u.id))]})]})]})]})}function Zr({location:t}){const{data:s,status:n}=rt(),r=ne("settings",t),i=ne("triggers",t),a=ne("automations",t),o=n==="pending";return e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:"Automation"}),e.jsxs(O,{children:[e.jsx(Te,{isLoading:o}),e.jsx("div",{ref:r,children:e.jsx(wr,{enabledAutomations:s.enabledAutomations,enabledOscIn:s.enabledOscIn,oscPortIn:s.oscPortIn})}),e.jsx("div",{ref:a,children:e.jsx(Qr,{automations:s.automations})}),e.jsx("div",{ref:i,children:e.jsx(Xr,{triggers:s.triggers,automations:s.automations})})]})]})}const ei="_goIcon_1fzu7_17",ti={goIcon:ei};function si(){const{data:t}=en(),s=n=>St(n);return e.jsx(T,{children:t.networkInterfaces.map(n=>{if(n.name==="localhost"&&!Xe)return null;const r=tn(n.address);return e.jsxs(kt,{copyValue:r,onClick:()=>s(r),children:[`${n.name} - ${n.address}`," ",e.jsx(ts,{className:ti.goIcon})]},n.name)})})}function fs(t){return Ns(t)}function ni(t){const s=Object.keys(t);if(s.length===0)return[];const n=[];for(const r of s){const{order:i,entries:a}=t[r];for(let o=0;o<i.length;o++){const l=i[o],h=a[l];n.push(h)}}return n}function ri(t,s,n){if(Object.keys(t).length===0)return[];if(n.length===0)return[];const r=[];let i=1;for(let a=0;a<n.length;a++){const o=n[a],l=s[o];!l||!Ze(l)||(o in t||r.push({id:o,index:i,title:l.title,cue:l.cue,scheduledStart:l.timeStart,actualEnd:null,scheduledEnd:l.timeEnd,actualStart:null}),o in t&&r.push({id:o,index:i,title:l.title,cue:l.cue,scheduledStart:l.timeStart,actualEnd:t[o].endedAt,scheduledEnd:l.timeEnd,actualStart:t[o].startedAt}),i++)}return r}const ii=["Index","Title","Cue","Scheduled Start","Actual Start","Scheduled End","Actual End"];function ai(t){const s=[];s.push(ii);for(const n of t)s.push([String(n.index),n.title,n.cue,ke(n.scheduledStart),ke(n.actualStart),ke(n.scheduledEnd),ke(n.actualEnd)]);return fs(s)}const li="_blink_15peo_1",oi="_fourtyfive_15peo_13",ci="_over_15peo_17",di="_under_15peo_21",Ke={blink:li,fourtyfive:oi,over:ci,under:di};function ui(){const{data:t}=nr(),{data:s}=Yn(),n=async()=>await rr(),r=a=>{if(!a)return;const o=ai(a),l=Dt(o,"text/csv;charset=utf-8;");Pt(l,"ontime-report.csv")},i=x.useMemo(()=>ri(t,s.entries,s.flatOrder),[t,s.entries,s.flatOrder]);return e.jsx(O,{children:e.jsxs(X,{children:[e.jsx(G,{children:"Report"}),e.jsx(re,{}),e.jsx(O,{children:e.jsxs(ge,{children:["Manage report",e.jsxs(T,{children:[e.jsxs(p,{onClick:()=>r(i),disabled:i.length===0,children:[e.jsx(Tt,{}),"Export CSV"]}),e.jsxs(p,{variant:"subtle-destructive",onClick:n,disabled:i.length===0,children:[e.jsx(Tt,{}),"Clear All"]})]})]})}),e.jsx(O,{children:e.jsxs(fe,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"#"}),e.jsx("th",{children:"Cue"}),e.jsx("th",{children:"Title"}),e.jsx("th",{children:"Scheduled Start"}),e.jsx("th",{children:"Actual Start"}),e.jsx("th",{children:"Scheduled End"}),e.jsx("th",{children:"Actual End"})]})}),e.jsxs("tbody",{children:[i.length===0&&e.jsx(st,{label:"Reports are generated when running through the show."}),i.map(a=>{const o=a.actualStart===null?null:a.actualStart<=a.scheduledStart?"under":"over",l=a.actualEnd===null?null:a.actualEnd<=a.scheduledEnd?"under":"over";return e.jsxs("tr",{children:[e.jsx("th",{children:a.index}),e.jsx("th",{children:a.cue}),e.jsx("th",{children:a.title}),e.jsx("th",{className:ye([o&&Ke[o]]),children:ke(a.scheduledStart)}),e.jsx("th",{className:ye([o&&Ke[o]]),children:ke(a.actualStart)}),e.jsx("th",{className:ye([l&&Ke[l]]),children:ke(a.scheduledEnd)}),e.jsx("th",{className:ye([l&&Ke[l]]),children:ke(a.actualEnd)})]},a.id)})]})]})})]})})}const hi="_expand_1sy0c_17",mi="_column_1sy0c_21",Ht={expand:hi,column:mi},xi=[{value:Se.Cuesheet,label:"Cuesheet"},{value:Se.Operator,label:"Operator"},{value:Se.Timer,label:"Timer"},{value:Se.Backstage,label:"Backstage"},{value:Se.Timeline,label:"Timeline"},{value:Se.StudioClock,label:"Studio Clock"},{value:Se.Countdown,label:"Countdown"},{value:Se.ProjectInfo,label:"Project Info"}],ji={alias:"",target:Se.Timer,search:"",enabled:!0};function pi({urlPreset:t,onClose:s}){var k,N;const{addPreset:n,updatePreset:r,isMutating:i}=is(),{handleSubmit:a,register:o,setFocus:l,setError:h,clearErrors:c,setValue:d,getValues:m,watch:u,formState:{errors:f,isSubmitting:j,isValid:g,isDirty:w}}=de({defaultValues:t??ji,resetOptions:{keepDirtyValues:!0}}),v=x.useRef(null),b=async R=>{try{t?await r(t.alias,R):await n(R),s()}catch(y){h("root",{message:$(y)})}};x.useEffect(()=>{l("alias")},[l]);const C=()=>{var R;c();try{const y=sn(m("alias"),((R=v.current)==null?void 0:R.value.trim())??"");d("target",y.target,{shouldDirty:!0,shouldValidate:!0}),d("search",y.search,{shouldDirty:!0,shouldValidate:!0})}catch(y){h("root",{message:At(y)});return}},F=R=>{try{return new URLSearchParams(R),!0}catch(y){return At(y)||"Invalid URL parameters"}};return e.jsxs(_t,{as:"form",onSubmit:a(b),onKeyDown:R=>we(R,s),className:Ht.column,children:[e.jsx("input",{hidden:!0,name:"enabled",value:"true"}),e.jsx("div",{children:"1. Enter URL and let Ontime generate the preset options"}),e.jsxs(T,{children:[e.jsxs("div",{children:[e.jsx(ae,{children:"Alias"}),e.jsx(L,{...o("alias",{required:"Alias is required"})})]}),e.jsxs("div",{className:Ht.expand,children:[e.jsx(ae,{children:"Generate options (paste URL to generate options)"}),e.jsxs(T,{children:[e.jsx(L,{placeholder:"Paste URL",fluid:!0,ref:v}),e.jsx(p,{onClick:C,children:"Generate"})]})]})]}),e.jsx("div",{children:" - or -"}),e.jsx("div",{children:"2. Choose a view and its parameters"}),e.jsxs("div",{children:[e.jsx(ae,{children:"Target"}),e.jsx(te,{options:xi,...o("target",{required:"Target is required"}),value:u("target"),onValueChange:R=>d("target",R,{shouldDirty:!0})})]}),e.jsxs("div",{children:[e.jsx(ae,{children:"Parameters"}),e.jsx(ft,{fluid:!0,rows:3,...o("search",{validate:F})}),e.jsx(E,{children:(k=f.search)==null?void 0:k.message})]}),e.jsxs("div",{children:[e.jsx(E,{children:(N=f.root)==null?void 0:N.message}),e.jsxs(T,{align:"end",children:[e.jsx(p,{onClick:s,children:"Cancel"}),e.jsx(p,{variant:"primary",type:"submit",disabled:!g||!w,loading:j||i,children:"Save"})]})]})]})}const gi="https://docs.getontime.no/features/url-presets/";function fi(){const[t,s]=x.useState({isOpen:!1,preset:void 0}),{data:n,status:r}=as(),{deletePreset:i,isMutating:a}=is(),o=()=>s({isOpen:!0}),l=c=>s({isOpen:!0,preset:c}),h=()=>s({isOpen:!1,preset:void 0});return e.jsx(O,{children:e.jsxs(X,{children:[e.jsxs(G,{children:["URL presets",e.jsxs(p,{onClick:o,children:["New ",e.jsx(me,{})]})]}),e.jsx(re,{}),e.jsx(O,{children:e.jsxs(je,{children:["URL presets are user pre-defined aliases to Ontime URLs.",e.jsx("br",{}),"This URL can contain full configuration including parameters, or simply route to a specific view.",e.jsx("br",{}),e.jsx("br",{}),"The easiest way to get started is to copy an URL from your browser and paste it into the form.",e.jsx(ee,{href:gi,children:"See the docs"})]})}),e.jsxs(O,{children:[e.jsx(Te,{isLoading:r==="pending"}),t.isOpen&&e.jsx(pi,{urlPreset:t.preset,onClose:h}),e.jsxs(fe,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Enabled"}),e.jsx("th",{children:"Target view"}),e.jsx("th",{children:"Alias"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[n.length===0&&e.jsx(st,{handleClick:o}),n.map((c,d)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(be,{defaultChecked:c.enabled,onCheckedChange:()=>{}})}),e.jsx("td",{children:e.jsx(Q,{children:c.target})}),e.jsx("td",{style:{width:"100%"},children:c.alias}),e.jsxs(T,{relation:"inner",as:"td",children:[e.jsx(J,{variant:"ghosted-white",onClick:m=>ls(c.alias,m),disabled:a,children:e.jsx(es,{})}),e.jsx(J,{onClick:()=>l(c),variant:"ghosted-white","aria-label":"Edit entry","data-testid":`field__edit_${d}`,disabled:a,children:e.jsx(et,{})}),e.jsx(J,{onClick:()=>i(c.alias),variant:"ghosted-destructive","aria-label":"Delete entry","data-testid":`field__delete_${d}`,disabled:a,children:e.jsx(he,{})})]})]},c.alias))]})]})]})]})})}function vi({location:t}){const s=ne("presets",t),n=ne("link",t),r=ne("report",t);return e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:"Sharing and reporting"}),e.jsx("div",{ref:s,children:e.jsx(fi,{})}),e.jsx("div",{ref:n,children:e.jsx(O,{children:e.jsxs(X,{children:[e.jsx(G,{children:"Share Ontime Link"}),!Ae&&e.jsxs(e.Fragment,{children:[e.jsx(Ce,{children:"Ontime is streaming on the following network interfaces"}),e.jsx(si,{})]}),e.jsx(re,{}),e.jsx(Mn,{})]})})}),e.jsx("div",{ref:r,children:e.jsx(ui,{})})]})}const Et=`${nt}/excel`;async function bi(t){const s=new FormData;s.append("excel",t),await z.post(`${Et}/upload`,s,{headers:{"Content-Type":"multipart/form-data"}})}async function yi(){return(await z.get(`${Et}/worksheets`)).data}async function wi(t){return(await z.post(`${Et}/preview`,{options:t})).data}const $e=`${nt}/sheets`,Si=async()=>(await z.get(`${$e}/connect`)).data,Ci=async(t,s)=>{const n=new FormData;return n.append("client_secret",t),(await z.post(`${$e}/${s}/connect`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},_i=async()=>(await z.post(`${$e}/revoke`)).data,ki=async(t,s)=>(await z.post(`${$e}/${t}/read`,{options:s})).data,vs=async t=>(await z.post(`${$e}/${t}/worksheets`)).data,Di=async(t,s)=>(await z.post(`${$e}/${t}/write`,{options:s})).data;function Pi(t){if(!Ei(t))throw new Error("Unknown file type");if(t.size===0)throw new Error("File is empty");if(t.size>1e7)throw new Error("File size limit (10MB) exceeded")}function bs(t){if(!Oi(t))throw new Error("Unknown file type");if(t.size===0)throw new Error("File is empty");if(t.size>1e6)throw new Error("File size limit (1MB) exceeded")}function Ei(t){return t==null?void 0:t.name.endsWith(".xlsx")}function Oi(t){return t==null?void 0:t.name.endsWith(".json")}function Ni(t){if(t.size===0)throw new Error("File is empty");if(t.size>1e6)throw new Error("File size limit (1MB) exceeded")}const ht=(t,s)=>t==="timeStart"||t==="timeEnd"||t==="duration"?Fe(s,{fallback:""}):t==="skip"?s?"x":"":String(s??""),Ri=(t,s,n)=>{const r=[["Ontime · Rundown export"]];t.title&&r.push([`Project title: ${t.title}`]),t.description&&r.push([`Project description: ${t.description}`]);const i=Object.keys(n).map(h=>`custom-${h}`),a=Object.keys(n),o=["timeStart","timeEnd","duration","id","colour","cue","title","note","skip",...i,"type"],l=["Time Start","Time End","Duration","ID","Colour","Cue","Title","Note","Skip?",...a,"Type"];return r.push(l),s.forEach(h=>{if(Qn(h))return;const c=[];o.forEach(d=>{if(Ze(h)){if(d.startsWith("custom-")){const m=d.split("custom-")[1],u=h.custom[m];c.push(ht(m,u))}else c.push(ht(d,h[d]));return}c.push(ht(d,h[d]))}),r.push(c)}),r},ve=`${nt}/db`;function ys(t){return z.post(`${ve}/download`,{filename:t})}async function Ti(t){try{const{data:s,name:n}=await _s(t),r=JSON.stringify(s,null,2),i=Dt(r,"application/json;charset=utf-8;");Pt(i,`${n}.json`)}catch(s){console.error(s)}}async function Ii(t="rundown"){try{const{data:s,name:n}=await _s(t),{project:r,rundowns:i,customFields:a}=s,o=ni(i),l=Ri(r,o,a),h=fs(l),c=Dt(h,"text/csv;charset=utf-8;");Pt(c,`${n}.csv`)}catch(s){console.error(s)}}async function ws(t){const s=new FormData;return s.append("project",t),(await z.post(`${ve}/upload`,s,{headers:{"Content-Type":"multipart/form-data"}})).data}async function Ss(t){return await z.patch(ve,t)}async function Fi(t){return(await z.post(`${ve}/new`,t)).data}async function Ai(t){return(await z.post(`${ve}/quick`,t)).data}async function Li(){return(await z.get(`${ve}/all`)).data}async function Cs(t){return(await z.post(`${ve}/load`,{filename:t})).data}async function $i(){return(await z.post(`${ve}/demo`)).data}async function Vi(t,s){const n=`${ve}/${t}/duplicate`,r=decodeURIComponent(n);return(await z.post(r,{newFilename:s})).data}async function Wi(t,s){const n=`${ve}/${t}/rename`,r=decodeURIComponent(n);return(await z.put(r,{newFilename:s})).data}async function Ui(t){const s=`${ve}/${t}`,n=decodeURIComponent(s);return(await z.delete(n)).data}async function _s(t){const s=await ys(t),n=s.headers["Content-Disposition"];let r=t;if(n!=null){const i=n.indexOf('"')+1,a=n.lastIndexOf('"');r=n.substring(i,a)}return{data:s.data,name:r}}const Mi={authenticate:{available:!1,error:""},sheetId:{available:!1,error:""},worksheet:{available:!1,error:""},pullPush:{available:!1,error:""}},Yt={stepData:Mi,worksheetNames:null,sheetId:null,authenticationStatus:"not_authenticated",rundown:null,customFields:null,spreadsheetImportMap:xr},K=Rs((t,s)=>({...Yt,patchStepData:n=>{const r=s().stepData;t({stepData:{...r,...n}})},setWorksheets:n=>t({worksheetNames:n}),setSheetId:n=>t({sheetId:n}),setAuthenticationStatus:n=>t({authenticationStatus:n}),setRundown:n=>t({rundown:n}),setCustomFields:n=>t({customFields:n}),patchSpreadsheetImportMap:(n,r)=>{const i=s().spreadsheetImportMap;i[n]!==r&&(i[n]=r)},reset:()=>t(Yt),resetPreview:()=>t({rundown:null,customFields:null})}));function lt(){const t=ss(),s=K(d=>d.patchStepData),n=K(d=>d.setRundown),r=K(d=>d.setCustomFields);return{connect:async(d,m)=>{try{return await Ci(d,m)}catch(u){s({authenticate:{available:!1,error:$(u)}})}},revoke:async()=>{try{return await _i()}catch(d){s({authenticate:{available:!1,error:$(d)}})}},verifyAuth:async()=>{try{return await Si()}catch(d){s({authenticate:{available:!1,error:$(d)}})}},importRundownPreview:async(d,m)=>{try{const u=await ki(d,m);n(u.rundown),r(u.customFields)}catch(u){s({pullPush:{available:!0,error:$(u)}})}},importRundown:async(d,m)=>{try{await Ss({rundowns:d,customFields:m}),await t.invalidateQueries({queryKey:[nn,rn]})}catch(u){s({pullPush:{available:!0,error:$(u)}})}},exportRundown:async(d,m)=>{try{await Di(d,m),s({pullPush:{available:!1,error:""}})}catch(u){s({pullPush:{available:!0,error:$(u)}})}}}}const bt={Worksheet:"event schedule",Flag:"flag",Start:"time start","Link start":"link start",End:"time end",Duration:"duration",Cue:"cue",Title:"title","Count to end":"count to end",Skip:"skip",Note:"notes",Colour:"colour","End action":"end action","Timer type":"timer type","Time warning":"warning time","Time danger":"danger time",ID:"id",custom:[]};function qi(t){return typeof t!="object"||t===null?!1:Object.keys(bt).every(n=>Object.hasOwn(t,n))}function Qt(t){const s=t.custom.reduce((n,{ontimeName:r,importName:i})=>(r&&i&&(n[r.trim()]=i.trim()),n),{});return{worksheet:t.Worksheet,flag:t.Flag,timeStart:t.Start,linkStart:t["Link start"],timeEnd:t.End,duration:t.Duration,cue:t.Cue,title:t.Title,countToEnd:t["Count to end"],skip:t.Skip,note:t.Note,colour:t.Colour,endAction:t["End action"],timerType:t["Timer type"],timeWarning:t["Time warning"],timeDanger:t["Time danger"],custom:s,entryId:t.ID}}function zi(t){localStorage.setItem("import-options",JSON.stringify(t))}function Bi(){const t=localStorage.getItem("import-options");if(!t)throw new Error("no import options found");return JSON.parse(t)}function Ki(){try{const t=Bi();return qi(t)?t:bt}catch{return bt}}const Gi="_uploadSection_10owf_17",Hi="_finishSection_10owf_18",Yi="_error_10owf_40",Qi="_success_10owf_43",Ji="_singleActionCell_10owf_47",De={uploadSection:Gi,finishSection:Hi,error:Yi,success:Qi,singleActionCell:Ji};function Xi({hasErrors:t,isSpreadsheet:s,onCancel:n,onSubmitExport:r,onSubmitImport:i}){const a=Ki(),{revoke:o}=lt(),{control:l,handleSubmit:h,register:c,setValue:d,watch:m,formState:{errors:u,isValid:f}}=de({mode:"onChange",defaultValues:a,values:a}),{fields:j,append:g,remove:w}=Qe({control:l,name:"custom"}),v=K(P=>P.stepData),b=K(P=>P.worksheetNames),[C,F]=x.useState("");x.useEffect(()=>{!b||b.length===0||b.includes(a.Worksheet)||d("Worksheet",b[0],{shouldValidate:!0,shouldDirty:!0})},[b,d,a.Worksheet]);const k=async P=>{F("export");const V=Qt(P);await r(V),F("")},N=async()=>{await o(),n()},R=async P=>{F("import");const V=Qt(P);zi(P),await i(V),F("")},y=P=>{w(P)},B=()=>{g({})},se=!!C,ue=s&&!se,I=!se&&!v.worksheet.error,W=!t&&f&&(ue||I);return e.jsxs(O,{as:"form",id:"import-map",children:[e.jsxs(ge,{children:["Import options",e.jsxs(T,{children:[!s&&e.jsx(xs,{text:"Revoke the google authentication",render:e.jsx(p,{}),onClick:N,disabled:se,children:"Revoke"}),e.jsx(p,{onClick:n,disabled:se,children:"Cancel"}),!s&&e.jsx(p,{variant:"primary",onClick:h(k),disabled:!I,loading:C==="export",children:"Export"}),e.jsx(p,{variant:"primary",onClick:h(R),disabled:!W,loading:C==="import",children:"Import preview"})]})]}),e.jsxs(fe,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Ontime field"}),e.jsx("th",{children:"Column name in spreadsheet"}),e.jsx("th",{className:De.singleActionCell})]})}),e.jsxs("tbody",{children:[Object.entries(a).map(([P,V])=>P==="custom"?null:P==="Worksheet"?e.jsxs("tr",{children:[e.jsx("td",{children:P}),e.jsx("td",{children:e.jsx(te,{id:V,value:m(P),onValueChange:D=>d(P,D,{shouldDirty:!0}),options:(b==null?void 0:b.map(D=>({value:D,label:D})))||[]})}),e.jsx("td",{className:De.singleActionCell})]},V):e.jsxs("tr",{children:[e.jsx("td",{children:P}),e.jsx("td",{children:e.jsx(L,{id:V,fluid:!0,maxLength:25,defaultValue:V,placeholder:"Use default column name",...c(P)})}),e.jsx("td",{className:De.singleActionCell})]},V)),j.map((P,V)=>{var _,U,Z;const D=P.ontimeName,H=P.importName,A=(Z=(U=(_=u.custom)==null?void 0:_[V])==null?void 0:U.ontimeName)==null?void 0:Z.message,S=`custom.${V}.ontimeName`;return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx(L,{maxLength:25,fluid:!0,defaultValue:D,placeholder:"Name of the field as shown in Ontime",...c(`custom.${V}.ontimeName`,{validate:ce=>os.isAlphanumericWithSpace(ce)?!0:"Only alphanumeric characters and space are allowed"})}),A&&e.jsx(E,{children:A})]}),e.jsx("td",{children:e.jsx(L,{maxLength:25,fluid:!0,defaultValue:H,placeholder:"Name of the column in the spreadsheet",...c(`custom.${V}.importName`)})}),e.jsx("td",{className:De.singleActionCell,children:e.jsx(J,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:()=>y(V),children:e.jsx(he,{})})})]},S)}),e.jsxs("tr",{children:[e.jsx("td",{}),e.jsx(T,{as:"td",align:"end",children:e.jsxs(p,{onClick:B,children:["Add custom field ",e.jsx(me,{})]})}),e.jsx("td",{})]})]})]}),e.jsx(E,{children:v.worksheet.error})]})}const Zi="https://docs.getontime.no/features/import-spreadsheet-gsheet/";function ea(){return e.jsxs(je,{children:["Ontime can import data from spreadsheets by: ",e.jsx("br",{}),"- importing the spreadsheet file in Ontime ",e.jsx("br",{}),"- synchronising your project with a Google Sheet",e.jsx("br",{}),e.jsx("br",{}),"To synchronise with a Google Sheet, you will need to allow Ontime to authenticate with your Google account.",e.jsx(ee,{href:Zi,children:"See the docs"})]})}function ta(t){const{onCancel:s}=t,{revoke:n,connect:r,verifyAuth:i}=lt(),[a,o]=x.useState(null),[l,h]=x.useState(null),[c,d]=x.useState(""),[m,u]=x.useState(""),f=K(D=>D.sheetId),j=K(D=>D.setSheetId),g=K(D=>D.setWorksheets),w=K(D=>D.patchStepData),v=K(D=>D.authenticationStatus),b=K(D=>D.setAuthenticationStatus),C=K(D=>D.stepData.authenticate.error),F=async()=>{const D=await i();D&&b(D.authenticated)};x.useEffect(()=>{w({authenticate:{available:!1,error:""}}),B()},[]);const k=async()=>{d("cancel"),await n(),await F(),d("")},N=()=>{s()},R=D=>{var H;(H=D.target.files)!=null&&H.length&&o(D.target.files[0])},y=async()=>{if(!a||!f)return;w({worksheet:{available:!1,error:""}}),d("connect");const D=await r(a,f);D&&(u(D.verification_url),h(D.user_code)),d("")},B=async(D=0)=>{const H=await i();if(H!=null&&H.authenticated&&(b(H.authenticated),H.authenticated!=="pending")){if(H.authenticated=="authenticated")try{const A=await vs(H.sheetId);g(A)}catch(A){const S=$(A);w({worksheet:{available:!1,error:S}})}d("");return}if(D<=10){setTimeout(()=>B(D+1),2e3);return}d("")},se=async()=>{d("authenticate"),St(m),window.addEventListener("focus",async()=>{B()},{once:!0})},ue=a&&f,I=!!l&&!!m,W=!!c,P=v==="authenticated",V=v==="pending";return e.jsxs(O,{children:[e.jsxs(ge,{children:["Sync with Google Sheet (experimental)",P?e.jsx(p,{onClick:k,loading:c==="cancel",children:"Revoke Authentication"}):e.jsx(p,{onClick:N,children:"Go Back"})]}),e.jsxs(oe,{children:[e.jsx(ae,{children:"Upload Client Secret provided by Google"}),e.jsx(E,{children:C}),e.jsx(L,{fluid:!0,type:"file",onChange:R,accept:".json",disabled:W||I})]}),e.jsxs(oe,{children:[e.jsx(ae,{children:"Enter ID of sheet to synchronise"}),e.jsx(E,{children:void 0}),e.jsx(L,{fluid:!0,placeholder:"Sheet ID",onChange:D=>j(D.target.value),disabled:W||I})]}),I?e.jsx(oe,{children:e.jsxs(T,{children:[V&&e.jsx("span",{children:"Authenticating..."}),e.jsx(kt,{copyValue:l??"",disabled:!I,children:l||"Upload files to generate Auth Key"}),e.jsxs(p,{onClick:se,disabled:!I,children:[e.jsx(Is,{}),"Authenticate"]})]})}):e.jsx(oe,{children:e.jsx(T,{children:e.jsxs(p,{onClick:y,disabled:!ue||W,loading:c==="connect",children:[e.jsx(Ts,{}),"Connect"]})})})]})}const sa="_center_1burk_17",na="_nowrap_1burk_21",ra="_secondaryRow_1burk_25",ia="_linkStartActive_1burk_30",