JezK
Edit File: settings.js
(globalThis.webpackChunksnapchat_for_woocommerce=globalThis.webpackChunksnapchat_for_woocommerce||[]).push([[472],{4848:(e,t,n)=>{"use strict";t.A=function(e){var t=e.size,n=void 0===t?24:t,o=e.onClick,s=(e.icon,e.className),i=function(e,t){if(null==e)return{};var n,o,c=function(e,t){if(null==e)return{};var n,o,c={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],0<=t.indexOf(n)||(c[n]=e[n]);return c}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}(e,r),l=["gridicon","gridicons-checkmark-circle",s,!1,!1,!1].filter(Boolean).join(" ");return c.default.createElement("svg",a({className:l,height:n,width:n,onClick:o},i,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}),c.default.createElement("g",null,c.default.createElement("path",{d:"M11 17.768l-4.884-4.884 1.768-1.768L11 14.232l8.658-8.658A9.98 9.98 0 0012 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10a9.94 9.94 0 00-.966-4.266L11 17.768z"})))};var o,c=(o=n(1609))&&o.__esModule?o:{default:o},r=["size","onClick","icon","className"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)}},6942:(e,t)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function c(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=a(e,r(n)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return c.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)o.call(e,n)&&e[n]&&(t=a(t,n));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(c.default=c,e.exports=c):void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},8052:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>F});var o=n(7723),c=n(6087),r=n(6476),a=n(14),s=n(8523),i=n(7892),l=n(6028),u=n(8242),d=n(9956),m=n(6427),f=n(9457),h=n(7792),p=n(7162);const _="all-accounts",w="snapchat-account";var g=n(790);const v={[_]:{title:(0,o.__)("Disconnect all accounts","snapchat-for-woocommerce"),confirmButton:(0,o.__)("Disconnect all accounts","snapchat-for-woocommerce"),confirmation:(0,o.__)("Yes, I want to disconnect all my accounts.","snapchat-for-woocommerce"),contents:[(0,o.__)("I understand that I am disconnecting any WordPress.com account and Snapchat account connected to this extension.","snapchat-for-woocommerce"),(0,o.__)("Lorem ipsum","snapchat-for-woocommerce"),(0,o.__)("Dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.","snapchat-for-woocommerce")]},[w]:{title:(0,o.__)("Disconnect Snapchat account","snapchat-for-woocommerce"),confirmButton:(0,o.__)("Disconnect Snapchat Account","snapchat-for-woocommerce"),confirmation:(0,o.__)("Yes, I want to disconnect my Snapchat account.","snapchat-for-woocommerce"),contents:[(0,o.__)("I understand that I am disconnecting my Snapchat account from this WooCommerce extension.","snapchat-for-woocommerce"),(0,o.__)("Some configurations for Snapchat created through WooCommerce may be lost. This cannot be undone.","snapchat-for-woocommerce")]}};function x({disconnectTarget:e,onRequestClose:t,onDisconnected:n,disconnectAction:r}){const[a,s]=(0,c.useState)(!1),[l,u]=(0,c.useState)(!1),d=(0,p.j)(),{title:w,confirmButton:x,confirmation:y,contents:b}=v[e],j=()=>{l||t()};return(0,g.jsxs)(f.A,{className:"sfw-disconnect-accounts-modal",title:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(h.A,{size:20}),w]}),isDismissible:!l,buttons:[(0,g.jsx)(i.A,{isSecondary:!0,disabled:l,onClick:j,children:(0,o.__)("Never mind","snapchat-for-woocommerce")},"1"),(0,g.jsx)(i.A,{isPrimary:!0,isDestructive:!0,loading:l,disabled:!a,onClick:()=>{let o=e===_?d.disconnectAllAccounts:d.disconnectSnapchatAccount;r&&(o=r),u(!0),o().then(()=>{n(),t()}).catch(()=>{u(!1)})},eventName:"sfw_disconnect_snapchat_confirm_modal_button_click",children:x},"2")],onRequestClose:j,children:[b.map((e,t)=>(0,g.jsx)("p",{children:e},t)),(0,g.jsx)(m.CheckboxControl,{label:y,checked:a,disabled:l,onChange:s})]})}function y(e){return(0,g.jsx)(x,{...e})}var b=n(6473);function j(){const{hasFinishedResolution:e}=(0,s.A)(),[t,n]=(0,c.useState)(null);return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)(y,{onRequestClose:()=>n(null),onDisconnected:()=>{(0,b.Rv)("sfw_disconnected_accounts",{context:t}),window.location.reload()},disconnectTarget:t}),!e&&(0,g.jsx)(l.A,{}),e&&(0,g.jsx)(d.L4,{hideAccountSwitch:!0,children:(0,g.jsx)(u.A.Card.Footer,{children:(0,g.jsx)(i.A,{isDestructive:!0,isLink:!0,onClick:()=>n(w),eventName:"sfw_disconnect_snapchat_button_click",children:(0,o.__)("Disconnect Snapchat account","snapchat-for-woocommerce")})})})]})}var C=n(3905),S=n(2482),k=n(873);const{exportNonce:A}=C.nP;var P=n(5640);const{exportNonce:O}=C.nP,E=()=>{const{shouldTriggerExport:e,lastExportTimeStamp:t,exportFileUrl:n,hasFinishedResolution:r}=(0,k.A)(),[a,s]=(0,c.useState)("1"===C.nP.isExportInProgress),[l,u]=(0,c.useState)(C.nP.exportFileUrl||null),[d,f]=(0,c.useState)(C.nP.lastTimestamp||null),h=l&&d,{generateCsv:p}=((e,t)=>{const{createNotice:n}=(0,P.A)();return{generateCsv:(0,c.useCallback)(async()=>{try{const c=await window.jQuery.post(window.ajaxurl,{action:"snapchat_for_woocommerce_generate_feed",security:O});if(c.success)return void e();if(!c.success&&"snapchat_for_woocommerce_no_products_found"===c.data?.code)return void n("error",(0,o.__)("No products found. Please create products to generate the CSV.","snapchat-for-woocommerce"));n("error",(0,o.__)("An error occurred","snapchat-for-woocommerce")),t()}catch(e){n("error",(0,o.sprintf)( // translators: %s: The error message returned from the CSV generation process. // translators: %s: The error message returned from the CSV generation process. (0,o.__)("CSV generation failed: %s","snapchat-for-woocommerce"),e.message)),t()}},[n,e,t])}})(()=>{s(!0)},()=>{s(!1),u(null),f(null)}),_=()=>{p()},w=(0,c.useCallback)(e=>{const{status:t}=e;switch(t){case"idle":s(!1);break;case"completed":s(!1),u(e.fileUrl),f(e.lastExport);break;case"in-progress":s(!0)}},[]);return((e,t)=>{const n=(0,c.useRef)(null),o=(0,c.useRef)(!1);(0,c.useEffect)(()=>{const c=async()=>{try{const e=await window.jQuery.post(window.ajaxurl,{action:"snapchat_for_woocommerce_export_status",security:A});e&&t(e)}catch(e){}};return e&&!n.current&&(o.current||(o.current=!0,c()),n.current=setInterval(c,5e3)),!e&&n.current&&(clearInterval(n.current),n.current=null,o.current=!1),()=>{n.current&&(clearInterval(n.current),n.current=null),o.current=!1}},[e,t])})(a,w),(0,c.useEffect)(()=>{a&&(u(null),f(null))},[a]),(0,c.useEffect)(()=>{e&&r&&p()},[e,r]),(0,c.useEffect)(()=>{t&&f(t),n&&u(n)},[t,n]),(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(S.A,{className:"sfw-product-catalog",title:(0,o.__)("Export Product Catalog","snapchat-for-woocommerce"),description:a?(0,o.__)("We’re generating your CSV file… This may take a few seconds.","snapchat-for-woocommerce"):d?(0,o.sprintf)( // translators: %s: The date and time when the product catalog was last exported. // translators: %s: The date and time when the product catalog was last exported. (0,o.__)("Last exported on %s.","snapchat-for-woocommerce"),d):(0,o.__)("Your product catalog is not synced to Snapchat yet. Generate a CSV to manually upload.","snapchat-for-woocommerce"),indicator:h?(0,g.jsx)(m.Flex,{spacing:4,wrap:"wrap",children:(0,g.jsx)(i.A,{variant:"secondary",onClick:_,loading:a,eventName:"sfw_regenerate_csv_button_click",eventProps:{context:"settings"},children:(0,o.__)("Regenerate CSV","snapchat-for-woocommerce")})}):(0,g.jsx)(i.A,{variant:"secondary",onClick:_,loading:a,eventName:"sfw_generate_csv_button_click",eventProps:{context:"settings"},children:(0,o.__)("Generate CSV","snapchat-for-woocommerce")}),children:d&&!l&&(0,g.jsx)("div",{className:"sfw-product-catalog__help",children:(0,g.jsx)("p",{children:(0,o.__)('The CSV file may have been deleted and could not be found. Click "Generate CSV" to regenerate a new one.',"snapchat-for-woocommerce")})})})})},I=()=>{const{capiEnabled:e,collectPii:t,hasFinishedResolution:n}=(0,k.A)(),[r,a]=(0,c.useState)(!1),{createNotice:s}=(0,P.A)(),{updateSettings:i}=(0,p.j)(),u=(0,c.useCallback)(async()=>{const{settings:{capiEnabled:t}}=await i({capiEnabled:!e});(0,b.Sf)("sfw_conversion_tracking_toggle",{status:t?"on":"off"})},[i,e]),d=(0,c.useCallback)(async()=>{const{settings:{collectPii:e}}=await i({collectPii:!t});(0,b.Sf)("sfw_collect_pii_toggle",{status:e?"on":"off"})},[i,t]);return n?(0,g.jsx)(S.A,{className:"sfw-settings-track-conversions",title:(0,o.__)("Conversions API","snapchat-for-woocommerce"),description:(0,o.__)("Send server-side conversion events to improve attribution.","snapchat-for-woocommerce"),actions:(0,g.jsxs)("div",{className:"sfw-settings-track-conversions__actions",children:[(0,g.jsx)("p",{children:(0,g.jsx)(m.CheckboxControl,{label:(0,o.__)("Enable Conversions API tracking","snapchat-for-woocommerce"),checked:e,disabled:r,onChange:async()=>{try{a(!0),await u(),s("success",(0,o.__)("Conversions API Tracking status updated successfully.","snapchat-for-woocommerce"))}catch(e){}finally{a(!1)}}})}),(0,g.jsx)("p",{children:(0,g.jsx)(m.CheckboxControl,{label:(0,o.__)("Collect Customer PII","snapchat-for-woocommerce"),checked:t,disabled:r,onChange:async()=>{try{a(!0),await d(),s("success",(0,o.__)("Collect PII status updated successfully.","snapchat-for-woocommerce"))}catch(e){}finally{a(!1)}},help:(0,o.__)("Share additional customer data (PII) with both Pixel and Conversions API events to improve ads measurement.","snapchat-for-woocommerce")})})]})}):(0,g.jsx)(l.A,{})};var N=n(5659),T=n(3666),D=n(2465);const F=()=>{(0,a.A)();const{isConnected:e,hasFinishedResolution:t}=(0,s.A)(),n="success"===(0,r.getQuery)()?.onboarding;return(0,c.useEffect)(()=>{!e&&t&&(0,r.getHistory)().replace((0,T.xP)())},[e,t]),(0,g.jsxs)("div",{className:"sfw-settings",children:[n&&(0,g.jsx)(N.A,{}),C.nP.isLegacyPluginActive&&(0,g.jsx)(u.A,{children:(0,g.jsx)(D.A,{})}),(0,g.jsx)(u.A,{title:(0,o.__)("Product Catalog","snapchat-for-woocommerce"),children:(0,g.jsx)(E,{})}),(0,g.jsx)(u.A,{title:(0,o.__)("Track Conversions","snapchat-for-woocommerce"),description:(0,o.__)("Manage how conversions are tracked on your site.","snapchat-for-woocommerce"),children:(0,g.jsx)(I,{})}),(0,g.jsx)(u.A,{title:(0,o.__)("Manage Snapchat Connection","snapchat-for-woocommerce"),description:(0,o.__)("See your currently connected account or disconnect.","snapchat-for-woocommerce"),children:(0,g.jsx)(j,{})})]})}},9031:(e,t,n)=>{"use strict";t.A=function(e){var t=e.size,n=void 0===t?24:t,o=e.onClick,s=(e.icon,e.className),i=function(e,t){if(null==e)return{};var n,o,c=function(e,t){if(null==e)return{};var n,o,c={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],0<=t.indexOf(n)||(c[n]=e[n]);return c}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}(e,r),l=["gridicon","gridicons-notice-outline",s,!!function(e){return 0==e%18}(n)&&"needs-offset",!1,!1].filter(Boolean).join(" ");return c.default.createElement("svg",a({className:l,height:n,width:n,onClick:o},i,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"}),c.default.createElement("g",null,c.default.createElement("path",{d:"M12 4c4.411 0 8 3.589 8 8s-3.589 8-8 8-8-3.589-8-8 3.589-8 8-8m0-2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 13h-2v2h2v-2zm-2-2h2l.5-6h-3l.5 6z"})))};var o,c=(o=n(1609))&&o.__esModule?o:{default:o},r=["size","onClick","icon","className"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)}}}]);