"use strict";(globalThis.webpackChunkesf_youtube_dashboard=globalThis.webpackChunkesf_youtube_dashboard||[]).push([[306],{818(e,a,t){t.d(a,{A:()=>l});var s=t(573),o=t(848);const l=(0,o.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(s.Path,{d:"m11.3 17.2-5-5c-.1-.1-.1-.3 0-.4l2.3-2.3-1.1-1-2.3 2.3c-.7.7-.7 1.8 0 2.5l5 5H7.5v1.5h5.3v-5.2h-1.5v2.6zm7.5-6.4-5-5h2.7V4.2h-5.2v5.2h1.5V6.8l5 5c.1.1.1.3 0 .4l-2.3 2.3 1.1 1.1 2.3-2.3c.6-.7.6-1.9-.1-2.5z"})})},579(e,a,t){t.d(a,{A:()=>o});var s=t(609);const o=({children:e,text:a})=>a?(0,s.createElement)("span",{className:"esf-youtube-tooltip","aria-label":a},e,(0,s.createElement)("span",{className:"esf-youtube-tooltip-text"},a)):e||null},306(e,a,t){t.r(a),t.d(a,{default:()=>d});var s=t(609),o=t(723),l=t(87),r=t(427),c=t(573),n=t(848);const i=(0,n.jsx)(c.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsx)(c.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"})});var u=t(818),b=t(579),_=t(685);const y=[{value:3600,label:(0,o.__)("Every 1 hour","easy-facebook-likebox")},{value:10800,label:(0,o.__)("Every 3 hours","easy-facebook-likebox")},{value:21600,label:(0,o.__)("Every 6 hours","easy-facebook-likebox")},{value:43200,label:(0,o.__)("Every 12 hours","easy-facebook-likebox")},{value:86400,label:(0,o.__)("Every 24 hours","easy-facebook-likebox")},{value:604800,label:(0,o.__)("Every 7 days","easy-facebook-likebox")}],f=()=>{if("undefined"==typeof window)return 43200;const e=window.esfYouTubeData?.youtubeSettings?.cache_duration,a=Number(e);return y.map(e=>e.value).includes(a)?a:43200},d=({addNotice:e})=>{const[a,t]=(0,l.useState)(f),[c,n]=(0,l.useState)(!1),[d,v]=(0,l.useState)(!1),m=(0,l.useCallback)(async()=>{n(!0);try{await(0,_.Xx)({cache_duration:a}),e((0,o.__)("Settings saved successfully.","easy-facebook-likebox"),"success")}catch(a){e(a?.message||(0,o.__)("Failed to save settings. Please try again.","easy-facebook-likebox"),"error")}finally{n(!1)}},[a,e]),h=(0,l.useCallback)(async()=>{v(!0);try{const a=await(0,_.IL)(),t="number"==typeof a?.deleted?a.deleted:0;e(t>0?(0,o.sprintf)(/* translators: %d: number of cache entries cleared */ /* translators: %d: number of cache entries cleared */
(0,o.__)("Cache cleared. %d item(s) removed.","easy-facebook-likebox"),t):(0,o.__)("Cache cleared. Fresh data will load on next visit.","easy-facebook-likebox"),"success")}catch(a){e(a?.message||(0,o.__)("Failed to clear cache. Please try again.","easy-facebook-likebox"),"error")}finally{v(!1)}},[e]),k=(0,l.useMemo)(()=>y.map(e=>({value:String(e.value),label:e.label})),[]);return(0,s.createElement)("div",{className:"esf-youtube-settings"},(0,s.createElement)("div",{className:"esf-youtube-settings__section"},(0,s.createElement)("div",{className:"esf-youtube-settings__row"},(0,s.createElement)("div",{className:"esf-youtube-settings__label-wrap"},(0,s.createElement)("label",{htmlFor:"esf-youtube-cache-duration",className:"esf-youtube-settings__label"},(0,o.__)("Caching","easy-facebook-likebox")),(0,s.createElement)(b.A,{text:(0,o.__)("How long feed data is stored before being refreshed from YouTube.","easy-facebook-likebox")},(0,s.createElement)("span",{className:"esf-youtube-settings__label-icon"},(0,s.createElement)(r.Icon,{icon:i,size:18})))),(0,s.createElement)("div",{className:"esf-youtube-settings__controls"},(0,s.createElement)(r.SelectControl,{id:"esf-youtube-cache-duration",value:String(a),options:k,onChange:e=>t(Number(e)),className:"esf-youtube-settings__select",hideLabelFromVision:!0}),(0,s.createElement)(r.Button,{variant:"secondary",isBusy:d,disabled:d,onClick:h,className:"esf-youtube-settings__btn-clear",icon:u.A,iconPosition:"left"},d?(0,o.__)("Clearing…","easy-facebook-likebox"):(0,o.__)("Clear All Caches","easy-facebook-likebox"))))),(0,s.createElement)("div",{className:"esf-youtube-settings__footer"},(0,s.createElement)(r.Button,{variant:"primary",isBusy:c,disabled:c,onClick:m,className:"esf-youtube-settings__btn-save"},c?(0,o.__)("Saving…","easy-facebook-likebox"):(0,o.__)("Save settings","easy-facebook-likebox"))))}},20(e,a,t){var s=t(609),o=Symbol.for("react.element"),l=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};a.jsx=function(e,a,t){var s,n={},i=null,u=null;for(s in void 0!==t&&(i=""+t),void 0!==a.key&&(i=""+a.key),void 0!==a.ref&&(u=a.ref),a)l.call(a,s)&&!c.hasOwnProperty(s)&&(n[s]=a[s]);if(e&&e.defaultProps)for(s in a=e.defaultProps)void 0===n[s]&&(n[s]=a[s]);return{$$typeof:o,type:e,key:i,ref:u,props:n,_owner:r.current}}},848(e,a,t){e.exports=t(20)}}]);