Preview: aiFrontend.js
Size: 228.21 KB
//home/nshryvcy/radiantskinclinics.org/wp-content/plugins/wordpress-seo/js/dist/externals/aiFrontend.js
(()=>{var e={9939(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(51609)),o=i(r(21679)),a=i(r(71802));function i(e){return e&&e.__esModule?e:{default:e}}const s=o.default.div`
text-transform: lowercase;
color: rgb(83, 100, 113);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
fill: currentcolor;
display: flex;
flex-direction: row;
align-items: flex-end;
`,c=e=>n.default.createElement(s,null,n.default.createElement("span",null,e.siteUrl));c.propTypes={siteUrl:a.default.string.isRequired},t.default=c},12129(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=s(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}(r(51609)),o=i(r(21679)),a=i(r(71802));function i(e){return e&&e.__esModule?e:{default:e}}function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(s=function(e){return e?r:t})(e)}const c=o.default.p`
color: #606770;
flex-shrink: 0;
font-size: 12px;
line-height: 16px;
overflow: hidden;
padding: 0;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
margin: 0;
position: ${e=>"landscape"===e.mode?"relative":"static"};
`,l=e=>{const{siteUrl:t}=e;return n.default.createElement(n.Fragment,null,n.default.createElement("span",{className:"screen-reader-text"},t),n.default.createElement(c,{"aria-hidden":"true"},n.default.createElement("span",null,t)))};l.propTypes={siteUrl:a.default.string.isRequired},t.default=l},12379(e){"use strict";e.exports=window.yoast.socialMetadataForms},14192(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=f(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}(r(51609)),o=p(r(21679)),a=p(r(71802)),i=r(27723),s=r(66087),c=r(12379),l=r(18495),u=r(47248),d=r(68511);function p(e){return e&&e.__esModule?e:{default:e}}function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(f=function(e){return e?r:t})(e)}const h=o.default.div`
position: relative;
${e=>"landscape"===e.mode?`max-width: ${e.dimensions.width}`:`min-width: ${e.dimensions.width}; height: ${e.dimensions.height}`};
overflow: hidden;
background-color: ${l.colors.$color_white};
`,m=o.default.div`
box-sizing: border-box;
max-width: ${c.FACEBOOK_IMAGE_SIZES.landscapeWidth}px;
height: ${c.FACEBOOK_IMAGE_SIZES.landscapeHeight}px;
background-color: ${l.colors.$color_grey};
border-style: dashed;
border-width: 1px;
// We're not using standard colors to increase contrast for accessibility.
color: #006DAC;
// We're not using standard colors to increase contrast for accessibility.
background-color: #f1f1f1;
display: flex;
justify-content: center;
align-items: center;
text-decoration: underline;
font-size: 14px;
cursor: pointer;
`;class y extends n.Component{constructor(e){super(e),this.state={imageProperties:null,status:"loading"},this.socialMedium="Facebook",this.handleFacebookImage=this.handleFacebookImage.bind(this),this.setState=this.setState.bind(this)}async handleFacebookImage(){try{const e=await(0,d.handleImage)(this.props.src,this.socialMedium);this.setState(e),this.props.onImageLoaded(e.imageProperties.mode||"landscape")}catch(e){this.setState(e),this.props.onImageLoaded("landscape")}}componentDidUpdate(e){e.src!==this.props.src&&this.handleFacebookImage()}componentDidMount(){this.handleFacebookImage()}retrieveContainerDimensions(e){switch(e){case"square":return{height:c.FACEBOOK_IMAGE_SIZES.squareHeight+"px",width:c.FACEBOOK_IMAGE_SIZES.squareWidth+"px"};case"portrait":return{height:c.FACEBOOK_IMAGE_SIZES.portraitHeight+"px",width:c.FACEBOOK_IMAGE_SIZES.portraitWidth+"px"};case"landscape":return{height:c.FACEBOOK_IMAGE_SIZES.landscapeHeight+"px",width:c.FACEBOOK_IMAGE_SIZES.landscapeWidth+"px"}}}render(){const{imageProperties:e,status:t}=this.state;if("loading"===t||""===this.props.src||"errored"===t)return n.default.createElement(m,{onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave},(0,i.__)("Select image","wordpress-seo"));const r=this.retrieveContainerDimensions(e.mode);return n.default.createElement(h,{mode:e.mode,dimensions:r,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,onClick:this.props.onImageClick},n.default.createElement(u.SocialImage,{imageProps:{src:this.props.src,alt:this.props.alt,aspectRatio:c.FACEBOOK_IMAGE_SIZES.aspectRatio},width:e.width,height:e.height,imageMode:e.mode}))}}y.propTypes={src:a.default.string,alt:a.default.string,onImageLoaded:a.default.func,onImageClick:a.default.func,onMouseEnter:a.default.func,onMouseLeave:a.default.func},y.defaultProps={src:"",alt:"",onImageLoaded:s.noop,onImageClick:s.noop,onMouseEnter:s.noop,onMouseLeave:s.noop},t.default=y},18495(e){"use strict";e.exports=window.yoast.styleGuide},21679(e){"use strict";e.exports=window.yoast.styledComponents},25948(e,t,r){"use strict";r.r(t),r.d(t,{CompactEncrypt:()=>ct,CompactSign:()=>ut,EmbeddedJWK:()=>bt,EncryptJWT:()=>yt,FlattenedEncrypt:()=>qe,FlattenedSign:()=>lt,GeneralEncrypt:()=>Ve,GeneralSign:()=>pt,SignJWT:()=>mt,UnsecuredJWT:()=>It,base64url:()=>o,calculateJwkThumbprint:()=>vt,calculateJwkThumbprintUri:()=>wt,compactDecrypt:()=>Ke,compactVerify:()=>Qe,createLocalJWKSet:()=>At,createRemoteJWKSet:()=>Ot,cryptoRuntime:()=>Ut,decodeJwt:()=>jt,decodeProtectedHeader:()=>Rt,errors:()=>n,experimental_jwksCache:()=>Pt,exportJWK:()=>$e,exportPKCS8:()=>Ge,exportSPKI:()=>Je,flattenedDecrypt:()=>Ue,flattenedVerify:()=>Xe,generalDecrypt:()=>De,generalVerify:()=>et,generateKeyPair:()=>Nt,generateSecret:()=>Wt,importJWK:()=>Pe,importPKCS8:()=>Oe,importSPKI:()=>xe,importX509:()=>Te,jwksCache:()=>xt,jwtDecrypt:()=>st,jwtVerify:()=>it});var n={};r.r(n),r.d(n,{JOSEAlgNotAllowed:()=>S,JOSEError:()=>b,JOSENotSupported:()=>k,JWEDecryptionFailed:()=>A,JWEInvalid:()=>C,JWKInvalid:()=>O,JWKSInvalid:()=>P,JWKSMultipleMatchingKeys:()=>L,JWKSNoMatchingKey:()=>I,JWKSTimeout:()=>M,JWSInvalid:()=>x,JWSSignatureVerificationFailed:()=>R,JWTClaimValidationFailed:()=>E,JWTExpired:()=>_,JWTInvalid:()=>T});var o={};r.r(o),r.d(o,{decode:()=>Mt,encode:()=>Lt});const a=crypto,i=e=>e instanceof CryptoKey,s=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await a.subtle.digest(r,t))},c=new TextEncoder,l=new TextDecoder,u=2**32;function d(...e){const t=e.reduce((e,{length:t})=>e+t,0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function p(e,t,r){if(t<0||t>=u)throw new RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function f(e){const t=Math.floor(e/u),r=e%u,n=new Uint8Array(8);return p(n,t,0),p(n,r,4),n}function h(e){const t=new Uint8Array(4);return p(t,e),t}function m(e){return d(h(e.length),e)}const y=e=>{let t=e;"string"==typeof t&&(t=c.encode(t));const r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},g=e=>y(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),v=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},w=e=>{let t=e;t instanceof Uint8Array&&(t=l.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return v(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class b extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}b.code="ERR_JOSE_GENERIC";class E extends b{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=n,this.payload=t}}E.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class _ extends b{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=n,this.payload=t}}_.code="ERR_JWT_EXPIRED";class S extends b{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}S.code="ERR_JOSE_ALG_NOT_ALLOWED";class k extends b{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}k.code="ERR_JOSE_NOT_SUPPORTED";class A extends b{constructor(e="decryption operation failed",t){super(e,t),this.code="ERR_JWE_DECRYPTION_FAILED"}}A.code="ERR_JWE_DECRYPTION_FAILED";class C extends b{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}C.code="ERR_JWE_INVALID";class x extends b{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}x.code="ERR_JWS_INVALID";class T extends b{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}T.code="ERR_JWT_INVALID";class O extends b{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}O.code="ERR_JWK_INVALID";class P extends b{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}P.code="ERR_JWKS_INVALID";class I extends b{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}}I.code="ERR_JWKS_NO_MATCHING_KEY";class L extends b{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Symbol.asyncIterator,L.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class M extends b{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}}M.code="ERR_JWKS_TIMEOUT";class R extends b{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}R.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";const j=a.getRandomValues.bind(a);function H(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new k(`Unsupported JWE Algorithm: ${e}`)}}const N=(e,t)=>{if(t.length<<3!==H(e))throw new C("Invalid Initialization Vector length")},W=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new C(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function U(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function K(e,t){return e.name===t}function D(e){return parseInt(e.name.slice(4),10)}function F(e,t){if(t.length&&!t.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();e+=`one of ${t.join(", ")}, or ${r}.`}else 2===t.length?e+=`one of ${t[0]} or ${t[1]}.`:e+=`${t[0]}.`;throw new TypeError(e)}}function J(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!K(e.algorithm,"AES-GCM"))throw U("AES-GCM");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw U(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!K(e.algorithm,"AES-KW"))throw U("AES-KW");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw U(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw U("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!K(e.algorithm,"PBKDF2"))throw U("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!K(e.algorithm,"RSA-OAEP"))throw U("RSA-OAEP");const r=parseInt(t.slice(9),10)||1;if(D(e.algorithm.hash)!==r)throw U(`SHA-${r}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}F(e,r)}function G(e,t,...r){if((r=r.filter(Boolean)).length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const $=(e,...t)=>G("Key must be ",e,...t);function B(e,t,...r){return G(`Key for the ${e} algorithm must be `,t,...r)}const q=e=>!!i(e)||"KeyObject"===e?.[Symbol.toStringTag],z=["CryptoKey"],V=async(e,t,r,n,o,s)=>{if(!(i(t)||t instanceof Uint8Array))throw new TypeError($(t,...z,"Uint8Array"));if(!n)throw new C("JWE Initialization Vector missing");if(!o)throw new C("JWE Authentication Tag missing");switch(N(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&W(t,parseInt(e.slice(-3),10)),async function(e,t,r,n,o,i){if(!(t instanceof Uint8Array))throw new TypeError($(t,"Uint8Array"));const s=parseInt(e.slice(1,4),10),c=await a.subtle.importKey("raw",t.subarray(s>>3),"AES-CBC",!1,["decrypt"]),l=await a.subtle.importKey("raw",t.subarray(0,s>>3),{hash:"SHA-"+(s<<1),name:"HMAC"},!1,["sign"]),u=d(i,n,r,f(i.length<<3)),p=new Uint8Array((await a.subtle.sign("HMAC",l,u)).slice(0,s>>3));let h,m;try{h=((e,t)=>{if(!(e instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(e.length!==t.length)throw new TypeError("Input buffers must have the same length");const r=e.length;let n=0,o=-1;for(;++o<r;)n|=e[o]^t[o];return 0===n})(o,p)}catch{}if(!h)throw new A;try{m=new Uint8Array(await a.subtle.decrypt({iv:n,name:"AES-CBC"},c,r))}catch{}if(!m)throw new A;return m}(e,t,r,n,o,s);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&W(t,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o,i){let s;t instanceof Uint8Array?s=await a.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):(J(t,e,"decrypt"),s=t);try{return new Uint8Array(await a.subtle.decrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},s,d(r,o)))}catch{throw new A}}(e,t,r,n,o,s);default:throw new k("Unsupported JWE Content Encryption Algorithm")}},Y=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const e of t){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return!1;r.add(e)}else r=new Set(t)}return!0};function Z(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}const X=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function Q(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function ee(e,t,r){if(i(e))return J(e,t,r),e;if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError($(e,...z,"Uint8Array"))}const te=async(e,t,r)=>{const n=await ee(t,e,"wrapKey");Q(n,e);const o=await a.subtle.importKey("raw",r,...X);return new Uint8Array(await a.subtle.wrapKey("raw",o,n,"AES-KW"))},re=async(e,t,r)=>{const n=await ee(t,e,"unwrapKey");Q(n,e);const o=await a.subtle.unwrapKey("raw",r,n,"AES-KW",...X);return new Uint8Array(await a.subtle.exportKey("raw",o))};async function ne(e,t,r,n,o=new Uint8Array(0),l=new Uint8Array(0)){if(!i(e))throw new TypeError($(e,...z));if(J(e,"ECDH"),!i(t))throw new TypeError($(t,...z));J(t,"ECDH","deriveBits");const u=d(m(c.encode(r)),m(o),m(l),h(n));let p;return p="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3,async function(e,t,r){const n=Math.ceil((t>>3)/32),o=new Uint8Array(32*n);for(let t=0;t<n;t++){const n=new Uint8Array(4+e.length+r.length);n.set(h(t+1)),n.set(e,4),n.set(r,4+e.length),o.set(await s("sha256",n),32*t)}return o.slice(0,t>>3)}(new Uint8Array(await a.subtle.deriveBits({name:e.algorithm.name,public:e},t,p)),n,u)}function oe(e){if(!i(e))throw new TypeError($(e,...z));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function ae(e,t,r,n){!function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new C("PBES2 Salt Input must be 8 or more octets")}(e);const o=function(e,t){return d(c.encode(e),new Uint8Array([0]),t)}(t,e),s=parseInt(t.slice(13,16),10),l={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:o},u={length:s,name:"AES-KW"},p=await function(e,t){if(e instanceof Uint8Array)return a.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(i(e))return J(e,t,"deriveBits","deriveKey"),e;throw new TypeError($(e,...z,"Uint8Array"))}(n,t);if(p.usages.includes("deriveBits"))return new Uint8Array(await a.subtle.deriveBits(l,p,s));if(p.usages.includes("deriveKey"))return a.subtle.deriveKey(l,p,u,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}function ie(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new k(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const se=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};function ce(e){return Z(e)&&"string"==typeof e.kty}const le=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new k('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),n=[t,e.ext??!1,e.key_ops??r],o={...e};return delete o.alg,delete o.use,a.subtle.importKey("jwk",o,...n)},ue=e=>w(e);let de,pe;const fe=e=>"KeyObject"===e?.[Symbol.toStringTag],he=async(e,t,r,n,o=!1)=>{let a=e.get(t);if(a?.[n])return a[n];const i=await le({...r,alg:n});return o&&Object.freeze(t),a?a[n]=i:e.set(t,{[n]:i}),i},me=(e,t)=>{if(fe(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?ue(r.k):(pe||(pe=new WeakMap),he(pe,e,r,t))}return ce(e)?e.k?w(e.k):(pe||(pe=new WeakMap),he(pe,e,e,t,!0)):e},ye=(e,t)=>{if(fe(e)){let r=e.export({format:"jwk"});return r.k?ue(r.k):(de||(de=new WeakMap),he(de,e,r,t))}return ce(e)?e.k?w(e.k):(de||(de=new WeakMap),he(de,e,e,t,!0)):e};function ge(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new k(`Unsupported JWE Algorithm: ${e}`)}}const ve=e=>j(new Uint8Array(ge(e)>>3)),we=(e,t)=>`-----BEGIN ${t}-----\n${(e.match(/.{1,64}/g)||[]).join("\n")}\n-----END ${t}-----`,be=async(e,t,r)=>{if(!i(r))throw new TypeError($(r,...z));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==e)throw new TypeError(`key is not a ${e} key`);return we(y(new Uint8Array(await a.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},Ee=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));const n=e.indexOf(t[0],r);if(-1===n)return!1;const o=e.subarray(n,n+t.length);return o.length===t.length&&(o.every((e,r)=>e===t[r])||Ee(e,t,n+1))},_e=e=>{switch(!0){case Ee(e,[42,134,72,206,61,3,1,7]):return"P-256";case Ee(e,[43,129,4,0,34]):return"P-384";case Ee(e,[43,129,4,0,35]):return"P-521";case Ee(e,[43,101,110]):return"X25519";case Ee(e,[43,101,111]):return"X448";case Ee(e,[43,101,112]):return"Ed25519";case Ee(e,[43,101,113]):return"Ed448";default:throw new k("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Se=async(e,t,r,n,o)=>{let i,s;const c=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),l="spki"===t;switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},s=l?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},s=l?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},s=l?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":i={name:"ECDSA",namedCurve:"P-256"},s=l?["verify"]:["sign"];break;case"ES384":i={name:"ECDSA",namedCurve:"P-384"},s=l?["verify"]:["sign"];break;case"ES512":i={name:"ECDSA",namedCurve:"P-521"},s=l?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const e=_e(c);i=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},s=l?[]:["deriveBits"];break}case"Ed25519":i={name:"Ed25519"},s=l?["verify"]:["sign"];break;case"EdDSA":i={name:_e(c)},s=l?["verify"]:["sign"];break;default:throw new k('Invalid or unsupported "alg" (Algorithm) value')}return a.subtle.importKey(t,c,i,o?.extractable??!1,s)},ke=(e,t,r)=>Se(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);function Ae(e){const t=[];let r=0;for(;r<e.length;){const n=Ce(e.subarray(r));t.push(n),r+=n.byteLength}return t}function Ce(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else{if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw new TypeError("invalid indefinite form length");n++}const r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}{const r=127&e[t];t++,n=0;for(let o=0;o<r;o++)n=256*n+e[t],t++}}const o=t+n;return{byteLength:o,contents:e.subarray(t,o),raw:e.subarray(0,o)}}async function xe(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw new TypeError('"spki" must be SPKI formatted string');return ke(e,t,r)}async function Te(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw new TypeError('"x509" must be X.509 formatted string');return((e,t,r)=>{let n;try{n=function(e){const t=e.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""),r=v(t);return we(function(e){const t=Ae(Ae(Ce(e).contents)[0].contents);return y(t[160===t[0].raw[0]?6:5].raw)}(r),"PUBLIC KEY")}(e)}catch(e){throw new TypeError("Failed to parse the X.509 certificate",{cause:e})}return ke(n,t,r)})(e,t,r)}async function Oe(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return((e,t,r)=>Se(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r))(e,t,r)}async function Pe(e,t){if(!Z(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return w(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new k('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return le({...e,alg:t});default:throw new k('Unsupported "kty" (Key Type) Parameter value')}}const Ie=e=>e?.[Symbol.toStringTag],Le=(e,t,r)=>{if(void 0!==t.use&&"sig"!==t.use)throw new TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&!0!==t.key_ops.includes?.(r))throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(void 0!==t.alg&&t.alg!==e)throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function Me(e,t,r,n){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,r,n)=>{if(!(t instanceof Uint8Array)){if(n&&ce(t)){if(function(e){return ce(e)&&"oct"===e.kty&&"string"==typeof e.k}(t)&&Le(e,t,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!q(t))throw new TypeError(B(e,t,...z,"Uint8Array",n?"JSON Web Key":null));if("secret"!==t.type)throw new TypeError(`${Ie(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,n,e):((e,t,r,n)=>{if(n&&ce(t))switch(r){case"sign":if(function(e){return"oct"!==e.kty&&"string"==typeof e.d}(t)&&Le(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(function(e){return"oct"!==e.kty&&void 0===e.d}(t)&&Le(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!q(t))throw new TypeError(B(e,t,...z,n?"JSON Web Key":null));if("secret"===t.type)throw new TypeError(`${Ie(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw new TypeError(`${Ie(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw new TypeError(`${Ie(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw new TypeError(`${Ie(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw new TypeError(`${Ie(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,r,n,e)}const Re=Me.bind(void 0,!1),je=Me.bind(void 0,!0),He=async(e,t,r,n,o)=>{if(!(i(r)||r instanceof Uint8Array))throw new TypeError($(r,...z,"Uint8Array"));switch(n?N(e,n):n=j(new Uint8Array(H(e)>>3)),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&W(r,parseInt(e.slice(-3),10)),async function(e,t,r,n,o){if(!(r instanceof Uint8Array))throw new TypeError($(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),s=await a.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),c=await a.subtle.importKey("raw",r.subarray(0,i>>3),{hash:"SHA-"+(i<<1),name:"HMAC"},!1,["sign"]),l=new Uint8Array(await a.subtle.encrypt({iv:n,name:"AES-CBC"},s,t)),u=d(o,n,l,f(o.length<<3));return{ciphertext:l,tag:new Uint8Array((await a.subtle.sign("HMAC",c,u)).slice(0,i>>3)),iv:n}}(e,t,r,n,o);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&W(r,parseInt(e.slice(1,4),10)),async function(e,t,r,n,o){let i;r instanceof Uint8Array?i=await a.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(J(r,e,"encrypt"),i=r);const s=new Uint8Array(await a.subtle.encrypt({additionalData:o,iv:n,name:"AES-GCM",tagLength:128},i,t)),c=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:c,iv:n}}(e,t,r,n,o);default:throw new k("Unsupported JWE Content Encryption Algorithm")}},Ne=function(e,t,r,n,o){if(void 0!==o.crit&&void 0===n?.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;a=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const t of n.crit){if(!a.has(t))throw new k(`Extension Header Parameter "${t}" is not recognized`);if(void 0===o[t])throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&void 0===n[t])throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(n.crit)},We=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)};async function Ue(e,t,r){if(!Z(e))throw new C("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new C("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new C("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new C("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new C("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new C("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new C("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new C("JWE AAD incorrect type");if(void 0!==e.header&&!Z(e.header))throw new C("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!Z(e.unprotected))throw new C("JWE Per-Recipient Unprotected Header incorrect type");let n;if(e.protected)try{const t=w(e.protected);n=JSON.parse(l.decode(t))}catch{throw new C("JWE Protected Header is invalid")}if(!Y(n,e.header,e.unprotected))throw new C("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const o={...n,...e.header,...e.unprotected};if(Ne(C,new Map,r?.crit,n,o),void 0!==o.zip)throw new k('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:u}=o;if("string"!=typeof s||!s)throw new C("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof u||!u)throw new C("missing JWE Encryption Algorithm (enc) in JWE Header");const p=r&&We("keyManagementAlgorithms",r.keyManagementAlgorithms),f=r&&We("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(p&&!p.has(s)||!p&&s.startsWith("PBES2"))throw new S('"alg" (Algorithm) Header Parameter value not allowed');if(f&&!f.has(u))throw new S('"enc" (Encryption Algorithm) Header Parameter value not allowed');let h;if(void 0!==e.encrypted_key)try{h=w(e.encrypted_key)}catch{throw new C("Failed to base64url decode the encrypted_key")}let m,y,g,v=!1;"function"==typeof t&&(t=await t(n,e),v=!0);try{m=await async function(e,t,r,n,o){switch(Re(e,t,"decrypt"),t=await(ye?.(t,e))||t,e){case"dir":if(void 0!==r)throw new C("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new C("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Z(n.epk))throw new C('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!oe(t))throw new k("ECDH with the provided key is not allowed or not supported by your javascript runtime");const o=await Pe(n.epk,e);let a,i;if(void 0!==n.apu){if("string"!=typeof n.apu)throw new C('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=w(n.apu)}catch{throw new C("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new C('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{i=w(n.apv)}catch{throw new C("Failed to base64url decode the apv")}}const s=await ne(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?ge(n.enc):parseInt(e.slice(-5,-2),10),a,i);if("ECDH-ES"===e)return s;if(void 0===r)throw new C("JWE Encrypted Key missing");return re(e.slice(-6),s,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new C("JWE Encrypted Key missing");return(async(e,t,r)=>{if(!i(t))throw new TypeError($(t,...z));if(J(t,e,"decrypt","unwrapKey"),se(e,t),t.usages.includes("decrypt"))return new Uint8Array(await a.subtle.decrypt(ie(e),t,r));if(t.usages.includes("unwrapKey")){const n=await a.subtle.unwrapKey("raw",r,t,ie(e),...X);return new Uint8Array(await a.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')})(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(void 0===r)throw new C("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new C('JOSE Header "p2c" (PBES2 Count) missing or invalid');const a=o?.maxPBES2Count||1e4;if(n.p2c>a)throw new C('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new C('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let i;try{i=w(n.p2s)}catch{throw new C("Failed to base64url decode the p2s")}return(async(e,t,r,n,o)=>{const a=await ae(o,e,n,t);return re(e.slice(-6),a,r)})(e,t,r,n.p2c,i)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new C("JWE Encrypted Key missing");return re(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(void 0===r)throw new C("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new C('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new C('JOSE Header "tag" (Authentication Tag) missing or invalid');let o,a;try{o=w(n.iv)}catch{throw new C("Failed to base64url decode the iv")}try{a=w(n.tag)}catch{throw new C("Failed to base64url decode the tag")}return async function(e,t,r,n,o){const a=e.slice(0,7);return V(a,t,r,n,o,new Uint8Array(0))}(e,t,r,o,a)}default:throw new k('Invalid or unsupported "alg" (JWE Algorithm) header value')}}(s,t,h,o,r)}catch(e){if(e instanceof TypeError||e instanceof C||e instanceof k)throw e;m=ve(u)}if(void 0!==e.iv)try{y=w(e.iv)}catch{throw new C("Failed to base64url decode the iv")}if(void 0!==e.tag)try{g=w(e.tag)}catch{throw new C("Failed to base64url decode the tag")}const b=c.encode(e.protected??"");let E,_;E=void 0!==e.aad?d(b,c.encode("."),c.encode(e.aad)):b;try{_=w(e.ciphertext)}catch{throw new C("Failed to base64url decode the ciphertext")}const A={plaintext:await V(u,m,_,y,g,E)};if(void 0!==e.protected&&(A.protectedHeader=n),void 0!==e.aad)try{A.additionalAuthenticatedData=w(e.aad)}catch{throw new C("Failed to base64url decode the aad")}return void 0!==e.unprotected&&(A.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(A.unprotectedHeader=e.header),v?{...A,key:t}:A}async function Ke(e,t,r){if(e instanceof Uint8Array&&(e=l.decode(e)),"string"!=typeof e)throw new C("Compact JWE must be a string or Uint8Array");const{0:n,1:o,2:a,3:i,4:s,length:c}=e.split(".");if(5!==c)throw new C("Invalid Compact JWE");const u=await Ue({ciphertext:i,iv:a||void 0,protected:n,tag:s||void 0,encrypted_key:o||void 0},t,r),d={plaintext:u.plaintext,protectedHeader:u.protectedHeader};return"function"==typeof t?{...d,key:u.key}:d}async function De(e,t,r){if(!Z(e))throw new C("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(Z))throw new C("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new C("JWE Recipients has no members");for(const n of e.recipients)try{return await Ue({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch{}throw new A}const Fe=Symbol();async function Je(e){return(e=>be("public","spki",e))(e)}async function Ge(e){return(e=>be("private","pkcs8",e))(e)}async function $e(e){return(async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:g(e)};if(!i(e))throw new TypeError($(e,...z,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:o,...s}=await a.subtle.exportKey("jwk",e);return s})(e)}const Be=async function(e,t,r,n,o={}){let s,c,l;switch(Re(e,r,"encrypt"),r=await(me?.(r,e))||r,e){case"dir":l=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!oe(r))throw new k("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:d}=o;let{epk:p}=o;p||(p=(await async function(e){if(!i(e))throw new TypeError($(e,...z));return a.subtle.generateKey(e.algorithm,!0,["deriveBits"])}(r)).privateKey);const{x:f,y:h,crv:m,kty:y}=await $e(p),v=await ne(r,p,"ECDH-ES"===e?t:e,"ECDH-ES"===e?ge(t):parseInt(e.slice(-5,-2),10),u,d);if(c={epk:{x:f,crv:m,kty:y}},"EC"===y&&(c.epk.y=h),u&&(c.apu=g(u)),d&&(c.apv=g(d)),"ECDH-ES"===e){l=v;break}l=n||ve(t);const w=e.slice(-6);s=await te(w,v,l);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":l=n||ve(t),s=await(async(e,t,r)=>{if(!i(t))throw new TypeError($(t,...z));if(J(t,e,"encrypt","wrapKey"),se(e,t),t.usages.includes("encrypt"))return new Uint8Array(await a.subtle.encrypt(ie(e),t,r));if(t.usages.includes("wrapKey")){const n=await a.subtle.importKey("raw",r,...X);return new Uint8Array(await a.subtle.wrapKey("raw",n,t,ie(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')})(e,r,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=n||ve(t);const{p2c:a,p2s:i}=o;({encryptedKey:s,...c}=await(async(e,t,r,n=2048,o=j(new Uint8Array(16)))=>{const a=await ae(o,e,n,t);return{encryptedKey:await te(e.slice(-6),a,r),p2c:n,p2s:g(o)}})(e,r,l,a,i));break}case"A128KW":case"A192KW":case"A256KW":l=n||ve(t),s=await te(e,r,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=n||ve(t);const{iv:a}=o;({encryptedKey:s,...c}=await async function(e,t,r,n){const o=e.slice(0,7),a=await He(o,r,t,n,new Uint8Array(0));return{encryptedKey:a.ciphertext,iv:g(a.iv),tag:g(a.tag)}}(e,r,l,a));break}default:throw new k('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:l,encryptedKey:s,parameters:c}};class qe{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new C("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Y(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new C("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(Ne(C,new Map,t?.crit,this._protectedHeader,r),void 0!==r.zip)throw new k('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:n,enc:o}=r;if("string"!=typeof n||!n)throw new C('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof o||!o)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a,i,s,u,p;if(this._cek&&("dir"===n||"ECDH-ES"===n))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${n}`);{let r;({cek:i,encryptedKey:a,parameters:r}=await Be(n,o,e,this._cek,this._keyManagementParameters)),r&&(t&&Fe in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...r}:this.setUnprotectedHeader(r):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...r}:this.setProtectedHeader(r))}u=this._protectedHeader?c.encode(g(JSON.stringify(this._protectedHeader))):c.encode(""),this._aad?(p=g(this._aad),s=d(u,c.encode("."),c.encode(p))):s=u;const{ciphertext:f,tag:h,iv:m}=await He(o,this._plaintext,i,this._iv,s),y={ciphertext:g(f)};return m&&(y.iv=g(m)),h&&(y.tag=g(h)),a&&(y.encrypted_key=g(a)),p&&(y.aad=p),this._protectedHeader&&(y.protected=l.decode(u)),this._sharedUnprotectedHeader&&(y.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(y.header=this._unprotectedHeader),y}}class ze{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class Ve{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){const r=new ze(this,e,{crit:t?.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(){if(!this._recipients.length)throw new C("at least one recipient must be added");if(1===this._recipients.length){const[e]=this._recipients,t=await new qe(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(e.unprotectedHeader).encrypt(e.key,{...e.options}),r={ciphertext:t.ciphertext,iv:t.iv,recipients:[{}],tag:t.tag};return t.aad&&(r.aad=t.aad),t.protected&&(r.protected=t.protected),t.unprotected&&(r.unprotected=t.unprotected),t.encrypted_key&&(r.recipients[0].encrypted_key=t.encrypted_key),t.header&&(r.recipients[0].header=t.header),r}let e;for(let t=0;t<this._recipients.length;t++){const r=this._recipients[t];if(!Y(this._protectedHeader,this._unprotectedHeader,r.unprotectedHeader))throw new C("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...r.unprotectedHeader},{alg:o}=n;if("string"!=typeof o||!o)throw new C('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===o||"ECDH-ES"===o)throw new C('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof n.enc||!n.enc)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(e){if(e!==n.enc)throw new C('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else e=n.enc;if(Ne(C,new Map,r.options.crit,this._protectedHeader,n),void 0!==n.zip)throw new k('JWE "zip" (Compression Algorithm) Header Parameter is not supported.')}const t=ve(e),r={ciphertext:"",iv:"",recipients:[],tag:""};for(let n=0;n<this._recipients.length;n++){const o=this._recipients[n],a={};r.recipients.push(a);const i={...this._protectedHeader,...this._unprotectedHeader,...o.unprotectedHeader}.alg.startsWith("PBES2")?2048+n:void 0;if(0===n){const e=await new qe(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(t).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(o.unprotectedHeader).setKeyManagementParameters({p2c:i}).encrypt(o.key,{...o.options,[Fe]:!0});r.ciphertext=e.ciphertext,r.iv=e.iv,r.tag=e.tag,e.aad&&(r.aad=e.aad),e.protected&&(r.protected=e.protected),e.unprotected&&(r.unprotected=e.unprotected),a.encrypted_key=e.encrypted_key,e.header&&(a.header=e.header);continue}const{encryptedKey:s,parameters:c}=await Be(o.unprotectedHeader?.alg||this._protectedHeader?.alg||this._unprotectedHeader?.alg,e,o.key,t,{p2c:i});a.encrypted_key=g(s),(o.unprotectedHeader||c)&&(a.header={...o.unprotectedHeader,...c})}return r}}function Ye(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new k(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Ze(e,t,r){if("sign"===r&&(t=await ye(t,e)),"verify"===r&&(t=await me(t,e)),i(t))return function(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!K(e.algorithm,"HMAC"))throw U("HMAC");const r=parseInt(t.slice(2),10);if(D(e.algorithm.hash)!==r)throw U(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!K(e.algorithm,"RSASSA-PKCS1-v1_5"))throw U("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(D(e.algorithm.hash)!==r)throw U(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!K(e.algorithm,"RSA-PSS"))throw U("RSA-PSS");const r=parseInt(t.slice(2),10);if(D(e.algorithm.hash)!==r)throw U(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw U("Ed25519 or Ed448");break;case"Ed25519":if(!K(e.algorithm,"Ed25519"))throw U("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!K(e.algorithm,"ECDSA"))throw U("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw U(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}F(e,r)}(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...z));return a.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...z,"Uint8Array","JSON Web Key"))}async function Xe(e,t,r){if(!Z(e))throw new x("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new x('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new x("JWS Protected Header incorrect type");if(void 0===e.payload)throw new x("JWS Payload missing");if("string"!=typeof e.signature)throw new x("JWS Signature missing or incorrect type");if(void 0!==e.header&&!Z(e.header))throw new x("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{const t=w(e.protected);n=JSON.parse(l.decode(t))}catch{throw new x("JWS Protected Header is invalid")}if(!Y(n,e.header))throw new x("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const o={...n,...e.header};let i=!0;if(Ne(x,new Map([["b64",!0]]),r?.crit,n,o).has("b64")&&(i=n.b64,"boolean"!=typeof i))throw new x('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:s}=o;if("string"!=typeof s||!s)throw new x('JWS "alg" (Algorithm) Header Parameter missing or invalid');const u=r&&We("algorithms",r.algorithms);if(u&&!u.has(s))throw new S('"alg" (Algorithm) Header Parameter value not allowed');if(i){if("string"!=typeof e.payload)throw new x("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new x("JWS Payload must be a string or an Uint8Array instance");let p=!1;"function"==typeof t?(t=await t(n,e),p=!0,je(s,t,"verify"),ce(t)&&(t=await Pe(t,s))):je(s,t,"verify");const f=d(c.encode(e.protected??""),c.encode("."),"string"==typeof e.payload?c.encode(e.payload):e.payload);let h,m;try{h=w(e.signature)}catch{throw new x("Failed to base64url decode the signature")}if(!await(async(e,t,r,n)=>{const o=await Ze(e,t,"verify");se(e,o);const i=Ye(e,o.algorithm);try{return await a.subtle.verify(i,o,r,n)}catch{return!1}})(s,t,h,f))throw new R;if(i)try{m=w(e.payload)}catch{throw new x("Failed to base64url decode the payload")}else m="string"==typeof e.payload?c.encode(e.payload):e.payload;const y={payload:m};return void 0!==e.protected&&(y.protectedHeader=n),void 0!==e.header&&(y.unprotectedHeader=e.header),p?{...y,key:t}:y}async function Qe(e,t,r){if(e instanceof Uint8Array&&(e=l.decode(e)),"string"!=typeof e)throw new x("Compact JWS must be a string or Uint8Array");const{0:n,1:o,2:a,length:i}=e.split(".");if(3!==i)throw new x("Invalid Compact JWS");const s=await Xe({payload:o,protected:n,signature:a},t,r),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...c,key:s.key}:c}async function et(e,t,r){if(!Z(e))throw new x("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(Z))throw new x("JWS Signatures missing or incorrect type");for(const n of e.signatures)try{return await Xe({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new R}const tt=e=>Math.floor(e.getTime()/1e3),rt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,nt=e=>{const t=rt.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const r=parseFloat(t[2]);let n;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":n=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":n=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":n=Math.round(3600*r);break;case"day":case"days":case"d":n=Math.round(86400*r);break;case"week":case"weeks":case"w":n=Math.round(604800*r);break;default:n=Math.round(31557600*r)}return"-"===t[1]||"ago"===t[4]?-n:n},ot=e=>e.toLowerCase().replace(/^application\//,""),at=(e,t,r={})=>{let n;try{n=JSON.parse(l.decode(t))}catch{}if(!Z(n))throw new T("JWT Claims Set must be a top-level JSON object");const{typ:o}=r;if(o&&("string"!=typeof e.typ||ot(e.typ)!==ot(o)))throw new E('unexpected "typ" JWT header value',n,"typ","check_failed");const{requiredClaims:a=[],issuer:i,subject:s,audience:c,maxTokenAge:u}=r,d=[...a];void 0!==u&&d.push("iat"),void 0!==c&&d.push("aud"),void 0!==s&&d.push("sub"),void 0!==i&&d.push("iss");for(const e of new Set(d.reverse()))if(!(e in n))throw new E(`missing required "${e}" claim`,n,e,"missing");if(i&&!(Array.isArray(i)?i:[i]).includes(n.iss))throw new E('unexpected "iss" claim value',n,"iss","check_failed");if(s&&n.sub!==s)throw new E('unexpected "sub" claim value',n,"sub","check_failed");if(c&&(f="string"==typeof c?[c]:c,!("string"==typeof(p=n.aud)?f.includes(p):Array.isArray(p)&&f.some(Set.prototype.has.bind(new Set(p))))))throw new E('unexpected "aud" claim value',n,"aud","check_failed");var p,f;let h;switch(typeof r.clockTolerance){case"string":h=nt(r.clockTolerance);break;case"number":h=r.clockTolerance;break;case"undefined":h=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:m}=r,y=tt(m||new Date);if((void 0!==n.iat||u)&&"number"!=typeof n.iat)throw new E('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new E('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>y+h)throw new E('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new E('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=y-h)throw new _('"exp" claim timestamp check failed',n,"exp","check_failed")}if(u){const e=y-n.iat;if(e-h>("number"==typeof u?u:nt(u)))throw new _('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(e<0-h)throw new E('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n};async function it(e,t,r){const n=await Qe(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&!1===n.protectedHeader.b64)throw new T("JWTs MUST NOT use unencoded payload");const o={payload:at(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return"function"==typeof t?{...o,key:n.key}:o}async function st(e,t,r){const n=await Ke(e,t,r),o=at(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(void 0!==a.iss&&a.iss!==o.iss)throw new E('replicated "iss" claim header parameter mismatch',o,"iss","mismatch");if(void 0!==a.sub&&a.sub!==o.sub)throw new E('replicated "sub" claim header parameter mismatch',o,"sub","mismatch");if(void 0!==a.aud&&JSON.stringify(a.aud)!==JSON.stringify(o.aud))throw new E('replicated "aud" claim header parameter mismatch',o,"aud","mismatch");const i={payload:o,protectedHeader:a};return"function"==typeof t?{...i,key:n.key}:i}class ct{constructor(e){this._flattened=new qe(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,t){const r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}class lt{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new x("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Y(this._protectedHeader,this._unprotectedHeader))throw new x("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader};let n=!0;if(Ne(x,new Map([["b64",!0]]),t?.crit,this._protectedHeader,r).has("b64")&&(n=this._protectedHeader.b64,"boolean"!=typeof n))throw new x('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:o}=r;if("string"!=typeof o||!o)throw new x('JWS "alg" (Algorithm) Header Parameter missing or invalid');je(o,e,"sign");let i,s=this._payload;n&&(s=c.encode(g(s))),i=this._protectedHeader?c.encode(g(JSON.stringify(this._protectedHeader))):c.encode("");const u=d(i,c.encode("."),s),p=await(async(e,t,r)=>{const n=await Ze(e,t,"sign");se(e,n);const o=await a.subtle.sign(Ye(e,n.algorithm),n,r);return new Uint8Array(o)})(o,e,u),f={signature:g(p),payload:""};return n&&(f.payload=l.decode(s)),this._unprotectedHeader&&(f.header=this._unprotectedHeader),this._protectedHeader&&(f.protected=l.decode(i)),f}}class ut{constructor(e){this._flattened=new lt(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const r=await this._flattened.sign(e,t);if(void 0===r.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class dt{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class pt{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){const r=new dt(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new x("at least one signature must be added");const e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){const r=this._signatures[t],n=new lt(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);const{payload:o,...a}=await n.sign(r.key,r.options);if(0===t)e.payload=o;else if(e.payload!==o)throw new x("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(a)}return e}}function ft(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}class ht{constructor(e={}){if(!Z(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return"number"==typeof e?this._payload={...this._payload,nbf:ft("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:ft("setNotBefore",tt(e))}:this._payload={...this._payload,nbf:tt(new Date)+nt(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:ft("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:ft("setExpirationTime",tt(e))}:this._payload={...this._payload,exp:tt(new Date)+nt(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:tt(new Date)}:e instanceof Date?this._payload={...this._payload,iat:ft("setIssuedAt",tt(e))}:this._payload="string"==typeof e?{...this._payload,iat:ft("setIssuedAt",tt(new Date)+nt(e))}:{...this._payload,iat:ft("setIssuedAt",e)},this}}class mt extends ht{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){const r=new ut(c.encode(JSON.stringify(this._payload)));if(r.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new T("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}class yt extends ht{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,t){const r=new ct(c.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}const gt=(e,t)=>{if("string"!=typeof e||!e)throw new O(`${t} missing or invalid`)};async function vt(e,t){if(!Z(e))throw new TypeError("JWK must be an object");if(t??(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(e.kty){case"EC":gt(e.crv,'"crv" (Curve) Parameter'),gt(e.x,'"x" (X Coordinate) Parameter'),gt(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":gt(e.crv,'"crv" (Subtype of Key Pair) Parameter'),gt(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":gt(e.e,'"e" (Exponent) Parameter'),gt(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":gt(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new k('"kty" (Key Type) Parameter missing or unsupported')}const n=c.encode(JSON.stringify(r));return g(await s(t,n))}async function wt(e,t){t??(t="sha256");const r=await vt(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function bt(e,t){const r={...e,...t?.header};if(!Z(r.jwk))throw new x('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await Pe({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||"public"!==n.type)throw new x('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function Et(e){return Z(e)}function _t(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}class St{constructor(e){if(this._cached=new WeakMap,!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(Et)}(e))throw new P("JSON Web Key Set malformed");this._jwks=_t(e)}async getKey(e,t){const{alg:r,kid:n}={...e,...t?.header},o=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new k('Unsupported "alg" value for a JSON Web Key Set')}}(r),a=this._jwks.keys.filter(e=>{let t=o===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":t="Ed25519"===e.crv;break;case"EdDSA":t="Ed25519"===e.crv||"Ed448"===e.crv}return t}),{0:i,length:s}=a;if(0===s)throw new I;if(1!==s){const e=new L,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(const e of a)try{yield await kt(t,e,r)}catch{}},e}return kt(this._cached,i,r)}}async function kt(e,t,r){const n=e.get(t)||e.set(t,{}).get(t);if(void 0===n[r]){const e=await Pe({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new P("JSON Web Key Set members must be public keys");n[r]=e}return n[r]}function At(e){const t=new St(e),r=async(e,r)=>t.getKey(e,r);return Object.defineProperties(r,{jwks:{value:()=>_t(t._jwks),enumerable:!0,configurable:!1,writable:!1}}),r}let Ct;"undefined"!=typeof navigator&&navigator.userAgent?.startsWith?.("Mozilla/5.0 ")||(Ct="jose/v5.10.0");const xt=Symbol();class Tt{constructor(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");var r,n;this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration="number"==typeof t?.timeoutDuration?t?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof t?.cooldownDuration?t?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof t?.cacheMaxAge?t?.cacheMaxAge:6e5,void 0!==t?.[xt]&&(this._cache=t?.[xt],r=t?.[xt],n=this._cacheMaxAge,"object"==typeof r&&null!==r&&"uat"in r&&"number"==typeof r.uat&&!(Date.now()-r.uat>=n)&&"jwks"in r&&Z(r.jwks)&&Array.isArray(r.jwks.keys)&&Array.prototype.every.call(r.jwks.keys,Z)&&(this._jwksTimestamp=this._cache.uat,this._local=At(this._cache.jwks)))}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._local&&this.fresh()||await this.reload();try{return await this._local(e,t)}catch(r){if(r instanceof I&&!1===this.coolingDown())return await this.reload(),this._local(e,t);throw r}}async reload(){this._pendingFetch&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);const e=new Headers(this._options.headers);Ct&&!e.has("User-Agent")&&(e.set("User-Agent",Ct),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||(this._pendingFetch=(async(e,t,r)=>{let n,o,a=!1;"function"==typeof AbortController&&(n=new AbortController,o=setTimeout(()=>{a=!0,n.abort()},t));const i=await fetch(e.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(a)throw new M;throw e});if(void 0!==o&&clearTimeout(o),200!==i.status)throw new b("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new b("Failed to parse the JSON Web Key Set HTTP response as JSON")}})(this._url,this._timeoutDuration,this._options).then(e=>{this._local=At(e),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=e),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function Ot(e,t){const r=new Tt(e,t),n=async(e,t)=>r.getKey(e,t);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!r._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>r._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}const Pt=xt;class It extends ht{encode(){return`${g(JSON.stringify({alg:"none"}))}.${g(JSON.stringify(this._payload))}.`}static decode(e,t){if("string"!=typeof e)throw new T("Unsecured JWT must be a string");const{0:r,1:n,2:o,length:a}=e.split(".");if(3!==a||""!==o)throw new T("Invalid Unsecured JWT");let i;try{if(i=JSON.parse(l.decode(w(r))),"none"!==i.alg)throw new Error}catch{throw new T("Invalid Unsecured JWT")}return{payload:at(i,w(n),t),header:i}}}const Lt=g,Mt=w;function Rt(e){let t;if("string"==typeof e){const r=e.split(".");3!==r.length&&5!==r.length||([t]=r)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(l.decode(Mt(t)));if(!Z(e))throw new Error;return e}catch{throw new TypeError("Invalid Token or Protected Header formatting")}}function jt(e){if("string"!=typeof e)throw new T("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:r}=e.split(".");if(5===r)throw new T("Only JWTs using Compact JWS serialization can be decoded");if(3!==r)throw new T("Invalid JWT");if(!t)throw new T("JWTs must contain a payload");let n,o;try{n=Mt(t)}catch{throw new T("Failed to base64url decode the payload")}try{o=JSON.parse(l.decode(n))}catch{throw new T("Failed to parse the decoded payload as JSON")}if(!Z(o))throw new T("Invalid JWT Claims Set");return o}function Ht(e){const t=e?.modulusLength??2048;if("number"!=typeof t||t<2048)throw new k("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function Nt(e,t){return async function(e,t){let r,n;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ht(t)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ht(t)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:Ht(t)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"Ed25519":r={name:"Ed25519"},n=["sign","verify"];break;case"EdDSA":{n=["sign","verify"];const e=t?.crv??"Ed25519";switch(e){case"Ed25519":case"Ed448":r={name:e};break;default:throw new k("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveKey","deriveBits"];const e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":r={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":r={name:e};break;default:throw new k("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(r,t?.extractable??!1,n)}(e,t)}async function Wt(e,t){return async function(e,t){let r,n,o;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),n={name:"HMAC",hash:`SHA-${r}`,length:r},o=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(e.slice(-3),10),j(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(e.slice(1,4),10),n={name:"AES-KW",length:r},o=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10),n={name:"AES-GCM",length:r},o=["encrypt","decrypt"];break;default:throw new k('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return a.subtle.generateKey(n,t?.extractable??!1,o)}(e,t)}const Ut="WebCryptoAPI"},27723(e){"use strict";e.exports=window.wp.i18n},29491(e){"use strict";e.exports=window.wp.compose},32485(e,t){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var a=typeof r;if("string"===a||"number"===a)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===a){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){e.push(r.toString());continue}for(var s in r)n.call(r,s)&&r[s]&&e.push(s)}}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},35427(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TWITTER_IMAGE_SIZES=t.FACEBOOK_IMAGE_SIZES=void 0,t.determineFacebookImageMode=function(e){(0,n.logOnce)("@yoast/social-metadata-previews/determineFacebookImageMode","[@yoast/social-metadata-previews] 'determineFacebookImageMode' is deprecated and will be removed in the future, please use this from @yoast/social-metadata-forms instead.");const{largeThreshold:t}=o;return e.height>e.width?"portrait":e.width<t.width||e.height<t.height||e.height===e.width?"square":"landscape"};var n=r(48598);t.TWITTER_IMAGE_SIZES=(0,n.createObjectWrapper)({squareWidth:125,squareHeight:125,landscapeWidth:506,landscapeHeight:265,aspectRatio:50.2},(e,t)=>(0,n.logOnce)(`@yoast/social-metadata-previews/TWITTER_IMAGE_SIZES/${e}/${t}`,`[@yoast/social-metadata-previews] "TWITTER_IMAGE_SIZES.${t}" is deprecated and will be removed in the future, please use this from @yoast/social-metadata-forms instead.`));const o=t.FACEBOOK_IMAGE_SIZES=(0,n.createObjectWrapper)({squareWidth:158,squareHeight:158,landscapeWidth:527,landscapeHeight:273,portraitWidth:158,portraitHeight:237,aspectRatio:52.2,largeThreshold:{width:446,height:233}},(e,t)=>(0,n.logOnce)(`@yoast/social-metadata-previews/FACEBOOK_IMAGE_SIZES/${e}/${t}`,`[@yoast/social-metadata-previews] "FACEBOOK_IMAGE_SIZES.${t}" is deprecated and will be removed in the future, please use this from @yoast/social-metadata-forms instead.`))},36737(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=((n=r(21679))&&n.__esModule?n:{default:n}).default.p`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
color: rgb(15, 20, 25);
cursor: pointer;
`;t.default=o},43473(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(51609)),o=i(r(21679)),a=i(r(71802));function i(e){return e&&e.__esModule?e:{default:e}}const s=o.default.div`
display: flex;
flex-direction: column;
padding: 12px;
justify-content: center;
margin: 0;
box-sizing: border-box;
flex: auto;
min-width: 0px;
gap:2px;
> * {
line-height:20px;
min-height:20px;
font-size:15px;
}
`,c=e=>n.default.createElement(s,null,e.children);c.propTypes={children:a.default.array.isRequired},t.default=c},45831(e){"use strict";e.exports=window.yoast.uiLibrary},46775(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.facebookTitleLineHeight=t.default=void 0;var n,o=(n=r(21679))&&n.__esModule?n:{default:n};const a=t.facebookTitleLineHeight=20,i=o.default.span`
line-height: ${a}px;
min-height : ${a}px;
color: #1d2129;
font-weight: 600;
overflow: hidden;
font-size: 16px;
margin: 3px 0 0;
letter-spacing: normal;
white-space: normal;
flex-shrink: 0;
cursor: pointer;
display: -webkit-box;
-webkit-line-clamp: ${e=>e.lineCount};
-webkit-box-orient: vertical;
overflow: hidden;
`;t.default=i},47248(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SocialImage=void 0;var n=i(r(71802)),o=i(r(51609)),a=i(r(21679));function i(e){return e&&e.__esModule?e:{default:e}}const s=a.default.img`
&& {
max-width: ${e=>e.width}px;
height: ${e=>e.height}px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-width: none;
}
`,c=a.default.img`
&& {
height: 100%;
position: absolute;
width: 100%;
object-fit: cover;
}
`,l=a.default.div`
padding-bottom: ${e=>e.aspectRatio}%;
`,u=({imageProps:e,width:t,height:r,imageMode:n="landscape"})=>"landscape"===n?o.default.createElement(l,{aspectRatio:e.aspectRatio},o.default.createElement(c,{src:e.src,alt:e.alt})):o.default.createElement(s,{src:e.src,alt:e.alt,width:t,height:r,imageProperties:e});t.SocialImage=u,u.propTypes={imageProps:n.default.shape({src:n.default.string.isRequired,alt:n.default.string.isRequired,aspectRatio:n.default.number.isRequired}).isRequired,width:n.default.number.isRequired,height:n.default.number.isRequired,imageMode:n.default.string}},48598(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logOnce=t.createObjectWrapper=void 0;var n=r(66087);const o={};t.logOnce=(e,t,{log:r=console.warn}={})=>{o[e]||(o[e]=!0,r(t))},t.createObjectWrapper=(e,t=n.noop)=>{const r={};for(const n in e)Object.hasOwn(e,n)&&Object.defineProperty(r,n,{set:r=>{e[n]=r,t("set",n,r)},get:()=>(t("get",n),e[n])});return r}},50197(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=p(r(51609)),o=u(r(71802)),a=u(r(21679)),i=u(r(12129)),s=u(r(14192)),c=p(r(46775)),l=u(r(78279));function u(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function p(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}const f=e=>{switch(e){case"landscape":return"527px";case"square":case"portrait":return"369px";default:return"476px"}},h=a.default.div`
box-sizing: border-box;
display: flex;
flex-direction: ${e=>"landscape"===e.mode?"column":"row"};
background-color: #f2f3f5;
max-width: 527px;
`,m=a.default.div`
box-sizing: border-box;
background-color: #f2f3f5;
margin: 0;
padding: 10px 12px;
position: relative;
border-bottom: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border-top: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border-right: ${e=>"landscape"===e.mode?"":"1px solid #dddfe2"};
border: ${e=>"landscape"===e.mode?"1px solid #dddfe2":""};
display: flex;
flex-direction: column;
flex-grow: 1;
justify-content: ${e=>"landscape"===e.mode?"flex-start":"center"};
font-size: 12px;
overflow: hidden;
`;class y extends n.Component{constructor(e){super(e),this.state={imageMode:null,maxLineCount:0,descriptionLineCount:0},this.facebookTitleRef=n.default.createRef(),this.onImageLoaded=this.onImageLoaded.bind(this),this.onImageEnter=this.props.onMouseHover.bind(this,"image"),this.onTitleEnter=this.props.onMouseHover.bind(this,"title"),this.onDescriptionEnter=this.props.onMouseHover.bind(this,"description"),this.onLeave=this.props.onMouseHover.bind(this,""),this.onSelectTitle=this.props.onSelect.bind(this,"title"),this.onSelectDescription=this.props.onSelect.bind(this,"description")}onImageLoaded(e){this.setState({imageMode:e})}getTitleLineCount(){return this.facebookTitleRef.current.offsetHeight/c.facebookTitleLineHeight}maybeSetMaxLineCount(){const{imageMode:e,maxLineCount:t}=this.state,r="landscape"===e?2:5;r!==t&&this.setState({maxLineCount:r})}maybeSetDescriptionLineCount(){const{descriptionLineCount:e,maxLineCount:t,imageMode:r}=this.state,n=this.getTitleLineCount();let o=t-n;"portrait"===r&&(o=5===n?0:4),o!==e&&this.setState({descriptionLineCount:o})}componentDidUpdate(){this.maybeSetMaxLineCount(),this.maybeSetDescriptionLineCount()}render(){const{imageMode:e,maxLineCount:t,descriptionLineCount:r}=this.state;return n.default.createElement(h,{id:"facebookPreview",mode:e},n.default.createElement(s.default,{src:this.props.imageUrl||this.props.imageFallbackUrl,alt:this.props.alt,onImageLoaded:this.onImageLoaded,onImageClick:this.props.onImageClick,onMouseEnter:this.onImageEnter,onMouseLeave:this.onLeave}),n.default.createElement(m,{mode:e},n.default.createElement(i.default,{siteUrl:this.props.siteUrl,mode:e}),n.default.createElement(c.default,{ref:this.facebookTitleRef,onMouseEnter:this.onTitleEnter,onMouseLeave:this.onLeave,onClick:this.onSelectTitle,lineCount:t},this.props.title),r>0&&n.default.createElement(l.default,{maxWidth:f(e),onMouseEnter:this.onDescriptionEnter,onMouseLeave:this.onLeave,onClick:this.onSelectDescription,lineCount:r},this.props.description)))}}y.propTypes={siteUrl:o.default.string.isRequired,title:o.default.string.isRequired,description:o.default.string,imageUrl:o.default.string,imageFallbackUrl:o.default.string,alt:o.default.string,onSelect:o.default.func,onImageClick:o.default.func,onMouseHover:o.default.func},y.defaultProps={description:"",alt:"",imageUrl:"",imageFallbackUrl:"",onSelect:()=>{},onImageClick:()=>{},onMouseHover:()=>{}},t.default=y},51609(e){"use strict";e.exports=window.React},52547(e){"use strict";e.exports=window.yoast.replacementVariableEditor},53324(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(56554),o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}(r(51609)),a=u(r(71802)),i=r(12379),s=u(r(50197)),c=u(r(66459)),l=r(52547);function u(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}class p extends o.Component{constructor(e){super(e),this.state={activeField:"",hoveredField:""},this.SocialPreview="Social"===e.socialMediumName?s.default:c.default,this.setHoveredField=this.setHoveredField.bind(this),this.setActiveField=this.setActiveField.bind(this),this.setEditorRef=this.setEditorRef.bind(this),this.setEditorFocus=this.setEditorFocus.bind(this)}setHoveredField(e){e!==this.state.hoveredField&&this.setState({hoveredField:e})}setActiveField(e){e!==this.state.activeField&&this.setState({activeField:e},()=>this.setEditorFocus(e))}setEditorFocus(e){switch(e){case"title":this.titleEditorRef.focus();break;case"description":this.descriptionEditorRef.focus()}}setEditorRef(e,t){switch(e){case"title":this.titleEditorRef=t;break;case"description":this.descriptionEditorRef=t}}render(){const{onDescriptionChange:e,onTitleChange:t,onSelectImageClick:r,onRemoveImageClick:a,socialMediumName:s,imageWarnings:c,siteUrl:l,description:u,descriptionInputPlaceholder:d,descriptionPreviewFallback:p,imageUrl:f,imageFallbackUrl:h,alt:m,title:y,titleInputPlaceholder:g,titlePreviewFallback:v,replacementVariables:w,recommendedReplacementVariables:b,applyReplacementVariables:E,onReplacementVariableSearchChange:_,isPremium:S,isLarge:k,socialPreviewLabel:A,idSuffix:C,activeMetaTabId:x}=this.props,T=E({title:y||v,description:u||p});return o.default.createElement(o.default.Fragment,null,A&&o.default.createElement(n.SimulatedLabel,null,A),o.default.createElement(this.SocialPreview,{onMouseHover:this.setHoveredField,onSelect:this.setActiveField,onImageClick:r,siteUrl:l,title:T.title,description:T.description,imageUrl:f,imageFallbackUrl:h,alt:m,isLarge:k,activeMetaTabId:x}),o.default.createElement(i.SocialMetadataPreviewForm,{onDescriptionChange:e,socialMediumName:s,title:y,titleInputPlaceholder:g,onRemoveImageClick:a,imageSelected:!!f,imageUrl:f,imageFallbackUrl:h,onTitleChange:t,onSelectImageClick:r,description:u,descriptionInputPlaceholder:d,imageWarnings:c,replacementVariables:w,recommendedReplacementVariables:b,onReplacementVariableSearchChange:_,onMouseHover:this.setHoveredField,hoveredField:this.state.hoveredField,onSelect:this.setActiveField,activeField:this.state.activeField,isPremium:S,setEditorRef:this.setEditorRef,idSuffix:C}))}}p.propTypes={title:a.default.string.isRequired,onTitleChange:a.default.func.isRequired,description:a.default.string.isRequired,onDescriptionChange:a.default.func.isRequired,imageUrl:a.default.string.isRequired,imageFallbackUrl:a.default.string.isRequired,onSelectImageClick:a.default.func.isRequired,onRemoveImageClick:a.default.func.isRequired,socialMediumName:a.default.string.isRequired,alt:a.default.string,isPremium:a.default.bool,imageWarnings:a.default.array,isLarge:a.default.bool,siteUrl:a.default.string,descriptionInputPlaceholder:a.default.string,titleInputPlaceholder:a.default.string,descriptionPreviewFallback:a.default.string,titlePreviewFallback:a.default.string,replacementVariables:l.replacementVariablesShape,recommendedReplacementVariables:l.recommendedReplacementVariablesShape,applyReplacementVariables:a.default.func,onReplacementVariableSearchChange:a.default.func,socialPreviewLabel:a.default.string,idSuffix:a.default.string,activeMetaTabId:a.default.string},p.defaultProps={imageWarnings:[],recommendedReplacementVariables:[],replacementVariables:[],isPremium:!1,isLarge:!0,siteUrl:"",descriptionInputPlaceholder:"",titleInputPlaceholder:"",descriptionPreviewFallback:"",titlePreviewFallback:"",alt:"",applyReplacementVariables:e=>e,onReplacementVariableSearchChange:null,socialPreviewLabel:"",idSuffix:"",activeMetaTabId:""},t.default=p},53838(e){"use strict";e.exports=window.yoast.searchMetadataPreviews},56200(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"FACEBOOK_IMAGE_SIZES",{enumerable:!0,get:function(){return i.FACEBOOK_IMAGE_SIZES}}),Object.defineProperty(t,"FacebookPreview",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"SocialPreviewEditor",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"TWITTER_IMAGE_SIZES",{enumerable:!0,get:function(){return i.TWITTER_IMAGE_SIZES}}),Object.defineProperty(t,"TwitterPreview",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"determineFacebookImageMode",{enumerable:!0,get:function(){return i.determineFacebookImageMode}});var n=s(r(50197)),o=s(r(66459)),a=s(r(53324)),i=r(35427);function s(e){return e&&e.__esModule?e:{default:e}}},56554(e){"use strict";e.exports=window.yoast.componentsNew},66087(e){"use strict";e.exports=window.lodash},66459(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=p(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}(r(51609)),o=d(r(71802)),a=d(r(21679)),i=d(r(9939)),s=d(r(81238)),c=d(r(43473)),l=d(r(36737)),u=d(r(79013));function d(e){return e&&e.__esModule?e:{default:e}}function p(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(p=function(e){return e?r:t})(e)}const f=a.default.div`
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
font-size: 15px;
font-weight: 400;
line-height: 20px;
max-width: 507px;
border: 1px solid #E1E8ED;
box-sizing: border-box;
border-radius: 14px;
color: #292F33;
background: #FFFFFF;
text-overflow: ellipsis;
display: flex;
&:hover {
background: #f5f8fa;
border: 1px solid rgba(136,153,166,.5);
}
`,h=(0,a.default)(f)`
flex-direction: column;
max-height: 370px;
`,m=(0,a.default)(f)`
flex-direction: row;
height: 125px;
`;class y extends n.Component{constructor(e){super(e),this.onImageEnter=this.props.onMouseHover.bind(this,"image"),this.onTitleEnter=this.props.onMouseHover.bind(this,"title"),this.onDescriptionEnter=this.props.onMouseHover.bind(this,"description"),this.onLeave=this.props.onMouseHover.bind(this,""),this.onSelectTitle=this.props.onSelect.bind(this,"title"),this.onSelectDescription=this.props.onSelect.bind(this,"description")}render(){const{isLarge:e,imageUrl:t,imageFallbackUrl:r,alt:o,title:a,description:d,siteUrl:p}=this.props,f=e?h:m;return n.default.createElement(f,{id:"twitterPreview"},n.default.createElement(s.default,{src:t||r,alt:o,isLarge:e,onImageClick:this.props.onImageClick,onMouseEnter:this.onImageEnter,onMouseLeave:this.onLeave}),n.default.createElement(c.default,null,n.default.createElement(i.default,{siteUrl:p}),n.default.createElement(l.default,{onMouseEnter:this.onTitleEnter,onMouseLeave:this.onLeave,onClick:this.onSelectTitle},a),n.default.createElement(u.default,{onMouseEnter:this.onDescriptionEnter,onMouseLeave:this.onLeave,onClick:this.onSelectDescription},d)))}}y.propTypes={siteUrl:o.default.string.isRequired,title:o.default.string.isRequired,description:o.default.string,isLarge:o.default.bool,imageUrl:o.default.string,imageFallbackUrl:o.default.string,alt:o.default.string,onSelect:o.default.func,onImageClick:o.default.func,onMouseHover:o.default.func},y.defaultProps={description:"",alt:"",imageUrl:"",imageFallbackUrl:"",onSelect:()=>{},onImageClick:()=>{},onMouseHover:()=>{},isLarge:!0},t.default=y},68511(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculateImageDimensions=s,t.calculateImageRatios=a,t.calculateLargestDimensions=i,t.determineImageProperties=c,t.handleImage=async function(e,t,r=!1){try{return{imageProperties:await c(e,t,r),status:"loaded"}}catch(e){return{imageProperties:null,status:"errored"}}},t.retrieveExpectedDimensions=o;var n=r(12379);function o(e){return"Twitter"===e?n.TWITTER_IMAGE_SIZES:n.FACEBOOK_IMAGE_SIZES}function a(e,t,r){return"landscape"===r?{widthRatio:t.width/e.landscapeWidth,heightRatio:t.height/e.landscapeHeight}:"portrait"===r?{widthRatio:t.width/e.portraitWidth,heightRatio:t.height/e.portraitHeight}:{widthRatio:t.width/e.squareWidth,heightRatio:t.height/e.squareHeight}}function i(e,t){return t.widthRatio<=t.heightRatio?{width:Math.round(e.width/t.widthRatio),height:Math.round(e.height/t.widthRatio)}:{width:Math.round(e.width/t.heightRatio),height:Math.round(e.height/t.heightRatio)}}function s(e,t,r){return"square"===r&&t.width===t.height?{width:e.squareWidth,height:e.squareHeight}:i(t,a(e,t,r))}async function c(e,t,r=!1){const a=await function(e){return new Promise((t,r)=>{const n=new Image;n.onload=()=>{t({width:n.width,height:n.height})},n.onerror=r,n.src=e})}(e);let i=r?"landscape":"square";"Facebook"===t&&(i=(0,n.determineFacebookImageMode)(a));const c=s(o(t),a,i);return{mode:i,height:c.height,width:c.width}}},69248(e,t,r){var n;n=()=>(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AIGenerator:()=>Wt,AIOptimize:()=>Dr,ASSESSMENTS_MAP:()=>Kr,AiClient:()=>F,ClientError:()=>O,ConsentModal:()=>Or,ConsentRevokeConfirmModal:()=>Lr,ConsentSavedNotification:()=>yt,DialogContent:()=>At,ErrorCode:()=>x,ErrorModal:()=>Rr,FacebookDescriptionGenerator:()=>Bt,FacebookTitleGenerator:()=>Jt,GradientButton:()=>Jr,GradientToast:()=>ct,IntroModal:()=>xr,MIN_CONTENT_CHARACTERS_DEFAULT:()=>Ze,MIN_CONTENT_CHARACTERS_IRREGULAR:()=>Xe,MoreContentTipNotification:()=>pt,PartnerVerifiedAccessTokenProvider:()=>Z,ReuseValidJWTProvider:()=>le,ReuseValidSessionJWTProvider:()=>ge,SearchDescriptionGenerator:()=>dr,SearchTitleGenerator:()=>ar,SparksLimitReachedNotification:()=>mt,TOAST_SIZE_MAP:()=>st,ToastContent:()=>Ct,ToastSkeleton:()=>gt,Undo:()=>Ot,UsageCounter:()=>ze,XDescriptionGenerator:()=>Xt,XTitleGenerator:()=>Vt,apiBaseURL:()=>ve,createErrorMessageFactory:()=>Ye,getErrorMessageWithMarkup:()=>Ve,getRecommendedMinimumContentLength:()=>et,withLocalStorage:()=>ft});const n=r(51609);var o=e.n(n);const a=r(71802);var i=e.n(a);const s=r(32485);var c=e.n(s);const l=r(45831);var u=["title","titleId"];const d=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,u);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm11.378-3.917c-.89-.777-2.366-.777-3.255 0a.75.75 0 0 1-.988-1.129c1.454-1.272 3.776-1.272 5.23 0 1.513 1.324 1.513 3.518 0 4.842a3.75 3.75 0 0 1-.837.552c-.676.328-1.028.774-1.028 1.152v.75a.75.75 0 0 1-1.5 0v-.75c0-1.279 1.06-2.107 1.875-2.502.182-.088.351-.199.503-.331.83-.727.83-1.857 0-2.584ZM12 18a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z",clipRule:"evenodd"}))});function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function m(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}function g(e,t,r){return t=_(t),function(e,t){if(t&&("object"==p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,b()?Reflect.construct(t,r||[],_(e).constructor):t.apply(e,r))}function v(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&E(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return w=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(b())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&E(o,r.prototype),o}(e,arguments,_(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),E(r,e)},w(e)}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!e})()}function E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}function _(e){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_(e)}function S(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function k(e,t){return e.get(C(e,t))}function A(e,t,r){return e.set(C(e,t),r),r}function C(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var x=Object.freeze({FAILED_TO_LOGIN:Symbol("failed to login"),NETWORK_ERROR:Symbol("network error"),UNAUTHORIZED:Symbol("unauthorized"),AI_CONTENT_FILTER:Symbol("ai content filter"),MISSING_LICENSE:Symbol("missing license"),UNCATEGORIZED:Symbol("uncategorized"),CONSENT_REVOKED:Symbol("consent revoked"),RATE_LIMITED:Symbol("rate limited"),REQUEST_TIMEOUT:Symbol("request timeout")}),T=new WeakMap,O=function(e){function t(e,r){var n;return f(this,t),S(n=g(this,t,[e]),T,void 0),A(T,n,r),n}return v(t,e),m(t,[{key:"code",get:function(){return k(T,this)}}])}(w(Error)),P=new WeakMap,I=function(e){function t(e,r){var n;return f(this,t),S(n=g(this,t,[e,x.MISSING_LICENSE]),P,void 0),A(P,n,Array.from(r||[])),n}return v(t,e),m(t,[{key:"missingLicenses",get:function(){return k(P,this)}}])}(O);function L(e){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},L(e)}function M(){M=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),s=new P(n||[]);return o(i,"_invoke",{value:C(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function w(){}var b={};l(b,i,function(){return this});var E=Object.getPrototypeOf,_=E&&E(E(I([])));_&&_!==r&&n.call(_,i)&&(b=_);var S=w.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function A(e,t){function r(o,a,i,s){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==L(u)&&n.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,i,s)},function(e){r("throw",e,i,s)}):t.resolve(u).then(function(e){l.value=e,i(l)},function(e){return r("throw",e,i,s)})}s(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function C(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=x(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var l=d(t,r,n);if("normal"===l.type){if(o=n.done?m:f,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=d(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(L(t)+" is not iterable")}return v.prototype=w,o(S,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(A.prototype),l(A.prototype,s,function(){return this}),t.AsyncIterator=A,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new A(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},k(S),l(S,c,"Generator"),l(S,i,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){W(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function H(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function N(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){H(a,n,o,i,s,"next",e)}function s(e){H(a,n,o,i,s,"throw",e)}i(void 0)})}}function W(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function U(e){var t=function(e){if("object"!=L(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=L(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==L(t)?t:t+""}function K(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var D=new WeakSet,F=function(){return e=function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}(this,D),W(this,"_accessTokenProvider",void 0),W(this,"_apiBase",void 0),W(this,"_logger",void 0),this._accessTokenProvider=t,this._apiBase=r.trim().replace(/\/*$/,""),this._logger=n||console},t=[{key:"getSuggestions",value:(s=N(M().mark(function e(t,r){var n,o,a,i,s,c;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(D,this,J).call(this);case 2:return o=e.sent,delete(i=j(j({},r),{},{focus_keyphrase:null==r?void 0:r.focusKeyphrase})).focusKeyphrase,e.prev=5,e.next=8,fetch("".concat(this._apiBase,"/v1/openai/suggestions/").concat(t),{method:"POST",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"},body:JSON.stringify({service:"openai",subject:i}),signal:AbortSignal.timeout(3e4)});case 8:a=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),this._logger.error("Failed to get suggestions",e.t0),"TimeoutError"!==e.t0.name){e.next=16;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 16:throw new O("Failed to get suggestions",x.NETWORK_ERROR);case 17:return e.next=19,a.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 19:if(s=e.sent,200!==a.status&&K(D,this,$).call(this,a,s),0!==(c=(null==s||null===(n=s.choices)||void 0===n?void 0:n.map(function(e){return e.text}))||[]).length){e.next=24;break}throw new O("No suggestions found",x.UNCATEGORIZED);case 24:return e.abrupt("return",c);case 25:case"end":return e.stop()}},e,this,[[5,11]])})),function(e,t){return s.apply(this,arguments)})},{key:"getFix",value:(i=N(M().mark(function e(t,r){var n,o,a,i,s,c;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(D,this,J).call(this);case 2:return o=e.sent,delete(i=j(j({},r),{},{focus_keyphrase:null==r?void 0:r.focusKeyphrase})).focusKeyphrase,e.prev=5,e.next=8,fetch("".concat(this._apiBase,"/v1/fix/assessments/").concat(t),{method:"POST",headers:{Authorization:"Bearer ".concat(o),"Content-Type":"application/json"},body:JSON.stringify({service:"openai",subject:i}),signal:AbortSignal.timeout(3e4)});case 8:a=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),this._logger.error("Failed to get optimization suggestions",e.t0),"TimeoutError"!==e.t0.name){e.next=16;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 16:throw new O("Failed to get optimization suggestions",x.NETWORK_ERROR);case 17:return e.next=19,a.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 19:if(s=e.sent,200!==a.status&&K(D,this,$).call(this,a,s),c=null==s||null===(n=s.choices)||void 0===n||null===(n=n[0])||void 0===n?void 0:n.text){e.next=24;break}throw new O("No suggestions found",x.UNCATEGORIZED);case 24:return e.abrupt("return",c);case 25:case"end":return e.stop()}},e,this,[[5,11]])})),function(e,t){return i.apply(this,arguments)})},{key:"getUsage",value:(a=N(M().mark(function e(t){var r,n,o;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(D,this,J).call(this);case 2:return r=e.sent,e.prev=3,e.next=6,fetch("".concat(this._apiBase,"/v1/usage/").concat(t),{method:"GET",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},signal:AbortSignal.timeout(3e4)});case 6:n=e.sent,e.next=15;break;case 9:if(e.prev=9,e.t0=e.catch(3),this._logger.error("Failed to get the usage stats",e.t0),"TimeoutError"!==e.t0.name){e.next=14;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 14:throw new O("Failed to get the usage stats",x.NETWORK_ERROR);case 15:return e.next=17,n.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 17:return o=e.sent,200!==n.status&&K(D,this,$).call(this,n,o),e.abrupt("return",o.totalUsed);case 20:case"end":return e.stop()}},e,this,[[3,9]])})),function(e){return a.apply(this,arguments)})},{key:"grantConsent",value:(o=N(M().mark(function e(){var t,r,n;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(D,this,J).call(this);case 2:return t=e.sent,e.prev=3,e.next=6,fetch("".concat(this._apiBase,"/v1/user/consent"),{method:"POST",headers:{Authorization:"Bearer ".concat(t)},signal:AbortSignal.timeout(3e4)});case 6:r=e.sent,e.next=15;break;case 9:if(e.prev=9,e.t0=e.catch(3),this._logger.error("Failed to grant user consent for using Yoast AI",e.t0),"TimeoutError"!==e.t0.name){e.next=14;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 14:throw new O("Failed to grant user consent for using Yoast AI",x.NETWORK_ERROR);case 15:return e.next=17,r.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 17:n=e.sent,200!==r.status&&K(D,this,$).call(this,r,n);case 19:case"end":return e.stop()}},e,this,[[3,9]])})),function(){return o.apply(this,arguments)})},{key:"revokeConsent",value:(n=N(M().mark(function e(){var t,r,n;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,K(D,this,J).call(this);case 2:return t=e.sent,e.prev=3,e.next=6,fetch("".concat(this._apiBase,"/v1/user/consent"),{method:"DELETE",headers:{Authorization:"Bearer ".concat(t)},signal:AbortSignal.timeout(3e4)});case 6:r=e.sent,e.next=15;break;case 9:if(e.prev=9,e.t0=e.catch(3),this._logger.error("Failed to revoke user consent for using Yoast AI",e.t0),"TimeoutError"!==e.t0.name){e.next=14;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 14:throw new O("Failed to revoke user consent for using Yoast AI",x.NETWORK_ERROR);case 15:return e.next=17,r.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 17:n=e.sent,200!==r.status&&K(D,this,$).call(this,r,n);case 19:case"end":return e.stop()}},e,this,[[3,9]])})),function(){return n.apply(this,arguments)})},{key:"getTokenAsPartner",value:(r=N(M().mark(function e(t){var r,n,o;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("".concat(this._apiBase,"/v1/token/request-as-partner"),{method:"POST",headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},signal:AbortSignal.timeout(3e4)});case 3:n=e.sent,e.next=12;break;case 6:if(e.prev=6,e.t0=e.catch(0),console.error("Failed to get partner token",e.t0),"TimeoutError"!==e.t0.name){e.next=11;break}throw new O("A timeout occurred",x.REQUEST_TIMEOUT);case 11:throw new O("Failed to get access token",x.NETWORK_ERROR);case 12:return e.next=14,n.clone().json().then(function(e){return e}).catch(N(M().mark(function e(){return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.text();case 2:return e.t0=e.sent,e.abrupt("return",{message:e.t0});case 4:case"end":return e.stop()}},e)})));case 14:if(o=e.sent,408!==n.status){e.next=17;break}throw new O(o.message||"Request timeout",x.REQUEST_TIMEOUT);case 17:if(429!==n.status){e.next=19;break}throw new O(o.message||"Rate limited",x.RATE_LIMITED);case 19:if(200===n.status&&"string"==typeof(null===(r=o.tokens)||void 0===r?void 0:r.access_token)){e.next=21;break}throw new O("Failed to get access token",x.FAILED_TO_LOGIN);case 21:return e.abrupt("return",o.tokens.access_token.trim());case 22:case"end":return e.stop()}},e,this,[[0,6]])})),function(e){return r.apply(this,arguments)})}],t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,U(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,o,a,i,s}();function J(){return G.apply(this,arguments)}function G(){return(G=N(M().mark(function e(){var t;return M().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._accessTokenProvider.getAccessToken();case 3:if((t=e.sent)&&"string"==typeof t&&0!==t.trim().length){e.next=6;break}throw new Error("No access token provided");case 6:return e.abrupt("return",t);case 9:if(e.prev=9,e.t0=e.catch(0),this._logger.error("Failed to get YoastAI access token",e.t0),!(e.t0 instanceof O&&Object.values(x).includes(e.t0.code))){e.next=14;break}throw e.t0;case 14:throw new O("Failed to get YoastAI access token",x.FAILED_TO_LOGIN);case 15:case"end":return e.stop()}},e,this,[[0,9]])}))).apply(this,arguments)}function $(e,t){var r=(null==t?void 0:t.message)||"Unknown error";switch(e.status){case 400:if("AI_CONTENT_FILTER"===t.error_code)throw new O(r,x.AI_CONTENT_FILTER);throw new O(r,x.UNCATEGORIZED);case 401:throw new O(r,x.UNAUTHORIZED);case 402:throw new I(r,t.missingLicenses);case 403:throw new O(r,x.CONSENT_REVOKED);case 408:throw new O(r,x.REQUEST_TIMEOUT);case 429:throw new O(r,x.RATE_LIMITED);default:throw new O(r,x.UNCATEGORIZED)}}function B(e){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(e)}function q(){q=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),s=new P(n||[]);return o(i,"_invoke",{value:C(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function w(){}var b={};l(b,i,function(){return this});var E=Object.getPrototypeOf,_=E&&E(E(I([])));_&&_!==r&&n.call(_,i)&&(b=_);var S=w.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function A(e,t){function r(o,a,i,s){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==B(u)&&n.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,i,s)},function(e){r("throw",e,i,s)}):t.resolve(u).then(function(e){l.value=e,i(l)},function(e){return r("throw",e,i,s)})}s(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function C(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=x(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var l=d(t,r,n);if("normal"===l.type){if(o=n.done?m:f,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=d(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(B(t)+" is not iterable")}return v.prototype=w,o(S,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(A.prototype),l(A.prototype,s,function(){return this}),t.AsyncIterator=A,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new A(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},k(S),l(S,c,"Generator"),l(S,i,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function z(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function V(e,t,r){return(t=Y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Y(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}var Z=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),V(this,"_partnerTokenProvider",void 0),V(this,"_aiClient",void 0),this._partnerTokenProvider=t,this._aiClient=new F(null,r)},t=[{key:"getAccessToken",value:function(){var e,t=(e=q().mark(function e(){var t;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._partnerTokenProvider.getAccessToken();case 2:return t=e.sent,e.abrupt("return",this._aiClient.getTokenAsPartner(t));case 4:case"end":return e.stop()}},e,this)}),function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){z(a,n,o,i,s,"next",e)}function s(e){z(a,n,o,i,s,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}()}],t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Y(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const X=r(25948);function Q(e){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(e)}function ee(){ee=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),s=new P(n||[]);return o(i,"_invoke",{value:C(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function w(){}var b={};l(b,i,function(){return this});var E=Object.getPrototypeOf,_=E&&E(E(I([])));_&&_!==r&&n.call(_,i)&&(b=_);var S=w.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function A(e,t){function r(o,a,i,s){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==Q(u)&&n.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,i,s)},function(e){r("throw",e,i,s)}):t.resolve(u).then(function(e){l.value=e,i(l)},function(e){return r("throw",e,i,s)})}s(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function C(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=x(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var l=d(t,r,n);if("normal"===l.type){if(o=n.done?m:f,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=d(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(Q(t)+" is not iterable")}return v.prototype=w,o(S,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(A.prototype),l(A.prototype,s,function(){return this}),t.AsyncIterator=A,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new A(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},k(S),l(S,c,"Generator"),l(S,i,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function te(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function re(e){var t=function(e){if("object"!=Q(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Q(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Q(t)?t:t+""}function ne(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function oe(e,t){return e.get(ie(e,t))}function ae(e,t,r){return e.set(ie(e,t),r),r}function ie(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var se=new WeakMap,ce=new WeakMap,le=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ne(this,se,void 0),ne(this,ce,void 0),ae(se,this,t),ae(ce,this,"")},t=[{key:"getAccessToken",value:function(){var e,t=(e=ee().mark(function e(){var t;return ee().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(oe(ce,this)&&(null===(t=(0,X.decodeJwt)(oe(ce,this)))||void 0===t?void 0:t.exp)>Date.now()/1e3)){e.next=3;break}return e.abrupt("return",oe(ce,this));case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:return e.t1=ae,e.t2=ce,e.t3=this,e.next=12,oe(se,this).getAccessToken();case 12:return e.t4=e.sent,(0,e.t1)(e.t2,e.t3,e.t4),e.abrupt("return",oe(ce,this));case 15:case"end":return e.stop()}},e,this,[[0,5]])}),function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){te(a,n,o,i,s,"next",e)}function s(e){te(a,n,o,i,s,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}()}],t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,re(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function ue(e){return ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ue(e)}function de(){de=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),s=new P(n||[]);return o(i,"_invoke",{value:C(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function w(){}var b={};l(b,i,function(){return this});var E=Object.getPrototypeOf,_=E&&E(E(I([])));_&&_!==r&&n.call(_,i)&&(b=_);var S=w.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function A(e,t){function r(o,a,i,s){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==ue(u)&&n.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,i,s)},function(e){r("throw",e,i,s)}):t.resolve(u).then(function(e){l.value=e,i(l)},function(e){return r("throw",e,i,s)})}s(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function C(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=x(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var l=d(t,r,n);if("normal"===l.type){if(o=n.done?m:f,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=d(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(ue(t)+" is not iterable")}return v.prototype=w,o(S,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(A.prototype),l(A.prototype,s,function(){return this}),t.AsyncIterator=A,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new A(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},k(S),l(S,c,"Generator"),l(S,i,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function pe(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function fe(e){var t=function(e){if("object"!=ue(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ue(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ue(t)?t:t+""}function he(e,t){return e.get(me(e,t))}function me(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var ye=new WeakMap,ge=function(){return e=function e(t){var r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,void 0)}(this,ye),n=t,(r=ye).set(me(r,this),n)},t=[{key:"getAccessToken",value:function(){var e,t=(e=de().mark(function e(){var t,r,n;return de().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=sessionStorage.getItem("yoast/ai-frontend/accessToken"),e.prev=1,!(t&&(null===(r=(0,X.decodeJwt)(t))||void 0===r?void 0:r.exp)>Date.now()/1e3)){e.next=4;break}return e.abrupt("return",t);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),sessionStorage.removeItem("yoast/ai-frontend/accessToken");case 9:return e.next=11,he(ye,this).getAccessToken();case 11:n=e.sent;try{sessionStorage.setItem("yoast/ai-frontend/accessToken",n)}catch(e){}return e.abrupt("return",n);case 14:case"end":return e.stop()}},e,this,[[1,6]])}),function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){pe(a,n,o,i,s,"next",e)}function s(e){pe(a,n,o,i,s,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}()}],t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fe(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}(),ve={production:"https://ai.yoa.st/api",staging:"https://ai-staging.yoa.st/api"};const we=r(27723);var be="styles-module__altColors--o1t8E",Ee="styles-module__bad--_XMc7",_e="styles-module__desktopPreview--KClpl",Se="styles-module__emptyCircle--nibrZ",ke="styles-module__good--Ueni9",Ae="styles-module__mainTitle--hcBkm",Ce="styles-module__mainTitleSkeleton--CSk1Z",xe="styles-module__mockedSelector--_0Gy5",Te="styles-module__ok--RvqJ4",Oe="styles-module__preview--AMJ8q",Pe="styles-module__previewSection--dQI7h",Ie="styles-module__progressBar--y7Coy",Le="styles-module__social--I2bZ1",Me="styles-module__titleProgress--BlLuI";const Re=r(66087);function je(e){return je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},je(e)}function He(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ne(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ne(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ne(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function We(e,t,r){return(t=function(e){var t=function(e){if("object"!=je(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=je(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==je(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ue=function(e){var t=e.id,r=e.value,a=e.onChange,i=e.selected,s=e.children,u=e.isLoading,d=(0,n.useCallback)(function(){a(r)},[a,r]);return o().createElement("label",{htmlFor:t,className:c()("styles-module__row--ioJoB",We({},"styles-module__selectedOption--hcd4O",i&&!u)),"data-testid":t},!u&&o().createElement("div",null,o().createElement(l.Radio,{id:t,label:"",name:"radio",value:"".concat(r),onChange:d,checked:i})),o().createElement("div",{className:"styles-module__optionLabel--kZshU"},s))};Ue.propTypes={id:i().string.isRequired,value:i().oneOfType([i().string,i().number]).isRequired,isLoading:i().bool,selected:i().bool,children:i().node,onChange:i().func};var Ke=function(e){var t=e.options,r=e.onChange,a=void 0===r?Re.noop:r,i=e.isLoading,s=void 0!==i&&i,c=e.selected,u=void 0===c?null:c,d=e.pageSize,p=void 0===d?5:d,f=e.suggestionRenderer,h=void 0===f?Re.identity:f,m=He((0,n.useState)(u),2),y=m[0],g=m[1],v=He((0,n.useState)(1),2),w=v[0],b=v[1],E=Math.max(p,1),_=Math.ceil(t.length/E);(0,n.useEffect)(function(){g(u)},[u]);var S,k,A=(0,n.useCallback)(function(e){g(e),a(t[e],e)},[t,a,g]);return(0,n.useEffect)(function(){b(_)},[t]),o().createElement(l.Root,null,o().createElement("form",{className:"styles-module__suggestionList--CVXuA"},(S=E*(w-1),!(k=t.slice(S,S+E)).length&&s&&(k=Array(E).fill(null)),k.map(function(e,t){var r=t+E*(w-1),n=y===r;return o().createElement(Ue,{key:"option-".concat(r),id:"option-".concat(r),value:r,selected:n,onChange:A,isLoading:s},s?o().createElement("div",{className:"styles-module__loadingMock--Mr6WN","data-testid":"loading-mock"},o().createElement(l.SkeletonLoader,{className:"yst-h-3 yst-w-3 yst-rounded-full"}),o().createElement(l.SkeletonLoader,{className:"styles-module__labelMock--NITYK"})):h(e))})),t.length>E?o().createElement("div",{className:"styles-module__pagination--FYqPO"},o().createElement(l.Pagination,{current:w,onNavigate:b,screenReaderTextNext:"Next",screenReaderTextPrevious:"Previous",variant:"text",total:_,"data-testid":"pagination"})):null))};function De(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}Ke.propTypes={options:i().array.isRequired,isLoading:i().bool,selected:i().number,pageSize:i().number,onChange:i().func,suggestionRenderer:i().func};var Fe=function(e){var t=e.title,r=e.isLoading,a=void 0===r||r,i=e.options,s=void 0===i?[]:i,c=e.requestMoreOptions,u=void 0===c?Re.noop:c,d=e.onChange,p=void 0===d?Re.noop:d,f=e.suggestionRenderer,h=void 0===f?Re.identity:f,m=e.canRequestMoreOptions,y=void 0===m||m,g=e.pageSize,v=void 0===g?5:g,w=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return De(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?De(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,n.useState)(null)),b=w[0],E=w[1],_=(0,n.useCallback)(function(e,t){E(t),p(e)},[p,E]);return(0,n.useEffect)(function(){if(s.length>0){var e=s.length-v;s.length%v!==0&&(e=Math.max(0,s.length-s.length%v)),(null===b||b<e)&&(E(e),p(s[e]))}},[s]),o().createElement(l.Root,null,o().createElement("div",{className:"styles-module__header--mjkFl"},o().createElement("div",null,t),s.length>0&&o().createElement(l.Button,{variant:"ai-secondary",size:"small",isLoading:a,onClick:u,"data-testid":"requestButton",disabled:!y},(0,we.__)("Generate 5 more","wordpress-seo-premium"))),o().createElement("div",{className:"styles-module__suggestions--sUYxk"},o().createElement(Ke,{isLoading:a,options:s,onChange:_,selected:b,pageSize:v,suggestionRenderer:h}),o().createElement("div",{className:"styles-module__suggestionsNote--P23gI"},s.length>0&&(0,we.__)("Text generated by AI may be offensive or inaccurate.","wordpress-seo-premium"))))};Fe.propTypes={title:i().node.isRequired,isLoading:i().bool,options:i().arrayOf(i().string),requestMoreOptions:i().func,onChange:i().func};var Je=function(e){var t=e.pressed,r=void 0!==t&&t,n=e.className,a=void 0===n?"":n,i="gradient-".concat(Math.random().toString(36).substring(2,9));return o().createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:a,"data-testid":"SparklesIcon"},o().createElement("path",{d:"M3.33284 2.96991V5.63658M1.99951 4.30324H4.66618M3.99951 12.3032V14.9699M2.66618 13.6366H5.33284M8.66618 2.96991L10.19 7.54134L13.9995 8.96991L10.19 10.3985L8.66618 14.9699L7.14237 10.3985L3.33284 8.96991L7.14237 7.54134L8.66618 2.96991Z",strokeLinecap:"round",strokeLinejoin:"round",stroke:r?"white":"url(#".concat(i,")"),style:{strokeWidth:"1.33333px"}}),o().createElement("defs",null,o().createElement("linearGradient",{id:i,x1:"1.99951",y1:"2.96991",x2:"15.3308",y2:"4.69764",gradientUnits:"userSpaceOnUse"},o().createElement("stop",{offset:"0%",stopColor:"#A61E69"}),o().createElement("stop",{offset:"100%",stopColor:"#6366F1"}))))};Je.propTypes={pressed:i().bool,className:i().string};const Ge=r(86087);var $e=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];(0,Re.isArray)(r[0])&&(r=r[0]);for(var o=[],a={},i=0;i<r.length;i++)o.push("<el".concat(i,">")),o.push("</el".concat(i,">")),a["el".concat(i)]=r[i];return(0,Ge.createInterpolateElement)(we.sprintf.apply(void 0,[e].concat(o)),a)};function Be(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var qe=function(e){var t,r=e.isVisible,a=e.requests,i=void 0===a?0:a,s=e.limit,c=void 0===s?0:s,u=e.mentionResetInTooltip,d=void 0===u||u,p=e.children,f=void 0===p?null:p,h=Math.max(c-i,0);t=d?-1===c?(0,we.__)("You have unlimited sparks left this month.","wordpress-seo-premium"):$e(/* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */
(0,we._n)("You have %1$s%2$s spark left this month.","You have %1$s%2$s sparks left this month.",h,"wordpress-seo-premium"),[o().createElement("span",{key:"requests"},h)]):-1===c?(0,we.__)("You have unlimited sparks left.","wordpress-seo-premium"):$e(/* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */ /* translators: %1$s is the number of sparks, %2$s is the span element tags that wrap the number of sparks */
(0,we._n)("You have %1$s%2$s spark left.","You have %1$s%2$s sparks left.",h,"wordpress-seo-premium"),[o().createElement("span",{key:"requests"},h)]);var m=(0,n.useMemo)(function(){var e=new Date,t=new Date;return t.setUTCDate(1),t.setUTCMonth(e.getUTCMonth()+1),t.setUTCDate(0),t.getUTCDate()-e.getUTCDate()},[]),y=$e(/* translators: %1$s is the number of days, %2$s is the span element tags that wrap the number of days */ /* translators: %1$s is the number of days, %2$s is the span element tags that wrap the number of days */ /* translators: %1$s is the number of days, %2$s is the span element tags that wrap the number of days */ /* translators: %1$s is the number of days, %2$s is the span element tags that wrap the number of days */
(0,we._n)("The next reset is in %1$s%2$s day.","The next reset is in %1$s%2$s days.",m,"wordpress-seo-premium"),[o().createElement("span",{key:"daysLeft"},m)]);return r?o().createElement(l.Tooltip,{counts:i,className:"yst-leading-4 yst-max-w-none","date-testid":"tooltip"},t," ",d&&y,f&&o().createElement(o().Fragment,null,o().createElement("br",null),f)):null};qe.propTypes={isVisible:i().bool.isRequired,requests:i().number,limit:i().number,mentionResetInTooltip:i().bool,children:i().node};var ze=function(e){var t=e.requests,r=void 0===t?0:t,n=e.limit,a=void 0===n?0:n,i=e.className,s=void 0===i?"":i,c=e.isSkeleton,u=void 0!==c&&c,d=e.mentionBetaInTooltip,p=void 0===d||d,f=e.mentionResetInTooltip,h=void 0===f||f,m=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!5;!(s=(r=o.call(t)).done)&&(i.push(r.value),5!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return Be(e,5);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Be(e,5):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,l.useToggleState)(!1)),y=m[0],g=m[3],v=m[4],w=-1===a?(0,we.__)("unlimited","wordpress-seo-premium"):a;return o().createElement(l.Root,{"data-testid":"UsageCounter",className:s},o().createElement(qe,{isVisible:y,requests:r,limit:a,mentionResetInTooltip:h},p&&(0,we.__)("While this feature is in beta, you have unlimited sparks.","wordpress-seo-premium")),u?o().createElement(l.SkeletonLoader,null,o().createElement(l.Badge,{variant:"info",size:"small",className:"yst-w-[65px]"}," ")):o().createElement(l.Badge,{"data-testid":"badge",className:"styles-module__badge--rMVjT",size:"small",onMouseEnter:g,onMouseLeave:v},o().createElement(Je,{className:"styles-module__icon--y4uAf"}),o().createElement("span",{className:"styles-module__data--C2k4_"},r)," / ",w))};function Ve(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.contactSupport,a=void 0===n?"https://yoa.st/shopify-support":n,i=r.rateLimitHelpArticle,s=void 0===i?"https://yoa.st/ai-generator-rate-limit-help":i,c=r.aiUsagePolicy,u=void 0===c?"https://openai.com/policies/usage-policies":c,d=r.commonErrorsHelpArticle,p=void 0===d?"https://yoa.st/ai-common-errors":d,f=o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("Something went wrong","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},(0,Ge.createInterpolateElement)((0,we.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,we.__)("Please try again later. If this issue persists, you can learn more about possible reasons for this error on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:o().createElement(l.Link,{variant:"error",href:p}),a2:o().createElement(l.Link,{variant:"error",href:a})}))),h=o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("You've reached the Yoast AI rate limit","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},$e(/* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */ /* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */ /* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */ /* translators: %1$s expands to an opening tag. %2$s expands to a closing tag. */
(0,we.__)("You might have reached your Yoast AI rate limit for a specific time frame or your sparks limit for this month. If you have reached your rate limit, please reduce the frequency of your requests to continue using Yoast AI features. Our %1$shelp article%2$s provides guidance on effectively planning and pacing your requests for an optimized workflow.","wordpress-seo-premium"),o().createElement(l.Link,{variant:"error",href:s}," "))));if(!e.code)return e.message;switch(e.code){case x.AI_CONTENT_FILTER:return o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("Usage policy violation","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},(0,Ge.createInterpolateElement)((0,we.sprintf)(
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
/* translators: %1$s, %2$s, %3$s, %4$s are anchor tags.
* %5$s expands to OpenAI.
*/
(0,we.__)("Due to %5$s's strict ethical guidelines and %1$susage policies%2$s, we cannot generate suggestions for the content on this page. If you intend to use AI, kindly avoid the use of explicit, violent, copyrighted, or sexually explicit content. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>","OpenAI"),{a1:o().createElement(l.Link,{variant:"error",href:u}," "),a2:o().createElement(l.Link,{variant:"error",href:a}," ")})));case x.MISSING_LICENSE:return null!==(t=e.missingLicenses)&&void 0!==t&&t.length?o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("Subscription required","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},(0,we.sprintf)(
/**
* translators:
* %1$s expands to a comma-separated list of all but the last product names that the user is missing a license for.
* %2$s expands to the last product name that the user is missing a license for.
*/
/**
* translators:
* %1$s expands to a comma-separated list of all but the last product names that the user is missing a license for.
* %2$s expands to the last product name that the user is missing a license for.
*/
/**
* translators:
* %1$s expands to a comma-separated list of all but the last product names that the user is missing a license for.
* %2$s expands to the last product name that the user is missing a license for.
*/
/**
* translators:
* %1$s expands to a comma-separated list of all but the last product names that the user is missing a license for.
* %2$s expands to the last product name that the user is missing a license for.
*/
(0,we._n)("To access this feature, you need an active %1$s subscription. Please activate your subscription or get a new subscription. Afterward, refresh this page. It may take up to 30 seconds for the feature to function correctly.","To access this feature, you need active %1$s subscriptions. Please activate your subscriptions or get new subscriptions. Afterward, refresh this page. It may take up to 30 seconds for the feature to function correctly.",e.missingLicenses.length,"wordpress-seo-premium"),e.missingLicenses.join(" and ")))):f;case x.RATE_LIMITED:return h;case x.REQUEST_TIMEOUT:return o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("Connection timeout","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},(0,Ge.createInterpolateElement)((0,we.sprintf)(/* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */ /* translators: %1$s and %3$s expand to an opening tag. %2$s and %4$s expand to a closing tag. */
(0,we.__)("It seems that a connection timeout has occurred. Please check your internet connection and try again later. Learn more on our page about %1$scommon AI feature problems and errors%2$s. In case you need further help, please %3$scontact our support team%4$s.","wordpress-seo-premium"),"<a1>","</a1>","<a2>","</a2>"),{a1:o().createElement(l.Link,{variant:"error",href:p}," "),a2:o().createElement(l.Link,{variant:"error",href:a}," ")})));case x.NETWORK_ERROR:return o().createElement(o().Fragment,null,o().createElement("span",{className:"yst-block yst-font-medium"},(0,we.__)("Connection timeout","wordpress-seo-premium")),o().createElement("p",{className:"yst-mt-2"},(0,we.__)("It seems that a connection timeout has occurred. Please check your internet connection and try again later.","wordpress-seo-premium")));case x.CONSENT_REVOKED:case x.FAILED_TO_LOGIN:case x.UNCATEGORIZED:case x.UNAUTHORIZED:default:return f}}function Ye(e){return function(t){return Ve(t,e)}}ze.propTypes={requests:i().number,limit:i().number,className:i().string,isSkeleton:i().bool,mentionBetaInTooltip:i().bool,mentionResetInTooltip:i().bool};var Ze=300,Xe=150,Qe=["suggestions/product-seo-title","suggestions/product-meta-description","suggestions/taxonomy-seo-title","suggestions/taxonomy-meta-description"],et=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Qe.includes(e)?Xe:Ze};const tt=r(29491);var rt="styles-module__buttonGroup--BqLdI",nt="styles-module__skeleton--u4mld",ot="styles-module__skeletonLoaderButtons--HkdNq",at=["children","className","size"];function it(){return it=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},it.apply(null,arguments)}var st={large:"yst-w-96"},ct=function(e){var t=e.children,r=e.className,n=void 0===r?"":r,a=e.size,i=void 0===a?"large":a,s=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,at);return o().createElement(l.Toast,it({className:c()("styles-module__yst-toast--ai--GbPe7",st[i],n)},s),t)};const lt=JSON.parse('{"UU":"@yoast/ai-frontend"}');function ut(){return ut=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ut.apply(null,arguments)}function dt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var pt=function(e){var t=e.content,r=e.recommendedMinimumContentLength,a=e.promptType,i=e.size,s=void 0===i?"large":i,c=e.isPermanentlyDismissed,u=void 0!==c&&c,d=e.onDismiss,p=void 0===d?Re.noop:d,f=e.onDismissPermanently,h=void 0===f?Re.noop:f,m=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!4;!(s=(r=o.call(t)).done)&&(i.push(r.value),4!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return dt(e,4);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?dt(e,4):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,l.useToggleState)(!1)),y=m[0],g=m[3],v=null!=a&&a.includes("meta-description")?/* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */(0,we.__)("%1$sTip%2$s: Improve the accuracy of your generated AI descriptions by writing more content in your page.","wordpress-seo-premium"):/* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */ /* translators: %1$s and %2$s expand to opening and closing of a span in order to emphasise the word. */(0,we.__)("%1$sTip%2$s: Improve the accuracy of your generated AI titles by writing more content in your page.","wordpress-seo-premium"),w=(0,n.useCallback)(function(){g(),p()},[]),b=(0,n.useCallback)(function(){g(),h()},[]);return u||y||t.length>r?null:o().createElement(l.Notifications.Notification,{id:"ai-generator-content-tip",variant:"info",size:s,dismissScreenReaderLabel:(0,we.__)("Dismiss","wordpress-seo-premium")},$e(v,o().createElement("span",{className:"yst-font-medium yst-text-slate-800"})),o().createElement("div",{className:rt},o().createElement(l.Button,{type:"button",variant:"tertiary",onClick:b},(0,we.__)("Don’t show again","wordpress-seo-premium")),o().createElement(l.Button,{type:"button",variant:"tertiary",className:"yst-text-slate-800",onClick:w},(0,we.__)("Dismiss","wordpress-seo-premium"))))},ft=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lt.UU+"/more-content-tip";return(0,tt.createHigherOrderComponent)(function(t){return function(r){var a="dismissed"===localStorage.getItem(e),i=(0,n.useCallback)(function(){try{localStorage.setItem(e,"dismissed")}catch(e){console.error("Could not permanently dismiss the notification.",e)}},[e]);return o().createElement(t,ut({},r,{isPermanentlyDismissed:a,onDismissPermanently:i}))}},"MoreContentTipWithLocalStorage")};function ht(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var mt=function(e){var t=e.used,r=e.limit,n=e.size,a=void 0===n?"large":n,i=e.className,s=void 0===i?"":i,c=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!5;!(s=(r=o.call(t)).done)&&(i.push(r.value),5!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return ht(e,5);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ht(e,5):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,l.useToggleState)(!1)),u=c[0],d=c[3],p=c[4];(0,Ge.useEffect)(function(){t===r&&r>0&&d()},[t,r,d]);var f=(0,we.sprintf)(/* translators: %s is the number of the sparks allowed. */ /* translators: %s is the number of the sparks allowed. */ /* translators: %s is the number of the sparks allowed. */ /* translators: %s is the number of the sparks allowed. */
(0,we._n)("You've used %s spark this month!","You've used %s sparks this month!",r,"wordpress-seo-premium"),r);return u&&o().createElement(l.Notifications.Notification,{id:"ai-sparks-limit",variant:"info",size:a,dismissScreenReaderLabel:(0,we.__)("Got it!","wordpress-seo-premium"),className:s,title:f},o().createElement("p",null,(0,we.__)("As long as this is a beta feature, you get unlimited sparks.","wordpress-seo-premium")),o().createElement("div",{className:rt},o().createElement(l.Button,{type:"button",variant:"tertiary",onClick:p},(0,we.__)("Got it!","wordpress-seo-premium"))))},yt=function(e){var t=e.granted,r=e.size,n=void 0===r?"large":r,a=e.autoDismiss,i=void 0===a?5e3:a,s=e.className,c=void 0===s?"":s,u=t?(0,we.__)("You now have access to Yoast AI features.","wordpress-seo-premium"):(0,we.__)("You've revoked your consent for Yoast AI.","wordpress-seo-premium");return o().createElement(l.Notifications.Notification,{id:"ai-consent-saved",variant:"success",size:n,title:(0,we.__)("Changes successfully saved!","wordpress-seo-premium"),dismissScreenReaderLabel:(0,we.__)("Dismiss","wordpress-seo-premium"),className:c,autoDismiss:i},o().createElement("p",null,u))},gt=function(){return o().createElement(o().Fragment,null,o().createElement("div",{className:"styles-module__skeletonWrapperTop--TovVH"},o().createElement(l.SkeletonLoader,{className:nt}),o().createElement("div",{className:"styles-module__skeletonLoaderWrapper--HI7Rm"},o().createElement(l.SkeletonLoader,{className:"styles-module__skeletonLoader1--acDyN"}),o().createElement(l.SkeletonLoader,{className:"styles-module__skeletonLoader2--f4AbH"}),o().createElement(l.SkeletonLoader,{className:"styles-module__skeletonLoader3--pI6W5"}),o().createElement(l.SkeletonLoader,{className:"styles-module__skeletonLoader4--l4uCY"})),o().createElement(l.SkeletonLoader,{className:nt}),o().createElement(l.SkeletonLoader,{className:nt})),o().createElement("div",{className:"styles-module__skeletonWrapperBottom--HMog6"},o().createElement(l.SkeletonLoader,{className:ot}),o().createElement(l.SkeletonLoader,{className:ot})))},vt=["title","titleId"];const wt=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,vt);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"}))});var bt=["title","titleId"];const Et=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,bt);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 8.25 21 12m0 0-3.75 3.75M21 12H3"}))});var _t=["title","titleId"];const St=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,_t);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"}))});function kt(){return kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},kt.apply(null,arguments)}var At=(0,n.forwardRef)(function(e,t){var r=e.title,n=void 0===r?"":r,a=e.badgeText,i=void 0===a?"":a,s=e.description,c=e.learnMoreLink,u=void 0===c?"":c,d=e.learnMoreLinkText,p=void 0===d?(0,we.__)("Learn more about AI Optimize","wordpress-seo-premium"):d,f=e.handleDismiss,h=void 0===f?Re.noop:f,m=e.dismissButtonText,y=void 0===m?(0,we.__)("Dismiss","wordpress-seo-premium"):m,g=e.handleApply,v=void 0===g?Re.noop:g,w=e.applyButtonContent,b=void 0===w?(0,we.__)("Apply","wordpress-seo-premium"):w,E=(0,l.useSvgAria)();return o().createElement(o().Fragment,null,o().createElement("div",{className:"styles-module__toastContentWrapper--e321x"},o().createElement("span",{className:"".concat("styles-module__logo--JhJ6O"," yst-shrink-0")}),o().createElement("div",{className:"styles-module__toastContentContainer--UNMow"},o().createElement("div",{className:"styles-module__toastContentContainerHeader--L5Dw3"},o().createElement("h2",{className:"yst-text-sm yst-font-medium yst-text-slate-800"},n),i&&o().createElement(l.Badge,{variant:"info",className:"yst-font-semibold",size:"small"},i)),o().createElement("p",null,s),u&&o().createElement(l.Link,{href:u,className:"styles-module__toastContentLink--cZjl1",style:{textDecoration:"none"},variant:"primary",target:"_blank",rel:"noopener noreferrer"},p,o().createElement(Et,{className:"styles-module__toastContentArrow--xnqYS"}))),o().createElement("div",{className:"yst-flex-shrink-0 yst-flex yst-self-start"},o().createElement("button",{type:"button",onClick:h,"aria-label":(0,we.__)("Dismiss notification","wordpress-seo-premium"),className:"yst-bg-transparent yst-rounded-md yst-inline-flex yst-text-slate-400 hover:yst-text-slate-500 focus:yst-outline-none focus:yst-ring-2 focus:yst-ring-offset-2 focus:yst-ring-primary-500"},o().createElement(St,kt({className:"yst-h-5 yst-w-5"},E))))),o().createElement("div",{className:"styles-module__toastContentButtonsWrapper--YHI5c"},o().createElement(l.Button,{type:"button",variant:"tertiary",size:"small",onClick:h},y),o().createElement(l.Button,{ref:t,type:"button",variant:"primary",size:"small",className:"styles-module__toastContentApplyButton--SlRYX",onClick:v},"string"==typeof b?o().createElement(o().Fragment,null,o().createElement(wt,{className:"styles-module__buttonIcon--v49u_"}),o().createElement("span",{className:"styles-module__buttonText--ec2s0"},b)):b)))});At.displayName="DialogContent",At.propTypes={title:i().string,badgeText:i().string,description:i().string.isRequired,learnMoreLink:i().string,learnMoreLinkText:i().string,handleDismiss:i().func,dismissButtonText:i().string,handleApply:i().func,applyButtonContent:i().oneOfType([i().string,i().element])};var Ct=At;function xt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Tt=function(e){var t=e.undo,r=(0,l.useToastContext)().handleDismiss,a=(0,n.useCallback)(function(){t(),r()},[t,r]);return o().createElement(l.Button,{type:"button",variant:"tertiary",className:"yst-text-primary-500 yst-py-0",onClick:a},(0,we.__)("Undo","wordpress-seo-premium"))},Ot=function(e){var t=e.onUndo,r=e.description,n=void 0===r?null:r,a=e.onDismiss,i=void 0===a?Re.noop:a,s=e.size,u=void 0===s?"large":s,d=e.className,p=void 0===d?"":d,f=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!4;!(s=(r=o.call(t)).done)&&(i.push(r.value),4!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return xt(e,4);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?xt(e,4):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,l.useToggleState)(!1)),h=f[0],m=f[2];return o().createElement(l.Toast,{id:"undo-toast",className:c()(st[u],p),autoDismiss:6e3,onDismiss:i,isVisible:h,setIsVisible:m},o().createElement("div",{className:"yst-flex yst-items-start yst-gap-3"},o().createElement("div",{className:"yst-flex-shrink-0"},o().createElement(l.ValidationIcon,{variant:"success",className:"yst-notification__icon"})),o().createElement("div",{className:"yst-flex yst-items-start yst-justify-between yst-flex-grow"},o().createElement(l.Toast.Title,{title:n||(0,we.__)("Successfully applied!","wordpress-seo-premium")}),o().createElement(Tt,{undo:t})),o().createElement(l.Toast.Close,{dismissScreenReaderLabel:(0,we.__)("Dismiss","wordpress-seo-premium")})))};function Pt(e){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pt(e)}function It(e,t,r){return(t=function(e){var t=function(e){if("object"!=Pt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Pt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Pt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Lt(e){return function(e){if(Array.isArray(e))return jt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Rt(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Mt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,t)||Rt(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rt(e,t){if(e){if("string"==typeof e)return jt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?jt(e,t):void 0}}function jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Ht=function(){return o().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2},o().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"}))},Nt=(0,tt.compose)([ft()])(pt),Wt=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.subject,i=e.header,s=void 0===i?Re.noop:i,u=e.onChange,p=void 0===u?Re.noop:u,f=e.onAccept,h=e.onClose,m=void 0===h?Re.noop:h,y=e.onRequestConsent,g=void 0===y?Re.noop:y,v=e.onUsageLimitUpdated,w=void 0===v?Re.noop:v,b=e.resultListLabel,E=e.applyLabel,_=e.modal,S=e.enrichSuggestions,k=void 0===S?Re.identity:S,A=e.suggestionRenderer,C=void 0===A?Re.identity:A,T=e.getErrorMessage,O=void 0===T?Ve:T,P=e.aiModalHelperLink,I=void 0===P?"https://yoa.st/ai-generator-help-button-modal":P,L=e.enableMoreContentTip,M=void 0===L||L,R=Mt((0,n.useState)([]),2),j=R[0],H=R[1],N=Mt((0,n.useState)(null),2),W=N[0],U=N[1],K=Mt((0,n.useState)(null),2),D=K[0],F=K[1],J=Mt((0,n.useState)(0),2),G=J[0],$=J[1],B=Mt((0,n.useState)(0),2),q=B[0],z=B[1],V=(0,n.useMemo)(function(){return k(j)},[j,k]),Y=et("suggestions/".concat(r)),Z=(0,n.useRef)(!1),X=Mt((0,n.useState)(!1),2),Q=X[0],ee=X[1],te=(null==W?void 0:W.code)!==x.AI_CONTENT_FILTER,re=(0,n.useCallback)(function(){t.getUsage((new Date).toISOString().slice(0,7)).then(function(e){z(e.license),$(e.limit),w&&w(e)}).catch(function(e){U(e)})},[t,z,$,U,w]),ne=(0,n.useCallback)(function(){Z.current||(Z.current=!0,ee(!0),U(null),t.getSuggestions(r,a).then(function(e){H([].concat(Lt(j),Lt(e)))}).catch(function(e){U(e),e.code===x.CONSENT_REVOKED&&g&&g()}).finally(function(){ee(!1),Z.current=!1,re()}))},[j,t,r,a,ee,U,Z,re]);(0,n.useEffect)(ne,[]);var oe=(0,n.useCallback)(function(e){F(e),p(e)},[]),ae=(0,n.useCallback)(function(){f(D)},[D]),ie=function(){var e=!W&&0===V.length,t=!W||(null==V?void 0:V.length)>0;return o().createElement("div",{className:"styles-module__aiGenerator--Q4G7H"},t&&s&&s(e),W&&o().createElement("div",{className:c()("styles-module__errorBanner--Aynek",It({},"styles-module__fullError--eTOfR",!t))},o().createElement(l.Alert,{variant:"error"},O(W))),t&&o().createElement(Fe,{isLoading:Q,onChange:oe,options:V,requestMoreOptions:ne,title:e?o().createElement(l.SkeletonLoader,{className:"styles-module__paginationTitleSkeleton--ePjfS"}):o().createElement(o().Fragment,null,b),suggestionRenderer:C,canRequestMoreOptions:!W||te}))},se=function(){var e=!W||(null==V?void 0:V.length)>0,t=W&&0===(null==V?void 0:V.length);return o().createElement("div",{className:"styles-module__buttonArea--I6ND0"},m&&m!==Re.noop&&o().createElement(l.Button,{variant:"secondary",onClick:m},(0,we.__)("Close","wordpress-seo-premium")),e&&o().createElement(l.Button,{variant:"primary",disabled:!D,"data-testid":"acceptButton",onClick:ae},o().createElement(Ht,null),E||(0,we.__)("Apply","wordpress-seo-premium")),t&&te&&o().createElement(l.Button,{variant:"primary","data-testid":"retryButton",onClick:ne},(0,we.__)("Try again","wordpress-seo-premium")))};return _?o().createElement(l.Root,null,o().createElement(l.Modal,{onClose:m,position:"center",isOpen:!0,className:"styles-module__modal--quowq"},o().createElement(l.Modal.Panel,{className:"styles-module__modalContainer--DyT0w"},o().createElement(l.Modal.Container,null,o().createElement(l.Modal.Title,null,0!==G&&o().createElement("div",{className:"styles-module__floatingCounter--KzR9L"},o().createElement(ze,{limit:G,requests:q})),o().createElement("div",{className:"styles-module__modalTitle--LTCoD"},o().createElement("span",{className:"styles-module__logo--gDbXB"}),o().createElement("span",null,_.title),o().createElement(l.Link,{id:"ai-modal-learn-more",href:I,variant:"primary",className:"styles-module__learnMore--mrUIw",target:"_blank",rel:"noopener","aria-label":(0,we.__)("Learn more about AI (Opens in a new browser tab)","wordpress-seo-premium")},o().createElement(d,null)),o().createElement(l.Badge,null,"Beta"))),o().createElement(l.Modal.Container.Content,{className:"styles-module__modalContent--uxbqo"},o().createElement("div",{className:c()(It({},"styles-module__fadeOut--O2ZCu",!W||V.length>0))},ie())),o().createElement(l.Modal.Container.Footer,null,se())),o().createElement(l.Notifications,null,o().createElement(mt,{used:q,limit:G}),M&&o().createElement(Nt,{content:a.content,recommendedMinimumContentLength:Y}))))):o().createElement(l.Root,null,o().createElement("div",{className:"styles-module__generatorContainer--jWKDs"},ie(),se()))};Wt.propTypes={subject:i().shape({content:i().string.isRequired,focusKeyphrase:i().string.isRequired,language:i().string.isRequired,platform:i().string.isRequired}).isRequired,suggestionPromptType:i().string,onClose:i().func,onChange:i().func,onRequestConsent:i().func,onUsageLimitUpdated:i().func,onAccept:i().func.isRequired,aiClient:i().instanceOf(F).isRequired,header:i().func,resultListLabel:i().string.isRequired,applyLabel:i().string,modal:i().shape({title:i().node.isRequired}),suggestionRenderer:i().func,getErrorMessage:i().func,aiModalHelperLink:i().string,enableMoreContentTip:i().bool};const Ut=r(56200);var Kt=function(){return o().createElement(l.Root,null,o().createElement(l.Card,{className:"styles-module__skeletonPreview--QYdU8","data-testid":"skeletonPreview"},o().createElement("div",{className:"styles-module__header--vHY_T"},o().createElement("div",{className:"styles-module__firstColumn--dorvx"},o().createElement(l.SkeletonLoader,null)),o().createElement("div",{className:"styles-module__secondColumn--m5oLy"},o().createElement(l.SkeletonLoader,null),o().createElement(l.SkeletonLoader,null))),o().createElement("div",{className:"styles-module__content--cEMcn"},o().createElement(l.SkeletonLoader,null),o().createElement(l.SkeletonLoader,null),o().createElement(l.SkeletonLoader,null))))};function Dt(){return Dt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Dt.apply(null,arguments)}function Ft(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Jt=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.enrichSelectionForPreview,g=void 0===y?Re.identity:y,v=e.enrichSuggestions,w=void 0===v?Re.identity:v,b=e.suggestionRenderer,E=void 0===b?Re.identity:b,_=e.getErrorMessage,S=void 0===_?Ve:_,k=e.enableMoreContentTip,A=void 0===k||k,C=e.aiModalHelperLink,x=void 0===C?"https://yoa.st/ai-generator-help-button-modal":C;i.platform=i.platform||"Facebook";var T=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return Ft(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ft(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,n.useState)("")),O=T[0],P=T[1],I=(0,n.useMemo)(function(){return g(O)},[O,g]),L=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Social preview","wordpress-seo-premium")),o().createElement("div",{className:c()(Pe,Le)},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):o().createElement(Ut.FacebookPreview,Dt({},a,{title:I||a.title})))))});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:P,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated social titles","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply social title","wordpress-seo-premium"),modal:m,header:L,enrichSuggestions:w,suggestionRenderer:E,getErrorMessage:S,enableMoreContentTip:A,aiModalHelperLink:x,onUsageLimitUpdated:h})};function Gt(){return Gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Gt.apply(null,arguments)}function $t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Bt=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.enrichSelectionForPreview,g=void 0===y?Re.identity:y,v=e.enrichSuggestions,w=void 0===v?Re.identity:v,b=e.suggestionRenderer,E=void 0===b?Re.identity:b,_=e.getErrorMessage,S=void 0===_?Ve:_,k=e.enableMoreContentTip,A=void 0===k||k,C=e.aiModalHelperLink,x=void 0===C?"https://yoa.st/ai-generator-help-button-modal":C;i.platform=i.platform||"Facebook";var T=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return $t(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$t(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,n.useState)("")),O=T[0],P=T[1],I=(0,n.useMemo)(function(){return g(O)},[O,g]),L=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Social preview","wordpress-seo-premium")),o().createElement("div",{className:c()(Pe,Le)},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):o().createElement(Ut.FacebookPreview,Gt({},a,{description:I||a.description})))))});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:P,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated social descriptions","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply social description","wordpress-seo-premium"),modal:m,header:L,enrichSuggestions:w,suggestionRenderer:E,getErrorMessage:S,enableMoreContentTip:A,aiModalHelperLink:x,onUsageLimitUpdated:h})};function qt(){return qt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},qt.apply(null,arguments)}function zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Vt=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.enrichSelectionForPreview,g=void 0===y?Re.identity:y,v=e.enrichSuggestions,w=void 0===v?Re.identity:v,b=e.suggestionRenderer,E=void 0===b?Re.identity:b,_=e.getErrorMessage,S=void 0===_?Ve:_,k=e.enableMoreContentTip,A=void 0===k||k,C=e.aiModalHelperLink,x=void 0===C?"https://yoa.st/ai-generator-help-button-modal":C;i.platform=i.platform||"Twitter";var T=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return zt(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?zt(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,n.useState)("")),O=T[0],P=T[1],I=(0,n.useMemo)(function(){return g(O)},[O,g]),L=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Social preview","wordpress-seo-premium")),o().createElement("div",{className:c()(Pe,Le)},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):o().createElement(Ut.TwitterPreview,qt({},a,{title:I||a.title})))))});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:P,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated social titles","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply social title","wordpress-seo-premium"),modal:m,header:L,enrichSuggestions:w,suggestionRenderer:E,getErrorMessage:S,enableMoreContentTip:A,aiModalHelperLink:x,onUsageLimitUpdated:h})};function Yt(){return Yt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Yt.apply(null,arguments)}function Zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Xt=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.enrichSelectionForPreview,g=void 0===y?Re.identity:y,v=e.enrichSuggestions,w=void 0===v?Re.identity:v,b=e.suggestionRenderer,E=void 0===b?Re.identity:b,_=e.getErrorMessage,S=void 0===_?Ve:_,k=e.enableMoreContentTip,A=void 0===k||k,C=e.aiModalHelperLink,x=void 0===C?"https://yoa.st/ai-generator-help-button-modal":C;i.platform=i.platform||"Twitter";var T=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return Zt(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Zt(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,n.useState)("")),O=T[0],P=T[1],I=(0,n.useMemo)(function(){return g(O)},[O,g]),L=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Social preview","wordpress-seo-premium")),o().createElement("div",{className:c()(Pe,Le)},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):o().createElement(Ut.TwitterPreview,Yt({},a,{description:I||a.description})))))});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:P,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated social descriptions","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply social description","wordpress-seo-premium"),modal:m,header:L,enrichSuggestions:w,suggestionRenderer:E,getErrorMessage:S,enableMoreContentTip:A,aiModalHelperLink:x,onUsageLimitUpdated:h})};const Qt=r(53838);function er(e){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},er(e)}function tr(){return tr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},tr.apply(null,arguments)}function rr(e,t,r){return(t=function(e){var t=function(e){if("object"!=er(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=er(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==er(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return or(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?or(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function or(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ar=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.defaultPreviewMode,g=void 0===y?"desktop":y,v=e.enrichSelectionForPreview,w=void 0===v?Re.identity:v,b=e.enrichSuggestions,E=void 0===b?Re.identity:b,_=e.suggestionRenderer,S=void 0===_?Re.identity:_,k=e.getErrorMessage,A=void 0===k?Ve:k,C=e.altColors,x=void 0!==C&&C,T=e.enableMoreContentTip,O=void 0===T||T,P=e.aiModalHelperLink,I=void 0===P?"https://yoa.st/ai-generator-help-button-modal":P;i.platform=i.platform||"Google";var L=nr((0,n.useState)(""),2),M=L[0],R=L[1],j=nr((0,n.useState)(g),2),H=j[0],N=j[1],W=(0,n.useMemo)(function(){return w(M)},[M,w]),U=(0,n.useMemo)(function(){return w(M,"lengthCalculation")},[M,w]),K=(0,n.useMemo)(function(){return(0,Qt.getTitleProgress)(U)},[U]),D=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Google preview","wordpress-seo-premium"),e?o().createElement("span",{className:xe},o().createElement("span",{className:Se}),o().createElement(l.SkeletonLoader,null),o().createElement("span",{className:Se}),o().createElement(l.SkeletonLoader,null)):o().createElement(l.RadioGroup,{id:"typeSelector",onChange:N,value:H,options:[{label:(0,we.__)("Mobile result","wordpress-seo-premium"),value:"mobile",screenReaderLabel:"mobile"},{label:(0,we.__)("Desktop result","wordpress-seo-premium"),value:"desktop",screenReaderLabel:"desktop"}]})),o().createElement("div",{className:Pe},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):(r=o().createElement(Qt.SnippetPreview,tr({onMouseUp:Re.noop,mode:H},a,{title:W||a.title})),"desktop"===H?o().createElement("div",{className:_e},r):r))),!e&&o().createElement("div",{className:Me},o().createElement("span",null,(0,we.__)("SEO title width","wordpress-seo-premium")),o().createElement(l.ProgressBar,tr({},(t=K.score)>=7?{className:c()(Ie,ke,rr({},be,x)),"data-testid":"progress-good"}:t>=5?{className:c()(Ie,Te,rr({},be,x)),"data-testid":"progress-ok"}:{className:c()(Ie,Ee,rr({},be,x)),"data-testid":"progress-bad"},{progress:K.actual,min:0,max:K.max}))));var t,r});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:R,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated SEO titles","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply SEO title","wordpress-seo-premium"),modal:m,header:D,enrichSuggestions:E,suggestionRenderer:S,getErrorMessage:A,enableMoreContentTip:O,aiModalHelperLink:I,onUsageLimitUpdated:h})};function ir(e){return ir="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ir(e)}function sr(){return sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sr.apply(null,arguments)}function cr(e,t,r){return(t=function(e){var t=function(e){if("object"!=ir(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ir(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ir(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function lr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ur(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ur(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var dr=function(e){var t=e.aiClient,r=e.suggestionPromptType,a=e.previewData,i=e.subject,s=e.onAccept,u=e.onClose,d=e.onRequestConsent,p=void 0===d?Re.noop:d,f=e.onUsageLimitUpdated,h=void 0===f?Re.noop:f,m=e.modal,y=e.defaultPreviewMode,g=void 0===y?"desktop":y,v=e.enrichSelectionForPreview,w=void 0===v?Re.identity:v,b=e.enrichSuggestions,E=void 0===b?Re.identity:b,_=e.suggestionRenderer,S=void 0===_?Re.identity:_,k=e.getErrorMessage,A=void 0===k?Ve:k,C=e.altColors,x=void 0!==C&&C,T=e.enableMoreContentTip,O=void 0===T||T,P=e.aiModalHelperLink,I=void 0===P?"https://yoa.st/ai-generator-help-button-modal":P;i.platform=i.platform||"Google";var L=lr((0,n.useState)(""),2),M=L[0],R=L[1],j=lr((0,n.useState)(g),2),H=j[0],N=j[1],W=(0,n.useMemo)(function(){return w(M)},[M,w]),U=(0,n.useMemo)(function(){return w(M,"lengthCalculation")},[M,w]),K=(0,n.useMemo)(function(){return(0,Qt.getDescriptionProgress)(U,a.date||"",a.isCornerstone||!1,a.isTaxonomy||!1,i.language)},[U,a.date,a.isCornerstone,a.isTaxonomy,i.language]),D=(0,n.useCallback)(function(e){return o().createElement(o().Fragment,null,o().createElement("span",{className:Ae},e?o().createElement(l.SkeletonLoader,{className:Ce}):(0,we.__)("Google preview","wordpress-seo-premium"),e?o().createElement("span",{className:xe},o().createElement("span",{className:Se}),o().createElement(l.SkeletonLoader,null),o().createElement("span",{className:Se}),o().createElement(l.SkeletonLoader,null)):o().createElement(l.RadioGroup,{id:"typeSelector",onChange:N,value:H,options:[{label:(0,we.__)("Mobile result","wordpress-seo-premium"),value:"mobile",screenReaderLabel:"mobile"},{label:(0,we.__)("Desktop result","wordpress-seo-premium"),value:"desktop",screenReaderLabel:"desktop"}]})),o().createElement("div",{className:Pe},o().createElement("div",{className:Oe},e?o().createElement(Kt,null):(r=o().createElement(Qt.SnippetPreview,sr({onMouseUp:Re.noop,mode:H},a,{description:W||a.description})),"desktop"===H?o().createElement("div",{className:_e},r):r))),!e&&o().createElement("div",{className:Me},o().createElement("span",null,(0,we.__)("Description width","wordpress-seo-premium")),o().createElement(l.ProgressBar,sr({},(t=K.score)>=7?{className:c()(Ie,ke,cr({},be,x)),"data-testid":"progress-good"}:t>=5?{className:c()(Ie,Te,cr({},be,x)),"data-testid":"progress-ok"}:{className:c()(Ie,Ee,cr({},be,x)),"data-testid":"progress-bad"},{progress:K.actual,min:0,max:K.max}))));var t,r});return o().createElement(Wt,{subject:i,suggestionPromptType:r,aiClient:t,onChange:R,onAccept:s,onClose:u,onRequestConsent:p,resultListLabel:(0,we.__)("Generated meta descriptions","wordpress-seo-premium"),applyLabel:(0,we.__)("Apply meta description","wordpress-seo-premium"),modal:m,header:D,enrichSuggestions:E,suggestionRenderer:S,getErrorMessage:A,enableMoreContentTip:O,aiModalHelperLink:I,onUsageLimitUpdated:h})},pr=["title","titleId"];const fr=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,pr);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{fillRule:"evenodd",d:"M16.72 7.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1 0 1.06l-3.75 3.75a.75.75 0 1 1-1.06-1.06l2.47-2.47H3a.75.75 0 0 1 0-1.5h16.19l-2.47-2.47a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))});var hr="styles-module__badge--anxyN",mr="styles-module__body--c3lMd",yr="styles-module__buttonSection--fA_Lt",gr="styles-module__content--s8aPG",vr="styles-module__icon--ap2v5",wr="styles-module__learnMoreLink--ZdsMp",br="styles-module__logo--cl0TH",Er="styles-module__modal--CWdoh",_r="styles-module__modalContainer--RcX43",Sr="styles-module__prompt--KATqc",kr="styles-module__top--Jckd_",Ar="styles-module__warningIconContainer--NcQlL",Cr="styles-module__warningPrompt--FUbHc",xr=function(e){var t=e.onAccept,r=e.onCancel,a=e.learnMoreLink,i=e.video,s=e.modal,u=void 0===s||s,d=e.contentText,p=e.title,f=e.subtitle,h=(0,n.useRef)(null),m=(0,n.useCallback)(function(){t(!0)},[t]),y=d||$e("Boost your search and social appearance in seconds! Generate high-quality titles and descriptions for your products, pages, and blog posts directly within your editor. %1$sLearn more %3$s%4$s%2$s",[o().createElement("a",{key:"link",target:"_blank","aria-label":(0,we.__)("Learn More","wordpress-seo-premium"),href:a,className:wr,rel:"noreferrer"}),o().createElement(fr,{className:"styles-module__contentIcon--aE3SN",key:"icon"})]),g=function(){return o().createElement(l.Root,null,o().createElement("div",{className:"styles-module__introModal--rMyze"},o().createElement("div",{className:kr}),o().createElement("div",{className:"styles-module__mainVideo--jjRHv"},o().createElement("div",{className:"styles-module__video--QfVLI"},i),o().createElement("div",{className:hr},o().createElement(l.Badge,{variant:"info"},"Beta"))),o().createElement("div",{className:"styles-module__titleSection--uRoF8"},o().createElement("span",{className:br}),o().createElement("span",{className:"styles-module__byline--eXZ9f"},p||(0,we.__)("New to Yoast SEO","wordpress-seo-premium"))),o().createElement("div",{className:"styles-module__mainContentSection--DEAYV"},o().createElement("h3",{className:"styles-module__mainContentHeader--b2brO"},f||(0,we.__)("Use AI to write your titles & descriptions","wordpress-seo-premium")),o().createElement("div",{className:"styles-module__mainContentText--dnFSm"},y)),o().createElement("div",{className:yr},o().createElement(l.Button,{"data-testid":"acceptButton",as:"button",className:"styles-module__main--KD5ki",size:"extra-large",onClick:m,ref:h},(0,we.__)("Got it!","wordpress-seo-premium")))))};return u?o().createElement(l.Root,null,o().createElement(l.Modal,{onClose:r,className:Er,isOpen:!0,initialFocus:h},o().createElement(l.Modal.Panel,{className:c()(_r,"styles-module__bigModal--xut4N")},g()))):o().createElement(l.Root,null,g())};function Tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}xr.propTypes={onAccept:i().func.isRequired,onCancel:i().func.isRequired,learnMoreLink:i().string.isRequired,video:i().node.isRequired,modal:i().bool,contentText:i().node,title:i().string,subtitle:i().string};var Or=function(e){var t=e.modal,r=void 0===t||t,a=e.onGrant,i=e.onClose,s=e.learnMoreLink,c=e.privacyPolicyLink,u=e.termsOfServiceLink,d=e.imageUrl,p=e.badgeText,f=e.title,h=e.consentText,m=e.contentText,y=e.isLoading,g=void 0!==y&&y,v=(0,n.useRef)(null),w=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,n,o,a,i=[],s=!0,c=!1;try{for(o=(t=t.call(e)).next,!2;!(s=(r=o.call(t)).done)&&(i.push(r.value),2!==i.length);s=!0);}catch(e){c=!0,n=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw n}}return i}}(e)||function(e){if(e){if("string"==typeof e)return Tr(e,2);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Tr(e,2):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,l.useToggleState)(!1)),b=w[0],E=w[1],_=h||$e("I approve the %1$sTerms of Service%2$s & %3$sPrivacy Policy%4$s of the Yoast AI service. This includes consenting to the collection and use of data to improve user experience.",[o().createElement("a",{key:"termsOfServiceLink",target:"_blank",rel:"noopener noreferrer","aria-label":(0,we.__)("terms of service link","wordpress-seo-premium"),href:u}),o().createElement("a",{key:"privacyLink",target:"_blank",rel:"noopener noreferrer","aria-label":(0,we.__)("privacy policy link","wordpress-seo-premium"),href:c})]),S=f||(0,we.__)("Grant consent for Yoast AI","wordpress-seo-premium"),k=m||$e("Enable AI-powered SEO! Use all AI Generate and Optimize features to boost your efficiency. Just give us the green light. %1$sLearn more →%2$s",[o().createElement("a",{href:s,"aria-label":(0,we.__)("Learn more link","wordpress-seo-premium"),key:"learnMoreLink",target:"_blank",rel:"noopener noreferrer",className:wr})]),A=(0,we.__)("Grant consent","wordpress-seo-premium"),C=(0,we.__)("Close","wordpress-seo-premium"),x=function(){return o().createElement(l.Root,null,o().createElement("div",{className:"styles-module__consentModal--A_0w0"},o().createElement("div",{className:kr}),o().createElement("div",{className:gr},o().createElement("div",{className:"styles-module__image--EZwCo"},o().createElement("img",{src:d,alt:"",className:"yst-w-full"}),p&&o().createElement("div",{className:hr},o().createElement(l.Badge,null,p))),o().createElement("h3",{className:"styles-module__title--upMch"},S),o().createElement("p",{className:"yst-text-slate-600 yst-text-sm yst-font-normal yst-mt-2 yst-px-4"},k),o().createElement(l.Checkbox,{id:"is-ai-consent-checkbox",label:_,onChange:E,checked:b,disabled:g,value:"true",className:"styles-module__checkbox--BNgin",name:"is-ai-consent","data-testid":"acceptCheckbox"}),o().createElement("div",{className:"styles-module__buttons--Synlt"},o().createElement(l.Button,{isLoading:g,variant:"primary",ref:v,size:"extra-large",onClick:a,disabled:!b,"data-testid":"acceptButton"},A),o().createElement(l.Button,{variant:"tertiary",size:"large",onClick:i,"data-testid":"closeButton"},C)))))};return r?o().createElement(l.Root,null,o().createElement(l.Modal,{isOpen:!0,onClose:i,className:Er,initialFocus:v},o().createElement(l.Modal.Panel,{className:_r},x()))):o().createElement(l.Root,null,x())};Or.propTypes={onGrant:i().func.isRequired,onClose:i().func.isRequired,isLoading:i().bool,learnMoreLink:i().string.isRequired,privacyPolicyLink:i().string.isRequired,termsOfServiceLink:i().string.isRequired,imageUrl:i().string.isRequired,modal:i().bool,badgeText:i().string,title:i().string,consentText:i().string,contentText:i().string};var Pr=["title","titleId"];const Ir=n.forwardRef(function(e,t){var r=e.title,o=e.titleId,a=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,Pr);return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":o},a),r?n.createElement("title",{id:o},r):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"}))});function Lr(e){var t=e.onConfirm,r=e.onClose,n=void 0===r?Re.noop:r,a=e.modal,i=void 0===a||a,s=e.isOpen,c=void 0===s||s,u=e.isLoading,d=void 0!==u&&u,p=(0,we.__)("Revoke AI consent","wordpress-seo-premium"),f=(0,we.sprintf)(
// translators: %1$s is replaced by "Yoast".
// translators: %1$s is replaced by "Yoast".
// translators: %1$s is replaced by "Yoast".
// translators: %1$s is replaced by "Yoast".
(0,we.__)("By revoking your consent, you will no longer have access to %1$s AI features. Are you sure you want to revoke your consent?","wordpress-seo-premium"),"Yoast"),h=(0,we.__)("Yes, revoke consent","wordpress-seo-premium"),m=(0,we.__)("Close","wordpress-seo-premium"),y=function(){return o().createElement(o().Fragment,null,o().createElement("div",{className:Cr},o().createElement("div",{className:mr},o().createElement("div",{className:Ar},o().createElement(Ir,{className:vr,"aria-hidden":"true"})),o().createElement("div",{className:Sr},o().createElement(l.Title,{size:"2"},p),o().createElement("p",{className:gr},f))),o().createElement("div",{className:yr},o().createElement(l.Button,{variant:"error",isLoading:d,disabled:d,onClick:t},h),n&&n!==Re.noop&&o().createElement(l.Button,{variant:"secondary",onClick:n},m))))};return i?o().createElement(l.Root,null,o().createElement(l.Modal,{isOpen:c,onClose:n},o().createElement(l.Modal.Panel,null,y()))):o().createElement(l.Root,null,y())}function Mr(){return Mr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Mr.apply(null,arguments)}var Rr=function(e){var t=e.modal,r=void 0===t||t,n=e.aiModalHelperLink,a=e.onClose,i=void 0===a?function(){}:a,s=e.title,c=e.badgeText,u=e.isOpen,p=void 0===u||u,f=e.children,h=s,m=(0,l.useSvgAria)(),y=(0,we.__)("Close modal","wordpress-seo-premium"),g=function(){return o().createElement(o().Fragment,null,o().createElement("div",{className:"styles-module__errorModalHeader--_cNpd"},o().createElement("span",{className:br}),o().createElement(l.Title,{className:"styles-module__errorModalTitle--vms_Y",as:"h1",size:"2"},h),o().createElement(l.Link,{variant:"primary",id:"ai-optimize-modal-learn-more",className:"styles-module__aiErrorModalLink--WHw0z",href:n,"aria-label":(0,we.__)("Learn more about AI (Opens in a new browser tab)","wordpress-seo-premium"),target:"_blank",rel:"noopener noreferrer"},o().createElement(d,Mr({},m,{className:"styles-module__questionMarkCircle--rbmIj"}))),o().createElement(l.Badge,{variant:"info"},c)),o().createElement("hr",{className:"yst-mt-6 yst--mx-6"}),o().createElement("div",null,o().createElement("div",{className:"styles-module__errorModalContentWrapper--c24iV"},f)))};return r?o().createElement(l.Root,null,o().createElement(l.Modal,{isOpen:p,onClose:i},o().createElement(l.Modal.Panel,{style:{maxWidth:"48rem"},closeButtonScreenReaderText:y},o().createElement(l.Modal.Container,null,o().createElement(l.Modal.Container.Header,null,g()))))):o().createElement(l.Root,null,g())};function jr(e){return jr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jr(e)}function Hr(){Hr=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=t&&t.prototype instanceof g?t:g,i=Object.create(a.prototype),s=new P(n||[]);return o(i,"_invoke",{value:C(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",h="executing",m="completed",y={};function g(){}function v(){}function w(){}var b={};l(b,i,function(){return this});var E=Object.getPrototypeOf,_=E&&E(E(I([])));_&&_!==r&&n.call(_,i)&&(b=_);var S=w.prototype=g.prototype=Object.create(b);function k(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function A(e,t){function r(o,a,i,s){var c=d(e[o],e,a);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==jr(u)&&n.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,i,s)},function(e){r("throw",e,i,s)}):t.resolve(u).then(function(e){l.value=e,i(l)},function(e){return r("throw",e,i,s)})}s(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function C(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var s=n.delegate;if(s){var c=x(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var l=d(t,r,n);if("normal"===l.type){if(o=n.done?m:f,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=d(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(jr(t)+" is not iterable")}return v.prototype=w,o(S,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=l(w,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},k(A.prototype),l(A.prototype,s,function(){return this}),t.AsyncIterator=A,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new A(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},k(S),l(S,c,"Generator"),l(S,i,function(){return this}),l(S,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function Nr(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function Wr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ur(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ur(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}Rr.propTypes={modal:i().bool,aiModalHelperLink:i().string.isRequired,title:i().string.isRequired,badgeText:i().string,isOpen:i().bool,onclose:i().func,children:i().node};var Kr={"seo-keyphrase-density":{title:(0,we.__)("AI - Keyphrase density","wordpress-seo-premium"),description:(0,we.__)("Use keyphrase words in the text frequently but not excessively.","wordpress-seo-premium")},"seo-keyphrase-introduction":{title:(0,we.__)("AI - Keyphrase in introduction","wordpress-seo-premium"),description:(0,we.__)("Include words from the keyphrase in the first paragraph of the text.","wordpress-seo-premium")},"seo-keyphrase-distribution":{title:(0,we.__)("AI - Keyphrase distribution","wordpress-seo-premium"),description:(0,we.__)("Evenly distribute keyphrase words throughout the text.","wordpress-seo-premium")},"seo-keyphrase-subheadings":{title:(0,we.__)("AI - Keyphrase in subheadings","wordpress-seo-premium"),description:(0,we.__)("Include at least one word from the keyphrase in each subheading.","wordpress-seo-premium")},"read-sentence-length":{title:(0,we.__)("AI - Sentence length","wordpress-seo-premium"),description:(0,we.__)("Ensure long sentences are shortened or split for better readability.","wordpress-seo-premium")},"read-paragraph-length":{title:(0,we.__)("AI - Paragraph length","wordpress-seo-premium"),description:(0,we.__)("Ensure long paragraphs are shortened or split for better readability.","wordpress-seo-premium")}},Dr=function(e){var t=e.aiClient,r=e.assessment,a=e.subject,i=e.isVisible,s=void 0!==i&&i,c=e.setIsVisible,u=void 0===c?Re.noop:c,d=e.onAccept,p=e.onClose,f=void 0===p?Re.noop:p,h=e.onSuggest,m=void 0===h?Re.noop:h,y=e.onUndo,g=void 0===y?Re.noop:y,v=e.getErrorMessage,w=void 0===v?Ve:v,b=(0,n.useRef)(!1),E=Wr((0,n.useState)(!0),2),_=E[0],S=E[1],k=Wr((0,n.useState)(!1),2),A=k[0],C=k[1],x=Wr((0,n.useState)(!1),2),T=x[0],O=x[1],P=Wr((0,n.useState)(0),2),I=P[0],L=P[1],M=Wr((0,n.useState)(0),2),R=M[0],j=M[1],H=Wr((0,n.useState)(null),2),N=H[0],W=H[1],U=(0,n.useCallback)(function(){C(!1)},[C]),K=function(){f(),U()},D=function(){var e,t=(e=Hr().mark(function e(){return Hr().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:O(!1),u(!1);case 2:case"end":return e.stop()}},e)}),function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){Nr(a,n,o,i,s,"next",e)}function s(e){Nr(a,n,o,i,s,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}(),F=(0,n.useCallback)(function(){t.getUsage((new Date).toISOString().slice(0,7)).then(function(e){j(e.license),L(e.limit)}).catch(function(e){W(e)})},[t]),J=(0,n.useCallback)(function(){b.current||(b.current=!0,S(!0),W(null),t.getFix(r,a).then(m).catch(function(e){W(e),U()}).finally(function(){S(!1),b.current=!1,F()}))},[t,r,a,m,U,F]);return(0,n.useEffect)(function(){s&&!A&&(C(!0),J())},[s,J]),o().createElement(o().Fragment,null,N&&o().createElement(Rr,{title:Kr[r].title,badgeText:(0,we.__)("Beta","wordpress-seo-premium"),isOpen:!!N,onClose:function(){f(),W(null)},aiModalHelperLink:""},o().createElement(l.Alert,{variant:"error"},w(N))),o().createElement(mt,{used:R,limit:I}),o().createElement("div",{className:"yst-w-max yst-relative"},o().createElement(ct,{id:"optimize-assessment-".concat(r),isVisible:A,setIsVisible:U,onDismiss:K},0!==I&&o().createElement("div",{className:"yst-absolute yst-right-8 yst--top-3 yst-z-30"},o().createElement(ze,{limit:I,requests:R,isSkeleton:_})),_?o().createElement(gt,null):o().createElement(Ct,{title:Kr[r].title,description:Kr[r].description,badgeText:"Beta",learnMoreLink:"",handleApply:function(){d(),O(!0),setTimeout(U,150)},handleDismiss:K}))),g&&T&&o().createElement("div",{className:"yst-w-max yst-relative"},o().createElement(Ot,{onUndo:g,onDismiss:D})))};function Fr(){return Fr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Fr.apply(null,arguments)}Dr.propTypes={aiClient:i().instanceOf(F).isRequired,assessment:i().oneOf(Object.keys(Kr)).isRequired,subject:i().shape({content:i().string.isRequired,focusKeyphrase:i().string.isRequired,language:i().string.isRequired,platform:i().string.isRequired}).isRequired,isVisible:i().bool,setIsVisible:i().func,onAccept:i().func.isRequired,onClose:i().func,onSuggest:i().func,onUndo:i().func,getErrorMessage:i().func};var Jr=(0,n.forwardRef)(function(e,t){var r=e.onClick,n=e.children,a=e.isLoading,i=void 0!==a&&a,s=e.variant,c=void 0===s?"secondary":s,u=e.size,d=void 0===u?"small":u;if(!1===["primary","secondary"].includes(c))throw new Error("Invalid variant prop value: ".concat(c,'. Only "primary" and "secondary" are allowed.'));return o().createElement(l.Root,null,o().createElement(l.Button,Fr({ref:t},e,{isLoading:i,variant:"ai-".concat(c),size:d,onClick:r}),n))});return Jr.displayName="GradientButton",Jr.propTypes={onClick:i().func.isRequired,children:i().node.isRequired,isLoading:i().bool,variant:i().oneOf(["primary","secondary"]),size:i().oneOf(["default","small","large","extra-large"])},t})(),e.exports=n()},71802(e){"use strict";e.exports=window.yoast.propTypes},78279(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const o=((n=r(21679))&&n.__esModule?n:{default:n}).default.p`
line-height: ${16}px;
min-height : ${16}px;
color: #606770;
font-size: 14px;
padding: 0;
text-overflow: ellipsis;
margin: 3px 0 0 0;
display: -webkit-box;
cursor: pointer;
-webkit-line-clamp: ${e=>e.lineCount};
-webkit-box-orient: vertical;
overflow: hidden;
@media all and ( max-width: ${e=>e.maxWidth} ) {
display: none;
}
`;t.default=o},79013(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=r(12379);const a=((n=r(21679))&&n.__esModule?n:{default:n}).default.p`
max-height: 55px;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
color: rgb(83, 100, 113);
display: -webkit-box;
cursor: pointer;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
@media all and ( max-width: ${o.TWITTER_IMAGE_SIZES.landscapeWidth}px ) {
display: none;
}
`;t.default=a},81238(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(27723),o=r(12379),a=r(66087),i=d(r(71802)),s=d(r(51609)),c=d(r(21679)),l=r(68511),u=r(47248);function d(e){return e&&e.__esModule?e:{default:e}}const p=(e,t=!0)=>e?`\n\t\t\tmax-width: ${o.TWITTER_IMAGE_SIZES.landscapeWidth}px;\n\t\t\t${t?"border-bottom: 1px solid #E1E8ED;":""}\n\t\t\tborder-radius: 14px 14px 0 0;\n\t\t\t`:`\n\t\twidth: ${o.TWITTER_IMAGE_SIZES.squareWidth}px;\n\t\t${t?"border-right: 1px solid #E1E8ED;":""}\n\t\tborder-radius: 14px 0 0 14px;\n\t\t`,f=c.default.div`
position: relative;
box-sizing: content-box;
overflow: hidden;
background-color: #e1e8ed;
flex-shrink: 0;
${e=>p(e.isLarge)}
`,h=c.default.div`
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
max-width: 100%;
margin: 0;
padding: 1em;
text-align: center;
font-size: 1rem;
${e=>p(e.isLarge,!1)}
`,m=(0,c.default)(h)`
${e=>e.isLarge&&`height: ${o.TWITTER_IMAGE_SIZES.landscapeHeight}px;`}
border-top-left-radius: 14px;
${e=>e.isLarge?"border-top-right-radius":"border-bottom-left-radius"}: 14px;
border-style: dashed;
border-width: 1px;
// We're not using standard colors to increase contrast for accessibility.
color: #006DAC;
// We're not using standard colors to increase contrast for accessibility.
background-color: #f1f1f1;
text-decoration: underline;
font-size: 14px;
cursor: pointer;
`;class y extends s.default.Component{constructor(e){super(e),this.state={status:"loading"},this.socialMedium="Twitter",this.handleTwitterImage=this.handleTwitterImage.bind(this),this.setState=this.setState.bind(this)}async handleTwitterImage(){if(null===this.props.src)return;const e=await(0,l.handleImage)(this.props.src,this.socialMedium,this.props.isLarge);this.setState(e)}componentDidUpdate(e){e.src!==this.props.src&&this.handleTwitterImage()}componentDidMount(){this.handleTwitterImage()}render(){const{status:e,imageProperties:t}=this.state;return"loading"===e||""===this.props.src||"errored"===e?s.default.createElement(m,{isLarge:this.props.isLarge,onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave},(0,n.__)("Select image","wordpress-seo")):s.default.createElement(f,{isLarge:this.props.isLarge,onClick:this.props.onImageClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave},s.default.createElement(u.SocialImage,{imageProps:{src:this.props.src,alt:this.props.alt,aspectRatio:o.TWITTER_IMAGE_SIZES.aspectRatio},width:t.width,height:t.height,imageMode:t.mode}))}}t.default=y,y.propTypes={isLarge:i.default.bool.isRequired,src:i.default.string,alt:i.default.string,onImageClick:i.default.func,onMouseEnter:i.default.func,onMouseLeave:i.default.func},y.defaultProps={src:"",alt:"",onMouseEnter:a.noop,onImageClick:a.noop,onMouseLeave:a.noop}},86087(e){"use strict";e.exports=window.wp.element}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=r(69248);(window.yoast=window.yoast||{}).aiFrontend=n})();
Directory Contents
Dirs: 0 × Files: 21