import{a as g}from"./ant-design.49bf0c8e.js";import{d as f,eH as _,K as m,o as p,N as y,b as i,eu as h,x as w,r as b,f as c,w as C,aJ as k,ey as E,u as L,c4 as B,bg as D}from"./outputWidgets.5ced94d7.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]="32c10f6d-17ff-4a47-9d3c-eed18a63e9da",s._sentryDebugIdIdentifier="sentry-dbid-32c10f6d-17ff-4a47-9d3c-eed18a63e9da")}catch{}})();const I={class:"unsaved-changes-handler"},u="You have unsaved changes. Are you sure you want to leave?",U=f({__name:"UnsavedChangesHandler",props:{hasChanges:{type:Boolean}},setup(s){const n=s,t=a=>(a=a||window.event,a&&(a.returnValue=u),u),r=()=>{window.addEventListener("beforeunload",t)};_(async(a,l,o)=>{if(!n.hasChanges)return o();await g(u)?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)=>(i(),h("div",I))}});const H=w(U,[["__scopeId","data-v-fa94acdd"]]),K=f({__name:"SaveButton",props:{model:{}},setup(s){const n=s,t=b(!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 i(),h(D,null,[c(L(B),{class:E(["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(()=>[k(" Save ")]),_:1},8,["class","loading","disabled"]),c(H,{"has-changes":(o=e.model)==null?void 0:o.hasChanges()},null,8,["has-changes"])],64)}}});export{K as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.5baa60de.js.map
