import{d as w,L as S,N as C,e as b,o as k,X as B,b as n,w as s,a as D,u as o,d7 as E,aF as r,d8 as I,bS as L,Z as c,cN as N,cL as $,$ as A}from"./vue-router.2a09679a.js";import{G as V,U as P}from"./UnsavedChangesHandler.fdad812d.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]="5f556b3a-c760-45da-b873-00779466bd79",a._sentryDebugIdIdentifier="sentry-dbid-5f556b3a-c760-45da-b873-00779466bd79")}catch{}})();const U={class:"popup-container"},z={style:{padding:"0px 4px"}},K=w({__name:"SaveButton",props:{model:{},neverShowPopover:{type:Boolean}},emits:["save"],setup(a,{emit:d}){var h;const l=a,m=e=>{var t;return(t=e.parentElement)!=null?t:document.body},p=new S(C.boolean(),"dontShowUnsavedChanges"),v=b((h=p.get())!=null?h:!1),_=()=>{p.set(!0),v.value=!0},u=b(!1);async function f(){u.value=!0;try{await l.model.save(),d("save")}catch{$.error({message:"Error saving"})}finally{u.value=!1}}return addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),f())}),addEventListener("beforeunload",e=>{l.model.hasChanges()&&(e.preventDefault(),e.returnValue="")}),(e,t)=>{var g;return k(),B("div",U,[n(o(N),{placement:"left",open:e.model.hasChanges()&&!v.value&&!e.neverShowPopover,"get-popup-container":m},{content:s(()=>[D("div",z,[n(o(E),null,{default:s(()=>[r("You have unsaved changes")]),_:1}),n(o(I),{onClick:_},{default:s(()=>[r("Don't show this again")]),_:1})])]),default:s(()=>{var y;return[n(o(L),{class:"save-button",loading:u.value,disabled:!((y=e.model)!=null&&y.hasChanges()),onClick:t[0]||(t[0]=i=>f())},{icon:s(()=>[c(e.$slots,"icon",{},()=>[n(o(V),{size:"18"})],!0)]),default:s(()=>{var i;return[(i=e.model)!=null&&i.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(P,{"has-changes":(g=e.model)==null?void 0:g.hasChanges()},null,8,["has-changes"])])}}});const G=A(K,[["__scopeId","data-v-e79e182b"]]);export{G as S};
//# sourceMappingURL=SaveButton.b7f2e2dd.js.map
