import{_ as E,i as s,h as S,g as v,E as g,z as O,r as h,o as B,c as b,a as l,d as T,b as w,A as C,f as V,G as k,F as x,k as d}from"./index-20f16f2f.js";const y={name:"PageMasterConfigDatareduction",setup(){const f=s(d.errorHandler).handleErrorAsync,o=s(d.notification),p=s(d.resourceStore),t=s(d.resourceHourStore),m=s(d.eventStore),i=S(null),c=f(async()=>{var _,D;if(!i.value)return;const a=v.combine(i.value,g());await t.mutate(p.resources.value.map(e=>({opcode:"unfill",param:{resource:e.id,startTime:v.min,endTime:a}})));const n=await m.query({startTime:v.min,endTime:a}),u=new Set(n.filter(e=>O(e.endTime,a)<=0)),r=new Set(n.filter(e=>!u.has(e)));for(;r.size;){const e=r.values().next().value;r.delete(e),u.delete(e),(_=e.eventChangeFrom)!=null&&_.fromEvent&&r.add(e.eventChangeFrom.fromEvent),(D=e.eventChangeTo)!=null&&D.toEvent&&r.add(e.eventChangeTo.toEvent)}await m.mutate([...u].map(e=>({opcode:"remove_event",param:{id:e.id}}))),o.add("info","削除しました。")});return{removeOldDataDateBefore:i,removeOldData:c}}},F=l("h1",null,"データ削減",-1),N=l("p",null," 指定した日付より前のイベント、可能時間を全て削除します。 ただし日付以後のイベントの振替元や振替先に指定されたイベントは削除されません。 ",-1),A=["disabled"];function H(f,o,p,t,m,i){const c=h("input-date"),a=h("date-time");return B(),b(x,null,[F,N,l("form",{onSubmit:o[1]||(o[1]=k(n=>t.removeOldData(),["prevent"]))},[l("label",null,[T(" 日付 "),w(c,{modelValue:t.removeOldDataDateBefore,"onUpdate:modelValue":o[0]||(o[0]=n=>t.removeOldDataDateBefore=n)},null,8,["modelValue"])]),l("button",{disabled:!t.removeOldDataDateBefore},[t.removeOldDataDateBefore?(B(),C(a,{key:0,value:t.removeOldDataDateBefore},null,8,["value"])):V("",!0),T(" より前のデータを削除 ")],8,A)],32)],64)}const M=E(y,[["render",H]]);export{M as default};
