1import{c as H,A as W,a as Y,r,j as e,B as c}from"./index-BKInu8Gb.js";import{I as J}from"./input-DS1MAjnD.js";import{L as P}from"./label-Bs-8-fl1.js";import{C as f,d as j,a as V}from"./card-BP0uVGrg.js";import{S as R,a as G,b as q,c as Q,d as X}from"./select-Ch53q4in.js";import{g as I}from"./config-BSf9rU-h.js";import{C as y}from"./circle-alert-CzrNrOzW.js";import{C as E}from"./circle-check-Bljibo5l.js";import{E as Z}from"./external-link-CcuYPQGf.js";import{S as ee}from"./sparkles-Dy67g5WL.js";import{C as se}from"./chevron-down-D6Dw-Q53.js";import{L as D}from"./loader-circle-CYXtu1pc.js";import{S as te}from"./shield-check-BVSk9h-w.js";import"./index-BdUYosLC.js";import"./index-DyLHZbNU.js";import"./index-90jyQyqH.js";import"./chevron-up-BfHJ_zal.js";import"./check-Bo92AKRy.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const g=H("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]),ae="c88662758472fe70133aae708c2b687a",re="anvevoice";function L(n){return`https://${n}/admin/themes/current/editor?context=apps&activateAppId=${ae}/${re}`}function ne(n){switch(n){case"bot_limit_reached":return"You've reached your plan's bot limit. Upgrade in your AnveVoice dashboard, or connect an existing bot with an API key below.";
6case"access_denied":return'Connection cancelled. Click "Continue with AnveVoice" to try again.';case"install_not_found":return"We couldn't find your Shopify install. Please reinstall the app from Shopify and try again.";default:return"Something went wrong connecting your AnveVoice account. Please try again, or use an API key below."}}function ke(){const[n]=W(),$=Y(),t=n.get("shop")??"",[o,O]=r.useState(""),[h,T]=r.useState([]),[l,v]=r.useState(""),[p,N]=r.useState(n.get("step")==="activate"?"activate":"key"),[b,B]=r.useState(!1),[w,u]=r.useState(!1),[k,x]=r.useState(!1),[S,i]=r.useState(""),[d,M]=r.useState(!1),[z,K]=r.useState(t?L(t):""),C=I("shopify-setup"),A=(()=>{const s=n.get("anve_error");return s?ne(s):""})(),U=()=>{window.location.href=`${I("shopify-connect")}/start?shop=${encodeURIComponent(t)}`};if(!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(f,{className:"max-w-md w-full mx-4",children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3 text-destructive",children:[e.jsx(y,{className:"h-5 w-5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Missing Shop Parameter"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Please install the app from your Shopify admin to get started."})]})]})})})});const _=async()=>{var s;if(o.trim()){u(!0),i("");try{const a=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"validate_key",api_key:o.trim(),shop:t})}),m=await a.json();if(!a.ok||m.error){i(m.error||"Invalid API key"),u(!1);return}T(m.bots||[]),M(!0),N("select"),((s=m.bots)==null?void 0:s.length)>0&&v(m.bots[0].id)}catch{i("Connection error. Please try again.")}finally{u(!1)}}},F=async()=>{if(!(!l||!o)){x(!0),i("");try{const s=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"deploy",api_key:o.trim(),embed_id:l,shop:t})}),a=await s.json();if(!s.ok||a.error){i(a.error||"Deployment failed"),x(!1);return}K(a.app_embed_url||L(t)),x(!1),N("activate")}catch{i("Connection error. Please try again."),x(!1)}}};if(p==="activate"){const s=l||n.get("embed")||"",a="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary text-xs font-semibold";return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(f,{className:"max-w-[480px] w-full",children:[e.jsx(V,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-emerald-100 dark:bg-emerald-950/40 flex items-center justify-center shrink-0",children:e.jsx(E,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-foreground",children:"Your voice assistant is connected"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5 mt-0.5",children:[e.jsx(g,{className:"h-3.5 w-3.5"}),t]})]})]})}),e.jsxs(j,{className:"space-y-5 pt-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"One last step to make the voice orb appear on your storefront:"}),e.jsxs("ol",{className:"space-y-4",children:[e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:a,children:"1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Open your theme editor"}),e.jsxs(c,{size:"sm",className:"mt-2",onClick:()=>window.open(z,"_blank"),children:[e.jsx(Z,{className:"h-4 w-4 mr-1.5"}),"Open theme editor"]})]})]}),e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:a,children:"2"}),e.jsxs("p",{className:"text-sm pt-0.5",children:[e.jsx("span",{className:"font-medium",children:"AnveVoice"})," is already switched on in the editor â just click ",e.jsx("span",{className:"font-medium",children:"Save"})," in the top-right corner."]})]}),e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:a,children:"3"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"See it on your store"}),e.jsxs(c,{size:"sm",variant:"outline",className:"mt-2",onClick:()=>window.open(`https://${t}`,"_blank"),children:[e.jsx(g,{className:"h-4 w-4 mr-1.5"}),"Preview your store"]})]})]})]}),e.jsx("div",{className:"rounded-md bg-muted/50 border px-3 py-2.5 text-xs text-muted-foreground",children:"The voice orb shows on every page once the embed is on, and it already knows your products. To change the greeting, voice, or review conversations, open your AnveVoice dashboard."}),s&&e.jsx(c,{variant:"outline",className:"w-full",onClick:()=>$(`/embeds/${s}`),children:"Customize your bot"})]})]})})}return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(f,{className:"max-w-[480px] w-full",children:[e.jsxs(V,{className:"pb-2",children:[e.jsxs("div",{className:"text-2xl font-bold text-foreground mb-1",children:["Anve",e.jsx("span",{className:"text-primary",children:"Voice"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an AI voice assistant to your Shopify store"}),e.jsx("div",{className:"inline-flex mt-3",children:e.jsxs("span",{className:"bg-muted border border-border rounded-md px-2.5 py-1 text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(g,{className:"h-3.5 w-3.5"}),t]})})]}),e.jsxs(j,{className:"space-y-5",children:[A&&e.jsxs("div",{className:"flex items-start gap-2 bg-destructive/10 border border-destructive/30 rounded-md px-3 py-2.5",children:[e.jsx(y,{className:"h-4 w-4 text-destructive shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-destructive",children:A})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(ee,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We'll create a voice assistant for this store and train it on your products automatically â takes about a minute, nothing to set up."})]}),e.jsx(c,{className:"w-full",onClick:U,children:"Continue with AnveVoice"})]}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>B(s=>!s),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(se,{className:`h-3.5 w-3.5 transition-transform ${b?"":"-rotate-90"}`}),"Already use AnveVoice? Connect an existing bot"]}),b&&e.jsxs("div",{className:"mt-3 space-y-4 rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Step 1 â Enter your API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(J,{value:o,onChange:s=>O(s.target.value),placeholder:"anvk_...",autoComplete:"off",disabled:d,className:"font-mono text-sm",onKeyDown:s=>{s.key==="Enter"&&!d&&_()}}),e.jsx(c,{size:"sm",onClick:_,disabled:w||d||!o.trim(),className:d?"bg-emerald-600 hover:bg-emerald-600":"",children:w?e.jsx(D,{className:"h-4 w-4 animate-spin"}):d?e.jsx(E,{className:"h-4 w-4"}):"Verify"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from the"," ",e.jsx("a",{href:"/developer",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Developer page"}
6)," ","in your AnveVoice dashboard"]})]}),p!=="key"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Step 2 â Select a bot to attach"}),h.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active bots found. Create one in your AnveVoice dashboard, or use âContinue with AnveVoiceâ above to have one made for you."}):e.jsxs(e.Fragment,{children:[e.jsxs(R,{value:l,onValueChange:v,children:[e.jsx(G,{children:e.jsx(q,{placeholder:"Select a bot..."})}),e.jsx(Q,{children:h.map(s=>e.jsxs(X,{value:s.id,children:[s.name,s.bot_type?` (${s.bot_type})`:""]},s.id))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h.length," bot(s) available"]})]})]}),p==="select"&&h.length>0&&e.jsx(c,{className:"w-full",onClick:F,disabled:k||!l,children:k?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 animate-spin mr-2"}),"Connecting..."]}):"Attach this bot"})]})]}),S&&e.jsxs("div",{className:"flex items-start gap-2 bg-destructive/10 border border-destructive/30 rounded-md px-3 py-2.5",children:[e.jsx(y,{className:"h-4 w-4 text-destructive shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-destructive",children:S})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Credentials validated securely on AnveVoice servers"})]})]})]})})}export{ke as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.