import{_ as U,i as T,h as g,e as B,u as E,x as _,r as k,o as s,c as u,a as t,F as b,y as V,z as I,t as C,l as L,v as $,A as f,B as w,f as D,k as h}from"./index-20f16f2f.js";const A={name:"PageMasterConfigTimelabel",setup(){const v=T(h.notification),d=T(h.errorHandler).handleErrorAsync,m=T(h.timeLabelStore),a=g([]),y=B(()=>{const l=a.value.filter(n=>!n.deleted),i=[];return i.push(...l.filter(n=>!n.label).map(n=>({item:n,code:"novalue",property:"label"}))),i.push(...l.filter(n=>!n.startTime).map(n=>({item:n,code:"novalue",property:"startTime"}))),i.push(...l.filter(n=>!n.endTime).map(n=>({item:n,code:"novalue",property:"endTime"}))),i.push(...l.filter(n=>n.startTime&&n.endTime&&I(n.startTime,n.endTime)>=0).map(n=>({item:n,code:"negativeduration"}))),i}),p=d(async()=>{await m.load(),a.value=m.timeLabels.value.map(l=>({id:l.id,startTime:l.startTime,endTime:l.endTime,label:l.label,disabled:l.disabled,deleted:!1})),r()});p();function c(){a.value.push({id:null,startTime:null,endTime:null,label:"",disabled:!1,deleted:!1})}function r(){a.value.sort(E(l=>l.label))}const e=d(async()=>{if(y.value.length){v.add("error","入力欄にエラーがあります。修正してください。");return}const l=a.value.filter(o=>o.id==null&&!o.deleted),i=a.value.filter(o=>o.id!=null&&!o.deleted),n=a.value.filter(o=>o.id!=null&&o.deleted);n.length&&!confirm("いくつかの時間帯が削除されます。それらの時間帯が指定されたイベントは時間帯指定なしの任意時刻入力として扱われるようになります。本当に削除しますか？")||(await m.mutate(l.map(o=>({opcode:"add",param:_({...o,deleted:void 0})})).concat(i.map(o=>({opcode:"update",param:_({...o,deleted:void 0})})),n.map(o=>({opcode:"remove",param:{id:o.id}})))),v.add("info","保存しました。"),await p())});return{timeLabels:a,timeLabelErrors:y,load:p,add:c,sort:r,save:e}}},M=t("h1",null,"時間帯登録",-1),S=t("p",null,"「チェックして保存」ボタンを押さない限り変更は保存されません！",-1),F=t("thead",null,[t("tr",null,[t("th",null,"ID"),t("th",null,"ラベル"),t("th",null,"開始時刻"),t("th",null,"終了時刻"),t("th",null,"非表示"),t("th",null,"操作")])],-1),N={key:0},O=["title"],P=["onUpdate:modelValue"],j=["onUpdate:modelValue"],z=["onClick"];function H(v,d,m,a,y,p){const c=k("input-time"),r=k("date-time");return s(),u(b,null,[M,S,t("table",null,[F,t("tbody",null,[(s(!0),u(b,null,V(a.timeLabels,e=>(s(),u(b,{key:e.id},[e.deleted?D("",!0):(s(),u("tr",N,[t("th",{title:e.id},C(e.id?`...${e.id.slice(-4)}`:"[未割当]"),9,O),t("td",null,[L(t("input",{"onUpdate:modelValue":l=>e.label=l},null,8,P),[[$,e.label]])]),t("td",null,[e.id==null?(s(),f(c,{key:0,modelValue:e.startTime,"onUpdate:modelValue":l=>e.startTime=l},null,8,["modelValue","onUpdate:modelValue"])):(s(),f(r,{key:1,value:e.startTime},null,8,["value"]))]),t("td",null,[e.id==null?(s(),f(c,{key:0,modelValue:e.endTime,"onUpdate:modelValue":l=>e.endTime=l},null,8,["modelValue","onUpdate:modelValue"])):(s(),f(r,{key:1,value:e.endTime},null,8,["value"]))]),t("td",null,[L(t("input",{type:"checkbox","onUpdate:modelValue":l=>e.disabled=l},null,8,j),[[w,e.disabled]])]),t("td",null,[t("button",{type:"button",onClick:l=>{e.deleted=!0}}," 削除 ",8,z)])]))],64))),128))])]),t("button",{type:"button",onClick:d[0]||(d[0]=e=>a.add())},"追加"),t("button",{type:"button",onClick:d[1]||(d[1]=e=>a.sort())},"ソート"),t("ul",null,[(s(!0),u(b,null,V(a.timeLabelErrors,(e,l)=>(s(),u("li",{key:l},C(e.code==="novalue"?`${a.timeLabels.filter(i=>!i.deleted).indexOf(e.item)+1}番目の${{label:"ラベル",startTime:"開始時刻",endTime:"終了時刻"}[e.property]}が指定されていません`:`${a.timeLabels.filter(i=>!i.deleted).indexOf(e.item)+1}番目の終了時刻が開始時刻よりも前か同じです`),1))),128))]),t("p",null,[t("button",{type:"button",onClick:d[2]||(d[2]=e=>a.save())},"チェックして保存")]),t("p",null,[t("button",{type:"button",onClick:d[3]||(d[3]=e=>a.load())},"リセット")])],64)}const R=U(A,[["render",H]]);export{R as default};
