var E=Object.create;var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var F=(t,o)=>{for(var e in o)u(t,e,{get:o[e],enumerable:!0})},y=(t,o,e,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of I(o))!O.call(t,i)&&i!==e&&u(t,i,{get:()=>o[i],enumerable:!(l=T(o,i))||l.enumerable});return t};var b=(t,o,e)=>(e=t!=null?E(M(t)):{},y(o||!t||!t.__esModule?u(e,"default",{value:t,enumerable:!0}):e,t)),N=t=>y(u({},"__esModule",{value:!0}),t);var W={};F(W,{bar:()=>S,context:()=>R,tray:()=>A});module.exports=N(W);var n=require("electron/main"),c=require("electron/common"),w=require("../../common/modules/client"),m=require("./config"),C=require("events"),g=require("./bug"),p=b(require("../../common/modules/l10n")),k=b(require("../windows/settings")),f=b(require("../windows/docs")),h=b(require("../windows/about")),r=require("./error");const s=new C.EventEmitter,v=(0,w.getBuildInfo)().type==="devel";s.on("hide",t=>{console.debug("[EVENT] Hiding menu bar..."),t.insertCSS(["div[class^=sidebar_],div[class^=sidebarList_]{ width: 0px !important; }","div[class^=sidebarRegion_]{ display: none !important; }","div[class^=contentColumn_]{ max-width: 100% !important; }"].join(`
`),{cssOrigin:"author"}).then(o=>{s.once("show",()=>{console.debug(`[EVENT] Showing menu bar (${o})...`),t.removeInsertedCSS(o)})}).catch(r.commonCatches.print)});function R(t){const{context:o}=new p.default().client;t.webContents.on("context-menu",(e,l)=>n.Menu.buildFromTemplate([{type:"separator"},...l.dictionarySuggestions.map(i=>({label:i,click:()=>t.webContents.replaceMisspelling(i)})),...l.misspelledWord!==""?[{type:"separator"},{label:o.dictionaryAdd,click:()=>t.webContents.session.addWordToSpellCheckerDictionary(l.misspelledWord)},{type:"separator"}]:[],...l.editFlags.canCopy||l.editFlags.canCut||l.editFlags.canDelete?[{label:o.cut,role:"cut",enabled:l.editFlags.canCut},{label:o.copy,role:"copy",enabled:l.editFlags.canCopy},{label:o.paste,enabled:c.clipboard.availableFormats().length!==0&&l.editFlags.canPaste,role:"paste"},{type:"separator"}]:[],...l.linkURL!==""?[{label:o.copyURL,click:()=>c.clipboard.writeText(l.linkURL)},...l.linkText!==""?[{label:o.copyURLText,click:()=>c.clipboard.writeText(l.linkText)}]:[],{type:"separator"}]:[],...l.mediaType==="image"?[{label:o.copyImage,click:()=>t.webContents.copyImageAt(l.x,l.y)},{label:o.copyImageURL,click:()=>c.clipboard.writeText(l.srcURL)},{type:"separator"}]:[],...v||m.appConfig.value.settings.advanced.devel.enabled?[{label:o.inspectElement,click:()=>t.webContents.inspectElement(l.x,l.y)}]:[]]).popup({window:t,x:l.x,y:l.y}))}function A(t){const o=new p.default().client,{icons:e}=w.appInfo,l=new n.Tray(e.tray.default);function i(){t.isVisible()&&t.isFocused()?t.hide():t.isVisible()?t.focus():t.show()}const a=n.Menu.buildFromTemplate([{label:n.app.getName(),icon:e.tray.default.resize({height:16}),enabled:!1},{type:"separator"},...process.platform!=="win32"?[{label:o.tray.toggle,click:()=>setImmediate(i)}]:[],{label:o.help.bugs,click:()=>{(0,g.createGithubIssue)().catch(r.commonCatches.throw)}},{label:o.windows.about,click:()=>(0,h.default)(t)},{label:o.windows.docs,click:()=>{(0,f.default)(t).catch(r.commonCatches.throw)}},{type:"separator"},...process.platform==="win32"?[{label:o.tray.toggle,click:()=>setImmediate(i)}]:[],{label:o.tray.quit,click:()=>n.app.quit()}]);l.setContextMenu(a),l.setToolTip(n.app.getName()),l.on("click",i);{let d=!1;n.app.once("before-quit",()=>d=!0),t.on("close",x=>{!d&&m.appConfig.value.settings.general.window.hideOnClose&&(x.preventDefault(),t.hide())})}return l}function S(t,o){const e=new p.default().client,l=t.substring(t.indexOf("+")+1),i=n.Menu.buildFromTemplate([{label:e.menubar.file.groupName,submenu:[{label:e.windows.settings,click:()=>(0,k.default)(o)},{type:"separator"},{label:e.menubar.file.relaunch,accelerator:"CmdOrCtrl+Alt+R",click:()=>{const a=[];for(const d of process.argv)/^--?(?:start-minimized|m)$/.test(d)||a.push(d);a.shift(),n.app.relaunch({args:a}),n.app.quit()}},{label:e.menubar.file.quit,accelerator:"CmdOrCtrl+Q",click:()=>{n.app.quit()}}]},{role:"editMenu",label:e.menubar.edit.groupName,submenu:[{label:e.menubar.edit.undo,role:"undo"},{label:e.menubar.edit.redo,role:"redo"},{type:"separator"},{label:e.context.cut,role:"cut"},{label:e.context.copy,role:"copy"},{label:e.context.paste,role:"paste"},{type:"separator"},{label:e.menubar.edit.selectAll,role:"selectAll"}]},{label:e.menubar.view.groupName,submenu:[{label:e.menubar.view.reload,role:"reload"},{label:e.menubar.view.forceReload,role:"forceReload"},{type:"separator"},{label:e.menubar.view.devTools,id:"devTools",role:"toggleDevTools",enabled:v||m.appConfig.value.settings.advanced.devel.enabled},{type:"separator"},{label:e.menubar.view.resetZoom,role:"resetZoom"},{label:e.menubar.view.zoomIn,role:"zoomIn"},{label:e.menubar.view.zoomOut,role:"zoomOut"},{type:"separator"},{label:e.menubar.view.fullScreen,role:"togglefullscreen"}]},{label:e.menubar.window.groupName,submenu:[{label:e.menubar.window.mobileMode,type:"checkbox",accelerator:"CmdOrCtrl+Alt+M",checked:!1,click:()=>{s.listenerCount("show")+s.listenerCount("hide")>1?s.emit("show"):s.emit("hide",o.webContents)}}]},{label:e.help.groupName,role:"help",submenu:[{label:e.windows.about,click:()=>(0,h.default)(o)},{label:e.help.repo,click:()=>{c.shell.openExternal(l).catch(r.commonCatches.throw)}},{label:e.windows.docs,click:()=>{(0,f.default)(o).catch(r.commonCatches.throw)}},{label:e.help.bugs,click:()=>{(0,g.createGithubIssue)().catch(r.commonCatches.throw)}}]}]);return n.Menu.setApplicationMenu(i),i}0&&(module.exports={bar,context,tray});
