/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.reporting_bundle_jsonpfunction=window.reporting_bundle_jsonpfunction||[]).push([[0],{49:function(t,e,s){"use strict";var r=s(50),n=s(51);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=y,e.resolve=function(t,e){return y(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?y(t,!1,!0).resolveObject(e):e},e.format=function(t){return n.isString(t)&&(t=y(t)),t instanceof o?t.format():o.prototype.format.call(t)},e.Url=o;var a=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(p),c=["%","/","?",";","#"].concat(l),u=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},j=s(52);function y(t,e,s){if(t&&n.isObject(t)&&t instanceof o)return t;var r=new o;return r.parse(t,e,s),r}o.prototype.parse=function(t,e,s){if(!n.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),i=-1!==o&&o127?L+="x":L+=E[I];if(!L.match(f)){var q=w.slice(0,T),z=w.slice(T+1),_=E.match(d);_&&(q.push(_[1]),z.unshift(_[2])),z.length&&(y="/"+z.join(".")+y),this.hostname=q.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",J=this.hostname||"";this.host=J+F,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!g[O])for(T=0,A=l.length;T0)&&s.host.split("@"))&&(s.auth=k.shift(),s.host=s.hostname=k.shift())),s.search=t.search,s.query=t.query,n.isNull(s.pathname)&&n.isNull(s.search)||(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.href=s.format(),s;if(!C.length)return s.pathname=null,s.search?s.path="/"+s.search:s.path=null,s.href=s.format(),s;for(var U=C.slice(-1)[0],S=(s.host||t.host||C.length>1)&&("."===U||".."===U)||""===U,T=0,M=C.length;M>=0;M--)"."===(U=C[M])?C.splice(M,1):".."===U?(C.splice(M,1),T++):T&&(C.splice(M,1),T--);if(!x&&!O)for(;T--;T)C.unshift("..");!x||""===C[0]||C[0]&&"/"===C[0].charAt(0)||C.unshift(""),S&&"/"!==C.join("/").substr(-1)&&C.push("");var k,w=""===C[0]||C[0]&&"/"===C[0].charAt(0);return R&&(s.hostname=s.host=w?"":C.length?C.shift():"",(k=!!(s.host&&s.host.indexOf("@")>0)&&s.host.split("@"))&&(s.auth=k.shift(),s.host=s.hostname=k.shift())),(x=x||s.host&&C.length)&&!w&&C.unshift(""),C.length?s.pathname=C.join("/"):(s.pathname=null,s.path=null),n.isNull(s.pathname)&&n.isNull(s.search)||(s.path=(s.pathname?s.pathname:"")+(s.search?s.search:"")),s.auth=t.auth||s.auth,s.slashes=s.slashes||t.slashes,s.href=s.format(),s},o.prototype.parseHost=function(){var t=this.host,e=i.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},50:function(t,e,s){t.exports=s(20)(2947)},51:function(t,e,s){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},52:function(t,e,s){"use strict";e.decode=e.parse=s(53),e.encode=e.stringify=s(54)},53:function(t,e,s){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,s,o){e=e||"&",s=s||"=";var a={};if("string"!=typeof t||0===t.length)return a;var i=/\+/g;t=t.split(e);var h=1e3;o&&"number"==typeof o.maxKeys&&(h=o.maxKeys);var p=t.length;h>0&&p>h&&(p=h);for(var l=0;l=0?(c=g.substr(0,m),u=g.substr(m+1)):(c=g,u=""),f=decodeURIComponent(c),d=decodeURIComponent(u),r(a,f)?n(a[f])?a[f].push(d):a[f]=[a[f],d]:a[f]=d}return a};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},54:function(t,e,s){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,s,i){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?o(a(t),(function(a){var i=encodeURIComponent(r(a))+s;return n(t[a])?o(t[a],(function(t){return i+encodeURIComponent(r(t))})).join(e):i+encodeURIComponent(r(t[a]))})).join(e):i?encodeURIComponent(r(i))+s+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var s=[],r=0;rObject(f.jsx)(o.EuiCallOut,{size:"s",title:d.title,iconType:"warning",color:"danger","data-test-subj":"shareReportingUnsavedState"},Object(f.jsx)(o.EuiText,{size:"s"},Object(f.jsx)("p",null,Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.unsavedStateErrorText",defaultMessage:"Save your work before copying this URL."}))),Object(f.jsx)(o.EuiSpacer,{size:"s"})),m={title:a.i18n.translate("xpack.reporting.panelContent.unsavedStateAndExceedsMaxLengthTitle",{defaultMessage:"URL too long"})},b=({isUnsaved:t})=>Object(f.jsx)(o.EuiCallOut,{title:m.title,size:"s",iconType:"warning",color:"danger"},Object(f.jsx)(o.EuiText,{size:"s"},Object(f.jsx)("p",null,t?Object(f.jsx)("span",{"data-test-subj":"urlTooLongTrySavingMessage"},Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.unsavedStateAndExceedsMaxLengthTrySaveDescription",defaultMessage:"This URL cannot be copied. Try saving your work."})):Object(f.jsx)("span",{"data-test-subj":"urlTooLongErrorMessage"},Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.unsavedStateAndExceedsMaxLengthDescription",defaultMessage:"This URL cannot be copied."})))));class reporting_panel_content_ReportingPanelContentUi extends h.Component{constructor(t){super(t),n()(this,"mounted",void 0),n()(this,"getAbsoluteReportGenerationUrl",(t=>{const e=this.props.apiClient.getReportingPublicJobPath(t.reportType,this.props.apiClient.getDecoratedJobParams(this.props.getJobParams(!0)));return l.a.resolve(window.location.href,e)})),n()(this,"isNotSaved",(()=>void 0===this.props.objectId||""===this.props.objectId)),n()(this,"renderGenerateReportButton",(t=>Object(f.jsx)(o.EuiButton,{disabled:t||this.state.isCreatingReportJob,fullWidth:!0,fill:!0,onClick:this.createReportingJob,"data-test-subj":"generateReportButton",size:"s",isLoading:this.state.isCreatingReportJob},Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.generateButtonLabel",defaultMessage:"Generate {reportingType}",values:{reportingType:this.prettyPrintReportingType()}})))),n()(this,"prettyPrintReportingType",(()=>{switch(this.props.reportType){case u.j:case u.k:return"PDF";case"csv_searchsource":return u.c;case"png":case u.o:return u.n;default:return this.props.reportType}})),n()(this,"markAsStale",(()=>{this.mounted&&this.setState({isStale:!0})})),n()(this,"setAbsoluteReportGenerationUrl",(()=>{if(!this.mounted)return;const t=this.getAbsoluteReportGenerationUrl(this.props);this.setState({absoluteUrl:t})})),n()(this,"createReportingJob",(()=>{const{intl:t}=this.props,e=this.props.apiClient.getDecoratedJobParams(this.props.getJobParams());return this.setState({isCreatingReportJob:!0}),this.props.apiClient.createReportingJob(this.props.reportType,e).then((()=>{this.props.toasts.addSuccess({title:t.formatMessage({id:"xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle",defaultMessage:"Queued report for {objectType}"},{objectType:this.state.objectType}),text:Object(c.toMountPoint)(Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.successfullyQueuedReportNotificationDescription",defaultMessage:"Track its progress in {path}.",values:{path:Object(f.jsx)("a",{href:this.props.apiClient.getManagementLink()},Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.publicNotifier.reportLink.reportingSectionUrlLinkLabel",defaultMessage:"Stack Management > Reporting"}))}}),{theme$:this.props.theme.theme$}),"data-test-subj":"queueReportSuccess"}),this.props.onClose&&this.props.onClose(),this.mounted&&this.setState({isCreatingReportJob:!1})})).catch((e=>{this.props.toasts.addError(e,{title:t.formatMessage({id:"xpack.reporting.panelContent.notification.reportingErrorTitle",defaultMessage:"Unable to create report"}),toastMessage:Object(f.jsx)("span",{dangerouslySetInnerHTML:{__html:e.body.message}})}),this.mounted&&this.setState({isCreatingReportJob:!1})}))}));const{objectType:e}=t.getJobParams();this.state={isStale:!1,absoluteUrl:this.getAbsoluteReportGenerationUrl(t),layoutId:"",objectType:e,isCreatingReportJob:!1}}componentDidUpdate(t,e){this.props.layoutId&&this.props.layoutId!==e.layoutId&&this.setState({...e,absoluteUrl:this.getAbsoluteReportGenerationUrl(this.props),layoutId:this.props.layoutId})}componentWillUnmount(){window.removeEventListener("hashchange",this.markAsStale),window.removeEventListener("resize",this.setAbsoluteReportGenerationUrl),this.mounted=!1}componentDidMount(){this.mounted=!0,window.addEventListener("hashchange",this.markAsStale,!1),window.addEventListener("resize",this.setAbsoluteReportGenerationUrl)}renderCopyURLButton({isUnsaved:t,exceedsMaxLength:e}){return t?e?Object(f.jsx)(b,{isUnsaved:!0}):Object(f.jsx)(g,null):e?Object(f.jsx)(b,{isUnsaved:!1}):Object(f.jsx)(o.EuiCopy,{textToCopy:this.state.absoluteUrl,anchorClassName:"eui-displayBlock"},(e=>Object(f.jsx)(o.EuiButton,{color:t?"warning":"primary",fullWidth:!0,onClick:e,size:"s","data-test-subj":"shareReportingCopyURL"},Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.copyUrlButtonLabel",defaultMessage:"Copy POST URL"}))))}render(){const t=this.isNotSaved()||this.props.isDirty||this.state.isStale;if(this.props.requiresSavedState&&t)return Object(f.jsx)(o.EuiForm,{className:"kbnShareContextMenu__finalPanel","data-test-subj":"shareReportingForm"},Object(f.jsx)(o.EuiFormRow,{helpText:Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.saveWorkDescription",defaultMessage:"Please save your work before generating a report."})},this.renderGenerateReportButton(!0)));const e=this.state.absoluteUrl.length>=25e3;return Object(f.jsx)(o.EuiForm,{className:"kbnShareContextMenu__finalPanel","data-test-subj":"shareReportingForm"},Object(f.jsx)(o.EuiText,{size:"s"},Object(f.jsx)("p",null,Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.generationTimeDescription",defaultMessage:"{reportingType}s can take a minute or two to generate based upon the size of your {objectType}.",description:"Here 'reportingType' can be 'PDF' or 'CSV'",values:{reportingType:this.prettyPrintReportingType(),objectType:this.state.objectType}}))),Object(f.jsx)(o.EuiSpacer,{size:"s"}),this.props.options,this.renderGenerateReportButton(!1),Object(f.jsx)(o.EuiHorizontalRule,{margin:"s",style:{width:"auto",marginLeft:"-16px",marginRight:"-16px"}}),Object(f.jsx)(o.EuiAccordion,{id:"advanced-options",buttonContent:a.i18n.translate("xpack.reporting.panelContent.advancedOptions",{defaultMessage:"Advanced options"}),paddingSize:"none","data-test-subj":"shareReportingAdvancedOptionsButton"},Object(f.jsx)(o.EuiSpacer,{size:"s"}),Object(f.jsx)(o.EuiText,{size:"s"},Object(f.jsx)("p",null,Object(f.jsx)(i.FormattedMessage,{id:"xpack.reporting.panelContent.howToCallGenerationDescription",defaultMessage:"Alternatively, copy this POST URL to call generation from outside Kibana or from Watcher."}))),Object(f.jsx)(o.EuiSpacer,{size:"s"}),this.renderCopyURLButton({isUnsaved:t,exceedsMaxLength:e})))}}const j=Object(i.injectI18n)(reporting_panel_content_ReportingPanelContentUi)}}]);