/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","./Enum/Severity","jquery","./AjaxDataHandler","TYPO3/CMS/Core/Ajax/AjaxRequest","./InfoWindow","./Modal","./ModuleMenu","TYPO3/CMS/Backend/Notification","./Viewport","./Storage/ModuleStateStorage","TYPO3/CMS/Backend/NewContentElementWizard"],(function(t,e,n,a,r,o,i,s,l,d,c,u,g){"use strict";a=__importDefault(a);class p{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(t,e){let n="",r=(0,a.default)(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+e+"]=edit"+n+"&returnUrl="+p.getReturnUrl())}static viewRecord(){const t=(0,a.default)(this).data("preview-url");if(t){window.open(t,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(t,e){i.showItem(t,e)}static mountAsTreeRoot(t,e){if("pages"===t){const t=new CustomEvent("typo3:pagetree:mountPoint",{detail:{pageId:e}});top.document.dispatchEvent(t)}}static newPageWizard(t,e){const n=(0,a.default)(this).data("pages-new-wizard-url");c.ContentContainer.setUrl(n+"&returnUrl="+p.getReturnUrl())}static newContentWizard(){const t=(0,a.default)(this);let e=t.data("new-wizard-url");e&&(e+="&returnUrl="+p.getReturnUrl(),s.advanced({title:t.data("title"),type:s.types.ajax,size:s.sizes.medium,content:e,severity:n.SeverityEnum.notice,ajaxCallback:()=>{const t=s.currentModal.get(0);t&&t.querySelector(".t3-new-content-element-wizard-inner")&&new g.NewContentElementWizard(t)}}))}static newRecord(t,e){c.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+("pages"!==t?"-":"")+e+"]=new&returnUrl="+p.getReturnUrl())}static openHistoryPopUp(t,e){c.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+e+"&returnUrl="+p.getReturnUrl())}static openListModule(t,e){const n="pages"===t?e:(0,a.default)(this).data("page-uid");l.App.showModule("web_list","id="+n)}static pagesSort(){const t=(0,a.default)(this).data("pages-sort-url");t&&c.ContentContainer.setUrl(t)}static pagesNewMultiple(){const t=(0,a.default)(this).data("pages-new-multiple-url");t&&c.ContentContainer.setUrl(t)}static disableRecord(t,e){const n=(0,a.default)(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+e+"]["+n+"]=1&redirect="+p.getReturnUrl())}static enableRecord(t,e){const n=(0,a.default)(this).data("disable-field")||"hidden";c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+e+"]["+n+"]=0&redirect="+p.getReturnUrl())}static showInMenus(t,e){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+e+"][nav_hide]=0&redirect="+p.getReturnUrl())}static hideInMenus(t,e){c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+e+"][nav_hide]=1&redirect="+p.getReturnUrl())}static deleteRecord(t,e){const o=(0,a.default)(this);s.confirm(o.data("title"),o.data("message"),n.SeverityEnum.warning,[{text:(0,a.default)(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:(0,a.default)(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){const n={component:"contextmenu",action:"delete",table:t,uid:e};r.process("cmd["+t+"]["+e+"][delete]=1",n).then(()=>{"pages"===t?(u.ModuleStateStorage.current("web").identifier===e.toString()&&top.document.dispatchEvent(new CustomEvent("typo3:pagetree:selectFirstNode")),p.refreshPageTree()):"tt_content"===t&&c.ContentContainer.refresh()})}s.dismiss()})}static copy(t,e){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+e+"]=1&CB[setCopyMode]=1";new o(n).get().finally(()=>{p.triggerRefresh(c.ContentContainer.get().location.href)})}static clipboardRelease(t,e){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+e+"]=0";new o(n).get().finally(()=>{p.triggerRefresh(c.ContentContainer.get().location.href)})}static cut(t,e){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+e+"]=1&CB[setCopyMode]=0";new o(n).get().finally(()=>{p.triggerRefresh(c.ContentContainer.get().location.href)})}static triggerRefresh(t){t.includes("record%2Fedit")||c.ContentContainer.refresh()}static clearCache(t,e){new o(TYPO3.settings.ajaxUrls.web_list_clearpagecache).withQueryArguments({id:e}).get({cache:"no-cache"}).then(async t=>{const e=await t.resolve();!0===e.success?d.success(e.title,e.message,1):d.error(e.title,e.message,1)},()=>{d.error("Clearing page caches went wrong on the server side.")})}static pasteAfter(t,e){p.pasteInto.bind((0,a.default)(this))(t,-e)}static pasteInto(t,e){const r=(0,a.default)(this),o=()=>{const n="&CB[paste]="+t+"%7C"+e+"&CB[pad]=normal&redirect="+p.getReturnUrl();c.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n)};if(!r.data("title"))return void o();s.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:(0,a.default)(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:(0,a.default)(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",t=>{"ok"===t.target.getAttribute("name")&&o(),s.dismiss()})}static refreshPageTree(){top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}}return p}));