import{d as t}from"./p-BCkDiHIY.js";function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))}const r="https://cdn.ai12z.net/assets/bot",o={ar:()=>import(`${r}/v1/lang/ar.js`),de:()=>import(`${r}/v1/lang/de.js`),en:()=>import(`${r}/v1/lang/en.js`),es:()=>import(`${r}/v1/lang/es.js`),fa:()=>import(`${r}/v1/lang/fa.js`),fr:()=>import(`${r}/v1/lang/fr.js`),hi:()=>import(`${r}/v1/lang/hi.js`),it:()=>import(`${r}/v1/lang/it.js`),ja:()=>import(`${r}/v1/lang/ja.js`),ko:()=>import(`${r}/v1/lang/ko.js`),nl:()=>import(`${r}/v1/lang/nl.js`),pl:()=>import(`${r}/v1/lang/pl.js`),pt:()=>import(`${r}/v1/lang/pt.js`),ro:()=>import(`${r}/v1/lang/ro.js`),sv:()=>import(`${r}/v1/lang/sv.js`),th:()=>import(`${r}/v1/lang/th.js`),tr:()=>import(`${r}/v1/lang/tr.js`),uk:()=>import(`${r}/v1/lang/uk.js`),vi:()=>import(`${r}/v1/lang/vi.js`),zh:()=>import(`${r}/v1/lang/zh.js`)};async function a(t){const n=o[t];if(n)try{return(await n()).default}catch(t){return{}}return{}}function e(t,n){if(!t)return;const r=document.createElement("link");r.setAttribute("rel","stylesheet"),r.setAttribute("href",n),t.appendChild(r)}function s(t,n){if(!t)return;const r=document.createElement("script");r.setAttribute("type","text/javascript"),r.setAttribute("src",n),t.appendChild(r)}function i(){let t=navigator.languages&&navigator.languages[0]||navigator.language;return-1!==t.indexOf("-")&&(t=t.split("-")[0]),-1!==t.indexOf("_")&&(t=t.split("_")[0]),t}function c(){return/(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent)}function u(t,n){localStorage.setItem(t,JSON.stringify(n))}function l(t,n){return t.target.classList.contains(n)}function v(t,n){return setInterval(t,n)}function f(t){t&&clearInterval(t)}function g(t,n){return!t&&(null==t?void 0:t.length)<3&&n&&n.length<1}function p(t,n,r="success",o,a,e,s,i){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({message:t,type:n,status:r},o&&{images:o}),a&&{id:a}),e&&{insightId:e}),s&&{thumbsId:s}),i&&{formModel:i})}function x(t,n,r){return void 0!==r?[...t.slice(0,r),n,...t.slice(r+1)]:[...t,n]}function d(t){return t.slice(0,-1)}function j(t,n){return n>0&&t>n}function m(t){try{const n=localStorage.getItem(`${t}`);return n?JSON.parse(n):[]}catch(t){return console.warn("Failed to read conversation history:",t),[]}}function $(n,r,o,a,e,s,i){if(!n)return;const c=JSON.parse(JSON.stringify(r));let u=m(e),l=[];if(u.length>0?(l=u.filter(a?t=>t.conversationId===o&&t.projectId===n&&t.configId===a:t=>t.conversationId===o&&t.projectId===n),l.length>0?(l[0].messages=c,l[0].date=new Date,"bot"===s&&(l[0].botState=i)):u.push({conversationId:o,projectId:n,configId:a,date:new Date,messages:c,botState:"bot"===s?i:{}})):u.push({conversationId:o,projectId:n,configId:a,date:new Date,messages:c,botState:"bot"===s?i:{}}),r.length>0){const n=t(u);try{window.localStorage.setItem(`${e}`,JSON.stringify(n))}catch(n){if("QuotaExceededError"===(null==n?void 0:n.name)){const n=t(u,1048576);try{window.localStorage.setItem(`${e}`,JSON.stringify(n))}catch(t){console.error("AI12Z: Even aggressive cleanup failed:",t),window.localStorage.removeItem(`${e}`)}}}}}function h(t,n,r){const o=function(t){const n=null!=t?t:"";return"string"==typeof n?n.trim():""}(n),a=o.length>0;return t.filter((t=>{if(r&&t.projectId!==r)return!1;const n="string"==typeof(null==t?void 0:t.configId)?t.configId.trim():"";return!n||!a||n===o}))}export{m as a,u as b,p as c,i as d,f as e,h as f,n as g,l as h,j as i,v as j,s as k,a as l,e as m,c as n,d as r,$ as s,x as u,g as v}