관리-도구
편집 파일: task-list.js
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[50],{439:function(e,t,n){"use strict";var o=n(8),c=n(12),r=n(4),a=n.n(r),i=n(0);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}t.a=function(e){var t=e.as,n=void 0===t?"div":t,r=e.className,l=Object(c.a)(e,["as","className"]);return function(e){var t=e.as,n=void 0===t?"div":t,o=Object(c.a)(e,["as"]);return"function"==typeof o.children?o.children(o):Object(i.createElement)(n,o)}(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){Object(o.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({as:n,className:a()("components-visually-hidden",r)},l))}},445:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var o=n(5),c=n.n(o),r=n(37),a=n(36);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=window.location,o=n.pathname,c=n.search,i=Object(a.g)("connectNonce","");return t=s({"wccom-site":Object(a.g)("siteUrl"),"wccom-back":o+c,"wccom-woo-version":Object(a.g)("wcVersion"),"wccom-connect-nonce":i},t),Object(r.addQueryArgs)(e,t)}},767:function(e,t,n){"use strict";var o=n(0),c=n(4),r=n.n(c),a=n(439);function i(e){var t=e.id,n=e.label,c=e.hideLabelFromVision,s=e.help,l=e.className,u=e.children;return Object(o.createElement)("div",{className:r()("components-base-control",l)},Object(o.createElement)("div",{className:"components-base-control__field"},n&&t&&(c?Object(o.createElement)(a.a,{as:"label",htmlFor:t},n):Object(o.createElement)("label",{className:"components-base-control__label",htmlFor:t},n)),n&&!t&&(c?Object(o.createElement)(a.a,{as:"label"},n):Object(o.createElement)(i.VisualLabel,null,n)),u),!!s&&Object(o.createElement)("p",{id:t+"__help",className:"components-base-control__help"},s))}i.VisualLabel=function(e){var t=e.className,n=e.children;return t=r()("components-base-control__label",t),Object(o.createElement)("span",{className:t},n)},t.a=i},779:function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var o=n(7),c=n(12),r=n(0),a=n(300),i=n(575),s=n(759),l=n(767);function u(e){var t=e.label,n=e.className,m=e.heading,p=e.checked,d=e.help,h=e.onChange,b=Object(c.a)(e,["label","className","heading","checked","help","onChange"]),_=Object(a.a)(u),f="inspector-checkbox-control-".concat(_);return Object(r.createElement)(l.a,{label:m,id:f,help:d,className:n},Object(r.createElement)("span",{className:"components-checkbox-control__input-container"},Object(r.createElement)("input",Object(o.a)({id:f,className:"components-checkbox-control__input",type:"checkbox",value:"1",onChange:function(e){return h(e.target.checked)},checked:p,"aria-describedby":d?f+"__help":void 0},b)),p?Object(r.createElement)(i.a,{icon:s.a,className:"components-checkbox-control__checked",role:"presentation"}):null),Object(r.createElement)("label",{className:"components-checkbox-control__label",htmlFor:f},t))}},785:function(e,t,n){"use strict";n.d(t,"b",(function(){return _})),n.d(t,"a",(function(){return f}));var o=n(38),c=n.n(o),r=n(34),a=n.n(r),i=n(30),s=n.n(i),l=n(0),u=n(3),m=n(81),p=n(2),d=n(36),h=n(77),b=Object(d.g)("dataEndpoints",{countries:{}}).countries;function _(e){var t={};return e.addressLine1.length||(t.addressLine1=Object(u.__)("Please add an address",'kkart')),e.countryState.length||(t.countryState=Object(u.__)("Please select a country / region",'kkart')),e.city.length||(t.city=Object(u.__)("Please add a city",'kkart')),e.postCode.length||(t.postCode=Object(u.__)("Please add a post code",'kkart')),t}function f(e){var t=e.getInputProps,n=e.setValue,o=Object(l.useMemo)((function(){return b.reduce((function(e,t){if(!t.states.length)return e.push({key:t.code,label:Object(m.decodeEntities)(t.name)}),e;var n=t.states.map((function(e){return{key:t.code+":"+e.code,label:Object(m.decodeEntities)(t.name)+" — "+Object(m.decodeEntities)(e.name)}}));return e.push.apply(e,s()(n)),e}),[])}),[]),r=function(e,t,n){var o=Object(l.useState)(""),c=a()(o,2),r=c[0],i=c[1],s=Object(l.useState)(""),u=a()(s,2),m=u[0],d=u[1];return Object(l.useEffect)((function(){var o=[],c=new RegExp(Object(p.escapeRegExp)(r),"i");if((m.length||r.length)&&(o=e.filter((function(e){return c.test(e.label)}))),r.length&&m.length){var a=new RegExp(Object(p.escapeRegExp)(m.replace(/\s/g,"")),"i");if((o=o.filter((function(e){return a.test(e.label.replace("-","").replace(/\s/g,""))}))).length>1){var i;(i=o.filter((function(e){return c.test(e.key)}))).length>0&&(o=i)}if(o.length>1){var s;1===(s=o.filter((function(e){return a.test(e.key)}))).length&&(o=s)}}1===o.length&&t!==o[0].key&&n("countryState",o[0].key)}),[r,m,t,e,n]),Object(l.createElement)(l.Fragment,null,Object(l.createElement)("input",{onChange:function(e){return i(e.target.value)},value:r,name:"country",type:"text",className:"kkart-select-control__autofill-input",tabIndex:"-1",autoComplete:"country"}),Object(l.createElement)("input",{onChange:function(e){return d(e.target.value)},value:m,name:"state",type:"text",className:"kkart-select-control__autofill-input",tabIndex:"-1",autoComplete:"address-level1"}))}(o,t("countryState").value,n);return Object(l.createElement)("div",{className:"kkart-store-address-fields"},Object(l.createElement)(h.TextControl,c()({label:Object(u.__)("Address line 1",'kkart'),required:!0,autoComplete:"address-line1"},t("addressLine1"))),Object(l.createElement)(h.TextControl,c()({label:Object(u.__)("Address line 2 (optional)",'kkart'),required:!0,autoComplete:"address-line2"},t("addressLine2"))),Object(l.createElement)(h.SelectControl,c()({label:Object(u.__)("Country / Region",'kkart'),required:!0,options:o,excludeSelectedOptions:!1,showAllOnFocus:!0,isSearchable:!0},t("countryState"),{controlClassName:t("countryState").className}),r),Object(l.createElement)(h.TextControl,c()({label:Object(u.__)("City",'kkart'),required:!0},t("city"),{autoComplete:"address-level2"})),Object(l.createElement)(h.TextControl,c()({label:Object(u.__)("Post code",'kkart'),required:!0,autoComplete:"postal-code"},t("postCode"))))}},821:function(e,t,n){"use strict";var o=n(7),c=n(12),r=n(0),a=n(4),i=n.n(a),s=n(2);t.a=function(e){var t=e.className,n=e.checked,a=e.id,l=e.onChange,u=void 0===l?s.noop:l,m=Object(c.a)(e,["className","checked","id","onChange"]),p=i()("components-form-toggle",t,{"is-checked":n});return Object(r.createElement)("span",{className:p},Object(r.createElement)("input",Object(o.a)({className:"components-form-toggle__input",id:a,type:"checkbox",checked:n,onChange:u},m)),Object(r.createElement)("span",{className:"components-form-toggle__track"}),Object(r.createElement)("span",{className:"components-form-toggle__thumb"}))}},849:function(e,t,n){"use strict";n.r(t),n.d(t,"TaskDashboard",(function(){return He}));var o=n(30),c=n.n(o),r=n(17),a=n.n(r),i=n(15),s=n.n(i),l=n(18),u=n.n(l),m=n(19),p=n.n(m),d=n(9),h=n.n(d),b=n(0),_=n(3),f=n(277),g=n(4),O=n.n(g),y=n(72),v=n(190),k=n(724),j=n(558),w=n(725),S=n(20),E=n(570),C=n(88),P=Object(b.createElement)(C.c,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(b.createElement)(C.b,{d:"M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"})),N=n(2),x=n(77),T=n(32),R=n(35),A=n(64),I=(n(794),n(736)),M=n(81),D=n(36),L=n(191),F=n(772),U=n(445);function B(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var q=function(e){u()(n,e);var t=B(n);function n(e){var o;return a()(this,n),(o=t.call(this,e)).state={purchaseNowButtonBusy:!1,purchaseLaterButtonBusy:!1},o}return s()(n,[{key:"onClickPurchaseNow",value:function(){var e=this.props,t=e.productIds,n=e.onClickPurchaseNow;if(this.setState({purchaseNowButtonBusy:!0}),t.length){Object(A.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:t,purchase_install:!0});var o=Object(U.a)("https://kkart.com/cart",{"wccom-replace-with":t.join(",")});n?n(o):window.location=o}}},{key:"onClickPurchaseLater",value:function(){var e=this.props.productIds;Object(A.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:e,purchase_install:!1}),this.setState({purchaseLaterButtonBusy:!0}),this.props.onClickPurchaseLater()}},{key:"onClose",value:function(){var e=this.props,t=e.onClose,n=e.productIds;Object(A.recordEvent)("tasklist_modal_proceed_checkout",{product_ids:n,purchase_install:!1}),t()}},{key:"renderProducts",value:function(){var e=this.props.productIds,t=Object(D.g)("onboarding",{}),n=t.productTypes,o=void 0===n?{}:n,c=t.themes,r=void 0===c?[]:c,a=[];return e.forEach((function(e){var t=Object(N.find)(o,(function(t){return t.product===e}));t&&a.push({title:t.label,content:t.description});var n=Object(N.find)(r,(function(t){return t.id===e}));n&&a.push({title:Object(_.sprintf)(Object(_.__)("%s — %s per year",'kkart'),n.title,Object(M.decodeEntities)(n.price)),content:Object(b.createElement)("span",{dangerouslySetInnerHTML:Object(F.a)(n.excerpt)})})})),Object(b.createElement)(x.List,{items:a})}},{key:"render",value:function(){var e=this,t=this.state,n=t.purchaseNowButtonBusy,o=t.purchaseLaterButtonBusy;return Object(b.createElement)(I.a,{title:Object(_.__)("Would you like to purchase and install the following features now?",'kkart'),onRequestClose:function(){return e.onClose()},className:"kkart-cart-modal"},this.renderProducts(),Object(b.createElement)("p",{className:"kkart-cart-modal__help-text"},Object(_.__)("You won't have access to this functionality until the extensions have been purchased and installed.",'kkart')),Object(b.createElement)("div",{className:"kkart-cart-modal__actions"},Object(b.createElement)(y.a,{isLink:!0,isBusy:o,onClick:function(){return e.onClickPurchaseLater()}},Object(_.__)("I'll do it later",'kkart')),Object(b.createElement)(y.a,{isPrimary:!0,isBusy:n,onClick:function(){return e.onClickPurchaseNow()}},Object(_.__)("Purchase & install now",'kkart'))))}}]),n}(b.Component),J=Object(f.a)(Object(S.withSelect)((function(e){var t=e(R.PLUGINS_STORE_NAME).getInstalledPlugins,n=(0,e(R.ONBOARDING_STORE_NAME).getProfileItems)(),o=t();return{profileItems:n,productIds:Object(L.e)(n,!1,o)}})))(q),G=n(14),V=n.n(G),z=n(98),H=n.n(z),Z=n(5),W=n.n(Z),Q=n(55),Y=n(11),K=n.n(Y),X=n(43),$=n.n(X);function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){W()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var oe=function(e){u()(c,e);var t,n,o=ne(c);function c(e){var t;a()(this,c),t=o.call(this,e);var n=e.tasksStatus,r=n.hasHomepage,i=n.hasProducts;return t.stepVisibility={homepage:!r,import:!i},t.state={isDirty:!1,isPending:!1,logo:null,stepIndex:0,isUpdatingLogo:!1,isUpdatingNotice:!1,storeNoticeText:e.demoStoreNotice||""},t.completeStep=t.completeStep.bind(K()(t)),t.createHomepage=t.createHomepage.bind(K()(t)),t.importProducts=t.importProducts.bind(K()(t)),t.updateLogo=t.updateLogo.bind(K()(t)),t.updateNotice=t.updateNotice.bind(K()(t)),t}return s()(c,[{key:"componentDidMount",value:function(){var e=this.props.tasksStatus.themeMods;e&&e.custom_logo&&this.setState({logo:{id:e.custom_logo}})}},{key:"componentDidUpdate",value:function(e){var t=this,n=this.state,o=n.isPending,c=n.logo,r=this.props.demoStoreNotice;!c||c.url||o||(this.setState({isPending:!0}),wp.media.attachment(c.id).fetch().then((function(){var e=wp.media.attachment(c.id).get("url");t.setState({isPending:!1,logo:{id:c.id,url:e}})}))),r&&e.demoStoreNotice!==r&&this.setState({storeNoticeText:r})}},{key:"completeStep",value:function(){var e=this.state.stepIndex;this.getSteps()[e+1]?this.setState({stepIndex:e+1}):Object(T.getHistory)().push(Object(T.getNewPath)({},"/",{}))}},{key:"importProducts",value:function(){var e=this,t=this.props,n=t.clearTaskStatusCache,o=t.createNotice;this.setState({isPending:!0}),Object(A.recordEvent)("tasklist_appearance_import_demo",{}),$()({path:"".concat(R.KKART_ADMIN_NAMESPACE,"/onboarding/tasks/import_sample_products"),method:"POST"}).then((function(t){t.failed&&t.failed.length?o("error",Object(_.__)("There was an error importing some of the sample products.",'kkart')):(o("success",Object(_.__)("All sample products have been imported.",'kkart')),n()),e.setState({isPending:!1}),e.completeStep()})).catch((function(t){o("error",t.message),e.setState({isPending:!1})}))}},{key:"createHomepage",value:function(){var e=this,t=this.props,n=t.clearTaskStatusCache,o=t.createNotice;this.setState({isPending:!0}),Object(A.recordEvent)("tasklist_appearance_create_homepage",{create_homepage:!0}),$()({path:"/kkart-admin/onboarding/tasks/create_homepage",method:"POST"}).then((function(t){n(),o(t.status,t.message,{actions:t.edit_post_link?[{label:Object(_.__)("Customize",'kkart'),onClick:function(){Object(A.queueRecordEvent)("tasklist_appearance_customize_homepage",{}),window.location="".concat(t.edit_post_link,"&kkart_onboarding_active_task=homepage")}}]:null}),e.setState({isPending:!1}),e.completeStep()})).catch((function(t){o("error",t.message),e.setState({isPending:!1})}))}},{key:"updateLogo",value:(n=H()(V.a.mark((function e(){var t,n,o,c,r,a,i,s,l;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.props,n=t.clearTaskStatusCache,o=t.createNotice,c=t.stylesheet,r=t.themeMods,a=t.updateOptions,i=this.state.logo,s=te(te({},r),{},{custom_logo:i?i.id:null}),Object(A.recordEvent)("tasklist_appearance_upload_logo"),this.setState({isUpdatingLogo:!0}),e.next=7,a(W()({},"theme_mods_".concat(c),s));case 7:l=e.sent,n(),l.success?(this.setState({isUpdatingLogo:!1}),o("success",Object(_.__)("Store logo updated sucessfully.",'kkart')),this.completeStep()):o("error",l.message);case 10:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateNotice",value:(t=H()(V.a.mark((function e(){var t,n,o,c,r,a;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.props,n=t.clearTaskStatusCache,o=t.createNotice,c=t.updateOptions,r=this.state.storeNoticeText,Object(A.recordEvent)("tasklist_appearance_set_store_notice",{added_text:Boolean(r.length)}),this.setState({isUpdatingNotice:!0}),e.next=6,c({kkart_task_list_appearance_complete:!0,kkart_demo_store:r.length?"yes":"no",kkart_demo_store_notice:r});case 6:a=e.sent,n(),a.success?(this.setState({isUpdatingNotice:!1}),o("success",Object(_.__)("🎨 Your store is looking great! Don't forget to continue personalizing it.",'kkart')),this.completeStep()):o("error",a.message);case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getSteps",value:function(){var e=this,t=this.state,n=t.isDirty,o=t.isPending,c=t.logo,r=t.storeNoticeText,a=t.isUpdatingLogo,i=[{key:"import",label:Object(_.__)("Import sample products",'kkart'),description:Object(_.__)("We’ll add some products that will make it easier to see what your store looks like",'kkart'),content:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(y.a,{onClick:this.importProducts,isBusy:o,isPrimary:!0},Object(_.__)("Import products",'kkart')),Object(b.createElement)(y.a,{onClick:function(){return e.completeStep()}},Object(_.__)("Skip",'kkart'))),visible:this.stepVisibility.import},{key:"homepage",label:Object(_.__)("Create a custom homepage",'kkart'),description:Object(_.__)("Create a new homepage and customize it to suit your needs",'kkart'),content:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(y.a,{isPrimary:!0,isBusy:o,onClick:this.createHomepage},Object(_.__)("Create homepage",'kkart')),Object(b.createElement)(y.a,{onClick:function(){Object(A.recordEvent)("tasklist_appearance_create_homepage",{create_homepage:!1}),e.completeStep()}},Object(_.__)("Skip",'kkart'))),visible:this.stepVisibility.homepage},{key:"logo",label:Object(_.__)("Upload a logo",'kkart'),description:Object(_.__)("Ensure your store is on-brand by adding your logo",'kkart'),content:o?null:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(x.ImageUpload,{image:c,onChange:function(t){return e.setState({isDirty:!0,logo:t})}}),Object(b.createElement)(y.a,{disabled:!c&&!n,onClick:this.updateLogo,isBusy:a,isPrimary:!0},Object(_.__)("Proceed",'kkart')),Object(b.createElement)(y.a,{isTertiary:!0,onClick:function(){return e.completeStep()}},Object(_.__)("Skip",'kkart'))),visible:!0},{key:"notice",label:Object(_.__)("Set a store notice",'kkart'),description:Object(_.__)("Optionally display a prominent notice across all pages of your store",'kkart'),content:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(x.TextControl,{label:Object(_.__)("Store notice text",'kkart'),placeholder:Object(_.__)("Store notice text",'kkart'),value:r,onChange:function(t){return e.setState({storeNoticeText:t})}}),Object(b.createElement)(y.a,{onClick:this.updateNotice,isPrimary:!0},Object(_.__)("Complete task",'kkart'))),visible:!0}];return Object(N.filter)(i,(function(e){return e.visible}))}},{key:"render",value:function(){var e=this.state,t=e.isPending,n=e.stepIndex,o=e.isUpdatingLogo,c=e.isUpdatingNotice,r=this.getSteps()[n].key;return Object(b.createElement)("div",{className:"kkart-task-appearance"},Object(b.createElement)(x.Card,{className:"is-narrow"},Object(b.createElement)(x.Stepper,{isPending:c||o||t,isVertical:!0,currentStep:r,steps:this.getSteps()})))}}]),c}(b.Component),ce=Object(f.a)(Object(S.withSelect)((function(e){var t=e(R.OPTIONS_STORE_NAME).getOption,n=(0,e(R.ONBOARDING_STORE_NAME).getTasksStatus)();return{demoStoreNotice:t("kkart_demo_store_notice"),stylesheet:t("stylesheet"),tasksStatus:n}})),Object(S.withDispatch)((function(e){var t=e("core/notices").createNotice,n=e(R.OPTIONS_STORE_NAME).updateOptions,o=e(R.ONBOARDING_STORE_NAME).invalidateResolutionForStoreSelector;return{clearTaskStatusCache:function(){return o("getTasksStatus")},createNotice:t,updateOptions:n}})))(oe);function re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var ae=[{title:Object(_.__)("Add manually (recommended)",'kkart'),content:Object(_.__)("For small stores we recommend adding products manually",'kkart'),before:Object(b.createElement)("i",{className:"material-icons-outlined"},"add_box"),after:Object(b.createElement)("i",{className:"material-icons-outlined"},"chevron_right"),onClick:function(){return Object(A.recordEvent)("tasklist_add_product",{method:"manually"})},href:Object(D.f)("post-new.php?post_type=product&kkart_onboarding_active_task=products&tutorial=true")},{title:Object(_.__)("Import",'kkart'),content:Object(_.__)("For larger stores we recommend importing all products at once via CSV file",'kkart'),before:Object(b.createElement)("i",{className:"material-icons-outlined"},"import_export"),after:Object(b.createElement)("i",{className:"material-icons-outlined"},"chevron_right"),onClick:function(){return Object(A.recordEvent)("tasklist_add_product",{method:"import"})},href:Object(D.f)("edit.php?post_type=product&page=product_importer&kkart_onboarding_active_task=product-import")},{title:Object(_.__)("Migrate",'kkart'),content:Object(_.__)("For stores currently selling elsewhere we suggest using a product migration service",'kkart'),before:Object(b.createElement)("i",{className:"material-icons-outlined"},"cloud_download"),after:Object(b.createElement)("i",{className:"material-icons-outlined"},"chevron_right"),onClick:function(){return Object(A.recordEvent)("tasklist_add_product",{method:"migrate"})},href:"https://kkart.com/products/cart2cart/",target:"_blank"}],ie=function(e){u()(n,e);var t=re(n);function n(){return a()(this,n),t.apply(this,arguments)}return s()(n,[{key:"render",value:function(){return Object(b.createElement)(b.Fragment,null,Object(b.createElement)(x.Card,{className:"kkart-task-card"},Object(b.createElement)(x.List,{items:ae})))}}]),n}(b.Component),se=n(38),le=n.n(se),ue=n(42),me=n.n(ue),pe=n(1),de=n.n(pe);function he(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var be=function(e){u()(o,e);var t,n=he(o);function o(e){var t;return a()(this,o),(t=n.call(this,e)).state={isConnecting:!1},t.connectJetpack=t.connectJetpack.bind(K()(t)),e.setIsPending(!0),t}return s()(o,[{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.createNotice,o=t.error,c=t.isRequesting,r=t.onError,a=t.setIsPending;e.isRequesting&&!c&&a(!1),o&&o!==e.error&&(r&&r(),n("error",o))}},{key:"connectJetpack",value:(t=H()(V.a.mark((function e(){var t,n,o;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.props,n=t.jetpackConnectUrl,o=t.onConnect,this.setState({isConnecting:!0},(function(){o&&o(),window.location=n}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"render",value:function(){var e=this.props,t=e.hasErrors,n=e.isRequesting,o=e.onSkip,c=e.skipText,r=e.onAbort,a=e.abortText;return Object(b.createElement)(b.Fragment,null,t?Object(b.createElement)(y.a,{isPrimary:!0,onClick:function(){return window.location.reload()}},Object(_.__)("Retry",'kkart')):Object(b.createElement)(y.a,{disabled:n,isBusy:this.state.isConnecting,isPrimary:!0,onClick:this.connectJetpack},Object(_.__)("Connect",'kkart')),o&&Object(b.createElement)(y.a,{onClick:o},c||Object(_.__)("No thanks",'kkart')),r&&Object(b.createElement)(y.a,{onClick:r},a||Object(_.__)("Abort",'kkart')))}}]),o}(b.Component);be.propTypes={createNotice:de.a.func.isRequired,error:de.a.string,hasErrors:de.a.bool,isRequesting:de.a.bool,jetpackConnectUrl:de.a.string,onConnect:de.a.func,onError:de.a.func,onSkip:de.a.func,redirectUrl:de.a.string,skipText:de.a.string,setIsPending:de.a.func,onAbort:de.a.func,abortText:de.a.string},be.defaultProps={setIsPending:function(){}};var _e=Object(f.a)(Object(S.withSelect)((function(e,t){var n=e(R.PLUGINS_STORE_NAME),o=n.getJetpackConnectUrl,c=n.isPluginsRequesting,r=n.getPluginsError,a={redirect_url:t.redirectUrl||window.location.href},i=c("getJetpackConnectUrl");return{error:r("getJetpackConnectUrl")||"",isRequesting:i,jetpackConnectUrl:o(a)}})),Object(S.withDispatch)((function(e){return{createNotice:e("core/notices").createNotice}})))(be),fe=n(785);function ge(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function Oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(n),!0).forEach((function(t){W()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ge(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ye(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var ve=function(e){u()(o,e);var t,n=ye(o);function o(){var e;return a()(this,o),(e=n.apply(this,arguments)).onSubmit=e.onSubmit.bind(K()(e)),e}return s()(o,[{key:"onSubmit",value:(t=H()(V.a.mark((function e(t){var n,o,c,r,a,i;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.props,o=n.onComplete,c=n.createNotice,r=n.isSettingsError,a=n.updateAndPersistSettingsForGroup,i=n.settings,e.next=3,a("general",{general:Oe(Oe({},i),{},{kkart_store_address:t.addressLine1,kkart_store_address_2:t.addressLine2,kkart_default_country:t.countryState,kkart_store_city:t.city,kkart_store_postcode:t.postCode})});case 3:r?c("error",Object(_.__)("There was a problem saving your store location.",'kkart')):o(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getInitialValues",value:function(){var e=this.props.settings;return{addressLine1:e.kkart_store_address||"",addressLine2:e.kkart_store_address_2||"",city:e.kkart_store_city||"",countryState:e.kkart_default_country||"",postCode:e.kkart_store_postcode||""}}},{key:"render",value:function(){return this.props.isSettingsRequesting?null:Object(b.createElement)(x.Form,{initialValues:this.getInitialValues(),onSubmitCallback:this.onSubmit,validate:fe.b},(function(e){var t=e.getInputProps,n=e.handleSubmit,o=e.setValue;return Object(b.createElement)(b.Fragment,null,Object(b.createElement)(fe.a,{getInputProps:t,setValue:o}),Object(b.createElement)(y.a,{isPrimary:!0,onClick:n},Object(_.__)("Continue",'kkart')))}))}}]),o}(b.Component),ke=n(821),je=n(762);function we(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var Se=function(e){u()(o,e);var t,n=we(o);function o(){var e;return a()(this,o),(e=n.apply(this,arguments)).updateShippingZones=e.updateShippingZones.bind(K()(e)),e}return s()(o,[{key:"getShippingMethods",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e&&e.methods&&Array.isArray(e.methods)?t?e.methods?e.methods.filter((function(e){return e.method_id===t})):[]:e.methods:[]}},{key:"disableShippingMethods",value:function(e,t){t.length&&t.forEach((function(t){$()({method:"POST",path:"/kkart/v3/shipping/zones/".concat(e.id,"/methods/").concat(t.instance_id),data:{enabled:!1}})}))}},{key:"updateShippingZones",value:(t=H()(V.a.mark((function e(t){var n,o,c,r,a,i,s=this;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.props,o=n.clearTaskStatusCache,c=n.createNotice,r=n.shippingZones,a=!1,i=!1,r.forEach((function(e){0===e.id?a=e.toggleable&&t["".concat(e.id,"_enabled")]:i=""!==t["".concat(e.id,"_rate")]&&parseFloat(t["".concat(e.id,"_rate")])!==parseFloat(0);var n=s.getShippingMethods(e),o=parseFloat(t["".concat(e.id,"_rate")])===parseFloat(0)?"free_shipping":"flat_rate",c=s.getShippingMethods(e,o).length?s.getShippingMethods(e,o)[0]:null;if(!e.toggleable||t["".concat(e.id,"_enabled")]){if(c){var r=n.filter((function(e){return e.instance_id!==c.instance_id}));s.disableShippingMethods(e,r)}$()({method:"POST",path:c?"/kkart/v3/shipping/zones/".concat(e.id,"/methods/").concat(c.instance_id):"/kkart/v3/shipping/zones/".concat(e.id,"/methods"),data:{method_id:o,enabled:!0,settings:{cost:t["".concat(e.id,"_rate")]}}})}else s.disableShippingMethods(e,n)})),Object(A.recordEvent)("tasklist_shipping_set_costs",{shipping_cost:i,rest_world:a}),o(),c("success",Object(_.__)("Your shipping rates have been updated.",'kkart')),this.props.onComplete();case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"renderInputPrefix",value:function(){var e=this.context.getCurrencyConfig(),t=e.symbolPosition,n=e.symbol;return 0===t.indexOf("right")?null:Object(b.createElement)("span",{className:"kkart-shipping-rate__control-prefix"},n)}},{key:"renderInputSuffix",value:function(e){var t=this.context.getCurrencyConfig(),n=t.symbolPosition,o=t.symbol;return 0===n.indexOf("right")?Object(b.createElement)("span",{className:"kkart-shipping-rate__control-suffix"},o):parseFloat(e)===parseFloat(0)?Object(b.createElement)("span",{className:"kkart-shipping-rate__control-suffix"},Object(_.__)("Free shipping",'kkart')):null}},{key:"getFormattedRate",value:function(e){var t=this.context.formatDecimalString,n=t(e);return e.length&&n.length?t(e):t(0)}},{key:"getInitialValues",value:function(){var e=this,t=this.context.formatDecimalString,n={};return this.props.shippingZones.forEach((function(o){var c=e.getShippingMethods(o),r=c.length&&c[0].settings.cost?e.getFormattedRate(c[0].settings.cost.value):t(0);n["".concat(o.id,"_rate")]=r,c.length&&c[0].enabled?n["".concat(o.id,"_enabled")]=!0:n["".concat(o.id,"_enabled")]=!1})),n}},{key:"validate",value:function(e){var t={};return Object.keys(e).filter((function(e){return e.endsWith("_rate")})).forEach((function(n){e[n]<0&&(t[n]=Object(_.__)("Shipping rates can not be negative numbers.",'kkart'))})),t}},{key:"render",value:function(){var e=this,t=this.props,n=t.buttonText,o=t.shippingZones;return o.length?Object(b.createElement)(x.Form,{initialValues:this.getInitialValues(),onSubmitCallback:this.updateShippingZones,validate:this.validate},(function(t){var c=t.getInputProps,r=t.handleSubmit,a=t.setTouched,i=t.setValue,s=t.values;return Object(b.createElement)(b.Fragment,null,Object(b.createElement)("div",{className:"kkart-shipping-rates"},o.map((function(t){return Object(b.createElement)("div",{className:"kkart-shipping-rate",key:t.id},Object(b.createElement)("div",{className:"kkart-shipping-rate__icon"},t.locations?t.locations.map((function(e){return Object(b.createElement)(x.Flag,{size:24,code:e.code,key:e.code})})):Object(b.createElement)("i",{className:"material-icons-outlined"},"public")),Object(b.createElement)("div",{className:"kkart-shipping-rate__main"},t.toggleable?Object(b.createElement)("label",{htmlFor:"kkart-shipping-rate__toggle-".concat(t.id),className:"kkart-shipping-rate__name"},t.name,Object(b.createElement)(ke.a,le()({id:"kkart-shipping-rate__toggle-".concat(t.id)},c("".concat(t.id,"_enabled"))))):Object(b.createElement)("div",{className:"kkart-shipping-rate__name"},t.name),(!t.toggleable||s["".concat(t.id,"_enabled")])&&Object(b.createElement)(x.TextControlWithAffixes,le()({label:Object(_.__)("Shipping cost",'kkart'),required:!0},c("".concat(t.id,"_rate")),{onBlur:function(){a("".concat(t.id,"_rate")),i("".concat(t.id,"_rate"),e.getFormattedRate(s["".concat(t.id,"_rate")]))},prefix:e.renderInputPrefix(),suffix:e.renderInputSuffix(s["".concat(t.id,"_rate")]),className:"muriel-input-text kkart-shipping-rate__control-wrapper"}))))}))),Object(b.createElement)(y.a,{isPrimary:!0,onClick:r},n||Object(_.__)("Update",'kkart')))})):null}}]),o}(b.Component);Se.propTypes={buttonText:de.a.string,onComplete:de.a.func.isRequired,createNotice:de.a.func.isRequired,shippingZones:de.a.array},Se.defaultProps={shippingZones:[]},Se.contextType=je.a;var Ee=Object(f.a)(Object(S.withDispatch)((function(e){var t=e(R.ONBOARDING_STORE_NAME).invalidateResolutionForStoreSelector;return{clearTaskStatusCache:function(){return t("getTasksStatus")}}})))(Se),Ce=n(776);function Pe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var Ne=function(e){u()(o,e);var t,n=Pe(o);function o(e){var t;return a()(this,o),(t=n.call(this,e)).initialState={isPending:!1,step:"store_location",shippingZones:[]},t.activePlugins=e.activePlugins,t.state=t.initialState,t.completeStep=t.completeStep.bind(K()(t)),t}return s()(o,[{key:"componentDidMount",value:function(){this.reset()}},{key:"reset",value:function(){this.setState(this.initialState)}},{key:"fetchShippingZones",value:(t=H()(V.a.mark((function e(){var t,n,o,c,r,a,i;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({isPending:!0}),t=this.props,n=t.countryCode,o=t.countryName,c=[],e.next=5,$()({path:"/kkart/v3/shipping/zones"});case 5:return r=e.sent,a=!1,e.next=9,Promise.all(r.map(function(){var e=H()(V.a.mark((function e(t){return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==t.id){e.next=8;break}return e.next=3,$()({path:"/kkart/v3/shipping/zones/".concat(t.id,"/methods")});case 3:return t.methods=e.sent,t.name=Object(_.__)("Rest of the world",'kkart'),t.toggleable=!0,c.push(t),e.abrupt("return");case 8:return e.next=10,$()({path:"/kkart/v3/shipping/zones/".concat(t.id,"/locations")});case 10:if(t.locations=e.sent,!t.locations.find((function(e){return n===e.code}))){e.next=18;break}return e.next=15,$()({path:"/kkart/v3/shipping/zones/".concat(t.id,"/methods")});case 15:t.methods=e.sent,c.push(t),a=!0;case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 9:if(a){e.next=17;break}return e.next=12,$()({method:"POST",path:"/kkart/v3/shipping/zones",data:{name:o}});case 12:return i=e.sent,e.next=15,$()({method:"POST",path:"/kkart/v3/shipping/zones/".concat(i.id,"/locations"),data:[{code:n,type:"country"}]});case 15:i.locations=e.sent,c.push(i);case 17:c.reverse(),this.setState({isPending:!1,shippingZones:c});case 19:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"componentDidUpdate",value:function(e,t){var n=this.props,o=n.countryCode,c=n.settings,r=c.kkart_store_address,a=c.kkart_default_country,i=c.kkart_store_postcode,s=this.state.step;"rates"!==s||e.countryCode===o&&"rates"===t.step||this.fetchShippingZones();var l=Boolean(r&&a&&i);"store_location"===s&&l&&this.completeStep()}},{key:"completeStep",value:function(){var e=this.props.createNotice,t=this.state.step,n=this.getSteps(),o=n.findIndex((function(e){return e.key===t})),c=n[o+1];c?this.setState({step:c.key}):(e("success",Object(_.__)("📦 Shipping is done! Don't worry, you can always change it later.",'kkart')),Object(T.getHistory)().push(Object(T.getNewPath)({},"/",{})))}},{key:"getPluginsToActivate",value:function(){var e=this.props.countryCode,t=[];return["GB","CA","AU"].includes(e)?t.push("kkart-shipstation-integration"):"US"===e&&(t.push("kkart-services"),t.push("jetpack")),Object(N.difference)(t,this.activePlugins)}},{key:"getSteps",value:function(){var e=this,t=this.props,n=t.countryCode,o=t.isJetpackConnected,c=this.getPluginsToActivate(),r=!o&&"US"===n,a=[{key:"store_location",label:Object(_.__)("Set store location",'kkart'),description:Object(_.__)("The address from which your business operates",'kkart'),content:Object(b.createElement)(ve,le()({},this.props,{onComplete:function(t){var n=Object(L.b)(t.countryState);Object(A.recordEvent)("tasklist_shipping_set_location",{country:n}),e.completeStep()}})),visible:!0},{key:"rates",label:Object(_.__)("Set shipping costs",'kkart'),description:Object(_.__)("Define how much customers pay to ship to different destinations",'kkart'),content:Object(b.createElement)(Ee,le()({buttonText:c.length||r?Object(_.__)("Proceed",'kkart'):Object(_.__)("Complete task",'kkart'),shippingZones:this.state.shippingZones,onComplete:this.completeStep},this.props)),visible:!0},{key:"label_printing",label:Object(_.__)("Enable shipping label printing",'kkart'),description:c.includes("kkart-shipstation-integration")?me()({mixedString:Object(_.__)("We recommend using ShipStation to save time at the post office by printing your shipping labels at home. Try ShipStation free for 30 days. {{link}}Learn more{{/link}}.",'kkart'),components:{link:Object(b.createElement)(x.Link,{href:"https://kkart.com/products/shipstation-integration",target:"_blank",type:"external"})}}):Object(_.__)("With Kkart Shipping and Jetpack you can save time at the Post Office by printing your shipping labels at home",'kkart'),content:Object(b.createElement)(x.Plugins,le()({onComplete:function(t,n){Object(Ce.a)(n),Object(A.recordEvent)("tasklist_shipping_label_printing",{install:!0,plugins_to_activate:c}),e.completeStep()},onError:function(e,t){return Object(Ce.a)(t)},onSkip:function(){Object(A.recordEvent)("tasklist_shipping_label_printing",{install:!1,plugins_to_activate:c}),Object(T.getHistory)().push(Object(T.getNewPath)({},"/",{}))},pluginSlugs:c},this.props)),visible:c.length},{key:"connect",label:Object(_.__)("Connect your store",'kkart'),description:Object(_.__)("Connect your store to WordPress.com to enable label printing",'kkart'),content:Object(b.createElement)(_e,le()({redirectUrl:Object(D.f)("admin.php?page=kkart-admin"),completeStep:this.completeStep},this.props,{onConnect:function(){Object(A.recordEvent)("tasklist_shipping_connect_store")}})),visible:r}];return Object(N.filter)(a,(function(e){return e.visible}))}},{key:"render",value:function(){var e=this.state,t=e.isPending,n=e.step,o=this.props.isUpdateSettingsRequesting;return Object(b.createElement)("div",{className:"kkart-task-shipping"},Object(b.createElement)(x.Card,{className:"is-narrow"},Object(b.createElement)(x.Stepper,{isPending:t||o,isVertical:!0,currentStep:n,steps:this.getSteps()})))}}]),o}(b.Component),xe=Object(f.a)(Object(S.withSelect)((function(e){var t=e(R.SETTINGS_STORE_NAME),n=t.getSettings,o=t.isUpdateSettingsRequesting,c=e(R.PLUGINS_STORE_NAME),r=c.getActivePlugins,a=c.isJetpackConnected,i=n("general").general,s=void 0===i?{}:i,l=Object(L.b)(s.kkart_default_country),u=Object(D.g)("dataEndpoints",{}).countries,m=l?(void 0===u?[]:u).find((function(e){return e.code===l})):null,p=m?m.name:null,d=r();return{countryCode:l,countryName:p,isUpdateSettingsRequesting:o("general"),settings:s,activePlugins:d,isJetpackConnected:a()}})),Object(S.withDispatch)((function(e){return{createNotice:e("core/notices").createNotice,updateAndPersistSettingsForGroup:e(R.SETTINGS_STORE_NAME).updateAndPersistSettingsForGroup}})))(Ne);function Te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function Re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Te(Object(n),!0).forEach((function(t){W()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ae(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var Ie=function(e){u()(o,e);var t,n=Ae(o);function o(e){var t;a()(this,o),t=n.call(this,e);var c=e.hasCompleteAddress,r=e.pluginsToActivate;return t.initialState={isPending:!1,stepIndex:c?1:0,cachedPluginsToActivate:r},t.state=t.initialState,t.completeStep=t.completeStep.bind(K()(t)),t}return s()(o,[{key:"componentDidMount",value:function(){this.reset()}},{key:"reset",value:function(){this.setState(this.initialState)}},{key:"shouldShowSuccessScreen",value:function(){var e=this.props,t=e.isJetpackConnected,n=e.hasCompleteAddress,o=e.pluginsToActivate;return n&&!o.length&&t&&this.isTaxJarSupported()}},{key:"isTaxJarSupported",value:function(){var e=this.props,t=e.countryCode,n=e.tasksStatus,o=n.automatedTaxSupportedCountries,c=void 0===o?[]:o;return!n.taxJarActivated&&c.includes(t)}},{key:"completeStep",value:function(){var e=this.state.stepIndex;this.getSteps()[e+1]&&this.setState({stepIndex:e+1})}},{key:"manuallyConfigureTaxRates",value:(t=H()(V.a.mark((function e(){var t,n,o,c=this;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.props,n=t.generalSettings,o=t.updateAndPersistSettingsForGroup,"yes"!==n.kkart_calc_taxes?(this.setState({isPending:!0}),o("general",{general:Re(Re({},n),{},{kkart_calc_taxes:"yes"})}).then((function(){return c.redirectToTaxSettings()})).catch((function(e){return Object(Ce.a)(e)}))):this.redirectToTaxSettings();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateAutomatedTax",value:function(e){var t=this,n=this.props,o=n.clearTaskStatusCache,c=n.createNotice,r=n.updateAndPersistSettingsForGroup,a=n.generalSettings,i=n.taxSettings;Promise.all([r("tax",{tax:Re(Re({},i),{},{kkart_connect_taxes_enabled:e?"yes":"no"})}),r("general",{general:Re(Re({},a),{},{kkart_calc_taxes:"yes"})})]).then((function(){o(),e?(c("success",Object(_.__)("You're awesome! One less item on your to-do list ✅",'kkart')),Object(T.getHistory)().push(Object(T.getNewPath)({},"/",{}))):t.redirectToTaxSettings()})).catch((function(){c("error",Object(_.__)("There was a problem updating your tax settings.",'kkart'))}))}},{key:"redirectToTaxSettings",value:function(){window.location=Object(D.f)("admin.php?page=kkart-settings&tab=tax§ion=standard&kkart_onboarding_active_task=tax")}},{key:"doNotChargeSalesTax",value:function(){var e=this.props.updateOptions;Object(A.queueRecordEvent)("tasklist_tax_connect_store",{connect:!1,no_tax:!0}),e({kkart_no_sales_tax:!0,kkart_calc_taxes:"no"}).then((function(){window.location=Object(D.f)("admin.php?page=kkart-admin")}))}},{key:"getSteps",value:function(){var e=this,t=this.props,n=t.generalSettings,o=t.isJetpackConnected,c=t.isPending,r=t.tosAccepted,a=t.updateOptions,i=this.state.cachedPluginsToActivate,s=[{key:"store_location",label:Object(_.__)("Set store location",'kkart'),description:Object(_.__)("The address from which your business operates",'kkart'),content:Object(b.createElement)(ve,le()({},this.props,{onComplete:function(t){var n=Object(L.b)(t.countryState);Object(A.recordEvent)("tasklist_tax_set_location",{country:n}),e.completeStep()},isSettingsRequesting:!1,settings:n})),visible:!0},{key:"plugins",label:Object(_.__)("Install Jetpack and Kkart Tax",'kkart'),description:Object(_.__)("Jetpack and Kkart Tax allow you to automate sales tax calculations",'kkart'),content:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(x.Plugins,{onComplete:function(t,n){Object(Ce.a)(n),Object(A.recordEvent)("tasklist_tax_install_extensions",{install_extensions:!0}),a({kkart_setup_jetpack_opted_in:!0}),e.completeStep()},onError:function(e,t){return Object(Ce.a)(t)},onSkip:function(){Object(A.queueRecordEvent)("tasklist_tax_install_extensions",{install_extensions:!1}),e.manuallyConfigureTaxRates()},skipText:Object(_.__)("Set up tax rates manually",'kkart'),onAbort:function(){return e.doNotChargeSalesTax()},abortText:Object(_.__)("My business doesn't charge sales tax",'kkart')}),!r&&Object(b.createElement)(v.a,{variant:"caption",className:"kkart-task__caption"},me()({mixedString:Object(_.__)("By installing Jetpack and Kkart Tax you agree to the {{link}}Terms of Service{{/link}}.",'kkart'),components:{link:Object(b.createElement)(x.Link,{href:"https://wordpress.com/tos/",target:"_blank",type:"external"})}}))),visible:(i.length||!r)&&this.isTaxJarSupported()},{key:"connect",label:Object(_.__)("Connect your store",'kkart'),description:Object(_.__)("Connect your store to WordPress.com to enable automated sales tax calculations",'kkart'),content:Object(b.createElement)(_e,le()({},this.props,{onConnect:function(){Object(A.recordEvent)("tasklist_tax_connect_store",{connect:!0,no_tax:!1})},onSkip:function(){Object(A.queueRecordEvent)("tasklist_tax_connect_store",{connect:!1,no_tax:!1}),e.manuallyConfigureTaxRates()},skipText:Object(_.__)("Set up tax rates manually",'kkart'),onAbort:function(){return e.doNotChargeSalesTax()},abortText:Object(_.__)("My business doesn't charge sales tax",'kkart')})),visible:!o&&this.isTaxJarSupported()},{key:"manual_configuration",label:Object(_.__)("Configure tax rates",'kkart'),description:Object(_.__)("Head over to the tax rate settings screen to configure your tax rates",'kkart'),content:Object(b.createElement)(b.Fragment,null,Object(b.createElement)(y.a,{disabled:c,isPrimary:!0,isBusy:c,onClick:function(){Object(A.recordEvent)("tasklist_tax_config_rates"),e.manuallyConfigureTaxRates()}},Object(_.__)("Configure",'kkart')),Object(b.createElement)("p",null,"yes"!==n.kkart_calc_taxes&&me()({mixedString:Object(_.__)('By clicking "Configure" you\'re enabling tax rates and calculations. More info {{link}}here{{/link}}.','kkart'),components:{link:Object(b.createElement)(x.Link,{href:"https://docs.kkart.com/document/setting-up-taxes-in-kkart/#section-1",target:"_blank",type:"external"})}}))),visible:!this.isTaxJarSupported()}];return Object(N.filter)(s,(function(e){return e.visible}))}},{key:"renderSuccessScreen",value:function(){var e=this,t=this.props.isPending;return Object(b.createElement)("div",{className:"kkart-task-tax__success"},Object(b.createElement)("span",{className:"kkart-task-tax__success-icon",role:"img","aria-labelledby":"kkart-task-tax__success-message"},"🎊"),Object(b.createElement)(x.H,{id:"kkart-task-tax__success-message"},Object(_.__)("Good news!",'kkart')),Object(b.createElement)("p",null,me()({mixedString:Object(_.__)("{{strong}}Jetpack{{/strong}} and {{strong}}Kkart Tax{{/strong}} can automate your sales tax calculations for you.",'kkart'),components:{strong:Object(b.createElement)("strong",null)}})),Object(b.createElement)(y.a,{disabled:t,isPrimary:!0,isBusy:t,onClick:function(){Object(A.recordEvent)("tasklist_tax_setup_automated_proceed",{setup_automatically:!0}),e.updateAutomatedTax(!0)}},Object(_.__)("Yes please",'kkart')),Object(b.createElement)(y.a,{disabled:t,isBusy:t,onClick:function(){Object(A.recordEvent)("tasklist_tax_setup_automated_proceed",{setup_automatically:!1}),e.updateAutomatedTax(!1)}},Object(_.__)("No thanks, I'll configure taxes manually",'kkart')),Object(b.createElement)(y.a,{disabled:t,isBusy:t,onClick:function(){return e.doNotChargeSalesTax()}},Object(_.__)("My business doesn't charge sales tax",'kkart')))}},{key:"render",value:function(){var e=this.state.stepIndex,t=this.props,n=t.isPending,o=t.isResolving,c=this.getSteps()[e];return Object(b.createElement)("div",{className:"kkart-task-tax"},Object(b.createElement)(x.Card,{className:"is-narrow"},this.shouldShowSuccessScreen()?this.renderSuccessScreen():Object(b.createElement)(x.Stepper,{isPending:n||o,isVertical:!0,currentStep:c.key,steps:this.getSteps()})))}}]),o}(b.Component),Me=Object(f.a)(Object(S.withSelect)((function(e){var t=e(R.SETTINGS_STORE_NAME),n=t.getSettings,o=t.isUpdateSettingsRequesting,c=e(R.OPTIONS_STORE_NAME).getOption,r=e(R.PLUGINS_STORE_NAME),a=r.getActivePlugins,i=r.isJetpackConnected,s=r.isPluginsRequesting,l=e(R.ONBOARDING_STORE_NAME).getTasksStatus,u=n("general").general,m=void 0===u?{}:u,p=Object(L.b)(m.kkart_default_country),d=m.kkart_store_address,h=m.kkart_default_country,b=m.kkart_store_postcode,_=Boolean(d&&h&&b),f=n("tax").tax,g=void 0===f?{}:f,O=a(),y=Object(N.difference)(["jetpack","kkart-services"],O),v=(c("kkart_connect_options")||{}).tos_accepted||c("kkart_setup_jetpack_opted_in"),k=l(),j=o("tax")||o("general"),w=s("getJetpackConnectUrl");return{countryCode:p,generalSettings:m,hasCompleteAddress:_,isJetpackConnected:i(),isPending:j,isResolving:w,pluginsToActivate:y,tasksStatus:k,taxSettings:g,tosAccepted:v}})),Object(S.withDispatch)((function(e){var t=e("core/notices").createNotice,n=e(R.OPTIONS_STORE_NAME).updateOptions,o=e(R.SETTINGS_STORE_NAME).updateAndPersistSettingsForGroup,c=e(R.ONBOARDING_STORE_NAME).invalidateResolutionForStoreSelector;return{clearTaskStatusCache:function(){return c("getTasksStatus")},createNotice:t,updateAndPersistSettingsForGroup:o,updateOptions:n}})))(Ie),De=n(792);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function Fe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach((function(t){W()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ue(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var Be=function(e){u()(c,e);var t,n,o=Ue(c);function c(e){var t;a()(this,c),t=o.apply(this,arguments);var n=e.methods,r={};return n.forEach((function(e){return r[e.key]=e.isEnabled})),t.state={busyMethod:null,enabledMethods:r,recommendedMethod:t.getRecommendedMethod()},t.markConfigured=t.markConfigured.bind(K()(t)),t}return s()(c,[{key:"componentDidUpdate",value:function(){var e=this.state.recommendedMethod,t=this.getRecommendedMethod();e!==t&&this.setState({recommendedMethod:t})}},{key:"getRecommendedMethod",value:function(){return this.props.methods.find((function(e){return"wcpay"===e.key&&e.visible}))?"wcpay":"stripe"}},{key:"markConfigured",value:function(e){var t=this.props.clearTaskStatusCache,n=this.state.enabledMethods;this.setState({enabledMethods:Fe(Fe({},n),{},W()({},e,!0))}),t(),Object(A.recordEvent)("tasklist_payment_connect_method",{payment_method:e}),Object(T.getHistory)().push(Object(T.getNewPath)({task:"payments"},"/",{}))}},{key:"getCurrentMethod",value:function(){var e=this.props,t=e.methods,n=e.query;if(n.method)return t.find((function(e){return e.key===n.method}))}},{key:"getInstallStep",value:function(){var e=this.getCurrentMethod();if(e.plugins&&e.plugins.length){var t=this.props.activePlugins,n=e.plugins.filter((function(e){return!t.includes(e)})),o=e.plugins.map((function(e){return R.pluginNames[e]})).join(" "+Object(_.__)("and",'kkart')+" ");return{key:"install",label:Object(_.sprintf)(Object(_.__)("Install %s",'kkart'),o),content:Object(b.createElement)(x.Plugins,{onComplete:function(t,n){Object(Ce.a)(n),Object(A.recordEvent)("tasklist_payment_install_method",{plugins:e.plugins})},onError:function(e,t){return Object(Ce.a)(t)},autoInstall:!0,pluginSlugs:e.plugins}),isComplete:!n.length}}}},{key:"toggleMethod",value:(n=H()(V.a.mark((function e(t){var n,o,c,r,a,i,s;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.props,o=n.clearTaskStatusCache,c=n.methods,r=n.options,a=n.updateOptions,i=this.state.enabledMethods,s=c.find((function(e){return e.key===t})),i[t]=!i[t],this.setState({enabledMethods:i}),Object(A.recordEvent)("tasklist_payment_toggle",{enabled:!s.isEnabled,payment_method:t}),e.next=8,a(W()({},s.optionName,Fe(Fe({},r[s.optionName]),{},{enabled:s.isEnabled?"no":"yes"})));case 8:o();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"handleClick",value:(t=H()(V.a.mark((function e(t){var n,o,c,r=this;return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.props.methods,o=t.key,c=t.onClick,Object(A.recordEvent)("tasklist_payment_setup",{options:n.map((function(e){return e.key})),selected:o}),!c){e.next=8;break}return this.setState({busyMethod:o}),e.next=7,new Promise(c).then((function(){r.setState({busyMethod:null})})).catch((function(){r.setState({busyMethod:null})}));case 7:return e.abrupt("return");case 8:Object(T.updateQueryString)({method:o});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"render",value:function(){var e=this,t=this.getCurrentMethod(),n=this.state,o=n.busyMethod,c=n.enabledMethods,r=n.recommendedMethod,a=this.props,i=a.methods,s=a.query;return t?Object(b.createElement)(x.Card,{className:"kkart-task-payment-method is-narrow"},Object(b.cloneElement)(t.container,{query:s,installStep:this.getInstallStep(),markConfigured:this.markConfigured,hasCbdIndustry:t.hasCbdIndustry})):Object(b.createElement)("div",{className:"kkart-task-payments"},i.map((function(t){var n=t.before,a=t.container,i=t.content,s=t.isConfigured,l=t.key,u=t.title;if(!t.visible)return null;var m=O()("kkart-task-payment","is-narrow",!s&&"kkart-task-payment-not-configured","kkart-task-payment-"+l),p=l===r&&!s,d=p&&"wcpay"!==l,h=p&&"wcpay"===l;return Object(b.createElement)(x.Card,{key:l,className:m},Object(b.createElement)("div",{className:"kkart-task-payment__before"},d&&Object(b.createElement)("div",{className:"kkart-task-payment__recommended-ribbon"},Object(b.createElement)("span",null,Object(_.__)("Recommended",'kkart'))),n),Object(b.createElement)("div",{className:"kkart-task-payment__text"},Object(b.createElement)(x.H,{className:"kkart-task-payment__title"},u,h&&Object(b.createElement)("span",{className:"kkart-task-payment__recommended-pill"},Object(_.__)("Recommended",'kkart'))),Object(b.createElement)("div",{className:"kkart-task-payment__content"},i)),Object(b.createElement)("div",{className:"kkart-task-payment__after"},a&&!s?Object(b.createElement)(y.a,{isPrimary:l===r,isSecondary:l!==r,isBusy:o===l,disabled:o,onClick:function(){return e.handleClick(t)}},Object(_.__)("Set up",'kkart')):Object(b.createElement)(ke.a,{checked:c[l],onChange:function(){return e.toggleMethod(l)},onClick:function(e){return e.stopPropagation()}})))})))}}]),c}(b.Component),qe=Object(f.a)(Object(S.withDispatch)((function(e){var t=e("core/notices").createNotice,n=e(R.PLUGINS_STORE_NAME).installAndActivatePlugins,o=e(R.OPTIONS_STORE_NAME).updateOptions,c=e(R.ONBOARDING_STORE_NAME),r=c.invalidateResolution,a=c.invalidateResolutionForStoreSelector;return r("getProfileItems",[]),r("getTasksStatus",[]),{clearTaskStatusCache:function(){return a("getTasksStatus")},createNotice:t,installAndActivatePlugins:n,updateOptions:o}})),Object(S.withSelect)((function(e,t){var n=t.createNotice,o=t.installAndActivatePlugins,c=e(R.ONBOARDING_STORE_NAME).getProfileItems,r=e(R.OPTIONS_STORE_NAME).getOption,a=e(R.PLUGINS_STORE_NAME),i=a.getActivePlugins,s=a.isJetpackConnected,l=(0,e(R.SETTINGS_STORE_NAME).getSettings)("general").general,u=void 0===l?{}:l,m=e(R.ONBOARDING_STORE_NAME).getTasksStatus,p=i(),d=m(),h=c(),b=["kkart_kkart_payments_settings","kkart_stripe_settings","kkart_ppec_paypal_settings","kkart_payfast_settings","kkart_square_credit_card_settings","kkart_klarna_payments_settings","kkart_kco_settings","kkart_square_refresh_tokens","kkart_cod_settings","kkart_bacs_settings","kkart_bacs_accounts","kkart_eway_settings"].reduce((function(e,t){return e[t]=r(t),e}),{}),_=Object(L.b)(u.kkart_default_country);return{countryCode:_,profileItems:h,activePlugins:p,options:b,methods:Object(De.a)({activePlugins:p,countryCode:_,createNotice:n,installAndActivatePlugins:o,isJetpackConnected:s(),onboardingStatus:d,options:b,profileItems:h})}})))(Be);function Je(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function Ge(e,t,n,o){Object(A.recordEvent)("task_view",{task_name:e,wcs_installed:o.includes("kkart-services"),wcs_active:n.includes("kkart-services"),jetpack_installed:o.includes("jetpack"),jetpack_active:n.includes("jetpack"),jetpack_connected:t})}function Ve(e){var t=e.activePlugins,n=e.countryCode,o=e.createNotice,c=e.installAndActivatePlugins,r=e.installedPlugins,a=e.isJetpackConnected,i=e.onboardingStatus,s=e.profileItems,l=e.query,u=e.toggleCartModal,m=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Je(Object(n),!0).forEach((function(t){W()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Je(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({hasPaymentGateway:!1,hasPhysicalProducts:!1,hasProducts:!1,isAppearanceComplete:!1,isTaxComplete:!1,shippingZonesCount:0,wcPayIsConnected:!1},i),p=m.hasPaymentGateway,d=m.hasPhysicalProducts,h=m.hasProducts,f=m.isAppearanceComplete,g=m.isTaxComplete,O=m.shippingZonesCount,y=m.wcPayIsConnected,v=Object(L.a)(s,r),k=v.products,j=v.remainingProducts,w=v.uniqueItemsList,S=-1!==r.indexOf("kkart-payments"),E=s.completed,C=s.product_types,P=Object(_.__)("Purchase & install extensions");if(1===w.length){var N=w[0],x=N.name,R="theme"===N.type?Object(_.__)("Purchase & install %s theme",'kkart'):Object(_.__)("Purchase & install %s extension",'kkart');P=Object(_.sprintf)(R,x)}var I,M=[{key:"store_details",title:Object(_.__)("Store details",'kkart'),container:null,onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"store_details"}),Object(T.getHistory)().push(Object(T.getNewPath)({},"/setup-wizard",{}))},completed:E,visible:!0,time:Object(_.__)("4 minutes",'kkart')},{key:"purchase",title:P,container:null,onClick:function(){return Object(A.recordEvent)("tasklist_click",{task_name:"purchase"}),j.length?u():null},visible:k.length,completed:k.length&&!j.length,time:Object(_.__)("2 minutes",'kkart'),isDismissable:!0},{key:"products",title:Object(_.__)("Add my products",'kkart'),container:Object(b.createElement)(ie,null),onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"products"}),Object(T.updateQueryString)({task:"products"})},completed:h,visible:!0,time:Object(_.__)("1 minute per product",'kkart')},{key:"kkart-payments",title:Object(_.__)("Set up Kkart Payments",'kkart'),container:Object(b.createElement)(b.Fragment,null),completed:y,onClick:(I=H()(V.a.mark((function e(n){return V.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("A"!==n.target.nodeName){e.next=2;break}return e.abrupt("return",!1);case 2:return e.next=4,new Promise((function(e,n){return Ge("wcpay",a,t,r),Object(A.recordEvent)("tasklist_click",{task_name:"kkart-payments"}),Object(De.b)(e,n,o,c)}));case 4:case"end":return e.stop()}}),e)}))),function(e){return I.apply(this,arguments)}),visible:window.wcAdminFeatures.wcpay&&S&&"US"===n,additionalInfo:Object(_.__)('By setting up, you are agreeing to the <a href="https://wordpress.com/tos/" target="_blank">Terms of Service</a>','kkart'),time:Object(_.__)("2 minutes",'kkart')},{key:"payments",title:Object(_.__)("Set up payments",'kkart'),container:Object(b.createElement)(qe,null),completed:p,onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"payments"}),Object(T.updateQueryString)({task:"payments"})},visible:!S||"US"!==n,time:Object(_.__)("2 minutes",'kkart')},{key:"tax",title:Object(_.__)("Set up tax",'kkart'),container:Object(b.createElement)(Me,null),onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"tax"}),Object(T.updateQueryString)({task:"tax"})},completed:g,visible:!0,time:Object(_.__)("1 minute",'kkart')},{key:"shipping",title:Object(_.__)("Set up shipping",'kkart'),container:Object(b.createElement)(xe,null),onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"shipping"}),Object(T.updateQueryString)({task:"shipping"})},completed:O>0,visible:C&&C.includes("physical")||d,time:Object(_.__)("1 minute",'kkart')},{key:"appearance",title:Object(_.__)("Personalize my store",'kkart'),container:Object(b.createElement)(ce,null),onClick:function(){Object(A.recordEvent)("tasklist_click",{task_name:"appearance"}),Object(T.updateQueryString)({task:"appearance"})},completed:f,visible:!0,time:Object(_.__)("2 minutes",'kkart')}];return Object(Q.applyFilters)("kkart_admin_onboarding_task_list",M.sort((function(e,t){return e.completed===t.completed?0:e.completed?1:-1})),l)}function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=h()(e);if(t){var c=h()(this).constructor;n=Reflect.construct(o,arguments,c)}else n=o.apply(this,arguments);return p()(this,n)}}var He=function(e){u()(n,e);var t=ze(n);function n(e){var o;return a()(this,n),(o=t.call(this,e)).state={isCartModalOpen:!1},o}return s()(n,[{key:"componentDidMount",value:function(){document.body.classList.add("kkart-onboarding"),document.body.classList.add("kkart-task-dashboard__body"),this.recordTaskView(),this.recordTaskListView(),this.possiblyCompleteTaskList(),this.possiblyTrackCompletedTasks()}},{key:"componentDidUpdate",value:function(e){var t=this.props.query;e.query.task!==t.task&&(window.document.documentElement.scrollTop=0,this.recordTaskView()),this.possiblyCompleteTaskList(),this.possiblyTrackCompletedTasks()}},{key:"possiblyCompleteTaskList",value:function(){var e=this.props,t=e.isTaskListComplete,n=e.updateOptions;this.getIncompleteTasks().length||t||n({kkart_task_list_complete:"yes",kkart_default_homepage_layout:"two_columns"})}},{key:"getCompletedTaskKeys",value:function(){return this.getVisibleTasks().filter((function(e){return e.completed})).map((function(e){return e.key}))}},{key:"getIncompleteTasks",value:function(){return this.getAllTasks().filter((function(e){return e.visible&&!e.completed}))}},{key:"possiblyTrackCompletedTasks",value:function(){var e=this.props,t=e.trackedCompletedTasks,n=e.updateOptions,o=this.getCompletedTaskKeys();0!==Object(N.xor)(t,o).length&&n({kkart_task_list_tracked_completed_tasks:o})}},{key:"dismissTask",value:function(e){var t=this,n=this.props,o=n.createNotice,r=n.dismissedTasks,a=n.updateOptions;o("success",Object(_.__)("Task dismissed"),{actions:[{label:Object(_.__)("Undo",'kkart'),onClick:function(){return t.undoDismissTask(e)}}]}),Object(A.recordEvent)("tasklist_dismiss_task",{task_name:e}),a({kkart_task_list_dismissed_tasks:[].concat(c()(r),[e])})}},{key:"undoDismissTask",value:function(e){var t=this.props,n=t.dismissedTasks;(0,t.updateOptions)({kkart_task_list_dismissed_tasks:n.filter((function(t){return t!==e}))})}},{key:"componentWillUnmount",value:function(){document.body.classList.remove("kkart-onboarding"),document.body.classList.remove("kkart-task-dashboard__body")}},{key:"getAllTasks",value:function(){var e=this.props;return Ve({activePlugins:e.activePlugins,countryCode:e.countryCode,createNotice:e.createNotice,installAndActivatePlugins:e.installAndActivatePlugins,installedPlugins:e.installedPlugins,isJetpackConnected:e.isJetpackConnected,onboardingStatus:e.onboardingStatus,profileItems:e.profileItems,query:e.query,toggleCartModal:this.toggleCartModal.bind(this)})}},{key:"getVisibleTasks",value:function(){var e=this.props.dismissedTasks;return this.getAllTasks().filter((function(t){return t.visible&&!e.includes(t.key)}))}},{key:"recordTaskView",value:function(){var e=this.props,t=e.isJetpackConnected,n=e.activePlugins,o=e.installedPlugins,c=e.query.task;c&&Ge(c,t,n,o)}},{key:"recordTaskListView",value:function(){if(!this.getCurrentTask()){var e=this.props.profileItems,t=this.getVisibleTasks();Object(A.recordEvent)("tasklist_view",{number_tasks:t.length,store_connected:e.wccom_connected})}}},{key:"hideTaskCard",value:function(e){Object(A.recordEvent)("tasklist_completed",{action:e,completed_task_count:this.getCompletedTaskKeys().length,incomplete_task_count:this.getIncompleteTasks().length}),this.props.updateOptions({kkart_task_list_hidden:"yes",kkart_task_list_prompt_shown:!0,kkart_default_homepage_layout:"two_columns"})}},{key:"getCurrentTask",value:function(){var e=this.props.query.task,t=this.getAllTasks().find((function(t){return t.key===e}));return t||null}},{key:"renderMenu",value:function(){var e=this;return Object(b.createElement)("div",{className:"kkart-card__menu kkart-card__header-item"},Object(b.createElement)(x.EllipsisMenu,{label:Object(_.__)("Task List Options",'kkart'),renderContent:function(){return Object(b.createElement)("div",{className:"kkart-task-card__section-controls"},Object(b.createElement)(y.a,{onClick:function(){return e.hideTaskCard("remove_card")}},Object(_.__)("Hide this",'kkart')))}}))}},{key:"toggleCartModal",value:function(){var e=this.state.isCartModalOpen;e||Object(A.recordEvent)("tasklist_purchase_extensions"),this.setState({isCartModalOpen:!e})}},{key:"render",value:function(){var e=this,t=this.props.query,n=this.state.isCartModalOpen,o=this.getCurrentTask(),c=this.getVisibleTasks().map((function(t){return t.className=O()(t.completed?"is-complete":null,t.className),t.before=Object(b.createElement)("div",{className:"kkart-task__icon"},t.completed&&Object(b.createElement)(E.a,{icon:P})),t.title=Object(b.createElement)(v.a,{as:"div",variant:t.completed?"body.small":"button"},t.title,t.additionalInfo&&Object(b.createElement)("div",{className:"kkart-task__additional-info",dangerouslySetInnerHTML:Object(F.a)(t.additionalInfo)}),t.time&&!t.completed&&Object(b.createElement)("div",{className:"kkart-task__estimated-time"},t.time)),!t.completed&&t.isDismissable&&(t.after=Object(b.createElement)(y.a,{"data-testid":"".concat(t.key,"-dismiss-button"),isTertiary:!0,onClick:function(n){n.stopPropagation(),e.dismissTask(t.key)}},Object(_.__)("Dismiss",'kkart'))),t.onClick||(t.onClick=function(e){if("A"===e.target.nodeName)return!1;Object(T.updateQueryString)({task:t.key})}),t}));return Object(b.createElement)(b.Fragment,null,Object(b.createElement)("div",{className:"kkart-task-dashboard__container"},o?Object(b.cloneElement)(o.container,{query:t}):Object(b.createElement)(b.Fragment,null,Object(b.createElement)(k.a,{size:"large",className:"kkart-task-card kkart-homescreen-card"},Object(b.createElement)(j.a,{size:"medium"},Object(b.createElement)("div",{className:"wooocommerce-task-card__header"},Object(b.createElement)(v.a,{variant:"title.small"},Object(_.__)("Finish setup",'kkart')),Object(b.createElement)(x.Badge,{count:this.getIncompleteTasks().length})),this.renderMenu()),Object(b.createElement)(w.a,null,Object(b.createElement)(x.List,{items:c}))))),n&&Object(b.createElement)(J,{onClose:function(){return e.toggleCartModal()},onClickPurchaseLater:function(){return e.toggleCartModal()}}))}}]),n}(b.Component);t.default=Object(f.a)(Object(S.withSelect)((function(e){var t=e(R.ONBOARDING_STORE_NAME),n=t.getProfileItems,o=t.getTasksStatus,c=e(R.OPTIONS_STORE_NAME).getOption,r=e(R.SETTINGS_STORE_NAME).getSettings,a=e(R.PLUGINS_STORE_NAME),i=a.getActivePlugins,s=a.getInstalledPlugins,l=a.isJetpackConnected,u=n(),m="yes"===c("kkart_task_list_complete"),p=c("kkart_task_list_tracked_completed_tasks")||[],d=c("kkart_task_list_dismissed_tasks")||[],h=r("general").general,b=void 0===h?{}:h,_=Object(L.b)(b.kkart_default_country),f=i(),g=s(),O=o();return{activePlugins:f,countryCode:_,dismissedTasks:d,isJetpackConnected:l(),installedPlugins:g,isTaskListComplete:m,onboardingStatus:O,profileItems:u,trackedCompletedTasks:p}})),Object(S.withDispatch)((function(e){var t=e("core/notices").createNotice,n=e(R.OPTIONS_STORE_NAME).updateOptions;return{createNotice:t,installAndActivatePlugins:e(R.PLUGINS_STORE_NAME).installAndActivatePlugins,updateOptions:n}})))(He)},98:function(e,t){function n(e,t,n,o,c,r,a){try{var i=e[r](a),s=i.value}catch(e){return void n(e)}i.done?t(s):Promise.resolve(s).then(o,c)}e.exports=function(e){return function(){var t=this,o=arguments;return new Promise((function(c,r){var a=e.apply(t,o);function i(e){n(a,c,r,i,s,"next",e)}function s(e){n(a,c,r,i,s,"throw",e)}i(void 0)}))}}}}]);