navasena/wp-content/plugins/woocommerce/assets/client/admin/chunks/shipping-recommendations.js

1 line
15 KiB
JavaScript
Raw Normal View History

2024-07-31 13:12:38 +07:00
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6125],{91462:(e,t,o)=>{o.r(t),o.d(t,{default:()=>O});var i=o(69307),n=o(9818),s=o(67221),c=o(24082),r=o(65736),m=o(55609),a=o(86020),l=o(10431),u=o(14599),p=o(46530),g=o(31815);const d=({isWCSInstalled:e})=>{const{layoutString:t}=(0,p.useLayoutContext)();return(0,i.createElement)("div",{className:"woocommerce-list__item-inner woocommerce-services-item"},(0,i.createElement)("div",{className:"woocommerce-list__item-before"},(0,i.createElement)("img",{className:"woocommerce-services-item__logo",src:g,alt:"WooCommerce Service Logo"})),(0,i.createElement)("div",{className:"woocommerce-list__item-text"},(0,i.createElement)("span",{className:"woocommerce-list__item-title"},(0,r.__)("WooCommerce Shipping","woocommerce"),(0,i.createElement)(a.Pill,null,(0,r.__)("Recommended","woocommerce"))),(0,i.createElement)("span",{className:"woocommerce-list__item-content"},(0,r.__)("Print USPS and DHL Express labels straight from your WooCommerce dashboard and save on shipping.","woocommerce"),(0,i.createElement)("br",null),(0,i.createElement)(m.ExternalLink,{href:"https://woocommerce.com/woocommerce-shipping/"},(0,r.__)("Learn more","woocommerce")))),(0,i.createElement)("div",{className:"woocommerce-list__item-after"},(0,i.createElement)(m.Button,{isSecondary:!0,onClick:()=>{(0,u.recordEvent)("tasklist_click",{task_name:"shipping-recommendation",context:`${t}/wc-settings`}),(0,l.navigateTo)({url:(0,l.getNewPath)({task:"shipping-recommendation"},"/",{})})}},e?(0,r.__)("Activate","woocommerce"):(0,r.__)("Get started","woocommerce"))))};var M=o(64760);const L="woocommerce_admin_reviewed_default_shipping_zones",h="woocommerce_admin_created_default_shipping_zones",S="woocommerce-settings-shipping-tour-floater-wrapper",N="woocommerce-settings-smart-defaults-shipping-tour-floater",E="table.wc-shipping-zones",_='a[href*="woocommerce-services-settings"]',j=e=>{const t=e.map((e=>{const t=document?.querySelector(e)?.getBoundingClientRect();if(!t)throw new Error("Shipping tour: Couldn't find element with selector: "+e);return t})),o=document.querySelector(`.${S}`)?.getBoundingClientRect()||{top:0,left:0},i=Math.min(...t.map((e=>e.top))),n=Math.min(...t.map((e=>e.left))),s=Math.max(...t.map((e=>e.right)))-n,c=Math.max(...t.map((e=>e.bottom)))-i,r=i-o.top;return{left:n-o.left,top:r,width:s,height:c}},y=({dims:e})=>(0,i.createElement)("div",{style:{position:"relative",pointerEvents:"none",...e},className:N}),w=[["th.wc-shipping-zone-sort","tfoot.wc-shipping-zone-worldwide tr > td.wc-shipping-zone-region"],["th.wc-shipping-zone-methods","tfoot.wc-shipping-zone-worldwide tr > td.wc-shipping-zone-methods"]],T=({step:e})=>{var t;const o=(0,i.useRef)(null);(0,i.useLayoutEffect)((()=>{o.current?.parentElement&&o.current.parentElement.insertBefore(o.current,document.querySelector("table.wc-shipping-zones"))}),[]);const n=null!==(t=w[e])&&void 0!==t?t:w[w.length-1],[s,c]=(0,i.useState)(j(n));(0,i.useEffect)((()=>{c(j(n));const e=new ResizeObserver((()=>{c(j(n))})),t=document.querySelector(E);if(!t)throw new Error("Shipping tour: Couldn't find shipping settings table element with selector: "+E);return e.observe(t),()=>{e.disconnect()}}),[n]);const r=document.querySelector(E)?.parentElement;if(!r)throw new Error("Shipping tour: Couldn't find shipping settings table parent element with selector: "+E);return(0,i.createPortal)((0,i.createElement)("div",{ref:o,className:S,style:{position:"absolute"}},(0,i.createElement)(y,{dims:s})),r)},I=({showShippingRecommendationsStep:e})=>{const{updateOptions:t}=(0,n.useDispatch)(s.OPTIONS_STORE_NAME),{show:o,isUspsDhlEligible:m}=(()=>{const{hasCreatedDefaultShippingZones:e,hasReviewedDefaultShippingOptions:t,businessCountry:o,isLoading:i}=(0,n.useSelect)((e=>{const{hasFinishedResolution:t,getOption:o}=e(s.OPTIONS_STORE_NAME);return{isLoading:!t("getOption",[h])&&!t("getOption",[L])&&!t("getOption",["woocommerce_default_country"]),hasCreatedDefaultShippingZones:"yes"===o(h),hasReviewedDefaultShippingOptions:"yes"==