import{d as w,L as C,N as S,e as b,o as k,X as B,b as n,w as s,a as D,u as o,d5 as I,aF as r,d6 as E,bP as L,Z as c,cK as $,cI as A,$ as N}from"./vue-router.85c27f05.js";import{G as P,U as V}from"./UnsavedChangesHandler.1e13e45a.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]="7da7de22-3268-4cb4-ae7c-0c380f18734f",a._sentryDebugIdIdentifier="sentry-dbid-7da7de22-3268-4cb4-ae7c-0c380f18734f")}catch{}})();const K={class:"popup-container"},U={style:{padding:"0px 4px"}},z=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 t;return(t=e.parentElement)!=null?t:document.body},p=new C(S.boolean(),"dontShowUnsavedChanges"),v=b((h=p.get())!=null?h:!1),_=()=>{p.set(!0),v.value=!0},i=b(!1);async function f(){i.value=!0;try{await l.model.save(),d("save")}catch{A.error({message:"Error saving"})}finally{i.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",K,[n(o($),{placement:"left",open:e.model.hasChanges()&&!v.value&&!e.neverShowPopover,"get-popup-container":m},{content:s(()=>[D("div",U,[n(o(I),null,{default:s(()=>[r("You have unsaved changes")]),_:1}),n(o(E),{onClick:_},{default:s(()=>[r("Don't show this again")]),_:1})])]),default:s(()=>{var y;return[n(o(L),{class:"save-button",loading:i.value,disabled:!((y=e.model)!=null&&y.hasChanges())||e.disabled,onClick:t[0]||(t[0]=u=>f())},{icon:s(()=>[c(e.$slots,"icon",{},()=>[n(o(P),{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(V,{"has-changes":(g=e.model)==null?void 0:g.hasChanges()},null,8,["has-changes"])])}}});const G=N(z,[["__scopeId","data-v-b886e845"]]);export{G as S};
//# sourceMappingURL=SaveButton.098ea3be.js.map
