Files
woocommerce-subscriptions/build/gifting-welcome-announcement.js
2025-09-02 10:17:52 +00:00

1 line
6.5 KiB
JavaScript

(()=>{"use strict";var e,o={20:(e,o,t)=>{var i=t(609),n=Symbol.for("react.element"),s=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function a(e,o,t){var i,a={},d=null,l=null;for(i in void 0!==t&&(d=""+t),void 0!==o.key&&(d=""+o.key),void 0!==o.ref&&(l=o.ref),o)s.call(o,i)&&!c.hasOwnProperty(i)&&(a[i]=o[i]);if(e&&e.defaultProps)for(i in o=e.defaultProps)void 0===a[i]&&(a[i]=o[i]);return{$$typeof:n,type:e,key:d,ref:l,props:a,_owner:r.current}}o.jsx=a,o.jsxs=a},338:(e,o,t)=>{var i=t(795);o.H=i.createRoot,i.hydrateRoot},609:e=>{e.exports=window.React},736:(e,o,t)=>{var i=t(609),n=t(338);const s=window.wp.components,r=window.wp.element,c=window.wp.primitives,a=(0,r.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(c.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})),d=window.wp.i18n,l=window.wp.apiFetch;var m=t.n(l),p=t(848);const u=({imagesPath:e,redirectUrl:o,data:t,dismissOption:n,isSubscriptionsListing:r})=>{const[c,l]=(0,i.useState)(r),u=(0,i.useRef)(!1),{headerImage:w,heading:h,description:_,primaryButton:b,secondaryButton:g}=t,f=()=>{if(u.current)return;const e="?page=wc-admin"===window.location.search;l(e)};(0,i.useEffect)((()=>{if(r)return;const{pushState:e,replaceState:o}=window.history;window.history.pushState=function(...o){e.apply(window.history,o),window.dispatchEvent(new Event("pushState"))},window.history.replaceState=function(...e){o.apply(window.history,e),window.dispatchEvent(new Event("replaceState"))},window.addEventListener("popstate",f),window.addEventListener("replaceState",f),window.addEventListener("pushState",f),f()}),[]);const v=e=>{var t;t=n,m()({path:`/wc/v3/subscriptions/settings/${t}`,method:"post",data:{value:true}}),u.current=!0,"done-btn"!==e?(l(!1),window.removeEventListener("popstate",f),window.removeEventListener("replaceState",f),window.removeEventListener("pushState",f)):window.location.href=o};return c?(0,p.jsx)("div",{className:"woocommerce-subscriptions-announcement",children:(0,p.jsx)("div",{className:"woocommerce-subscriptions-announcement__container",children:(0,p.jsxs)(s.Card,{className:"woocommerce-tour-kit-step",elevation:2,children:[(0,p.jsx)(s.CardHeader,{isBorderless:!0,size:"small",className:"woocommerce-tour-kit-step__header",children:(0,p.jsx)(s.Flex,{className:"woocommerce-tour-kit-step-controls",justify:"flex-end",children:(0,p.jsx)(s.Button,{className:"woocommerce-tour-kit-step-controls__close-btn",label:(0,d.__)("Close","woocommerce-subscriptions"),icon:(0,p.jsx)(s.Icon,{icon:a,viewBox:"6 4 12 14"}),iconSize:16,onClick:()=>v("close-btn")})})}),w&&(0,p.jsx)(s.CardMedia,{className:"woocommerce-tour-kit-step__header-image",children:(0,p.jsx)("img",{src:e+"/"+w,alt:(0,d.__)("Step image","woocommerce-subscriptions")})}),(0,p.jsxs)(s.CardBody,{className:"woocommerce-tour-kit-step__body",size:"small",children:[(0,p.jsx)("h2",{className:"woocommerce-tour-kit-step__heading",children:h}),(0,p.jsx)("p",{className:"woocommerce-tour-kit-step__description",dangerouslySetInnerHTML:{__html:_}})]}),(0,p.jsx)(s.CardFooter,{isBorderless:!0,size:"small",children:(0,p.jsx)("div",{className:"woocommerce-tour-kit-step-navigation",children:(0,p.jsxs)("div",{children:[(0,p.jsx)(s.Button,{className:"woocommerce-tour-kit-step-navigation__back-btn",variant:"tertiary",onClick:()=>v("close-btn"),children:g.text||(0,d.__)("Close","woocommerce-subscriptions")}),(0,p.jsx)(s.Button,{className:"woocommerce-tour-kit-step-navigation__next-btn",variant:"primary",disabled:b.isDisabled,onClick:()=>v("done-btn"),children:b.text||(0,d.__)("Done","woocommerce-subscriptions")})]})})})]})})}):null},w=(0,n.H)(document.getElementById("wcs-gifting-welcome-announcement-root")),h=(e=>{const o=e?(0,d.__)("Gifting is now part of WooCommerce Subscriptions","woocommerce-subscriptions"):(0,d.__)("Introducing subscription gifting","woocommerce-subscriptions"),t=e?`${(0,d.__)("No separate extension needed! The built-in gifting feature is fully compatible with product, cart and checkout blocks, plus you can now choose which subscription products can be gifted.","woocommerce-subscriptions")}\n\t\t\t<br /><br />\n\t\t\t${(0,d.__)("The Gifting for WooCommerce Subscriptions extension can now be disabled via Plugins.","woocommerce-subscriptions")}`:(0,d.__)("Let your shoppers purchase subscriptions as gifts using the new built-in gifting feature in WooCommerce Subscriptions. It works seamlessly with product, cart and checkout blocks, and can be enabled storewide or managed per product.","woocommerce-subscriptions"),i=e?(0,d.__)("Go to plugins","woocommerce-subscriptions"):(0,d.__)("Set up gifting","woocommerce-subscriptions");return{name:"gifting-announcement",heading:o,headerImage:"gifting-modal-icon.svg",description:t,secondaryButton:{text:(0,d.__)("Maybe later","woocommerce-subscriptions")},primaryButton:{text:i}}})(window.wcsGiftingSettings.isStandaloneGiftingEnabled),{imagesPath:_,pluginsUrl:b,subscriptionsUrl:g,isStandaloneGiftingEnabled:f,isSubscriptionsListing:v}=window.wcsGiftingSettings;w.render((0,p.jsx)(u,{imagesPath:_,data:h,dismissOption:"woocommerce_subscriptions_gifting_is_welcome_announcement_dismissed",redirectUrl:f?b:g,isSubscriptionsListing:!!v}))},795:e=>{e.exports=window.ReactDOM},848:(e,o,t)=>{e.exports=t(20)}},t={};function i(e){var n=t[e];if(void 0!==n)return n.exports;var s=t[e]={exports:{}};return o[e](s,s.exports,i),s.exports}i.m=o,e=[],i.O=(o,t,n,s)=>{if(!t){var r=1/0;for(l=0;l<e.length;l++){for(var[t,n,s]=e[l],c=!0,a=0;a<t.length;a++)(!1&s||r>=s)&&Object.keys(i.O).every((e=>i.O[e](t[a])))?t.splice(a--,1):(c=!1,s<r&&(r=s));if(c){e.splice(l--,1);var d=n();void 0!==d&&(o=d)}}return o}s=s||0;for(var l=e.length;l>0&&e[l-1][2]>s;l--)e[l]=e[l-1];e[l]=[t,n,s]},i.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return i.d(o,{a:o}),o},i.d=(e,o)=>{for(var t in o)i.o(o,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},i.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={716:0,601:0};i.O.j=o=>0===e[o];var o=(o,t)=>{var n,s,[r,c,a]=t,d=0;if(r.some((o=>0!==e[o]))){for(n in c)i.o(c,n)&&(i.m[n]=c[n]);if(a)var l=a(i)}for(o&&o(t);d<r.length;d++)s=r[d],i.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return i.O(l)},t=globalThis.webpackChunkwoocommerce_subscriptions=globalThis.webpackChunkwoocommerce_subscriptions||[];t.forEach(o.bind(null,0)),t.push=o.bind(null,t.push.bind(t))})();var n=i.O(void 0,[601],(()=>i(736)));n=i.O(n)})();