import{a as g}from"./ant-design.523e8417.js";import{d as i,eH as _,J as m,o as p,L as y,b as f,et as h,v as b,r as w,f as u,w as C,aI as L,ex as k,u as E,c0 as I,bf as B}from"./outputWidgets.a4629ff8.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[n]="18294a9d-86bc-4266-9dc3-39ee3702466c",s._sentryDebugIdIdentifier="sentry-dbid-18294a9d-86bc-4266-9dc3-39ee3702466c")}catch{}})();const D={class:"unsaved-changes-handler"},c="You have unsaved changes. Are you sure you want to leave?",U=i({__name:"UnsavedChangesHandler",props:{hasChanges:{type:Boolean}},setup(s){const n=s,t=a=>(a=a||window.event,a&&(a.returnValue=c),c),r=()=>{window.addEventListener("beforeunload",t)};_(async(a,l,o)=>{if(!n.hasChanges)return o();await g(c)?o():o(!1)});const e=()=>window.removeEventListener("beforeunload",t),d=a=>a?r():e();return m(()=>n.hasChanges,d),p(()=>d(n.hasChanges)),y(e),(a,l)=>(f(),h("div",D))}});const H=b(U,[["__scopeId","data-v-fa94acdd"]]),F=i({__name:"SaveButton",props:{model:{}},setup(s){const n=s,t=w(!1);async function r(){t.value=!0;try{await n.model.save()}finally{t.value=!1}}return addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),r())}),addEventListener("beforeunload",e=>{n.model.hasChanges()&&(e.preventDefault(),e.returnValue="")}),(e,d)=>{var a,l,o;return f(),h(B,null,[u(E(I),{class:k(["save-button",{changes:(a=e.model)==null?void 0:a.hasChanges()}]),loading:t.value,disabled:!((l=e.model)!=null&&l.hasChanges()),onClick:d[0]||(d[0]=v=>r())},{default:C(()=>[L(" Save ")]),_:1},8,["class","loading","disabled"]),u(H,{"has-changes":(o=e.model)==null?void 0:o.hasChanges()},null,8,["has-changes"])],64)}}});export{F as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.f9b0c6e4.js.map
