import{u as S}from"./CalculatorBuilder-itTCCi74.js";import{w as O,n as a}from"./vendor-vue-runtime-core-DwK6Ry68.js";function J(f,s){const o=s.split(".");let t=f;for(const e of o){if(t==null||typeof t!="object")return;t=t[e]}return t}function m(f,s,o){const t=s.split(".");let e=f;for(let n=0;n<t.length-1;n++)(e[t[n]]==null||typeof e[t[n]]!="object")&&(e[t[n]]={}),e=e[t[n]];e[t[t.length-1]]=o}function b(f,s,o,t){const{isRestoring:e,restoredVersion:n}=S();let r=!1;async function g(c){r=!0,c(),await a(),await a(),r=!1}return O(()=>JSON.parse(JSON.stringify(s)),c=>{var d;if(r||e.value)return;const i=f();if(!i)return;const l=c;for(const u of Object.keys(l)){const y=(o==null?void 0:o[u])??u,N=((d=t==null?void 0:t[u])==null?void 0:d.call(t,l[u],c))??l[u],p=JSON.stringify(N);JSON.stringify(J(i,y))!==p&&m(i,y,JSON.parse(p))}},{deep:!0}),{suppressAutoSync:g,restoredVersion:n}}export{b as u};
//# sourceMappingURL=useAutoSyncDraft-e28EpTsr.js.map
