import{a as O}from"./ant-design.f2f7cc3b.js";import{f as r,eG as S,d as y,eI as D,H as V,o as E,K as L,b as w,ev as C,v as A,r as b,w as l,e as B,u as c,aq as h,bO as I,ez as k,eD as z,cy as H,bq as P,cw as U}from"./outputWidgets.fdae7e91.js";import"./index.1bf0713d.js";import{A as $}from"./Link.3418723f.js";import{a as j}from"./Text.2d7466b9.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]="5a129b1e-f80f-406c-a058-d0481029cc65",n._sentryDebugIdIdentifier="sentry-dbid-5a129b1e-f80f-406c-a058-d0481029cc65")}catch{}})();var M={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 N=M;function _(n){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?Object(arguments[a]):{},o=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),o.forEach(function(s){x(n,s,t[s])})}return n}function x(n,a,t){return a in n?Object.defineProperty(n,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[a]=t,n}var p=function(a,t){var o=_({},a,t.attrs);return r(S,_({},o,{icon:N}),null)};p.displayName="SaveOutlined";p.inheritAttrs=!1;const q=p,F={class:"unsaved-changes-handler"},g="You have unsaved changes. Are you sure you want to leave?",T=y({__name:"UnsavedChangesHandler",props:{hasChanges:{type:Boolean}},setup(n){const a=n,t=e=>(e=e||window.event,e&&(e.returnValue=g),g),o=()=>{window.addEventListener("beforeunload",t)};D(async(e,u,d)=>{if(!a.hasChanges)return d();await O(g)?d():d(!1)});const s=()=>window.removeEventListener("beforeunload",t),i=e=>e?o():s();return V(()=>a.hasChanges,i),E(()=>i(a.hasChanges)),L(s),(e,u)=>(w(),C("div",F))}});const Y=A(T,[["__scopeId","data-v-fa94acdd"]]),G={style:{padding:"0px 4px"}},X=y({__name:"SaveButton",props:{model:{}},setup(n){const a=n,t=b(!1),o=()=>{t.value=!0},s=b(!1);async function i(){s.value=!0;try{await a.model.save()}catch{U.error({message:"Error saving"})}finally{s.value=!1}}return addEventListener("keydown",e=>{(e.metaKey||e.ctrlKey)&&e.key==="s"&&(e.preventDefault(),i())}),addEventListener("beforeunload",e=>{a.model.hasChanges()&&(e.preventDefault(),e.returnValue="")}),(e,u)=>{var d;return w(),C(P,null,[r(c(H),{placement:"left",visible:e.model.hasChanges()&&!t.value},{content:l(()=>[B("div",G,[r(c(j),null,{default:l(()=>[h("You have unsaved changes")]),_:1}),r(c($),{onClick:o},{default:l(()=>[h("Don't show this again")]),_:1})])]),default:l(()=>{var f,m;return[r(c(I),{class:k(["save-button",{changes:(f=e.model)==null?void 0:f.hasChanges()}]),loading:s.value,disabled:!((m=e.model)!=null&&m.hasChanges()),onClick:u[0]||(u[0]=v=>i())},{icon:l(()=>[r(c(q))]),default:l(()=>{var v;return[h(z((v=e.model)!=null&&v.hasChanges()?"Save":"Saved")+" ",1)]}),_:1},8,["class","loading","disabled"])]}),_:1},8,["visible"]),r(Y,{"has-changes":(d=e.model)==null?void 0:d.hasChanges()},null,8,["has-changes"])],64)}}});export{X as _};
//# sourceMappingURL=SaveButton.vue_vue_type_script_setup_true_lang.a382dcd1.js.map
