import{a as _}from"./ant-design.4ca18c4d.js";import{f as i,eG as y,d as m,eI as w,H as C,o as O,K as S,b as p,ev as b,v as V,r as D,w as v,u as h,aq as E,eD as I,ez as L,bO as z,bq as B,cw as H}from"./outputWidgets.e33755f8.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="c1d3a641-0ee8-40bb-afd9-7ef7c2e0c452",n._sentryDebugIdIdentifier="sentry-dbid-c1d3a641-0ee8-40bb-afd9-7ef7c2e0c452")}catch{}})();var U={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M893.3 293.3L730.7 130.7c-7.5-7.5-16.7-13-26.7-16V112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V338.5c0-17-6.7-33.2-18.7-45.2zM384 184h256v104H384V184zm456 656H184V184h136v136c0 17.7 14.3 32 32 32h320c17.7 0 32-14.3 32-32V205.8l136 136V840zM512 442c-79.5 0-144 64.5-144 144s64.5 144 144 144 144-64.5 144-144-64.5-144-144-144zm0 224c-44.2 0-80-35.8-80-80s35.8-80 80-80 80 35.8 80 80-35.8 80-80 80z"}}]},name:"save",theme:"outlined"};const k=U;function g(n){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?Object(arguments[a]):{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(e){P(n,e,t[e])})}return n}function P(n,a,t){return a in n?Object.defineProperty(n,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[a]=t,n}var f=function(a,t){var r=g({},a,t.attrs);return i(y,g({},r,{icon:k}),null)};f.displayName="SaveOutlined";f.inheritAttrs=!1;const j=f,M={class:"unsaved-changes-handler"},u="You have unsaved changes. Are you sure you want to leave?",$=m({__name:"UnsavedChangesHandler",props:{hasChanges:{type:Boolean}},setup(n){const a=n,t=s=>(s=s||window.event,s&&(s.returnValue=u),u),r=()=>{window.addEventListener("beforeunload",t)};w(async(s,l,o)=>{if(!a.hasChanges)return o();await _(u)?o():o(!1)});const e=()=>window.removeEventListener("beforeunload",t),d=s=>s?r():e();return C(()=>a.hasChanges,d),O(()=>d(a.hasChanges)),S(e),(s,l)=>(p(),b("div",M))}});const A=V($,[["__scopeId","data-v-fa94acdd"]]),x=m({__name:"SaveButton",props:{model:{}},setup(n){const a=n,t=D(!1);async function r(){t.value=!0;try{await a.model.save()}catch{H.error({message:"Error saving"})}finally{t.value=!1}}return addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),r())}),addEventListener("beforeunload",e=>{a.model.hasChanges()&&(e.preventDefault(),e.returnValue="")}),(e,d)=>{var s,l,o;return p(),b(B,null,[i(h(z),{class:L(["save-button",{changes:(s=e.model)==null?void 0:s.hasChanges()}]),loading:t.value,disabled:!((l=e.model)!=null&&l.hasChanges()),onClick:d[0]||(d[0]=c=>r())},{icon:v(()=>[i(h(j))]),default:v(()=>{var c;return[E(I((c=e.model)!=null&&c.hasChanges()?"Save":"Saved")+" ",1)]}),_:1},8,["class","loading","disabled"]),i(A,{"has-changes":(o=e.model)==null?void 0:o.hasChanges()},null,8,["has-changes"])],64)}}});export{x as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.8a8a9b35.js.map
