"use strict";var H=Object.create;var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var F=Object.getPrototypeOf;var E=Object.prototype.hasOwnProperty;var h=(o,t)=>l(o,"name",{value:t,configurable:true});var L=(o,t)=>{for(var a in t)l(o,a,{get:t[a],enumerable:true})};var R=(o,t,a,i)=>{if(t&&typeof t==="object"||typeof t==="function"){for(let e of T(t))if(!E.call(o,e)&&e!==a)l(o,e,{get:()=>t[e],enumerable:!(i=v(t,e))||i.enumerable})}return o};var B=(o,t,a)=>(a=o!=null?H(F(o)):{},R(t||!o||!o.__esModule?l(a,"default",{value:o,enumerable:true}):a,o));var G=o=>R(l({},"__esModule",{value:true}),o);var I=(o,t,a,i)=>{var e=i>1?void 0:i?v(t,a):t;for(var p=o.length-1,u;p>=0;p--)if(u=o[p])e=(i?u(t,a,e):u(e))||e;if(i&&e)l(t,a,e);return e};var K={};L(K,{default:()=>D});module.exports=G(K);var r=require("react/jsx-runtime");var n=require("@mdi/js");var U=require("mobx-react");var f=require("react");var g=require("react-intl");var M=B(require("react-jss"));var C=require("react-tooltip");var c=B(require("../../../components/ui/icon"));var w=require("../../../jsUtils");const b=(0,g.defineMessages)({goHome:{id:"webControls.goHome",defaultMessage:"Home"},openInBrowser:{id:"webControls.openInBrowser",defaultMessage:"Open in Browser"},back:{id:"webControls.back",defaultMessage:"Back"},forward:{id:"webControls.forward",defaultMessage:"Forward"},reload:{id:"webControls.reload",defaultMessage:"Reload"}});const O=window?.matchMedia("(prefers-reduced-motion: no-preference)")?"opacity 0.25s":"none";const j=h(o=>({root:{background:o.colorBackground,position:"relative",borderLeft:[1,"solid",o.todos.todosLayer.borderLeftColor],zIndex:300,height:50,display:"flex",flexDirection:"row",alignItems:"center",padding:[0,10],"& + div":{height:"calc(100% - 50px)"}},button:{width:30,height:50,transition:O,"&:hover":{opacity:.8},"&:disabled":{opacity:.5}},icon:{width:"20px !important",height:20,marginTop:5,color:o.colorText},input:{marginBottom:0,height:"auto",margin:[0,10],flex:1,border:0,padding:[4,10],borderRadius:o.borderRadius,background:o.inputBackground,color:o.inputColor},inputButton:{color:o.colorText}}),"styles");let d=class extends f.Component{inputRef=(0,f.createRef)();static getDerivedStateFromProps(t,a){const{url:i}=t;const{editUrl:e}=a;return e?null:{inputUrl:i,editUrl:e}}constructor(t){super(t);this.state={inputUrl:"",editUrl:false}}render(){const{classes:t,goHome:a,canGoBack:i,goBack:e,canGoForward:p,goForward:u,reload:N,openInBrowser:S,url:y,navigate:x,intl:m}=this.props;const{inputUrl:k,editUrl:P}=this.state;return(0,r.jsxs)("div",{className:t.root,children:[(0,r.jsx)("button",{onClick:a,type:"button",className:t.button,"data-tooltip-id":"tooltip-web-controls","data-tooltip-content":m.formatMessage(b.goHome),"data-place":"bottom",children:(0,r.jsx)(c.default,{icon:n.mdiHomeOutline,className:t.icon})}),(0,r.jsx)("button",{onClick:e,type:"button",className:t.button,disabled:!i,"data-tooltip-id":"tooltip-web-controls","data-tooltip-content":m.formatMessage(b.back),"data-place":"bottom",children:(0,r.jsx)(c.default,{icon:n.mdiArrowLeft,className:t.icon})}),(0,r.jsx)("button",{onClick:u,type:"button",className:t.button,disabled:!p,"data-tooltip-id":"tooltip-web-controls","data-tooltip-content":m.formatMessage(b.forward),"data-place":"bottom",children:(0,r.jsx)(c.default,{icon:n.mdiArrowRight,className:t.icon})}),(0,r.jsx)("button",{onClick:N,type:"button",className:t.button,"data-tooltip-id":"tooltip-web-controls","data-tooltip-content":m.formatMessage(b.reload),"data-place":"bottom",children:(0,r.jsx)(c.default,{icon:n.mdiReload,className:t.icon})}),(0,r.jsx)("input",{value:P?k:y,className:t.input,onChange:s=>this.setState({inputUrl:s.target.value}),onFocus:s=>{s.target.select();this.setState({editUrl:true})},onBlur:s=>{s.target.blur();this.setState({editUrl:false})},onKeyDown:s=>{if((0,w.isEnterKeyPress)(s.key)){this.setState({editUrl:false});x(k);if(this.inputRef?.current){this.inputRef.current.blur()}}else if((0,w.isEscapeKeyPress)(s.key)){this.setState({editUrl:false,inputUrl:y});if(this.inputRef?.current){this.inputRef.current.blur()}}},ref:this.inputRef}),(0,r.jsx)("button",{onClick:S,type:"button",className:t.button,"data-tooltip-id":"tooltip-web-controls","data-tooltip-content":m.formatMessage(b.openInBrowser),"data-place":"bottom",children:(0,r.jsx)(c.default,{icon:n.mdiEarth,className:t.icon})}),(0,r.jsx)(C.Tooltip,{id:"tooltip-web-controls",place:"bottom",variant:"dark",style:{height:"auto"}})]})}};h(d,"WebControls");d=I([U.observer],d);var D=(0,g.injectIntl)((0,M.default)(j,{injectTheme:true})(d));
