import{d as w,L as C,B as S,f as y,o as k,K as B,b as n,w as s,a as D,u as t,d2 as E,az as r,d3 as I,bM as L,O as c,cH as A,cF as V,Q as $}from"./index.e310aebb.js";import{G as z,U as K}from"./UnsavedChangesHandler.b4b7d195.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[d]="70a5b3e7-5367-4d27-b7ab-83cd4c2e577b",a._sentryDebugIdIdentifier="sentry-dbid-70a5b3e7-5367-4d27-b7ab-83cd4c2e577b")}catch{}})();const N={class:"popup-container"},P={style:{padding:"0px 4px"}},U=w({__name:"SaveButton",props:{model:{},neverShowPopover:{type:Boolean},disabled:{type:Boolean}},emits:["save"],setup(a,{emit:d}){var h;const l=a,m=e=>{var o;return(o=e.parentElement)!=null?o:document.body},p=new C(S.boolean(),"dontShowUnsavedChanges"),f=y((h=p.get())!=null?h:!1),_=()=>{p.set(!0),f.value=!0},i=y(!1);async function v(){i.value=!0;try{await l.model.save(),d("save")}catch(e){console.error(e),V.error({message:"Error saving"})}finally{i.value=!1}}return addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),v())}),addEventListener("beforeunload",e=>{l.model.hasChanges()&&(e.preventDefault(),e.returnValue="")}),(e,o)=>{var g;return k(),B("div",N,[n(t(A),{placement:"left",open:e.model.hasChanges()&&!f.value&&!e.neverShowPopover,"get-popup-container":m},{content:s(()=>[D("div",P,[n(t(E),null,{default:s(()=>[r("You have unsaved changes")]),_:1}),n(t(I),{onClick:_},{default:s(()=>[r("Don't show this again")]),_:1})])]),default:s(()=>{var b;return[n(t(L),{class:"save-button",loading:i.value,disabled:!((b=e.model)!=null&&b.hasChanges())||e.disabled,onClick:o[0]||(o[0]=u=>v())},{icon:s(()=>[c(e.$slots,"icon",{},()=>[n(t(z),{size:"18"})],!0)]),default:s(()=>{var u;return[(u=e.model)!=null&&u.hasChanges()?c(e.$slots,"with-changes",{key:0},()=>[r(" Save ")],!0):c(e.$slots,"without-changes",{key:1},()=>[r(" Saved ")],!0)]}),_:3},8,["loading","disabled"])]}),_:3},8,["open"]),n(K,{"has-changes":(g=e.model)==null?void 0:g.hasChanges()},null,8,["has-changes"])])}}});const F=$(U,[["__scopeId","data-v-80b2ff4e"]]);export{F as S};
//# sourceMappingURL=SaveButton.3679bfe7.js.map
