diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ee720b1b..80d00046e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ This is an alpha version! The changes listed here are not final. - Add retry event for Brief - AI Assistant: Add A8c dictionary - AI Assistant: add AI Guidelines link to the AI Assistant sidebar panel +- AI Assistant: Add FeatureControl to Write Brief - AI Assistant: Add option to add word to spelling dictionary - AI Assistant: Do not mark words starting with special characters as spelling mistakes - AI Assistant: Fix flickering when adding word to Breve dictionary diff --git a/_inc/blocks/editor-beta.asset.php b/_inc/blocks/editor-beta.asset.php index a978c78ac9..25e429d45b 100644 --- a/_inc/blocks/editor-beta.asset.php +++ b/_inc/blocks/editor-beta.asset.php @@ -1 +1 @@ - array('jetpack-script-data', 'lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-block-serialization-default-parser', 'wp-blocks', 'wp-commands', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-rich-text', 'wp-token-list', 'wp-url', 'wp-viewport', 'wp-widgets', 'wp-wordcount'), 'version' => '085a56f80b46ffafb632'); + array('jetpack-script-data', 'lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-block-serialization-default-parser', 'wp-blocks', 'wp-commands', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-rich-text', 'wp-token-list', 'wp-url', 'wp-viewport', 'wp-widgets', 'wp-wordcount'), 'version' => '980be369b3a62d973a9c'); diff --git a/_inc/blocks/editor-beta.js b/_inc/blocks/editor-beta.js index 0749fff62e..70202e5c69 100644 --- a/_inc/blocks/editor-beta.js +++ b/_inc/blocks/editor-beta.js @@ -5,7 +5,7 @@ __("You have %1$d requests remaining.","jetpack"),e)),React.createElement(r.Butt // translators: %1$d: A dynamic error message __("Error: %1$s","jetpack"),i)),t===d.Or?React.createElement(r.Button,{variant:"link",onClick:a,href:o,target:o?"_blank":null},__("Upgrade now","jetpack")):React.createElement(r.Button,{variant:"link",onClick:n},__("Try again","jetpack")))}},2166:(e,t,n)=>{"use strict";n.d(t,{R:()=>o,_:()=>s});var r=n(51609),a=n.n(r);const s=(0,r.createContext)({}),o=({value:e,children:t})=>a().createElement(s.Provider,{value:e,children:t})},13965:(e,t,n)=>{"use strict";n.d(t,{Rb:()=>r.R,Z2:()=>s.A,_z:()=>r._,cQ:()=>a.A});var r=n(2166),a=n(59886),s=n(53471)},53471:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(51609),a=n(78836),s=n(13965);function o({onDone:e,onSuggestion:t,onError:n}={}){const o=(0,r.useContext)(s._z),{eventSource:i}=o,c=(0,r.useCallback)((t=>e?.(t?.detail)),[e]),l=(0,r.useCallback)((e=>t?.(e?.detail)),[t]),u=(0,r.useCallback)((e=>{n?.(e?.detail)}),[]);return(0,r.useEffect)((()=>{if(i)return e&&i.addEventListener("done",c),t&&i.addEventListener("suggestion",l),n&&i.addEventListener(a.zn,u),()=>{i.removeEventListener("done",c),i.removeEventListener("suggestion",l),i.removeEventListener(a.zn,u)}}),[i]),o}},59886:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(29491),a=n(86087),s=n(51609),o=n.n(s),i=n(46219),c=n(13965);const l=(0,r.createHigherOrderComponent)((e=>t=>{const{suggestion:n,error:r,requestingState:s,request:l,stopSuggestion:u,eventSource:d}=(0,i.Ay)(),p=(0,a.useMemo)((()=>({suggestion:n,requestingError:r,requestingState:s,eventSource:d,requestSuggestion:l,stopSuggestion:u})),[n,r,s,d,l,u]);return o().createElement(c.Rb,{value:p},o().createElement(e,t))}),"withAiDataProvider")},46219:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>l,fC:()=>i});var r=n(86087),a=n(27723),s=n(87286),o=n(78836);const __=a.__;function i(e){switch(e){case o.Or:return{code:o.Or,message:__("You have reached the limit of requests for this site.","jetpack"),severity:"info"};case o.L9:return{code:o.L9,message:__("Your request was unclear. Mind trying again?","jetpack"),severity:"info"};case o.AZ:return{code:o.AZ,message:__("Jetpack AI services are currently unavailable. Sorry for the inconvenience.","jetpack"),severity:"info"};case o.ud:return{code:o.ud,message:__("This request has been flagged by our moderation system. Please try to rephrase it and try again.","jetpack"),severity:"info"};case o.cT:return{code:o.cT,message:__("The content is too large to be processed all at once. Please try to shorten it or divide it into smaller parts.","jetpack"),severity:"info"};case o.mA:default:return{code:o.mA,message:__("It was not possible to process your request. Mind trying again?","jetpack"),severity:"info"}}}function c(e){return e.replace(/^<\|start_header_id\|>assistant<\|end_header_id\|>[\n]+/,"")}function l({prompt:e,autoRequest:t=!1,askQuestionOptions:n={},initialRequestingState:a="init",onSuggestion:l,onDone:u,onStop:d,onError:p,onAllErrors:m}={}){const[g,A]=(0,r.useState)(a),[h,E]=(0,r.useState)(""),[f,b]=(0,r.useState)(),v=(0,r.useRef)(void 0),C=(0,r.useCallback)((e=>{const t=c(e?.detail);t&&(E(t),l?.(t))}),[l]),k=(0,r.useCallback)((e=>{N();const t=c(e?.detail);u?.(t),A("done")}),[u]),y=(0,r.useCallback)((e=>{m?.(e?.detail)}),[m]),B=(0,r.useCallback)((e=>{v?.current?.close(),A("error"),b(i(e)),p?.(i(e))}),[p]),w=(0,r.useCallback)((()=>B(o.Or)),[]),_=(0,r.useCallback)((()=>B(o.L9)),[]),I=(0,r.useCallback)((()=>B(o.AZ)),[]),j=(0,r.useCallback)((()=>B(o.ud)),[]),x=(0,r.useCallback)((()=>B(o.mA)),[]),S=(0,r.useCallback)((async(e,t={...n})=>{if(b(void 0),A("requesting"),v.current=await(0,s.A)(e,t),!v?.current)return;const r=v.current;A("suggesting"),r.addEventListener("suggestion",C),r.addEventListener(o.Or,w),r.addEventListener(o.L9,_),r.addEventListener(o.AZ,I),r.addEventListener(o.ud,j),r.addEventListener(o.mA,x),r.addEventListener(o.zn,y),r.addEventListener("done",k)}),[k,w,_,I,j,x,C]),Q=(0,r.useCallback)((()=>{A("init"),E(""),b(void 0)}),[]),N=(0,r.useCallback)((()=>{if(!v?.current)return;const e=v?.current;e.close(),e.removeEventListener("suggestion",C),e.removeEventListener(o.Or,w),e.removeEventListener(o.L9,_),e.removeEventListener(o.AZ,I),e.removeEventListener(o.ud,j),e.removeEventListener(o.mA,x),e.removeEventListener("done",k)}),[v,C,w,_,I,j,x,k]),R=(0,r.useCallback)((()=>{N(),d?.(),A("done")}),[d]);return(0,r.useEffect)((()=>{if(e?.length)return t&&S(e,n),()=>{R()}}),[t,e,S,R]),{suggestion:h,error:f,requestingState:g,request:S,stopSuggestion:R,reset:Q,handleErrorQuotaExceededError:w,eventSource:v.current}}},7804:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(86087),a=n(27723),s=n(10067),o=n.n(s),i=n(57745);const __=a.__,c=o()("jetpack-ai-client:use-audio-transcription"),l=e=>{if("string"==typeof e)return e;if("code"in e)switch(e.code){case"error_quota_exceeded":return __("You exceeded your current quota, please check your plan details.","jetpack");case"jetpack_ai_missing_audio_param":return __("The audio_file is required to perform a transcription.","jetpack");case"jetpack_ai_service_unavailable":return __("The Jetpack AI service is temporarily unavailable.","jetpack");case"file_size_not_supported":return __("The provided audio file is too big.","jetpack");case"file_type_not_supported":return __("The provided audio file type is not supported.","jetpack");case"jetpack_ai_error":return __("There was an error processing the transcription request.","jetpack");default:return e.message}return"message"in e?e.message:__("There was an error processing the transcription request.","jetpack")};function u({feature:e,onReady:t,onError:n}){const[a,s]=(0,r.useState)(""),[o,u]=(0,r.useState)(""),[d,p]=(0,r.useState)(!1),m=(0,r.useRef)(null);return{transcriptionResult:a,isTranscribingAudio:d,transcriptionError:o,transcribeAudio:(0,r.useCallback)((r=>{c("Transcribing audio"),s(""),u(""),p(!0);const a=new AbortController;m.current=a,(0,i.A)(r,e,a.signal).then((e=>{s(e),t?.(e)})).catch((e=>{a.signal.aborted||(u(e.message),n?.(l(e)))})).finally((()=>p(!1)))}),[i.A,s,u,p]),cancelTranscription:(0,r.useCallback)((()=>{m.current?.abort(),s(""),u(""),p(!1)}),[m,s,u,p])}}},66859:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(86087),a=n(27723);const __=a.__,s=25e6,o=1500,i=["audio/mpeg","audio/mp3","audio/ogg","audio/flac","audio/x-flac","audio/m4a","audio/x-m4a","audio/mp4","audio/wav","audio/wave","audio/x-wav","audio/webm"];function c(){const[e,t]=(0,r.useState)(!1);return{isValidatingAudio:e,validateAudio:(0,r.useCallback)(((e,n,r)=>{if(t(!0),e?.size>s)return t(!1),r(__("The audio file is too large. The maximum file size is 25MB.","jetpack"));const a=e instanceof File;if(a&&!i.includes(e.type))return t(!1),r(__("The audio file type is not supported. Please use a supported audio file type.","jetpack"));const c=new AudioContext;e.arrayBuffer().then((s=>{c.decodeAudioData(s,(function(s){const i=Math.ceil(s.duration);return i>o?(t(!1),r(__("The audio file is too long. The maximum recording time is 25 minutes.","jetpack"))):(t(!1),n({duration:i,isFile:a,size:e?.size}))}))}))}),[t])}}},62614:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(10067),a=n.n(r),s=n(31439),o=n(51391);const i=a()("ai-client:use-image-generator"),c=(e,t)=>{const n=4e3-t;return e.length>n?e.substring(0,n-6)+" [...]":e},l=async(e,t,n)=>{const r=((e,t)=>{if(t){const n=`I need a Stable Diffusion prompt to generate a featured image for a blog post based on this user-provided image description:\n\n${t.length>1e3?t.substring(0,1e3):t}\n\nThe image should be a photo. Make sure you highlight the main suject of the image description, and include brief details about the light and style of the image.\nInclude a request to use high resolution and produce a highly detailed image, with sharp focus.\nReturn just the prompt, without comments.\n\nFor additional context, this is the post content:\n\n`;return n+c(e,n.length)}return"I need a Stable Diffusion prompt to generate a featured image for a blog post with the following content.\nThe image should be a photo. Make sure you highlight the main suject of the content, and include brief details about the light and style of the image.\nInclude a request to use high resolution and produce a highly detailed image, with sharp focus.\nReturn just the prompt, without comments. The content is:\n\n"+c(e,412)})(e,t);return await(0,s.A)(r,{feature:n})},u=()=>{const e=async function(e){let t="";try{t=(await(0,o.A)()).token}catch(e){return i("Error getting token: %o",e),Promise.reject(e)}try{const n="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-image",r={Authorization:`Bearer ${t}`,"Content-Type":"application/json"},a=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(e)}).then((e=>e.json()));return a?.data?.status&&a?.data?.status>200?(i("Error generating image: %o",a),Promise.reject(a)):a}catch(e){return i("Error generating image: %o",e),Promise.reject(e)}};return{generateImage:async function({feature:t,postContent:n,responseFormat:r="url",userPrompt:a}){try{i("Generating image");const s=((e,t)=>{if(t){const n=`I need a cover image for a blog post based on this user prompt:\n\n${t.length>1e3?t.substring(0,1e3):t}\n\nBefore creating the image, identify the main topic of the user prompt and relate it to the post content.\nDo not represent the whole content in one image, keep it simple and just represent one single idea.\nDo not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph.\nDo not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes.\nIf the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions.\nIf the content is more abstract, use a more abstract style to represent the main idea.\nMake sure the light and the style are visually appealing.\nDo not add text to the image.\n\nFor additional context, this is the post content:\n\n`;return n+c(e,n.length)}const n="I need a cover image for a blog post.\nBefore creating the image, identify the main topic of the content and only represent it.\nDo not represent the whole content in one image, keep it simple and just represent one single idea.\nDo not add details, detailed explanations or highlights from the content, just represent the main idea as if it was a photograph.\nDo not use collages or compositions with multiple elements or scenes. Stick to one single scene. Do not compose unrealistic scenes.\nIf the content describes facts, objects or concepts from the real world, represent them on a realistic style and do not make unreal compositions.\nIf the content is more abstract, use a more abstract style to represent the main idea.\nMake sure the light and the style are visually appealing.\nDo not add text to the image.\n\nThis is the post content:\n\n";return n+c(e,838)})(n,a),o={prompt:s,response_format:r,feature:t,size:"1792x1024"};return await e(o)}catch(e){return i("Error generating image: %o",e),Promise.reject(e)}},generateImageWithStableDiffusion:async function({feature:t,postContent:n,userPrompt:r}){try{i("Generating image with Stable Diffusion");const a={prompt:await l(n,r,t),feature:t,model:"stable-diffusion",style:"photographic"};return await e(a)}catch(e){return i("Error generating image: %o",e),Promise.reject(e)}},generateImageWithParameters:e}}},96657:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(86087);const a="audio/mp4;codecs=mp4a",s="audio/mp4",o="audio/webm";function i({onDone:e}={}){const t=(0,r.useRef)(null),[n,i]=(0,r.useState)("inactive"),c=(0,r.useRef)(!1),l=(0,r.useRef)(0),[u,d]=(0,r.useState)(0),p=(0,r.useRef)(null),[m,g]=(0,r.useState)(null),A=(0,r.useRef)([]).current,[h,E]=(0,r.useState)(null),f=(0,r.useRef)(null);function b(){return MediaRecorder.isTypeSupported(a)?new Blob(A,{type:s}):new Blob(A,{type:o})}const v=(0,r.useCallback)((e=>{if(B(),!e)return t?.current?.start();e<100&&(e=100),l.current=Date.now(),t?.current?.start(e)}),[]),C=(0,r.useCallback)((()=>{c.current=!0,t?.current?.pause(),d((e=>e+Date.now()-l.current))}),[]),k=(0,r.useCallback)((()=>{c.current=!1,t?.current?.resume(),l.current=Date.now()}),[]),y=(0,r.useCallback)((()=>{t?.current?.stop(),"recording"===n&&d((e=>e+Date.now()-l.current))}),[]),B=(0,r.useCallback)((()=>{A.length=0,g(null),E(null),d(0),c.current=!1,l.current=0}),[]),w=(0,r.useCallback)((()=>{t?.current&&(t.current.removeEventListener("start",j),t.current.removeEventListener("stop",x),t.current.removeEventListener("pause",S),t.current.removeEventListener("resume",Q),t.current.removeEventListener("dataavailable",N),t.current=null)}),[]),_=(0,r.useCallback)((()=>{if(i("inactive"),B(),w(),!navigator.mediaDevices?.getUserMedia)return;const e=new AudioContext;f.current=e.createAnalyser();navigator.mediaDevices.getUserMedia({audio:!0}).then((n=>{p.current=n;e.createMediaStreamSource(n).connect(f.current),MediaRecorder.isTypeSupported(a)?t.current=new MediaRecorder(n,{mimeType:a}):t.current=new MediaRecorder(n,{mimeType:o}),t.current.addEventListener("start",j),t.current.addEventListener("stop",x),t.current.addEventListener("pause",S),t.current.addEventListener("resume",Q),t.current.addEventListener("dataavailable",N)})).catch((e=>{throw e}))}),[]),I=(0,r.useCallback)((e=>{y(),E("string"==typeof e?e:e.message),i("error")}),[]);function j(){i("recording")}function x(){const t=b();e?.(t),A.length=0}function S(){i("paused")}function Q(){i("recording")}function N(e){const{data:t}=e;t?.size&&(A.push(t),g(b()),c.current||d((e=>{const t=Date.now(),n=t-l.current;return l.current=t,e+n})))}return(0,r.useEffect)((()=>(_(),()=>{p.current&&p.current.getTracks().forEach((e=>e.stop())),w()})),[]),{state:n,blob:m,error:h,duration:u,analyser:f.current,onError:I,controls:{start:v,pause:C,resume:k,stop:y,reset:_}}}},93869:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(63162),a=n(47143),s=n(86087),o=n(10067);const i=n.n(o)()("ai-client:save-to-media-library");function c(){const[e,t]=(0,s.useState)(!1),{getSettings:n}=(0,a.useSelect)((e=>e("core/block-editor")),[]);return{isLoading:e,saveToMediaLibrary:(e,a)=>{const s=n();return new Promise(((n,o)=>{t(!0),i("Fetching image from URL"),fetch(e).then((e=>{i("Transforming response to blob"),e.blob().then((e=>{i("Uploading blob to media library");const c=Array();a?c.push(new File([e],a)):c.push(e),s.mediaUpload({allowedTypes:["image"],filesList:c,onFileChange([e]){(0,r.isBlobURL)(e?.url)||(e&&(i("Image uploaded to media library",e),n(e)),t(!1))},onError(e){i("Error uploading image to media library:",e),o(e),t(!1)}})})).catch((e=>{i("Error transforming response to blob:",e?.message),o(e?.message),t(!1)}))})).catch((e=>{i("Error fetching image from URL:",e?.message),o(e?.message),t(!1)}))}))}}}},97784:(e,t,n)=>{"use strict";n.d(t,{A:()=>l,u:()=>c});var r=n(86087),a=n(10067),s=n.n(a),o=n(46219);const i=s()("jetpack-ai-client:use-transcription-post-processing"),c="voice-to-content-simple-draft";function l({feature:e,onReady:t,onError:n,onUpdate:a}){const[s,c]=(0,r.useState)(""),[l,u]=(0,r.useState)(""),[d,p]=(0,r.useState)(!1),m=(0,r.useCallback)((e=>{c(e),a?.(e)}),[c,a]),g=(0,r.useCallback)((e=>{c(e),a?.(e),t?.(e)}),[c,a,t]),A=(0,r.useCallback)((e=>{u(e.message),n?.(e.message)}),[u,n]),{request:h,stopSuggestion:E}=(0,o.Ay)({onSuggestion:m,onDone:g,onError:A});return{postProcessingResult:s,isProcessingTranscription:d,postProcessingError:l,processTranscription:(0,r.useCallback)(((t,n)=>{i("Post-processing transcription"),c(""),u(""),p(!0);h([{role:"jetpack-ai",context:{type:t,content:n}}],{feature:e})}),[c,u,p,h,e]),cancelTranscriptionProcessing:(0,r.useCallback)((()=>{E(),p(!1)}),[E,p])}}},30151:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(56427),a=n(51609),s=n.n(a);const o=s().createElement(r.SVG,{viewBox:"0 0 32 32",width:"32",height:"32",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"ai-assistant-icon"},s().createElement(r.Path,{className:"spark-first",d:"M9.33301 5.33325L10.4644 8.20188L13.333 9.33325L10.4644 10.4646L9.33301 13.3333L8.20164 10.4646L5.33301 9.33325L8.20164 8.20188L9.33301 5.33325Z"}),s().createElement(r.Path,{className:"spark-second",d:"M21.3333 5.33333L22.8418 9.15817L26.6667 10.6667L22.8418 12.1752L21.3333 16L19.8248 12.1752L16 10.6667L19.8248 9.15817L21.3333 5.33333Z"}),s().createElement(r.Path,{className:"spark-third",d:"M14.6667 13.3333L16.5523 18.1144L21.3333 20L16.5523 21.8856L14.6667 26.6667L12.781 21.8856L8 20L12.781 18.1144L14.6667 13.3333Z"}))},42154:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(56427);const a=React.createElement(r.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},React.createElement(r.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M10 3.95833C6.66328 3.95833 3.95833 6.66327 3.95833 9.99999C3.95833 13.3367 6.66328 16.0417 10 16.0417C13.3367 16.0417 16.0417 13.3367 16.0417 9.99999C16.0417 6.66327 13.3367 3.95833 10 3.95833ZM2.70833 9.99999C2.70833 5.97292 5.97292 2.70833 10 2.70833C14.0271 2.70833 17.2917 5.97292 17.2917 9.99999C17.2917 14.0271 14.0271 17.2917 10 17.2917C5.97292 17.2917 2.70833 14.0271 2.70833 9.99999Z"}),React.createElement(r.Path,{d:"M10.8333 5.83333H9.16667V10.8333H10.8333V5.83333Z"}),React.createElement(r.Path,{d:"M10.8333 12.5H9.16667V14.1667H10.8333V12.5Z"}))},91396:(e,t,n)=>{"use strict";n.d(t,{Qr:()=>o.A,Vo:()=>a.A,cj:()=>r.A,ni:()=>s.A});var r=n(30151),a=n(81353),s=(n(95007),n(96626),n(4416),n(25680)),o=n(67205)},81353:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(56427),a=n(51609),s=n.n(a);const o=s().createElement(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG"},s().createElement(r.Path,{d:"M12 4.75C11.0479 4.75 10.1052 4.93753 9.22554 5.30187C8.34593 5.66622 7.5467 6.20025 6.87348 6.87348C6.20025 7.5467 5.66622 8.34593 5.30187 9.22554C4.93753 10.1052 4.75 11.0479 4.75 12C4.75 12.9521 4.93753 13.8948 5.30187 14.7745C5.66622 15.6541 6.20025 16.4533 6.87348 17.1265C7.5467 17.7997 8.34593 18.3338 9.22554 18.6981C10.1052 19.0625 11.0479 19.25 12 19.25C13.9228 19.25 15.7669 18.4862 17.1265 17.1265C18.4862 15.7669 19.25 13.9228 19.25 12C19.25 10.0772 18.4862 8.23312 17.1265 6.87348C15.7669 5.51384 13.9228 4.75 12 4.75ZM3.25 12C3.25 9.67936 4.17187 7.45376 5.81282 5.81282C7.45376 4.17187 9.67936 3.25 12 3.25C14.3206 3.25 16.5462 4.17187 18.1872 5.81282C19.8281 7.45376 20.75 9.67936 20.75 12C20.75 14.3206 19.8281 16.5462 18.1872 18.1872C16.5462 19.8281 14.3206 20.75 12 20.75C9.67936 20.75 7.45376 19.8281 5.81282 18.1872C4.17187 16.5462 3.25 14.3206 3.25 12Z",fill:"#008710"}),s().createElement(r.Rect,{x:"10.5",y:"8.25",width:"3",height:"4.875",rx:"1.5",fill:"#008710"}),s().createElement(r.Path,{d:"M15 11.25C15 11.644 14.9224 12.0341 14.7716 12.3981C14.6209 12.762 14.3999 13.0927 14.1213 13.3713C13.8427 13.6499 13.512 13.8709 13.1481 14.0216C12.7841 14.1724 12.394 14.25 12 14.25C11.606 14.25 11.2159 14.1724 10.8519 14.0216C10.488 13.8709 10.1573 13.6499 9.87868 13.3713C9.6001 13.0927 9.37913 12.762 9.22836 12.3981C9.0776 12.0341 9 11.644 9 11.25",stroke:"#008710",strokeWidth:"1.125",strokeLinecap:"round"}),s().createElement(r.Path,{d:"M11.4375 15.75C11.4375 16.0607 11.6893 16.3125 12 16.3125C12.3107 16.3125 12.5625 16.0607 12.5625 15.75L11.4375 15.75ZM11.4375 14.25L11.4375 15.75L12.5625 15.75L12.5625 14.25L11.4375 14.25Z",fill:"#008710"}))},95007:(e,t,n)=>{"use strict";var r=n(56427),a=n(51609),s=n.n(a);r.SVG,r.Path,r.Path},25680:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(56427),a=n(51609),s=n.n(a);const o=s().createElement(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG"},s().createElement(r.Path,{d:"M12 4.75C11.0479 4.75 10.1052 4.93753 9.22554 5.30187C8.34593 5.66622 7.5467 6.20025 6.87348 6.87348C6.20025 7.5467 5.66622 8.34593 5.30187 9.22554C4.93753 10.1052 4.75 11.0479 4.75 12C4.75 12.9521 4.93753 13.8948 5.30187 14.7745C5.66622 15.6541 6.20025 16.4533 6.87348 17.1265C7.5467 17.7997 8.34593 18.3338 9.22554 18.6981C10.1052 19.0625 11.0479 19.25 12 19.25C13.9228 19.25 15.7669 18.4862 17.1265 17.1265C18.4862 15.7669 19.25 13.9228 19.25 12C19.25 10.0772 18.4862 8.23312 17.1265 6.87348C15.7669 5.51384 13.9228 4.75 12 4.75ZM3.25 12C3.25 9.67936 4.17187 7.45376 5.81282 5.81282C7.45376 4.17187 9.67936 3.25 12 3.25C14.3206 3.25 16.5462 4.17187 18.1872 5.81282C19.8281 7.45376 20.75 9.67936 20.75 12C20.75 14.3206 19.8281 16.5462 18.1872 18.1872C16.5462 19.8281 14.3206 20.75 12 20.75C9.67936 20.75 7.45376 19.8281 5.81282 18.1872C4.17187 16.5462 3.25 14.3206 3.25 12Z",fill:"#008710"}),s().createElement(r.Rect,{x:"12.75",y:"9",width:"2.25",height:"6",fill:"#008710"}),s().createElement(r.Rect,{x:"9",y:"9",width:"2.25",height:"6",fill:"#008710"}))},96626:(e,t,n)=>{"use strict";var r=n(56427),a=n(51609),s=n.n(a);r.SVG,r.Path,r.Path},4416:(e,t,n)=>{"use strict";var r=n(56427),a=n(51609),s=n.n(a);r.SVG,r.Path,r.Rect},67205:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(56427),a=n(51609),s=n.n(a);const o=s().createElement(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s().createElement(r.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.5 10C12.5 11.3807 11.3807 12.5 10 12.5C8.61929 12.5 7.5 11.3807 7.5 10C7.5 8.61929 8.61929 7.5 10 7.5C11.3807 7.5 12.5 8.61929 12.5 10ZM14 10C14 12.2091 12.2091 14 10 14C7.79086 14 6 12.2091 6 10C6 7.79086 7.79086 6 10 6C12.2091 6 14 7.79086 14 10ZM16.75 21V19C16.75 17.4812 15.5188 16.25 14 16.25L6 16.25C4.48122 16.25 3.25 17.4812 3.25 19V21H4.75L4.75 19C4.75 18.3096 5.30964 17.75 6 17.75L14 17.75C14.6904 17.75 15.25 18.3096 15.25 19V21H16.75Z",fill:"currentColor"}),s().createElement(r.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M19.976 16.3599C21.2507 14.5642 22.0001 12.3695 22.0001 9.99969C22.0001 7.63128 21.2515 5.43769 19.9782 3.64258L18.754 4.50967C19.8537 6.05996 20.5001 7.95434 20.5001 9.99969C20.5001 12.0464 19.8528 13.9419 18.7519 15.4928L19.976 16.3599ZM17.3357 14.4897C18.2357 13.222 18.7648 11.6727 18.7648 9.99969C18.7648 8.32808 18.2365 6.77984 17.3379 5.51279L16.1137 6.37988C16.8387 7.4021 17.2648 8.65114 17.2648 9.99969C17.2648 11.3496 16.8378 12.5998 16.1116 13.6226L17.3357 14.4897Z",fill:"currentColor"}))},96865:(e,t,n)=>{"use strict";n.d(t,{AK:()=>d.AK,AZ:()=>m.AZ,E0:()=>o.A,FC:()=>d.FC,Hh:()=>g.Hh,Kf:()=>l.A,L9:()=>m.L9,N0:()=>d.N0,OO:()=>g.OO,Or:()=>m.Or,Qr:()=>u.Qr,R0:()=>r.A,Su:()=>g.Su,Tg:()=>A.T,Vo:()=>u.Vo,XE:()=>a.Ay,Yj:()=>d.Yj,Z2:()=>p.Z2,be:()=>s.A,cQ:()=>p.cQ,cT:()=>m.cT,cj:()=>u.cj,mA:()=>m.mA,ni:()=>u.ni,rh:()=>g.rh,rr:()=>c.A,uH:()=>m.uH,ud:()=>m.ud,wS:()=>d.wS,xA:()=>i.A,z3:()=>d.z3});n(51391),n(53664),n(87286);var r=n(31439),a=(n(57745),n(46219)),s=n(96657),o=n(7804),i=n(97784),c=n(66859),l=n(62614),u=n(91396),d=n(27802),p=n(13965),m=n(78836),g=n(72586),A=n(23101)},51391:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(85985),a=n(10067),s=n.n(a),o=n(48931);const i=s()("jetpack-ai-client:jwt"),c="jetpack-ai-jwt",l=12e4;async function u({apiNonce:e,siteId:t,expirationTime:n}={}){e=e||window.JP_CONNECTION_INITIAL_STATE.apiNonce,t=t||window.JP_CONNECTION_INITIAL_STATE.siteSuffix,n=n||l;const a=(0,r.Sy)(),s=localStorage.getItem(c);let u,d=null;if(s)try{d=JSON.parse(s)}catch(e){i("Error parsing token",e)}if(d&&d?.expire>Date.now())return i("Using cached token"),d;u=a?await(0,o.A)({path:"/wpcom/v2/sites/"+t+"/jetpack-openai-query/jwt",method:"POST"}):await(0,o.A)({path:"/jetpack/v4/jetpack-ai-jwt?_cacheBuster="+Date.now(),credentials:"same-origin",headers:{"X-WP-Nonce":e},method:"POST"});const p={token:u.token,blogId:a?t:u.blog_id,expire:Date.now()+n};return i("Storing new token"),localStorage.setItem(c,JSON.stringify(p)),p}},72586:(e,t,n)=>{"use strict";n.d(t,{Hh:()=>r.Hh,OO:()=>r.OO,Su:()=>r.Su,rh:()=>r.rh});var r=n(55166)},68641:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(21147);const a={paragraph:e=>e.replaceAll("\n","
")},s={emDelimiter:"_",headingStyle:"atx"},o={strikethrough:{filter:["del","s"],replacement:function(e){return"~~"+e+"~~"}}};class i{constructor({options:e={},rules:t={},keep:n=[],remove:a=[],fixes:i=[]}={}){this.fixes=i,this.turndownService=new r.A({...s,...e}),this.turndownService.keep(n),this.turndownService.remove(a);const c={...o,...t};for(const e in c)this.turndownService.addRule(e,c[e])}render({content:e}){const t=this.turndownService.turndown(e);return this.fixes.reduce(((e,t)=>a[t](e)),t)}}},55166:(e,t,n)=>{"use strict";n.d(t,{Hh:()=>i,OO:()=>r.A,Su:()=>a.S,rh:()=>c});var r=n(68641),a=n(31737);const s=new a.A,o=new r.A,i=({content:e,rules:t,extension:n})=>s.render({content:e,rules:t,extension:n}),c=({content:e})=>o.render({content:e})},31737:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,S:()=>s});var r=n(97158);const a=e=>e.replaceAll("\x3c!-- wp:list-item --\x3e","").replaceAll("\x3c!-- /wp:list-item --\x3e","").replaceAll("\x3c!-- wp:list --\x3e","").replaceAll("\x3c!-- /wp:list --\x3e","").replaceAll("
  • ","\x3c!-- wp:list-item --\x3e
  • ").replaceAll("
  • ","\x3c!-- /wp:list-item --\x3e").replaceAll("
      ",'\x3c!-- wp:list {"ordered":true} --\x3e
        ').replaceAll("
      ","
    \x3c!-- /wp:list --\x3e").replaceAll("\x3c!-- /wp:list --\x3e"),s={list:(e,t=!1)=>{const n=e.replace(/
  • \s+

    /g,"

  • ").replace(/<\/p>\s+<\/li>/g,"
  • ");return t?a(n):n},listItem:(e,t=!1)=>t?a(e.replace(/^<[ou]l>\s*/g,"").replace(/\s*<\/[ou]l>\s*$/g,"")):e,paragraph:(e,t=!1)=>t?e.replaceAll(/\s*<br \/>\s*/g,"
    "):e,table:(e,t=!1,{hasFixedLayout:n=!1})=>t?e.startsWith("\x3c!-- wp:table")?e:`\x3c!-- wp:table { "hasFixedLayout":${n?"true":"false"} } --\x3e${e}\x3c!-- /wp:table --\x3e`:e},o={breaks:!0},i=["list"];class c{constructor(e=o){this.markdownConverter=new r.A(e)}render({content:e,rules:t=i,extension:n=!1}){const r=this.markdownConverter.render(e);return t.reduce(((e,t)=>s[t](e,n)),r)}}},21902:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=()=>React.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon"},React.createElement("path",{d:"M6.99976 3.99994L7.84828 6.15141L9.99976 6.99994L7.84828 7.84847L6.99976 9.99994L6.15123 7.84847L3.99976 6.99994L6.15123 6.15141L6.99976 3.99994Z"}),React.createElement("path",{d:"M16 4L17.1314 6.86863L20 8L17.1314 9.13137L16 12L14.8686 9.13137L12 8L14.8686 6.86863L16 4Z"}),React.createElement("path",{d:"M11 10L12.4142 13.5858L16 15L12.4142 16.4142L11 20L9.58579 16.4142L6 15L9.58579 13.5858L11 10Z"}))},11574:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=()=>React.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon"},React.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.9291 7.96836L10.7308 17.6492L6.2145 14.2911L7.10952 13.0873L10.4221 15.5504L16.7253 7.07333L17.9291 7.96836Z"}))},47621:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=()=>React.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon"},React.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.2927 13.7485C18.5014 17.0423 15.5366 19.4901 12 19.4901C8.92508 19.4901 6.28236 17.6396 5.12469 14.9915L8.79556 12.8139L12.2508 14.0309C12.482 14.1123 12.7383 14.0756 12.9374 13.9327L15.8243 11.8601L15.9039 11.8992C16.1998 12.0451 16.6072 12.249 17.0533 12.4807C17.8331 12.8857 18.6946 13.3572 19.2927 13.7485ZM19.499 12.1129C18.9341 11.7788 18.3001 11.4379 17.7447 11.1495C17.287 10.9118 16.8698 10.7031 16.5672 10.5539C16.4158 10.4792 16.2928 10.4193 16.2074 10.378L16.1085 10.3303L16.0824 10.3177L16.0729 10.3132C15.8261 10.1954 15.5347 10.2214 15.3126 10.3809L12.3802 12.4861L8.9634 11.2827C8.75395 11.2089 8.52258 11.2318 8.3316 11.3451L4.65716 13.5248C4.55414 13.0294 4.5 12.5161 4.5 11.9901C4.5 7.84798 7.85786 4.49011 12 4.49011C16.1421 4.49011 19.5 7.84798 19.5 11.9901C19.5 12.0311 19.4997 12.072 19.499 12.1129ZM21 11.9901C21 16.9607 16.9706 20.9901 12 20.9901C7.02944 20.9901 3 16.9607 3 11.9901C3 7.01955 7.02944 2.99011 12 2.99011C16.9706 2.99011 21 7.01955 21 11.9901Z"}))},97034:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=()=>React.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"jetpack-ai-logo-generator-icon"},React.createElement("path",{d:"M7 6.49011L11 8.99011L7 11.4901V6.49011Z"}),React.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 2.99011C3.89543 2.99011 3 3.88554 3 4.99011V18.9901C3 20.0947 3.89543 20.9901 5 20.9901H19C20.1046 20.9901 21 20.0947 21 18.9901V4.99011C21 3.88554 20.1046 2.99011 19 2.99011H5ZM19 4.49011H5C4.72386 4.49011 4.5 4.71397 4.5 4.99011V15.6973L8.12953 13.0508C8.38061 12.8677 8.71858 12.8584 8.97934 13.0274L11.906 14.9243L15.4772 11.4524C15.7683 11.1694 16.2317 11.1694 16.5228 11.4524L19.5 14.3469V4.99011C19.5 4.71397 19.2761 4.49011 19 4.49011ZM4.5 18.9901V17.5537L8.59643 14.5667L11.5921 16.5084C11.8857 16.6987 12.2719 16.6607 12.5228 16.4167L16 13.0361L19.4772 16.4167L19.5 16.3933V18.9901C19.5 19.2663 19.2761 19.4901 19 19.4901H5C4.72386 19.4901 4.5 19.2663 4.5 18.9901Z"}))},95933:(e,t,n)=>{"use strict";n.d(t,{x:()=>s});var r=n(56427),a=n(27723);const __=a.__,s=({onCancel:e,onRetry:t})=>{const n=__("We are sorry. There was an error loading your Jetpack AI plan data. Please, try again.","jetpack");return React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper"},React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message"},React.createElement("span",{className:"jetpack-ai-logo-generator-modal__loading-message"},n)),React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-actions"},React.createElement(r.Button,{variant:"tertiary",onClick:e},__("Cancel","jetpack")),React.createElement(r.Button,{variant:"primary",onClick:t},__("Try again","jetpack"))))}},76194:(e,t,n)=>{"use strict";n.d(t,{N:()=>i});var r=n(27723),a=n(51609),s=n.n(a),o=n(42669);const __=r.__,i=({state:e="loadingFeature"})=>{const t=__("Loading…","jetpack"),n=__("Analyzing your site to create the perfect logo…","jetpack"),r=__("Generating logo…","jetpack");return s().createElement("div",{className:"jetpack-ai-logo-generator-modal__loading-wrapper"},s().createElement(o.$,null),s().createElement("span",{className:"jetpack-ai-logo-generator-modal__loading-message"},"loadingFeature"===e&&t,"analyzing"===e&&n,"generating"===e&&r))}},64537:(e,t,n)=>{"use strict";n.d(t,{T:()=>I});var r=n(85985),a=n(56427),s=n(47143),o=n(27723),i=n(51113),c=n(53512),l=n(13022),u=n(10067),d=n.n(u),p=n(51609),m=n(61356),g=n(60674),A=n(88725),h=n(44461),E=n(19362),f=n(74423),b=n(95933),v=n(76194),C=n(32623),k=n(34706),y=n(11114),B=n(35421),w=n(48204);const __=o.__,_=d()("jetpack-ai-calypso:generator-modal"),I=({isOpen:e,onClose:t,onApplyLogo:n,onReload:o,siteDetails:u,context:d,placement:I})=>{const{tracks:j}=(0,r.st)(),{recordEvent:x}=j,{setSiteDetails:S,fetchAiAssistantFeature:Q,loadLogoHistory:N}=(0,s.useDispatch)(f.E),{getIsRequestingAiAssistantFeature:R}=(0,s.select)(f.E),[T,P]=(0,p.useState)(null),[L,M]=(0,p.useState)(),D=(0,p.useRef)(!0),F=(0,p.useRef)(!1),[O,z]=(0,p.useState)(!1),[U,H]=(0,p.useState)(!1),{selectedLogo:V,getAiAssistantFeature:q,generateFirstPrompt:G,generateLogo:$,setContext:W}=(0,A.A)(),{featureFetchError:Z,firstLogoPromptFetchError:J,clearErrors:Y}=(0,h.A)(),K=u?.ID,[X,ee]=(0,p.useState)(!1),{nextTierCheckoutURL:te}=(0,g.Q)(),ne=q(),re=(0,p.useCallback)((async()=>{try{P("analyzing"),x(m.vm,{context:d,tool:"first-prompt"});const e=await G();M(e),P("generating"),await $({prompt:e}),P(null)}catch(e){_("Error generating first logo",e),P(null)}}),[d,G,$]),ae=(0,p.useCallback)((async()=>{try{const e=!(0,E.NP)(String(K)),t=ne?.costs?.["jetpack-ai-logo-generator"]?.logo??m._S,n=1,r=ne?.currentTier?.value||0,a=ne?.usagePeriod?.requestsCount||0,s=!(1===r)&&!!ne?.nextTier&&!e&&r-a{W(d),x(m.iz,{context:d,placement:I}),ae()}),[W,d,I,ae]),oe=()=>{D.current=!0,t(),P(null),z(!1),H(!1),Y(),ee(!1),x(m.ub,{context:d,placement:I})},ie=e=>{ee(!0),n?.(e)},ce=()=>{x(m.$i,{context:d})};let le;return(0,p.useEffect)((()=>{if(K&&S(u),!F.current){R()||(F.current=!0,Q())}}),[K,u,S,R]),(0,p.useEffect)((()=>{e&&K&&ne?.costs&&D.current&&(D.current=!1,se())}),[e,K,se,ne]),le=T?React.createElement(v.N,{state:T}):Z||J?React.createElement(b.x,{onCancel:oe,onRetry:()=>{oe(),o?.()}}):O||U?React.createElement(B.R,{onCancel:oe,upgradeURL:te,reason:O?"feature":"requests"}):React.createElement(React.Fragment,null,!X&&React.createElement(y.X,{initialPrompt:L}),React.createElement(k.s,{logo:V,onApplyLogo:ie,logoAccepted:X,siteId:String(K)}),X?React.createElement("div",{className:"jetpack-ai-logo-generator__accept"},React.createElement(w.H,null),React.createElement("div",{className:"jetpack-ai-logo-generator__accept-actions"},React.createElement(a.Button,{variant:"primary",onClick:oe},__("Close","jetpack")))):React.createElement(React.Fragment,null,React.createElement(C.N,null),React.createElement("div",{className:"jetpack-ai-logo-generator__footer"},React.createElement(a.Button,{variant:"link",className:"jetpack-ai-logo-generator__feedback-button",href:"https://jetpack.com/redirect/?source=jetpack-ai-feedback",target:"_blank",onClick:ce},React.createElement("span",null,__("Provide feedback","jetpack")),React.createElement(i.A,{icon:c.A,className:"icon"}))))),React.createElement(React.Fragment,null,e&&React.createElement(a.Modal,{className:"jetpack-ai-logo-generator-modal",onRequestClose:oe,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,title:__("Jetpack AI Logo Generator","jetpack")},React.createElement("div",{className:(0,l.A)("jetpack-ai-logo-generator-modal__body",{"notice-modal":O||U||Z||J})},le)))}},32623:(e,t,n)=>{"use strict";n.d(t,{N:()=>c});var r=n(85985),a=n(56427),s=n(13022),o=n(61356),i=n(88725);const c=()=>{const{tracks:e}=(0,r.st)(),{recordEvent:t}=e,{logos:n,selectedLogo:c,setSelectedLogoIndex:l,context:u}=(0,i.A)(),d=e=>{const t=new URL(e);return t.searchParams.has("resize")||t.searchParams.append("resize","48,48"),t.toString()};return React.createElement("div",{className:"jetpack-ai-logo-generator__carousel"},n.map(((e,r)=>React.createElement(a.Button,{key:e.url,className:(0,s.A)("jetpack-ai-logo-generator__carousel-logo",{"is-selected":e.url===c.url}),onClick:()=>(e=>{t(o.Nt,{context:u,logos_count:n.length,selected_logo:e+1}),l(e)})(r)},React.createElement("img",{src:d(e.url),alt:e.description})))))}},42669:(e,t,n)=>{"use strict";n.d(t,{$:()=>s});var r=n(13022),a=n(26076);const s=({className:e=null})=>React.createElement("img",{src:a,alt:"Loading",className:(0,r.A)("jetpack-ai-logo-generator-modal__loader",e)})},34706:(e,t,n)=>{"use strict";n.d(t,{s:()=>B});var r=n(85985),a=n(56427),s=n(47143),o=n(27723),i=n(10067),c=n.n(i),l=n(11574),u=n(47621),d=n(97034),p=n(61356),m=n(88725),g=n(44461),A=n(19362),h=n(74423),E=n(42669);const __=o.__,f=c()("jetpack-ai-calypso:logo-presenter"),b=({siteId:e})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,{saveLogo:o,selectedLogo:i,isSavingLogoToLibrary:c,logos:u,selectedLogoIndex:g,context:E}=(0,m.A)(),b=!!i?.mediaId,{loadLogoHistory:v}=(0,s.useDispatch)(h.E),C=__("Saving…","jetpack"),k=__("Saved","jetpack");return c||b?React.createElement(a.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action"},React.createElement(a.Icon,{icon:c?React.createElement(d.A,null):React.createElement(l.A,null)}),React.createElement("span",{className:"action-text"},c?C:k)):React.createElement(a.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{if(!b&&!c){n(p.h4,{context:E,logos_count:u.length,selected_logo:g?g+1:0});try{const t=await o(i);(0,A.H)({siteId:e,url:i.url,newUrl:t.mediaURL,mediaId:t.mediaId}),v(e)}catch(e){f("Error saving logo",e)}}}},React.createElement(a.Icon,{icon:React.createElement(d.A,null)}),React.createElement("span",{className:"action-text"},__("Save in Library","jetpack")))},v=({onApplyLogo:e})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,{isSavingLogoToLibrary:s,selectedLogo:o,logos:i,selectedLogoIndex:c,context:l}=(0,m.A)();return React.createElement(a.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{s||(n(p.Zb,{context:l,logos_count:i.length,selected_logo:null!=c?c+1:0}),e?.(o?.mediaId))},disabled:s||!o?.mediaId},React.createElement(a.Icon,{icon:React.createElement(u.A,null)}),React.createElement("span",{className:"action-text"},__("Use on block","jetpack")))},C=()=>React.createElement(React.Fragment,null,React.createElement(E.$,{className:"jetpack-ai-logo-generator-modal-presenter__logo"}),React.createElement("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text"},__("Generating new logo…","jetpack"))),k=({siteId:e,logo:t,onApplyLogo:n})=>React.createElement(React.Fragment,null,React.createElement("img",{src:t.url,alt:t.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__action-wrapper"},React.createElement("span",{className:"jetpack-ai-logo-generator-modal-presenter__description"},t.description),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__actions"},React.createElement(b,{siteId:e}),React.createElement(v,{onApplyLogo:n})))),y=({logo:e})=>React.createElement(React.Fragment,null,React.createElement("img",{src:e.url,alt:e.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__success-wrapper"},React.createElement(a.Icon,{icon:React.createElement(l.A,null)}),React.createElement("span",null,__("Your new logo was set to the block!","jetpack")))),B=({logo:e=null,loading:t=!1,onApplyLogo:n,logoAccepted:r=!1,siteId:a})=>{const{isRequestingImage:s}=(0,m.A)(),{saveToLibraryError:o,logoUpdateError:i}=(0,g.A)();if(!e)return null;let c;return c=t||s?React.createElement(C,null):r?React.createElement(y,{logo:e}):React.createElement(k,{siteId:String(a),logo:e,onApplyLogo:n}),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__wrapper"},React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter"},React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__content"},c),!r&&React.createElement("div",{className:"jetpack-ai-logo-generator-modal-presenter__rectangle"})),o&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error saving the logo to your library. Please try again.","jetpack")),i&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error applying the logo to your site. Please try again.","jetpack")))}},11114:(e,t,n)=>{"use strict";n.d(t,{X:()=>f});var r=n(85985),a=n(56427),s=n(27723),o=n(51113),i=n(19783),c=n(10067),l=n.n(c),u=n(51609),d=n(21902),p=n(61356),m=n(60674),g=n(88725),A=n(44461),h=n(64024);const __=s.__,E=l()("jetpack-ai-calypso:prompt-box"),f=({initialPrompt:e=""})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,[c,l]=(0,u.useState)(e),[f,b]=(0,u.useState)(0),{enhancePromptFetchError:v,logoFetchError:C}=(0,A.A)(),{nextTierCheckoutURL:k,hasNextTier:y}=(0,m.Q)(),B=c?.length>=p.N3,{generateLogo:w,enhancePrompt:_,setIsEnhancingPrompt:I,isBusy:j,isEnhancingPrompt:x,site:S,getAiAssistantFeature:Q,requireUpgrade:N,context:R}=(0,g.A)(),T=__("Enhancing…","jetpack"),P=__("Enhance prompt","jetpack"),L=x?T:P,M=(0,u.useRef)(null),D=(0,u.useCallback)((async()=>{E("Enhancing prompt",c),I(!0),n(p.vm,{context:R,tool:"enhance-prompt"});try{const e=await _({prompt:c});l(e),I(!1)}catch(e){E("Error enhancing prompt",e),I(!1)}}),[R,_,c,I]),F=Q(String(S?.id||"")),O=F?.currentTier?.value||0,z=F?.usagePeriod?.requestsCount||0,U=1===O;(0,u.useEffect)((()=>{b(O-z<=0?0:O-z)}),[O,z]),(0,u.useEffect)((()=>{M.current&&M.current.textContent!==c&&(M.current.textContent=c)}),[c]);const H=(0,u.useCallback)((async()=>{n(p.vm,{context:R,tool:"image"}),w({prompt:c})}),[R,w,c]);return React.createElement("div",{className:"jetpack-ai-logo-generator__prompt"},React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-header"},React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-label"},__("Describe your site:","jetpack")),React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-actions"},React.createElement(a.Button,{variant:"link",disabled:j||N||!B,onClick:D},React.createElement(d.A,null),React.createElement("span",null,L)))),React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-query"},React.createElement("div",{ref:M,contentEditable:!j&&!N,suppressContentEditableWarning:!0,className:"prompt-query__input",onInput:e=>{l(e.target.textContent||"")},onPaste:e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain"),n=window.getSelection();if(!n||!n.rangeCount)return;n.deleteFromDocument();n.getRangeAt(0).insertNode(document.createTextNode(t)),n.collapseToEnd(),l(M.current?.textContent||"")},"data-placeholder":__("Describe your site or simply ask for a logo specifying some details about it","jetpack")}),React.createElement(a.Button,{variant:"primary",className:"jetpack-ai-logo-generator__prompt-submit",onClick:H,disabled:j||N||!B},__("Generate","jetpack"))),React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-footer"},!U&&!N&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-requests"},React.createElement("div",null,(0,s.sprintf)( // translators: %u is the number of requests -__("%u requests remaining.","jetpack"),f)),y&&React.createElement(React.Fragment,null," ",React.createElement(a.Button,{variant:"link",href:k,target:"_blank",onClick:()=>{n(p.AN,{context:R,placement:p.Cn})}},__("Upgrade","jetpack")))," ",React.createElement(a.Tooltip,{text:__("Logo generation costs 10 requests; prompt enhancement costs 1 request each","jetpack"),placement:"bottom"},React.createElement(o.A,{className:"prompt-footer__icon",icon:i.A}))),!U&&N&&React.createElement(h.G,null),v&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error enhancing prompt. Please try again.","jetpack")),C&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error generating logo. Please try again.","jetpack"))))}},64024:(e,t,n)=>{"use strict";n.d(t,{G:()=>p});var r=n(85985),a=n(56427),s=n(86087),o=n(27723),i=n(51113),c=n(90311),l=n(61356),u=n(60674),d=n(88725);const __=o.__,p=()=>{const{tracks:e}=(0,r.st)(),{recordEvent:t}=e,n=__("Upgrade","jetpack"),o=(0,s.createInterpolateElement)(__("Not enough requests left to generate a logo. Upgrade now to increase it.","jetpack"),{strong:React.createElement("strong",null)}),{nextTierCheckoutURL:p}=(0,u.Q)(),{context:m}=(0,d.A)();return React.createElement("div",{className:"jetpack-upgrade-plan-banner"},React.createElement("div",{className:"jetpack-upgrade-plan-banner__wrapper"},React.createElement("div",null,React.createElement(i.A,{className:"jetpack-upgrade-plan-banner__icon",icon:c.A}),React.createElement("span",{className:"jetpack-upgrade-plan-banner__banner-description"},o)),React.createElement(a.Button,{href:p,target:"_blank",className:"is-primary",onClick:()=>{t(l.AN,{context:m,placement:l.tF})}},n)))}},35421:(e,t,n)=>{"use strict";n.d(t,{R:()=>c});var r=n(85985),a=n(56427),s=n(27723),o=n(61356),i=n(88725);const __=s.__,c=({onCancel:e,upgradeURL:t,reason:n})=>{const{tracks:s}=(0,r.st)(),{recordEvent:c}=s,l=__("The logo generator requires a paid Jetpack AI plan. Upgrade your plan to access exclusive features, including logo generation. The upgrade will also increase the amount of requests you can use in all AI-powered features.","jetpack"),u=__("Not enough requests left to generate a logo. Upgrade your Jetpack AI to increase the amount of requests you can use in all AI-powered features.","jetpack"),{context:d}=(0,i.A)();return React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper"},React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message"},React.createElement("span",{className:"jetpack-ai-logo-generator-modal__loading-message"},"feature"===n?l:u)," ",React.createElement(a.Button,{variant:"link",href:"https://jetpack.com/ai/",target:"_blank"},__("Learn more about Jetpack AI.","jetpack"))),React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-actions"},React.createElement(a.Button,{variant:"tertiary",onClick:e},__("Cancel","jetpack")),React.createElement(a.Button,{variant:"primary",href:t,target:"_blank",onClick:()=>{c(o.AN,{context:d,placement:o.Tz}),e()}},__("Upgrade","jetpack"))))}},48204:(e,t,n)=>{"use strict";n.d(t,{H:()=>c});var r=n(56427),a=n(27723),s=n(53512),o=n(13022),i=n(36791);const __=a.__,c=({className:e=null,onVisitBlankTarget:t})=>React.createElement("div",{className:(0,o.A)("jetpack-ai-logo-generator-modal-visit-site-banner",e)},React.createElement("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__jetpack-logo"},React.createElement("img",{src:i,alt:"Jetpack"})),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__content"},React.createElement("strong",null,__("Do you want to know all the amazing things you can do with Jetpack AI?","jetpack")),React.createElement("span",null,__("Generate and tweak content, create forms, get feedback and much more.","jetpack")),React.createElement("div",null,React.createElement(r.Button,{variant:"link",href:"https://jetpack.com/redirect/?source=logo_generator_learn_more_about_jetpack_ai",target:"_blank",onClick:t||null},__("Learn more about Jetpack AI","jetpack"),React.createElement(r.Icon,{icon:s.A,size:20})))))},61356:(e,t,n)=>{"use strict";n.d(t,{$i:()=>l,AN:()=>u,Cn:()=>d,N3:()=>g,Nt:()=>c,Tz:()=>p,Zb:()=>i,_S:()=>A,h4:()=>o,iz:()=>r,tF:()=>m,ub:()=>a,vm:()=>s});const r="jetpack_ai_logo_generator_modal_open",a="jetpack_ai_logo_generator_modal_close",s="jetpack_ai_logo_generator_generate",o="jetpack_ai_logo_generator_save",i="jetpack_ai_logo_generator_use",c="jetpack_ai_logo_generator_navigate",l="jetpack_ai_logo_generator_feedback",u="jetpack_ai_upgrade_button",d="input_footer",p="free_user_screen",m="upgrade_prompt",g=3,A=10},60674:(e,t,n)=>{"use strict";n.d(t,{Q:()=>l});var r=n(85985),a=n(47143),s=n(10067),o=n.n(s),i=n(74423);const c=o()("ai-client:logo-generator:use-checkout"),l=()=>{const{nextTier:e}=(0,a.useSelect)((e=>({nextTier:e(i.E).getAiAssistantFeature().nextTier})),[]),t=new URL("https://jetpack.com/redirect/");t.searchParams.set("source","jetpack-ai-yearly-tier-upgrade-nudge"),t.searchParams.set("site",(0,r.GE)()),t.searchParams.set("path",`jetpack_ai_yearly:-q-${e?.limit}`);const n=`${window?.Jetpack_Editor_Initial_State?.adminUrl}admin.php?redirect_to_referrer=1&page=my-jetpack#/add-jetpack-ai`,s=(0,r.d9)()||(0,r.Sy)()?t.toString():n;return c("Next tier checkout URL: ",s),{nextTierCheckoutURL:s,hasNextTier:!!e}}},88725:(e,t,n)=>{"use strict";n.d(t,{A:()=>A});var r=n(47143),a=n(10067),s=n.n(a),o=n(51609),i=n(62614),c=n(93869),l=n(51391),u=n(19362),d=n(28229),p=n(74423),m=n(44461);const g=s()("jetpack-ai-calypso:use-logo-generator"),A=()=>{const{setSelectedLogoIndex:e,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setIsRequestingImage:a,setIsEnhancingPrompt:s,increaseAiAssistantRequestsCount:A,addLogoToHistory:h,setContext:E}=(0,r.useDispatch)(p.E),{logos:f,selectedLogoIndex:b,selectedLogo:v,siteDetails:C,isSavingLogoToLibrary:k,isApplyingLogo:y,isEnhancingPrompt:B,isBusy:w,isRequestingImage:_,getAiAssistantFeature:I,requireUpgrade:j,context:x}=(0,r.useSelect)((e=>{const t=e(p.E);return{logos:t.getLogos(),selectedLogoIndex:t.getSelectedLogoIndex(),selectedLogo:t.getSelectedLogo(),siteDetails:t.getSiteDetails(),isSavingLogoToLibrary:t.getIsSavingLogoToLibrary(),isApplyingLogo:t.getIsApplyingLogo(),isRequestingImage:t.getIsRequestingImage(),isEnhancingPrompt:t.getIsEnhancingPrompt(),isBusy:t.getIsBusy(),getAiAssistantFeature:t.getAiAssistantFeature,requireUpgrade:t.getRequireUpgrade(),context:t.getContext()}}),[]),{setFirstLogoPromptFetchError:S,setEnhancePromptFetchError:Q,setLogoFetchError:N,setSaveToLibraryError:R,setLogoUpdateError:T}=(0,m.A)(),{generateImageWithParameters:P}=(0,i.A)(),{saveToMediaLibrary:L}=(0,c.A)(),{ID:M=null,name:D=null,description:F=null}=C||{},O=M?String(M):null,z=I(O),U=z?.costs?.["jetpack-ai-logo-generator"]?.logo,H=(0,o.useCallback)((async function(){S(null),A();try{const e=await(0,l.A)();if(!e||!e.token)throw new Error("No token provided");g("Generating first prompt for site");const t={question:`Generate a simple and short prompt asking for a logo based on the site's name and description, keeping the same language.\nExample for a site named "The minimalist fashion blog", described as "Daily inspiration for all things fashion": A logo for a minimalist fashion site focused on daily sartorial inspiration with a clean and modern aesthetic that is sleek and sophisticated.\nAnother example, now for a site called "El observatorio de aves", described as "Un sitio dedicado a nuestros compañeros y compañeras entusiastas de la observación de aves.": Un logo para un sitio web dedicado a la observación de aves, capturando la esencia de la naturaleza y la pasión por la avifauna en un diseño elegante y representativo, reflejando una estética natural y apasionada por la vida silvestre.\n\nSite name: ${D}\nSite description: ${F}`,feature:"jetpack-ai-logo-generator",stream:!1},n="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",r={Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},a=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(t)}).then((e=>e.json()));return a?.choices?.[0]?.message?.content}catch(e){throw A(-1),S(e),e}}),[S,A,D,F]),V=(0,o.useCallback)((async function({prompt:e}){N(null);try{const t=await(0,l.A)();if(!t||!t.token)throw new Error("No token provided");g("Generating image with prompt",e);const n={prompt:`I NEED to test how the tool works with extremely simple prompts. DO NOT add any detail, just use it AS-IS:\nCreate a single text-free iconic vector logo that symbolically represents the user request, using abstract or symbolic imagery.\nThe design should be modern, with either a vivid color scheme full of gradients or a color scheme that's monochromatic. Use any of those styles based on the user request mood.\nEnsure the logo is set against a clean solid background.\nEnsure the logo works in small sizes.\nThe imagery in the logo should subtly hint at the mood of the user request but DO NOT use any text, letters, or the name of the site on the imagery.\nThe image should contain a single icon, without variations, color palettes or different versions.\n\nUser request:${e}`,feature:"jetpack-ai-logo-generator",response_format:"b64_json"};return await P(n)}catch(e){throw N(e),e}}),[]),q=(0,o.useCallback)((async e=>{R(null);try{if(g("Saving logo for site"),e.mediaId)return{mediaId:e.mediaId,mediaURL:e.url};const n={mediaId:0,mediaURL:""};t(!0);const{id:r,url:a}=await L(e.url,"site-logo.png");return n.mediaId=parseInt(r),n.mediaURL=a,n}catch(e){throw R(e),e}finally{t(!1)}}),[t,R]),G=(0,o.useCallback)((async()=>{T(null);try{if(!O||!v)throw new Error("Missing siteId or logo");g("Applying logo for site",O),n(!0);const{mediaId:e}=v;if(!e)throw new Error("Missing mediaId");await(0,d.Z)({siteId:O,imageId:String(e)})}catch(e){throw T(e),e}finally{n(!1)}}),[v,n,T,O]),$=(0,o.useCallback)((e=>{h(e),(0,u.hm)({...e,siteId:String(O)})}),[O,h,u.hm]),W=(0,o.useCallback)((async function({prompt:e}){g("Generating logo for site"),a(!0);try{if(!U)throw new Error("Missing cost information");let t;A(U);try{if(t=await V({prompt:e}),!t||!t.data.length)throw new Error("No image returned")}catch(e){throw A(-U),e}const n={url:"data:image/png;base64,"+t.data[0].b64_json,description:e};try{const t=await q(n);$({url:t.mediaURL,description:e,mediaId:t.mediaId})}catch(e){throw $(n),e}}finally{a(!1)}}),[U,A,q,$,V]);return{logos:f,selectedLogoIndex:b,selectedLogo:v,setSelectedLogoIndex:e,site:{id:O,name:D,description:F},generateFirstPrompt:H,saveLogo:q,applyLogo:G,generateImage:V,enhancePrompt:async function({prompt:e}){Q(null),A();try{const t=await(0,l.A)();if(!t||!t.token)throw new Error("No token provided");g("Enhancing prompt",e);const n={messages:[{role:"system",content:"Enhance the prompt you receive.\nThe prompt is meant for generating a logo. Return the same prompt enhanced, and make each enhancement wrapped in brackets.\nDo not add any mention to text, letters, typography or the name of the site in the prompt.\nFor example: user's prompt: A logo for an ice cream shop. Returned prompt: A logo for an ice cream shop [that is pink] [and vibrant]."},{role:"user",content:e}],feature:"jetpack-ai-logo-generator",stream:!1},r="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",a={Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},s=await fetch(r,{method:"POST",headers:a,body:JSON.stringify(n)}).then((e=>e.json()));return s?.choices?.[0]?.message?.content}catch(e){throw A(-1),Q(e),e}},storeLogo:$,generateLogo:W,setIsEnhancingPrompt:s,setIsRequestingImage:a,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setContext:E,isEnhancingPrompt:B,isRequestingImage:_,isSavingLogoToLibrary:k,isApplyingLogo:y,isBusy:w,getAiAssistantFeature:I,requireUpgrade:j,context:x}}},44461:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(47143),a=n(74423);const s=()=>{const{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:n,setLogoFetchError:s,setSaveToLibraryError:o,setLogoUpdateError:i}=(0,r.useDispatch)(a.E),{featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:m}=(0,r.useSelect)((e=>{const t=e(a.E);return{featureFetchError:t.getFeatureFetchError(),firstLogoPromptFetchError:t.getFirstLogoPromptFetchError(),enhancePromptFetchError:t.getEnhancePromptFetchError(),logoFetchError:t.getLogoFetchError(),saveToLibraryError:t.getSaveToLibraryError(),logoUpdateError:t.getLogoUpdateError()}}),[]);return{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:n,setLogoFetchError:s,setSaveToLibraryError:o,setLogoUpdateError:i,clearErrors:()=>{e(null),t(null),n(null),s(null),o(null),i(null)},featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:m}}},23101:(e,t,n)=>{"use strict";n.d(t,{T:()=>r.T});var r=n(64537)},19362:(e,t,n)=>{"use strict";n.d(t,{$t:()=>i,H:()=>o,NP:()=>c,Pv:()=>l,hm:()=>s});var r=n(13858);const a=10;function s({siteId:e,url:t,description:n,mediaId:r}){const s=i(e),o={url:t,description:n,mediaId:r};return s.push(o),localStorage.setItem(`logo-history-${e}`,JSON.stringify(s.slice(-a))),o}function o({siteId:e,url:t,newUrl:n,mediaId:r}){const s=i(e),o=s.findIndex((e=>e.url===t));return o>-1&&(s[o].url=n,s[o].mediaId=r),localStorage.setItem(`logo-history-${e}`,JSON.stringify(s.slice(-a))),s[o]}function i(e){const t=localStorage.getItem(`logo-history-${e}`);let n=t?JSON.parse(t):[];return Array.isArray(n)||(n=[]),n=n.slice(-a),n=n.filter((e=>"object"==typeof e&&"string"==typeof e.url&&"string"==typeof e.description)).map((e=>({url:e.url,description:e.description,mediaId:e.mediaId}))),n}function c(e){return 0===i(e).length}async function l(e){const t=i(e).filter((({mediaId:e})=>void 0!==e)).map((({mediaId:t})=>new Promise(((n,a)=>{(0,r.T)({siteId:e,mediaId:t}).then((e=>n({mediaId:t,exists:e}))).catch((e=>a(e)))}))));try{(await Promise.all(t)).filter((({exists:e})=>!e)).forEach((({mediaId:t})=>function({siteId:e,mediaId:t}){const n=i(e),r=n.findIndex((e=>e.mediaId===t));-1!==r&&(n.splice(r,1),localStorage.setItem(`logo-history-${e}`,JSON.stringify(n)))}({siteId:e,mediaId:t})))}catch(e){}}},13858:(e,t,n)=>{"use strict";n.d(t,{T:()=>a});var r=n(48931);async function a({mediaId:e}){const t=Number(e);if(Number.isNaN(t))return!1;try{return await(0,r.A)({path:`/wp/v2/media/${Number(e)}`,method:"GET"}),!0}catch(e){const t=e?.data?.status;if(404===t)return!1;throw e}}},28229:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var r=n(22746);async function a({siteId:e,imageId:t}){const n={site_logo:t,site_icon:t};return(0,r.A)({path:`/sites/${String(e)}/settings`,apiVersion:"v2",apiNamespace:"wp/v2",body:n,query:"source=jetpack-ai",method:"POST"})}},22746:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(48931);const a=5;let s=0;async function o(e){if(s+=1,s>a)throw s-=1,new Error("Too many requests");return(0,r.A)(e).finally((()=>{s-=1}))}},9624:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(19362),a=n(22746),s=n(9938);const o={storeAiAssistantFeature:e=>({type:s.UU,feature:e}),fetchAiAssistantFeature:()=>async({dispatch:e})=>{e({type:s.ql});try{const t=await(0,a.A)({path:"/wpcom/v2/jetpack-ai/ai-assistant-feature",query:"force=wpcom"});e(o.storeAiAssistantFeature(function(e){return{hasFeature:!!e["has-feature"],isOverLimit:!!e["is-over-limit"],requestsCount:e["requests-count"],requestsLimit:e["requests-limit"],requireUpgrade:!!e["site-require-upgrade"],errorMessage:e["error-message"],errorCode:e["error-code"],upgradeType:e["upgrade-type"],usagePeriod:{currentStart:e["usage-period"]?.["current-start"],nextStart:e["usage-period"]?.["next-start"],requestsCount:e["usage-period"]?.["requests-count"]||0},currentTier:e["current-tier"],nextTier:e["next-tier"],tierPlansEnabled:!!e["tier-plans-enabled"],costs:e.costs}}(t)))}catch(t){e({type:s.Rx,error:t})}},increaseAiAssistantRequestsCount:(e=1)=>({dispatch:t})=>{t({type:s.Lg,count:e})},setAiAssistantFeatureRequireUpgrade:(e=!0)=>({type:s.Kt,requireUpgrade:e}),setTierPlansEnabled:(e=!0)=>({type:s.c1,tierPlansEnabled:e}),setSiteDetails:e=>({type:s.Bz,siteDetails:e}),setSelectedLogoIndex:e=>({type:s.BG,selectedLogoIndex:e}),addLogoToHistory:e=>({type:s.sG,logo:e}),setIsSavingLogoToLibrary:e=>({type:s.E6,isSavingLogoToLibrary:e}),setIsApplyingLogo:e=>({type:s.Ep,isApplyingLogo:e}),updateSelectedLogo:(e,t)=>({type:s.r_,mediaId:e,url:t}),setIsRequestingImage:e=>({type:s.vk,isRequestingImage:e}),setIsEnhancingPrompt:e=>({type:s.O5,isEnhancingPrompt:e}),loadLogoHistory(e){const t=(0,r.$t)(e);return{type:s.ZI,history:t}},setFeatureFetchError:e=>({type:s.Rx,error:e}),setFirstLogoPromptFetchError:e=>({type:s.MQ,error:e}),setEnhancePromptFetchError:e=>({type:s.gG,error:e}),setLogoFetchError:e=>({type:s.q_,error:e}),setSaveToLibraryError:e=>({type:s.x0,error:e}),setLogoUpdateError:e=>({type:s.FN,error:e}),setContext:e=>({type:s.kZ,context:e})},i=o},9938:(e,t,n)=>{"use strict";n.d(t,{BG:()=>m,Bz:()=>c,E6:()=>A,Ep:()=>h,FN:()=>_,GB:()=>l,Kt:()=>o,Lg:()=>s,MQ:()=>k,O5:()=>b,Rx:()=>C,UU:()=>r,ZI:()=>v,c1:()=>i,gG:()=>y,kZ:()=>p,mx:()=>d,nb:()=>u,q_:()=>B,ql:()=>a,r_:()=>E,sG:()=>g,vk:()=>f,x0:()=>w});const r="STORE_AI_ASSISTANT_FEATURE",a="REQUEST_AI_ASSISTANT_FEATURE",s="INCREASE_AI_ASSISTANT_REQUESTS_COUNT",o="SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE",i="SET_TIER_PLANS_ENABLED",c="SET_SITE_DETAILS",l=20,u=999999999,d=3,p="SET_CONTEXT",m="SET_SELECTED_LOGO_INDEX",g="ADD_LOGO_TO_HISTORY",A="SET_IS_SAVING_LOGO_TO_LIBRARY",h="SET_IS_APPLYING_LOGO",E="SAVE_SELECTED_LOGO",f="SET_IS_REQUESTING_IMAGE",b="SET_IS_ENHANCING_PROMPT",v="SET_SITE_HISTORY",C="SET_FEATURE_FETCH_ERROR",k="SET_FIRST_LOGO_PROMPT_FETCH_ERROR",y="SET_ENHANCE_PROMPT_FETCH_ERROR",B="SET_LOGO_FETCH_ERROR",w="SET_SAVE_TO_LIBRARY_ERROR",_="SET_LOGO_UPDATE_ERROR"},74423:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(47143),a=n(9624),s=n(23695),o=n(80037);const i="jetpack-ai/logo-generator",c=(0,r.createReduxStore)(i,{__experimentalUseThunks:!0,actions:a.A,reducer:s.A,selectors:o.A});(0,r.register)(c)},94891:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(9938);const a={siteDetails:{},features:{aiAssistantFeature:{hasFeature:!0,isOverLimit:!1,requestsCount:0,requestsLimit:r.GB,requireUpgrade:!1,errorMessage:"",errorCode:"",upgradeType:"default",currentTier:{slug:"ai-assistant-tier-free",value:0,limit:20},usagePeriod:{currentStart:"",nextStart:"",requestsCount:0},nextTier:null,tierPlansEnabled:!1,_meta:{isRequesting:!1,asyncRequestCountdown:r.mx,asyncRequestTimerId:0,isRequestingImage:!1}}},history:[],selectedLogoIndex:0}},23695:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(61356),a=n(9938),s=n(94891);function o(e=s.A,t){switch(t.type){case a.ql:return{...e,_meta:{...e._meta??{},featureFetchError:null},features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!0,asyncRequestCountdown:a.mx,asyncRequestTimerId:0}}}};case a.UU:{const n={"jetpack-ai-logo-generator":{logo:r._S}};return{...e,features:{...e.features,aiAssistantFeature:{costs:n,...t.feature,requireUpgrade:t.feature?.requireUpgrade||0===t.feature?.currentTier?.value,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!1}}}}}case a.Lg:{const n=e?.features?.aiAssistantFeature?.usagePeriod||{requestsCount:0},r=(e?.features?.aiAssistantFeature?.requestsCount||0)+(t.count??1);n.requestsCount+=t.count??1;const s=e?.features?.aiAssistantFeature?.currentTier?.value,o=void 0===s&&!e?.features?.aiAssistantFeature?.hasFeature||0===s,i=void 0===s&&e?.features?.aiAssistantFeature?.hasFeature||1===s;let c=e?.features?.aiAssistantFeature?.currentTier?.limit||a.GB;i?c=a.nb:o&&(c=e?.features?.aiAssistantFeature?.requestsLimit);const l=(i||o?r:e?.features?.aiAssistantFeature?.usagePeriod?.requestsCount||0)>=c,u=o||l&&null!==e?.features?.aiAssistantFeature?.nextTier;return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,isOverLimit:l,requestsCount:r,requireUpgrade:u,usagePeriod:{...n}}}}}case a.Kt:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,requireUpgrade:t.requireUpgrade,...t.requireUpgrade?{isOverLimit:!0}:{}}}};case a.c1:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,tierPlansEnabled:t.tierPlansEnabled}}};case a.Bz:return{...e,siteDetails:t.siteDetails};case a.BG:return{...e,selectedLogoIndex:t.selectedLogoIndex};case a.sG:{const n=[...e.history,t.logo];return{...e,history:n,selectedLogoIndex:n.length-1}}case a.E6:return{...e,_meta:{...e._meta??{},isSavingLogoToLibrary:t.isSavingLogoToLibrary}};case a.Ep:return{...e,_meta:{...e._meta??{},isApplyingLogo:t.isApplyingLogo}};case a.r_:{const n=e.history?.[e.selectedLogoIndex];return{...e,history:[...e.history.slice(0,e.selectedLogoIndex),{...n,mediaId:t.mediaId,url:t.url},...e.history.slice(e.selectedLogoIndex+1)]}}case a.vk:return{...e,_meta:{...e._meta??{},isRequestingImage:t.isRequestingImage}};case a.O5:return{...e,_meta:{...e._meta??{},isEnhancingPrompt:t.isEnhancingPrompt}};case a.ZI:return{...e,history:t.history,selectedLogoIndex:t.history?.length?t.history.length-1:0};case a.Rx:return{...e,_meta:{...e._meta??{},featureFetchError:t.error}};case a.MQ:return{...e,_meta:{...e._meta??{},firstLogoPromptFetchError:t.error}};case a.gG:return{...e,_meta:{...e._meta??{},enhancePromptFetchError:t.error}};case a.q_:return{...e,_meta:{...e._meta??{},logoFetchError:t.error}};case a.x0:return{...e,_meta:{...e._meta??{},saveToLibraryError:t.error}};case a.FN:return{...e,_meta:{...e._meta??{},logoUpdateError:t.error}};case a.kZ:return{...e,_meta:{...e._meta??{},context:t.context}}}return e}},80037:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(61356);const a={getAiAssistantFeature(e){const t={...e.features.aiAssistantFeature};return delete t._meta,t},getSiteDetails:e=>e.siteDetails,getIsRequestingAiAssistantFeature:e=>e.features.aiAssistantFeature?._meta?.isRequesting??!1,getLogos:e=>e.history??[],getSelectedLogoIndex:e=>e.selectedLogoIndex??null,getSelectedLogo:e=>e.history?.[e.selectedLogoIndex]??null,getIsSavingLogoToLibrary:e=>e._meta?.isSavingLogoToLibrary??!1,getIsApplyingLogo:e=>e._meta?.isApplyingLogo??!1,getIsEnhancingPrompt:e=>e._meta?.isEnhancingPrompt??!1,getIsRequestingImage:e=>e._meta?.isRequestingImage??!1,getIsBusy:e=>a.getIsApplyingLogo(e)||a.getIsSavingLogoToLibrary(e)||a.getIsRequestingImage(e)||a.getIsEnhancingPrompt(e),getRequireUpgrade(e){const t=e.features.aiAssistantFeature,n=t?.costs?.["jetpack-ai-logo-generator"]?.logo??r._S,a=t?.currentTier?.value||0,s=t?.usagePeriod?.requestsCount||0,o=1===a,i=!t?.nextTier;return e.features.aiAssistantFeature?.requireUpgrade||!o&&!i&&a-se._meta?.featureFetchError??null,getFirstLogoPromptFetchError:e=>e._meta?.firstLogoPromptFetchError??null,getEnhancePromptFetchError:e=>e._meta?.enhancePromptFetchError??null,getLogoFetchError:e=>e._meta?.logoFetchError??null,getSaveToLibraryError:e=>e._meta?.saveToLibraryError??null,getLogoUpdateError:e=>e._meta?.logoUpdateError??null,getContext:e=>e._meta?.context??""},s=a},53664:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(7675),a=n(10067),s=n.n(a),o=n(46219),i=n(51391),c=n(78836);const l=s()("jetpack-ai-client:suggestions-event-source");class u extends EventTarget{constructor(e){super(),this.fullMessage="",this.fullFunctionCall={name:"",arguments:""},this.isPromptClear=!1,this.controller=new AbortController,this.initEventSource(e)}async initEventSource({url:e,question:t,token:n,options:a={}}){if(!n)try{l("Token was not provided, requesting one..."),n=(await(0,i.A)()).token}catch(e){return void this.processErrorEvent(e)}const s={};if(Number.isInteger(parseInt(a.postId))&&(s.post_id=+a.postId),!e){const t=new URL("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query");a?.fromCache&&t.searchParams.append("stream_cache","true"),e=t.toString(),l("URL not provided, using default: %o",e)}Array.isArray(t)?s.messages=t:s.question=t,a?.feature?.length&&(l("Feature: %o",a.feature),s.feature=a.feature),a?.functions?.length&&(l("Functions: %o",a.functions),s.functions=a.functions),a?.model?.length&&(l("Model: %o",a.model),s.model=a.model),this.errorUnclearPromptTriggered=!1,await(0,r.y)(e,{openWhenHidden:!0,method:"POST",headers:{"Content-type":"application/json",Authorization:"Bearer "+n},body:JSON.stringify(s),onclose:()=>{l("Stream closed")},onerror:e=>{throw this.processErrorEvent(e),e},onmessage:e=>{this.processEvent(e)},onopen:async e=>{if(e.ok)return;let t;throw e.status>=400&&e.status<=500&&![413,422,429].includes(e.status)&&(l("Connection error: %o",e),t=c.mA,this.dispatchEvent(new CustomEvent(c.mA,{detail:e}))),503===e.status&&(t=c.AZ,this.dispatchEvent(new CustomEvent(c.AZ))),413===e.status&&(t=c.cT,this.dispatchEvent(new CustomEvent(c.cT))),422===e.status&&(t=c.ud,this.dispatchEvent(new CustomEvent(c.ud))),429===e.status&&(t=c.Or,this.dispatchEvent(new CustomEvent(c.Or))),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(t)})),new Error},signal:this.controller.signal})}checkForUnclearPrompt(){if(this.isPromptClear)return;const e=this.fullMessage.replace(/__|(\*\*)/g,"");if(e.startsWith("JETPACK_AI_ERROR")){if(this.errorUnclearPromptTriggered)return;this.errorUnclearPromptTriggered=!0,this.dispatchEvent(new CustomEvent(c.L9)),l("Unclear error prompt dispatched"),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(c.L9)}))}else"JETPACK_AI_ERROR".startsWith(e)?l(this.fullMessage):this.isPromptClear=!0}close(){this.controller.abort()}processEvent(e){if("[DONE]"===e.data){if(this.errorUnclearPromptTriggered)return;if(this.fullMessage.length)return this.dispatchEvent(new CustomEvent("done",{detail:this.fullMessage})),void l("Done: %o",this.fullMessage);if(this.fullFunctionCall.name.length)return this.dispatchEvent(new CustomEvent("function_done",{detail:this.fullFunctionCall})),void l("Done: %o",this.fullFunctionCall)}let t;try{t=JSON.parse(e.data)}catch(t){return void l("Error parsing JSON",e,t)}const{delta:n}=t?.choices?.[0]??{delta:{content:null,function_call:null}},r=n.content,a=n.function_call;r&&(this.fullMessage+=r,this.checkForUnclearPrompt(),this.isPromptClear&&(this.dispatchEvent(new CustomEvent("chunk",{detail:r})),l("suggestion: %o",this.fullMessage),this.dispatchEvent(new CustomEvent("suggestion",{detail:this.fullMessage})))),a&&(null!=a.name&&(this.fullFunctionCall.name+=a.name),null!=a.arguments&&(this.fullFunctionCall.arguments+=a.arguments),this.dispatchEvent(new CustomEvent("functionCallChunk",{detail:this.fullFunctionCall})))}processErrorEvent(e){l("onerror: %o",e),this.dispatchEvent(new CustomEvent(c.mA,{detail:e})),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(c.mA)}))}}},78836:(e,t,n)=>{"use strict";n.d(t,{AZ:()=>a,L9:()=>l,Or:()=>s,cT:()=>i,mA:()=>c,uH:()=>r.u,ud:()=>o,zn:()=>u});var r=n(97784);const a="error_service_unavailable",s="error_quota_exceeded",o="error_moderation",i="error_context_too_large",c="error_network",l="error_unclear_prompt",u="error_response"},90372:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(10067);const a=n.n(r)()("dops:analytics");let s,o;window._tkq=window._tkq||[],window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=+new Date;const i={initialize:function(e,t,n){i.setUser(e,t),i.setSuperProps(n),i.identifyUser()},setGoogleAnalyticsEnabled:function(e,t=null){this.googleAnalyticsEnabled=e,this.googleAnalyticsKey=t},setMcAnalyticsEnabled:function(e){this.mcAnalyticsEnabled=e},setUser:function(e,t){o={ID:e,username:t}},setSuperProps:function(e){s=e},assignSuperProps:function(e){s=Object.assign(s||{},e)},mc:{bumpStat:function(e,t){const n=function(e,t){let n="";if("object"==typeof e){for(const t in e)n+="&x_"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);a("Bumping stats %o",e)}else n="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(t),a('Bumping stat "%s" in group "%s"',t,e);return n}(e,t);i.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv"+n+"&t="+Math.random())},bumpStatWithPageView:function(e,t){const n=function(e,t){let n="";if("object"==typeof e){for(const t in e)n+="&"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);a("Built stats %o",e)}else n="&"+encodeURIComponent(e)+"="+encodeURIComponent(t),a('Built stat "%s" in group "%s"',t,e);return n}(e,t);i.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom"+n+"&t="+Math.random())}},pageView:{record:function(e,t){i.tracks.recordPageView(e),i.ga.recordPageView(e,t)}},purchase:{record:function(e,t,n,r,a,s,o){i.ga.recordPurchase(e,t,n,r,a,s,o)}},tracks:{recordEvent:function(e,t){t=t||{},0===e.indexOf("akismet_")||0===e.indexOf("jetpack_")?(s&&(a("- Super Props: %o",s),t=Object.assign(t,s)),a('Record event "%s" called with props %s',e,JSON.stringify(t)),window._tkq.push(["recordEvent",e,t])):a('- Event name must be prefixed by "akismet_" or "jetpack_"')},recordJetpackClick:function(e){const t="object"==typeof e?e:{target:e};i.tracks.recordEvent("jetpack_wpa_click",t)},recordPageView:function(e){i.tracks.recordEvent("akismet_page_view",{path:e})},setOptOut:function(e){a("Pushing setOptOut: %o",e),window._tkq.push(["setOptOut",e])}},ga:{initialized:!1,initialize:function(){let e={};i.ga.initialized||(o&&(e={userId:"u-"+o.ID}),window.ga("create",this.googleAnalyticsKey,"auto",e),i.ga.initialized=!0)},recordPageView:function(e,t){i.ga.initialize(),a("Recording Page View ~ [URL: "+e+"] [Title: "+t+"]"),this.googleAnalyticsEnabled&&(window.ga("set","page",e),window.ga("send",{hitType:"pageview",page:e,title:t}))},recordEvent:function(e,t,n,r){i.ga.initialize();let s="Recording Event ~ [Category: "+e+"] [Action: "+t+"]";void 0!==n&&(s+=" [Option Label: "+n+"]"),void 0!==r&&(s+=" [Option Value: "+r+"]"),a(s),this.googleAnalyticsEnabled&&window.ga("send","event",e,t,n,r)},recordPurchase:function(e,t,n,r,a,s,o){window.ga("require","ecommerce"),window.ga("ecommerce:addTransaction",{id:e,revenue:r,currency:o}),window.ga("ecommerce:addItem",{id:e,name:t,sku:n,price:a,quantity:s}),window.ga("ecommerce:send")}},identifyUser:function(){o&&window._tkq.push(["identifyUser",o.ID,o.username])},setProperties:function(e){window._tkq.push(["setProperties",e])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}},c=i},5932:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>d});var r=n(56439),a=n(93832);function s(e){class t extends Error{constructor(...t){super(...t),this.name=e}}return t}const o=s("JsonParseError"),i=s("JsonParseAfterRedirectError"),c=s("Api404Error"),l=s("Api404AfterRedirectError"),u=s("FetchNetworkError");const d=new function(e,t){let n=e,s=e,o={"X-WP-Nonce":t},i={credentials:"same-origin",headers:o},c={method:"post",credentials:"same-origin",headers:Object.assign({},o,{"Content-type":"application/json"})},l=function(e){const t=e.split("?"),n=t.length>1?t[1]:"",r=n.length?n.split("&"):[];return r.push("_cacheBuster="+(new Date).getTime()),t[0]+"?"+r.join("&")};const u={setApiRoot(e){n=e},setWpcomOriginApiUrl(e){s=e},setApiNonce(e){o={"X-WP-Nonce":e},i={credentials:"same-origin",headers:o},c={method:"post",credentials:"same-origin",headers:Object.assign({},o,{"Content-type":"application/json"})}},setCacheBusterCallback:e=>{l=e},registerSite:(e,t,a)=>{const s={registration_nonce:e,no_iframe:!0};return(0,r.jetpackConfigHas)("consumer_slug")&&(s.plugin_slug=(0,r.jetpackConfigGet)("consumer_slug")),null!==t&&(s.redirect_uri=t),a&&(s.from=a),g(`${n}jetpack/v4/connection/register`,c,{body:JSON.stringify(s)}).then(p).then(m)},fetchAuthorizationUrl:e=>d((0,a.addQueryArgs)(`${n}jetpack/v4/connection/authorize_url`,{no_iframe:"1",redirect_uri:e}),i).then(p).then(m),fetchSiteConnectionData:()=>d(`${n}jetpack/v4/connection/data`,i).then(m),fetchSiteConnectionStatus:()=>d(`${n}jetpack/v4/connection`,i).then(m),fetchSiteConnectionTest:()=>d(`${n}jetpack/v4/connection/test`,i).then(p).then(m),fetchUserConnectionData:()=>d(`${n}jetpack/v4/connection/data`,i).then(m),fetchUserTrackingSettings:()=>d(`${n}jetpack/v4/tracking/settings`,i).then(p).then(m),updateUserTrackingSettings:e=>g(`${n}jetpack/v4/tracking/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),disconnectSite:()=>g(`${n}jetpack/v4/connection`,c,{body:JSON.stringify({isActive:!1})}).then(p).then(m),fetchConnectUrl:()=>d(`${n}jetpack/v4/connection/url`,i).then(p).then(m),unlinkUser:()=>g(`${n}jetpack/v4/connection/user`,c,{body:JSON.stringify({linked:!1})}).then(p).then(m),reconnect:()=>g(`${n}jetpack/v4/connection/reconnect`,c).then(p).then(m),fetchConnectedPlugins:()=>d(`${n}jetpack/v4/connection/plugins`,i).then(p).then(m),setHasSeenWCConnectionModal:()=>g(`${n}jetpack/v4/seen-wc-connection-modal`,c).then(p).then(m),fetchModules:()=>d(`${n}jetpack/v4/module/all`,i).then(p).then(m),fetchModule:e=>d(`${n}jetpack/v4/module/${e}`,i).then(p).then(m),activateModule:e=>g(`${n}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!0})}).then(p).then(m),deactivateModule:e=>g(`${n}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!1})}),updateModuleOptions:(e,t)=>g(`${n}jetpack/v4/module/${e}`,c,{body:JSON.stringify(t)}).then(p).then(m),updateSettings:e=>g(`${n}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),getProtectCount:()=>d(`${n}jetpack/v4/module/protect/data`,i).then(p).then(m),resetOptions:e=>g(`${n}jetpack/v4/options/${e}`,c,{body:JSON.stringify({reset:!0})}).then(p).then(m),activateVaultPress:()=>g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"vaultpress",status:"active"})}).then(p).then(m),getVaultPressData:()=>d(`${n}jetpack/v4/module/vaultpress/data`,i).then(p).then(m),installPlugin:(e,t)=>{const r={slug:e,status:"active"};return t&&(r.source=t),g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify(r)}).then(p).then(m)},activateAkismet:()=>g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"akismet",status:"active"})}).then(p).then(m),getAkismetData:()=>d(`${n}jetpack/v4/module/akismet/data`,i).then(p).then(m),checkAkismetKey:()=>d(`${n}jetpack/v4/module/akismet/key/check`,i).then(p).then(m),checkAkismetKeyTyped:e=>g(`${n}jetpack/v4/module/akismet/key/check`,c,{body:JSON.stringify({api_key:e})}).then(p).then(m),fetchStatsData:e=>d(function(e){let t=`${n}jetpack/v4/module/stats/data`;-1!==t.indexOf("?")?t+=`&range=${encodeURIComponent(e)}`:t+=`?range=${encodeURIComponent(e)}`;return t}(e),i).then(p).then(m).then(h),getPluginUpdates:()=>d(`${n}jetpack/v4/updates/plugins`,i).then(p).then(m),getPlans:()=>d(`${n}jetpack/v4/plans`,i).then(p).then(m),fetchSettings:()=>d(`${n}jetpack/v4/settings`,i).then(p).then(m),updateSetting:e=>g(`${n}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchSiteData:()=>d(`${n}jetpack/v4/site`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteFeatures:()=>d(`${n}jetpack/v4/site/features`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteProducts:()=>d(`${n}jetpack/v4/site/products`,i).then(p).then(m),fetchSitePurchases:()=>d(`${n}jetpack/v4/site/purchases`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteBenefits:()=>d(`${n}jetpack/v4/site/benefits`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteDiscount:()=>d(`${n}jetpack/v4/site/discount`,i).then(p).then(m).then((e=>e.data)),fetchSetupQuestionnaire:()=>d(`${n}jetpack/v4/setup/questionnaire`,i).then(p).then(m),fetchRecommendationsData:()=>d(`${n}jetpack/v4/recommendations/data`,i).then(p).then(m),fetchRecommendationsProductSuggestions:()=>d(`${n}jetpack/v4/recommendations/product-suggestions`,i).then(p).then(m),fetchRecommendationsUpsell:()=>d(`${n}jetpack/v4/recommendations/upsell`,i).then(p).then(m),fetchRecommendationsConditional:()=>d(`${n}jetpack/v4/recommendations/conditional`,i).then(p).then(m),saveRecommendationsData:e=>g(`${n}jetpack/v4/recommendations/data`,c,{body:JSON.stringify({data:e})}).then(p),fetchProducts:()=>d(`${n}jetpack/v4/products`,i).then(p).then(m),fetchRewindStatus:()=>d(`${n}jetpack/v4/rewind`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchScanStatus:()=>d(`${n}jetpack/v4/scan`,i).then(p).then(m).then((e=>JSON.parse(e.data))),dismissJetpackNotice:e=>g(`${n}jetpack/v4/notice/${e}`,c,{body:JSON.stringify({dismissed:!0})}).then(p).then(m),fetchPluginsData:()=>d(`${n}jetpack/v4/plugins`,i).then(p).then(m),fetchIntroOffers:()=>d(`${n}jetpack/v4/intro-offers`,i).then(p).then(m),fetchVerifySiteGoogleStatus:e=>d(null!==e?`${n}jetpack/v4/verify-site/google/${e}`:`${n}jetpack/v4/verify-site/google`,i).then(p).then(m),verifySiteGoogle:e=>g(`${n}jetpack/v4/verify-site/google`,c,{body:JSON.stringify({keyring_id:e})}).then(p).then(m),submitSurvey:e=>g(`${n}jetpack/v4/marketing/survey`,c,{body:JSON.stringify(e)}).then(p).then(m),saveSetupQuestionnaire:e=>g(`${n}jetpack/v4/setup/questionnaire`,c,{body:JSON.stringify(e)}).then(p).then(m),updateLicensingError:e=>g(`${n}jetpack/v4/licensing/error`,c,{body:JSON.stringify(e)}).then(p).then(m),updateLicenseKey:e=>g(`${n}jetpack/v4/licensing/set-license`,c,{body:JSON.stringify({license:e})}).then(p).then(m),getUserLicensesCounts:()=>d(`${n}jetpack/v4/licensing/user/counts`,i).then(p).then(m),getUserLicenses:()=>d(`${n}jetpack/v4/licensing/user/licenses`,i).then(p).then(m),updateLicensingActivationNoticeDismiss:e=>g(`${n}jetpack/v4/licensing/user/activation-notice-dismiss`,c,{body:JSON.stringify({last_detached_count:e})}).then(p).then(m),updateRecommendationsStep:e=>g(`${n}jetpack/v4/recommendations/step`,c,{body:JSON.stringify({step:e})}).then(p),confirmIDCSafeMode:()=>g(`${n}jetpack/v4/identity-crisis/confirm-safe-mode`,c).then(p),startIDCFresh:e=>g(`${n}jetpack/v4/identity-crisis/start-fresh`,c,{body:JSON.stringify({redirect_uri:e})}).then(p).then(m),migrateIDC:()=>g(`${n}jetpack/v4/identity-crisis/migrate`,c).then(p),attachLicenses:e=>g(`${n}jetpack/v4/licensing/attach-licenses`,c,{body:JSON.stringify({licenses:e})}).then(p).then(m),fetchSearchPlanInfo:()=>d(`${s}jetpack/v4/search/plan`,i).then(p).then(m),fetchSearchSettings:()=>d(`${s}jetpack/v4/search/settings`,i).then(p).then(m),updateSearchSettings:e=>g(`${s}jetpack/v4/search/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchSearchStats:()=>d(`${s}jetpack/v4/search/stats`,i).then(p).then(m),fetchWafSettings:()=>d(`${n}jetpack/v4/waf`,i).then(p).then(m),updateWafSettings:e=>g(`${n}jetpack/v4/waf`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchWordAdsSettings:()=>d(`${n}jetpack/v4/wordads/settings`,i).then(p).then(m),updateWordAdsSettings:e=>g(`${n}jetpack/v4/wordads/settings`,c,{body:JSON.stringify(e)}),fetchSearchPricing:()=>d(`${s}jetpack/v4/search/pricing`,i).then(p).then(m),fetchMigrationStatus:()=>d(`${n}jetpack/v4/migration/status`,i).then(p).then(m),fetchBackupUndoEvent:()=>d(`${n}jetpack/v4/site/backup/undo-event`,i).then(p).then(m),fetchBackupPreflightStatus:()=>d(`${n}jetpack/v4/site/backup/preflight`,i).then(p).then(m)};function d(e,t){return fetch(l(e),t)}function g(e,t,n){return fetch(e,Object.assign({},t,n)).catch(A)}function h(e){return e.general&&void 0===e.general.response||e.week&&void 0===e.week.response||e.month&&void 0===e.month.response?e:{}}Object.assign(this,u)};function p(e){return e.status>=200&&e.status<300?e:404===e.status?new Promise((()=>{throw e.redirected?new l(e.redirected):new c})):e.json().catch((e=>g(e))).then((t=>{const n=new Error(`${t.message} (Status ${e.status})`);throw n.response=t,n.name="ApiError",n}))}function m(e){return e.json().catch((t=>g(t,e.redirected,e.url)))}function g(e,t,n){throw t?new i(n):new o}function A(){throw new u}},42266:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(90311),a=n(19783),s=n(83883),o=n(51113),i=n(13022),c=n(51609),l=n.n(c),u=n(65486);const d=e=>{switch(e){case"error":case"warning":default:return r.A;case"info":return a.A;case"success":return s.A}},p=({level:e="warning",children:t,showIcon:n=!0,className:r})=>{const a=(0,i.A)(u.A.container,u.A[`is-${e}`],r);return l().createElement("div",{className:a},n&&l().createElement("div",{className:u.A["icon-wrapper"]},l().createElement(o.A,{icon:d(e),className:u.A.icon})),l().createElement("div",null,t))}},51112:(e,t,n)=>{"use strict";n.d(t,{A:()=>g});var r=n(96072),a=n.n(r),s=n(56427),o=n(27723),i=n(51113),c=n(53512),l=n(13022),u=n(51609),d=n.n(u),p=n(77560);const __=o.__,m=(0,u.forwardRef)(((e,t)=>{const{children:n,variant:r="primary",size:o="normal",weight:u="bold",icon:m,iconSize:g,disabled:A,isDestructive:h,isLoading:E,isExternalLink:f,className:b,text:v,fullWidth:C,...k}=e,y=(0,l.A)(p.A.button,b,{[p.A.normal]:"normal"===o,[p.A.small]:"small"===o,[p.A.icon]:Boolean(m),[p.A.loading]:E,[p.A.regular]:"regular"===u,[p.A["full-width"]]:C,[p.A["is-icon-button"]]:Boolean(m)&&!n});k.ref=t;const B="normal"===o?20:16,w=f&&d().createElement(d().Fragment,null,d().createElement(i.A,{size:B,icon:c.A,className:p.A["external-icon"]}),d().createElement(s.VisuallyHidden,{as:"span"},/* translators: accessibility text */ +__("%u requests remaining.","jetpack"),f)),y&&React.createElement(React.Fragment,null," ",React.createElement(a.Button,{variant:"link",href:k,target:"_blank",onClick:()=>{n(p.AN,{context:R,placement:p.Cn})}},__("Upgrade","jetpack")))," ",React.createElement(a.Tooltip,{text:__("Logo generation costs 10 requests; prompt enhancement costs 1 request each","jetpack"),placement:"bottom"},React.createElement(o.A,{className:"prompt-footer__icon",icon:i.A}))),!U&&N&&React.createElement(h.G,null),v&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error enhancing prompt. Please try again.","jetpack")),C&&React.createElement("div",{className:"jetpack-ai-logo-generator__prompt-error"},__("Error generating logo. Please try again.","jetpack"))))}},64024:(e,t,n)=>{"use strict";n.d(t,{G:()=>p});var r=n(85985),a=n(56427),s=n(86087),o=n(27723),i=n(51113),c=n(90311),l=n(61356),u=n(60674),d=n(88725);const __=o.__,p=()=>{const{tracks:e}=(0,r.st)(),{recordEvent:t}=e,n=__("Upgrade","jetpack"),o=(0,s.createInterpolateElement)(__("Not enough requests left to generate a logo. Upgrade now to increase it.","jetpack"),{strong:React.createElement("strong",null)}),{nextTierCheckoutURL:p}=(0,u.Q)(),{context:m}=(0,d.A)();return React.createElement("div",{className:"jetpack-upgrade-plan-banner"},React.createElement("div",{className:"jetpack-upgrade-plan-banner__wrapper"},React.createElement("div",null,React.createElement(i.A,{className:"jetpack-upgrade-plan-banner__icon",icon:c.A}),React.createElement("span",{className:"jetpack-upgrade-plan-banner__banner-description"},o)),React.createElement(a.Button,{href:p,target:"_blank",className:"is-primary",onClick:()=>{t(l.AN,{context:m,placement:l.tF})}},n)))}},35421:(e,t,n)=>{"use strict";n.d(t,{R:()=>c});var r=n(85985),a=n(56427),s=n(27723),o=n(61356),i=n(88725);const __=s.__,c=({onCancel:e,upgradeURL:t,reason:n})=>{const{tracks:s}=(0,r.st)(),{recordEvent:c}=s,l=__("The logo generator requires a paid Jetpack AI plan. Upgrade your plan to access exclusive features, including logo generation. The upgrade will also increase the amount of requests you can use in all AI-powered features.","jetpack"),u=__("Not enough requests left to generate a logo. Upgrade your Jetpack AI to increase the amount of requests you can use in all AI-powered features.","jetpack"),{context:d}=(0,i.A)();return React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper"},React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-message"},React.createElement("span",{className:"jetpack-ai-logo-generator-modal__loading-message"},"feature"===n?l:u)," ",React.createElement(a.Button,{variant:"link",href:"https://jetpack.com/ai/",target:"_blank"},__("Learn more about Jetpack AI.","jetpack"))),React.createElement("div",{className:"jetpack-ai-logo-generator-modal__notice-actions"},React.createElement(a.Button,{variant:"tertiary",onClick:e},__("Cancel","jetpack")),React.createElement(a.Button,{variant:"primary",href:t,target:"_blank",onClick:()=>{c(o.AN,{context:d,placement:o.Tz}),e()}},__("Upgrade","jetpack"))))}},48204:(e,t,n)=>{"use strict";n.d(t,{H:()=>c});var r=n(56427),a=n(27723),s=n(53512),o=n(13022),i=n(36791);const __=a.__,c=({className:e=null,onVisitBlankTarget:t})=>React.createElement("div",{className:(0,o.A)("jetpack-ai-logo-generator-modal-visit-site-banner",e)},React.createElement("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__jetpack-logo"},React.createElement("img",{src:i,alt:"Jetpack"})),React.createElement("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__content"},React.createElement("strong",null,__("Do you want to know all the amazing things you can do with Jetpack AI?","jetpack")),React.createElement("span",null,__("Generate and tweak content, create forms, get feedback and much more.","jetpack")),React.createElement("div",null,React.createElement(r.Button,{variant:"link",href:"https://jetpack.com/redirect/?source=logo_generator_learn_more_about_jetpack_ai",target:"_blank",onClick:t||null},__("Learn more about Jetpack AI","jetpack"),React.createElement(r.Icon,{icon:s.A,size:20})))))},61356:(e,t,n)=>{"use strict";n.d(t,{$i:()=>l,AN:()=>u,Cn:()=>d,N3:()=>g,Nt:()=>c,Tz:()=>p,Zb:()=>i,_S:()=>A,h4:()=>o,iz:()=>r,tF:()=>m,ub:()=>a,vm:()=>s});const r="jetpack_ai_logo_generator_modal_open",a="jetpack_ai_logo_generator_modal_close",s="jetpack_ai_logo_generator_generate",o="jetpack_ai_logo_generator_save",i="jetpack_ai_logo_generator_use",c="jetpack_ai_logo_generator_navigate",l="jetpack_ai_logo_generator_feedback",u="jetpack_ai_upgrade_button",d="input_footer",p="free_user_screen",m="upgrade_prompt",g=3,A=10},60674:(e,t,n)=>{"use strict";n.d(t,{Q:()=>l});var r=n(85985),a=n(47143),s=n(10067),o=n.n(s),i=n(74423);const c=o()("ai-client:logo-generator:use-checkout"),l=()=>{const{nextTier:e}=(0,a.useSelect)((e=>({nextTier:e(i.E).getAiAssistantFeature().nextTier})),[]),t=new URL("https://jetpack.com/redirect/");t.searchParams.set("source","jetpack-ai-yearly-tier-upgrade-nudge"),t.searchParams.set("site",(0,r.GE)()),t.searchParams.set("path",`jetpack_ai_yearly:-q-${e?.limit}`);const n=`${window?.Jetpack_Editor_Initial_State?.adminUrl}admin.php?redirect_to_referrer=1&page=my-jetpack#/add-jetpack-ai`,s=(0,r.d9)()||(0,r.Sy)()?t.toString():n;return c("Next tier checkout URL: ",s),{nextTierCheckoutURL:s,hasNextTier:!!e}}},88725:(e,t,n)=>{"use strict";n.d(t,{A:()=>A});var r=n(47143),a=n(10067),s=n.n(a),o=n(51609),i=n(62614),c=n(93869),l=n(51391),u=n(19362),d=n(28229),p=n(74423),m=n(44461);const g=s()("jetpack-ai-calypso:use-logo-generator"),A=()=>{const{setSelectedLogoIndex:e,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setIsRequestingImage:a,setIsEnhancingPrompt:s,increaseAiAssistantRequestsCount:A,addLogoToHistory:h,setContext:E}=(0,r.useDispatch)(p.E),{logos:f,selectedLogoIndex:b,selectedLogo:v,siteDetails:C,isSavingLogoToLibrary:k,isApplyingLogo:y,isEnhancingPrompt:B,isBusy:w,isRequestingImage:_,getAiAssistantFeature:I,requireUpgrade:j,context:x}=(0,r.useSelect)((e=>{const t=e(p.E);return{logos:t.getLogos(),selectedLogoIndex:t.getSelectedLogoIndex(),selectedLogo:t.getSelectedLogo(),siteDetails:t.getSiteDetails(),isSavingLogoToLibrary:t.getIsSavingLogoToLibrary(),isApplyingLogo:t.getIsApplyingLogo(),isRequestingImage:t.getIsRequestingImage(),isEnhancingPrompt:t.getIsEnhancingPrompt(),isBusy:t.getIsBusy(),getAiAssistantFeature:t.getAiAssistantFeature,requireUpgrade:t.getRequireUpgrade(),context:t.getContext()}}),[]),{setFirstLogoPromptFetchError:S,setEnhancePromptFetchError:Q,setLogoFetchError:N,setSaveToLibraryError:R,setLogoUpdateError:T}=(0,m.A)(),{generateImageWithParameters:P}=(0,i.A)(),{saveToMediaLibrary:L}=(0,c.A)(),{ID:M=null,name:D=null,description:F=null}=C||{},O=M?String(M):null,z=I(O),U=z?.costs?.["jetpack-ai-logo-generator"]?.logo,H=(0,o.useCallback)((async function(){S(null),A();try{const e=await(0,l.A)();if(!e||!e.token)throw new Error("No token provided");g("Generating first prompt for site");const t={question:`Generate a simple and short prompt asking for a logo based on the site's name and description, keeping the same language.\nExample for a site named "The minimalist fashion blog", described as "Daily inspiration for all things fashion": A logo for a minimalist fashion site focused on daily sartorial inspiration with a clean and modern aesthetic that is sleek and sophisticated.\nAnother example, now for a site called "El observatorio de aves", described as "Un sitio dedicado a nuestros compañeros y compañeras entusiastas de la observación de aves.": Un logo para un sitio web dedicado a la observación de aves, capturando la esencia de la naturaleza y la pasión por la avifauna en un diseño elegante y representativo, reflejando una estética natural y apasionada por la vida silvestre.\n\nSite name: ${D}\nSite description: ${F}`,feature:"jetpack-ai-logo-generator",stream:!1},n="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",r={Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},a=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(t)}).then((e=>e.json()));return a?.choices?.[0]?.message?.content}catch(e){throw A(-1),S(e),e}}),[S,A,D,F]),V=(0,o.useCallback)((async function({prompt:e}){N(null);try{const t=await(0,l.A)();if(!t||!t.token)throw new Error("No token provided");g("Generating image with prompt",e);const n={prompt:`I NEED to test how the tool works with extremely simple prompts. DO NOT add any detail, just use it AS-IS:\nCreate a single text-free iconic vector logo that symbolically represents the user request, using abstract or symbolic imagery.\nThe design should be modern, with either a vivid color scheme full of gradients or a color scheme that's monochromatic. Use any of those styles based on the user request mood.\nEnsure the logo is set against a clean solid background.\nEnsure the logo works in small sizes.\nThe imagery in the logo should subtly hint at the mood of the user request but DO NOT use any text, letters, or the name of the site on the imagery.\nThe image should contain a single icon, without variations, color palettes or different versions.\n\nUser request:${e}`,feature:"jetpack-ai-logo-generator",response_format:"b64_json"};return await P(n)}catch(e){throw N(e),e}}),[]),q=(0,o.useCallback)((async e=>{R(null);try{if(g("Saving logo for site"),e.mediaId)return{mediaId:e.mediaId,mediaURL:e.url};const n={mediaId:0,mediaURL:""};t(!0);const{id:r,url:a}=await L(e.url,"site-logo.png");return n.mediaId=parseInt(r),n.mediaURL=a,n}catch(e){throw R(e),e}finally{t(!1)}}),[t,R]),G=(0,o.useCallback)((async()=>{T(null);try{if(!O||!v)throw new Error("Missing siteId or logo");g("Applying logo for site",O),n(!0);const{mediaId:e}=v;if(!e)throw new Error("Missing mediaId");await(0,d.Z)({siteId:O,imageId:String(e)})}catch(e){throw T(e),e}finally{n(!1)}}),[v,n,T,O]),$=(0,o.useCallback)((e=>{h(e),(0,u.hm)({...e,siteId:String(O)})}),[O,h,u.hm]),W=(0,o.useCallback)((async function({prompt:e}){g("Generating logo for site"),a(!0);try{if(!U)throw new Error("Missing cost information");let t;A(U);try{if(t=await V({prompt:e}),!t||!t.data.length)throw new Error("No image returned")}catch(e){throw A(-U),e}const n={url:"data:image/png;base64,"+t.data[0].b64_json,description:e};try{const t=await q(n);$({url:t.mediaURL,description:e,mediaId:t.mediaId})}catch(e){throw $(n),e}}finally{a(!1)}}),[U,A,q,$,V]);return{logos:f,selectedLogoIndex:b,selectedLogo:v,setSelectedLogoIndex:e,site:{id:O,name:D,description:F},generateFirstPrompt:H,saveLogo:q,applyLogo:G,generateImage:V,enhancePrompt:async function({prompt:e}){Q(null),A();try{const t=await(0,l.A)();if(!t||!t.token)throw new Error("No token provided");g("Enhancing prompt",e);const n={messages:[{role:"system",content:"Enhance the prompt you receive.\nThe prompt is meant for generating a logo. Return the same prompt enhanced, and make each enhancement wrapped in brackets.\nDo not add any mention to text, letters, typography or the name of the site in the prompt.\nFor example: user's prompt: A logo for an ice cream shop. Returned prompt: A logo for an ice cream shop [that is pink] [and vibrant]."},{role:"user",content:e}],feature:"jetpack-ai-logo-generator",stream:!1},r="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",a={Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},s=await fetch(r,{method:"POST",headers:a,body:JSON.stringify(n)}).then((e=>e.json()));return s?.choices?.[0]?.message?.content}catch(e){throw A(-1),Q(e),e}},storeLogo:$,generateLogo:W,setIsEnhancingPrompt:s,setIsRequestingImage:a,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setContext:E,isEnhancingPrompt:B,isRequestingImage:_,isSavingLogoToLibrary:k,isApplyingLogo:y,isBusy:w,getAiAssistantFeature:I,requireUpgrade:j,context:x}}},44461:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(47143),a=n(74423);const s=()=>{const{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:n,setLogoFetchError:s,setSaveToLibraryError:o,setLogoUpdateError:i}=(0,r.useDispatch)(a.E),{featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:m}=(0,r.useSelect)((e=>{const t=e(a.E);return{featureFetchError:t.getFeatureFetchError(),firstLogoPromptFetchError:t.getFirstLogoPromptFetchError(),enhancePromptFetchError:t.getEnhancePromptFetchError(),logoFetchError:t.getLogoFetchError(),saveToLibraryError:t.getSaveToLibraryError(),logoUpdateError:t.getLogoUpdateError()}}),[]);return{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:n,setLogoFetchError:s,setSaveToLibraryError:o,setLogoUpdateError:i,clearErrors:()=>{e(null),t(null),n(null),s(null),o(null),i(null)},featureFetchError:c,firstLogoPromptFetchError:l,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:m}}},23101:(e,t,n)=>{"use strict";n.d(t,{T:()=>r.T});var r=n(64537)},19362:(e,t,n)=>{"use strict";n.d(t,{$t:()=>i,H:()=>o,NP:()=>c,Pv:()=>l,hm:()=>s});var r=n(13858);const a=10;function s({siteId:e,url:t,description:n,mediaId:r}){const s=i(e),o={url:t,description:n,mediaId:r};return s.push(o),localStorage.setItem(`logo-history-${e}`,JSON.stringify(s.slice(-a))),o}function o({siteId:e,url:t,newUrl:n,mediaId:r}){const s=i(e),o=s.findIndex((e=>e.url===t));return o>-1&&(s[o].url=n,s[o].mediaId=r),localStorage.setItem(`logo-history-${e}`,JSON.stringify(s.slice(-a))),s[o]}function i(e){const t=localStorage.getItem(`logo-history-${e}`);let n=t?JSON.parse(t):[];return Array.isArray(n)||(n=[]),n=n.slice(-a),n=n.filter((e=>"object"==typeof e&&"string"==typeof e.url&&"string"==typeof e.description)).map((e=>({url:e.url,description:e.description,mediaId:e.mediaId}))),n}function c(e){return 0===i(e).length}async function l(e){const t=i(e).filter((({mediaId:e})=>void 0!==e)).map((({mediaId:t})=>new Promise(((n,a)=>{(0,r.T)({siteId:e,mediaId:t}).then((e=>n({mediaId:t,exists:e}))).catch((e=>a(e)))}))));try{(await Promise.all(t)).filter((({exists:e})=>!e)).forEach((({mediaId:t})=>function({siteId:e,mediaId:t}){const n=i(e),r=n.findIndex((e=>e.mediaId===t));-1!==r&&(n.splice(r,1),localStorage.setItem(`logo-history-${e}`,JSON.stringify(n)))}({siteId:e,mediaId:t})))}catch(e){}}},13858:(e,t,n)=>{"use strict";n.d(t,{T:()=>a});var r=n(48931);async function a({mediaId:e}){const t=Number(e);if(Number.isNaN(t))return!1;try{return await(0,r.A)({path:`/wp/v2/media/${Number(e)}`,method:"GET"}),!0}catch(e){const t=e?.data?.status;if(404===t)return!1;throw e}}},28229:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var r=n(22746);async function a({siteId:e,imageId:t}){const n={site_logo:t,site_icon:t};return(0,r.A)({path:`/sites/${String(e)}/settings`,apiVersion:"v2",apiNamespace:"wp/v2",body:n,query:"source=jetpack-ai",method:"POST"})}},22746:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(48931);const a=5;let s=0;async function o(e){if(s+=1,s>a)throw s-=1,new Error("Too many requests");return(0,r.A)(e).finally((()=>{s-=1}))}},9624:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(19362),a=n(22746),s=n(9938);const o={storeAiAssistantFeature:e=>({type:s.UU,feature:e}),fetchAiAssistantFeature:()=>async({dispatch:e})=>{e({type:s.ql});try{const t=await(0,a.A)({path:"/wpcom/v2/jetpack-ai/ai-assistant-feature",query:"force=wpcom"});e(o.storeAiAssistantFeature(function(e){return{hasFeature:!!e["has-feature"],isOverLimit:!!e["is-over-limit"],requestsCount:e["requests-count"],requestsLimit:e["requests-limit"],requireUpgrade:!!e["site-require-upgrade"],errorMessage:e["error-message"],errorCode:e["error-code"],upgradeType:e["upgrade-type"],usagePeriod:{currentStart:e["usage-period"]?.["current-start"],nextStart:e["usage-period"]?.["next-start"],requestsCount:e["usage-period"]?.["requests-count"]||0},currentTier:e["current-tier"],nextTier:e["next-tier"],tierPlansEnabled:!!e["tier-plans-enabled"],costs:e.costs,featuresControl:e["features-control"]}}(t)))}catch(t){e({type:s.Rx,error:t})}},increaseAiAssistantRequestsCount:(e=1)=>({dispatch:t})=>{t({type:s.Lg,count:e})},setAiAssistantFeatureRequireUpgrade:(e=!0)=>({type:s.Kt,requireUpgrade:e}),setTierPlansEnabled:(e=!0)=>({type:s.c1,tierPlansEnabled:e}),setSiteDetails:e=>({type:s.Bz,siteDetails:e}),setSelectedLogoIndex:e=>({type:s.BG,selectedLogoIndex:e}),addLogoToHistory:e=>({type:s.sG,logo:e}),setIsSavingLogoToLibrary:e=>({type:s.E6,isSavingLogoToLibrary:e}),setIsApplyingLogo:e=>({type:s.Ep,isApplyingLogo:e}),updateSelectedLogo:(e,t)=>({type:s.r_,mediaId:e,url:t}),setIsRequestingImage:e=>({type:s.vk,isRequestingImage:e}),setIsEnhancingPrompt:e=>({type:s.O5,isEnhancingPrompt:e}),loadLogoHistory(e){const t=(0,r.$t)(e);return{type:s.ZI,history:t}},setFeatureFetchError:e=>({type:s.Rx,error:e}),setFirstLogoPromptFetchError:e=>({type:s.MQ,error:e}),setEnhancePromptFetchError:e=>({type:s.gG,error:e}),setLogoFetchError:e=>({type:s.q_,error:e}),setSaveToLibraryError:e=>({type:s.x0,error:e}),setLogoUpdateError:e=>({type:s.FN,error:e}),setContext:e=>({type:s.kZ,context:e})},i=o},9938:(e,t,n)=>{"use strict";n.d(t,{BG:()=>m,Bz:()=>c,E6:()=>A,Ep:()=>h,FN:()=>_,GB:()=>l,Kt:()=>o,Lg:()=>s,MQ:()=>k,O5:()=>b,Rx:()=>C,UU:()=>r,ZI:()=>v,c1:()=>i,gG:()=>y,kZ:()=>p,mx:()=>d,nb:()=>u,q_:()=>B,ql:()=>a,r_:()=>E,sG:()=>g,vk:()=>f,x0:()=>w});const r="STORE_AI_ASSISTANT_FEATURE",a="REQUEST_AI_ASSISTANT_FEATURE",s="INCREASE_AI_ASSISTANT_REQUESTS_COUNT",o="SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE",i="SET_TIER_PLANS_ENABLED",c="SET_SITE_DETAILS",l=20,u=999999999,d=3,p="SET_CONTEXT",m="SET_SELECTED_LOGO_INDEX",g="ADD_LOGO_TO_HISTORY",A="SET_IS_SAVING_LOGO_TO_LIBRARY",h="SET_IS_APPLYING_LOGO",E="SAVE_SELECTED_LOGO",f="SET_IS_REQUESTING_IMAGE",b="SET_IS_ENHANCING_PROMPT",v="SET_SITE_HISTORY",C="SET_FEATURE_FETCH_ERROR",k="SET_FIRST_LOGO_PROMPT_FETCH_ERROR",y="SET_ENHANCE_PROMPT_FETCH_ERROR",B="SET_LOGO_FETCH_ERROR",w="SET_SAVE_TO_LIBRARY_ERROR",_="SET_LOGO_UPDATE_ERROR"},74423:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var r=n(47143),a=n(9624),s=n(23695),o=n(80037);const i="jetpack-ai/logo-generator",c=(0,r.createReduxStore)(i,{__experimentalUseThunks:!0,actions:a.A,reducer:s.A,selectors:o.A});(0,r.register)(c)},94891:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(9938);const a={siteDetails:{},features:{aiAssistantFeature:{hasFeature:!0,isOverLimit:!1,requestsCount:0,requestsLimit:r.GB,requireUpgrade:!1,errorMessage:"",errorCode:"",upgradeType:"default",currentTier:{slug:"ai-assistant-tier-free",value:0,limit:20},usagePeriod:{currentStart:"",nextStart:"",requestsCount:0},nextTier:null,tierPlansEnabled:!1,_meta:{isRequesting:!1,asyncRequestCountdown:r.mx,asyncRequestTimerId:0,isRequestingImage:!1}}},history:[],selectedLogoIndex:0}},23695:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(61356),a=n(9938),s=n(94891);function o(e=s.A,t){switch(t.type){case a.ql:return{...e,_meta:{...e._meta??{},featureFetchError:null},features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!0,asyncRequestCountdown:a.mx,asyncRequestTimerId:0}}}};case a.UU:{const n={"jetpack-ai-logo-generator":{logo:r._S}};return{...e,features:{...e.features,aiAssistantFeature:{costs:n,...t.feature,requireUpgrade:t.feature?.requireUpgrade||0===t.feature?.currentTier?.value,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!1}}}}}case a.Lg:{const n=e?.features?.aiAssistantFeature?.usagePeriod||{requestsCount:0},r=(e?.features?.aiAssistantFeature?.requestsCount||0)+(t.count??1);n.requestsCount+=t.count??1;const s=e?.features?.aiAssistantFeature?.currentTier?.value,o=void 0===s&&!e?.features?.aiAssistantFeature?.hasFeature||0===s,i=void 0===s&&e?.features?.aiAssistantFeature?.hasFeature||1===s;let c=e?.features?.aiAssistantFeature?.currentTier?.limit||a.GB;i?c=a.nb:o&&(c=e?.features?.aiAssistantFeature?.requestsLimit);const l=(i||o?r:e?.features?.aiAssistantFeature?.usagePeriod?.requestsCount||0)>=c,u=o||l&&null!==e?.features?.aiAssistantFeature?.nextTier;return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,isOverLimit:l,requestsCount:r,requireUpgrade:u,usagePeriod:{...n}}}}}case a.Kt:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,requireUpgrade:t.requireUpgrade,...t.requireUpgrade?{isOverLimit:!0}:{}}}};case a.c1:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,tierPlansEnabled:t.tierPlansEnabled}}};case a.Bz:return{...e,siteDetails:t.siteDetails};case a.BG:return{...e,selectedLogoIndex:t.selectedLogoIndex};case a.sG:{const n=[...e.history,t.logo];return{...e,history:n,selectedLogoIndex:n.length-1}}case a.E6:return{...e,_meta:{...e._meta??{},isSavingLogoToLibrary:t.isSavingLogoToLibrary}};case a.Ep:return{...e,_meta:{...e._meta??{},isApplyingLogo:t.isApplyingLogo}};case a.r_:{const n=e.history?.[e.selectedLogoIndex];return{...e,history:[...e.history.slice(0,e.selectedLogoIndex),{...n,mediaId:t.mediaId,url:t.url},...e.history.slice(e.selectedLogoIndex+1)]}}case a.vk:return{...e,_meta:{...e._meta??{},isRequestingImage:t.isRequestingImage}};case a.O5:return{...e,_meta:{...e._meta??{},isEnhancingPrompt:t.isEnhancingPrompt}};case a.ZI:return{...e,history:t.history,selectedLogoIndex:t.history?.length?t.history.length-1:0};case a.Rx:return{...e,_meta:{...e._meta??{},featureFetchError:t.error}};case a.MQ:return{...e,_meta:{...e._meta??{},firstLogoPromptFetchError:t.error}};case a.gG:return{...e,_meta:{...e._meta??{},enhancePromptFetchError:t.error}};case a.q_:return{...e,_meta:{...e._meta??{},logoFetchError:t.error}};case a.x0:return{...e,_meta:{...e._meta??{},saveToLibraryError:t.error}};case a.FN:return{...e,_meta:{...e._meta??{},logoUpdateError:t.error}};case a.kZ:return{...e,_meta:{...e._meta??{},context:t.context}}}return e}},80037:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(61356);const a={getAiAssistantFeature(e){const t={...e.features.aiAssistantFeature};return delete t._meta,t},getSiteDetails:e=>e.siteDetails,getIsRequestingAiAssistantFeature:e=>e.features.aiAssistantFeature?._meta?.isRequesting??!1,getLogos:e=>e.history??[],getSelectedLogoIndex:e=>e.selectedLogoIndex??null,getSelectedLogo:e=>e.history?.[e.selectedLogoIndex]??null,getIsSavingLogoToLibrary:e=>e._meta?.isSavingLogoToLibrary??!1,getIsApplyingLogo:e=>e._meta?.isApplyingLogo??!1,getIsEnhancingPrompt:e=>e._meta?.isEnhancingPrompt??!1,getIsRequestingImage:e=>e._meta?.isRequestingImage??!1,getIsBusy:e=>a.getIsApplyingLogo(e)||a.getIsSavingLogoToLibrary(e)||a.getIsRequestingImage(e)||a.getIsEnhancingPrompt(e),getRequireUpgrade(e){const t=e.features.aiAssistantFeature,n=t?.costs?.["jetpack-ai-logo-generator"]?.logo??r._S,a=t?.currentTier?.value||0,s=t?.usagePeriod?.requestsCount||0,o=1===a,i=!t?.nextTier;return e.features.aiAssistantFeature?.requireUpgrade||!o&&!i&&a-se._meta?.featureFetchError??null,getFirstLogoPromptFetchError:e=>e._meta?.firstLogoPromptFetchError??null,getEnhancePromptFetchError:e=>e._meta?.enhancePromptFetchError??null,getLogoFetchError:e=>e._meta?.logoFetchError??null,getSaveToLibraryError:e=>e._meta?.saveToLibraryError??null,getLogoUpdateError:e=>e._meta?.logoUpdateError??null,getContext:e=>e._meta?.context??""},s=a},53664:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(7675),a=n(10067),s=n.n(a),o=n(46219),i=n(51391),c=n(78836);const l=s()("jetpack-ai-client:suggestions-event-source");class u extends EventTarget{constructor(e){super(),this.fullMessage="",this.fullFunctionCall={name:"",arguments:""},this.isPromptClear=!1,this.controller=new AbortController,this.initEventSource(e)}async initEventSource({url:e,question:t,token:n,options:a={}}){if(!n)try{l("Token was not provided, requesting one..."),n=(await(0,i.A)()).token}catch(e){return void this.processErrorEvent(e)}const s={};if(Number.isInteger(parseInt(a.postId))&&(s.post_id=+a.postId),!e){const t=new URL("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query");a?.fromCache&&t.searchParams.append("stream_cache","true"),e=t.toString(),l("URL not provided, using default: %o",e)}Array.isArray(t)?s.messages=t:s.question=t,a?.feature?.length&&(l("Feature: %o",a.feature),s.feature=a.feature),a?.functions?.length&&(l("Functions: %o",a.functions),s.functions=a.functions),a?.model?.length&&(l("Model: %o",a.model),s.model=a.model),this.errorUnclearPromptTriggered=!1,await(0,r.y)(e,{openWhenHidden:!0,method:"POST",headers:{"Content-type":"application/json",Authorization:"Bearer "+n},body:JSON.stringify(s),onclose:()=>{l("Stream closed")},onerror:e=>{throw this.processErrorEvent(e),e},onmessage:e=>{this.processEvent(e)},onopen:async e=>{if(e.ok)return;let t;throw e.status>=400&&e.status<=500&&![413,422,429].includes(e.status)&&(l("Connection error: %o",e),t=c.mA,this.dispatchEvent(new CustomEvent(c.mA,{detail:e}))),503===e.status&&(t=c.AZ,this.dispatchEvent(new CustomEvent(c.AZ))),413===e.status&&(t=c.cT,this.dispatchEvent(new CustomEvent(c.cT))),422===e.status&&(t=c.ud,this.dispatchEvent(new CustomEvent(c.ud))),429===e.status&&(t=c.Or,this.dispatchEvent(new CustomEvent(c.Or))),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(t)})),new Error},signal:this.controller.signal})}checkForUnclearPrompt(){if(this.isPromptClear)return;const e=this.fullMessage.replace(/__|(\*\*)/g,"");if(e.startsWith("JETPACK_AI_ERROR")){if(this.errorUnclearPromptTriggered)return;this.errorUnclearPromptTriggered=!0,this.dispatchEvent(new CustomEvent(c.L9)),l("Unclear error prompt dispatched"),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(c.L9)}))}else"JETPACK_AI_ERROR".startsWith(e)?l(this.fullMessage):this.isPromptClear=!0}close(){this.controller.abort()}processEvent(e){if("[DONE]"===e.data){if(this.errorUnclearPromptTriggered)return;if(this.fullMessage.length)return this.dispatchEvent(new CustomEvent("done",{detail:this.fullMessage})),void l("Done: %o",this.fullMessage);if(this.fullFunctionCall.name.length)return this.dispatchEvent(new CustomEvent("function_done",{detail:this.fullFunctionCall})),void l("Done: %o",this.fullFunctionCall)}let t;try{t=JSON.parse(e.data)}catch(t){return void l("Error parsing JSON",e,t)}const{delta:n}=t?.choices?.[0]??{delta:{content:null,function_call:null}},r=n.content,a=n.function_call;r&&(this.fullMessage+=r,this.checkForUnclearPrompt(),this.isPromptClear&&(this.dispatchEvent(new CustomEvent("chunk",{detail:r})),l("suggestion: %o",this.fullMessage),this.dispatchEvent(new CustomEvent("suggestion",{detail:this.fullMessage})))),a&&(null!=a.name&&(this.fullFunctionCall.name+=a.name),null!=a.arguments&&(this.fullFunctionCall.arguments+=a.arguments),this.dispatchEvent(new CustomEvent("functionCallChunk",{detail:this.fullFunctionCall})))}processErrorEvent(e){l("onerror: %o",e),this.dispatchEvent(new CustomEvent(c.mA,{detail:e})),this.dispatchEvent(new CustomEvent(c.zn,{detail:(0,o.fC)(c.mA)}))}}},78836:(e,t,n)=>{"use strict";n.d(t,{AZ:()=>a,L9:()=>l,Or:()=>s,cT:()=>i,mA:()=>c,uH:()=>r.u,ud:()=>o,zn:()=>u});var r=n(97784);const a="error_service_unavailable",s="error_quota_exceeded",o="error_moderation",i="error_context_too_large",c="error_network",l="error_unclear_prompt",u="error_response"},90372:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(10067);const a=n.n(r)()("dops:analytics");let s,o;window._tkq=window._tkq||[],window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=+new Date;const i={initialize:function(e,t,n){i.setUser(e,t),i.setSuperProps(n),i.identifyUser()},setGoogleAnalyticsEnabled:function(e,t=null){this.googleAnalyticsEnabled=e,this.googleAnalyticsKey=t},setMcAnalyticsEnabled:function(e){this.mcAnalyticsEnabled=e},setUser:function(e,t){o={ID:e,username:t}},setSuperProps:function(e){s=e},assignSuperProps:function(e){s=Object.assign(s||{},e)},mc:{bumpStat:function(e,t){const n=function(e,t){let n="";if("object"==typeof e){for(const t in e)n+="&x_"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);a("Bumping stats %o",e)}else n="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(t),a('Bumping stat "%s" in group "%s"',t,e);return n}(e,t);i.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv"+n+"&t="+Math.random())},bumpStatWithPageView:function(e,t){const n=function(e,t){let n="";if("object"==typeof e){for(const t in e)n+="&"+encodeURIComponent(t)+"="+encodeURIComponent(e[t]);a("Built stats %o",e)}else n="&"+encodeURIComponent(e)+"="+encodeURIComponent(t),a('Built stat "%s" in group "%s"',t,e);return n}(e,t);i.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom"+n+"&t="+Math.random())}},pageView:{record:function(e,t){i.tracks.recordPageView(e),i.ga.recordPageView(e,t)}},purchase:{record:function(e,t,n,r,a,s,o){i.ga.recordPurchase(e,t,n,r,a,s,o)}},tracks:{recordEvent:function(e,t){t=t||{},0===e.indexOf("akismet_")||0===e.indexOf("jetpack_")?(s&&(a("- Super Props: %o",s),t=Object.assign(t,s)),a('Record event "%s" called with props %s',e,JSON.stringify(t)),window._tkq.push(["recordEvent",e,t])):a('- Event name must be prefixed by "akismet_" or "jetpack_"')},recordJetpackClick:function(e){const t="object"==typeof e?e:{target:e};i.tracks.recordEvent("jetpack_wpa_click",t)},recordPageView:function(e){i.tracks.recordEvent("akismet_page_view",{path:e})},setOptOut:function(e){a("Pushing setOptOut: %o",e),window._tkq.push(["setOptOut",e])}},ga:{initialized:!1,initialize:function(){let e={};i.ga.initialized||(o&&(e={userId:"u-"+o.ID}),window.ga("create",this.googleAnalyticsKey,"auto",e),i.ga.initialized=!0)},recordPageView:function(e,t){i.ga.initialize(),a("Recording Page View ~ [URL: "+e+"] [Title: "+t+"]"),this.googleAnalyticsEnabled&&(window.ga("set","page",e),window.ga("send",{hitType:"pageview",page:e,title:t}))},recordEvent:function(e,t,n,r){i.ga.initialize();let s="Recording Event ~ [Category: "+e+"] [Action: "+t+"]";void 0!==n&&(s+=" [Option Label: "+n+"]"),void 0!==r&&(s+=" [Option Value: "+r+"]"),a(s),this.googleAnalyticsEnabled&&window.ga("send","event",e,t,n,r)},recordPurchase:function(e,t,n,r,a,s,o){window.ga("require","ecommerce"),window.ga("ecommerce:addTransaction",{id:e,revenue:r,currency:o}),window.ga("ecommerce:addItem",{id:e,name:t,sku:n,price:a,quantity:s}),window.ga("ecommerce:send")}},identifyUser:function(){o&&window._tkq.push(["identifyUser",o.ID,o.username])},setProperties:function(e){window._tkq.push(["setProperties",e])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}},c=i},5932:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>d});var r=n(56439),a=n(93832);function s(e){class t extends Error{constructor(...t){super(...t),this.name=e}}return t}const o=s("JsonParseError"),i=s("JsonParseAfterRedirectError"),c=s("Api404Error"),l=s("Api404AfterRedirectError"),u=s("FetchNetworkError");const d=new function(e,t){let n=e,s=e,o={"X-WP-Nonce":t},i={credentials:"same-origin",headers:o},c={method:"post",credentials:"same-origin",headers:Object.assign({},o,{"Content-type":"application/json"})},l=function(e){const t=e.split("?"),n=t.length>1?t[1]:"",r=n.length?n.split("&"):[];return r.push("_cacheBuster="+(new Date).getTime()),t[0]+"?"+r.join("&")};const u={setApiRoot(e){n=e},setWpcomOriginApiUrl(e){s=e},setApiNonce(e){o={"X-WP-Nonce":e},i={credentials:"same-origin",headers:o},c={method:"post",credentials:"same-origin",headers:Object.assign({},o,{"Content-type":"application/json"})}},setCacheBusterCallback:e=>{l=e},registerSite:(e,t,a)=>{const s={registration_nonce:e,no_iframe:!0};return(0,r.jetpackConfigHas)("consumer_slug")&&(s.plugin_slug=(0,r.jetpackConfigGet)("consumer_slug")),null!==t&&(s.redirect_uri=t),a&&(s.from=a),g(`${n}jetpack/v4/connection/register`,c,{body:JSON.stringify(s)}).then(p).then(m)},fetchAuthorizationUrl:e=>d((0,a.addQueryArgs)(`${n}jetpack/v4/connection/authorize_url`,{no_iframe:"1",redirect_uri:e}),i).then(p).then(m),fetchSiteConnectionData:()=>d(`${n}jetpack/v4/connection/data`,i).then(m),fetchSiteConnectionStatus:()=>d(`${n}jetpack/v4/connection`,i).then(m),fetchSiteConnectionTest:()=>d(`${n}jetpack/v4/connection/test`,i).then(p).then(m),fetchUserConnectionData:()=>d(`${n}jetpack/v4/connection/data`,i).then(m),fetchUserTrackingSettings:()=>d(`${n}jetpack/v4/tracking/settings`,i).then(p).then(m),updateUserTrackingSettings:e=>g(`${n}jetpack/v4/tracking/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),disconnectSite:()=>g(`${n}jetpack/v4/connection`,c,{body:JSON.stringify({isActive:!1})}).then(p).then(m),fetchConnectUrl:()=>d(`${n}jetpack/v4/connection/url`,i).then(p).then(m),unlinkUser:()=>g(`${n}jetpack/v4/connection/user`,c,{body:JSON.stringify({linked:!1})}).then(p).then(m),reconnect:()=>g(`${n}jetpack/v4/connection/reconnect`,c).then(p).then(m),fetchConnectedPlugins:()=>d(`${n}jetpack/v4/connection/plugins`,i).then(p).then(m),setHasSeenWCConnectionModal:()=>g(`${n}jetpack/v4/seen-wc-connection-modal`,c).then(p).then(m),fetchModules:()=>d(`${n}jetpack/v4/module/all`,i).then(p).then(m),fetchModule:e=>d(`${n}jetpack/v4/module/${e}`,i).then(p).then(m),activateModule:e=>g(`${n}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!0})}).then(p).then(m),deactivateModule:e=>g(`${n}jetpack/v4/module/${e}/active`,c,{body:JSON.stringify({active:!1})}),updateModuleOptions:(e,t)=>g(`${n}jetpack/v4/module/${e}`,c,{body:JSON.stringify(t)}).then(p).then(m),updateSettings:e=>g(`${n}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),getProtectCount:()=>d(`${n}jetpack/v4/module/protect/data`,i).then(p).then(m),resetOptions:e=>g(`${n}jetpack/v4/options/${e}`,c,{body:JSON.stringify({reset:!0})}).then(p).then(m),activateVaultPress:()=>g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"vaultpress",status:"active"})}).then(p).then(m),getVaultPressData:()=>d(`${n}jetpack/v4/module/vaultpress/data`,i).then(p).then(m),installPlugin:(e,t)=>{const r={slug:e,status:"active"};return t&&(r.source=t),g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify(r)}).then(p).then(m)},activateAkismet:()=>g(`${n}jetpack/v4/plugins`,c,{body:JSON.stringify({slug:"akismet",status:"active"})}).then(p).then(m),getAkismetData:()=>d(`${n}jetpack/v4/module/akismet/data`,i).then(p).then(m),checkAkismetKey:()=>d(`${n}jetpack/v4/module/akismet/key/check`,i).then(p).then(m),checkAkismetKeyTyped:e=>g(`${n}jetpack/v4/module/akismet/key/check`,c,{body:JSON.stringify({api_key:e})}).then(p).then(m),fetchStatsData:e=>d(function(e){let t=`${n}jetpack/v4/module/stats/data`;-1!==t.indexOf("?")?t+=`&range=${encodeURIComponent(e)}`:t+=`?range=${encodeURIComponent(e)}`;return t}(e),i).then(p).then(m).then(h),getPluginUpdates:()=>d(`${n}jetpack/v4/updates/plugins`,i).then(p).then(m),getPlans:()=>d(`${n}jetpack/v4/plans`,i).then(p).then(m),fetchSettings:()=>d(`${n}jetpack/v4/settings`,i).then(p).then(m),updateSetting:e=>g(`${n}jetpack/v4/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchSiteData:()=>d(`${n}jetpack/v4/site`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteFeatures:()=>d(`${n}jetpack/v4/site/features`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteProducts:()=>d(`${n}jetpack/v4/site/products`,i).then(p).then(m),fetchSitePurchases:()=>d(`${n}jetpack/v4/site/purchases`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteBenefits:()=>d(`${n}jetpack/v4/site/benefits`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchSiteDiscount:()=>d(`${n}jetpack/v4/site/discount`,i).then(p).then(m).then((e=>e.data)),fetchSetupQuestionnaire:()=>d(`${n}jetpack/v4/setup/questionnaire`,i).then(p).then(m),fetchRecommendationsData:()=>d(`${n}jetpack/v4/recommendations/data`,i).then(p).then(m),fetchRecommendationsProductSuggestions:()=>d(`${n}jetpack/v4/recommendations/product-suggestions`,i).then(p).then(m),fetchRecommendationsUpsell:()=>d(`${n}jetpack/v4/recommendations/upsell`,i).then(p).then(m),fetchRecommendationsConditional:()=>d(`${n}jetpack/v4/recommendations/conditional`,i).then(p).then(m),saveRecommendationsData:e=>g(`${n}jetpack/v4/recommendations/data`,c,{body:JSON.stringify({data:e})}).then(p),fetchProducts:()=>d(`${n}jetpack/v4/products`,i).then(p).then(m),fetchRewindStatus:()=>d(`${n}jetpack/v4/rewind`,i).then(p).then(m).then((e=>JSON.parse(e.data))),fetchScanStatus:()=>d(`${n}jetpack/v4/scan`,i).then(p).then(m).then((e=>JSON.parse(e.data))),dismissJetpackNotice:e=>g(`${n}jetpack/v4/notice/${e}`,c,{body:JSON.stringify({dismissed:!0})}).then(p).then(m),fetchPluginsData:()=>d(`${n}jetpack/v4/plugins`,i).then(p).then(m),fetchIntroOffers:()=>d(`${n}jetpack/v4/intro-offers`,i).then(p).then(m),fetchVerifySiteGoogleStatus:e=>d(null!==e?`${n}jetpack/v4/verify-site/google/${e}`:`${n}jetpack/v4/verify-site/google`,i).then(p).then(m),verifySiteGoogle:e=>g(`${n}jetpack/v4/verify-site/google`,c,{body:JSON.stringify({keyring_id:e})}).then(p).then(m),submitSurvey:e=>g(`${n}jetpack/v4/marketing/survey`,c,{body:JSON.stringify(e)}).then(p).then(m),saveSetupQuestionnaire:e=>g(`${n}jetpack/v4/setup/questionnaire`,c,{body:JSON.stringify(e)}).then(p).then(m),updateLicensingError:e=>g(`${n}jetpack/v4/licensing/error`,c,{body:JSON.stringify(e)}).then(p).then(m),updateLicenseKey:e=>g(`${n}jetpack/v4/licensing/set-license`,c,{body:JSON.stringify({license:e})}).then(p).then(m),getUserLicensesCounts:()=>d(`${n}jetpack/v4/licensing/user/counts`,i).then(p).then(m),getUserLicenses:()=>d(`${n}jetpack/v4/licensing/user/licenses`,i).then(p).then(m),updateLicensingActivationNoticeDismiss:e=>g(`${n}jetpack/v4/licensing/user/activation-notice-dismiss`,c,{body:JSON.stringify({last_detached_count:e})}).then(p).then(m),updateRecommendationsStep:e=>g(`${n}jetpack/v4/recommendations/step`,c,{body:JSON.stringify({step:e})}).then(p),confirmIDCSafeMode:()=>g(`${n}jetpack/v4/identity-crisis/confirm-safe-mode`,c).then(p),startIDCFresh:e=>g(`${n}jetpack/v4/identity-crisis/start-fresh`,c,{body:JSON.stringify({redirect_uri:e})}).then(p).then(m),migrateIDC:()=>g(`${n}jetpack/v4/identity-crisis/migrate`,c).then(p),attachLicenses:e=>g(`${n}jetpack/v4/licensing/attach-licenses`,c,{body:JSON.stringify({licenses:e})}).then(p).then(m),fetchSearchPlanInfo:()=>d(`${s}jetpack/v4/search/plan`,i).then(p).then(m),fetchSearchSettings:()=>d(`${s}jetpack/v4/search/settings`,i).then(p).then(m),updateSearchSettings:e=>g(`${s}jetpack/v4/search/settings`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchSearchStats:()=>d(`${s}jetpack/v4/search/stats`,i).then(p).then(m),fetchWafSettings:()=>d(`${n}jetpack/v4/waf`,i).then(p).then(m),updateWafSettings:e=>g(`${n}jetpack/v4/waf`,c,{body:JSON.stringify(e)}).then(p).then(m),fetchWordAdsSettings:()=>d(`${n}jetpack/v4/wordads/settings`,i).then(p).then(m),updateWordAdsSettings:e=>g(`${n}jetpack/v4/wordads/settings`,c,{body:JSON.stringify(e)}),fetchSearchPricing:()=>d(`${s}jetpack/v4/search/pricing`,i).then(p).then(m),fetchMigrationStatus:()=>d(`${n}jetpack/v4/migration/status`,i).then(p).then(m),fetchBackupUndoEvent:()=>d(`${n}jetpack/v4/site/backup/undo-event`,i).then(p).then(m),fetchBackupPreflightStatus:()=>d(`${n}jetpack/v4/site/backup/preflight`,i).then(p).then(m)};function d(e,t){return fetch(l(e),t)}function g(e,t,n){return fetch(e,Object.assign({},t,n)).catch(A)}function h(e){return e.general&&void 0===e.general.response||e.week&&void 0===e.week.response||e.month&&void 0===e.month.response?e:{}}Object.assign(this,u)};function p(e){return e.status>=200&&e.status<300?e:404===e.status?new Promise((()=>{throw e.redirected?new l(e.redirected):new c})):e.json().catch((e=>g(e))).then((t=>{const n=new Error(`${t.message} (Status ${e.status})`);throw n.response=t,n.name="ApiError",n}))}function m(e){return e.json().catch((t=>g(t,e.redirected,e.url)))}function g(e,t,n){throw t?new i(n):new o}function A(){throw new u}},42266:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(90311),a=n(19783),s=n(83883),o=n(51113),i=n(13022),c=n(51609),l=n.n(c),u=n(65486);const d=e=>{switch(e){case"error":case"warning":default:return r.A;case"info":return a.A;case"success":return s.A}},p=({level:e="warning",children:t,showIcon:n=!0,className:r})=>{const a=(0,i.A)(u.A.container,u.A[`is-${e}`],r);return l().createElement("div",{className:a},n&&l().createElement("div",{className:u.A["icon-wrapper"]},l().createElement(o.A,{icon:d(e),className:u.A.icon})),l().createElement("div",null,t))}},51112:(e,t,n)=>{"use strict";n.d(t,{A:()=>g});var r=n(96072),a=n.n(r),s=n(56427),o=n(27723),i=n(51113),c=n(53512),l=n(13022),u=n(51609),d=n.n(u),p=n(77560);const __=o.__,m=(0,u.forwardRef)(((e,t)=>{const{children:n,variant:r="primary",size:o="normal",weight:u="bold",icon:m,iconSize:g,disabled:A,isDestructive:h,isLoading:E,isExternalLink:f,className:b,text:v,fullWidth:C,...k}=e,y=(0,l.A)(p.A.button,b,{[p.A.normal]:"normal"===o,[p.A.small]:"small"===o,[p.A.icon]:Boolean(m),[p.A.loading]:E,[p.A.regular]:"regular"===u,[p.A["full-width"]]:C,[p.A["is-icon-button"]]:Boolean(m)&&!n});k.ref=t;const B="normal"===o?20:16,w=f&&d().createElement(d().Fragment,null,d().createElement(i.A,{size:B,icon:c.A,className:p.A["external-icon"]}),d().createElement(s.VisuallyHidden,{as:"span"},/* translators: accessibility text */ __("(opens in a new tab)","jetpack"))),_=f?"_blank":void 0,I=n?.[0]&&null!==n[0]&&"components-tooltip"!==n?.[0]?.props?.className;return d().createElement(s.Button,a()({target:_,variant:r,className:(0,l.A)(y,{"has-text":!!m&&I}),icon:f?void 0:m,iconSize:g,disabled:A,"aria-disabled":A,isDestructive:h,text:v},k),E&&d().createElement(s.Spinner,null),d().createElement("span",null,n),w)}));m.displayName="Button";const g=m},69222:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(96072),a=n.n(r),s=n(29491),o=n(86087),i=n(27723),c=n(51112),l=n(78478);const __=i.__,u=({buttonStyle:e="icon",textToCopy:t,onCopy:n,...r})=>{const[i,u]=(0,o.useState)(!1),d=(0,o.useRef)(),p=(0,s.useCopyToClipboard)(t,(()=>{d.current&&clearTimeout(d.current),u(!0),n?.(),d.current=setTimeout((()=>{u(!1),d.current=void 0}),3e3)}));(0,o.useEffect)((()=>()=>{d.current&&clearTimeout(d.current)}),[]);let m=null,g=null;"text"!==e&&(m=i?React.createElement(l.Nr,null):React.createElement(l.ui,null));const A=__("Copy to clipboard","jetpack");return"icon"!==e&&(g=i?__("Copied!","jetpack"):A),React.createElement(c.A,a()({"aria-label":A,icon:m,children:g,ref:p},r))}},63406:(e,t,n)=>{"use strict";n.d(t,{I:()=>s});var r=n(47143),a=n(692);function s(){const e=(0,r.useDispatch)(a.store),t=(0,r.useSelect)((e=>e(a.store).getNotices()),[]);return{...e,createNotice:(t,n,r)=>e.createNotice(t,n,{type:"snackbar",...r}),createErrorNotice:(t,n)=>e.createErrorNotice(t,{type:"snackbar",...n}),createInfoNotice:(t,n)=>e.createInfoNotice(t,{type:"snackbar",...n}),createSuccessNotice:(t,n)=>e.createSuccessNotice(t,{type:"snackbar",...n}),createWarningNotice:(t,n)=>e.createWarningNotice(t,{type:"snackbar",...n}),getNotices:()=>t}}},11883:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(27723),a=n(13022),s=n(51609);n(4459);const __=r.__;class o extends s.Component{static defaultProps={"aria-hidden":"false",focusable:"true"};needsOffset(e,t){return["gridicons-arrow-left","gridicons-arrow-right","gridicons-calendar","gridicons-cart","gridicons-folder","gridicons-info","gridicons-info-outline","gridicons-posts","gridicons-star-outline","gridicons-star"].indexOf(e)>=0&&t%18==0}getSVGDescription(e){if("description"in this.props)return this.props.description;switch(e){default:return"";case"gridicons-audio":return __("Has audio.","jetpack");case"gridicons-arrow-left":return __("Arrow left","jetpack");case"gridicons-arrow-right":return __("Arrow right","jetpack");case"gridicons-calendar":return __("Is an event.","jetpack");case"gridicons-cart":return __("Is a product.","jetpack");case"chevron-down":return __("Show filters","jetpack");case"gridicons-comment":return __("Matching comment.","jetpack");case"gridicons-cross":return __("Close.","jetpack");case"gridicons-filter":return __("Toggle search filters.","jetpack");case"gridicons-folder":return __("Category","jetpack");case"gridicons-info":case"gridicons-info-outline":return __("Information.","jetpack");case"gridicons-image-multiple":return __("Has multiple images.","jetpack");case"gridicons-image":return __("Has an image.","jetpack");case"gridicons-page":return __("Page","jetpack");case"gridicons-post":return __("Post","jetpack");case"gridicons-jetpack-search":case"gridicons-search":return __("Magnifying Glass","jetpack");case"gridicons-tag":return __("Tag","jetpack");case"gridicons-video":return __("Has a video.","jetpack")}}renderIcon(e){switch(e){default:return null;case"gridicons-audio":return React.createElement("g",null,React.createElement("path",{d:"M8 4v10.184C7.686 14.072 7.353 14 7 14c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3V7h7v4.184c-.314-.112-.647-.184-1-.184-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3V4H8z"}));case"gridicons-arrow-left":return React.createElement("g",null,React.createElement("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"}));case"gridicons-arrow-right":return React.createElement("g",null,React.createElement("path",{d:"M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z"}));case"gridicons-block":return React.createElement("g",null,React.createElement("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zM4 12c0-4.418 3.582-8 8-8 1.848 0 3.545.633 4.9 1.686L5.686 16.9C4.633 15.545 4 13.848 4 12zm8 8c-1.848 0-3.546-.633-4.9-1.686L18.314 7.1C19.367 8.455 20 10.152 20 12c0 4.418-3.582 8-8 8z"}));case"gridicons-calendar":return React.createElement("g",null,React.createElement("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.105 0-2 .896-2 2v13c0 1.104.895 2 2 2h14c1.104 0 2-.896 2-2V6c0-1.104-.896-2-2-2zm0 15H5V8h14v11z"}));case"gridicons-cart":return React.createElement("g",null,React.createElement("path",{d:"M9 20c0 1.1-.9 2-2 2s-1.99-.9-1.99-2S5.9 18 7 18s2 .9 2 2zm8-2c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2zm.396-5c.937 0 1.75-.65 1.952-1.566L21 5H7V4c0-1.105-.895-2-2-2H3v2h2v11c0 1.105.895 2 2 2h12c0-1.105-.895-2-2-2H7v-2h10.396z"}));case"gridicons-checkmark":return React.createElement("g",null,React.createElement("path",{d:"M11 17.768l-4.884-4.884 1.768-1.768L11 14.232l8.658-8.658C17.823 3.39 15.075 2 12 2 6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10c0-1.528-.353-2.97-.966-4.266L11 17.768z"}));case"gridicons-chevron-left":return React.createElement("g",null,React.createElement("path",{d:"M16.443 7.41L15.0399 6L9.06934 12L15.0399 18L16.443 16.59L11.8855 12L16.443 7.41Z"}));case"gridicons-chevron-right":return React.createElement("g",null,React.createElement("path",{d:"M10.2366 6L8.8335 7.41L13.391 12L8.8335 16.59L10.2366 18L16.2072 12L10.2366 6Z"}));case"gridicons-chevron-down":return React.createElement("g",null,React.createElement("path",{d:"M20 9l-8 8-8-8 1.414-1.414L12 14.172l6.586-6.586"}));case"gridicons-comment":return React.createElement("g",null,React.createElement("path",{d:"M3 6v9c0 1.105.895 2 2 2h9v5l5.325-3.804c1.05-.75 1.675-1.963 1.675-3.254V6c0-1.105-.895-2-2-2H5c-1.105 0-2 .895-2 2z"}));case"gridicons-computer":return React.createElement("g",null,React.createElement("path",{d:"M20 2H4c-1.104 0-2 .896-2 2v12c0 1.104.896 2 2 2h6v2H7v2h10v-2h-3v-2h6c1.104 0 2-.896 2-2V4c0-1.104-.896-2-2-2zm0 14H4V4h16v12z"}));case"gridicons-cross":return React.createElement("g",null,React.createElement("path",{d:"M18.36 19.78L12 13.41l-6.36 6.37-1.42-1.42L10.59 12 4.22 5.64l1.42-1.42L12 10.59l6.36-6.36 1.41 1.41L13.41 12l6.36 6.36z"}));case"gridicons-filter":return React.createElement("g",null,React.createElement("path",{d:"M10 19h4v-2h-4v2zm-4-6h12v-2H6v2zM3 5v2h18V5H3z"}));case"gridicons-folder":return React.createElement("g",null,React.createElement("path",{d:"M18 19H6c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2h3c1.1 0 2 .9 2 2h7c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2z"}));case"gridicons-image":return React.createElement("g",null,React.createElement("path",{d:"M13 9.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5-.672 1.5-1.5 1.5-1.5-.672-1.5-1.5zM22 6v12c0 1.105-.895 2-2 2H4c-1.105 0-2-.895-2-2V6c0-1.105.895-2 2-2h16c1.105 0 2 .895 2 2zm-2 0H4v7.444L8 9l5.895 6.55 1.587-1.85c.798-.932 2.24-.932 3.037 0L20 15.426V6z"}));case"gridicons-image-multiple":return React.createElement("g",null,React.createElement("path",{d:"M15 7.5c0-.828.672-1.5 1.5-1.5s1.5.672 1.5 1.5S17.328 9 16.5 9 15 8.328 15 7.5zM4 20h14c0 1.105-.895 2-2 2H4c-1.1 0-2-.9-2-2V8c0-1.105.895-2 2-2v14zM22 4v12c0 1.105-.895 2-2 2H8c-1.105 0-2-.895-2-2V4c0-1.105.895-2 2-2h12c1.105 0 2 .895 2 2zM8 4v6.333L11 7l4.855 5.395.656-.73c.796-.886 2.183-.886 2.977 0l.513.57V4H8z"}));case"gridicons-info":return React.createElement("g",null,React.createElement("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"}));case"gridicons-info-outline":return React.createElement("g",null,React.createElement("path",{d:"M13 9h-2V7h2v2zm0 2h-2v6h2v-6zm-1-7c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8m0-2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2z"}));case"gridicons-jetpack-search":return React.createElement("g",null,React.createElement("path",{d:"M0 9.257C0 4.15 4.151 0 9.257 0c5.105 0 9.256 4.151 9.256 9.257a9.218 9.218 0 01-2.251 6.045l.034.033h1.053L24 22.01l-1.986 1.989-6.664-6.662v-1.055l-.033-.033a9.218 9.218 0 01-6.06 2.264C4.15 18.513 0 14.362 0 9.257zm4.169 1.537h4.61V1.82l-4.61 8.973zm5.547-3.092v8.974l4.61-8.974h-4.61z"}));case"gridicons-phone":return React.createElement("g",null,React.createElement("path",{d:"M16 2H8c-1.104 0-2 .896-2 2v16c0 1.104.896 2 2 2h8c1.104 0 2-.896 2-2V4c0-1.104-.896-2-2-2zm-3 19h-2v-1h2v1zm3-2H8V5h8v14z"}));case"gridicons-pages":return React.createElement("g",null,React.createElement("path",{d:"M16 8H8V6h8v2zm0 2H8v2h8v-2zm4-6v12l-6 6H6c-1.105 0-2-.895-2-2V4c0-1.105.895-2 2-2h12c1.105 0 2 .895 2 2zm-2 10V4H6v16h6v-4c0-1.105.895-2 2-2h4z"}));case"gridicons-posts":return React.createElement("g",null,React.createElement("path",{d:"M16 19H3v-2h13v2zm5-10H3v2h18V9zM3 5v2h11V5H3zm14 0v2h4V5h-4zm-6 8v2h10v-2H11zm-8 0v2h5v-2H3z"}));case"gridicons-search":return React.createElement("g",null,React.createElement("path",{d:"M21 19l-5.154-5.154C16.574 12.742 17 11.42 17 10c0-3.866-3.134-7-7-7s-7 3.134-7 7 3.134 7 7 7c1.42 0 2.742-.426 3.846-1.154L19 21l2-2zM5 10c0-2.757 2.243-5 5-5s5 2.243 5 5-2.243 5-5 5-5-2.243-5-5z"}));case"gridicons-star-outline":return React.createElement("g",null,React.createElement("path",{d:"M12 6.308l1.176 3.167.347.936.997.042 3.374.14-2.647 2.09-.784.62.27.963.91 3.25-2.813-1.872-.83-.553-.83.552-2.814 1.87.91-3.248.27-.962-.783-.62-2.648-2.092 3.374-.14.996-.04.347-.936L12 6.308M12 2L9.418 8.953 2 9.257l5.822 4.602L5.82 21 12 16.89 18.18 21l-2.002-7.14L22 9.256l-7.418-.305L12 2z"}));case"gridicons-star":return React.createElement("g",null,React.createElement("path",{d:"M12 2l2.582 6.953L22 9.257l-5.822 4.602L18.18 21 12 16.89 5.82 21l2.002-7.14L2 9.256l7.418-.304"}));case"gridicons-tag":return React.createElement("g",null,React.createElement("path",{d:"M20 2.007h-7.087c-.53 0-1.04.21-1.414.586L2.592 11.5c-.78.78-.78 2.046 0 2.827l7.086 7.086c.78.78 2.046.78 2.827 0l8.906-8.906c.376-.374.587-.883.587-1.413V4.007c0-1.105-.895-2-2-2zM17.007 9c-1.105 0-2-.895-2-2s.895-2 2-2 2 .895 2 2-.895 2-2 2z"}));case"gridicons-video":return React.createElement("g",null,React.createElement("path",{d:"M20 4v2h-2V4H6v2H4V4c-1.105 0-2 .895-2 2v12c0 1.105.895 2 2 2v-2h2v2h12v-2h2v2c1.105 0 2-.895 2-2V6c0-1.105-.895-2-2-2zM6 16H4v-3h2v3zm0-5H4V8h2v3zm4 4V9l4.5 3-4.5 3zm10 1h-2v-3h2v3zm0-5h-2V8h2v3z"}));case"gridicons-lock":return React.createElement(React.Fragment,null,React.createElement("g",{id:"lock"},React.createElement("path",{d:"M18,8h-1V7c0-2.757-2.243-5-5-5S7,4.243,7,7v1H6c-1.105,0-2,0.895-2,2v10c0,1.105,0.895,2,2,2h12c1.105,0,2-0.895,2-2V10 C20,8.895,19.105,8,18,8z M9,7c0-1.654,1.346-3,3-3s3,1.346,3,3v1H9V7z M13,15.723V18h-2v-2.277c-0.595-0.346-1-0.984-1-1.723 c0-1.105,0.895-2,2-2s2,0.895,2,2C14,14.738,13.595,15.376,13,15.723z"})),React.createElement("g",{id:"Layer_1"}));case"gridicons-external":return React.createElement("g",null,React.createElement("path",{d:"M19 13v6c0 1.105-.895 2-2 2H5c-1.105 0-2-.895-2-2V7c0-1.105.895-2 2-2h6v2H5v12h12v-6h2zM13 3v2h4.586l-7.793 7.793 1.414 1.414L19 6.414V11h2V3h-8z"}))}}render(){const{size:e=24,className:t=""}=this.props,n=this.props.height||e,r=this.props.width||e,s=this.props.style||{height:n,width:r},o="gridicons-"+this.props.icon,i=(0,a.A)("gridicon",o,t,{"needs-offset":this.needsOffset(o,e)}),c=this.getSVGDescription(o);return React.createElement("svg",{className:i,focusable:this.props.focusable,height:n,onClick:this.props.onClick,style:s,viewBox:"0 0 24 24",width:r,xmlns:"http://www.w3.org/2000/svg","aria-hidden":this.props["aria-hidden"]},c?React.createElement("desc",null,c):null,this.renderIcon(o))}}const i=o},40597:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(56427),a=n(13022),s=n(51609),o=n.n(s),i=n(51112),c=n(11883);n(84813);const l=e=>({"top-end":"top left",top:"top center","top-start":"top right","bottom-end":"bottom left",bottom:"bottom center","bottom-start":"bottom right"}[e]),u=({className:e="",iconClassName:t="",placement:n="bottom-end",animate:u=!0,iconCode:d="info-outline",iconSize:p=18,offset:m=10,title:g,children:A,popoverAnchorStyle:h="icon",forceShow:E=!1,wide:f=!1,inline:b=!0,shift:v=!1})=>{const[C,k]=(0,s.useState)(!1),y=(0,s.useCallback)((()=>k(!1)),[k]),B=(0,s.useCallback)((e=>{e.preventDefault(),k(!C)}),[C,k]),w={position:l(n),placement:n,animate:u,noArrow:!1,resize:!1,flip:!1,offset:m,focusOnMount:"container",onClose:y,className:"icon-tooltip-container",inline:b,shift:v},_="wrapper"===h,I=(0,a.A)("icon-tooltip-wrapper",e),j={left:_?0:-(62-p/2)+"px"},x=_&&E;return o().createElement("div",{className:I,"data-testid":"icon-tooltip_wrapper"},!_&&o().createElement(i.A,{variant:"link",onMouseDown:B},o().createElement(c.A,{className:t,icon:d,size:p})),o().createElement("div",{className:(0,a.A)("icon-tooltip-helper",{"is-wide":f}),style:j},(x||C)&&o().createElement(r.Popover,w,o().createElement("div",null,g&&o().createElement("div",{className:"icon-tooltip-title"},g),o().createElement("div",{className:"icon-tooltip-content"},A)))))}},78478:(e,t,n)=>{"use strict";n.d(t,{M5:()=>p,Nr:()=>u,ui:()=>d});var r=n(96072),a=n.n(r),s=n(56427),o=n(13022),i=n(84705),c=n(47842);const l=({className:e,size:t=24,viewBox:n="0 0 24 24",opacity:r=1,color:i="#2C3338",children:l})=>{const u={className:(0,o.A)(c.A.iconWrapper,e),width:t,height:t,viewBox:n,opacity:r,fill:void 0};return i&&(u.fill=i),React.createElement(s.SVG,a()({},u,{fillRule:"evenodd",clipRule:"evenodd",xmlns:"http://www.w3.org/2000/svg"}),React.createElement(s.G,{opacity:r},l))},u=({size:e,className:t=c.A["checkmark-icon"],color:n})=>React.createElement(l,{className:t,size:e,color:n},React.createElement(s.Path,{d:"M11 17.768l-4.884-4.884 1.768-1.768L11 14.232l8.658-8.658C17.823 3.39 15.075 2 12 2 6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10c0-1.528-.353-2.97-.966-4.266L11 17.768z"})),d=({size:e,className:t=c.A["clipboard-icon"],color:n})=>React.createElement(l,{className:t,size:e,color:n},React.createElement(s.Path,{d:"M5.625 5.5H15.375C15.444 5.5 15.5 5.55596 15.5 5.625V15.375C15.5 15.444 15.444 15.5 15.375 15.5H5.625C5.55596 15.5 5.5 15.444 5.5 15.375V5.625C5.5 5.55596 5.55596 5.5 5.625 5.5ZM4 5.625C4 4.72754 4.72754 4 5.625 4H15.375C16.2725 4 17 4.72754 17 5.625V10V15.375C17 16.2725 16.2725 17 15.375 17C15.375 17 6.52246 17 5.625 17C4.72754 17 4 16.2725 4 15.375V5.625ZM18.5 17.2812V8.28125H20V17.2812C20 18.7995 18.7704 20 17.2511 20H6.25V18.5H17.2511C17.9409 18.5 18.5 17.9721 18.5 17.2812Z"}));const p=({serviceName:e,className:t,iconSize:n})=>React.createElement(i.Ay,{className:(0,o.A)(c.A.socialIcon,c.A[e],t),icon:e,size:n||24})},67142:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(96072),a=n.n(r),s=n(27723),o=n(13022),i=n(51609),c=n.n(i);const __=s.__,l=({logoColor:e="#069e08",showText:t=!0,className:n,height:r=32,...s})=>{const i=t?"0 0 118 32":"0 0 32 32";return c().createElement("svg",a()({xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:i,className:(0,o.A)("jetpack-logo",n),"aria-labelledby":"jetpack-logo-title",height:r},s,{role:"img"}),c().createElement("title",{id:"jetpack-logo-title"},__("Jetpack Logo","jetpack")),c().createElement("path",{fill:e,d:"M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"}),t&&c().createElement(c().Fragment,null,c().createElement("path",{d:"M41.3,26.6c-0.5-0.7-0.9-1.4-1.3-2.1c2.3-1.4,3-2.5,3-4.6V8h-3V6h6v13.4C46,22.8,45,24.8,41.3,26.6z"}),c().createElement("path",{d:"M65,18.4c0,1.1,0.8,1.3,1.4,1.3c0.5,0,2-0.2,2.6-0.4v2.1c-0.9,0.3-2.5,0.5-3.7,0.5c-1.5,0-3.2-0.5-3.2-3.1V12H60v-2h2.1V7.1 H65V10h4v2h-4V18.4z"}),c().createElement("path",{d:"M71,10h3v1.3c1.1-0.8,1.9-1.3,3.3-1.3c2.5,0,4.5,1.8,4.5,5.6s-2.2,6.3-5.8,6.3c-0.9,0-1.3-0.1-2-0.3V28h-3V10z M76.5,12.3 c-0.8,0-1.6,0.4-2.5,1.2v5.9c0.6,0.1,0.9,0.2,1.8,0.2c2,0,3.2-1.3,3.2-3.9C79,13.4,78.1,12.3,76.5,12.3z"}),c().createElement("path",{d:"M93,22h-3v-1.5c-0.9,0.7-1.9,1.5-3.5,1.5c-1.5,0-3.1-1.1-3.1-3.2c0-2.9,2.5-3.4,4.2-3.7l2.4-0.3v-0.3c0-1.5-0.5-2.3-2-2.3 c-0.7,0-2.3,0.5-3.7,1.1L84,11c1.2-0.4,3-1,4.4-1c2.7,0,4.6,1.4,4.6,4.7L93,22z M90,16.4l-2.2,0.4c-0.7,0.1-1.4,0.5-1.4,1.6 c0,0.9,0.5,1.4,1.3,1.4s1.5-0.5,2.3-1V16.4z"}),c().createElement("path",{d:"M104.5,21.3c-1.1,0.4-2.2,0.6-3.5,0.6c-4.2,0-5.9-2.4-5.9-5.9c0-3.7,2.3-6,6.1-6c1.4,0,2.3,0.2,3.2,0.5V13 c-0.8-0.3-2-0.6-3.2-0.6c-1.7,0-3.2,0.9-3.2,3.6c0,2.9,1.5,3.8,3.3,3.8c0.9,0,1.9-0.2,3.2-0.7V21.3z"}),c().createElement("path",{d:"M110,15.2c0.2-0.3,0.2-0.8,3.8-5.2h3.7l-4.6,5.7l5,6.3h-3.7l-4.2-5.8V22h-3V6h3V15.2z"}),c().createElement("path",{d:"M58.5,21.3c-1.5,0.5-2.7,0.6-4.2,0.6c-3.6,0-5.8-1.8-5.8-6c0-3.1,1.9-5.9,5.5-5.9s4.9,2.5,4.9,4.9c0,0.8,0,1.5-0.1,2h-7.3 c0.1,2.5,1.5,2.8,3.6,2.8c1.1,0,2.2-0.3,3.4-0.7C58.5,19,58.5,21.3,58.5,21.3z M56,15c0-1.4-0.5-2.9-2-2.9c-1.4,0-2.3,1.3-2.4,2.9 C51.6,15,56,15,56,15z"})))}},60442:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(29491),a=n(59053);const s=["sm","md","lg"],o=(e,t)=>{const n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t],[i,c,l]=s,u={sm:(0,r.useMediaQuery)(a.A[i]),md:(0,r.useMediaQuery)(a.A[c]),lg:(0,r.useMediaQuery)(a.A[l])};return n.map(((e,t)=>{const n=o[t];return n?((e,t,n)=>{const r=s.indexOf(e),a=r+1,o=t.includes("=");let i=[];return t.startsWith("<")&&(i=s.slice(0,o?a:r)),t.startsWith(">")&&(i=s.slice(o?r:a)),i?.length?i.some((e=>n[e])):n[e]})(e,n,u):u[e]}))}},11876:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(13022),a=n(51609),s=n.n(a),o=n(47876);const i=({children:e=null,width:t=null,height:n=null,className:a=""})=>s().createElement("div",{className:(0,r.A)(o.A.placeholder,a),style:{width:t,height:n}},e)},47656:(e,t,n)=>{"use strict";n.d(t,{A:()=>m});var r=n(90311),a=n(19783),s=n(83883),o=n(51113),i=n(10991),c=n(13022),l=n(51609),u=n.n(l),d=n(16024);const p=e=>{switch(e){case"error":case"warning":default:return r.A;case"info":return a.A;case"success":return s.A}},m=({level:e="info",title:t,children:n,actions:r,hideCloseButton:a=!1,onClose:s})=>{const l=(0,c.A)(d.A.container,d.A[`is-${e}`]);return u().createElement("div",{className:l},u().createElement("div",{className:d.A["icon-wrapper"]},u().createElement(o.A,{icon:p(e),className:d.A.icon})),u().createElement("div",{className:d.A["main-content"]},t&&u().createElement("div",{className:d.A.title},t),n,r&&r.length>0&&u().createElement("div",{className:d.A["action-bar"]},r.map(((e,t)=>u().createElement("div",{key:t,className:d.A.action},e))))),!a&&u().createElement("button",{"aria-label":"close",className:d.A["close-button"],onClick:s},u().createElement(o.A,{icon:i.A})))}},37975:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(51437);const a=(e,t={})=>{const n=(0,r.Y)();return new Intl.NumberFormat(n,t).format(e)}},36281:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(21782);const a=({value:e="https://jetpack.com",bgColor:t,fgColor:n,level:a,includeMargin:s,imageSettings:o,renderAs:i="canvas",size:c=248})=>React.createElement(r.Ay,{value:e,size:c,bgColor:t,fgColor:n,level:a,includeMargin:s,imageSettings:o,renderAs:i})},56461:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(28120),a=n.n(r),s=n(51609),o=n.n(s);n(85335);const i=({color:e="#FFFFFF",className:t="",size:n=20})=>{const r=t+" jp-components-spinner",a={width:n,height:n,fontSize:n,borderTopColor:e},s={borderTopColor:e,borderRightColor:e};return o().createElement("div",{className:r},o().createElement("div",{className:"jp-components-spinner__outer",style:a},o().createElement("div",{className:"jp-components-spinner__inner",style:s})))};i.propTypes={color:a().string,className:a().string,size:a().number};const c=i},10110:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r,Z:()=>a});const r={"headline-medium":"h1","headline-small":"h2","headline-small-regular":"h2","title-medium":"h3","title-medium-semi-bold":"h3","title-small":"h4",body:"p","body-small":"p","body-extra-small":"p","body-extra-small-bold":"p",label:"p"},a=["mt","mr","mb","ml","mx","my","m","pt","pr","pb","pl","px","py","p"]},47425:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>d});var r=n(96072),a=n.n(r),s=n(13022),o=n(51609),i=n.n(o),c=n(10110),l=n(22073);const u=(0,o.forwardRef)((({variant:e="body",children:t,component:n,className:r,...u},d)=>{const p=n||c.Q[e]||"span",m=(0,o.useMemo)((()=>c.Z.reduce(((e,t)=>(void 0!==u[t]&&(e+=l.A[`${t}-${u[t]}`]+" ",delete u[t]),e)),"")),[u]);return u.ref=d,i().createElement(p,a()({className:(0,s.A)(l.A.reset,l.A[e],r,m)},u),t)}));u.displayName="Text";const d=u},50723:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>p});var r=n(51609),a=n.n(r),s=n(25196);const o={"--font-headline-medium":"48px","--font-headline-small":"36px","--font-title-medium":"24px","--font-title-small":"20px","--font-body":"16px","--font-body-small":"14px","--font-body-extra-small":"12px","--font-title-large":"var(--font-headline-small)","--font-label":"var(--font-body-extra-small)"},i={"--jp-black":"#000000","--jp-black-80":"#2c3338","--jp-white":"#ffffff","--jp-white-off":"#f9f9f6","--jp-gray":"#dcdcde","--jp-gray-0":"#F6F7F7","--jp-gray-5":"var(--jp-gray)","--jp-gray-10":"#C3C4C7","--jp-gray-20":"#A7AAAD","--jp-gray-40":"#787C82","--jp-gray-50":"#646970","--jp-gray-60":"#50575E","--jp-gray-70":"#3C434A","--jp-gray-80":"#2C3338","--jp-gray-90":"#1d2327","--jp-gray-off":"#e2e2df","--jp-red-0":"#F7EBEC","--jp-red-5":"#FACFD2","--jp-red-40":"#E65054","--jp-red-50":"#D63638","--jp-red-60":"#B32D2E","--jp-red-70":"#8A2424","--jp-red-80":"#691C1C","--jp-red":"#d63639","--jp-yellow-5":"#F5E6B3","--jp-yellow-10":"#F2CF75","--jp-yellow-20":"#F0C930","--jp-yellow-30":"#DEB100","--jp-yellow-40":"#C08C00","--jp-yellow-50":"#9D6E00","--jp-yellow-60":"#7D5600","--jp-blue-20":"#68B3E8","--jp-blue-40":"#1689DB","--jp-pink":"#C9356E","--jp-green-0":"#f0f2eb","--jp-green-5":"#d0e6b8","--jp-green-10":"#9dd977","--jp-green-20":"#64ca43","--jp-green-30":"#2fb41f","--jp-green-40":"#069e08","--jp-green-50":"#008710","--jp-green-60":"#007117","--jp-green-70":"#005b18","--jp-green-80":"#004515","--jp-green-90":"#003010","--jp-green-100":"#001c09","--jp-green":"#069e08","--jp-green-primary":"var( --jp-green-40 )","--jp-green-secondary":"var( --jp-green-30 )"},c={"--jp-border-radius":"4px","--jp-menu-border-height":"1px","--jp-underline-thickness":"2px"},l={"--spacing-base":"8px"},u={},d=(e,t,n)=>{const r={...o,...i,...c,...l};for(const t in r)e.style.setProperty(t,r[t]);n&&e.classList.add(s.A.global),t&&(u[t]={provided:!0,root:e})},p=({children:e=null,targetDom:t,id:n,withGlobalStyles:s=!0})=>{const o=(0,r.useRef)(),i=u?.[n]?.provided;return(0,r.useLayoutEffect)((()=>{if(!i)return t?d(t,n,s):void(o?.current&&d(o.current,n,s))}),[t,o,i,n,s]),t?a().createElement(a().Fragment,null,e):a().createElement("div",{ref:o},e)}},51437:(e,t,n)=>{"use strict";n.d(t,{Y:()=>a});var r=n(38443);const a=()=>{const{l10n:{locale:e}}=(0,r.getSettings)();if(e)return(e=>{const t=e.match(/^([a-z]{2,3})(_[a-z]{2}|_[a-z][a-z0-9]{4,7})?(?:_.*)?$/i);return t?`${t[1]}${t[2]?t[2]:""}`.replace("_","-"):"en-US"})(e);return window?.window?.navigator?.language??"en-US"}},3924:(e,t,n)=>{"use strict";function r(e,t={}){const n={};let r;if("undefined"!=typeof window&&(r=window?.JP_CONNECTION_INITIAL_STATE?.calypsoEnv),0===e.search("https://")){const t=new URL(e);e=`https://${t.host}${t.pathname}`,n.url=encodeURIComponent(e)}else n.source=encodeURIComponent(e);for(const e in t)n[e]=encodeURIComponent(t[e]);!Object.keys(n).includes("site")&&"undefined"!=typeof jetpack_redirects&&Object.hasOwn(jetpack_redirects,"currentSiteRawUrl")&&(n.site=jetpack_redirects.currentBlogID??jetpack_redirects.currentSiteRawUrl),r&&(n.calypso_env=r);return"https://jetpack.com/redirect/?"+Object.keys(n).map((e=>e+"="+n[e])).join("&")}n.d(t,{A:()=>r})},56439:(e,t,n)=>{let r={};try{r=n(74277)}catch{console.error("jetpackConfig is missing in your webpack config file. See @automattic/jetpack-config"),r={missingConfig:!0}}const a=e=>Object.hasOwn(r,e);e.exports={jetpackConfigHas:a,jetpackConfigGet:e=>{if(!a(e))throw'This app requires the "'+e+'" Jetpack Config to be defined in your webpack configuration file. See details in @automattic/jetpack-config package docs.';return r[e]}}},89660:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(5932),a=n(97999),s=n(47143),o=n(51609),i=n(34293);const c=window?.JP_CONNECTION_INITIAL_STATE||(0,a.getScriptData)()?.connection||{},l=({registrationNonce:e=c.registrationNonce,apiRoot:t=c.apiRoot,apiNonce:n=c.apiNonce,redirectUri:a,autoTrigger:l,from:u,skipUserConnection:d}={})=>{const{registerSite:p,connectUser:m,refreshConnectedPlugins:g}=(0,s.useDispatch)(i.a),A=(0,s.useSelect)((e=>e(i.a).getRegistrationError())),{siteIsRegistering:h,userIsConnecting:E,userConnectionData:f,connectedPlugins:b,connectionErrors:v,isRegistered:C,isUserConnected:k,hasConnectedOwner:y,isOfflineMode:B}=(0,s.useSelect)((e=>({siteIsRegistering:e(i.a).getSiteIsRegistering(),userIsConnecting:e(i.a).getUserIsConnecting(),userConnectionData:e(i.a).getUserConnectionData(),connectedPlugins:e(i.a).getConnectedPlugins(),connectionErrors:e(i.a).getConnectionErrors(),isOfflineMode:e(i.a).getIsOfflineMode(),...e(i.a).getConnectionStatus()}))),w=()=>d?a?(window.location=a,Promise.resolve(a)):Promise.resolve():m({from:u,redirectUri:a}),_=t=>(t&&t.preventDefault(),C?w():p({registrationNonce:e,redirectUri:a,from:u}).then((()=>w())));return(0,o.useEffect)((()=>{r.Ay.setApiRoot(t),r.Ay.setApiNonce(n)}),[t,n]),(0,o.useEffect)((()=>{!l||h||E||_()}),[]),{handleRegisterSite:_,handleConnectUser:w,refreshConnectedPlugins:g,isRegistered:C,isUserConnected:k,siteIsRegistering:h,userIsConnecting:E,registrationError:A,userConnectionData:f,hasConnectedOwner:y,connectedPlugins:b,connectionErrors:v,isOfflineMode:B}}},33935:(e,t,n)=>{"use strict";n.d(t,{A1:()=>c,Ay:()=>k,DO:()=>i,Ij:()=>o,Kl:()=>m,LW:()=>l,MU:()=>g,XY:()=>u,ZO:()=>s,dz:()=>d,gH:()=>p,v_:()=>a});var r=n(5932);const a="SET_CONNECTION_STATUS",s="SET_CONNECTION_STATUS_IS_FETCHING",o="SET_SITE_IS_REGISTERING",i="SET_USER_IS_CONNECTING",c="SET_REGISTRATION_ERROR",l="CLEAR_REGISTRATION_ERROR",u="SET_AUTHORIZATION_URL",d="DISCONNECT_USER_SUCCESS",p="SET_CONNECTED_PLUGINS",m="SET_CONNECTION_ERRORS",g="SET_IS_OFFLINE_MODE",A=e=>({type:a,connectionStatus:e}),h=e=>({type:o,isRegistering:e}),E=e=>({type:i,isConnecting:e}),f=e=>({type:c,registrationError:e}),b=()=>({type:l}),v=e=>({type:u,authorizationUrl:e}),C=e=>({type:p,connectedPlugins:e});const k={setConnectionStatus:A,setConnectionStatusIsFetching:e=>({type:s,isFetching:e}),fetchConnectionStatus:()=>({type:"FETCH_CONNECTION_STATUS"}),fetchAuthorizationUrl:e=>({type:"FETCH_AUTHORIZATION_URL",redirectUri:e}),setSiteIsRegistering:h,setUserIsConnecting:E,setRegistrationError:f,clearRegistrationError:b,setAuthorizationUrl:v,registerSite:function*({registrationNonce:e,redirectUri:t,from:n=""}){yield b(),yield h(!0);try{const r=yield{type:"REGISTER_SITE",registrationNonce:e,redirectUri:t,from:n};return yield A({isRegistered:!0}),yield v(r.authorizeUrl),yield h(!1),Promise.resolve(r)}catch(e){return yield f(e),yield h(!1),Promise.reject(e)}},connectUser:function*({from:e,redirectFunc:t,redirectUri:n}={}){yield E(!0),yield{type:"CONNECT_USER",from:e,redirectFunc:t,redirectUri:n}},disconnectUserSuccess:()=>({type:d}),setConnectedPlugins:C,refreshConnectedPlugins:()=>async({dispatch:e})=>await new Promise((t=>r.Ay.fetchConnectedPlugins().then((n=>{e(C(n)),t(n)})))),setConnectionErrors:e=>({type:m,connectionErrors:e}),setIsOfflineMode:e=>({type:g,isOfflineMode:e})}},22494:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(5932),a=n(47143),s=n(32279);const o={FETCH_AUTHORIZATION_URL:({redirectUri:e})=>r.Ay.fetchAuthorizationUrl(e),REGISTER_SITE:({registrationNonce:e,redirectUri:t,from:n})=>r.Ay.registerSite(e,t,n),CONNECT_USER:(0,a.createRegistryControl)((({resolveSelect:e})=>({from:t,redirectFunc:n,redirectUri:r}={})=>new Promise(((a,o)=>{e(s.A).getAuthorizationUrl(r).then((e=>{const r=n||(e=>window.location.assign(e)),s=new URL(e);t&&s.searchParams.set("from",encodeURIComponent(t));const o=s.toString();r(o),a(o)})).catch((e=>{o(e)}))}))))}},5051:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(47143),a=n(33935);const s=(0,r.combineReducers)({connectionStatus:(e={},t)=>{switch(t.type){case a.v_:return{...e,...t.connectionStatus};case a.dz:return{...e,isUserConnected:!1}}return e},connectionStatusIsFetching:(e=!1,t)=>t.type===a.ZO?t.isFetching:e,siteIsRegistering:(e=!1,t)=>t.type===a.Ij?t.isRegistering:e,userIsConnecting:(e=!1,t)=>t.type===a.DO?t.isConnecting:e,registrationError:(e,t)=>{switch(t.type){case a.LW:return!1;case a.A1:return t.registrationError;default:return e}},authorizationUrl:(e,t)=>t.type===a.XY?t.authorizationUrl:e,userConnectionData:(e,t)=>(t.type,e),connectedPlugins:(e={},t)=>t.type===a.gH?t.connectedPlugins:e,connectionErrors:(e={},t)=>t.type===a.Kl?t.connectionErrors:e,isOfflineMode:(e=!1,t)=>t.type===a.MU?t.isConnecting:e})},58019:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(47143),a=n(33935),s=n(32279);const o={...{getAuthorizationUrl:{isFulfilled:(e,...t)=>{const n=Boolean(e.authorizationUrl),a=(0,r.select)(s.A).hasFinishedResolution("getAuthorizationUrl",t);return n&&!a&&(0,r.dispatch)(s.A).finishResolution("getAuthorizationUrl",t),n},*fulfill(e){const t=yield a.Ay.fetchAuthorizationUrl(e);yield a.Ay.setAuthorizationUrl(t.authorizeUrl)}}}}},52676:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r={...{getConnectionStatus:e=>e.connectionStatus||{},getConnectionStatusIsFetching:()=>!1,getSiteIsRegistering:e=>e.siteIsRegistering||!1,getUserIsConnecting:e=>e.userIsConnecting||!1,getRegistrationError:e=>e.registrationError||!1,getAuthorizationUrl:e=>e.authorizationUrl||!1,getUserConnectionData:e=>e.userConnectionData||!1,getConnectedPlugins:e=>e.connectedPlugins||[],getConnectionErrors:e=>e.connectionErrors||[],getIsOfflineMode:e=>e.isOfflineMode||!1,getWpcomUser:e=>e?.userConnectionData?.currentUser?.wpcomUser,getBlogId:e=>e?.userConnectionData?.currentUser?.blogId}}},18734:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(47143);class a{static store=null;static mayBeInit(e,t){null===a.store&&(a.store=(0,r.createReduxStore)(e,t),(0,r.register)(a.store))}}const s=a},32279:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r="jetpack-connection"},34293:(e,t,n)=>{"use strict";n.d(t,{a:()=>u.A});var r=n(97999),a=n(33935),s=n(22494),o=n(5051),i=n(58019),c=n(52676),l=n(18734),u=n(32279);const d=window.JP_CONNECTION_INITIAL_STATE||(0,r.getScriptData)()?.connection;d||console.error("Jetpack Connection package: Initial state is missing. Check documentation to see how to use the Connection composer package to set up the initial state."),l.A.mayBeInit(u.A,{__experimentalUseThunks:!0,reducer:o.A,actions:a.Ay,selectors:c.A,resolvers:i.A,controls:s.A,initialState:d||{}})},7162:(e,t,n)=>{"use strict";n.d(t,{GlobalModals:()=>p.m,PostPublishPanels:()=>i.A,PublicizePanel:()=>o.A,SocialImageGeneratorPanel:()=>s.A,SocialPreviewsModal:()=>r.A,SocialPreviewsPanel:()=>a.A,usePublicizeConfig:()=>l.A,useSocialMediaConnections:()=>c.A,useSyncPostDataToStore:()=>d.F});n(89729),n(10267),n(70925);var r=n(81115),a=n(97192),s=n(29341),o=(n(12226),n(98725),n(29761),n(66561)),i=(n(25300),n(26029)),c=(n(37051),n(26637),n(50001)),l=(n(39553),n(77627)),u=(n(31873),n(54822),n(70407));n.o(u,"GlobalModals")&&n.d(t,{GlobalModals:function(){return u.GlobalModals}}),n.o(u,"useSyncPostDataToStore")&&n.d(t,{useSyncPostDataToStore:function(){return u.useSyncPostDataToStore}});n(39815);var d=n(75168),p=(n(49036),n(383),n(49192),n(48222),n(50646),n(47453))},12141:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(78478),a=n(86087),s=n(13022),o=n(28120),i=n.n(o);const c=e=>{const{checked:t,serviceName:n,label:o,onClick:i,profilePicture:c}=e,[l,u]=(0,a.useState)(!!c),d=(0,a.useCallback)((()=>u(!1)),[]),p=(0,a.useCallback)((e=>{13===e.keyCode&&i()}),[i]);return React.createElement("div",{onClick:i,onKeyDown:p,role:"switch","aria-checked":t,tabIndex:"0",className:(0,s.A)("components-connection-icon",{"components-connection-icon__picture":l})},l&&React.createElement("img",{src:c,alt:o,onError:d}),React.createElement(r.M5,{alt:o,serviceName:"instagram-business"===n?"instagram":"twitter"===n?"x":n,className:"jetpack-publicize-gutenberg-social-icon"}))};c.propTypes={serviceName:i().string,label:i().string,profilePicture:i().string};const l=c},55488:(e,t,n)=>{"use strict";n(56427),n(27723),n(51609),n(12141),n(27817),n(86158),n(43119),n(52683),n(85605)},27817:(e,t,n)=>{"use strict";n.d(t,{s:()=>c});var r=n(56427),a=n(47143),s=n(27723),o=n(89729),i=n(85605);const __=s.__;function c({connection:e}){const t=(0,a.useSelect)((t=>t(o.M_).getUpdatingConnections().includes(e.connection_id)),[e.connection_id]);return React.createElement("div",{className:i.A["connection-name"]},e.profile_link?React.createElement(r.ExternalLink,{className:i.A["profile-link"],href:e.profile_link},e.display_name||e.external_display):React.createElement("span",{className:i.A["profile-link"]},e.display_name),t?React.createElement(r.Spinner,{color:"black","aria-label":__("Updating account","jetpack")}):null)}},86158:(e,t,n)=>{"use strict";n.d(t,{v:()=>l});var r=n(3924),a=n(56427),s=n(86087),o=n(27723),i=n(43119),c=n(76046);const __=o.__;function l({connection:e,service:t}){return"broken"!==e.status?null:React.createElement("div",null,React.createElement("span",{className:"description"},t?__("There is an issue with this connection.","jetpack"):(0,s.createInterpolateElement)((0,o.sprintf)("%1$s %2$s",__("This platform is no longer supported.","jetpack"),__("You can use our Manual Sharing feature instead.","jetpack")),{link:React.createElement(a.ExternalLink,{href:(0,r.A)("jetpack-social-manual-sharing-help")})}))," ",t?React.createElement(c.C,{connection:e,service:t}):React.createElement(i.V,{connection:e,variant:"link",isDestructive:!1}))}},43119:(e,t,n)=>{"use strict";n.d(t,{V:()=>u});var r=n(51112),a=n(56427),s=n(47143),o=n(86087),i=n(27723),c=n(89729),l=n(85605);const __=i.__,_x=i._x;function u({connection:e,variant:t="secondary",isDestructive:n=!0,buttonClassName:u}){const[d,p]=(0,o.useReducer)((e=>!e),!1),{deleteConnectionById:m}=(0,s.useDispatch)(c.M_),{isDisconnecting:g}=(0,s.useSelect)((t=>{const{getDeletingConnections:n}=t(c.M_);return{isDisconnecting:n().includes(e.connection_id)}}),[e.connection_id]),A=(0,o.useCallback)((async()=>{p(),await m({connectionId:e.connection_id})}),[e.connection_id,m]);return e.can_disconnect?React.createElement(React.Fragment,null,React.createElement(a.__experimentalConfirmDialog,{className:l.A.confirmDialog,isOpen:d,onConfirm:A,onCancel:p,cancelButtonText:__("Cancel","jetpack"),confirmButtonText:__("Yes","jetpack")},(0,o.createInterpolateElement)((0,i.sprintf)( // translators: %s: The name of the connection the user is disconnecting. __("Are you sure you want to disconnect %s?","jetpack"),e.display_name),{strong:React.createElement("strong",null)})),React.createElement(r.A,{size:"small",onClick:p,disabled:g,variant:t,isDestructive:n,className:u},g?__("Disconnecting…","jetpack"):_x("Disconnect","Disconnect a social media account","jetpack"))):null}},26637:(e,t,n)=>{"use strict";n(56427),n(47143),n(86087),n(27723),n(50001),n(89729),n(48222),n(48712),n(55488),n(85605)},52683:(e,t,n)=>{"use strict";n.d(t,{j:()=>c});var r=n(56427),a=n(47143),s=n(86087),o=n(27723),i=n(89729);const __=o.__;function c({connection:e}){const{updateConnectionById:t}=(0,a.useDispatch)(i.M_),{isUpdating:n}=(0,a.useSelect)((t=>{const{getUpdatingConnections:n}=t(i.M_);return{isUpdating:n().includes(e.connection_id)}}),[e.connection_id]),o=(0,s.useCallback)((n=>{t(e.connection_id,{shared:n})}),[e.connection_id,t]);return React.createElement(r.CheckboxControl,{checked:e.shared??!1,onChange:o,disabled:n||"broken"===e.status,label:__("Mark the connection as shared","jetpack")})}},76046:(e,t,n)=>{"use strict";n.d(t,{C:()=>l});var r=n(51112),a=n(47143),s=n(86087),o=n(27723),i=n(89729),c=n(70745);const __=o.__,_x=o._x;function l({connection:e,service:t,variant:n="link"}){const{deleteConnectionById:o,setKeyringResult:l,openConnectionsModal:u,setReconnectingAccount:d}=(0,a.useDispatch)(i.M_),{isDisconnecting:p}=(0,a.useSelect)((t=>{const{getDeletingConnections:n}=t(i.M_);return{isDisconnecting:n().includes(e.connection_id)}}),[e.connection_id]),m=(0,s.useCallback)((e=>{l(e),e?.ID&&u()}),[u,l]),g=(0,c.P)({service:t,onConfirm:m}),A=(0,s.useCallback)((async()=>{if(!await o({connectionId:e.connection_id,showSuccessNotice:!1}))return;await d(`${e.service_name}:${e.external_id}`);const n=new FormData;"mastodon"===t.ID&&n.set("instance",e.external_display),g(n)}),[e,o,g,t.ID,d]);return e.can_disconnect?React.createElement(r.A,{size:"small",onClick:A,disabled:p,variant:n},p?__("Disconnecting…","jetpack"):_x("Reconnect","Reconnect a social media account","jetpack")):null}},91910:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(13022),a=n(28120),s=n.n(a),o=n(12141);const i=e=>{const{checked:t,disabled:n,onChange:a,serviceName:s,label:i,profilePicture:c}=e,l=(0,r.A)("components-connection-toggle",{"is-not-checked":!t,"is-disabled":n});return React.createElement("div",{className:l,title:i},React.createElement(o.A,{checked:t,label:i,onClick:a,serviceName:s,profilePicture:c}))};i.propTypes={className:s().string,checked:s().bool,id:s().string.isRequired,disabled:s().bool,onChange:s().func,serviceName:s().string,label:s().string,profilePicture:s().string};const c=i},10267:(e,t,n)=>{"use strict";n.d(t,{A:()=>m});var r=n(85985),a=n(56427),s=n(47143),o=n(86087),i=n(27723),c=n(89729),l=n(91910),u=n(95051),d=n(49514);const __=i.__;class p extends o.Component{maybeDisplayLinkedInNotice=()=>this.connectionNeedsReauth()&&React.createElement(a.Notice,{className:u.A["publicize-notice"],isDismissible:!1,status:"error"},React.createElement("p",null,__("Your LinkedIn connection needs to be reauthenticated to continue working – head to Sharing to take care of it.","jetpack")),React.createElement(a.ExternalLink,{href:`https://wordpress.com/marketing/connections/${(0,r.GE)()}`},__("Go to Sharing settings","jetpack")));connectionNeedsReauth=()=>this.props.mustReauthConnections.includes(this.props.name);onConnectionChange=()=>{const{id:e}=this.props;this.isDisabled()||this.props.toggleConnection(e)};connectionIsFailing(){const{failedConnections:e,name:t}=this.props;return e.some((e=>e.service_name===t))}isDisabled(){return this.props.disabled||this.connectionIsFailing()||this.connectionNeedsReauth()}render(){const{enabled:e,id:t,label:n,name:r,profilePicture:a}=this.props,s="connection-"+r+"-"+t,o=r.replace("_","-"),i=React.createElement(l.A,{id:s,className:d.A["connection-toggle"],checked:e,onChange:this.onConnectionChange,disabled:this.isDisabled(),serviceName:o,label:n,profilePicture:a});return React.createElement("li",null,this.maybeDisplayLinkedInNotice(),React.createElement("div",{className:d.A["connection-container"]},i))}}const m=(0,s.withSelect)((e=>({failedConnections:e(c.Af).getFailedConnections(),mustReauthConnections:e(c.Af).getMustReauthConnections()})))(p)},77125:(e,t,n)=>{"use strict";n.d(t,{l:()=>A});var r=n(51112),a=n(56427),s=n(47143),o=n(86087),i=n(27723),c=n(77627),l=n(50001),u=n(89729),d=n(51475),p=n(9515),m=n(71016),g=n(89886);const __=i.__,_x=i._x,A=()=>{const{connections:e}=(0,l.A)(),t=e.filter((e=>"broken"===e.status||(0,g.Y)(e,"broken"))),{connectionsAdminUrl:n}=(0,c.A)(),i=(0,s.useSelect)((e=>e(u.M_).useAdminUiV1()),[]),{openConnectionsModal:A}=(0,s.useDispatch)(u.M_),h=i?React.createElement(r.A,{variant:"link",onClick:A,className:m.A["broken-connection-btn"]}):React.createElement(a.ExternalLink,{href:n}),E=(0,p.h)();if(!t.length)return null;const f=t.reduce(((e,t)=>(e[t.service_name]||(e[t.service_name]=[]),e[t.service_name].push(t),e)),{});return t.length>0&&React.createElement(d.A,{type:"error"},__("Your following connections need to be reconnected:","jetpack"),React.createElement("ul",null,Object.entries(f).map((([e,t])=>{const n=E(e);return React.createElement("li",{key:e},React.createElement("div",{className:m.A["broken-connection-service"]},React.createElement("span",null,n,_x(":","Colon to display before the list of connections","jetpack")," "),t.map((({display_name:e,external_display:n,id:r},a)=>React.createElement(o.Fragment,{key:r},React.createElement("span",{className:m.A["broken-connection"]},e||n),aconnections management section.",'"them" refers to the broken connections.',"jetpack"),{fixLink:h}))}},64636:(e,t,n)=>{"use strict";n.d(t,{D:()=>l});var r=n(56427),a=n(27723),s=n(77627),o=n(50001),i=n(25349),c=n(71016);const __=a.__,l=()=>{const{hasConnections:e}=(0,o.A)(),{needsUserConnection:t,userConnectionUrl:n}=(0,s.A)();return t?React.createElement(r.PanelRow,null,React.createElement("p",null,__("You must connect your WordPress.com account to be able to add social media connections.","jetpack")," ",React.createElement("a",{href:n},__("Connect now","jetpack")))):e?null:React.createElement(r.PanelRow,null,React.createElement("p",null,React.createElement("span",{className:c.A["no-connections-text"]},__("Sharing is disabled because there are no social media accounts connected.","jetpack")),React.createElement(i.C,{label:__("Connect an account","jetpack")})))}},14993:(e,t,n)=>{"use strict";n.d(t,{E:()=>A});var r=n(85985),a=n(51609),s=n(77627),o=n(50001),i=n(10267),c=n(77125),l=n(57193),u=n(75013),d=n(25349),p=n(71016),m=n(50923),g=n(39329);const A=()=>{const{recordEvent:e}=(0,r.st)(),{connections:t,toggleById:n}=(0,o.A)(),{canBeTurnedOn:A,shouldBeDisabled:h}=(0,g.j)(),{needsUserConnection:E,isPublicizeEnabled:f}=(0,s.A)(),b=(0,a.useCallback)(((t,r)=>()=>{n(t),e("jetpack_social_connection_toggled",{location:"editor",enabled:!r.enabled,service_name:r.service_name})}),[e,n]);return React.createElement("div",null,React.createElement("ul",{className:p.A["connections-list"]},t.map((e=>{const{display_name:t,id:n,service_name:r,profile_picture:a,connection_id:s}=e,o=s||n;return React.createElement(i.A,{disabled:h(e),enabled:A(e)&&e.enabled,key:o,id:o,label:t,name:r,toggleConnection:b(o,e),profilePicture:a})}))),f?React.createElement(React.Fragment,null,React.createElement(u.L,null),React.createElement(c.l,null),React.createElement(m.Z,null),React.createElement(l.H,null)):null,E?null:React.createElement(d.C,{variant:"secondary"}))}},57193:(e,t,n)=>{"use strict";n.d(t,{H:()=>l});var r=n(56427),a=n(27723),s=n(77627),o=n(50001),i=n(71016),c=n(39329);const _n=a._n;function l(){const{enabledConnections:e}=(0,o.A)(),{isPublicizeEnabled:t}=(0,s.A)(),{canBeTurnedOn:n,shouldBeDisabled:l}=(0,c.j)(),u=e.filter((e=>n(e)&&!l(e)));return u.length&&t?React.createElement(r.PanelRow,null,React.createElement("p",{className:i.A["enabled-connections-notice"]},(0,a.sprintf)(/* translators: %d: number of connections */ @@ -128,7 +128,7 @@ __("Delete %s","jetpack"),o.label),disabled:a===c},a===c?__("Deleting","jetpack" (0,u.sprintf)(__("Allowed formats: %s","jetpack"),m))),(0,r.createElement)("div",{className:"videopress-block-tracks-editor__single-track-editor-label-language"},(0,r.createElement)(i.TextControl,{onChange:t=>n({...e,label:t}),label:__("Label","jetpack"),value:v,help:__("Title of track","jetpack"),disabled:f}),(0,r.createElement)(i.TextControl,{onChange:t=>n({...e,srcLang:t}),label:__("Source language","jetpack"),value:C,help:__("Language tag (en, fr, etc.)","jetpack"),disabled:f})),(0,r.createElement)(i.SelectControl,{className:"videopress-block-tracks-editor__single-track-editor-kind-select",options:g,value:k,label:/* translators: %s: The kind of video text track e.g: "Subtitles, Captions" */ __("Kind","jetpack"),onChange:t=>{n({...e,kind:t})},disabled:f}),(0,r.createElement)("div",{className:"videopress-block-tracks-editor__single-track-editor-buttons-container"},f?(0,r.createElement)(i.Spinner,null):(0,r.createElement)(i.Button,{variant:"secondary",disabled:!e.tmpFile,onClick:()=>{h(null),""===v&&(e.label=__("English","jetpack")),""===C&&(e.srcLang="en"),void 0===e.kind&&(e.kind=p),d(e)?h(__("A track already exists for that language and kind.","jetpack")):(b(!0),E(e,t).then((()=>{n(e),h(null),a()})).catch((e=>{e.message&&h(e.message)})).finally((()=>{b(!1)})))}},__("Save","jetpack")),(0,r.createElement)(i.Button,{variant:"link",onClick:s},__("Close","jetpack"))),A&&(0,r.createElement)("div",{className:"videopress-block-tracks-editor__single-track-editor-error"},/* translators: %s: An error message returned after a failed video track file upload." */ /* translators: %s: An error message returned after a failed video track file upload." */ (0,u.sprintf)(__("Error: %s","jetpack"),A))))}function C({tracks:e=[],onChange:t,guid:n}){const[a,s]=(0,l.useState)(null);return(0,r.createElement)(i.Dropdown,{contentClassName:"videopress-block-tracks-editor",renderToggle:({isOpen:e,onToggle:t})=>(0,r.createElement)(i.ToolbarButton,{label:__("Text tracks","jetpack"),showTooltip:!0,"aria-expanded":e,"aria-haspopup":"true",onClick:t,icon:A}),renderContent:()=>null!==a?(0,r.createElement)(v,{track:e[a],guid:n,onChange:n=>{const r=[...e];r[a]=n,t(r)},onClose:()=>s(null),onCancel:()=>{t(e.filter(((e,t)=>t!==a))),s(null)},trackExists:t=>-1!==e.filter(((e,t)=>t!==a)).findIndex((e=>e.kind===t.kind&&e.srcLang===t.srcLang))}):(0,r.createElement)(r.Fragment,null,(0,r.createElement)(i.NavigableMenu,null,(0,r.createElement)(b,{tracks:e,onChange:t,guid:n}),(0,r.createElement)(i.MenuGroup,{className:"videopress-block-tracks-editor__add-tracks-container",label:__("Add tracks","jetpack")},(0,r.createElement)(i.MenuItem,{icon:d.A,onClick:()=>{(()=>{const n=e.length,r=[...e];r[n]||(r[n]={}),r[n]={...e[n]},t(r),s(n)})()}},__("Upload track","jetpack")))))})}},22857:(e,t,n)=>{"use strict";n.d(t,{d:()=>g});var r=n(82170),a=n(94715),s=n(56427),o=n(86087),i=n(27723),c=n(51113),l=n(13022),u=n(12199);const __=i.__,d=["image"],p=e=>{const{videoPosterImageUrl:t}=e;return(0,r.createElement)("div",{className:"resumable-upload__editor-thumb-placeholder"},t?(0,r.createElement)(r.Fragment,null,(0,r.createElement)("img",{src:t,alt:"Poster"}),(0,r.createElement)(c.A,{className:"uploading-editor__play-icon",icon:u.ud})):(0,r.createElement)("span",null,"No Poster Selected"))},m=e=>{const{onSelectPoster:t,onRemovePoster:n}=e;return(0,r.createElement)(s.BaseControl,{className:(0,l.A)(e.className,"editor-video-poster-control")},(0,r.createElement)(p,e),(0,r.createElement)(a.MediaUpload,{title:__("Select Poster Image","jetpack"),onSelect:t,allowedTypes:d,render:({open:e})=>(0,r.createElement)("div",{className:"poster-selector__buttons"},(0,r.createElement)(s.Button,{onClick:n,variant:"link",isDestructive:!0},__("Remove Poster Image","jetpack")),(0,r.createElement)(s.Button,{variant:"secondary",onClick:e},__("Select Poster Image","jetpack")))}))},g=e=>{const{file:t,onSelectPoster:n,onRemovePoster:i,videoPosterImageData:l,title:p,onChangeTitle:g,onVideoFrameSelected:A}=e,[h,E]=(0,o.useState)(0),[f,b]=(0,o.useState)(!0),v=(0,o.useRef)(null),C=(0,o.useRef)(null),k=()=>{b(!1)};(0,o.useEffect)((()=>{null!==t&&v&&(v.current.src=URL.createObjectURL(t))}),[t,v]);const y={};return l&&(y.display="none"),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"uploading-editor"},(0,r.createElement)("div",{className:"uploading-editor__summary"}),(0,r.createElement)("div",{className:"uploading-editor__fields"},(0,r.createElement)(s.TextControl,{label:__("Video title","jetpack"),className:"uploading-editor__title",onChange:g,value:p}),(0,r.createElement)("div",{className:"uploading-editor__content"},(0,r.createElement)(s.BaseControl,{label:__("Video poster (optional)","jetpack")},f?(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"uploading-editor__video-container"},(0,r.createElement)("div",{className:"uploading-editor__video-poster-wrapper"},l&&(0,r.createElement)(m,{onSelectPoster:n,onRemovePoster:i,videoPosterImageUrl:l.url}),(0,r.createElement)("video",{ref:v,muted:!0,className:"uploading-editor__video",onDurationChange:e=>{const t=e.target.duration;E(t),v.current&&(v.current.currentTime=t/2)},onError:k,onLoadedMetadata:e=>{e.target.videoHeight||k()},style:y})),!l&&(0,r.createElement)(c.A,{className:"uploading-editor__play-icon",icon:u.ud})),(0,r.createElement)("span",{style:y},(0,r.createElement)(s.RangeControl,{className:"uploading-editor__range",min:"0",step:"0.1",max:h,showTooltip:!1,withInputField:!1,onChange:e=>{A(1e3*e),v.current&&(v.current.currentTime=e)}})),(0,r.createElement)("span",{className:"uploading-editor__scrubber-help",style:y},(0,o.createInterpolateElement)(__("This is how the video will look. Use the slider to choose a poster or select a custom one.","jetpack"),{a:(0,r.createElement)(a.MediaUpload,{title:__("Select Poster Image","jetpack"),onSelect:n,allowedTypes:d,render:({open:e})=>(0,r.createElement)("a",{className:"uploading-editor__upload-link",onClick:e,onKeyDown:e,ref:C,role:"button",tabIndex:0},__("select a custom one","jetpack"))})}))):(0,r.createElement)(m,{onSelectPoster:n,videoPosterImageUrl:l?l.url:null}))))))}},17900:(e,t,n)=>{"use strict";n.d(t,{e:()=>a});var r=n(93832);const a=(e,{autoplay:t,controls:n,loop:a,muted:s,playsinline:o,poster:i,preload:c,seekbarColor:l,seekbarPlayedColor:u,seekbarLoadingColor:d,useAverageColor:p})=>{if(!e)return null;const m={resizeToParent:!0,cover:!0,...t&&{autoPlay:!0},...!n&&{controls:!1},...a&&{loop:!0},...s&&{muted:!0,persistVolume:!1},...o&&{playsinline:!0},...i&&{posterUrl:i},...""!==c&&{preloadContent:c},...""!==l&&{sbc:l},...""!==u&&{sbpc:u},...""!==d&&{sblc:d},...p&&{useAverageColor:!0}};return(0,r.addQueryArgs)(`https://videopress.com/v/${e}`,m)}},47960:(e,t,n)=>{"use strict";n.d(t,{QW:()=>c,T3:()=>i,Zz:()=>o,x1:()=>l});n(74997);var r=n(13022),a=n(74628);const s=e=>{const t=a.C1.reduce(((e,{className:t})=>(e[t]=!1,e)),{"wp-has-aspect-ratio":!1});return(0,r.A)(e,t)};function o(e,t="",n=!0){if(!n)return s(t);const o=document.implementation.createHTMLDocument("");o.body.innerHTML=e;const i=o.body.querySelector("iframe");if(i&&i.height&&i.width){const e=(i.width/i.height).toFixed(2);for(let n=0;n=o.ratio)return(0,r.A)(s(t),o.className,"wp-has-aspect-ratio")}}return t}const i=e=>e.replace(/\.[^/.]+$/,""),c=e=>{if(!e||"string"!=typeof e)return null;const t=e.match(/^https?:\/\/(?video(?:\.word|s\.files\.word)?press\.com)(?:\/v|\/embed)?\/(?[a-zA-Z\d]{8})/);return t?.groups?.guid?t.groups.guid:null},l=e=>{const{guid:t,videoPressTracks:n,isVideoPressExample:r}=e;if(!t?.length)return!1;if(!Array.isArray(n))return!1;return!(!Object.keys(e).includes("isVideoPressExample")||"boolean"!=typeof r)}},58731:(e,t,n)=>{"use strict";n.d(t,{A:()=>A});var r=n(82170),a=n(85985),s=n(94715),o=n(74997),i=n(56427),c=n(47143),l=n(43656),u=(n(86087),n(27723)),d=n(47960),p=n(54746);const __=u.__,m={instances:[]},g=(e=[],t=!1,n=0)=>{if(t&&(m.instances=[]),e.forEach((e=>{if(e.innerBlocks.length)return void g(e.innerBlocks,!1,n+1);const{clientId:t,name:r,attributes:a}=e;"core/video"===r&&(0,d.x1)(a)&&m.instances.push({clientId:t,name:r,attributes:a})})),0===n)return m.instances};function A({clientId:e,attributes:t}){const n=(0,c.useSelect)((e=>e(l.store).getCurrentPostId())),{getBlocks:u}=(0,c.useSelect)(s.store),{replaceBlock:m}=(0,c.useDispatch)(s.store),{tracks:A}=(0,a.st)();return(0,r.createElement)("div",{className:p.A.wrapper},(0,r.createElement)(i.Notice,{status:"info",isDismissible:!1,className:p.A["conversion-notice"]},__("You can transform this post's video blocks to the new VideoPress block to take advantage of new features, such as adding chapters directly in the description or hiding the video's share menu.","jetpack")),(0,r.createElement)(i.Button,{variant:"primary",onClick:()=>{const r=g(u(),!0);r?.length&&(r.find((t=>t.clientId===e))||r.push({clientId:e,name:"core/video",currentBlockAttributes:t}),r.forEach((e=>{const{clientId:t,name:r,attributes:a}=e;"core/video"===r&&(0,d.x1)(a)&&(m(t,(0,o.createBlock)("videopress/video",a)),A.recordEvent("jetpack_editor_videopress_block_manual_conversion_click",{post_id:n}))})))}},__("Transform blocks to VideoPress","jetpack")))}},55159:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(82170),a=n(94715),s=n(29491),o=n(47960),i=n(58731);const c=(0,s.createHigherOrderComponent)((e=>t=>(0,o.x1)(t.attributes)?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(a.InspectorControls,null,(0,r.createElement)(i.A,{clientId:t.clientId,attributes:t.attributes})),(0,r.createElement)(e,t)):(0,r.createElement)(e,t)))},51983:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(85985),a=n(55159);const s="videopress/video";function o(e,t){if("core/video"!==t)return e;const{available:n}=(0,r.FB)(s);return n?{...e,edit:(0,a.A)(e.edit)}:e}},5146:(e,t,n)=>{"use strict";n.d(t,{A:()=>d});var r=n(82170),a=n(56427),s=n(27723),o=n(67858),i=n(84605);const __=s.__,c="videopress/video-chapters",l=!!window?.Jetpack_Editor_Initial_State?.available_blocks[c],u=31;function d({isRequestingVideoItem:e}){const{attributes:t,setAttributes:n}=(0,i.A)(),{title:s,description:d}=t,p=(0,o.m)(c),m=d?.length?d.split("\n").map((e=>Math.ceil(e.length/u)||1)).reduce(((e,t)=>e+t),0):4,g=Math.min(12,Math.max(m,4));if(!l)return null;return(0,r.createElement)(a.PanelBody,{title:__("Details","jetpack"),className:p?"is-beta":""},(0,r.createElement)(a.TextControl,{label:__("Title","jetpack"),value:s,placeholder:__("Video title","jetpack"),onChange:e=>{n({title:e})},disabled:e}),(0,r.createElement)(a.TextareaControl,{label:__("Description","jetpack"),value:d,placeholder:__("Video description","jetpack"),onChange:e=>{n({description:e})},disabled:e,rows:g}))}},83112:(e,t,n)=>{"use strict";n.d(t,{A:()=>d});var r=n(82170),a=n(94715),s=n(29491),o=n(86087),i=n(5146),c=n(52753),l=n(95501),u=n(7345);const d=(0,s.createHigherOrderComponent)((e=>t=>{const{attributes:n,setAttributes:s}=t,[d,p]=(0,c.A)(n?.id),[m]=(0,l.n)(n);return(0,o.useEffect)((()=>{if(!d)return;const e={};d?.title&&(e.title=d.title),d?.description&&(e.description=d.description),Object.keys(e).length&&(s(e),m(e))}),[d,s,m]),u.j&&"core/video"!==!t.name&&t.attributes?.guid?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(a.InspectorControls,null,(0,r.createElement)(i.A,{isRequestingVideoItem:p})),(0,r.createElement)(e,t)):(0,r.createElement)(e,t)}))},84605:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(94715),a=n(47143);function s(){const{clientId:e,attributes:t}=(0,a.useSelect)((e=>{const t=e(r.store).getSelectedBlockClientId();return{clientId:t,attributes:t?e("core/block-editor").getBlockAttributes(t):void 0}})),{updateBlockAttributes:n}=(0,a.useDispatch)(r.store);return{clientId:e,attributes:t,setAttributes:t=>n(e,t)}}},95501:(e,t,n)=>{"use strict";n.d(t,{n:()=>A});var r=n(1455),a=n.n(r),s=n(29491),o=n(3582),i=n(47143),c=n(43656),l=n(86087),u=n(27723),d=n(96247),p=n(17900),m=n(17204),g=n(97393);const __=u.__;function A(e){const{id:t,title:n,description:r,guid:u}=e,A=(0,i.useSelect)((e=>e(c.store).isSavingPost()),[]),h=(0,s.usePrevious)(A),E=(0,i.useDispatch)(o.store).invalidateResolution,[f,b]=(0,l.useState)(),v=(0,l.useCallback)((e=>{b((t=>({...t,...e})))}),[]);(0,l.useEffect)((()=>{b({title:n,description:r})}),[]);const C=function(e){return t=>new Promise(((n,r)=>{a()({path:"/wpcom/v2/videopress/meta",method:"POST",data:{id:e,...t}}).then((e=>{if(200!==e?.data)return r(e);n(e)})).catch(r)}))}(t);return(0,l.useEffect)((()=>{if(!A||h)return;if(!t)return;const a={};if(f?.title!==n&&(a.title=n),f?.description!==r&&(a.description=r),!Object.keys(a).length)return;if(C(a).then((()=>v({title:n,description:r}))),!a?.description?.length)return;const s=(0,m.Ay)(a.description);if(!s?.length)return;const o={label:__("English","jetpack"),srcLang:"en",kind:"chapters",tmpFile:(0,g.Ay)(a.description)};(0,d.n)(o,u).then((()=>{const t=(0,p.e)(u,e);E("getEmbedPreview",[t])}))}),[A,h,n,f?.title,f?.description,r,C,v,e,E,t,u]),[v]}},52753:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(1455),a=n.n(r),s=n(86087);function o(e){const[t,n]=(0,s.useState)({}),[r,o]=(0,s.useState)(!1);return(0,s.useEffect)((()=>{e&&(o(!0),async function(){try{const t=await a()({path:`/wp/v2/media/${e}`});n(t?.jetpack_videopress||{}),o(!1)}catch(e){throw o(!1),new Error(e)}}())}),[e]),[t,r]}},7345:(e,t,n)=>{"use strict";n.d(t,{A:()=>s,j:()=>a});var r=n(83112);const a=!!window?.Jetpack_Editor_Initial_State?.available_blocks["videopress/video-chapters"];function s(e,t){if(!a)return e;if("core/video"!==t)return e;const n={...e.attributes,title:{type:"string"},description:{type:"string"}};return{...e,attributes:n,edit:(0,r.A)(e.edit)}}},17204:(e,t,n)=>{"use strict";function r(e){return e.split("\n").map((e=>function(e){const t=/(?\(?(?