File: /home/bohousj/www/wp-content/plugins/wordpress-seo-premium/assets/js/dist/ai-generator-2400.min.js
(()=>{var e={332:(e,t)=>{var s;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var n=typeof s;if("string"===n||"number"===n)e.push(s);else if(Array.isArray(s)){if(s.length){var o=a.apply(null,s);o&&e.push(o)}}else if("object"===n){if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]")){e.push(s.toString());continue}for(var i in s)r.call(s,i)&&s[i]&&e.push(i)}}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(s=function(){return a}.apply(t,[]))||(e.exports=s)}()}},t={};function s(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React,t=window.wp.components,r=window.wp.data,a=window.wp.domReady;var n=s.n(a);const o=window.wp.hooks,i=window.wp.i18n,l=window.yoast.uiLibrary,c=window.lodash,u=window.yoast.reduxJsToolkit,m="adminUrl",p=(0,u.createSlice)({name:m,initialState:"",reducers:{setAdminUrl:(e,{payload:t})=>t}}),d=p.getInitialState,y={selectAdminUrl:e=>(0,c.get)(e,m,"")};y.selectAdminLink=(0,u.createSelector)([y.selectAdminUrl,(e,t)=>t],((e,t)=>{try{return new URL(t,e).href}catch(t){return e}}));const g=p.actions,w=p.reducer,h=window.wp.apiFetch;var f=s.n(h);const E="hasConsent",v=`${E}/storeConsent`,b=(0,u.createSlice)({name:E,initialState:!1,reducers:{giveAiGeneratorConsent:(e,{payload:t})=>t}}),S=b.getInitialState,_={selectHasAiGeneratorConsent:e=>(0,c.get)(e,E,!1)},k={...b.actions,storeAiGeneratorConsent:function*(e){try{yield{type:v,payload:e}}catch(e){return!1}return yield{type:`${E}/giveAiGeneratorConsent`,payload:e},!0}},x={[v]:async({payload:e})=>await f()({path:"yoast/v1/ai_generator/consent",method:"POST",data:{consent:e},parse:!1})},C=b.reducer,N="pluginUrl",T=(0,u.createSlice)({name:N,initialState:"",reducers:{setPluginUrl:(e,{payload:t})=>t}}),R=(T.getInitialState,{selectPluginUrl:e=>(0,c.get)(e,N,"")});R.selectImageLink=(0,u.createSelector)([R.selectPluginUrl,(e,t,s="assets/images")=>s,(e,t)=>t],((e,t,s)=>[(0,c.trimEnd)(e,"/"),(0,c.trim)(t,"/"),(0,c.trimStart)(s,"/")].join("/"))),T.actions,T.reducer;const A=window.wp.url,P="linkParams",$=(0,u.createSlice)({name:P,initialState:{},reducers:{setLinkParams:(e,{payload:t})=>t}}),I=($.getInitialState,{selectLinkParam:(e,t,s={})=>(0,c.get)(e,`${P}.${t}`,s),selectLinkParams:e=>(0,c.get)(e,P,{})});I.selectLink=(0,u.createSelector)([I.selectLinkParams,(e,t)=>t],((e,t)=>(0,A.addQueryArgs)(t,e))),$.actions,$.reducer;const L="yoast-seo/editor",q="request",M="success",O="error",U="loading",F="wistiaEmbedPermission",B=(0,u.createSlice)({name:F,initialState:{value:!1,status:"idle",error:{}},reducers:{setWistiaEmbedPermissionValue:(e,{payload:t})=>{e.value=Boolean(t)}},extraReducers:e=>{e.addCase(`${F}/${q}`,(e=>{e.status=U})),e.addCase(`${F}/${M}`,((e,{payload:t})=>{e.status="success",e.value=Boolean(t&&t.value)})),e.addCase(`${F}/${O}`,((e,{payload:t})=>{e.status="error",e.value=Boolean(t&&t.value),e.error={code:(0,c.get)(t,"error.code",500),message:(0,c.get)(t,"error.message","Unknown")}}))}}),D=(B.getInitialState,B.actions,B.reducer,window.wp.element),G=window.yoast.propTypes;var Y=s.n(G);const W="yoast-seo-premium/ai-generator",z="google",H="social",j="twitter",V="title",K="description",X={post:"post",product:"product",attachment:"attachment",productCategory:"product_cat",productTag:"product_tag"},J="post",Q="term",Z={post:"title",term:"term_title"},ee=(0,c.mapValues)(Z,(e=>`%%${e}%%`)),te={mobile:"mobile",desktop:"desktop"},se={idle:"idle",loading:"loading",success:"success",error:"error"},re="success",ae="error",ne="abort",oe=window.yoast.analysis;let ie,le=!1;const ce=["_formal","_informal","_ao90"],ue=e=>{for(const t of ce)if(e.endsWith(t))return e.slice(0,-t.length);return e},me="\\–\\-\\(\\)_\\[\\]’‘“”〝〞〟‟„\"'.?!:;,¿¡«»‹›—×+&۔؟،؛。。!‼?⁇⁉⁈‥…・ー、〃〄〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟〠〶〼〽{}|~⦅⦆「」、[]・¥$%@&'()*/:;<>\\\<>";me.split(""),new RegExp("^["+me+"]+"),new RegExp("["+me+"]+$");const pe=new RegExp("["+me+"#$%&*+/=@^`{|}~ -¿–-⁊ -₠-⃀]","g"),de=e=>0===e.replace(pe,"").trim().length,ye={editType:V,previewType:z,postType:X.post,contentType:J},ge=(0,D.createContext)(ye),we=ge.Provider,he=()=>(0,D.useContext)(ge),fe=(0,c.get)(window,"yoast.editorModules.components.contexts.location.LocationContext",(0,D.createContext)("unknown")),Ee=()=>(0,D.useContext)(fe),ve=e=>{const t=(0,D.useRef)(null);return(0,D.useCallback)((s=>{(0,c.attempt)((()=>t.current&&t.current.disconnect())),null!==s&&(t.current=new ResizeObserver((t=>{(0,c.forEach)(t,(t=>e(t)))})),t.current.observe(s))}),[e])},be=(0,u.createSlice)({name:"suggestions",initialState:{status:se.loading,error:{code:200,message:""},entities:[],selected:""},reducers:{setLoading:e=>{e.status=se.loading},setSuccess:(e,{payload:t})=>{e.status=se.success,e.selected=t[0],e.entities.push(...t)},setError:(e,{payload:t})=>{e.status=se.error,e.error=t},setSelected:(e,{payload:t})=>{e.selected=t}}}),Se=e=>{switch(e){case H:return"Facebook";case j:return"Twitter";default:return"Google"}},_e=window.yoast.searchMetadataPreviews,ke=e.forwardRef((function(t,s){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},t),e.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"}))})),xe=e.forwardRef((function(t,s){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},t),e.createElement("path",{fillRule:"evenodd",d:"M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"}))}));Y().string.isRequired,Y().shape({src:Y().string.isRequired,width:Y().string,height:Y().string}).isRequired,Y().shape({value:Y().bool.isRequired,status:Y().string.isRequired,set:Y().func.isRequired}).isRequired,Y().string.isRequired,Y().shape({src:Y().string.isRequired,width:Y().string,height:Y().string}).isRequired,Y().shape({value:Y().bool.isRequired,status:Y().string.isRequired,set:Y().func.isRequired}).isRequired;const Ce=({href:t,children:s,...r})=>(0,e.createElement)(l.Link,{target:"_blank",rel:"noopener noreferrer",...r,href:t},s,(0,e.createElement)("span",{className:"yst-sr-only"},/* translators: Hidden accessibility text. */ /* translators: Hidden accessibility text. */
(0,i.__)("(Opens in a new browser tab)","wordpress-seo-premium")));Ce.propTypes={href:Y().string.isRequired,children:Y().node},Ce.defaultProps={children:null};window.yoast.reactHelmet;Y().string.isRequired,Y().shape({src:Y().string.isRequired,width:Y().string,height:Y().string}).isRequired,Y().shape({value:Y().bool.isRequired,status:Y().string.isRequired,set:Y().func.isRequired}).isRequired;const Ne=({onGiveConsent:t,learnMoreLink:s,privacyPolicyLink:r,termsOfServiceLink:a,imageLink:n})=>{const{onClose:o,initialFocus:c}=(0,l.useModalContext)(),[u,m]=(0,l.useToggleState)(!1),p=(0,D.useCallback)((()=>{o(),t()}),[t,o]),d=(0,D.useMemo)((()=>({src:n,width:"432",height:"244"})),[n]),y=(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s and %2$s are a set of anchor tags and %3$s and %4$s are a set of anchor tags. */ /* translators: %1$s and %2$s are a set of anchor tags and %3$s and %4$s are a set of anchor tags. */
(0,i.__)("I approve the %1$sTerms of Service%2$s & %3$sPrivacy Policy%4$s of the Yoast AI service. This includes consenting to the collection and use of data to improve user experience.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Ce,{href:a}),a2:(0,e.createElement)(Ce,{href:r})});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"yst-px-10 yst-pt-10 yst-introduction-gradient yst-text-center"},(0,e.createElement)("div",{className:"yst-relative yst-w-full"},(0,e.createElement)("img",{className:"yst-w-full yst-h-auto yst-rounded-md yst-drop-shadow-md",alt:"",loading:"lazy",decoding:"async",...d}))),(0,e.createElement)("div",{className:"yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center"},(0,e.createElement)("div",{className:"yst-mt-4 yst-mx-1.5 yst-text-center"},(0,e.createElement)("h3",{className:"yst-text-slate-900 yst-text-lg yst-font-medium"},(0,i.sprintf)(/* translators: %s expands to Yoast AI. */ /* translators: %s expands to Yoast AI. */
(0,i.__)("Grant consent for %s","wordpress-seo-premium"),"Yoast AI")),(0,e.createElement)("div",{className:"yst-mt-2 yst-text-slate-600 yst-text-sm"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s is a break tag; %2$s and %3$s are anchor tag; %4$s is the arrow icon. */ /* translators: %1$s is a break tag; %2$s and %3$s are anchor tag; %4$s is the arrow icon. */
(0,i.__)("Enable AI-powered SEO! Use all AI Generate and Optimize features to boost your efficiency. Just give us the green light. %1$s%2$sLearn more%3$s%4$s","wordpress-seo-premium"),"<br/>","<a>","<ArrowNarrowRightIcon />","</a>"),{a:(0,e.createElement)(Ce,{href:s,className:"yst-inline-flex yst-items-center yst-gap-1 yst-no-underline yst-font-medium",variant:"primary"}),ArrowNarrowRightIcon:(0,e.createElement)(xe,{className:"yst-w-4 yst-h-4 rtl:yst-rotate-180"}),br:(0,e.createElement)("br",null)}))),(0,e.createElement)("div",{className:"yst-flex yst-w-full yst-mt-6"},(0,e.createElement)("hr",{className:"yst-w-full yst-text-gray-200"})),(0,e.createElement)("div",{className:"yst-flex yst-items-start yst-mt-4"},(0,e.createElement)("input",{type:"checkbox",id:"yst-ai-consent-checkbox",name:"yst-ai-consent-checkbox",checked:u,value:u?"true":"false",onChange:m,className:"yst-checkbox__input",ref:c}),(0,e.createElement)("label",{htmlFor:"yst-ai-consent-checkbox",className:"yst-label yst-checkbox__label yst-text-xs yst-font-normal yst-text-slate-500"},y)),(0,e.createElement)("div",{className:"yst-w-full yst-flex yst-mt-4"},(0,e.createElement)(l.Button,{as:"button",className:"yst-grow",size:"large",disabled:!u,onClick:p},(0,i.__)("Grant consent","wordpress-seo-premium"))),(0,e.createElement)(l.Button,{as:"button",className:"yst-mt-4",variant:"tertiary",onClick:o},(0,i.__)("Close","wordpress-seo-premium"))))};Ne.propTypes={onGiveConsent:Y().func.isRequired,learnMoreLink:Y().string.isRequired,privacyPolicyLink:Y().string.isRequired,termsOfServiceLink:Y().string.isRequired,imageLink:Y().string.isRequired};const Te=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Something went wrong","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,i.__)("Please try again later. If this issue persists, you can learn more about possible reasons for this error on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Ce,{variant:"error",href:t}),a2:(0,e.createElement)(Ce,{variant:"error",href:s})})))},Re=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Not enough content","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,i.__)("Please add more content to ensure a valuable AI suggestion. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Ce,{variant:"error",href:t}),a2:(0,e.createElement)(Ce,{variant:"error",href:s})})))},Ae=()=>{const t=(0,r.useSelect)((e=>e(W).selectAdminLink("?page=wpseo_page_settings#/site-features#card-wpseo-keyword_analysis_active")),[]),s=(0,D.useCallback)((()=>{window.location.reload()}),[]),{onClose:a}=(0,l.useModalContext)();return(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-space-y-6 yst-mt-6"},(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("SEO analysis required","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(
/**
* translators:
* %1$s expands to Yoast SEO.
* %2$s and %3$s expand to an opening and closing anchor tag, respectively, that links to the settings page.
* %4$s expands to Yoast AI.
*/
/**
* translators:
* %1$s expands to Yoast SEO.
* %2$s and %3$s expand to an opening and closing anchor tag, respectively, that links to the settings page.
* %4$s expands to Yoast AI.
*/
(0,i.__)("%4$s requires the SEO analysis to be enabled. To enable it, please navigate to %2$sSite features%3$s in %1$s, turn on the SEO analysis, and click 'Save changes'. If it's disabled in your WordPress user profile, access your profile and enable it there. Please contact your administrator if you don't have access to these settings.","wordpress-seo-premium"),"Yoast SEO","<a>","</a>","Yoast AI"),{a:(0,e.createElement)(Ce,{variant:"error",href:t})}))),(0,e.createElement)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 yst-place-content-end"},(0,e.createElement)(l.Button,{variant:"secondary",onClick:a},(0,i.__)("Close","wordpress-seo-premium")),(0,e.createElement)(l.Button,{className:"yst-revoke-button",variant:"primary",onClick:s},(0,i.__)("Refresh page","wordpress-seo-premium"))))},Pe=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-rate-limit-help")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("You've reached the Yoast AI rate limit","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */ /* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */
(0,i.__)("You might have reached your Yoast AI rate limit for a specific time frame or your sparks limit for this month. If you have reached your rate limit, please reduce the frequency of your requests to continue using Yoast AI features. Our %1$shelp article%2$s provides guidance on effectively planning and pacing your requests for an optimized workflow.","wordpress-seo-premium"),"<a>","</a>"),{a:(0,e.createElement)(Ce,{variant:"error",href:t})})))},$e=({invalidSubscriptions:t})=>{const s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-activate-premium")),[]),a=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-new-premium")),[]),n=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-activate-yoast-woocommerce")),[]),o=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-new-yoast-woocommerce")),[]),c=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-activate-woocommerce-premium-bundle")),[]),u=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-new-woocommerce-premium-bundle")),[]),{onClose:m}=(0,l.useModalContext)(),p=(0,D.useCallback)((async()=>{try{await f()({path:"yoast/v1/ai_generator/bust_subscription_cache",method:"POST",parse:!1})}catch(e){console.error(e)}window.location.reload()}),[]);let d,y,g;1===t.length&&(d=t[0],y="Yoast SEO Premium"===d?s:n,g="Yoast SEO Premium"===d?a:o);const w=(0,D.createInterpolateElement)((0,i.sprintf)(
/**
* translators:
* %1$s expands to Yoast SEO Premium or Yoast WooCommerce SEO.
* %2$s expands to MyYoast.
* %3$s and %4$s expand to an opening and closing anchor tag, respectively, to activate your subscription.
* %5$s and %6$s expand to an opening and closing anchor tag, respectively, to get a new subscription.
**/
/**
* translators:
* %1$s expands to Yoast SEO Premium or Yoast WooCommerce SEO.
* %2$s expands to MyYoast.
* %3$s and %4$s expand to an opening and closing anchor tag, respectively, to activate your subscription.
* %5$s and %6$s expand to an opening and closing anchor tag, respectively, to get a new subscription.
**/
(0,i.__)("To access this feature, you need an active %1$s subscription. Please %3$sactivate your subscription in %2$s%4$s or %5$sget a new %1$s subscription%6$s. Afterward, refresh this page. It may take up to 30 seconds for the feature to function correctly.","wordpress-seo-premium"),d,"MyYoast","<Activate>","</Activate>","<New>","</New>"),{Activate:(0,e.createElement)(Ce,{variant:"error",href:y}),New:(0,e.createElement)(Ce,{variant:"error",href:g})}),h=(0,D.createInterpolateElement)((0,i.sprintf)(
/**
* translators:
* %1$s expands to MyYoast.
* %2$s expands to Yoast SEO Premium.
* %3$s expands to Yoast WooCommerce SEO.
* %4$s expands to Yoast WooCommerce SEO Premium bundle.
* %5$s and %6$s expand to an opening and closing anchor tag, respectively, to activate your subscription.
* %7$s and %8$s expand to an opening and closing anchor tag, respectively, to get a new subscription.
**/
/**
* translators:
* %1$s expands to MyYoast.
* %2$s expands to Yoast SEO Premium.
* %3$s expands to Yoast WooCommerce SEO.
* %4$s expands to Yoast WooCommerce SEO Premium bundle.
* %5$s and %6$s expand to an opening and closing anchor tag, respectively, to activate your subscription.
* %7$s and %8$s expand to an opening and closing anchor tag, respectively, to get a new subscription.
**/
(0,i.__)("To access this feature, you need active %2$s and %3$s subscriptions. Please %5$sactivate your subscriptions in %1$s%6$s or %7$sget a new %4$s%8$s. Afterward, refresh this page. It may take up to 30 seconds for the feature to function correctly.","wordpress-seo-premium"),"MyYoast","Yoast SEO Premium","Yoast WooCommerce SEO","Yoast WooCommerce SEO Premium bundle","<Activate>","</Activate>","<New>","</New>"),{Activate:(0,e.createElement)(Ce,{variant:"error",href:c}),New:(0,e.createElement)(Ce,{variant:"error",href:u})});return(0,e.createElement)(D.Fragment,null,(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Subscription required","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},1===t.length&&w,t.length>1&&h)),(0,e.createElement)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 yst-place-content-end"},(0,e.createElement)(l.Button,{variant:"secondary",onClick:m},(0,i.__)("Close","wordpress-seo-premium")),(0,e.createElement)(l.Button,{variant:"primary",onClick:p},(0,i.__)("Refresh page","wordpress-seo-premium"))))};$e.propTypes={invalidSubscriptions:Y().array},$e.defaultProps={invalidSubscriptions:[]};const Ie=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Connection timeout","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,i.__)("It seems that a connection timeout has occurred. Please check your internet connection and try again later. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Ce,{variant:"error",href:t}),a2:(0,e.createElement)(Ce,{variant:"error",href:s})})))},Le=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Usage policy violation","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
(0,i.__)("Due to %5$s's strict ethical guidelines and %1$susage policies%2$s, we cannot generate suggestions for the content on this page. If you intend to use AI, kindly avoid the use of explicit, violent, copyrighted, or sexually explicit content. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>","OpenAI"),{a1:(0,e.createElement)(Ce,{variant:"error",href:"https://openai.com/policies/usage-policies"}),a2:(0,e.createElement)(Ce,{variant:"error",href:t})})))},qe=({errorMessage:t})=>{const s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Something went wrong","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,i.sprintf)(/* translators: %s is the error response of the request. */ /* translators: %s is the error response of the request. */
(0,i.__)("The request came back with the following error: '%s'.","wordpress-seo-premium"),t)),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */ /* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */
(0,i.__)("Please try again later. If the issue persists, please %1$scontact our support team%2$s.","wordpress-seo-premium"),"<a>","</a>"),{a:(0,e.createElement)(Ce,{variant:"error",href:s})})))};qe.propTypes={errorMessage:Y().string},qe.defaultProps={errorMessage:""};const Me=()=>{const t=(0,r.useSelect)((e=>e(W).selectAdminLink("plugins.php")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Something went wrong","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s expands to Yoast SEO Premium. %2$s expands to an opening link tag. %3$s expands to a closing link tag. */ /* translators: %1$s expands to Yoast SEO Premium. %2$s expands to an opening link tag. %3$s expands to a closing link tag. */
(0,i.__)("The version of %1$s is outdated. Please upgrade %1$s %2$shere%3$s!","wordpress-seo-premium"),"Yoast SEO Premium","<a>","</a>"),{a:(0,e.createElement)(Ce,{variant:"error",href:t})})))},Oe=(e,t)=>e&&[X.product,X.productTag,X.productCategory].includes(t),Ue=({currentSubscriptions:t,isSeoAnalysisActive:s})=>{const{postType:a}=he(),n=(0,r.useSelect)((e=>e(L).getIsWooCommerceActive()),[]),o=(0,D.useMemo)((()=>!t.wooCommerceSubscription&&Oe(n,a)),[n,a,t.wooCommerceSubscription]),i=[];return t.premiumSubscription||i.push("Yoast SEO Premium"),o&&i.push("Yoast WooCommerce SEO"),i.length>0?(0,e.createElement)(l.Modal.Container.Content,{className:"yst-pt-6"},(0,e.createElement)($e,{invalidSubscriptions:i})):s?void 0:(0,e.createElement)(Ae,null)};Ue.propTypes={currentSubscriptions:Y().object,isSeoAnalysisActive:Y().bool};const Fe=({onStartGenerating:t})=>{const s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-terms-of-service")),[]),a=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-privacy-policy")),[]),n=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-learn-more")),[]),o=(0,r.useSelect)((e=>e("yoast-seo-premium/editor").selectImageLink("ai-consent.png")),[]),{storeAiGeneratorConsent:i}=(0,r.useDispatch)(W),l={learnMoreLink:n,termsOfServiceLink:s,privacyPolicyLink:a,imageLink:o,onGiveConsent:(0,D.useCallback)((async()=>{await i(!0),t()}),[i,t])};return(0,e.createElement)(Ne,{...l})};Fe.propTypes={onStartGenerating:Y().func.isRequired};const Be=e.forwardRef((function(t,s){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},t),e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"}))})),De=e.forwardRef((function(t,s){return e.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},t),e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"}))})),Ge=/(?<start><\/badge>|^(?!<badge>))(?<wrap>[\s\S]+?)(?<end><badge>|$)/g,Ye=({height:t})=>{const[s,a]=(0,D.useState)(""),{onClose:n}=(0,l.useModalContext)(),{editType:o,previewType:u,contentType:m}=he(),p=(()=>{const{editType:e,previewType:t}=he();let s="SEO";switch(t){case H:s="social";break;case j:s="X"}switch(e){case V:return(0,i.sprintf)(/* translators: %s is the type of title. */ /* translators: %s is the type of title. */
(0,i.__)("Generated %s titles","wordpress-seo-premium"),s);case K:return t===z&&(s="meta"),(0,i.sprintf)(/* translators: %s is the type of description. */ /* translators: %s is the type of description. */
(0,i.__)("Generated %s descriptions","wordpress-seo-premium"),s)}})(),d=(()=>{const{editType:e,previewType:t}=he();let s="SEO";switch(t){case H:s="social";break;case j:s="X"}switch(e){case V:return(0,i.sprintf)(/* translators: %s is the type of title. */ /* translators: %s is the type of title. */
(0,i.__)("Apply %s title","wordpress-seo-premium"),s);case K:return t===z&&(s="meta"),(0,i.sprintf)(/* translators: %s is the type of description. */ /* translators: %s is the type of description. */
(0,i.__)("Apply %s description","wordpress-seo-premium"),s)}})(),y=Ee(),{suggestions:g,fetchSuggestions:w,setSelectedSuggestion:h}=(()=>{const[e,t]=(0,D.useReducer)(be.reducer,be.getInitialState()),{editType:s,previewType:a,postType:n,contentType:o}=he(),i=(0,r.useSelect)((e=>e(L).getContentLocale()),[]),l=(0,r.useSelect)((e=>e(W).selectPromptContent()),[]);let u=(0,r.useSelect)((e=>e(L).getFocusKeyphrase()),[]);const m=(0,r.useSelect)((e=>e(L).getIsWooCommerceActive()),[]);u=oe.languageProcessing.helpers.processExactMatchRequest(u).keyphrase,u.length>191&&(u=u.slice(0,191));const p=((e,t,s,r)=>{const a=e===K?"meta-description":"seo-title";let n=(e=>{switch(e){case X.product:return"product-";case X.productCategory:case X.productTag:return"product-taxonomy-"}return""})(s);return n&&t||r!==Q||(n="taxonomy-"),`${n}${a}`})(s,m,n,o);return{suggestions:e,fetchSuggestions:(0,D.useCallback)((async(e=!0)=>{t(be.actions.setLoading());const{status:s,payload:r}=await(async({endpoint:e,data:t})=>{let s;const r=1e3*(0,c.get)(window,"wpseoPremiumAiGenerator.requestTimeout",30);try{ie&&ie.abort(),ie=new AbortController,le=!1,s=setTimeout((()=>{le=!0,ie.abort()}),r);const a=await f()({path:e,method:"POST",data:t,parse:!1,signal:ie.signal}),n=await a.json();return{status:re,payload:n}}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return le?{status:ae,payload:{message:"timeout",code:408}}:{status:ne};const{message:t,missingLicenses:s,errorIdentifier:r}=await(async e=>{try{const t=e.body.getReader(),{value:s}=await t.read(),r=new TextDecoder("utf-8").decode(s);return console.error(r),JSON.parse(r)}catch(e){return{message:"Unknown"}}})(e);return{status:ae,payload:{message:t,code:e.status||500,missingLicenses:s,errorIdentifier:r}}}finally{clearTimeout(s)}})({endpoint:"yoast/v1/ai_generator/get_suggestions/",canAbort:e,data:{type:p,prompt_content:l,focus_keyphrase:u,platform:Se(a),language:ue(i).replace("_","-")}});switch(s){case ne:break;case ae:t(be.actions.setError(r));break;case re:t(be.actions.setSuccess(r))}return s}),[t]),setSelectedSuggestion:(0,D.useCallback)((e=>t(be.actions.setSelected(e))),[t])}})(),E=(()=>{const{previewType:e}=he();switch(e){case H:return st;case j:return gt;default:return Xe}})(),{addAppliedSuggestion:v,addUsageCount:b,fetchUsageCount:S}=(0,r.useDispatch)(W),_=(0,l.usePrevious)(t),k=g.status===se.success?t:_,x=`calc(${0===k?"50%":k/2+"px"} - 40vh)`,[C,N]=(0,D.useState)(!1),T=(0,D.useCallback)((e=>{N(e.target.offsetHeight!==e.target.scrollHeight)}),[N]),R=ve(T),A=(()=>{const{editType:e,previewType:t,contentType:s}=he(),a=(()=>{const{previewType:e}=he();return(0,D.useMemo)((()=>{switch(e){case z:return()=>(0,r.select)(L).getSnippetEditorData().title;case H:return(0,r.select)(L).getFacebookTitleOrFallback;case j:return(0,r.select)(L).getTwitterTitleOrFallback;default:return(0,c.constant)("")}}),[e])})(),n=(0,r.useSelect)((s=>s(W).selectAppliedSuggestionFor({editType:e,previewType:t})),[e,t]);return(0,D.useMemo)((()=>{let t=a();return e===K?t:(n&&(t=t.replace(n,ee[s])),((e,t)=>e.includes(ee[t])?e:ee[t])(t,s))}),[e,a])})(),P=(()=>{const e=(()=>{const{previewType:e}=he();return(0,D.useMemo)((()=>{switch(e){case z:return()=>(0,r.select)(L).getSnippetEditorData().description;case H:return(0,r.select)(L).getFacebookDescriptionOrFallback;case j:return(0,r.select)(L).getTwitterDescriptionOrFallback;default:return(0,c.constant)("")}}),[e])})();return(0,D.useMemo)(e,[e])})(),$=(()=>{const e=(0,r.useSelect)((e=>{const t=e(L).getReplaceVars();return t.forEach((e=>{""!==e.value||["title","excerpt","excerpt_only"].includes(e.name)||(e.value="%%"+e.name+"%%"),e.badge=`<badge>${e.label}</badge>`})),t}),[]);return(0,D.useCallback)(((t,{key:s="value",overrides:r={},applyPluggable:a=!0,editType:n=V,contentType:o=J}={})=>{for(const a of e)t=t.replace(new RegExp("%%"+(0,c.escapeRegExp)(a.name)+"%%","g"),(0,c.get)(r,a.name,a[s]));return o===Q&&(t=t.replace(" Archives","")),a?((e,t=V)=>{const s=(0,c.get)(window,"yoast.editorModules.helpers.replacementVariableHelpers.applyReplaceUsingPlugin",(e=>({url:e.url,title:oe.languageProcessing.stripHTMLTags(e.title),description:oe.languageProcessing.stripHTMLTags(e.description)}))),r=oe.languageProcessing.stripSpaces(e),a=s({title:"",description:"",[t]:r});return(0,c.get)(a,t,e)})(t,n):t}),[e])})(),I=(0,D.useMemo)((()=>o===V?{[Z[m]]:g.selected}:{}),[o,m,g.selected]),q=(0,D.useMemo)((()=>$(A,{overrides:I,contentType:m})),[$,A,o,m,g.selected]),M=(0,D.useMemo)((()=>$(A,{overrides:{...I,sep:"",sitename:""},contentType:m})),[$,A,o,m,g.selected]),O=(0,D.useMemo)((()=>o===K?g.selected:$(P,{editType:K})),[$,P,o,g.selected]),U=(0,D.useCallback)((e=>$(A,{overrides:{[Z[m]]:e},key:"badge",applyPluggable:!1,contentType:m})),[$,A,m]),{currentPage:F,setCurrentPage:B,isOnLastPage:G,totalPages:Y,getItemsOnCurrentPage:te}=(({totalItems:e=0,perPage:t=5})=>{const[s,r]=(0,D.useState)(1),a=(0,D.useMemo)((()=>Math.ceil(e/t)),[e,t]),n=(0,D.useMemo)((()=>s*t),[s,t]),o=(0,D.useMemo)((()=>n-t),[n,t]),i=(0,D.useMemo)((()=>1===s),[s]),l=(0,D.useMemo)((()=>s===a),[s,a]),u=(0,D.useCallback)((()=>{s>1&&r(s-1)}),[s,r]),m=(0,D.useCallback)((()=>{s<a&&r(s+1)}),[s,r,a]),p=(0,D.useCallback)((e=>(0,c.slice)(e,o,n)),[o,n]);return{currentPage:s,setCurrentPage:r,totalPages:a,isOnFirstPage:i,isOnLastPage:l,previousPage:u,nextPage:m,firstOnPage:o,lastOnPage:n,getItemsOnCurrentPage:p}})({totalItems:g.status===se.loading||g.status===se.error?g.entities.length+5:g.entities.length,perPage:5}),ce=(0,D.useMemo)((()=>(0,c.map)(te(g.entities),(t=>{let s=t;return o===V&&(s=U(t),s=s.replace(Ge,((e,t,s,r,a,n,{start:o,wrap:i,end:l})=>{const c=i.trim();return 0===c.length?`${o}${i}${l}`:`${o}<span>${c}</span>${l}`})),s=(0,D.createInterpolateElement)(s,{badge:(0,e.createElement)(l.Badge,{className:"yst-mr-2 last:yst-mr-0",variant:"plain"}," "),span:(0,e.createElement)("span",{className:"yst-flex yst-items-center yst-mr-2 last:yst-mr-0"})})),{value:t,label:s}}))),[g.entities,te,o,U]),me=(0,D.useMemo)((()=>g.status!==se.error||g.status===se.error&&!G),[g.status,G]),pe=(0,D.useMemo)((()=>g.status===se.loading&&G),[g.status,G]),de=(0,D.useMemo)((()=>g.status===se.error&&G),[g.status,G]),ye=(0,D.useCallback)((()=>{B(g.status===se.error?Y:Y+1),b(),w()}),[w,g.status,Y,B,h]),ge=(0,D.useCallback)((()=>a("")),[a]),we=(()=>{const{editType:e}=he();switch(e){case V:return(()=>{const{previewType:e}=he(),{updateData:t,setFacebookPreviewTitle:s,setTwitterPreviewTitle:a}=(0,r.useDispatch)(L);return(0,D.useMemo)((()=>{switch(e){case z:return e=>t({title:e});case H:return s;case j:return a;default:return c.noop}}),[e,t,s,a])})();case K:return(()=>{const{previewType:e}=he(),{updateData:t,setFacebookPreviewDescription:s,setTwitterPreviewDescription:a}=(0,r.useDispatch)(L);return(0,D.useMemo)((()=>{switch(e){case z:return e=>t({description:e});case H:return s;case j:return a;default:return c.noop}}),[e,t,s,a])})();default:return c.noop}})(),fe=(0,D.useCallback)((()=>{const e=o===V?A.replace(new RegExp(ee[m]+"( Archives)?"),g.selected):g.selected;we(e),v({editType:o,previewType:u,suggestion:g.selected}),n()}),[we,o,u,g.selected,A,n,v]);return(0,D.useEffect)((()=>{""===s&&w().then((e=>{a(e),e===re&&S()}))}),[s,a,w]),s===ae||g.status===se.error&&402===g.error.code?(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-space-y-6 yst-mt-6"},(0,e.createElement)(lt,{errorCode:g.error.code,errorIdentifier:g.error.errorIdentifier,invalidSubscriptions:g.error.missingLicenses,showActions:!0,onRetry:ge,errorMessage:g.error.message})):(0,e.createElement)(D.Fragment,null,(0,e.createElement)(l.Modal.Container.Content,{ref:R,className:"yst-flex yst-flex-col yst-py-6 yst-space-y-2"},(0,e.createElement)(E,{title:q,description:O,status:g.status,titleForLength:M,showPreviewSkeleton:""===s,showLengthProgress:!pe}),me&&(pe?(0,e.createElement)(pt,{idSuffix:y,suggestionClassNames:o===V?[["yst-h-3 yst-w-9/12"],["yst-h-3 yst-w-7/12"],["yst-h-3 yst-w-10/12"],["yst-h-3 yst-w-11/12"],["yst-h-3 yst-w-8/12"]]:void 0}):(0,e.createElement)(D.Fragment,null,(0,e.createElement)("div",{className:"yst-flex yst-space-y-4"},(0,e.createElement)(l.Label,{as:"span",className:"yst-flex-grow yst-cursor-default yst-mt-auto"},p),(0,e.createElement)(l.Button,{variant:"secondary",size:"small",onClick:g.status===se.loading?c.noop:ye,isLoading:g.status===se.loading},g.status!==se.loading&&(0,e.createElement)(De,{className:"yst--ml-1 yst-mr-2 yst-h-4 yst-w-4 yst-text-gray-400"}),(0,i.__)("Generate 5 more","wordpress-seo-premium"))),(0,e.createElement)(mt,{idSuffix:y,suggestions:ce,selected:g.selected,onChange:h}),(0,e.createElement)("div",{className:"yst-flex yst-justify-between yst-gap-x-2 yst-items-start"},(0,e.createElement)("p",{className:"yst-text-slate-500 yst-text-[11px] yst-mt-1"},(0,i.__)("Text generated by AI may be offensive or inaccurate.","wordpress-seo-premium")),Y>1&&(0,e.createElement)(l.Pagination,{className:"yst-shrink-0",current:F,total:Y,onNavigate:B,disabled:g.status===se.loading,variant:"text"
/* translators: Hidden accessibility text. */,screenReaderTextPrevious:(0,i.__)("Previous","wordpress-seo-premium")
/* translators: Hidden accessibility text. */,screenReaderTextNext:(0,i.__)("Next","wordpress-seo-premium")})))),g.status===se.error&&G&&(0,e.createElement)(lt,{errorCode:g.error.code,errorIdentifier:g.error.errorIdentifier,invalidSubscriptions:g.error.missingLicenses,errorMessage:g.error.message})),(0,e.createElement)(l.Modal.Container.Footer,null,C&&(0,e.createElement)("div",{className:"yst-absolute yst-inset-x-0 yst--mt-10 yst-mr-[calc(2.5rem-1px)] yst-h-10 yst-pointer-events-none yst-bg-gradient-to-t yst-from-slate-50"}),(0,e.createElement)("hr",{className:"yst-mb-6 yst--mx-6"}),(0,e.createElement)("div",{className:"sm:yst-flex sm:yst-justify-end sm:yst-space-x-2"},(0,e.createElement)("div",{className:"yst-hidden sm:yst-inline"},(0,e.createElement)(l.Button,{variant:"secondary",onClick:n},(0,i.__)("Close","wordpress-seo-premium"))),(0,e.createElement)("div",{className:"yst-block sm:yst-inline"},(0,e.createElement)(l.Button,{className:"yst-w-full sm:yst-w-auto",variant:"primary",onClick:fe,disabled:""===g.selected||g.status===se.loading||de},(0,e.createElement)(Be,{className:"yst--ml-1 yst-mr-1 yst-h-4 yst-w-4 yst-text-white"}),d)),(0,e.createElement)("div",{className:"yst-mt-3 sm:yst-hidden"},(0,e.createElement)(l.Button,{variant:"secondary",onClick:n,className:"yst-w-full sm:yst-w-auto"},(0,i.__)("Close","wordpress-seo-premium"))))),(0,e.createElement)(l.Notifications,{className:"yst-mx-[calc(50%-50vw)] yst-transition-all",style:{marginTop:x},position:"bottom-left"},g.status!==se.loading&&(0,e.createElement)(ft,{className:"yst-mx-[calc(50%-50vw)] yst-transition-all"}),(g.status===se.success||g.status===se.loading)&&(0,e.createElement)(yt,null)))};Ye.propTypes={height:Y().number.isRequired};const We=window.yoast.componentsNew;var ze=s(332),He=s.n(ze);const je=({className:t=""})=>{const[s,a]=(0,D.useState)(!1),n=(0,r.useSelect)((e=>e(W).selectUsageCount()),[]),o=(0,r.useSelect)((e=>e(W).selectLimit()),[]),c=(0,D.useMemo)((()=>-1===o?"unlimited":n>o?0:o-n),[n,o]),u=(0,D.useCallback)((()=>a(!0)),[a]),m=(0,D.useCallback)((()=>a(!1)),[a]),p=(0,D.useMemo)((()=>{const e=new Date;return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()-e.getDate()}),[]),d=`${"unlimited"===c?(0,i.__)("You have unlimited sparks left this month.","wordpress-seo-premium"):(0,i.sprintf)(/* translators: %1$s is the number of Yoast AI generations ("sparks") left this month. */ /* translators: %1$s is the number of Yoast AI generations ("sparks") left this month. */
(0,i._n)("You have %1$s spark left this month.","You have %1$s sparks left this month.",c,"wordpress-seo-premium"),c)} ${(0,i.sprintf)(/* translators: %1$s is the number of days left before the next reset. */ /* translators: %1$s is the number of days left before the next reset. */
(0,i._n)("The next reset is in %1$s day.","The next reset is in %1$s days.",p,"wordpress-seo-premium"),p)}`,y=-1===o?(0,i.__)("unlimited","wordpress-seo-premium"):o;return n>0&&(0,e.createElement)(l.Badge,{onMouseEnter:u,onMouseLeave:m,className:He()("yst-bg-white yst-from-primary-50 yst-to-indigo-50 yst-border-gradient yst-absolute yst-shadow yst-py-0 yst-leading-[18px] yst-h-[18px]",t),size:"small"},s&&(0,e.createElement)(l.Tooltip,{counts:n,className:"yst-leading-4 yst-max-w-none"},d,(0,e.createElement)("br",null),(0,i.__)("While this feature is in beta, you have unlimited sparks.","wordpress-seo-premium")),(0,e.createElement)(We.SparklesIcon,{className:"yst-ai-counter-badge__sparkles-icon yst-w-[11px] yst-mr-1 yst-text-slate-500"}),(0,e.createElement)("span",{className:"yst-text-slate-700 yst-font-semibold yst-mr-0.5"},n),(0,e.createElement)("span",{className:"yst-text-slate-500 yst-font-normal yst-mr-0.5 yst-text-[10px]"},"/"),(0,e.createElement)("span",{className:"yst-text-slate-500 yst-font-normal yst-mr-0.5 yst-text-[10px]"},y))};je.propTypes={className:Y().string};const Ve=({onUseAi:t})=>{const{editType:s,postType:a}=he(),n=Ee(),o=(()=>{const{editType:e,previewType:t}=he();switch(t){case H:return e===K?(0,i.__)("AI social description generator","wordpress-seo-premium"):(0,i.__)("AI social title generator","wordpress-seo-premium");case j:return e===K?(0,i.__)("AI X description generator","wordpress-seo-premium"):(0,i.__)("AI X title generator","wordpress-seo-premium");default:return e===K?(0,i.__)("AI description generator","wordpress-seo-premium"):(0,i.__)("AI title generator","wordpress-seo-premium")}})(),[c,,,u,m]=(0,l.useToggleState)(!1),p=(0,D.useRef)(null),d=(0,r.useSelect)((e=>e(L).getFocusKeyphrase()),[]),y=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-help-button-modal")),[]),{closeEditorModal:g}=(0,r.useDispatch)(L),w=(0,r.useSelect)((e=>e(W).selectHasAiGeneratorConsent()),[]),h=(0,r.useSelect)((e=>e(W).selectPromptContentInitialized()),[]),f=(0,r.useSelect)((e=>e(W).selectProductSubscriptions()),[]),E=(0,r.useSelect)((e=>e(W).selectPremiumSubscription()),[]),v=(0,r.useSelect)((e=>e(W).selectWooCommerceSubscription()),[]),b=(0,r.useSelect)((e=>e(L).getPreference("isKeywordAnalysisActive",!0)),[]),S=(0,r.useSelect)((e=>e(L).getIsWooCommerceActive()),[]),_=(0,i.__)("Close modal","wordpress-seo-premium"),k=(0,l.useSvgAria)(),[x,C]=(0,D.useState)(0),N=(0,D.useCallback)((e=>C(e.borderBoxSize[0].blockSize)),[C]),T=ve(N),R=function(e,t,s,r,a){return Oe(a,e)?t&&s&&r:t&&r}(a,E,v,b,S),A={onClose:m,aiModalHelperLink:y,svgAriaProps:k,panelRef:T,closeButtonScreenReaderText:_,title:o},P=(0,D.useCallback)((()=>{if(de(d))return m(),g(),void setTimeout((()=>(e=>{const t=`focus-keyword-input-${"modal"===e?"sidebar":e}`;if("metabox"===e){const e=document.getElementById("wpseo-meta-tab-content");e&&e.click()}const s=document.getElementById(t);s&&s.focus()})(n)),0);u()}),[d,u,m,g,n]),$=(0,D.useCallback)((()=>{b?P():u()}),[P,b,u]),I=(0,D.useCallback)((()=>{t(),u(),w&&b&&P()}),[t,u,w,b,P]);return(0,e.createElement)(D.Fragment,null,(0,e.createElement)("button",{type:"button",id:`yst-replacevar__use-ai-button__${s}__${n}`,className:"yst-replacevar__use-ai-button",onClick:I,disabled:!h},(0,i.__)("Use AI","wordpress-seo-premium")),c&&(0,e.createElement)(D.Fragment,null,(0,e.createElement)(l.Modal,{className:"yst-introduction-modal",isOpen:!w&&R,onClose:m,initialFocus:p},(0,e.createElement)(l.Modal.Panel,{className:"yst-max-w-lg yst-p-0 yst-rounded-3xl",closeButtonScreenReaderText:_},(0,e.createElement)(Fe,{onStartGenerating:$,focusElementRef:p}))),(0,e.createElement)(Ke,{...A,isOpen:R&&w},(0,e.createElement)(Ye,{height:x})),(0,e.createElement)(Ke,{...A,isOpen:!R},(0,e.createElement)(Ue,{currentSubscriptions:f,isSeoAnalysisActive:b}))))};Ve.propTypes={onUseAi:Y().func.isRequired};const Ke=({isOpen:t,onClose:s,panelRef:r,closeButtonScreenReaderText:a,title:n,aiModalHelperLink:o,svgAriaProps:c,children:u})=>(0,e.createElement)(l.Modal,{className:"yst-ai-modal",isOpen:t,onClose:s},(0,e.createElement)(l.Modal.Panel,{ref:r,className:"yst-max-w-3xl yst-relative",closeButtonScreenReaderText:a},(0,e.createElement)(l.Modal.Container,null,(0,e.createElement)(l.Modal.Container.Header,null,(0,e.createElement)(je,{className:"yst-top-[-8px] yst-right-14"}),(0,e.createElement)("div",{className:"yst-flex yst-items-center"},(0,e.createElement)("span",{className:"yst-logo-icon yst-h-5 yst-w-5"}),(0,e.createElement)(l.Modal.Title,{className:"yst-ml-3 yst-mr-1.5",as:"h1",size:"2"},n),(0,e.createElement)(l.Link,{id:"ai-modal-learn-more",href:o,variant:"primary",className:"yst-no-underline yst-mr-2",target:"_blank",rel:"noopener"
/* translators: Hidden accessibility text. */,"aria-label":(0,i.__)("Learn more about AI (Opens in a new browser tab)","wordpress-seo-premium")},(0,e.createElement)(ke,{...c,className:"yst-w-4 yst-h-4 yst-text-slate-500"})),(0,e.createElement)(l.Badge,{variant:"info"},"Beta")),(0,e.createElement)("hr",{className:"yst-mt-6 yst--mx-6"})),u)));Ke.propTypes={isOpen:Y().bool.isRequired,onClose:Y().func.isRequired,panelRef:Y().func.isRequired,closeButtonScreenReaderText:Y().string.isRequired,title:Y().string.isRequired,aiModalHelperLink:Y().string.isRequired,svgAriaProps:Y().object.isRequired,children:Y().node.isRequired};const Xe=({title:t,description:s,status:a,titleForLength:n,showPreviewSkeleton:o,showLengthProgress:c})=>{const u=(0,r.useSelect)((e=>e(L).getSnippetEditorMode()),[]),[m,p]=(0,D.useState)(u),{editType:d}=he(),y=Ee(),g=(({editType:e,title:t,description:s})=>{const a=(0,r.useSelect)((e=>e(L).getDateFromSettings()),[]),n=(0,r.useSelect)((e=>e(L).getContentLocale()),[]),o=(0,r.useSelect)((e=>e(L).isCornerstoneContent()),[]),i=(0,r.useSelect)((e=>e(L).getIsTerm()),[]);return(0,D.useMemo)((()=>e===K?(0,_e.getDescriptionProgress)(s,a,o,i,n):(0,_e.getTitleProgress)(t)),[e,t,s,a,o,i,n])})({editType:d,title:n,description:s});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"yst-mb-2 lg:yst-flex"},(0,e.createElement)(l.Label,{as:"span",className:"yst-flex-grow yst-cursor-default"},(0,i.__)("Google preview","wordpress-seo-premium")),(0,e.createElement)(tt,{mode:m,idSuffix:y,onChange:p,disabled:a===se.loading})),o?(0,e.createElement)(Ze,null):(0,e.createElement)(Qe,{mode:m,title:t,description:s}),(0,e.createElement)("div",{className:"yst-pt-4"},(0,e.createElement)(l.Label,{as:"span",className:"yst-flex-grow yst-cursor-default"},d===V&&(0,i.__)("SEO title width","wordpress-seo-premium"),d===K&&(0,i.__)("Meta description length","wordpress-seo-premium")),(0,e.createElement)(et,{className:"yst-mt-2",progress:c?g.actual:0,min:0,max:g.max,score:g.score})))};Xe.propTypes={title:Y().string.isRequired,description:Y().string.isRequired,status:Y().oneOf(Object.keys(se)).isRequired,titleForLength:Y().string.isRequired,showPreviewSkeleton:Y().bool.isRequired,showLengthProgress:Y().bool.isRequired};const Je=/mobi/i,Qe=({mode:t,title:s,description:a})=>{var n,o;const i=(0,r.useSelect)((e=>e(L).getBaseUrlFromSettings()),[]),l=(0,r.useSelect)((e=>e(L).getSnippetEditorData().slug||""),[]),u=(0,r.useSelect)((e=>e(L).getDateFromSettings()),[]),m=(0,r.useSelect)((e=>e(L).getFocusKeyphrase()),[]),p=(0,r.useSelect)((e=>e(L).getSnippetEditorPreviewImageUrl()),[]),d=(0,r.useSelect)((e=>e(L).getSiteIconUrlFromSettings()),[]),y=(0,r.useSelect)((e=>e(L).getShoppingData()),[]),g=(0,r.useSelect)((e=>e(L).getSnippetEditorWordsToHighlight()),[]),w=(0,r.useSelect)((e=>e(L).getSiteName()),[]),h=(0,r.useSelect)((e=>e(L).getContentLocale()),[]),f=(0,D.useMemo)((()=>i+l),[i,l]),E=(0,D.useMemo)((()=>{var e,t;return Je.test(null===(e=window)||void 0===e||null===(t=e.navigator)||void 0===t?void 0:t.userAgent)}),[null===(n=window)||void 0===n||null===(o=n.navigator)||void 0===o?void 0:o.userAgent]);return(0,e.createElement)("div",{className:`yst-bg-slate-200 yst--mx-6 ${t}${E?" yst-user-agent__mobile":""}`},(0,e.createElement)(_e.SnippetPreview,{title:s,description:a,mode:t,url:f,keyword:m,date:u,faviconSrc:d,mobileImageSrc:p,wordsToHighlight:g,siteName:w,locale:h,shoppingData:y,onMouseUp:c.noop}))};Qe.propTypes={mode:Y().oneOf(Object.keys(te)).isRequired,title:Y().string.isRequired,description:Y().string.isRequired};const Ze=()=>(0,e.createElement)("div",{className:"yst-max-w-[400px] yst-py-4 yst-px-3 yst-border yst-rounded-lg yst-w-full yst-mx-auto"},(0,e.createElement)("div",{className:"yst-flex yst-gap-x-3"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-flex-shrink-0 yst-h-7 yst-w-7 yst-rounded-full"}),(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-w-full yst-gap-y-1"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-2.5 yst-w-10/12"}))),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-4 yst-w-full yst-mt-6 yst-mb-4"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-full"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-10/12 yst-mt-2.5"})),et=({className:t,progress:s,max:r,score:a})=>{const n=(0,D.useMemo)((()=>(e=>e>=7?"yst-score-good":e>=5?"yst-score-ok":"yst-score-bad")(a)),[a]);return(0,e.createElement)(l.ProgressBar,{className:He()("yst-length-progress-bar",n,t),progress:s,min:0,max:r})};et.propTypes={className:Y().string,progress:Y().number.isRequired,max:Y().number.isRequired,score:Y().number.isRequired},et.defaultProps={className:""};const tt=({idSuffix:t,mode:s,onChange:r,disabled:a})=>{const n=(0,D.useCallback)((({target:e})=>e.checked&&r(e.value)),[r]);return(0,e.createElement)(l.RadioGroup,{id:`yst-ai-mode__${t}`,className:"yst-ai-mode yst-pt-2 lg:yst-pt-0",disabled:a},(0,e.createElement)(l.RadioGroup.Radio,{id:`yst-ai-mode__mobile__${t}`,name:`yst-ai-mode__${t}`,label:(0,i.__)("Mobile result","wordpress-seo-premium"),value:te.mobile,checked:s===te.mobile,onChange:n,disabled:a}),(0,e.createElement)(l.RadioGroup.Radio,{id:`yst-ai-mode__desktop__${t}`,name:`yst-ai-mode__${t}`,label:(0,i.__)("Desktop result","wordpress-seo-premium"),value:te.desktop,checked:s===te.desktop,onChange:n,disabled:a}))};tt.propTypes={idSuffix:Y().string.isRequired,mode:Y().oneOf(Object.keys(te)).isRequired,onChange:Y().func.isRequired,disabled:Y().bool.isRequired};const st=({title:t,description:s,showPreviewSkeleton:r})=>(0,e.createElement)("div",null,(0,e.createElement)("div",{className:"yst-flex yst-mb-6"},(0,e.createElement)(l.Label,{as:"span",className:"yst-flex-grow yst-cursor-default"},(0,i.__)("Social preview","wordpress-seo-premium"))),r?(0,e.createElement)(nt,null):(0,e.createElement)(at,{title:t,description:s}));st.propTypes={title:Y().string.isRequired,description:Y().string.isRequired,showPreviewSkeleton:Y().bool.isRequired};const rt=window.yoast["social-metadata-previews"],at=({title:t,description:s})=>{const a=(0,r.useSelect)((e=>e(L).getSiteUrl()),[]),n=(0,r.useSelect)((e=>e(L).getFacebookImageUrl()),[]),o=(0,r.useSelect)((e=>e(L).getEditorDataImageFallback()),[]),i=(0,r.useSelect)((e=>e(L).getFacebookAltText()),[]);return(0,e.createElement)("div",{className:"yst-bg-slate-200 yst-p-2 yst--mx-6 yst-mx-auto"},(0,e.createElement)(rt.FacebookPreview,{title:t,description:s,siteUrl:a,imageUrl:n,imageFallbackUrl:o,alt:i,onSelect:c.noop,onImageClick:c.noop,onMouseHover:c.noop}))};at.propTypes={title:Y().string.isRequired,description:Y().string.isRequired};const nt=()=>(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-w-[527px] yst-border yst-mx-auto"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-[273px] yst-w-full yst-rounded-none yst-border yst-border-dashed"}),(0,e.createElement)("div",{className:"yst-w-full yst-p-4 yst-space-y-1"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-5 yst-w-10/12"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-full"}))),ot=()=>{const t=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-common-errors")),[]),s=(0,r.useSelect)((e=>e(L).selectLink("https://yoa.st/ai-generator-support")),[]);return(0,e.createElement)(l.Alert,{variant:"error"},(0,e.createElement)("span",{className:"yst-block yst-font-medium"},(0,i.__)("Yoast AI cannot reach your site","wordpress-seo-premium")),(0,e.createElement)("p",{className:"yst-mt-2"},(0,D.createInterpolateElement)((0,i.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,i.__)("To use this feature, your site must be publicly accessible. This applies to both test sites and instances where your REST API is password-protected. Please ensure your site is accessible to the public and try again. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:(0,e.createElement)(Ce,{variant:"error",href:t}),a2:(0,e.createElement)(Ce,{variant:"error",href:s})})))},it=({children:t,onRetry:s})=>{const{onClose:r}=(0,l.useModalContext)();return(0,e.createElement)(D.Fragment,null,t,(0,e.createElement)("div",{className:"yst-mt-6 yst-mb-1 yst-flex yst-space-x-3 yst-place-content-end"},(0,e.createElement)(l.Button,{variant:"secondary",onClick:r},(0,i.__)("Close","wordpress-seo-premium")),(0,e.createElement)(l.Button,{variant:"primary",onClick:s},(0,i.__)("Try again","wordpress-seo-premium"))))};it.propTypes={children:Y().node.isRequired,onRetry:Y().func.isRequired};const lt=({errorCode:t,errorIdentifier:s,invalidSubscriptions:r,showActions:a,onRetry:n,errorMessage:o})=>{switch(t){case 400:switch(s){case"AI_CONTENT_FILTER":return(0,e.createElement)(Le,null);case"NOT_ENOUGH_CONTENT":return(0,e.createElement)(Re,null);case"SITE_UNREACHABLE":return(0,e.createElement)(ot,null);case"WP_HTTP_REQUEST_ERROR":return a?(0,e.createElement)(it,{onRetry:n},(0,e.createElement)(qe,{errorMessage:o})):(0,e.createElement)(qe,{errorMessage:o});default:return a?(0,e.createElement)(it,{onRetry:n},(0,e.createElement)(Te,null)):(0,e.createElement)(Te,null)}case 402:return(0,e.createElement)($e,{invalidSubscriptions:r});case 408:return a?(0,e.createElement)(it,{onRetry:n},(0,e.createElement)(Ie,null)):(0,e.createElement)(Ie,null);case 429:return(0,e.createElement)(Pe,null);case 410:return(0,e.createElement)(Me,null);default:return a?(0,e.createElement)(it,{onRetry:n},(0,e.createElement)(Te,null)):(0,e.createElement)(Te,null)}};lt.propTypes={errorCode:Y().number.isRequired,errorIdentifier:Y().string.isRequired,invalidSubscriptions:Y().array,showActions:Y().bool,onRetry:Y().func,errorMessage:Y().string},lt.defaultProps={showActions:!1,onRetry:c.noop,invalidSubscriptions:[],errorMessage:""};const ct=Y().shape({value:Y().string.isRequired,label:Y().node.isRequired}),ut=({id:t,name:s,suggestion:r,isChecked:a,onChange:n})=>{const o=(0,D.useCallback)((()=>n(r.value)),[r,n]);return(0,e.createElement)("label",{htmlFor:t,className:He()("yst-flex yst-p-4 yst-items-center yst-border first:yst-rounded-t-md last:yst-rounded-b-md",a&&"yst-z-10 yst-border-primary-500")},(0,e.createElement)("input",{type:"radio",id:t,name:s,className:"yst-radio__input",value:r.value,checked:a,onChange:o}),(0,e.createElement)("div",{className:He()("yst-label yst-radio__label yst-flex yst-flex-wrap yst-items-center",!a&&"yst-text-slate-600")},r.label))};ut.propTypes={id:Y().string.isRequired,name:Y().string.isRequired,suggestion:ct.isRequired,isChecked:Y().bool.isRequired,onChange:Y().func.isRequired};const mt=({idSuffix:t,suggestions:s,selected:r,onChange:a})=>(0,e.createElement)("div",null,(0,e.createElement)(l.RadioGroup,{className:"yst-suggestions-radio-group yst-flex yst-flex-col",id:`yst-ai-suggestions-radio-group__${t}`},s.map(((s,n)=>(0,e.createElement)(ut,{key:`yst-ai-suggestions-radio-${t}__${n}`,id:`yst-ai-suggestions-radio-${t}__${n}`,name:`ai-suggestion__${t}`,isChecked:s.value===r,onChange:a,suggestion:s})))));mt.propTypes={idSuffix:Y().string.isRequired,suggestions:Y().arrayOf(ct).isRequired,selected:Y().string.isRequired,onChange:Y().func.isRequired};const pt=({suggestionClassNames:t})=>(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst--space-y-[1px]"},t.map(((t,s)=>(0,e.createElement)("div",{key:`yst-ai-suggestion-radio-skeleton__${s}`,className:"yst-flex yst-p-4 yst-gap-x-3 yst-items-center yst-border first:yst-rounded-t-md last:yst-rounded-b-md"},(0,e.createElement)("input",{type:"radio",disabled:!0,className:"yst-my-0.5"}),(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-w-full"},t.map(((t,r)=>(0,e.createElement)(l.SkeletonLoader,{key:`yst-ai-suggestion-radio-skeleton-${s}__${r}`,className:t}))))))));pt.propTypes={suggestionClassNames:Y().arrayOf(Y().arrayOf(Y().string))},pt.defaultProps={suggestionClassNames:[["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-9/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-7/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-10/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-11/12"],["yst-h-3 yst-w-full","yst-mt-2.5 yst-h-3 yst-w-8/12"]]};const dt="wpseo_premium_ai_generator",yt=()=>{const t=(0,r.useSelect)((e=>e(L).isAlertDismissed(dt)),[]),s=(0,r.useSelect)((e=>e(L).getEditorDataContent()),[]),a=(0,r.useSelect)((e=>e(L).getIsWooCommerceActive()),[]),[n,,,o]=(0,l.useToggleState)(!1),{editType:c,postType:u,contentType:m}=he(),{dismissAlert:p}=(0,r.useDispatch)(L),d=(0,D.useCallback)((()=>{p(dt)}),[p]),y=(0,D.useMemo)((()=>c===K?(0,i.__)("%1$sTip%2$s: Improve the accuracy of your generated AI descriptions by writing more content in your page.","wordpress-seo-premium"):(0,i.__)("%1$sTip%2$s: Improve the accuracy of your generated AI titles by writing more content in your page.","wordpress-seo-premium")
/* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */),[c]),g=(0,D.useMemo)((()=>((e,t,s)=>Oe(s,e)||t===Q?150:300)(u,m,a)),[u,m,a]);return t||n||s.length>g?null:(0,e.createElement)(l.Notifications.Notification,{id:"ai-generator-content-tip",variant:"info",dismissScreenReaderLabel:(0,i.__)("Dismiss","wordpress-seo-premium")},(0,D.createInterpolateElement)((0,i.sprintf)(y,"<span>","</span>"),{span:(0,e.createElement)("span",{className:"yst-font-medium yst-text-slate-800"})}),(0,e.createElement)("div",{className:"yst-flex yst-mt-3 yst--ml-3 yst-gap-1"},(0,e.createElement)(l.Button,{type:"button",variant:"tertiary",onClick:d},(0,i.__)("Don’t show again","wordpress-seo-premium")),(0,e.createElement)(l.Button,{type:"button",variant:"tertiary",className:"yst-text-slate-800",onClick:o},(0,i.__)("Dismiss","wordpress-seo-premium"))))},gt=({title:t,description:s,showPreviewSkeleton:r})=>(0,e.createElement)("div",null,(0,e.createElement)("div",{className:"yst-flex yst-mb-6"},(0,e.createElement)(l.Label,{as:"span",className:"yst-flex-grow yst-cursor-default"},(0,i.__)("X preview","wordpress-seo-premium"))),r?(0,e.createElement)(ht,null):(0,e.createElement)(wt,{title:t,description:s}));gt.propTypes={title:Y().string.isRequired,description:Y().string.isRequired,showPreviewSkeleton:Y().bool.isRequired};const wt=({title:t,description:s})=>{const a=(0,r.useSelect)((e=>e(L).getSiteUrl()),[]),n=(0,r.useSelect)((e=>e(L).getTwitterImageUrl()),[]),o=(0,r.useSelect)((e=>e(L).getFacebookImageUrl()),[]),i=(0,r.useSelect)((e=>e(L).getEditorDataImageFallback()),[]),l=(0,r.useSelect)((e=>e(L).getTwitterImageType()),[]),u=(0,r.useSelect)((e=>e(L).getTwitterAltText()),[]);return(0,e.createElement)("div",{className:"yst-bg-slate-200 yst-p-2 yst--mx-6"},(0,e.createElement)(rt.TwitterPreview,{title:t,description:s,siteUrl:a,imageUrl:n,imageFallbackUrl:o||i,isLarge:"summary"!==l,alt:u,onSelect:c.noop,onImageClick:c.noop,onMouseHover:c.noop}))};wt.propTypes={title:Y().string.isRequired,description:Y().string.isRequired};const ht=()=>(0,e.createElement)("div",{className:"yst-flex yst-flex-col yst-max-h-[370px] yst-w-[507px] yst-border yst-rounded-t-[14px] yst-overflow-hidden yst-mx-auto"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-[265px] yst-w-full yst-rounded-none yst-border yst-border-dashed"}),(0,e.createElement)("div",{className:"yst-w-full yst-p-4 yst-space-y-1"},(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-1/3"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-5 yst-w-10/12"}),(0,e.createElement)(l.SkeletonLoader,{className:"yst-h-3 yst-w-full"}))),ft=({className:t="",size:s=""})=>{const a=(0,r.useSelect)((e=>e(W).selectUsageCount()),[]),n=(0,r.useSelect)((e=>e(W).selectLimit()),[]),[o,c]=(0,D.useState)(!1);(0,D.useEffect)((()=>{c(a===n)}),[a,n]);const u=(0,D.useCallback)((()=>{c(!1)}),[]);return o&&(0,e.createElement)(l.Notifications.Notification,{id:"ai-sparks-limit",variant:"info",size:s,dismissScreenReaderLabel:(0,i.__)("Got it!","wordpress-seo-premium"),title:(0,i.sprintf)(/* translators: %s is the number of the sparks allowed. */ /* translators: %s is the number of the sparks allowed. */
(0,i._n)("You've used %s spark this month.","You've used %s sparks this month.",n,"wordpress-seo-premium"),n),className:t},(0,e.createElement)("p",null,(0,i.__)("As long as this is a beta feature, you get unlimited sparks.","wordpress-seo-premium")),(0,e.createElement)("div",{className:"yst-mt-3 yst--mr-8 yst-justify-end yst-flex"},(0,e.createElement)(l.Button,{type:"button",variant:"primary",size:"small",onClick:u},(0,i.__)("Got it!","wordpress-seo-premium"))))};ft.propTypes={className:Y().string,size:Y().string};const Et="appliedSuggestions",vt=(0,u.createSlice)({name:Et,initialState:{},reducers:{addAppliedSuggestion:(e,{payload:{editType:t,previewType:s,suggestion:r}})=>{e[s]={...e[s],[t]:r}}}}),bt=vt.getInitialState,St={selectAppliedSuggestions:e=>(0,c.get)(e,Et,{})};St.selectAppliedSuggestionFor=(0,u.createSelector)([St.selectAppliedSuggestions,(e,t)=>t],((e,{editType:t,previewType:s})=>(0,c.get)(e,[s,t],"")));const _t=vt.actions,kt=vt.reducer,xt="productSubscriptions",Ct=(0,u.createSlice)({name:xt,initialState:{premiumSubscription:!1,wooCommerceSubscription:!1},reducers:{}}),Nt=Ct.getInitialState,Tt={selectProductSubscriptions:e=>(0,c.get)(e,xt,!1),selectPremiumSubscription:e=>(0,c.get)(e,`${xt}.premiumSubscription`),selectWooCommerceSubscription:e=>(0,c.get)(e,`${xt}.wooCommerceSubscription`)},Rt=Ct.actions,At=Ct.reducer,Pt="promptContent",$t=(0,u.createSlice)({name:Pt,initialState:{content:"",initialized:!1},reducers:{setPromptContent:(e,{payload:t})=>({content:t,initialized:!0})}}),It=$t.getInitialState,Lt={selectPromptContent:e=>(0,c.get)(e,`${Pt}.content`,""),selectPromptContentInitialized:e=>(0,c.get)(e,`${Pt}.initialized`,!1)},qt=$t.actions,Mt=$t.reducer,Ot="promptContentFixAssessments",Ut=(0,u.createSlice)({name:Ot,initialState:{introduction:{text:"",length:0},fullContent:{text:"",length:0}},reducers:{setPromptContentFixAssessments:(e,{payload:t})=>t}}),Ft=Ut.getInitialState,Bt={selectPromptContentFixAssessments:e=>(0,c.get)(e,Ot,"")},Dt=Ut.actions,Gt=Ut.reducer,Yt="appliedFixesStatus",Wt=(0,u.createSlice)({name:Yt,initialState:!1,reducers:{setAreFixesApplied:(e,{payload:t})=>t}}),zt=Wt.getInitialState,Ht={areFixesApplied:e=>(0,c.get)(e,Yt,"")},jt=Wt.actions,Vt=Wt.reducer,Kt="usageCount",Xt="fetchUsageCount",Jt=(0,u.createSlice)({name:Kt,initialState:{currentUsageCount:0,currentLimit:100},reducers:{addUsageCount:(e,{payload:t=1})=>{e.currentUsageCount=e.currentUsageCount+t}},extraReducers:e=>{e.addCase(`${Xt}/${q}`,(e=>{e.currentUsageCount=0})),e.addCase(`${Xt}/${M}`,((e,t)=>{e.currentUsageCount=(0,c.get)(t,"payload.totalUsed.license",0),e.currentLimit=(0,c.get)(t,"payload.totalUsed.limit",100)})),e.addCase(`${Xt}/${O}`,(e=>{e.currentUsageCount=0}))}}),Qt=Jt.getInitialState,Zt={selectUsageCount:e=>(0,c.get)(e,[Kt,"currentUsageCount"],0),selectLimit:e=>(0,c.get)(e,[Kt,"currentLimit"],100)},es={...Jt.actions,fetchUsageCount:function*(){yield{type:`${Xt}/${q}`};try{const e=yield{type:Xt};return{type:`${Xt}/${M}`,payload:e}}catch(e){return{type:`${Xt}/${O}`,payload:e}}}},ts={[Xt]:async()=>f()({method:"POST",path:"yoast/v1/ai_generator/get_usage"})},ss=Jt.reducer;let rs=!1;const as=()=>{rs||(rs=!0)},ns=[X.attachment],os=(s,{fieldId:a,type:n})=>{const o=(0,c.get)(window,"wpseoPremiumAiGenerator.postType",""),i=(0,c.get)(window,"wpseoPremiumAiGenerator.contentType",""),u=(0,r.select)("yoast-seo/editor").getIsWooSeoUpsell()||(0,r.select)("yoast-seo/editor").getIsWooSeoUpsellTerm();if(ns.includes(o)||u)return s;const m=function(e){return e.startsWith("yoast-google-preview")?z:e.startsWith("social")?H:e.startsWith("x-")?j:void 0}(a);if(!m)return s;const p=(0,c.get)(window,"wpseoScriptData.metabox.isRtl",!1);return s.push((0,e.createElement)(t.Fill,{name:`yoast.replacementVariableEditor.additionalButtons.${a}`},(0,e.createElement)(l.Root,{context:{isRtl:p}},(0,e.createElement)(we,{value:{editType:n,previewType:m,postType:o,contentType:i}},(0,e.createElement)(Ve,{onUseAi:as}))))),s},is=(e,t)=>rs&&(0,r.select)(W).selectHasAiGeneratorConsent()?(de(t)&&e.push((0,i.__)("Please enter a valid focus keyphrase.","wordpress-seo-premium")),e):e,ls=()=>{const{setPromptContent:e}=(0,r.dispatch)(W);return()=>{(e=>{const t=(0,c.get)(window,"wpseoPremiumAiGenerator.postType","")===X.product,s=(0,c.get)(window,"wpseoPremiumAiGenerator.contentType","")===Q,r=(0,c.get)(window,"wpseoScriptData.isWooCommerceActive",!1),a=t&&r||s?150:300,n=(0,c.get)(window,"YoastSEO.analysis.worker.runResearch",c.noop),o=(0,c.get)(window,"YoastSEO.analysis.collectData",!1);n("getParagraphs",o?oe.Paper.parse(o()):null).then((t=>{let s="";if(t.result){const e=t.result;if(e){let t=0;e.forEach((e=>{e.sentences.forEach((e=>{if(t+=e.tokens.length,t>a)return s;s+=e.text.replace(/[\n\r]+/g," ")})),s+=" ",t+=1}))}}e(s.trimEnd()||".")}))})(e)}},cs=()=>{ls(),(0,r.subscribe)((0,c.debounce)((()=>{const{getEditorDataContent:e}=(0,r.select)("yoast-seo/editor"),t=(0,c.get)(window,"yoast.editorModules.helpers.createWatcher",c.noop),s=ls();return setTimeout(s,1500),t(e,s)})(),1500,{maxWait:3e3}))};n()((()=>{((e={})=>{(0,r.register)((e=>(0,r.createReduxStore)(W,{actions:{...g,...k,..._t,...Rt,...qt,...Dt,...jt,...es},selectors:{...y,..._,...St,...Tt,...Lt,...Bt,...Ht,...Zt},initialState:(0,c.merge)({},{[m]:d(),[E]:S(),[Et]:bt(),[xt]:Nt(),[Pt]:It(),[Ot]:Ft(),[Yt]:zt(),[Kt]:Qt()},e),reducer:(0,r.combineReducers)({[m]:w,[E]:C,[Et]:kt,[xt]:At,[Pt]:Mt,[Ot]:Gt,[Yt]:Vt,[Kt]:ss}),controls:{...x,...ts}}))(e))})({[m]:(0,c.get)(window,"wpseoPremiumAiGenerator.adminUrl",""),[E]:"1"===(0,c.get)(window,"wpseoPremiumAiGenerator.hasConsent",!1),[xt]:(0,c.get)(window,"wpseoPremiumAiGenerator.productSubscriptions",{})}),(0,o.addFilter)("yoast.replacementVariableEditor.additionalButtons","yoast/yoast-seo-premium/AiGenerator",os),(0,o.addFilter)("yoast.focusKeyphrase.errors","yoast/yoast-seo-premium/AiGenerator",is),(0,o.addAction)("yoast.elementor.loaded","yoast/yoast-seo-premium/AiGenerator",cs)})),window.jQuery(window).on("YoastSEO:ready",(()=>{cs()}))})()})();