(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[51],{511:function(e,t,o){"use strict";var s=o(0),n=o(2),i=o(13),c=o(7),a=o(18),r=o.n(a),m=o(4),l=o(21),u=o(11),d=o(122);class p extends s.Component{constructor(e){super(e),this.state={isLoadingScripts:!1,isRequestStarted:!1}}async componentDidUpdate(e,t){const{hasErrors:o,isRequesting:s,onClose:i,onContinue:c,createNotice:a}=this.props,{isLoadingScripts:r,isRequestStarted:m}=this.state;if(!m)return;const l=!s&&!r&&(e.isRequesting||t.isLoadingScripts)&&!o,u=!s&&e.isRequesting&&o;l&&(i(),c()),u&&(a("error",Object(n.__)("There was a problem updating your preferences",'woocommerce')),i())}updateTracking({allowTracking:e}){const{updateOptions:t}=this.props;e&&"function"==typeof window.wcTracks.enable?(this.setState({isLoadingScripts:!0}),window.wcTracks.enable(()=>{this._isMounted&&(Object(d.initializeExPlat)(),this.setState({isLoadingScripts:!1}))})):e||(window.wcTracks.isEnabled=!1);const o=e?"yes":"no";this.setState({isRequestStarted:!0}),t({woocommerce_allow_tracking:o})}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){if(this.props.allowTracking){const{onClose:e,onContinue:t}=this.props;return e(),t(),null}const{isRequesting:e,title:t=Object(n.__)("Build a better WooCommerce",'woocommerce'),message:o=r()({mixedString:Object(n.__)("Get improved features and faster fixes by sharing non-sensitive data via {{link}}usage tracking{{/link}} that shows us how WooCommerce is used. No personal data is tracked or stored.",'woocommerce'),components:{link:Object(s.createElement)(l.Link,{href:"https://woocommerce.com/usage-tracking",target:"_blank",type:"external"})}}),dismissActionText:i=Object(n.__)("No thanks",'woocommerce'),acceptActionText:c=Object(n.__)("Yes, count me in!",'woocommerce')}=this.props,{isRequestStarted:a}=this.state,u=a&&e;return Object(s.createElement)(m.Modal,{title:t,isDismissible:this.props.isDismissible,onRequestClose:()=>this.props.onClose(),className:"woocommerce-usage-modal"},Object(s.createElement)("div",{className:"woocommerce-usage-modal__wrapper"},Object(s.createElement)("div",{className:"woocommerce-usage-modal__message"},o),Object(s.createElement)("div",{className:"woocommerce-usage-modal__actions"},Object(s.createElement)(m.Button,{isSecondary:!0,isBusy:u,onClick:()=>this.updateTracking({allowTracking:!1})},i),Object(s.createElement)(m.Button,{isPrimary:!0,isBusy:u,onClick:()=>this.updateTracking({allowTracking:!0})},c))))}}t.a=Object(i.compose)(Object(c.withSelect)(e=>{const{getOption:t,getOptionsUpdatingError:o,isOptionsUpdating:s}=e(u.OPTIONS_STORE_NAME);return{allowTracking:"yes"===t("woocommerce_allow_tracking"),isRequesting:Boolean(s()),hasErrors:Boolean(o())}}),Object(c.withDispatch)(e=>{const{createNotice:t}=e("core/notices"),{updateOptions:o}=e(u.OPTIONS_STORE_NAME);return{createNotice:t,updateOptions:o}}))(p)},516:function(e,t,o){"use strict";o.r(t),o.d(t,"UsageModal",(function(){return l}));var s=o(0),n=o(2),i=o(12),c=o(18),a=o.n(c),r=o(21),m=o(511);const l=()=>{const e="1"===Object(i.getQuery)()["wcpay-connection-success"],[t,o]=Object(s.useState)(e);if(!t)return null;const c=()=>{o(!1),Object(i.updateQueryString)({"wcpay-connection-success":void 0})},l=Object(n.__)("Help us build a better WooCommerce Payments experience",'woocommerce'),u=a()({mixedString:Object(n.__)("By agreeing to share non-sensitive {{link}}usage data{{/link}}, you’ll help us improve features and optimize the WooCommerce Payments experience. You can opt out at any time.",'woocommerce'),components:{link:Object(s.createElement)(r.Link,{href:"https://woocommerce.com/usage-tracking",target:"_blank",type:"external"})}});return Object(s.createElement)(m.a,{isDismissible:!1,title:l,message:u,acceptActionText:Object(n.__)("I agree",'woocommerce'),dismissActionText:Object(n.__)("No thanks",'woocommerce'),onContinue:c,onClose:c})};t.default=l}}]);