@getontime/cli
Version:
Time keeping for live events
3 lines (2 loc) • 8.76 kB
JavaScript
import{a7 as x,j as t,r as g,aw as k,aT as V,D as N,o as $,p as D,q as F,G as E,t as I}from"./vendor-DFNUfA2K.js";import{bi as L,i as y,B as S,T as h,y as q,bj as A,g as H,bf as M,w as R,x as T,bd as z,af as v,c as B,bk as O,ai as U}from"./index-BNit4nUw.js";import{C as W,I as Z}from"./useWindowTitle-Bgl000Se.js";import{S as G}from"./Select-Bp_h4xvR.js";import{d as J,S as K}from"./useProjectData-BfKJevmX.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="5d69da95-1268-4e37-a104-0615c2d66451",e._sentryDebugIdIdentifier="sentry-dbid-5d69da95-1268-4e37-a104-0615c2d66451")}catch{}})();function Re(e,s=[],n=!0){const a=[...s];for(const[r,i]of Object.entries(e))n&&i.type==="image"||a.push({value:`custom-${r}`,label:`Custom: ${i.label}`});return a}function Te(e,s=!0){const n=[];for(const[a,r]of Object.entries(e))s&&r.type==="image"||n.push({value:a,label:r.label,colour:r.colour||"transparent"});return n}function ze(e){return e.custom.map((s,n)=>({value:`${n}-${s.title}`,label:s.title}))}function Q(e){return e.startsWith("#")?e.substring(1):e}function X(e){const s={defaultValues:{},colorFields:new Set,booleanFields:new Set,isPersistedField:new Set,persistedValues:{}};return e.forEach(n=>{n.options.forEach(a=>{a.type==="persist"?(s.isPersistedField.add(a.id),a.values&&(s.persistedValues[a.id]=a.values)):s.defaultValues[a.id]=String(a.defaultValue),a.type==="colour"?s.colorFields.add(a.id):a.type==="boolean"&&s.booleanFields.add(a.id)})}),s}function Y(e,s){const n=new URLSearchParams,a=new Set,r=X(s),i=(o,c)=>{const l=`${o}:${c}`;a.has(l)||(a.add(l),n.append(o,c))};return Object.entries(r.persistedValues).forEach(([o,c])=>{c.forEach(l=>{l&&i(o,l)})}),Object.entries(e).forEach(([o,c])=>{typeof c=="string"&&c.length&&(r.isPersistedField.has(o)&&(Array.from(a).forEach(l=>{l.startsWith(`${o}:`)&&a.delete(l)}),n.delete(o)),c.split(",").forEach(l=>{const d=r.colorFields.has(o)?Q(l):r.booleanFields.has(o)?l==="on"?"true":"false":l;(r.isPersistedField.has(o)||r.defaultValues[o]!==d)&&i(o,d)}))}),n}const ee="_presetSection_dyqzq_17",se="_preset_dyqzq_17",te="_active_dyqzq_31",ae="_presetActions_dyqzq_35",_={presetSection:ee,preset:se,active:te,presetActions:ae};function ne({target:e}){const{viewPresets:s}=L(e),[n,a]=x(),r=i=>{a(`${i.search}&alias=${i.alias}`)};return s.length===0?null:t.jsx("div",{className:_.presetSection,children:s.map(i=>{const o=window.location.search.includes(`alias=${i.alias}`);return t.jsxs("div",{className:y([_.preset,o&&_.active]),children:[t.jsx("div",{children:i.alias}),t.jsx(S,{variant:"subtle-white",onClick:()=>r(i),disabled:o,className:_.presetActions,children:o?"Applied":"Apply"})]},i.alias)})})}var w=(e=>(e.ClockOptions="Clock Options",e.TimerOptions="Timer Options",e.DataSources="Data sources",e.ElementVisibility="Element visibility",e.BehaviourOptions="View behaviour",e.StyleOverride="View style override",e.Animation="View animation",e.Schedule="Schedule options",e.Hidden="Hidden options",e))(w||{});function Be(e,s,n,a,r,i){if(!r)return null;const o=i??s;if(n)return r.current===null?null:e?Math.max(r.current,0):r.current;switch(o){case h.CountDown:return r.current===null?null:e?Math.max(r.current,0):r.current;case h.CountUp:return Math.abs(r.elapsed??0);case h.Clock:return a;case h.None:return null;default:return null}}function re(e){return e===null?!1:(e==null?void 0:e.toLowerCase())==="true"||e==="1"}function Oe(e){if(e)return e.startsWith("#")?e:`#${e}`}function Ue(e,s){var n;if(!(!e||typeof s!="string"||s==="none")){if(s.startsWith("custom-")){const a=s.split("custom-")[1];return(n=e.custom)==null?void 0:n[a]}return e[s]}}function We(e,s,n,a){if(e==null||s===h.None)return a.removeSeconds?q:A;if(s===h.Clock)return H(e);let r=e;a.removeSeconds&&r<-1e3&&s!==h.CountUp&&(r-=M);let i=R(r,{direction:s});return a.removeLeadingZero&&(i=T(i)),a.removeSeconds&&(i=ie(i,n)),i}function ie(e,s){return e=z(e),e.length<3?`${e} ${s}`:e}const oe="_inline_4jmjk_17",le={inline:oe},ce=e=>e.startsWith("#")?e:`#${e}`;function ue(e){const{name:s,value:n}=e,[a,r]=g.useState(()=>ce(n));return t.jsxs("div",{className:le.inline,children:[t.jsx(J,{color:a,onChange:r,alwaysDisplayColor:!0}),t.jsx("span",{children:a}),t.jsx("input",{type:"hidden",name:s,value:a})]})}const de="_inline_1b4uk_17",fe="_toggleSelect_1b4uk_24",me="_empty_1b4uk_52",b={inline:de,toggleSelect:fe,empty:me};function P({paramField:e}){const[s]=x(),{id:n,type:a,defaultValue:r}=e;if(a==="persist")return!e.values||!e.values.length?null:t.jsx("input",{hidden:!0,name:n,readOnly:!0,value:e.values.join(",")});if(a==="option"){const l=s.get(n)||r;return e.values.length===0?t.jsx("span",{className:b.empty,children:"No options available"}):t.jsx(G,{size:"large",name:n,defaultValue:l,options:e.values})}if(a==="multi-option")return t.jsx(he,{paramField:e});if(a==="boolean")return t.jsx(pe,{id:n,initialValue:re(s.get(n))||r});if(a==="number"){const{placeholder:c}=e,l=s.get(n)??r;return t.jsx(v,{height:"large",type:"number",step:"any",name:n,defaultValue:l,placeholder:c})}if(a==="colour"){const c=`#${s.get(n)??r}`;return t.jsx(ue,{name:n,value:c})}const i=s.get(n)??r,{placeholder:o}=e;return t.jsx(v,{height:"large",name:n,defaultValue:i,placeholder:o})}function he({paramField:e}){const[s]=x(),{id:n,values:a,defaultValue:r=[""]}=e,i=s.getAll(n),[o,c]=g.useState(i||r),l=(d,p)=>{c(p?u=>[...u,d]:u=>u.filter(j=>j!==d))};return a.length===0?t.jsx("span",{className:b.empty,children:"No options available"}):t.jsxs(t.Fragment,{children:[t.jsx("input",{name:n,hidden:!0,readOnly:!0,value:o.join(",")}),t.jsx("div",{className:b.inline,children:a.map(d=>t.jsxs("label",{className:b.toggleSelect,style:{"--user-bg":d.colour},children:[t.jsx(W,{checked:o.includes(d.value),onCheckedChange:p=>l(d.value,p)}),d.label]},d.value))})]})}function pe({id:e,initialValue:s}){const[n,a]=g.useState(s);return t.jsx(K,{size:"large",name:e,checked:n,onCheckedChange:a})}const ge="_section_xeph4_17",_e="_sectionHeader_xeph4_22",be="_collapsible_xeph4_28",xe="_label_xeph4_32",je="_title_xeph4_41",ye="_description_xeph4_47",Se="_closed_xeph4_53",ve="_open_xeph4_58",f={section:ge,sectionHeader:_e,collapsible:be,label:xe,title:je,description:ye,closed:Se,open:ve};function we({title:e,collapsible:s,options:n}){const[a,r]=k({key:`params-${e}`,defaultValue:!1}),i=()=>{s&&r(o=>!o)};return t.jsx("section",{className:f.section,children:e===w.Hidden?t.jsx(Ce,{options:n}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:y([f.sectionHeader,s&&f.collapsible]),onClick:i,children:[e,s&&t.jsx(V,{className:y([a?f.closed:f.open])})]}),t.jsx(Pe,{options:n,collapsed:a})]})})}function Pe({options:e,collapsed:s}){return s?null:t.jsx(t.Fragment,{children:e.map(n=>t.jsxs("label",{className:f.label,children:[t.jsx("span",{className:f.title,children:n.title}),t.jsx("span",{className:f.description,children:n.description}),t.jsx(P,{paramField:n})]},n.title))})}function Ce({options:e}){return t.jsx(t.Fragment,{children:e.map((s,n)=>t.jsx(P,{paramField:s},s.title+n))})}const ke="_backdrop_fd6ux_26",Ve="_drawer_fd6ux_17",Ne="_header_fd6ux_65",$e="_body_fd6ux_75",De="_footer_fd6ux_82",Fe="_sectionList_fd6ux_90",Ee="_info_fd6ux_97",m={backdrop:ke,drawer:Ve,header:Ne,body:$e,footer:De,sectionList:Fe,info:Ee},Ze=g.memo(Ie);function Ie({target:e,viewOptions:s}){const[n,a]=x(),{data:r}=B(),{isOpen:i,close:o}=O(),c=g.useReducer(u=>u+1,0)[1],l=()=>{o()},d=()=>{a(),c()},p=u=>{u.preventDefault();const j=Object.fromEntries(new FormData(u.currentTarget)),C=Y(j,s);a(C),c()};return t.jsx(N,{open:i,onOpenChange:u=>{u||l()},children:t.jsxs($,{children:[t.jsx(D,{className:m.backdrop}),t.jsxs(F,{className:m.drawer,children:[t.jsxs("div",{className:m.header,children:[t.jsx(E,{children:"Customise"}),t.jsx(U,{variant:"subtle-white",size:"large","data-testid":"close-view-params",onClick:l,children:t.jsx(I,{})})]}),t.jsxs("div",{className:m.body,children:[r.overrideStyles&&t.jsx(Z,{className:m.info,children:"This view style is being modified by a custom CSS file."}),t.jsx(ne,{target:e}),t.jsx("form",{id:"edit-params-form",onSubmit:p,className:m.sectionList,children:s.map(u=>t.jsx(we,{title:u.title,collapsible:u.collapsible,options:u.options},u.title))})]}),t.jsxs("div",{className:m.footer,children:[t.jsx(S,{variant:"subtle",size:"large",onClick:d,type:"reset",children:"Reset to default"}),t.jsx(S,{variant:"primary",size:"large",form:"edit-params-form",type:"submit","data-testid":"apply-view-params",children:"Apply"})]})]})]})})}export{w as O,Ze as V,Oe as a,We as b,Be as c,ze as d,Te as e,Ue as g,re as i,Re as m};
//# sourceMappingURL=ViewParamsEditor-C6i_vUmm.js.map