import e from"@babel/runtime/helpers/defineProperty";import{jsxs as t,Fragment as o,jsx as r}from"react/jsx-runtime";import{useRef as n,useCallback as l}from"react";import{Modal as i}from"../../Modal/Modal.js";import{storeApi as a}from"../Store/Store.js";import"../Store/utils.js";import{Text as m}from"../../Text/Text.js";import{ConfirmationModalType as c}from"../types.js";var u,d=(e(u={},c.Revert,{title:"Revert to Original Template?",text:"All modifications made to this template will be lost. This action cannot be undone. If needed, save your changes as a new template before reverting.",confirmText:"Revert to original"}),e(u,c.DeleteFolder,{title:"Delete folder?",text:function(e){var t=e.folder,o=null==t?void 0:t.name,r=null==t?void 0:t.items.map((function(e){var t=e.name;return'"'.concat(t,'"')})).join(", ");return'Are you sure you want to delete the "'.concat(o,'" folder, and the following templates: ').concat(r,"?")},confirmText:"Delete"}),e(u,c.DeleteTemplate,{title:"Delete Template?",text:function(e){var n=e.template,l=e.isCurrentTemplate;return t(o,l?{children:["The “",null==n?void 0:n.name,"” template you are about to delete is currently in use. If you proceed, you will lose the template permanently and must rebuild everything from scratch.",r("br",{}),"Please confirm if you wish to continue, or cancel to keep the template."]}:{children:["Deleting the “",null==n?void 0:n.name,"” template will result in the permanent loss of the current version. However, you will be able to recreate the template from scratch if needed.",r("br",{}),"Please confirm if you wish to proceed or cancel to keep the template."]})},confirmText:"Delete"}),u),s=function(){var e,t,o,c,u,s=a.useConfirmationModalType,p=a.useCloseConfirmation,f=a.useConfirmationCallback,v=a.useConfirmationTemplateId,h=a.useTemplateById,y=a.useSelectedTemplateId,T=a.useConfirmationFolder,x=f(),b=n(),C=s(),w=p(),g=v(),j=T(),D=h(g),A=y()===g,I=l((function(){null==x||x(),w()}),[w,x]);return C&&(b.current=d[C]),r(i,{size:"small",open:!!C,onClose:w,title:null===(e=b.current)||void 0===e?void 0:e.title,primaryActionText:null===(t=b.current)||void 0===t?void 0:t.confirmText,primaryActionHandler:I,secondaryActionText:"Cancel",secondaryActionHandler:w,children:r(m,{size:16,color:"T6",children:"function"==typeof(null===(o=b.current)||void 0===o?void 0:o.text)?null===(c=b.current)||void 0===c?void 0:c.text({template:D,isCurrentTemplate:A,folder:j}):null===(u=b.current)||void 0===u?void 0:u.text})})};export{s as ConfirmationModal};
//# sourceMappingURL=ConfirmationModal.js.map
