(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[331],{2283:(e,t,n)=>{"use strict";n.d(t,{$H:()=>s,Im:()=>l,Jf:()=>u,O9:()=>o,hj:()=>i,pN:()=>r,w$:()=>a});let a=async e=>{let t;try{let n="string"==typeof e?e:e.url;t=await fetch(n,{method:"string"==typeof e?"GET":e.method,mode:"cors",headers:"string"!=typeof e&&o(e.body)?{"Content-Type":"application/json"}:void 0,body:"string"!=typeof e&&o(e.body)?JSON.stringify(e.body):void 0});let a=await t.json();if(!t.ok)throw"error"in a?a.error:a;return{data:a,response:t}}catch(e){return console.error(e),{error:e,response:t}}},o=e=>null!=e,r=e=>null==e,l=e=>null==e||""===e,i=e=>null!=e&&""!==e,s=e=>t=>t.id===e,u=e=>e.startsWith("http")||e.startsWith("mailto:")||e.startsWith("tel:")||e.startsWith("sms:")||/^\{\{.*\}\}/.test(e)?e:"https://".concat(e)},3735:(e,t,n)=>{"use strict";n.d(t,{_:()=>U});var a,o=n(79616),r=n(6663),l=n(33601);let i=(e,t)=>{var n,a;return"undefined"!=typeof window?window.__ENV?null!=(n=window.__ENV[e])?n:t:void 0:void 0!==l?null!=(a=l.env[e])?a:t:void 0};var s=n(33601);let u=r.k5(["true","false"]).transform(e=>"true"===e),d={server:{NODE_ENV:r.k5(["development","staging","production","test"]).optional(),DATABASE_URL:r.Yj().url().refine(e=>e.startsWith("postgres")||e.startsWith("mysql")),ENCRYPTION_SECRET:r.Yj().length(32),NEXTAUTH_URL:r.vk(e=>e&&"string"==typeof e&&e.length>0||"preview"!==s.env.VERCEL_ENV||!s.env.VERCEL_BUILDER_PROJECT_NAME||!s.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME?e:s.env.VERCEL_BRANCH_URL.includes(s.env.VERCEL_BUILDER_PROJECT_NAME)?"https://".concat(s.env.VERCEL_BRANCH_URL):"https://".concat(s.env.VERCEL_BRANCH_URL).replace(s.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME,s.env.VERCEL_BUILDER_PROJECT_NAME),r.Yj().url()),DISABLE_SIGNUP:u.optional().default("false"),ADMIN_EMAIL:r.Yj().min(1).optional().transform(e=>null==e?void 0:e.split(",")),DEFAULT_WORKSPACE_PLAN:r.k5(["FREE","STARTER","PRO","LIFETIME","UNLIMITED"]).refine(e=>["FREE","STARTER","PRO","LIFETIME","UNLIMITED"].includes(e)).default("FREE"),DEBUG:u.optional().default("false"),CHAT_API_TIMEOUT:r.au.number().optional(),RADAR_HIGH_RISK_KEYWORDS:r.Yj().min(1).transform(e=>e.split(",")).optional(),RADAR_INTERMEDIATE_RISK_KEYWORDS:r.Yj().min(1).transform(e=>e.split(",")).optional(),RADAR_CUMULATIVE_KEYWORDS:r.Yj().min(1).transform(e=>e.split("/").map(e=>e.split(",").map(e=>e.split("|")))).optional(),TRADEMARK_VIOLATION_KEYWORDS:r.Yj().min(1).transform(e=>e.split(",")).optional(),LANDING_PAGE_URL:r.vk(e=>e&&"string"==typeof e&&e.length>0||"preview"!==s.env.VERCEL_ENV||!s.env.VERCEL_LANDING_PROJECT_NAME?e:"https://".concat(s.env.VERCEL_BRANCH_URL),r.Yj().url().optional())},client:{NEXT_PUBLIC_VIEWER_URL:r.vk(e=>e&&"string"==typeof e&&e.length>0||"preview"!==s.env.VERCEL_ENV||!s.env.VERCEL_BUILDER_PROJECT_NAME||!s.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME?e:s.env.VERCEL_BRANCH_URL.includes(s.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME)?"https://".concat(s.env.VERCEL_BRANCH_URL):"https://".concat(s.env.VERCEL_BRANCH_URL).replace(s.env.VERCEL_BUILDER_PROJECT_NAME,s.env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME),r.Yj().min(1).transform(e=>e.split(","))),NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID:r.Yj().min(1).optional(),NEXT_PUBLIC_BOT_FILE_UPLOAD_MAX_SIZE:r.au.number().optional(),NEXT_PUBLIC_CHAT_API_URL:r.Yj().url().optional(),NEXT_PUBLIC_VIEWER_404_TITLE:r.Yj().optional().default("404"),NEXT_PUBLIC_VIEWER_404_SUBTITLE:r.Yj().optional().default("The bot you're looking for doesn't exist")},runtimeEnv:{NEXT_PUBLIC_VIEWER_URL:i("NEXT_PUBLIC_VIEWER_URL"),NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID:i("NEXT_PUBLIC_ONBOARDING_TYPEBOT_ID"),NEXT_PUBLIC_BOT_FILE_UPLOAD_MAX_SIZE:i("NEXT_PUBLIC_BOT_FILE_UPLOAD_MAX_SIZE"),NEXT_PUBLIC_CHAT_API_URL:i("NEXT_PUBLIC_CHAT_API_URL"),NEXT_PUBLIC_USE_EXPERIMENTAL_CHAT_API_ON:i("NEXT_PUBLIC_USE_EXPERIMENTAL_CHAT_API_ON"),NEXT_PUBLIC_VIEWER_404_TITLE:i("NEXT_PUBLIC_VIEWER_404_TITLE"),NEXT_PUBLIC_VIEWER_404_SUBTITLE:i("NEXT_PUBLIC_VIEWER_404_SUBTITLE")}},c={server:{GITHUB_CLIENT_ID:r.Yj().min(1).optional(),GITHUB_CLIENT_SECRET:r.Yj().min(1).optional()}},p={server:{FACEBOOK_CLIENT_ID:r.Yj().min(1).optional(),FACEBOOK_CLIENT_SECRET:r.Yj().min(1).optional()}},b={server:{SMTP_USERNAME:r.Yj().min(1).optional(),SMTP_PASSWORD:r.Yj().min(1).optional(),SMTP_HOST:r.Yj().min(1).optional(),SMTP_PORT:r.au.number().optional().default(25),SMTP_AUTH_DISABLED:u.optional().default("false"),SMTP_SECURE:u.optional().default("false"),SMTP_IGNORE_TLS:u.optional()},client:{NEXT_PUBLIC_SMTP_FROM:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_SMTP_FROM:i("NEXT_PUBLIC_SMTP_FROM")}},m={server:{GITLAB_CLIENT_ID:r.Yj().min(1).optional(),GITLAB_CLIENT_SECRET:r.Yj().min(1).optional(),GITLAB_BASE_URL:r.Yj().url().optional().default("https://gitlab.com"),GITLAB_NAME:r.Yj().min(1).optional().default("GitLab"),GITLAB_REQUIRED_GROUPS:r.Yj().transform(e=>e?e.split(","):void 0).optional()}},h={server:{AZURE_AD_CLIENT_ID:r.Yj().min(1).optional(),AZURE_AD_CLIENT_SECRET:r.Yj().min(1).optional(),AZURE_AD_TENANT_ID:r.Yj().min(1).optional()}},g={server:{CUSTOM_OAUTH_NAME:r.Yj().min(1).optional().default("Custom OAuth"),CUSTOM_OAUTH_SCOPE:r.Yj().min(1).optional().default("openid profile email"),CUSTOM_OAUTH_CLIENT_ID:r.Yj().min(1).optional(),CUSTOM_OAUTH_CLIENT_SECRET:r.Yj().min(1).optional(),CUSTOM_OAUTH_WELL_KNOWN_URL:r.Yj().url().optional(),CUSTOM_OAUTH_USER_ID_PATH:r.Yj().min(1).optional().default("id"),CUSTOM_OAUTH_USER_EMAIL_PATH:r.Yj().min(1).optional().default("email"),CUSTOM_OAUTH_USER_NAME_PATH:r.Yj().min(1).optional().default("name"),CUSTOM_OAUTH_USER_IMAGE_PATH:r.Yj().min(1).optional().default("image"),CUSTOM_OAUTH_ISSUER:r.vk(e=>{var t;return e||(null==(t=s.env.CUSTOM_OAUTH_WELL_KNOWN_URL)?void 0:t.split("/.well-known")[0])},r.Yj().url().optional())}},y={server:{GOOGLE_AUTH_CLIENT_ID:r.Yj().min(1).optional(),GOOGLE_AUTH_CLIENT_SECRET:r.Yj().min(1).optional()}},f={server:{GOOGLE_SHEETS_CLIENT_ID:r.Yj().min(1).optional(),GOOGLE_SHEETS_CLIENT_SECRET:r.Yj().min(1).optional()},client:{NEXT_PUBLIC_GOOGLE_SHEETS_API_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_GOOGLE_SHEETS_API_KEY:i("NEXT_PUBLIC_GOOGLE_SHEETS_API_KEY")}},v={client:{NEXT_PUBLIC_GOOGLE_FONTS_API_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_GOOGLE_FONTS_API_KEY:i("NEXT_PUBLIC_GOOGLE_FONTS_API_KEY")}},w={server:{STRIPE_SECRET_KEY:r.Yj().min(1).optional(),STRIPE_WEBHOOK_SECRET:r.Yj().min(1).optional(),STRIPE_STARTER_PRICE_ID:r.Yj().min(1).optional(),STRIPE_STARTER_CHATS_PRICE_ID:r.Yj().min(1).optional(),STRIPE_PRO_PRICE_ID:r.Yj().min(1).optional(),STRIPE_PRO_CHATS_PRICE_ID:r.Yj().min(1).optional()},client:{NEXT_PUBLIC_STRIPE_PUBLIC_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_STRIPE_PUBLIC_KEY:i("NEXT_PUBLIC_STRIPE_PUBLIC_KEY")}},x={server:{S3_ACCESS_KEY:r.Yj().min(1).optional(),S3_SECRET_KEY:r.Yj().min(1).optional(),S3_BUCKET:r.Yj().min(1).optional().default("typebot"),S3_PORT:r.au.number().optional(),S3_ENDPOINT:r.Yj().min(1).optional(),S3_SSL:u.optional().default("true"),S3_REGION:r.Yj().min(1).optional(),S3_PUBLIC_CUSTOM_DOMAIN:r.Yj().url().optional()}},I={client:{NEXT_PUBLIC_GIPHY_API_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_GIPHY_API_KEY:i("NEXT_PUBLIC_GIPHY_API_KEY")}},E={server:{VERCEL_TOKEN:r.Yj().min(1).optional(),VERCEL_TEAM_ID:r.Yj().min(1).optional(),VERCEL_GIT_COMMIT_SHA:r.Yj().min(1).optional(),VERCEL_BUILDER_PROJECT_NAME:r.Yj().min(1).optional(),VERCEL_LANDING_PROJECT_NAME:r.Yj().min(1).optional()},client:{NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME:r.Yj().min(1).optional(),NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA:r.Yj().min(1).optional(),NEXT_PUBLIC_VERCEL_ENV:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME:i("NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME"),NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA:i("NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA"),NEXT_PUBLIC_VERCEL_ENV:i("NEXT_PUBLIC_VERCEL_ENV")}},T={server:{SLEEKPLAN_SSO_KEY:r.Yj().min(1).optional()}},_={client:{NEXT_PUBLIC_UNSPLASH_APP_NAME:r.Yj().min(1).optional(),NEXT_PUBLIC_UNSPLASH_ACCESS_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_UNSPLASH_APP_NAME:i("NEXT_PUBLIC_UNSPLASH_APP_NAME"),NEXT_PUBLIC_UNSPLASH_ACCESS_KEY:i("NEXT_PUBLIC_UNSPLASH_ACCESS_KEY")}},C={client:{NEXT_PUBLIC_PEXELS_API_KEY:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_PEXELS_API_KEY:i("NEXT_PUBLIC_PEXELS_API_KEY")}},S={server:{META_SYSTEM_USER_TOKEN:r.Yj().min(1).optional(),WHATSAPP_PREVIEW_FROM_PHONE_NUMBER_ID:r.Yj().min(1).optional(),WHATSAPP_PREVIEW_TEMPLATE_NAME:r.Yj().min(1).optional(),WHATSAPP_PREVIEW_TEMPLATE_LANG:r.Yj().min(1).optional().default("en_US"),WHATSAPP_CLOUD_API_URL:r.Yj().url().optional().default("https://graph.facebook.com"),WHATSAPP_INTERACTIVE_GROUP_SIZE:r.au.number().optional().default(3)}},j={server:{REDIS_URL:r.Yj().url().optional()}},N={server:{SENTRY_DSN:r.Yj().min(1).optional(),SENTRY_AUTH_TOKEN:r.Yj().min(1).optional(),SENTRY_PROJECT:r.Yj().min(1).optional(),SENTRY_ORG:r.Yj().min(1).optional()}},k={server:{MESSAGE_WEBHOOK_URL:r.Yj().url().optional(),USER_CREATED_WEBHOOK_URL:r.Yj().url().optional()}},A={client:{NEXT_PUBLIC_POSTHOG_KEY:r.Yj().min(1).optional()},server:{POSTHOG_API_HOST:r.vk(e=>e||s.env.POSTHOG_API_HOST,r.Yj().url().optional().default("https://us.posthog.com")),POSTHOG_PERSONAL_API_KEY:r.Yj().min(1).optional(),POSTHOG_PROJECT_ID:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_POSTHOG_KEY:i("NEXT_PUBLIC_POSTHOG_KEY")}},P={client:{NEXT_PUBLIC_TOLGEE_API_KEY:r.Yj().min(1).optional(),NEXT_PUBLIC_TOLGEE_API_URL:r.Yj().url().optional().default('https://tolgee.server.baptistearno.com"')},runtimeEnv:{NEXT_PUBLIC_TOLGEE_API_KEY:i("NEXT_PUBLIC_TOLGEE_API_KEY"),NEXT_PUBLIC_TOLGEE_API_URL:null!=(a=i("NEXT_PUBLIC_TOLGEE_API_URL"))?a:"https://tolgee.server.baptistearno.com"}},R={server:{KEYCLOAK_CLIENT_ID:r.Yj().min(1).optional(),KEYCLOAK_CLIENT_SECRET:r.Yj().min(1).optional(),KEYCLOAK_REALM:r.Yj().min(1).optional(),KEYCLOAK_BASE_URL:r.Yj().url().optional()}},L={client:{NEXT_PUBLIC_PARTYKIT_HOST:r.Yj().min(1).optional()},runtimeEnv:{NEXT_PUBLIC_PARTYKIT_HOST:i("NEXT_PUBLIC_PARTYKIT_HOST")}},U=(0,o.w)({server:{...d.server,...c.server,...p.server,...b.server,...y.server,...f.server,...w.server,...x.server,...E.server,...T.server,...S.server,...j.server,...m.server,...h.server,...g.server,...N.server,...k.server,...R.server,...A.server},client:{...d.client,...b.client,...f.client,...v.client,...w.client,...I.client,...E.client,..._.client,...C.client,...A.client,...P.client,...L.client},experimental__runtimeEnv:{...d.runtimeEnv,...b.runtimeEnv,...f.runtimeEnv,...v.runtimeEnv,...w.runtimeEnv,...I.runtimeEnv,...E.runtimeEnv,..._.runtimeEnv,...C.runtimeEnv,...A.runtimeEnv,...P.runtimeEnv,...L.runtimeEnv},skipValidation:"true"===s.env.SKIP_ENV_CHECK||"undefined"!=typeof window&&void 0===window.__ENV,onValidationError(e){throw console.error("❌ Invalid environment variables:",e.flatten().fieldErrors),Error("Invalid environment variables: ".concat(JSON.stringify(e.flatten().fieldErrors)))},onInvalidAccess:e=>{throw Error("❌ Attempted to access a server-side environment variable on the client: ".concat(e))}})},27693:()=>{},28157:(e,t,n)=>{"use strict";n.d(t,{hK:()=>o,lG:()=>l,at:()=>r});let a={orange:{light:{1:"#fefcfb",2:"#fff4f0",3:"#ffe8de",4:"#ffd6c7",5:"#ffc8b5",6:"#ffb8a0",7:"#ffa286",8:"#f98868",9:"#ff5924",10:"#f24905",11:"#dc3b00",12:"#5b2a1c"},dark:{1:"#120b09",2:"#1f1411",3:"#371810",4:"#4e1606",5:"#5e1e0b",6:"#6e2c18",7:"#873c26",8:"#ad4d31",9:"#ff5924",10:"#f14b0f",11:"#ff9776",12:"#ffd7ca"}},gray:{light:{1:"#ffffff",2:"#F8F8F8",3:"#f1f1f1",4:"#e8e8e8",5:"#e0e0e0",6:"#dfdfdf",7:"#cecece",8:"#bbbbbb",9:"#8d8d8d",10:"#838383",11:"#464646",12:"#202020"},dark:{1:"#0D0D0D",2:"#1D1D1D",3:"#222222",4:"#2a2a2a",5:"#313131",6:"#3a3a3a",7:"#484848",8:"#606060",9:"#6e6e6e",10:"#7b7b7b",11:"#b4b4b4",12:"#eeeeee"}}};var o=function(e){return e.COLOR="Color",e.IMAGE="Image",e.NONE="None",e}({});let r="Color",l={6:"#FFFFFF","6.1":a.gray.light["2"]};a.orange.light["9"],a.gray.light["3"],a.gray.light["9"],a.gray.light["1"],a.gray.light["12"],a.gray.light["6"],a.orange.light["9"],a.gray.light["1"],a.orange.light["6"],a.orange.light["9"],a.gray.light["1"],a.orange.light["8"],a.gray.light["12"],a.gray.light["7"]},47668:()=>{},51511:(e,t,n)=>{"use strict";n.d(t,{Y:()=>a,f:()=>o});let a=e=>"\x3c!-- Google Tag Manager --\x3e\n(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\nj=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer','".concat(e,"');\n\x3c!-- End Google Tag Manager --\x3e"),o=e=>{if(document.getElementById("gtm-noscript"))return"";let t=document.createElement("noscript");t.id="gtm-noscript";let n=document.createElement("iframe");return n.src="https://www.googletagmanager.com/ns.html?id=".concat(e),n.height="0",n.width="0",n.style.display="none",n.style.visibility="hidden",t.appendChild(n),t}},57246:()=>{},57608:()=>{},57633:()=>{},59393:(e,t,n)=>{"use strict";n.d(t,{M:()=>r});var a=n(6029),o=n(3735);let r=e=>{let{error:t}=e;return(0,a.jsx)("div",{style:{height:"100dvh",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",padding:"0 1rem"},children:o._.NEXT_PUBLIC_VIEWER_URL[0]?(0,a.jsx)("p",{style:{fontSize:"24px",textAlign:"center"},children:t.message}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h1",{style:{fontWeight:"bold",fontSize:"30px"},children:"NEXT_PUBLIC_VIEWER_URL is missing"}),(0,a.jsxs)("h2",{children:["Make sure to configure the app properly (",(0,a.jsx)("a",{href:"https://docs.typebot.io/self-hosting/configuration",children:"https://docs.typebot.io/self-hosting/configuration"}),")"]})]})})}},69443:(e,t,n)=>{"use strict";n.d(t,{L6:()=>a});let a={general:{isInputPrefillEnabled:!1,isHideQueryParamsEnabled:!0,isNewResultOnRefreshEnabled:!0,rememberUser:{isEnabled:!1,storage:"session"},isBrandingEnabled:!1,isTypingEmulationEnabled:!0},typingEmulation:{enabled:!0,speed:400,maxDelay:3,delayBetweenBubbles:0,isDisabledOnFirstMessage:!0},metadata:{description:"Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form.",favIconUrl:e=>e+"/favicon.svg",imageUrl:e=>e+"/site-preview.png"}}},72032:(e,t,n)=>{"use strict";n.d(t,{N:()=>aK});var a,o=n(6029),r=n(2283),l=n(69443),i=n(96059),s=n(3735),u=n(28157),d=n(55729),c=function(e){return e.TEXT="text",e.IMAGE="image",e.VIDEO="video",e.EMBED="embed",e.AUDIO="audio",e}({}),p=function(e){return e.TEXT="text input",e.NUMBER="number input",e.EMAIL="email input",e.URL="url input",e.DATE="date input",e.TIME="time input",e.PHONE="phone number input",e.CHOICE="choice input",e.PICTURE_CHOICE="picture choice input",e.PAYMENT="payment input",e.RATING="rating input",e.FILE="file input",e.CARDS="cards",e}({}),b=function(e){return e.GOOGLE_SHEETS="Google Sheets",e.OPEN_AI="OpenAI",e.GOOGLE_ANALYTICS="Google Analytics",e.HTTP_REQUEST="Webhook",e.EMAIL="Email",e.ZAPIER="Zapier",e.MAKE_COM="Make.com",e.PABBLY_CONNECT="Pabbly",e.CHATWOOT="Chatwoot",e.PIXEL="Pixel",e}({}),m=function(e){return e.SET_VARIABLE="Set variable",e.CONDITION="Condition",e.REDIRECT="Redirect",e.SCRIPT="Code",e.TYPEBOT_LINK="Typebot link",e.WAIT="Wait",e.AB_TEST="AB test",e.WEBHOOK="webhook",e.JUMP="Jump",e.RETURN="Return",e}({});let h=["openai","cal-com","chat-node","qr-code","dify-ai","mistral","elevenlabs","anthropic","together-ai","open-router","nocodb","segment","posthog","groq","zendesk","perplexity","deepseek","blink","gmail"];var g=n(79814),y=n(61686);(e=>{void 0===e.ZodType.prototype.layout&&(e.ZodType.prototype.layout=function(e){return new this.constructor({...this._def,layout:e})})})(g),(0,y.I)(g);let f=g.array(g.string().nullable()),v=g.object({id:g.string(),name:g.string(),isSessionVariable:g.boolean().optional()});v.extend({value:g.string().or(f).nullish()}),v.extend({value:g.string().or(f)}),v.extend({value:g.unknown()}),g.custom(e=>/^{{.+}}$/g.test(e));let w=g.string().or(g.number()).transform(e=>"string"==typeof e?(e=>!!e&&e.startsWith("{{")&&e.endsWith("}}")&&2===e.split("{{").length)(e)?e:(e=>{if("number"==typeof e)return e;if(!e)return;let t=Number.parseFloat(e.toString().replace(",","."));return isNaN(t)?void 0:t})(e):e).openapi({effectType:"input"});g.object({resultId:g.string(),index:g.number(),blockId:g.string(),variableId:g.string(),value:g.string().or(f).nullable()});let x={object:e=>g.object(e),literal:e=>g.literal(e),string:g.string().optional(),boolean:g.boolean().optional(),enum:e=>g.enum(e).optional(),number:w.optional(),staticNumber:g.number().optional(),array:e=>g.array(e).optional(),discriminatedUnion:(e,t)=>g.discriminatedUnion(e,[g.object({[e]:g.undefined()}),...t]),saveResponseArray:(e,t)=>{var n,a;return g.array(g.object({item:g.enum(e).optional().layout({...null!=(n=null==t?void 0:t.item)?n:{},placeholder:"Select a response"}),variableId:g.string().optional().layout({...null!=(a=null==t?void 0:t.variableId)?a:{},inputType:"variableDropdown"})})).optional()},filter:e=>{let{operators:t=I,isJoinerHidden:n}=e;return g.object({comparisons:g.array(g.object({input:g.string().optional().layout({label:"Enter a field "}),operator:g.enum(t).optional().layout({defaultValue:"Equal to"}),value:g.string().optional().layout({placeholder:"Enter a value"})})),joiner:g.enum(["AND","OR"]).optional().layout({placeholder:"Select joiner",isHidden:n})}).optional()}},I=["Equal to","Not equal","Contains","Does not contain","Greater than","Less than","Is set","Is empty","Starts with","Ends with","Matches regex","Does not match regex"];var E=n(68140);let T=e=>{var t,n;return null==(n=e.responseMapping)||null==(t=n.find(e=>"Message content"===e.item||!e.item))?void 0:t.variableId};var _=n(20996);let C=async e=>{let{err:t,context:n}=e;try{if("string"==typeof t)return{context:n,description:t,details:void 0};if(t instanceof Error)return{context:n,description:t.message,details:await S(t)};return{context:n,description:JSON.stringify(t)}}catch(e){return console.error(e),_.Cp(e),{context:n,description:"Unknown error (failed to parse)"}}},S=async e=>"responseBody"in e?"string"==typeof e.responseBody?e.responseBody:JSON.stringify(e.responseBody):"response"in e&&"object"==typeof e.response&&e.response&&"text"in e.response&&"function"==typeof e.response.text&&!e.response.bodyUsed?await e.response.text():"string"==typeof e.cause?e.cause:JSON.stringify(e.cause);var j=n(17072);let N=["Message content","Total tokens","Prompt tokens","Completion tokens"];var k=n(70491),A=n(11335);let P=async e=>{let{input:t,shouldDownloadImages:n}=e,a=t.split("\n\n"),o=[];for(let e of a){var r,l;if(e.startsWith("http")||e.startsWith('["http'))for(let t of e.startsWith("[")?JSON.parse(e):[e]){let e=t.trim();try{let a=await k.Ay.get(e);a.ok&&(null==(r=a.headers.get("content-type"))?void 0:r.startsWith("image/"))?o.push({type:"image",image:n?await a.arrayBuffer():t.trim()}):o.push({type:"text",text:e})}catch(e){e instanceof A.H?console.log(e.response.status,await e.response.text()):console.error(e)}}else if((null==(l=o.at(-1))?void 0:l.type)==="text"){let t=o.at(-1);(o=o.slice(0,-1)).push({type:"text",text:t.text+"\n\n"+e})}else o.push({type:"text",text:e})}return o},R=async e=>{let{messages:t,isVisionEnabled:n,shouldDownloadImages:a,variables:o}=e;return t?(await Promise.all(t.map(async e=>{if(e.role)return"Dialogue"===e.role?L({message:e,variables:o,isVisionEnabled:n,shouldDownloadImages:a}):U({message:e,variables:o,isVisionEnabled:n,shouldDownloadImages:a})}))).flat().filter(r.O9):[]},L=async e=>{var t;let{message:n,variables:a,isVisionEnabled:o,shouldDownloadImages:r}=e;if(!n.dialogueVariableId)return;let l=null!=(t=a.get(n.dialogueVariableId))?t:[];return Promise.all((Array.isArray(l)?l:[l]).map(async(e,t)=>{if(e)return 0===t&&"assistant"===n.startsBy?{role:"assistant",content:e}:t%("assistant"===n.startsBy?1:2)==0?{role:"user",content:o?await P({input:null!=e?e:"",shouldDownloadImages:r}):e}:{role:"assistant",content:e}}))},U=async e=>{let{message:t,variables:n,isVisionEnabled:a,shouldDownloadImages:o}=e;if(!t.content)return;let l=n.parse(t.content);if(!(0,r.Im)(l))return"user"===t.role?{role:"user",content:a?await P({input:l,shouldDownloadImages:o}):l}:{role:t.role,content:l}},O=e=>{if((0,r.pN)(e))return null;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return console.warn("Failed to safely stringify variable value",e),null}};var D=n(47668),B=n.n(D);let V=e=>{if(null===e)return null;if(void 0===e)return;if("string"!=typeof e)return e;let t=e.startsWith("0")&&!e.startsWith("0.")&&e.length>1;if("string"==typeof e&&t)return e;let n=e.startsWith("+");return"string"==typeof e&&n||"number"==typeof e?e:"true"===e||"false"!==e&&("null"===e?null:"undefined"!==e?isNaN(e)?e:Number(e):void 0)},M=e=>"object"==typeof e?new(B()).ExternalCopy(e).copyInto():e,Y=/\{\{=(.+?)=\}\}/g,H=/\{\{([^{}]+)\}\}|(\$)\{\{([^{}]+)\}\}/g,F=(e,t)=>{let{variables:n,sessionStore:a,fieldToParse:o="value",isInsideJson:l=!1,takeLatestIfList:i=!1,isInsideHtml:s=!1}=t;return e&&""!==e?e.replace(Y,(e,t)=>{var o;let r=K(t,{variables:n,sessionStore:a});return null!=(o=O(r))?o:r}).replace(H,(e,t,a,u)=>{let d=null!=a?a:"",c=null!=t?t:u,p=n.find(e=>c===e.name&&("id"===o||(0,r.O9)(e.value)));if(!p)return d+"";if("id"===o)return d+p.id;let{value:b}=p;if(l)return d+G(b);let m=d+O(i&&Array.isArray(b)?b[b.length-1]:b);return m?s?W(m):m:d+""}):""},K=(e,t)=>{let{variables:n,sessionStore:a}=t;try{let t=F(e,{variables:n,sessionStore:a,fieldToParse:"id"});return(e=>{let{variables:t,sessionStore:n}=e,a=n.getOrCreateIsolate().createContextSync(),o=a.global;return o.setSync("global",o.derefInto()),t.forEach(e=>{o.setSync(e.id,M(V(e.value)))}),e=>a.evalClosureSync("return (function() {\n return new Function($0)();\n }())",[e],{result:{copy:!0},timeout:1e4})})({variables:n,sessionStore:a})(t.includes("return ")?t:"return ".concat(t))}catch(t){return F(e,{variables:n,sessionStore:a})}},G=e=>{let t=JSON.stringify(e);return"string"==typeof e?t.slice(1,-1):t},W=e=>"string"==typeof e?e.replace(//g,">"):JSON.stringify(e).replace(//g,">"),z=async e=>{let{variables:t,body:n,sessionStore:a,args:o}=e,l=F(n,{fieldToParse:"id",variables:t,sessionStore:a}),i=(e=>[...e.matchAll(/\{\{(.*?)\}\}/g)].reduce((e,n)=>{let a=n[1],o=t.find(e=>e.name===a);return!o||e.find(e=>e.id===o.id)?e:[...e,o]},[]))(n).map(e=>({id:e.id,value:V(e.value)})).concat(o?Object.entries(o).map(e=>{let[t,n]=e;return{id:t,value:n}}):[]),u=new Map,d=a.getOrCreateIsolate().createContextSync(),c=d.global;c.setSync("global",c.derefInto()),d.evalClosure("globalThis.setVariable = (...args) => $0.apply(undefined, args, { arguments: { copy: true }, promise: true, result: { copy: true, promise: true } })",[new D.Reference((e,t)=>{u.set(e,t)})]),d.evalClosure("globalThis.fetch = (...args) => $0.apply(undefined, args, { arguments: { copy: true }, promise: true, result: { copy: true, promise: true } })",[new D.Reference(async function(){for(var e=arguments.length,t=Array(e),n=0;n{let{id:t,value:n}=e;c.setSync(t,M(n))});try{let e=await d.evalClosure("return (async function() {\n const AsyncFunction = async function () {}.constructor;\n return new AsyncFunction($0)();\n }())",[l],{result:{copy:!0,promise:!0},timeout:1e4});return d.release(),{output:e,newVariables:Array.from(u.entries()).map(e=>{let[n,a]=e,o=t.find(e=>e.name===n);if(o)return{id:o.id,name:o.name,value:a}}).filter(r.O9)}}catch(t){d.release(),"development"===s._.NODE_ENV&&(console.log("Error while executing the function"),console.error(t));let e=await C({err:t,context:"While executing function"});return{error:e,output:e}}},q=e=>{let{tools:t,variables:n,sessionStore:a}=e;return(null==t?void 0:t.length)?t.reduce((e,t)=>(t.code&&t.name&&(e[t.name]={description:t.description,parameters:X(t.parameters),execute:async e=>{var o;let{output:r,newVariables:l}=await z({sessionStore:a,variables:n.list(),args:e,body:t.code});return l&&l.length>0&&n.set(l),null!=(o=O(r))?o:""}}),e),{}):{}},X=e=>{if(!e||(null==e?void 0:e.length)===0)return g.object({});let t={};return e.forEach(e=>{if(e.name){switch(e.type){case"string":t[e.name]=g.string();break;case"number":t[e.name]=g.number();break;case"boolean":t[e.name]=g.boolean();break;case"enum":if(!e.values||0===e.values.length)return;t[e.name]=g.enum(e.values)}(0,r.hj)(e.description)&&(t[e.name]=t[e.name].describe(e.description)),!1===e.required&&(t[e.name]=t[e.name].optional())}}),g.object(t)},J=async e=>{let{variables:t,messages:n,model:a,isVisionEnabled:o,temperature:r,tools:l,responseMapping:i,logs:s,sessionStore:u,headers:d}=e;try{let e=await R({messages:n,variables:t,isVisionEnabled:o,shouldDownloadImages:!1}),s=await (0,j.Df)({model:a,temperature:r,messages:e,tools:q({tools:l,variables:t,sessionStore:u}),maxSteps:6,headers:d});return null==i||i.forEach(e=>{e.variableId&&(e.item&&"Message content"!==e.item||t.set([{id:e.variableId,value:s.text}]),"Total tokens"===e.item&&t.set([{id:e.variableId,value:s.usage.totalTokens}]),"Prompt tokens"===e.item&&t.set([{id:e.variableId,value:s.usage.promptTokens}]),"Completion tokens"===e.item&&t.set([{id:e.variableId,value:s.usage.completionTokens}]))}),s}catch(e){s.add(await C({err:e,context:"While generating chat completion"}))}},$=async e=>{let{variables:t,messages:n,model:a,isVisionEnabled:o,temperature:r,tools:l,responseMapping:i,onFinish:s,sessionStore:u,headers:d}=e;try{let e=await R({messages:n,variables:t,isVisionEnabled:o,shouldDownloadImages:!1});return{stream:(0,j.gM)({model:a,messages:e,temperature:r,tools:q({tools:l,variables:t,sessionStore:u}),maxSteps:6,headers:d,onFinish:e=>{null==i||i.forEach(n=>{n.variableId&&("Total tokens"===n.item&&t.set([{id:n.variableId,value:e.usage.totalTokens}]),"Prompt tokens"===n.item&&t.set([{id:n.variableId,value:e.usage.promptTokens}]),"Completion tokens"===n.item&&t.set([{id:n.variableId,value:e.usage.completionTokens}]))}),null==s||s(e)}}).toDataStream({getErrorMessage:e=>JSON.stringify((e=>{let{err:t,context:n}=e;try{if("string"==typeof t)return{context:n,description:t,details:void 0};if(t instanceof Error)return{context:n,description:t.message,details:(e=>"responseBody"in e?"string"==typeof e.responseBody?e.responseBody:JSON.stringify(e.responseBody):"string"==typeof e.cause?e.cause:JSON.stringify(e.cause))(t)};return{context:n,description:JSON.stringify(t)}}catch(e){return _.Cp(e),{context:n,description:"Unknown error (failed to parse)"}}})({err:e,context:"While streaming AI"})),sendUsage:!1})}}catch(e){return{error:await C({err:e,context:"While running chat completion stream"})}}},Z={name:x.string.layout({label:"Name",placeholder:"myVariable",withVariableButton:!1}),description:x.string.layout({label:"Description",withVariableButton:!1}),required:x.boolean.layout({label:"Is required?"})},Q=x.array(x.discriminatedUnion("type",[x.object({type:x.literal("string")}).extend(Z),x.object({type:x.literal("number")}).extend(Z),x.object({type:x.literal("boolean")}).extend(Z),x.object({type:x.literal("enum"),values:x.array(x.string).layout({itemLabel:"possible value"})}).extend(Z)])).layout({accordion:"Parameters",itemLabel:"parameter"}),ee=x.object({type:x.literal("function"),name:x.string.layout({label:"Name",placeholder:"myFunctionName",withVariableButton:!1}),description:x.string.layout({label:"Description",placeholder:"A brief description of what this function does.",withVariableButton:!1}),parameters:Q,code:x.string.layout({inputType:"code",label:"Code",lang:"javascript",moreInfoTooltip:"A javascript code snippet that can use the defined parameters. It should return a value.",withVariableButton:!1})}),et=x.array(x.discriminatedUnion("type",[ee])).layout({accordion:"Tools",itemLabel:"tool"}),en={type:"encryptedCredentials",name:"Anthropic account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key [here](https://console.anthropic.com/settings/keys).",placeholder:"sk-...",withVariableButton:!1,isDebounceDisabled:!0})})},ea=["claude-opus-4-1","claude-sonnet-4-0","claude-opus-4-0","claude-3-7-sonnet-latest","claude-3-5-haiku-latest","claude-3-5-sonnet-latest","claude-3-opus-latest"];function eo(e){return"-"===e||"^"===e||"$"===e||"+"===e||"."===e||"("===e||")"===e||"|"===e||"["===e||"]"===e||"{"===e||"}"===e||"*"===e||"?"===e||"\\"===e?"\\".concat(e):e}function er(e,t){if("string"!=typeof t)throw TypeError("Sample must be a string, but ".concat(typeof t," given"));return e.test(t)}let el=(e,t)=>{if("string"!=typeof e&&!Array.isArray(e))throw TypeError("The first argument must be a single pattern string or an array of patterns, but ".concat(typeof e," given"));if(("string"==typeof t||"boolean"==typeof t)&&(t={separator:t}),"\\"===(t=t||{}).separator)throw Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");let n=function e(t){let n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(Array.isArray(t)){let a=t.map(t=>"^".concat(e(t,n),"$"));return"(?:".concat(a.join("|"),")")}let a="",o="",r=".";!0===n?(a="/",o="[/\\\\]",r="[^/\\\\]"):n&&((o=function(e){let t="";for(let n=0;n1?(o="(?:".concat(o,")"),r="((?!".concat(o,").)")):r="[^".concat(o,"]"));let l=n?"".concat(o,"+?"):"",i=n?"".concat(o,"*?"):"",s=n?t.split(a):[t],u="";for(let e=0;e0)){if(n&&(o=e===s.length-1?i:"**"!==a?l:""),n&&"**"===t){o&&(u+=0===e?"":o,u+="(?:".concat(r,"*?").concat(o,")*?"));continue}if(t){for(let e=0;eArray.isArray(e)?e.map(e=>"Message Content"===e.item?{...e,item:"Message content"}:e):void 0,x.saveResponseArray(["Message content"]).layout({accordion:"Save Response"}))}),ep={variableId:x.string.layout({inputType:"variableDropdown"}),description:x.string.layout({label:"Description",accordion:"Advanced"}),isRequired:x.boolean.layout({label:"Is required",moreInfoTooltip:"If set to false, there is a chance the variable will be empty",accordion:"Advanced",defaultValue:!0})},eb=x.array(x.discriminatedUnion("type",[x.object({type:x.literal("string")}).extend(ep),x.object({type:x.literal("number")}).extend(ep),x.object({type:x.literal("boolean")}).extend(ep),x.object({type:x.literal("array")}).extend(ep),x.object({type:x.literal("enum"),values:x.array(x.string).layout({itemLabel:"possible value",mergeWithLastField:!0})}).extend(ep)])).layout({itemLabel:"variable mapping",accordion:"Schema"}),em=e=>{let{models:t}=e;return x.object({model:x.string.layout({placeholder:"Select a model",label:"Model",helperText:t.helperText,autoCompleteItems:"static"===t.type?t.models:void 0,fetcher:"fetcher"===t.type?t.id:void 0}),prompt:x.string.layout({label:"Prompt",placeholder:"Type your text here",inputType:"textarea",isRequired:!0,moreInfoTooltip:'Meant to guide the model on what to generate. i.e. "Generate a role-playing game character", "Extract the company name from this text", etc.'}),variablesToExtract:eb})},eh=async e=>{let{variablesToExtract:t,model:n,prompt:a,variables:o,logs:r}=e;if(!a)return r.add("No prompt provided");let l=o.list(),i=eg({variablesToExtract:t,variables:l});if(!i)return void r.add("Could not parse variables to extract");let s=null==t?void 0:t.some(e=>!1===e.isRequired);try{let{object:e}=await (0,j.pY)({model:n,schema:i,prompt:"".concat(a,"\n\nYou should generate a JSON object")+(s?" and provide empty values if the information is not there or if you are unsure.":".")});Object.entries(e).forEach(e=>{let[t,n]=e;if(null===n)return;let a=l.find(e=>e.name===t);a&&o.set([{id:a.id,value:n}])})}catch(e){r.add(await C({err:e}))}},eg=e=>{let{variablesToExtract:t,variables:n}=e;if(!t||(null==t?void 0:t.length)===0)return;let a={};return t.forEach(e=>{if(!e)return;let t=n.find(t=>t.id===e.variableId);if(t){switch(e.type){case"string":a[t.name]=g.string();break;case"number":a[t.name]=g.number();break;case"boolean":a[t.name]=g.boolean();break;case"array":a[t.name]=g.array(g.string());break;case"enum":if(!e.values||0===e.values.length)return;a[t.name]=g.enum(e.values)}!1===e.isRequired&&(a[t.name]=a[t.name].nullish()),(0,r.hj)(e.description)&&(a[t.name]=a[t.name].describe(e.description))}}),g.object(a)};em({models:{type:"static",models:ea}});let ey={type:"encryptedCredentials",name:"Blink app",schema:x.object({apiKey:x.string.layout({label:"App token",isRequired:!0,inputType:"password",helperText:"You can generate an app token by following [the official Blink instructions](https://developer.joinblink.com/docs/creating-an-integration).",withVariableButton:!1,isDebounceDisabled:!0})})},ef={email:"Emails",company_name:"Company Names",first_name:"First Names",second_name:"Second Names",display_name:"Display Names",initials:"Initials",job_title:"Job Titles",profile_photo_id:"Profile Photo IDs",timezone:"Timezones",manager_id:"Manager IDs",department_name:"Department Names",account_status:"Account Statuses",id:"User IDs",employee_id:"Employee IDs"},ev="https://api.joinblink.com/v2";x.object({filter:x.discriminatedUnion("type",[x.object({type:x.literal("User ID"),userId:x.string}),x.object({type:x.literal("Employee ID"),employeeId:x.string})]).optional().layout({accordion:"Filter"}),responseMapping:x.saveResponseArray(Object.values(ef)).layout({accordion:"Save in variables"})});x.object({url:x.string.optional().layout({label:"URL",placeholder:"https://app.joinblink.com/#/hub/xxxx-xxxx"})});var ew=function(e){return e.URL="url",e.YOUTUBE="youtube",e.VIMEO="vimeo",e.TIKTOK="tiktok",e.GUMLET="gumlet",e}({});let ex={aspectRatio:"16/9",maxWidth:"100%"},eI={aspectRatio:"9/16",maxWidth:"400px"},eE=/youtube\.com\/(watch\?v=|shorts\/)([\w-]+)|youtu\.be\/([\w-]+)(\?.+)*/,eT={t:"start"},e_=/vimeo\.com\/(\d+)/,eC=/tiktok\.com\/@[\w.-]+\/video\/(\d+)/,eS=/gumlet\.(com|tv)\/watch\/(\w+)/,ej=/https:\/\/onedrive.live.com\/embed\?[^"]+/,eN={"audio/aac":"aac","audio/mp3":"mp3","audio/mp4":"m4a","audio/mpeg":"mp3","audio/ogg":"ogg","audio/wav":"wav","audio/wave":"wav","audio/webm":"weba","image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/heic":"heic","image/heif":"heif","image/jpeg":"jpeg","image/jpg":"jpg","image/png":"png","image/svg+xml":"svg","image/tiff":"tif","image/webp":"webp","image/wmf":"wmf","video/mp4":"mp4","video/mpeg":"mpeg","video/ogg":"ogv","video/quicktime":"mov","video/webm":"webm","application/pdf":"pdf","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application/zip":"zip","application/x-rar-compressed":"rar","application/x-7z-compressed":"7z","application/json":"json","application/xml":"xml","application/javascript":"js","application/x-tar":"tar","application/gzip":"gz","application/vnd.android.package-archive":"apk","application/x-executable":"exe","application/vnd.apple.installer+xml":"mpkg","application/rtf":"rtf","application/x-sh":"sh","application/x-font-ttf":"ttf","application/vnd.oasis.opendocument.text":"odt","application/vnd.oasis.opendocument.spreadsheet":"ods","application/vnd.oasis.opendocument.presentation":"odp"},ek=x.discriminatedUnion("type",[x.object({type:x.literal("Header"),title:x.string,iconUrl:x.string.layout({label:"Icon URL",placeholder:"https://example.com/icon.png"})}),x.object({type:x.literal("Text"),value:x.string.layout({inputType:"textarea"})}),x.object({type:x.literal("Labelled Text"),label:x.string.layout({label:"Label"}),value:x.string.layout({label:"Value",inputType:"textarea"}),iconUrl:x.string.layout({label:"Icon URL",placeholder:"https://example.com/icon.png"})}),x.object({type:x.literal("Image"),imageUrl:x.string.layout({placeholder:"https://example.com/image.jpg"}),fitImage:x.boolean.layout({label:"Fit Image"}),width:x.number.layout({label:"Width (px)",direction:"row"}),height:x.number.layout({label:"Height (px)",direction:"row"})}),x.object({type:x.literal("Image gallery"),imageUrls:x.array(x.string).layout({label:"URLs",itemLabel:"Image URL"})}),x.object({type:x.literal("YouTube"),link:x.string.layout({placeholder:"i.e. https://www.youtube.com/watch?v=dQw4w9WgXcQ"})}),x.object({type:x.literal("Link"),url:x.string.layout({placeholder:"https://example.com"}),title:x.string.layout({label:"Title"}),description:x.string.layout({label:"Description"}),imageUrl:x.string.layout({label:"Image URL"}),imagePlacement:x.enum(["left","right","top"]).layout({label:"Image Placement",defaultValue:"left"})}),x.object({type:x.literal("Buttons"),buttons:x.array(x.object({clientAction:x.discriminatedUnion("type",[x.object({type:x.literal("Open Link"),url:x.string.layout({placeholder:"https://example.com"})}),x.object({type:x.literal("Open Webview"),url:x.string.layout({placeholder:"https://example.com"})})]),label:x.string.layout({label:"Label"}),iconUrl:x.string.layout({label:"Icon URL"})}))}),x.object({type:x.literal("Attachment"),url:x.string.layout({placeholder:"https://example.com"})}),x.object({type:x.literal("Event"),title:x.string.layout({label:"Title"}),description:x.string.layout({label:"Description",inputType:"textarea"}),start:x.string.layout({label:"Start Date",placeholder:"2025-01-01T00:00:00Z"}),end:x.string.layout({label:"End Date",placeholder:"2025-01-01T08:00:00Z"}),allDay:x.boolean.layout({label:"All‑day Event"})}),x.object({type:x.literal("Horizontal Bar Chart"),total:x.number.layout({label:"Global Total"}),data:x.array(x.object({name:x.string.layout({label:"Name"}),value:x.number.layout({label:"Total"}),label:x.string.layout({label:"Total label"})})).layout({itemLabel:"bar"})})]);x.object({categoryId:x.string.layout({label:"Category ID"}),ribbonColor:x.string.layout({label:"Ribbon Color",placeholder:"#FF0000",accordion:"Card Content"}),sections:x.array(ek).layout({accordion:"Card Content",isOrdered:!0}),allowComments:x.boolean.layout({label:"Allow Comments",accordion:"Options"}),allowReactions:x.boolean.layout({label:"Allow Reactions",accordion:"Options"}),userIds:x.array(x.string).layout({label:"User IDs",accordion:"Send to"}),groupIds:x.array(x.string).layout({label:"Group IDs",accordion:"Send to"}),pushNotification:x.object({title:x.string.layout({label:"Title",accordion:"Push Notification"}),text:x.string.layout({label:"Text",accordion:"Push Notification"})}).optional(),responseMapping:x.saveResponseArray(["Event ID"]).optional().layout({accordion:"Save in variables"})});let eA="https://app.cal.com",eP=x.object({baseUrl:x.string.layout({label:"Base origin",placeholder:"https://cal.com",defaultValue:eA,accordion:"Customize host"})}),eR={name:"Book event",baseOptions:eP,options:x.object({link:x.string.layout({label:"Event link",placeholder:"https://cal.com/..."}),layout:x.enum(["Month","Weekly","Columns"]).layout({label:"Layout:",defaultValue:"Month",direction:"row"}),name:x.string.layout({accordion:"Prefill information",label:"Name",placeholder:"John Doe"}),email:x.string.layout({accordion:"Prefill information",label:"Email",placeholder:"johndoe@gmail.com"}),additionalNotes:x.string.layout({accordion:"Prefill information",label:"Additional notes"}),phone:x.string.layout({accordion:"Prefill information",label:"Attendee Phone Number",moreInfoTooltip:"Will be used as meeting location",placeholder:"+919999999999"}),anyPrefilledInformations:x.array(x.object({questionId:x.string.layout({label:"Question Identifier"}),value:x.string.layout({label:"Value"})})).layout({accordion:"Prefill information"}),saveBookedDateInVariableId:x.string.layout({label:"Save booked date",inputType:"variableDropdown"})}),getSetVariableIds:e=>{let{saveBookedDateInVariableId:t}=e;return t?[t]:[]},run:{web:{displayEmbedBubble:{parseUrl:e=>{let{options:t}=e;return t.link},waitForEvent:{getSaveVariableId:e=>{let{saveBookedDateInVariableId:t}=e;return t},parseFunction:()=>({args:{},content:'{\n const callback = (e) => {\n continueFlow(e.detail.data.date)\n Cal("off", {\n action: "bookingSuccessful",\n callback\n })\n }\n\n Cal("on", {\n action: "bookingSuccessful",\n callback\n })\n }'})},parseInitFunction:e=>{var t,n,a,o,r,l,i,s;let{options:u}=e;if(!u.link)throw Error("Missing link");let d=null!=(a=u.baseUrl)?a:eA,c=(null==(t=u.link)?void 0:t.startsWith("http"))?u.link.replace(/http.+:\/\/[^/]+\//,""):u.link;return{args:{baseUrl:d,link:null!=c?c:"",name:null!=(o=u.name)?o:null,email:null!=(r=u.email)?r:null,layout:eL(u.layout),phone:null!=(l=u.phone)?l:null,additionalNotes:null!=(i=u.additionalNotes)?i:null,otherPrefilledInformations:null!=(s=null==(n=u.anyPrefilledInformations)?void 0:n.reduce((e,t)=>(t.questionId&&t.value&&(e[t.questionId]=t.value),e),{}))?s:null},content:'(function (C, A, L) {\n let p = function (a, ar) {\n a.q.push(ar);\n };\n let d = C.document;\n C.Cal =\n C.Cal ||\n function () {\n let cal = C.Cal;\n let ar = arguments;\n if (!cal.loaded) {\n cal.ns = {};\n cal.q = cal.q || [];\n d.head.appendChild(d.createElement("script")).src = A;\n cal.loaded = true;\n }\n if (ar[0] === L) {\n const api = function () {\n p(api, arguments);\n };\n const namespace = ar[1];\n api.q = api.q || [];\n typeof namespace === "string"\n ? (cal.ns[namespace] = api) && p(api, ar)\n : p(cal, ar);\n return;\n }\n p(cal, ar);\n };\n })(window, baseUrl + "/embed/embed.js", "init");\n\n Cal("init", { origin: baseUrl });\n\n const location = phone ? JSON.stringify({\n value: "phone",\n optionValue: phone\n }) : undefined\n\n Cal("inline", {\n elementOrSelector: typebotElement,\n calLink: link,\n layout,\n config: {\n name: name ?? undefined,\n email: email ?? undefined,\n notes: additionalNotes ?? undefined,\n location,\n ...otherPrefilledInformations,\n }\n });\n\n Cal("ui", {"hideEventTypeDetails":false,layout});'}}}}}},eL=e=>{switch(e){case"Weekly":return"week_view";case"Columns":return"column_view";default:return"month_view"}},eU={type:"encryptedCredentials",name:"ChatNode account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,helperText:"You can generate an API key [here](https://go.chatnode.ai/typebot).",inputType:"password",withVariableButton:!1,isDebounceDisabled:!0})})};x.object({botId:x.string.layout({label:"Bot ID",placeholder:"68c052c5c3680f63",moreInfoTooltip:"The bot_id you want to ask question to. You can find it at the end of your ChatBot URl in your dashboard"}),threadId:x.string.layout({label:"Thread ID",moreInfoTooltip:"Used to remember the conversation with the user. If empty, a new thread is created."}),message:x.string.layout({label:"Message",placeholder:"Hi, what can I do with ChatNode",inputType:"textarea"}),responseMapping:x.saveResponseArray(["Message","Thread ID"]).layout({accordion:"Save response"})});var eO=n(27896);let eD=e=>{var t,n;return null!=(n=null==(t=e.responseMapping)?void 0:t.map(e=>e.variableId).filter(r.O9))?n:[]},eB={content:x.string.layout({inputType:"textarea",placeholder:"Content"})},eV=x.object({role:x.literal("system")}).extend(eB),eM=x.object({role:x.literal("user")}).extend(eB),eY=x.object({role:x.literal("assistant")}).extend(eB),eH=x.object({role:x.literal("Dialogue"),dialogueVariableId:x.string.layout({inputType:"variableDropdown",placeholder:"Dialogue variable"}),startsBy:x.enum(["user","assistant"]).layout({label:"starts by",direction:"row",defaultValue:"user"})}),eF=e=>{let{models:t}=e;return x.object({model:x.string.layout({placeholder:"Select a model",label:"Model",helperText:t.helperText,autoCompleteItems:"static"===t.type?t.models:void 0,fetcher:"fetcher"===t.type?t.id:void 0}),messages:x.array(x.discriminatedUnion("role",[eV,eM,eY,eH])).layout({accordion:"Messages",itemLabel:"message",isOrdered:!0}),tools:et,temperature:x.number.layout({accordion:"Advanced settings",label:"Temperature",direction:"row",defaultValue:1}),responseMapping:x.saveResponseArray(N).layout({accordion:"Save response"})})},eK={type:"encryptedCredentials",name:"DeepSeek account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key [here](https://platform.deepseek.com/api_keys).",placeholder:"sk-...",withVariableButton:!1,isDebounceDisabled:!0}),baseUrl:x.string.layout({label:"Base URL",defaultValue:"https://api.deepseek.com/v1",withVariableButton:!1,isDebounceDisabled:!0})})};eF({models:{type:"static",models:["deepseek-chat","deepseek-reasoner"]}});var eG=n(48353),eW=n(20248);let ez="https://api.dify.ai",eq="dify-chat",eX="system@typebot.io",eJ=["Answer","Total Tokens"],e$={type:"encryptedCredentials",name:"Dify.AI account",schema:x.object({apiKey:x.string.layout({label:"App API key",inputType:"password",placeholder:"app-...",withVariableButton:!1,isDebounceDisabled:!0}),knowledgeApiKey:x.string.layout({label:"Knowledge API key",inputType:"password",placeholder:"dataset-...",withVariableButton:!1}),apiEndpoint:x.string.layout({label:"API Endpoint",isRequired:!0,withVariableButton:!1,defaultValue:ez,accordion:"Advanced settings"}).refine(e=>{let t;return!e||(0,eW.isURL)(e,{protocols:["https","http"],require_protocol:!0,...t})}).transform(e=>e?new URL(e).origin:e)})},eZ=e=>{let t={};return null==e||e.forEach(e=>{let{key:n,value:a}=e;n&&(t[n]=a)}),t},eQ={Answer:"Message content","Total Tokens":"Total tokens","Conversation ID":"Conversation ID"},e0=(e,t)=>{var n;return(null==t?void 0:t.trim())?{success:!0,apiKey:t.trim(),apiEndpoint:null!=(n=null==e?void 0:e.trim())?n:ez}:{success:!1,error:"No API key provided"}};x.object({query:x.string.layout({label:"Query",placeholder:"User input/question content",inputType:"textarea",isRequired:!0}),conversationVariableId:x.string.layout({label:"Conversation ID",moreInfoTooltip:"Used to remember the conversation with the user. If empty, a new conversation ID is created.",inputType:"variableDropdown"}),user:x.string.layout({label:"User",moreInfoTooltip:"The user identifier, defined by the developer, must ensure uniqueness within the app.",isHidden:!0}),inputs:x.array(x.object({key:x.string.layout({label:"Key"}),value:x.string.layout({label:"Value"})})).layout({accordion:"Inputs"}),responseMapping:x.saveResponseArray([...eJ,...N],{item:{hiddenItems:eJ}}).layout({accordion:"Save response"}).transform(e=>{if(e)return e.map(e=>({...e,item:e.item?eQ[e.item]||e.item:void 0})).filter(e=>!e.item||[...N,"Conversation ID"].includes(e.item))}).openapi({effectType:"input"})});x.object({datasetId:x.string.layout({label:"Knowledge Base ID",isRequired:!0,fetcher:"fetchKnowledgeBases"}),query:x.string.layout({label:"Query",isRequired:!0,inputType:"textarea"}),responseMapping:x.saveResponseArray(["Retrieved chunks"]).layout({accordion:"Save response"})});var e1=n(26739),e2=n(57608);let e5=async e=>{let{key:t,file:n,mimeType:a,visibility:o="public"}=e,r=(()=>{if(!s._.S3_ENDPOINT||!s._.S3_ACCESS_KEY||!s._.S3_SECRET_KEY)throw Error("S3 not properly configured. Missing one of those variables: S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY");return new e2.Client({endPoint:s._.S3_ENDPOINT,port:s._.S3_PORT,useSSL:s._.S3_SSL,accessKey:s._.S3_ACCESS_KEY,secretKey:s._.S3_SECRET_KEY,region:s._.S3_REGION})})();return(await r.putObject(s._.S3_BUCKET,"".concat(o,"/").concat(t),n,{"Content-Type":a,"Cache-Control":"public, max-age=86400"}),"public"===o)?"".concat(s._.S3_PUBLIC_CUSTOM_DOMAIN?s._.S3_PUBLIC_CUSTOM_DOMAIN:"http".concat(s._.S3_SSL?"s":"","://").concat(s._.S3_ENDPOINT).concat(s._.S3_PORT?":".concat(s._.S3_PORT):"","/").concat(s._.S3_BUCKET),"/public/").concat(t):"".concat(s._.NEXTAUTH_URL,"/api/s3/private/").concat(t)},e3={type:"encryptedCredentials",name:"ElevenLabs account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key in your ElevenLabs dashboard in the Profile menu.",isDebounceDisabled:!0,withVariableButton:!1})})},e4="https://api.elevenlabs.io";var e6=n(51642).Buffer;x.object({text:x.string.layout({label:"Text",inputType:"textarea",placeholder:"Enter the text to convert to speech"}),voiceId:x.string.layout({fetcher:"fetchVoices",label:"Voice",placeholder:"Select a voice"}),modelId:x.string.layout({fetcher:"fetchModels",label:"Model",placeholder:"Select a model"}),saveUrlInVariableId:x.string.layout({label:"Save audio URL in variable",placeholder:"Select a variable",inputType:"variableDropdown"})});let e9={type:"oauth",name:"Gmail account",authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:["https://www.googleapis.com/auth/gmail.modify","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email"],defaultClientEnvKeys:{id:"GMAIL_CLIENT_ID",secret:"GMAIL_CLIENT_SECRET"},extraAuthParams:{access_type:"offline",prompt:"consent"}};var e7=n(73848),e8=n.n(e7),te=n(51642).Buffer;let tt=async e=>{let{to:t,from:n,subject:a,body:o,attachmentUrls:r}=e,l=r&&r.length>0?await Promise.all(r.map(async(e,t)=>{var n,a,o;let r=await k.Ay.get(e);return{filename:null!=(a=null==(n=e.split("/").pop())?void 0:n.split("?")[0])?a:"attachment-".concat(t),content:te.from(await r.arrayBuffer()),contentType:null!=(o=r.headers.get("content-type"))?o:"application/octet-stream"}})):[],i=new(e8())({to:t,from:n,subject:a,text:o,attachments:l});return new Promise((e,t)=>i.compile().build((n,a)=>{n?t(n):e(a)}))};var tn=n(92490),ta=n(57633);let to=e=>{let t=new ta.OAuth2Client({credentials:{access_token:e}});return(0,tn.gmail)({version:"v1",auth:t})},tr=async e=>await k.Ay.get("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:"Bearer ".concat(e)}}).json(),tl=async(e,t)=>{let{accessToken:n}=t;if(e){if(e.includes("@"))return e;let{email:t}=await tr(n);return"".concat(e," <").concat(t,">")}let{name:a,email:o}=await tr(n);return"".concat(a," <").concat(o,">")};x.object({to:x.string.layout({label:"To"}),subject:x.string.layout({label:"Subject"}),body:x.string.layout({label:"Body",inputType:"textarea"}),attachments:x.string.layout({inputType:"variableDropdown",label:"Attachments",moreInfoTooltip:"File URLs to attach. Note: Gmail has a 25MB total attachment limit."}),label:x.string.layout({label:"Label",fetcher:"fetchLabels",withVariableButton:!1,accordion:"Advanced configuration"}),from:x.string.layout({label:"From",accordion:"Advanced configuration",placeholder:"John Doe "}),threadId:x.string.layout({label:"Thread ID",accordion:"Advanced configuration",moreInfoTooltip:"If provided, the email will be sent as a reply of that specified thread."}),replyTo:x.string.layout({label:"Reply to",accordion:"Advanced configuration",placeholder:"john.doe@gmail.com",moreInfoTooltip:"If provided, the reply to this email will be set to the provided email address",isHidden:e=>{let{threadId:t}=e;return(0,r.hj)(t)}}),responseMapping:x.saveResponseArray(["Thread ID"]).layout({accordion:"Save response"})});var ti=n(50183);let ts="https://api.groq.com/openai/v1",tu={type:"encryptedCredentials",name:"Groq account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key [here](https://console.groq.com/keys).",withVariableButton:!1,isDebounceDisabled:!0}),baseUrl:x.string.layout({label:"Base URL",defaultValue:ts,withVariableButton:!1,isDebounceDisabled:!0})})};eF({models:{type:"fetcher",id:"fetchModels"}});var td=n(44288);let tc={type:"encryptedCredentials",name:"Mistral account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",withVariableButton:!1,helperText:"You can generate an API key [here](https://console.mistral.ai/api-keys).",isDebounceDisabled:!0})})},tp=["mistral-medium-latest","mistral-large-latest","pixtral-large-latest","mistral-small-latest","mistral-saba-latest","ministral-3b-latest","ministral-8b-latest"];eF({models:{type:"static",models:tp}});em({models:{type:"static",models:tp}});let tb="https://app.nocodb.com",tm=["Equal to","Not equal","Contains","Greater than","Less than","Is set","Is empty","Starts with","Ends with"],th={type:"encryptedCredentials",name:"NocoDB account",schema:x.object({baseUrl:x.string.layout({label:"Base URL",isRequired:!0,helperText:"Change it only if you are self-hosting NocoDB.",withVariableButton:!1,defaultValue:tb}).transform(e=>null==e?void 0:e.replace(/\/$/,"")),apiKey:x.string.layout({label:"API Token",isRequired:!0,helperText:"You can generate an API token [here](https://app.nocodb.com/#/account/tokens)",inputType:"password",withVariableButton:!1})})},tg=async e=>{let{baseUrl:t,apiKey:n,tableId:a,updates:o,recordIdsToUpdate:l}=e;for(let e of(await k.Ay.get("".concat(null!=t?t:tb,"/api/v2/meta/tables/").concat(a),{headers:{"xc-token":n}}).json()).columns.filter(e=>"LinkToAnotherRecord"===e.uidt).map(e=>{var t;return{id:e.id,value:ty(null==(t=o.find(t=>t.fieldName===e.title))?void 0:t.value)}}).filter(e=>(0,r.O9)(e.value)))for(let o of l)await k.Ay.post("".concat(null!=t?t:tb,"/api/v2/tables/").concat(a,"/links/").concat(e.id,"/records/").concat(o),{headers:{"xc-token":n},json:e.value.map(e=>({Id:e}))}).json()},ty=e=>{if(e){if(e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(t){console.error("Failed to parse JSON value:",e,t)}return[e]}},tf={auth:th,name:"Create Record",options:x.object({tableId:x.string.layout({label:"Table ID",isRequired:!0,helperText:"Identifier of the table to create records in."}),fields:x.array(x.object({key:x.string.layout({label:"Field",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"field"})}),run:{server:async e=>{let{credentials:{baseUrl:t,apiKey:n},options:{tableId:a,fields:o},logs:r}=e;try{if(!o||0===o.length)return;if(!n)return r.add("API key is required");if(!a)return r.add("Table ID is required");let e=await k.Ay.post("".concat(null!=t?t:tb,"/api/v2/tables/").concat(a,"/records"),{headers:{"xc-token":n},json:(e=>{let t={};return e.forEach(e=>{let{key:n,value:a}=e;n&&a&&(t[n]=a)}),t})(o)}).json();await tg({baseUrl:t,apiKey:n,tableId:a,updates:o,recordIdsToUpdate:[e.Id]})}catch(e){r.add(await C({err:e,context:"While creating NocoDB record"}))}}}},tv=e=>{if(!e||!e.comparisons||0===e.comparisons.length)return;let t=e.comparisons.map(e=>{switch(e.operator){case"Not equal":return"(".concat(e.input,",ne,").concat(e.value,")");case"Contains":return"(".concat(e.input,",like,%").concat(e.value,"%)");case"Greater than":return"(".concat(e.input,",gt,").concat(e.value,")");case"Less than":return"(".concat(e.input,",lt,").concat(e.value,")");case"Is set":return"(".concat(e.input,",isnot,null)");case"Is empty":return"(".concat(e.input,",is,null)");case"Starts with":return"(".concat(e.input,",like,").concat(e.value,"%)");case"Ends with":return"(".concat(e.input,",like,%").concat(e.value,")");default:return"(".concat(e.input,",eq,").concat(e.value,")")}}).filter(Boolean).join("~"+("OR"===e.joiner?"or":"and"));if(!(0,r.Im)(t))return t},tw=e=>Object.entries(e).reduce((e,t)=>{let[n,a]=t;return null==a?e:{...e,[n]:a.toString()}},{}),tx={auth:th,name:"Search Records",options:x.object({tableId:x.string.layout({label:"Table ID",moreInfoTooltip:"Can be found by clicking on the 3 dots next to the table name.",isRequired:!0}),viewId:x.string.layout({label:"View ID",moreInfoTooltip:"Can be found by clicking on the 3 dots next to the view name."}),returnType:x.enum(["All","First","Last","Random"]).layout({accordion:"Filter",defaultValue:"All"}),filter:x.filter({operators:tm,isJoinerHidden:e=>{let{filter:t}=e;return!(null==t?void 0:t.comparisons)||t.comparisons.length<2}}).layout({accordion:"Filter"}),responseMapping:x.array(x.object({fieldName:x.string.layout({label:"Enter a field name"}),variableId:x.string.layout({inputType:"variableDropdown"})})).layout({accordion:"Response Mapping"})}),getSetVariableIds:e=>{var t;let{responseMapping:n}=e;return null!=(t=null==n?void 0:n.map(e=>e.variableId).filter(r.O9))?t:[]},run:{server:async e=>{let{credentials:{baseUrl:t,apiKey:n},options:{tableId:a,responseMapping:o,filter:l,returnType:i,viewId:s},variables:u,logs:d}=e;if(!n)return d.add("API key is required");try{let e,c=await k.Ay.get("".concat(null!=t?t:tb,"/api/v2/tables/").concat(a,"/records"),{headers:{"xc-token":n},searchParams:tw({where:tv(l),viewId:s,limit:1e3})}).json();if(i&&"All"!==i){let t=c.pageInfo.totalRows;"First"===i?e=0:"Last"===i?e=t-1:"Random"===i&&(e=Math.floor(Math.random()*t))}let p=(0,r.O9)(e)&&c.list[e]?[c.list[e]]:c.list;if(0===p.length)return d.add({status:"info",description:"Couldn't find any rows matching the filter",details:JSON.stringify(l,null,2)});null==o||o.forEach(e=>{if(!e.fieldName||!e.variableId)return;if((0,r.pN)(p[0][e.fieldName]))return void d.add("Field ".concat(e.fieldName," does not exist in the table"));let t=p.map(t=>t[e.fieldName]);u.set([{id:e.variableId,value:1===t.length?t[0]:t}])})}catch(e){d.add(await C({err:e,context:"While searching NocoDB records"}))}}}},tI={auth:th,name:"Update Existing Record",options:x.object({tableId:x.string.layout({label:"Table ID",isRequired:!0,moreInfoTooltip:"Can be found by clicking on the 3 dots next to the table name."}),viewId:x.string.layout({label:"View ID",moreInfoTooltip:"Can be found by clicking on the 3 dots next to the view name."}),filter:x.filter({operators:tm,isJoinerHidden:e=>{let{filter:t}=e;return!(null==t?void 0:t.comparisons)||t.comparisons.length<2}}).layout({accordion:"Select Records"}),updates:x.array(x.object({fieldName:x.string.layout({label:"Enter a field name"}),value:x.string.layout({placeholder:"Enter a value"})})).layout({accordion:"Updates"})}),run:{server:async e=>{let{credentials:{baseUrl:t,apiKey:n},options:{tableId:a,filter:o,viewId:r,updates:l},logs:i}=e;if(!n)return i.add("API key is required");if(!l)return i.add("At least one update is required");if(!a)return i.add("Table ID is required");if(!(null==o?void 0:o.comparisons)||0===o.comparisons.length)return i.add("At least one filter is required");try{let e,i=await k.Ay.get("".concat(null!=t?t:tb,"/api/v2/tables/").concat(a,"/records"),{headers:{"xc-token":n},searchParams:tw({where:tv(o),viewId:r,limit:1e3})}).json();await k.Ay.patch("".concat(null!=t?t:tb,"/api/v2/tables/").concat(a,"/records"),{headers:{"xc-token":n},json:(e=i.list.map(e=>e.Id),e.map(e=>{let t={Id:e};return l.forEach(e=>{let{fieldName:n,value:a}=e;n&&(t[n]=null!=a?a:null)}),t}))}),await tg({baseUrl:t,apiKey:n,tableId:a,updates:l,recordIdsToUpdate:i.list.map(e=>e.Id)})}catch(e){i.add(await C({err:e,context:"While updating NocoDB existing record"}))}}}},tE={id:"nocodb",name:"NocoDB",tags:["database"],LightLogo:e=>(0,o.jsxs)("svg",{viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,o.jsx)("rect",{width:"32",height:"32",rx:"4",fill:"url(#paint0_linear_1871_109536)"}),(0,o.jsx)("path",{d:"M8.3335 15.1562L12.0047 18.8297V24.6454H8.3335V15.1562ZM23.7533 7.34649V24.0464C23.7533 24.3894 23.4738 24.6665 23.1309 24.6665C22.9665 24.6665 22.8092 24.6031 22.6917 24.4857L8.3335 11.5367V7.8726C8.3335 7.52968 8.61066 7.25253 8.95359 7.25253H8.98648C9.1509 7.25253 9.3106 7.31831 9.42569 7.4334L20.0798 16.6783V7.34649H23.7533Z",fill:"white"}),(0,o.jsx)("defs",{children:(0,o.jsxs)("linearGradient",{id:"paint0_linear_1871_109536",x1:"15.9976",y1:"42.7731",x2:"15.9976",y2:"-8.9707",gradientUnits:"userSpaceOnUse",children:[(0,o.jsx)("stop",{stopColor:"#4351E8"}),(0,o.jsx)("stop",{offset:"1",stopColor:"#2A1EA5"})]})})]}),auth:th,actions:[tx,tf,tI],docsUrl:"https://docs.typebot.io/editor/blocks/integrations/nocodb",onboarding:{youtubeId:"ViKETDQ8Sfg",deployedAt:new Date("2023-06-20")}};var tT=n(95901);let t_={type:"encryptedCredentials",name:"OpenRouter account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key [here](https://openrouter.ai/keys).",isDebounceDisabled:!0})})},tC={baseUrl:"https://openrouter.ai/api/v1"};eF({models:{type:"fetcher",id:"fetchModels"}});var tS=n(87765),tj=n(52175);let tN={type:"encryptedCredentials",name:"OpenAI account",schema:x.object({apiKey:x.string.layout({isRequired:!0,label:"API key",placeholder:"sk-...",inputType:"password",helperText:"You can generate an API key [here](https://platform.openai.com/account/api-keys).",withVariableButton:!1,isDebounceDisabled:!0}),baseUrl:x.string.layout({label:"Base URL",defaultValue:"https://api.openai.com/v1",moreInfoTooltip:"Use a different URL prefix for API calls, e.g. to use proxy servers.",withVariableButton:!1,isDebounceDisabled:!0})})},tk=x.object({baseUrl:x.string.layout({accordion:"Customize provider",label:"Base URL"}),apiVersion:x.string.layout({accordion:"Customize provider",label:"API version"})}).layout({isHidden:!0}).describe("Deprecated, use other dedicated OpenAI compatible blocks instead"),tA=x.object({threadId:x.string.layout({label:"Thread ID",moreInfoTooltip:"Used to remember the conversation with the user. If empty, a new thread is created.",isHidden:!0})}),tP=["gpt-5","gpt-5-mini","gpt-5-nano","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","gpt-4o","gpt-4o-mini"],tR=["o3-mini","o1","o1-mini"],tL=["gpt-5*","gpt-4-turbo*","gpt-4o*","gpt-4*vision-preview"],tU=["gpt-4-turbo-preview"],tO={voiceModel:"tts-1"},tD=e=>!(!e||tU.includes(e))&&el(tL)(e),tB=async e=>{let t=e.split("\n\n"),n=[];for(let e of t){var a,o;if(e.startsWith("http")||e.startsWith('["http'))for(let t of e.startsWith("[")?JSON.parse(e):[e]){let e=t.trim();try{let o=await k.Ay.get(e);o.ok&&(null==(a=o.headers.get("content-type"))?void 0:a.startsWith("image/"))?n.push({type:"image_url",image_url:t.trim()}):n.push({type:"text",text:e})}catch(e){e instanceof A.H?console.log(e.response.status,await e.response.text()):console.error(e)}}else if((null==(o=n.at(-1))?void 0:o.type)==="text"){let t=n.at(-1);(n=n.slice(0,-1)).push({type:"text",text:t.text+"\n\n"+e})}else n.push({type:"text",text:e})}return n},tV={auth:tN,baseOptions:tk,name:"Ask Assistant",options:x.object({assistantId:x.string.layout({label:"Assistant ID",placeholder:"Select an assistant",moreInfoTooltip:"The OpenAI assistant you want to ask question to.",fetcher:"fetchAssistants"}),threadVariableId:x.string.layout({label:"Thread ID",moreInfoTooltip:"Used to remember the conversation with the user. If empty, a new thread is created.",inputType:"variableDropdown"}),message:x.string.layout({label:"Message",inputType:"textarea"}),functions:x.array(x.object({name:x.string.layout({fetcher:"fetchAssistantFunctions",label:"Name"}),code:x.string.layout({inputType:"code",label:"Code",lang:"javascript",moreInfoTooltip:"A javascript code snippet that can use the defined parameters. It should return a value.",withVariableButton:!1})})).layout({accordion:"Functions",itemLabel:"function"}),additionalInstructions:x.string.layout({label:"Additional Instructions",inputType:"textarea",accordion:"Advanced settings"}),responseMapping:x.saveResponseArray(["Message","Thread ID"],{item:{hiddenItems:["Thread ID"]}}).layout({accordion:"Save response"})}).merge(tA),fetchers:[{id:"fetchAssistants",fetch:async e=>{var t;let{options:n,credentials:a}=e;if(!(null==a?void 0:a.apiKey))return{data:[]};let o={apiKey:a.apiKey,baseURL:null!=(t=a.baseUrl)?t:n.baseUrl,defaultHeaders:{"api-key":a.apiKey},defaultQuery:n.apiVersion?{"api-version":n.apiVersion}:void 0},l=new tj.z4(o);try{return{data:(await l.beta.assistants.list({limit:100})).data.map(e=>e.name?{label:e.name,value:e.id}:void 0).filter(r.O9)}}catch(e){return{error:await C({err:e})}}},dependencies:["baseUrl","apiVersion"]},{id:"fetchAssistantFunctions",fetch:async e=>{var t;let{options:n,credentials:a}=e;if(!n.assistantId||!(null==a?void 0:a.apiKey))return{data:[]};let o={apiKey:a.apiKey,baseURL:null!=(t=a.baseUrl)?t:n.baseUrl,defaultHeaders:{"api-key":a.apiKey},defaultQuery:n.apiVersion?{"api-version":n.apiVersion}:void 0},l=new tj.z4(o);try{return{data:(await l.beta.assistants.retrieve(n.assistantId)).tools.filter(e=>"function"===e.type).map(e=>"function"===e.type&&e.function.name?e.function.name:void 0).filter(r.O9)}}catch(e){return{error:await C({err:e})}}},dependencies:["baseUrl","apiVersion","assistantId"]}],getSetVariableIds:e=>{var t;let{responseMapping:n}=e;return null!=(t=null==n?void 0:n.map(e=>e.variableId).filter(r.O9))?t:[]},run:{stream:{getStreamVariableId:e=>{var t;let{responseMapping:n}=e;return null==n||null==(t=n.find(e=>!e.item||"Message"===e.item))?void 0:t.variableId},run:async e=>{var t;let{credentials:n,options:a,variables:o,sessionStore:r}=e;return{stream:await tM({apiKey:n.apiKey,assistantId:a.assistantId,message:a.message,baseUrl:null!=(t=n.baseUrl)?t:a.baseUrl,apiVersion:a.apiVersion,threadVariableId:a.threadVariableId,variables:o,functions:a.functions,responseMapping:a.responseMapping,additionalInstructions:a.additionalInstructions,sessionStore:r})}}},server:async e=>{let{credentials:{apiKey:t},options:{baseUrl:n,apiVersion:a,assistantId:o,message:r,responseMapping:l,threadId:i,threadVariableId:s,functions:u,additionalInstructions:d},variables:c,logs:p,sessionStore:b}=e,m=await tM({apiKey:t,assistantId:o,logs:p,message:r,baseUrl:n,apiVersion:a,threadVariableId:s,variables:c,threadId:i,functions:u,additionalInstructions:d,sessionStore:b});if(!m)return void p.add("createAssistantStream returned undefined");let h="";await (0,tS.EC)({stream:m,onTextPart:e=>{h+=e},onErrorPart:e=>{null==p||p.add(e)}}),null==l||l.forEach(e=>{e.variableId&&(!e.item||"Message"===e.item)&&c.set([{id:e.variableId,value:h.replace(/【.+】/g,"")}])})}}},tM=async e=>{var t,n;let a,{apiKey:o,assistantId:l,logs:i,message:s,baseUrl:u,apiVersion:d,threadVariableId:c,variables:p,threadId:b,functions:m,responseMapping:h,additionalInstructions:g,sessionStore:y}=e;if((0,r.Im)(l)){null==i||i.add("Assistant ID is empty");return}if((0,r.Im)(s)){null==i||i.add("Message is empty");return}let f=new tj.z4({apiKey:o,baseURL:u,defaultHeaders:{"api-key":o},defaultQuery:d?{"api-version":d}:void 0});if(c&&(0,r.hj)(null==(t=p.get(c))?void 0:t.toString()))a=null==(n=p.get(c))?void 0:n.toString();else if((0,r.hj)(b))a=b;else{a=(await f.beta.threads.create({})).id;let e=null==h?void 0:h.find(e=>"Thread ID"===e.item);(null==e?void 0:e.variableId)?await p.set([{id:e.variableId,value:a}]):c&&await p.set([{id:c,value:a}])}if(!a){null==i||i.add("Could not get thread ID");return}try{let e=await f.beta.assistants.retrieve(l);return await f.beta.threads.messages.create(a,{role:"user",content:tD(e.model)?await tB(s):s}),tY(async e=>{var t;let{forwardStream:n}=e;if(!a)return;let o=f.beta.threads.runs.stream(a,{assistant_id:l,additional_instructions:g}),i=await n(o);for(;(null==i?void 0:i.status)==="requires_action"&&(null==(t=i.required_action)?void 0:t.type)==="submit_tool_outputs";){let e=(await Promise.all(i.required_action.submit_tool_outputs.tool_calls.map(async e=>{var t;let n=JSON.parse(e.function.arguments),a=null==m?void 0:m.find(t=>t.name===e.function.name);if(!a||!e.function.name||!a.code)return;let{output:o,newVariables:r}=await z({variables:p.list(),body:a.code,args:n,sessionStore:y});return r&&r.length>0&&await p.set(r),{tool_call_id:e.id,output:null!=(t=O(o))?t:""}}))).filter(r.O9);i=await n(f.beta.threads.runs.submitToolOutputsStream(a,i.id,{tool_outputs:e}))}})}catch(e){null==i||i.add(await C({err:e}))}},tY=e=>new ReadableStream({async start(t){let n=new TextEncoder,a=async e=>{let a;for await(let l of e)switch(l.event){case"thread.message.delta":{var o,r;let e=null==(o=l.data.delta.content)?void 0:o[0];(null==e?void 0:e.type)==="text"&&(null==(r=e.text)?void 0:r.value)!=null&&t.enqueue(n.encode((0,tS.H4)("text",e.text.value)));break}case"thread.run.completed":case"thread.run.requires_action":a=l.data}return a};try{await e({forwardStream:a})}catch(e){var o,r;r=null!=(o=e.message)?o:"".concat(e),t.enqueue(n.encode((0,tS.H4)("error",r)))}finally{t.close()}},pull(){},cancel(){}});var tH=n(41880);eF({models:{type:"static",models:tP.concat(tR)}});var tF=n(51642).Buffer;x.object({model:x.string.layout({fetcher:"fetchSpeechModels",defaultValue:"tts-1",placeholder:"Select a model"}),input:x.string.layout({label:"Input",inputType:"textarea"}),voice:x.enum(["alloy","echo","fable","onyx","nova","shimmer"]).layout({label:"Voice",placeholder:"Select a voice"}),saveUrlInVariableId:x.string.layout({inputType:"variableDropdown",label:"Save URL in variable"})});x.object({url:x.string.layout({label:"Audio URL"}),transcriptionVariableId:x.string.layout({label:"Save result to",inputType:"variableDropdown"})});em({models:{type:"static",models:tP.concat(tR)}}),tP.concat(tR);var tK=n(61956);let tG={type:"encryptedCredentials",name:"Perplexity account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can generate an API key [here](https://www.perplexity.ai/settings/api)",placeholder:"pplx-...",withVariableButton:!1,isDebounceDisabled:!0}),baseUrl:x.string.layout({label:"Base URL",defaultValue:"https://api.perplexity.ai",withVariableButton:!1,isDebounceDisabled:!0})})};eF({models:{type:"static",models:["sonar-deep-research","sonar-reasoning-pro","sonar-reasoning","sonar-pro","sonar"]}});let tW="https://us.i.posthog.com",tz={type:"encryptedCredentials",name:"Posthog account",schema:x.object({apiKey:x.string.layout({label:"Project API key",isRequired:!0,inputType:"password",withVariableButton:!1,isDebounceDisabled:!0}),host:x.string.layout({label:"Host",withVariableButton:!1,isDebounceDisabled:!0,defaultValue:tW})})};var tq=n(57246);let tX=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tW;return new tq.PostHog(e,{host:t,requestTimeout:5e3})},tJ=e=>{let{properties:t,personProperties:n,isAnonymous:a}=e;if(!t)return;let o={};if(t.forEach(e=>{let{key:t,value:n}=e;t&&n&&(o[t]=n)}),a)o.$process_person_profile=!1;else if(n){let e={};n.forEach(t=>{let{key:n,value:a}=t;n&&a&&(e[n]=a)}),o.$set=e}return o};x.object({isAnonymous:x.boolean.layout({label:"Anonymous",isRequired:!1,defaultValue:!1}),distinctId:x.string.layout({label:"Distinct ID",isRequired:!1,isHidden:e=>e.isAnonymous}),event:x.string.layout({label:"Event",isRequired:!0}),properties:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"a property",accordion:"Properties"}),personProperties:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"a property",accordion:"Person properties"}),groups:x.array(x.object({type:x.string.layout({label:"Type",isRequired:!0}),key:x.string.layout({label:"Key",isRequired:!0})})).layout({itemLabel:"a group",accordion:"Associated groups"})});x.object({distinctId:x.string.layout({label:"Distinct ID",isRequired:!1}),groupType:x.string.layout({label:"Type",isRequired:!0}),groupKey:x.string.layout({label:"Key",isRequired:!0}),properties:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"property"})});var t$=n(27693);x.object({data:x.string.layout({label:"Data",helperText:"This can be a URL, or any text data you want to encode into a QR code."}),saveUrlInVariableId:x.string.layout({label:"Save QR code image URL",inputType:"variableDropdown"})});var tZ=n(45819);let tQ={type:"encryptedCredentials",name:"Segment account",schema:x.object({apiKey:x.string.layout({label:"Write Key",isRequired:!0,inputType:"password",helperText:"You can find your Write Key in your Segment source settings.",withVariableButton:!1,isDebounceDisabled:!0})})};x.object({userId:x.string.layout({label:"User ID",isRequired:!0,moreInfoTooltip:"New ID of the user."}),previousId:x.string.layout({label:"Previous ID",moreInfoTooltip:"Previous ID of the user to alias."})});let t0={auth:tQ,name:"Identify User",options:x.object({userId:x.string.layout({label:"User ID",isRequired:!0}),email:x.string.layout({label:"Email",isRequired:!1}),traits:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"trait"})}),run:{server:async e=>{let{credentials:{apiKey:t},options:{userId:n,email:a,traits:o}}=e;if(!a||0===a.length||!n||0===n.length||void 0===t)return;let r=new tZ.j0({writeKey:t});void 0===o||0===o.length?r.identify({userId:n,traits:{email:a}}):r.identify({userId:n,traits:t1(o,a)}),await r.closeAndFlush()}}},t1=(e,t)=>{let n={};return e.push({key:"email",value:t}),e.forEach(e=>{let{key:t,value:a}=e;t&&a&&(n[t]=a)}),n},t2={auth:tQ,name:"Track",options:x.object({eventName:x.string.layout({label:"Name",isRequired:!0}),userId:x.string.layout({label:"User ID",isRequired:!0}),properties:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"property"})}),run:{server:async e=>{let{credentials:{apiKey:t},options:{eventName:n,userId:a,properties:o}}=e;if(!n||0===n.length||!a||0===a.length||void 0===t)return;let r=new tZ.j0({writeKey:t});void 0===o||0===o.length?r.track({userId:a,event:n}):r.track({userId:a,event:n,properties:t5(o)}),await r.closeAndFlush()}}},t5=e=>{let t={};return e.forEach(e=>{let{key:n,value:a}=e;n&&a&&(t[n]=a)}),t},t3={auth:tQ,name:"Page",options:x.object({userId:x.string.layout({label:"User ID",isRequired:!0}),name:x.string.layout({label:"Name",isRequired:!0}),category:x.string.layout({label:"Category",isRequired:!1}),properties:x.array(x.object({key:x.string.layout({label:"Key",isRequired:!0}),value:x.string.layout({label:"Value",isRequired:!0})})).layout({itemLabel:"property"})}),run:{server:async e=>{let{credentials:{apiKey:t},options:{userId:n,name:a,category:o,properties:r}}=e;if(!a||0===a.length||!n||0===n.length||void 0===t)return;let l=new tZ.j0({writeKey:t});void 0===r||0===r.length?l.page({userId:n,name:a,category:void 0!==o?o:""}):l.page({userId:n,name:a,category:void 0!==o?o:"",properties:t4(r)}),await l.closeAndFlush()}}},t4=e=>{let t={};return e.forEach(e=>{let{key:n,value:a}=e;n&&a&&(t[n]=a)}),t};var t6=n(54634);let t9={type:"encryptedCredentials",name:"Together account",schema:x.object({apiKey:x.string.layout({label:"API key",isRequired:!0,inputType:"password",helperText:"You can get your API key [here](https://api.together.xyz/settings/api-keys).",isDebounceDisabled:!0})})};eF({models:{type:"text",helperText:"You can find the list of all the models available [here](https://docs.together.ai/docs/inference-models#chat-models). Copy the model string for API."}});var t7=n(51429);let t8={type:"encryptedCredentials",name:"Zendesk Conversations API",schema:x.object({conversationsKeyId:x.string.layout({label:"Conversations Key ID",isRequired:!0,withVariableButton:!1,isDebounceDisabled:!0,helperText:"[How to find my Zendesk Key ID and Secret Key?](https://docs.typebot.io/editor/blocks/integrations/zendesk#how-to-find-my-zendesk-key-id-and-secret-key)"}),conversationsSecretKey:x.string.layout({label:"Conversations Secret Key",isRequired:!0,inputType:"password",withVariableButton:!1,isDebounceDisabled:!0})})},ne={auth:t8,name:"Open Web Widget",options:x.object({userId:x.string.layout({label:"User ID"}),name:x.string.layout({label:"Name"}),email:x.string.layout({label:"Email"}),webWidgetKey:x.string.layout({label:"Web Widget Key",helperText:"[Finding web widget key](https://docs.typebot.io/editor/blocks/integrations/zendesk#open-web-widget)"})}),run:{web:{parseFunction:e=>{let{credentials:{conversationsSecretKey:t,conversationsKeyId:n},options:{userId:a,name:o,email:r,webWidgetKey:l}}=e,i="";return a&&r?i=(0,t7.sign)({scope:"user",external_id:null!=a?a:"",name:null!=o?o:"",email:r,email_verified:"true"},null!=t?t:"",{algorithm:"HS256",keyid:null!=n?n:""}):a&&(i=(0,t7.sign)({scope:"user",external_id:null!=a?a:"",name:null!=o?o:""},null!=t?t:"",{algorithm:"HS256",keyid:null!=n?n:""})),{args:{isAuthEnabled:void 0!==a&&""!==a?"true":"false",token:i,key:null!=l?l:""},content:nt()}}}}},nt=()=>'(function (d, t) {\n var ZD_URL = "https://static.zdassets.com/ekr/snippet.js?key=" + key;\n\n var ze_script = d.createElement(t);\n var s = d.getElementsByTagName(t)[0];\n\n ze_script.id="ze-snippet";\n ze_script.src = ZD_URL;\n ze_script.crossorigin = "anonymous";\n ze_script.defer = true;\n ze_script.async = true;\n s.parentNode.insertBefore(ze_script, s);\n\n ze_script.onload = function () {\n if ( isAuthEnabled === "true" && token != "") {\n zE("messenger", "loginUser", function (callback) {\n callback(token);\n zE("messenger", "open");\n });\n } else {\n zE("messenger", "open");\n }\n };\n })(document, "script");\n\n return "'.concat("Zendesk Web Widget Opened",'"\n ');tE.id;let nn=e=>Object.values(p).includes(e.type),na=e=>Object.values(c).includes(e.type);var no=n(92349);let nr=(e,t)=>{for(let s=0;s\n Click to upload\n or drag and drop
\n (size limit: 10MB)",button:"Upload",clear:"Clear",skip:"Skip",success:{single:"File uploaded",multiple:"{total} files uploaded"}}};var nh=function(e){return e.STRIPE="Stripe",e}({}),ng=n(78895);let ny={length:10};var nf=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fieldToParse:"value",escapeForJson:!1};return n=>n&&""!==n?n.replace(/\{\{(.*?)\}\}/g,(n,a)=>{let o=a.replace(/{{|}}/g,""),l=e.find(e=>o===e.name&&("id"===t.fieldToParse||(0,r.O9)(e.value)));if(!l)return"";if("id"===t.fieldToParse)return l.id;let{value:i}=l;return t.escapeForJson?nx("string"==typeof i?i:JSON.stringify(i)):nv(i)||""}):""},nv=e=>{if((0,r.pN)(e))return null;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return console.warn("Failed to safely stringify variable value",e),null}},nw=e=>{if(null===e)return null;if(void 0!==e){if(Array.isArray(e)||"number"==typeof e)return e;if("true"===e)return!0;if("false"===e)return!1;if("null"===e)return null;if("undefined"!==e)try{return JSON.parse(e)}catch(t){return e}}},nx=e=>e.replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/\\[^n"]/g,"\\\\ "),nI=(0,d.createContext)({}),nE=e=>{let{children:t,resultId:n,onNewAnswer:a,onVariablesUpdated:l}=e,[i,s]=(0,d.useState)({answers:[],variables:[],createdAt:new Date}),u=e=>{let t=e.map(e=>({...e,value:nv(e.value)}));s(e=>{let n=[...e.variables.filter(e=>t.every(t=>t.id!==e.id||t.name!==e.name)),...t].filter(e=>(0,r.O9)(e.value));return l&&l(n),{...e,variables:n}})};return(0,o.jsx)(nI.Provider,{value:{resultId:n,resultValues:i,addAnswer:e=>t=>{var n,o;return t.variableId&&u([{id:t.variableId,value:t.content,name:null!=(o=null==(n=e.find(e=>e.id===t.variableId))?void 0:n.name)?o:""}]),s(e=>({...e,answers:[...e.answers,t]})),a&&a(t)},updateVariables:u},children:t})},nT=()=>(0,d.useContext)(nI),n_=e=>{try{var t;null==(t=window.top)||t.postMessage({from:"typebot",...e},"*")}catch(e){console.error(e)}},nC=(0,d.createContext)({}),nS=e=>{let{children:t,typebot:n,apiHost:a,isPreview:l,isLoading:i,onNewLog:s}=e,[u,c]=(0,d.useState)(n),[p,b]=(0,d.useState)([]),[m,h]=(0,d.useState)(n.typebotId),[g,y]=(0,d.useState)([]),[f,v]=(0,d.useState)([]);return(0,d.useEffect)(()=>{c(e=>({...e,theme:n.theme,settings:n.settings}))},[n.theme,n.settings]),(0,o.jsx)(nC.Provider,{value:{typebot:u,linkedTypebots:p,apiHost:a,isPreview:l,updateVariableValue:(e,t)=>{var n,a;let o=nv(t);n_({newVariableValue:{name:null!=(a=null==(n=u.variables.find(t=>t.id===e))?void 0:n.name)?a:"",value:null!=o?o:""}});let l=u.variables.find(t=>t.id===e),i=u.variables.filter(t=>t.name===(null==l?void 0:l.name)&&t.id!==e),s=[l,...i].filter(r.O9);c(e=>({...e,variables:e.variables.map(e=>s.some(t=>t.id===e.id)?{...e,value:o}:e)}))},createEdge:e=>{c(t=>({...t,edges:[...t.edges,e]}))},injectLinkedTypebot:e=>{let t,n,a=(t=e.variables,n=u.variables,t.map(e=>{var t;let a=n.find(t=>t.name===e.name);return{...e,value:null!=(t=null==a?void 0:a.value)?t:e.value}})),o={id:"typebotId"in e?e.typebotId:e.id,groups:e.groups,edges:e.edges,variables:a};return b(e=>[...e,o]),c({...u,groups:[...u.groups,...o.groups],variables:[...u.variables,...o.variables],edges:[...u.edges,...o.edges]}),o},onNewLog:s,linkedBotQueue:g,isLoading:i,parentTypebotIds:f,pushParentTypebotId:e=>{v(t=>[...t,e])},pushEdgeIdInLinkedTypebotQueue:e=>y(t=>[...t,e]),popEdgeIdFromLinkedTypebotQueue:()=>{y(e=>e.slice(1)),v(e=>e.slice(1)),h(g[0].typebotId)},currentTypebotId:m,setCurrentTypebotId:h},children:t})},nj=()=>(0,d.useContext)(nC),nN={general:{bgImage:"--typebot-container-bg-image",bgColor:"--typebot-container-bg-color",fontFamily:"--typebot-container-font-family"},chat:{hostBubbles:{bgColor:"--typebot-host-bubble-bg-color",color:"--typebot-host-bubble-color"},guestBubbles:{bgColor:"--typebot-guest-bubble-bg-color",color:"--typebot-guest-bubble-color"},inputs:{bgColor:"--typebot-input-bg-color",color:"--typebot-input-color",placeholderColor:"--typebot-input-placeholder-color"},buttons:{bgColor:"--typebot-button-bg-color",color:"--typebot-button-color"}}},nk=(e,t)=>{e.backgroundColor&&t.setProperty(nN.chat.hostBubbles.bgColor,e.backgroundColor),e.color&&t.setProperty(nN.chat.hostBubbles.color,e.color)},nA=(e,t)=>{e.backgroundColor&&t.setProperty(nN.chat.guestBubbles.bgColor,e.backgroundColor),e.color&&t.setProperty(nN.chat.guestBubbles.color,e.color)},nP=(e,t)=>{e.backgroundColor&&t.setProperty(nN.chat.buttons.bgColor,e.backgroundColor),e.color&&t.setProperty(nN.chat.buttons.color,e.color)},nR=(e,t)=>{e.backgroundColor&&t.setProperty(nN.chat.inputs.bgColor,e.backgroundColor),e.color&&t.setProperty(nN.chat.inputs.color,e.color),e.placeholderColor&&t.setProperty(nN.chat.inputs.placeholderColor,e.placeholderColor)},nL=(0,d.createContext)({}),nU=e=>{let{children:t,onScroll:n}=e;return(0,o.jsx)(nL.Provider,{value:{scroll:n},children:t})},nO=()=>(0,d.useContext)(nL),nD=window.matchMedia("only screen and (max-width: 760px)").matches,nB=window.parent&&window.location!==(null==(a=window.top)?void 0:a.location),nV=(e,t,n)=>({status:e?"error":"success",description:e?n:t,details:e&&JSON.stringify(e,null,2).substring(0,1e3)}),nM=e=>{var t;return'\nwindow.$chatwoot.setUser("'.concat(null!=(t=null==e?void 0:e.id)?t:"",'", {\n email: ').concat((null==e?void 0:e.email)?'"'.concat(e.email,'"'):"undefined",",\n name: ").concat((null==e?void 0:e.name)?'"'.concat(e.name,'"'):"undefined",",\n avatar_url: ").concat((null==e?void 0:e.avatarUrl)?'"'.concat(e.avatarUrl,'"'):"undefined",",\n phone_number: ").concat((null==e?void 0:e.phoneNumber)?'"'.concat(e.phoneNumber,'"'):"undefined",",\n});\n\n")},nY=function(){let{baseUrl:e,websiteToken:t,user:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return"\nif (window.$chatwoot) {\n if(".concat(!!n,") {\n ").concat(nM(n),'\n }\n window.$chatwoot.toggle("open");\n} else {\n (function (d, t) {\n var BASE_URL = "').concat(e,'";\n var g = d.createElement(t),\n s = d.getElementsByTagName(t)[0];\n g.src = BASE_URL + "/packs/js/sdk";\n g.defer = true;\n g.async = true;\n s.parentNode.insertBefore(g, s);\n g.onload = function () {\n window.chatwootSDK.run({\n websiteToken: "').concat(t,'",\n baseUrl: BASE_URL,\n });\n window.addEventListener("chatwoot:ready", function () {\n if(').concat(!!((null==n?void 0:n.id)||(null==n?void 0:n.email)),") {\n ").concat(nM(n),'\n }\n window.$chatwoot.toggle("open");\n });\n };\n })(document, "script");\n}')},nH=async(e,t)=>{var a;let{variables:o}=t;if(!(null==(a=e.options)?void 0:a.trackingId))return e.outgoingEdgeId;let{default:r}=await n.e(36).then(n.bind(n,11036));return await r(e.options.trackingId),(0,i.a)(((e,t)=>Object.keys(e).reduce((n,a)=>{let o=e[a];return{...n,[a]:"string"==typeof o?nf(t)(o):o}},{}))(e.options,o)),e.outgoingEdgeId},nF=async(e,t)=>{if(!e.options||!("action"in e.options))return e.outgoingEdgeId;switch(e.options.action){case ns.INSERT_ROW:nK(e.options,t);break;case ns.UPDATE_ROW:nG(e.options,t);break;case ns.GET:await nW(e.options,t)}return e.outgoingEdgeId},nK=(e,t)=>{let{variables:n,apiHost:a,onNewLog:o,resultId:l}=t;if(!e.cellsToInsert)return void o({status:"warning",description:"Cells to insert are undefined"});(0,r.w$)({url:"".concat(a,"/api/integrations/google-sheets/spreadsheets/").concat(e.spreadsheetId,"/sheets/").concat(e.sheetId),method:"POST",body:{action:ns.INSERT_ROW,credentialsId:e.credentialsId,resultId:l,values:nz(e.cellsToInsert,n)}}).then(e=>{let{error:t}=e;o(nV(t,"Succesfully inserted a row in the sheet","Failed to insert a row in the sheet"))})},nG=(e,t)=>{var n,a,o;let{variables:l,apiHost:i,onNewLog:s,resultId:u}=t;e.cellsToUpsert&&"referenceCell"in e&&(0,r.w$)({url:"".concat(i,"/api/integrations/google-sheets/spreadsheets/").concat(e.spreadsheetId,"/sheets/").concat(e.sheetId),method:"POST",body:{action:ns.UPDATE_ROW,credentialsId:e.credentialsId,values:nz(e.cellsToUpsert,l),resultId:u,referenceCell:{column:null==(n=e.referenceCell)?void 0:n.column,value:nf(l)(null!=(o=null==(a=e.referenceCell)?void 0:a.value)?o:"")}}}).then(e=>{let{error:t}=e;s(nV(t,"Succesfully updated a row in the sheet","Failed to update a row in the sheet"))})},nW=async(e,t)=>{var n,a,o,l,i,s;let{variables:u,updateVariableValue:d,updateVariables:c,apiHost:p,onNewLog:b,resultId:m}=t;if(!e.cellsToExtract)return;let{data:h,error:g}=await (0,r.w$)({url:"".concat(p,"/api/integrations/google-sheets/spreadsheets/").concat(e.spreadsheetId,"/sheets/").concat(e.sheetId),method:"POST",body:{action:ns.GET,credentialsId:e.credentialsId,referenceCell:"referenceCell"in e?{column:null==(n=e.referenceCell)?void 0:n.column,value:nf(u)(null!=(i=null==(a=e.referenceCell)?void 0:a.value)?i:"")}:void 0,filter:e.filter?{comparisons:null==(o=e.filter.comparisons)?void 0:o.map(e=>({...e,value:nf(u)(e.value)})),logicalOperator:null!=(s=null==(l=e.filter)?void 0:l.logicalOperator)?s:"AND"}:void 0,columns:e.cellsToExtract.map(e=>e.column),resultId:m}});b(nV(g,"Succesfully fetched data from sheet","Failed to fetch data from sheet")),h&&c(e.cellsToExtract.reduce((e,t)=>{var n,a;let o=u.find((0,r.$H)(t.variableId)),l=h.rows,i=null!=(a=l[Math.floor(Math.random()*l.length)][null!=(n=t.column)?n:""])?a:null;return o?(d(o.id,i),[...e,{...o,value:i}]):e},[]))},nz=(e,t)=>e.reduce((e,n)=>n.column&&n.value?{...e,[n.column]:nf(t)(n.value)}:e,{}),nq=async(e,t)=>{var n,a;let{blockId:o,variables:l,updateVariableValue:i,updateVariables:s,typebotId:u,apiHost:d,resultValues:c,onNewLog:p,resultId:b,parentTypebotIds:m}=t,h=(0,nu.stringify)({resultId:b}),{data:g,error:y}=await (0,r.w$)({url:"".concat(d,"/api/typebots/").concat(u,"/blocks/").concat(o,"/executeWebhook?").concat(h),method:"POST",body:{variables:l,resultValues:c,parentTypebotIds:m}}),f=null==g?void 0:g.statusCode.toString(),v=!f||(null==f?void 0:f.startsWith("4"))||(null==f?void 0:f.startsWith("5"));p({status:y?"error":v?"warning":"success",description:v?"Webhook returned an error":"Webhook successfuly executed",details:JSON.stringify(null!=y?y:g,null,2).substring(0,1e3)});let w=null==(a=e.options)||null==(n=a.responseVariableMapping)?void 0:n.reduce((e,t)=>{if(!(null==t?void 0:t.bodyPath)||!t.variableId)return e;let n=l.find((0,r.$H)(t.variableId));if(!n)return e;let a=Function("data","return data.".concat(nf(l)(null==t?void 0:t.bodyPath)));try{let t=a(g);return i(null==n?void 0:n.id,t),[...e,{...n,value:t}]}catch(t){return e}},[]);return w&&s(w),e.outgoingEdgeId},nX=e=>t=>{var n,a;if(!(null==t?void 0:t.variableId))return!1;let o=(null!=(a=null==(n=e.find(e=>e.id===t.variableId))?void 0:n.value)?a:"").toString().trim(),l=nf(e)(t.value).trim();return!(0,r.pN)(l)&&!!t.comparisonOperator&&nJ(o,t.comparisonOperator,l)},nJ=(e,t,n)=>{switch(t){case nc.CONTAINS:return e.toLowerCase().includes(n.toLowerCase());case nc.EQUAL:return e===n;case nc.NOT_EQUAL:return e!==n;case nc.GREATER:return Number.parseFloat(e)>Number.parseFloat(n);case nc.LESS:return Number.parseFloat(e)0}},n$=async(e,t)=>{var n;let{typebot:{variables:a}}=t;if(null==(n=e.options)?void 0:n.content){if(e.options.shouldExecuteInParentContext&&nB)n_({codeToExecute:nf(a)(e.options.content)});else{let t=Function(...a.map(e=>e.id),nf(a,{fieldToParse:"id"})(e.options.content));try{await t(...a.map(e=>nw(e.value)))}catch(e){console.error(e)}}return e.outgoingEdgeId}},nZ=async(e,t)=>{var n,a;let{apiHost:o,injectLinkedTypebot:l,isPreview:i}=t,{data:s,error:u}=i?await (0,r.w$)("/api/typebots/".concat(null==(n=e.options)?void 0:n.typebotId)):await (0,r.w$)("".concat(o,"/api/publicTypebots/").concat(null==(a=e.options)?void 0:a.typebotId));if(!(!s||u))return l(s.typebot)},nQ=async(e,t)=>{var n,a,o,r,l;let{typebot:i,linkedTypebots:s,onNewLog:u,createEdge:d,setCurrentTypebotId:c,pushEdgeIdInLinkedTypebotQueue:p,pushParentTypebotId:b,currentTypebotId:m}=t,h=(null==(n=e.options)?void 0:n.typebotId)==="current"?i:null!=(r=[i,...s].find(t=>{var n,a;return"typebotId"in t?t.typebotId===(null==(n=e.options)?void 0:n.typebotId):t.id===(null==(a=e.options)?void 0:a.typebotId)}))?r:await nZ(e,t);if(!h)return u({status:"error",description:"Failed to link typebot",details:""}),{nextEdgeId:e.outgoingEdgeId};e.outgoingEdgeId&&p({edgeId:e.outgoingEdgeId,typebotId:m}),b(m),c("typebotId"in h?h.typebotId:h.id);let g=null!=(l=null==(a=e.options)?void 0:a.groupId)?l:null==(o=h.groups.find(e=>e.blocks.some(e=>"start"===e.type)))?void 0:o.id;if(!g)return{nextEdgeId:e.outgoingEdgeId};let y={id:(1e3*Math.random()).toString(),from:{blockId:""},to:{groupId:g}};return d(y),{nextEdgeId:y.id,linkedTypebot:{...h,edges:[...h.edges,y]}}},n0=async(e,t)=>{var n;let{typebot:{variables:a}}=t;if(!(null==(n=e.options)?void 0:n.secondsToWaitFor))return e.outgoingEdgeId;let o=nf(a)(e.options.secondsToWaitFor);return isNaN(o)||await new Promise(e=>setTimeout(e,1e3*Number.parseInt(o,10))),e.outgoingEdgeId},n1=async(e,t)=>{switch(e.type){case m.SET_VARIABLE:return{nextEdgeId:((e,t)=>{var n;let{typebot:{variables:a},updateVariableValue:o,updateVariables:l}=t;if(!(null==(n=e.options)?void 0:n.variableId)||void 0!==e.options.type&&"Custom"!==e.options.type)return e.outgoingEdgeId;let i=e.options.expressionToEvaluate?(e=>t=>{let n=nf(e,{fieldToParse:"id"})(t.includes("return ")?t:"return ".concat(t));try{return Function(...e.map(e=>e.id),n)(...e.map(e=>nw(e.value)))}catch(n){return nf(e)(t)}})(a)(e.options.expressionToEvaluate):void 0,s=a.find((0,r.$H)(e.options.variableId));return s&&(o(s.id,i),l([{...s,value:i}])),e.outgoingEdgeId})(e,t)};case m.CONDITION:return{nextEdgeId:((e,t)=>{let{typebot:{variables:n}}=t,a=e.items.find(e=>{var t,a;let{content:o}=e;return(null==o?void 0:o.logicalOperator)===nd.AND?null==(t=o.comparisons)?void 0:t.every(nX(n)):null==o||null==(a=o.comparisons)?void 0:a.some(nX(n))});return a?a.outgoingEdgeId:e.outgoingEdgeId})(e,t)};case m.REDIRECT:return((e,t)=>{var n,a;let{typebot:{variables:o}}=t;if(!(null==(n=e.options)?void 0:n.url))return{nextEdgeId:e.outgoingEdgeId};let l=(0,r.Jf)(nf(o)(e.options.url)),i=window.parent&&window.location!==(null==(a=window.top)?void 0:a.location),s=null;if(i){if(!e.options.isNewTab)return window.top.location.href=l,{nextEdgeId:e.outgoingEdgeId};try{s=window.open(l)}catch(e){n_({redirectUrl:l})}}else s=window.open(l,e.options.isNewTab?"_blank":"_self");return{nextEdgeId:e.outgoingEdgeId,blockedPopupUrl:s?void 0:l}})(e,t);case m.SCRIPT:return{nextEdgeId:await n$(e,t)};case m.TYPEBOT_LINK:return nQ(e,t);case m.WAIT:return{nextEdgeId:await n0(e,t)};default:return{}}},n2=d.forwardRef(function(e,t){let{onChange:n,...a}=e;return(0,o.jsx)("input",{ref:t,className:"focus:outline-none bg-transparent px-4 py-4 flex-1 w-full text-input",type:"text",style:{fontSize:"16px"},autoFocus:!nD,onChange:e=>n(e.target.value),...a})}),n5=e=>(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"19px",color:"white",...e,children:(0,o.jsx)("path",{d:"M476.59 227.05l-.16-.07L49.35 49.84A23.56 23.56 0 0027.14 52 24.65 24.65 0 0016 72.59v113.29a24 24 0 0019.52 23.57l232.93 43.07a4 4 0 010 7.86L35.53 303.45A24 24 0 0016 327v113.31A23.57 23.57 0 0026.59 460a23.94 23.94 0 0013.22 4 24.55 24.55 0 009.52-1.93L476.4 285.94l.19-.09a32 32 0 000-58.8z"})}),n3=e=>{let{label:t,isDisabled:n,isLoading:a,disableIcon:r,...l}=e;return(0,o.jsxs)("button",{type:"submit",disabled:n||a,...l,className:"py-2 px-4 justify-center font-semibold rounded-md text-white focus:outline-none flex items-center disabled:opacity-50 disabled:cursor-not-allowed disabled:brightness-100 transition-all filter hover:brightness-90 active:brightness-75 typebot-button "+l.className,children:[a&&(0,o.jsx)(n4,{className:"text-white"}),(0,o.jsx)("span",{className:"xs:flex "+(r?"":"hidden"),children:t}),(0,o.jsx)(n5,{className:"send-icon flex "+(r?"hidden":"xs:hidden")})]})},n4=e=>(0,o.jsxs)("svg",{...e,className:"animate-spin -ml-1 mr-3 h-5 w-5 "+e.className,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","data-testid":"loading-spinner",children:[(0,o.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,o.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),n6=e=>{var t,n,a,r,l,i;let{block:s,onSubmit:u,defaultValue:c,hasGuestAvatar:p}=e,[b,m]=(0,d.useState)(null!=c?c:""),h=(0,d.useRef)(null),g=()=>{(()=>{var e;return""!==b&&(null==(e=h.current)?void 0:e.reportValidity())})()&&u({value:b})};return(0,o.jsxs)("div",{className:"flex items-end justify-between rounded-lg pr-2 typebot-input w-full","data-testid":"input",style:{marginRight:p?"50px":"0.5rem",maxWidth:"350px"},onKeyDown:e=>{"Enter"===e.key&&g()},children:[(0,o.jsx)(n2,{ref:h,value:b,placeholder:null!=(l=null==(n=s.options)||null==(t=n.labels)?void 0:t.placeholder)?l:"Type your email...",onChange:e=>m(e),type:"email",autoComplete:"email"}),(0,o.jsx)(n3,{type:"button",label:null!=(i=null==(r=s.options)||null==(a=r.labels)?void 0:a.button)?i:"Send",isDisabled:""===b,className:"my-2 ml-2",onClick:g})]})},n9=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,n7=e=>{var t,n,a,r,l,i,s;let{block:u,onSubmit:c,defaultValue:p,hasGuestAvatar:b}=e,[m,h]=(0,d.useState)(null!=p?p:""),g=(0,d.useRef)(null),y=()=>{(()=>{var e;return""!==m&&(null==(e=g.current)?void 0:e.reportValidity())})()&&c({value:m})};return(0,o.jsxs)("div",{className:"flex items-end justify-between rounded-lg pr-2 typebot-input w-full","data-testid":"input",style:{marginRight:b?"50px":"0.5rem",maxWidth:"350px"},onKeyDown:e=>{"Enter"===e.key&&y()},children:[(0,o.jsx)(np.Ay,{ref:g,value:m,onChange:e=>h(e),placeholder:null!=(i=null==(n=u.options)||null==(t=n.labels)?void 0:t.placeholder)?i:"Your phone number...",defaultCountry:null==(a=u.options)?void 0:a.defaultCountryCode,autoFocus:!nD}),(0,o.jsx)(n3,{type:"button",label:null!=(s=null==(l=u.options)||null==(r=l.labels)?void 0:r.button)?s:"Send",isDisabled:""===m,className:"my-2 ml-2",onClick:y})]})},n8=e=>{var t,n,a,r,l,i;let{block:s,onSubmit:u,defaultValue:c,hasGuestAvatar:p}=e,[b,m]=(0,d.useState)(null!=c?c:""),h=(0,d.useRef)(null),g=()=>{(()=>{var e;return""!==b&&(null==(e=h.current)?void 0:e.reportValidity())})()&&u({value:b})};return(0,o.jsxs)("div",{className:"flex items-end justify-between rounded-lg pr-2 typebot-input w-full","data-testid":"input",style:{marginRight:p?"50px":"0.5rem",maxWidth:"350px"},onKeyDown:e=>{"Enter"===e.key&&g()},children:[(0,o.jsx)(n2,{ref:h,value:b,placeholder:null!=(l=null==(n=s.options)||null==(t=n.labels)?void 0:t.placeholder)?l:"Type your URL...",onChange:e=>{if(!e.startsWith("https://"))return"https:/"===e?void 0:m("https://".concat(e));m(e)},type:"url",autoComplete:"url"}),(0,o.jsx)(n3,{type:"button",label:null!=(i=null==(r=s.options)||null==(a=r.labels)?void 0:a.button)?i:"Send",isDisabled:""===b,className:"my-2 ml-2",onClick:g})]})},ae=/^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})$/,at=e=>{let{url:t,onLinkClick:n}=e;return(0,o.jsxs)("div",{className:"w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow flex flex-col gap-2",role:"alert",children:[(0,o.jsx)("span",{className:"mb-1 text-sm font-semibold text-gray-900",children:"Popup blocked"}),(0,o.jsx)("div",{className:"mb-2 text-sm font-normal",children:"The bot wants to open a new tab but it was blocked by your broswer. It needs a manual approval."}),(0,o.jsx)("a",{href:t,target:"_blank",className:"py-1 px-4 justify-center text-sm font-semibold rounded-md text-white focus:outline-none flex items-center disabled:opacity-50 disabled:cursor-not-allowed disabled:brightness-100 transition-all filter hover:brightness-90 active:brightness-75 typebot-button",rel:"noreferrer",onClick:n,children:"Continue in new tab"})]})},an=()=>(0,o.jsx)("figure",{className:"flex justify-center items-center rounded-full text-white w-6 h-6 text-sm relative xs:w-10 xs:h-10 xs:text-xl","data-testid":"default-avatar",children:(0,o.jsxs)("svg",{width:"75",height:"75",viewBox:"0 0 75 75",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"absolute top-0 left-0 w-6 h-6 xs:w-full xs:h-full xs:text-xl",children:[(0,o.jsx)("mask",{id:"mask0",x:"0",y:"0","mask-type":"alpha",children:(0,o.jsx)("circle",{cx:"37.5",cy:"37.5",r:"37.5",fill:"#0042DA"})}),(0,o.jsxs)("g",{mask:"url(#mask0)",children:[(0,o.jsx)("rect",{x:"-30",y:"-43",width:"131",height:"154",fill:"#0042DA"}),(0,o.jsx)("rect",{x:"2.50413",y:"120.333",width:"81.5597",height:"86.4577",rx:"2.5",transform:"rotate(-52.6423 2.50413 120.333)",stroke:"#FED23D",strokeWidth:"5"}),(0,o.jsx)("circle",{cx:"76.5",cy:"-1.5",r:"29",stroke:"#FF8E20",strokeWidth:"5"}),(0,o.jsx)("path",{d:"M-49.8224 22L-15.5 -40.7879L18.8224 22H-49.8224Z",stroke:"#F7F8FF",strokeWidth:"5"})]})]})}),aa=e=>{let{avatarSrc:t}=e,[n]=(0,d.useState)(t);return""===n?null:(0,r.O9)(n)?(0,o.jsx)("figure",{className:"flex justify-center items-center rounded-full text-white w-6 h-6 text-sm relative xs:w-10 xs:h-10 xs:text-xl",children:(0,o.jsx)("img",{src:n,alt:"Bot avatar",className:"rounded-full object-cover w-full h-full"})}):(0,o.jsx)(an,{})},ao=(0,d.forwardRef)(function(e,t){let{hostAvatarSrc:n,keepShowing:a}=e,[r,l]=(0,d.useState)(!1),[i,s]=(0,d.useState)(0),u=()=>{if(!c.current||!p.current)return;let{height:e}=c.current.getBoundingClientRect(),{height:t}=p.current.getBoundingClientRect();s(e-t)},c=(0,d.useRef)(null),p=(0,d.useRef)(null);return(0,d.useImperativeHandle)(t,()=>({refreshTopOffset:u})),(0,d.useEffect)(()=>{if(!document)return;l(!0);let e=new nb.tb(u);return e.observe(document.body),()=>{e.disconnect()}},[]),(0,o.jsx)("div",{className:"flex w-6 xs:w-10 mr-2 mb-2 flex-shrink-0 items-center relative typebot-avatar-container ",ref:c,children:(0,o.jsx)(ni.A,{classNames:"bubble",timeout:500,in:r&&a,unmountOnExit:!0,children:(0,o.jsx)("div",{className:"absolute w-6 xs:w-10 h-6 xs:h-10 mb-4 xs:mb-2 flex items-center top-0",ref:p,style:{top:"".concat(i,"px"),transition:"top 350ms ease-out, opacity 500ms"},children:(0,o.jsx)(aa,{avatarSrc:n})})})})}),ar=()=>(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("div",{className:"w-2 h-2 mr-1 rounded-full bubble1"}),(0,o.jsx)("div",{className:"w-2 h-2 mr-1 rounded-full bubble2"}),(0,o.jsx)("div",{className:"w-2 h-2 rounded-full bubble3"})]}),al=e=>{let{url:t,onTransitionEnd:n}=e,{typebot:a,isLoading:r}=nj(),l=(0,d.useRef)(null),[i,s]=(0,d.useState)(!0),[u]=(0,d.useState)(nf(a.variables)(t));return(0,d.useEffect)(()=>{if(!i||r)return;let e=setTimeout(()=>{s(!1),setTimeout(()=>{n()},400)},500);return()=>{clearTimeout(e)}},[r,i,n]),(0,o.jsx)("div",{className:"flex flex-col",children:(0,o.jsx)("div",{className:"flex mb-2 w-full lg:w-11/12 items-center",children:(0,o.jsxs)("div",{className:"flex relative z-10 items-start typebot-host-bubble",children:[(0,o.jsx)("div",{className:"flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 ",style:{width:i?"4rem":"100%",height:i?"2rem":"100%"},children:i?(0,o.jsx)(ar,{}):null}),(0,o.jsx)("audio",{ref:l,src:u,className:"z-10 content-opacity m-2 "+(i?"opacity-0":"opacity-100"),style:{height:i?"2rem":"revert"},autoPlay:!0,controls:!0})]})})})},ai=e=>{var t,n;let{block:a,onTransitionEnd:r}=e,{typebot:l,isLoading:i}=nj(),s=(0,d.useRef)(null),[u,c]=(0,d.useState)(!0),[p]=(0,d.useState)(nf(l.variables)(null==(t=a.content)?void 0:t.url)),b=(0,d.useCallback)(()=>{c(!1),setTimeout(()=>{r()},400)},[r]);(0,d.useEffect)(()=>{if(!u||i)return;let e=setTimeout(()=>{c(!1),b()},1e3);return()=>{clearTimeout(e)}},[i,u,b]);let m=(null==(n=a.content)?void 0:n.height)?"string"==typeof a.content.height?nf(l.variables)(a.content.height)+"px":a.content.height:"2rem";return(0,o.jsx)("div",{className:"flex flex-col w-full",ref:s,children:(0,o.jsx)("div",{className:"flex mb-2 w-full lg:w-11/12 items-center",children:(0,o.jsxs)("div",{className:"flex relative z-10 items-start typebot-host-bubble w-full",children:[(0,o.jsx)("div",{className:"flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 ",style:{width:u?"4rem":"100%",height:u?"2rem":"100%"},children:u?(0,o.jsx)(ar,{}):null}),(0,o.jsx)("iframe",{id:"embed-bubble-content",src:p,className:"w-full z-20 p-4 content-opacity "+(u?"opacity-0":"opacity-100"),style:{height:u?"2rem":m,borderRadius:"15px"}})]})})})},as=e=>{var t;let{block:n,onTransitionEnd:a}=e,{typebot:r,isLoading:l}=nj(),i=(0,d.useRef)(null),s=(0,d.useRef)(null),[u,c]=(0,d.useState)(!0),[p]=(0,d.useState)(nf(r.variables)(null==(t=n.content)?void 0:t.url)),b=(0,d.useCallback)(()=>{c(!1),setTimeout(()=>{a()},400)},[a]);return(0,d.useEffect)(()=>{if(!u||l)return;let e=setTimeout(()=>{c(!1),b()},5e3);return()=>{clearTimeout(e)}},[l,u,b]),(0,d.useEffect)(()=>{let e=s.current;if(!(!e||l||!u))return e.onload=()=>{c(!1),b()},()=>{e.onload=null}},[l,u,b]),(0,o.jsx)("div",{className:"flex flex-col",ref:i,children:(0,o.jsx)("div",{className:"flex mb-2 w-full lg:w-11/12 items-center",children:(0,o.jsxs)("div",{className:"flex relative z-10 items-start typebot-host-bubble",children:[(0,o.jsx)("div",{className:"flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 ",style:{width:u?"4rem":"100%",height:u?"2rem":"100%"},children:u?(0,o.jsx)(ar,{}):null}),(0,o.jsx)("img",{ref:s,src:p,className:"p-4 content-opacity z-10 w-auto rounded-lg "+(u?"opacity-0":"opacity-100"),style:{maxHeight:"32rem",height:u?"2rem":"auto",maxWidth:"100%"},alt:"Bubble image"})]})})})},au=e=>{var t,n,a;let{block:r,onTransitionEnd:i}=e,{typebot:s,isLoading:u}=nj(),p=(0,d.useRef)(null),[b,m]=(0,d.useState)(!0),[h]=(0,d.useState)(nf(s.variables)(null==(t=r.content)?void 0:t.html)),g=(0,d.useCallback)(()=>{m(!1),setTimeout(()=>{i()},400)},[i]);return(0,d.useEffect)(()=>{var e,t,n;if(!b||u)return;let a=setTimeout(()=>{g()},(e=>{var t,n,a,o,r;let{bubbleContent:i,typingSettings:s}=e,u=null!=(n=null==(t=i.match(/(\w+)/g))?void 0:t.length)?n:0;0===u&&(u=i.length);let{enabled:d,speed:c,maxDelay:p}={enabled:null!=(a=null==s?void 0:s.enabled)?a:l.L6.typingEmulation.enabled,speed:null!=(o=null==s?void 0:s.speed)?o:l.L6.typingEmulation.speed,maxDelay:null!=(r=null==s?void 0:s.maxDelay)?r:l.L6.typingEmulation.maxDelay},b=d?u/c*6e4:0;return b>1e3*p&&(b=1e3*p),b})({bubbleContent:null!=(n=null==(e=r.content)?void 0:e.plainText)?n:"",typingSettings:null==(t=s.settings)?void 0:t.typingEmulation}));return()=>{clearTimeout(a)}},[null==(n=r.content)?void 0:n.plainText,u,b,g,null==(a=s.settings)?void 0:a.typingEmulation]),(0,o.jsx)("div",{className:"flex flex-col",ref:p,children:(0,o.jsx)("div",{className:"flex mb-2 w-full items-center",children:(0,o.jsxs)("div",{className:"flex relative items-start typebot-host-bubble",children:[(0,o.jsx)("div",{className:"flex items-center absolute px-4 py-2 rounded-lg bubble-typing ",style:{width:b?"4rem":"100%",height:b?"2rem":"100%"},"data-testid":"host-bubble",children:b?(0,o.jsx)(ar,{}):null}),r.type===c.TEXT&&(0,o.jsx)("p",{style:{textOverflow:"ellipsis"},className:"overflow-hidden content-opacity mx-4 my-2 whitespace-pre-wrap slate-html-container relative "+(b?"opacity-0 h-6":"opacity-100 h-full"),dangerouslySetInnerHTML:{__html:h}})]})})})},ad=e=>{let{block:t,onTransitionEnd:n}=e,{typebot:a,isLoading:r}=nj(),l=(0,d.useRef)(null),[i,s]=(0,d.useState)(!0),u=(0,d.useCallback)(()=>{s(!1),setTimeout(()=>{n()},400)},[n]);return(0,d.useEffect)(()=>{if(!i||r)return;let e=setTimeout(()=>{s(!1),u()},1e3);return()=>{clearTimeout(e)}},[r,i,u]),(0,o.jsx)("div",{className:"flex flex-col",ref:l,children:(0,o.jsx)("div",{className:"flex mb-2 w-full lg:w-11/12 items-center",children:(0,o.jsxs)("div",{className:"flex relative z-10 items-start typebot-host-bubble",children:[(0,o.jsx)("div",{className:"flex items-center absolute px-4 py-2 rounded-lg bubble-typing z-10 ",style:{width:i?"4rem":"100%",height:i?"2rem":"100%"},children:i?(0,o.jsx)(ar,{}):null}),(0,o.jsx)(ac,{content:t.content,isTyping:i,variables:a.variables})]})})})},ac=e=>{let{content:t,isTyping:n,variables:a}=e,[r]=(0,d.useState)(nf(a)(null==t?void 0:t.url));if(!(null==t?void 0:t.type))return null;switch(t.type){case ew.URL:{let e=window.navigator.vendor.match(/apple/i);return(0,o.jsxs)("video",{controls:!0,className:"p-4 focus:outline-none w-full z-10 content-opacity rounded-md "+(n?"opacity-0":"opacity-100"),style:{height:n?"2rem":"auto",maxHeight:e?"40vh":""},autoPlay:!0,children:[(0,o.jsx)("source",{src:r,type:"video/mp4"}),"Sorry, your browser doesn't support embedded videos."]})}case ew.VIMEO:case ew.YOUTUBE:{let e=t.type===ew.VIMEO?"https://player.vimeo.com/video":"https://www.youtube.com/embed";return(0,o.jsx)("iframe",{src:"".concat(e,"/").concat(t.id),className:"w-full p-4 content-opacity z-10 rounded-md "+(n?"opacity-0":"opacity-100"),height:n?"2rem":"200px",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}default:return null}},ap=e=>{let{block:t,onTransitionEnd:n}=e;switch(t.type){case c.TEXT:return(0,o.jsx)(au,{block:t,onTransitionEnd:n});case c.IMAGE:return(0,o.jsx)(as,{block:t,onTransitionEnd:n});case c.VIDEO:return(0,o.jsx)(ad,{block:t,onTransitionEnd:n});case c.EMBED:return(0,o.jsx)(ai,{block:t,onTransitionEnd:n});case c.AUDIO:var a;return(0,o.jsx)(al,{url:null==(a=t.content)?void 0:a.url,onTransitionEnd:n})}},ab=e=>{var t,n;let{block:a,onSubmit:r}=e,{typebot:{variables:l}}=nj(),{resultValues:i}=nT(),[s,u]=(0,d.useState)([]),c=i&&0===i.answers.length&&1===a.items.length;return(0,o.jsxs)("form",{className:"flex flex-col items-end",onSubmit:()=>r({value:s.map(e=>nf(l)(a.items[e].content)).join(", ")}),children:[(0,o.jsx)("div",{className:"flex flex-wrap justify-end",children:a.items.map((e,t)=>{var n,i;return(0,o.jsxs)("span",{className:"relative inline-flex ml-2 mb-2",children:[(0,o.jsx)("button",{role:(null==(n=a.options)?void 0:n.isMultipleChoice)?"checkbox":"button",onClick:(e=>t=>{var n;t.preventDefault(),(null==(n=a.options)?void 0:n.isMultipleChoice)?(e=>{let t=s.indexOf(e);-1!==t?(s.splice(t,1),u([...s])):u([...s,e])})(e):r({value:nf(l)(a.items[e].content),itemId:a.items[e].id})})(t),className:"py-2 px-4 text-left font-semibold rounded-md transition-all filter hover:brightness-90 active:brightness-75 duration-100 focus:outline-none typebot-button "+(!s.includes(t)&&(null==(i=a.options)?void 0:i.isMultipleChoice)?"selectable":""),"data-testid":"button","data-itemid":e.id,children:nf(l)(e.content)}),c&&(0,o.jsxs)("span",{className:"flex h-3 w-3 absolute top-0 right-0 -mt-1 -mr-1 ping",children:[(0,o.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full brightness-225 opacity-75"}),(0,o.jsx)("span",{className:"relative inline-flex rounded-full h-3 w-3 brightness-200"})]})]},e.id)})}),(0,o.jsx)("div",{className:"flex",children:s.length>0&&(0,o.jsx)(n3,{label:null!=(n=null==(t=a.options)?void 0:t.buttonLabel)?n:"Send",disableIcon:!0})})]})},am=e=>{var t,n,a;let{onSubmit:r,options:l}=e,{hasTime:i,isRange:s,labels:u}=null!=l?l:{},[c,p]=(0,d.useState)({from:"",to:""});return(0,o.jsx)("div",{className:"flex flex-col w-full lg:w-4/6",children:(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsxs)("form",{className:"flex justify-between rounded-lg typebot-input pr-2 items-end",onSubmit:e=>{""===c.from&&""===c.to||(e.preventDefault(),r({value:"".concat(c.from).concat(s?" to ".concat(c.to):""),label:(e=>{let{from:t,to:n,hasTime:a,isRange:o}=e,r=window.navigator.language,l={day:"2-digit",month:"2-digit",year:"numeric",hour:a?"2-digit":void 0,minute:a?"2-digit":void 0},i=new Date(a?t:t.replace(/-/g,"/")).toLocaleString(r,l),s=new Date(a?n:n.replace(/-/g,"/")).toLocaleString(r,l);return"".concat(i).concat(o?" to ".concat(s):"")})({...c,hasTime:i,isRange:s})}))},children:[(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsxs)("div",{className:"flex items-center p-4 "+(s?"pb-0":""),children:[s&&(0,o.jsx)("p",{className:"font-semibold mr-2",children:null!=(t=null==u?void 0:u.from)?t:"From:"}),(0,o.jsx)("input",{className:"focus:outline-none flex-1 w-full text-input",style:{minHeight:"2rem",minWidth:"100px",fontSize:"16px"},type:i?"datetime-local":"date",onChange:e=>p({...c,from:e.target.value}),"data-testid":"from-date"})]}),s&&(0,o.jsxs)("div",{className:"flex items-center p-4",children:[s&&(0,o.jsx)("p",{className:"font-semibold",children:null!=(n=null==u?void 0:u.to)?n:"To:"}),(0,o.jsx)("input",{className:"focus:outline-none flex-1 w-full text-input ml-2",style:{minHeight:"2rem",minWidth:"100px",fontSize:"16px"},type:i?"datetime-local":"date",onChange:e=>p({...c,to:e.target.value}),"data-testid":"to-date"})]})]}),(0,o.jsx)(n3,{label:null!=(a=null==u?void 0:u.button)?a:"Send",isDisabled:""===c.to&&""===c.from,className:"my-2 ml-2"})]})})})},ah=async e=>{let{basePath:t="/api",files:n,onUploadProgress:a}=e,o=[],l=0;for(let{file:e,path:i}of n){a&&a(l/n.length*100),l+=1;let{data:s}=await (0,r.w$)("".concat(t,"/storage/upload-url?filePath=").concat(encodeURIComponent(i),"&fileType=").concat(e.type));if(!(null==s?void 0:s.presignedUrl))continue;let u=s.presignedUrl;if(s.hasReachedStorageLimit)o.push(null);else{if(!(await fetch(u,{method:"PUT",body:e})).ok)continue;o.push(u.split("?")[0])}}return o},ag=e=>{var t,n,a,r;let{block:{id:l,options:i},onSubmit:s,onSkip:u}=e,{isMultipleAllowed:c,labels:p,isRequired:b}=null!=i?i:{},m=i&&"sizeLimit"in i?null==i?void 0:i.sizeLimit:void 0,{isPreview:h,currentTypebotId:g}=nj(),{resultId:y}=nT(),[f,v]=(0,d.useState)([]),[w,x]=(0,d.useState)(!1),[I,E]=(0,d.useState)(0),[T,_]=(0,d.useState)(!1),[C,S]=(0,d.useState)(),j=async e=>{e.target.files&&N(e.target.files)},N=e=>{S(void 0);let t=Array.from(e);return t.some(e=>e.size>(null!=m?m:10)*1048576)?S("A file is larger than ".concat(null!=m?m:10,"MB")):!c&&e?A(t[0]):void v([...f,...t])},k=async e=>{e.preventDefault(),0!==f.length&&P(f)},A=async e=>{var t;if(h)return s({label:"File uploaded",value:"http://fake-upload-url.com"});x(!0);let n=await ah({basePath:"/api/typebots/".concat(g,"/blocks/").concat(l),files:[{file:e,path:"public/results/".concat(y,"/").concat(l,"/").concat(e.name)}]});if(x(!1),n.length)return s({label:"File uploaded",value:null!=(t=n[0])?t:""});S("An error occured while uploading the file")},P=async e=>{if(h)return s({label:"".concat(e.length," file").concat(e.length>1?"s":""," uploaded"),value:e.map((e,t)=>"http://fake-upload-url.com/".concat(t)).join(", ")});x(!0);let t=await ah({basePath:"/api/typebots/".concat(g,"/blocks/").concat(l),files:e.map(e=>({file:e,path:"public/results/".concat(y,"/").concat(l,"/").concat(e.name)})),onUploadProgress:E});if(x(!1),E(0),t.length!==e.length)return S("An error occured while uploading the files");s({label:"".concat(t.length," file").concat(t.length>1?"s":""," uploaded"),value:t.join(", ")})};return(0,o.jsxs)("form",{className:"flex flex-col w-full",onSubmit:k,children:[(0,o.jsx)("label",{htmlFor:"dropzone-file",className:"typebot-upload-input py-6 flex flex-col justify-center items-center w-full bg-gray-50 rounded-lg border-2 border-gray-300 border-dashed cursor-pointer hover:bg-gray-100 px-8 mb-2 "+(T?"dragging-over":""),onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&N(e.dataTransfer.files)},children:w?1===f.length?(0,o.jsx)(n4,{}):(0,o.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2.5",children:(0,o.jsx)("div",{className:"upload-progress-bar h-2.5 rounded-full",style:{width:"".concat(I>0?I:10,"%"),transition:"width 150ms cubic-bezier(0.4, 0, 0.2, 1)"}})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex flex-col justify-center items-center",children:[f.length?(0,o.jsxs)("span",{className:"relative",children:[(0,o.jsx)(af,{}),(0,o.jsx)("div",{className:"total-files-indicator flex items-center justify-center absolute -right-1 rounded-full px-1 h-4",style:{bottom:"5px"},children:f.length})]}):(0,o.jsx)(ay,{}),(0,o.jsx)("p",{className:"text-sm text-gray-500 text-center",dangerouslySetInnerHTML:{__html:null!=(t=null==p?void 0:p.placeholder)?t:""}})]}),(0,o.jsx)("input",{id:"dropzone-file",type:"file",className:"hidden",multiple:c,onChange:j})]})}),0===f.length&&!1===b&&(0,o.jsx)("div",{className:"flex justify-end",children:(0,o.jsx)("button",{className:"py-2 px-4 justify-center font-semibold rounded-md text-white focus:outline-none flex items-center disabled:opacity-50 disabled:cursor-not-allowed disabled:brightness-100 transition-all filter hover:brightness-90 active:brightness-75 typebot-button ",onClick:u,children:null!=(n=null==p?void 0:p.skip)?n:nm.labels.skip})}),c&&f.length>0&&!w&&(0,o.jsx)("div",{className:"flex justify-end",children:(0,o.jsxs)("div",{className:"flex",children:[f.length&&(0,o.jsx)("button",{className:"secondary-button py-2 px-4 justify-center font-semibold rounded-md text-white focus:outline-none flex items-center disabled:opacity-50 disabled:cursor-not-allowed disabled:brightness-100 transition-all filter hover:brightness-90 active:brightness-75 mr-2",onClick:()=>v([]),children:null!=(a=null==p?void 0:p.clear)?a:nm.labels.clear}),(0,o.jsx)(n3,{type:"submit",label:(null==p?void 0:p.button)===nm.labels.button?"".concat(p.button," ").concat(f.length," file").concat(f.length>1?"s":""):null!=(r=null==p?void 0:p.button)?r:"",disableIcon:!0})]})}),C&&(0,o.jsx)("p",{className:"text-red-500 text-sm",children:C})]})},ay=()=>(0,o.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-3",children:[(0,o.jsx)("polyline",{points:"16 16 12 12 8 16"}),(0,o.jsx)("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),(0,o.jsx)("path",{d:"M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"}),(0,o.jsx)("polyline",{points:"16 16 12 12 8 16"})]}),af=()=>(0,o.jsxs)("svg",{className:"mb-3",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,o.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,o.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),av=e=>{var t,n,a,r,l,i,s,u,c,p;let{block:b,onSubmit:m,defaultValue:h,hasGuestAvatar:g}=e,[y,f]=(0,d.useState)(null!=h?h:""),v=(0,d.useRef)(null),w=()=>{(()=>{var e;return""!==y&&(null==(e=v.current)?void 0:e.reportValidity())})()&&m({value:y})};return(0,o.jsxs)("div",{className:"flex items-end justify-between rounded-lg pr-2 typebot-input w-full","data-testid":"input",style:{marginRight:g?"50px":"0.5rem",maxWidth:"350px"},onKeyDown:e=>{"Enter"===e.key&&w()},children:[(0,o.jsx)(n2,{ref:v,value:y,placeholder:null!=(u=null==(n=b.options)||null==(t=n.labels)?void 0:t.placeholder)?u:"Type your answer...",onChange:e=>f(e),type:"number",style:{appearance:"auto"},min:null==(a=b.options)?void 0:a.min,max:null==(r=b.options)?void 0:r.max,step:null!=(c=null==(l=b.options)?void 0:l.step)?c:"any"}),(0,o.jsx)(n3,{type:"button",label:null!=(p=null==(s=b.options)||null==(i=s.labels)?void 0:i.button)?p:"Send",isDisabled:""===y,className:"my-2 ml-2",onClick:w})]})},aw=e=>{let{options:t,onSuccess:n}=e,{apiHost:a,isPreview:l,typebot:{variables:i},onNewLog:s}=nj(),[u,c]=(0,d.useState)(null),[p,b]=(0,d.useState)(""),[m,h]=(0,d.useState)("");return(0,d.useEffect)(()=>{(async()=>{var e;let{data:n,error:o}=await (e=>{let{apiHost:t,isPreview:n,inputOptions:a,variables:o}=e;return(0,r.w$)({url:"".concat(t,"/api/integrations/stripe/createPaymentIntent"),method:"POST",body:{inputOptions:a,isPreview:n,variables:o}})})({apiHost:a,isPreview:l,variables:i,inputOptions:t});if(o)return s({status:"error",description:o.name+" "+o.message,details:o.message});!n||!document||(await (e=>new Promise(t=>{if(e.getElementById("stripe-script"))return t();let n=e.createElement("script");n.src="https://js.stripe.com/v3",n.id="stripe-script",e.body.appendChild(n),n.onload=()=>{t()}}))(document),(null==(e=window)?void 0:e.Stripe)&&(c(window.Stripe(n.publicKey)),b(n.clientSecret),h(n.amountLabel)))})()},[]),u&&p?(0,o.jsx)(ng.Elements,{stripe:u,options:{clientSecret:p},children:(0,o.jsx)(ax,{onSuccess:n,clientSecret:p,amountLabel:m,options:t,variables:i,viewerHost:a})}):(0,o.jsx)(n4,{className:"text-blue-500"})},ax=e=>{var t;let{onSuccess:n,clientSecret:a,amountLabel:r,options:l,variables:i,viewerHost:s}=e,{scroll:u}=nO(),[c,p]=(0,d.useState)(!0),b=(0,ng.useStripe)(),m=(0,ng.useElements)(),[h,g]=(0,d.useState)(),[y,f]=(0,d.useState)(!1),[v,w]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(!(!b||!a)){if(c)return p(!1);b.retrievePaymentIntent(a).then(e=>{let{paymentIntent:t}=e;switch(null==t?void 0:t.status){case"succeeded":g("Payment succeeded!");break;case"processing":g("Your payment is processing.");break;case"requires_payment_method":g("Your payment was not successful, please try again.");break;default:g("Something went wrong.")}})}},[b,a]),(0,o.jsxs)("form",{id:"payment-form",onSubmit:async e=>{var t,a,o,r,u;if(e.preventDefault(),!b||!m)return;f(!0);let{error:d,paymentIntent:c}=await b.confirmPayment({elements:m,confirmParams:{return_url:s,payment_method_data:{billing_details:{name:(null==l||null==(t=l.additionalInformation)?void 0:t.name)?nf(i)(l.additionalInformation.name):void 0,email:(null==l||null==(a=l.additionalInformation)?void 0:a.email)?nf(i)(null==(o=l.additionalInformation)?void 0:o.email):void 0,phone:(null==l||null==(r=l.additionalInformation)?void 0:r.phoneNumber)?nf(i)(null==(u=l.additionalInformation)?void 0:u.phoneNumber):void 0}}},redirect:"if_required"});if(f(!1),(null==d?void 0:d.type)!=="validation_error"){if((null==d?void 0:d.type)==="card_error")return g(d.message);if(!d&&"succeeded"===c.status)return n()}},className:"flex flex-col rounded-lg p-4 typebot-input w-full items-center",children:[(0,o.jsx)(ng.PaymentElement,{id:"payment-element",className:"w-full",onReady:()=>{w(!0),u()}}),v&&(0,o.jsx)(n3,{label:"".concat(null==l||null==(t=l.labels)?void 0:t.button," ").concat(r),isDisabled:y||!b||!m,isLoading:y,className:"mt-4 w-full max-w-lg",disableIcon:!0}),h&&(0,o.jsx)("div",{id:"payment-message",className:"typebot-input-error-message mt-4 text-center",children:h})]})},aI=e=>{let{onSuccess:t,options:n}=e;switch(null==n?void 0:n.provider){case void 0:case nh.STRIPE:return(0,o.jsx)(aw,{onSuccess:t,options:n})}},aE=e=>{var t,n,a,l,i,s,u,c,p,b;let{block:m,onSubmit:h}=e,[g,y]=(0,d.useState)(),f=e=>{var t;(null==(t=m.options)?void 0:t.isOneClickSubmitEnabled)&&h({value:e.toString()}),y(e)};return(0,o.jsxs)("form",{className:"flex flex-col",onSubmit:e=>{e.preventDefault(),(0,r.pN)(g)||h({value:g.toString()})},children:[(null==(n=m.options)||null==(t=n.labels)?void 0:t.left)&&(0,o.jsx)("span",{className:"text-sm w-full mb-2 rating-label",children:m.options.labels.left}),(0,o.jsx)("div",{className:"flex flex-wrap justify-center",children:Array.from(Array((null!=(p=null==(a=m.options)?void 0:a.length)?p:ny.length)+ +((null==(l=m.options)?void 0:l.buttonType)==="Numbers"))).map((e,t)=>{var n;return(0,d.createElement)(aT,{...m.options,key:t,rating:g,idx:t+ +((null==(n=m.options)?void 0:n.buttonType)!=="Numbers"),onClick:f})})}),(null==(s=m.options)||null==(i=s.labels)?void 0:i.right)&&(0,o.jsx)("span",{className:"text-sm w-full text-right mb-2 pr-2 rating-label",children:m.options.labels.right}),(0,o.jsx)("div",{className:"flex justify-end mr-2",children:(0,r.O9)(g)&&(0,o.jsx)(n3,{label:null!=(b=null==(c=m.options)||null==(u=c.labels)?void 0:u.button)?b:"Send",disableIcon:!0})})]})},aT=e=>{let{rating:t,idx:n,buttonType:a,customIcon:l,onClick:i}=e;return"Numbers"===a?(0,o.jsx)("button",{onClick:e=>{e.preventDefault(),i(n)},className:"py-2 px-4 mr-2 mb-2 text-left font-semibold rounded-md transition-all filter hover:brightness-90 active:brightness-75 duration-100 focus:outline-none typebot-button "+((0,r.O9)(t)&&n<=t?"":"selectable"),children:n}):(0,o.jsx)("div",{className:"flex justify-center items-center rating-icon-container cursor-pointer mr-2 mb-2 "+((0,r.O9)(t)&&n<=t?"selected":""),onClick:()=>i(n),dangerouslySetInnerHTML:{__html:(null==l?void 0:l.isEnabled)&&!(0,r.Im)(l.svg)?l.svg:a_}})},a_='',aC=d.forwardRef(function(e,t){let{onChange:n,...a}=e;return(0,o.jsx)("textarea",{ref:t,className:"focus:outline-none bg-transparent px-4 py-4 flex-1 w-full text-input",rows:6,"data-testid":"textarea",required:!0,style:{fontSize:"16px"},autoFocus:!nD,onChange:e=>n(e.target.value),...a})}),aS=e=>{var t,n,a,r,l,i,s,u,c,p;let{block:b,onSubmit:m,defaultValue:h,hasGuestAvatar:g}=e,[y,f]=(0,d.useState)(null!=h?h:""),v=(0,d.useRef)(null),w=null==(t=b.options)?void 0:t.isLong,x=e=>f(e),I=()=>{(()=>{var e;return""!==y&&(null==(e=v.current)?void 0:e.reportValidity())})()&&m({value:y})};return(0,o.jsxs)("div",{className:"flex items-end justify-between rounded-lg pr-2 typebot-input w-full","data-testid":"input",style:{marginRight:g?"50px":"0.5rem",maxWidth:w?void 0:"350px"},onKeyDown:e=>{w||"Enter"===e.key&&I()},children:[w?(0,o.jsx)(aC,{ref:v,onChange:x,value:y,placeholder:null!=(u=null==(a=b.options)||null==(n=a.labels)?void 0:n.placeholder)?u:"Type your answer..."}):(0,o.jsx)(n2,{ref:v,onChange:x,value:y,placeholder:null!=(c=null==(l=b.options)||null==(r=l.labels)?void 0:r.placeholder)?c:"Type your answer..."}),(0,o.jsx)(n3,{type:"button",label:null!=(p=null==(s=b.options)||null==(i=s.labels)?void 0:i.button)?p:"Send",isDisabled:""===y,className:"my-2 ml-2",onClick:I})]})},aj=e=>{let{message:t,showAvatar:n,avatarSrc:a}=e,[r]=(0,d.useState)(t);return(0,o.jsx)(ni.A,{classNames:"bubble",timeout:1e3,children:(0,o.jsxs)("div",{className:"flex justify-end mb-2 items-end",style:{marginLeft:"50px"},children:[(0,o.jsx)("span",{className:"px-4 py-2 rounded-lg mr-2 whitespace-pre-wrap max-w-full typebot-guest-bubble cursor-pointer","data-testid":"guest-bubble",children:r}),n&&(0,o.jsx)(aa,{avatarSrc:a})]})})},aN=e=>{var t,n,a,i,s,u,c,b,m;let{block:h,hasAvatar:g,hasGuestAvatar:y,onTransitionEnd:f,onSkip:v}=e,{typebot:w,isLoading:x}=nj(),{addAnswer:I}=nT(),[E,T]=(0,d.useState)(),[_,C]=(0,d.useState)(!1),{variableId:S}=null!=(a=h.options)?a:{},j=(null!=(i=null==(t=w.settings.general)?void 0:t.isInputPrefillEnabled)?i:l.L6.general.isInputPrefillEnabled)&&S?null==(n=w.variables.find(e=>{var t;return e.name===(null==(t=w.variables.find((0,r.$H)(S)))?void 0:t.name)}))?void 0:n.value:void 0,N=async e=>{let{label:t,value:n,itemId:a}=e;T(null!=t?t:n);let o=!((e,t)=>{switch(t){case p.EMAIL:return n9.test(e);case p.PHONE:return(0,np.h1)(e);case p.URL:return ae.test(e)}return!0})(n,h.type);if(!o&&I){let{group:e}=nr(h.id,w.groups);await I(w.variables)({blockId:h.id,groupId:e.id,content:n,variableId:S,uploadedFiles:h.type===p.FILE})}_||f({label:t,value:n,itemId:a},o),C(!1)};if(x)return null;if(E){let e=null==(u=w.theme.chat)||null==(s=u.guestAvatar)?void 0:s.url;return(0,o.jsx)(aj,{message:E,showAvatar:null!=(m=null==(b=w.theme.chat)||null==(c=b.guestAvatar)?void 0:c.isEnabled)&&m,avatarSrc:e&&nf(w.variables)(e)})}return(0,o.jsxs)("div",{className:"flex justify-end",children:[g&&(0,o.jsx)("div",{className:"flex w-6 xs:w-10 h-6 xs:h-10 mr-2 mb-2 mt-1 flex-shrink-0 items-center"}),(0,o.jsx)(ak,{block:h,onSubmit:N,onSkip:v,defaultValue:null==j?void 0:j.toString(),hasGuestAvatar:y})]})},ak=e=>{let{block:t,onSubmit:n,onSkip:a,defaultValue:r,hasGuestAvatar:l}=e;switch(t.type){case p.TEXT:return(0,o.jsx)(aS,{block:t,onSubmit:n,defaultValue:r,hasGuestAvatar:l});case p.NUMBER:return(0,o.jsx)(av,{block:t,onSubmit:n,defaultValue:r,hasGuestAvatar:l});case p.EMAIL:return(0,o.jsx)(n6,{block:t,onSubmit:n,defaultValue:r,hasGuestAvatar:l});case p.URL:return(0,o.jsx)(n8,{block:t,onSubmit:n,defaultValue:r,hasGuestAvatar:l});case p.PHONE:return(0,o.jsx)(n7,{block:t,onSubmit:n,defaultValue:r,hasGuestAvatar:l});case p.DATE:return(0,o.jsx)(am,{options:t.options,onSubmit:n});case p.CHOICE:return(0,o.jsx)(ab,{block:t,onSubmit:n});case p.PAYMENT:return(0,o.jsx)(aI,{options:t.options,onSuccess:()=>{var e,a,o;return n({value:null!=(o=null==(a=t.options)||null==(e=a.labels)?void 0:e.success)?o:"Success"})}});case p.RATING:return(0,o.jsx)(aE,{block:t,onSubmit:n});case p.FILE:return(0,o.jsx)(ag,{block:t,onSubmit:n,onSkip:a});default:return null}},aA=e=>{var t,n;let{blocks:a,startBlockIndex:l,groupTitle:i,onGroupEnd:s,keepShowingHostAvatar:u}=e,{currentTypebotId:g,typebot:y,updateVariableValue:f,createEdge:v,apiHost:w,isPreview:x,parentTypebotIds:I,onNewLog:E,injectLinkedTypebot:T,linkedTypebots:_,setCurrentTypebotId:C,pushEdgeIdInLinkedTypebotQueue:S,pushParentTypebotId:j}=nj(),{resultValues:N,updateVariables:k,resultId:A}=nT(),{scroll:P}=nO(),[R,L]=(0,d.useState)([]),[U,O]=(0,d.useState)([]),[D,B]=(0,d.useState)(),V=e=>{if(L([...R,e]),na(e)){let t=(e=>{var t;return null==(t=e.filter(e=>na(e)||nn(e)).pop())?void 0:t.type})(R);t&&Object.values(c).includes(t)?O(U.map((t,n)=>n===U.length-1?{bubbles:[...t.bubbles,e]}:t)):O([...U,{bubbles:[e]}])}nn(e)&&(0===U.length||(0,r.O9)(U[U.length-1].input)?O([...U,{bubbles:[],input:e}]):O(U.map((t,n)=>n===U.length-1?{...t,input:e}:t)))};(0,d.useEffect)(()=>{let e=a[l];e&&V(e)},[]),(0,d.useEffect)(()=>{P(),M()},[R]);let M=async()=>{let e=[...R].pop();if(e){if(Object.values(m).includes(e.type)){var t;let{nextEdgeId:n,linkedTypebot:a,blockedPopupUrl:o}=await n1(e,{isPreview:x,apiHost:w,typebot:y,linkedTypebots:_,updateVariableValue:f,updateVariables:k,injectLinkedTypebot:T,onNewLog:E,createEdge:v,setCurrentTypebotId:C,pushEdgeIdInLinkedTypebotQueue:S,currentTypebotId:g,pushParentTypebotId:j});if(o&&B(o),e.type===m.REDIRECT&&(null==(t=e.options)?void 0:t.isNewTab)===!1)return;n?s({edgeId:n,updatedTypebot:a}):Y()}if(Object.values(b).concat(h).includes(e.type)){let{group:t}=nr(e.id,y.groups),n=await (e=>{let{block:t,context:n}=e;switch(t.type){case b.GOOGLE_SHEETS:return nF(t,n);case b.GOOGLE_ANALYTICS:return nH(t,n);case b.ZAPIER:case b.MAKE_COM:case b.PABBLY_CONNECT:case b.HTTP_REQUEST:return nq(t,n);case b.EMAIL:return((e,t)=>{var n,a,o,l,i,s;let{variables:u,apiHost:d,isPreview:c,onNewLog:p,resultId:b,typebotId:m,resultValues:h}=t;if(c)return p({status:"info",description:"Emails are not sent in preview mode"}),e.outgoingEdgeId;let{options:g}=e;return(0,r.w$)({url:"".concat(d,"/api/typebots/").concat(m,"/integrations/email?resultId=").concat(b),method:"POST",body:{credentialsId:null==g?void 0:g.credentialsId,recipients:null==g||null==(n=g.recipients)?void 0:n.map(nf(u)),subject:nf(u)(null!=(o=null==g?void 0:g.subject)?o:""),body:nf(u)(null!=(l=null==g?void 0:g.body)?l:""),cc:(null!=(i=null==g?void 0:g.cc)?i:[]).map(nf(u)),bcc:(null!=(s=null==g?void 0:g.bcc)?s:[]).map(nf(u)),replyTo:(null==g?void 0:g.replyTo)?nf(u)(g.replyTo):void 0,fileUrls:null==(a=u.find((0,r.$H)(null==g?void 0:g.attachmentsVariableId)))?void 0:a.value,isCustomBody:null==g?void 0:g.isCustomBody,isBodyCode:null==g?void 0:g.isBodyCode,resultValues:h}}).then(e=>{let{error:t}=e;p(nV(t,"Succesfully sent an email","Failed to send an email"))}),e.outgoingEdgeId})(t,n);case b.CHATWOOT:return((e,t)=>{let{variables:n,isPreview:a,onNewLog:o}=t;if(a)o({status:"info",description:"Chatwoot won't open in preview mode"});else if(nB)n_({closeChatBubble:!0}),n_({codeToExecute:nf(n)(nY(e.options))});else{let t=Function(nf(n)(nY(e.options)));try{t()}catch(e){console.error(e)}}return e.outgoingEdgeId})(t,n);default:return}})({block:e,context:{apiHost:w,typebotId:g,groupId:t.id,blockId:e.id,variables:y.variables,isPreview:x,updateVariableValue:f,updateVariables:k,resultValues:N,groups:y.groups,onNewLog:E,resultId:A,parentTypebotIds:I}});n?s({edgeId:n}):Y()}"start"===e.type&&s({edgeId:e.outgoingEdgeId})}},Y=(e,t)=>{P();let n=[...R].pop();if(n){var o,i,u;if(t&&(e=>nn(e)&&(0,r.O9)(e.options)&&"retryMessageContent"in e.options)(n)){let{group:e}=nr(n.id,y.groups);return V(((e,t,n,a)=>{var o;let r=nf(n)(null==(o=e.options)?void 0:o.retryMessageContent),l=e.id+1e3*Math.random(),i={id:(1e3*Math.random()).toString(),from:{blockId:l},to:{groupId:t,blockId:e.id}};return a(i),{id:l,type:c.TEXT,content:{html:"
".concat(r,"
"),richText:[],plainText:r},outgoingEdgeId:i.id}})(n,e.id,y.variables,v))}if(nn(n)&&(null==(o=n.options)?void 0:o.variableId)&&e&&f(n.options.variableId,e.value),n.type===p.CHOICE&&!(null==(i=n.options)?void 0:i.isMultipleChoice)){let t=null==(u=n.items.find((0,r.$H)(null==e?void 0:e.itemId)))?void 0:u.outgoingEdgeId;if(t)return s({edgeId:t})}if((null==n?void 0:n.outgoingEdgeId)||R.length===a.length)return s({edgeId:n.outgoingEdgeId})}let d=a[R.length+l];d?V(d):s({})},H=null==(n=y.theme.chat)||null==(t=n.hostAvatar)?void 0:t.url;return(0,o.jsx)("div",{className:"flex w-full","data-group-name":i,children:(0,o.jsx)("div",{className:"flex flex-col w-full min-w-0",children:U.map((e,t)=>{var n,a,r,l,i,s;return(0,o.jsx)(aP,{displayChunk:e,hostAvatar:{isEnabled:null==(i=null==(a=y.theme.chat)||null==(n=a.hostAvatar)?void 0:n.isEnabled)||i,src:H&&nf(y.variables)(H)},hasGuestAvatar:null!=(s=null==(l=y.theme.chat)||null==(r=l.guestAvatar)?void 0:r.isEnabled)&&s,onDisplayNextBlock:Y,keepShowingHostAvatar:u,blockedPopupUrl:D,onBlockedPopupLinkClick:()=>B(void 0)},t)})})})},aP=e=>{let{displayChunk:{bubbles:t,input:n},hostAvatar:a,hasGuestAvatar:l,keepShowingHostAvatar:i,blockedPopupUrl:s,onBlockedPopupLinkClick:u,onDisplayNextBlock:c}=e,[p,b]=(0,d.useState)(!1),m=(0,d.useRef)();(0,d.useEffect)(()=>{h()});let h=()=>{var e;return null==(e=m.current)?void 0:e.refreshTopOffset()};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex",children:[a.isEnabled&&t.length>0&&(0,o.jsx)(ao,{ref:m,hostAvatarSrc:a.src,keepShowing:(i||(0,r.O9)(n))&&!p}),(0,o.jsx)("div",{className:"flex-1",style:{marginRight:l?"50px":"0.5rem"},children:(0,o.jsx)(nl.A,{children:t.map(e=>(0,o.jsx)(ni.A,{classNames:"bubble",timeout:500,unmountOnExit:!0,children:(0,o.jsx)(ap,{block:e,onTransitionEnd:()=>{c(),h()}})},e.id))})})]}),!p&&(0,o.jsx)(ni.A,{classNames:"bubble",timeout:500,unmountOnExit:!0,in:(0,r.O9)(n),children:n?(0,o.jsx)(aN,{block:n,onTransitionEnd:c,onSkip:()=>{c(),b(!0)},hasAvatar:a.isEnabled,hasGuestAvatar:l}):(0,o.jsx)("div",{})}),s?(0,o.jsx)("div",{className:"flex justify-end",children:(0,o.jsx)(at,{url:s,onLinkClick:u})}):null]})},aR=e=>{let{theme:t,predefinedVariables:n,startGroupId:a,onNewGroupVisible:l,onCompleted:i}=e,{typebot:s,updateVariableValue:u,linkedBotQueue:c,popEdgeIdFromLinkedTypebotQueue:p}=nj(),[b,m]=(0,d.useState)([]),{updateVariables:h}=nT(),g=(0,d.useRef)(null),y=(0,d.useRef)(null),[f,v]=(0,d.useState)(!1),w=e=>{let{edgeId:t,updatedTypebot:n,groupId:a}=e,o=null!=n?n:s;if(a){let e=o.groups.find((0,r.$H)(a));return e?(l({id:"edgeId",from:{blockId:"block"},to:{groupId:a}}),m([...b,{group:e,startBlockIndex:0}])):void 0}let u=o.edges.find((0,r.$H)(t));if(!u){if(c.length>0){let e=c[0].edgeId;p(),w({edgeId:e})}return i()}let d=o.groups.find((0,r.$H)(u.to.groupId));if(!d)return i();let h=u.to.blockId?d.blocks.findIndex((0,r.$H)(u.to.blockId)):0;l(u),m([...b,{group:d,startBlockIndex:-1===h?0:h}])};(0,d.useEffect)(()=>{if(f)return;(0,r.O9)(n)&&Object.keys(n).length>0&&h(x(n)),v(!0);let e=s.groups[0].blocks[0].outgoingEdgeId;(e||a)&&w({edgeId:a?void 0:e,groupId:a})},[n]);let x=e=>{let t=[];return Object.keys(e).forEach(n=>{let a=s.variables.find(e=>e.name.toLowerCase()===n.toLowerCase());if(!e||(0,r.pN)(a))return;let o=e[n];o&&(u(null==a?void 0:a.id,o),t.push({...a,value:o}))}),t};return(0,d.useEffect)(()=>{document&&((e,t)=>{e&&(e.general&&((e,t)=>{let{background:n,font:a}=e;a&&"string"==typeof a&&t.setProperty(nN.general.fontFamily,a)})(e.general,t),e.chat&&((e,t)=>{let{hostBubbles:n,guestBubbles:a,buttons:o,inputs:r}=e;n&&nk(n,t),a&&nA(a,t),o&&nP(o,t),r&&nR(r,t)})(e.chat,t))})(t,document.body.style)},[t]),(0,o.jsxs)("div",{ref:y,className:"overflow-y-scroll w-full lg:w-3/4 min-h-full rounded lg:px-5 px-3 pt-10 relative scrollable-container typebot-chat-view",children:[(0,o.jsx)(nU,{onScroll:()=>{y.current&&setTimeout(()=>{no.Nk.scrollToBottom({duration:500,container:y.current})},1)},children:b.map((e,t)=>{let n=b[t+1],a=n&&nn(n.group.blocks[n.startBlockIndex]);return(0,o.jsx)(aA,{blocks:e.group.blocks,startBlockIndex:e.startBlockIndex,onGroupEnd:w,groupTitle:e.group.title,keepShowingHostAvatar:t===b.length-1||a},e.group.id+t)})}),(0,o.jsx)("div",{className:"w-full h-32",ref:g})]})},aL=()=>{let e=(0,d.useRef)(null);return(0,d.useEffect)(()=>{if(!document)return;let t=document.querySelector('[data-testid="container"]'),n=new MutationObserver(n=>{n.forEach(n=>{n.removedNodes.forEach(n=>{"lite-badge"===n.id&&t.append(e.current)})})});return n.observe(t,{subtree:!1,childList:!0}),()=>{n.disconnect()}},[]),(0,o.jsxs)("a",{ref:e,href:"https://www.typebot.io/?utm_source=litebadge",target:"_blank",rel:"noopener noreferrer",className:"fixed py-1 px-2 bg-white z-50 rounded shadow-md lite-badge",style:{bottom:"20px"},id:"lite-badge",children:["Made with ",(0,o.jsx)("span",{className:"text-blue-500",children:"Typebot"}),"."]})},aU=e=>{var t,n,a,r,l,i,c,p;let{typebot:b,apiHost:m=s._.NEXT_PUBLIC_VIEWER_URL[0],isPreview:h=!1,isLoading:g=!1,resultId:y,startGroupId:f,predefinedVariables:v,onNewLog:w,onNewGroupVisible:x,onNewAnswer:I,onCompleted:E,onVariablesUpdated:T}=e,_=(0,d.useMemo)(()=>{var e,t,n;return(null==b||null==(n=b.theme)||null==(t=n.general)||null==(e=t.background)?void 0:e.type)===u.hK.COLOR?b.theme.general.background.content:"transparent"},[null==b||null==(n=b.theme)||null==(t=n.general)?void 0:t.background]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("style",{children:['/* CSS variables. */\n:root {\n --PhoneInput-color--focus: #03b2cb;\n --PhoneInputInternationalIconPhone-opacity: 0.8;\n --PhoneInputInternationalIconGlobe-opacity: 0.65;\n --PhoneInputCountrySelect-marginRight: 0.35em;\n --PhoneInputCountrySelectArrow-width: 0.3em;\n --PhoneInputCountrySelectArrow-marginLeft: var(\n --PhoneInputCountrySelect-marginRight\n );\n --PhoneInputCountrySelectArrow-borderWidth: 1px;\n --PhoneInputCountrySelectArrow-opacity: 0.45;\n --PhoneInputCountrySelectArrow-color: currentColor;\n --PhoneInputCountrySelectArrow-color--focus: var(--PhoneInput-color--focus);\n --PhoneInputCountrySelectArrow-transform: rotate(45deg);\n --PhoneInputCountryFlag-aspectRatio: 1.5;\n --PhoneInputCountryFlag-height: 1em;\n --PhoneInputCountryFlag-borderWidth: 1px;\n --PhoneInputCountryFlag-borderColor: rgba(0, 0, 0, 0.5);\n --PhoneInputCountryFlag-borderColor--focus: var(--PhoneInput-color--focus);\n --PhoneInputCountryFlag-backgroundColor--loading: rgba(0, 0, 0, 0.1);\n}\n\n.PhoneInput {\n /* This is done to stretch the contents of this component. */\n display: flex;\n align-items: center;\n}\n\n.PhoneInputInput {\n /* The phone number input stretches to fill all empty space */\n flex: 1;\n /* The phone number input should shrink\n to make room for the extension input */\n min-width: 0;\n}\n\n.PhoneInputCountryIcon {\n width: calc(\n var(--PhoneInputCountryFlag-height) *\n var(--PhoneInputCountryFlag-aspectRatio)\n );\n height: var(--PhoneInputCountryFlag-height);\n}\n\n.PhoneInputCountryIcon--square {\n width: var(--PhoneInputCountryFlag-height);\n}\n\n.PhoneInputCountryIcon--border {\n /* Removed `background-color` because when an `` was still loading\n it would show a dark gray rectangle. */\n /* For some reason the `` is not stretched to 100% width and height\n and sometime there can be seen white pixels of the background at top and bottom. */\n background-color: var(--PhoneInputCountryFlag-backgroundColor--loading);\n /* Border is added via `box-shadow` because `border` interferes with `width`/`height`. */\n /* For some reason the `` is not stretched to 100% width and height\n and sometime there can be seen white pixels of the background at top and bottom,\n so an additional "inset" border is added. */\n box-shadow:\n 0 0 0 var(--PhoneInputCountryFlag-borderWidth)\n var(--PhoneInputCountryFlag-borderColor),\n inset 0 0 0 var(--PhoneInputCountryFlag-borderWidth)\n var(--PhoneInputCountryFlag-borderColor);\n}\n\n.PhoneInputCountryIconImg {\n /* Fixes weird vertical space above the flag icon. */\n /* https://gitlab.com/catamphetamine/react-phone-number-input/-/issues/7#note_348586559 */\n display: block;\n /* 3rd party flag icons won\'t stretch if they have `width` and `height`.\n Also, if an icon\'s aspect ratio was different, it wouldn\'t fit too. */\n width: 100%;\n height: 100%;\n}\n\n.PhoneInputInternationalIconPhone {\n opacity: var(--PhoneInputInternationalIconPhone-opacity);\n}\n\n.PhoneInputInternationalIconGlobe {\n opacity: var(--PhoneInputInternationalIconGlobe-opacity);\n}\n\n/* Styling native country `