UNPKG

@getontime/cli

Version:
2 lines 107 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CustomTranslationModal-DiQbmcgD.js","./vendor-q6fv0YT2.js","./vendor-4xP-6xVS.css","./index-B81u4hxi.js","./index-D6S93MXv.css","./useWindowTitle-Bpmo_HzW.js","./useWindowTitle-DrFGLRMI.css","./Modal-BKx0PDGT.js","./SwatchPicker-Cm5Eicvv.js","./SwatchPicker-Cw1aXCwD.css","./Modal-D3tAPV2u.css","./StyleEditor-CpciRLYh.js","./StyleEditor-Bie84LSc.css","./RundownExport-EorsanA0.js","./EditorUtils-DuKjlUkF.js","./EditorUtils-L4Sg72o_.css","./ProtectRoute-BH-QvsU0.js","./ProtectRoute-Bm5sjStK.css","./useRundown-Bn6ZPsz0.js","./MilestoneEditor-BA0PVIQh.js","./TimeInput-C8DQoFXv.js","./parseUserTime-YeFR8t3F.js","./TimeInput-Cu-N5DmX.css","./dateConfig-D7xim1t4.js","./validateEvent-Do8yE_DJ.js","./editorSettings-D2f7e1a6.js","./editorSettings-BqHbWs9b.css","./rundownUtils-CtVGQDQn.js","./useCustomFields-k4piRt9n.js","./Select-BGGVCKqU.js","./Select-Cd08aEcf.css","./Tooltip-B5vsLcFu.js","./Tooltip-CKb7gU2M.css","./offset-R98EXhWK.js","./MilestoneEditor-BqNKKlvI.css","./Empty-CJbZxh45.js","./Empty-DvR62o5B.css","./useFollowComponent-B7vvPzG2.js","./RundownExport-Bgtg_idR.css","./TimerControlExport-Dx3SSGNG.js","./useReport-DSuFnUb9.js","./TimerControlExport-cJRa5GUp.css","./MessageControlExport-GmOrvUik.js","./MessageControlExport-D_pNX6Vj.css"])))=>i.map(i=>d[i]); import{h as g,j as e,ac as ss,e as Y,k as vt,ad as ce,ae as Ts,af as As,ag as et,ah as je,T as pe,aa as rt,ai as Fs,y as wt,aj as Is,ak as Ft,f as Ls,O as St,A as $s,al as Vs,am as Ms,an as Ge,ao as Ws,P as qe,C as Ne,ap as ns,aq as rs,ar as Us,as,at as It,au as qs,av as zs,l as is,aw as Bs,$ as Qe,v as Ct,ax as Ks,x as Hs,M as Gs,I as Qs,m as Ys}from"./vendor-q6fv0YT2.js";import{e as be,Q as _t,R as Js,S as Xs,U as tt,s as Zs,V as en,W as Ee,X as Ze,Y as N,Z as Me,_ as Ae,$ as P,a0 as se,a1 as Q,a2 as pt,a3 as tn,a4 as sn,a5 as kt,a6 as nn,a7 as ls,a8 as rn,a9 as A,B as f,aa as ie,ab as Se,ac as Le,ad as ve,ae as oe,af as W,ag as B,ah as M,ai as V,aj as $e,ak as X,al as we,am as at,an,ao as ln,ap as Dt,f as Oe,aq as os,ar as Rt,as as cs,at as ne,x as Lt,O as Re,au as on,av as $t,aw as ds,ax as us,ay as Nt,az as cn,aA as dn,aB as Et,aC as ct,m as Ie,k as un,aD as hn,aE as mn,aF as fe,aG as hs,aH as st,T as Ye,aI as xn,aJ as ms,aK as Vt,aL as jn,aM as pn,aN as gn,aO as We,aP as fn,aQ as yn,b as bn,aR as vn,N as wn,aS as Sn,aT as Cn,aU as _n,a as kn,aV as Dn,aW as Rn,aX as Mt,aY as Nn,aZ as Wt,a_ as En,a$ as Pn}from"./index-B81u4hxi.js";import{P as On}from"./ProtectRoute-BH-QvsU0.js";import{I as me,C as Tn,u as An}from"./useWindowTitle-Bpmo_HzW.js";import{e as Fn,u as it,T as H,t as dt,a as In,b as Ln,d as $n,c as Vn,f as Mn,g as Wn,S as Un,h as qn,D as xs,M as Pt}from"./Modal-BKx0PDGT.js";import{S as ke,a as ut}from"./SwatchPicker-Cm5Eicvv.js";import{i as js,R as ps,s as zn,a as Bn,G as Kn,b as Hn,O as Gn,T as Qn}from"./OverviewWrapper-BQb2xl_N.js";import{e as Yn,f as Jn,g as Xn,i as gs,h as fs,j as Zn,k as er,l as tr,m as sr,r as nr,n as rr,o as ar,p as ir,q as lr}from"./useRundown-Bn6ZPsz0.js";import{S as re}from"./Select-BGGVCKqU.js";import{u as lt,p as or,e as cr,d as dr}from"./useCustomFields-k4piRt9n.js";import{u as ur,d as hr}from"./useReport-DSuFnUb9.js";import{T as gt,u as ys,e as Be}from"./editorSettings-D2f7e1a6.js";import{S as mr,L as xr,T as jr}from"./EditorUtils-DuKjlUkF.js";import{T as bs}from"./Tooltip-B5vsLcFu.js";import{A as vs,T as Ke}from"./TimeInput-C8DQoFXv.js";import{T as Ut,E as ht}from"./validateEvent-Do8yE_DJ.js";import{p as He}from"./parseUserTime-YeFR8t3F.js";import{u as pr,a as gr,b as fr}from"./useProjectData-DdgKoYzk.js";import{S as yr,P as br,O as vr,M as wr,C as Sr}from"./TimeElements-DbclWDbU.js";import"./offset-R98EXhWK.js";import"./SuperscriptPeriod-DsPdWN_s.js";/* empty css */import"./playbackstate-CPQdnF-k.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof bt<"u"?bt:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="2e8249d1-0d18-40a3-bb07-442d7b2a76ea",t._sentryDebugIdIdentifier="sentry-dbid-2e8249d1-0d18-40a3-bb07-442d7b2a76ea")}catch{}})();function Cr(t){return t.trim().replaceAll(" ","_")}const _r={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:"note",colour:"colour",endAction:"end action",timerType:"timer type",timeWarning:"warning time",timeDanger:"danger time",custom:{},id:"id"},kr=(t,s,n={})=>{const{isDisabled:r=!1}=n,i=g.useCallback(l=>{l.key===s&&!l.repeat&&!r&&(l.preventDefault(),t())},[t,r,s]);g.useEffect(()=>(document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}),[i])},Dr="_link_70oau_17",Rr="_inline_70oau_27",qt={link:Dr,inline:Rr};function te({href:t,inline:s,children:n}){const r=i=>{i.preventDefault(),_t(t)};return e.jsxs("a",{href:"#!",target:"_blank",rel:"noreferrer",className:be([qt.link,s&&qt.inline]),onClick:r,children:[n," ",e.jsx(ss,{style:{fontSize:"1em"}})]})}async function Nr(){const t=await Y.get(Js);return{url:t.data.html_url,version:t.data.tag_name}}const zt={url:"",version:"",hasUpdates:!1};function ws(){const{data:t,status:s,isFetching:n,isError:r,refetch:i}=vt({queryKey:en,queryFn:Nr,placeholderData:(c,m)=>c,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1,staleTime:Zs,enabled:tt}),l=(t==null?void 0:t.version)&&!t.version.includes(Xs);return{data:t?{...t,hasUpdates:l}:zt,placeholder:zt,status:s,isFetching:n,isError:r,refetch:i}}function Er(){const{data:t,isError:s}=ws();return s?e.jsxs(Ee,{children:[`You are currently using Ontime version ${Ze}`,e.jsx(N,{children:"Could not fetch version information"})]}):t.hasUpdates?e.jsxs(Ee,{children:[`You are currently using Ontime version ${Ze}.`,e.jsx("br",{}),e.jsx("br",{}),`A new version ${t.version} is available.`," ",e.jsx("br",{}),Me?"You can restart your stage to get the latest available version.":e.jsx(te,{href:t.url,children:"Please visit the release page to download"})]}):e.jsx(Ee,{children:`You are currently using the latest version of Ontime: ${Ze}`})}function Pr(){return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{children:"About Ontime"}),e.jsxs(P,{children:[e.jsxs(se,{children:[e.jsx(Q,{children:"Ontime"}),e.jsxs(Ee,{children:["Free, open-source software for managing rundowns and event timers",e.jsx(te,{href:pt,children:"www.getontime.no"})]}),e.jsxs(Ee,{children:["Considering sponsoring our work",e.jsx(te,{href:tn,children:"GitHub Sponsors"}),e.jsx(te,{href:sn,children:"Buy Me a Coffee"})]}),e.jsxs(Ee,{children:["If you are looking for an online version of Ontime, consider trying out our cloud service",e.jsx(te,{href:pt,children:"www.getontime.no"})]})]}),e.jsx(Q,{children:"Current version"}),e.jsx(Er,{}),e.jsx(Q,{children:"Links"}),e.jsx(te,{href:kt,children:"Read the docs"}),e.jsx(te,{href:nn,children:"Follow the project on GitHub"}),e.jsx(te,{href:ls,children:"Discord server"}),e.jsx(te,{href:rn,children:"Subreddit"})]})]})}function ae(t,s){const n=g.useRef(null);return g.useEffect(()=>{s&&n.current&&s===t&&n.current.scrollIntoView({behavior:"smooth",block:"center"})},[s,t]),n}const Or="https://docs.getontime.no/api/protocols/osc/";function Tr({enabledAutomations:t,enabledOscIn:s,oscPortIn:n}){var y,b,v;const{handleSubmit:r,reset:i,register:l,setError:a,watch:c,setValue:m,formState:{errors:o,isSubmitting:u,isDirty:h,isValid:d}}=ce({mode:"onChange",defaultValues:{enabledAutomations:t,enabledOscIn:s,oscPortIn:n},resetOptions:{keepDirtyValues:!1}}),x=async S=>{try{await Fn(S),i(S)}catch(L){const D=V(L);a("root",{message:D})}},j=()=>{i({enabledAutomations:t,enabledOscIn:s,oscPortIn:n})},p=!u&&h&&d;return e.jsxs(se,{children:[e.jsxs(Q,{children:["Automation settings",e.jsxs(A,{children:[e.jsx(f,{variant:"ghosted",onClick:j,disabled:!p,children:"Revert to saved"}),e.jsx(f,{variant:"primary",type:"submit",form:"automation-settings-form",disabled:!p,loading:u,children:"Save"})]})]}),(o==null?void 0:o.root)&&e.jsx(N,{children:o.root.message}),e.jsx(ie,{}),e.jsx(P,{children:e.jsxs(me,{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(te,{href:Or,children:"See the docs"})]})}),e.jsxs(P,{as:"form",id:"automation-settings-form",onSubmit:r(x),onKeyDown:S=>Se(S,j),children:[e.jsx(Le,{isLoading:!1}),e.jsx(ve,{children:"Automation"}),e.jsx(oe,{children:e.jsxs(W,{children:[e.jsx(B,{title:"Enable automations",description:"Allow Ontime to send messages on lifecycle triggers",error:(y=o.enabledAutomations)==null?void 0:y.message}),e.jsx(ke,{size:"large",checked:c("enabledAutomations"),onCheckedChange:S=>m("enabledAutomations",S,{shouldDirty:!0,shouldValidate:!0})})]})}),e.jsx(ve,{children:"OSC Input"}),e.jsxs(oe,{children:[Me&&e.jsx(me,{children:"For security reasons OSC integrations are not available in the cloud service."}),e.jsxs(W,{children:[e.jsx(B,{title:"OSC input",description:"Allow control of Ontime through OSC",error:(b=o.enabledOscIn)==null?void 0:b.message}),e.jsx(ke,{size:"large",checked:c("enabledOscIn"),onCheckedChange:S=>m("enabledOscIn",S,{shouldDirty:!0,shouldValidate:!0})})]}),e.jsxs(W,{children:[e.jsx(B,{title:"Listen on port",description:"Port for incoming OSC. Default: 8888",error:(v=o.oscPortIn)==null?void 0:v.message}),e.jsx(M,{id:"oscPortIn",placeholder:"8888",maxLength:5,style:{textAlign:"right",width:"5rem"},type:"number",fluid:!0,...l("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:js,message:"Value should be numeric"}})})]})]})]})]})}const Ar=["{{human.clock}}","{{human.duration}}","{{human.expectedEnd}}","{{human.runningTimer}}","{{human.elapsedTime}}","{{human.startedAt}}"],Fr=["{{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}}"],Ir=["{{eventNow.id}}","{{eventNow.cue}}","{{eventNow.title}}","{{eventNow.note}}","{{eventNow.timeStart}}","{{eventNow.timeEnd}}","{{eventNow.duration}}","{{eventNow.colour}}","{{eventNow.delay}}"],Lr=["{{eventNext.id}}","{{eventNext.cue}}","{{eventNext.title}}","{{eventNext.note}}","{{eventNext.timeStart}}","{{eventNext.timeEnd}}","{{eventNext.duration}}","{{eventNext.colour}}","{{eventNext.delay}}"];function $r(t){return[...Ar,...Fr,...Ir,...Object.entries(t).map(([s])=>`{{eventNow.custom.${s}}}`),...Lr,...Object.entries(t).map(([s])=>`{{eventNext.custom.${s}}}`)]}function Vr(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 Mr(t){const s=t.lastIndexOf("{{");return s!==-1?t.slice(s):""}const Wr="_wrapper_1dmtf_17",Ur="_suggestions_1dmtf_21",Bt={wrapper:Wr,suggestions:Ur},qr=g.forwardRef(function(s,n){const{value:r,onChange:i,...l}=s,{data:a}=lt(),c=Ts(()=>j(!1)),m=g.useMemo(()=>$r(a),[a]),[o,u]=g.useState(r||""),[h,d]=g.useState([]),[x,j]=g.useState(!1),p=v=>{const S=Mr(v);return m.filter(L=>L.startsWith(S))},y=v=>{u(v.target.value),v.target.value.endsWith("{")?(j(!0),d(p(v.target.value))):v.target.value===""||v.target.value.endsWith("}}")?j(!1):x&&d(p(v.target.value)),i==null||i(v)},b=v=>{u(S=>{const L=Vr(S,v);return S+L}),j(!1)};return e.jsxs("div",{className:Bt.wrapper,ref:As(c,n),children:[e.jsx(M,{value:o,...l,onChange:y,fluid:!0}),x&&h.length>0&&e.jsx("ul",{className:Bt.suggestions,children:h.map(v=>e.jsx("li",{onClick:()=>b(v),children:v},v))})]})}),ft=[{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 zr=[{value:null,label:"Select field"},{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"}],Br=[{value:"eventNext.id",label:"Next ID"},{value:"eventNext.title",label:"Next Title"},{value:"eventNext.cue",label:"Next Cue"}];function Kr(t){return[...zr,...Object.entries(t).map(([s,{label:n}])=>({value:`eventNow.custom.${s}`,label:`Custom: ${n}`})),...Br,...Object.entries(t).map(([s,{label:n}])=>({value:`eventNext.custom.${s}`,label:`Next custom: ${n}`}))]}function Hr(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 Gr="_outerColumn_1klj0_17",Qr="_innerColumn_1klj0_25",Yr="_ruleSection_1klj0_31",Jr="_titleSection_1klj0_37",Xr="_filterSection_1klj0_38",Zr="_oscSection_1klj0_39",ea="_httpSection_1klj0_40",ta="_actionSection_1klj0_41",sa="_test_1klj0_95",na="_outputCard_1klj0_99",ue={outerColumn:Gr,innerColumn:Qr,ruleSection:Yr,titleSection:Jr,filterSection:Xr,oscSection:Zr,httpSection:ea,actionSection:ta,test:sa,outputCard:na};function ra({index:t,register:s,setValue:n,rowErrors:r,value:i,children:l,watch:a}){var u,h,d,x,j;const[c,m]=g.useState(i),o=p=>{n(`outputs.${t}.action`,p,{shouldDirty:!0}),m(p)};return e.jsxs("div",{className:ue.actionSection,children:[e.jsxs("label",{children:["Action",e.jsx(re,{onValueChange:p=>{p!==null&&o(p)},value:a(`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(N,{children:(u=r==null?void 0:r.action)==null?void 0:u.message})]}),c.startsWith("aux")&&c.endsWith("set")&&e.jsxs("label",{children:["New time",e.jsx(M,{...s(`outputs.${t}.time`,{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"eg: 10m5s"}),e.jsx(N,{children:(h=r==null?void 0:r.time)==null?void 0:h.message})]}),c==="message-set"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Text (leave empty for no change)",e.jsx(M,{...s(`outputs.${t}.text`),fluid:!0,placeholder:"eg: Timer is finished"}),e.jsx(N,{children:(d=r==null?void 0:r.text)==null?void 0:d.message})]}),e.jsxs("label",{children:["Visibility",e.jsx(re,{onValueChange:p=>{const y=p===null?void 0:p;n(`outputs.${t}.visible`,y,{shouldDirty:!0})},value:a(`outputs.${t}.visible`),options:[{value:null,label:"Untouched"},{value:!0,label:"Show"},{value:!1,label:"Hide"}]}),e.jsx(N,{children:(x=r==null?void 0:r.visible)==null?void 0:x.message})]})]}),c==="message-secondary"&&e.jsxs("label",{children:["Timer secondary source",e.jsx(re,{onValueChange:p=>{if(p!==null){if(p==="null"){n(`outputs.${t}.secondarySource`,null,{shouldDirty:!0});return}n(`outputs.${t}.secondarySource`,p,{shouldDirty:!0})}},value:a(`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:"secondary",label:"Secondary"},{value:"null",label:"None"}]}),e.jsx(N,{children:(j=r==null?void 0:r.secondarySource)==null?void 0:j.message})]}),e.jsx("div",{className:ue.test,children:l})]})}const aa="https://docs.getontime.no/api/automation/#using-variables-in-automation";function ia({automation:t,onClose:s}){var K;const n=Kt(t),{data:r}=lt(),{refetch:i}=it(),l=g.useMemo(()=>Kr(r),[r]),{control:a,handleSubmit:c,getValues:m,register:o,setError:u,setFocus:h,setValue:d,watch:x,formState:{errors:j,isSubmitting:p,isDirty:y,isValid:b}}=ce({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:v,append:S,remove:L}=et({name:"filters",control:a}),{fields:D,append:O,remove:U}=et({name:"outputs",control:a});g.useEffect(()=>{h("title")},[h]);const w=()=>{S({field:"",operator:"equals",value:""})},$=()=>{O({type:"osc",targetIP:"",targetPort:void 0,address:"",args:""})},_=()=>{O({type:"http",url:""})},G=()=>{O({type:"ontime",action:"aux1-start"})},q=async I=>{try{const k=m(`outputs.${I}`);if(!k.targetIP||!k.targetPort||!k.address)return;await dt({type:"osc",targetIP:k.targetIP,targetPort:k.targetPort,address:k.address,args:k.args})}catch{}},F=async I=>{try{const k=m(`outputs.${I}`);if(!k.url)return;await dt({type:"http",url:k.url})}catch{}},E=async I=>{try{const k=m(`outputs.${I}`);await dt({...k,type:"ontime"})}catch{}},T=async I=>{Kt(t)?await k(t.id,{id:t.id,...I}):await ge(I),i();async function k(de,le){try{await In(de,le),s()}catch(C){u("root",{message:V(C)})}}async function ge(de){try{await Ln(de),s()}catch(le){u("root",{message:V(le)})}}},R=!p&&y&&b;return e.jsxs($e,{as:"form",name:"automation-form",onSubmit:c(T),className:ue.outerColumn,onKeyDown:I=>Se(I,s),children:[e.jsx(Q,{children:n?"Edit automation":"Create automation"}),e.jsxs("div",{className:ue.innerSection,children:[e.jsx("h3",{children:"Automation options"}),e.jsxs("div",{className:ue.titleSection,children:[e.jsxs("label",{children:["Title",e.jsx(M,{...o("title",{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"Load preset"})]}),e.jsx(N,{children:(K=j.title)==null?void 0:K.message})]})]}),e.jsxs("div",{className:ue.innerSection,children:[e.jsx("h3",{children:"Filters (optional)"}),e.jsxs("div",{className:ue.ruleSection,children:[e.jsxs("label",{children:["Trigger outputs if",e.jsx(ps,{orientation:"horizontal",value:x("filterRule"),onValueChange:I=>d("filterRule",I,{shouldDirty:!0}),items:[{value:"all",label:"All filters pass"},{value:"any",label:"Any filter passes"}]})]}),v.map((I,k)=>{var de,le,C,Z,_e,De;const ge=`filters.${k}.field.${I.id}`;return e.jsxs("div",{className:ue.filterSection,children:[e.jsxs("label",{children:["Runtime data source",e.jsx(re,{value:x(`filters.${k}.field`)||null,onValueChange:xe=>{xe!==null&&d(`filters.${k}.field`,xe,{shouldDirty:!0})},options:l.map(({value:xe,label:J})=>({value:xe,label:J,disabled:xe===null})),"aria-label":"Event field"}),e.jsx(N,{children:(C=(le=(de=j.filters)==null?void 0:de[k])==null?void 0:le.field)==null?void 0:C.message})]}),e.jsxs("label",{children:["Matching condition",e.jsx(re,{value:x(`filters.${k}.operator`),onValueChange:xe=>{xe!==null&&d(`filters.${k}.operator`,xe,{shouldDirty:!0})},options:[{value:"equals",label:"equals"},{value:"not_equals",label:"not equals"},{value:"contains",label:"contains"}],"aria-label":"Operator"}),e.jsx(N,{children:(De=(_e=(Z=j.filters)==null?void 0:Z[k])==null?void 0:_e.operator)==null?void 0:De.message})]}),e.jsxs("label",{children:["Value to match",e.jsx(M,{...o(`filters.${k}.value`),fluid:!0,placeholder:"<empty / no value>"})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsx("div",{children:e.jsx(X,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>L(k),children:e.jsx(je,{})})})]})]},ge)}),e.jsx("div",{children:e.jsxs(f,{type:"submit",onClick:w,children:["Add filter ",e.jsx(pe,{})]})})]})]}),e.jsxs("div",{className:ue.innerColumn,children:[e.jsx("h3",{children:"Outputs"}),e.jsxs(me,{children:["Automation outputs can be used to send data from Ontime to external software ",e.jsx("br",{}),"or to change properties of Ontime itself.",e.jsx(te,{href:aa,children:"See the documentation for templates"})]}),D.map((I,k)=>{var ge,de,le,C,Z,_e,De,xe;if(Yn(I)){const J=(ge=j.outputs)==null?void 0:ge[k];return e.jsxs("div",{className:ue.outputCard,children:[e.jsx(H,{children:"OSC"}),e.jsxs("div",{className:ue.oscSection,children:[e.jsxs("label",{children:["Target IP",e.jsx(M,{...o(`outputs.${k}.targetIP`,{required:{value:!0,message:"Required field"}}),fluid:!0,placeholder:"127.0.0.1"}),e.jsx(N,{children:(de=J==null?void 0:J.targetIP)==null?void 0:de.message})]}),e.jsxs("label",{children:["Target Port",e.jsx(M,{...o(`outputs.${k}.targetPort`,{required:{value:!0,message:"Required field"},setValueAs:At=>At===""?0:Number(At),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(N,{children:(le=J==null?void 0:J.targetPort)==null?void 0:le.message})]}),e.jsxs("label",{children:["Address",e.jsx(M,{...o(`outputs.${k}.address`),fluid:!0,placeholder:"/cue/start"}),e.jsx(N,{children:(C=J==null?void 0:J.address)==null?void 0:C.message})]}),e.jsxs("label",{children:["Arguments",e.jsx(qr,{...o(`outputs.${k}.args`),value:I.args,placeholder:"1"}),e.jsx(N,{children:(Z=J==null?void 0:J.args)==null?void 0:Z.message})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsxs(A,{relation:"inner",children:[e.jsx(f,{variant:"ghosted-white",onClick:()=>q(k),children:"Test"}),e.jsx(X,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>U(k),children:e.jsx(je,{})})]})]})]})]},I.id)}if(Jn(I)){const J=(_e=j.outputs)==null?void 0:_e[k];return e.jsxs("div",{className:ue.outputCard,children:[e.jsx(H,{children:"HTTP"}),e.jsxs("div",{className:ue.httpSection,children:[e.jsxs("label",{children:["Target URL",e.jsx(M,{...o(`outputs.${k}.url`,{required:{value:!0,message:"Required field"},pattern:{value:zn,message:"HTTP messages should target http:// or https://"}}),fluid:!0,placeholder:"http://127.0.0.1/start/1"}),e.jsx(N,{children:(De=J==null?void 0:J.url)==null?void 0:De.message})]}),e.jsxs("div",{children:[e.jsx("span",{children:" "}),e.jsxs(A,{relation:"inner",children:[e.jsx(f,{variant:"ghosted-white",onClick:()=>F(k),children:"Test"}),e.jsx(X,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>U(k),children:e.jsx(je,{})})]})]})]})]},I.id)}if(Xn(I)){const J=(xe=j.outputs)==null?void 0:xe[k];return e.jsxs("div",{className:ue.outputCard,children:[e.jsx(H,{children:"Ontime action"}),e.jsxs(ra,{value:I.action,index:k,register:o,rowErrors:J,setValue:d,watch:x,children:[e.jsx("span",{children:" "}),e.jsxs(A,{relation:"inner",children:[e.jsx(f,{variant:"ghosted-white",onClick:()=>E(k),children:"Test"}),e.jsx(X,{"aria-label":"Delete",variant:"ghosted-destructive",onClick:()=>U(k),children:e.jsx(je,{})})]})]})]},I.id)}return null}),e.jsxs(A,{relation:"inner",children:[e.jsxs(f,{onClick:$,children:["OSC ",e.jsx(pe,{})]}),e.jsxs(f,{onClick:_,children:["HTTP ",e.jsx(pe,{})]}),e.jsxs(f,{onClick:G,children:["Ontime action ",e.jsx(pe,{})]})]})]}),e.jsxs(A,{align:"end",children:[(j==null?void 0:j.root)&&e.jsx(N,{children:j.root.message}),e.jsx(f,{onClick:s,children:"Cancel"}),e.jsx(f,{variant:"primary",type:"submit",disabled:!R,loading:p,children:"Save"})]})]})}const Ht={title:"",filterRule:"all",filters:[],outputs:[]};function la(t){const{automations:s}=t,{refetch:n}=it(),[r,i]=g.useState(null),[l,a]=g.useState(null),c=async o=>{try{a(null),await $n(o)}catch(u){a(V(u))}finally{n()}},m=Object.keys(s);return e.jsxs(se,{children:[e.jsxs(Q,{children:["Manage automations",e.jsxs(f,{type:"submit",disabled:!!r,onClick:()=>i(Ht),children:["New ",e.jsx(pe,{})]})]}),e.jsx(ie,{}),r!==null&&e.jsx(ia,{automation:r,onClose:()=>i(null)}),e.jsxs(we,{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:[m.length===0&&e.jsx(at,{handleClick:r?void 0:()=>i(Ht)}),m.map(o=>Object.hasOwn(s,o)?e.jsx(g.Fragment,{children:e.jsxs("tr",{children:[e.jsx("td",{children:s[o].title}),e.jsx("td",{children:e.jsx(H,{children:s[o].filterRule})}),e.jsx("td",{children:s[o].filters.length}),e.jsx("td",{children:s[o].outputs.length}),e.jsxs(A,{align:"end",relation:"inner",as:"td",children:[e.jsx(X,{variant:"ghosted-white","aria-label":"Edit entry",onClick:()=>i(s[o]),children:e.jsx(rt,{})}),e.jsx(X,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:()=>c(o),children:e.jsx(je,{})})]})]})},o):null),l&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(N,{children:l})})})]})]})]})}function Ss({automations:t,initialId:s,initialTitle:n,initialAutomationId:r,initialTrigger:i,onCancel:l,postSubmit:a}){var L,D,O,U;const{handleSubmit:c,register:m,setFocus:o,setError:u,watch:h,setValue:d,formState:{errors:x,isSubmitting:j,isValid:p,isDirty:y}}=ce({defaultValues:{title:n,trigger:i??ft[0].value,automationId:r??((L=t==null?void 0:t[Object.keys(t)[0]])==null?void 0:L.id)},resetOptions:{keepDirtyValues:!0}});g.useEffect(()=>{o("title")},[o]);const b=async w=>{if(s){try{await Vn(s,{id:s,...w}),a()}catch($){u("root",{message:`Failed to save changes to trigger ${V($)}`})}return}try{await Mn(w),a()}catch($){u("root",{message:`Failed to save trigger ${V($)}`})}},v=Object.keys(t).map(w=>({value:w,label:t[w].title})),S=y&&p;return e.jsxs($e,{as:"form",name:"trigger-form",onSubmit:c(b),onKeyDown:w=>Se(w,l),children:[e.jsx(Q,{children:s?"Edit trigger":"Create trigger"}),e.jsxs("label",{children:["Title",e.jsx(M,{...m("title",{required:{value:!0,message:"Required field"}}),fluid:!0,defaultValue:n}),e.jsx(N,{children:(D=x.title)==null?void 0:D.message})]}),e.jsxs("label",{children:["Lifecycle trigger",e.jsx(re,{value:h("trigger"),onValueChange:w=>{w!==null&&d("trigger",w,{shouldDirty:!0})},options:ft.map(w=>({value:w.value,label:w.label})),"aria-label":"Lifecycle trigger"}),e.jsx(N,{children:(O=x.trigger)==null?void 0:O.message})]}),e.jsxs("label",{children:["Automation title",e.jsx(re,{value:h("automationId"),onValueChange:w=>{w!==null&&d("automationId",w,{shouldDirty:!0})},options:v,"aria-label":"Automation title"}),e.jsx(N,{children:(U=x.automationId)==null?void 0:U.message})]}),e.jsxs(A,{align:"end",children:[e.jsx(f,{disabled:j,onClick:l,children:"Cancel"}),e.jsx(f,{type:"submit",variant:"primary",disabled:!S,loading:j,children:"Save"})]})]})}function oa(t){var h,d;const{automations:s,id:n,title:r,trigger:i,automationId:l,duplicate:a,handleDelete:c,postSubmit:m}=t,[o,u]=g.useState(!1);return o?e.jsx("tr",{children:e.jsx("td",{colSpan:99,children:e.jsx(Ss,{automations:s,initialId:n,initialTitle:r,initialTrigger:i,initialAutomationId:l,onCancel:()=>u(!1),postSubmit:()=>{u(!1),m()}})})}):e.jsxs("tr",{"data-warn":a,children:[e.jsxs(A,{as:"td",relation:"inner",children:[a&&e.jsx(Fs,{color:"#FFBC56"}),r]}),e.jsx("td",{children:e.jsx(H,{children:(h=ft.find(x=>x.value===i))==null?void 0:h.label})}),e.jsx("td",{children:e.jsx(H,{children:(d=s==null?void 0:s[l])==null?void 0:d.title})}),e.jsxs(A,{align:"end",relation:"inner",as:"td",children:[e.jsx(X,{variant:"ghosted-white","aria-label":"Edit entry",onClick:()=>u(!0),children:e.jsx(rt,{})}),e.jsx(X,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:c,children:e.jsx(je,{})})]})]})}function ca(t){const{triggers:s,automations:n}=t,[r,i]=g.useState(!1),{refetch:l}=it(),[a,c]=g.useState(null),m=async d=>{try{await Wn(d)}catch(x){c(V(x))}finally{l()}},o=()=>{i(!1),l()},u=g.useMemo(()=>Hr(s),[s]),h=Object.keys(n).length>0;return e.jsxs(se,{children:[e.jsxs(Q,{children:["Manage triggers",e.jsxs(f,{type:"submit",form:"trigger-form",disabled:!h,loading:!1,onClick:()=>i(!0),children:["New ",e.jsx(pe,{})]})]}),e.jsx(ie,{}),e.jsxs(P,{children:[u&&e.jsx(N,{children:"You have created multiple links between the same trigger and automation which can performance issues."}),r&&e.jsx(Ss,{automations:n,onCancel:()=>i(!1),postSubmit:o}),e.jsxs(we,{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(at,{label:"Create an automation to attach triggers to",handleClick:h?()=>i(!0):void 0}),s.map((d,x)=>e.jsxs(g.Fragment,{children:[e.jsx(oa,{automations:n,id:d.id,title:d.title,trigger:d.trigger,automationId:d.automationId,duplicate:u==null?void 0:u.includes(x),handleDelete:()=>m(d.id),postSubmit:o}),a&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(N,{children:a})})})]},d.id))]})]})]})]})}function da({location:t}){const{data:s,status:n}=it(),r=ae("settings",t),i=ae("triggers",t),l=ae("automations",t),a=n==="pending";return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{children:"Automation"}),e.jsxs(P,{children:[e.jsx(Le,{isLoading:a}),e.jsx("div",{ref:r,children:e.jsx(Tr,{enabledAutomations:s.enabledAutomations,enabledOscIn:s.enabledOscIn,oscPortIn:s.oscPortIn})}),e.jsx("div",{ref:l,children:e.jsx(la,{automations:s.automations})}),e.jsx("div",{ref:i,children:e.jsx(ca,{triggers:s.triggers,automations:s.automations})})]})]})}const ua="_goIcon_1fzu7_17",ha={goIcon:ua};function ma(){const{data:t}=an(),s=n=>_t(n);return e.jsx(A,{children:t.networkInterfaces.map(n=>{if(n.name==="localhost"&&!tt)return null;const r=ln(n.address);return e.jsxs(Dt,{copyValue:r,onClick:()=>s(r),children:[`${n.name} - ${n.address}`," ",e.jsx(wt,{className:ha.goIcon})]},n.name)})})}function xa(t){return Is(t)}function ja(t,s,n){if(Object.keys(t).length===0)return[];if(n.length===0)return[];const r=[];let i=1;for(let l=0;l<n.length;l++){const a=n[l],c=s[a];!c||!gs(c)||(a in t||r.push({id:a,index:i,title:c.title,cue:c.cue,scheduledStart:c.timeStart,actualEnd:null,scheduledEnd:c.timeEnd,actualStart:null}),a in t&&r.push({id:a,index:i,title:c.title,cue:c.cue,scheduledStart:c.timeStart,actualEnd:t[a].endedAt,scheduledEnd:c.timeEnd,actualStart:t[a].startedAt}),i++)}return r}const pa=["Index","Title","Cue","Scheduled Start","Actual Start","Scheduled End","Actual End"];function ga(t){const s=[];s.push(pa);for(const n of t)s.push([String(n.index),n.title,n.cue,Oe(n.scheduledStart),Oe(n.actualStart),Oe(n.scheduledEnd),Oe(n.actualEnd)]);return xa(s)}const fa="_blink_15peo_1",ya="_fourtyfive_15peo_13",ba="_over_15peo_17",va="_under_15peo_21",Je={blink:fa,fourtyfive:ya,over:ba,under:va};function wa(){const{data:t}=ur(),{data:s}=fs(),n=async()=>await hr(),r=l=>{if(!l)return;const a=ga(l),c=os(a,"text/csv;charset=utf-8;");Rt(c,"ontime-report.csv")},i=g.useMemo(()=>ja(t,s.entries,s.flatOrder),[t,s.entries,s.flatOrder]);return e.jsx(P,{children:e.jsxs(se,{children:[e.jsx(Q,{children:"Report"}),e.jsx(ie,{}),e.jsx(P,{children:e.jsxs(ve,{children:["Manage report",e.jsxs(A,{children:[e.jsxs(f,{onClick:()=>r(i),disabled:i.length===0,children:[e.jsx(Ft,{}),"Export CSV"]}),e.jsxs(f,{variant:"subtle-destructive",onClick:n,disabled:i.length===0,children:[e.jsx(Ft,{}),"Clear All"]})]})]})}),e.jsx(P,{children:e.jsxs(we,{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(at,{label:"Reports are generated when running through the show."}),i.map(l=>{const a=l.actualStart===null?null:l.actualStart<=l.scheduledStart?"under":"over",c=l.actualEnd===null?null:l.actualEnd<=l.scheduledEnd?"under":"over";return e.jsxs("tr",{children:[e.jsx("th",{children:l.index}),e.jsx("th",{children:l.cue}),e.jsx("th",{children:l.title}),e.jsx("th",{className:be([a&&Je[a]]),children:Oe(l.scheduledStart)}),e.jsx("th",{className:be([a&&Je[a]]),children:Oe(l.actualStart)}),e.jsx("th",{className:be([c&&Je[c]]),children:Oe(l.scheduledEnd)}),e.jsx("th",{className:be([c&&Je[c]]),children:Oe(l.actualEnd)})]},l.id)})]})]})})]})})}const Sa="_expand_1sy0c_17",Ca="_column_1sy0c_21",Gt={expand:Sa,column:Ca},_a=[{value:Re.Cuesheet,label:"Cuesheet"},{value:Re.Operator,label:"Operator"},{value:Re.Timer,label:"Timer"},{value:Re.Backstage,label:"Backstage"},{value:Re.Timeline,label:"Timeline"},{value:Re.StudioClock,label:"Studio Clock"},{value:Re.Countdown,label:"Countdown"},{value:Re.ProjectInfo,label:"Project Info"}],ka={alias:"",target:Re.Timer,search:"",enabled:!0};function Da({urlPreset:t,onClose:s}){var D,O,U;const{addPreset:n,updatePreset:r,isMutating:i}=cs(),{handleSubmit:l,register:a,setFocus:c,setError:m,clearErrors:o,setValue:u,getValues:h,watch:d,formState:{errors:x,isSubmitting:j,isValid:p,isDirty:y}}=ce({defaultValues:t??ka,mode:"onChange",resetOptions:{keepDirtyValues:!0}}),b=g.useRef(null),v=async w=>{try{t?await r(t.alias,w):await n(w),s()}catch($){m("root",{message:V($)})}};g.useEffect(()=>{c("alias")},[c]);const S=()=>{var w;o();try{const $=on(h("alias"),((w=b.current)==null?void 0:w.value.trim())??"");u("target",$.target,{shouldDirty:!0,shouldValidate:!0}),u("search",$.search,{shouldDirty:!0,shouldValidate:!0})}catch($){m("root",{message:$t($)});return}},L=w=>{try{return new URLSearchParams(w),!0}catch($){return $t($)||"Invalid URL parameters"}};return e.jsxs($e,{as:"form",onSubmit:l(v),onKeyDown:w=>Se(w,s),className:Gt.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(A,{children:[e.jsxs("div",{children:[e.jsx(ne,{children:"Alias"}),e.jsx(M,{...a("alias",{required:"Alias is required",pattern:{value:Bn,message:"Field can only contain URL safe characters (a-z, 0-9, _ and -)"}})})]}),e.jsxs("div",{className:Gt.expand,children:[e.jsx(ne,{children:"Generate options (paste URL to generate options)"}),e.jsxs(A,{children:[e.jsx(M,{placeholder:"Paste URL",fluid:!0,ref:b}),e.jsx(f,{onClick:S,children:"Generate"})]})]})]}),((D=x.alias)==null?void 0:D.message)&&e.jsx(N,{children:x.alias.message}),e.jsxs("div",{children:[Lt," or ",Lt]}),e.jsx("div",{children:"2. Choose a view and its parameters"}),e.jsxs("div",{children:[e.jsx(ne,{children:"Target"}),e.jsx(re,{options:_a,...a("target",{required:"Target is required"}),value:d("target"),onValueChange:w=>{w!==null&&u("target",w,{shouldDirty:!0})}})]}),e.jsxs("div",{children:[e.jsx(ne,{children:"Parameters"}),e.jsx(gt,{fluid:!0,rows:3,...a("search",{validate:L})}),e.jsx(N,{children:(O=x.search)==null?void 0:O.message})]}),e.jsxs("div",{children:[e.jsx(N,{children:(U=x.root)==null?void 0:U.message}),e.jsxs(A,{align:"end",children:[e.jsx(f,{onClick:s,children:"Cancel"}),e.jsx(f,{variant:"primary",type:"submit",disabled:!p||!y,loading:j||i,children:"Save"})]})]})]})}const Ra="https://docs.getontime.no/features/url-presets/";function Na(){const[t,s]=g.useState({isOpen:!1,preset:void 0}),{data:n,status:r}=ds(),{deletePreset:i,isMutating:l}=cs(),a=()=>s({isOpen:!0}),c=o=>s({isOpen:!0,preset:o}),m=()=>s({isOpen:!1,preset:void 0});return e.jsx(P,{children:e.jsxs(se,{children:[e.jsxs(Q,{children:["URL presets",e.jsxs(f,{onClick:a,children:["New ",e.jsx(pe,{})]})]}),e.jsx(ie,{}),e.jsx(P,{children:e.jsxs(me,{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(te,{href:Ra,children:"See the docs"})]})}),e.jsxs(P,{children:[e.jsx(Le,{isLoading:r==="pending"}),t.isOpen&&e.jsx(Da,{urlPreset:t.preset,onClose:m}),e.jsxs(we,{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(at,{handleClick:a}),n.map((o,u)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(ke,{defaultChecked:o.enabled,onCheckedChange:()=>{}})}),e.jsx("td",{children:e.jsx(H,{children:o.target})}),e.jsx("td",{style:{width:"100%"},children:o.alias}),e.jsxs(A,{relation:"inner",as:"td",children:[e.jsx(X,{variant:"ghosted-white",onClick:h=>us(o.alias,h),disabled:l,children:e.jsx(ss,{})}),e.jsx(X,{onClick:()=>c(o),variant:"ghosted-white","aria-label":"Edit entry","data-testid":`field__edit_${u}`,disabled:l,children:e.jsx(rt,{})}),e.jsx(X,{onClick:()=>i(o.alias),variant:"ghosted-destructive","aria-label":"Delete entry","data-testid":`field__delete_${u}`,disabled:l,children:e.jsx(je,{})})]})]},o.alias))]})]})]})]})})}function Ea({location:t}){const s=ae("presets",t),n=ae("link",t),r=ae("report",t);return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{children:"Sharing and reporting"}),e.jsx("div",{ref:s,children:e.jsx(Na,{})}),e.jsx("div",{ref:n,children:e.jsx(P,{children:e.jsxs(se,{children:[e.jsx(Q,{children:"Share Ontime Link"}),!Me&&e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:"Ontime is streaming on the following network interfaces"}),e.jsx(ma,{})]}),e.jsx(ie,{}),e.jsx(Kn,{})]})})}),e.jsx("div",{ref:r,children:e.jsx(wa,{})})]})}const Ot=`${Nt}/excel`;async function Pa(t){const s=new FormData;return s.append("excel",t),(await Y.post(`${Ot}/upload`,s,{headers:{"Content-Type":"multipart/form-data"}})).data}async function Oa(t){return(await Y.post(`${Ot}/preview`,{options:t})).data}async function Ta(t,s){try{const n=await Y.get(`${Ot}/${t}/export`,{responseType:"blob"});Rt(n.data,`${s??"Ontime_rundown"}.xlsx`)}catch(n){console.error("Error downloading file:",n)}}const Ue=`${Nt}/sheets`,Aa=async()=>(await Y.get(`${Ue}/connect`)).data,Fa=async(t,s)=>{const n=new FormData;return n.append("client_secret",t),(await Y.post(`${Ue}/${s}/connect`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},Ia=async()=>(await Y.post(`${Ue}/revoke`)).data,La=async(t,s)=>(await Y.post(`${Ue}/${t}/read`,{options:s})).data,Cs=async t=>(await Y.post(`${Ue}/${t}/worksheets`)).data,$a=async(t,s)=>(await Y.post(`${Ue}/${t}/write`,{options:s})).data;function Va(t){if(!Ma(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 _s(t){if(!Wa(t))throw new Error("Unknown file type");if(t.size===0)throw new Error("File is empty");if(t.size>2e6)throw new Error("File size limit (2MB) exceeded")}function Ma(t){return t==null?void 0:t.name.endsWith(".xlsx")}function Wa(t){return t==null?void 0:t.name.endsWith(".json")}function Ua(t){if(t.size===0)throw new Error("File is empty");if(t.size>15e5)throw new Error("File size limit (1.5MB) exceeded")}const Ce=`${Nt}/db`;function ks(t){return Y.post(`${Ce}/download`,{filename:t})}async function qa(t){try{const{data:s,name:n}=await Ja(t),r=JSON.stringify(s,null,2),i=os(r,"application/json;charset=utf-8;");Rt(i,`${n}.json`)}catch(s){console.error(s)}}async function Ds(t){const s=new FormData;return s.append("project",t),(await Y.post(`${Ce}/upload`,s,{headers:{"Content-Type":"multipart/form-data"}})).data}async function Rs(t){return await Y.patch(Ce,t)}async function za(t){return(await Y.post(`${Ce}/new`,t)).data}async function Ba(t){return(await Y.post(`${Ce}/quick`,t)).data}async function Ka(){return(await Y.get(`${Ce}/all`)).data}async function Ns(t){return(await Y.post(`${Ce}/load`,{filename:t})).data}async function Ha(){return(await Y.post(`${Ce}/demo`)).data}async function Ga(t,s){const n=`${Ce}/${t}/duplicate`,r=decodeURIComponent(n);return(await Y.post(r,{newFilename:s})).data}async function Qa(t,s){const n=`${Ce}/${t}/rename`,r=decodeURIComponent(n);return(await Y.put(r,{newFilename:s})).data}async function Ya(t){const s=`${Ce}/${t}`,n=decodeURIComponent(s);return(await Y.delete(n)).data}async function Ja(t){const s=await ks(t),n=s.headers["Content-Disposition"];let r=t;if(n!=null){const i=n.indexOf('"')+1,l=n.lastIndexOf('"');r=n.substring(i,l)}return{data:s.data,name:r}}const Xa={authenticate:{available:!1,error:""},sheetId:{available:!1,error:""},worksheet:{available:!1,error:""},pullPush:{available:!1,error:""}},Qt={stepData:Xa,worksheetNames:null,sheetId:null,authenticationStatus:"not_authenticated",rundown:null,customFields:null,summary:null,spreadsheetImportMap:_r},z=Ls((t,s)=>({...Qt,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}),setSummary:n=>t({summary:n}),patchSpreadsheetImportMap:(n,r)=>{const i=s().spreadsheetImportMap;i[n]!==r&&(i[n]=r)},reset:()=>t(Qt),resetPreview:()=>t({rundown:null,customFields:null,summary:null})}));function ot(){const t=St(),s=z(h=>h.patchStepData),n=z(h=>h.setRundown),r=z(h=>h.setCustomFields),i=z(h=>h.setSummary);return{connect:async(h,d)=>{try{return await Fa(h,d)}catch(x){s({authenticate:{available:!1,error:V(x)}})}},revoke:async()=>{try{return await Ia()}catch(h){s({authenticate:{available:!1,error:V(h)}})}},verifyAuth:async()=>{try{return await Aa()}catch(h){s({authenticate:{available:!1,error:V(h)}})}},importRundownPreview:async(h,d)=>{try{const x=await La(h,d);n(x.rundown),r(x.customFields),i(x.summary)}catch(x){s({pullPush:{available:!0,error:V(x)}})}},importRundown:async(h,d)=>{try{await Rs({rundowns:h,customFields:d}),await t.invalidateQueries({queryKey:[cn,dn]})}catch(x){s({pullPush:{available:!0,error:V(x)}})}},exportRundown:async(h,d)=>{try{await $a(h,d),s({pullPush:{available:!1,error:""}})}catch(x){s({pullPush:{available:!0,error:V(x)}})}}}}const yt={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 Za(t){return typeof t!="object"||t===null?!1:Object.keys(yt).every(n=>Object.hasOwn(t,n))}function Yt(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,id:t.ID}}function ei(t){localStorage.setItem("import-options",JSON.stringify(t))}function ti(){const t=localStorage.getItem("import-options");if(!t)throw new Error("no import options found");return JSON.parse(t)}function si(){try{const t=ti();return Za(t)?t:yt}catch{return yt}}const ni="_uploadSection_10owf_17",ri="_finishSection_10owf_18",ai="_error_10owf_40",ii="_success_10owf_43",li="_singleActionCell_10owf_47",Te={uploadSection:ni,finishSection:ri,error:ai,success:ii,singleActionCell:li};function oi({hasErrors:t,isSpreadsheet:s,onCancel:n,onSubmitExport:r,onSubmitImport:i}){const l=si(),{revoke:a}=ot(),{control:c,handleSubmit:m,register:o,setValue:u,watch:h,formState:{errors:d,isValid:x}}=ce({mode:"onChange",defaultValues:l,values:l}),{fields:j,append:p,remove:y}=et({control:c,name:"custom"}),b=z(E=>E.stepData),v=z(E=>E.worksheetNames),[S,L]=g.useState("");g.useEffect(()=>{!v||v.length===0||v.includes(l.Worksheet)||u("Worksheet",v[0],{shouldValidate:!0,shouldDirty:!0})},[v,u,l.Worksheet]);const D=async E=>{L("export");const T=Yt(E);await r(T),L("")},O=async()=>{await a(),n()},U=async E=>{L("import");const T=Yt(E);ei(E),await i(T),L("")},w=E=>{y(E)},$=()=>{p({})},_=!!S,G=s&&!_,q=!_&&!b.worksheet.error,F=!t&&x&&(G||q);return e.jsxs(P,{as:"form",id:"import-map",children:[e.jsxs(ve,{children:["Import options",e.jsxs(A,{children:[!s&&e.jsx(bs,{text:"Revoke the google authentication",render:e.jsx(f,{}),onClick:O,disabled:_,children:"Revoke"}),e.jsx(f,{onClick:n,disabled:_,children:"Cancel"}),!s&&e.jsx(f,{variant:"primary",onClick:m(D),disabled:!q,loading:S==="export",children:"Export"}),e.jsx(f,{variant:"primary",onClick:m(U),disabled:!F,loading:S==="import",children:"Import preview"})]})]}),e.jsxs(me,{children:["Match your spreadsheet columns to Ontime fields. ",e.jsx("br",{}),"You can also add Custom Fields by providing a name for Ontime and the spreadsheet column name."]}),e.jsxs(we,{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:Te.singleActionCell})]})}),e.jsxs("tbody",{children:[Object.entries(l).map(([E,T])=>E==="custom"?null:E==="Worksheet"?e.jsxs("tr",{children:[e.jsx("td",{children:E}),e.jsx("td",{children:e.jsx(re,{id:T,value:h(E),onValueChange:R=>{R!==null&&u(E,R,{shouldDirty:!0})},options:(v==null?void 0:v.map(R=>({value:R,label:R})))||[]})}),e.jsx("td",{className:Te.singleActionCell})]},T):e.jsxs("tr",{children:[e.jsx("td",{children:E}),e.jsx("td",{children:e.jsx(M,{id:T,fluid:!0,maxLength:25,defaultValue:T,placeholder:"Use default column name",...o(E)})}),e.jsx("td",{className:Te.singleActionCell})]},T)),j.map((E,T)=>{var ge,de,le;const R=E.ontimeName,K=E.importName,I=(le=(de=(ge=d.custom)==null?void 0:ge[T])==null?void 0:de.ontimeName)==null?void 0:le.message,k=`custom.${T}.ontimeName`;return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx(M,{maxLength:25,fluid:!0,defaultValue:R,placeholder:"Name of the field as shown in Ontime",...o(`custom.${T}.ontimeName`,{validate:C=>Et.isAlphanumericWithSpace(C)?!0:"Only alphanumeric characters and space are allowed"})}),I&&e.jsx(N,{children:I})]}),e.jsx("td",{children:e.jsx(M,{maxLength:25,fluid:!0,defaultValue:K,placeholder:"Name of the column in the spreadsheet",...o(`custom.${T}.importName`)})}),e.jsx("td",{className:Te.singleActionCell,children:e.jsx(X,{variant:"ghosted-destructive","aria-label":"Delete entry",onClick:()=>w(T),children:e.jsx(je,{})})})]},k)}),e.jsxs("tr",{children:[e.jsx("td",{}),e.jsx(A,{as:"td",align:"end",children:e.jsxs(f,{onClick:$,children:["Add custom field ",e.jsx(pe,{})]})}),e.jsx("td",{})]})]})]}),e.jsx(N,{children:b.worksheet.error})]})}const ci="https://docs.getontime.no/features/import-spreadsheet-gsheet/";function di(){return e.jsxs(me,{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(te,{href:ci,children:"See the docs"})]})}function ui(t){const{onCancel:s}=t,{revoke:n,connect:r,verifyAuth:i}=ot(),[l,a]=g.useState(null),[c,m]=g.useState(null),[o,u]=g.useState(""),[h,d]=g.useState(""),x=z(R=>R.sheetId),j=z(R=>R.setSheetId),p=z(R=>R.setWorksheets),y=z(R=>R.patchStepData),b=z(R=>R.authenticationStatus),v=z(R=>R.setAuthenticationStatus),S=z(R=>R.stepData.authenticate.error),L=async()=>{const R=await i();R&&v(R.authenticated)};g.useEffect(()=>{y({authenticate:{available:!1,error:""}}),$()},[]);const D=async()=>{u("cancel"),await n(),await L(),u("")},O=()=>{s()},U=R=>{var K;(K=R.target.files)!=null&&K.length&&a(R.target.files[0])},w=async()=>{if(!l||!x)return;y({worksheet:{available:!1,error:""}}),u("connect");const R=await r(l,x);R&&(d(R.verification_url),m(R.user_code)),u("")},$=async(R=0)=>{const K=await i();if(K!=null&&K.authenticated&&(v(K.authenticated),K.authenticated!=="pending")){if(K.authenticated=="authenticated")try{const I=await Cs(K.sheetId);p(I)}catch(I){const k=V(I);y({worksheet:{available:!1,error:k}})}u("");return}if(R<=10){setTimeout(()=>$(R+1),2e3);return}u("")},_=async()=>{u("authenticate"),_t(h),window.addEventListener("focus",async()=>{$()},{once:!0})},G=l&&x,q=!!c&&!!h,F=!!o,E=b==="authenticated",T=b==="pending";return e.jsxs(P,{children:[e.jsxs(ve,{children:["Sync with Google Sheet (experimental)",E?e.jsx(f,{onClick:D,loading:o==="cancel",children:"Revoke Authentication"}):e.jsx(f,{onClick:O,children:"Go Back"})]}),e.jsxs(oe,{children:[e.jsx(ne,{children:"Upload Client Secret provided by Google"}),e.jsx(N,{children:S}),e.jsx(M,{fluid:!0,type:"file",onChange:U,accept:".json",disabled:F||q})]}),e.jsxs(oe,{children:[e.jsx(ne,{children:"Enter ID of sheet to synchronise"}),e.jsx(N,{children:void 0}),e.jsx(M,{fluid:!0,placeholder:"Sheet ID",onChange:R=>j(R.target.value),disabled:F||q})]}),q?e.jsx(oe,{children:e.jsxs(A,{children:[T&&e.jsx("span",{children:"Authenticating..."}),e.jsx(Dt,{copyValue:c??"",disabled:!q,children:c||"Upload files to generate Auth Key"}),e.jsxs(f,{onClick:_,disabled:!q,children:[e.jsx(Vs,{}),"Authenticate"]})]})}):e.jsx(oe,{children:e.jsx(A,{children:e.jsxs(f,{onClick:w,disabled:!G||F,loading:o==="connect",children:[e.jsx($s,{}),"Connect"]})})})]})}const hi="_center_l8uww_17",mi="_nowrap_l8uww_21",xi="_secondaryRow_l8uww_25",ji="_linkStartActive_l8uww_30",pi="_flex_l8uww_36",gi="_subdued_l8uww_42",ee={center:hi,nowrap:mi,secondaryRow:xi,linkStartActive:ji,flex:pi