/*! For license information please see editor-no-post-editor.js.LICENSE.txt */ (()=>{var e={7675(e,t,n){"use strict";n.d(t,{y:()=>a});var r=n(76416),s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(e);s{const f=Object.assign({},a);let b;function v(){b.abort(),document.hidden||j()}f.accept||(f.accept=o),h||document.addEventListener("visibilitychange",v);let y=1e3,k=0;function x(){document.removeEventListener("visibilitychange",v),window.clearTimeout(k),b.abort()}null==n||n.addEventListener("abort",()=>{x(),t()});const _=null!=m?m:window.fetch,w=null!=c?c:l;async function j(){var n;b=new AbortController;try{const n=await _(e,Object.assign(Object.assign({},g),{headers:f,signal:b.signal}));await w(n),await(0,r.q5)(n.body,(0,r.iv)((0,r.VL)(e=>{e?f[i]=e:delete f[i]},e=>{y=e},u))),null==d||d(),x(),t()}catch(e){if(!b.signal.aborted)try{const t=null!==(n=null==p?void 0:p(e))&&void 0!==n?n:y;window.clearTimeout(k),k=window.setTimeout(j,t)}catch(e){x(),s(e)}}}j()})}function l(e){const t=e.headers.get("content-type");if(!(null==t?void 0:t.startsWith(o)))throw new Error(`Expected content-type to be ${o}, Actual: ${t}`)}},76416(e,t,n){"use strict";async function r(e,t){const n=e.getReader();let r;for(;!(r=await n.read()).done;)t(r.value)}function s(e){let t,n,r,s=!1;return function(o){void 0===t?(t=o,n=0,r=-1):t=function(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}(t,o);const i=t.length;let a=0;for(;n0){const n=s.decode(o.subarray(0,a)),i=a+(32===o[a+1]?2:1),l=s.decode(o.subarray(i));switch(n){case"data":r.data=r.data?r.data+"\n"+l:l;break;case"event":r.event=l;break;case"id":e(r.id=l);break;case"retry":const n=parseInt(l,10);isNaN(n)||t(r.retry=n)}}}}function i(){return{data:"",event:"",id:"",retry:void 0}}n.d(t,{VL:()=>o,iv:()=>s,q5:()=>r})},87399(e){!function(){"use strict";var t=[],n=3988292384;function r(e){var t,r,s,o,i=-1;for(t=0,s=e.length;t>>=1:o=o>>>1^n;i=i>>>8^o}return-1^i}function s(e,n){var r,o,i;if(void 0!==s.crc&&n&&e||(s.crc=~0,e)){for(r=s.crc,o=0,i=e.length;o>>8^t[255&(r^e[o])];return s.crc=r,-1^r}}!function(){var e,r,s;for(r=0;r<256;r+=1){for(e=r,s=0;s<8;s+=1)1&e?e=n^e>>>1:e>>>=1;t[r]=e>>>0}}(),e.exports=function(e,t){var n;e="string"==typeof e?(n=e,Array.prototype.map.call(n,function(e){return e.charCodeAt(0)})):e;return((t?r(e):s(e))>>>0).toString(16)},e.exports.direct=r,e.exports.table=s}()},39904(e,t){"use strict";var n=/^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;t.t=function(e){if(!e)return!1;if(e.length>254)return!1;if(!n.test(e))return!1;var t=e.split("@");return!(t[0].length>64)&&!t[1].split(".").some(function(e){return e.length>63})}},2467(e){"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function s(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",s),n([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,s,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var i=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var s,o,i,c;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),i=o[t]),void 0===i)i=o[t]=n,++e._eventsCount;else if("function"==typeof i?i=o[t]=r?[n,i]:[i,n]:r?i.unshift(n):i.push(n),(s=l(e))>0&&i.length>s&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},s=u.bind(r);return s.listener=n,r.wrapFn=s,s}function p(e,t,n){var r=e._events;if(void 0===r)return[];var s=r[t];return void 0===s?[]:"function"==typeof s?n?[s.listener||s]:[s]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=o[e];if(void 0===l)return!1;if("function"==typeof l)r(l,this,t);else{var c=l.length,u=m(l,c);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){i=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},o.prototype.listenerCount=h,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},20305(e){"use strict";function t(e,t,n,r){var s=Number(e[t].meta.id+1).toString(),o="";return"string"==typeof r.docId&&(o="-"+r.docId+"-"),o+s}function n(e,t){var n=Number(e[t].meta.id+1).toString();return e[t].meta.subId>0&&(n+=":"+e[t].meta.subId),"["+n+"]"}function r(e,t,n,r,s){var o=s.rules.footnote_anchor_name(e,t,n,r,s),i=s.rules.footnote_caption(e,t,n,r,s),a=o;return e[t].meta.subId>0&&(a+=":"+e[t].meta.subId),''+i+""}function s(e,t,n){return(n.xhtmlOut?'
\n':'
\n')+'
\n
    \n'}function o(){return"
\n
\n"}function i(e,t,n,r,s){var o=s.rules.footnote_anchor_name(e,t,n,r,s);return e[t].meta.subId>0&&(o+=":"+e[t].meta.subId),'
  • '}function a(){return"
  • \n"}function l(e,t,n,r,s){var o=s.rules.footnote_anchor_name(e,t,n,r,s);return e[t].meta.subId>0&&(o+=":"+e[t].meta.subId),' ↩︎'}e.exports=function(e){var c=e.helpers.parseLinkLabel,u=e.utils.isSpace;e.renderer.rules.footnote_ref=r,e.renderer.rules.footnote_block_open=s,e.renderer.rules.footnote_block_close=o,e.renderer.rules.footnote_open=i,e.renderer.rules.footnote_close=a,e.renderer.rules.footnote_anchor=l,e.renderer.rules.footnote_caption=n,e.renderer.rules.footnote_anchor_name=t,e.block.ruler.before("reference","footnote_def",function(e,t,n,r){var s,o,i,a,l,c,d,p,h,m,g,f=e.bMarks[t]+e.tShift[t],b=e.eMarks[t];if(f+4>b)return!1;if(91!==e.src.charCodeAt(f))return!1;if(94!==e.src.charCodeAt(f+1))return!1;for(l=f+2;l=b||58!==e.src.charCodeAt(++l))return!1;if(r)return!0;for(l++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),c=e.src.slice(f+2,l-2),e.env.footnotes.refs[":"+c]=-1,(d=new e.Token("footnote_reference_open","",1)).meta={label:c},d.level=e.level++,e.tokens.push(d),s=e.bMarks[t],o=e.tShift[t],i=e.sCount[t],a=e.parentType,g=l,p=h=e.sCount[t]+l-(e.bMarks[t]+e.tShift[t]);l=i)&&(94===e.src.charCodeAt(a)&&(91===e.src.charCodeAt(a+1)&&(n=a+2,!((r=c(e,a+1))<0)&&(t||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),s=e.env.footnotes.list.length,e.md.inline.parse(e.src.slice(n,r),e.md,e.env,o=[]),e.push("footnote_ref","",0).meta={id:s},e.env.footnotes.list[s]={content:e.src.slice(n,r),tokens:o}),e.pos=r+1,e.posMax=i,!0))))}),e.inline.ruler.after("footnote_inline","footnote_ref",function(e,t){var n,r,s,o,i=e.posMax,a=e.pos;if(a+3>i)return!1;if(!e.env.footnotes||!e.env.footnotes.refs)return!1;if(91!==e.src.charCodeAt(a))return!1;if(94!==e.src.charCodeAt(a+1))return!1;for(r=a+2;r=i)&&(r++,n=e.src.slice(a+2,r-1),void 0!==e.env.footnotes.refs[":"+n]&&(t||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+n]<0?(s=e.env.footnotes.list.length,e.env.footnotes.list[s]={label:n,count:0},e.env.footnotes.refs[":"+n]=s):s=e.env.footnotes.refs[":"+n],o=e.env.footnotes.list[s].count,e.env.footnotes.list[s].count++,e.push("footnote_ref","",0).meta={id:s,subId:o,label:n}),e.pos=r,e.posMax=i,!0)))}),e.core.ruler.after("inline","footnote_tail",function(e){var t,n,r,s,o,i,a,l,c,u,d=!1,p={};if(e.env.footnotes&&(e.tokens=e.tokens.filter(function(e){return"footnote_reference_open"===e.type?(d=!0,c=[],u=e.meta.label,!1):"footnote_reference_close"===e.type?(d=!1,p[":"+u]=c,!1):(d&&c.push(e),!d)}),e.env.footnotes.list)){for(i=e.env.footnotes.list,a=new e.Token("footnote_block_open","",1),e.tokens.push(a),t=0,n=i.length;t0?i[t].count:1,r=0;rr});const r={placeholder:"NisihrgiIKl_knpYJtfg",pulse:"R2i0K45dEF157drbVRPI"}},8706(e,t,n){"use strict";n.d(t,{A:()=>r});const r={global:"_fUXxnSp5pagKBp9gSN7"}},48297(){},75070(){},47621(){},13371(){},37209(){},49663(){},97850(){},78518(){},84368(){},85808(){},49882(){},18681(){},82805(){},28769(){},78215(){},61095(){},75360(){},25378(){},45318(){},16279(){},59357(){},88561(){},27453(){},14647(){},93726(){},31369(){},30938(){},50221(){},2753(){},52918(){},64525(){},1982(){},79935(){},45199(){},89399(){},73163(){},63036(){},88894(){},75646(){},89275(){},17309(){},17319(){},58203(){},80490(){},20744(){},591(){},86154(){},58227(){},89732(e,t,n){"use strict";n.d(t,{A:()=>r});const r={wrapper:"h2NGkiVs1r1nf85LtJpF","conversion-notice":"k3Apzwo3v9n0IaHbB8tf"}},60333(){},94533(){},42265(){},22734(){},24920(){},72613(){},90698(){},42036(){},93571(){},94378(){},51082(){},51521(){},62653(){},44997(e){var t=1e3,n=60*t,r=60*n,s=24*r,o=7*s,i=365.25*s;function a(e,t,n,r){var s=t>=1.5*n;return Math.round(e/n)+" "+r+(s?"s":"")}e.exports=function(e,l){l=l||{};var c=typeof e;if("string"===c&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*i;case"weeks":case"week":case"w":return l*o;case"days":case"day":case"d":return l*s;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*n;case"seconds":case"second":case"secs":case"sec":case"s":return l*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(e);if("number"===c&&isFinite(e))return l.long?function(e){var o=Math.abs(e);if(o>=s)return a(e,o,s,"day");if(o>=r)return a(e,o,r,"hour");if(o>=n)return a(e,o,n,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=s)return Math.round(e/s)+"d";if(o>=r)return Math.round(e/r)+"h";if(o>=n)return Math.round(e/n)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},14936(e,t,n){"use strict";n.d(t,{A:()=>h});var r=n(87399),s=n.n(r),o=n(10067),i=n.n(o),a=n(11264),l=n.n(a);const c=i()("photon"),u={width:"w",height:"h",letterboxing:"lb",removeLetterboxing:"ulb"},d="__domain__.invalid",p=`https://${d}`;function h(e,t){let n;try{n=new URL(e,p)}catch{return null}const r="https:"===n.protocol,o=new URL("https://i0.wp.com");if(i=n.host,/^i[0-2]\.wp\.com$/.test(i))o.pathname=n.pathname,o.hostname=r?"i0.wp.com":n.hostname;else{if(n.search)return null;let e=n.href.replace(`${n.protocol}/`,"");"blob:"===n.protocol&&(e=n.pathname.replace("://","//")),n.hostname===d&&(e=n.pathname),o.pathname=e,o.hostname=function(e,t){if(t)return"i0.wp.com";const n=s()(e),r=l()(n),o="i"+Math.floor(3*r());return c('determined server "%s" to use with "%s"',o,e),o+".wp.com"}(e,"https:"===o.protocol),r&&o.searchParams.set("ssl","1")}var i;if(t)for(const[e,n]of Object.entries(t))"host"!==e&&"hostname"!==e?"secure"!==e||n?o.searchParams.set(u[e]??e,n.toString()):o.protocol="http:":o.hostname=n;return c("generated Photon URL: %s",o.href),o.href}},87072(e,t,n){"use strict";n.d(t,{Ay:()=>y});const r=2147483647,s=36,o=/^xn--/,i=/[^\0-\x7F]/,a=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},c=Math.floor,u=String.fromCharCode;function d(e){throw new RangeError(l[e])}function p(e,t){const n=e.split("@");let r="";n.length>1&&(r=n[0]+"@",e=n[1]);const s=function(e,t){const n=[];let r=e.length;for(;r--;)n[r]=t(e[r]);return n}((e=e.replace(a,".")).split("."),t).join(".");return r+s}function h(e){const t=[];let n=0;const r=e.length;for(;n=55296&&s<=56319&&n=48&&e<58?e-48+26:e>=65&&e<91?e-65:e>=97&&e<123?e-97:s},g=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},f=function(e,t,n){let r=0;for(e=n?c(e/700):e>>1,e+=c(e/t);e>455;r+=s)e=c(e/35);return c(r+36*e/(e+38))},b=function(e){const t=[],n=e.length;let o=0,i=128,a=72,l=e.lastIndexOf("-");l<0&&(l=0);for(let n=0;n=128&&d("not-basic"),t.push(e.charCodeAt(n));for(let u=l>0?l+1:0;u=n&&d("invalid-input");const l=m(e.charCodeAt(u++));l>=s&&d("invalid-input"),l>c((r-o)/t)&&d("overflow"),o+=l*t;const p=i<=a?1:i>=a+26?26:i-a;if(lc(r/h)&&d("overflow"),t*=h}const p=t.length+1;a=f(o-l,p,0==l),c(o/p)>r-i&&d("overflow"),i+=c(o/p),o%=p,t.splice(o++,0,i)}return String.fromCodePoint(...t)},v=function(e){const t=[],n=(e=h(e)).length;let o=128,i=0,a=72;for(const n of e)n<128&&t.push(u(n));const l=t.length;let p=l;for(l&&t.push("-");p=o&&tc((r-i)/h)&&d("overflow"),i+=(n-o)*h,o=n;for(const n of e)if(nr&&d("overflow"),n===o){let e=i;for(let n=s;;n+=s){const r=n<=a?1:n>=a+26?26:n-a;if(eString.fromCodePoint(...e)},decode:b,encode:v,toASCII:function(e){return p(e,function(e){return i.test(e)?"xn--"+v(e):e})},toUnicode:function(e){return p(e,function(e){return o.test(e)?b(e.slice(4).toLowerCase()):e})}}},24588(e,t){"use strict";var n=Object.prototype.hasOwnProperty;function r(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function s(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,o,i=[];for(o in"string"!=typeof t&&(t="?"),e)if(n.call(e,o)){if((r=e[o])||null!=r&&!isNaN(r)||(r=""),o=s(o),r=s(r),null===o||null===r)continue;i.push(o+"="+r)}return i.length?t+i.join("&"):""},t.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,s={};t=n.exec(e);){var o=r(t[1]),i=r(t[2]);null===o||null===i||o in s||(s[o]=i)}return s}},96811(e){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},94107(e,t,n){"use strict";n.d(t,{A:()=>j});var r=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some(function(e,r){return e[0]===t&&(n=r,!0)}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n0},e.prototype.connect_=function(){s&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),l?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){s&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;a.some(function(e){return!!~n.indexOf(e)})&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),u=function(e,t){for(var n=0,r=Object.keys(t);n0},e}(),_="undefined"!=typeof WeakMap?new WeakMap:new r,w=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=c.getInstance(),r=new x(t,n,this);_.set(this,r)};["observe","unobserve","disconnect"].forEach(function(e){w.prototype[e]=function(){var t;return(t=_.get(this))[e].apply(t,arguments)}});const j=void 0!==o.ResizeObserver?o.ResizeObserver:w},11264(e){"use strict";var t=256,n=[],r=window,s=Math.pow(t,6),o=Math.pow(2,52),i=2*o,a=255,l=Math.random;function c(e){var n,r=e.length,s=this,o=0,i=s.i=s.j=0,l=s.S=[];for(r||(e=[r++]);o=i;)e/=2,n/=2,r>>>=1;return(e+r)/n}},e.exports.resetGlobal=function(){Math.random=l},d(Math.random(),n)},48931(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(1455),s=n.n(r);const o="default"in s()?s().default:s()},87286(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(47143),s=n(10067),o=n.n(s),i=n(53664);const a=o()("jetpack-ai-client:ask-question");async function l(e,{postId:t=null,fromCache:n=!1,feature:s,functions:o,model:l,languageCode:c}={}){const u=c||(0,r.select)("core").getEntityRecord("root","site")?.language||"en_US";return a("Asking question: %o. options: %o",e,{postId:t,fromCache:n,feature:s,functions:o,model:l,languageCode:u}),new i.A({question:e,options:{postId:t,feature:s,fromCache:n,functions:o,model:l,languageCode:u}})}},31439(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(47143),s=n(10067),o=n.n(s),i=n(51391);const a=o()("jetpack-ai-client:ask-question-sync");async function l(e,t={}){t.languageCode=t.languageCode||(0,r.select)("core").getEntityRecord("root","site")?.language||"en_US",a("Asking question with no streaming: %o. options: %o",e,t);let n;try{n=(await(0,i.A)()).token}catch(e){return a("Error getting token: %o",e),Promise.reject(e)}const s=Array.isArray(e)?{messages:e}:{question:e},{languageCode:o,...l}=t,c={...s,...l,language_code:o,stream:!1},u={Authorization:`Bearer ${n}`,"Content-Type":"application/json"};try{const e=await fetch("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query",{method:"POST",headers:u,body:JSON.stringify(c)}).then(e=>e.json());return e?.data?.status&&e?.data?.status>200?(a("Error generating prompt: %o",e),Promise.reject(e)):e.choices?.[0]?.message?.content}catch(e){return a("Error asking question: %o",e),Promise.reject(e)}}},57745(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(10067),s=n.n(r),o=n(51391);const i=s()("jetpack-ai-client:audio-transcription");async function a(e,t,n){let r;i("Transcribing audio: %o. Feature: %o",e,t);try{r=(await(0,o.A)()).token}catch(e){return i("Error getting token: %o",e),Promise.reject(e)}const s=new FormData;s.append("audio_file",e);try{const e={Authorization:`Bearer ${r}`},o="https://public-api.wordpress.com/wpcom/v2/jetpack-ai-transcription"+(t?`?feature=${t}`:"");return fetch(o,{method:"POST",body:s,headers:e,signal:n??void 0}).then(e=>(i("Transcription response: %o",e),e.ok?e.json().then(e=>e?.text):e.json().then(e=>Promise.reject(e))))}catch(e){return i("Transcription error response: %o",e),Promise.reject(e)}}},70629(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(13022),o=n(6754),i=(n(34657),n(10790));function a({className:e,disabled:t=!1,value:n="",placeholder:a="",isTransparent:l=!1,state:c="init",onChange:u,banner:d=null,error:p=null,actions:h=null,message:m=null,promptUserInputRef:g=null,wrapperRef:f=null}){return(0,i.jsxs)("div",{className:(0,s.A)("jetpack-components-ai-control__container-wrapper",e),ref:f,children:[p,(0,i.jsxs)("div",{className:"jetpack-components-ai-control__container",children:[d,(0,i.jsxs)("div",{className:(0,s.A)("jetpack-components-ai-control__wrapper",{"is-transparent":l}),children:[(0,i.jsx)(o.A,{state:c}),(0,i.jsx)("div",{className:"jetpack-components-ai-control__input-wrapper",children:(0,i.jsx)(r.PlainText,{value:n,onChange:u,placeholder:a,className:"jetpack-components-ai-control__input",disabled:t,ref:g})}),h]}),m]})]})}},71417(e,t,n){"use strict";n.d(t,{A:()=>x});var r=n(56427),s=n(29491),o=n(86087),i=n(27723),a=n(13109),l=n(87756),c=n(88901),u=n(65995),d=n(48568),p=n(57839),h=n(10067),m=n.n(h),g=n(51609),f=n(63098),b=n(70629),v=(n(34657),n(10790));const __=i.__,y=m()("jetpack-ai-client:block-ai-control");function k({disabled:e=!1,value:t="",placeholder:n="",showAccept:i=!1,acceptLabel:h=__("Accept","jetpack"),showButtonLabels:m=!0,isTransparent:g=!1,state:k="init",showGuideLine:x=!1,customFooter:_=null,onChange:w,onSend:j,onStop:C,onAccept:A,onDiscard:S,showRemove:E=!1,banner:T=null,error:N=null,lastAction:P},B){const R="requesting"===k||"suggesting"===k,[I,D]=(0,o.useState)(!1),[L,F]=(0,o.useState)(t||null),M=(0,o.useRef)(null);(0,o.useImperativeHandle)(B,()=>M.current),(0,o.useEffect)(()=>{I&&M?.current?.focus()},[I]);const O=(0,o.useCallback)(()=>{F(t),D(!1),j?.(t)},[t]),U=(0,o.useCallback)(e=>{w?.(e),"init"!==k&&D(L?e!==L:e.length>0)},[L,k]),z=(0,o.useCallback)(()=>{S?.()},[]),$=(0,o.useCallback)(()=>{y("cancelEdit, revert to last value",L),w?.(L||""),D(!1)},[L]);(0,s.useKeyboardShortcut)("mod+enter",()=>{i&&A?.()},{target:M}),(0,s.useKeyboardShortcut)("enter",e=>{e.preventDefault(),O()},{target:M});const q=(0,v.jsxs)(v.Fragment,{children:[(!i||I)&&(0,v.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:R?(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:C,variant:"secondary",label:__("Stop request","jetpack"),children:m?__("Stop","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}):(0,v.jsxs)(v.Fragment,{children:[I&&(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:$,variant:"secondary",label:__("Cancel","jetpack"),children:m?__("Cancel","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}),E&&!I&&!t?.length&&S&&(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:z,variant:"secondary",label:__("Cancel","jetpack"),children:m?__("Cancel","jetpack"):(0,v.jsx)(a.A,{icon:u.A})}),t?.length>0&&(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:O,variant:"primary",disabled:!t?.length||e,label:__("Send request","jetpack"),children:m?__("Generate","jetpack"):(0,v.jsx)(a.A,{icon:l.A})})]})}),i&&!I&&(0,v.jsxs)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:[(t?.length>0||null===L)&&(0,v.jsxs)(r.Flex,{gap:1,role:"group",className:"jetpack-components-ai-control__button-group",children:[(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Discard","jetpack"),onClick:z,tooltipPosition:"top",children:(0,v.jsx)(a.A,{icon:p.A})}),(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Regenerate","jetpack"),onClick:()=>j?.(t),tooltipPosition:"top",disabled:!t?.length||null===t||e,children:(0,v.jsx)(a.A,{icon:d.A})})]}),(0,v.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:A,variant:"primary",label:h,children:m?h:(0,v.jsx)(a.A,{icon:c.A})})]})]}),H=x&&!R&&!I&&(_||(0,v.jsx)(f.Yj,{aiFeedbackThumbsOptions:{showAIFeedbackThumbs:!0,ratedItem:"ai-assistant",prompt:P,block:"ai-assistant"}}));return(0,v.jsx)(b.A,{disabled:e||R,value:t,placeholder:n,isTransparent:g,state:k,onChange:U,banner:T,error:N,actions:q,message:H,promptUserInputRef:M})}const x=(0,g.forwardRef)(k)},61(e,t,n){"use strict";n.d(t,{A:()=>f});var r=n(56427),s=n(29491),o=n(86087),i=n(27723),a=n(13109),l=n(87756),c=n(65995),u=n(84701),d=n(51609),p=n(63098),h=n(70629),m=(n(34657),n(10790));const __=i.__;function g({className:e,disabled:t=!1,value:n="",placeholder:i="",showButtonLabels:d=!0,isTransparent:g=!1,state:f="init",showGuideLine:b=!1,error:v,requestsRemaining:y,showUpgradeMessage:k=!1,showFairUsageMessage:x=!1,upgradeUrl:_,wrapperRef:w,onChange:j,onSend:C,onStop:A,onClose:S,onUndo:E,onUpgrade:T,onTryAgain:N,lastAction:P,blockType:B},R){const I="requesting"===f||"suggesting"===f,[D,L]=(0,o.useState)(!1),[F,M]=(0,o.useState)(n||null),O=(0,o.useRef)(null),U=n?.length<=0&&"done"===f;(0,o.useImperativeHandle)(R,()=>O.current),(0,o.useEffect)(()=>{D&&O?.current?.focus()},[D]);const z=(0,o.useCallback)(()=>{M(n),L(!1),C?.(n)},[C,n]),$=(0,o.useCallback)(e=>{j?.(e),"init"!==f&&L(F?e!==F:e.length>0)},[j,F,f]),q=(0,o.useCallback)(()=>{A?.()},[A]),H=(0,o.useCallback)(()=>{S?.()},[S]),V=(0,o.useCallback)(()=>{E?.()},[E]),G=(0,o.useCallback)(e=>{T?.(e)},[T]),W=(0,o.useCallback)(()=>{N?.()},[N]);(0,s.useKeyboardShortcut)("enter",e=>{e.preventDefault(),z()},{target:O});const Z=(0,m.jsx)(m.Fragment,{children:I?(0,m.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:q,variant:"secondary",label:__("Stop request","jetpack"),children:d?__("Stop","jetpack"):(0,m.jsx)(a.A,{icon:c.A})}):(0,m.jsxs)(m.Fragment,{children:[n?.length>0&&(0,m.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:(0,m.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",onClick:z,variant:"primary",disabled:!n?.length||t,label:__("Send request","jetpack"),children:d?__("Generate","jetpack"):(0,m.jsx)(a.A,{icon:l.A})})}),U&&(0,m.jsx)("div",{className:"jetpack-components-ai-control__controls-prompt_button_wrapper",children:(0,m.jsxs)(r.Flex,{gap:1,role:"group",className:"jetpack-components-ai-control__button-group",children:[(0,m.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Undo","jetpack"),onClick:V,tooltipPosition:"top",children:(0,m.jsx)(a.A,{icon:u.A})}),(0,m.jsx)(r.Button,{className:"jetpack-components-ai-control__controls-prompt_button",label:__("Close","jetpack"),onClick:H,variant:"tertiary",children:__("Close","jetpack")})]})})]})});let J=null;return v?.message?J=(0,m.jsx)(p.Kw,{error:v.message,code:v.code,onTryAgainClick:W,onUpgradeClick:G,upgradeUrl:_}):x?J=(0,m.jsx)(p.k9,{}):k?J=(0,m.jsx)(p.AK,{requestsRemaining:y,onUpgradeClick:G,upgradeUrl:_}):b&&(J=U?(0,m.jsx)(p.Yj,{aiFeedbackThumbsOptions:{showAIFeedbackThumbs:!0,ratedItem:"ai-assistant",prompt:P,block:B}}):(0,m.jsx)(p.Yj,{})),(0,m.jsx)(h.A,{className:e,disabled:t||I,value:n,placeholder:i,isTransparent:g,state:f,onChange:$,actions:Z,message:J,promptUserInputRef:O,wrapperRef:w})}const f=(0,d.forwardRef)(g)},42299(e,t,n){"use strict";n.d(t,{FC:()=>s.A,N0:()=>r.A});n(70629);var r=n(71417),s=n(61)},11497(e,t,n){"use strict";n.d(t,{A:()=>d});var r=n(85985),s=n(56427),o=n(86087),i=n(27723),a=n(57577),l=n(22201),c=n(13022),u=(n(57799),n(10790));const __=i.__;function d({disabled:e=!1,iconSize:t=24,ratedItem:n="",feature:i="",savedRatings:d={},options:p={},onRate:h}){if(!function(e){return!0===(0,r.FB)(e).available}("ai-response-feedback"))return null;const[m,g]=(0,o.useState)({}),{tracks:f}=(0,r.st)();(0,o.useEffect)(()=>{const e={...d,...m};JSON.stringify(e)!==JSON.stringify(m)&&g(e)},[d]);const b=e=>!!m[n]&&m[n]===e,v=e=>{const t=e?"thumbs-up":"thumbs-down";b(t)||(g({...m,[n]:t}),h?.(t),f.recordEvent("jetpack_ai_feedback",{type:i,rating:t,media_library_id:p.mediaLibraryId||null,prompt:p.prompt||null,revised_prompt:p.revisedPrompt||null,block:p.block||null}))};return(0,u.jsxs)("div",{className:"ai-assistant-feedback__selection",children:[(0,u.jsx)(s.Tooltip,{text:__("I like this","jetpack"),children:(0,u.jsx)(s.Button,{disabled:e,icon:l.A,onClick:()=>v(!0),iconSize:t,showTooltip:!1,className:(0,c.A)({"ai-assistant-feedback__thumb-selected":b("thumbs-up")})})}),(0,u.jsx)(s.Tooltip,{text:__("I don't find this useful","jetpack"),children:(0,u.jsx)(s.Button,{disabled:e,icon:a.A,onClick:()=>v(!1),iconSize:t,showTooltip:!1,className:(0,c.A)({"ai-assistant-feedback__thumb-selected":b("thumbs-down")})})})]})}},23059(e,t,n){"use strict";n(56427),n(5573),n(10790)},96390(e,t,n){"use strict";n(85985),n(56427),n(86087),n(27723);var r=n(10067),s=n.n(r);n(23101),n(46381),n(14016),n(57853),n(77990),n(47560),n(56239),n(10790);s()("jetpack-ai-client:ai-image-modal")},77990(e,t,n){"use strict";n(56427),n(86087),n(27723),n(11497),n(23059),n(23263),n(10790)},47560(e,t,n){"use strict";n(86087),n(27723),n(45349),n(10790)},89289(e,t,n){"use strict";n(85985),n(56427),n(47143),n(43656),n(86087),n(27723);var r=n(10067),s=n.n(r);n(45817),n(43984),n(72448),n(71508),n(62038),n(96390),n(3620),n(35918),n(10790);s()("jetpack-ai-client:featured-image")},83158(e,t,n){"use strict";n(85985),n(56427),n(86087),n(27723);var r=n(10067),s=n.n(r);n(45817),n(72448),n(71508),n(62038),n(96390),n(3620),n(35918),n(10790);s()("jetpack-ai:general-purpose-image")},3620(e,t,n){"use strict";n(47143),n(86087),n(27723),n(93832),n(31439),n(72448),n(62614),n(62038)},35918(e,t,n){"use strict";n(97999),n(86087)},77089(e,t,n){"use strict";n(89289),n(83158)},46381(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(56427),s=n(86087),o=n(27723),i=n(13109),a=n(28847),l=(n(28151),n(10790));const __=o.__;function c({onGuidelinesClick:e,onFeedbackClick:t}){const n=(0,s.useCallback)(()=>{e?.()},[e]),o=(0,s.useCallback)(()=>{t?.()},[t]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"ai-image-modal__footer-disclaimer",children:[(0,l.jsx)(i.A,{icon:a.A}),(0,l.jsx)("span",{children:__("Generated images could be inaccurate, biased or include text.","jetpack")}),(0,l.jsx)(r.Button,{variant:"link",className:"ai-image-modal__guidelines-button",href:"https://jetpack.com/redirect/?source=ai-guidelines",target:"_blank",onClick:n,children:(0,l.jsxs)("span",{children:[__("Guidelines","jetpack")," ↗"]})})]}),(0,l.jsx)(r.Button,{variant:"link",className:"ai-image-modal__feedback-button",href:"https://jetpack.com/redirect/?source=jetpack-ai-feedback",target:"_blank",onClick:o,children:(0,l.jsxs)("span",{children:[__("Give feedback","jetpack")," ↗"]})})]})}},6754(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(56427),s=n(13022),o=(n(44582),n(10790));function i({state:e}){return(0,o.jsx)("div",{className:(0,s.A)("jetpack-ai-status-indicator__icon-wrapper",{[`is-${e}`]:!0}),children:(0,o.jsx)(r.Spinner,{})})}},68203(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(32569),s=n(10790);function o({duration:e,className:t}){return(0,s.jsx)("span",{className:t,children:(0,r.f)(e,{addDecimalPart:!1})})}},32569(e,t,n){"use strict";function r(e,{addDecimalPart:t=!1,showMinutes:n=!0,showHours:r=!1}={}){const s=Math.floor(e/36e5),o=Math.floor(e/6e4)%60,i=Math.floor(e/1e3)%60,a=Math.floor(e/10)%100,l=[s>0||r?s.toString().padStart(2,"0")+":":"",s>0||o>0||n?o.toString().padStart(2,"0")+":":"",i.toString().padStart(2,"0")];return t&&l.push("."+a.toString().padStart(2,"0")),l.join("")}n.d(t,{f:()=>r})},27802(e,t,n){"use strict";n.d(t,{AK:()=>o.AK,FC:()=>r.FC,Hb:()=>i.A,N0:()=>r.N0,QA:()=>i.Q,z3:()=>s.A});var r=n(42299),s=(n(11497),n(23059),n(77089),n(6754),n(68203)),o=(n(46381),n(63098)),i=(n(14016),n(57853))},63098(e,t,n){"use strict";n.d(t,{AK:()=>w,Kw:()=>j,Yj:()=>x,k9:()=>_});var r=n(56427),s=n(86087),o=n(27723),i=n(13109),a=n(88901),l=n(79654),c=n(13022),u=(n(60802),n(42154)),d=n(78836),p=n(11497),h=n(10790);const __=o.__,m="warning",g="error",f="success",b="info",v={[b]:null,[m]:null,[g]:u.A,[f]:a.A};function y({severity:e=b,icon:t=null,aiFeedbackThumbsOptions:n={showAIFeedbackThumbs:!1,ratedItem:"",prompt:"",block:null,onRate:()=>{}},children:r}){return(0,h.jsxs)("div",{className:(0,c.A)("jetpack-ai-assistant__message",`jetpack-ai-assistant__message-severity-${e}`),children:[(v[e]||t)&&(0,h.jsx)(i.A,{icon:v[e]||t}),(0,h.jsx)("div",{className:"jetpack-ai-assistant__message-content",children:r}),n.showAIFeedbackThumbs&&n.prompt&&(0,h.jsx)(p.A,{disabled:!1,ratedItem:n.ratedItem,feature:"ai-assistant",options:{prompt:n.prompt,block:n.block},onRate:n.onRate})]})}function k(){return(0,h.jsx)(l.N,{openInNewTab:!0,href:"https://jetpack.com/redirect/?source=ai-guidelines",children:__("Learn more","jetpack")})}function x({aiFeedbackThumbsOptions:e={showAIFeedbackThumbs:!1,ratedItem:"",prompt:"",block:null,onRate:()=>{}}}){return(0,h.jsxs)(y,{aiFeedbackThumbsOptions:e,children:[(0,h.jsx)("span",{children:__("AI-generated content could be inaccurate or biased.","jetpack")}),(0,h.jsx)(k,{})]})}function _(){const e=__("You've reached this month's request limit, per our fair usage policy","jetpack"),t=(0,s.createInterpolateElement)(e,{link:(0,h.jsx)(l.N,{openInNewTab:!0,href:"https://jetpack.com/redirect/?source=ai-assistant-fair-usage-policy",children:null})});return(0,h.jsx)(y,{severity:m,children:t})}function w({requestsRemaining:e,severity:t,onUpgradeClick:n,upgradeUrl:s}){let i=t;return null==i&&(i=e>0?b:m),(0,h.jsxs)(y,{severity:i,children:[(0,h.jsx)("span",{children:(0,o.sprintf)( // translators: %1$d: number of requests remaining __("You have %1$d requests remaining.","jetpack"),e)}),(0,h.jsx)(r.Button,{variant:"link",onClick:n,href:s,target:s?"_blank":null,children:(0,h.jsx)("span",{children:__("Upgrade now","jetpack")})})]})}function j({error:e,code:t,onTryAgainClick:n,onUpgradeClick:s,upgradeUrl:i}){const a=e||__("Something went wrong","jetpack");return(0,h.jsxs)(y,{severity:g,children:[(0,h.jsx)("span",{children:(0,o.sprintf)( // translators: %1$d: A dynamic error message __("Error: %1$s","jetpack"),a)}),t===d.Or?(0,h.jsx)(r.Button,{variant:"link",onClick:s,href:i,target:i?"_blank":null,children:(0,h.jsx)("span",{children:__("Upgrade now","jetpack")})}):(0,h.jsx)(r.Button,{variant:"link",onClick:n,children:(0,h.jsx)("span",{children:__("Try again","jetpack")})})]})}},14016(e,t,n){"use strict";n(56427),n(27723),n(6754),n(1184),n(10790)},57853(e,t,n){"use strict";n.d(t,{A:()=>b,Q:()=>f});var r=n(3924),s=n(85985),o=n(82201),i=n(56427),a=n(86087),l=n(27723),c=n(10067),u=n.n(c),d=n(42694),p=n(72448),h=n(71567),m=(n(92051),n(10790));const __=l.__,g=u()("jetpack-ai-client:upgrade-prompt"),f=({variant:e="error"})=>{const t=(()=>{const{usagePeriod:e}=(0,p.A)(),t=(e=>{const t=__("You've reached this month's request limit, per our fair usage policy.","jetpack");if(!e)return t; // Translators: %s is the date when the requests will reset. const n=__("Requests will reset on %s.","jetpack");return`${t} ${(0,l.sprintf)(n,e)}`})((e=>{if(!e?.nextStart)return null;const t=new Date(e.nextStart);return t.toLocaleString("default",{month:"long"})+" "+t.getDate()})(e));return(0,a.createInterpolateElement)(t,{link:(0,m.jsx)("a",{href:"https://jetpack.com/redirect/?source=ai-assistant-fair-usage-policy",target:"_blank",rel:"noreferrer"}),span:(0,m.jsx)("span",{})})})();return"muted"===e?(0,m.jsx)("span",{className:"jetpack-ai-fair-usage-notice-muted-variant",children:t}):"error"===e?(0,m.jsx)(i.Notice,{status:"error",isDismissible:!1,className:"jetpack-ai-fair-usage-notice",children:t}):null},b=e=>{const{upgradeType:t,currentTier:n}=(0,p.A)();return 1===n?.value?(0,m.jsx)(f,{}):"vip"===t?(({description:e=null,useLightNudge:t=!1})=>{const n=t?h.U:o.cb,r=(0,a.createInterpolateElement)(__("You've reached the Jetpack AI rate limit. Please reach out to your VIP account team.","jetpack"),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(n,{buttonText:null,checkoutUrl:null,className:"jetpack-ai-upgrade-banner",description:e||r,goToCheckoutPage:null,isRedirecting:null,visible:!0,align:null,title:null,context:null})})({description:e.description,useLightNudge:e?.useLightNudge}):(({placement:e=null,description:t=null,useLightNudge:n=!1})=>{const i=n?h.U:o.cb,{checkoutUrl:c}=(0,d.A)(),u=(0,s.CP)(),{nextTier:f,tierPlansEnabled:b,currentTier:v,requestsCount:y}=(0,p.A)(),{tracks:k}=(0,s.st)(),x=(0,a.useCallback)(()=>{g("upgrade",e),k.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:v?.slug,requests_count:y,placement:e})},[v,y,k,e]),_=(0,a.useCallback)(()=>{g("contact us",e),k.recordEvent("jetpack_ai_upgrade_contact_us",{placement:e})},[k,e]);if(!u){const e=(0,a.createInterpolateElement)(__("Congratulations on exploring Jetpack AI and reaching the free requests limit! Reach out to the site administrator to upgrade and keep using Jetpack AI.","jetpack"),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(i,{showButton:!1,className:"jetpack-ai-upgrade-banner",description:t||e,visible:!0,align:null,title:null,context:null})}if(b){if(!f){const e=(0,r.A)("jetpack-ai-tiers-more-requests-contact"),n=__("You have reached the request limit for your current plan.","jetpack");return(0,m.jsx)(i,{buttonText:__("Contact Us","jetpack"),description:t||n,className:"jetpack-ai-upgrade-banner",checkoutUrl:e,visible:!0,align:null,title:null,context:null,goToCheckoutPage:_,target:"_blank"})}const e=(0,a.createInterpolateElement)((0,l.sprintf)(/* Translators: %d: the number of requests allowed */ __("You have reached the requests limit for your current plan. Upgrade now to increase your requests limit to %d.","jetpack"),f.limit),{strong:(0,m.jsx)("strong",{})});return(0,m.jsx)(i,{buttonText:(0,l.sprintf)(/* Translators: %d: the number of requests */ __("Upgrade to %d requests","jetpack"),f.limit),checkoutUrl:c,className:"jetpack-ai-upgrade-banner",description:t||e,goToCheckoutPage:x,visible:!0,align:"center",title:null,context:null,target:"_blank"})}return(0,m.jsx)(i,{buttonText:__("Upgrade","jetpack"),checkoutUrl:c,className:"jetpack-ai-upgrade-banner",description:(0,a.createInterpolateElement)(__("Congratulations on exploring Jetpack AI and reaching the free requests limit! Upgrade now to keep using it.","jetpack"),{strong:(0,m.jsx)("strong",{})}),goToCheckoutPage:x,visible:!0,align:null,title:null,context:null,target:"_blank"})})(e)}},71567(e,t,n){"use strict";n.d(t,{U:()=>i});var r=n(56427),s=n(27723),o=(n(92051),n(10790));const __=s.__,i=({title:e,description:t,buttonText:n=null,checkoutUrl:s=null,goToCheckoutPage:i=null,isRedirecting:a=!1,showButton:l=!0,target:c="_top"})=>{const u=__("Redirecting…","jetpack");return(0,o.jsx)("div",{className:"jetpack-upgrade-plan-banner-light",children:(0,o.jsx)(r.Notice,{status:"error",isDismissible:!1,children:(0,o.jsxs)("p",{children:[e&&(0,o.jsx)("strong",{children:e}),t," ",l&&(0,o.jsx)(r.Button,{href:a?null:s,onClick:i,variant:"link",target:c,children:(0,o.jsx)("span",{children:a?u:n})})]})})})}},43984(e,t,n){"use strict";n.d(t,{A4:()=>l,DD:()=>x,DT:()=>N,Gm:()=>g,HM:()=>_,JR:()=>w,K2:()=>C,Rq:()=>T,UA:()=>m,UD:()=>j,br:()=>d,d5:()=>b,eJ:()=>h,fD:()=>p,fv:()=>v,im:()=>i,mI:()=>A,mT:()=>E,oZ:()=>o,pE:()=>f,sn:()=>a,so:()=>s,u0:()=>y,uQ:()=>k,vE:()=>u,yQ:()=>S,yy:()=>c});var r=n(27723);const __=r.__,s={en:{label:__("English","jetpack")},es:{label:__("Spanish","jetpack")},fr:{label:__("French","jetpack")},de:{label:__("German","jetpack")},it:{label:__("Italian","jetpack")},pt:{label:__("Portuguese","jetpack")},ru:{label:__("Russian","jetpack")},zh:{label:__("Chinese","jetpack")},ja:{label:__("Japanese","jetpack")},ar:{label:__("Arabic","jetpack")},hi:{label:__("Hindi","jetpack")},ko:{label:__("Korean","jetpack")}},o={formal:{label:__("Formal","jetpack"),emoji:"🎩"},informal:{label:__("Informal","jetpack"),emoji:"😊"},optimistic:{label:__("Optimistic","jetpack"),emoji:"😃"},humorous:{label:__("Humorous","jetpack"),emoji:"😂"},serious:{label:__("Serious","jetpack"),emoji:"😐"},skeptical:{label:__("Skeptical","jetpack"),emoji:"🤨"},empathetic:{label:__("Empathetic","jetpack"),emoji:"💗"},confident:{label:__("Confident","jetpack"),emoji:"😎"},passionate:{label:__("Passionate","jetpack"),emoji:"❤️"},provocative:{label:__("Provocative","jetpack"),emoji:"🔥"}},i="titleSummary",a="continue",l="simplify",c="correctSpelling",u="generateTitle",d="makeLonger",p="makeShorter",h="changeTone",m="summarize",g="changeLanguage",f="userPrompt",b="transformListToTable",v="writePostFromList",y=__("Translate","jetpack"),k=__("Change tone","jetpack"),x=__("Correct spelling and grammar","jetpack"),_=__("Simplify","jetpack"),w=__("Summarize","jetpack"),j=__("Make shorter","jetpack"),C=__("Expand","jetpack"),A=__("Turn list into a table","jetpack"),S=__("Write a post from this list","jetpack"),E=__("Generate a post title","jetpack"),T=__("Summary based on title","jetpack"),N=__("Continue writing","jetpack")},2166(e,t,n){"use strict";n.d(t,{R:()=>i});var r=n(51609),s=n(10790);const o=(0,r.createContext)({}),i=({value:e,children:t})=>(0,s.jsx)(o.Provider,{value:e,children:t})},13965(e,t,n){"use strict";n.d(t,{Rb:()=>r.R});var r=n(2166);n(59886),n(53471)},53471(e,t,n){"use strict";n(51609),n(78836),n(13965)},59886(e,t,n){"use strict";var r=n(29491),s=n(86087),o=n(46219),i=n(13965),a=n(10790);(0,r.createHigherOrderComponent)(e=>t=>{const{suggestion:n,error:r,requestingState:l,request:c,stopSuggestion:u,eventSource:d}=(0,o.Ay)(),p=(0,s.useMemo)(()=>({suggestion:n,requestingError:r,requestingState:l,eventSource:d,requestSuggestion:c,stopSuggestion:u}),[n,r,l,d,c,u]);return(0,a.jsx)(i.Rb,{value:p,children:(0,a.jsx)(e,{...t})})},"withAiDataProvider")},42694(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(3924),s=n(97999),o=n(85985),i=n(72448);function a(){const{nextTier:e,tierPlansEnabled:t}=(0,i.A)(),n=(()=>{const e=new URLSearchParams(window.location.search),t=(0,o.GE)();return(0,s.isSimpleSite)()&&e.has("post")?`https://wordpress.com/post/${t}/${e.get("post")}`:`https://wordpress.com/home/${t}`})(),a=(0,r.A)("jetpack-ai-yearly-tier-upgrade-nudge",{site:(0,o.GE)(),path:t?`jetpack_ai_yearly:-q-${e?.limit}`:"jetpack_ai_yearly",query:`redirect_to=${encodeURIComponent(n)}`}),l=(0,r.A)("jetpack-ai-upgrade-url-for-jetpack-sites",{site:(0,o.GE)(),path:"jetpack_ai_yearly"}),c=(0,s.isWpcomPlatformSite)()?a:l,{autosaveAndRedirect:u,isRedirecting:d}=(0,o.ZR)(c);return{checkoutUrl:c,autosaveAndRedirect:u,isRedirecting:d}}},72448(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(85985),s=n(47143),o=n(86087);function i(){const e=(0,s.useSelect)(e=>e("wordpress-com/plans").getAiAssistantFeature(),[]),t=(0,s.useSelect)(e=>e("wordpress-com/plans").getIsRequestingAiAssistantFeature(),[]),{fetchAiAssistantFeature:n,increaseAiAssistantRequestsCount:i,dequeueAiAssistantFeatureAsyncRequest:a}=(0,s.useDispatch)("wordpress-com/plans");return(0,o.useMemo)(()=>{const s=(0,r.Bd)(e?.currentTier),o=e?.currentTier?.limit||e?.requestsLimit,l=s===r._X?e?.requestsCount:e?.usagePeriod?.requestsCount,c=s===r._X?e?.requestsLimit:o;return{...e,requestsCount:l,requestsLimit:c,loading:t,error:null,refresh:n,increaseRequestsCount:i,dequeueAsyncRequest:a}},[e,t,n,i,a])}},46219(e,t,n){"use strict";n.d(t,{Ay:()=>p,fC:()=>u});var r=n(86087),s=n(27723),o=n(10067),i=n.n(o),a=n(87286),l=n(78836);const __=s.__,c=i()("ai-client:use-ai-suggestions");function u(e){switch(e){case l.Or:return{code:l.Or,message:__("You have reached the limit of requests for this site.","jetpack"),severity:"info"};case l.L9:return{code:l.L9,message:__("Your request was unclear. Mind trying again?","jetpack"),severity:"info"};case l.AZ:return{code:l.AZ,message:__("Jetpack AI services are currently unavailable. Sorry for the inconvenience.","jetpack"),severity:"info"};case l.ud:return{code:l.ud,message:__("Our service provider OpenAI could not process your prompt due to a moderation system. Please try to rephrase it changing potentially problematic words and try again.","jetpack"),severity:"info"};case l.cT:return{code:l.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 l.mA:default:return{code:l.mA,message:__("It was not possible to process your request. Mind trying again?","jetpack"),severity:"info"}}}function d(e){return e.replace(/^<\|start_header_id\|>assistant<\|end_header_id\|>[\n]+/,"")}function p({prompt:e,autoRequest:t=!1,askQuestionOptions:n={},initialRequestingState:s="init",onSuggestion:o,onDone:i,onStop:p,onError:h,onAllErrors:m}={}){const[g,f]=(0,r.useState)(s),[b,v]=(0,r.useState)(""),[y,k]=(0,r.useState)(l.Np),x=(0,r.useRef)(l.Np),[_,w]=(0,r.useState)(),j=(0,r.useRef)(void 0),C=(0,r.useCallback)(e=>{c("handleSuggestion",e);const t=d(e?.detail);t?(v(t),o?.(t)):c("no partial suggestion")},[o]),A=(0,r.useCallback)(e=>{L();const t=d(e?.detail?.message??e?.detail);i?.(t,x.current),f("done")},[i]),S=(0,r.useCallback)(e=>{m?.(e?.detail)},[m]),E=(0,r.useCallback)(e=>{j?.current?.close(),f("error"),w(u(e)),h?.(u(e))},[h]),T=(0,r.useCallback)(()=>E(l.Or),[]),N=(0,r.useCallback)(()=>E(l.L9),[]),P=(0,r.useCallback)(()=>E(l.AZ),[]),B=(0,r.useCallback)(()=>E(l.ud),[]),R=(0,r.useCallback)(()=>E(l.mA),[]),I=(0,r.useCallback)(async(e,t={...n})=>{var r;if(w(void 0),f("requesting"),r=l.Np,k(r),x.current=r,j.current=await(0,a.A)(e,t),!j?.current)return void c("no event source");const s=j.current;f("suggesting"),s.addEventListener("suggestion",C),s.addEventListener(l.Or,T),s.addEventListener(l.L9,N),s.addEventListener(l.AZ,P),s.addEventListener(l.ud,B),s.addEventListener(l.mA,R),s.addEventListener(l.zn,S),s.addEventListener("done",A)},[A,T,N,P,B,R,C]),D=(0,r.useCallback)(()=>{f("init"),v(""),w(void 0)},[]),L=(0,r.useCallback)(()=>{if(!j?.current)return;const e=j?.current;e.close(),e.removeEventListener("suggestion",C),e.removeEventListener(l.Or,T),e.removeEventListener(l.L9,N),e.removeEventListener(l.AZ,P),e.removeEventListener(l.ud,B),e.removeEventListener(l.mA,R),e.removeEventListener("done",A)},[j,C,T,N,P,B,R,A]),F=(0,r.useCallback)(()=>{L(),p?.(),f("done")},[p]);return(0,r.useEffect)(()=>{if(e?.length)return t&&I(e,n),()=>{F()}},[t,e,I,F]),{suggestion:b,model:y,error:_,requestingState:g,request:I,stopSuggestion:F,reset:D,handleErrorQuotaExceededError:T,eventSource:j.current}}},7804(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(86087),s=n(27723),o=n(10067),i=n.n(o),a=n(57745);const __=s.__,l=i()("jetpack-ai-client:use-audio-transcription");function c({feature:e,onReady:t,onError:n}){const[s,o]=(0,r.useState)(""),[i,c]=(0,r.useState)(""),[u,d]=(0,r.useState)(!1),p=(0,r.useRef)(null);return{transcriptionResult:s,isTranscribingAudio:u,transcriptionError:i,transcribeAudio:(0,r.useCallback)(r=>{l("Transcribing audio"),o(""),c(""),d(!0);const s=new AbortController;p.current=s,(0,a.A)(r,e,s.signal).then(e=>{o(e),t?.(e)}).catch(e=>{s.signal.aborted||(c(e.message),n?.((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")})(e)))}).finally(()=>d(!1))},[a.A,o,c,d]),cancelTranscription:(0,r.useCallback)(()=>{p.current?.abort(),o(""),c(""),d(!1)},[p,o,c,d])}}},66859(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(86087),s=n(27723);const __=s.__,o=["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 i(){const[e,t]=(0,r.useState)(!1);return{isValidatingAudio:e,validateAudio:(0,r.useCallback)((e,n,r)=>{if(t(!0),e?.size>25e6)return t(!1),r(__("The audio file is too large. The maximum file size is 25MB.","jetpack"));const s=e instanceof File;if(s&&!o.includes(e.type))return t(!1),r(__("The audio file type is not supported. Please use a supported audio file type.","jetpack"));const i=new AudioContext;e.arrayBuffer().then(o=>{i.decodeAudioData(o,function(o){const i=Math.ceil(o.duration);return i>1500?(t(!1),r(__("The audio file is too long. The maximum recording time is 25 minutes.","jetpack"))):(t(!1),n({duration:i,isFile:s,size:e?.size}))})})},[t])}}},66223(e,t,n){"use strict";n.d(t,{Hu:()=>s,Wp:()=>r});const r="auto",s="none"},62614(e,t,n){"use strict";n.d(t,{Ay:()=>u});var r=n(10067),s=n.n(r),o=n(31439),i=n(51391);const a=s()("ai-client:use-image-generator"),l=(e,t)=>{const n=4e3-t;return e.length>n?e.substring(0,n-6)+" [...]":e},c=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+l(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"+l(e,412)})(e,t);return await(0,o.A)(r,{feature:n})},u=()=>{const e=async function(e){let t;try{t=(await(0,i.A)()).token}catch(e){return a("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"},s=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(e)}).then(e=>e.json());return s?.data?.status&&s?.data?.status>200?(a("Error generating image: %o",s),Promise.reject(s)):s}catch(e){return a("Error generating image: %o",e),Promise.reject(e)}};return{generateImage:async function({feature:t,postContent:n,responseFormat:r="url",userPrompt:s}){try{a("Generating image");const o=((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+l(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+l(e,838)})(n,s),i={prompt:o,response_format:r,feature:t,size:"1792x1024"};return await e(i)}catch(e){return a("Error generating image: %o",e),Promise.reject(e)}},generateImageWithStableDiffusion:async function({feature:t,postContent:n,userPrompt:r}){try{a("Generating image with Stable Diffusion");const s={prompt:await c(n,r,t),feature:t,model:"stable-diffusion"};return await e(s)}catch(e){return a("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 s="audio/mp4;codecs=mp4a",o="audio/webm";function i({onDone:e}={}){const t=(0,r.useRef)(null),[n,i]=(0,r.useState)("inactive"),a=(0,r.useRef)(!1),l=(0,r.useRef)(0),[c,u]=(0,r.useState)(0),d=(0,r.useRef)(null),[p,h]=(0,r.useState)(null),m=(0,r.useRef)([]).current,[g,f]=(0,r.useState)(null),b=(0,r.useRef)(null);function v(){return MediaRecorder.isTypeSupported(s)?new Blob(m,{type:"audio/mp4"}):new Blob(m,{type:o})}const y=(0,r.useCallback)(e=>{if(w(),!e)return t?.current?.start();e<100&&(e=100),l.current=Date.now(),t?.current?.start(e)},[]),k=(0,r.useCallback)(()=>{a.current=!0,t?.current?.pause(),u(e=>e+Date.now()-l.current)},[]),x=(0,r.useCallback)(()=>{a.current=!1,t?.current?.resume(),l.current=Date.now()},[]),_=(0,r.useCallback)(()=>{t?.current?.stop(),"recording"===n&&u(e=>e+Date.now()-l.current)},[]),w=(0,r.useCallback)(()=>{m.length=0,h(null),f(null),u(0),a.current=!1,l.current=0},[]),j=(0,r.useCallback)(()=>{t?.current&&(t.current.removeEventListener("start",S),t.current.removeEventListener("stop",E),t.current.removeEventListener("pause",T),t.current.removeEventListener("resume",N),t.current.removeEventListener("dataavailable",P),t.current=null)},[]),C=(0,r.useCallback)(()=>{if(i("inactive"),w(),j(),!navigator.mediaDevices?.getUserMedia)return;const e=new AudioContext;b.current=e.createAnalyser();navigator.mediaDevices.getUserMedia({audio:!0}).then(n=>{d.current=n;e.createMediaStreamSource(n).connect(b.current),MediaRecorder.isTypeSupported(s)?t.current=new MediaRecorder(n,{mimeType:s}):t.current=new MediaRecorder(n,{mimeType:o}),t.current.addEventListener("start",S),t.current.addEventListener("stop",E),t.current.addEventListener("pause",T),t.current.addEventListener("resume",N),t.current.addEventListener("dataavailable",P)}).catch(e=>{throw e})},[]),A=(0,r.useCallback)(e=>{_(),f("string"==typeof e?e:e.message),i("error")},[]);function S(){i("recording")}function E(){const t=v();e?.(t),m.length=0}function T(){i("paused")}function N(){i("recording")}function P(e){const{data:t}=e;t?.size&&(m.push(t),h(v()),a.current||u(e=>{const t=Date.now(),n=t-l.current;return l.current=t,e+n}))}return(0,r.useEffect)(()=>(C(),()=>{d.current&&d.current.getTracks().forEach(e=>e.stop()),j()}),[]),{state:n,blob:p,error:g,duration:c,analyser:b.current,onError:A,controls:{start:y,pause:k,resume:x,stop:_,reset:C}}}},71508(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(74997),s=n(47143),o=n(43656),i=n(86087),a=n(55166);const l=()=>{const{getBlocks:e,isEditedPostEmpty:t}=(0,s.useSelect)(e=>{const t=e("core/block-editor"),n=e(o.store);return{getBlocks:t.getBlocks,isEditedPostEmpty:n.isEditedPostEmpty}},[]),n=(0,i.useCallback)(()=>{const t=e();return 0===t.length?"":(0,r.serialize)(t)},[e]);return{getPostContent:(0,i.useCallback)(e=>{let t=n();return t?(e&&"function"==typeof e&&(t=e(t)),t?(0,a.rh)({content:t}):""):""},[e]),isEditedPostEmpty:t,getSerializedPostContent:n}}},62038(e,t,n){"use strict";n(63162),n(47143),n(86087);var r=n(10067);n.n(r)()("jetpack-ai-client:save-to-media-library")},93869(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(63162),s=n(47143),o=n(86087),i=n(10067);const a=n.n(i)()("ai-client:save-to-media-library");function l(){const[e,t]=(0,o.useState)(!1),{getSettings:n}=(0,s.useSelect)(e=>e("core/block-editor"),[]);return{isLoading:e,saveToMediaLibrary:(e,s)=>{const o=n();return new Promise((n,i)=>{t(!0),a("Fetching image from URL"),fetch(e).then(e=>{a("Transforming response to blob"),e.blob().then(e=>{a("Uploading blob to media library");const l=Array();s?l.push(new File([e],s)):l.push(e),o.mediaUpload({allowedTypes:["image"],filesList:l,onFileChange([e]){(0,r.isBlobURL)(e?.url)||(e&&(a("Image uploaded to media library",e),n(e)),t(!1))},onError(e){a("Error uploading image to media library:",e),i(e),t(!1)}})}).catch(e=>{a("Error transforming response to blob:",e?.message),i(e?.message),t(!1)})}).catch(e=>{a("Error fetching image from URL:",e?.message),i(e?.message),t(!1)})})}}}},97784(e,t,n){"use strict";n.d(t,{A:()=>c,u:()=>l});var r=n(86087),s=n(10067),o=n.n(s),i=n(46219);const a=o()("jetpack-ai-client:use-transcription-post-processing"),l="voice-to-content-simple-draft";function c({feature:e,onReady:t,onError:n,onUpdate:s}){const[o,l]=(0,r.useState)(""),[c,u]=(0,r.useState)(""),[d,p]=(0,r.useState)(!1),h=(0,r.useCallback)(e=>{l(e),s?.(e)},[l,s]),m=(0,r.useCallback)(e=>{l(e),s?.(e),t?.(e)},[l,s,t]),g=(0,r.useCallback)(e=>{u(e.message),n?.(e.message)},[u,n]),{request:f,stopSuggestion:b}=(0,i.Ay)({onSuggestion:h,onDone:m,onError:g});return{postProcessingResult:o,isProcessingTranscription:d,postProcessingError:c,processTranscription:(0,r.useCallback)((t,n)=>{a("Post-processing transcription"),l(""),u(""),p(!0);f([{role:"jetpack-ai",context:{type:t,content:n}}],{feature:e})},[l,u,p,f,e]),cancelTranscriptionProcessing:(0,r.useCallback)(()=>{b(),p(!1)},[b,p])}}},30151(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsxs)(r.SVG,{viewBox:"0 0 32 32",width:"32",height:"32",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"ai-assistant-icon",children:[(0,s.jsx)(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"}),(0,s.jsx)(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"}),(0,s.jsx)(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:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsxs)(r.SVG,{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(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"}),(0,s.jsx)(r.Path,{d:"M10.8333 5.83333H9.16667V10.8333H10.8333V5.83333Z"}),(0,s.jsx)(r.Path,{d:"M10.8333 12.5H9.16667V14.1667H10.8333V12.5Z"})]})},91396(e,t,n){"use strict";n.d(t,{Qr:()=>i.A,Vo:()=>s.A,cj:()=>r.A,ni:()=>o.A});var r=n(30151),s=n(81353),o=(n(95007),n(96626),n(4416),n(25680)),i=n(67205)},81353(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsxs)(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG",children:[(0,s.jsx)(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"}),(0,s.jsx)(r.Rect,{x:"10.5",y:"8.25",width:"3",height:"4.875",rx:"1.5",fill:"#008710"}),(0,s.jsx)(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"}),(0,s.jsx)(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";n(56427),n(10790)},25680(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsxs)(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/SVG",children:[(0,s.jsx)(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"}),(0,s.jsx)(r.Rect,{x:"12.75",y:"9",width:"2.25",height:"6",fill:"#008710"}),(0,s.jsx)(r.Rect,{x:"9",y:"9",width:"2.25",height:"6",fill:"#008710"})]})},96626(e,t,n){"use strict";n(56427),n(10790)},4416(e,t,n){"use strict";n(56427),n(10790)},67205(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsxs)(r.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(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"}),(0,s.jsx)(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,{A4:()=>f.A4,AK:()=>h.AK,AZ:()=>m.AZ,DD:()=>f.DD,DT:()=>f.DT,E0:()=>l.A,FC:()=>h.FC,Fs:()=>g.Fs,Gm:()=>f.Gm,HM:()=>f.HM,Hb:()=>h.Hb,JR:()=>f.JR,K2:()=>f.K2,L9:()=>m.L9,MB:()=>g.MB,N0:()=>h.N0,ON:()=>s.A,OO:()=>g.OO,Or:()=>m.Or,QA:()=>h.QA,Qr:()=>p.Qr,R0:()=>r.A,Rq:()=>f.Rq,Tg:()=>b.T,UA:()=>f.UA,UD:()=>f.UD,Vo:()=>p.Vo,Zo:()=>g.Zo,_E:()=>g.Hh,_G:()=>g._G,be:()=>a.A,br:()=>f.br,cT:()=>m.cT,cj:()=>p.cj,d5:()=>f.d5,dh:()=>d.A,eJ:()=>f.eJ,fD:()=>f.fD,im:()=>f.im,in:()=>g.in,mA:()=>m.mA,mI:()=>f.mI,mT:()=>f.mT,ni:()=>p.ni,o2:()=>i.Ay,oZ:()=>f.oZ,pE:()=>f.pE,rh:()=>g.rh,rr:()=>u.A,sn:()=>f.sn,so:()=>f.so,u0:()=>f.u0,uH:()=>m.uH,uQ:()=>f.uQ,ud:()=>m.ud,vE:()=>f.vE,xA:()=>c.A,yM:()=>o.A,yQ:()=>f.yQ,yy:()=>f.yy,z3:()=>h.z3});n(51391),n(53664),n(87286);var r=n(31439),s=(n(57745),n(42694)),o=n(72448),i=n(46219),a=n(96657),l=n(7804),c=n(97784),u=n(66859),d=(n(62614),n(71508)),p=n(91396),h=n(27802),m=(n(13965),n(78836)),g=n(72586),f=n(43984),b=n(23101)},51391(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(97999),s=n(10067),o=n.n(s),i=n(48931);const a=o()("jetpack-ai-client:jwt"),l="jetpack-ai-jwt";async function c({apiNonce:e,siteId:t,expirationTime:n}={}){e=e||window.JP_CONNECTION_INITIAL_STATE.apiNonce,t=t||window.JP_CONNECTION_INITIAL_STATE.siteSuffix,n=n||12e4;const s=localStorage.getItem(l);let o,c=null;if(s)try{c=JSON.parse(s)}catch(e){a("Error parsing token",e)}if(c&&c?.expire>Date.now())return a("Using cached token"),c;const u=(0,r.isSimpleSite)();o=u?await(0,i.A)({path:"/wpcom/v2/sites/"+t+"/jetpack-openai-query/jwt",method:"POST"}):await(0,i.A)({path:"/jetpack/v4/jetpack-ai-jwt?_cacheBuster="+Date.now(),credentials:"same-origin",headers:{"X-WP-Nonce":e},method:"POST"});const d={token:o.token,blogId:u?t:o.blog_id,expire:Date.now()+n};return a("Storing new token"),localStorage.setItem(l,JSON.stringify(d)),d}},20231(e,t,n){"use strict";n.d(t,{_:()=>s});var r=n(47143);const s=()=>{const e=(0,r.select)("core/block-editor").getBlocks(),t=[],n=e=>{t.push(e),e.innerBlocks?.length&&e.innerBlocks.forEach(n)};return e.forEach(n),t}},40464(e,t,n){"use strict";n.d(t,{Z:()=>r});const r=async e=>{try{const t=await fetch(e),n=await t.arrayBuffer();return`data:image/png;base64,${btoa(new Uint8Array(n).reduce((e,t)=>e+String.fromCharCode(t),""))}`}catch{return e}}},72586(e,t,n){"use strict";n.d(t,{Fs:()=>i.F,Hh:()=>r.Hh,MB:()=>s.M,OO:()=>r.OO,Zo:()=>l.Z,_G:()=>a._,in:()=>o.i,rh:()=>r.rh});var r=n(55166),s=n(84861),o=n(61269),i=n(1811),a=n(20231),l=n(40464)},84861(e,t,n){"use strict";n.d(t,{M:()=>s});var r=n(43984);function s(e,t={}){const{language:n,tone:s}=t,o=n?.split(" (")[0];switch(e){case r.Gm:return`${r.u0}: ${r.so[o].label}`;case r.eJ:return`${r.uQ}: ${r.oZ[s].label}`;case r.yy:return r.DD;case r.A4:return r.HM;case r.UA:return r.JR;case r.br:return r.K2;case r.fD:return r.UD;case r.d5:return r.mI;case r.fv:return r.yQ;case r.vE:return r.mT;case r.im:return r.Rq;case r.sn:return r.DT;default:return null}}},68641(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(21147);const s={paragraph:e=>e.replaceAll("\n","
    ")},o={emDelimiter:"_",headingStyle:"atx"},i={strikethrough:{filter:["del","s"],replacement:function(e){return"~~"+e+"~~"}}};class a{turndownService;fixes;constructor({options:e={},rules:t={},keep:n=[],remove:s=[],fixes:a=[]}={}){this.fixes=a,this.turndownService=new r.A({...o,...e}),this.turndownService.keep(n),this.turndownService.remove(s);const l={...i,...t};for(const e in l)this.turndownService.addRule(e,l[e])}render({content:e}){const t=this.turndownService.turndown(e);return this.fixes.reduce((e,t)=>s[t](e),t)}}},55166(e,t,n){"use strict";n.d(t,{Hh:()=>i,OO:()=>r.A,rh:()=>a});var r=n(68641);const s=new(n(31737).A),o=new r.A,i=({content:e,rules:t,extension:n})=>s.render({content:e,rules:t,extension:n}),a=({content:e})=>o.render({content:e})},31737(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(97158);const s=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
        ").replaceAll("
      ","
    \x3c!-- /wp:list --\x3e"),o={list:(e,t=!1)=>{const n=e.replace(/
  • \s+

    /g,"

  • ").replace(/<\/p>\s+<\/li>/g,"
  • ");return t?s(n):n},listItem:(e,t=!1)=>t?s(e.replace(/^<[ou]l>\s*/g,"").replace(/\s*<\/[ou]l>\s*$/g,"")):e,paragraph:(e,t=!1)=>t?e.split("<br />").map((e,t,n)=>(t0&&(e=e.trimStart()),e)).join("
    "):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},i={breaks:!0},a=["list"];class l{markdownConverter;constructor(e=i){this.markdownConverter=new r.A(e)}render({content:e,rules:t=a,extension:n=!1}){const r=this.markdownConverter.render(e);return t.reduce((e,t)=>o[t](e,n),r)}}},61269(e,t,n){"use strict";n.d(t,{i:()=>o});var r=n(94715),s=n(47143);function o(e){if(!e)return;const{selectBlock:t}=(0,s.dispatch)(r.store),{enableComplementaryArea:n}=(0,s.dispatch)("core/interface");t(e),n("core/edit-post","edit-post/block")}},1811(e,t,n){"use strict";n.d(t,{F:()=>s});var r=n(47143);const s=async()=>{const{clearSelectedBlock:e}=(0,r.dispatch)("core/block-editor"),{enableComplementaryArea:t}=(0,r.dispatch)("core/interface");e(),await t("core/edit-post","jetpack-sidebar/jetpack");const n=document.querySelector(".jetpack-ai-assistant-panel"),s=n?.classList.contains("is-opened"),o=n?.querySelector("h2 button");s&&o?.click(),setTimeout(()=>{o?.click()},50)}},21902(e,t,n){"use strict";n.d(t,{A:()=>s});n(33829);var r=n(10790);const s=()=>(0,r.jsxs)("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",children:[(0,r.jsx)("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"}),(0,r.jsx)("path",{d:"M16 4L17.1314 6.86863L20 8L17.1314 9.13137L16 12L14.8686 9.13137L12 8L14.8686 6.86863L16 4Z"}),(0,r.jsx)("path",{d:"M11 10L12.4142 13.5858L16 15L12.4142 16.4142L11 20L9.58579 16.4142L6 15L9.58579 13.5858L11 10Z"})]});n.dn(s)},11574(e,t,n){"use strict";n.d(t,{A:()=>s});n(33829);var r=n(10790);const s=()=>(0,r.jsx)("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",children:(0,r.jsx)("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"})});n.dn(s)},70002(e,t,n){"use strict";n.d(t,{A:()=>s});n(33829);var r=n(10790);const s=()=>(0,r.jsx)("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",children:(0,r.jsx)("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"})});n.dn(s)},97034(e,t,n){"use strict";n.d(t,{A:()=>s});n(33829);var r=n(10790);const s=()=>(0,r.jsxs)("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",children:[(0,r.jsx)("path",{d:"M7 6.49011L11 8.99011L7 11.4901V6.49011Z"}),(0,r.jsx)("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"})]});n.dn(s)},6019(e,t,n){"use strict";n.d(t,{Q:()=>i});var r=n(56427),s=n(78867),o=n(10790);const i=({variant:e="error"})=>{const t=(0,s.A)();return"muted"===e?(0,o.jsx)("span",{className:"jetpack-ai-fair-usage-notice-muted-variant",children:t}):"error"===e?(0,o.jsx)(r.Notice,{status:"error",isDismissible:!1,className:"jetpack-ai-fair-usage-notice",children:t}):null}},95933(e,t,n){"use strict";n.d(t,{x:()=>i});var r=n(56427),s=n(27723),o=n(10790);const __=s.__,i=({onCancel:e,onRetry:t})=>{const n=__("We are sorry. There was an error loading your Jetpack AI plan data. Please, try again.","jetpack"),s=__("We are sorry. There was an error loading your Jetpack AI plan data. Please, reload the page and try again.","jetpack");return(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper",children:[(0,o.jsx)("div",{className:"jetpack-ai-logo-generator-modal__notice-message",children:(0,o.jsx)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:t?n:s})}),(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-actions",children:[(0,o.jsx)(r.Button,{variant:"tertiary",onClick:e,children:__("Cancel","jetpack")}),t&&(0,o.jsx)(r.Button,{variant:"primary",onClick:t,children:__("Try again","jetpack")})]})]})}},76194(e,t,n){"use strict";n.d(t,{N:()=>i});var r=n(27723),s=n(42669),o=(n(55307),n(10790));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(0,o.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__loading-wrapper",children:[(0,o.jsx)(s.$,{}),(0,o.jsxs)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:["loadingFeature"===e&&t,"analyzing"===e&&n,"generating"===e&&r]})]})}},64537(e,t,n){"use strict";n.d(t,{T:()=>S});var r=n(85985),s=n(56427),o=n(47143),i=n(27723),a=n(13022),l=n(10067),c=n.n(l),u=n(51609),d=n(46381),p=n(61356),h=n(60674),m=n(88725),g=n(44461),f=n(19362),b=n(74423),v=n(95933),y=n(76194),k=n(32623),x=n(34706),_=n(11114),w=n(35421),j=n(48204),C=(n(68294),n(10790));const __=i.__,A=c()("jetpack-ai-calypso:generator-modal"),S=({isOpen:e,onClose:t,onApplyLogo:n,onReload:i=null,siteDetails:l,context:c,placement:S})=>{const{tracks:E}=(0,r.st)(),{recordEvent:T}=E,{setSiteDetails:N,fetchAiAssistantFeature:P,loadLogoHistory:B,setIsLoadingHistory:R}=(0,o.useDispatch)(b.E),{getIsRequestingAiAssistantFeature:I}=(0,o.select)(b.E),[D,L]=(0,u.useState)(null),[F,M]=(0,u.useState)(),O=(0,u.useRef)(!0),U=(0,u.useRef)(!1),[z,$]=(0,u.useState)(!1),[q,H]=(0,u.useState)(!1),{selectedLogo:V,getAiAssistantFeature:G,generateFirstPrompt:W,generateLogo:Z,setContext:J,tierPlansEnabled:K,site:Y,requireUpgrade:Q}=(0,m.A)(),{featureFetchError:X,setFeatureFetchError:ee,firstLogoPromptFetchError:te,clearErrors:ne}=(0,g.A)(),re=l?.ID,[se,oe]=(0,u.useState)(!1),{nextTierCheckoutURL:ie}=(0,h.Q)(),ae=G(),le=(0,u.useCallback)(async()=>{try{L("analyzing"),T(p.vm,{context:c,tool:"first-prompt"});const e=await W();M(e),L("generating"),await Z({prompt:e,style:"none"}),L(null)}catch(e){A("Error generating first logo",e),L(null)}},[c,W,Z]),ce=(0,u.useCallback)(async()=>{try{if(!re)throw new Error("Site ID is missing");if(!ae?.featuresControl?.["logo-generator"]?.enabled)throw ee("Failed to fetch feature data"),new Error("Failed to fetch feature data");const e=!(0,f.NP)(String(re)),t=ae?.costs?.["jetpack-ai-logo-generator"]?.logo??p._S,n=1,r=ae?.currentTier?.limit||0,s=ae?.currentTier?.value||0,o=ae?.usagePeriod?.requestsCount||0,i=!(K?1===s:s>0)&&!!ae?.nextTier&&!e&&(K?r-o{J(c),T(p.iz,{context:c,placement:S}),ce()},[J,c,S,ce]),de=()=>{O.current=!0,t(),L(null),$(!1),H(!1),ne(),oe(!1),R(!1),T(p.ub,{context:c,placement:S})},pe=(0,u.useCallback)(()=>{i&&(de(),U.current=!1,i())},[i,de]),he=e=>{oe(!0),n?.(e)},me=()=>{T(p.$i,{context:c})};let ge;return(0,u.useEffect)(()=>{if(re&&N(l),!U.current){I()||(U.current=!0,P())}},[re,l,N,I]),(0,u.useEffect)(()=>{e&&O.current&&(O.current=!1,ue())},[e,ue]),ge=D?(0,C.jsx)(y.N,{state:D}):X||te?(0,C.jsx)(v.x,{onCancel:de,onRetry:i?pe:null}):z||q?(0,C.jsx)(w.R,{onCancel:de,upgradeURL:ie,reason:z?"feature":"requests"}):(0,C.jsxs)(C.Fragment,{children:[!se&&(0,C.jsx)(_.X,{initialPrompt:F}),(0,C.jsx)(x.s,{logo:V,onApplyLogo:he,logoAccepted:se,siteId:String(re)}),se?(0,C.jsxs)("div",{className:"jetpack-ai-logo-generator__accept",children:[(0,C.jsx)(j.H,{}),(0,C.jsx)("div",{className:"jetpack-ai-logo-generator__accept-actions",children:(0,C.jsx)(s.Button,{variant:"primary",onClick:de,children:__("Close","jetpack")})})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(k.N,{}),(0,C.jsx)("div",{className:"jetpack-ai-logo-generator__footer",children:(0,C.jsx)(d.A,{onFeedbackClick:me})})]})]}),(0,C.jsx)(C.Fragment,{children:e&&(0,C.jsx)(s.Modal,{className:"jetpack-ai-logo-generator-modal",onRequestClose:de,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,title:__("Jetpack AI Logo Generator","jetpack"),children:(0,C.jsx)("div",{className:(0,a.A)("jetpack-ai-logo-generator-modal__body",{"notice-modal":z||q||X||te}),children:ge})})})}},32623(e,t,n){"use strict";n.d(t,{N:()=>u});var r=n(85985),s=n(56427),o=n(13022),i=n(26076),a=n(61356),l=n(88725),c=(n(29900),n(10790));const u=()=>{const{tracks:e}=(0,r.st)(),{recordEvent:t}=e,{logos:n,selectedLogo:u,setSelectedLogoIndex:d,context:p,isLoadingHistory:h}=(0,l.A)(),m=e=>{const t=new URL(e);return t.searchParams.has("resize")||t.searchParams.append("resize","48,48"),t.toString()};return(0,c.jsxs)("div",{className:"jetpack-ai-logo-generator__carousel",children:[!n.length&&h&&(0,c.jsx)(s.Button,{disabled:!0,className:(0,o.A)("jetpack-ai-logo-generator__carousel-logo"),children:(0,c.jsx)("img",{height:"48",width:"48",src:i,alt:"loading"})}),!n.length&&!h&&(0,c.jsx)("div",{children:" "}),n.map((e,r)=>(0,c.jsx)(s.Button,{className:(0,o.A)("jetpack-ai-logo-generator__carousel-logo",{"is-selected":e.url===u.url}),onClick:()=>(e=>{t(a.Nt,{context:p,logos_count:n.length,selected_logo:e+1}),d(e)})(r),children:(0,c.jsx)("img",{src:m(e.url),alt:e.description})},e.url))]})}},42669(e,t,n){"use strict";n.d(t,{$:()=>i});var r=n(13022),s=n(26076),o=n(10790);const i=({className:e=null})=>(0,o.jsx)("img",{src:s,alt:"Loading",className:(0,r.A)("jetpack-ai-logo-generator-modal__loader",e)})},34706(e,t,n){"use strict";n.d(t,{s:()=>T});var r=n(85985),s=n(56427),o=n(47143),i=n(27723),a=n(10067),l=n.n(a),c=n(11497),u=n(11574),d=n(70002),p=n(97034),h=n(61356),m=n(88725),g=n(44461),f=n(19362),b=n(74423),v=n(42669),y=(n(8243),n(10790));const __=i.__,_x=i._x,k=l()("jetpack-ai-calypso:logo-presenter"),x=({siteId:e})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,{saveLogo:i,selectedLogo:a,isSavingLogoToLibrary:l,logos:c,selectedLogoIndex:d,context:g}=(0,m.A)(),v=!!a?.mediaId,{loadLogoHistory:x}=(0,o.useDispatch)(b.E),_=_x("Saving…","Logo save button","jetpack"),w=__("Saved","jetpack");return l||v?(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",children:[(0,y.jsx)(s.Icon,{icon:l?(0,y.jsx)(p.A,{}):(0,y.jsx)(u.A,{})}),(0,y.jsx)("span",{className:"action-text",children:l?_:w})]}):(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{if(!v&&!l){n(h.h4,{context:g,logos_count:c.length,selected_logo:d?d+1:0});try{const t=await i(a);(0,f.H)({siteId:e,url:a.url,newUrl:t.mediaURL,mediaId:t.mediaId}),x(e)}catch(e){k("Error saving logo",e)}}},children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(p.A,{})}),(0,y.jsx)("span",{className:"action-text",children:__("Save in Library","jetpack")})]})},_=({onApplyLogo:e})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,{isSavingLogoToLibrary:o,selectedLogo:i,logos:a,selectedLogoIndex:l,context:c}=(0,m.A)();return(0,y.jsxs)(s.Button,{className:"jetpack-ai-logo-generator-modal-presenter__action",onClick:async()=>{o||(n(h.Zb,{context:c,logos_count:a.length,selected_logo:null!=l?l+1:0}),e?.(i?.mediaId))},disabled:o||!i?.mediaId,variant:"secondary",children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(d.A,{})}),(0,y.jsx)("span",{className:"action-text",children:__("Use on block","jetpack")})]})},w=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.$,{className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Generating new logo…","jetpack")})]}),j=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v.$,{className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Fetching previous logos…","jetpack")})]}),C=()=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{width:0,height:"229px"}}),(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__loading-text",children:__("Once you generate a logo, it will show up here","jetpack")})]}),A=({disabled:e,ratedItem:t,onRate:n})=>{const{logos:r,selectedLogo:s}=(0,m.A)(),o=r.filter(e=>e.rating).reduce((e,t)=>(e[t.url]=t.rating,e),{});return(0,y.jsx)(c.A,{disabled:e,ratedItem:t,feature:"logo-generator",savedRatings:o,options:{mediaLibraryId:s.mediaId,prompt:s.description},onRate:n})},S=({siteId:e,logo:t,onApplyLogo:n})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("img",{src:t.url,alt:t.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__action-wrapper",children:[(0,y.jsx)("span",{className:"jetpack-ai-logo-generator-modal-presenter__description",children:t.description}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__actions",children:[(0,y.jsx)(x,{siteId:e}),(0,y.jsx)(_,{onApplyLogo:n}),(0,y.jsx)(A,{ratedItem:t.url,disabled:!1,onRate:n=>{(0,f.H)({siteId:e,url:t.url,newUrl:t.url,mediaId:t.mediaId,rating:n})}})]})]})]}),E=({logo:e})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("img",{src:e.url,alt:e.description,className:"jetpack-ai-logo-generator-modal-presenter__logo"}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__success-wrapper",children:[(0,y.jsx)(s.Icon,{icon:(0,y.jsx)(u.A,{})}),(0,y.jsx)("span",{children:__("Your new logo was set to the block!","jetpack")})]})]}),T=({logo:e=null,loading:t=!1,onApplyLogo:n,logoAccepted:r=!1,siteId:s})=>{const{isRequestingImage:o}=(0,m.A)(),{saveToLibraryError:i,logoUpdateError:a}=(0,g.A)();let l;return e||o?e?l=t||o?(0,y.jsx)(w,{}):r?(0,y.jsx)(E,{logo:e}):(0,y.jsx)(S,{siteId:String(s),logo:e,onApplyLogo:n}):(k("No logo provided, history still loading or logo being generated"),l=(0,y.jsx)(j,{})):l=(0,y.jsx)(C,{}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter__wrapper",children:[(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-presenter",children:[(0,y.jsx)("div",{className:"jetpack-ai-logo-generator-modal-presenter__content",children:l}),!r&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator-modal-presenter__rectangle"})]}),i&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error saving the logo to your library. Please try again.","jetpack")}),a&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error applying the logo to your site. Please try again.","jetpack")})]})}},11114(e,t,n){"use strict";n.d(t,{X:()=>_});var r=n(85985),s=n(56427),o=n(27723),i=n(13109),a=n(28847),l=n(10067),c=n.n(l),u=n(51609),d=n(66223),p=n(21902),h=n(61356),m=n(60674),g=n(88725),f=n(44461),b=n(6019),v=n(64024),y=(n(76391),n(10790));const __=o.__,k=c()("jetpack-ai-calypso:prompt-box"),x=({prompt:e="",setPrompt:t=()=>{},disabled:n=!1,actionDisabled:r=!1,generateHandler:o=()=>{},placeholder:i="",buttonLabel:a=""})=>{const l=(0,u.useRef)(null);(0,u.useEffect)(()=>{l.current&&l.current.textContent!==e&&(l.current.textContent=e)},[e]);return(0,y.jsxs)("div",{className:"jetpack-ai-image-generator__prompt-query",children:[(0,y.jsx)("div",{role:"textbox",tabIndex:0,ref:l,contentEditable:!n,suppressContentEditableWarning:!0,className:"prompt-query__input",onInput:e=>{t(e.target.textContent||"")},onPaste:e=>{e.preventDefault();const n=e.currentTarget.ownerDocument.getSelection();if(!n||!n.rangeCount)return;const r=e.clipboardData.getData("text/plain");n.deleteFromDocument();n.getRangeAt(0).insertNode(document.createTextNode(r)),n.collapseToEnd(),t(l.current?.textContent||"")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),o()),e.stopPropagation()},onKeyUp:()=>{""===l.current?.textContent&&(l.current.innerHTML="")},"data-placeholder":i}),(0,y.jsx)(s.Button,{variant:"primary",className:"jetpack-ai-image-generator__prompt-submit",onClick:o,disabled:r,children:a||__("Generate","jetpack")})]})},_=({initialPrompt:e=""})=>{const{tracks:t}=(0,r.st)(),{recordEvent:n}=t,[l,c]=(0,u.useState)(e),[_,w]=(0,u.useState)(0),{enhancePromptFetchError:j,logoFetchError:C}=(0,f.A)(),{nextTierCheckoutURL:A,hasNextTier:S}=(0,m.Q)(),E=l?.length>=h.N3,[T,N]=(0,u.useState)(!1),[P,B]=(0,u.useState)(null),[R,I]=(0,u.useState)([]),{generateLogo:D,enhancePrompt:L,setIsEnhancingPrompt:F,isBusy:M,isEnhancingPrompt:O,site:U,getAiAssistantFeature:z,requireUpgrade:$,context:q,tierPlansEnabled:H,imageStyles:V,guessStyle:G}=(0,g.A)(),W=__("Enhancing…","jetpack"),Z=__("Enhance prompt","jetpack"),J=O?W:Z,K=(0,u.useRef)(null),Y=(0,u.useCallback)(async()=>{k("Enhancing prompt",l),F(!0),n(h.vm,{context:q,tool:"enhance-prompt"});try{const e=await L({prompt:l});c(e),F(!1)}catch(e){k("Error enhancing prompt",e),F(!1)}},[q,L,l,F]),Q=z(String(U?.id||"")),X=Q?.currentTier?.value||0,ee=Q?.usagePeriod?.requestsCount||0,te=1===X;(0,u.useEffect)(()=>{w(X-ee<=0?0:X-ee)},[X,ee]),(0,u.useEffect)(()=>{K.current&&K.current.textContent!==l&&(K.current.textContent=l)},[l]),(0,u.useEffect)(()=>{V&&V.length>0?(I([V.find(({value:e})=>e===d.Hu),V.find(({value:e})=>e===d.Wp),...V.filter(({value:e})=>![d.Hu,d.Wp].includes(e))].filter(e=>e)),N(!0),B(d.Hu)):(I([]),N(!1),B(null))},[V]);const ne=(0,u.useCallback)(async()=>{if(k(q),P===d.Wp){F(!0),n(h.Tk,{context:q,tool:"image"});const e=await G(l)||d.Hu;B(e),n(h.vm,{context:q,tool:"image",style:e}),F(!1),D({prompt:l,style:e})}else n(h.vm,{context:q,tool:"image",style:P}),D({prompt:l,style:P})},[q,D,l,P]),re=(0,u.useCallback)(e=>{k("change style",e),B(e),n(h.UO,{context:q,style:e})},[q,B,n]);return(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt",children:[(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-header",children:[(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-label",children:__("Describe your site:","jetpack")}),(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-actions",children:(0,y.jsxs)(s.Button,{variant:"link",disabled:M||$||!E,onClick:Y,children:[(0,y.jsx)(p.A,{}),J]})}),T&&(0,y.jsx)(s.SelectControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,value:P,options:R,onChange:re,disabled:M||$})]}),(0,y.jsx)(x,{prompt:l,setPrompt:c,generateHandler:ne,disabled:M||$,actionDisabled:M||$||!E,placeholder:__("Describe your site or simply ask for a logo specifying some details about it","jetpack")}),(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-footer",children:[!te&&!$&&(0,y.jsxs)("div",{className:"jetpack-ai-logo-generator__prompt-requests",children:[(0,y.jsx)("div",{children:(0,o.sprintf)( // translators: %d is the number of requests __("%d requests remaining.","jetpack"),_)}),S&&(0,y.jsxs)(y.Fragment,{children:[" ",(0,y.jsx)(s.Button,{variant:"link",href:A,target:"_blank",onClick:()=>{n(h.AN,{context:q,placement:h.Cn})},children:(0,y.jsx)("span",{children:__("Upgrade","jetpack")})})]})," ",(0,y.jsx)(s.Tooltip,{text:__("Logo generation costs 10 requests; prompt enhancement costs 1 request each","jetpack"),placement:"bottom",children:(0,y.jsx)(i.A,{className:"prompt-footer__icon",icon:a.A})})]}),$&&H&&(0,y.jsx)(v.G,{}),$&&!H&&(0,y.jsx)(b.Q,{}),j&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error enhancing prompt. Please try again.","jetpack")}),C&&(0,y.jsx)("div",{className:"jetpack-ai-logo-generator__prompt-error",children:__("Error generating logo. Please try again.","jetpack")})]})]})}},64024(e,t,n){"use strict";n.d(t,{G:()=>h});var r=n(85985),s=n(56427),o=n(86087),i=n(27723),a=n(13109),l=n(84699),c=n(61356),u=n(60674),d=n(88725),p=(n(94089),n(10790));const __=i.__,h=()=>{const{tracks:e}=(0,r.st)(),{recordEvent:t}=e,n=__("Upgrade","jetpack"),i=(0,o.createInterpolateElement)(__("Not enough requests left to generate a logo. Upgrade now to increase it.","jetpack"),{strong:(0,p.jsx)("strong",{})}),{nextTierCheckoutURL:h}=(0,u.Q)(),{context:m}=(0,d.A)();return(0,p.jsx)("div",{className:"jetpack-upgrade-plan-banner",children:(0,p.jsxs)("div",{className:"jetpack-upgrade-plan-banner__wrapper",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)(a.A,{className:"jetpack-upgrade-plan-banner__icon",icon:l.A}),(0,p.jsx)("span",{className:"jetpack-upgrade-plan-banner__banner-description",children:i})]}),(0,p.jsx)(s.Button,{href:h,target:"_blank",className:"is-primary",onClick:()=>{t(c.AN,{context:m,placement:c.tF})},children:(0,p.jsx)("span",{children:n})})]})})}},35421(e,t,n){"use strict";n.d(t,{R:()=>u});var r=n(3924),s=n(85985),o=n(56427),i=n(27723),a=n(61356),l=n(88725),c=n(10790);const __=i.__,u=({onCancel:e,upgradeURL:t,reason:n})=>{const{tracks:i}=(0,s.st)(),{recordEvent:u}=i,d=__("Upgrade your Jetpack AI for access to logo generation. This upgrade will also increase the amount of monthly requests you can use in for all AI-powered features.","jetpack"),p=__("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"),h=(0,r.A)("ai-logo-generator-fair-usage-policy",{anchor:"usage-limitations-and-upgrades"}),{context:m}=(0,l.A)();return(0,c.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message-wrapper",children:[(0,c.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-message",children:[(0,c.jsx)("span",{className:"jetpack-ai-logo-generator-modal__loading-message",children:"feature"===n?d:p})," ",(0,c.jsx)(o.Button,{variant:"link",href:h,target:"_blank",children:(0,c.jsx)("span",{children:__("Learn more about Jetpack AI.","jetpack")})})]}),(0,c.jsxs)("div",{className:"jetpack-ai-logo-generator-modal__notice-actions",children:[(0,c.jsx)(o.Button,{variant:"tertiary",onClick:e,children:(0,c.jsx)("span",{children:__("Cancel","jetpack")})}),(0,c.jsx)(o.Button,{variant:"primary",href:t,target:"_blank",onClick:()=>{u(a.AN,{context:m,placement:a.Tz}),e()},children:(0,c.jsx)("span",{children:__("Upgrade","jetpack")})})]})]})}},48204(e,t,n){"use strict";n.d(t,{H:()=>c});var r=n(56427),s=n(27723),o=n(1866),i=n(13022),a=n(36791),l=(n(39769),n(10790));const __=s.__,c=({className:e=null,onVisitBlankTarget:t})=>(0,l.jsxs)("div",{className:(0,i.A)("jetpack-ai-logo-generator-modal-visit-site-banner",e),children:[(0,l.jsx)("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__jetpack-logo",children:(0,l.jsx)("img",{src:a,alt:"Jetpack"})}),(0,l.jsxs)("div",{className:"jetpack-ai-logo-generator-modal-visit-site-banner__content",children:[(0,l.jsx)("strong",{children:__("Do you want to know all the amazing things you can do with Jetpack AI?","jetpack")}),(0,l.jsx)("span",{children:__("Generate and tweak content, create forms, get feedback and much more.","jetpack")}),(0,l.jsx)("div",{children:(0,l.jsxs)(r.Button,{variant:"link",href:"https://jetpack.com/redirect/?source=logo_generator_learn_more_about_jetpack_ai",target:"_blank",onClick:t||null,children:[(0,l.jsx)("span",{children:__("Learn more about Jetpack AI","jetpack")}),(0,l.jsx)(r.Icon,{icon:o.A,size:20})]})})]})]})},61356(e,t,n){"use strict";n.d(t,{$i:()=>c,AN:()=>u,Cn:()=>h,N3:()=>f,Nt:()=>l,Tk:()=>p,Tz:()=>m,UO:()=>d,Zb:()=>a,_S:()=>b,h4:()=>i,iz:()=>r,tF:()=>g,ub:()=>s,vm:()=>o});const r="jetpack_ai_logo_generator_modal_open",s="jetpack_ai_logo_generator_modal_close",o="jetpack_ai_logo_generator_generate",i="jetpack_ai_logo_generator_save",a="jetpack_ai_logo_generator_use",l="jetpack_ai_logo_generator_navigate",c="jetpack_ai_logo_generator_feedback",u="jetpack_ai_upgrade_button",d="jetpack_ai_logo_generator_switch_style",p="jetpack_ai_logo_generator_guess_style",h="input_footer",m="free_user_screen",g="upgrade_prompt",f=3,b=10},60674(e,t,n){"use strict";n.d(t,{Q:()=>a});var r=n(97999),s=n(85985),o=n(47143),i=n(74423);const a=()=>{const{nextTier:e,tierPlansEnabled:t}=(0,o.useSelect)(e=>{const t=e(i.E);return{nextTier:t.getAiAssistantFeature().nextTier,tierPlansEnabled:t.getAiAssistantFeature().tierPlansEnabled}},[]),n=!(0,r.isWpcomPlatformSite)(),a=n?"jetpack-ai-upgrade-url-for-jetpack-sites":"jetpack-ai-yearly-tier-upgrade-nudge",l=(0,s.GE)(),c=`https://wordpress.com/home/${l}`,u=new URL("https://jetpack.com/redirect/");u.searchParams.set("source",a),u.searchParams.set("site",l),u.searchParams.set("path",t?`jetpack_ai_yearly:-q-${e?.limit}`:"jetpack_ai_yearly"),n||u.searchParams.set("query",`redirect_to=${encodeURIComponent(c)}`);return{nextTierCheckoutURL:u.toString(),hasNextTier:!!e}}},78867(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(3924),s=n(47143),o=n(86087),i=n(27723),a=n(74423),l=n(10790);const __=i.__,c=()=>{const{usagePeriod:e}=(0,s.useSelect)(e=>({usagePeriod:e(a.E).getAiAssistantFeature().nextTier}),[]),t=(e=>{const t=__("You've reached this month's request limit, per our fair usage policy.","jetpack");if(!e)return t; // Translators: %s is the date when the requests will reset. const n=__("Requests will reset on %s.","jetpack");return`${t} ${(0,i.sprintf)(n,e)}`})((e=>{if(!e?.nextStart)return null;const t=new Date(e.nextStart);return t.toLocaleString("default",{month:"long"})+" "+t.getDate()})(e)),n=(0,r.A)("ai-logo-generator-fair-usage-policy",{anchor:"jetpack-ai-usage-limit"});return(0,o.createInterpolateElement)(t,{link:(0,l.jsx)("a",{href:n,target:"_blank",rel:"noreferrer"}),span:(0,l.jsx)("span",{})})}},88725(e,t,n){"use strict";n.d(t,{A:()=>f});var r=n(47143),s=n(10067),o=n.n(s),i=n(51609),a=n(31439),l=n(62614),c=n(93869),u=n(51391),d=n(19362),p=n(28229),h=n(74423),m=n(44461);const g=o()("jetpack-ai-calypso:use-logo-generator"),f=()=>{const{setSelectedLogoIndex:e,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setIsRequestingImage:s,setIsEnhancingPrompt:o,increaseAiAssistantRequestsCount:f,addLogoToHistory:b,setContext:v,setIsLoadingHistory:y}=(0,r.useDispatch)(h.E),{logos:k,selectedLogoIndex:x,selectedLogo:_,siteDetails:w,isSavingLogoToLibrary:j,isApplyingLogo:C,isEnhancingPrompt:A,isBusy:S,isRequestingImage:E,getAiAssistantFeature:T,requireUpgrade:N,context:P,tierPlansEnabled:B,isLoadingHistory:R}=(0,r.useSelect)(e=>{const t=e(h.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(),tierPlansEnabled:t.getTierPlansEnabled(),isLoadingHistory:t.getIsLoadingHistory()}},[]),{setFirstLogoPromptFetchError:I,setEnhancePromptFetchError:D,setLogoFetchError:L,setSaveToLibraryError:F,setLogoUpdateError:M}=(0,m.A)(),{generateImageWithParameters:O}=(0,l.Ay)(),{saveToMediaLibrary:U}=(0,c.A)(),{ID:z=null,name:$=null,description:q=null}=w||{},H=z?String(z):null,V=T(H),G=V?.costs?.["jetpack-ai-logo-generator"]?.logo,W=V?.featuresControl?.["logo-generator"],Z=W?.styles||[],J=(0,i.useCallback)(async function(){I(null),f();try{const e=await(0,u.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: ${$}\nSite description: ${q}`,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"},s=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(t)}).then(e=>e.json());return s?.choices?.[0]?.message?.content}catch(e){throw f(-1),I(e),e}},[I,f,$,q]),K=(0,i.useCallback)(async function(e){if(L(null),!Z||!Z.length)return null;const t=[{role:"jetpack-ai",context:{type:"ai-assistant-guess-logo-style",request:e,name:$,description:q}}];try{const e=await(0,a.A)(t,{feature:"jetpack-ai-logo-generator"});if(!e)return null;const n=Z.find(({value:t})=>t===e);return n?n.value:null}catch(e){g("Error guessing style",e),Promise.reject(e)}},[Z,$,q]),Y=(0,i.useCallback)(async function({prompt:e,style:t=null}){L(null);try{const n=await(0,u.A)();if(!n||!n.token)throw new Error("No token provided");if("auto"===t)throw new Error("Auto style is not supported");g("Generating image with prompt",e);const r={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}`,messages:t?[{role:"jetpack-ai",context:{type:"ai-assistant-generate-logo",request:e,name:$,description:q,style:t}}]:[],feature:"jetpack-ai-logo-generator",response_format:"b64_json",style:t||""};return await O(r)}catch(e){throw L(e),e}},[$,q]),Q=(0,i.useCallback)(async e=>{F(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:s}=await U(e.url,"site-logo.png");return n.mediaId=parseInt(r),n.mediaURL=s,n}catch(e){throw F(e),e}finally{t(!1)}},[t,F]),X=(0,i.useCallback)(async()=>{M(null);try{if(!H||!_)throw new Error("Missing siteId or logo");g("Applying logo for site",H),n(!0);const{mediaId:e}=_;if(!e)throw new Error("Missing mediaId");await(0,p.Z)({siteId:H,imageId:String(e)})}catch(e){throw M(e),e}finally{n(!1)}},[_,n,M,H]),ee=(0,i.useCallback)(e=>{b(e),(0,d.hm)({...e,siteId:String(H)})},[H,b,d.hm]),te=(0,i.useCallback)(async function({prompt:e,style:t}){g("Generating logo for site"),s(!0);try{if(!G)throw new Error("Missing cost information");let n;f(G);try{if(n=await Y({prompt:e,style:t}),!n||!n.data.length)throw new Error("No image returned")}catch(e){throw f(-G),e}const r=n.data[0].revised_prompt||null,s={url:"data:image/png;base64,"+n.data[0].b64_json,description:e,revisedPrompt:r};try{const t=await Q(s);ee({url:t.mediaURL,description:e,mediaId:t.mediaId,revisedPrompt:r})}catch(e){throw ee(s),e}}finally{s(!1)}},[G,f,Q,ee,Y]);return{logos:k,selectedLogoIndex:x,selectedLogo:_,setSelectedLogoIndex:e,site:{id:H,name:$,description:q},generateFirstPrompt:J,saveLogo:Q,applyLogo:X,generateImage:Y,enhancePrompt:async function({prompt:e}){D(null),f();try{const t=await(0,u.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",s={Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},o=await fetch(r,{method:"POST",headers:s,body:JSON.stringify(n)}).then(e=>e.json());return o?.choices?.[0]?.message?.content}catch(e){throw f(-1),D(e),e}},storeLogo:ee,generateLogo:te,setIsEnhancingPrompt:o,setIsRequestingImage:s,setIsSavingLogoToLibrary:t,setIsApplyingLogo:n,setContext:v,isEnhancingPrompt:A,isRequestingImage:E,isSavingLogoToLibrary:j,isApplyingLogo:C,isBusy:S,getAiAssistantFeature:T,requireUpgrade:N,context:P,tierPlansEnabled:B,isLoadingHistory:R,setIsLoadingHistory:y,imageStyles:Z,guessStyle:K}}},44461(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(47143),s=n(74423);const o=()=>{const{setFeatureFetchError:e,setFirstLogoPromptFetchError:t,setEnhancePromptFetchError:n,setLogoFetchError:o,setSaveToLibraryError:i,setLogoUpdateError:a}=(0,r.useDispatch)(s.E),{featureFetchError:l,firstLogoPromptFetchError:c,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:h}=(0,r.useSelect)(e=>{const t=e(s.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:o,setSaveToLibraryError:i,setLogoUpdateError:a,clearErrors:()=>{e(null),t(null),n(null),o(null),i(null),a(null)},featureFetchError:l,firstLogoPromptFetchError:c,enhancePromptFetchError:u,logoFetchError:d,saveToLibraryError:p,logoUpdateError:h}}},23101(e,t,n){"use strict";n.d(t,{T:()=>r.T});var r=n(64537);n(11114)},19362(e,t,n){"use strict";n.d(t,{$t:()=>i,H:()=>o,NP:()=>a,Pv:()=>l,hm:()=>s});var r=n(13858);function s({siteId:e,url:t,description:n,mediaId:r,revisedPrompt:s}){const o=i(e),a={url:t,description:n,mediaId:r,revisedPrompt:s};return o.push(a),localStorage.setItem(`logo-history-${e}`,JSON.stringify(o.slice(-10))),a}function o({siteId:e,url:t,newUrl:n,mediaId:r,rating:s}){const o=i(e),a=o.findIndex(e=>e.url===t);return a>-1&&(o[a].url=n,o[a].mediaId=r,o[a].rating=s),localStorage.setItem(`logo-history-${e}`,JSON.stringify(o.slice(-10))),o[a]}function i(e){const t=localStorage.getItem(`logo-history-${e}`);let n=t?JSON.parse(t):[];return Array.isArray(n)||(n=[]),n=n.slice(-10),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,rating:e.rating})),n}function a(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,s)=>{(0,r.T)({siteId:e,mediaId:t}).then(e=>n({mediaId:t,exists:e})).catch(e=>s(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{}}},13858(e,t,n){"use strict";n.d(t,{T:()=>s});var r=n(48931);async function s({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:()=>s});var r=n(22746);async function s({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);let s=0;async function o(e){if(s+=1,s>5)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:()=>a});var r=n(19362),s=n(22746),o=n(9938);const i={storeAiAssistantFeature:e=>({type:o.UU,feature:e}),fetchAiAssistantFeature:()=>async({dispatch:e})=>{e({type:o.ql});try{const t=await(0,s.A)({path:"/wpcom/v2/jetpack-ai/ai-assistant-feature",query:"force=wpcom"});if(t.data)throw new Error("Failed to fetch");e(i.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:o.Rx,error:t})}},increaseAiAssistantRequestsCount:(e=1)=>({dispatch:t})=>{t({type:o.Lg,count:e})},setAiAssistantFeatureRequireUpgrade:(e=!0)=>({type:o.Kt,requireUpgrade:e}),setTierPlansEnabled:(e=!0)=>({type:o.c1,tierPlansEnabled:e}),setSiteDetails:e=>({type:o.Bz,siteDetails:e}),setSelectedLogoIndex:e=>({type:o.BG,selectedLogoIndex:e}),addLogoToHistory:e=>({type:o.sG,logo:e}),setIsSavingLogoToLibrary:e=>({type:o.E6,isSavingLogoToLibrary:e}),setIsApplyingLogo:e=>({type:o.Ep,isApplyingLogo:e}),updateSelectedLogo:(e,t)=>({type:o.r_,mediaId:e,url:t}),setIsRequestingImage:e=>({type:o.vk,isRequestingImage:e}),setIsEnhancingPrompt:e=>({type:o.O5,isEnhancingPrompt:e}),loadLogoHistory(e){const t=(0,r.$t)(e);return{type:o.ZI,history:t}},setFeatureFetchError:e=>({type:o.Rx,error:e}),setFirstLogoPromptFetchError:e=>({type:o.MQ,error:e}),setEnhancePromptFetchError:e=>({type:o.gG,error:e}),setLogoFetchError:e=>({type:o.q_,error:e}),setSaveToLibraryError:e=>({type:o.x0,error:e}),setLogoUpdateError:e=>({type:o.FN,error:e}),setContext:e=>({type:o.kZ,context:e}),setIsLoadingHistory:e=>({type:o.hY,isLoadingHistory:e})},a=i},9938(e,t,n){"use strict";n.d(t,{BG:()=>h,Bz:()=>l,E6:()=>g,Ep:()=>f,FN:()=>S,GB:()=>c,Kt:()=>i,Lg:()=>o,MQ:()=>w,O5:()=>y,Rx:()=>_,UU:()=>r,ZI:()=>k,c1:()=>a,gG:()=>j,hY:()=>x,kZ:()=>p,mx:()=>d,nb:()=>u,q_:()=>C,ql:()=>s,r_:()=>b,sG:()=>m,vk:()=>v,x0:()=>A});const r="STORE_AI_ASSISTANT_FEATURE",s="REQUEST_AI_ASSISTANT_FEATURE",o="INCREASE_AI_ASSISTANT_REQUESTS_COUNT",i="SET_AI_ASSISTANT_FEATURE_REQUIRE_UPGRADE",a="SET_TIER_PLANS_ENABLED",l="SET_SITE_DETAILS",c=20,u=3e3,d=3,p="SET_CONTEXT",h="SET_SELECTED_LOGO_INDEX",m="ADD_LOGO_TO_HISTORY",g="SET_IS_SAVING_LOGO_TO_LIBRARY",f="SET_IS_APPLYING_LOGO",b="SAVE_SELECTED_LOGO",v="SET_IS_REQUESTING_IMAGE",y="SET_IS_ENHANCING_PROMPT",k="SET_SITE_HISTORY",x="SET_IS_LOADING_HISTORY",_="SET_FEATURE_FETCH_ERROR",w="SET_FIRST_LOGO_PROMPT_FETCH_ERROR",j="SET_ENHANCE_PROMPT_FETCH_ERROR",C="SET_LOGO_FETCH_ERROR",A="SET_SAVE_TO_LIBRARY_ERROR",S="SET_LOGO_UPDATE_ERROR"},74423(e,t,n){"use strict";n.d(t,{E:()=>a});var r=n(47143),s=n(9624),o=n(23695),i=n(80037);const a="jetpack-ai/logo-generator",l=(0,r.createReduxStore)(a,{__experimentalUseThunks:!0,actions:s.A,reducer:o.A,selectors:i.A});(0,r.register)(l)},94891(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(9938);const s={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},featuresControl:{"logo-generator":{enabled:!1,styles:[]}}}},history:[],selectedLogoIndex:0}},23695(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(61356),s=n(9938),o=n(94891);function i(e=o.A,t){switch(t.type){case s.ql:return{...e,_meta:{...e._meta??{},featureFetchError:null},features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!0,asyncRequestCountdown:s.mx,asyncRequestTimerId:0}}}};case s.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 s.Lg:{const n=e?.features?.aiAssistantFeature?.usagePeriod||{requestsCount:0},r=(e?.features?.aiAssistantFeature?.requestsCount||0)+(t.count??1);n.requestsCount+=t.count??1;const o=e?.features?.aiAssistantFeature?.currentTier?.value,i=void 0===o&&!e?.features?.aiAssistantFeature?.hasFeature||0===o,a=void 0===o&&e?.features?.aiAssistantFeature?.hasFeature||1===o;let l=e?.features?.aiAssistantFeature?.currentTier?.limit||s.GB;a?l=s.nb:i&&(l=e?.features?.aiAssistantFeature?.requestsLimit);const c=(a||i?r:e?.features?.aiAssistantFeature?.usagePeriod?.requestsCount||0)>=l,u=i||c&&null!==e?.features?.aiAssistantFeature?.nextTier;return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,isOverLimit:c,requestsCount:r,requireUpgrade:u,usagePeriod:{...n}}}}}case s.Kt:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,requireUpgrade:t.requireUpgrade,...t.requireUpgrade?{isOverLimit:!0}:{}}}};case s.c1:return{...e,features:{...e.features,aiAssistantFeature:{...e.features.aiAssistantFeature,tierPlansEnabled:t.tierPlansEnabled}}};case s.Bz:return{...e,siteDetails:t.siteDetails};case s.BG:return{...e,selectedLogoIndex:t.selectedLogoIndex};case s.sG:{const n=[...e.history,t.logo];return{...e,history:n,selectedLogoIndex:n.length-1}}case s.E6:return{...e,_meta:{...e._meta??{},isSavingLogoToLibrary:t.isSavingLogoToLibrary}};case s.Ep:return{...e,_meta:{...e._meta??{},isApplyingLogo:t.isApplyingLogo}};case s.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 s.vk:return{...e,_meta:{...e._meta??{},isRequestingImage:t.isRequestingImage}};case s.O5:return{...e,_meta:{...e._meta??{},isEnhancingPrompt:t.isEnhancingPrompt}};case s.ZI:return{...e,history:t.history,selectedLogoIndex:t.history?.length?t.history.length-1:0};case s.Rx:return{...e,features:{...e.features,aiAssistantFeature:{...e?.features?.aiAssistantFeature,_meta:{...e?.features?.aiAssistantFeature?._meta,isRequesting:!1}}},_meta:{...e._meta??{},featureFetchError:t.error}};case s.MQ:return{...e,_meta:{...e._meta??{},firstLogoPromptFetchError:t.error}};case s.gG:return{...e,_meta:{...e._meta??{},enhancePromptFetchError:t.error}};case s.q_:return{...e,_meta:{...e._meta??{},logoFetchError:t.error}};case s.x0:return{...e,_meta:{...e._meta??{},saveToLibraryError:t.error}};case s.FN:return{...e,_meta:{...e._meta??{},logoUpdateError:t.error}};case s.kZ:return{...e,_meta:{...e._meta??{},context:t.context}};case s.hY:return{...e,_meta:{...e._meta??{},isLoadingHistory:t.isLoadingHistory}}}return e}},80037(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(61356);const s={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=>s.getIsApplyingLogo(e)||s.getIsSavingLogoToLibrary(e)||s.getIsRequestingImage(e)||s.getIsEnhancingPrompt(e),getRequireUpgrade(e){const t=e.features.aiAssistantFeature;if(!t?.tierPlansEnabled)return t?.requireUpgrade;const n=t?.costs?.["jetpack-ai-logo-generator"]?.logo??r._S,s=t?.currentTier?.value||0,o=t?.usagePeriod?.requestsCount||0,i=1===s,a=!t?.nextTier;return e.features.aiAssistantFeature?.requireUpgrade||!i&&!a&&s-oe._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??"",getTierPlansEnabled:e=>e.features.aiAssistantFeature?.tierPlansEnabled??!1,getIsLoadingHistory:e=>e._meta?.isLoadingHistory??!1},o=s},53664(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(7675),s=n(10067),o=n.n(s),i=n(46219),a=n(51391),l=n(78836);const c=o()("jetpack-ai-client:suggestions-event-source");class u extends EventTarget{fullMessage;fullFunctionCall;isPromptClear;controller;errorUnclearPromptTriggered;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:s={}}){if(!n)try{c("Token was not provided, requesting one..."),n=(await(0,a.A)()).token}catch(e){return void this.processErrorEvent(e)}const o={};if(Number.isInteger(parseInt(s.postId))&&(o.post_id=+s.postId),!e){const t=new URL("https://public-api.wordpress.com/wpcom/v2/jetpack-ai-query");s?.fromCache&&t.searchParams.append("stream_cache","true"),e=t.toString(),c("URL not provided, using default: %o",e)}Array.isArray(t)?o.messages=t:o.question=t,s?.feature?.length&&(c("Feature: %o",s.feature),o.feature=s.feature),s?.functions?.length&&(c("Functions: %o",s.functions),o.functions=s.functions),s?.model?.length&&(c("Model: %o",s.model),o.model=s.model),s?.languageCode?.length&&(c("Language: %o",s.languageCode),o.language_code=s.languageCode),this.errorUnclearPromptTriggered=!1,await(0,r.y)(e,{openWhenHidden:!0,method:"POST",headers:{"Content-type":"application/json",Authorization:"Bearer "+n},body:JSON.stringify(o),onclose:()=>{c("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)&&(c("Connection error: %o",e),t=l.mA,this.dispatchEvent(new CustomEvent(l.mA,{detail:e}))),503===e.status&&(t=l.AZ,this.dispatchEvent(new CustomEvent(l.AZ))),413===e.status&&(t=l.cT,this.dispatchEvent(new CustomEvent(l.cT))),422===e.status&&(t=l.ud,this.dispatchEvent(new CustomEvent(l.ud))),429===e.status&&(t=l.Or,this.dispatchEvent(new CustomEvent(l.Or))),this.dispatchEvent(new CustomEvent(l.zn,{detail:(0,i.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(l.L9)),c("Unclear error prompt dispatched"),this.dispatchEvent(new CustomEvent(l.zn,{detail:(0,i.fC)(l.L9)}))}else"JETPACK_AI_ERROR".startsWith(e)?c(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 c("Done: %o",this.fullMessage);if(this.fullFunctionCall.name.length)return this.dispatchEvent(new CustomEvent("function_done",{detail:this.fullFunctionCall})),void c("Done: %o",this.fullFunctionCall)}let t;try{t=JSON.parse(e.data)}catch(t){return void c("Error parsing JSON",e,t)}const{delta:n}=t?.choices?.[0]??{delta:{content:null,function_call:null}},r=n.content,s=n.function_call;r&&(this.fullMessage+=r,this.checkForUnclearPrompt(),this.isPromptClear&&(this.dispatchEvent(new CustomEvent("chunk",{detail:r})),c("suggestion: %o",this.fullMessage),this.dispatchEvent(new CustomEvent("suggestion",{detail:this.fullMessage})))),s&&(null!=s.name&&(this.fullFunctionCall.name+=s.name),null!=s.arguments&&(this.fullFunctionCall.arguments+=s.arguments),this.dispatchEvent(new CustomEvent("functionCallChunk",{detail:this.fullFunctionCall})))}processErrorEvent(e){c("onerror: %o",e),this.dispatchEvent(new CustomEvent(l.mA,{detail:e})),this.dispatchEvent(new CustomEvent(l.zn,{detail:(0,i.fC)(l.mA)}))}}},78836(e,t,n){"use strict";n.d(t,{AZ:()=>s,L9:()=>c,Np:()=>d,Or:()=>o,cT:()=>a,mA:()=>l,uH:()=>r.u,ud:()=>i,zn:()=>u});var r=n(97784);const s="error_service_unavailable",o="error_quota_exceeded",i="error_moderation",a="error_context_too_large",l="error_network",c="error_unclear_prompt",u="error_response",d="default"},90372(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(10067);const s=n.n(r)()("dops:analytics");let o,i;window._tkq=window._tkq||[],window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=+new Date;const a={initialize:function(e,t,n){a.setUser(e,t),a.setSuperProps(n),a.identifyUser()},setGoogleAnalyticsEnabled:function(e,t=null){this.googleAnalyticsEnabled=e,this.googleAnalyticsKey=t},setMcAnalyticsEnabled:function(e){this.mcAnalyticsEnabled=e},setUser:function(e,t){i={ID:e,username:t}},setSuperProps:function(e){o=e},assignSuperProps:function(e){o=Object.assign(o||{},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]);s("Bumping stats %o",e)}else n="&x_"+encodeURIComponent(e)+"="+encodeURIComponent(t),s('Bumping stat "%s" in group "%s"',t,e);return n}(e,t);a.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]);s("Built stats %o",e)}else n="&"+encodeURIComponent(e)+"="+encodeURIComponent(t),s('Built stat "%s" in group "%s"',t,e);return n}(e,t);a.mcAnalyticsEnabled&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom"+n+"&t="+Math.random())}},pageView:{record:function(e,t){a.tracks.recordPageView(e),a.ga.recordPageView(e,t)}},purchase:{record:function(e,t,n,r,s,o,i){a.ga.recordPurchase(e,t,n,r,s,o,i)}},tracks:{recordEvent:function(e,t){t=t||{},0===e.indexOf("akismet_")||0===e.indexOf("jetpack_")?(!t.blog_id&&"object"==typeof window.jpTracksContext&&window.jpTracksContext.blog_id&&(t.blog_id=window.jpTracksContext.blog_id),o&&(s("- Super Props: %o",o),t=Object.assign(t,o)),s('Record event "%s" called with props %s',e,JSON.stringify(t)),window._tkq.push(["recordEvent",e,t])):s('- Event name must be prefixed by "akismet_" or "jetpack_"')},recordJetpackClick:function(e){const t="object"==typeof e?e:{target:e};a.tracks.recordEvent("jetpack_wpa_click",t)},recordPageView:function(e){a.tracks.recordEvent("akismet_page_view",{path:e})},setOptOut:function(e){s("Pushing setOptOut: %o",e),window._tkq.push(["setOptOut",e])}},ga:{initialized:!1,initialize:function(){let e={};a.ga.initialized||(i&&(e={userId:"u-"+i.ID}),window.ga("create",this.googleAnalyticsKey,"auto",e),a.ga.initialized=!0)},recordPageView:function(e,t){a.ga.initialize(),s("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){a.ga.initialize();let o="Recording Event ~ [Category: "+e+"] [Action: "+t+"]";void 0!==n&&(o+=" [Option Label: "+n+"]"),void 0!==r&&(o+=" [Option Value: "+r+"]"),s(o),this.googleAnalyticsEnabled&&window.ga("send","event",e,t,n,r)},recordPurchase:function(e,t,n,r,s,o,i){window.ga("require","ecommerce"),window.ga("ecommerce:addTransaction",{id:e,revenue:r,currency:i}),window.ga("ecommerce:addItem",{id:e,name:t,sku:n,price:s,quantity:o}),window.ga("ecommerce:send")}},identifyUser:function(){i&&window._tkq.push(["identifyUser",i.ID,i.username])},setProperties:function(e){window._tkq.push(["setProperties",e])},clearedIdentity:function(){window._tkq.push(["clearIdentity"])}},l=a},5932(e,t,n){"use strict";n.d(t,{Ay:()=>d});var r=n(56439),s=n(93832);function o(e){class t extends Error{constructor(...t){super(...t),this.name=e}}return t}const i=o("JsonParseError"),a=o("JsonParseAfterRedirectError"),l=o("Api404Error"),c=o("Api404AfterRedirectError"),u=o("FetchNetworkError");const d=new function(e,t){let n=e,o=e,i={"X-WP-Nonce":t},a={credentials:"same-origin",headers:i},l={method:"post",credentials:"same-origin",headers:Object.assign({},i,{"Content-type":"application/json"})},c=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){o=e},setApiNonce(e){i={"X-WP-Nonce":e},a={credentials:"same-origin",headers:i},l={method:"post",credentials:"same-origin",headers:Object.assign({},i,{"Content-type":"application/json"})}},setCacheBusterCallback:e=>{c=e},registerSite:(e,t,s)=>{const o={};return(0,r.jetpackConfigHas)("consumer_slug")&&(o.plugin_slug=(0,r.jetpackConfigGet)("consumer_slug")),null!==t&&(o.redirect_uri=t),s&&(o.from=s),m(`${n}jetpack/v4/connection/register`,l,{body:JSON.stringify(o)}).then(p).then(h)},fetchAuthorizationUrl:e=>d((0,s.addQueryArgs)(`${n}jetpack/v4/connection/authorize_url`,{no_iframe:"1",redirect_uri:e}),a).then(p).then(h),fetchSiteConnectionData:()=>d(`${n}jetpack/v4/connection/data`,a).then(h),fetchSiteConnectionStatus:()=>d(`${n}jetpack/v4/connection`,a).then(h),fetchSiteConnectionTest:()=>d(`${n}jetpack/v4/connection/test`,a).then(p).then(h),fetchUserConnectionData:()=>d(`${n}jetpack/v4/connection/data`,a).then(h),fetchUserTrackingSettings:()=>d(`${n}jetpack/v4/tracking/settings`,a).then(p).then(h),updateUserTrackingSettings:e=>m(`${n}jetpack/v4/tracking/settings`,l,{body:JSON.stringify(e)}).then(p).then(h),disconnectSite:()=>m(`${n}jetpack/v4/connection`,l,{body:JSON.stringify({isActive:!1})}).then(p).then(h),fetchConnectUrl:()=>d(`${n}jetpack/v4/connection/url`,a).then(p).then(h),unlinkUser:(e=!1,t={})=>{const r={linked:!1,force:!!e};return t.disconnectAllUsers&&(r["disconnect-all-users"]=!0),m(`${n}jetpack/v4/connection/user`,l,{body:JSON.stringify(r)}).then(p).then(h)},reconnect:()=>m(`${n}jetpack/v4/connection/reconnect`,l).then(p).then(h),fetchConnectedPlugins:()=>d(`${n}jetpack/v4/connection/plugins`,a).then(p).then(h),setHasSeenWCConnectionModal:()=>m(`${n}jetpack/v4/seen-wc-connection-modal`,l).then(p).then(h),fetchModules:()=>d(`${n}jetpack/v4/module/all`,a).then(p).then(h),fetchModule:e=>d(`${n}jetpack/v4/module/${e}`,a).then(p).then(h),activateModule:e=>m(`${n}jetpack/v4/module/${e}/active`,l,{body:JSON.stringify({active:!0})}).then(p).then(h),deactivateModule:e=>m(`${n}jetpack/v4/module/${e}/active`,l,{body:JSON.stringify({active:!1})}),updateModuleOptions:(e,t)=>m(`${n}jetpack/v4/module/${e}`,l,{body:JSON.stringify(t)}).then(p).then(h),updateSettings:e=>m(`${n}jetpack/v4/settings`,l,{body:JSON.stringify(e)}).then(p).then(h),getProtectCount:()=>d(`${n}jetpack/v4/module/protect/data`,a).then(p).then(h),resetOptions:e=>m(`${n}jetpack/v4/options/${e}`,l,{body:JSON.stringify({reset:!0})}).then(p).then(h),activateVaultPress:()=>m(`${n}jetpack/v4/plugins`,l,{body:JSON.stringify({slug:"vaultpress",status:"active"})}).then(p).then(h),getVaultPressData:()=>d(`${n}jetpack/v4/module/vaultpress/data`,a).then(p).then(h),installPlugin:(e,t)=>{const r={slug:e,status:"active"};return t&&(r.source=t),m(`${n}jetpack/v4/plugins`,l,{body:JSON.stringify(r)}).then(p).then(h)},activateAkismet:()=>m(`${n}jetpack/v4/plugins`,l,{body:JSON.stringify({slug:"akismet",status:"active"})}).then(p).then(h),getAkismetData:()=>d(`${n}jetpack/v4/module/akismet/data`,a).then(p).then(h),checkAkismetKey:()=>d(`${n}jetpack/v4/module/akismet/key/check`,a).then(p).then(h),checkAkismetKeyTyped:e=>m(`${n}jetpack/v4/module/akismet/key/check`,l,{body:JSON.stringify({api_key:e})}).then(p).then(h),getFeatureTypeStatus:e=>d(`${n}jetpack/v4/feature/${e}`,a).then(p).then(h),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),a).then(p).then(h).then(f),getPluginUpdates:()=>d(`${n}jetpack/v4/updates/plugins`,a).then(p).then(h),getPlans:()=>d(`${n}jetpack/v4/plans`,a).then(p).then(h),fetchSettings:()=>d(`${n}jetpack/v4/settings`,a).then(p).then(h),updateSetting:e=>m(`${n}jetpack/v4/settings`,l,{body:JSON.stringify(e)}).then(p).then(h),fetchSiteData:()=>d(`${n}jetpack/v4/site`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteFeatures:()=>d(`${n}jetpack/v4/site/features`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteProducts:()=>d(`${n}jetpack/v4/site/products`,a).then(p).then(h),fetchSitePurchases:()=>d(`${n}jetpack/v4/site/purchases`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteBenefits:()=>d(`${n}jetpack/v4/site/benefits`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchSiteDiscount:()=>d(`${n}jetpack/v4/site/discount`,a).then(p).then(h).then(e=>e.data),fetchSetupQuestionnaire:()=>d(`${n}jetpack/v4/setup/questionnaire`,a).then(p).then(h),fetchRecommendationsData:()=>d(`${n}jetpack/v4/recommendations/data`,a).then(p).then(h),fetchRecommendationsProductSuggestions:()=>d(`${n}jetpack/v4/recommendations/product-suggestions`,a).then(p).then(h),fetchRecommendationsUpsell:()=>d(`${n}jetpack/v4/recommendations/upsell`,a).then(p).then(h),fetchRecommendationsConditional:()=>d(`${n}jetpack/v4/recommendations/conditional`,a).then(p).then(h),saveRecommendationsData:e=>m(`${n}jetpack/v4/recommendations/data`,l,{body:JSON.stringify({data:e})}).then(p),fetchProducts:()=>d(`${n}jetpack/v4/products`,a).then(p).then(h),fetchRewindStatus:()=>d(`${n}jetpack/v4/rewind`,a).then(p).then(h).then(e=>JSON.parse(e.data)),fetchScanStatus:()=>d(`${n}jetpack/v4/scan`,a).then(p).then(h).then(e=>JSON.parse(e.data)),dismissJetpackNotice:e=>m(`${n}jetpack/v4/notice/${e}`,l,{body:JSON.stringify({dismissed:!0})}).then(p).then(h),fetchPluginsData:()=>d(`${n}jetpack/v4/plugins`,a).then(p).then(h),fetchIntroOffers:()=>d(`${n}jetpack/v4/intro-offers`,a).then(p).then(h),fetchVerifySiteGoogleStatus:e=>d(null!==e?`${n}jetpack/v4/verify-site/google/${e}`:`${n}jetpack/v4/verify-site/google`,a).then(p).then(h),verifySiteGoogle:e=>m(`${n}jetpack/v4/verify-site/google`,l,{body:JSON.stringify({keyring_id:e})}).then(p).then(h),submitSurvey:e=>m(`${n}jetpack/v4/marketing/survey`,l,{body:JSON.stringify(e)}).then(p).then(h),saveSetupQuestionnaire:e=>m(`${n}jetpack/v4/setup/questionnaire`,l,{body:JSON.stringify(e)}).then(p).then(h),updateLicensingError:e=>m(`${n}jetpack/v4/licensing/error`,l,{body:JSON.stringify(e)}).then(p).then(h),updateLicenseKey:e=>m(`${n}jetpack/v4/licensing/set-license`,l,{body:JSON.stringify({license:e})}).then(p).then(h),getUserLicensesCounts:()=>d(`${n}jetpack/v4/licensing/user/counts`,a).then(p).then(h),getUserLicenses:()=>d(`${n}jetpack/v4/licensing/user/licenses`,a).then(p).then(h),updateLicensingActivationNoticeDismiss:e=>m(`${n}jetpack/v4/licensing/user/activation-notice-dismiss`,l,{body:JSON.stringify({last_detached_count:e})}).then(p).then(h),updateRecommendationsStep:e=>m(`${n}jetpack/v4/recommendations/step`,l,{body:JSON.stringify({step:e})}).then(p),confirmIDCSafeMode:()=>m(`${n}jetpack/v4/identity-crisis/confirm-safe-mode`,l).then(p),startIDCFresh:e=>m(`${n}jetpack/v4/identity-crisis/start-fresh`,l,{body:JSON.stringify({redirect_uri:e})}).then(p).then(h),migrateIDC:()=>m(`${n}jetpack/v4/identity-crisis/migrate`,l).then(p),attachLicenses:e=>m(`${n}jetpack/v4/licensing/attach-licenses`,l,{body:JSON.stringify({licenses:e})}).then(p).then(h),fetchSearchPlanInfo:()=>d(`${o}jetpack/v4/search/plan`,a).then(p).then(h),fetchSearchSettings:()=>d(`${o}jetpack/v4/search/settings`,a).then(p).then(h),updateSearchSettings:e=>m(`${o}jetpack/v4/search/settings`,l,{body:JSON.stringify(e)}).then(p).then(h),fetchSearchStats:()=>d(`${o}jetpack/v4/search/stats`,a).then(p).then(h),fetchWafSettings:()=>d(`${n}jetpack/v4/waf`,a).then(p).then(h),updateWafSettings:e=>m(`${n}jetpack/v4/waf`,l,{body:JSON.stringify(e)}).then(p).then(h),fetchWordAdsSettings:()=>d(`${n}jetpack/v4/wordads/settings`,a).then(p).then(h),updateWordAdsSettings:e=>m(`${n}jetpack/v4/wordads/settings`,l,{body:JSON.stringify(e)}),fetchSearchPricing:()=>d(`${o}jetpack/v4/search/pricing`,a).then(p).then(h),fetchMigrationStatus:()=>d(`${n}jetpack/v4/migration/status`,a).then(p).then(h),fetchBackupUndoEvent:()=>d(`${n}jetpack/v4/site/backup/undo-event`,a).then(p).then(h),fetchBackupPreflightStatus:()=>d(`${n}jetpack/v4/site/backup/preflight`,a).then(p).then(h)};function d(e,t){return fetch(c(e),t)}function m(e,t,n){return fetch(e,Object.assign({},t,n)).catch(g)}function f(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 c(e.redirected):new l}):e.json().catch(e=>m(e)).then(t=>{const n=new Error(`${t.message} (Status ${e.status})`);throw n.response=t,n.name="ApiError",n})}function h(e){return e.json().catch(t=>m(t,e.redirected,e.url))}function m(e,t,n){throw t?new a(n):new i}function g(){throw new u}},11876(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(13022),s=n(87682),o=n(10790);const i=({children:e=null,width:t=null,height:n=null,className:i=""})=>(0,o.jsx)("div",{className:(0,r.A)(s.A.placeholder,i),style:{width:t,height:n},children:e})},50723(e,t,n){"use strict";n.d(t,{Ay:()=>p});var r=n(51609),s=n(8706),o=n(10790);const i={"--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)"},a={"--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 )"},l={"--jp-border-radius":"4px","--jp-menu-border-height":"1px","--jp-underline-thickness":"2px"},c={"--spacing-base":"8px"},u={},d=(e,t,n)=>{const r={...i,...a,...l,...c};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 i=(0,r.useRef)(),a=u?.[n]?.provided;return(0,r.useLayoutEffect)(()=>{if(!a)return t?d(t,n,s):void(i?.current&&d(i.current,n,s))},[t,i,a,n,s]),t?(0,o.jsx)(o.Fragment,{children:e}):(0,o.jsx)("div",{ref:i,children:e})}},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 s=e=>Object.hasOwn(r,e);e.exports={jetpackConfigHas:s,jetpackConfigGet:e=>{if(!s(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]}}},14882(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(5932),s=n(97999),o=n(47143),i=n(51609),a=n(34293);const l=window?.JP_CONNECTION_INITIAL_STATE||(0,s.getScriptData)()?.connection||{};function c({registrationNonce:e=l.registrationNonce,apiRoot:t=l.apiRoot,apiNonce:n=l.apiNonce,redirectUri:s,autoTrigger:c,from:u,skipUserConnection:d,skipPricingPage:p}={}){const{registerSite:h,connectUser:m,refreshConnectedPlugins:g}=(0,o.useDispatch)(a.a),f=(0,o.useSelect)(e=>e(a.a).getRegistrationError(),[]),{siteIsRegistering:b,userIsConnecting:v,userConnectionData:y,connectedPlugins:k,connectionErrors:x,isRegistered:_,isUserConnected:w,hasConnectedOwner:j,isOfflineMode:C}=(0,o.useSelect)(e=>{const t=e(a.a).getConnectionStatus();return{siteIsRegistering:e(a.a).getSiteIsRegistering(),userIsConnecting:e(a.a).getUserIsConnecting(),userConnectionData:e(a.a).getUserConnectionData()||{},connectedPlugins:e(a.a).getConnectedPlugins(),connectionErrors:e(a.a).getConnectionErrors(),isOfflineMode:e(a.a).getIsOfflineMode(),isRegistered:t.isRegistered??!1,isUserConnected:t.isUserConnected??!1,hasConnectedOwner:t.hasConnectedOwner??!1}},[]),A=()=>d?s?(window.location.href=s,Promise.resolve(s)):Promise.resolve():m({from:u,redirectUri:s,skipPricingPage:p}),S=t=>(t&&t.preventDefault(),_?A():h({registrationNonce:e,redirectUri:s,from:u}).then(()=>A()));return(0,i.useEffect)(()=>{r.Ay.setApiRoot(t),r.Ay.setApiNonce(n)},[t,n]),(0,i.useEffect)(()=>{!c||b||v||S()},[]),{handleRegisterSite:S,handleConnectUser:A,refreshConnectedPlugins:g,isRegistered:_,isUserConnected:w,siteIsRegistering:b,userIsConnecting:v,registrationError:f,userConnectionData:y,hasConnectedOwner:j,connectedPlugins:k,connectionErrors:x,isOfflineMode:C}}},33935(e,t,n){"use strict";n.d(t,{A1:()=>l,Ay:()=>_,DO:()=>a,Ij:()=>i,Kl:()=>h,LW:()=>c,MU:()=>m,XY:()=>u,ZO:()=>o,dz:()=>d,gH:()=>p,v_:()=>s});var r=n(5932);const s="SET_CONNECTION_STATUS",o="SET_CONNECTION_STATUS_IS_FETCHING",i="SET_SITE_IS_REGISTERING",a="SET_USER_IS_CONNECTING",l="SET_REGISTRATION_ERROR",c="CLEAR_REGISTRATION_ERROR",u="SET_AUTHORIZATION_URL",d="DISCONNECT_USER_SUCCESS",p="SET_CONNECTED_PLUGINS",h="SET_CONNECTION_ERRORS",m="SET_IS_OFFLINE_MODE",g=e=>({type:s,connectionStatus:e}),f=e=>({type:i,isRegistering:e}),b=e=>({type:a,isConnecting:e}),v=e=>({type:l,registrationError:e}),y=()=>({type:c}),k=e=>({type:u,authorizationUrl:e}),x=e=>({type:p,connectedPlugins:e});const _={setConnectionStatus:g,setConnectionStatusIsFetching:e=>({type:o,isFetching:e}),fetchConnectionStatus:()=>({type:"FETCH_CONNECTION_STATUS"}),fetchAuthorizationUrl:e=>({type:"FETCH_AUTHORIZATION_URL",redirectUri:e}),setSiteIsRegistering:f,setUserIsConnecting:b,setRegistrationError:v,clearRegistrationError:y,setAuthorizationUrl:k,registerSite:function*({registrationNonce:e,redirectUri:t,from:n=""}){yield y(),yield f(!0);try{const r=yield{type:"REGISTER_SITE",registrationNonce:e,redirectUri:t,from:n};return yield g({isRegistered:!0}),yield k(r.authorizeUrl),yield f(!1),Promise.resolve(r)}catch(e){return yield v(e),yield f(!1),Promise.reject(e)}},connectUser:function*({from:e,redirectFunc:t,redirectUri:n,skipPricingPage:r}={}){yield b(!0),yield{type:"CONNECT_USER",from:e,redirectFunc:t,redirectUri:n,skipPricingPage:r}},disconnectUserSuccess:()=>({type:d}),setConnectedPlugins:x,refreshConnectedPlugins:()=>async({dispatch:e})=>await new Promise(t=>r.Ay.fetchConnectedPlugins().then(n=>{e(x(n)),t(n)})),setConnectionErrors:e=>({type:h,connectionErrors:e}),setIsOfflineMode:e=>({type:m,isOfflineMode:e})}},27938(e,t,n){"use strict";function r(e){return window.location.assign(e)}n.d(t,{d:()=>r})},22494(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(5932),s=n(47143),o=n(27938),i=n(32279);const a={FETCH_AUTHORIZATION_URL:({redirectUri:e})=>r.Ay.fetchAuthorizationUrl(e),REGISTER_SITE:({redirectUri:e,from:t})=>r.Ay.registerSite(null,e,t),CONNECT_USER:(0,s.createRegistryControl)(({resolveSelect:e})=>({from:t,redirectFunc:n,redirectUri:r,skipPricingPage:s}={})=>new Promise((a,l)=>{e(i.A).getAuthorizationUrl(r).then(e=>{const r=n||(e=>(0,o.d)(e)),i=new URL(e);s&&i.searchParams.set("skip_pricing","true"),t&&i.searchParams.set("from",encodeURIComponent(t));const l=i.toString();r(l),a(l)}).catch(e=>{l(e)})}))}},5051(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(47143),s=n(33935);const o=(0,r.combineReducers)({connectionStatus:(e={},t)=>{switch(t.type){case s.v_:return{...e,...t.connectionStatus};case s.dz:return{...e,isUserConnected:!1}}return e},connectionStatusIsFetching:(e=!1,t)=>t.type===s.ZO?t.isFetching:e,siteIsRegistering:(e=!1,t)=>t.type===s.Ij?t.isRegistering:e,userIsConnecting:(e=!1,t)=>t.type===s.DO?t.isConnecting:e,registrationError:(e,t)=>{switch(t.type){case s.LW:return!1;case s.A1:return t.registrationError;default:return e}},authorizationUrl:(e,t)=>t.type===s.XY?t.authorizationUrl:e,userConnectionData:(e,t)=>(t.type,e),connectedPlugins:(e={},t)=>t.type===s.gH?t.connectedPlugins:e,connectionErrors:(e={},t)=>t.type===s.Kl?t.connectionErrors:e,isOfflineMode:(e=!1,t)=>t.type===s.MU?t.isConnecting:e})},58019(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(47143),s=n(33935),o=n(32279);const i={...{getAuthorizationUrl:{isFulfilled:(e,...t)=>{const n=Boolean(e.authorizationUrl),s=(0,r.select)(o.A).hasFinishedResolution("getAuthorizationUrl",t);return n&&!s&&(0,r.dispatch)(o.A).finishResolution("getAuthorizationUrl",t),n},*fulfill(e){const t=yield s.Ay.fetchAuthorizationUrl(e);yield s.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:()=>o});var r=n(47143);class s{static store=null;static mayBeInit(e,t){null===s.store&&(s.store=(0,r.createReduxStore)(e,t),(0,r.register)(s.store))}}const o=s},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),s=n(33935),o=n(22494),i=n(5051),a=n(58019),l=n(52676),c=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."),c.A.mayBeInit(u.A,{__experimentalUseThunks:!0,reducer:i.A,actions:s.Ay,selectors:l.A,resolvers:a.A,controls:o.A,initialState:d||{}})},63673(e,t,n){"use strict";n.d(t,{FALLBACK_CURRENCY:()=>s,FALLBACK_LOCALE:()=>r});n(38443);const r="en",s="USD"},11452(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(63673),s=n(49980),o=n(91167);const i=function(){let e,t,n;const i=()=>{const t="undefined"!=typeof window?window.wp?.date?.getSettings?.()?.l10n?.locale:void 0,n="undefined"!=typeof window?window?.navigator?.language:void 0;return(e??(t||n)??r.FALLBACK_LOCALE).split("_")[0]};return{setLocale:t=>{e=t},setGeoLocation:e=>{t=e},setCurrencyOverrides:e=>{n=e},formatNumber:(e,{decimals:t=0,forceLatin:n=!0,numberFormatOptions:r={}}={})=>{try{return(0,o.j)({browserSafeLocale:i(),decimals:t,forceLatin:n,numberFormatOptions:r}).format(e)}catch{return String(e)}},formatNumberCompact:(e,{decimals:t=0,forceLatin:n=!0,numberFormatOptions:r={}}={})=>{try{return(0,o.c)({browserSafeLocale:i(),decimals:t,forceLatin:n,numberFormatOptions:r}).format(e)}catch{return String(e)}},formatCurrency:(e,r,{stripZeros:o=!1,isSmallestUnit:a=!1,signForPositive:l=!1,forceLatin:c=!0}={})=>(0,s.u)({number:e,currency:r,browserSafeLocale:i(),stripZeros:o,isSmallestUnit:a,signForPositive:l,geoLocation:t,forceLatin:c,currencyOverrides:n}),getCurrencyObject:(e,r,{stripZeros:o=!1,isSmallestUnit:a=!1,signForPositive:l=!1,forceLatin:c=!0}={})=>(0,s.v)({number:e,currency:r,browserSafeLocale:i(),stripZeros:o,isSmallestUnit:a,signForPositive:l,geoLocation:t,forceLatin:c,currencyOverrides:n})}}},3328(e,t,n){"use strict";n.d(t,{J:()=>l});var r=n(10067),s=n.n(r),o=n(63673);const i=s()("number-formatters:get-cached-formatter"),a=new Map;function l({locale:e,fallbackLocale:t=o.FALLBACK_LOCALE,options:n,retries:r=1}){const s=JSON.stringify([e,n]);try{return a.get(s)??a.set(s,new Intl.NumberFormat(e,n)).get(s)}catch(s){if(i(`Intl.NumberFormat was called with a non-existent locale "${e}"; falling back to ${t}`),r)return l({locale:t,options:n,retries:r-1});throw s}}},54268(e,t,n){"use strict";n.d(t,{vv:()=>c});const r=(0,n(11452).A)(),{setLocale:s,setGeoLocation:o,setCurrencyOverrides:i,formatNumber:a,formatNumberCompact:l,formatCurrency:c,getCurrencyObject:u}=r},76673(e,t,n){"use strict";n.d(t,{a:()=>r});const r={AED:{symbol:"د.إ.‏"},AFN:{symbol:"؋"},ALL:{symbol:"Lek"},AMD:{symbol:"֏"},ANG:{symbol:"ƒ"},AOA:{symbol:"Kz"},ARS:{symbol:"$"},AUD:{symbol:"A$"},AWG:{symbol:"ƒ"},AZN:{symbol:"₼"},BAM:{symbol:"КМ"},BBD:{symbol:"Bds$"},BDT:{symbol:"৳"},BGN:{symbol:"лв."},BHD:{symbol:"د.ب.‏"},BIF:{symbol:"FBu"},BMD:{symbol:"$"},BND:{symbol:"$"},BOB:{symbol:"Bs"},BRL:{symbol:"R$"},BSD:{symbol:"$"},BTC:{symbol:"Ƀ"},BTN:{symbol:"Nu."},BWP:{symbol:"P"},BYR:{symbol:"р."},BZD:{symbol:"BZ$"},CAD:{symbol:"C$"},CDF:{symbol:"FC"},CHF:{symbol:"CHF"},CLP:{symbol:"$"},CNY:{symbol:"¥"},COP:{symbol:"$"},CRC:{symbol:"₡"},CUC:{symbol:"CUC"},CUP:{symbol:"$MN"},CVE:{symbol:"$"},CZK:{symbol:"Kč"},DJF:{symbol:"Fdj"},DKK:{symbol:"kr."},DOP:{symbol:"RD$"},DZD:{symbol:"د.ج.‏"},EGP:{symbol:"ج.م.‏"},ERN:{symbol:"Nfk"},ETB:{symbol:"ETB"},EUR:{symbol:"€"},FJD:{symbol:"FJ$"},FKP:{symbol:"£"},GBP:{symbol:"£"},GEL:{symbol:"Lari"},GHS:{symbol:"₵"},GIP:{symbol:"£"},GMD:{symbol:"D"},GNF:{symbol:"FG"},GTQ:{symbol:"Q"},GYD:{symbol:"G$"},HKD:{symbol:"HK$"},HNL:{symbol:"L."},HRK:{symbol:"kn"},HTG:{symbol:"G"},HUF:{symbol:"Ft"},IDR:{symbol:"Rp"},ILS:{symbol:"₪"},INR:{symbol:"₹"},IQD:{symbol:"د.ع.‏"},IRR:{symbol:"﷼"},ISK:{symbol:"kr."},JMD:{symbol:"J$"},JOD:{symbol:"د.ا.‏"},JPY:{symbol:"¥"},KES:{symbol:"S"},KGS:{symbol:"сом"},KHR:{symbol:"៛"},KMF:{symbol:"CF"},KPW:{symbol:"₩"},KRW:{symbol:"₩"},KWD:{symbol:"د.ك.‏"},KYD:{symbol:"$"},KZT:{symbol:"₸"},LAK:{symbol:"₭"},LBP:{symbol:"ل.ل.‏"},LKR:{symbol:"₨"},LRD:{symbol:"L$"},LSL:{symbol:"M"},LYD:{symbol:"د.ل.‏"},MAD:{symbol:"د.م.‏"},MDL:{symbol:"lei"},MGA:{symbol:"Ar"},MKD:{symbol:"ден."},MMK:{symbol:"K"},MNT:{symbol:"₮"},MOP:{symbol:"MOP$"},MRO:{symbol:"UM"},MTL:{symbol:"₤"},MUR:{symbol:"₨"},MVR:{symbol:"MVR"},MWK:{symbol:"MK"},MXN:{symbol:"MX$"},MYR:{symbol:"RM"},MZN:{symbol:"MT"},NAD:{symbol:"N$"},NGN:{symbol:"₦"},NIO:{symbol:"C$"},NOK:{symbol:"kr"},NPR:{symbol:"₨"},NZD:{symbol:"NZ$"},OMR:{symbol:"﷼"},PAB:{symbol:"B/."},PEN:{symbol:"S/."},PGK:{symbol:"K"},PHP:{symbol:"₱"},PKR:{symbol:"₨"},PLN:{symbol:"zł"},PYG:{symbol:"₲"},QAR:{symbol:"﷼"},RON:{symbol:"lei"},RSD:{symbol:"Дин."},RUB:{symbol:"₽"},RWF:{symbol:"RWF"},SAR:{symbol:"﷼"},SBD:{symbol:"S$"},SCR:{symbol:"₨"},SDD:{symbol:"LSd"},SDG:{symbol:"£‏"},SEK:{symbol:"kr"},SGD:{symbol:"S$"},SHP:{symbol:"£"},SLL:{symbol:"Le"},SOS:{symbol:"S"},SRD:{symbol:"$"},STD:{symbol:"Db"},SVC:{symbol:"₡"},SYP:{symbol:"£"},SZL:{symbol:"E"},THB:{symbol:"฿"},TJS:{symbol:"TJS"},TMT:{symbol:"m"},TND:{symbol:"د.ت.‏"},TOP:{symbol:"T$"},TRY:{symbol:"TL"},TTD:{symbol:"TT$"},TVD:{symbol:"$T"},TWD:{symbol:"NT$"},TZS:{symbol:"TSh"},UAH:{symbol:"₴"},UGX:{symbol:"USh"},USD:{},UYU:{symbol:"$U"},UZS:{symbol:"сўм"},VEB:{symbol:"Bs."},VEF:{symbol:"Bs. F."},VND:{symbol:"₫"},VUV:{symbol:"VT"},WST:{symbol:"WS$"},XAF:{symbol:"F"},XCD:{symbol:"$"},XOF:{symbol:"F"},XPF:{symbol:"F"},YER:{symbol:"﷼"},ZAR:{symbol:"R"},ZMW:{symbol:"ZK"},WON:{symbol:"₩"}}},49980(e,t,n){"use strict";n.d(t,{u:()=>f,v:()=>b});var r=n(10067),s=n.n(r),o=n(63673),i=n(3328),a=n(76673);const l=s()("number-formatters:number-format-currency");function c(e,t,n){if("USD"===e&&t&&""!==t&&"US"!==t)return{symbol:"US$",...n?.USD};const r=a.a[e],s=n?.[e];return r||s?{...r,...s}:void 0}function u(e,t,n){return c(e,t,n)?e:(l(`getValidCurrency was called with a non-existent currency "${e}"; falling back to ${o.FALLBACK_CURRENCY}`),o.FALLBACK_CURRENCY)}function d({number:e,currency:t,browserSafeLocale:n,forceLatin:r=!0,stripZeros:s,signForPositive:o}){const a=`${n}${r?"-u-nu-latn":""}`,l={style:"currency",currency:t,...s&&Number.isInteger(e)&&{maximumFractionDigits:0,minimumFractionDigits:0},...o&&{signDisplay:"exceptZero"}};return(0,i.J)({locale:a,options:l})}const p={IDR:2,HUF:2};function h(e,t,n){return d({number:0,currency:t,browserSafeLocale:e,forceLatin:n}).resolvedOptions().maximumFractionDigits}function m(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}function g(e,t,n,r,s){if(isNaN(e))return l("formatCurrency was called with NaN"),0;if(r){Number.isInteger(e)||l("formatCurrency was called with isSmallestUnit and a float which will be rounded",e);const r=10**function(e,t,n){const r=n?.[e]?.decimal;return"number"==typeof r?r:p[e]??t}(n,t,s);return m(Math.round(e)/r,t)}return m(e,t)}const f=({number:e,browserSafeLocale:t,currency:n,stripZeros:r,isSmallestUnit:s,signForPositive:o,geoLocation:i,forceLatin:a,currencyOverrides:l})=>{const p=u(n,i,l),m=c(p,i,l),f=h(t,p,a);if(s&&void 0===f)throw new Error(`Could not determine currency precision for ${p} in ${t}`);const b=g(e,f??0,p,s,l);return d({number:b,currency:p,browserSafeLocale:t,forceLatin:a,stripZeros:r,signForPositive:o}).formatToParts(b).reduce((e,t)=>"currency"===t.type&&m?.symbol?e+m.symbol:e+t.value,"")},b=({number:e,browserSafeLocale:t,currency:n,stripZeros:r,isSmallestUnit:s,signForPositive:o,geoLocation:i,forceLatin:a,currencyOverrides:l})=>{const p=u(n,i,l),m=c(p,i,l),f=g(e,h(t,p,a)??0,p,s,l),b=d({number:f,currency:p,browserSafeLocale:t,forceLatin:a,stripZeros:r,signForPositive:o}).formatToParts(f);let v="",y="$",k="before",x=!1,_=!1,w="",j="";b.forEach(e=>{switch(e.type){case"currency":return y=m?.symbol??e.value,void(x&&(k="after"));case"group":case"integer":return w+=e.value,void(x=!0);case"decimal":case"fraction":return j+=e.value,x=!0,void(_=!0);case"minusSign":return void(v="-");case"plusSign":v="+"}});const C=!Number.isInteger(f)&&_;return{sign:v,symbol:y,symbolPosition:k,integer:w,fraction:j,hasNonZeroFraction:C,floatValue:f}}},91167(e,t,n){"use strict";n.d(t,{c:()=>o,j:()=>s});var r=n(3328);const s=({browserSafeLocale:e,decimals:t=0,forceLatin:n=!0,numberFormatOptions:s={}})=>{const o=`${e}${n?"-u-nu-latn":""}`,i={minimumFractionDigits:t,maximumFractionDigits:t,...s};return(0,r.J)({locale:o,options:i})},o=({numberFormatOptions:e={},...t})=>s({...t,numberFormatOptions:{notation:"compact",maximumFractionDigits:1,...e}})},85985(e,t,n){"use strict";n.d(t,{$i:()=>r.A,BT:()=>a.A,Bd:()=>p.Bd,CP:()=>b.C,Cq:()=>m.C,Dk:()=>l.Dk,FB:()=>i.A,GE:()=>s.A,GT:()=>l.GT,M_:()=>g.store,Mm:()=>f.A,Ti:()=>p.Ti,W4:()=>l.W4,ZR:()=>d.A,_6:()=>v.A,_X:()=>p._X,aq:()=>l.aq,ds:()=>p.ds,gB:()=>c.A,pP:()=>o.p,q7:()=>h.A,sH:()=>l.sH,sh:()=>m.s,st:()=>u.A,tu:()=>l.tu,xI:()=>b.x});var r=n(34972),s=n(54815),o=(n(41409),n(62634)),i=n(8573),a=(n(82034),n(65595)),l=n(53265),c=n(49354),u=n(73489),d=n(89581),p=n(20710),h=(n(58406),n(76923)),m=n(30335),g=n(87687),f=n(44360),b=n(9061),v=n(25929);n(5765)},5765(e,t,n){"use strict";n(98490)},82201(e,t,n){"use strict";n.d(t,{cb:()=>r.c});n(15877);var r=n(30984);n(82308)},15877(e,t,n){"use strict";n(97999),n(27723),n(48297),n(10790)},30984(e,t,n){"use strict";n.d(t,{c:()=>a});var r=n(56427),s=n(27723),o=n(13022),i=(n(75070),n(10790));const __=s.__,a=({className:e,description:t,align:n=null,title:s=null,buttonText:a=null,visible:l=!0,context:c=null,checkoutUrl:u=null,goToCheckoutPage:d=null,isRedirecting:p=!1,showButton:h=!0,target:m="_top"})=>{const g=(0,o.A)(e,"jetpack-upgrade-plan-banner",{"wp-block":"editor-canvas"===c,"block-editor-block-list__block":"editor-canvas"===c,"jetpack-upgrade-plan__hidden":!l}),f=__("Redirecting…","jetpack");return(0,i.jsx)("div",{className:g,"data-align":n,children:(0,i.jsxs)("div",{className:"jetpack-upgrade-plan-banner__wrapper",children:[s&&(0,i.jsx)("strong",{className:(0,o.A)("banner-title",{[`${e}__title`]:e}),children:s}),t&&(0,i.jsx)("span",{className:`${e}__description banner-description`,children:t}),h&&(0,i.jsx)(r.Button,{href:p?null:u,onClick:d,target:m,className:(0,o.A)("is-primary",{"jetpack-upgrade-plan__hidden":!u}),isBusy:p,children:(0,i.jsx)("span",{children:p?f:a})})]})})}},82308(e,t,n){"use strict";n(47143),n(51609),n(10790)},30335(e,t,n){"use strict";n.d(t,{C:()=>o,s:()=>s});var r=n(86087);function s(e){const t={};let n="span",s=e.icon;const o=document.createElement("div");o.innerHTML=e.icon;const i=o.querySelector("svg");return i&&(n="svg",s=i.innerHTML,Array.from(i.attributes).forEach(({nodeName:e,nodeValue:n})=>t[e]=n)),(0,r.createElement)(n,{...t,dangerouslySetInnerHTML:{__html:s||""}})}function o(e){return{src:s(e)}}},34972(e,t,n){"use strict";n.d(t,{A:()=>r});function r(){return"object"==typeof window?window?.Jetpack_Editor_Initial_State??null:null}},8573(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(34972);function s(e){const t=(0,r.A)(),n=t?.available_blocks?.[e]?.available??!1,s=t?.available_blocks?.[e]?.unavailable_reason??"unknown";return{available:n,...!n&&{details:t?.available_blocks?.[e]?.details??{},unavailableReason:s}}}},54815(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(97999);function s(){return window&&window.Jetpack_Editor_Initial_State&&window.Jetpack_Editor_Initial_State.siteFragment?window.Jetpack_Editor_Initial_State.siteFragment:(0,r.getScriptData)()?.site?.suffix??null}},73489(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(90372),s=n(14882),o=n(86087);const{tracks:i}=r.A,{recordEvent:a}=i,l=({pageViewEventName:e=null,pageViewNamespace:t="jetpack",pageViewSuffix:n="page_view",pageViewEventProperties:l={}}={})=>{const[c,u]=(0,o.useState)(!1),{isUserConnected:d,isRegistered:p,userConnectionData:h={}}=(0,s.A)(),{wpcomUser:{login:m,ID:g}={},blogId:f}=h.currentUser||{},b=(0,o.useCallback)(async(e,t={})=>{d&&g&&m&&a(e,t)},[d,g,m]);return(0,o.useEffect)(()=>{d&&g&&m&&f&&r.A.initialize(g,m,{blog_id:f})},[f,g,m,d]),(0,o.useEffect)(()=>{const r=e?`${t}_${e}_${n}`:null;p&&r&&(c||(b(r,l),u(!0)))},[c,t,e,n,p,l,b]),{recordEvent:b,tracks:i}}},89581(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(47143),s=n(86087);const o=()=>{};function i(e=null,t=o){const[n,i]=(0,s.useState)(!1),{isAutosaveablePost:a,isDirtyPost:l,currentPost:c}=(0,r.useSelect)(e=>{const t=e("core/editor");return{isAutosaveablePost:t.isEditedPostAutosaveable(),isDirtyPost:t.isEditedPostDirty(),currentPost:t.getCurrentPost()}},[]),u=Object.keys(c).length>0,d=(0,r.useSelect)(e=>!!window.wp?.customize||!!e("core/edit-widgets")),p=(0,r.dispatch)("core/editor").savePost,h=(0,r.useSelect)(e=>e("core").__experimentalGetDirtyEntityRecords()),m=async e=>{e?.preventDefault(),u?l&&a&&await p(e):await(async()=>{for(let e=0;e{r?.preventDefault(),n||(i(!0),m(r).then(()=>{e&&function(e,t,n=!1){t&&t(e),n?window.open(e,"_blank"):window.top.location.href=e}(e,t,d)}))},isRedirecting:n}}},76923(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(87687),s=n(47143),o=n(86087);const i=e=>{const{isModuleActive:t,isChangingStatus:n,isLoadingModules:i}=(0,s.useSelect)(t=>{const n=t(r.JETPACK_MODULES_STORE_ID);return{isModuleActive:n.isModuleActive(e),isChangingStatus:n.isModuleUpdating(e),isLoadingModules:n.areModulesLoading(e)}},[e]),{updateJetpackModuleStatus:a}=(0,s.useDispatch)(r.JETPACK_MODULES_STORE_ID),l=(0,o.useCallback)(t=>a({name:e,active:t}),[e,a]);return(0,o.useMemo)(()=>({isLoadingModules:i,isChangingStatus:n,isModuleActive:t,changeStatus:l}),[i,n,t,l])}},20710(e,t,n){"use strict";n.d(t,{Bd:()=>i,Ti:()=>o,_X:()=>r,ds:()=>s});const r="free",s="tiered",o="unlimited",i=e=>e?0===e?.value?r:1===e?.value?o:s:null},58406(e,t,n){"use strict";n(86087)},25929(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(47143),s=n(52619),o=n(53265),i=n(89581);const a=()=>{},l="a8c.wpcom-block-editor.openCheckoutModal";function c(e,t=a){const{checkoutUrl:n,planData:c}=(0,r.useSelect)(t=>{const n=t("core/editor"),r=t("wordpress-com/plans"),{id:s,type:i}=n.getCurrentPost(),a=r&&r.getPlan(e);return{checkoutUrl:(0,o.Q4)({plan:a,planSlug:e,postId:s,postType:i}),planData:a}},[e]),{autosave:u,autosaveAndRedirect:d,isRedirecting:p}=(0,i.A)(n,t);return[n,async e=>{if(e.preventDefault(),(0,s.hasAction)(l))return e.preventDefault(),u(e),void(0,s.doAction)(l,{products:[c]});d(e)},p,c]}},62410(e,t,n){"use strict";n.d(t,{KZ:()=>p,M4:()=>u,QB:()=>d,T3:()=>c,ik:()=>m,oW:()=>g,ud:()=>h,ux:()=>l});var r=n(38377),s=n(56427),o=n(13022),i=(n(47621),n(10790));const a=r.T["Jetpack Green 40"],l=({size:e=24,border:t=0,className:n="",color:r=a})=>{const l=t?-t/e*32:0;return(0,i.jsxs)(s.SVG,{className:(0,o.A)("jetpack-logo",n),width:e,height:e,viewBox:`${l} ${l} ${32-2*l} ${32-2*l}`,children:[(0,i.jsx)(s.Path,{className:"jetpack-logo__icon-circle",fill:r,stroke:t?"#fff":"transparent",strokeWidth:t,d:"M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z"}),(0,i.jsx)(s.Polygon,{className:"jetpack-logo__icon-triangle",fill:"#fff",points:`15,19 ${7-.5*l},19 15,${3-l}`}),(0,i.jsx)(s.Polygon,{className:"jetpack-logo__icon-triangle",fill:"#fff",points:`17,${29+l} 17,13 ${25+.5*l},13`})]})},c={src:(0,i.jsx)(s.SVG,{viewBox:"0 0 100 100",children:(0,i.jsx)(s.Path,{d:"M100,44H72.4l23.9-13.8l-6-10.4L66.4,33.6L80.2,9.7l-10.4-6L56,27.59V0H44v27.6L30.2,3.7l-10.4,6l13.8,23.9 L9.7,19.8l-6,10.4L27.6,44H0V56h27.6L3.7,69.8l6,10.4l23.9-13.8L19.8,90.3l10.4,6L44,72.4V100H56V72.41l13.8,23.9l10.4-6L66.4,66.4 l23.9,13.8l6-10.4L72.4,56H100V44z M50,65.23c-8.41,0-15.23-6.82-15.23-15.23c0-8.41,6.82-15.23,15.23-15.23S65.23,41.59,65.23,50 C65.23,58.41,58.41,65.23,50,65.23z"})})},u={src:(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20.7 17",xmlSpace:"preserve",children:(0,i.jsx)(s.Path,{d:"m20.7 12.9-.9-11c0-.5-.2-.9-.5-1.3-.3-.3-.8-.5-1.3-.5L1.9 0h-.1c-.2 0-.5 0-.7.1C.9.2.7.4.5.5.4.7.2.9.1 1.1c-.1.2-.1.5-.1.7v.1l.9 13.4c0 .5.2.9.5 1.3.3.2.8.4 1.3.4H3l16.1-2c.4 0 .9-.3 1.1-.6.3-.3.5-.8.5-1.2v-.3zm-3.1.8L4.2 15.3H4c-.4 0-.8-.1-1-.4-.3-.3-.4-.6-.5-1L1.7 3.2v-.1c0-.4.2-.8.5-1 .3-.3.7-.4 1-.4h.1l13.5.1c.4 0 .8.1 1 .4.3.3.4.6.5 1L19 12v.3c0 .4-.2.7-.4 1-.3.2-.6.4-1 .4z"})})},d={src:(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 43 43",xmlSpace:"preserve",children:(0,i.jsx)(s.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 31.908c0 1.376.893 2.268 2.27 2.268h6.63c3.956 0 7.192-1.337 9.392-3.68H12v1.412zM20.901 9H14.27C12.893 9 12 9.893 12 11.269v1.411h18.294C28.093 10.338 24.857 9 20.9 9zm5.787 16.176c0 1.113.726 1.835 1.845 1.835h3.973c.45-1.117.753-2.345.894-3.671h-4.867c-1.119 0-1.845.722-1.845 1.836zm-5.507-7.166c0 1.113.725 1.836 1.844 1.836H33.4a13.644 13.644 0 0 0-.894-3.672h-9.481c-1.119 0-1.844.723-1.844 1.836zm1.843 7.166c0-1.114-.726-1.836-1.845-1.836H12v3.671h9.18c1.118 0 1.843-.722 1.843-1.835zm-5.508-7.166c0-1.113-.726-1.836-1.844-1.836H12v3.672h3.672c1.118 0 1.844-.723 1.844-1.836zm41.151 3.199"})})},p=(0,i.jsx)(s.SVG,{width:"29",height:"21",viewBox:"0 0 29 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M2.79037 0.59375C4.0363 0.59375 5.13102 1.41658 5.47215 2.60947L8.8452 14.4044C8.8486 14.4164 8.85411 14.4273 8.86124 14.4368L12.8572 0.59375H15.0927H21.2721C25.6033 0.59375 28.5066 3.39892 28.5066 7.64565C28.5066 11.9411 25.5272 14.6196 21.0818 14.6196H18.1499H14.3719L13.6379 16.8813C12.9796 18.9095 11.0827 20.2839 8.94152 20.2839C6.80035 20.2839 4.90341 18.9095 4.24517 16.8813L0.137069 4.22276C-0.444671 2.43022 0.898038 0.59375 2.79037 0.59375ZM15.7374 10.4119H20.0156C21.8718 10.4119 22.9856 9.35018 22.9856 7.64565C22.9856 5.93137 21.8718 4.91839 20.0156 4.91839H17.5202L15.7374 10.4119Z",fill:"#000000"})}),h=(0,i.jsx)(s.SVG,{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{d:"M4.75725 2.075C4.60279 1.97745 4.41041 1.97489 4.25365 2.06832C4.09689 2.16174 4 2.3367 4 2.52632V21.4737C4 21.6633 4.09689 21.8383 4.25365 21.9317C4.41041 22.0251 4.60279 22.0226 4.75725 21.925L19.7573 12.4513C19.9079 12.3562 20 12.1849 20 12C20 11.8151 19.9079 11.6438 19.7573 11.5487L4.75725 2.075Z",fill:"white"})}),m=(0,i.jsx)(s.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.Path,{d:"M20 3H4c-.6 0-1 .4-1 1v16c0 .5.4 1 1 1h8.6v-7h-2.3v-2.7h2.3v-2c0-2.3 1.4-3.6 3.5-3.6 1 0 1.8.1 2.1.1v2.4h-1.4c-1.1 0-1.3.5-1.3 1.3v1.7h2.7l-.4 2.8h-2.3v7H20c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1z"})}),g=(0,i.jsx)(s.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(s.G,{children:(0,i.jsx)(s.Path,{d:"M12 4.622c2.403 0 2.688.01 3.637.052.877.04 1.354.187 1.67.31.42.163.72.358 1.036.673.315.315.51.615.673 1.035.123.317.27.794.31 1.67.043.95.052 1.235.052 3.638s-.01 2.688-.052 3.637c-.04.877-.187 1.354-.31 1.67-.163.42-.358.72-.673 1.036-.315.315-.615.51-1.035.673-.317.123-.794.27-1.67.31-.95.043-1.234.052-3.638.052s-2.688-.01-3.637-.052c-.877-.04-1.354-.187-1.67-.31-.42-.163-.72-.358-1.036-.673-.315-.315-.51-.615-.673-1.035-.123-.317-.27-.794-.31-1.67-.043-.95-.052-1.235-.052-3.638s.01-2.688.052-3.637c.04-.877.187-1.354.31-1.67.163-.42.358-.72.673-1.036.315-.315.615-.51 1.035-.673.317-.123.794-.27 1.67-.31.95-.043 1.235-.052 3.638-.052M12 3c-2.444 0-2.75.01-3.71.054s-1.613.196-2.185.418c-.592.23-1.094.538-1.594 1.04-.5.5-.807 1-1.037 1.593-.223.572-.375 1.226-.42 2.184C3.01 9.25 3 9.555 3 12s.01 2.75.054 3.71.196 1.613.418 2.186c.23.592.538 1.094 1.038 1.594s1.002.808 1.594 1.038c.572.222 1.227.375 2.185.418.96.044 1.266.054 3.71.054s2.75-.01 3.71-.054 1.613-.196 2.186-.418c.592-.23 1.094-.538 1.594-1.038s.808-1.002 1.038-1.594c.222-.572.375-1.227.418-2.185.044-.96.054-1.266.054-3.71s-.01-2.75-.054-3.71-.196-1.613-.418-2.186c-.23-.592-.538-1.094-1.038-1.594s-1.002-.808-1.594-1.038c-.572-.222-1.227-.375-2.185-.418C14.75 3.01 14.445 3 12 3zm0 4.378c-2.552 0-4.622 2.07-4.622 4.622s2.07 4.622 4.622 4.622 4.622-2.07 4.622-4.622S14.552 7.378 12 7.378zM12 15c-1.657 0-3-1.343-3-3s1.343-3 3-3 3 1.343 3 3-1.343 3-3 3zm4.804-8.884c-.596 0-1.08.484-1.08 1.08s.484 1.08 1.08 1.08c.596 0 1.08-.484 1.08-1.08s-.483-1.08-1.08-1.08z"})})})},49354(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(34972);function s(){return!(!(0,r.A)()?.jetpack?.is_current_user_connected&&!window?.JP_CONNECTION_INITIAL_STATE?.connectionStatus?.isUserConnected)}},44360(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(34972);function s(){return!0===(0,r.A)()?.jetpack?.is_my_jetpack_available}},9520(e,t,n){"use strict";n.d(t,{C:()=>d,x:()=>u});var r=n(97999),s=n(10067),o=n.n(s);const i=window?.JP_CONNECTION_INITIAL_STATE,a=o()("shared-extension-utils:connection");let l=!1;const c=e=>{l||(a(e),l=!0)};function u(){return(0,r.isSimpleSite)()?(c("Simple site connected ✅"),!0):(0,r.isWoASite)()?(c("Atomic site connected ✅"),!0):i?.connectionStatus?.isUserConnected?(c("Jetpack user is connected ✅"),!0):(c("User is not connected ❌"),!1)}function d(){if((0,r.isSimpleSite)())return!0;return!1==!(i?.userConnectionData?.currentUser?.permissions??{}).manage_options}},9061(e,t,n){"use strict";n.d(t,{C:()=>r.C,x:()=>r.x});var r=n(9520)},53265(e,t,n){"use strict";n.d(t,{Dk:()=>m,GT:()=>f,Q4:()=>c,W4:()=>u,aq:()=>d,sH:()=>g,tu:()=>p});var r=n(97999),s=n(27723),o=n(93832),i=n(34972),a=n(8573),l=n(54815);const __=s.__;function c({planSlug:e,plan:t,postId:n,postType:s}){const i=e.startsWith("jetpack_")?e:t?.path_slug,a=(void 0===s?()=>{const e=new URLSearchParams(window.location.search);return(0,o.addQueryArgs)(window.location.protocol+`//${(0,l.A)().replace("::","/")}/wp-admin/site-editor.php`,{postId:e.get("postId"),postType:e.get("postType"),plan_upgraded:1})}:()=>{const e=["page","post"].includes(s)?"":"edit";return(0,r.isSimpleSite)()?(0,o.addQueryArgs)("/"+[e,s,(0,l.A)(),n].filter(Boolean).join("/"),{plan_upgraded:1}):(0,o.addQueryArgs)(window.location.protocol+`//${(0,l.A)().replace("::","/")}/wp-admin/post.php`,{action:"edit",post:n,plan_upgraded:1})})();return(0,r.isWoASite)()?(0,o.addQueryArgs)(`https://wordpress.com/plans/${(0,l.A)()}`,{redirect_to:a,customerType:"business"}):i&&(0,o.addQueryArgs)(`https://wordpress.com/checkout/${(0,l.A)()}/${i}`,{redirect_to:a})}function u(e){if(!e)return!1;const t=/^jetpack\//.test(e)?e.substr(8,e.length):e,{available:n,unavailableReason:r}=(0,a.A)(t);return!n&&"missing_plan"===r}function d(e,t){return"missing_plan"===e&&t.required_plan}function p(e){if(!e)return!1;const t=/^jetpack\//.test(e)?e.substr(8,e.length):e,{details:n,unavailableReason:r}=(0,a.A)(t);return d(r,n)}const h=[{name:"core/cover",mediaPlaceholder:!0,mediaReplaceFlow:!0,fileType:"video",description:__("Upgrade your plan to use video covers","jetpack")},{name:"core/audio",mediaPlaceholder:!0,mediaReplaceFlow:!0,fileType:"audio",description:__("Upgrade your plan to upload audio","jetpack")}];function m(){return(0,i.A)()?.jetpack?.enable_upgrade_nudge??!1}const g=e=>h.some(t=>t.name===e),f=e=>h.filter(({name:t})=>t===e)[0]},82034(e,t,n){"use strict";n(92279)},41409(e,t,n){"use strict";n(97999)},62634(e,t,n){"use strict";n.d(t,{p:()=>s});var r=n(34972);function s(){const e=(0,r.A)();return e?.jetpack?.is_private_site??!1}},65595(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(29491),s=(n(13371),n(10790));const o=e=>(0,r.createHigherOrderComponent)(t=>n=>(0,s.jsx)(t,{...n,className:n.name===e?"has-warning is-interactive":n.className}),"withHasWarningIsInteractiveClassNames");n.dn(o)},52068(e,t,n){"use strict";n.d(t,{Ay:()=>_});var r=n(96865),s=n(56427),o=n(47143),i=n(27723),a=n(55565),l=n(73493),c=n(93761),u=n(90437),d=n(80224),p=n(27571),h=n(48499),m=n(2162),g=n(62402),f=(n(37209),n(10790));const __=i.__,b="correct-spelling",v="simplify",y="make-longer",k="make-shorter",x={default:[{name:r.DD,key:b,aiSuggestion:r.yy,icon:d.A}],"core/paragraph":[{name:r.HM,key:v,aiSuggestion:r.A4,icon:u.A},{name:r.JR,key:"summarize",aiSuggestion:r.UA,icon:c.A},{name:r.K2,key:y,aiSuggestion:r.br,icon:l.A},{name:r.UD,key:k,aiSuggestion:r.fD,icon:l.A}],"core/list-item":[{name:r.HM,key:v,aiSuggestion:r.A4,icon:u.A},{name:r.K2,key:y,aiSuggestion:r.br,icon:l.A},{name:r.UD,key:k,aiSuggestion:r.fD,icon:l.A}],"core/list":p.L.includes("core/list")?[{name:r.HM,key:v,aiSuggestion:r.A4,icon:u.A},{name:r.K2,key:y,aiSuggestion:r.br,icon:l.A},{name:r.UD,key:k,aiSuggestion:r.fD,icon:l.A},{name:r.mI,key:"turn-list-into-table",aiSuggestion:r.d5,icon:a.A,options:{alwaysTransformToAIAssistant:!0,rootParentOnly:!0}}]:[{name:r.yQ,key:"write-post-from-list",aiSuggestion:r.pE,icon:u.A,options:{userPrompt:"Write a post based on the list items. Include a title as first order heading and try to use secondary headings for each entry"}}]};function _({blockType:e,clientId:t,disabled:n=!1,onAskAiAssistant:i,onRequestSuggestion:a}){const l=(0,h.C)("ai-correct-spelling"),c=x[e]??[],{getBlockParents:u}=(0,o.select)("core/block-editor"),d=u(t);return(0,f.jsxs)(f.Fragment,{children:[n&&(0,f.jsx)(s.Notice,{status:"warning",isDismissible:!1,className:"jetpack-ai-assistant__info",children:__("Add content to activate the tools below","jetpack")}),(0,f.jsxs)(s.MenuGroup,{children:[(0,f.jsx)(s.MenuItem,{icon:r.cj,iconPosition:"left",onClick:i,disabled:n,children:(0,f.jsx)("div",{className:"jetpack-ai-assistant__menu-item",children:__("Ask AI Assistant","jetpack")})},"key-ai-assistant"),[...x.default,...c].filter(e=>!(e.options?.rootParentOnly&&d.length>0||e.key===b&&!l)).map(e=>(0,f.jsx)(s.MenuItem,{icon:e?.icon,iconPosition:"left",onClick:()=>{a(e.aiSuggestion,{...e.options??{}})},disabled:n,children:(0,f.jsx)("div",{className:"jetpack-ai-assistant__menu-item",children:e.name})},`key-${e.key}`)),(0,f.jsx)(g.hN,{onChange:e=>{a(r.eJ,{tone:e})},disabled:n}),(0,f.jsx)(m.HU,{onChange:e=>{a(r.Gm,{language:e})},disabled:n})]})]})}},32249(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(3924),s=n(56427),o=n(27723),i=n(79654),a=(n(49663),n(10790));const __=o.__;const l=function(){const e=(0,r.A)("jetpack-ai-feedback");return(0,a.jsx)("div",{className:"jetpack-ai-feedback-control",children:(0,a.jsxs)(s.BaseControl,{children:[(0,a.jsx)(s.BaseControl.VisualLabel,{children:__("Feedback","jetpack")}),(0,a.jsx)("p",{children:__("Your feedback is valuable in our commitment to refine and improve this feature.","jetpack")}),(0,a.jsx)(i.N,{openInNewTab:!0,href:e,children:__("Share your feedback","jetpack")})]})})}},2162(e,t,n){"use strict";n.d(t,{Ay:()=>g,HU:()=>f});var r=n(96865),s=n(85985),o=n(56427),i=n(27723),a=n(13109),l=n(48329),c=n(41490),u=(n(97850),n(10790));const __=i.__,d=["en","es","fr","de","it","pt","ru","zh","ja","ar","hi","ko"],p=window?.Jetpack_Editor_Initial_State?.siteLocale||navigator?.language,h=p?.split("-")[0]||"en",m=(p?.split("-"),({value:e,onChange:t})=>{const n=[...d.filter(e=>e!==h)];return d.includes(h)&&n.unshift(h),(0,u.jsx)(o.MenuGroup,{label:__("Select language","jetpack"),children:n.map(n=>(0,u.jsx)(o.MenuItem,{onClick:()=>t(n+" ("+r.so[n].label+")"),isSelected:e===n,children:r.so[n].label},`key-${n}`))})});function g({value:e=h,label:t=r.u0,onChange:n,disabled:i=!1}){const{tracks:l}=(0,s.st)();return i?(0,u.jsx)(o.Tooltip,{text:t,children:(0,u.jsx)(o.Button,{disabled:!0,children:(0,u.jsx)(a.A,{icon:c.A})})}):(0,u.jsx)(o.ToolbarDropdownMenu,{icon:c.A,label:t,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&l.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"i18n"})},children:()=>(0,u.jsx)(m,{value:e,onChange:n})})}function f({value:e=h,label:t=r.u0,onChange:n,disabled:s=!1}){return(0,u.jsx)(o.DropdownMenu,{className:"ai-assistant__i18n-dropdown",icon:c.A,label:t,toggleProps:{children:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"ai-assistant__i18n-dropdown__toggle-label",children:t}),(0,u.jsx)(a.A,{icon:l.A})]}),disabled:s},children:({onClose:t})=>(0,u.jsx)(m,{onChange:(...e)=>{n(...e),t()},value:e})})}},99050(e,t,n){"use strict";n.d(t,{Ay:()=>u});var r=n(96865),s=n(85985),o=n(56427),i=n(27723),a=n(33196),l=n(10790);const __=i.__,c=[{name:__("Summarize","jetpack"),key:"summarize",aiSuggestion:r.UA},{name:__("Make longer","jetpack"),key:"make-longer",aiSuggestion:r.br},{name:__("Make shorter","jetpack"),key:"make-shorter",aiSuggestion:r.fD}];function u({key:e,label:t=__("Improve","jetpack"),exclude:n=[],onChange:r,disabled:i=!1}){const{tracks:u}=(0,s.st)();return i?(0,l.jsx)(o.Tooltip,{text:t,children:(0,l.jsx)(o.Button,{disabled:!0,children:(0,l.jsx)(o.Icon,{icon:a.A})})}):(0,l.jsx)(o.ToolbarDropdownMenu,{icon:a.A,label:t,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&u.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"improve"})},children:()=>{const s=c.filter(e=>!n.includes(e.key));return(0,l.jsx)(o.MenuGroup,{label:t,children:s.map(t=>(0,l.jsx)(o.MenuItem,{onClick:()=>r(t.aiSuggestion,{contentType:"generated"}),isSelected:e===t.key,children:t.name},`key-${t.key}`))})}})}},33468(e,t,n){"use strict";n.d(t,{Ay:()=>b});var r=n(96865),s=n(85985),o=n(56427),i=n(27723),a=n(33196),l=n(73493),c=n(93761),u=n(90437),d=n(80224),p=n(55507),h=n(48499),m=n(10790);const __=i.__,g=[{label:__("Post about…","jetpack"),description:{original:"Write a post about ",translated:__("Write a post about","jetpack")+" "}},{label:__("Informative article on…","jetpack"),description:{original:"Craft an informative article explaining ",translated:__("Craft an informative article explaining","jetpack")+" "}},{label:__("Step-by-step tutorial on…","jetpack"),description:{original:"Write a step-by-step tutorial on ",translated:__("Write a step-by-step tutorial on","jetpack")+" "}},{label:__("Motivational post on…","jetpack"),description:{original:"Create a motivational post on ",translated:__("Create a motivational post on","jetpack")+" "}}],f=[{label:__("Say it differently…","jetpack"),description:{original:"Rewrite it in a way that ",translated:__("Rewrite it in a way that","jetpack")+" "}},{label:__("Add…","jetpack"),description:{original:"Add more details about ",translated:__("Add more details about","jetpack")+" "}},{label:__("Remove…","jetpack"),description:{original:"Remove unnecessary details about ",translated:__("Remove unnecessary details about","jetpack")+" "}}];function b({hasContentBefore:e,hasContent:t,hasPostTitle:n,contentIsLoaded:i,onPromptSelect:b,onSuggestionSelect:v}){const y=__("Write with AI…","jetpack"),k=(0,h.C)("ai-correct-spelling"),{tracks:x}=(0,s.st)();return(0,m.jsx)(o.ToolbarDropdownMenu,{className:"jetpack-ai-assistant__templates-control",icon:null,label:y,text:y,onToggle:e=>{e&&x.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"write-with-ai"})},children:({onClose:s})=>i?(0,m.jsx)(o.MenuGroup,{label:__("Write…","jetpack"),children:f.map((e,t)=>(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>{s(),b(e.description)},children:e.label},`key-${t}`))}):(0,m.jsxs)(m.Fragment,{children:[e&&(0,m.jsxs)(o.MenuGroup,{label:__("Based on preceding content…","jetpack"),children:[(0,m.jsx)(o.MenuItem,{icon:l.A,iconPosition:"left",onClick:()=>v(r.sn),children:r.DT}),k&&(0,m.jsx)(o.MenuItem,{icon:d.A,iconPosition:"left",onClick:()=>v(r.yy),children:r.DD}),(0,m.jsx)(o.MenuItem,{icon:u.A,iconPosition:"left",onClick:()=>v(r.A4),children:r.HM})]}),t&&(0,m.jsxs)(o.MenuGroup,{label:__("Based on entire content…","jetpack"),children:[t&&(0,m.jsx)(o.MenuItem,{icon:c.A,iconPosition:"left",onClick:()=>v(r.UA),children:r.JR}),t&&(0,m.jsx)(o.MenuItem,{icon:p.A,iconPosition:"left",onClick:()=>v(r.vE),children:r.mT})]}),(0,m.jsxs)(o.MenuGroup,{label:__("Write…","jetpack"),children:[n&&(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>v(r.im),children:r.Rq}),g.map((e,t)=>(0,m.jsx)(o.MenuItem,{icon:a.A,iconPosition:"left",onClick:()=>{s(),b(e.description)},children:e.label},`key-${t}`))]})]})})}},62402(e,t,n){"use strict";n.d(t,{Ay:()=>h,US:()=>u,hN:()=>p});var r=n(96865),s=n(85985),o=n(56427),i=n(27723),a=n(48329),l=(n(78518),n(10790));const __=i.__,c=["formal","informal","optimistic","humorous","serious","skeptical","empathetic","confident","passionate","provocative"],u="formal",d=({value:e,onChange:t})=>(0,l.jsx)(o.MenuGroup,{label:__("Select tone","jetpack"),children:c.map(n=>(0,l.jsx)(o.MenuItem,{onClick:()=>t(n),isSelected:e===n,children:`${r.oZ[n].emoji} ${r.oZ[n].label}`},`key-${n}`))});function p({label:e=r.uQ,value:t=u,onChange:n,disabled:s=!1}){return(0,l.jsx)(o.DropdownMenu,{icon:r.Qr,label:e,className:"ai-assistant__tone-dropdown",popoverProps:{variant:"toolbar"},toggleProps:{children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"ai-assistant__tone-dropdown__toggle-label",children:e}),(0,l.jsx)(o.Icon,{icon:a.A})]}),disabled:s},children:({onClose:e})=>(0,l.jsx)(d,{value:t,onChange:t=>{n(t),e()}})})}function h({value:e=u,onChange:t,disabled:n=!1}){const{tracks:i}=(0,s.st)();return n?(0,l.jsx)(o.Tooltip,{text:r.uQ,children:(0,l.jsx)(o.Button,{disabled:!0,children:(0,l.jsx)(o.Icon,{icon:r.Qr})})}):(0,l.jsx)(o.ToolbarDropdownMenu,{icon:r.Qr,label:r.uQ,popoverProps:{variant:"toolbar"},onToggle:e=>{e&&i.recordEvent("jetpack_ai_assistant_block_toolbar_menu_show",{tool:"tone"})},children:()=>(0,l.jsx)(d,{value:e,onChange:t})})}},51698(e,t,n){"use strict";n.d(t,{A:()=>m});var r=n(96865),s=n(94715),o=n(56427),i=n(27723),a=n(88901),l=n(60484),c=n(2162),u=n(99050),d=n(33468),p=n(62402),h=n(10790);const __=i.__,m=({contentIsLoaded:e,getSuggestionFromOpenAI:t,retryRequest:n,handleAcceptContent:i,handleTryAgain:m,showRetry:g,contentBefore:f,hasPostTitle:b,wholeContent:v,setUserPrompt:y,recordEvent:k,isGeneratingTitle:x})=>(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(s.BlockControls,{children:[!g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.ToolbarGroup,{children:(0,h.jsx)(d.Ay,{hasContentBefore:!!f?.length,hasContent:!!v?.length,hasPostTitle:b,contentIsLoaded:e,onPromptSelect:e=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"prompt-template",prompt:e.original}),y(e.translated)},onSuggestionSelect:e=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:e}),t(e)}})}),(0,h.jsxs)(s.BlockControls,{group:"block",children:[(0,h.jsx)(p.Ay,{value:"neutral",onChange:n=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:r.eJ}),t(r.eJ,{tone:n,contentType:e?"generated":null})},disabled:!e&&!v?.length}),(0,h.jsx)(c.Ay,{value:"en",onChange:n=>{k("jetpack_editor_ai_assistant_block_toolbar_button_click",{type:"suggestion",suggestion:r.Gm}),t(r.Gm,{language:n,contentType:e?"generated":null})},disabled:!e&&!v?.length}),(0,h.jsx)(u.Ay,{onChange:t,exclude:x?["summarize"]:[],disabled:!e})]})]}),(g||m)&&(0,h.jsxs)(o.ToolbarGroup,{children:[!g&&e&&m&&(0,h.jsx)(o.ToolbarButton,{onClick:m,children:__("Try Again","jetpack")}),g&&e&&(0,h.jsx)(o.ToolbarButton,{icon:a.A,onClick:i,children:__("Accept","jetpack")}),g&&(0,h.jsx)(o.ToolbarButton,{icon:l.A,onClick:n,children:__("Retry","jetpack")})]})]})})},3586(e,t,n){"use strict";n.d(t,{A:()=>j});var r=n(96865),s=n(85985),o=n(94715),i=n(74997),a=n(56427),l=n(29491),c=n(47143),u=n(86087),d=n(27723),p=n(79654),h=n(13022),m=n(27970),g=n(56199),f=n(2274),b=n(32249),v=n(51698),y=n(4393),k=n(44732),x=n(76695),_=(n(84368),n(10790));const __=d.__,w="post"===window?.Jetpack_Editor_Initial_State?.screenBase;function j({attributes:e,setAttributes:t,clientId:n,isSelected:d}){const[j,C]=(0,u.useState)(null),{tracks:A}=(0,s.st)(),{getBlock:S}=(0,c.useSelect)("core/block-editor"),E=(0,u.useRef)(null),T=(0,u.useRef)(null),{replaceBlocks:N,removeBlock:P}=(0,c.useDispatch)("core/block-editor"),{editPost:B}=(0,c.useDispatch)("core/editor"),[R,I]=(0,u.useState)((0,r.MB)(e.preTransformAction)),{isOverLimit:D,requireUpgrade:L,increaseRequestsCount:F,requestsCount:M,requestsLimit:O,currentTier:U,loading:z,tierPlansEnabled:$}=(0,r.yM)(),q=Math.max(O-M,0),{autosaveAndRedirect:H}=(0,r.ON)(),V=(0,s.Bd)(U),G=()=>{setTimeout(()=>{E.current?.focus?.()},100)},W=()=>{setTimeout(()=>{T.current?.focus?.()},100)},Z=(0,l.useViewportMatch)("medium","<"),J=(0,u.useRef)(null),{getSuggestionFromOpenAI:K,stopSuggestion:Y,showRetry:Q,contentBefore:X,postTitle:ee,retryRequest:te,wholeContent:ne,requestingState:re,error:se}=(0,y.A)({onSuggestionDone:(0,u.useCallback)(()=>{G(),F()},[F]),onUnclearPrompt:(0,u.useCallback)(()=>{W(),F()},[F]),onModeration:G,attributes:e,clientId:n,content:e.content,tracks:A,userPrompt:e.userPrompt,requireUpgrade:L,initialRequestingState:e.requestingState,contentRef:J,blockRef:T}),oe="requesting"===re,ie=["requesting","suggesting"].includes(re),ae=(0,s.xI)(),{productPageUrl:le}=(0,k.A)(),ce=(0,x.y)(n);(0,u.useEffect)(()=>{if(!ce)return;const e=JSON.parse(localStorage.getItem(ce));if(!e)return;const{type:t,options:n}=e;localStorage.removeItem(ce),K(t,n)},[ce,K]),(0,u.useEffect)(()=>{se&&C(!1)},[se]),(0,u.useEffect)(()=>{["init","done"].includes(re)&&t({requestingState:re})},[re,t]);const ue=!!e.content,de=e.promptType===r.vE,pe=__("Accept","jetpack"),he=__("Accept title","jetpack"),me=de?he:pe,ge=async()=>{let t=(0,r._E)({content:e.content||""});if(t?.split("\n").length>1&&t?.split("\n")?.[0]?.match(/^

    .*<\/h1>$/)&&!ee){const e=t.split("\n"),n=e.shift();t=e.join("\n"),B({title:n.replace(/<[^>]*>/g,"")})}const s=(0,i.rawHandler)({HTML:t});await N(n,s);const o=(e=>{let t=null;return e.forEach(e=>{const n=document.querySelector(`.wp-block[data-block="${e.clientId}"]`);if(!n)return;"true"===n.contentEditable&&(t=n);const r=n.querySelectorAll("[contenteditable=true]");t=r.length?r[r.length-1]:t}),t})(s);o&&(e=>{const t=e.ownerDocument.getSelection();t.selectAllChildren(e),t.collapseToEnd(),e.focus()})(o)},fe=()=>{ge(),A.recordEvent("jetpack_ai_assistant_block_accept",{feature:"ai-assistant"})},be=()=>{w?(B({title:e.content?e.content.trim():""}),P(n),A.recordEvent("jetpack_ai_assistant_block_accept",{feature:"ai-assistant"})):fe()},ve=()=>{Y(),G(),A.recordEvent("jetpack_ai_assistant_block_stop",{feature:"ai-assistant"})},ye=(0,o.useBlockProps)({ref:T,className:(0,h.A)({"is-waiting-response":oe})}),ke=__("Ask Jetpack AI…","jetpack"),xe=__("Write about… Make a table for…","jetpack"),_e=(0,_.jsxs)(_.Fragment,{children:[D&&d&&(0,_.jsx)(r.Hb,{placement:"ai-assistant-block"}),!ae&&(0,_.jsx)(f.A,{block:"AI Assistant"})]}),we=(0,_.jsx)(_.Fragment,{children:se?.message&&!j&&"error_quota_exceeded"!==se?.code&&(0,_.jsx)(a.Notice,{status:se.status,isDismissible:!1,className:"jetpack-ai-assistant__error",children:se.message})}),je=D&&V===s.Ti?(0,_.jsx)(r.QA,{variant:"muted"}):null,Ce=(0,u.useCallback)(e=>{e.preventDefault(),A.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:U?.slug,requests_count:M,placement:"jetpack_ai_assistant_block"}),H(e)},[A,U,M,H]);return(0,_.jsx)(a.KeyboardShortcuts,{bindGlobal:!0,shortcuts:{esc:()=>{["requesting","suggesting"].includes(re)&&ve()}},children:(0,_.jsxs)("div",{...ye,children:[ue&&(0,_.jsx)("div",{ref:J,className:"jetpack-ai-assistant__content",children:(0,_.jsx)(u.RawHTML,{children:(0,r._E)({content:e.content||""})})}),(0,_.jsxs)(o.InspectorControls,{children:[je&&(0,_.jsxs)("div",{className:"block-editor-block-card",style:{paddingTop:0},children:[(0,_.jsx)("span",{className:"block-editor-block-icon"}),je]}),(0,_.jsxs)("div",{className:"block-editor-block-card",style:{paddingTop:0},children:[(0,_.jsx)("span",{className:"block-editor-block-icon"}),(0,_.jsx)(p.N,{openInNewTab:!0,href:le,children:__("Discover all features","jetpack")})]}),(V===s._X||$&&V!==s.Ti)&&(0,_.jsx)(a.PanelBody,{initialOpen:!0,children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(m.A,{placement:g.k})})}),(0,_.jsx)(a.PanelBody,{initialOpen:!0,children:(0,_.jsx)(a.PanelRow,{children:(0,_.jsx)(b.A,{})})})]}),!ie&&ae&&!L&&(0,_.jsx)(v.A,{isWaitingState:ie,contentIsLoaded:ue,getSuggestionFromOpenAI:(e,t)=>{const n=(0,r.MB)(e,t);I(n),K(e,t)},retryRequest:te,handleAcceptContent:fe,handleAcceptTitle:be,handleTryAgain:null,showRetry:Q,contentBefore:X,hasPostTitle:!!ee?.length,wholeContent:ne,promptType:e.promptType,setUserPrompt:e=>{if(!E?.current)return;E.current.focus(),t({userPrompt:e})},recordEvent:A.recordEvent,isGeneratingTitle:de}),(0,_.jsx)(r.N0,{ref:E,disabled:L||!ae,value:e.userPrompt,placeholder:e?.content?ke:xe,onChange:e=>{C(!0),t({userPrompt:e})},onSend:()=>{I(e.userPrompt),((...e)=>{K(...e),W()})("userPrompt"),A.recordEvent("jetpack_ai_assistant_block_generate",{feature:"ai-assistant"})},onStop:ve,onAccept:()=>{de?be():fe()},onDiscard:()=>{const r=e?.content===S(n).attributes?.content;t({content:e?.originalContent,promptType:void 0,messages:e?.originalMessages}),ge(),r?A.recordEvent("jetpack_ai_assistant_block_dismiss"):A.recordEvent("jetpack_ai_assistant_block_discard",{feature:"ai-assistant"})},state:re,isTransparent:L||!ae,showButtonLabels:!Z,showAccept:"init"!==re&&ue&&!ie,acceptLabel:me,showGuideLine:ue,showRemove:e?.content?.length>0,banner:_e,error:we,customFooter:q%5!=0&&1!==M||z||V!==s._X?null:(0,_.jsx)(r.AK,{requestsRemaining:q,onUpgradeClick:Ce}),lastAction:R})]})})}},61351(e,t,n){"use strict";var r=n(94375),s=n(54681),o=n(3586),i=n(13802);n(84368),n(50797),n(78118);(0,r.M)(s,{edit:o.A,save:()=>null,transforms:i.Ay})},31124(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(96865),s=n(56427),o=n(27723),i=n(10790);const __=o.__;function a({label:e=__("AI Assistant","jetpack"),behavior:t,onAction:n,onDropdownToggle:o,renderContent:a,behaviorContext:l,disabled:c}){return(0,i.jsx)(s.Dropdown,{popoverProps:{variant:"toolbar"},renderToggle:({isOpen:o,onToggle:a})=>(0,i.jsx)(s.ToolbarButton,{className:"jetpack-ai-assistant__button",showTooltip:!0,onClick:()=>{if("function"!=typeof t)switch(t){case"action":n?.();break;case"dropdown":a()}else t({context:l})},"aria-haspopup":"true","aria-expanded":o,label:e,icon:r.cj,disabled:c}),onToggle:o,renderContent:a})}},9731(e,t,n){"use strict";n.d(t,{A:()=>b});var r=n(96865),s=n(85985),o=n(56427),i=n(86087),a=n(27723),l=n(83147),c=n(28755),u=n(10067),d=n.n(u),p=n(31124),h=n(89872),m=(n(85808),n(10790));const __=a.__,g=d()("jetpack-ai:image-extension-toolbar-dropdown"),f=(0,i.forwardRef)(({onClose:e,onRequestAltText:t,onRequestCaption:n,loadingAltText:s,loadingCaption:a},u)=>{const{requireUpgrade:d}=(0,r.yM)(),p=(0,i.useCallback)(async r=>{try{r===h.X?await(t?.()):await(n?.()),e?.()}catch(e){g("Error generating %s",r,e)}},[t,n,e]);return(0,m.jsx)("div",{className:"jetpack-ai-assistant-image-toolbar-dropdown-wrapper",tabIndex:-1,ref:u,children:(0,m.jsxs)(o.MenuGroup,{children:[(0,m.jsx)(o.MenuItem,{icon:s?(0,m.jsx)(o.Spinner,{}):c.A,iconPosition:"left",onClick:()=>{p(h.X)},disabled:!!s||d,children:__("Generate alt text","jetpack")},"key-ai-assistant-alt-text"),(0,m.jsx)(o.MenuItem,{icon:a?(0,m.jsx)(o.Spinner,{}):l.A,iconPosition:"left",onClick:()=>{p(h.Q)},disabled:!!a||d,children:__("Generate caption","jetpack")},"key-ai-assistant-caption")]})})});function b({label:e=__("AI Assistant","jetpack"),onRequestAltText:t,onRequestCaption:n,loadingAltText:o=!1,loadingCaption:a=!1,disabled:l=!1,wrapperRef:c}){const{requireUpgrade:u}=(0,r.yM)(),{tracks:d}=(0,s.st)(),h=(0,i.useCallback)(e=>{e&&(d.recordEvent("jetpack_ai_assistant_extension_toolbar_menu_show",{block_type:"core/image"}),u&&(0,r.Fs)())},[u,d]),g=(0,i.useCallback)(()=>(d.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:"alt-text",block_type:"core/image"}),t?.()),[t,d]),b=(0,i.useCallback)(()=>(d.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:"caption",block_type:"core/image"}),n?.()),[n,d]);return(0,m.jsx)(p.A,{label:e,behavior:"dropdown",onDropdownToggle:h,disabled:l,renderContent:({onClose:e})=>(0,m.jsx)(f,{ref:c,onClose:e,onRequestAltText:g,onRequestCaption:b,loadingAltText:o,loadingCaption:a})})}},78118(e,t,n){"use strict";var r=n(96865),s=n(94715),o=n(29491),i=n(47143),a=n(43656),l=n(86087),c=n(52619),u=n(10067),d=n.n(u),p=n(16204),h=n(35317),m=n(48499),g=n(10821),f=n(4647),b=n(89872),v=n(9731),y=n(10790);const k=d()("jetpack-ai:image-extension"),x=(0,m.C)("ai-assistant-image-extension"),_={group:"block"};const w=(0,o.createHigherOrderComponent)(e=>{function t(t){const{increaseRequestsCount:n,dequeueAsyncRequest:o,requireUpgrade:c}=(0,r.yM)(),{getCurrentPostId:u,isImageBusy:d}=(0,i.useSelect)(e=>{const{getCurrentPostId:n}=e(a.store);return{getCurrentPostId:n,isImageBusy:e(p.M)?.isImageBusy(t.clientId)??!1}},[t.clientId]),{getPostContent:h}=(0,r.dh)(),[m,x]=(0,l.useState)(d),[w,j]=(0,l.useState)(!1),{updateBlockAttributes:C}=(0,i.useDispatch)(a.store),{createNotice:A}=(0,i.useDispatch)("core/notices"),S=(0,l.useRef)(null),E=!!t.attributes.url,T=m||w;(0,l.useEffect)(()=>{x(d)},[d]);const N=(e,t)=>{e===b.X?x(t):e===b.Q&&j(t)},P=(0,l.useCallback)(e=>{S.current&&(S.current.setAttribute("tabindex","0"),S.current.focus()),N(e,!0)},[]),B=(0,l.useCallback)(e=>{A("error",e,{isDismissible:!0})},[A]);(0,l.useEffect)(()=>{T||S.current&&S.current.setAttribute("tabindex","-1")},[T]);const R=(0,l.useCallback)(async(e,s=!1)=>{if(!c){P(e);try{const i={};e===b.X&&(0,r.in)(t.clientId),e===b.Q&&(i.positions=[t.clientId]),o();const a=await(0,r.R0)([{role:"jetpack-ai",context:{type:e,content:h(f.P),...i,images:[{url:s?await(0,r.Zo)(t.attributes.url):t.attributes.url}]}}],{postId:u(),feature:"jetpack-ai-image-extension"});n();const l=JSON.parse(a?.replace?.(/^```json\s*/,"")?.replace(/```$/,""));if(e===b.X){const e=l.texts?.[0];C(t.clientId,{alt:e})}else if(e===b.Q){const e=l.captions?.[0];C(t.clientId,{caption:e})}N(e,!1)}catch(t){if(t?.message.includes("The image URL is invalid")&&!s)return k("Retrying with base64 image"),R(e,!0);k(`Error generating ${e}`,t),t?.message&&B(`Image ${e===b.X?"alt text":"caption"} generation failed: ${t.message}`),N(e,!1)}}},[o,u,h,n,t.attributes.url,t.clientId,c,B,P,C]);return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(e,{...t}),!g.TL&&(0,y.jsx)(s.BlockControls,{..._,children:(0,y.jsx)(v.A,{onRequestAltText:()=>R(b.X),onRequestCaption:()=>R(b.Q),loadingAltText:m,loadingCaption:w,disabled:!E,wrapperRef:S})})]})}return n=>(0,h.A)(n.name)?(0,y.jsx)(t,{...n}):(0,y.jsx)(e,{...n})},"blockEditWithAiComponents");(0,c.addFilter)("blocks.registerBlockType","jetpack/ai-assistant-support/with-ai-image-extension",function(e,t){var n;return(n=t,!!(0,g.Bi)()&&!!x&&"core/image"===n)?{...e,edit:w(e.edit),supports:{...e.supports,"jetpack/ai":{assistant:!0}}}:e},100)},10821(e,t,n){"use strict";n.d(t,{Bi:()=>c,TL:()=>l});var r=n(85985),s=n(74997),o=n(47143),i=n(48499);const a=(0,i.C)("ai-assistant-support"),l=(0,i.C)("ai-sidebar-toolbar-button");function c(){if(!(0,s.getBlockType)("jetpack/ai-assistant"))return!1;if(!a)return!1;if(!(0,r.xI)())return!1;return!((0,o.select)("core/edit-post")?.getHiddenBlockTypes?.()??[]).includes("jetpack/ai-assistant")}},4647(e,t,n){"use strict";n.d(t,{P:()=>s});var r=n(96865);const s=e=>{const t=(0,r._G)().filter(e=>"core/image"===e.name);let n=0;return e=(e=e.replace(/]*>.*?<\/figcaption>/g,"")).replace(//gs,()=>{const e=t[n];return n++,e?``:""})}},52998(e,t,n){"use strict";n.d(t,{mt:()=>i});var r=n(96865),s=n(74997),o=n(47143);class i{clientId;renderRules=[];firstUpdate=!0;behavior="dropdown";isChildBlock=!1;feature="ai-assistant";adjustPosition=!0;startOpen=!1;hideOnBlockFocus=!0;supports={};constructor(e,t=[]){this.clientId=e,this.renderRules=t}getBlock(){const{getBlock:e}=(0,o.select)("core/block-editor");return e(this.clientId)}getContent(){const e=this.getBlock();return t=(0,s.getBlockContent)(e),(0,r.rh)({content:t});var t}renderContent(e){return function(e,t=[]){return(0,r._E)({content:e,rules:t,extension:!0})}(e,this.renderRules)}onSuggestion(e){if(!e)return;const t=this.renderContent(e);this.replaceBlockContent(t)}onDone(e){this.firstUpdate=!0}replaceBlockContent(e){const[t]=(0,s.rawHandler)({HTML:e});if(!t)return;const{updateBlockAttributes:n,replaceInnerBlocks:r,__unstableMarkNextChangeAsNotPersistent:i}=(0,o.dispatch)("core/block-editor");this.firstUpdate?this.firstUpdate=!1:i(),n(this.clientId,t.attributes),i(),r(this.clientId,t.innerBlocks)}getExtensionInputPlaceholder(){return null}}},96306(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(96865),s=n(85985),o=n(86087),i=n(27723),a=n(13022),l=(n(49882),n(10790));const __=i.__,c=(0,a.A)("jetpack-ai-assistant-extension-ai-input","wp-block");function u({customPlaceholder:e,className:t,requestingState:n,requestingError:i,inputRef:u,wrapperRef:d,action:p,blockType:h,feature:m,request:g,stopSuggestion:f,close:b,undo:v,tryAgain:y,lastAction:k}){const x=e||__("Ask Jetpack AI to edit…","jetpack"),[_,w]=(0,o.useState)(""),[j,C]=(0,o.useState)(x),{checkoutUrl:A}=(0,r.ON)(),{tracks:S}=(0,s.st)(),[E,T]=(0,o.useState)(0),[N,P]=(0,o.useState)(!1),{requireUpgrade:B,requestsCount:R,requestsLimit:I,loading:D,nextTier:L,currentTier:F}=(0,r.yM)(),M=(0,o.useMemo)(()=>B||["requesting","suggesting"].includes(n),[B,n]),O=(0,o.useMemo)(()=>B&&1===F?.value,[B,F]),U=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_extension_generate",{block_type:h,feature:m}),g?.(_)},[h,m,g,S,_]),z=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_extension_stop",{block_type:h}),C(x),f?.()},[h,x,f,S]);const $=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_undo",{block_type:h,prompt:k||null}),v?.()},[h,k,S,v]),q=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_upgrade_button",{current_tier_slug:F?.slug,requests_count:R,placement:"jetpack_ai_assistant_extension"})},[F?.slug,R,S]),H=(0,o.useCallback)(()=>{S.recordEvent("jetpack_ai_assistant_try_again",{block_type:h}),y?.()},[h,S,y]);return(0,o.useEffect)(()=>{["init","done"].includes(n)&&w("")},[n]),(0,o.useEffect)(()=>{C(p||x),p&&w("")},[p,x]),(0,o.useEffect)(()=>{P(!D&&!!L&&0===_.length)},[D,L,_]),(0,o.useEffect)(()=>{const e=Math.max(I-R,0);T(e)},[I,R]),(0,l.jsx)(r.FC,{className:(0,a.A)(c,t),placeholder:j,disabled:M,value:_,state:n,showGuideLine:!0,error:i,requestsRemaining:E,showUpgradeMessage:N,showFairUsageMessage:O,upgradeUrl:A,onChange:w,onSend:U,onStop:z,onClose:function(){b?.()},onUndo:$,onUpgrade:q,onTryAgain:H,wrapperRef:d,ref:u,lastAction:k,blockType:h})}},37931(e,t,n){"use strict";n.d(t,{A:()=>p});var r=n(85985),s=n(86087),o=n(27723),i=n(52068),a=n(76695),l=n(31124),c=n(21785),u=n(10790);const __=o.__;function d({blockType:e,onClose:t,onAskAiAssistant:n,onRequestSuggestion:r}){const{canTransformToAIAssistant:o,transformToAIAssistant:l,getSelectedBlockClientIds:c}=(0,a.A)(),d=(0,s.useCallback)(s=>{const i=c(),[a]=i,u=s?.options?.alwaysTransformToAIAssistant||!1;!(i.length<2)&&o({clientId:a,blockName:e})||u?l({request:s}):(s?r?.(s.promptType,s.options):n?.(),t?.())},[e,o,c,n,t,r,l]),[p]=c();return(0,u.jsx)(i.Ay,{blockType:e,clientId:p,onRequestSuggestion:(e,t)=>{d({promptType:e,options:t})},onAskAiAssistant:async()=>{d()},disabled:!1})}function p({behavior:e,blockType:t,label:n=__("AI Assistant","jetpack"),onAskAiAssistant:o,onRequestSuggestion:i}){const{tracks:a}=(0,r.st)(),p=(0,s.useContext)(c.B),h=(0,s.useCallback)(e=>{e&&a.recordEvent("jetpack_ai_assistant_extension_toolbar_menu_show",{block_type:t})},[t,a]),m=(0,s.useCallback)(()=>{a.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_prompt_show",{block_type:t}),o?.()},[t,o,a]),g=(0,s.useCallback)((e,n)=>{a.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:e,block_type:t}),i?.(e,n)},[t,i,a]);return(0,u.jsx)(l.A,{label:n,behavior:e,onAction:m,onDropdownToggle:h,renderContent:({onClose:e})=>(0,u.jsx)(d,{blockType:t,onClose:e,onAskAiAssistant:m,onRequestSuggestion:g}),behaviorContext:p})}},27571(e,t,n){"use strict";n.d(t,{L:()=>s,l:()=>r});const r=["jetpack/field-name","jetpack/field-number","jetpack/field-email","jetpack/field-text","jetpack/field-textarea","jetpack/field-time","jetpack/field-checkbox","jetpack/field-date","jetpack/field-telephone","jetpack/field-url","jetpack/field-checkbox-multiple","jetpack/field-radio","jetpack/field-select","jetpack/field-consent","jetpack/button"],s=["core/heading","core/paragraph","core/list-item","core/list","jetpack/contact-form",...r]},21785(e,t,n){"use strict";n.d(t,{B:()=>g,Q:()=>f});var r=n(86087),s=n(10067),o=n.n(s),i=n(52998),a=n(27571),l=n(50161),c=n(22352),u=n(53269),d=n(94987),p=n(125);const h=o()("jetpack-ai-assistant:extensions:get-block-handler"),m={"core/heading":l.T,"core/paragraph":p.d,"core/list-item":d.g,"core/list":u.b,"jetpack/contact-form":c.p,...a.l.reduce((e,t)=>({...e,[t]:c.g}),{})},g=(0,r.createContext)({});function f(e,t){let n=m[e];n||(h(`No handler found for block type: ${e}. Using default handler.`),n=i.mt);const r=new n(t);return{onSuggestion:r.onSuggestion.bind(r),onDone:r.onDone.bind(r),getContent:r.getContent.bind(r),getExtensionInputPlaceholder:r.getExtensionInputPlaceholder.bind(r),behavior:r.behavior,isChildBlock:r.isChildBlock,feature:r.feature,adjustPosition:r.adjustPosition,startOpen:r.startOpen,hideOnBlockFocus:r.hideOnBlockFocus,supports:r.supports}}},50161(e,t,n){"use strict";n.d(t,{T:()=>s});var r=n(52998);class s extends r.mt{constructor(e){super(e,[])}onSuggestion(e){const t=this.getBlock();if(e.startsWith("#")||(e=`${"#".repeat(t?.attributes?.level||1)} ${e}`),e.match(/^#*\s*$/))return;const n=this.renderContent(e);this.replaceBlockContent(n)}}},8663(e,t,n){"use strict";n.d(t,{g:()=>o});var r=n(47143),s=n(52998);class o extends s.mt{jetpackFormBlockName="jetpack/contact-form";constructor(e){super(e,[]),this.behavior=this.handleBehavior,this.isChildBlock=!0,this.hideOnBlockFocus=!1}handleBehavior=({context:e})=>{const t=(0,r.dispatch)("core/block-editor"),{getBlockParentsByBlockName:n}=(0,r.select)("core/block-editor"),s=n(this.clientId,this.jetpackFormBlockName)?.[0];t.selectBlock(s),e?.[this.jetpackFormBlockName]?.handleAskAiAssistant?.()}}},22352(e,t,n){"use strict";n.d(t,{g:()=>c.g,p:()=>u});var r=n(74997),s=n(47143),o=n(27723),i=n(62514),a=n(96568),l=n(52998),c=n(8663);const __=o.__;class u extends l.mt{currentListOfValidBlocks=[];originalVariationName=null;constructor(e){super(e,[]),this.behavior="action",this.feature="jetpack-form-ai-extension",this.startOpen=!0,this.hideOnBlockFocus=!1,this.adjustPosition=!1,this.supports={file_upload_field:1}}setContent(e,t=!1){const{replaceInnerBlocks:n,updateBlockAttributes:o}=(0,s.dispatch)("core/block-editor"),l=(0,r.parse)(e).find(e=>"jetpack/contact-form"===e.name);l&&l.attributes?.variationName&&(this.originalVariationName=l.attributes.variationName);const c=e.replace(//g,""),u=(0,a.d)(c),d=(0,r.parse)(u).filter(e=>e.isValid&&!["core/freeform","core/missing","core/html"].includes(e.name));let p=!1;if(d.length0){const e=d[d.length-1],t=this.currentListOfValidBlocks[d.length-1];p=!(0,i.w)(e,t)}if(d.length>0&&(d.length!==this.currentListOfValidBlocks.length||p)&&(n(this.clientId,d),this.currentListOfValidBlocks=d),t){if(this.originalVariationName){const e=this.getBlock();e&&e.attributes.variationName!==this.originalVariationName&&o(this.clientId,{variationName:this.originalVariationName})}const e=e=>"jetpack/button"===e.name||"core/button"===e.name&&"button"===e.attributes?.tagName,t=d.filter(e),s=d.some(e=>"jetpack/form-step-navigation"===e.name);if(this.currentListOfValidBlocks=this.currentListOfValidBlocks||[],t.length>1){let r=0;this.currentListOfValidBlocks=this.currentListOfValidBlocks.filter(n=>!e(n)||(r++,r===t.length)),n(this.clientId,this.currentListOfValidBlocks)}else 0!==t.length||s||n(this.clientId,[...this.currentListOfValidBlocks,(0,r.createBlock)("core/button",{tagName:"button",type:"submit",text:__("Submit","jetpack"),lock:{remove:!0}})]);this.currentListOfValidBlocks=[]}}getExtensionInputPlaceholder(){if(!this.getContent()){const e=[__("Example: a contact form with name, email, and message fields","jetpack"),__("Example: a pizza ordering form with name, address, phone number and toppings","jetpack"),__("Example: a survey form with multiple choice questions","jetpack")];return e[Math.floor(Math.random()*e.length)]}const e=[__("Example: remove email field","jetpack"),__("Example: make email optional","jetpack"),__("Example: add message field and make it required","jetpack")];return e[Math.floor(Math.random()*e.length)]}getContent(){const e=this.getBlock();if(!e)return"";const{innerBlocks:t}=e;return t?.length?t.reduce((e,t)=>e+(0,r.serialize)(t)+"\n\n",""):""}onSuggestion(e){this.setContent(e)}onDone(e){this.setContent(e,!0)}}},71295(e,t,n){"use strict";n.d(t,{j:()=>o});var r=n(10821),s=n(27571);function o(e){return!!(0,r.Bi)()&&!!s.L.includes(e)}},94987(e,t,n){"use strict";n.d(t,{g:()=>s});var r=n(52998);class s extends r.mt{constructor(e){super(e,["listItem"]),this.isChildBlock=!0}}},53269(e,t,n){"use strict";n.d(t,{b:()=>s});var r=n(52998);class s extends r.mt{constructor(e){super(e,["list"])}}},125(e,t,n){"use strict";n.d(t,{d:()=>a});var r=n(96865),s=n(74997),o=n(52998);const i=new r.OO({fixes:["paragraph"]});class a extends o.mt{constructor(e){super(e,["paragraph"])}getContent(){const e=this.getBlock();return t=(0,s.getBlockContent)(e),i.render({content:t});var t}}},50797(e,t,n){"use strict";var r=n(96865),s=n(85985),o=n(94715),i=n(29491),a=n(47143),l=n(86087),c=n(52619),u=n(13022),d=n(10067),p=n.n(d),h=n(32735),m=n(35317),g=n(4e4),f=n(10821),b=n(96306),v=n(37931),y=n(21785),k=n(71295),x=n(10790);const _=p()("jetpack-ai-assistant:extensions:with-ai-extension"),w={"core/heading":"heading","core/paragraph":"paragraph","core/list-item":"list-item","core/list":"list","jetpack/contact-form":"form-ai"},j={group:"block"},C=(0,i.createHigherOrderComponent)(e=>{function t(t){const{clientId:n,isSelected:i,name:d,isSelectionEnabled:p}=t,m=(0,l.useRef)(null),k=(0,l.useRef)(0),C=(0,l.useRef)(null),A=(0,l.useRef)(""),S=(0,l.useRef)(null),E=(0,l.useRef)(document),T=(0,l.useRef)([]),[N,P]=(0,l.useState)(""),[B,R]=(0,l.useState)(null),I=(0,l.useRef)(null),D=(0,l.useRef)(null),L=(0,l.useRef)(null),F=(0,l.useRef)(null),{undo:M}=(0,a.useDispatch)("core/editor"),{postId:O}=(0,a.useSelect)(e=>{const{getCurrentPostId:t}=e("core/editor");return{postId:t()}},[]),{id:U,className:z}=(0,o.useBlockProps)({className:(0,u.A)({[d?.replace?.("/","-")]:!0})}),{increaseRequestsCount:$,dequeueAsyncRequest:q,requireUpgrade:H}=(0,r.yM)(),{snapToBottom:V,enableAutoScroll:G,disableAutoScroll:W}=(0,h.A)({current:E?.current?.getElementById(U)},void 0,!0),Z=(0,l.useCallback)(()=>{S.current?.focus()},[]),{tracks:J}=(0,s.st)(),{onSuggestion:K,onDone:Y,getContent:Q,getExtensionInputPlaceholder:X,behavior:ee,isChildBlock:te,feature:ne,adjustPosition:re,startOpen:se,hideOnBlockFocus:oe,supports:ie}=(0,l.useMemo)(()=>(0,y.Q)(d,n),[d,n]),ae=X(),[le,ce]=(0,l.useState)(se),ue=(0,l.useCallback)(()=>{ce(e=>!e)},[]),de=(0,l.useCallback)(({promptType:e,options:t})=>{const n=Q(),r=w[d];return[...T.current,{role:"jetpack-ai",context:{type:(0,g.p$)(e,r),content:n,request:t?.userPrompt,tone:t?.tone,language:t?.language,is_follow_up:T.current.length>0,supports:ie}}]},[d,Q,ie]),pe=(0,l.useCallback)(e=>{const t=e||E.current.getElementById(U);t&&m.current&&t.style.setProperty("padding-bottom",`calc(${k.current+16}px + ${A.current||"0px"} )`,"important")},[U]),he=(0,l.useCallback)(e=>{K(e),re&&pe(),V()},[K,re,V,pe]),me=(0,l.useCallback)((e,t)=>{if(W(),Y(e),$(),P(""),J.recordEvent("jetpack_ai_assistant_toolbar_extension_generate",{prompt_type:I.current,model:t,generation_time:null!==F.current?window?.performance?.now?.()-F.current:null}),D.current?.message){const e={role:"assistant",content:Q()};if(T.current.push(D.current.message,e),T.current.length>20){T.current.splice(0,T.current.length-20);const e=T.current.findIndex(e=>"jetpack-ai"===e.role);-1!==e&&(T.current=T.current.slice(e),T.current[0].context={...T.current[0].context,is_follow_up:!1})}}D.current=null,setTimeout(()=>{re&&pe(),Z()},100),(0,c.doAction)("jetpack_ai_assistant_generation_complete",n,d)},[W,Y,$,Q,re,Z,pe,J,I,n,d]),ge=(0,l.useCallback)(e=>{W(),P(""),_("Request error",e),e.code!==r.mA&&e.code!==r.Or&&$()},[W,$]),{request:fe,stopSuggestion:be,requestingState:ve,model:ye,error:ke,reset:xe}=(0,r.o2)({onSuggestion:he,onDone:me,onError:ge,askQuestionOptions:{postId:O,feature:ne}});(0,l.useEffect)(()=>{L.current=ve},[ve]);const _e=(0,l.useCallback)((e,t)=>{if(ce(!0),H)return;I.current=e;const n=(0,r.MB)(e,t);n&&(P(n),R(n));const s=de({promptType:e,options:t});_("Request suggestion",e,t);const o=s[s.length-1];D.current={promptType:e,options:t,humanText:n,message:o},q(),G(),F.current=window?.performance?.now?.()||null,fe(s)},[q,G,de,fe,H]),we=(0,l.useCallback)(e=>{const t={userPrompt:e};R(e),G(),_e("userPrompt",t)},[G,_e]),je=(0,l.useCallback)(()=>{W(),be(),Z()},[W,be,Z]),Ce=(0,l.useCallback)(()=>{D.current&&_e(D.current.promptType,D.current.options)},[D,_e]),Ae=(0,l.useCallback)(()=>{ce(!1),xe(),P(""),D.current=null,T.current=[]},[xe]),Se=(0,l.useCallback)(async()=>{J.recordEvent("jetpack_ai_assistant_toolbar_extension_undo",{prompt_type:I.current,model:ye}),await M(),Ae()},[M,Ae,J,ye,I]);(0,l.useEffect)(()=>{i||Ae()},[i,Ae]),(0,l.useEffect)(()=>{S.current&&p&&(E.current=S.current.ownerDocument,Z())},[le,Z,p]),(0,l.useEffect)(()=>{let e=E.current.getElementById(U);if(e&&re)return le&&!C.current&&m.current?(A.current=e.style.paddingBottom,C.current=new ResizeObserver(([t])=>{if(e=E.current.getElementById(U),k.current=t.contentRect.height,e&&m.current&&k.current>0){pe(e);const{marginBottom:t}=getComputedStyle(e),n=parseFloat(t);m.current.style.setProperty("margin-top",`-${k.current+n}px`,"important"),m.current.style.setProperty("margin-bottom",`${n+16}px`,"important")}}),C.current.observe(m.current)):C.current&&(e.style.paddingBottom=A.current,C.current.disconnect(),C.current=null,k.current=0),()=>{C.current&&C.current.disconnect()}},[pe,re,n,C,U,le]),(0,l.useEffect)(()=>{if(oe&&le){const e=E.current.getElementById(U),t=()=>{["requesting","suggesting"].includes(L.current)||(ce(!1),e?.removeEventListener("focusin",t))};return e?.addEventListener("focusin",t),()=>{e?.removeEventListener("focusin",t)}}},[oe,le,U]);const Ee=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(e,{...t}),le&&(0,x.jsx)(b.A,{customPlaceholder:ae||null,className:z,requestingState:ve,requestingError:ke,wrapperRef:m,inputRef:S,action:N,blockType:d,feature:ne,request:we,stopSuggestion:je,close:Ae,undo:Se,tryAgain:Ce,lastAction:B}),!f.TL&&(0,x.jsx)(o.BlockControls,{...j,children:(0,x.jsx)(v.A,{blockType:d,onAskAiAssistant:ue,onRequestSuggestion:_e,behavior:ee})})]});if(te)return Ee;const Te={value:{[d]:{handleAskAiAssistant:ue,handleRequestSuggestion:_e}}};return(0,x.jsx)(y.B.Provider,{...Te,children:Ee})}return n=>{const r=(0,m.A)(n.name);return n.clientId&&n.attributes&&r?(0,x.jsx)(t,{...n}):(0,x.jsx)(e,{...n})}},"blockEditWithAiComponents");(0,c.addFilter)("blocks.registerBlockType","jetpack/ai-assistant-support/with-ai-text-extension",function(e,t){return(0,k.j)(t)?{...e,edit:C(e.edit),supports:{...e.supports,"jetpack/ai":{assistant:!0}}}:e},100)},89872(e,t,n){"use strict";n.d(t,{Q:()=>s,X:()=>r});const r="images-alt-text",s="images-caption"},4393(e,t,n){"use strict";n.d(t,{A:()=>h});var r=n(96865),s=n(47143),o=n(86087),i=n(10067),a=n.n(i),l=n(62402),c=n(64425),u=n(16597),d=n(32735);const p=a()("jetpack-ai-assistant:error"),h=({attributes:e,clientId:t,content:n,tracks:i,userPrompt:a,onSuggestionDone:h,onUnclearPrompt:m,onModeration:g,requireUpgrade:f,initialRequestingState:b,contentRef:v,blockRef:y})=>{const[k,x]=(0,o.useState)(!1),[_,w]=(0,o.useState)(""),{updateBlockAttributes:j}=(0,s.useDispatch)("core/block-editor"),{dequeueAiAssistantFeatureAsyncRequest:C,setAiAssistantFeatureRequireUpgrade:A}=(0,s.useDispatch)("wordpress-com/plans"),{snapToBottom:S,enableAutoScroll:E,disableAutoScroll:T}=(0,d.A)(y,v),N=(0,s.useSelect)(e=>e("core/editor").getEditedPostAttribute("title")),P=(0,s.useSelect)(e=>e("core/editor").getCurrentPostId()),B=(0,o.useRef)([]),R=(0,o.useRef)(void 0),{request:I,stopSuggestion:D,handleErrorQuotaExceededError:L,requestingState:F,error:M}=(0,r.o2)({onSuggestion:e=>{j(t,{content:e?.replaceAll(c.uV,"")}),S()},onDone:e=>{const n=e.replaceAll(c.uV,""),r={role:"assistant",content:n};B.current.push(R.current,r),B.current.length>20&&B.current.splice(0,B.current.length-20),j(t,{content:n,messages:B.current}),S(),T(),h?.()},onStop:()=>{S(),T(),h?.()},onError:e=>{switch(e?.code){case r.cT:x(!1);break;case r.ud:x(!1),g?.();break;case r.mA:case r.AZ:x(!0);break;case r.Or:x(!1),A(!0);break;case r.L9:m?.()}},onAllErrors:e=>{p(e)},initialRequestingState:b,askQuestionOptions:{postId:P,feature:"ai-assistant",functions:{}}}),O=["requesting","suggesting"].includes(F),U=async(s,o={})=>{if(C(),f)return L(),void x(!1);if(o={retryRequest:!1,tone:l.US,...o},O)return;x(!1);let d=_;if(i.recordEvent("jetpack_ai_chat_completion",{post_id:P}),B.current=[...e.messages],R.current={},o.retryRequest)R.current=d[d.length-1];else{const i=e?.isLayoutBuldingModeEnable?(0,u.rJ)(t):(0,u.aB)();d=(0,c.jf)({generatedContent:n,allPostContent:i,postContentAbove:(0,u.b$)(t),currentPostTitle:N,options:o,userPrompt:o?.userPrompt||a,type:s,isGeneratingTitle:e.promptType===r.vE}),R.current=d.pop(),d=[...d,...B.current],d.push(R.current),w(d),e.promptType!==r.vE&&j(t,{promptType:s})}try{E(),await I(d)}catch(e){p(e),x(!0),T()}};return{setShowRetry:x,showRetry:k,postTitle:N,contentBefore:(0,u.b$)(t),wholeContent:(0,u.aB)(),requestingState:F,error:M,getSuggestionFromOpenAI:U,stopSuggestion:D,retryRequest:()=>U("",{retryRequest:!0})}}},44732(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(3924),s=n(97999),o=n(85985);function i(){const e=(0,o.Mm)()&&!(0,s.isSimpleSite)(),t=e?(0,s.getMyJetpackUrl)("#/jetpack-ai"):(0,r.A)("org-ai"),{autosaveAndRedirect:n,isRedirecting:i}=(0,o.ZR)(t);return{productPageUrl:t,autosaveAndRedirect:n,isRedirecting:i,isMyJetpackAvailable:e}}},75956(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(90372),s=n(86087);const o=window?.Jetpack_Editor_Initial_State?.tracksUserData||null,i=parseInt(window?.Jetpack_Editor_Initial_State?.wpcomBlogId)||0,a=()=>((0,s.useEffect)(()=>{o&&r.A.initialize(o?.userid,o?.username,i?{blog_id:i}:{})},[]),r.A)},32735(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(86087),s=n(10067);const o=n.n(s)()("jetpack-ai-assistant:use-auto-scroll"),i=(e,t,n=!1)=>{const s=(0,r.useRef)(null),i=(0,r.useRef)(null),a=(0,r.useRef)(!1),l=(0,r.useRef)(!1),c=(0,r.useRef)(!1),u=(0,r.useRef)(!1),d=(0,r.useRef)({scrollPadding:"",scrollMargin:""}),p=(0,r.useCallback)(()=>{o("enabling ignore scroll"),l.current=!0},[]),h=(0,r.useCallback)(()=>{a.current&&c.current&&!l.current&&p()},[p]),m=(0,r.useCallback)(()=>{a.current=!0,l.current=!1,c.current=!1,u.current=!1,s.current?.addEventListener("scroll",h),o("enabling auto scroll")},[h]),g=(0,r.useCallback)(()=>{a.current=!1,l.current=!1,c.current=!1,u.current=!1,s.current?.removeEventListener("scroll",h),i.current?.style&&(i.current.style.scrollPadding=d.current.scrollPadding,i.current.style.scrollMargin=d.current.scrollMargin),s.current=null,o("disabling auto scroll")},[h]),f=(0,r.useCallback)(()=>{if(!a.current||l.current)return;const r=n?e?.current:t?.current?.firstElementChild?.lastElementChild;r&&!u.current&&(c.current=!0,u.current=!0,s?.current?.removeEventListener?.("scroll",h),r?.scrollIntoView({block:"end",inline:"end"}),setTimeout(()=>{u.current=!1,s?.current?.addEventListener?.("scroll",h)},200))},[e,t,n,h]),b=(0,r.useCallback)(e=>{if(null==e)return null;if("BODY"===e?.nodeName)return e;if(e?.ownerDocument!==document)return e.ownerDocument;const{overflow:t}=window.getComputedStyle(e);return t.split(" ").every(e=>"auto"===e||"scroll"===e)?e:e?.parentElement?b(e?.parentElement):e},[]);return(0,r.useEffect)(()=>{const t=b(e?.current?.parentElement);!s.current&&t&&(s.current=t,i.current=t instanceof HTMLElement?t:t.documentElement,d.current={scrollPadding:i.current.style.scrollPadding,scrollMargin:i.current.style.scrollMargin},a.current&&(i.current.style.scrollPadding="80px",i.current.style.scrollMargin="10px"))},[e,b]),{snapToBottom:f,enableAutoScroll:m,disableAutoScroll:g}}},35317(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(85985);const s={"jetpack/contact-form":"contact-form"};function o(e){const t=s[e],{isModuleActive:n}=(0,r.q7)(t);return!t||n}},76695(e,t,n){"use strict";n.d(t,{A:()=>c,y:()=>l});var r=n(85985),s=n(47143),o=n(51609),i=n(16597),a=n(13802);function l(e){return`ai-assistant-block-${e}`}const c=()=>{const{replaceBlock:e,removeBlocks:t}=(0,s.useDispatch)("core/block-editor"),n=(0,s.useSelect)(e=>e("core/block-editor"),[]),{getSelectedBlockClientIds:c,getBlocksByClientId:u,getBlock:d,getBlockParents:p}=n,{tracks:h}=(0,r.st)();return{canTransformToAIAssistant:(0,o.useCallback)(({clientId:e,blockName:t})=>{if(!d(e))return!1;if(!a.y7.includes(t))return!1;const n=p(e);if(0===n.length)return!0;const r=d(n[n.length-1]);return!["core/list","core/list-item"].includes(r.name)},[d,p]),transformToAIAssistant:(0,o.useCallback)(({request:n}={})=>{const r=c(),s=u(r),o=(0,i.Sb)(s),[d]=s,[p,...m]=r,g={...d?.attributes||{},content:o,preTransformAction:n?.promptType},f=(0,a.rr)(d.name,g);if(n?.promptType){h.recordEvent("jetpack_editor_ai_assistant_extension_toolbar_button_click",{suggestion:n.promptType,block_type:d.name});const e={clientId:p,type:n.promptType,options:{...n.options,contentType:"generated",fromExtension:!0}};localStorage.setItem(l(f.clientId),JSON.stringify(e))}else h.recordEvent("jetpack_ai_assistant_prompt_show",{block_type:d.name});e(p,f),t(m)},[u,c,t,e,h]),getSelectedBlockClientIds:c}}},4e4(e,t,n){"use strict";n.d(t,{J1:()=>s,K6:()=>o,p$:()=>a});var r=n(96865);function s(e){return{role:"jetpack-ai",context:{type:"ai-assistant-initial-prompt",for:a(e)}}}function o({generatedContent:e,allPostContent:t,postContentAbove:n,currentPostTitle:s,options:o,type:a,userPrompt:l,isGeneratingTitle:c}){const u=[],d="generated"===o?.contentType;let p=null;switch(a){case r.im:p=s;break;case r.sn:case r.A4:case r.yy:p=n;break;case r.vE:p=t;break;case r.br:case r.fD:p=e;break;case r.eJ:case r.UA:case r.Gm:p=d?e:t;break;case r.d5:p=n;break;case r.pE:p=e||t}const h=function(e,t){return!e&&t&&t.length>0?{role:"jetpack-ai",context:{type:"ai-assistant-relevant-content",content:t}}:null}(a===r.pE?!!e?.length:d,p);return h&&u.push(h),u.push({role:"jetpack-ai",context:i({generatedContent:e,allPostContent:t,postContentAbove:n,currentPostTitle:s,options:o,type:a,userPrompt:l,isGeneratingTitle:c})}),u}function i({options:e,type:t,userPrompt:n,isGeneratingTitle:s}){const o=function(e,t,n){return e?"title":!t||n?"content":null}(s,"generated"===e?.contentType,e?.fromExtension||!1);return{type:a(t),...o?{subject:o}:{},...t===r.eJ&&e?.tone?{tone:e.tone}:{},...t===r.Gm&&e?.language?{language:e.language}:{},...t===r.pE&&n?{request:n}:{}}}function a(e,t){const n={[r.im]:"ai-assistant-summary-by-title",[r.sn]:"ai-assistant-continue-writing",[r.A4]:"ai-assistant-simplify",[r.yy]:"ai-assistant-correct-spelling",[r.vE]:"ai-assistant-generate-title",[r.br]:"ai-assistant-make-longer",[r.fD]:"ai-assistant-make-shorter",[r.eJ]:"ai-assistant-change-tone",[r.UA]:"ai-assistant-summarize",[r.Gm]:"ai-assistant-change-language",[r.pE]:"ai-assistant-user-prompt",[r.d5]:"ai-assistant-transform-list-to-table"};return"form-ai"===t?"form-ai-extension":t?`${n[e]}-${t}-extension`:n[e]}},64425(e,t,n){"use strict";n.d(t,{jf:()=>o,uV:()=>s});n(96865);var r=n(4e4);const s="````";function o({generatedContent:e,allPostContent:t,postContentAbove:n,currentPostTitle:s,options:o,type:i,userPrompt:a,isGeneratingTitle:l}){return[(0,r.J1)(i),...(0,r.K6)({generatedContent:e,allPostContent:t,postContentAbove:n,currentPostTitle:s,options:o,type:i,userPrompt:a,isGeneratingTitle:l})]}},16597(e,t,n){"use strict";n.d(t,{Sb:()=>l,aB:()=>a,b$:()=>i,rJ:()=>c});var r=n(96865),s=n(74997),o=n(47143);function i(e){if(!e)return"";const t=(0,o.select)("core/block-editor"),n=t.getBlockIndex(e),i=t.getBlocks().slice(0,n)??[];return i?.length?(0,r.rh)({content:(0,s.serialize)(i)}):""}function a(){const e=(0,o.select)("core/block-editor").getBlocks();return e?.length?(0,r.rh)({content:(0,s.serialize)(e)}):""}function l(e){return e.filter(e=>null!=e).map(e=>(0,s.getBlockContent)(e)).join("\n\n")}function c(e){const t=(0,o.select)("core/block-editor").getBlock(e);return t?.innerBlocks?.length?l(t.innerBlocks):""}},62514(e,t,n){"use strict";n.d(t,{w:()=>o});const r=e=>{delete e.clientId;for(const t of e.innerBlocks??[])r(t);return e},s=e=>r((e=>JSON.parse(JSON.stringify(e)))(e));function o(e,t){const n=s(e),r=s(t);return JSON.stringify(n)===JSON.stringify(r)}},96568(e,t,n){"use strict";function r(e){const t=document.createElement("div");return t.innerHTML=e,t.innerHTML}n.d(t,{d:()=>r})},48499(e,t,n){"use strict";n.d(t,{C:()=>s});var r=n(85985);function s(e){return!0===(0,r.FB)(e).available}},13802(e,t,n){"use strict";n.d(t,{Ay:()=>c,rr:()=>l,y7:()=>i});var r=n(96865),s=n(74997),o=n(54681);const i=["core/heading","core/paragraph","core/list"],a=[];function l(e,t){const{content:n,...i}=t;let a=n;"core/heading"===e&&t?.level&&(a=a.replace(/<(\/?)h\d([^>]*)>/g,`<$1h${t.level}$2>`));const l=(0,r.rh)({content:a}),c=[];return c.push({role:"jetpack-ai",context:{type:"ai-assistant-relevant-content",content:l}}),(0,s.createBlock)(o.name,{...i,content:l,originalContent:l,messages:c,originalMessages:c})}for(const e of i)a.push({type:"block",blocks:[e],isMatch:()=>i.includes(e),transform:(t,n)=>{const r=(0,s.getSaveContent)(e,t,n);return l(e,{...t,content:r})}});const c={from:a}},60487(e,t,n){"use strict";n.d(t,{A:()=>p});var r=n(56427),s=n(86087),o=n(27723),i=n(13022),a=n(66087),l=n(10790);const __=o.__,c="09:00",u="17:00";class d extends s.Component{renderInterval=(e,t)=>{const{day:n}=this.props,{opening:o,closing:a}=e;return(0,l.jsxs)(s.Fragment,{children:[(0,l.jsxs)("div",{className:"business-hours__row",children:[(0,l.jsx)("div",{className:(0,i.A)(n.name,"business-hours__day"),children:0===t&&this.renderDayToggle()}),(0,l.jsxs)("div",{className:(0,i.A)(n.name,"business-hours__hours"),children:[(0,l.jsx)(r.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"time",label:__("Opening","jetpack"),value:o,className:"business-hours__open",placeholder:c,onChange:e=>{this.setHour(e,"opening",t)}}),(0,l.jsx)(r.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,type:"time",label:__("Closing","jetpack"),value:a,className:"business-hours__close",placeholder:u,onChange:e=>{this.setHour(e,"closing",t)}})]}),(0,l.jsx)("div",{className:"business-hours__remove",children:n.hours.length>1&&(0,l.jsx)(r.Button,{isSmall:!0,variant:"link",icon:"trash",label:__("Remove Hours","jetpack"),onClick:()=>{this.removeInterval(t)}})})]}),t===n.hours.length-1&&(0,l.jsxs)("div",{className:"business-hours__row business-hours-row__add",children:[(0,l.jsx)("div",{className:(0,i.A)(n.name,"business-hours__day"),children:" "}),(0,l.jsx)("div",{className:(0,i.A)(n.name,"business-hours__hours"),children:(0,l.jsx)(r.Button,{variant:"link",label:__("Add Hours","jetpack"),onClick:this.addInterval,children:__("Add Hours","jetpack")})}),(0,l.jsx)("div",{className:"business-hours__remove",children:" "})]})]},t)};setHour=(e,t,n)=>{const{day:r,attributes:s,setAttributes:o}=this.props,{days:i}=s;o({days:i.map(s=>s.name===r.name?{...s,hours:s.hours.map((r,s)=>s===n?{...r,[t]:e}:r)}:s)})};toggleClosed=e=>{const{day:t,attributes:n,setAttributes:r}=this.props,{days:s}=n;r({days:s.map(n=>{if(n.name===t.name){const t=e?[{opening:c,closing:u}]:[];return{...n,hours:t}}return n})})};addInterval=()=>{const{day:e,attributes:t,setAttributes:n}=this.props,{days:r}=t;e.hours.push({opening:"",closing:""}),n({days:r.map(t=>t.name===e.name?{...t,hours:e.hours}:t)})};removeInterval=e=>{const{day:t,attributes:n,setAttributes:r}=this.props,{days:s}=n;r({days:s.map(n=>t.name===n.name?{...n,hours:n.hours.filter((t,n)=>e!==n)}:n)})};isClosed(){const{day:e}=this.props;return(0,a.isEmpty)(e.hours)}renderDayToggle(){const{day:e,localization:t}=this.props;return(0,l.jsxs)(s.Fragment,{children:[(0,l.jsx)("span",{className:"business-hours__day-name",children:t.days[e.name]}),(0,l.jsx)(r.ToggleControl,{__nextHasNoMarginBottom:!0,label:this.isClosed()?__("Closed","jetpack"):__("Open","jetpack"),checked:!this.isClosed(),onChange:this.toggleClosed})]})}renderClosed(){const{day:e}=this.props;return(0,l.jsxs)("div",{className:"business-hours__row business-hours-row__closed",children:[(0,l.jsx)("div",{className:(0,i.A)(e.name,"business-hours__day"),children:this.renderDayToggle()}),(0,l.jsx)("div",{className:(0,i.A)(e.name,"closed","business-hours__hours"),children:" "}),(0,l.jsx)("div",{className:"business-hours__remove",children:" "})]})}render(){const{day:e}=this.props;return this.isClosed()?this.renderClosed():e.hours.map(this.renderInterval)}}const p=d},39943(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(86087),s=n(27723),o=n(66087),i=n(10790);const _x=s._x,a="undefined"!=typeof window&&window.navigator?.language||"en",l=Intl?.DateTimeFormat?new Intl.DateTimeFormat(a,{hour:"numeric",minute:"numeric",hour12:!0}):null;class c extends r.Component{formatTime(e){const[t,n]=e.split(":");if(!t||!n)return!1;const r=new Date;return r.setHours(t),r.setMinutes(n),l?l.format(r):e}renderInterval=(e,t)=>{const{day:n}=this.props,r=n.hours;return(0,i.jsxs)("span",{children:[(0,s.sprintf)("%1$s - %2$s",this.formatTime(e.opening),this.formatTime(e.closing)),r.length>1+t&&(0,i.jsx)("span",{children:", "})]},t)};render(){const{day:e,localization:t}=this.props,n=e.hours.filter(e=>this.formatTime(e.opening)&&this.formatTime(e.closing));return(0,i.jsxs)("div",{className:"jetpack-business-hours__item",children:[(0,i.jsx)("dt",{className:e.name,children:t.days[e.name]}),(0,i.jsxs)("dd",{children:[(0,o.isEmpty)(n)?_x("Closed","business is closed on a full day","jetpack"):n.map(this.renderInterval),(0,i.jsx)("br",{})]})]})}}const u=c},39155(e,t,n){"use strict";n.d(t,{A:()=>b});var r=n(85985),s=n(1455),o=n.n(s),i=n(94715),a=n(56427),l=n(38443),c=n(86087),u=n(27723),d=n(9050),p=n(60487),h=n(39943),m=n(10790);const __=u.__,g=(0,r.sh)(d),f={days:{Sun:__("Sunday","jetpack"),Mon:__("Monday","jetpack"),Tue:__("Tuesday","jetpack"),Wed:__("Wednesday","jetpack"),Thu:__("Thursday","jetpack"),Fri:__("Friday","jetpack"),Sat:__("Saturday","jetpack")},startOfWeek:0},b=e=>{const{attributes:t,isSelected:n}=e,r=(0,i.useBlockProps)(),[s,u]=(0,c.useState)(f),[d,b]=(0,c.useState)(!1),{days:v}=t,{startOfWeek:y}=s,k=v.concat(v.slice(0,y)).slice(y);let x;if((0,c.useEffect)(()=>{o()({path:"/wpcom/v2/business-hours/localized-week"}).then(e=>{u(e),b(!0)},()=>{u(f),b(!0)})},[]),d)if(n)x=(0,m.jsx)("div",{className:"is-edit",children:k.map((t,n)=>(0,m.jsx)(p.A,{day:t,localization:s,...e},n))});else{const e=(0,l.getSettings)(),{formats:{time:t}}=e;x=(0,m.jsx)("dl",{className:"jetpack-business-hours",children:k.map((e,n)=>(0,m.jsx)(h.A,{day:e,localization:s,timeFormat:t},n))})}else x=(0,m.jsx)(a.Placeholder,{icon:g,label:__("Loading business hours","jetpack")});return(0,m.jsx)("div",{...r,children:x})}},71410(e,t,n){"use strict";var r=n(94375),s=n(9050),o=n(39155),i=(n(18681),n(82805),n(10790));(0,r.M)(s,{edit:e=>(0,i.jsx)(o.A,{...e}),save:()=>null})},28310(e,t,n){"use strict";n.d(t,{A:()=>s});var r=n(98329);const s={element:{type:"string",enum:["a","button","input"]},saveInPostContent:{type:"boolean",default:!1},uniqueId:{type:"string"},passthroughAttributes:{type:"object"},text:{type:"string",role:"content"},placeholder:{type:"string",role:"content"},url:{type:"string",role:"content"},textColor:{type:"string"},customTextColor:{type:"string",validator:r.A},backgroundColor:{type:"string"},customBackgroundColor:{type:"string",validator:r.A},gradient:{type:"string"},customGradient:{type:"string"},borderRadius:{type:"number"},width:{type:"string"},customVariant:{type:"string"},metaName:{type:"string"}}},12365(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(56427),s=n(86087),o=n(27723),i=n(8746),a=n(10790);const __=o.__;function l({borderRadius:e="",setAttributes:t}){const n=(0,s.useCallback)(e=>t({borderRadius:e}),[t]);return(0,a.jsx)(r.PanelBody,{title:__("Border Settings","jetpack"),children:(0,a.jsx)(r.RangeControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,allowReset:!0,initialPosition:i.hc,label:__("Border radius","jetpack"),max:i.Bs,min:i.rG,onChange:n,value:e})})}},10179(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(94715),s=n(27723),o=n(10790);const __=s.__;function i({isGradientAvailable:e,backgroundColor:t,fallbackBackgroundColor:n,fallbackTextColor:s,gradientValue:i,setBackgroundColor:a,setGradient:l,setTextColor:c,textColor:u}){const d=(0,o.jsx)(r.ContrastChecker,{backgroundColor:t.color,fallbackBackgroundColor:n,fallbackTextColor:s,isLargeText:!1,textColor:u.color});return e?(0,o.jsx)(r.__experimentalPanelColorGradientSettings,{settings:[{colorValue:u.color,label:__("Text Color","jetpack"),onColorChange:c},{colorValue:t.color,gradientValue:i,label:__("Background","jetpack"),onColorChange:a,onGradientChange:l}],title:__("Background & Text Color","jetpack"),children:d}):(0,o.jsx)(r.PanelColorSettings,{colorSettings:[{value:u.color,onChange:c,label:__("Text Color","jetpack")},{value:t.color,onChange:a,label:__("Background","jetpack")}],title:__("Background & Text Color","jetpack"),children:d})}},8746(e,t,n){"use strict";n.d(t,{Bs:()=>i,Uc:()=>s,hc:()=>o,rG:()=>a});var r=n(94715);const s=!!r.__experimentalUseGradient,o=5,i=50,a=0},2761(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(47143),s=n(38062),o=n(12365),i=n(10179),a=n(10790);function l({attributes:e,backgroundColor:t,clientId:n,context:l,fallbackBackgroundColor:c,fallbackTextColor:u,setAttributes:d,setBackgroundColor:p,setTextColor:h,textColor:m,gradientValue:g,setGradient:f,isGradientAvailable:b}){const{align:v,borderRadius:y}=e,k="jetpack/parentBlockWidth"in l,x=k?l["jetpack/parentBlockWidth"]:e.width,_=(0,r.useSelect)(e=>{const{getBlock:t,getBlockRootClientId:r}=e("core/block-editor");return t(r(n))}),{updateBlockAttributes:w}=(0,r.useDispatch)("core/block-editor");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.A,{backgroundColor:t,fallbackBackgroundColor:c,fallbackTextColor:u,gradientValue:g,setBackgroundColor:p,setGradient:f,setTextColor:h,textColor:m,isGradientAvailable:b}),(0,a.jsx)(o.A,{borderRadius:y,setAttributes:d}),(0,a.jsx)(s.D,{align:v,width:x,onChange:e=>{k?w(_.clientId,{width:e}):d({width:e})}})]})}},55903(e,t,n){"use strict";n.d(t,{A:()=>m});var r=n(94715),s=n(29491),o=n(47143),i=n(86087),a=n(27723),l=n(13022),c=n(8746),u=n(2761),d=n(7528),p=n(81177),h=(n(28769),n(10790));const __=a.__;const m=(0,s.compose)((0,r.withColors)({backgroundColor:"background-color"},{textColor:"color"}))(function(e){const{attributes:t,backgroundColor:n,className:s,clientId:a,setAttributes:m,textColor:g}=e,{borderRadius:f,element:b,placeholder:v,text:y,width:k,fontSize:x,customVariant:_,metaName:w}=t;(0,p.A)({attributes:t,clientId:a,setAttributes:m});const{metadata:j}=(0,o.useSelect)(e=>{const{getBlockAttributes:t}=e(r.store);return{metadata:t(a)?.metadata}},[a]),{updateBlockAttributes:C,__unstableMarkNextChangeAsNotPersistent:A}=(0,o.useDispatch)("core/block-editor"),{gradientClass:S,gradientValue:E,setGradient:T}=c.Uc?(0,r.__experimentalUseGradient)({gradientAttribute:"gradient",customGradientAttribute:"customGradient"}):{},N=(0,r.useBlockProps)({className:(0,l.A)("wp-block-button",s),style:{width:k}}),[P,B]=(0,d.A)(),R=(0,r.__experimentalUseBorderProps)(t),I=(0,l.A)("wp-block-button__link",R.className,{"has-background":n.color||E,[n.class]:!E&&n.class,"has-text-color":g.color,[g.class]:g.class,[S]:S,"no-border-radius":0===f,[`has-${x}-font-size`]:!!x,"has-custom-font-size":!!x,[`is-${_}`]:!!_});(0,i.useEffect)(()=>{a&&w&&j?.name!==w&&(A(),C(a,{metadata:{...j,name:w}}))},[w,j,C,a,A]);const D={...!n.color&&E?{background:E}:{backgroundColor:n.color},fontSize:t.style?.typography?.fontSize,color:g.color,borderRadius:f?f+"px":void 0,...R.style};return(0,h.jsxs)("div",{...N,children:[(0,h.jsx)(r.RichText,{allowedFormats:"input"===b?[]:void 0,className:I,disableLineBreaks:"input"===b,onChange:e=>m({text:e}),placeholder:v||__("Add text…","jetpack"),ref:B,style:D,value:y,withoutInteractiveFormatting:!0}),(0,h.jsx)(r.InspectorControls,{children:(0,h.jsx)(u.A,{gradientValue:E,setGradient:T,isGradientAvailable:c.Uc,...P,...e})})]})})},45878(e,t,n){"use strict";var r=n(94375),s=n(5383);(0,r.A)(s.U,s.W)},36270(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=(0,s.jsx)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(r.Path,{d:"M19 6.5H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7c0-1.1-.9-2-2-2zm.5 9c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v7zM8 13h8v-1.5H8V13z"})})},5383(e,t,n){"use strict";n.d(t,{U:()=>c,W:()=>u});var r=n(27723),s=n(97969),o=n(28310),i=n(55903),a=n(36270),l=n(85154);const __=r.__,c="button",u={apiVersion:3,title:__("Button","jetpack"),icon:a.A,category:(0,s.A)("design","layout"),keywords:[],supports:{html:!1,inserter:!1,align:["left","center","right"],typography:{fontSize:!0,__experimentalFontFamily:!0,__experimentalTextTransform:!0,__experimentalDefaultControls:{fontSize:!0}},__experimentalBorder:{color:!0,style:!0,width:!0,__experimentalSkipSerialization:!0,__experimentalDefaultControls:{color:!0,style:!0,width:!0}}},styles:[{name:"fill",label:__("Fill","jetpack"),isDefault:!0},{name:"outline",label:__("Outline","jetpack")}],selectors:{border:".wp-block-jetpack-button .wp-block-button__link"},attributes:o.A,edit:i.A,save:l.A,usesContext:["jetpack/parentBlockWidth"]}},85154(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(13022),o=n(8746),i=n(10790);function a({attributes:e,blockName:t,uniqueId:n}){const{backgroundColor:a,borderRadius:l,className:c,customBackgroundColor:u,customGradient:d,customTextColor:p,gradient:h,saveInPostContent:m,text:g,textColor:f,url:b,width:v,fontSize:y}=e;if(!m)return null;const k=r.useBlockProps.save(),x=(0,r.__experimentalGetBorderClassesAndStyles)(e),_=(0,r.getColorClassName)("background-color",a),w=o.Uc?(0,r.__experimentalGetGradientClass)(h):void 0,j=(0,r.getColorClassName)("color",f),C=(0,s.A)("wp-block-button","jetpack-submit-button",c,k?.className,x.className,{[`wp-block-jetpack-${t}`]:t}),A=(0,s.A)("wp-block-button__link",{"has-text-color":f||p,[j]:j,"has-background":a||h||u||d,[_]:_,[w]:w,"no-border-radius":0===l,"has-custom-width":!!v,[`has-${y}-font-size`]:!!y,"has-custom-font-size":!!y}),S={background:d||void 0,backgroundColor:_||d||h?void 0:u,fontSize:e.style?.typography?.fontSize,color:j?void 0:p,borderRadius:l?l+"px":void 0,width:v,...x.style};return(0,i.jsx)("div",{...k,className:C,children:(0,i.jsx)(r.RichText.Content,{className:A,"data-id-attr":n||"placeholder",href:b,id:n,rel:"noopener noreferrer",role:"button",style:S,tagName:"a",target:"_blank",value:g})})}},7528(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(29491),s=n(86087);function o(){const[e,t]=(0,s.useState)(),n=(0,r.useRefEffect)(n=>{const r=()=>{const r=getComputedStyle(n),s=r.backgroundColor,o=r.color;s===e?.fallbackBackgroundColor&&o===e?.fallbackTextColor||t({fallbackBackgroundColor:s,fallbackTextColor:o})},s=new MutationObserver(r);return s.observe(n,{attributeFilter:["style","class"]}),r(),()=>{s.disconnect()}},[]);return[e,n]}},81177(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(47143),s=n(86087),o=n(66087);function i({attributes:e,clientId:t,setAttributes:n}){const{passthroughAttributes:i}=e,a=(0,r.useSelect)(n=>{const r=n("core/block-editor"),s=r.getBlockRootClientId(t),o=r.getBlockAttributes(s)||{};if(!s||!i)return{};let a=!1;const l={};return Object.entries(i).forEach(([t,n])=>{const r=o[n];r!==e[t]&&(a=!0,l[t]=r)}),a?l:{}},[t,i,e]);(0,s.useEffect)(()=>{(0,o.isEmpty)(a)||n(a)},[a,n])}},95816(e,t,n){"use strict";n.d(t,{a:()=>r});const r="https://calendly.com/wpcom/jetpack-block-example"},99723(e,t,n){"use strict";n.d(t,{Ay:()=>p});var r=n(97999),s=n(94715),o=n(56427),i=n(27723),a=n(79654),l=n(5873),c=n(10790);const __=i.__,_x=i._x,u=({onEditClick:e})=>(0,c.jsx)(o.ToolbarGroup,{children:(0,c.jsx)(o.ToolbarButton,{onClick:()=>e(!0),children:__("Edit","jetpack")})}),d=e=>{const{attributes:{hideEventTypeDetails:t,url:n},defaultClassName:s,embedCode:i,parseEmbedCode:l,setAttributes:u,setEmbedCode:d}=e;let p=null;return n&&(p=(0,r.isWpcomPlatformSite)()?"https://wordpress.com/support/wordpress-editor/blocks/calendly-block/#customize-the-calendly-block":"https://jetpack.com/support/jetpack-blocks/calendly-block/#customizing-a-calendly-block"),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(o.PanelBody,{PanelBody:!0,title:__("Calendar settings","jetpack"),initialOpen:!1,children:[(0,c.jsxs)("form",{onSubmit:l,className:`${s}-embed-form-sidebar`,children:[(0,c.jsx)("input",{type:"text",id:"embedCode",onChange:e=>d(e.target.value),placeholder:__("Calendly web address or embed code…","jetpack"),value:i||"",className:"components-placeholder__input"}),(0,c.jsx)("div",{children:(0,c.jsx)(o.Button,{variant:"secondary",type:"submit",children:_x("Embed","button label","jetpack")})})]}),(0,c.jsx)(o.ToggleControl,{__nextHasNoMarginBottom:!0,label:__("Hide event type details","jetpack"),checked:t,onChange:()=>u({hideEventTypeDetails:!t})})]}),p&&(0,c.jsx)(o.Notice,{className:`${s}-color-notice`,isDismissible:!1,children:(0,c.jsx)(a.N,{openInNewTab:!0,href:p,children:__("Explore more customization options.","jetpack")})})]})},p=e=>{const{attributes:t,clientId:n,isEditingUrl:r,setAttributes:o,setIsEditingUrl:i}=e,{style:a,url:p}=t,h=[{value:"inline",label:__("Inline","jetpack")},{value:"link",label:__("Link","jetpack")}];return(0,c.jsxs)(c.Fragment,{children:[p&&!r&&(0,c.jsx)(s.BlockControls,{children:(0,c.jsx)(u,{onEditClick:i})}),p&&(0,c.jsx)(l.A,{clientId:n,styleOptions:h,onSelectStyle:o,activeStyle:a,attributes:t,viewportWidth:500}),(0,c.jsx)(s.InspectorControls,{children:(0,c.jsx)(d,{...e})})]})}},19493(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(74997),s=n(27723),o=n(98329),i=n(10790);const __=s.__,a={attributes:{backgroundColor:{type:"string",default:"ffffff",validator:o.A},submitButtonText:{type:"string",default:__("Schedule time with me","jetpack")},submitButtonTextColor:{type:"string"},submitButtonBackgroundColor:{type:"string"},submitButtonClasses:{type:"string"},hideEventTypeDetails:{type:"boolean",default:!1},primaryColor:{type:"string",default:"00A2FF",validator:o.A},textColor:{type:"string",default:"4D5055",validator:o.A},style:{type:"string",default:"inline",validValues:["inline","link"]},url:{type:"string",validator:e=>!e||e.startsWith("https://calendly.com/")},backgroundButtonColor:{type:"string"},textButtonColor:{type:"string"},customBackgroundButtonColor:{type:"string",validator:o.A},customTextButtonColor:{type:"string",validator:o.A}},migrate:e=>{const{submitButtonText:t,submitButtonTextColor:n,submitButtonBackgroundColor:s,submitButtonClasses:o,backgroundButtonColor:i,textButtonColor:a,customBackgroundButtonColor:l,customTextButtonColor:c,...u}=e,d={text:(p=e).submitButtonText||__("Schedule time with me","jetpack"),textColor:p.submitButtonTextColor||p.textButtonColor,customTextColor:p.customTextButtonColor,backgroundColor:p.submitButtonBackgroundColor||p.backgroundButtonColor,customBackgroundColor:p.customBackgroundButtonColor,url:p.url};var p;return[u,[(0,r.createBlock)("jetpack/button",{element:"a",uniqueId:"calendly-widget-id",...d})]]},save:({attributes:{url:e}})=>(0,i.jsx)("a",{href:e,children:e})}},52385(e,t,n){"use strict";n.d(t,{A:()=>w});var r=n(85985),s=n(94715),o=n(74997),i=n(56427),a=n(47143),l=n(86087),c=n(27723),u=n(79654),d=n(13022),p=n(66087),h=n(78218),m=n(56145),g=n(13248),f=n(95816),b=n(99723),v=n(38028),y=(n(78215),n(61095),n(10790));const __=c.__,_x=c._x,k="jetpack/button",x={element:"a",text:__("Schedule time with me","jetpack"),uniqueId:"calendly-widget-id",url:f.a},_=(0,r.sh)(g);const w=(0,i.withNotices)(function(e){const{attributes:t,clientId:n,name:r,noticeOperations:c,noticeUI:w,setAttributes:j}=e,C=(0,o.getBlockDefaultClassName)(r),A=(0,h.y)(g.attributes,t);(0,p.isEqual)(A,t)||j(A);const{backgroundColor:S,hideEventTypeDetails:E,primaryColor:T,textColor:N,style:P,url:B}=A,[R,I]=(0,l.useState)(B),[D,L]=(0,l.useState)(!1),[F,M]=(0,l.useState)(!1),[O,U]=(0,l.useState)({}),z=(0,s.useBlockProps)(),$=()=>{c.removeAllNotices(),c.createErrorNotice(__("Your calendar couldn't be embedded. Please double check your URL or code.","jetpack"))};(0,l.useEffect)(()=>{B&&f.a!==B&&"link"!==P&&(0,m.A)(B,M).catch(()=>{j({url:void 0}),$()})},[]);const q=e=>{if(!e)return void $();e.preventDefault();const t=(0,v.a9)(R);if(t){if(t.buttonAttributes&&"link"===t.style){const e=(0,a.select)("core/editor").getBlocksByClientId(n);e.length&&e[0].innerBlocks.forEach(e=>{(0,a.dispatch)("core/editor").updateBlockAttributes(e.clientId,t.buttonAttributes)}),U(t.buttonAttributes)}(0,m.A)(t.url,M).then(()=>{const e=(0,h.y)(g.attributes,t);j(e),L(!1),c.removeAllNotices()}).catch(()=>{j({url:void 0}),$()})}else $()},H=(0,y.jsxs)("div",{className:"wp-block-embed is-loading",children:[(0,y.jsx)(i.Spinner,{}),(0,y.jsx)("p",{children:__("Embedding…","jetpack")})]}),V=(0,y.jsxs)(i.Placeholder,{label:__("Calendly","jetpack"),instructions:__("Enter your Calendly web address or embed code below.","jetpack"),icon:_,notices:w,children:[(0,y.jsxs)("form",{onSubmit:q,children:[(0,y.jsx)("input",{type:"text",id:"embedCode",onChange:e=>I(e.target.value),placeholder:__("Calendly web address or embed code…","jetpack"),value:R||"",className:"components-placeholder__input"}),(0,y.jsx)("div",{children:(0,y.jsx)(i.Button,{variant:"secondary",type:"submit",children:_x("Embed","button label","jetpack")})})]}),(0,y.jsx)("div",{className:`${C}-learn-more`,children:(0,y.jsx)(u.N,{openInNewTab:!0,href:"https://help.calendly.com/hc/en-us/articles/223147027-Embed-options-overview",children:__("Need help finding your embed code?","jetpack")})})]}),G=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:`${C}-overlay`}),(0,y.jsx)("iframe",{src:(()=>{const e=new URLSearchParams({embed_domain:"wordpress.com",embed_type:"Inline",hide_event_type_details:E?1:0,background_color:S,primary_color:T,text_color:N});return`${B}?${e}`})(),width:"100%",height:"100%",frameBorder:"0","data-origwidth":"100%","data-origheight":"100%",title:"Calendly"})]}),W=(0,y.jsx)(s.InnerBlocks,{template:[[k,{...x,...O,passthroughAttributes:{url:"url"}}]],templateLock:"all"});return F?H:(0,y.jsxs)("div",{...z,className:(0,d.A)(z.className,{[`calendly-style-${P}`]:B&&!D}),children:[(0,y.jsx)(b.Ay,{...e,defaultClassName:C,embedCode:R,isEditingUrl:D,parseEmbedCode:q,setEmbedCode:I,setIsEditingUrl:L}),B&&!D?(Z=P,"inline"===Z?G:W):V]});var Z})},60312(e,t,n){"use strict";var r=n(74997),s=n(94375),o=n(13248),i=n(19493),a=n(52385),l=n(2668),c=n(38028);n(78215);(0,s.M)(o,{edit:a.A,save:l.A,transforms:{from:[{type:"raw",isMatch:e=>"P"===e.nodeName&&c.QL.test(e.textContent),transform:e=>{const t=(0,c.a9)(e.textContent);return(0,r.createBlock)("jetpack/calendly",t)}}]},deprecated:[i.A]})},2668(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(94715),s=n(10790);function o(){const e=r.useBlockProps.save();return(0,s.jsx)("div",{...e,children:(0,s.jsx)(r.InnerBlocks.Content,{})})}},38028(e,t,n){"use strict";n.d(t,{QL:()=>r,a9:()=>s});const r=/(^|\/\/)(calendly\.com[^"']*)/i,s=e=>{if(!e)return;const t=(e=>{const t=e.match(r);if(t)return"https://"+t[2]})(e);if(!t)return;const n=(e=>{const t={},n=new URL(e);if(t.url=n.origin+n.pathname,!n.search)return t;const r=new URLSearchParams(n.search),s=r.get("background_color"),o=r.get("primary_color"),i=r.get("text_color"),a=/^[A-Za-z0-9]{6}$/;return r.get("hide_event_type_details")&&(t.hideEventTypeDetails=r.get("hide_event_type_details")),s&&s.match(a)&&(t.backgroundColor=s),o&&o.match(a)&&(t.primaryColor=o),i&&i.match(a)&&(t.textColor=i),t})(t),s=(e=>e.indexOf("data-url")>0?"inline":e.indexOf("initPopupWidget")>0||e.indexOf("initBadgeWidget")>0?"link":void 0)(e);if(s&&(n.style=s),"link"===s){n.buttonAttributes={};const t=(e=>{let t=e.match(/false;">([^<]+)<\//);return t?t[1]:(t=e.match(/text: '([^']*?)'/),t?t[1]:void 0)})(e);t&&(n.buttonAttributes.text=t);const r=(e=>{const t=e.match(/textColor: '([^']*?)'/);if(t)return t[1]})(e);r&&(n.buttonAttributes.textColor=void 0,n.buttonAttributes.customTextColor=r);const s=(e=>{const t=e.match(/color: '([^']*?)'/);if(t)return t[1]})(e);s&&(n.buttonAttributes.backgroundColor=void 0,n.buttonAttributes.customBackgroundColor=s)}return n}},98091(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(94715),s=n(56427),o=n(86087),i=n(27723),a=n(13022),l=n(81942),c=n(10790);const __=i.__,u=e=>{const{attributes:{address:t,addressLine2:n,addressLine3:i,city:u,region:d,postal:p,country:h,linkToGoogleMaps:m},isSelected:g,setAttributes:f}=e,b=[t,n,i,u,d,p,h].some(e=>""!==e),v=(0,a.A)({"jetpack-address-block":!0,"is-selected":g}),y=(0,o.useCallback)(e=>{"Enter"===e.key&&e.preventDefault()},[]),k=(0,r.useBlockProps)({className:v}),x=(0,c.jsx)(s.ToggleControl,{__nextHasNoMarginBottom:!0,label:__("Link address to Google Maps","jetpack"),checked:m,onChange:e=>f({linkToGoogleMaps:e})});return(0,c.jsxs)("div",{...k,children:[!g&&b&&(0,l.A)(e),(g||!b)&&(0,c.jsxs)(o.Fragment,{children:[(0,c.jsx)(r.PlainText,{value:t,placeholder:__("Street Address","jetpack"),"aria-label":__("Street Address","jetpack"),onChange:e=>f({address:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:n,placeholder:__("Address Line 2","jetpack"),"aria-label":__("Address Line 2","jetpack"),onChange:e=>f({addressLine2:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:i,placeholder:__("Address Line 3","jetpack"),"aria-label":__("Address Line 3","jetpack"),onChange:e=>f({addressLine3:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:u,placeholder:__("City","jetpack"),"aria-label":__("City","jetpack"),onChange:e=>f({city:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:d,placeholder:__("State/Province/Region","jetpack"),"aria-label":__("State/Province/Region","jetpack"),onChange:e=>f({region:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:p,placeholder:__("Postal/Zip Code","jetpack"),"aria-label":__("Postal/Zip Code","jetpack"),onChange:e=>f({postal:e}),onKeyDown:y}),(0,c.jsx)(r.PlainText,{value:h,placeholder:__("Country","jetpack"),"aria-label":__("Country","jetpack"),onChange:e=>f({country:e}),onKeyDown:y}),x]})]})}},39563(e,t,n){"use strict";n.d(t,{U:()=>l,W:()=>c});var r=n(27723),s=n(5573),o=n(98091),i=n(81942),a=n(10790);const __=r.__,_x=r._x,l="address",c={apiVersion:3,title:__("Address","jetpack"),description:__("Lets you add a physical address with Schema markup.","jetpack"),keywords:[_x("location","block search term","jetpack"),_x("direction","block search term","jetpack"),_x("place","block search term","jetpack")],icon:(0,a.jsxs)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,a.jsx)(s.Path,{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zM7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 2.88-2.88 7.19-5 9.88C9.92 16.21 7 11.85 7 9z"}),(0,a.jsx)(s.Circle,{cx:"12",cy:"9",r:"2.5"})]}),category:"grow",attributes:{address:{type:"string",default:""},addressLine2:{type:"string",default:""},addressLine3:{type:"string",default:""},city:{type:"string",default:""},region:{type:"string",default:""},postal:{type:"string",default:""},country:{type:"string",default:""},linkToGoogleMaps:{type:"boolean",default:!1}},parent:["jetpack/contact-info"],edit:o.A,save:i.A}},81942(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(94715),s=n(86087),o=n(27723),i=n(10790);const __=o.__,a=({attributes:{address:e,addressLine2:t,addressLine3:n,city:r,region:o,postal:a,country:l}})=>(0,i.jsxs)(s.Fragment,{children:[e&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address1",children:e}),t&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address2",children:t}),n&&(0,i.jsx)("div",{className:"jetpack-address__address jetpack-address__address3",children:n}),r&&!(o||a)&&(0,i.jsx)("div",{className:"jetpack-address__city",children:r}),r&&(o||a)&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"jetpack-address__city",children:r}),", ",(0,i.jsx)("span",{className:"jetpack-address__region",children:o})," ",(0,i.jsx)("span",{className:"jetpack-address__postal",children:a})]}),!r&&(o||a)&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"jetpack-address__region",children:o})," ",(0,i.jsx)("span",{className:"jetpack-address__postal",children:a})]}),l&&(0,i.jsx)("div",{className:"jetpack-address__country",children:l})]}),l=({attributes:{address:e,addressLine2:t,addressLine3:n,city:r,region:s,postal:o,country:i}})=>{let a=s?`+${s},`:"";a=o?`${a}+${o}`:a;return`https://www.google.com/maps/search/${e?`${e},`:""}${t?`${t},`:""}${n?`${n},`:""}${r?`+${r},`:""}${a}${i?`+${i}`:""}`.replace(" ","+")},c=e=>{if(!(({address:e,addressLine2:t,addressLine3:n,city:r,region:s,postal:o,country:i})=>[e,t,n,r,s,o,i].some(e=>""!==e))(e.attributes))return null;const t=r.useBlockProps.save();return(0,i.jsxs)("div",{...t,children:[e.attributes.linkToGoogleMaps&&(0,i.jsx)("a",{href:l(e),target:"_blank",rel:"noopener noreferrer",title:__("Open address in Google Maps","jetpack"),children:(0,i.jsx)(a,{...e})}),!e.attributes.linkToGoogleMaps&&(0,i.jsx)(a,{...e})]})}},44246(e,t,n){"use strict";n.d(t,{A:()=>l});var r=n(94715),s=n(13022),o=n(10790);const i=["jetpack/markdown","jetpack/address","jetpack/email","jetpack/phone","jetpack/map","jetpack/business-hours","core/paragraph","core/image","core/heading","core/gallery","core/list","core/quote","core/shortcode","core/audio","core/code","core/cover","core/html","core/separator","core/spacer","core/subhead","core/video"],a=[["jetpack/email"],["jetpack/phone"],["jetpack/address"]],l=e=>{const{className:t,isSelected:n}=e,l=(0,r.useBlockProps)({className:(0,s.A)(t,{"jetpack-contact-info-block":!0,"is-selected":n})});return(0,o.jsx)("div",{...l,children:(0,o.jsx)(r.InnerBlocks,{allowedBlocks:i,templateLock:!1,template:a})})}},25907(e,t,n){"use strict";var r=n(74997),s=n(94375),o=n(39563),i=n(75173),a=n(44246),l=n(90951),c=n(70063),u=n(36611);n(75360),n(25378);(0,s.M)(i,{edit:a.A,save:u.A,transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:({idBase:e,instance:t})=>!!t?.raw&&"widget_contact_info"===e,transform:({instance:e})=>{let t=[(0,r.createBlock)("core/heading",{content:e.raw.title}),(0,r.createBlock)("jetpack/email",{email:e.raw.email}),(0,r.createBlock)("jetpack/phone",{phone:e.raw.phone}),(0,r.createBlock)("jetpack/address",{address:e.raw.address})];return e.raw.hours&&(t=[...t,(0,r.createBlock)("core/paragraph",{content:e.raw.hours})]),e.raw.showmap&&e.raw.address&&(t=[...t,(0,r.createBlock)("jetpack/map",{address:e.raw.address})]),(0,r.createBlock)("jetpack/contact-info",{},t)}}]}},[{name:o.U,settings:o.W},{name:l.U,settings:l.W},{name:c.U,settings:c.W}])},43167(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(27723),o=n(64882),i=n(27266);const __=s.__,a=e=>{const t=(0,r.useBlockProps)(),{setAttributes:n}=e;return(0,o.A)("email",e,__("Email","jetpack"),i.A,e=>n({email:e}),t)}},90951(e,t,n){"use strict";n.d(t,{U:()=>l,W:()=>c});var r=n(27723),s=n(5573),o=n(43167),i=n(27266),a=n(10790);const __=r.__,_x=r._x,l="email",c={apiVersion:3,title:__("Email Address","jetpack"),description:__("Lets you add an email address with an automatically generated click-to-email link.","jetpack"),keywords:["e-mail","email",_x("message","block search term","jetpack")],icon:(0,a.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(s.Path,{d:"M22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6zm-2 0l-8 5-8-5h16zm0 12H4V8l8 5 8-5v10z"})}),category:"grow",attributes:{email:{type:"string",default:""}},edit:o.A,save:i.A,parent:["jetpack/contact-info"]}},27266(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(86087),o=n(39904),i=n(10790);const a=({attributes:{email:e}})=>{if(!e)return null;const t=r.useBlockProps.save();return(0,i.jsx)("div",{...t,children:(n=e,n.split(/(\s+)/).map((e,t)=>{const n=e.replace(/([.,/#!$%^&*;:{}=\-_`~()\][])+$/g,"");return e.indexOf("@")&&(0,o.t)(n)?e===n?(0,i.jsx)("a",{href:`mailto:${e}`,children:e},t):(0,i.jsxs)(s.Fragment,{children:[(0,i.jsx)("a",{href:`mailto:${e}`,children:n},t),(0,i.jsx)(s.Fragment,{children:e.slice(-(e.length-n.length))})]},t):(0,i.jsx)(s.Fragment,{children:e},t)}))});var n}},42711(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(27723),o=n(64882),i=n(84330);const __=s.__,a=e=>{const t=(0,r.useBlockProps)(),{setAttributes:n}=e;return(0,o.A)("phone",e,__("Phone number","jetpack"),i.A,e=>n({phone:e}),t)}},70063(e,t,n){"use strict";n.d(t,{U:()=>l,W:()=>c});var r=n(27723),s=n(5573),o=n(42711),i=n(84330),a=n(10790);const __=r.__,_x=r._x,l="phone",c={apiVersion:3,title:__("Phone Number","jetpack"),description:__("Lets you add a phone number with an automatically generated click-to-call link.","jetpack"),keywords:[_x("mobile","block search term","jetpack"),_x("telephone","block search term","jetpack"),_x("cell","block search term","jetpack")],icon:(0,a.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(s.Path,{d:"M6.54 5c.06.89.21 1.76.45 2.59l-1.2 1.2c-.41-1.2-.67-2.47-.76-3.79h1.51m9.86 12.02c.85.24 1.72.39 2.6.45v1.49c-1.32-.09-2.59-.35-3.8-.75l1.2-1.19M7.5 3H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.49c0-.55-.45-1-1-1-1.24 0-2.45-.2-3.57-.57-.1-.04-.21-.05-.31-.05-.26 0-.51.1-.71.29l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.2c.28-.28.36-.67.25-1.02C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1z"})}),category:"grow",attributes:{phone:{type:"string",default:""}},parent:["jetpack/contact-info"],edit:o.A,save:i.A}},84330(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(94715),s=n(10790);function o(e){const t=e.match(/\d+\.\d+|\d+\b|\d+(?=\w)/g);if(!t)return e;const n=e.indexOf(t[0]);let r=n?e.substring(n-1):e,o=n?e.substring(0,n):"",i=r.replace(/\D/g,"");/[0-9/+/(]/.test(r[0])?(o=o.slice(0,-1),"+"===r[0]&&(i="+"+i)):r=r.substring(1);return[o.trim()?(0,s.jsx)("span",{className:"phone-prefix",children:o},"phonePrefix"):null,(0,s.jsx)("a",{href:`tel:${i}`,children:r},"phoneNumber")]}const i=({attributes:{phone:e}})=>{if(!e)return null;const t=r.useBlockProps.save();return(0,s.jsx)("div",{...t,children:o(e)})}},36611(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(94715),s=n(10790);const o=()=>{const e=r.useBlockProps.save();return(0,s.jsx)("div",{...e,children:(0,s.jsx)(r.InnerBlocks.Content,{})})};n.dn(o)},75800(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(4567),s=n(3975),o=n(94715),i=n(86087),a=n(13022),l=n(72730),c=n(10790);const u=({className:e=null,currency:t=null,defaultValue:n=null,disabled:u=!1,label:d="",onChange:p=null,value:h=""})=>{const[m,g]=(0,i.useState)((0,r.Ay)(h,t,{symbol:""})),[f,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),k=(0,i.useRef)(null),x=(0,i.useCallback)((e,n)=>{g(r=>{if(e!==r){const r=(0,l.C_)(e,t);r&&r>=(0,l.dv)(t)?(y(!1),n&&p?.(r)):y(!0)}return e})},[t,p]),_=()=>{k.current&&(k.current.focus(),b(!0))};return(0,i.useEffect)(()=>{if(!k.current)return;const e=k.current,s=()=>{b(!1),m||x((0,r.Ay)(n,t,{symbol:""}))};return e.addEventListener("blur",s),()=>{e.removeEventListener("blur",s)}},[t,n,m,k,x]),(0,i.useEffect)(()=>{f||v||g((0,r.Ay)(h,t,{symbol:""}))},[t,f,v,h]),(0,i.useEffect)(()=>{x((0,r.Ay)(h,t,{symbol:""}))},[t,h]),(0,c.jsxs)("div",{className:(0,a.A)("donations__amount",e,{"has-focus":f,"has-error":v}),role:"button",tabIndex:0,onClick:_,onKeyDown:_,children:[s.y[t].symbol,u?(0,c.jsx)("div",{className:"donations__amount-value",children:(0,r.Ay)(h||n,t,{symbol:""})}):(0,c.jsx)(o.RichText,{allowedFormats:[],"aria-label":d,onChange:e=>x(e,!0),placeholder:(0,r.Ay)(n,t,{symbol:""}),ref:k,value:m,withoutInteractiveFormatting:!0})]})}},22883(e,t,n){"use strict";n.d(t,{A:()=>i});const r=["left","center","right","full"],s=(e,t="border")=>{if(!e||"object"!=typeof e)return[];const n=[],r=["top","right","bottom","left"];return r.some(t=>e[t])?r.forEach(r=>{const s=e[r];s&&(s.color&&n.push(`${t}-${r}-color:${s.color}`),s.style&&n.push(`${t}-${r}-style:${s.style}`),s.width&&n.push(`${t}-${r}-width:${s.width}`))}):(e.color&&n.push(`${t}-color:${e.color}`),e.style&&n.push(`${t}-style:${e.style}`),e.width&&n.push(`${t}-width:${e.width}`)),n},o=e=>{if(!e)return[];if("string"==typeof e)return[`border-radius:${e}`];if("object"==typeof e){const t={topLeft:"border-top-left-radius",topRight:"border-top-right-radius",bottomRight:"border-bottom-right-radius",bottomLeft:"border-bottom-left-radius"};return Object.entries(t).filter(([t])=>e[t]).map(([t,n])=>`${n}:${e[t]}`)}return[]},i=(e,t)=>{const{activeTabBackgroundColor:n,activeTabTextColor:i,inactiveTabBackgroundColor:a,inactiveTabTextColor:l,selectedAmountBackgroundColor:c,selectedAmountTextColor:u,selectedAmountOutlineColor:d,tabBorderColor:p,tabFontSize:h,tabPadding:m,amountFontSize:g,amountBorder:f,amountBorderRadius:b,buttonFontSize:v,buttonPadding:y,buttonAlignment:k,buttonBorderRadius:x,contentAlignment:_,blockBorder:w,blockBorderRadius:j,displayMode:C}=e,A=[];if(["left","center","right"].includes(_)){A.push(`${t} .donations__content{text-align:${_}}`);const e={left:"flex-start",center:"center",right:"flex-end"};A.push(`${t} .donations__amounts{justify-content:${e[_]}}`)}if(p&&A.push(`${t} .donations__nav,${t} .donations__nav-item,${t} .donations__nav-item.is-active{border-color:${p}}`),x){const e=o(x);e.length&&A.push(`${t} .donations__donate-button{${e.join(";")}}`)}const S=[];g&&S.push(`font-size:${g}`),S.push(...s(f)),S.push(...o(b)),S.length&&A.push(`${t} .donations__amount{${S.join(";")}}`);const E=[];h&&E.push(`font-size:${h}`),m&&["top","right","bottom","left"].forEach(e=>{m[e]&&E.push(`padding-${e}:${m[e]}`)}),E.length&&A.push(`${t} .donations__nav-item{${E.join(";")}}`);const T=[];n&&T.push(`background:${n}`),i&&T.push(`color:${i}`),T.length&&A.push(`${t} .donations__nav-item.is-active{${T.join(";")}}`);const N=[];a&&N.push(`background:${a}`),l&&N.push(`color:${l}`),N.length&&A.push(`${t} .donations__nav-item:not(.is-active){${N.join(";")}}`);const P=[];c&&P.push(`background-color:${c}`),u&&P.push(`color:${u}`),d&&P.push(`box-shadow:0 0 0 1px #fff,0 0 0 3px ${d}`),P.length&&A.push(`${t} .donations__amount.is-selected{${P.join(";")}}`);const B=[];if(v&&B.push(`font-size:${v}`),y&&["top","right","bottom","left"].forEach(e=>{y[e]&&B.push(`padding-${e}:${y[e]}`)}),B.length&&A.push(`${t} .donations__donate-button{${B.join(";")}}`),r.includes(k)&&("full"===k?A.push(`${t} .donations__donate-button-wrapper{display:block;width:100%}${t} .donations__donate-button{display:block;width:100%;box-sizing:border-box;text-align:center}`):A.push(`${t} .donations__donate-button-wrapper{text-align:${k}}`)),"modal"!==C){const e=[...s(w),...o(j)];e.length&&A.push(`.wp-block-jetpack-donations${t}{${e.join(";")}}`)}return"modal"===C&&["left","center","right"].includes(_)&&A.push(`${t}{text-align:${_}}`),A.join("")}},57018(e,t,n){"use strict";n.d(t,{A:()=>v});var r=n(4567),s=n(3975),o=n(85985),i=n(94715),a=n(56427),l=n(47143),c=n(86087),u=n(27723),d=n(48558),p=n(72730),h=n(16521),m=n(2556),g=n(75703),f=n(10790);const __=u.__,b={"one-time":"oneTimeDonation","1 month":"monthlyDonation","1 year":"annualDonation"},v=e=>{const{attributes:t,setAttributes:n,clientId:v}=e,{tracks:y}=(0,o.st)(),k=(0,c.useRef)({}),x=!(0,l.useSelect)(e=>e(h.M).getConnectUrl()||"",[]),_=(0,c.useCallback)((e,t)=>{y.recordEvent("jetpack_donations_setting_changed",{feature:"donations",surface:"block_editor",setting_name:e,setting_value:t,stripe_connected:x})},[y,x]),w=(0,c.useCallback)((e,t)=>{k.current[e]&&clearTimeout(k.current[e]),k.current[e]=setTimeout(()=>{_(e,t),delete k.current[e]},800)},[_]),{currency:j,oneTimeDonation:C,monthlyDonation:A,annualDonation:S,showCustomAmount:E,contentAlignment:T,defaultInterval:N,customAmountPlaceholder:P,minimumAmount:B,maximumAmount:R,displayMode:I,triggerButtonText:D,triggerIcon:L,triggerSticky:F,blockBorder:M,blockBorderRadius:O}=t,U=(0,p.dv)(j),z=P??100*U,$=!1!==C.show,q=!!A.show,H=!!S.show,V=($?1:0)+(q?1:0)+(H?1:0),G=__("At least one frequency must be enabled.","jetpack"),W=(0,g.fq)($,q,H)??"one-time",Z="one-time"===N&&$||"1 month"===N&&q||"1 year"===N&&H?N:W,J={"one-time":"show_one_time","1 month":"show_monthly","1 year":"show_yearly"},K=(e,r)=>{const s=b[e],o=t[s],i={[s]:{...o,show:r}};if(!r&&Z===e){const t={oneTime:"one-time"!==e&&$,monthly:"1 month"!==e&&q,annual:"1 year"!==e&&H},n=(0,g.fq)(t.oneTime,t.monthly,t.annual);n&&(i.defaultInterval=n)}n(i),_(J[e],r)},Y={"one-time":__("One-Time","jetpack"),"1 month":__("Monthly","jetpack"),"1 year":__("Yearly","jetpack")},Q=[...$?[{value:"one-time",label:Y["one-time"]}]:[],...q?[{value:"1 month",label:Y["1 month"]}]:[],...H?[{value:"1 year",label:Y["1 year"]}]:[]],X=e=>[{value:"",label:__("None","jetpack")},...(e||[]).map((e,t)=>({value:String(t),label:(0,r.Ay)(e,j)}))],ee=e=>void 0!==e.defaultAmountIndex?String(e.defaultAmountIndex):"",te={"one-time":"default_amount_one_time","1 month":"default_amount_monthly","1 year":"default_amount_yearly"},ne=e=>r=>{const s=""===r?void 0:parseInt(r,10);((e,r,s)=>{const o=b[e];n({[o]:{...t[o],[r]:s}})})(e,"defaultAmountIndex",s),_(te[e],s??null)},re=(0,c.useCallback)(e=>n({contentAlignment:e||""}),[n]);let se;void 0!==B&&void 0!==R&&R(0,f.jsx)(a.Dropdown,{contentClassName:"jetpack-donations__currency-popover",renderToggle:({onToggle:e,isOpen:t})=>(0,f.jsx)(a.ToolbarButton,{className:"jetpack-donations__currency-toggle",icon:(0,f.jsxs)(f.Fragment,{children:[j+" - "+s.y[j].symbol,(0,f.jsx)(a.Dashicon,{icon:"arrow-down"})]}),label:__("Change currency","jetpack"),onClick:e,onKeyDown:n=>{t||n.keyCode!==d.DOWN||(n.preventDefault(),n.stopPropagation(),e())}}),renderContent:({onClose:e})=>(0,f.jsx)(a.MenuGroup,{children:Object.keys(p.VK).map(t=>(0,f.jsx)(a.MenuItem,{isSelected:t===j,icon:t===j?"yes":"",onClick:()=>{(e=>{const t=(0,p.Xj)(e);n({currency:e,oneTimeDonation:{...C,amounts:t},monthlyDonation:{...A,amounts:t},annualDonation:{...S,amounts:t},customAmountPlaceholder:void 0}),_("currency",e)})(t),e()},children:t+" - "+s.y[t].symbol},`jetpack-donations-currency-${t}`))})})})})]}),(0,f.jsxs)(i.InspectorControls,{children:[(0,f.jsxs)(a.PanelBody,{title:__("Display","jetpack"),children:[(0,f.jsxs)(a.__experimentalToggleGroupControl,{label:__("Display mode","jetpack"),value:I,onChange:e=>n({displayMode:e}),isBlock:!0,__nextHasNoMarginBottom:!0,children:[(0,f.jsx)(a.__experimentalToggleGroupControlOption,{value:"inline",label:__("In-page","jetpack")}),(0,f.jsx)(a.__experimentalToggleGroupControlOption,{value:"modal",label:__("Pop-up","jetpack")})]}),"modal"===I&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.ToggleControl,{label:__("Sticky","jetpack"),help:__("Fix the button to the bottom right corner of the page.","jetpack"),checked:!!F,onChange:e=>n({triggerSticky:e}),style:{marginTop:16},__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.TextControl,{label:__("Button text","jetpack"),value:D??"",placeholder:__("Donate","jetpack"),onChange:e=>n({triggerButtonText:e||void 0}),__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.ToggleControl,{label:__("Show icon","jetpack"),checked:"none"!==L,onChange:e=>n({triggerIcon:e?"heart":"none"}),style:{marginTop:16},__nextHasNoMarginBottom:!0}),"none"!==L&&(0,f.jsx)("div",{className:"jetpack-donations__icon-picker",children:m.Sh.map(({key:e,label:t,icon:r})=>(0,f.jsx)(a.Tooltip,{text:t,children:(0,f.jsx)(a.Button,{className:"jetpack-donations__icon-option",onClick:()=>n({triggerIcon:e}),"aria-label":t,isPressed:L===e,children:(0,f.jsx)(a.Icon,{icon:r,size:20})})},e))})]})]}),(0,f.jsxs)(a.PanelBody,{title:__("Settings","jetpack"),children:[(0,f.jsx)(a.ToggleControl,{checked:$,onChange:e=>K("one-time",e),disabled:$&&1===V,help:$&&1===V?G:void 0,label:__("Show one-time donations","jetpack"),__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.ToggleControl,{checked:q,onChange:e=>K("1 month",e),disabled:q&&1===V,help:q&&1===V?G:void 0,label:__("Show monthly donations","jetpack"),__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.ToggleControl,{checked:H,onChange:e=>K("1 year",e),disabled:H&&1===V,help:H&&1===V?G:void 0,label:__("Show annual donations","jetpack"),__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.ToggleControl,{checked:E,onChange:e=>{n({showCustomAmount:e}),_("show_custom_amount",e)},label:__("Show custom amount option","jetpack"),__nextHasNoMarginBottom:!0}),(0,f.jsx)("h3",{className:"jp-donations-defaults-heading",style:{margin:"24px 0 8px",fontSize:13,fontWeight:600,textTransform:"none"},children:__("Defaults","jetpack")}),(0,f.jsx)(a.SelectControl,{label:__("Frequency","jetpack"),value:Z,options:Q,onChange:e=>{n({defaultInterval:e}),_("default_frequency",e)},__nextHasNoMarginBottom:!0}),(0,f.jsx)("h4",{className:"jp-donations-defaults-subheading",style:{margin:"16px 0 8px",fontSize:11,fontWeight:500,textTransform:"uppercase"},children:__("Amounts","jetpack")}),$&&(0,f.jsxs)(a.Flex,{justify:"space-between",align:"center",style:{marginBottom:8},children:[(0,f.jsx)(a.FlexItem,{style:{minWidth:80},children:__("One-Time","jetpack")}),(0,f.jsx)(a.FlexBlock,{children:(0,f.jsx)(a.SelectControl,{hideLabelFromVision:!0,label:__("Default amount for One-Time","jetpack"),value:ee(C),options:X(C.amounts),onChange:ne("one-time"),__nextHasNoMarginBottom:!0})})]}),q&&(0,f.jsxs)(a.Flex,{justify:"space-between",align:"center",style:{marginBottom:8},children:[(0,f.jsx)(a.FlexItem,{style:{minWidth:80},children:__("Monthly","jetpack")}),(0,f.jsx)(a.FlexBlock,{children:(0,f.jsx)(a.SelectControl,{hideLabelFromVision:!0,label:__("Default amount for Monthly","jetpack"),value:ee(A),options:X(A.amounts),onChange:ne("1 month"),__nextHasNoMarginBottom:!0})})]}),H&&(0,f.jsxs)(a.Flex,{justify:"space-between",align:"center",style:{marginBottom:8},children:[(0,f.jsx)(a.FlexItem,{style:{minWidth:80},children:__("Annual","jetpack")}),(0,f.jsx)(a.FlexBlock,{children:(0,f.jsx)(a.SelectControl,{hideLabelFromVision:!0,label:__("Default amount for Annual","jetpack"),value:ee(S),options:X(S.amounts),onChange:ne("1 year"),__nextHasNoMarginBottom:!0})})]}),E&&(0,f.jsxs)(a.Flex,{justify:"space-between",align:"center",style:{marginBottom:8},children:[(0,f.jsx)(a.FlexItem,{style:{minWidth:80},children:__("Custom","jetpack")}),(0,f.jsx)(a.FlexBlock,{children:(0,f.jsx)(a.TextControl,{type:"number",hideLabelFromVision:!0,label:__("Suggested custom amount","jetpack"),value:z,onChange:e=>{const t=""===e||void 0===e?void 0:Number(e);n({customAmountPlaceholder:t}),w("custom_amount_placeholder",t??null)},min:(0,p.dv)(j),step:.01,__nextHasNoMarginBottom:!0})})]}),(0,f.jsx)("p",{style:{marginTop:24},children:(0,f.jsx)(a.ExternalLink,{href:`https://wordpress.com/earn/payments/${(0,o.GE)()}`,children:__("View donation earnings","jetpack")})})]}),(0,f.jsxs)(a.PanelBody,{title:__("Security","jetpack"),initialOpen:!1,children:[(0,f.jsx)("p",{style:{marginTop:0,marginBottom:16,fontSize:13},children:__("Setting minimum and maximum donation amounts can help prevent fraudulent transactions.","jetpack")}),(0,f.jsx)(a.TextControl,{type:"number",label:__("Minimum amount","jetpack"),value:B??"",onChange:e=>{const t=""===e?void 0:Number(e);n({minimumAmount:t}),w("minimum_amount",t??null)},min:U,step:.01,__nextHasNoMarginBottom:!0}),(0,f.jsx)(a.TextControl,{type:"number",label:__("Maximum amount","jetpack"),value:R??"",onChange:e=>{const t=""===e?void 0:Number(e);n({maximumAmount:t}),w("maximum_amount",t??null)},min:B??U,step:.01,help:se,__nextHasNoMarginBottom:!0})]})]}),"modal"!==I&&(0,f.jsx)(i.InspectorControls,{group:"border",children:(0,f.jsxs)(a.__experimentalToolsPanel,{label:__("Border","jetpack"),resetAll:()=>n({blockBorder:void 0,blockBorderRadius:void 0}),panelId:v,children:[(0,f.jsx)(a.__experimentalToolsPanelItem,{label:__("Border","jetpack"),hasValue:()=>!!M,onDeselect:()=>n({blockBorder:void 0}),isShownByDefault:!0,panelId:v,children:(0,f.jsx)(a.BorderBoxControl,{label:__("Border","jetpack"),value:M,onChange:e=>n({blockBorder:e}),enableAlpha:!0,enableStyle:!0,__next40pxDefaultSize:!0})}),(0,f.jsx)(a.__experimentalToolsPanelItem,{label:__("Radius","jetpack"),hasValue:()=>!!O,onDeselect:()=>n({blockBorderRadius:void 0}),isShownByDefault:!0,panelId:v,children:(0,f.jsx)(i.__experimentalBorderRadiusControl,{values:O,onChange:e=>n({blockBorderRadius:e})})})]})})]})}},27718(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(4567),s=n(3975),o=n(94715),i=n(27723),a=n(72730),l=n(10790);const __=i.__,c={attributes:{currency:{type:"string",default:"USD"},oneTimeDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a one-time donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate","jetpack")}},monthlyDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a monthly donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate monthly","jetpack")}},annualDonation:{type:"object",default:{show:!0,planId:null,amounts:[5,15,100],heading:__("Make a yearly donation","jetpack"),extraText:__("Your contribution is appreciated.","jetpack"),buttonText:__("Donate yearly","jetpack")}},showCustomAmount:{type:"boolean",default:!0},chooseAmountText:{type:"string",default:__("Choose an amount","jetpack")},customAmountText:{type:"string",default:__("Or enter a custom amount","jetpack")}},supports:{html:!1},save:({attributes:e})=>{const{currency:t,oneTimeDonation:n,monthlyDonation:i,annualDonation:c,showCustomAmount:u,chooseAmountText:d,customAmountText:p}=e;if(!n||!n.show||-1===n.planId)return null;const h={"one-time":{title:__("One-Time","jetpack")},...i.show&&{"1 month":{title:__("Monthly","jetpack")}},...c.show&&{"1 year":{title:__("Yearly","jetpack")}}};return(0,l.jsx)("div",{children:(0,l.jsxs)("div",{className:"donations__container",children:[Object.keys(h).length>1&&(0,l.jsx)("div",{className:"donations__nav",children:Object.entries(h).map(([e,{title:t}])=>(0,l.jsx)("div",{role:"button",tabIndex:0,className:"donations__nav-item","data-interval":e,children:t},`jetpack-donations-nav-item-${e} `))}),(0,l.jsx)("div",{className:"donations__content",children:(0,l.jsxs)("div",{className:"donations__tab",children:[(0,l.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__one-time-item",value:n.heading}),i.show&&(0,l.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__monthly-item",value:i.heading}),c.show&&(0,l.jsx)(o.RichText.Content,{tagName:"h4",className:"donations__annual-item",value:c.heading}),(0,l.jsx)(o.RichText.Content,{tagName:"p",value:d}),(0,l.jsx)("div",{className:"donations__amounts donations__one-time-item",children:n.amounts.map(e=>(0,l.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,r.Ay)(e,t)},e))}),i.show&&(0,l.jsx)("div",{className:"donations__amounts donations__monthly-item",children:i.amounts.map(e=>(0,l.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,r.Ay)(e,t)},e))}),c.show&&(0,l.jsx)("div",{className:"donations__amounts donations__annual-item",children:c.amounts.map(e=>(0,l.jsx)("div",{className:"donations__amount","data-amount":e,children:(0,r.Ay)(e,t)},e))}),u&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.RichText.Content,{tagName:"p",value:p}),(0,l.jsxs)("div",{className:"donations__amount donations__custom-amount",children:[s.y[t].symbol,(0,l.jsx)("div",{className:"donations__amount-value","data-currency":t,"data-empty-text":(0,r.Ay)(100*(0,a.dv)(t),t,{symbol:""})})]})]}),(0,l.jsx)("div",{className:"donations__separator",children:"——"}),(0,l.jsx)(o.RichText.Content,{tagName:"p",className:"donations__one-time-item",value:n.extraText}),i.show&&(0,l.jsx)(o.RichText.Content,{tagName:"p",className:"donations__monthly-item",value:i.extraText}),c.show&&(0,l.jsx)(o.RichText.Content,{tagName:"p",className:"donations__annual-item",value:c.extraText}),(0,l.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__one-time-item",children:(0,l.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__one-time-item",value:n.buttonText})}),i.show&&(0,l.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__monthly-item",children:(0,l.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__monthly-item",value:i.buttonText})}),c.show&&(0,l.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper donations__annual-item",children:(0,l.jsx)(o.RichText.Content,{tagName:"a",className:"wp-block-button__link donations__donate-button donations__annual-item",value:c.buttonText})})]})})]})})}}},31152(e,t,n){"use strict";n.d(t,{A:()=>T});var r=n(85985),s=n(94715),o=n(56427),i=n(29491),a=n(47143),l=n(86087),c=n(27723),u=n(2274),d=n(53796),p=n(72730),h=n(27574),m=n(26247),g=n(16521),f=n(3696),b=n(22883),v=n(57018),y=n(70975),k=n(93033),x=n(56848),_=n(2556),w=(n(16279),n(79085)),j=n(77794),C=n(36580),A=n(10790);const __=c.__,S=new Set,E=e=>{const{attributes:t,setAttributes:n,clientId:c}=e,{currency:T,tabsAppearance:N,className:P,displayMode:B,triggerButtonText:R,triggerIcon:I,triggerSticky:D}=t,{tracks:L}=(0,r.st)();(0,l.useEffect)(()=>{if("string"==typeof P&&P.split(" ").includes("is-style-buttons")){const e=P.split(" ").filter(e=>"is-style-buttons"!==e).join(" ").trim();n({tabsAppearance:"buttons",className:e||void 0})}},[P,n]);const F=(0,i.useInstanceId)(E,"jp-donations"),M=(0,b.A)(t,`.${F}`),O=[F,"buttons"===N&&"is-style-buttons","modal"===B&&"is-display-modal","modal"===B&&D&&"is-sticky"].filter(Boolean).join(" "),U=(0,s.useBlockProps)({className:O}),[z,$]=(0,l.useState)(""),[q,H]=(0,l.useState)([]),[V,G]=(0,l.useState)(!1),W=(0,m.A)(),Z=(0,a.useSelect)(e=>e(s.store).getSettings().isPreviewMode,[]),{lockPostSaving:J,unlockPostSaving:K}=(0,a.useDispatch)("core/editor"),{getEntityRecord:Y,getCurrentUser:Q}=(0,a.useSelect)("core"),{editEntityRecord:X,saveEditedEntityRecord:ee}=(0,a.useDispatch)("core"),te=(0,a.useSelect)(e=>e("core/editor").getCurrentPost(),[]),ne=(0,a.useSelect)(e=>e("core/editor").isPostSavingLocked(),[]),re=(0,a.useSelect)(e=>e(g.M).getConnectUrl()||"",[]),{setConnectUrl:se,setConnectedAccountDefaultCurrency:oe}=(0,a.useDispatch)(f.EF),ie=(0,a.useSelect)(e=>e(f.EF).getConnectedAccountDefaultCurrency());(0,l.useEffect)(()=>{if(Z||!c||S.has(c))return;W&&!re&&!ie||(S.add(c),L.recordEvent("jetpack_donations_block_loaded",{feature:"donations",surface:"block_editor",is_user_connected:!!W,stripe_connected:W?!re:null}))},[c,W,re,ie,L,Z]),(0,l.useEffect)(()=>{if(!T&&ie&&!ne){const e=ie.toUpperCase(),t=!!p.VK[e];n(t?{currency:e}:{currency:"USD"})}},[T,ie,ne,n]);const ae=e=>{$(e)},le=Q();(0,l.useEffect)(()=>{le?.id&&Y("root","user",le.id)},[le?.id,Y]);const ce=le?.meta?.jetpack_donation_warning_dismissed||!1;(0,l.useEffect)(()=>{Z||le?.id&&!1===ce&&G(!0)},[le,ce,Z]),(0,l.useEffect)(()=>{if(Z)return;J("donations");const e=e=>e.reduce((e,{id:t,currency:n,type:r,interval:s})=>(n===T&&"donation"===r&&(e[s]=t),e),{});(0,k.A)("donation").then(t=>{if(!t&&"object"!=typeof t||t.errors)return K("donations"),void $(__("Could not load data from WordPress.com.","jetpack"));se((0,h.A)(te.id,t.connect_url)),oe(t?.connected_account_default_currency?.toUpperCase());const n=e(t.products);return(e=>{const t=Object.keys(e);return t.includes("one-time")&&t.includes("1 month")&&t.includes("1 year")})(n)?(H(n),void K("donations")):t.connect_url?(H({"one-time":-1,"1 month":-1,"1 year":-1}),void K("donations")):(T&&(0,y.A)(T).then(t=>{H(e(t)),K("donations")},ae),void K("donations"))},ae)},[J,T,te.id,se,oe,K,Z]);const ue=Z?{"one-time":-1,"1 month":-1,"1 year":-1}:q,de=Z&&!T?{...e,attributes:{...t,currency:"USD"}}:e;let pe;if(Z||W)if(!Z&&z)pe=(0,A.jsx)(w.A,{error:z});else if(!Z&&re)pe=(0,A.jsx)(d.V,{blockName:"donations"});else if(Z||T)if("modal"===B){const t=_.Sh.find(({key:e})=>e===I),n=R||__("Donate","jetpack");pe=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(v.A,{...e}),(0,A.jsxs)("button",{className:"donations__trigger-button wp-block-button__link",tabIndex:-1,"aria-hidden":"true",children:[t&&"none"!==I&&(0,A.jsx)(o.Icon,{className:"donations__trigger-icon",icon:t.icon,size:20}),n]})]})}else pe=(0,A.jsx)(C.A,{...de,products:ue});else pe=(0,A.jsx)(o.Spinner,{});else pe=(0,A.jsx)(u.A,{block:"Donations Form",explanation:__("Connect your WordPress.com account to enable donations.","jetpack")});const he=(0,l.useCallback)(async()=>{if(G(!1),le?.id)try{await X("root","user",le.id,{meta:{jetpack_donation_warning_dismissed:!0}}),await ee("root","user",le.id)}catch(e){console.error("Failed to update user meta:",e)}else console.error("Cannot update user meta: User not loaded")},[le,X,ee]);return(0,A.jsxs)("div",{...U,children:[(0,A.jsx)(j.A,{attributes:t,setAttributes:n}),M&&(0,A.jsx)("style",{children:M}),pe,V&&(0,A.jsx)(x.A,{onClose:he})]})},T=E},46197(e,t,n){"use strict";var r=n(74997),s=n(94375),o=n(87325),i=n(27718),a=n(31152),l=n(47693),c=n(30746);n(45318);(0,s.M)(o,{edit:a.A,save:l.A,deprecated:[i.A]}),(0,r.registerBlockVariation)("jetpack/donations",c.Ay)},70975(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(1455),s=n.n(r);const o=async e=>{try{return await s()({path:"/wpcom/v2/memberships/products",method:"POST",data:{type:"donation",currency:e,is_editable:!1}})}catch(e){return Promise.reject(e.message)}}},93033(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(1455),s=n.n(r),o=n(93832);const i=async(e=null)=>{const t=new URLSearchParams(window.location.search),n=(0,o.addQueryArgs)("/wpcom/v2/memberships/status",{source:"https://wordpress.com"===t.get("origin")?"gutenberg-wpcom":"gutenberg",...e&&{type:e},is_editable:!1});try{return await s()({path:n,method:"GET"})}catch(e){return Promise.reject(e.message)}}},56848(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(3924),s=n(97999),o=n(56427),i=n(86087),a=n(27723),l=n(79654),c=n(10790);const __=a.__,u=({onClose:e})=>{const t=(0,s.isWpcomPlatformSite)()?"wpcom-support-donation-block":"jetpack-support-donation-block";return(0,c.jsx)(o.Modal,{className:"jetpack-donations-first-time-modal",onRequestClose:e,title:__("Accept Donations with Stripe","jetpack"),children:(0,c.jsxs)("div",{className:"jetpack-donations-first-time-modal__content",children:[(0,c.jsx)("p",{children:(0,i.createInterpolateElement)(__("To accept donations on your site, you'll need to connect your Stripe account. Here's what you need to do: Learn more about donations.","jetpack"),{docLink:(0,c.jsx)(l.N,{openInNewTab:!0,href:(0,r.A)(t)})})}),(0,c.jsxs)("ol",{children:[(0,c.jsx)("li",{children:__("Connect your Stripe account to your WordPress.com account","jetpack")}),(0,c.jsx)("li",{children:__("Set up your business information in Stripe","jetpack")}),(0,c.jsx)("li",{children:__("Configure your payment settings and supported currencies","jetpack")})]}),(0,c.jsx)("p",{children:__("Once connected, you can customize your donation form and start accepting payments.","jetpack")}),(0,c.jsx)("p",{children:(0,i.createInterpolateElement)(__("Please note that accepting donations has additional requirements from Stripe. Learn more about requirements for accepting donations.","jetpack"),{requirementsLink:(0,c.jsx)(l.N,{openInNewTab:!0,href:(0,r.A)("jetpack-support-donation-block-stripe-reqs")})})}),(0,c.jsx)("div",{className:"jetpack-donations-first-time-modal__actions",children:(0,c.jsx)(o.Button,{variant:"primary",onClick:e,children:__("Got it","jetpack")})})]})})}},2556(e,t,n){"use strict";n.d(t,{$f:()=>c,Sh:()=>u});var r=n(27723),s=n(42005),o=n(5573),i=n(10790);const __=r.__,a=(0,i.jsx)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(o.Path,{d:"M16.5 4.5c2.206 0 4 1.794 4 4 0 4.67-5.543 8.94-8.5 11.023C9.043 17.44 3.5 13.17 3.5 8.5c0-2.206 1.794-4 4-4 1.298 0 2.522.638 3.273 1.706L12 7.953l1.227-1.746c.75-1.07 1.975-1.707 3.273-1.707m0-1.5c-1.862 0-3.505.928-4.5 2.344C11.005 3.928 9.362 3 7.5 3 4.462 3 2 5.462 2 8.5c0 5.72 6.5 10.438 10 12.85 3.5-2.412 10-7.13 10-12.85C22 5.462 19.538 3 16.5 3z"})}),l=(0,i.jsx)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(o.Path,{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5 14.67 11 15.5 11zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"})}),c=(0,i.jsx)(o.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(o.Path,{d:"M20 3H4v10c0 2.21 1.79 4 4 4h6c2.21 0 4-1.79 4-4v-3h2c1.11 0 2-.89 2-2V5c0-1.11-.89-2-2-2zm0 5h-2V5h2v3zM4 19h16v2H4zM9 1v2M12 1v2M15 1v2"})}),u=[{key:"heart",label:__("Heart","jetpack"),icon:a},{key:"gift",label:__("Gift","jetpack"),icon:s.A},{key:"smiley",label:__("Smiley","jetpack"),icon:l},{key:"coffee",label:__("Cup","jetpack"),icon:c}]},79085(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(56427),s=n(27723),o=n(10790);const __=s.__,i=({error:e})=>(0,o.jsx)(r.Placeholder,{icon:"lock",label:__("Donations","jetpack"),instructions:e})},47693(e,t,n){"use strict";n.d(t,{A:()=>a});var r=n(94715),s=n(75703),o=n(10790);const i=(0,s.OI)(),a=({attributes:e})=>{const{fallbackLinkUrl:t,oneTimeDonation:n,monthlyDonation:s,annualDonation:a}=e;if(!n||!n.show||!n.planId||-1===n.planId)return null;const l=r.useBlockProps.save();return(0,o.jsxs)("div",{...l,children:[(0,o.jsx)(r.RichText.Content,{tagName:"h4",value:i.oneTimeDonation?.heading}),(0,o.jsx)(r.RichText.Content,{tagName:"p",value:n.extraText??i.extraText}),(0,o.jsx)(r.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.oneTimeDonation?.buttonText}),s.show&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("hr",{className:"donations__separator"}),(0,o.jsx)(r.RichText.Content,{tagName:"h4",value:i.monthlyDonation?.heading}),(0,o.jsx)(r.RichText.Content,{tagName:"p",value:s.extraText??i.extraText}),(0,o.jsx)(r.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.monthlyDonation?.buttonText})]}),a.show&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("hr",{className:"donations__separator"}),(0,o.jsx)(r.RichText.Content,{tagName:"h4",value:i.annualDonation?.heading}),(0,o.jsx)(r.RichText.Content,{tagName:"p",value:a.extraText??i.extraText}),(0,o.jsx)(r.RichText.Content,{tagName:"a",className:"jetpack-donations-fallback-link",href:t,rel:"noopener noreferrer noamphtml",target:"_blank",value:i.annualDonation?.buttonText})]})]})}},77794(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(94715),s=n(56427),o=n(86087),i=n(27723),a=n(10790);const __=i.__,l={placement:"left-start",offset:36},c=({label:e,settings:t})=>{const n=(0,o.useCallback)(()=>t.some(e=>!!e.value),[t]),i=(0,o.useCallback)(()=>t.forEach(e=>e.onChange()),[t]),c=(0,o.useCallback)(({isOpen:n,onToggle:r})=>(0,a.jsx)(s.Button,{onClick:r,"aria-expanded":n,"aria-label":e,__next40pxDefaultSize:!0,children:(0,a.jsxs)(s.__experimentalHStack,{justify:"flex-start",children:[(0,a.jsx)(s.__experimentalZStack,{isLayered:!1,offset:-8,children:t.map((e,t)=>(0,a.jsx)(s.Flex,{expanded:!1,children:(0,a.jsx)(s.ColorIndicator,{colorValue:e.value})},t))}),(0,a.jsx)(s.FlexItem,{className:"block-editor-panel-color-gradient-settings__color-name",children:e})]})}),[e,t]),u=(0,o.useCallback)(()=>{if(1===t.length)return(0,a.jsx)(s.__experimentalDropdownContentWrapper,{paddingSize:"none",children:(0,a.jsx)("div",{className:"block-editor-panel-color-gradient-settings__dropdown-content",children:(0,a.jsx)(r.__experimentalColorGradientControl,{label:t[0].label,colorValue:t[0].value,onColorChange:t[0].onChange})})});const e=t.map(e=>({name:e.label.toLowerCase().replace(/\s+/g,"-"),title:e.label}));return(0,a.jsx)(s.__experimentalDropdownContentWrapper,{paddingSize:"none",children:(0,a.jsx)("div",{className:"block-editor-panel-color-gradient-settings__dropdown-content",children:(0,a.jsx)(s.TabPanel,{tabs:e,children:e=>{const n=t.find(t=>t.label.toLowerCase().replace(/\s+/g,"-")===e.name);return(0,a.jsx)(r.__experimentalColorGradientControl,{label:n.label,colorValue:n.value,onColorChange:n.onChange,showTitle:!1})}})})})},[t]);return(0,a.jsx)(s.__experimentalToolsPanelItem,{className:"block-editor-tools-panel-color-gradient-settings__item",label:e,hasValue:n,onDeselect:i,isShownByDefault:!0,children:(0,a.jsx)(s.Dropdown,{popoverProps:l,className:"block-editor-tools-panel-color-gradient-settings__dropdown",renderToggle:c,renderContent:u})})},u=({attributes:e,setAttributes:t})=>{const{activeTabBackgroundColor:n,activeTabTextColor:i,inactiveTabBackgroundColor:l,inactiveTabTextColor:u,selectedAmountBackgroundColor:d,selectedAmountTextColor:p,selectedAmountOutlineColor:h,tabsAppearance:m,tabBorderColor:g,tabFontSize:f,tabPadding:b,buttonFontSize:v,buttonPadding:y,buttonAlignment:k,buttonBorderRadius:x,amountFontSize:_,amountBorder:w,amountBorderRadius:j}=e,C=(0,o.useMemo)(()=>{const e=e=>n=>t({[e]:n});return{tabsAppearance:e("tabsAppearance"),activeTabBackgroundColor:e("activeTabBackgroundColor"),activeTabTextColor:e("activeTabTextColor"),inactiveTabBackgroundColor:e("inactiveTabBackgroundColor"),inactiveTabTextColor:e("inactiveTabTextColor"),tabBorderColor:e("tabBorderColor"),tabFontSize:e("tabFontSize"),tabPadding:e("tabPadding"),selectedAmountBackgroundColor:e("selectedAmountBackgroundColor"),selectedAmountTextColor:e("selectedAmountTextColor"),selectedAmountOutlineColor:e("selectedAmountOutlineColor"),amountFontSize:e("amountFontSize"),amountBorder:e("amountBorder"),amountBorderRadius:e("amountBorderRadius"),buttonFontSize:e("buttonFontSize"),buttonPadding:e("buttonPadding"),buttonAlignment:e=>t({buttonAlignment:e||""}),buttonBorderRadius:e("buttonBorderRadius")}},[t]),A=(0,o.useMemo)(()=>[{label:__("Text","jetpack"),value:i,onChange:C.activeTabTextColor},{label:__("Background","jetpack"),value:n,onChange:C.activeTabBackgroundColor}],[n,i,C]),S=(0,o.useMemo)(()=>[{label:__("Text","jetpack"),value:u,onChange:C.inactiveTabTextColor},{label:__("Background","jetpack"),value:l,onChange:C.inactiveTabBackgroundColor}],[l,u,C]),E=(0,o.useMemo)(()=>[{label:__("Tab border","jetpack"),value:g,onChange:C.tabBorderColor}],[g,C]),T=(0,o.useMemo)(()=>[{label:__("Text","jetpack"),value:p,onChange:C.selectedAmountTextColor},{label:__("Background","jetpack"),value:d,onChange:C.selectedAmountBackgroundColor},{label:__("Outline","jetpack"),value:h,onChange:C.selectedAmountOutlineColor}],[d,p,h,C]),N=(0,o.useCallback)(()=>{},[]),P=(0,o.useCallback)(()=>{C.tabsAppearance("tabs"),C.activeTabBackgroundColor(),C.activeTabTextColor(),C.inactiveTabBackgroundColor(),C.inactiveTabTextColor(),C.tabBorderColor(),C.tabFontSize(),C.tabPadding()},[C]),B=(0,o.useCallback)(()=>{C.selectedAmountBackgroundColor(),C.selectedAmountTextColor(),C.selectedAmountOutlineColor(),C.amountFontSize(),C.amountBorder(),C.amountBorderRadius()},[C]),R=(0,o.useCallback)(()=>{C.buttonFontSize(),C.buttonPadding(),C.buttonBorderRadius(),C.buttonAlignment("")},[C]),I=(0,o.useMemo)(()=>({tabsAppearance:()=>"buttons"===m,tabFontSize:()=>!!f,tabPadding:()=>!!b,amountFontSize:()=>!!_,amountBorder:()=>!!w,amountBorderRadius:()=>!!j,buttonFontSize:()=>!!v,buttonPadding:()=>!!y,buttonAlignment:()=>!!k,buttonBorderRadius:()=>!!x}),[m,f,b,_,w,j,v,y,k,x]),D=(0,o.useMemo)(()=>({tabsAppearance:()=>C.tabsAppearance("tabs"),buttonAlignment:()=>C.buttonAlignment("")}),[C]);return(0,a.jsxs)(r.InspectorControls,{group:"styles",children:[(0,a.jsxs)(s.PanelBody,{title:__("Tabs","jetpack"),initialOpen:!1,className:"jp-donations-style-panel",children:[(0,a.jsx)(s.__experimentalToolsPanel,{label:__("Tab appearance","jetpack"),resetAll:N,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Appearance","jetpack"),hasValue:I.tabsAppearance,onDeselect:D.tabsAppearance,isShownByDefault:!0,children:(0,a.jsxs)(s.__experimentalToggleGroupControl,{label:__("Appearance","jetpack"),value:m||"tabs",onChange:C.tabsAppearance,isBlock:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,children:[(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"tabs",label:__("Tabs","jetpack")}),(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"buttons",label:__("Buttons","jetpack")})]})})}),(0,a.jsx)(s.__experimentalToolsPanel,{className:"color-block-support-panel",label:__("Colors","jetpack"),resetAll:N,hasInnerWrapper:!0,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:(0,a.jsxs)("div",{className:"color-block-support-panel__inner-wrapper",children:[(0,a.jsx)(c,{label:__("Active Tab","jetpack"),settings:A}),(0,a.jsx)(c,{label:__("Inactive Tab","jetpack"),settings:S}),(0,a.jsx)(c,{label:__("Tab Border","jetpack"),settings:E})]})}),(0,a.jsx)(r.ContrastChecker,{backgroundColor:n,textColor:i}),(0,a.jsx)(r.ContrastChecker,{backgroundColor:l,textColor:u}),(0,a.jsxs)(s.__experimentalToolsPanel,{label:__("Tab dimensions","jetpack"),resetAll:N,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:[(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Font size","jetpack"),hasValue:I.tabFontSize,onDeselect:C.tabFontSize,isShownByDefault:!0,children:(0,a.jsx)(r.FontSizePicker,{value:f,onChange:C.tabFontSize,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Padding","jetpack"),hasValue:I.tabPadding,onDeselect:C.tabPadding,isShownByDefault:!0,children:(0,a.jsx)(s.BoxControl,{label:__("Padding","jetpack"),values:b,onChange:C.tabPadding,allowReset:!1,__next40pxDefaultSize:!0})})]}),(0,a.jsx)(s.PanelRow,{children:(0,a.jsx)(s.Button,{variant:"secondary",onClick:P,children:__("Reset","jetpack")})})]}),(0,a.jsxs)(s.PanelBody,{title:__("Amounts","jetpack"),initialOpen:!1,className:"jp-donations-style-panel",children:[(0,a.jsx)(s.__experimentalToolsPanel,{className:"color-block-support-panel",label:__("Colors","jetpack"),resetAll:N,hasInnerWrapper:!0,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:(0,a.jsx)("div",{className:"color-block-support-panel__inner-wrapper",children:(0,a.jsx)(c,{label:__("Selected Amount","jetpack"),settings:T})})}),(0,a.jsx)(r.ContrastChecker,{backgroundColor:d,textColor:p}),(0,a.jsxs)(s.__experimentalToolsPanel,{label:__("Amount settings","jetpack"),resetAll:N,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:[(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Font size","jetpack"),hasValue:I.amountFontSize,onDeselect:C.amountFontSize,isShownByDefault:!0,children:(0,a.jsx)(r.FontSizePicker,{value:_,onChange:C.amountFontSize,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Border","jetpack"),hasValue:I.amountBorder,onDeselect:C.amountBorder,isShownByDefault:!0,children:(0,a.jsx)(s.BorderBoxControl,{label:__("Border","jetpack"),value:w,onChange:C.amountBorder,enableAlpha:!0,enableStyle:!0,__next40pxDefaultSize:!0})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Border radius","jetpack"),hasValue:I.amountBorderRadius,onDeselect:C.amountBorderRadius,isShownByDefault:!0,children:(0,a.jsx)(r.__experimentalBorderRadiusControl,{values:j,onChange:C.amountBorderRadius})})]}),(0,a.jsx)(s.PanelRow,{children:(0,a.jsx)(s.Button,{variant:"secondary",onClick:B,children:__("Reset","jetpack")})})]}),(0,a.jsxs)(s.PanelBody,{title:__("Donate button","jetpack"),initialOpen:!1,className:"jp-donations-style-panel",children:[(0,a.jsxs)(s.__experimentalToolsPanel,{label:__("Button settings","jetpack"),resetAll:N,headingLevel:3,__experimentalFirstVisibleItemClass:"first",__experimentalLastVisibleItemClass:"last",children:[(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Font size","jetpack"),hasValue:I.buttonFontSize,onDeselect:C.buttonFontSize,isShownByDefault:!0,children:(0,a.jsx)(r.FontSizePicker,{value:v,onChange:C.buttonFontSize,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Padding","jetpack"),hasValue:I.buttonPadding,onDeselect:C.buttonPadding,isShownByDefault:!0,children:(0,a.jsx)(s.BoxControl,{label:__("Padding","jetpack"),values:y,onChange:C.buttonPadding,allowReset:!1,__next40pxDefaultSize:!0})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Radius","jetpack"),hasValue:I.buttonBorderRadius,onDeselect:C.buttonBorderRadius,isShownByDefault:!0,children:(0,a.jsx)(r.__experimentalBorderRadiusControl,{values:x,onChange:C.buttonBorderRadius})}),(0,a.jsx)(s.__experimentalToolsPanelItem,{label:__("Alignment","jetpack"),hasValue:I.buttonAlignment,onDeselect:D.buttonAlignment,isShownByDefault:!0,children:(0,a.jsxs)(s.__experimentalToggleGroupControl,{label:__("Alignment","jetpack"),value:k||"",onChange:C.buttonAlignment,isBlock:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,children:[(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"left",label:__("Left","jetpack")}),(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"center",label:__("Center","jetpack")}),(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"right",label:__("Right","jetpack")}),(0,a.jsx)(s.__experimentalToggleGroupControlOption,{value:"full",label:__("Full width","jetpack")})]})})]}),(0,a.jsx)(s.PanelRow,{children:(0,a.jsx)(s.Button,{variant:"secondary",onClick:R,children:__("Reset","jetpack")})})]})]})}},62225(e,t,n){"use strict";n.d(t,{A:()=>d});var r=n(94715),s=n(47143),o=n(27723),i=n(72730),a=n(75800),l=n(75703),c=n(10790);const __=o.__,u=(0,l.OI)(),d=({activeTab:e,attributes:t,setAttributes:n})=>{const{currency:l,oneTimeDonation:d,monthlyDonation:p,annualDonation:h,showCustomAmount:m,customAmountPlaceholder:g,chooseAmountText:f=u.chooseAmountText,customAmountText:b=u.customAmountText}=t,v={"one-time":"oneTimeDonation","1 month":"monthlyDonation","1 year":"annualDonation"}[e],y=e=>t[v][e],k=(e,r)=>{const s=t[v];n({[v]:{...s,[e]:r}})},x=(0,i.Xj)(l),_=y("amounts"),w=(0,s.useSelect)(e=>e("core/rich-text").getFormatTypes(),[]).map(e=>e.name).filter(e=>"core/link"!==e);return(0,c.jsxs)("div",{className:"donations__tab",children:[(0,c.jsx)(r.RichText,{tagName:"h4",placeholder:__("Write a message…","jetpack"),value:y("heading")??u[v]?.heading,onChange:e=>k("heading",e)}),(0,c.jsx)(r.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:f,onChange:e=>n({chooseAmountText:e})}),(0,c.jsx)("div",{className:"donations__amounts",children:_.map((e,t)=>(0,c.jsx)(a.A,{currency:l,defaultValue:x[t],label:(0,o.sprintf)( // translators: %d: Tier level e.g: "1", "2", "3" __("Tier %d","jetpack"),t+1),onChange:e=>((e,t)=>{const n=[..._];n[t]=e,k("amounts",n)})(e,t),value:e},`jetpack-donations-amount-${t}`))}),m&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:b,onChange:e=>n({customAmountText:e})}),(0,c.jsx)(a.A,{currency:l,label:__("Custom amount","jetpack"),defaultValue:g??100*(0,i.dv)(l),className:"donations__custom-amount",disabled:!0})]}),(0,c.jsx)("hr",{className:"donations__separator"}),(0,c.jsx)(r.RichText,{tagName:"p",placeholder:__("Write a message…","jetpack"),value:y("extraText")??u.extraText,onChange:e=>k("extraText",e)}),(0,c.jsx)("div",{className:"wp-block-button donations__donate-button-wrapper",children:(0,c.jsx)(r.RichText,{className:"wp-block-button__link wp-element-button donations__donate-button",placeholder:__("Write a message…","jetpack"),value:y("buttonText")??u[v]?.buttonText,onChange:e=>{return t=e,void n({oneTimeDonation:{...d,buttonText:t},monthlyDonation:{...p,buttonText:t},annualDonation:{...h,buttonText:t}});var t},allowedFormats:w})})]})}},36580(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(86087),s=n(27723),o=n(13022),i=n(57018),a=n(62225),l=n(75703),c=n(10790);const __=s.__,u=e=>{const{attributes:t,products:n,setAttributes:s}=e,{oneTimeDonation:u,monthlyDonation:d,annualDonation:p,defaultInterval:h}=t,m=!1!==u.show,g=(0,l.fq)(m,d.show,p.show)??"one-time",f="one-time"===h&&m||"1 month"===h&&d.show||"1 year"===h&&p.show?h:g,[b,v]=(0,r.useState)(f),y=(0,r.useCallback)(e=>b===e,[b]),k={...m&&{"one-time":{title:__("One-Time","jetpack")}},...d.show&&{"1 month":{title:__("Monthly","jetpack")}},...p.show&&{"1 year":{title:__("Yearly","jetpack")}}};return(0,r.useEffect)(()=>{u.planId===n["one-time"]&&d.planId===n["1 month"]&&p.planId===n["1 year"]||s({...n["one-time"]&&{oneTimeDonation:{...u,planId:n["one-time"]}},...n["1 month"]&&{monthlyDonation:{...d,planId:n["1 month"]}},...n["1 year"]&&{annualDonation:{...p,planId:n["1 year"]}}})},[u,d,p,s,n]),(0,r.useEffect)(()=>{const e=(0,l.fq)(m,d.show,p.show);null!==e&&(!m&&y("one-time")&&v(e),!d.show&&y("1 month")&&v(e),!p.show&&y("1 year")&&v(e))},[m,d,p,v,y]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"donations__container",children:[Object.keys(k).length>1&&(0,c.jsx)("div",{className:"donations__nav",children:Object.entries(k).map(([e,{title:t}])=>(0,c.jsx)("div",{role:"button",tabIndex:0,className:(0,o.A)("donations__nav-item",{"is-active":y(e)}),onClick:()=>v(e),onKeyDown:()=>v(e),children:t},`jetpack-donations-nav-item-${e} `))}),(0,c.jsx)("div",{className:"donations__content",children:(0,c.jsx)(a.A,{activeTab:b,attributes:t,setAttributes:s})})]}),(0,c.jsx)(i.A,{...e})]})}},30746(e,t,n){"use strict";n.d(t,{Ay:()=>a});var r=n(27723),s=n(2556);const __=r.__,o="tips",i={variationName:o,displayMode:"modal",triggerSticky:!1,triggerButtonText:"Buy me a coffee",triggerIcon:"coffee",contentAlignment:"center",buttonAlignment:"full",tabsAppearance:"buttons",showCustomAmount:!1,chooseAmountText:"",annualDonation:{show:!1,planId:null,amounts:[3,5,8]},oneTimeDonation:{show:!0,planId:null,amounts:[3,5,8],defaultAmountIndex:0,heading:"",buttonText:"Buy coffee",extraText:"Thanks for your generosity!"},monthlyDonation:{show:!0,planId:null,amounts:[3,5,8],defaultAmountIndex:0,heading:"",buttonText:"Buy coffee",extraText:"Thanks for your generosity!"}},a={name:o,title:__("Tips","jetpack"),description:__("Get financial support from friends and followers.","jetpack"),icon:s.$f,isDefault:!1,attributes:i,scope:["inserter"],isActive:e=>e.variationName===o,keywords:[__("tips","jetpack"),__("coffee","jetpack"),__("support","jetpack"),__("buy me a coffee","jetpack")]}},75703(e,t,n){"use strict";function r(e,t,n){return e?"one-time":t?"1 month":n?"1 year":null}function s(){if("undefined"==typeof window)return{};const e=window.Jetpack_DonationsBlock?.defaultTexts;return"object"!=typeof e?{}:e}n.d(t,{OI:()=>s,fq:()=>r})},36850(e,t,n){"use strict";n.d(t,{GY:()=>s,_t:()=>r,gQ:()=>o});const r=/^\s*https?:\/\/(?:www\.)?(?:eventbrite\.[a-z.]+)\/e\/[^/]*?(\d+)\/?(?:\?[^/]*)?\s*$/i,s=/^\s*https?:\/\/(?:.+\.)?(?:eventbrite\.[a-z.]+)\/?(?:\?[^/]*)?\s*$/i,o="https://www.eventbrite.com/e/test-event-tickets-123456789"},38449(e,t,n){"use strict";n.d(t,{o:()=>c,s:()=>u});var r=n(56427),s=n(27723),o=n(5873),i=n(72660),a=n(10790);const __=s.__,_x=s._x,l=[{value:"inline",label:__("In-page Embed","jetpack"),preview:(0,a.jsx)("div",{className:"block-editor-block-preview__container",children:(0,a.jsx)("img",{src:i,alt:__("In page Eventbrite checkout example","jetpack")})})},{value:"modal",label:__("Button & Modal","jetpack")}],c=({setEditingUrl:e})=>(0,a.jsx)(r.ToolbarGroup,{children:(0,a.jsx)(r.ToolbarButton,{className:"components-toolbar__control",label:__("Edit URL","jetpack"),icon:"edit",onClick:()=>e(!0)})}),u=({attributes:e,clientId:t,setAttributes:n})=>(0,a.jsx)(o.A,{title:_x("Embed Type","option for how the embed displays on a page, e.g. inline or as a modal","jetpack"),clientId:t,styleOptions:l,onSelectStyle:n,activeStyle:e.style,attributes:e,viewportWidth:130})},77629(e,t,n){"use strict";n.d(t,{A:()=>r});const r=[n(87879).A]},87879(e,t,n){"use strict";n.d(t,{A:()=>u});var r=n(94715),s=n(74997),o=n(27723),i=n(13022),a=n(66087),l=n(10790);const _x=o._x,c=["text","backgroundColor","textColor","customBackgroundColor","customTextColor","borderRadius"];const u={attributes:{url:{type:"string",validator:e=>!e||e.startsWith("http")},eventId:{type:"number"},useModal:{type:"boolean"},style:{type:"string"},text:{type:"string",default:_x("Register","verb: e.g. register for an event.","jetpack")},backgroundColor:{type:"string"},textColor:{type:"string"},customBackgroundColor:{type:"string"},customTextColor:{type:"string"},borderRadius:{type:"number"}},migrate:e=>{const{className:t,style:n}=e;let r=n;r||(r=e.useModal?"modal":"inline");const o={...Object.fromEntries(Object.entries(e).filter(([e])=>"useModal"!==e&&!c.includes(e))),className:t&&t.replace("is-style-outline",""),style:r},i=(0,a.pick)(e,c);return[o,[(0,s.createBlock)("jetpack/button",{element:"a",text:i.text||_x("Register","verb: e.g. register for an event.","jetpack"),...i,uniqueId:"eventbrite-widget-id",className:t&&-1!==t.indexOf("is-style-outline")?"is-style-outline":""})]]},save:function({attributes:e}){const{eventId:t,useModal:n,url:s,style:o}=e;if(t)return n||"modal"===o?function(e){const{backgroundColor:t,borderRadius:n,customBackgroundColor:s,customTextColor:o,eventId:a,text:c,textColor:u,url:d}=e,p=(0,r.getColorClassName)("color",u),h=(0,r.getColorClassName)("background-color",t),m=(0,i.A)("wp-block-button__link",{"has-text-color":u||o,[p]:p,"has-background":t||s,[h]:h,"no-border-radius":0===n}),g={backgroundColor:h?void 0:s,color:p?void 0:o,borderRadius:n?n+"px":void 0};return(0,l.jsx)("div",{className:"wp-block-button",children:(0,l.jsx)(r.RichText.Content,{className:m,href:d,id:`eventbrite-widget-${a}`,rel:"noopener noreferrer",role:"button",style:g,tagName:"a",target:"_blank",value:c})})}(e):s&&(0,l.jsx)("a",{className:"eventbrite__direct-link",href:s,children:s})},isEligible:(e,t)=>("modal"===e.style||e.useModal)&&((0,a.isEmpty)(t)||Object.entries(e).some(([e,t])=>t&&c.includes(e)))}},56311(e,t,n){"use strict";n.d(t,{A:()=>v});var r=n(94715),s=n(56427),o=n(86087),i=n(27723),a=n(78218),l=n(56145),c=n(82306),u=n(36850),d=n(38449),p=n(50013),h=n(68332),m=n(72055),g=n(12074),f=(n(59357),n(10790));const __=i.__,_x=i._x,b={name:"jetpack/button",attributes:{element:"a",text:_x("Register","verb: e.g. register for an event.","jetpack"),uniqueId:"eventbrite-widget-id"}},v=(0,s.withNotices)(e=>{const{attributes:t,noticeOperations:n,onReplace:i,setAttributes:v}=e,{url:y,style:k}=t,x=(0,r.useBlockProps)(),[_,w]=(0,o.useState)(!1),[j,C]=(0,o.useState)(t.url||""),[A,S]=(0,o.useState)(!1),E=!A&&y&&!u._t.test(y),T=(0,o.useCallback)(()=>{n.removeAllNotices(),n.createErrorNotice((0,f.jsxs)(f.Fragment,{children:[__("Sorry, this content could not be embedded.","jetpack")," ",(0,f.jsx)(s.Button,{variant:"link",onClick:()=>(0,g.pG)(j,i),children:_x("Convert block to link","button label","jetpack")})]}))},[n,i,j]),N=(0,o.useCallback)(e=>{if(!e||u.gQ===e||"modal"===k)return;const t=(0,g.HE)(e);if(t){const r={eventId:t,url:e};(0,l.A)(r.url,S).then(e=>{const t=(0,a.y)(c.attributes,{...r,url:e});v(t),C(e),n.removeAllNotices()}).catch(()=>{v({eventId:void 0,url:void 0}),T()})}else T()},[k,n,T,v,C,S]);let P;return(0,o.useEffect)(()=>{N(y)},[y,N]),P=A?(0,f.jsx)(h.A,{}):_||!y||E?(0,f.jsx)(p.A,{...e,editedUrl:j,onChange:e=>C(e.target.value),onSubmit:e=>{e&&e.preventDefault(),N((0,g.pJ)(j)),w(!1)}}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(d.s,{...e}),(0,f.jsx)(r.BlockControls,{children:(0,f.jsx)(d.o,{setEditingUrl:w})}),"modal"===k?(0,f.jsx)(r.InnerBlocks,{template:[[b.name,b.attributes]],templateLock:"all"}):(0,f.jsx)(m.A,{...e})]}),(0,f.jsx)("div",{...x,children:P})})},34590(e,t,n){"use strict";var r=n(74997),s=n(94375),o=n(82306),i=n(36850),a=n(77629),l=n(56311),c=n(52074);(0,s.M)(o,{edit:l.A,save:c.A,transforms:{from:[{type:"raw",isMatch:e=>"P"===e.nodeName&&(i._t.test(e.textContent)||i.GY.test(e.textContent)),transform:e=>(0,r.createBlock)("jetpack/eventbrite",{url:e.textContent.trim()})}]},deprecated:a.A})},50013(e,t,n){"use strict";n.d(t,{A:()=>d});var r=n(97999),s=n(85985),o=n(56427),i=n(27723),a=n(79654),l=n(82306),c=(n(12074),n(10790));const __=i.__,_x=i._x,u=(0,s.sh)(l),d=({className:e,noticeUI:t,editedUrl:n,onChange:s,onSubmit:i})=>{const l=(0,r.isWpcomPlatformSite)()?"http://support.wordpress.com/wordpress-editor/blocks/eventbrite-block/":"https://jetpack.com/support/jetpack-blocks/eventbrite-block/";return(0,c.jsx)("div",{className:e,children:(0,c.jsxs)(o.Placeholder,{label:__("Eventbrite Checkout","jetpack"),instructions:__("Paste a link to an Eventbrite event to embed ticket checkout.","jetpack"),icon:u,notices:t,children:[(0,c.jsxs)("form",{onSubmit:i,children:[(0,c.jsx)("input",{type:"url",value:n,className:"components-placeholder__input","aria-label":__("Eventbrite URL","jetpack"),placeholder:__("Enter an event URL to embed here…","jetpack"),onChange:s}),(0,c.jsx)(o.Button,{variant:"secondary",type:"submit",children:_x("Embed","submit button label","jetpack")})]}),(0,c.jsx)("div",{className:"components-placeholder__learn-more",children:(0,c.jsx)(a.N,{openInNewTab:!0,href:l,children:__("Learn more about Eventbrite embeds","jetpack")})})]})})}},68332(e,t,n){"use strict";n.d(t,{A:()=>i});var r=n(56427),s=n(27723),o=n(10790);const __=s.__,i=()=>(0,o.jsxs)("div",{className:"wp-block-embed is-loading",children:[(0,o.jsx)(r.Spinner,{}),(0,o.jsx)("p",{children:__("Embedding…","jetpack")})]})},72055(e,t,n){"use strict";n.d(t,{A:()=>o});var r=n(56427),s=n(10790);const o=({className:e,attributes:t})=>{const{eventId:n}=t;if(!n)return;const o=`eventbrite-widget-${n}`,i=`\n\t\t\t