@yoast/ai-insights-client 1.4.28 → 1.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}
14
14
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(i=>r.set(i)),r}static accessor(t){const r=(this[i0]=this[i0]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=uo(o);r[a]||(z4(i,o),r[a]=!0)}return B.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);B.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});B.freezeMethods(Ht);function du(e,t){const n=this||Ra,r=t||n,i=Ht.from(r.headers);let s=r.data;return B.forEach(e,function(a){s=a.call(n,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function D2(e){return!!(e&&e.__CANCEL__)}function Zs(e,t,n){Pe.call(this,e==null?"canceled":e,Pe.ERR_CANCELED,t,n),this.name="CanceledError"}B.inherits(Zs,Pe,{__CANCEL__:!0});function L2(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function H4(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function U4(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i=0,s=0,o;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),u=r[s];o||(o=c),n[i]=l,r[i]=c;let d=s,f=0;for(;d!==i;)f+=n[d++],d=d%e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),c-o<t)return;const h=u&&c-u;return h?Math.round(f*1e3/h):void 0}}function V4(e,t){let n=0,r=1e3/t,i,s;const o=(c,u=Date.now())=>{n=u,i=null,s&&(clearTimeout(s),s=null),e.apply(null,c)};return[(...c)=>{const u=Date.now(),d=u-n;d>=r?o(c,u):(i=c,s||(s=setTimeout(()=>{s=null,o(i)},r-d)))},()=>i&&o(i)]}const Wl=(e,t,n=3)=>{let r=0;const i=U4(50,250);return V4(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-r,c=i(l),u=o<=a;r=o;const d={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-o)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},n)},s0=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},o0=e=>(...t)=>B.asap(()=>e(...t)),K4=At.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,At.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(At.origin),At.navigator&&/(msie|trident)/i.test(At.navigator.userAgent)):()=>!0,G4=At.hasStandardBrowserEnv?{write(e,t,n,r,i,s){const o=[e+"="+encodeURIComponent(t)];B.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),B.isString(r)&&o.push("path="+r),B.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function W4(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Q4(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function I2(e,t,n){let r=!W4(t);return e&&(r||n==!1)?Q4(e,t):t}const a0=e=>e instanceof Ht?{...e}:e;function Mi(e,t){t=t||{};const n={};function r(c,u,d,f){return B.isPlainObject(c)&&B.isPlainObject(u)?B.merge.call({caseless:f},c,u):B.isPlainObject(u)?B.merge({},u):B.isArray(u)?u.slice():u}function i(c,u,d,f){if(B.isUndefined(u)){if(!B.isUndefined(c))return r(void 0,c,d,f)}else return r(c,u,d,f)}function s(c,u){if(!B.isUndefined(u))return r(void 0,u)}function o(c,u){if(B.isUndefined(u)){if(!B.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,d){if(d in t)return r(c,u);if(d in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,u,d)=>i(a0(c),a0(u),d,!0)};return B.forEach(Object.keys(Object.assign({},e,t)),function(u){const d=l[u]||i,f=d(e[u],t[u],u);B.isUndefined(f)&&d!==a||(n[u]=f)}),n}const R2=e=>{const t=Mi({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=t;t.headers=o=Ht.from(o),t.url=j2(I2(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let l;if(B.isFormData(n)){if(At.hasStandardBrowserEnv||At.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((l=o.getContentType())!==!1){const[c,...u]=l?l.split(";").map(d=>d.trim()).filter(Boolean):[];o.setContentType([c||"multipart/form-data",...u].join("; "))}}if(At.hasStandardBrowserEnv&&(r&&B.isFunction(r)&&(r=r(t)),r||r!==!1&&K4(t.url))){const c=i&&s&&G4.read(s);c&&o.set(i,c)}return t},Y4=typeof XMLHttpRequest!="undefined",X4=Y4&&function(e){return new Promise(function(n,r){const i=R2(e);let s=i.data;const o=Ht.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,u,d,f,h,g;function m(){h&&h(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(i.method.toUpperCase(),i.url,!0),p.timeout=i.timeout;function v(){if(!p)return;const S=Ht.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),x={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:e,request:p};L2(function(w){n(w),m()},function(w){r(w),m()},x),p=null}"onloadend"in p?p.onloadend=v:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(v)},p.onabort=function(){p&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,p)),p=null)},p.onerror=function(){r(new Pe("Network Error",Pe.ERR_NETWORK,e,p)),p=null},p.ontimeout=function(){let C=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const x=i.transitional||M2;i.timeoutErrorMessage&&(C=i.timeoutErrorMessage),r(new Pe(C,x.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,p)),p=null},s===void 0&&o.setContentType(null),"setRequestHeader"in p&&B.forEach(o.toJSON(),function(C,x){p.setRequestHeader(x,C)}),B.isUndefined(i.withCredentials)||(p.withCredentials=!!i.withCredentials),a&&a!=="json"&&(p.responseType=i.responseType),c&&([f,g]=Wl(c,!0),p.addEventListener("progress",f)),l&&p.upload&&([d,h]=Wl(l),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",h)),(i.cancelToken||i.signal)&&(u=S=>{p&&(r(!S||S.type?new Zs(null,e,p):S),p.abort(),p=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const b=H4(i.url);if(b&&At.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}p.send(s||null)})},Z4=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,i;const s=function(c){if(!i){i=!0,a();const u=c instanceof Error?c:this.reason;r.abort(u instanceof Pe?u:new Zs(u instanceof Error?u.message:u))}};let o=t&&setTimeout(()=>{o=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>B.asap(a),l}},J4=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},e5=async function*(e,t){for await(const n of t5(e))yield*J4(n,t)},t5=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},l0=(e,t,n,r)=>{const i=e5(e,t);let s=0,o,a=l=>{o||(o=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await i.next();if(c){a(),l.close();return}let d=u.byteLength;if(n){let f=s+=d;n(f)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},Pc=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",F2=Pc&&typeof ReadableStream=="function",n5=Pc&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),N2=(e,...t)=>{try{return!!e(...t)}catch(n){return!1}},r5=F2&&N2(()=>{let e=!1;const t=new Request(At.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),c0=64*1024,wd=F2&&N2(()=>B.isReadableStream(new Response("").body)),Ql={stream:wd&&(e=>e.body)};Pc&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Ql[t]&&(Ql[t]=B.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new Pe(`Response type '${t}' is not supported`,Pe.ERR_NOT_SUPPORT,r)})})})(new Response);const i5=async e=>{if(e==null)return 0;if(B.isBlob(e))return e.size;if(B.isSpecCompliantForm(e))return(await new Request(At.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(B.isArrayBufferView(e)||B.isArrayBuffer(e))return e.byteLength;if(B.isURLSearchParams(e)&&(e=e+""),B.isString(e))return(await n5(e)).byteLength},s5=async(e,t)=>{const n=B.toFiniteNumber(e.getContentLength());return n==null?i5(t):n},o5=Pc&&(async e=>{let{url:t,method:n,data:r,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:f}=R2(e);c=c?(c+"").toLowerCase():"text";let h=Z4([i,s&&s.toAbortSignal()],o),g;const m=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let p;try{if(l&&r5&&n!=="get"&&n!=="head"&&(p=await s5(u,r))!==0){let x=new Request(t,{method:"POST",body:r,duplex:"half"}),k;if(B.isFormData(r)&&(k=x.headers.get("content-type"))&&u.setContentType(k),x.body){const[w,_]=s0(p,Wl(o0(l)));r=l0(x.body,c0,w,_)}}B.isString(d)||(d=d?"include":"omit");const v="credentials"in Request.prototype;g=new Request(t,{...f,signal:h,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:v?d:void 0});let b=await fetch(g,f);const S=wd&&(c==="stream"||c==="response");if(wd&&(a||S&&m)){const x={};["status","statusText","headers"].forEach(O=>{x[O]=b[O]});const k=B.toFiniteNumber(b.headers.get("content-length")),[w,_]=a&&s0(k,Wl(o0(a),!0))||[];b=new Response(l0(b.body,c0,w,()=>{_&&_(),m&&m()}),x)}c=c||"text";let C=await Ql[B.findKey(Ql,c)||"text"](b,e);return!S&&m&&m(),await new Promise((x,k)=>{L2(x,k,{data:C,headers:Ht.from(b.headers),status:b.status,statusText:b.statusText,config:e,request:g})})}catch(v){throw m&&m(),v&&v.name==="TypeError"&&/Load failed|fetch/i.test(v.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,e,g),{cause:v.cause||v}):Pe.from(v,v&&v.code,e,g)}}),Sd={http:w4,xhr:X4,fetch:o5};B.forEach(Sd,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(n){}Object.defineProperty(e,"adapterName",{value:t})}});const u0=e=>`- ${e}`,a5=e=>B.isFunction(e)||e===null||e===!1,B2={getAdapter:e=>{e=B.isArray(e)?e:[e];const{length:t}=e;let n,r;const i={};for(let s=0;s<t;s++){n=e[s];let o;if(r=n,!a5(n)&&(r=Sd[(o=String(n)).toLowerCase()],r===void 0))throw new Pe(`Unknown adapter '${o}'`);if(r)break;i[o||"#"+s]=r}if(!r){const s=Object.entries(i).map(([a,l])=>`adapter ${a} `+(l===!1?"is not supported by the environment":"is not available in the build"));let o=t?s.length>1?`since :
15
15
  `+s.map(u0).join(`
16
16
  `):" "+u0(s[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:Sd};function fu(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Zs(null,e)}function d0(e){return fu(e),e.headers=Ht.from(e.headers),e.data=du.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),B2.getAdapter(e.adapter||Ra.adapter)(e).then(function(r){return fu(e),r.data=du.call(e,e.transformResponse,r),r.headers=Ht.from(r.headers),r},function(r){return D2(r)||(fu(e),r&&r.response&&(r.response.data=du.call(e,e.transformResponse,r.response),r.response.headers=Ht.from(r.response.headers))),Promise.reject(r)})}const q2="1.10.0",Tc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Tc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const f0={};Tc.transitional=function(t,n,r){function i(s,o){return"[Axios v"+q2+"] Transitional option '"+s+"'"+o+(r?". "+r:"")}return(s,o,a)=>{if(t===!1)throw new Pe(i(o," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!f0[o]&&(f0[o]=!0,console.warn(i(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,o,a):!0}};Tc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function l5(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const s=r[i],o=t[s];if(o){const a=e[s],l=a===void 0||o(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const Ml={assertOptions:l5,validators:Tc},Rn=Ml.validators;let Ei=class{constructor(t){this.defaults=t||{},this.interceptors={request:new r0,response:new r0}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
17
- `+s):r.stack=s}catch(o){}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Mi(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&Ml.assertOptions(r,{silentJSONParsing:Rn.transitional(Rn.boolean),forcedJSONParsing:Rn.transitional(Rn.boolean),clarifyTimeoutError:Rn.transitional(Rn.boolean)},!1),i!=null&&(B.isFunction(i)?n.paramsSerializer={serialize:i}:Ml.assertOptions(i,{encode:Rn.function,serialize:Rn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ml.assertOptions(n,{baseUrl:Rn.spelling("baseURL"),withXsrfToken:Rn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&B.merge(s.common,s[n.method]);s&&B.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=Ht.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let u,d=0,f;if(!l){const g=[d0.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,c),f=g.length,u=Promise.resolve(n);d<f;)u=u.then(g[d++],g[d++]);return u}f=a.length;let h=n;for(d=0;d<f;){const g=a[d++],m=a[d++];try{h=g(h)}catch(p){m.call(this,p);break}}try{u=d0.call(this,h)}catch(g){return Promise.reject(g)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(t){t=Mi(this.defaults,t);const n=I2(t.baseURL,t.url,t.allowAbsoluteUrls);return j2(n,t.params,t.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(t){Ei.prototype[t]=function(n,r){return this.request(Mi(r||{},{method:t,url:n,data:(r||{}).data}))}});B.forEach(["post","put","patch"],function(t){function n(r){return function(s,o,a){return this.request(Mi(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Ei.prototype[t]=n(),Ei.prototype[t+"Form"]=n(!0)});let c5=class z2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{r.subscribe(a),s=a}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},t(function(s,o,a){r.reason||(r.reason=new Zs(s,o,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new z2(function(i){t=i}),cancel:t}}};function u5(e){return function(n){return e.apply(null,n)}}function d5(e){return B.isObject(e)&&e.isAxiosError===!0}const Cd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Cd).forEach(([e,t])=>{Cd[t]=e});function H2(e){const t=new Ei(e),n=b2(Ei.prototype.request,t);return B.extend(n,Ei.prototype,t,{allOwnKeys:!0}),B.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return H2(Mi(e,i))},n}const ot=H2(Ra);ot.Axios=Ei;ot.CanceledError=Zs;ot.CancelToken=c5;ot.isCancel=D2;ot.VERSION=q2;ot.toFormData=Ac;ot.AxiosError=Pe;ot.Cancel=ot.CanceledError;ot.all=function(t){return Promise.all(t)};ot.spread=u5;ot.isAxiosError=d5;ot.mergeConfig=Mi;ot.AxiosHeaders=Ht;ot.formToJSON=e=>$2(B.isHTMLForm(e)?new FormData(e):e);ot.getAdapter=B2.getAdapter;ot.HttpStatusCode=Cd;ot.default=ot;const{Axios:YL,AxiosError:XL,CanceledError:ZL,isCancel:JL,CancelToken:eI,VERSION:tI,all:nI,Cancel:rI,isAxiosError:iI,spread:sI,toFormData:oI,AxiosHeaders:aI,HttpStatusCode:lI,formToJSON:cI,getAdapter:uI,mergeConfig:dI}=ot,f5={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function Jo(e){"@babel/helpers - typeof";return Jo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jo(e)}function Dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return Yt(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(Yt(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,Yt(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,Yt(d,"constructor",c),Yt(c,"constructor",l),l.displayName="GeneratorFunction",Yt(c,i,"GeneratorFunction"),Yt(d),Yt(d,i,"Generator"),Yt(d,r,function(){return this}),Yt(d,"toString",function(){return"[object Generator]"}),(Dt=function(){return{w:s,m:f}})()}function Yt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}Yt=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){Yt(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},Yt(e,t,n,r)}function h0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ai(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?h0(Object(n),!0).forEach(function(r){h5(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h0(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function h5(e,t,n){return(t=g5(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g5(e){var t=y5(e,"string");return Jo(t)=="symbol"?t:t+""}function y5(e,t){if(Jo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Jo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function g0(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function $i(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){g0(s,r,i,o,a,"next",l)}function a(l){g0(s,r,i,o,a,"throw",l)}o(void 0)})}}var U2=function(){var t;return((t=f5)===null||t===void 0?void 0:t.VITE_MYYOAST_ACCESS_TOKEN)||""};function y0(e){var t;if(typeof document!="undefined"){var n="; ".concat(document.cookie),r=n.split("; ".concat(e,"="));if(r.length===2)return(t=r.pop())===null||t===void 0?void 0:t.split(";").shift()}}var m5="yst-insights-token",Js=ot.create({withCredentials:!0});Js.interceptors.request.use(function(){var e=$i(Dt().m(function t(n){var r,i;return Dt().w(function(s){for(;;)switch(s.n){case 0:return s.n=1,v5();case 1:return r=s.v,s.n=2,K2();case 2:return i=s.v,n.headers=Ai(Ai(Ai({},n.headers||{}),i?{"X-XSRF-TOKEN":i}:{}),r?{Authorization:"Bearer ".concat(r)}:{}),s.a(2,n)}},t)}));return function(t){return e.apply(this,arguments)}}(),function(e){return Promise.reject(e)},{synchronous:!1});Js.interceptors.response.use(function(e){return e},function(){var e=$i(Dt().m(function t(n){var r;return Dt().w(function(i){for(;;)switch(i.n){case 0:return n==null||(r=n.response)===null||r===void 0||r.status,i.a(2,Promise.reject(n))}},t)}));return function(t){return e.apply(this,arguments)}}());function St(e){return _d.apply(this,arguments)}function _d(){return _d=$i(Dt().m(function e(t){var n;return Dt().w(function(r){for(;;)switch(r.n){case 0:return n=Ai({},t),delete n.baseURL,r.a(2,Js.request(Ai(Ai({},n),{},{withCredentials:!0})))}},e)})),_d.apply(this,arguments)}function V2(e){Js.defaults.baseURL=e}function m0(){return Js.defaults.baseURL}function p5(e){U2=e}var fo=null;function v5(){return kd.apply(this,arguments)}function kd(){return kd=$i(Dt().m(function e(){var t,n,r,i,s;return Dt().w(function(o){for(;;)switch(o.p=o.n){case 0:if(t=U2(),n=Js.defaults.baseURL,r=b5(t,n),i=sessionStorage.getItem(r),!i){o.n=4;break}if(o.p=1,s=JSON.parse(i),!((s==null?void 0:s.validUntil)>Date.now()&&s.value)){o.n=2;break}return o.a(2,String(s.value));case 2:o.n=4;break;case 3:o.p=3,o.v;case 4:if(!fo){o.n=5;break}return o.a(2,fo);case 5:return fo=$i(Dt().m(function a(){var l,c,u,d,f;return Dt().w(function(h){for(;;)switch(h.p=h.n){case 0:return h.p=0,h.n=1,K2();case 1:return l=h.v,h.n=2,ot.post(n+"/users/getToken",{},{headers:Ai({Authorization:"Bearer "+t},l?{"X-XSRF-TOKEN":l}:{}),withCredentials:!0});case 2:if(c=h.v,u=c.data,!(u!=null&&u.plainTextToken)){h.n=3;break}return sessionStorage.setItem(r,JSON.stringify({value:u.plainTextToken,validUntil:Date.parse(((d=u.accessToken)===null||d===void 0?void 0:d.expires_at)||"")||Date.now()+15*60*1e3})),h.a(2,u.plainTextToken);case 3:h.n=5;break;case 4:h.p=4,f=h.v,ot.isAxiosError(f)?f.response?console.error("Login failed with status",f.response.status,f.response.data):f.request?console.error("Login request made but no response received",f.request):console.error("Error setting up login request",f.message):console.error("Non-Axios error during login",f);case 5:return h.p=5,fo=null,h.f(5);case 6:return h.a(2,"")}},a,null,[[0,4,5,6]])}))(),o.a(2,fo)}},e,null,[[1,3]])})),kd.apply(this,arguments)}function b5(e,t){var n=Array.from(e+t).reduce(function(r,i){return(r<<5)-r+i.charCodeAt(0)},0);return m5+":"+n}var ho=null;function K2(){return Od.apply(this,arguments)}function Od(){return Od=$i(Dt().m(function e(){var t;return Dt().w(function(n){for(;;)switch(n.n){case 0:if(window.location.hostname===new URL(m0()||window.location.href).hostname){n.n=1;break}return n.a(2,"");case 1:if(t=y0("XSRF-TOKEN"),!t){n.n=2;break}return n.a(2,decodeURIComponent(t));case 2:if(!ho){n.n=3;break}return n.a(2,ho);case 3:return ho=$i(Dt().m(function r(){var i;return Dt().w(function(s){for(;;)switch(s.p=s.n){case 0:return s.p=0,s.n=1,ot.get(((i=m0())===null||i===void 0?void 0:i.replace("/api/v1",""))+"/sanctum/csrf-cookie",{withCredentials:!0});case 1:return s.a(2,decodeURIComponent(y0("XSRF-TOKEN")||""));case 2:return s.p=2,ho=null,s.f(2);case 3:return s.a(2)}},r,null,[[0,,2,3]])}))(),n.a(2,ho)}},e)})),Od.apply(this,arguments)}function ea(e){"@babel/helpers - typeof";return ea=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ea(e)}function p0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?p0(Object(n),!0).forEach(function(r){x5(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p0(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function x5(e,t,n){return(t=w5(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w5(e){var t=S5(e,"string");return ea(t)=="symbol"?t:t+""}function S5(e,t){if(ea(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ea(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var C5=function(t,n){return St({url:"/brands/".concat(t,"/analysis"),method:"GET",signal:n})},G2=function(t){return["/brands/".concat(t,"/analysis")]},_5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:G2(t),a=function(c){var u=c.signal;return C5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function W2(e,t,n){var r=_5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var k5=function(t,n,r){return St({url:"/brands/".concat(t,"/analysis/").concat(n),method:"GET",signal:r})},Q2=function(t,n){return["/brands/".concat(t,"/analysis/").concat(n)]},O5=function(t,n,r){var i,s=r!=null?r:{},o=s.query,a=(i=o==null?void 0:o.queryKey)!==null&&i!==void 0?i:Q2(t,n),l=function(u){var d=u.signal;return k5(t,n,d)};return _e({queryKey:a,queryFn:l,enabled:!!(t&&n)},o)};function jc(e,t,n,r){var i=O5(e,t,n),s=Jr(i,r);return s.queryKey=i.queryKey,s}var E5=function(t,n){return St({url:"/brands/".concat(t,"/analysis/").concat(n),method:"DELETE"})},A5=function(t){var n=["deleteSingleAnalysis"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.analysisId;return E5(c,u)};return _e({mutationFn:s},i)},P5=function(t,n){var r=A5(t);return br(r,n)},T5=function(t,n,r){return St({url:"/brands/".concat(t,"/analysis/").concat(n,"/status"),method:"GET",signal:r})},j5=function(t,n){return["/brands/".concat(t,"/analysis/").concat(n,"/status")]},M5=function(t,n,r){var i,s=r!=null?r:{},o=s.query,a=(i=o==null?void 0:o.queryKey)!==null&&i!==void 0?i:j5(t,n),l=function(u){var d=u.signal;return T5(t,n,d)};return _e({queryKey:a,queryFn:l,enabled:!!(t&&n)},o)};function $5(e,t,n,r){var i=M5(e,t,n),s=Jr(i,r);return s.queryKey=i.queryKey,s}var D5=function(t){return St({url:"/users/logout",method:"POST",signal:t})},L5=function(t){var n=["logout"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(){return D5()};return _e({mutationFn:s},i)},I5=function(t,n){var r=L5(t);return br(r,n)},R5=function(t,n){return St({url:"/brands/".concat(t,"/associated-brands"),method:"GET",signal:n})},Yl=function(t){return["/brands/".concat(t,"/associated-brands")]},F5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:Yl(t),a=function(c){var u=c.signal;return R5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function N5(e,t,n){var r=F5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var B5=function(t,n,r){return St({url:"/brands/".concat(t,"/associated-brand-groups"),method:"POST",headers:{"Content-Type":"application/json"},data:n,signal:r})},q5=function(t){var n=["createBrandAssociationGroup"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return B5(c,u)};return _e({mutationFn:s},i)},Y2=function(t,n){var r=q5(t);return br(r,n)},z5=function(t){return St({url:"/brandGroups/".concat(t),method:"DELETE"})},H5=function(t){var n=["deleteBrandAssociationGroup"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandGroupId;return z5(c)};return _e({mutationFn:s},i)},U5=function(t,n){var r=H5(t);return br(r,n)},V5=function(t){return St({url:"/brands",method:"GET",signal:t})},Gn=function(){return["/brands"]},K5=function(t){var n,r=t!=null?t:{},i=r.query,s=(n=i==null?void 0:i.queryKey)!==null&&n!==void 0?n:Gn(),o=function(l){var c=l.signal;return V5(c)};return _e({queryKey:s,queryFn:o},i)};function zi(e,t){var n=K5(e),r=Jr(n,t);return r.queryKey=n.queryKey,r}var G5=function(t,n){return St({url:"/brands",method:"POST",headers:{"Content-Type":"application/json"},data:t,signal:n})},W5=function(t){var n=["createBrand"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.data;return G5(c)};return _e({mutationFn:s},i)},Q5=function(t,n){var r=W5(t);return br(r,n)},Y5=function(t,n){return St({url:"/brands/".concat(t),method:"GET",signal:n})},kf=function(t){return["/brands/".concat(t)]},X5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:kf(t),a=function(c){var u=c.signal;return Y5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function Ed(e,t,n){var r=X5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var Z5=function(t){return St({url:"/brands/".concat(t),method:"DELETE"})},J5=function(t){var n=["deleteBrand"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId;return Z5(c)};return _e({mutationFn:s},i)},eC=function(t,n){var r=J5(t);return br(r,n)},tC=function(t,n){return St({url:"/brands/".concat(t,"/settings"),method:"PATCH",headers:{"Content-Type":"application/json"},data:n})},nC=function(t){var n=["updateBrandSettings"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return tC(c,u)};return _e({mutationFn:s},i)},X2=function(t,n){var r=nC(t);return br(r,n)},rC=function(t,n){return St({url:"/brands/".concat(t,"/queries"),method:"PUT",headers:{"Content-Type":"application/json"},data:n})},iC=function(t){var n=["updateBrandQueries"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return rC(c,u)};return _e({mutationFn:s},i)},sC=function(t,n){var r=iC(t);return br(r,n)},oC=function(t,n){return St({url:"/brands/".concat(t,"/query-suggestions"),method:"GET",signal:n})},aC=function(t){return["/brands/".concat(t,"/query-suggestions")]},lC=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:aC(t),a=function(c){var u=c.signal;return oC(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function cC(e,t,n){var r=lC(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var uC=function(t){return St({url:"/users/current",method:"GET",signal:t})},Mc=function(){return["/users/current"]},dC=function(t){var n,r=t!=null?t:{},i=r.query,s=(n=i==null?void 0:i.queryKey)!==null&&n!==void 0?n:Mc(),o=function(l){var c=l.signal;return uC(c)};return _e({queryKey:s,queryFn:o},i)};function $c(e,t){var n=dC(e),r=Jr(n,t);return r.queryKey=n.queryKey,r}var fC=function(){return St({url:"/users/data",method:"DELETE"})},hC=function(t){var n=["deleteUserData"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(){return fC()};return _e({mutationFn:s},i)},gC=function(t,n){var r=hC(t);return br(r,n)},Z2=z.createContext(void 0),yC=function(t){var n,r,i,s,o,a,l,c,u=t.children,d=t.brandId,f=t.analysisId,h=t.model,g=t.hostAppProps,m=g===void 0?{}:g,p=Za("/brands/:brandId"),v=Za("/brands/:brandId/*"),b=Za("/brands/:brandId/analysis/:analysisId"),S=Za("/brands/:brandId/analysis/:analysisId/*"),C=(b==null||(n=b.params)===null||n===void 0?void 0:n.brandId)||(S==null||(r=S.params)===null||r===void 0?void 0:r.brandId)||(v==null||(i=v.params)===null||i===void 0?void 0:i.brandId)||(p==null||(s=p.params)===null||s===void 0?void 0:s.brandId),x=b!=null&&(o=b.params)!==null&&o!==void 0&&o.analysisId||S!=null&&(a=S.params)!==null&&a!==void 0&&a.analysisId?Number((b==null||(l=b.params)===null||l===void 0?void 0:l.analysisId)||(S==null||(c=S.params)===null||c===void 0?void 0:c.analysisId)):void 0,k=z.useMemo(function(){return{brandId:C||d||"",analysisId:x||f||"latest",model:h||"openai",hostAppProps:m}},[C,d,x,f,h,m]),w=z.useMemo(function(){return{data:k}},[k]);return y.jsx(Z2.Provider,{value:w,children:u})},J2=z.createContext(void 0),mC=function(t){var n=t.children,r=t.setBrandId,i=t.setAnalysisId,s=t.setModel,o=z.useCallback(function(d){r(d),i("latest")},[r,i]),a=z.useCallback(function(d){i(d)},[i]),l=z.useCallback(function(d){s(d)},[s]),c=z.useMemo(function(){return{setBrandId:o,setAnalysisId:a,setModel:l}},[o,a,l]),u=z.useMemo(function(){return{mutations:c}},[c]);return y.jsx(J2.Provider,{value:u,children:n})};function hu(e,t){return xC(e)||bC(e,t)||vC(e,t)||pC()}function pC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
17
+ `+s):r.stack=s}catch(o){}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Mi(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&Ml.assertOptions(r,{silentJSONParsing:Rn.transitional(Rn.boolean),forcedJSONParsing:Rn.transitional(Rn.boolean),clarifyTimeoutError:Rn.transitional(Rn.boolean)},!1),i!=null&&(B.isFunction(i)?n.paramsSerializer={serialize:i}:Ml.assertOptions(i,{encode:Rn.function,serialize:Rn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ml.assertOptions(n,{baseUrl:Rn.spelling("baseURL"),withXsrfToken:Rn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&B.merge(s.common,s[n.method]);s&&B.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=Ht.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let u,d=0,f;if(!l){const g=[d0.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,c),f=g.length,u=Promise.resolve(n);d<f;)u=u.then(g[d++],g[d++]);return u}f=a.length;let h=n;for(d=0;d<f;){const g=a[d++],m=a[d++];try{h=g(h)}catch(p){m.call(this,p);break}}try{u=d0.call(this,h)}catch(g){return Promise.reject(g)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(t){t=Mi(this.defaults,t);const n=I2(t.baseURL,t.url,t.allowAbsoluteUrls);return j2(n,t.params,t.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(t){Ei.prototype[t]=function(n,r){return this.request(Mi(r||{},{method:t,url:n,data:(r||{}).data}))}});B.forEach(["post","put","patch"],function(t){function n(r){return function(s,o,a){return this.request(Mi(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Ei.prototype[t]=n(),Ei.prototype[t+"Form"]=n(!0)});let c5=class z2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{r.subscribe(a),s=a}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},t(function(s,o,a){r.reason||(r.reason=new Zs(s,o,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new z2(function(i){t=i}),cancel:t}}};function u5(e){return function(n){return e.apply(null,n)}}function d5(e){return B.isObject(e)&&e.isAxiosError===!0}const Cd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Cd).forEach(([e,t])=>{Cd[t]=e});function H2(e){const t=new Ei(e),n=b2(Ei.prototype.request,t);return B.extend(n,Ei.prototype,t,{allOwnKeys:!0}),B.extend(n,t,null,{allOwnKeys:!0}),n.create=function(i){return H2(Mi(e,i))},n}const ot=H2(Ra);ot.Axios=Ei;ot.CanceledError=Zs;ot.CancelToken=c5;ot.isCancel=D2;ot.VERSION=q2;ot.toFormData=Ac;ot.AxiosError=Pe;ot.Cancel=ot.CanceledError;ot.all=function(t){return Promise.all(t)};ot.spread=u5;ot.isAxiosError=d5;ot.mergeConfig=Mi;ot.AxiosHeaders=Ht;ot.formToJSON=e=>$2(B.isHTMLForm(e)?new FormData(e):e);ot.getAdapter=B2.getAdapter;ot.HttpStatusCode=Cd;ot.default=ot;const{Axios:YL,AxiosError:XL,CanceledError:ZL,isCancel:JL,CancelToken:eI,VERSION:tI,all:nI,Cancel:rI,isAxiosError:iI,spread:sI,toFormData:oI,AxiosHeaders:aI,HttpStatusCode:lI,formToJSON:cI,getAdapter:uI,mergeConfig:dI}=ot,f5={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};function Jo(e){"@babel/helpers - typeof";return Jo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jo(e)}function Dt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return Yt(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(Yt(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,Yt(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,Yt(d,"constructor",c),Yt(c,"constructor",l),l.displayName="GeneratorFunction",Yt(c,i,"GeneratorFunction"),Yt(d),Yt(d,i,"Generator"),Yt(d,r,function(){return this}),Yt(d,"toString",function(){return"[object Generator]"}),(Dt=function(){return{w:s,m:f}})()}function Yt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}Yt=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){Yt(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},Yt(e,t,n,r)}function h0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ai(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?h0(Object(n),!0).forEach(function(r){h5(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h0(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function h5(e,t,n){return(t=g5(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g5(e){var t=y5(e,"string");return Jo(t)=="symbol"?t:t+""}function y5(e,t){if(Jo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Jo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function g0(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function $i(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){g0(s,r,i,o,a,"next",l)}function a(l){g0(s,r,i,o,a,"throw",l)}o(void 0)})}}var U2=function(){var t;return((t=f5)===null||t===void 0?void 0:t.VITE_MYYOAST_ACCESS_TOKEN)||""};function y0(e){var t;if(typeof document!="undefined"){var n="; ".concat(document.cookie),r=n.split("; ".concat(e,"="));if(r.length===2)return(t=r.pop())===null||t===void 0?void 0:t.split(";").shift()}}var m5="yst-insights-token",Js=ot.create({withCredentials:!0});Js.interceptors.request.use(function(){var e=$i(Dt().m(function t(n){var r,i;return Dt().w(function(s){for(;;)switch(s.n){case 0:return s.n=1,v5();case 1:return r=s.v,s.n=2,K2();case 2:return i=s.v,n.headers=Ai(Ai(Ai({},n.headers||{}),i?{"X-XSRF-TOKEN":i}:{}),r?{Authorization:"Bearer ".concat(r)}:{}),s.a(2,n)}},t)}));return function(t){return e.apply(this,arguments)}}(),function(e){return Promise.reject(e)},{synchronous:!1});Js.interceptors.response.use(function(e){return e},function(){var e=$i(Dt().m(function t(n){var r;return Dt().w(function(i){for(;;)switch(i.n){case 0:return n==null||(r=n.response)===null||r===void 0||r.status,i.a(2,Promise.reject(n))}},t)}));return function(t){return e.apply(this,arguments)}}());function St(e){return _d.apply(this,arguments)}function _d(){return _d=$i(Dt().m(function e(t){var n;return Dt().w(function(r){for(;;)switch(r.n){case 0:return n=Ai({},t),delete n.baseURL,r.a(2,Js.request(Ai(Ai({},n),{},{withCredentials:!0})))}},e)})),_d.apply(this,arguments)}function V2(e){Js.defaults.baseURL=e}function m0(){return Js.defaults.baseURL}function p5(e){U2=e}var fo=null;function v5(){return kd.apply(this,arguments)}function kd(){return kd=$i(Dt().m(function e(){var t,n,r,i,s;return Dt().w(function(o){for(;;)switch(o.p=o.n){case 0:if(t=U2(),n=Js.defaults.baseURL,r=b5(t,n),i=sessionStorage.getItem(r),!i){o.n=4;break}if(o.p=1,s=JSON.parse(i),!((s==null?void 0:s.validUntil)>Date.now()&&s.value)){o.n=2;break}return o.a(2,String(s.value));case 2:o.n=4;break;case 3:o.p=3,o.v;case 4:if(!fo){o.n=5;break}return o.a(2,fo);case 5:return fo=$i(Dt().m(function a(){var l,c,u,d,f;return Dt().w(function(h){for(;;)switch(h.p=h.n){case 0:return h.p=0,h.n=1,K2();case 1:return l=h.v,h.n=2,ot.post(n+"/users/getToken",{},{headers:Ai({Authorization:"Bearer "+t},l?{"X-XSRF-TOKEN":l}:{}),withCredentials:!0});case 2:if(c=h.v,u=c.data,!(u!=null&&u.plainTextToken)){h.n=3;break}return sessionStorage.setItem(r,JSON.stringify({value:u.plainTextToken,validUntil:Date.parse(((d=u.accessToken)===null||d===void 0?void 0:d.expires_at)||"")||Date.now()+15*60*1e3})),h.a(2,u.plainTextToken);case 3:h.n=5;break;case 4:h.p=4,f=h.v,ot.isAxiosError(f)?f.response?console.error("Login failed with status",f.response.status,f.response.data):f.request?console.error("Login request made but no response received",f.request):console.error("Error setting up login request",f.message):console.error("Non-Axios error during login",f);case 5:return h.p=5,fo=null,h.f(5);case 6:return h.a(2,"")}},a,null,[[0,4,5,6]])}))(),o.a(2,fo)}},e,null,[[1,3]])})),kd.apply(this,arguments)}function b5(e,t){var n=Array.from(e+t).reduce(function(r,i){return(r<<5)-r+i.charCodeAt(0)},0);return m5+":"+n}var ho=null;function K2(){return Od.apply(this,arguments)}function Od(){return Od=$i(Dt().m(function e(){var t;return Dt().w(function(n){for(;;)switch(n.n){case 0:if(window.location.hostname===new URL(m0()||window.location.href).hostname){n.n=1;break}return n.a(2,"");case 1:if(t=y0("XSRF-TOKEN"),!t){n.n=2;break}return n.a(2,decodeURIComponent(t));case 2:if(!ho){n.n=3;break}return n.a(2,ho);case 3:return ho=$i(Dt().m(function r(){var i;return Dt().w(function(s){for(;;)switch(s.p=s.n){case 0:return s.p=0,s.n=1,ot.get(((i=m0())===null||i===void 0?void 0:i.replace("/api/v1",""))+"/sanctum/csrf-cookie",{withCredentials:!0});case 1:return s.a(2,decodeURIComponent(y0("XSRF-TOKEN")||""));case 2:return s.p=2,ho=null,s.f(2);case 3:return s.a(2)}},r,null,[[0,,2,3]])}))(),n.a(2,ho)}},e)})),Od.apply(this,arguments)}function ea(e){"@babel/helpers - typeof";return ea=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ea(e)}function p0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?p0(Object(n),!0).forEach(function(r){x5(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p0(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function x5(e,t,n){return(t=w5(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w5(e){var t=S5(e,"string");return ea(t)=="symbol"?t:t+""}function S5(e,t){if(ea(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ea(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var C5=function(t,n){return St({url:"/brands/".concat(t,"/analysis"),method:"GET",signal:n})},G2=function(t){return["/brands/".concat(t,"/analysis")]},_5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:G2(t),a=function(c){var u=c.signal;return C5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function W2(e,t,n){var r=_5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var k5=function(t,n,r){return St({url:"/brands/".concat(t,"/analysis/").concat(n),method:"GET",signal:r})},Q2=function(t,n){return["/brands/".concat(t,"/analysis/").concat(n)]},O5=function(t,n,r){var i,s=r!=null?r:{},o=s.query,a=(i=o==null?void 0:o.queryKey)!==null&&i!==void 0?i:Q2(t,n),l=function(u){var d=u.signal;return k5(t,n,d)};return _e({queryKey:a,queryFn:l,enabled:!!(t&&n)},o)};function jc(e,t,n,r){var i=O5(e,t,n),s=Jr(i,r);return s.queryKey=i.queryKey,s}var E5=function(t,n){return St({url:"/brands/".concat(t,"/analysis/").concat(n),method:"DELETE"})},A5=function(t){var n=["deleteSingleAnalysis"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.analysisId;return E5(c,u)};return _e({mutationFn:s},i)},P5=function(t,n){var r=A5(t);return br(r,n)},T5=function(t,n,r){return St({url:"/brands/".concat(t,"/analysis/").concat(n,"/status"),method:"GET",signal:r})},j5=function(t,n){return["/brands/".concat(t,"/analysis/").concat(n,"/status")]},M5=function(t,n,r){var i,s=r!=null?r:{},o=s.query,a=(i=o==null?void 0:o.queryKey)!==null&&i!==void 0?i:j5(t,n),l=function(u){var d=u.signal;return T5(t,n,d)};return _e({queryKey:a,queryFn:l,enabled:!!(t&&n)},o)};function $5(e,t,n,r){var i=M5(e,t,n),s=Jr(i,r);return s.queryKey=i.queryKey,s}var D5=function(t){return St({url:"/users/logout",method:"POST",signal:t})},L5=function(t){var n=["logout"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(){return D5()};return _e({mutationFn:s},i)},I5=function(t,n){var r=L5(t);return br(r,n)},R5=function(t,n){return St({url:"/brands/".concat(t,"/associated-brands"),method:"GET",signal:n})},Yl=function(t){return["/brands/".concat(t,"/associated-brands")]},F5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:Yl(t),a=function(c){var u=c.signal;return R5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function N5(e,t,n){var r=F5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var B5=function(t,n,r){return St({url:"/brands/".concat(t,"/associated-brand-groups"),method:"POST",headers:{"Content-Type":"application/json"},data:n,signal:r})},q5=function(t){var n=["createBrandAssociationGroup"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return B5(c,u)};return _e({mutationFn:s},i)},Y2=function(t,n){var r=q5(t);return br(r,n)},z5=function(t,n){return St({url:"/brands/".concat(t,"/associated-brand-groups/").concat(n),method:"DELETE"})},H5=function(t){var n=["deleteBrandAssociationGroup"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.brandGroupId;return z5(c,u)};return _e({mutationFn:s},i)},U5=function(t,n){var r=H5(t);return br(r,n)},V5=function(t){return St({url:"/brands",method:"GET",signal:t})},Gn=function(){return["/brands"]},K5=function(t){var n,r=t!=null?t:{},i=r.query,s=(n=i==null?void 0:i.queryKey)!==null&&n!==void 0?n:Gn(),o=function(l){var c=l.signal;return V5(c)};return _e({queryKey:s,queryFn:o},i)};function zi(e,t){var n=K5(e),r=Jr(n,t);return r.queryKey=n.queryKey,r}var G5=function(t,n){return St({url:"/brands",method:"POST",headers:{"Content-Type":"application/json"},data:t,signal:n})},W5=function(t){var n=["createBrand"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.data;return G5(c)};return _e({mutationFn:s},i)},Q5=function(t,n){var r=W5(t);return br(r,n)},Y5=function(t,n){return St({url:"/brands/".concat(t),method:"GET",signal:n})},kf=function(t){return["/brands/".concat(t)]},X5=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:kf(t),a=function(c){var u=c.signal;return Y5(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function Ed(e,t,n){var r=X5(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var Z5=function(t){return St({url:"/brands/".concat(t),method:"DELETE"})},J5=function(t){var n=["deleteBrand"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId;return Z5(c)};return _e({mutationFn:s},i)},eC=function(t,n){var r=J5(t);return br(r,n)},tC=function(t,n){return St({url:"/brands/".concat(t,"/settings"),method:"PATCH",headers:{"Content-Type":"application/json"},data:n})},nC=function(t){var n=["updateBrandSettings"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return tC(c,u)};return _e({mutationFn:s},i)},X2=function(t,n){var r=nC(t);return br(r,n)},rC=function(t,n){return St({url:"/brands/".concat(t,"/queries"),method:"PUT",headers:{"Content-Type":"application/json"},data:n})},iC=function(t){var n=["updateBrandQueries"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(a){var l=a!=null?a:{},c=l.brandId,u=l.data;return rC(c,u)};return _e({mutationFn:s},i)},sC=function(t,n){var r=iC(t);return br(r,n)},oC=function(t,n){return St({url:"/brands/".concat(t,"/query-suggestions"),method:"GET",signal:n})},aC=function(t){return["/brands/".concat(t,"/query-suggestions")]},lC=function(t,n){var r,i=n!=null?n:{},s=i.query,o=(r=s==null?void 0:s.queryKey)!==null&&r!==void 0?r:aC(t),a=function(c){var u=c.signal;return oC(t,u)};return _e({queryKey:o,queryFn:a,enabled:!!t},s)};function cC(e,t,n){var r=lC(e,t),i=Jr(r,n);return i.queryKey=r.queryKey,i}var uC=function(t){return St({url:"/users/current",method:"GET",signal:t})},Mc=function(){return["/users/current"]},dC=function(t){var n,r=t!=null?t:{},i=r.query,s=(n=i==null?void 0:i.queryKey)!==null&&n!==void 0?n:Mc(),o=function(l){var c=l.signal;return uC(c)};return _e({queryKey:s,queryFn:o},i)};function $c(e,t){var n=dC(e),r=Jr(n,t);return r.queryKey=n.queryKey,r}var fC=function(){return St({url:"/users/data",method:"DELETE"})},hC=function(t){var n=["deleteUserData"],r=t?t.mutation&&"mutationKey"in t.mutation&&t.mutation.mutationKey?t:_e(_e({},t),{},{mutation:_e(_e({},t.mutation),{},{mutationKey:n})}):{mutation:{mutationKey:n}},i=r.mutation,s=function(){return fC()};return _e({mutationFn:s},i)},gC=function(t,n){var r=hC(t);return br(r,n)},Z2=z.createContext(void 0),yC=function(t){var n,r,i,s,o,a,l,c,u=t.children,d=t.brandId,f=t.analysisId,h=t.model,g=t.hostAppProps,m=g===void 0?{}:g,p=Za("/brands/:brandId"),v=Za("/brands/:brandId/*"),b=Za("/brands/:brandId/analysis/:analysisId"),S=Za("/brands/:brandId/analysis/:analysisId/*"),C=(b==null||(n=b.params)===null||n===void 0?void 0:n.brandId)||(S==null||(r=S.params)===null||r===void 0?void 0:r.brandId)||(v==null||(i=v.params)===null||i===void 0?void 0:i.brandId)||(p==null||(s=p.params)===null||s===void 0?void 0:s.brandId),x=b!=null&&(o=b.params)!==null&&o!==void 0&&o.analysisId||S!=null&&(a=S.params)!==null&&a!==void 0&&a.analysisId?Number((b==null||(l=b.params)===null||l===void 0?void 0:l.analysisId)||(S==null||(c=S.params)===null||c===void 0?void 0:c.analysisId)):void 0,k=z.useMemo(function(){return{brandId:C||d||"",analysisId:x||f||"latest",model:h||"openai",hostAppProps:m}},[C,d,x,f,h,m]),w=z.useMemo(function(){return{data:k}},[k]);return y.jsx(Z2.Provider,{value:w,children:u})},J2=z.createContext(void 0),mC=function(t){var n=t.children,r=t.setBrandId,i=t.setAnalysisId,s=t.setModel,o=z.useCallback(function(d){r(d),i("latest")},[r,i]),a=z.useCallback(function(d){i(d)},[i]),l=z.useCallback(function(d){s(d)},[s]),c=z.useMemo(function(){return{setBrandId:o,setAnalysisId:a,setModel:l}},[o,a,l]),u=z.useMemo(function(){return{mutations:c}},[c]);return y.jsx(J2.Provider,{value:u,children:n})};function hu(e,t){return xC(e)||bC(e,t)||vC(e,t)||pC()}function pC(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
18
18
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vC(e,t){if(e){if(typeof e=="string")return v0(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v0(e,t):void 0}}function v0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function bC(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function xC(e){if(Array.isArray(e))return e}var wC=function(t){var n=t.children,r=t.hostAppProps,i=r===void 0?{}:r,s=z.useState(void 0),o=hu(s,2),a=o[0],l=o[1],c=z.useState("latest"),u=hu(c,2),d=u[0],f=u[1],h=z.useState(void 0),g=hu(h,2),m=g[0],p=g[1];return y.jsx(mC,{brandId:a,setBrandId:l,analysisId:d,setAnalysisId:f,model:m,setModel:p,children:y.jsx(yC,{brandId:a,analysisId:d,model:m,hostAppProps:i,children:n})})},Zn=function(){var t=z.useContext(Z2);if(t===void 0)throw new Error("useBrandAnalysisData must be used within a BrandAnalysisDataProvider");return t.data},Fa=function(){var t=z.useContext(J2);if(t===void 0)throw new Error("useBrandAnalysisMutations must be used within a BrandAnalysisMutationsProvider");return t.mutations},gu={exports:{}};/*!
19
19
  Copyright (c) 2018 Jed Watson.
20
20
  Licensed under the MIT License (MIT), see
@@ -1280,16 +1280,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1280
1280
  cursor: not-allowed;
1281
1281
  }
1282
1282
  `}},kn=e=>Hb("light",e),On=e=>Hb("dark",e);Sc(["click","mousedown","input"]);var rD=e=>{const[t,n]=u1({prefix:"TanstackQueryDevtools"}),r=p2(),i=U(()=>{const s=t.theme_preference||d1;return s!=="system"?s:r()});return D(Kf.Provider,{value:e,get children(){return D(y1,{localStore:t,setLocalStore:n,get children(){return D(Wf.Provider,{value:i,get children(){return D(U$,{localStore:t,setLocalStore:n})}})}})}})},iD=rD;const sD=Object.freeze(Object.defineProperty({__proto__:null,default:iD},Symbol.toStringTag,{value:"Module"}));var oD=e=>{const[t,n]=u1({prefix:"TanstackQueryDevtools"}),r=p2(),i=U(()=>{const s=t.theme_preference||d1;return s!=="system"?s:r()});return D(Kf.Provider,{value:e,get children(){return D(y1,{disabled:!0,localStore:t,setLocalStore:n,get children(){return D(Wf.Provider,{value:i,get children(){return D(K$,{get children(){return D(gh,{localStore:t,setLocalStore:n,get onClose(){return e.onClose},showPanelViewOnly:!0})}})}})}})}})},aD=oD;const lD=Object.freeze(Object.defineProperty({__proto__:null,default:aD},Symbol.toStringTag,{value:"Module"}));function Ub(e){var t=e.children,n=e.description,r=e.title;return y.jsxs(P.Paper.Header,{children:[r&&y.jsx(P.Title,{className:ke({"yst-mb-3":n||t}),children:r}),n&&(typeof n=="string"?y.jsx("p",{children:n}):n),t]})}function Uu(e,t){return fD(e)||dD(e,t)||uD(e,t)||cD()}function cD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1283
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uD(e,t){if(e){if(typeof e=="string")return _m(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_m(e,t):void 0}}function _m(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function fD(e){if(Array.isArray(e))return e}var hD=function(t){var n=t.isOpen,r=t.onClose,i=t.groupToEdit,s=t.allBrands,o=Zn(),a=o.brandId,l=z.useState(""),c=Uu(l,2),u=c[0],d=c[1],f=z.useState([]),h=Uu(f,2),g=h[0],m=h[1],p=z.useState(!1),v=Uu(p,2),b=v[0],S=v[1],C=Vt();z.useEffect(function(){if(n&&i&&i.type==="group"){var I;d(String(i.name||""));var K=((I=i.groupedBrands)===null||I===void 0?void 0:I.map(function(Y){return String(Y.id||"")}))||[];m(K)}},[n,i]);var x=Y2({mutation:{onSuccess:function(){C.invalidateQueries({queryKey:Yl(a)}),j()},onError:function(K){console.error("Error creating brand group:",K)}}}),k=x.mutate,w=x.isPending,_=U5({mutation:{onSuccess:function(){C.invalidateQueries({queryKey:Yl(a)}),j(),E()},onError:function(K){console.error("Error deleting brand group:",K),window.alert("An error occurred while ungrouping the brands. Please try again later.")}}}),O=_.mutate,A=_.isPending,M=function(){!u.trim()||!(i!=null&&i.id)||k({brandId:a,data:{groupName:u.trim(),brandIds:g.map(function(K){return Number(K)})}})},j=function(){d(""),m([]),r()},q=function(){return g.map(function(K){if(i&&i.type==="group"){var Y,N=(Y=i.groupedBrands)===null||Y===void 0?void 0:Y.find(function(ie){return String(ie.id)===K});if(N)return N.name||""}var W=s.find(function(ie){return String(ie.id)===K});return W?W.type==="group"?"Group: ".concat(W.name):W.name||"":""}).filter(Boolean)},R=function(){S(!0)},E=function(){return S(!1)},$=function(){typeof(i==null?void 0:i.id)=="number"&&O({brandGroupId:i.id})};return!i||i.type!=="group"?null:y.jsxs(y.Fragment,{children:[y.jsx(P.Modal,{isOpen:n,onClose:b?function(){}:j,as:"div",children:y.jsx(P.Modal.Panel,{children:y.jsxs(P.Modal.Container,{children:[y.jsx(P.Modal.Container.Header,{className:"yst-mb-4",children:y.jsx(P.Modal.Title,{as:"h3",className:"yst-text-lg yst-font-medium",children:"Edit brand group"})}),y.jsxs(P.Modal.Container.Content,{className:"yst-mb-8 yst-space-y-4",children:[y.jsx("p",{className:"yst-text-sm yst-text-slate-600",children:"Update the group name or ungroup brands by removing their tags."}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:"editGroupName",className:"yst-mb-2 yst-block yst-text-sm yst-font-medium",children:"Group name"}),y.jsx(P.TextInput,{id:"editGroupName",value:u,onChange:function(I){return d(I.target.value)},placeholder:"Enter group name",className:"yst-w-full"})]}),y.jsxs("div",{children:[y.jsx(P.TagField,{readOnly:!0,id:"editGroupedBrands",label:"Grouped brands",tags:q(),onRemoveTag:function(I){if(g.length<2)return S(!0);m(function(K){return K.filter(function(Y,N){return N!==I})})},onAddTag:function(){}}),g.length===0?y.jsx("p",{className:"yst-mt-2 yst-text-sm",children:'Click "Ungroup brands" to remove this group.'}):y.jsx("p",{className:"yst-mt-2 yst-text-sm yst-italic yst-text-gray-500",children:"Note: To add brands to this group, save this group, then use the checkboxes to select this group as well as any additional brands to be grouped."})]})]}),y.jsx(P.Modal.Container.Footer,{children:y.jsxs("div",{className:"yst-flex yst-w-full yst-items-center yst-justify-between",children:[y.jsx("div",{className:"yst-flex yst-justify-start",children:y.jsx(P.Button,{variant:"tertiary",onClick:R,disabled:w,className:"yst-text-red-600",children:"Ungroup brands"})}),y.jsxs("div",{className:"yst-flex yst-justify-end yst-gap-2",children:[y.jsx(P.Button,{variant:"secondary",onClick:j,children:"Cancel"}),y.jsx(P.Button,{variant:"primary",onClick:M,disabled:!u.trim()||w,isLoading:w,children:w?"Saving...":"Save changes"})]})]})})]})})}),y.jsx(Ic,{isOpen:b,onClose:E,onConfirm:$,title:"Ungroup this brand group?",description:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"The group will be removed, but the brands inside will remain in your brand list."}),y.jsx("p",{children:"This action cannot be undone. To create a new group with these brands, simply select them and create a new group."})]}),confirmText:"Yes, ungroup",isLoading:A})]})};function km(e,t){return pD(e)||mD(e,t)||yD(e,t)||gD()}function gD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1283
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uD(e,t){if(e){if(typeof e=="string")return _m(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_m(e,t):void 0}}function _m(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function fD(e){if(Array.isArray(e))return e}var hD=function(t){var n=t.isOpen,r=t.onClose,i=t.groupToEdit,s=t.allBrands,o=Zn(),a=o.brandId,l=z.useState(""),c=Uu(l,2),u=c[0],d=c[1],f=z.useState([]),h=Uu(f,2),g=h[0],m=h[1],p=z.useState(!1),v=Uu(p,2),b=v[0],S=v[1],C=Vt();z.useEffect(function(){if(n&&i&&i.type==="group"){var I;d(String(i.name||""));var K=((I=i.groupedBrands)===null||I===void 0?void 0:I.map(function(Y){return String(Y.id||"")}))||[];m(K)}},[n,i]);var x=Y2({mutation:{onSuccess:function(){C.invalidateQueries({queryKey:Yl(a)}),j()},onError:function(K){console.error("Error creating brand group:",K)}}}),k=x.mutate,w=x.isPending,_=U5({mutation:{onSuccess:function(){C.invalidateQueries({queryKey:Yl(a)}),j(),E()},onError:function(K){console.error("Error deleting brand group:",K),window.alert("An error occurred while ungrouping the brands. Please try again later.")}}}),O=_.mutate,A=_.isPending,M=function(){!u.trim()||!(i!=null&&i.id)||k({brandId:a,data:{groupName:u.trim(),brandIds:g.map(function(K){return Number(K)})}})},j=function(){d(""),m([]),r()},q=function(){return g.map(function(K){if(i&&i.type==="group"){var Y,N=(Y=i.groupedBrands)===null||Y===void 0?void 0:Y.find(function(ie){return String(ie.id)===K});if(N)return N.name||""}var W=s.find(function(ie){return String(ie.id)===K});return W?W.type==="group"?"Group: ".concat(W.name):W.name||"":""}).filter(Boolean)},R=function(){S(!0)},E=function(){return S(!1)},$=function(){typeof(i==null?void 0:i.id)=="number"&&O({brandId:a,brandGroupId:i.id})};return!i||i.type!=="group"?null:y.jsxs(y.Fragment,{children:[y.jsx(P.Modal,{isOpen:n,onClose:b?function(){}:j,as:"div",children:y.jsx(P.Modal.Panel,{children:y.jsxs(P.Modal.Container,{children:[y.jsx(P.Modal.Container.Header,{className:"yst-mb-4",children:y.jsx(P.Modal.Title,{as:"h3",className:"yst-text-lg yst-font-medium",children:"Edit brand group"})}),y.jsxs(P.Modal.Container.Content,{className:"yst-mb-8 yst-space-y-4",children:[y.jsx("p",{className:"yst-text-sm yst-text-slate-600",children:"Update the group name or ungroup brands by removing their tags."}),y.jsxs("div",{children:[y.jsx("label",{htmlFor:"editGroupName",className:"yst-mb-2 yst-block yst-text-sm yst-font-medium",children:"Group name"}),y.jsx(P.TextInput,{id:"editGroupName",value:u,onChange:function(I){return d(I.target.value)},placeholder:"Enter group name",className:"yst-w-full"})]}),y.jsxs("div",{children:[y.jsx(P.TagField,{readOnly:!0,id:"editGroupedBrands",label:"Grouped brands",tags:q(),onRemoveTag:function(I){if(g.length<2)return S(!0);m(function(K){return K.filter(function(Y,N){return N!==I})})},onAddTag:function(){}}),g.length===0?y.jsx("p",{className:"yst-mt-2 yst-text-sm",children:'Click "Ungroup brands" to remove this group.'}):y.jsx("p",{className:"yst-mt-2 yst-text-sm yst-italic yst-text-gray-500",children:"Note: To add brands to this group, save this group, then use the checkboxes to select this group as well as any additional brands to be grouped."})]})]}),y.jsx(P.Modal.Container.Footer,{children:y.jsxs("div",{className:"yst-flex yst-w-full yst-items-center yst-justify-between",children:[y.jsx("div",{className:"yst-flex yst-justify-start",children:y.jsx(P.Button,{variant:"tertiary",onClick:R,disabled:w,className:"yst-text-red-600",children:"Ungroup brands"})}),y.jsxs("div",{className:"yst-flex yst-justify-end yst-gap-2",children:[y.jsx(P.Button,{variant:"secondary",onClick:j,children:"Cancel"}),y.jsx(P.Button,{variant:"primary",onClick:M,disabled:!u.trim()||w,isLoading:w,children:w?"Saving...":"Save changes"})]})]})})]})})}),y.jsx(Ic,{isOpen:b,onClose:E,onConfirm:$,title:"Ungroup this brand group?",description:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"The group will be removed, but the brands inside will remain in your brand list."}),y.jsx("p",{children:"This action cannot be undone. To create a new group with these brands, simply select them and create a new group."})]}),confirmText:"Yes, ungroup",isLoading:A})]})};function km(e,t){return pD(e)||mD(e,t)||yD(e,t)||gD()}function gD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1284
1284
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yD(e,t){if(e){if(typeof e=="string")return Om(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Om(e,t):void 0}}function Om(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function pD(e){if(Array.isArray(e))return e}var vD=function(t){var n=t.isOpen,r=t.onClose,i=t.brandId,s=t.brandsToGroup,o=t.onGroupCreated,a=Vt(),l=z.useState(""),c=km(l,2),u=c[0],d=c[1],f=z.useState([]),h=km(f,2),g=h[0],m=h[1];z.useEffect(function(){if(n&&s.length>0){var k,w=(k=s[0])===null||k===void 0?void 0:k.name;d(String(w||"New Group")),m(s.map(function(_){var O;return String((O=_.id)!==null&&O!==void 0?O:"")}))}},[n,s]);var p=Y2({mutation:{onSuccess:function(){a.invalidateQueries({queryKey:Yl(i)}),o==null||o(),S()},onError:function(w){console.error("Error creating group:",w)}}}),v=p.mutate,b=p.isPending,S=function(){d(""),m([]),r()},C=function(){if(!(!u.trim()||g.length===0)){var w=g.flatMap(function(_){var O=s.find(function(A){return String(A.id)===_});return O&&O.type==="group"&&Array.isArray(O.groupedBrands)?O.groupedBrands.map(function(A){return String(A.id)}):_});v({brandId:i,data:{groupName:u.trim(),brandIds:w.filter(function(_){return _!==""}).map(function(_){return Number(_)})}})}},x=function(w){m(function(_){return _.filter(function(O){return O!==w})})};return y.jsx(P.Modal,{isOpen:n,onClose:S,children:y.jsx(P.Modal.Panel,{children:y.jsxs(P.Modal.Container,{children:[y.jsx(P.Modal.Container.Header,{children:y.jsx(P.Modal.Title,{children:"Edit brand group"})}),y.jsxs(P.Modal.Container.Content,{className:"yst-space-y-4",children:[y.jsxs("div",{children:[y.jsx("label",{htmlFor:"groupName",className:"yst-mb-2 yst-block yst-text-sm yst-font-medium",children:"Group name"}),y.jsx(P.TextInput,{id:"groupName",value:u,onChange:function(k){return d(k.target.value)},placeholder:"Enter group name",className:"yst-w-full"})]}),y.jsxs("div",{children:[y.jsx(P.TagField,{readOnly:!0,id:"groupedBrands",label:"Brands in group (".concat(g.length,")"),tags:g.map(function(k){var w=s.find(function(_){return String(_.id)===k});return w?w.type==="group"?"Group: ".concat(w.name):w.name||"":""}).filter(Boolean),onRemoveTag:function(k){var w=g.find(function(_){var O=s.find(function(M){return String(M.id)===_});if(!O)return!1;var A=O.type==="group"?"Group: ".concat(O.name):O.name||"";return A===k});w&&x(w)},onAddTag:function(){}}),g.length===0&&y.jsx("p",{className:"yst-text-sm yst-italic yst-text-gray-500",children:"No brands selected"})]}),y.jsx("p",{children:"Note: To add brands to this group, save this group, then use the checkboxes to select this group as well as any additional brands to be grouped."})]}),y.jsx(P.Modal.Container.Footer,{className:"yst-pt-4",children:y.jsxs("div",{className:"yst-flex yst-justify-end yst-gap-2",children:[y.jsx(P.Button,{variant:"secondary",onClick:S,disabled:b,children:"Cancel"}),y.jsx(P.Button,{variant:"primary",onClick:C,disabled:!u.trim()||g.length===0||b,children:b?"Saving...":"Save group"})]})})]})})})};function pa(e){"@babel/helpers - typeof";return pa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pa(e)}function Em(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Am(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Em(Object(n),!0).forEach(function(r){Vb(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Em(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Vb(e,t,n){return(t=bD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bD(e){var t=xD(e,"string");return pa(t)=="symbol"?t:t+""}function xD(e,t){if(pa(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(pa(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wD(e){return _D(e)||CD(e)||Kb(e)||SD()}function SD(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1285
1285
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function CD(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _D(e){if(Array.isArray(e))return sf(e)}function Bn(e,t){return ED(e)||OD(e,t)||Kb(e,t)||kD()}function kD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1286
1286
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kb(e,t){if(e){if(typeof e=="string")return sf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sf(e,t):void 0}}function sf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function OD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function ED(e){if(Array.isArray(e))return e}var AD=function(){var t,n=dn(),r=z.useState(!1),i=Bn(r,2),s=i[0],o=i[1],a=z.useState({}),l=Bn(a,2),c=l[0],u=l[1],d=z.useState(""),f=Bn(d,2),h=f[0],g=f[1],m=z.useState(1),p=Bn(m,2),v=p[0],b=p[1],S=z.useState({}),C=Bn(S,2),x=C[0],k=C[1],w=z.useState(!1),_=Bn(w,2),O=_[0],A=_[1],M=z.useState(!1),j=Bn(M,2),q=j[0],R=j[1],E=z.useState(null),$=Bn(E,2),I=$[0],K=$[1],Y=Zn(),N=Y.brandId;function W(ge){return String(ge.id)}var ie=N5(N,{query:{enabled:!!N}}),se=ie.data,F=ie.isLoading,ae=10,ne=(se==null||(t=se.data)===null||t===void 0?void 0:t.associatedBrands.filter(function(ge){var me,fe;return h?((me=(fe=ge.name)===null||fe===void 0?void 0:fe.toLowerCase())!==null&&me!==void 0?me:"").includes(h.toLowerCase()):!0}))||[],xe=Math.ceil(ne.length/ae),ee=(v-1)*ae,Se=wD(ne).sort(function(ge,me){return ge.type==="group"&&me.type!=="group"?-1:ge.type!=="group"&&me.type==="group"?1:0}),re=Se.slice(ee,ee+ae),de=function(me){var fe=ne.find(function(Be){return W(Be)===me});fe&&fe.type==="group"?(K(fe),R(!0)):console.log("Individual brand edit not implemented yet")},H=Object.entries(x).filter(function(ge){var me=Bn(ge,2),fe=me[1];return fe}).map(function(ge){var me=Bn(ge,1),fe=me[0];return fe}),he=function(){console.log("Group brands:",H),A(!0)},je=function(me){g(me.target.value),b(1)},tt=function(me){k(function(fe){return Am(Am({},fe),{},Vb({},me,!fe[me]))})},De=function(){n("/")},Fe=function(){k({}),u({}),o(!1)},X=function(){A(!1)},Me=function(){k({}),b(1),g("")},rt=function(){R(!1),K(null)},Ne=function(me,fe){return me in c?!!c[me]:!fe.isHidden},Le=[{Header:"Brand name",accessor:"name",Cell:function(me){var fe=me.value,Be=me.row;return y.jsx("span",{className:"yst-font-medium yst-text-slate-900",children:y.jsxs("div",{className:"yst-flex yst-items-center yst-gap-2",children:[y.jsx(P.Checkbox,{id:"brand-checkbox-".concat(Be.id),checked:!!x[W(Be)],onChange:function(){return tt(W(Be))},value:W(Be),label:Be.isSelf?y.jsx(Lc,{children:fe}):fe,name:"brand-checkbox-".concat(Be.id),disabled:!Ne(W(Be),Be)}),Be.type==="group"&&y.jsx(L6,{className:"yst-h-4 yst-w-4 yst-text-slate-400"})]})})},LoadingComponent:function(me){var fe=me.id,Be=fe===void 0?"":fe;return y.jsxs("div",{className:"yst-flex",children:[y.jsx(P.Checkbox,{id:"loading-row-checkbox-".concat(Be),value:"loading",label:"",disabled:!0,name:"brand-checkbox-".concat(Be)})," ",y.jsx(P.SkeletonLoader,{className:"yst-h-6 yst-w-32",id:"loading-row-skeleton-".concat(Be)})]})}},{Header:"Actions",accessor:"id",Cell:function(me){var fe=me.value,Be=me.row;return y.jsx(y.Fragment,{children:Be.type==="group"?y.jsxs(P.Button,{variant:"tertiary",size:"small",onClick:function(){return de(String(fe!=null?fe:""))},className:"yst-gap-1.5 yst-px-0",disabled:!Ne(W(Be),Be),children:[y.jsx(ev,{className:"yst-h-4 yst-w-4"}),"Edit group"]}):void 0})},LoadingComponent:function(){return y.jsx(P.SkeletonLoader,{className:"yst-h-6 yst-w-24"})}}];return y.jsxs(P.Paper,{className:"yst-mx-auto yst-max-w-2xl",children:[y.jsx(Ub,{title:"Brand list ".concat(""),children:y.jsx("p",{children:"These are the brands found in responses to your example prompts. Group related brands to improve your analysis. You can rename or exclude irrelevant brands, and new brands will be added automatically if they appear in future analysis runs."})}),y.jsxs(P.Paper.Content,{children:[y.jsx("div",{className:"yst-mb-6",children:y.jsx(P.TextInput,{id:"brand-search",label:"Search brands",placeholder:"Search brands",value:h,onChange:je})}),y.jsx("div",{className:"yst-mb-6",children:y.jsxs(P.Table,{columns:Le,className:"yst-w-full",variant:"minimal",children:[y.jsx(P.Table.Head,{children:y.jsx(P.Table.Row,{children:Le.map(function(ge){return y.jsx(P.Table.Header,{children:ge.Header},ge.accessor)})})}),y.jsx(P.Table.Body,{children:F?[1,2,3].map(function(ge,me){return y.jsx(P.Table.Row,{children:Le.map(function(fe,Be){return y.jsx(P.Table.Cell,{children:y.jsx(fe.LoadingComponent,{id:"skeleton-".concat(me,"-").concat(Be)},fe.accessor)},"cell-".concat(Be))})},me)}):re.length===0?y.jsx(P.Table.Row,{children:y.jsx(P.Table.Cell,{colSpan:Le.length,children:y.jsxs("div",{className:"yst-py-12 yst-text-center",children:[y.jsx("h3",{className:"yst-mt-4 yst-text-lg yst-font-medium yst-text-slate-900",children:"No brands found"}),y.jsx("p",{className:"yst-mt-2 yst-text-sm yst-text-slate-500",children:h?'No brands match "'.concat(h,'". Try a different search term.'):"No brands have been found yet. Run an analysis to discover brands."}),h&&y.jsx(P.Button,{variant:"secondary",size:"small",onClick:function(){g(""),b(1)},className:"yst-mt-4",children:"Clear search"})]})})}):re.map(function(ge){return y.jsx(P.Table.Row,{children:Le.map(function(me){return y.jsx(P.Table.Cell,{children:me.Cell?me.Cell({value:ge[me.accessor],row:ge}):ge[me.accessor]},me.accessor)})},ge.id)})})]})}),y.jsxs("div",{className:"yst-flex yst-items-center yst-justify-between",children:[y.jsxs(P.Button,{variant:"secondary",onClick:he,className:"yst-mb-0 yst-gap-2",disabled:H.length<2,children:[y.jsx(WC,{})," Group brands"]}),y.jsx(P.Pagination,{variant:"text",current:v,total:xe,onNavigate:b,className:"yst-flex-row",screenReaderTextPrevious:"Previous page",screenReaderTextNext:"Next page"})]})]}),y.jsx(Ef,{children:y.jsx("div",{className:"yst-flex yst-items-center yst-justify-end yst-gap-4",children:s?y.jsxs(y.Fragment,{children:[y.jsx(P.Button,{variant:"secondary",className:"yst-mb-0",onClick:Fe,children:"Discard changes"}),y.jsx(P.Button,{variant:"primary",className:"yst-mb-0",onClick:De,children:"Save changes"})]}):y.jsx(P.Button,{as:Zr,to:"/brands/".concat(N),variant:"tertiary",className:"yst-mb-0",children:"Return to analysis"})})}),y.jsx(vD,{isOpen:O,onClose:X,brandId:N,brandsToGroup:ne.filter(function(ge){return H.includes(W(ge))}),onGroupCreated:Me}),y.jsx(hD,{isOpen:q,onClose:rt,groupToEdit:I,allBrands:ne})]})};const PD=Object.freeze(Object.defineProperty({__proto__:null,default:AD},Symbol.toStringTag,{value:"Module"}));function TD(e,t){return DD(e)||$D(e,t)||MD(e,t)||jD()}function jD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1287
1287
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MD(e,t){if(e){if(typeof e=="string")return Pm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pm(e,t):void 0}}function Pm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $D(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function DD(e){if(Array.isArray(e))return e}var LD=function(t){var n=t.isOpen,r=t.onClose,i=Vt(),s=z.useState(""),o=TD(s,2),a=o[0],l=o[1],c=gC({mutation:{onSuccess:function(){i.clear(),r()}}}),u=c.mutate,d=c.isPending;return z.useEffect(function(){n&&l("")},[n]),y.jsx(Ic,{isOpen:n,onClose:r,onConfirm:function(){u()},isLoading:d,disabled:a!=="DELETE ALL",title:"Delete all data?",description:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"This will permanently erase all brands, analysis results, and queries from your account."}),y.jsx("p",{children:"This action cannot be undone."}),y.jsx(P.TextField,{id:"delete-all-confirmation",label:"To confirm, please type DELETE ALL:",value:a,onChange:function(f){return l(f.target.value)}}),y.jsx("p",{children:y.jsx("em",{children:"This is to make sure you understand this action is permanent."})})]}),confirmText:"Yes, delete all data",cancelText:"No, go back"})};function of(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return Jt(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(Jt(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,Jt(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,Jt(d,"constructor",c),Jt(c,"constructor",l),l.displayName="GeneratorFunction",Jt(c,i,"GeneratorFunction"),Jt(d),Jt(d,i,"Generator"),Jt(d,r,function(){return this}),Jt(d,"toString",function(){return"[object Generator]"}),(of=function(){return{w:s,m:f}})()}function Jt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}Jt=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){Jt(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},Jt(e,t,n,r)}function Tm(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function ID(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Tm(s,r,i,o,a,"next",l)}function a(l){Tm(s,r,i,o,a,"throw",l)}o(void 0)})}}function RD(e,t){return qD(e)||BD(e,t)||ND(e,t)||FD()}function FD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1288
1288
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ND(e,t){if(e){if(typeof e=="string")return jm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jm(e,t):void 0}}function jm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function BD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function qD(e){if(Array.isArray(e))return e}var zD=function(t){var n=t.isOpen,r=t.brandId,i=t.onClose,s=t.brandName,o=Vt(),a=z.useState(""),l=RD(a,2),c=l[0],u=l[1],d=eC({mutation:{onSuccess:function(){var g=ID(of().m(function p(){return of().w(function(v){for(;;)switch(v.n){case 0:return v.n=1,Promise.all([o.invalidateQueries({queryKey:Gn()}),o.invalidateQueries({queryKey:Mc()})]);case 1:console.log("Brand data deleted"),i();case 2:return v.a(2)}},p)}));function m(){return g.apply(this,arguments)}return m}()}}),f=d.mutate,h=d.isPending;return z.useEffect(function(){n&&u("")},[n]),y.jsx(Ic,{isOpen:n,onClose:i,onConfirm:function(){if(!s){console.error("Brand name is required for deletion confirmation");return}f({brandId:r})},isLoading:h,disabled:c.toLowerCase()!==(s==null?void 0:s.toLowerCase()),title:"Delete brand?",description:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"This will permanently delete all data associated with this brand, including past analyses and query history."}),y.jsx("p",{children:"This action cannot be undone."}),y.jsx(P.TextField,{id:"delete-modal-brand-name-confirmation",label:"To confirm, please type your brand name ".concat(s,":"),value:c,onChange:function(g){return u(g.target.value)}}),y.jsx("p",{children:y.jsx("em",{children:"This is to make sure you understand this action is permanent."})})]}),confirmText:"Yes, delete brand",cancelText:"No, go back"})};function va(e){"@babel/helpers - typeof";return va=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},va(e)}function Ro(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return en(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(en(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,en(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,en(d,"constructor",c),en(c,"constructor",l),l.displayName="GeneratorFunction",en(c,i,"GeneratorFunction"),en(d),en(d,i,"Generator"),en(d,r,function(){return this}),en(d,"toString",function(){return"[object Generator]"}),(Ro=function(){return{w:s,m:f}})()}function en(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}en=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){en(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},en(e,t,n,r)}function Mm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function kr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Mm(Object(n),!0).forEach(function(r){HD(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function HD(e,t,n){return(t=UD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UD(e){var t=VD(e,"string");return va(t)=="symbol"?t:t+""}function VD(e,t){if(va(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(va(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function $m(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function Dm(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){$m(s,r,i,o,a,"next",l)}function a(l){$m(s,r,i,o,a,"throw",l)}o(void 0)})}}function KD(e,t){return YD(e)||QD(e,t)||WD(e,t)||GD()}function GD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1289
1289
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WD(e,t){if(e){if(typeof e=="string")return Lm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Lm(e,t):void 0}}function Lm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QD(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function YD(e){if(Array.isArray(e))return e}var XD=function(t){var n,r,i=t.brand,s=t.isLast,o=t.onDelete,a=i.id,l=Zn(),c=l.hostAppProps,u=c.onAddSubscription,d=dn(),f=Fa(),h=f.setBrandId,g=z.useState(!1),m=KD(g,2),p=m[0],v=m[1],b=Vt(),S=$c({query:{select:function(q){var R=q.data;return R}}}),C=S.data,x=X2({mutation:{onMutate:function(){var j=Dm(Ro().m(function R(E){var $,I,K;return Ro().w(function(Y){for(;;)switch(Y.n){case 0:return $=E.brandId,I=E.data,Y.n=1,b.cancelQueries({queryKey:Gn()});case 1:return K=b.getQueryData(Gn()),b.setQueryData(Gn(),function(N){var W,ie;return N&&kr(kr({},N),{},{data:kr(kr({},N.data),{},{brands:((W=(ie=N.data)===null||ie===void 0?void 0:ie.brands)!==null&&W!==void 0?W:[]).map(function(se){return se.id===$?kr(kr({},se),{},{settings:kr(kr({},se.settings),{},{enableAutomaticAnalysis:I.enableAutomaticAnalysis})}):se})})})}),Y.a(2,{previous:K})}},R)}));function q(R){return j.apply(this,arguments)}return q}(),onSuccess:function(){if(i&&i.settings&&i.settings.enableAutomaticAnalysis===!1)return v(!1);v(!M)},onError:function(q,R,E){E!=null&&E.previous&&b.setQueryData(Gn(),E.previous)},onSettled:function(){var j=Dm(Ro().m(function R(){return Ro().w(function(E){for(;;)switch(E.n){case 0:return E.n=1,Promise.all([b.invalidateQueries({queryKey:Gn()}),b.invalidateQueries({queryKey:Mc()})]);case 1:return E.a(2)}},R)}));function q(){return j.apply(this,arguments)}return q}()}}),k=x.mutate,w=x.isPending,_=function(q){k({brandId:a,data:{enableAutomaticAnalysis:q}})},O=function(q){if(q){if(!A)return v(!0);if(!M)return _(!0);v(!0)}else _(!1)},A=Number(C==null?void 0:C.maxNumberOfActiveBrands)-Number(C==null?void 0:C.numberOfActiveBrands)>0||!!(i!=null&&(n=i.settings)!==null&&n!==void 0&&n.enableAutomaticAnalysis),M=mv(i==null?void 0:i.firstNextAnalysisOpportunity);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:ke("yst-flex yst-max-w-2xl yst-flex-1 yst-flex-row yst-items-center yst-justify-start yst-gap-4 yst-py-4 yst-text-slate-800",{"yst-border-b-[1px] yst-border-b-slate-200":!s}),children:[y.jsx(P.Toggle,{id:"toggle-brand-".concat(i==null?void 0:i.id),checked:i==null||(r=i.settings)===null||r===void 0?void 0:r.enableAutomaticAnalysis,screenReaderLabel:"Enable or disable automatic analysis for this brand",onChange:O,disabled:(i==null?void 0:i.id)==="loading"||w}),y.jsxs("div",{className:"yst-font-medium",children:[(i==null?void 0:i.id)==="loading"?y.jsx(P.SkeletonLoader,{className:"yst-h-6 yst-w-32"}):i==null?void 0:i.name,(i==null?void 0:i.setupStatus)==="pendingQuerySelection"&&y.jsx("div",{children:y.jsx(P.Link,{onClick:function(){i.id?(h(i.id),d("/setup/".concat(i.id,"/queries"))):console.error("Brand ID is missing.")},children:"Finish setup"})}),(i==null?void 0:i.nextScheduledAnalysis)&&y.jsxs("div",{className:"yst-italic yst-font-normal yst-text-slate-500",children:["Next analysis:"," ",jd(i.nextScheduledAnalysis)]})]}),y.jsx("div",{className:"yst-ml-auto yst-flex yst-flex-row yst-items-center yst-justify-end yst-gap-2 yst-text-slate-800",children:(i==null?void 0:i.id)==="loading"?y.jsx(P.SkeletonLoader,{className:"yst-h-6 yst-w-24"}):y.jsxs(P.Button,{size:"small",variant:"tertiary",className:"yst-gap-1 yst-text-red-600 *:hover:yst-text-red-700",onClick:function(){i!=null&&i.id&&o(i.id)},disabled:(i==null?void 0:i.id)==="loading",children:[y.jsx(Of,{})," Delete brand"]})})]}),y.jsx(P.Modal,{isOpen:p,onClose:function(){return v(!1)},position:"center",as:"div",className:ke({"yst-mx-auto yst-max-w-xl":A}),children:A?y.jsx(P.Modal.Panel,{children:M?y.jsxs(y.Fragment,{children:[y.jsx(P.Modal.Container.Header,{className:"yst-mb-3 yst-w-full",children:y.jsx(P.Modal.Title,{as:"h3",className:"yst-text-lg yst-font-medium",children:"Start brand analysis now?"})}),y.jsxs(P.Modal.Container.Content,{className:"yst-mb-4 yst-space-y-3",children:[y.jsx("p",{children:"Activating this brand will immediately start a new analysis."}),y.jsx("p",{children:"This will use one of your weekly analyses included in your subscription."})]}),y.jsxs(P.Modal.Container.Footer,{className:"yst-mt-3 yst-flex yst-justify-end yst-gap-2",children:[y.jsx(P.Button,{variant:"secondary",onClick:function(){return v(!1)},children:"Cancel"}),y.jsx(P.Button,{variant:"primary",onClick:function(){_(!0)},isLoading:w,children:"Yes, start analysis"})]})]}):y.jsxs(y.Fragment,{children:[y.jsx(P.Modal.Container.Header,{className:"yst-mb-3 yst-w-full",children:y.jsx(P.Modal.Title,{as:"h3",className:"yst-text-lg yst-font-medium",children:"Automatic analysis enabled"})}),y.jsxs(P.Modal.Container.Content,{className:"yst-mb-4 yst-space-y-3",children:[y.jsx("p",{children:"You've turned on the weekly automatic analysis for this brand."}),y.jsxs("p",{children:["The next analysis will run on"," ",y.jsx("span",{className:"yst-font-medium",children:jd(i==null?void 0:i.nextScheduledAnalysis)||"the next analysis cycle"}),"."]})]}),y.jsx(P.Modal.Container.Footer,{className:"yst-mt-3 yst-flex yst-justify-end yst-gap-2",children:y.jsx(P.Button,{variant:"primary",onClick:function(){return v(!1)},children:"Got it"})})]})}):y.jsxs(P.Modal.Panel,{children:[y.jsx("div",{className:"yst-flex yst-items-start yst-justify-stretch yst-gap-4",children:y.jsxs("div",{className:"yst-flex-1",children:[y.jsx(P.Modal.Container.Header,{className:"yst-mb-3 yst-w-full",children:y.jsx(P.Modal.Title,{as:"h3",className:"yst-text-center yst-text-lg yst-font-medium",children:"You've reached your active brand limit"})}),y.jsx(P.Modal.Container.Content,{children:y.jsx("p",{className:"yst-text-center",children:"Each subscription lets you activate 1 brand. Add another subscription or deactivate an existing brand to activate this brand."})})]})}),y.jsx(P.Modal.Container.Footer,{children:y.jsxs("div",{className:"yst-flex yst-flex-col yst-justify-stretch yst-gap-2",children:[u&&y.jsxs(P.Button,{variant:"upsell",className:"yst-flex yst-gap-1",onClick:u,children:[y.jsx(tv,{}),"Add a subscription"]}),y.jsx(P.Button,{variant:"tertiary",className:"",onClick:function(){return v(!1)},children:"Manage active brands"})]})})]})})]})},Im,Rm,Fm;function Vu(e,t){return tL(e)||eL(e,t)||JD(e,t)||ZD()}function ZD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1290
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function JD(e,t){if(e){if(typeof e=="string")return Nm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nm(e,t):void 0}}function Nm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eL(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function tL(e){if(Array.isArray(e))return e}function yh(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Bm=qa(Im||(Im=yh(["xl:yst-w-1/3"]))),qm=qa(Rm||(Rm=yh(["xl:yst-w-2/3"]))),zm=qa(Fm||(Fm=yh(["yst-flex yst-flex-col yst-gap-8 xl:yst-flex-row"]))),nL=function(){var t,n,r,i,s=z.useState(!1),o=Vu(s,2),a=o[0],l=o[1],c=z.useState(!1),u=Vu(c,2),d=u[0],f=u[1],h=z.useState(null),g=Vu(h,2),m=g[0],p=g[1],v=$c({query:{select:function(w){var _=w.data;return _}}}),b=v.data,S=zi({query:{select:function(w){var _=w.data;return _==null?void 0:_.brands}}}),C=S.data,x=C==null?void 0:C.find(function(k){return k.id===m});return y.jsxs("form",{children:[y.jsxs(P.Card,{children:[y.jsx(c1,{title:"Settings",description:"Manage your brand settings and data. You can update analysis preferences or delete brands from your account."}),y.jsxs(P.Card.Content,{children:[y.jsxs(zm,{children:[y.jsxs(Bm,{className:"yst-space-y-2",children:[y.jsx(P.Title,{size:"4",children:"Brands"}),y.jsxs("p",{children:["You have"," ",y.jsxs("b",{children:[(t=b==null?void 0:b.activeSubscriptions)!==null&&t!==void 0?t:"—"," active subscriptions"]}),". This gives you up to"," ",y.jsxs("b",{children:[(n=b==null?void 0:b.maxNumberOfActiveBrands)!==null&&n!==void 0?n:"—"," active brands"]}),", for which we’ll automatically run a weekly analysis."]}),y.jsx("p",{children:"You can activate or deactivate brands anytime, or permanently delete a brand and all its data."})]}),y.jsxs(qm,{children:[C&&y.jsxs("p",{className:"yst-flex yst-w-full yst-max-w-2xl yst-flex-1 yst-flex-row yst-items-center yst-justify-start yst-gap-2 yst-border-b-[1px] yst-border-b-slate-200 yst-py-4 yst-font-medium yst-text-slate-800",children:["Active brands: ",(r=b==null?void 0:b.numberOfActiveBrands)!==null&&r!==void 0?r:"—"," of"," ",(i=b==null?void 0:b.maxNumberOfActiveBrands)!==null&&i!==void 0?i:"—"]}),C&&C.length===0&&y.jsxs("p",{className:"yst-mt-4 yst-text-slate-500",children:["No brands found. Please"," ",y.jsx(P.Link,{as:Zr,to:"/setup",children:"add a brand"})," ","to start analyzing."]}),(C!=null?C:[{id:"loading",name:"Loading..."}]).map(function(k,w,_){return y.jsx(XD,{brand:k,isLast:w===_.length-1,onDelete:function(O){p(O),l(!0)}},k.id)})]})]}),y.jsx(za,{}),y.jsxs(zm,{children:[y.jsxs(Bm,{className:"yst-space-y-2",children:[y.jsx(P.Title,{size:"4",children:"Delete all data"}),y.jsx("p",{children:"Permanently delete all brands, analysis results, and query history from your account."})]}),y.jsxs(qm,{className:"yst-space-y-4",children:[y.jsxs(P.Button,{variant:"error",onClick:function(){f(!0)},disabled:(C==null?void 0:C.length)===0,children:[y.jsx(Of,{})," Delete all data"]}),y.jsx("p",{children:y.jsxs("i",{children:[y.jsx("b",{children:"Note:"})," This will erase everything and cannot be reversed."]})})]})]})]})]}),y.jsx(zD,{isOpen:a,onClose:function(){l(!1),p(null)},brandId:m||"",brandName:x==null?void 0:x.name}),y.jsx(LD,{isOpen:d,onClose:function(){f(!1)}})]})};const rL=Object.freeze(Object.defineProperty({__proto__:null,default:nL},Symbol.toStringTag,{value:"Module"}));function yc(e){"@babel/helpers - typeof";return yc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yc(e)}var af=[{path:"/setup",id:1,title:"Brand & location info",description:"Enter a few basic details about your brand so we can generate relevant queries people might use in AI models like ChatGPT. This helps us analyze how visible your brand is in their responses."},{path:"/setup/:brandId/queries",id:2,title:"Queries",description:"Review the queries we've generated from your brand info. These are phrases people might type into AI models that could trigger your brand to appear."},{path:"/setup/:brandId/analysis",id:3,title:"Analysis",description:"We're checking how your brand shows up in AI. Your queries will now be tested in ChatGPT. This process should take around 5 minutes."}],iL=function(t){return af.find(function(n){return!!Fs(n.path,t)})||af[0]};function sL(){var e=Ut(),t=iL(e.pathname);return y.jsxs(P.Paper,{className:"yst-mx-auto yst-max-w-2xl",children:[y.jsx(Ub,{title:y.jsx(Gb,{currentStep:t,steps:af}),description:t.description}),y.jsx(P.Paper.Content,{children:y.jsx(Ns,{})})]})}var Gb=function(t){var n=t.title,r=t.currentStep,i=t.steps;return y.jsxs("span",{className:"yst-inline-flex yst-flex-row yst-gap-4",children:[y.jsxs("span",{className:"yst-tracking-[.2em] yst-text-slate-400",children:[y.jsx("span",{className:"yst-text-slate-900",children:yc(r)==="object"?r.id:r}),"/",Array.isArray(i)?i.length:i]}),y.jsx("span",{children:yc(r)==="object"?r.title:n||"Step ".concat(r)})]})};const oL=Object.freeze(Object.defineProperty({__proto__:null,SetupPaperTitle:Gb,default:sL},Symbol.toStringTag,{value:"Module"}));var Wb=function(t){var n=t.onBack,r=t.variant,i=r===void 0?"ai":r,s=t.buttonText,o=t.onButtonClick,a=t.isButtonDisabled,l=a===void 0?!1:a,c=t.isLoading,u=c===void 0?!1:c;return y.jsx(Ef,{nestedInPaperContent:!0,children:y.jsxs("div",{className:ke({"yst-flex yst-flex-1 yst-flex-col yst-items-start yst-justify-between yst-gap-4 md:yst-flex-row md:yst-items-center md:yst-justify-between":n}),children:[n&&y.jsx(P.Button,{variant:"tertiary",onClick:n,className:"yst-no-underline",children:"← Back"}),y.jsx("div",{className:ke("yst-flex yst-flex-col yst-items-stretch yst-gap-4 md:yst-flex-row md:yst-items-center md:yst-justify-end"),children:y.jsxs(P.Button,{onClick:o,variant:i==="ai"?"primary":i,className:"yst-gap-1.5",style:i==="ai"?{background:"linear-gradient(102deg, #A61E69 0%, #6366F1 100%)",color:"#fff"}:{},disabled:l,type:"submit",isLoading:u,children:[i==="ai"&&y.jsx(YC,{}),s]})})]})})},aL=[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"CA",label:"Canada"},{value:"AU",label:"Australia"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"NL",label:"Netherlands"}],lL=[{value:"AR",label:"Argentina"},{value:"BE",label:"Belgium"},{value:"BR",label:"Brazil"},{value:"CN",label:"China"},{value:"EG",label:"Egypt"},{value:"ID",label:"Indonesia"},{value:"IE",label:"Ireland"},{value:"IL",label:"Israel"},{value:"IN",label:"India"},{value:"IT",label:"Italy"},{value:"JP",label:"Japan"},{value:"KR",label:"South Korea"},{value:"MX",label:"Mexico"},{value:"NG",label:"Nigeria"},{value:"PL",label:"Poland"},{value:"RU",label:"Russia"},{value:"SA",label:"Saudi Arabia"},{value:"SE",label:"Sweden"},{value:"ES",label:"Spain"},{value:"TH",label:"Thailand"},{value:"TR",label:"Turkey"},{value:"TW",label:"Taiwan"},{value:"ZA",label:"South Africa"}],Hm=[].concat(aL,lL,[{value:"OTHER",label:"Other"}]),cL=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"zh",label:"Chinese (Mandarin)"},{value:"ja",label:"Japanese"}],uL=[{value:"ar",label:"Arabic"},{value:"da",label:"Danish"},{value:"nl",label:"Dutch"},{value:"fi",label:"Finnish"},{value:"hi",label:"Hindi"},{value:"it",label:"Italian"},{value:"ko",label:"Korean"},{value:"no",label:"Norwegian"},{value:"pl",label:"Polish"},{value:"pt",label:"Portuguese"},{value:"ru",label:"Russian"},{value:"sv",label:"Swedish"},{value:"th",label:"Thai"},{value:"tr",label:"Turkish"}],dL=[].concat(cL,uL);function Kr(e){"@babel/helpers - typeof";return Kr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kr(e)}function Um(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Vm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Um(Object(n),!0).forEach(function(r){Qb(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Um(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Qb(e,t,n){return(t=fL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fL(e){var t=hL(e,"string");return Kr(t)=="symbol"?t:t+""}function hL(e,t){if(Kr(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Kr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function lf(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return tn(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(tn(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,tn(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,tn(d,"constructor",c),tn(c,"constructor",l),l.displayName="GeneratorFunction",tn(c,i,"GeneratorFunction"),tn(d),tn(d,i,"Generator"),tn(d,r,function(){return this}),tn(d,"toString",function(){return"[object Generator]"}),(lf=function(){return{w:s,m:f}})()}function tn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}tn=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){tn(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},tn(e,t,n,r)}function Km(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function gL(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Km(s,r,i,o,a,"next",l)}function a(l){Km(s,r,i,o,a,"throw",l)}o(void 0)})}}function Oo(e,t){return vL(e)||pL(e,t)||mL(e,t)||yL()}function yL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1290
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function JD(e,t){if(e){if(typeof e=="string")return Nm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nm(e,t):void 0}}function Nm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eL(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function tL(e){if(Array.isArray(e))return e}function yh(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Bm=qa(Im||(Im=yh(["xl:yst-w-1/3"]))),qm=qa(Rm||(Rm=yh(["xl:yst-w-2/3"]))),zm=qa(Fm||(Fm=yh(["yst-flex yst-flex-col yst-gap-8 xl:yst-flex-row"]))),nL=function(){var t,n,r,i,s=z.useState(!1),o=Vu(s,2),a=o[0],l=o[1],c=z.useState(!1),u=Vu(c,2),d=u[0],f=u[1],h=z.useState(null),g=Vu(h,2),m=g[0],p=g[1],v=$c({query:{select:function(w){var _=w.data;return _}}}),b=v.data,S=zi({query:{select:function(w){var _=w.data;return _==null?void 0:_.brands}}}),C=S.data,x=C==null?void 0:C.find(function(k){return k.id===m});return y.jsxs("form",{children:[y.jsxs(P.Card,{children:[y.jsx(c1,{title:"Settings",description:"Manage your brand settings and data. You can update analysis preferences or delete brands from your account."}),y.jsxs(P.Card.Content,{children:[y.jsxs(zm,{children:[y.jsxs(Bm,{className:"yst-space-y-2",children:[y.jsx(P.Title,{size:"4",children:"Brands"}),y.jsxs("p",{children:["You have"," ",y.jsxs("b",{children:[(t=b==null?void 0:b.activeSubscriptions)!==null&&t!==void 0?t:"—"," subscriptions"]}),". This gives you up to"," ",y.jsxs("b",{children:[(n=b==null?void 0:b.maxNumberOfActiveBrands)!==null&&n!==void 0?n:"—"," active brand(s)"]}),", for which we’ll automatically run a weekly analysis."]}),y.jsx("p",{children:"You can activate or deactivate brands anytime, or permanently delete a brand and all its data."})]}),y.jsxs(qm,{children:[C&&y.jsxs("p",{className:"yst-flex yst-w-full yst-max-w-2xl yst-flex-1 yst-flex-row yst-items-center yst-justify-start yst-gap-2 yst-border-b-[1px] yst-border-b-slate-200 yst-py-4 yst-font-medium yst-text-slate-800",children:["Active brands: ",(r=b==null?void 0:b.numberOfActiveBrands)!==null&&r!==void 0?r:"—"," of"," ",(i=b==null?void 0:b.maxNumberOfActiveBrands)!==null&&i!==void 0?i:"—"]}),C&&C.length===0&&y.jsxs("p",{className:"yst-mt-4 yst-text-slate-500",children:["No brands found. Please"," ",y.jsx(P.Link,{as:Zr,to:"/setup",children:"add a brand"})," ","to start analyzing."]}),(C!=null?C:[{id:"loading",name:"Loading..."}]).map(function(k,w,_){return y.jsx(XD,{brand:k,isLast:w===_.length-1,onDelete:function(O){p(O),l(!0)}},k.id)})]})]}),y.jsx(za,{}),y.jsxs(zm,{children:[y.jsxs(Bm,{className:"yst-space-y-2",children:[y.jsx(P.Title,{size:"4",children:"Delete all data"}),y.jsx("p",{children:"Permanently delete all brands, analysis results, and query history from your account."})]}),y.jsxs(qm,{className:"yst-space-y-4",children:[y.jsxs(P.Button,{variant:"error",onClick:function(){f(!0)},disabled:(C==null?void 0:C.length)===0,children:[y.jsx(Of,{})," Delete all data"]}),y.jsx("p",{children:y.jsxs("i",{children:[y.jsx("b",{children:"Note:"})," This will erase everything and cannot be reversed."]})})]})]})]})]}),y.jsx(zD,{isOpen:a,onClose:function(){l(!1),p(null)},brandId:m||"",brandName:x==null?void 0:x.name}),y.jsx(LD,{isOpen:d,onClose:function(){f(!1)}})]})};const rL=Object.freeze(Object.defineProperty({__proto__:null,default:nL},Symbol.toStringTag,{value:"Module"}));function yc(e){"@babel/helpers - typeof";return yc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yc(e)}var af=[{path:"/setup",id:1,title:"Brand & location info",description:"Enter a few basic details about your brand so we can generate relevant queries people might use in AI models like ChatGPT. This helps us analyze how visible your brand is in their responses."},{path:"/setup/:brandId/queries",id:2,title:"Queries",description:"Review the queries we've generated from your brand info. These are phrases people might type into AI models that could trigger your brand to appear."},{path:"/setup/:brandId/analysis",id:3,title:"Analysis",description:"We're checking how your brand shows up in AI. Your queries will now be tested in ChatGPT. This process should take around 5 minutes."}],iL=function(t){return af.find(function(n){return!!Fs(n.path,t)})||af[0]};function sL(){var e=Ut(),t=iL(e.pathname);return y.jsxs(P.Paper,{className:"yst-mx-auto yst-max-w-2xl",children:[y.jsx(Ub,{title:y.jsx(Gb,{currentStep:t,steps:af}),description:t.description}),y.jsx(P.Paper.Content,{children:y.jsx(Ns,{})})]})}var Gb=function(t){var n=t.title,r=t.currentStep,i=t.steps;return y.jsxs("span",{className:"yst-inline-flex yst-flex-row yst-gap-4",children:[y.jsxs("span",{className:"yst-tracking-[.2em] yst-text-slate-400",children:[y.jsx("span",{className:"yst-text-slate-900",children:yc(r)==="object"?r.id:r}),"/",Array.isArray(i)?i.length:i]}),y.jsx("span",{children:yc(r)==="object"?r.title:n||"Step ".concat(r)})]})};const oL=Object.freeze(Object.defineProperty({__proto__:null,SetupPaperTitle:Gb,default:sL},Symbol.toStringTag,{value:"Module"}));var Wb=function(t){var n=t.onBack,r=t.variant,i=r===void 0?"ai":r,s=t.buttonText,o=t.onButtonClick,a=t.isButtonDisabled,l=a===void 0?!1:a,c=t.isLoading,u=c===void 0?!1:c;return y.jsx(Ef,{nestedInPaperContent:!0,children:y.jsxs("div",{className:ke({"yst-flex yst-flex-1 yst-flex-col yst-items-start yst-justify-between yst-gap-4 md:yst-flex-row md:yst-items-center md:yst-justify-between":n}),children:[n&&y.jsx(P.Button,{variant:"tertiary",onClick:n,className:"yst-no-underline",children:"← Back"}),y.jsx("div",{className:ke("yst-flex yst-flex-col yst-items-stretch yst-gap-4 md:yst-flex-row md:yst-items-center md:yst-justify-end"),children:y.jsxs(P.Button,{onClick:o,variant:i==="ai"?"primary":i,className:"yst-gap-1.5",style:i==="ai"?{background:"linear-gradient(102deg, #A61E69 0%, #6366F1 100%)",color:"#fff"}:{},disabled:l,type:"submit",isLoading:u,children:[i==="ai"&&y.jsx(YC,{}),s]})})]})})},aL=[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"CA",label:"Canada"},{value:"AU",label:"Australia"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"NL",label:"Netherlands"}],lL=[{value:"AR",label:"Argentina"},{value:"BE",label:"Belgium"},{value:"BR",label:"Brazil"},{value:"CN",label:"China"},{value:"EG",label:"Egypt"},{value:"ID",label:"Indonesia"},{value:"IE",label:"Ireland"},{value:"IL",label:"Israel"},{value:"IN",label:"India"},{value:"IT",label:"Italy"},{value:"JP",label:"Japan"},{value:"KR",label:"South Korea"},{value:"MX",label:"Mexico"},{value:"NG",label:"Nigeria"},{value:"PL",label:"Poland"},{value:"RU",label:"Russia"},{value:"SA",label:"Saudi Arabia"},{value:"SE",label:"Sweden"},{value:"ES",label:"Spain"},{value:"TH",label:"Thailand"},{value:"TR",label:"Turkey"},{value:"TW",label:"Taiwan"},{value:"ZA",label:"South Africa"}],Hm=[].concat(aL,lL,[{value:"OTHER",label:"Other"}]),cL=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"zh",label:"Chinese (Mandarin)"},{value:"ja",label:"Japanese"}],uL=[{value:"ar",label:"Arabic"},{value:"da",label:"Danish"},{value:"nl",label:"Dutch"},{value:"fi",label:"Finnish"},{value:"hi",label:"Hindi"},{value:"it",label:"Italian"},{value:"ko",label:"Korean"},{value:"no",label:"Norwegian"},{value:"pl",label:"Polish"},{value:"pt",label:"Portuguese"},{value:"ru",label:"Russian"},{value:"sv",label:"Swedish"},{value:"th",label:"Thai"},{value:"tr",label:"Turkish"}],dL=[].concat(cL,uL);function Kr(e){"@babel/helpers - typeof";return Kr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kr(e)}function Um(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Vm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Um(Object(n),!0).forEach(function(r){Qb(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Um(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Qb(e,t,n){return(t=fL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fL(e){var t=hL(e,"string");return Kr(t)=="symbol"?t:t+""}function hL(e,t){if(Kr(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Kr(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function lf(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return tn(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(tn(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,tn(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,tn(d,"constructor",c),tn(c,"constructor",l),l.displayName="GeneratorFunction",tn(c,i,"GeneratorFunction"),tn(d),tn(d,i,"Generator"),tn(d,r,function(){return this}),tn(d,"toString",function(){return"[object Generator]"}),(lf=function(){return{w:s,m:f}})()}function tn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}tn=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){tn(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},tn(e,t,n,r)}function Km(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function gL(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Km(s,r,i,o,a,"next",l)}function a(l){Km(s,r,i,o,a,"throw",l)}o(void 0)})}}function Oo(e,t){return vL(e)||pL(e,t)||mL(e,t)||yL()}function yL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1291
1291
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mL(e,t){if(e){if(typeof e=="string")return Gm(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Gm(e,t):void 0}}function Gm(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function pL(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function vL(e){if(Array.isArray(e))return e}var bL=function(){var t,n=dn(),r=Fa(),i=Vt(),s=z.useState(),o=Oo(s,2),a=o[0],l=o[1],c=z.useState(!1),u=Oo(c,2),d=u[0],f=u[1],h=z.useState({name:"",url:"",description:"",language:"en",isLocal:!1,country:"",region:""}),g=Oo(h,2),m=g[0],p=g[1],v=z.useState(null),b=Oo(v,2),S=b[0],C=b[1],x=Q5({mutation:{onSuccess:function(){var E=gL(lf().m(function I(K){var Y;return lf().w(function(N){for(;;)switch(N.n){case 0:return Y=K.data.id,N.n=1,Promise.all([i.invalidateQueries({queryKey:Mc()}),i.invalidateQueries({queryKey:Gn()})]);case 1:Y&&r.setBrandId(Y),K!=null&&K.status&&K.status>=200&&K.status<300&&Y&&(r.setBrandId(Y),l(Y));case 2:return N.a(2)}},I)}));function $(I){return E.apply(this,arguments)}return $}(),onError:function(){f(!1)}}}),k=x.mutate,w=x.isPending,_=x.error,O=zi({query:{enabled:!!a,select:function($){var I=$.data;return I==null?void 0:I.brands},refetchInterval:function($){var I;return(($==null||(I=$.state)===null||I===void 0||(I=I.data)===null||I===void 0||(I=I.data)===null||I===void 0?void 0:I.brands)||[]).find(function(K){return K.id===a})?!1:2*1e3}}}),A=O.data;z.useEffect(function(){a&&A!==null&&A!==void 0&&A.find(function(E){return E.id===a})&&n("/setup/".concat(a,"/queries"),{replace:!0})},[a,A,n]);var M=function($,I){p(function(K){return Vm(Vm({},K),{},Qb({},$,I))})},j=function($){if($.preventDefault(),C(null),m.description.length>250){C("Your brand description is too long. Please keep it within the 250-character limit."),f(!1);return}f(!0);var I=m.url;I&&!/^https?:\/\//i.test(I)&&(I="https://".concat(I)),k({data:{name:m.name,url:I,description:m.description,focusLanguage:m.language,country:m.country,regionOrCity:m.region}})};function q(E){return Kr(E)==="object"&&E!==null&&"response"in E&&Kr(E.response)==="object"&&E.response!==void 0&&"data"in E.response}var R=q(_)?_.response.data.errors:void 0;return y.jsxs("form",{onSubmit:j,children:[y.jsxs("div",{className:"yst-space-y-6",children:[y.jsx(P.Title,{size:"2",children:"Brand info"}),!!_&&y.jsx(P.Alert,{variant:"error",title:"Error",isVisible:!!_,children:y.jsx("ul",{children:R&&Kr(R)==="object"?Object.entries(R).flatMap(function(E){var $=Oo(E,2),I=$[0],K=$[1];return Array.isArray(K)?K.map(function(Y,N){return y.jsx("li",{children:Y},"".concat(I,"-").concat(N))}):null}):"There was an error creating the brand."})}),S&&y.jsx(P.Alert,{variant:"error",title:"Error",isVisible:!!S,children:y.jsx("ul",{children:y.jsx("li",{children:"Your brand description is too long. Please keep it within the 250-character limit."})})}),y.jsx(P.TextField,{id:"name",label:"Brand name",value:m.name,onChange:function(E){return M("name",E.target.value)}}),y.jsx(P.TextField,{id:"url",label:"Website URL (optional)",placeholder:"Example: https://yourwebsite.com",value:m.url,onChange:function(E){return M("url",E.target.value)}}),y.jsxs("div",{id:"brand-description-textarea",children:[y.jsx(P.TextareaField,{id:"brand-description",label:"Brand description",value:m.description,onChange:function(E){var $=E.target.value;M("description",$)},...m.description.length>250?{validation:{variant:"error",message:"Your brand description is too long. Please keep it within the 250-character limit."}}:{},placeholder:"e.g. We design eco-friendly yoga mats for busy professionals who want sustainable gear that’s durable, stylish and kind to the planet."}),y.jsxs("div",{className:"yst-flex yst-mt-1",children:[y.jsxs("div",{className:"yst-flex-grow yst-flex-col",children:[m.description.length>250&&y.jsx("div",{className:"yst-text-red-500 yst-mb-2",children:"Your brand description is too long. Please keep it within the 250-character limit."}),"Tell us about your brand: what you do, who it’s for and what makes it special."]}),y.jsxs("div",{className:ke("yst-text-xs yst-mt-[-4px] yst-ml-6",{"yst-text-slate-500":m.description.length<=250,"yst-text-red-500":m.description.length>250}),children:[m.description.length,"/250"]})]})]}),y.jsxs("div",{className:"yst-space-y-2",children:[y.jsx(P.Select,{className:"yst-max-w-sm",id:"language-select",label:"Target language",value:m.language,onChange:function(E){return M("language",E)},options:dL.map(function(E){return{label:E.label,value:E.value}})}),y.jsx("p",{children:"The main language your brand uses to communicate or create content."})]})]}),y.jsx(za,{}),y.jsxs("div",{className:"yst-space-y-6",children:[y.jsx(P.Title,{size:"2",children:"Location info"}),y.jsx("p",{children:"Specify a location to enhance the accuracy of the analysis."}),y.jsx(P.Autocomplete,{className:"yst-max-w-sm",id:"country-select",label:"Target country (optional)",value:m.country,nullable:!0,placeholder:"Select...",onChange:function(E){return M("country",E)},onQueryChange:function(){},selectedLabel:((t=Hm.find(function(E){return E.value===m.country}))===null||t===void 0?void 0:t.label)||"",children:Hm.map(function(E){return y.jsx(P.Autocomplete.Option,{value:E.value,children:E.label},E.value)})}),m.country&&y.jsx(P.TextField,{id:"region",label:"Target city, state, or region (optional)",value:m.region,onChange:function(E){return M("region",E.target.value)},description:`Enter a city, state, or region to narrow down the analysis. For
1292
1292
  example: California, Bavaria, or Paris.`})]}),y.jsx(Wb,{onBack:function(){return n(-1)},buttonText:"Generate queries",isButtonDisabled:w||!!a||d,isLoading:w||!!a})]})};const xL=Object.freeze(Object.defineProperty({__proto__:null,default:bL},Symbol.toStringTag,{value:"Module"})),wL=e=>L.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},L.createElement("path",{d:"M3.33284 2V4.66667M1.99951 3.33333H4.66618M3.99951 11.3333V14M2.66618 12.6667H5.33284M8.66618 2L10.19 6.57143L13.9995 8L10.19 9.42857L8.66618 14L7.14237 9.42857L3.33284 8L7.14237 6.57143L8.66618 2Z",stroke:"url(#paint0_linear_3891_2757)",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),L.createElement("defs",null,L.createElement("linearGradient",{id:"paint0_linear_3891_2757",x1:1.99951,y1:2,x2:15.3308,y2:3.72773,gradientUnits:"userSpaceOnUse"},L.createElement("stop",{stopColor:"#A61E69"}),L.createElement("stop",{offset:1,stopColor:"#6366F1"}))));function ba(e){"@babel/helpers - typeof";return ba=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ba(e)}function SL(e){return kL(e)||_L(e)||Yb(e)||CL()}function CL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1293
1293
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _L(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function kL(e){if(Array.isArray(e))return uf(e)}function Wm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Or(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wm(Object(n),!0).forEach(function(r){OL(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function OL(e,t,n){return(t=EL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function EL(e){var t=AL(e,"string");return ba(t)=="symbol"?t:t+""}function AL(e,t){if(ba(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ba(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function cf(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n=typeof Symbol=="function"?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function s(h,g,m,p){var v=g&&g.prototype instanceof a?g:a,b=Object.create(v.prototype);return nn(b,"_invoke",function(S,C,x){var k,w,_,O=0,A=x||[],M=!1,j={p:0,n:0,v:e,a:q,f:q.bind(e,4),d:function(E,$){return k=E,w=0,_=e,j.n=$,o}};function q(R,E){for(w=R,_=E,t=0;!M&&O&&!$&&t<A.length;t++){var $,I=A[t],K=j.p,Y=I[2];R>3?($=Y===E)&&(_=I[(w=I[4])?5:(w=3,3)],I[4]=I[5]=e):I[0]<=K&&(($=R<2&&K<I[1])?(w=0,j.v=E,j.n=I[1]):K<Y&&($=R<3||I[0]>E||E>Y)&&(I[4]=R,I[5]=E,j.n=Y,w=0))}if($||R>1)return o;throw M=!0,E}return function(R,E,$){if(O>1)throw TypeError("Generator is already running");for(M&&E===1&&q(E,$),w=E,_=$;(t=w<2?e:_)||!M;){k||(w?w<3?(w>1&&(j.n=-1),q(w,_)):j.n=_:j.v=_);try{if(O=2,k){if(w||(R="next"),t=k[R]){if(!(t=t.call(k,_)))throw TypeError("iterator result is not an object");if(!t.done)return t;_=t.value,w<2&&(w=0)}else w===1&&(t=k.return)&&t.call(k),w<2&&(_=TypeError("The iterator does not provide a '"+R+"' method"),w=1);k=e}else if((t=(M=j.n<0)?_:S.call(C,j))!==o)break}catch(I){k=e,w=1,_=I}finally{O=1}}return{value:t,done:M}}}(h,m,p),!0),b}var o={};function a(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(nn(t={},r,function(){return this}),t),d=c.prototype=a.prototype=Object.create(u);function f(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,c):(h.__proto__=c,nn(h,i,"GeneratorFunction")),h.prototype=Object.create(d),h}return l.prototype=c,nn(d,"constructor",c),nn(c,"constructor",l),l.displayName="GeneratorFunction",nn(c,i,"GeneratorFunction"),nn(d),nn(d,i,"Generator"),nn(d,r,function(){return this}),nn(d,"toString",function(){return"[object Generator]"}),(cf=function(){return{w:s,m:f}})()}function nn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(s){i=0}nn=function(o,a,l,c){if(a)i?i(o,a,{value:l,enumerable:!c,configurable:!c,writable:!c}):o[a]=l;else{var u=function(f,h){nn(o,f,function(g){return this._invoke(f,h,g)})};u("next",0),u("throw",1),u("return",2)}},nn(e,t,n,r)}function Qm(e,t,n,r,i,s,o){try{var a=e[s](o),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function PL(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var s=e.apply(t,n);function o(l){Qm(s,r,i,o,a,"next",l)}function a(l){Qm(s,r,i,o,a,"throw",l)}o(void 0)})}}function Zi(e,t){return ML(e)||jL(e,t)||Yb(e,t)||TL()}function TL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1294
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yb(e,t){if(e){if(typeof e=="string")return uf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uf(e,t):void 0}}function uf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function jL(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function ML(e){if(Array.isArray(e))return e}var rs=5,Fo="Generating...",$L="Re-generating...",DL=["******************************","***********************","*******************************************************","***********************************************","***************************************************************","*******************************************************","*******************************************************","***********************************************"],LL=Array.from({length:rs},function(e,t){return{id:"query-".concat(t),text:Fo,isRegenerating:!0}}),IL=function(){var t=pc(),n=t.brandId,r="/setup/".concat(n,"/analysis"),i=dn(),s=Vt(),o=z.useState(LL),a=Zi(o,2),l=a[0],c=a[1],u=z.useState(!1),d=Zi(u,2),f=d[0],h=d[1],g=z.useState([]),m=Zi(g,2),p=m[0],v=m[1],b=z.useState([]),S=Zi(b,2),C=S[0],x=S[1],k=z.useState(!1),w=Zi(k,2),_=w[0],O=w[1],A=z.useState(null),M=Zi(A,2),j=M[0],q=M[1],R=cC(n||"",{query:{enabled:!!n}}),E=R.data,$=R.isRefetching,I=R.isError,K=R.refetch,Y=sC({mutation:{onSuccess:function(){var re=PL(cf().m(function H(he){return cf().w(function(je){for(;;)switch(je.n){case 0:if(q(null),!(he!=null&&he.status&&he.status>=200&&he.status<300)){je.n=2;break}return je.n=1,Promise.all([s.invalidateQueries({queryKey:kf(n||"")}),s.invalidateQueries({queryKey:Gn()})]);case 1:i(r);case 2:return je.a(2)}},H)}));function de(H){return re.apply(this,arguments)}return de}(),onError:function(de){var H,he;if((de==null||(H=de.response)===null||H===void 0||(H=H.data)===null||H===void 0?void 0:H.message)==="Cannot update queries for a brand that has existing analyses."){i(r,{replace:!0});return}var je=(de==null||(he=de.response)===null||he===void 0||(he=he.data)===null||he===void 0?void 0:he.message)||(de==null?void 0:de.message)||"An unexpected error occurred.";q(je)}}}),N=Y.mutate,W=Y.isPending;z.useEffect(function(){n||i("/setup",{replace:!0})},[n,i]),z.useEffect(function(){var re;if(E!=null&&(re=E.data)!==null&&re!==void 0&&re.queries&&Array.isArray(E.data.queries)){var de=E.data.queries.slice(0,rs);c(de.map(function(H,he){return{id:"query-".concat(he),text:H,isRegenerating:!1}})),x(E.data.queries.slice(rs))}else I&&(c(Array.from({length:rs},function(H,he){return{id:"query-".concat(he),text:"",isRegenerating:!1}})),x([]))},[E,I]),z.useEffect(function(){var re;if(_&&E!==null&&E!==void 0&&(re=E.data)!==null&&re!==void 0&&re.queries&&Array.isArray(E.data.queries)&&!$){var de=E.data.queries.slice(0,rs),H=p.map(Number);c(function(he){return he.map(function(je,tt){var De=H.indexOf(tt);return Or(Or({},je),{},{text:De>=0&&de[De]?de[De]:je.text,isRegenerating:!1})})}),O(!1),v([])}},[E,$,_,p]);var ie=z.useCallback(function(re,de){var H=new Set(de);return C.filter(function(he){return!H.has(he)}).slice(0,re)},[C]),se=z.useMemo(function(){return $||l.length===0||l.some(function(re){return re.isRegenerating||re.text===Fo&&!I})||f},[$,l,f,I]),F=$||l.some(function(re){return re.text===Fo})&&!I,ae=z.useCallback(function(re){var de=re.toString();v(function(H){return H.includes(de)?H.filter(function(he){return he!==de}):[].concat(SL(H),[de])})},[]),ne=z.useCallback(function(re,de){c(function(H){return H.map(function(he,je){return je===re?Or(Or({},he),{},{text:de}):he})})},[]),xe=function(){h(!f),v([])},ee=z.useCallback(function(){if(!($||p.length===0)){c(function(he){return he.map(function(je,tt){return Or(Or({},je),{},{isRegenerating:p.includes(tt.toString())})})});var re=l.map(function(he){return he.text}),de=p.length,H=ie(de,re);H.length===de?(c(function(he){return he.map(function(je,tt){var De=p.indexOf(tt.toString());return De>=0?Or(Or({},je),{},{text:H[De],isRegenerating:!1}):je})}),x(function(he){var je=new Set(H);return he.filter(function(tt){return!je.has(tt)})}),v([])):(O(!0),K())}},[$,p,K,l,ie]),Se=z.useCallback(function(re){re.preventDefault(),n&&N({brandId:n,data:{queries:l.map(function(de){return de.text})}})},[n,l,N]);return y.jsxs("div",{children:[j&&y.jsx(P.Alert,{className:"yst-mb-4",variant:"error",children:j}),y.jsxs("form",{onSubmit:Se,children:[y.jsxs("div",{className:"yst-mb-8",children:[y.jsx(P.Title,{size:"2",className:"yst-mb-2",children:"Your queries"}),y.jsxs("div",{className:"yst-space-y-4",children:[y.jsx("p",{children:"You can edit your queries or regenerate new ones with AI."}),y.jsx("div",{className:ke("yst-flex yst-gap-2",f?"yst-justify-end":"yst-justify-start"),children:f?y.jsxs(y.Fragment,{children:[y.jsx(P.Button,{size:"small",variant:"secondary",onClick:xe,children:"Done"}),y.jsxs(P.Button,{variant:"secondary",size:"small",onClick:ee,className:"yst-gap-1",isLoading:$,disabled:$||p.length===0,children:[y.jsx(wL,{"aria-hidden":"true"}),"Regenerate selected queries"]})]}):y.jsxs(P.Button,{size:"small",variant:"secondary",onClick:xe,className:"yst-gap-1.5",disabled:F,children:[y.jsx(IC,{}),"Select queries to regenerate"]})})]})]}),y.jsx("div",{className:"yst-mb-8",children:l.length===0?DL.map(function(re,de){return y.jsx("div",{className:ke("yst-mb-4 yst-cursor-pointer yst-rounded yst-border yst-border-slate-300 yst-p-3 yst-transition-colors","yst-bg-white"),children:y.jsx(P.SkeletonLoader,{children:re||"Example placeholder query for demonstration purposes."})},"placeholder-query-".concat(de))}):l.slice(0,rs).map(function(re,de){var H=re.isRegenerating?re.text===Fo?Fo:$L:re.text;return y.jsx("div",{className:ke("yst-mb-4"),children:y.jsxs("div",{className:"yst-flex yst-gap-2",children:[f&&y.jsx("div",{className:"yst-flex yst-items-center",children:y.jsx(P.Checkbox,{id:"query-regenerate-".concat(de),name:"query-regenerate-".concat(de),value:de.toString(),checked:p.includes(de.toString()),onChange:function(){return ae(de)},disabled:$})}),y.jsxs("div",{className:"yst-flex-1",children:[y.jsx(P.Label,{htmlFor:"query-text-".concat(de),className:"yst-mb-2 yst-block yst-text-sm yst-font-medium yst-text-slate-700",children:"Query ".concat(de+1)}),y.jsx(P.TextInput,{id:"query-text-".concat(de),type:"text",value:H,onChange:function(he){re.isRegenerating||ne(de,he.target.value)},placeholder:"Enter your query...",className:"yst-w-full",disabled:re.isRegenerating,required:!0,maxLength:255})]})]})},re.id)})}),y.jsx(Wb,{buttonText:"Run analysis (~ 5 minutes)",isButtonDisabled:se,isLoading:W})]})]})};const RL=Object.freeze(Object.defineProperty({__proto__:null,default:IL},Symbol.toStringTag,{value:"Module"}));var FL=["min","max","progress","className"];function NL(e,t){if(e==null)return{};var n,r,i=BL(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function BL(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Xb=z.forwardRef(function(e,t){var n=e.min,r=e.max,i=e.progress,s=e.className,o=NL(e,FL),a=z.useMemo(function(){var c=Math.max(0,r-n);if(c===0)return 0;var u=(i-n)/c*100;return Math.max(0,Math.min(100,u))},[n,r,i]),l=Math.min(Math.max(i,n),r);return y.jsx("div",{ref:t,role:"progressbar","aria-valuemin":n,"aria-valuemax":r,"aria-valuenow":l,"aria-valuetext":"".concat(Math.round(a),"%"),className:ke(s),...o,children:y.jsx("div",{className:"yst-relative yst-h-2 yst-w-full yst-overflow-hidden yst-rounded-full yst-bg-slate-200/40",children:y.jsx("div",{className:"yst-absolute yst-left-0 yst-top-0 yst-h-full yst-rounded-full yst-bg-[linear-gradient(97.38deg,_#A61E69_0%,_#6366F1_100%)] yst-transition-[width] yst-duration-300 yst-ease-out",style:{width:"".concat(a,"%")}})})})});Xb.displayName="ProgressBarGradient";var Ji=[{labelAbove:"Running queries...",label:"Running queries",threshold:99},{labelAbove:"Done!",label:"Building analysis",threshold:100}],Zb=function(t){var n=t.progress,r=n===void 0?0:n,i=t.className,s=i===void 0?"":i,o=function(){for(var c=0;c<Ji.length;c++)if(r<=Ji[c].threshold)return Ji[c];return Ji[Ji.length-1]},a=o();return y.jsxs("div",{className:ke("yst-font-medium yst-text-slate-800",s),children:[y.jsxs("div",{className:"yst-flex yst-items-center yst-justify-center yst-gap-2",children:[r<100?y.jsx(P.Spinner,{}):y.jsx(sv,{className:"yst-text-green-400"}),y.jsx("span",{className:"yst-text-sm yst-font-medium yst-italic",children:a.labelAbove})]}),y.jsx(Xb,{className:"yst-mt-3",progress:r,min:0,max:100}),y.jsx("div",{className:"yst-mt-3 yst-flex yst-justify-between yst-text-xs",children:Ji.map(function(l){return y.jsx("span",{children:y.jsx(Lc,{disabled:a.label!==l.label,children:l.label})},l.label)})})]})};Zb.propTypes={progress:Td.number,className:Td.string};var qL=function(t){switch(t){case"pending":case"processing":return 2*1e3;case"completed":return!1;default:return 10*1e3}},zL=function(){var t,n,r,i=dn(),s=Vt(),o=pc(),a=Zn(),l=a.brandId,c=o.brandId||l,u=Ed(c,{query:{enabled:!!c,select:function(C){var x=C.data;return x}}}),d=u.data,f=$5(c,"latest",{query:{enabled:!!c,select:function(C){var x=C.data;return x},refetchInterval:function(C){var x,k=C==null||(x=C.state)===null||x===void 0||(x=x.data)===null||x===void 0?void 0:x.data;return qL(k==null?void 0:k.status)}}}),h=f.data,g=h==null?void 0:h.id,m=g?"/brands/".concat(c,"/analysis/").concat(g):"/brands/".concat(c);z.useEffect(function(){var S=(h==null?void 0:h.status)==="pending"||(h==null?void 0:h.status)==="processing"||(h==null?void 0:h.status)==="completed";d!=null&&d.nextScheduledAnalysis&&h!==null&&h!==void 0&&h.status&&c7(d.nextScheduledAnalysis,5)&&!S&&i("/brands/".concat(c),{replace:!0})},[d==null?void 0:d.nextScheduledAnalysis,c,i,h==null?void 0:h.status]),z.useEffect(function(){((d==null?void 0:d.setupStatus)==="completed"||(d==null?void 0:d.setupStatus)==="scheduledFirstAnalysis"&&d!==null&&d!==void 0&&d.firstNextAnalysisOpportunity&&!mv(d.firstNextAnalysisOpportunity,2))&&i(m,{replace:!0})},[d==null?void 0:d.firstNextAnalysisOpportunity,d==null?void 0:d.setupStatus,m,i]);var p=d==null||(t=d.queries)===null||t===void 0?void 0:t.length,v=(h==null||(n=h.completedQueries)===null||n===void 0?void 0:n.length)||0,b=function(){if(p&&p>0){var S=80/p,C=v*S;return(h==null?void 0:h.status)==="completed"?100:Math.round(Math.min(C,80))}return 0}();return y.jsxs("div",{children:[y.jsxs("div",{className:"yst-space-y-8",children:[y.jsx(Zb,{progress:b}),y.jsx(za,{}),y.jsx("div",{className:"yst-space-y-8",children:d==null||(r=d.queries)===null||r===void 0?void 0:r.map(function(S){var C,x=S.id,k=S.query,w=x&&(h==null||(C=h.completedQueries)===null||C===void 0?void 0:C.includes(x));return y.jsxs("div",{className:ke("yst-flex yst-items-center yst-justify-between yst-gap-3"),children:[w===!0?y.jsx(sv,{className:"yst-h-5 yst-w-5 yst-text-green-400"}):y.jsx(P.Spinner,{}),y.jsx("span",{className:"yst-flex-1 yst-text-sm",children:k})]},"result-item-".concat(k))})})]}),y.jsx("div",{className:"yst-mb-[-2rem] yst-ml-[-2rem] yst-mr-[-2rem] yst-mt-8 yst-flex yst-justify-end yst-gap-4 yst-rounded-bl-lg yst-rounded-br-lg yst-border-t yst-border-slate-200 yst-bg-slate-50 yst-px-8 yst-py-6",children:y.jsx(P.Button,{as:Zr,to:m,onClick:function(){return s.clear()},children:b===100?"Continue →":"Skip for now"})})]})};const HL=Object.freeze(Object.defineProperty({__proto__:null,default:zL},Symbol.toStringTag,{value:"Module"}));exports.AIInsightsClient=LA;exports.setApiBaseUrl=V2;
1294
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yb(e,t){if(e){if(typeof e=="string")return uf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uf(e,t):void 0}}function uf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function jL(e,t){var n=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function ML(e){if(Array.isArray(e))return e}var rs=5,Fo="Generating...",$L="Re-generating...",DL=["******************************","***********************","*******************************************************","***********************************************","***************************************************************","*******************************************************","*******************************************************","***********************************************"],LL=Array.from({length:rs},function(e,t){return{id:"query-".concat(t),text:Fo,isRegenerating:!0}}),IL=function(){var t=pc(),n=t.brandId,r="/setup/".concat(n,"/analysis"),i=dn(),s=Vt(),o=z.useState(LL),a=Zi(o,2),l=a[0],c=a[1],u=z.useState(!1),d=Zi(u,2),f=d[0],h=d[1],g=z.useState([]),m=Zi(g,2),p=m[0],v=m[1],b=z.useState([]),S=Zi(b,2),C=S[0],x=S[1],k=z.useState(!1),w=Zi(k,2),_=w[0],O=w[1],A=z.useState(null),M=Zi(A,2),j=M[0],q=M[1],R=cC(n||"",{query:{enabled:!!n}}),E=R.data,$=R.isRefetching,I=R.isError,K=R.refetch,Y=sC({mutation:{onSuccess:function(){var re=PL(cf().m(function H(he){return cf().w(function(je){for(;;)switch(je.n){case 0:if(q(null),!(he!=null&&he.status&&he.status>=200&&he.status<300)){je.n=2;break}return je.n=1,Promise.all([s.invalidateQueries({queryKey:kf(n||"")}),s.invalidateQueries({queryKey:Gn()})]);case 1:i(r);case 2:return je.a(2)}},H)}));function de(H){return re.apply(this,arguments)}return de}(),onError:function(de){var H,he;if((de==null||(H=de.response)===null||H===void 0||(H=H.data)===null||H===void 0?void 0:H.message)==="Cannot update queries for a brand that has existing analyses."){i(r,{replace:!0});return}var je=(de==null||(he=de.response)===null||he===void 0||(he=he.data)===null||he===void 0?void 0:he.message)||(de==null?void 0:de.message)||"An unexpected error occurred.";q(je)}}}),N=Y.mutate,W=Y.isPending;z.useEffect(function(){n||i("/setup",{replace:!0})},[n,i]),z.useEffect(function(){var re;if(E!=null&&(re=E.data)!==null&&re!==void 0&&re.queries&&Array.isArray(E.data.queries)){var de=E.data.queries.slice(0,rs);c(de.map(function(H,he){return{id:"query-".concat(he),text:H,isRegenerating:!1}})),x(E.data.queries.slice(rs))}else I&&(c(Array.from({length:rs},function(H,he){return{id:"query-".concat(he),text:"",isRegenerating:!1}})),x([]))},[E,I]),z.useEffect(function(){var re;if(_&&E!==null&&E!==void 0&&(re=E.data)!==null&&re!==void 0&&re.queries&&Array.isArray(E.data.queries)&&!$){var de=E.data.queries.slice(0,rs),H=p.map(Number);c(function(he){return he.map(function(je,tt){var De=H.indexOf(tt);return Or(Or({},je),{},{text:De>=0&&de[De]?de[De]:je.text,isRegenerating:!1})})}),O(!1),v([])}},[E,$,_,p]);var ie=z.useCallback(function(re,de){var H=new Set(de);return C.filter(function(he){return!H.has(he)}).slice(0,re)},[C]),se=z.useMemo(function(){return $||l.length===0||l.some(function(re){return re.isRegenerating||re.text===Fo&&!I})||f},[$,l,f,I]),F=$||l.some(function(re){return re.text===Fo})&&!I,ae=z.useCallback(function(re){var de=re.toString();v(function(H){return H.includes(de)?H.filter(function(he){return he!==de}):[].concat(SL(H),[de])})},[]),ne=z.useCallback(function(re,de){c(function(H){return H.map(function(he,je){return je===re?Or(Or({},he),{},{text:de}):he})})},[]),xe=function(){h(!f),v([])},ee=z.useCallback(function(){if(!($||p.length===0)){c(function(he){return he.map(function(je,tt){return Or(Or({},je),{},{isRegenerating:p.includes(tt.toString())})})});var re=l.map(function(he){return he.text}),de=p.length,H=ie(de,re);H.length===de?(c(function(he){return he.map(function(je,tt){var De=p.indexOf(tt.toString());return De>=0?Or(Or({},je),{},{text:H[De],isRegenerating:!1}):je})}),x(function(he){var je=new Set(H);return he.filter(function(tt){return!je.has(tt)})}),v([])):(O(!0),K())}},[$,p,K,l,ie]),Se=z.useCallback(function(re){re.preventDefault(),n&&N({brandId:n,data:{queries:l.map(function(de){return de.text})}})},[n,l,N]);return y.jsxs("div",{children:[j&&y.jsx(P.Alert,{className:"yst-mb-4",variant:"error",children:j}),y.jsxs("form",{onSubmit:Se,children:[y.jsxs("div",{className:"yst-mb-8",children:[y.jsx(P.Title,{size:"2",className:"yst-mb-2",children:"Your queries"}),y.jsxs("div",{className:"yst-space-y-4",children:[y.jsx("p",{children:"You can edit your queries or regenerate new ones with AI."}),y.jsx("div",{className:ke("yst-flex yst-gap-2",f?"yst-justify-end":"yst-justify-start"),children:f?y.jsxs(y.Fragment,{children:[y.jsx(P.Button,{size:"small",variant:"secondary",onClick:xe,children:"Done"}),y.jsxs(P.Button,{variant:"secondary",size:"small",onClick:ee,className:"yst-gap-1",isLoading:$,disabled:$||p.length===0,children:[y.jsx(wL,{"aria-hidden":"true"}),"Regenerate selected queries"]})]}):y.jsxs(P.Button,{size:"small",variant:"secondary",onClick:xe,className:"yst-gap-1.5",disabled:F,children:[y.jsx(IC,{}),"Select queries to regenerate"]})})]})]}),y.jsx("div",{className:"yst-mb-8",children:l.length===0?DL.map(function(re,de){return y.jsx("div",{className:ke("yst-mb-4 yst-cursor-pointer yst-rounded yst-border yst-border-slate-300 yst-p-3 yst-transition-colors","yst-bg-white"),children:y.jsx(P.SkeletonLoader,{children:re||"Example placeholder query for demonstration purposes."})},"placeholder-query-".concat(de))}):l.slice(0,rs).map(function(re,de){var H=re.isRegenerating?re.text===Fo?Fo:$L:re.text;return y.jsx("div",{className:ke("yst-mb-4"),children:y.jsxs("div",{className:"yst-flex yst-gap-2",children:[f&&y.jsx("div",{className:"yst-flex yst-items-center",children:y.jsx(P.Checkbox,{id:"query-regenerate-".concat(de),name:"query-regenerate-".concat(de),value:de.toString(),checked:p.includes(de.toString()),onChange:function(){return ae(de)},disabled:$})}),y.jsxs("div",{className:"yst-flex-1",children:[y.jsx(P.Label,{htmlFor:"query-text-".concat(de),className:"yst-mb-2 yst-block yst-text-sm yst-font-medium yst-text-slate-700",children:"Query ".concat(de+1)}),y.jsx(P.TextInput,{id:"query-text-".concat(de),type:"text",value:H,onChange:function(he){re.isRegenerating||ne(de,he.target.value)},placeholder:"Enter your query...",className:"yst-w-full",disabled:re.isRegenerating,required:!0,maxLength:255})]})]})},re.id)})}),y.jsx(Wb,{buttonText:"Run analysis (~ 5 minutes)",isButtonDisabled:se,isLoading:W})]})]})};const RL=Object.freeze(Object.defineProperty({__proto__:null,default:IL},Symbol.toStringTag,{value:"Module"}));var FL=["min","max","progress","className"];function NL(e,t){if(e==null)return{};var n,r,i=BL(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function BL(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Xb=z.forwardRef(function(e,t){var n=e.min,r=e.max,i=e.progress,s=e.className,o=NL(e,FL),a=z.useMemo(function(){var c=Math.max(0,r-n);if(c===0)return 0;var u=(i-n)/c*100;return Math.max(0,Math.min(100,u))},[n,r,i]),l=Math.min(Math.max(i,n),r);return y.jsx("div",{ref:t,role:"progressbar","aria-valuemin":n,"aria-valuemax":r,"aria-valuenow":l,"aria-valuetext":"".concat(Math.round(a),"%"),className:ke(s),...o,children:y.jsx("div",{className:"yst-relative yst-h-2 yst-w-full yst-overflow-hidden yst-rounded-full yst-bg-slate-200/40",children:y.jsx("div",{className:"yst-absolute yst-left-0 yst-top-0 yst-h-full yst-rounded-full yst-bg-[linear-gradient(97.38deg,_#A61E69_0%,_#6366F1_100%)] yst-transition-[width] yst-duration-300 yst-ease-out",style:{width:"".concat(a,"%")}})})})});Xb.displayName="ProgressBarGradient";var Ji=[{labelAbove:"Running queries...",label:"Running queries",threshold:99},{labelAbove:"Done!",label:"Building analysis",threshold:100}],Zb=function(t){var n=t.progress,r=n===void 0?0:n,i=t.className,s=i===void 0?"":i,o=function(){for(var c=0;c<Ji.length;c++)if(r<=Ji[c].threshold)return Ji[c];return Ji[Ji.length-1]},a=o();return y.jsxs("div",{className:ke("yst-font-medium yst-text-slate-800",s),children:[y.jsxs("div",{className:"yst-flex yst-items-center yst-justify-center yst-gap-2",children:[r<100?y.jsx(P.Spinner,{}):y.jsx(sv,{className:"yst-text-green-400"}),y.jsx("span",{className:"yst-text-sm yst-font-medium yst-italic",children:a.labelAbove})]}),y.jsx(Xb,{className:"yst-mt-3",progress:r,min:0,max:100}),y.jsx("div",{className:"yst-mt-3 yst-flex yst-justify-between yst-text-xs",children:Ji.map(function(l){return y.jsx("span",{children:y.jsx(Lc,{disabled:a.label!==l.label,children:l.label})},l.label)})})]})};Zb.propTypes={progress:Td.number,className:Td.string};var qL=function(t){switch(t){case"pending":case"processing":return 2*1e3;case"completed":return!1;default:return 10*1e3}},zL=function(){var t,n,r,i=dn(),s=Vt(),o=pc(),a=Zn(),l=a.brandId,c=o.brandId||l,u=Ed(c,{query:{enabled:!!c,select:function(C){var x=C.data;return x}}}),d=u.data,f=$5(c,"latest",{query:{enabled:!!c,select:function(C){var x=C.data;return x},refetchInterval:function(C){var x,k=C==null||(x=C.state)===null||x===void 0||(x=x.data)===null||x===void 0?void 0:x.data;return qL(k==null?void 0:k.status)}}}),h=f.data,g=h==null?void 0:h.id,m=g?"/brands/".concat(c,"/analysis/").concat(g):"/brands/".concat(c);z.useEffect(function(){var S=(h==null?void 0:h.status)==="pending"||(h==null?void 0:h.status)==="processing"||(h==null?void 0:h.status)==="completed";d!=null&&d.nextScheduledAnalysis&&h!==null&&h!==void 0&&h.status&&c7(d.nextScheduledAnalysis,5)&&!S&&i("/brands/".concat(c),{replace:!0})},[d==null?void 0:d.nextScheduledAnalysis,c,i,h==null?void 0:h.status]),z.useEffect(function(){((d==null?void 0:d.setupStatus)==="completed"||(d==null?void 0:d.setupStatus)==="scheduledFirstAnalysis"&&d!==null&&d!==void 0&&d.firstNextAnalysisOpportunity&&!mv(d.firstNextAnalysisOpportunity,2))&&i(m,{replace:!0})},[d==null?void 0:d.firstNextAnalysisOpportunity,d==null?void 0:d.setupStatus,m,i]);var p=d==null||(t=d.queries)===null||t===void 0?void 0:t.length,v=(h==null||(n=h.completedQueries)===null||n===void 0?void 0:n.length)||0,b=function(){if(p&&p>0){var S=80/p,C=v*S;return(h==null?void 0:h.status)==="completed"?100:Math.round(Math.min(C,80))}return 0}();return y.jsxs("div",{children:[y.jsxs("div",{className:"yst-space-y-8",children:[y.jsx(Zb,{progress:b}),y.jsx(za,{}),y.jsx("div",{className:"yst-space-y-8",children:d==null||(r=d.queries)===null||r===void 0?void 0:r.map(function(S){var C,x=S.id,k=S.query,w=x&&(h==null||(C=h.completedQueries)===null||C===void 0?void 0:C.includes(x));return y.jsxs("div",{className:ke("yst-flex yst-items-center yst-justify-between yst-gap-3"),children:[w===!0?y.jsx(sv,{className:"yst-h-5 yst-w-5 yst-text-green-400"}):y.jsx(P.Spinner,{}),y.jsx("span",{className:"yst-flex-1 yst-text-sm",children:k})]},"result-item-".concat(k))})})]}),y.jsx("div",{className:"yst-mb-[-2rem] yst-ml-[-2rem] yst-mr-[-2rem] yst-mt-8 yst-flex yst-justify-end yst-gap-4 yst-rounded-bl-lg yst-rounded-br-lg yst-border-t yst-border-slate-200 yst-bg-slate-50 yst-px-8 yst-py-6",children:y.jsx(P.Button,{as:Zr,to:m,onClick:function(S){if(b!==100){S.preventDefault();return}s.clear()},disabled:b!==100,children:"Continue →"})})]})};const HL=Object.freeze(Object.defineProperty({__proto__:null,default:zL},Symbol.toStringTag,{value:"Module"}));exports.AIInsightsClient=LA;exports.setApiBaseUrl=V2;
1295
1295
  //# sourceMappingURL=ai-insights-client.cjs.js.map