/*
 * 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(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Backend/Enum/Severity","./Workspaces","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Storage/Persistent","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Utility","TYPO3/CMS/Backend/Wizard","TYPO3/CMS/Core/SecurityUtility","TYPO3/CMS/Backend/WindowManager","TYPO3/CMS/Core/Event/RegularEvent","TYPO3/CMS/Backend/Element/IconElement","TYPO3/CMS/Backend/Input/Clearable"],(function(e,t,a,s,n,i,o,l,r,c,d,p,g){"use strict";var h;a=__importDefault(a),n=__importDefault(n),g=__importDefault(g),function(e){e.searchForm="#workspace-settings-form",e.searchTextField='#workspace-settings-form input[name="search-text"]',e.searchSubmitBtn='#workspace-settings-form button[type="submit"]',e.depthSelector='#workspace-settings-form [name="depth"]',e.languageSelector='#workspace-settings-form select[name="languages"]',e.stagesSelector='#workspace-settings-form select[name="stages"]',e.workspaceActions=".workspace-actions",e.chooseStageAction='.workspace-actions [name="stage-action"]',e.chooseSelectionAction='.workspace-actions [name="selection-action"]',e.chooseMassAction='.workspace-actions [name="mass-action"]',e.container="#workspace-panel",e.contentsContainer="#workspace-contents",e.noContentsContainer="#workspace-contents-empty",e.previewLinksButton=".t3js-preview-link",e.pagination="#workspace-pagination"}(h||(h={}));class u extends n.default{static refreshPageTree(){top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh"))}static generateDiffView(e){const t=(0,a.default)("<div />",{class:"diff"});for(let s of e)t.append((0,a.default)("<div />",{class:"diff-item"}).append((0,a.default)("<div />",{class:"diff-item-title"}).text(s.label),(0,a.default)("<div />",{class:"diff-item-result diff-item-result-inline"}).html(s.content)));return t}static generateCommentView(e){const t=(0,a.default)("<div />");for(let s of e){const e=(0,a.default)("<div />",{class:"panel panel-default"});s.user_comment.length>0&&e.append((0,a.default)("<div />",{class:"panel-body"}).html(s.user_comment)),e.append((0,a.default)("<div />",{class:"panel-footer"}).append((0,a.default)("<span />",{class:"label label-success me-2"}).text(s.previous_stage_title+" > "+s.stage_title),(0,a.default)("<span />",{class:"label label-info"}).text(s.tstamp))),t.append((0,a.default)("<div />",{class:"media"}).append((0,a.default)("<div />",{class:"media-left text-center"}).text(s.user_username).prepend((0,a.default)("<div />").html(s.user_avatar)),(0,a.default)("<div />",{class:"media-body"}).append(e)))}return t}static generateHistoryView(e){const t=(0,a.default)("<div />");for(let s of e){const e=(0,a.default)("<div />",{class:"panel panel-default"});let n;if("object"==typeof s.differences){if(0===s.differences.length)continue;n=(0,a.default)("<div />",{class:"diff"});for(let e=0;e<s.differences.length;++e)n.append((0,a.default)("<div />",{class:"diff-item"}).append((0,a.default)("<div />",{class:"diff-item-title"}).text(s.differences[e].label),(0,a.default)("<div />",{class:"diff-item-result diff-item-result-inline"}).html(s.differences[e].html)));e.append((0,a.default)("<div />").append(n))}else e.append((0,a.default)("<div />",{class:"panel-body"}).text(s.differences));e.append((0,a.default)("<div />",{class:"panel-footer"}).append((0,a.default)("<span />",{class:"label label-info"}).text(s.datetime))),t.append((0,a.default)("<div />",{class:"media"}).append((0,a.default)("<div />",{class:"media-left text-center"}).text(s.user).prepend((0,a.default)("<div />").html(s.user_avatar)),(0,a.default)("<div />",{class:"media-body"}).append(e)))}return t}static changeCollectionParentState(e,t){const a=document.querySelector('tr[data-collection-current="'+e+'"] input[type=checkbox]');null!==a&&a.checked!==t&&(a.checked=t,a.dataset.manuallyChanged="true",a.dispatchEvent(new CustomEvent("multiRecordSelection:checkbox:state:changed",{bubbles:!0,cancelable:!1})))}static changeCollectionChildrenState(e,t){const a=document.querySelectorAll('tr[data-collection="'+e+'"] input[type=checkbox]');a.length&&a.forEach(e=>{e.checked!==t&&(e.checked=t,e.dataset.manuallyChanged="true",e.dispatchEvent(new CustomEvent("multiRecordSelection:checkbox:state:changed",{bubbles:!0,cancelable:!1})))})}constructor(){super(),this.elements={},this.settings={dir:"ASC",id:TYPO3.settings.Workspaces.id,depth:1,language:"all",limit:30,query:"",sort:"label_Live",start:0,filterTxt:""},this.paging={currentPage:1,totalPages:1,totalItems:0},this.latestPath="",this.markedRecordsForMassAction=[],this.indentationPadding=26,this.handleCheckboxStateChanged=e=>{const t=(0,a.default)(e.target),s=t.parents("tr"),n=t.prop("checked"),i=s.data("table")+":"+s.data("uid")+":"+s.data("t3ver_oid");if(n)this.markedRecordsForMassAction.push(i);else{const e=this.markedRecordsForMassAction.indexOf(i);e>-1&&this.markedRecordsForMassAction.splice(e,1)}s.data("collectionCurrent")?u.changeCollectionChildrenState(s.data("collectionCurrent"),n):s.data("collection")&&(u.changeCollectionChildrenState(s.data("collection"),n),u.changeCollectionParentState(s.data("collection"),n)),this.elements.$chooseMassAction.prop("disabled",this.markedRecordsForMassAction.length>0)},this.viewChanges=e=>{e.preventDefault();const t=(0,a.default)(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemotePayload("getRowDetails",{stage:t.data("stage"),t3ver_oid:t.data("t3ver_oid"),table:t.data("table"),uid:t.data("uid"),filterFields:!0})).then(async e=>{const n=(await e.resolve())[0].result.data[0],o=(0,a.default)("<div />"),l=(0,a.default)("<ul />",{class:"nav nav-tabs",role:"tablist"}),r=(0,a.default)("<div />",{class:"tab-content"}),c=[];o.append((0,a.default)("<p />").html(TYPO3.lang.path.replace("{0}",n.path_Live)),(0,a.default)("<p />").html(TYPO3.lang.current_step.replace("{0}",n.label_Stage).replace("{1}",n.stage_position).replace("{2}",n.stage_count))),n.diff.length>0&&(l.append((0,a.default)("<li />",{role:"presentation",class:"nav-item"}).append((0,a.default)("<a />",{class:"nav-link",href:"#workspace-changes","aria-controls":"workspace-changes",role:"tab","data-bs-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.changeSummary"]))),r.append((0,a.default)("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-changes"}).append((0,a.default)("<div />",{class:"form-section"}).append(u.generateDiffView(n.diff))))),n.comments.length>0&&(l.append((0,a.default)("<li />",{role:"presentation",class:"nav-item"}).append((0,a.default)("<a />",{class:"nav-link",href:"#workspace-comments","aria-controls":"workspace-comments",role:"tab","data-bs-toggle":"tab"}).html(TYPO3.lang["window.recordChanges.tabs.comments"]+"&nbsp;").append((0,a.default)("<span />",{class:"badge"}).text(n.comments.length)))),r.append((0,a.default)("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-comments"}).append((0,a.default)("<div />",{class:"form-section"}).append(u.generateCommentView(n.comments))))),n.history.total>0&&(l.append((0,a.default)("<li />",{role:"presentation",class:"nav-item"}).append((0,a.default)("<a />",{class:"nav-link",href:"#workspace-history","aria-controls":"workspace-history",role:"tab","data-bs-toggle":"tab"}).text(TYPO3.lang["window.recordChanges.tabs.history"]))),r.append((0,a.default)("<div />",{role:"tabpanel",class:"tab-pane",id:"workspace-history"}).append((0,a.default)("<div />",{class:"form-section"}).append(u.generateHistoryView(n.history.data))))),l.find("li > a").first().addClass("active"),r.find(".tab-pane").first().addClass("active"),o.append((0,a.default)("<div />").append(l,r)),!1!==n.label_PrevStage&&t.data("stage")!==t.data("prevStage")&&c.push({text:n.label_PrevStage.title,active:!0,btnClass:"btn-default",name:"prevstage",trigger:()=>{i.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"prev")}}),!1!==n.label_NextStage&&c.push({text:n.label_NextStage.title,active:!0,btnClass:"btn-default",name:"nextstage",trigger:()=>{i.currentModal.trigger("modal-dismiss"),this.sendToStage(t,"next")}}),c.push({text:TYPO3.lang.close,active:!0,btnClass:"btn-info",name:"cancel",trigger:()=>{i.currentModal.trigger("modal-dismiss")}}),i.advanced({type:i.types.default,title:TYPO3.lang["window.recordInformation"].replace("{0}",t.find(".t3js-title-live").text().trim()),content:o,severity:s.SeverityEnum.info,buttons:c,size:i.sizes.medium})})},this.confirmDeleteRecordFromWorkspace=e=>{const t=(0,a.default)(e.target).closest("tr"),n=i.confirm(TYPO3.lang["window.discard.title"],TYPO3.lang["window.discard.message"],s.SeverityEnum.warning,[{text:TYPO3.lang.cancel,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{n.modal("hide")}},{text:TYPO3.lang.ok,btnClass:"btn-warning",name:"ok"}]);n.on("button.clicked",e=>{"ok"===e.target.name&&this.sendRemoteRequest([this.generateRemoteActionsPayload("deleteSingleRecord",[t.data("table"),t.data("uid")])]).then(()=>{n.modal("hide"),this.getWorkspaceInfos(),u.refreshPageTree()})})},this.runSelectionAction=e=>{const t=(0,a.default)(e.currentTarget).val(),s="discard"!==t;if(0===t.length)return;const n=[];for(let e=0;e<this.markedRecordsForMassAction.length;++e){const t=this.markedRecordsForMassAction[e].split(":");n.push({table:t[0],liveId:t[2],versionId:t[1]})}s?this.checkIntegrity({selection:n,type:"selection"}).then(async e=>{c.setForceSelection(!1),"warning"===(await e.resolve())[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderSelectionActionWizard(t,n)}):(c.setForceSelection(!1),this.renderSelectionActionWizard(t,n))},this.addIntegrityCheckWarningToWizard=()=>{c.addSlide("integrity-warning","Warning",TYPO3.lang["integrity.hasIssuesDescription"]+"<br>"+TYPO3.lang["integrity.hasIssuesQuestion"],s.SeverityEnum.warning)},this.runMassAction=e=>{const t=(0,a.default)(e.currentTarget).val(),s="discard"!==t;0!==t.length&&(s?this.checkIntegrity({language:this.settings.language,type:t}).then(async e=>{c.setForceSelection(!1),"warning"===(await e.resolve())[0].result.result&&this.addIntegrityCheckWarningToWizard(),this.renderMassActionWizard(t)}):(c.setForceSelection(!1),this.renderMassActionWizard(t)))},this.sendToSpecificStageAction=e=>{const t=[],s=(0,a.default)(e.currentTarget).val();for(let e=0;e<this.markedRecordsForMassAction.length;++e){const a=this.markedRecordsForMassAction[e].split(":");t.push({table:a[0],uid:a[1],t3ver_oid:a[2]})}this.sendRemoteRequest(this.generateRemoteActionsPayload("sendToSpecificStageWindow",[s,t])).then(async e=>{const a=this.renderSendToStageWindow(await e.resolve());a.on("button.clicked",e=>{if("ok"===e.target.name){const n=r.convertFormToObject(e.currentTarget.querySelector("form"));n.affects={elements:t,nextStage:s},this.sendRemoteRequest([this.generateRemoteActionsPayload("sendToSpecificStageExecute",[n]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).then(async e=>{const t=await e.resolve();a.modal("hide"),this.renderWorkspaceInfos(t[1].result),u.refreshPageTree()})}}).on("modal-destroyed",()=>{this.elements.$chooseStageAction.val("")})})},this.generatePreviewLinks=()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("generateWorkspacePreviewLinksForAllLanguages",[this.settings.id])).then(async e=>{const t=(await e.resolve())[0].result,n=(0,a.default)("<dl />");a.default.each(t,(e,t)=>{n.append((0,a.default)("<dt />").text(e),(0,a.default)("<dd />").append((0,a.default)("<a />",{href:t,target:"_blank"}).text(t)))}),i.show(TYPO3.lang.previewLink,n,s.SeverityEnum.info,[{text:TYPO3.lang.ok,active:!0,btnClass:"btn-info",name:"ok",trigger:()=>{i.currentModal.trigger("modal-dismiss")}}],["modal-inner-scroll"])})},(0,a.default)(()=>{this.getElements(),this.registerEvents(),this.notifyWorkspaceSwitchAction(),this.settings.depth=this.elements.$depthSelector.val(),this.settings.language=this.elements.$languageSelector.val(),this.settings.stage=this.elements.$stagesSelector.val(),this.elements.$container.length&&this.getWorkspaceInfos()})}notifyWorkspaceSwitchAction(){const e=document.querySelector("main[data-workspace-switch-action]");if(e.dataset.workspaceSwitchAction){const t=JSON.parse(e.dataset.workspaceSwitchAction);top.TYPO3.WorkspacesMenu.performWorkspaceSwitch(t.id,t.title),top.document.dispatchEvent(new CustomEvent("typo3:pagetree:refresh")),top.TYPO3.ModuleMenu.App.refreshMenu()}}checkIntegrity(e){return this.sendRemoteRequest(this.generateRemotePayload("checkIntegrity",e))}getElements(){this.elements.$searchForm=(0,a.default)(h.searchForm),this.elements.$searchTextField=(0,a.default)(h.searchTextField),this.elements.$searchSubmitBtn=(0,a.default)(h.searchSubmitBtn),this.elements.$depthSelector=(0,a.default)(h.depthSelector),this.elements.$languageSelector=(0,a.default)(h.languageSelector),this.elements.$stagesSelector=(0,a.default)(h.stagesSelector),this.elements.$container=(0,a.default)(h.container),this.elements.$contentsContainer=(0,a.default)(h.contentsContainer),this.elements.$noContentsContainer=(0,a.default)(h.noContentsContainer),this.elements.$tableBody=this.elements.$contentsContainer.find("tbody"),this.elements.$workspaceActions=(0,a.default)(h.workspaceActions),this.elements.$chooseStageAction=(0,a.default)(h.chooseStageAction),this.elements.$chooseSelectionAction=(0,a.default)(h.chooseSelectionAction),this.elements.$chooseMassAction=(0,a.default)(h.chooseMassAction),this.elements.$previewLinksButton=(0,a.default)(h.previewLinksButton),this.elements.$pagination=(0,a.default)(h.pagination)}registerEvents(){(0,a.default)(document).on("click",'[data-action="publish"]',e=>{const t=e.target.closest("tr");this.checkIntegrity({selection:[{liveId:t.dataset.uid,versionId:t.dataset.t3ver_oid,table:t.dataset.table}],type:"selection"}).then(async e=>{"warning"===(await e.resolve())[0].result.result&&this.addIntegrityCheckWarningToWizard(),c.setForceSelection(!1),c.addSlide("publish-confirm","Publish",TYPO3.lang["window.publish.message"],s.SeverityEnum.info),c.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("publishSingleRecord",[t.dataset.table,t.dataset.t3ver_oid,t.dataset.uid])).then(()=>{c.dismiss(),this.getWorkspaceInfos(),u.refreshPageTree()})}).done(()=>{c.show()})})}).on("click",'[data-action="prevstage"]',e=>{this.sendToStage((0,a.default)(e.currentTarget).closest("tr"),"prev")}).on("click",'[data-action="nextstage"]',e=>{this.sendToStage((0,a.default)(e.currentTarget).closest("tr"),"next")}).on("click",'[data-action="changes"]',this.viewChanges).on("click",'[data-action="preview"]',this.openPreview.bind(this)).on("click",'[data-action="open"]',e=>{const t=e.currentTarget.closest("tr");let a=TYPO3.settings.FormEngine.moduleUrl+"&returnUrl="+encodeURIComponent(document.location.href)+"&id="+TYPO3.settings.Workspaces.id+"&edit["+t.dataset.table+"]["+t.dataset.uid+"]=edit";window.location.href=a}).on("click",'[data-action="version"]',e=>{const t=e.currentTarget.closest("tr"),a="pages"===t.dataset.table?t.dataset.t3ver_oid:t.dataset.pid;window.location.href=TYPO3.settings.WebLayout.moduleUrl+"&id="+a}).on("click",'[data-action="remove"]',this.confirmDeleteRecordFromWorkspace).on("click",'[data-action="expand"]',e=>{const t=(0,a.default)(e.currentTarget);let s;s="true"===t.first().attr("aria-expanded")?"apps-pagetree-expand":"apps-pagetree-collapse",t.empty().append(this.getIcon(s))}),(0,a.default)(window.top.document).on("click",".t3js-workspace-recipients-selectall",()=>{(0,a.default)(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!0)}).on("click",".t3js-workspace-recipients-deselectall",()=>{(0,a.default)(".t3js-workspace-recipient",window.top.document).not(":disabled").prop("checked",!1)}),this.elements.$searchForm.on("submit",e=>{e.preventDefault(),this.settings.filterTxt=this.elements.$searchTextField.val(),this.getWorkspaceInfos()}),this.elements.$searchTextField.on("keyup",e=>{""!==e.target.value?this.elements.$searchSubmitBtn.removeClass("disabled"):(this.elements.$searchSubmitBtn.addClass("disabled"),this.getWorkspaceInfos())});const e=this.elements.$searchTextField.get(0);void 0!==e&&e.clearable({onClear:()=>{this.elements.$searchSubmitBtn.addClass("disabled"),this.settings.filterTxt="",this.getWorkspaceInfos()}}),new g.default("multiRecordSelection:checkbox:state:changed",this.handleCheckboxStateChanged).bindTo(document),this.elements.$depthSelector.on("change",e=>{const t=e.target.value;o.set("moduleData.workspaces.settings.depth",t),this.settings.depth=t,this.getWorkspaceInfos()}),this.elements.$previewLinksButton.on("click",this.generatePreviewLinks),this.elements.$languageSelector.on("change",e=>{const t=(0,a.default)(e.target);o.set("moduleData.workspaces.settings.language",t.val()),this.settings.language=t.val(),this.sendRemoteRequest(this.generateRemotePayload("getWorkspaceInfos",this.settings)).then(async e=>{const a=await e.resolve();this.elements.$languageSelector.prev().html(t.find(":selected").data("icon")),this.renderWorkspaceInfos(a[0].result)})}),this.elements.$stagesSelector.on("change",e=>{const t=e.target.value;o.set("moduleData.workspaces.settings.stage",t),this.settings.stage=t,this.getWorkspaceInfos()}),this.elements.$chooseStageAction.on("change",this.sendToSpecificStageAction),this.elements.$chooseSelectionAction.on("change",this.runSelectionAction),this.elements.$chooseMassAction.on("change",this.runMassAction),this.elements.$pagination.on("click","[data-action]",e=>{e.preventDefault();const t=(0,a.default)(e.currentTarget);let s=!1;switch(t.data("action")){case"previous":this.paging.currentPage>1&&(this.paging.currentPage--,s=!0);break;case"next":this.paging.currentPage<this.paging.totalPages&&(this.paging.currentPage++,s=!0);break;case"page":this.paging.currentPage=parseInt(t.data("page"),10),s=!0;break;default:throw'Unknown action "'+t.data("action")+'"'}s&&(this.settings.start=parseInt(this.settings.limit.toString(),10)*(this.paging.currentPage-1),this.getWorkspaceInfos())})}sendToStage(e,t){let a,s,n;if("next"===t)a=e.data("nextStage"),s="sendToNextStageWindow",n="sendToNextStageExecute";else{if("prev"!==t)throw"Invalid direction given.";a=e.data("prevStage"),s="sendToPrevStageWindow",n="sendToPrevStageExecute"}this.sendRemoteRequest(this.generateRemoteActionsPayload(s,[e.data("uid"),e.data("table"),e.data("t3ver_oid")])).then(async t=>{const s=this.renderSendToStageWindow(await t.resolve());s.on("button.clicked",t=>{if("ok"===t.target.name){const i=r.convertFormToObject(t.currentTarget.querySelector("form"));i.affects={table:e.data("table"),nextStage:a,t3ver_oid:e.data("t3ver_oid"),uid:e.data("uid"),elements:[]},this.sendRemoteRequest([this.generateRemoteActionsPayload(n,[i]),this.generateRemotePayload("getWorkspaceInfos",this.settings)]).then(async e=>{const t=await e.resolve();s.modal("hide"),this.renderWorkspaceInfos(t[1].result),u.refreshPageTree()})}})})}getWorkspaceInfos(){this.sendRemoteRequest(this.generateRemotePayload("getWorkspaceInfos",this.settings)).then(async e=>{this.renderWorkspaceInfos((await e.resolve())[0].result)})}renderWorkspaceInfos(e){this.elements.$tableBody.children().remove(),this.resetMassActionState(e.data.length),this.buildPagination(e.total),0===e.total?(this.elements.$contentsContainer.hide(),this.elements.$noContentsContainer.show()):(this.elements.$contentsContainer.show(),this.elements.$noContentsContainer.hide());for(let t=0;t<e.data.length;++t){const s=e.data[t],n=(0,a.default)("<div />",{class:"btn-group"});let i,o=s.Workspaces_CollectionChildren>0&&""!==s.Workspaces_CollectionCurrent;n.append(this.getAction(o,"expand",s.expanded?"apps-pagetree-expand":"apps-pagetree-collapse").attr("title",TYPO3.lang["tooltip.expand"]).attr("data-bs-target",'[data-collection="'+s.Workspaces_CollectionCurrent+'"]').attr("aria-expanded",!o||s.expanded?"true":"false").attr("data-bs-toggle","collapse"),this.getAction(s.hasChanges,"changes","actions-document-info").attr("title",TYPO3.lang["tooltip.showChanges"]),this.getAction(s.allowedAction_publish&&""===s.Workspaces_CollectionParent,"publish","actions-version-swap-version").attr("title",TYPO3.lang["tooltip.publish"]),this.getAction(s.allowedAction_view,"preview","actions-version-workspace-preview").attr("title",TYPO3.lang["tooltip.viewElementAction"]),this.getAction(s.allowedAction_edit,"open","actions-open").attr("title",TYPO3.lang["tooltip.editElementAction"]),this.getAction(s.allowedAction_versionPageOpen,"version","actions-version-page-open").attr("title",TYPO3.lang["tooltip.openPage"]),this.getAction(s.allowedAction_delete,"remove","actions-version-document-remove").attr("title",TYPO3.lang["tooltip.discardVersion"])),""!==s.integrity.messages&&(i=(0,a.default)("<span>"+this.getIcon(s.integrity.status)+"</span>"),i.attr("data-bs-toggle","tooltip").attr("data-bs-placement","top").attr("data-bs-html","true").attr("title",s.integrity.messages)),this.latestPath!==s.path_Workspace&&(this.latestPath=s.path_Workspace,this.elements.$tableBody.append((0,a.default)("<tr />").append((0,a.default)("<th />"),(0,a.default)("<th />",{colspan:6}).html('<span title="'+s.path_Workspace+'">'+s.path_Workspace_crop+"</span>"))));const r=(0,a.default)("<span />",{class:"form-check form-toggle"}).append((0,a.default)("<input />",{type:"checkbox",class:"form-check-input t3js-multi-record-selection-check"})),c={"data-uid":s.uid,"data-pid":s.livepid,"data-t3ver_oid":s.t3ver_oid,"data-t3ver_wsid":s.t3ver_wsid,"data-table":s.table,"data-next-stage":s.value_nextStage,"data-prev-stage":s.value_prevStage,"data-stage":s.stage};if(""!==s.Workspaces_CollectionParent){let t=e.data.find(e=>e.Workspaces_CollectionCurrent===s.Workspaces_CollectionParent);c["data-collection"]=s.Workspaces_CollectionParent,c.class="collapse"+(t.expanded?" show":"")}else""!==s.Workspaces_CollectionCurrent&&(c["data-collection-current"]=s.Workspaces_CollectionCurrent);this.elements.$tableBody.append((0,a.default)("<tr />",c).append((0,a.default)("<td />").empty().append(r),(0,a.default)("<td />",{class:"t3js-title-workspace",style:s.Workspaces_CollectionLevel>0?"padding-left: "+this.indentationPadding*s.Workspaces_CollectionLevel+"px":""}).html('<span class="icon icon-size-small">'+this.getIcon(s.icon_Workspace)+'</span>&nbsp;<a href="#" data-action="changes"><span class="workspace-state-'+s.state_Workspace+'" title="'+s.label_Workspace+'">'+s.label_Workspace_crop+"</span></a>"),(0,a.default)("<td />",{class:"t3js-title-live"}).html('<span class="icon icon-size-small">'+this.getIcon(s.icon_Live)+'</span>&nbsp;<span class"workspace-live-title title="'+s.label_Live+'">'+s.label_Live_crop+"</span>"),(0,a.default)("<td />").text(s.label_Stage),(0,a.default)("<td />").empty().append(i),(0,a.default)("<td />").html(this.getIcon(s.language.icon)),(0,a.default)("<td />",{class:"text-end nowrap"}).append(n))),l.initialize('[data-bs-toggle="tooltip"]',{delay:{show:500,hide:100},trigger:"hover",container:"body"})}}buildPagination(e){if(0===e)return void this.elements.$pagination.contents().remove();if(this.paging.totalItems=e,this.paging.totalPages=Math.ceil(e/parseInt(this.settings.limit.toString(),10)),1===this.paging.totalPages)return void this.elements.$pagination.contents().remove();const t=(0,a.default)("<ul />",{class:"pagination"}),s=[],n=(0,a.default)("<li />",{class:"page-item"}).append((0,a.default)("<button />",{class:"page-link",type:"button","data-action":"previous"}).append((0,a.default)("<typo3-backend-icon />",{identifier:"actions-arrow-left-alt",size:"small"}))),i=(0,a.default)("<li />",{class:"page-item"}).append((0,a.default)("<button />",{class:"page-link",type:"button","data-action":"next"}).append((0,a.default)("<typo3-backend-icon />",{identifier:"actions-arrow-right-alt",size:"small"})));1===this.paging.currentPage&&n.disablePagingAction(),this.paging.currentPage===this.paging.totalPages&&i.disablePagingAction();for(let e=1;e<=this.paging.totalPages;e++){const t=(0,a.default)("<li />",{class:"page-item"+(this.paging.currentPage===e?" active":"")});t.append((0,a.default)("<button />",{class:"page-link",type:"button","data-action":"page","data-page":e}).append((0,a.default)("<span />").text(e))),s.push(t)}t.append(n,s,i),this.elements.$pagination.empty().append(t)}openPreview(e){const t=(0,a.default)(e.currentTarget).closest("tr");this.sendRemoteRequest(this.generateRemoteActionsPayload("viewSingleRecord",[t.data("table"),t.data("uid")])).then(async e=>{const t=(await e.resolve())[0].result;p.localOpen(t)})}renderSelectionActionWizard(e,t){c.addSlide("mass-action-confirmation",TYPO3.lang["window.selectionAction.title"],"<p>"+(new d).encodeHtml(TYPO3.lang["tooltip."+e+"Selected"])+"</p>",s.SeverityEnum.warning),c.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteActionsPayload("executeSelectionAction",{action:e,selection:t})).then(()=>{this.markedRecordsForMassAction=[],this.getWorkspaceInfos(),c.dismiss(),u.refreshPageTree()})}).done(()=>{c.show(),c.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseSelectionAction.val("")})})}renderMassActionWizard(e){let t;switch(e){case"publish":t="publishWorkspace";break;case"discard":t="flushWorkspace";break;default:throw"Invalid mass action "+e+" called."}const a=new d;c.setForceSelection(!1),c.addSlide("mass-action-confirmation",TYPO3.lang["window.massAction.title"],"<p>"+a.encodeHtml(TYPO3.lang["tooltip."+e+"All"])+"<br><br>"+a.encodeHtml(TYPO3.lang["tooltip.affectWholeWorkspace"])+"</p>",s.SeverityEnum.warning);const n=async e=>{const a=(await e.resolve())[0].result;a.processed<a.total?this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,a)).then(n):(this.getWorkspaceInfos(),c.dismiss())};c.addFinalProcessingSlide(()=>{this.sendRemoteRequest(this.generateRemoteMassActionsPayload(t,{init:!0,total:0,processed:0,language:this.settings.language})).then(n)}).done(()=>{c.show(),c.getComponent().on("wizard-dismissed",()=>{this.elements.$chooseMassAction.val("")})})}getAction(e,t,s){return e?(0,a.default)("<button />",{class:"btn btn-default","data-action":t,"data-bs-toggle":"tooltip"}).append(this.getIcon(s)):(0,a.default)("<span />",{class:"btn btn-default disabled"}).append(this.getIcon("empty-empty"))}getIcon(e){switch(e){case"language":e="flags-multiple";break;case"integrity":case"info":e="status-dialog-information";break;case"success":e="status-dialog-ok";break;case"warning":e="status-dialog-warning";break;case"error":e="status-dialog-error"}return'<typo3-backend-icon identifier="'+e+'" size="small"></typo3-backend-icon>'}resetMassActionState(e){this.markedRecordsForMassAction=[],e&&(this.elements.$workspaceActions.removeClass("hidden"),this.elements.$chooseMassAction.prop("disabled",!1)),document.dispatchEvent(new CustomEvent("multiRecordSelection:actions:hide"))}}return a.default.fn.disablePagingAction=function(){(0,a.default)(this).addClass("disabled").find("button").prop("disabled",!0)},new u}));