1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,290571,e=>{"use strict";var t=function(e,s){return(t=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])})(e,s)};function s(e,s){if("function"!=typeof s&&null!==s)throw TypeError("Class extends value "+String(s)+" is not a constructor or null");function o(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(o.prototype=s.prototype,new o)}var o=function(){return(o=Object.assign||function(e){for(var t,s=1,o=arguments.length;s<o;s++)for(var r in t=arguments[s])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function r(e,t){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(s[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function a(e,t,s,o){return new(s||(s=Promise))(function(r,a){function i(e){try{l(o.next(e))}catch(e){a(e)}}function n(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(i,n)}l((o=o.apply(e,t||[])).next())})}function i(e,t){var s,o,r,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=n(0),i.throw=n(1),i.return=n(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function n(n){return function(l){var u=[n,l];if(s)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(s=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,o=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){a.label=u[1];break}if(6===u[0]&&a.label<r[1]){a.label=r[1],r=u;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(u);break}r[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],o=0}finally{s=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],o=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var o,r,a=s.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}return i}function u(e,t,s){if(s||2==arguments.length)for(var o,r=0,a=t.length;r<a;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,e.s(["__assign",()=>o,"__awaiter",()=>a,"__extends",()=>s,"__generator",()=>i,"__read",()=>l,"__rest",()=>r,"__spreadArray",()=>u,"__values",()=>n])},618566,(e,t,s)=>{t.exports=e.r(976562)},587583,e=>{"use strict";var t=e.i(271645),s=e.i(769464);let o=new Map([["bold",t.createElement(t.Fragment,null,t.createElement("path",{d:"M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z"}))],["duotone",t.createElement(t.Fragment,null,t.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),t.createElement("path",{d:"M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z"}))],["fill",t.createElement(t.Fragment,null,t.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,176A72,72,0,0,1,92,65.64a8,8,0,0,1,8,13.85,56,56,0,1,0,56,0,8,8,0,0,1,8-13.85A72,72,0,0,1,128,200Z"}))],["light",t.createElement(t.Fragment,null,t.createElement("path",{d:"M230,128a102,102,0,0,1-204,0c0-40.18,23.35-76.86,59.5-93.45a6,6,0,0,1,5,10.9C58.61,60.09,38,92.49,38,128a90,90,0,0,0,180,0c0-35.51-20.61-67.91-52.5-82.55a6,6,0,0,1,5-10.9C206.65,51.14,230,87.82,230,128Z"}))],["regular",t.createElement(t.Fragment,null,t.createElement("path",{d:"M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z"}))],["thin",t.createElement(t.Fragment,null,t.createElement("path",{d:"M228,128a100,100,0,0,1-200,0c0-39.4,22.9-75.37,58.33-91.63a4,4,0,1,1,3.34,7.27C57.07,58.6,36,91.71,36,128a92,92,0,0,0,184,0c0-36.29-21.07-69.4
1-53.67-84.36a4,4,0,1,1,3.34-7.27C205.1,52.63,228,88.6,228,128Z"}))]]),r=t.forwardRef((e,r)=>t.createElement(s.default,{ref:r,...e,weights:o}));r.displayName="CircleNotchIcon",e.s(["CircleNotchIcon",()=>r],587583)},671428,e=>{"use strict";var t=e.i(843476),s=e.i(647163);function o({className:e,...o}){return(0,t.jsx)("div",{className:(0,s.cn)("animate-pulse rounded-md bg-gray-300",e),...o})}e.s(["Skeleton",()=>o])},741159,308085,763890,e=>{"use strict";let t={default:{promptId:"pmpt_6981d5979600819693f76387e58fa9bc0fc033ca5d73ae68"},"dna-playground":{promptId:"pmpt_6984dbdd7ed48190b2b68b7d7374889207e86e08d2459d0d"},"lab-enabled":{promptContent:!0},"speed-sensing-layer":{promptId:"pmpt_6989b32a90f48197b83f5df76e8d7b60096afbce8c17c689"},"claude-skill":{skillId:"skill_012qMFLdkmenTbfkZHzNqyon",skillType:"custom",skillVersion:"latest"}};function s(e){return t[e]||t.default}function o(e,t=600,s=700,r="OAuth"){let a=window.screenX+(window.outerWidth-t)/2,i=window.screenY+(window.outerHeight-s)/2,n=`width=${t},height=${s},left=${a},top=${i},scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=no,menubar=no`,l=window.open(e,r,n);return l&&l.focus(),l}function r(e,t,s=1e3){if(!e)return()=>{};let o=()=>{e.closed?t():setTimeout(o,s)};return setTimeout(o,s),()=>{}}async function a({fn:e,isComplete:t,isFailed:s,onTick:o,onComplete:r,onFailed:a,onTimeout:i,onError:n,interval:l=5e3,maxAttempts:u=300}){let c=0;for(;c<u;){c++;try{let i=await e();if(o?.(i,c),t(i))return void r(i);if(s(i))return void a(i)}catch(e){n?.(e,c)}if(c>=u)return void i();await new Promise(e=>setTimeout(e,l))}}e.s(["getPromptModeConfig",()=>s],741159),e.s(["monitorPopupClose",()=>r,"openOAuthPopup",()=>o],308085),e.s(["pollUntilComplete",()=>a],763890)},320082,e=>{"use strict";var t=e.i(920778);let s=new Set;function o(e,t){return[e,t.job_id??t.session_id??"unknown",t.status??"",t.phase??""].join(":")}function r(e,o={},a){let i,n=a?.dedupeKey;if(n){if(s.has(n))return;s.add(n)}(0,t.trackEvent)(e,(i={},Object.entries(o).forEach(([e,t])=>{if("string"==typeof t&&t.trim()){i[e]=t.trim();return}"boolean"==typeof t&&(i[e]=t)}),i))}e.s(["getBuilderLifecycleDedupeKey",()=>o,"trackBuilderLifecycleEvent",()=>r])},635358,e=>{"use strict";var t=e.i(843476),s=e.i(271645),o=e.i(618566),r=e.i(954616),a=e.i(912598),i=e.i(624185),n=e.i(796311);e.i(336687);var l=e.i(22133),u=e.i(741159),c=e.i(308085),d=e.i(763890),p=e.i(347967),y=e.i(25265),h=e.i(669621),m=e.i(320082),f=e.i(615996),g=e.i(22398);let b="shopify-chat-messages",_=new Set(["COMPLETED","FAILED","CANCELLED"]),S=/^\.[^\s,;|/\\]+$/u,w=/reseller-enabled tlds?/i,v="AI_ASSISTANT_MESSAGE",I=(e,t)=>e?{...e,reseller_page:t.reseller_page??e.reseller_page??!1,tld_list:t.tld_list??e.tld_list??[],tld_details:t.tld_details??e.tld_details??[],tld_present:t.tld_present??e.tld_present??!1}:null,C=e=>{let t=function(e){if(!e)return null;try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch{return null}}(e?.message),s=t?t.message||void 0:e?.message;return{businessDNA:e?.business_dna??t?.business_dna??null,promptText:e?.prompt,message:s,messageId:e?.message_id,routingFields:{reseller_page:e?.reseller_page??t?.reseller_page,tld_list:e?.tld_list??t?.tld_list,tld_details:e?.tld_details??t?.tld_details,tld_present:e?.tld_present??t?.tld_present}}},E=(0,s.createContext)(void 0);function x({children:e}){let{sessionId:x,setSessionId:k,setChatContextType:T}=(0,i.useSessionStore)(),{token:A}=(0,n.useAuthStore)(),P=(0,o.useRouter)(),N=(0,o.usePathname)(),j=(0,o.useSearchParams)(),D=(0,a.useQueryClient)(),O="/chat"===N,B="/chat"===N||N?.startsWith("/chat/"),L=B?j.get("sessionId"):null,z=B?j.get("chatContextType"):null,[M,R]=(0,s.useState)(()=>((e,t)=>{try{let s=localStorage.getItem(e);return s?JSON.parse(s):t}catch(s){return console.error(`Error loading ${e} from localStorage:`,s),t}})(b,[])),[F,$]=(0,s.useState)(""),[U,q]=(0,s.useState)(""),[Y,G]=(0,s.useState)(!1),[K,H]=(0,s.use
1State)(!1),[J,Z]=(0,s.useState)(!1),[V,W]=(0,s.useState)(null),[Q,X]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[es,eo]=(0,s.useState)(!0),[er,ea]=(0,s.useState)("chat"),[ei,en]=(0,s.useState)(!1),[el,eu]=(0,s.useState)(null),[ec,ed]=(0,s.useState)(null),[ep,ey]=(0,s.useState)(!1),[eh,em]=(0,s.useState)(null),[ef,eg]=(0,s.useState)(null),eb=(0,s.useRef)(null),e_=(0,s.useRef)(null),eS=(0,l.useCreateWebsite)(),{data:ew}=(0,h.useBillingOverview)(),ev="custom",eI="latest",eC=(0,s.useCallback)(()=>eh?v:"BUSINESS_DNA_ONBOARDING",[eh]),eE=ee?.status==="COMPLETED",ex=(0,s.useMemo)(()=>eE?M.filter(e=>"business-dna-completion"!==e.data.type):M,[eE,M]);(0,s.useEffect)(()=>{try{localStorage.setItem(b,JSON.stringify(M))}catch(e){console.error(`Error saving ${b} to localStorage:`,e)}},[M]),(0,s.useEffect)(()=>{if(U)return;let e=new URLSearchParams(window.location.search).get("promptMode"),t=(0,u.getPromptModeConfig)(e);e&&t.skillId&&q(t.skillId)},[U]);let ek=(0,s.useCallback)(e=>{if(e)return(0,u.getPromptModeConfig)(e);if(ef)return(0,u.getPromptModeConfig)(ef);let t=new URLSearchParams(window.location.search).get("promptMode");return(0,u.getPromptModeConfig)(t)},[ef]);(0,s.useEffect)(()=>{B&&L&&(k(L),"wordpress"===z||"shopify"===z||"saas"===z||"custom"===z||"reseller"===z?T(z):T("custom"))},[B,z,L,T,k]),(0,s.useEffect)(()=>{O||(ea("chat"),en(!1))},[O]),(0,s.useEffect)(()=>{if(!B||!x||!A){et(null),eo(!1);return}let e=!1;return et(null),eo(!0),f.apiClient.getProject(x,A).then(t=>{if(e)return;let s=t.data,{latestJobId:o,status:r}=s;if(et(s),!o||!r||_.has(r)){H(!1),W(null),Z(!1);return}H(!0),Z(!1),W(o)}).catch(t=>{e||(console.error("Failed to restore latest chat build state:",t),et(null),H(!1),W(null),Z(!1))}).finally(()=>{e||eo(!1)}),()=>{e=!0}},[B,x,A]);let eT=(0,s.useCallback)(async e=>{if(ew?.currentPlan?.slug!=="free")return void D.invalidateQueries({queryKey:["ai-credits"]});try{let t=await D.fetchQuery({queryKey:["ai-credits"],queryFn:()=>f.apiClient.getAiCredits(A||void 0),staleTime:0}),s=y.CREDIT_ACTION_COSTS[e];Math.max(0,t.balance??0)<s&&(0,p.handle402Error)({data:{isFreePlan:!0}})}catch{D.invalidateQueries({queryKey:["ai-credits"]})}},[ew?.currentPlan?.slug,D,A]),eA=(0,r.useMutation)({mutationFn:async e=>("BUSINESS_DNA_ONBOARDING"===e.actionType?await ej("BUSINESS_DNA_ONBOARDING"):"AI_ASSISTANT_MESSAGE"===e.actionType&&await ej("AI_ASSISTANT_MESSAGE"),f.apiClient.initializeChat(e,A||void 0)),onSuccess:(e,t)=>{let s=C(e);eT(s.businessDNA?v:t.actionType),s.businessDNA&&em(I(s.businessDNA,s.routingFields))},onError:(e,t)=>{console.error("Shopify chat API error:",e)}}),eP=(0,s.useCallback)((e,t)=>{let s={id:`${Date.now()}-${Math.random()}`,sender:e,data:t,timestamp:new Date};R(e=>[...e,s])},[]),eN=(0,s.useCallback)(()=>{R([]),$(""),q(""),G(!1),H(!1),Z(!1),W(null),X(!1),eu(null),ey(!1),em(null),eg(null),ea("chat"),localStorage.removeItem(b)},[]),{assertCredits:ej}=(0,y.useCreditActionGuard)(),eD=(0,s.useCallback)(async e=>{let t=e.trim();if(t){eP("user",{type:"composite",text:t}),$(""),G(!0);try{if(ep){ey(!1);let e=t;(e=(e=e.replace(/^https?:\/\//,"")).replace(/\/$/,"")).includes(".")||(e=`${e}.myshopify.com`);try{eP("assistant",{type:"composite",text:`Connecting to your Shopify store at \`${e}\`...`});let{redirectUrl:t}=await f.apiClient.initiateAppInstall(e,A||void 0),s=(0,c.openOAuthPopup)(t,600,700,"Shopify App Install");s?(eP("assistant",{type:"composite",text:`â Please complete the authorization in the popup window to connect your Shopify store.`}),(0,c.monitorPopupClose)(s,async()=>{console.log("OAuth popup closed, checking connection status..."),G(!0);try{if(await new Promise(e=>setTimeout(e,1e4)),(await f.apiClient.checkOAuthConnectionStatus(e,A||void 0)).isConnected){eP("assistant",{type:"composite",text:`â **Store Connected!** 2 3Your Shopify store \`${e}\` has been successfully connected. Installing your theme now...`}),G(!0);try{let t=eh??C(eA.data).businessDNA;if(!t)throw Error("Business DNA is not available. Please complete the business profile before installing.");let s={shop:e,themeName:"NeuralDNS Theme",zipUrl:"https://github.com/anshul0724/shopify-theme/raw/refs/heads/main/New-Theme.zip",sessionId:x||"",business_dna:{biz_category:t.biz_category,location_model:t.location_model,target_audience:t.target_audience,design_vibe:t.design_vibe,usp_hook:t.usp_hook,conversion_goal:t.conversion_goal,biz_stage:t.biz_stage,naming_status:{has_name:t.naming_status.has_name,value:t.naming_status.value,keywords:t.naming_status.keywords?.join(", ")||null}}},{jobId:o}=await f.apiClient.installShopifyTheme(s,A||void 0);G(!1),H(!0),await (0,d.pollUntilComplete)({fn:()=>f.apiClient.getBuilderJobStatus(o,A||void 0),isComplete:e=>"COMPLETED"===e.status,isFailed:e=>"FAILED"===e.status,onComplete:()=>{H(!1),eP("assistant",{type:"composite",text:`ð **Theme Installed!** 4 5Your theme has been successfully installed on \`${e}\`. 6 7You can now proceed with building your store.`})},onFailed:()=>{H(!1),eP("assistant",{type:"composite",text:`â ï¸ **Theme Installation Failed** 8
9The theme installation job failed. Please try again or contact support.`})},onTimeout:()=>{H(!1),eP("assistant",{type:"composite",text:`â³ **Installation Taking Longer Than Expected** 10 11The theme installation is still in progress. Please check your Shopify dashboard for updates.`})},onError:e=>{console.error("Error polling install job status:",e)}})}catch(t){console.error("Failed to install Shopify theme:",t),H(!1);let e=t?.message;eP("assistant",{type:"composite",text:`â ï¸ **Theme Installation Failed** 12 13${e||"Your store was connected but the theme installation encountered an error. Please try again or contact support."}`})}}else eP("assistant",{type:"composite",text:`â ï¸ **Connection Not Completed** 14 15It looks like the authorization wasn't completed. This can happen if: 16- You cancelled the authorization 17- The popup was closed before completing 18- There was an error during the process 19 20Would you like to try connecting again? Just send me your store domain.`})}catch(e){console.error("Failed to check OAuth status:",e),eP("assistant",{type:"composite",text:`â ï¸ **Unable to Verify Connection** 21 22I couldn't verify if your store was connected successfully. Please refresh the page or try again.`})}finally{G(!1)}})):eP("assistant",{type:"composite",text:`â ï¸ **Popup Blocked** 23 24Please allow popups for this site and try again.`})}catch(t){console.error("Failed to initiate app install:",t),eP("assistant",{type:"composite",text:`â ï¸ **Connection Failed** 25 26Failed to connect to \`${e}\`. Please verify the store URL and try again. 27 28Make sure to enter your full Shopify store URL (e.g., \`your-store.myshopify.com\`).`})}G(!1);return}let e=ek(),s=U||e.skillId,o={sessionId:x||"",message:t,actionType:eC(),...e,...s?{skillId:s,skillType:e.skillType??ev,skillVersion:e.skillVersion??eI}:{}},r=await eA.mutateAsync(o),a=C(r);if(a.promptText&&eu(a.promptText),r)if(a.businessDNA){let e=I(a.businessDNA,a.routingFields);console.log("[Chat] Creating business-dna-completion message"),eP("assistant",{type:"business-dna-completion",text:a.message||"I've analyzed your business and created a comprehensive DNA profile!",businessDNA:e})}else console.log("[Chat] Creating composite message (no business_dna)"),eP("assistant",{type:"composite",text:a.message||`I've processed your request about: "${t}". How can I help you further with your store?`,promptText:a.promptText,messageId:a.messageId});else eP("assistant",{type:"composite",text:`I've received your message: "${t}". How can I assist you with your Shopify store setup?`,promptText:void 0})}catch(e){if(console.error("Error handling message:",e),(0,p.is402Error)(e))return void(0,p.handle402Error)(e);eP("assistant",{type:"composite",text:`â ï¸ **Error** 29 30I encountered an error processing your message. Please try again.`,promptText:void 0})}finally{G(!1)}}},[eP,eA,x,U,ep,A,eh,ek,eC]),eO=(0,s.useCallback)(async e=>{let t=e.trim().replace(/^[\"ââ]+|[\"ââ]+$/g,"").trim(),s=[...M].reverse().find(e=>"assistant"===e.sender)?.data?.text;if(S.test(t)&&"string"==typeof s&&w.test(s)){let e=F.split(",").map(e=>e.trim()).filter(e=>S.test(e)),s=t.toLowerCase();$((e.some(e=>e.toLowerCase()===s)?e.filter(e=>e.toLowerCase()!==s):[...e,t]).join(", "));return}t.toLowerCase().includes("i already have a name")||t.toLowerCase().includes("i have a name")?$("My business name is"):await eD(t)},[F,eD,M]),eB=(0,s.useCallback)(async(e,t)=>{eP("user",{type:"composite",text:"yes"===t?"Yes":"No"}),G(!0),await new Promise(e=>setTimeout(e,1500));try{"shopify-store-check"===e?"yes"===t?(ey(!0),eP("assistant",{type:"composite",text:"Perfect! Please provide your Shopify store domain (e.g., `your-store.myshopify.com` or `yourstore.com`)."})):eP("assistant",{type:"composite",text:`No problem! You'll need to create a Shopify store first. 31 32<a href="https://www.shopify.com/signup" target="_blank" rel="noopener noreferrer">**Create your Shopify store â**</a> 33 34Once you've created your store, come back here and we'll help you connect it. Just click "Let's build it!" again when you're ready. 35 36Is there anything else I can help you with in the meantime?`}):"confirm-action"===e?eP("assistant",{type:"composite",text:"yes"===t?"Great! Proceeding with the action.":"Action cancelled. Let me know if you need help with anything else.",promptText:void 0}):eP("assistant",{type:"composite",text:`You chose: ${t}. How else can I assist you with your Shopify store?`,promptText:void 0})}catch(e){console.error("Error handling button click:",e),eP("assistant",{type:"composite",text:`â ï¸ **Error** 37 38I encountered an error processing your choice. Please try again.`})}finally{G(!1)}},[eP,ey]),eL=(0,s.useCallback)(async(e,t,s,o=!1)=>
38{if(!t)throw Error("No session ID available");let r=e.trim();if(r){o||eP("user",{type:"composite",text:r}),$(""),G(!0);try{s&&eg(s);let e=ek(s),o=U||e.skillId,a={sessionId:t,message:r,actionType:eC(),...e,...o?{skillId:o,skillType:e.skillType??ev,skillVersion:e.skillVersion??eI}:{}},i=await eA.mutateAsync(a),n=C(i);if(console.log("[Chat Init] API Response:",i),console.log("[Chat Init] Business DNA:",n.businessDNA),console.log("[Chat Init] Prompt Text:",n.promptText),n.promptText&&eu(n.promptText),i)if(n.businessDNA){let e=I(n.businessDNA,n.routingFields);console.log("[Chat Init] Creating business-dna-completion message"),eP("assistant",{type:"business-dna-completion",text:n.message||"I've analyzed your business and created a comprehensive DNA profile!",businessDNA:e})}else console.log("[Chat Init] Creating composite message (no business_dna)"),eP("assistant",{type:"composite",text:n.message||`I've processed your request about: "${r}". How can I help you further with your Shopify store?`,promptText:n.promptText,messageId:n.messageId});else eP("assistant",{type:"composite",text:`I've received your message: "${r}". How can I assist you with your Shopify store setup?`,promptText:void 0})}catch(e){if(console.error("Error initializing chat:",e),(0,p.is402Error)(e))return void(0,p.handle402Error)(e);eP("assistant",{type:"composite",text:`â ï¸ **Error** 39 40I encountered an error initializing the chat. Please try again.`,promptText:void 0})}finally{G(!1)}}},[eP,eA,U,ek,eC]),ez=(0,s.useCallback)(async(e,t)=>{if(!t)throw Error("No session ID available");let s=e.trim();s&&(eg("speed-sensing-layer"),await eL(s,t,"speed-sensing-layer"),$(""))},[eL]),eM=(0,s.useCallback)(async(e,t)=>{$(t)},[]);(0,s.useEffect)(()=>{if(!O||!A){e_.current=null;return}let e=(0,g.normalizeDirectChatPrompt)(j.get(g.DIRECT_CHAT_QUERY_PARAM)),t=j.get(g.DIRECT_CHAT_PENDING_PARAM)===g.DIRECT_CHAT_PENDING_VALUE;if(!e&&!t){e_.current=null;return}let s=!e&&t?(0,g.readPendingDirectChatPrompt)():null,o=e??s;if(!o){if(t&&1){let e=new URLSearchParams(j.toString());e.delete(g.DIRECT_CHAT_PENDING_PARAM);let t=e.toString();P.replace(t?`${N}?${t}`:N,{scroll:!1})}return}let r=`${e?"query":"pending"}:${o}`;e_.current!==r&&(e_.current=r,(async()=>{try{let e=await f.apiClient.createSessionId(A);if(e_.current!==r||!e?.sessionId)return;let t="custom";if(eN(),(0,m.trackBuilderLifecycleEvent)("Builder session started",{surface:"direct_chat",context_type:t,session_id:e.sessionId}),k(e.sessionId),T(t),await ez(o,e.sessionId),e_.current!==r)return;(0,g.clearPendingDirectChatPrompt)();let s=new URLSearchParams;s.set("sessionId",e.sessionId),s.set("chatContextType",t),P.replace(`/chat?${s.toString()}`,{scroll:!1})}catch(e){e_.current=null,console.error("Failed to initialize direct chat prompt:",e),(0,p.is402Error)(e)&&(0,p.handle402Error)(e)}})())},[ej,eN,ez,O,N,P,j,T,k,A]);let eR=(0,s.useCallback)(async e=>{console.log("Creating website with data:",e),console.log("Auth token available:",!!n.useAuthStore.getState().token),H(!0);try{let t=await eS.mutateAsync(e);console.log("Website creation initiated:",t);let s=i.useSessionStore.getState().sessionId,o=i.useSessionStore.getState().chatContextType;if(!s)throw Error("Session ID not found");let r=i.useSessionStore.getState().chatContextType;(0,m.trackBuilderLifecycleEvent)("Build started",{surface:"chat",context_type:r||"wordpress",session_id:s,job_id:t.sessionId||s,status:t.status,has_job:!!(t.sessionId||s)}),await (0,d.pollUntilComplete)({fn:()=>f.apiClient.getBuilderJobStatus(s,n.useAuthStore.getState().token||void 0),isComplete:e=>"COMPLETED"===e.status,isFailed:e=>"FAILED"===e.status,onComplete:e=>{(0,m.trackBuilderLifecycleEvent)("Build completed",{surface:"chat",context_type:r||"wordpress",session_id:s,job_id:e.jobId??s,status:e.status,has_job:!!(e.jobId??s)},{dedupeKey:(0,m.getBuilderLifecycleDedupeKey)("Build completed",{job_id:e.jobId??s,status:e.status})});let t=e.deploymentUrl||null,a=`/chat/playground?sessionId=${s}&chatContextType=${o||"custom"}`;t?eP("assistant",{type:"markdown",text:`## ð Your website is live! 41 42**ð Live URL:** [${t}](${t}) 43 44Head over to the **Playground** to start making changes â tweak your design, update content, and see edits in real time.`,actions:[{label:"Go to Playground",href:a}]}):eP("assistant",{type:"composite",text:`ð **Your website has been successfully created!** 45 46Please check your email or dashboard for the website details.`}),H(!1),P.replace(a)},onFailed:e=>{(0,m.trackBuilderLifecycleEvent)("Build failed",{surface:"chat",context_type:r||"wordpress",session_id:s,job_id:e.jobId??s,status:e.status,phase:"terminal",has_job:!!(e.jobId??s),error_present:!!e.error},{dedupeKey:(0,m.getBuilderLifecycleDedupeKey)("Build failed",{job_id:e.jobId??s,status:e.status,phase:"terminal"})});let t=e.error||"Unknown error";eP("assistant",{type:"composite",text:`â ï¸ **Website creation failed** 47 48Error: ${t} 49
50Please try again or contact support if the problem persists.`}),H(!1)},onTimeout:()=>{(0,m.trackBuilderLifecycleEvent)("Build failed",{surface:"chat",context_type:r||"wordpress",session_id:s,job_id:s,status:"TIMEOUT",phase:"timeout",has_job:!0,error_present:!0},{dedupeKey:(0,m.getBuilderLifecycleDedupeKey)("Build failed",{job_id:s,status:"TIMEOUT",phase:"timeout"})}),eP("assistant",{type:"composite",text:`â³ **Your request is taking longer than expected** 51 52The website creation is still in progress. Please check your dashboard shortly for updates.`}),H(!1)},onError:e=>{console.error("Error polling session status:",e)},interval:6e3,maxAttempts:300})}catch(r){console.error("Website creation failed:",r),H(!1);let e=i.useSessionStore.getState().sessionId,t=i.useSessionStore.getState().chatContextType;(0,m.trackBuilderLifecycleEvent)("Build failed",{surface:"chat",context_type:t||"wordpress",session_id:e,status:"ERROR",phase:"start_request",has_job:!1,error_present:!0});let s=r?.status||r?.response?.status||r?.data?.status||r?.cause?.status,o=r?.message||r?.cause?.message;if(524===s||"Failed to fetch"===o)return void eP("assistant",{type:"composite",text:`â³ **Your request is taking longer than expected** 53 54This can take a few minutes. Your request was sent and is still processing. 55Please check your dashboard shortly or refresh to see the website once it's ready.`});eP("assistant",{type:"composite",text:`â ï¸ **Something went wrong** 56 57I encountered an issue while creating your website. Please try again or contact support if the problem persists.`})}},[eS,eP,P]),eF=(0,s.useCallback)(async(e,t)=>{let s;if(J||K)return;let{chatContextType:o,sessionId:r}=i.useSessionStore.getState();Z(!0);try{let a=async()=>{if(!r)return!1;try{let e=(await f.apiClient.getProject(r,n.useAuthStore.getState().token||void 0)).data;et(e);let s=e.latestJobId,o=e.status;if(!s||!o)return!1;if(!_.has(o))return H(!0),Z(!1),W(s),!0;if(!t?.allowRestartFromTerminalJob)return H(!1),Z(!1),W(null),!0;return!1}catch(e){return console.error("Failed to inspect existing build state before starting a new build:",e),!1}};if("shopify"===o)return void eP("assistant",{type:"composite",text:`Great! Let's connect your Shopify store. 58 59**Do you already have a Shopify store?**`,hasButtons:!0,buttonAction:"shopify-store-check"});if(H(!0),W(null),"wordpress"===o){if(await a())return;await eR({subdomain:e.naming_status.value,region:"us-central1-c",site_title:e.naming_status.value,admin_username:"admin",admin_password:"MySecurePass123",is_demo:"0",demo_domain_delete_after_days:7,business_type:e.biz_category,business_name:e.naming_status.value,business_description:ec||"",sessionId:r||void 0});return}if("custom"===o||"saas"===o||"reseller"===o){if(await a())return;let t=async()=>{H(!0),Z(!0),W(null);let t=M.find(e=>"user"===e.sender)?.data.text||"",s=await f.apiClient.createBuilderJob({sessionId:r||"",prompt:t,business_dna:{biz_category:e.biz_category,location_model:e.location_model,target_audience:e.target_audience,design_vibe:e.design_vibe,usp_hook:e.usp_hook,conversion_goal:e.conversion_goal,biz_stage:e.biz_stage,reseller_page:e.reseller_page??!1,tld_list:e.tld_list??[],tld_details:e.tld_details??[],tld_present:e.tld_present??!1,naming_status:{has_name:e.naming_status.has_name,value:e.naming_status.value,keywords:e.naming_status.keywords?.join(", ")||null}}},n.useAuthStore.getState().token||void 0);(0,m.trackBuilderLifecycleEvent)("Build started",{surface:"chat",context_type:o||"custom",session_id:r,job_id:s.jobId,status:s.status,has_job:!!s.jobId}),s.message&&eP("assistant",{type:"composite",text:s.message,messageId:s.messageId??void 0}),W(s.jobId),D.invalidateQueries({queryKey:["ai-credits"]})};s=t,await t();return}}catch(t){let e=t instanceof Error?t.message:"Something went wrong.";if(console.warn("Failed to start build:",e),(0,m.trackBuilderLifecycleEvent)("Build failed",{surface:"chat",context_type:o||"custom",session_id:r,status:"ERROR",phase:"start_request",has_job:!1,error_present:!0}),H(!1),W(null),Z(!1),(0,p.is402Error)(t))return void(0,p.handle402Error)(t,{onTrialActivated:s});eP("assistant",{type:"markdown",text:"Failed to fetch"===e?"â ï¸ **Failed to Start Build**\n\nCould not reach the build service. Please check that the API is reachable and try again.":"â ï¸ **Failed to Start Build**\n\nSomething went wrong. Please try again."});return}finally{"custom"!==o&&"saas"!==o&&"reseller"!==o&&Z(!1)}Z(!1),eP("assistant",{type:"composite",text:"â ï¸ **Unsupported context**\n\nPlease choose a valid build context and try again."})},[eP,ec,eR,J,K,M]),e$=(0,s.useMemo)(()=>({messages:ex,currentMessage:F,setCurrentMessage:$,skillId:U,setSkillId:q,isTyping:Y,isCreatingWebsite:K,isBuildSubmitting:J,activeBuilderJobId:V,isSearchingDomains:Q,handleSendMessage:eD,handleListItemClick:eO,handleButtonClick:eB,handleClarificationOptionClick:eM,messagesEndRef:eb,initializeChatWithMessage:eL,initializeChatWithPromptModeSelection:ez,isInitializing:eA.isPending,error:eA.error?.message||null,clearChat:eN,promptText:el,createWebsite:eR,startWebsiteBuild:eF,addMessage:eP,setAwaitingShopDomain:ey,isAwaitingShopDomain:ep,setIsCreatingWebsite:H,setIsBuildSubmitting:Z,setActiveBuilderJobId:W,project:ee,setProject:et,isProjectLoading:es,compactPane:er,setCompactPane:ea,isCompactChat:ei,setIsCompactChat:en}),[ex,F,U,Y,K,J,V,Q,ee,et,es,er,ei,eD,eO,eB,eM,eL,ez,eA.isPending,eA.error,eN,el,ec,eR,eF,eP,q,ep,ea,en]);return(0,t.jsx)(E.Provider,{value:e$,children:e})}function k(){let e=(0,s.useContext)(E);if(void 0===e)throw Error("useChatContext must be used within a ChatProvider");return e}e.s(["ChatProvider",()=>x,"useChatContext",()=>k])},454624,e=>{"use strict";e.i(247167);var t=e.i(271645),s=e.i(207670),o=e.i(519130),r=e.i(942196),a=e.i(940799),i=e.i(75149),n=e.i(594425),l=e.i(540672),u=e.i(319727);function c(e){return(0,u.default)("MuiSvgIcon",e)}(0,l.default)("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);var d=e.i(843476);let p=(0,a.styled)("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(e,t)=>{let{ownerState:s}=e;return[t.root,"inherit"!==s.color&&t[`color${(0,r.default)(s.color)}`],t[`fontSize${(0,r.default)(s.fontSize)}`]]}})((0,i.default)(({theme:e})=>({userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:e.transitions?.create?.("fill",{duration:(e.vars??e).transitions?.duration?.shorter}),variants:[{props:e=>!e.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:e.typography?.pxToRem?.(20)||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:e.typography?.pxToRem?.(24)||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:e.typography?.pxToRem?.(35)||"2.1875rem"}},...Object.entries((e.vars??e).palette).filter(([,e])=>e&&e.main).map(([t])=>({props:{color:t},style:{color:(e.vars??e).palette?.[t]?.main}})),{props:{color:"action"},style:{color:(e.vars??e).palette?.action?.active}},{props:{color:"disabled"},style:{color:(e.vars??e).palette?.action?.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}))),y=t.forwardRef(function(e,a){let i=(0,n.useDefaultProps)({props:e,name:"MuiSvgIcon"}),{children:l,className:u,color:y="inherit",component:h="svg",fontSize:m="medium",htmlColor:f,inheritViewBox:g=!1,titleAccess:b,viewBox:_="0 0 24 24",...S}=i,w=t.isValidElement(l)&&"svg"===l.type,v={...i,color:y,component:h,fontSize:m,instanceFontSize:e.fontSize,inheritViewBox:g,viewBox:_,hasSvgAsChild:w},I={};
59g||(I.viewBox=_);let C=(e=>{let{color:t,fontSize:s,classes:a}=e,i={root:["root","inherit"!==t&&`color${(0,r.default)(t)}`,`fontSize${(0,r.default)(s)}`]};return(0,o.default)(i,c,a)})(v);return(0,d.jsxs)(p,{as:h,className:(0,s.default)(C.root,u),focusable:"false",color:f,"aria-hidden":!b||void 0,role:b?"img":void 0,ref:a,...I,...S,...w&&l.props,ownerState:v,children:[w?l.props.children:l,b?(0,d.jsx)("title",{children:b}):null]})});function h(e,s){function o(t,s){return(0,d.jsx)(y,{"data-testid":void 0,ref:s,...t,children:e})}return o.muiName=y.muiName,t.memo(t.forwardRef(o))}y.muiName="SvgIcon",e.s(["default",()=>h],454624)}]);
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.