quala-widget
Version:
Smart feedback widget for SaaS trial optimization
1 lines • 91 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Quala={},e.React,e["react/jsx-runtime"],e.ReactDOM)}(this,(function(e,t,i,r){"use strict";var o=Object.defineProperty,n=(e,t,i)=>((e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);function s(e,t){for(var i=0;i<t.length;i++){const r=t[i];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const i=Object.getOwnPropertyDescriptor(r,t);i&&Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const a=class e{constructor(){n(this,"createRootFn",null),n(this,"legacyRender",null),n(this,"isReady",!1),n(this,"debug",!1)}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(e){this.debug=e}log(e,...t){this.debug&&console.log(`[Quala Renderer] ${e}`,...t)}async initialize(){var e,t;if(!this.isReady){try{const e=require("react-dom/client");if(e&&e.createRoot)return this.createRootFn=e.createRoot,this.isReady=!0,void this.log("Using direct require for react-dom/client")}catch(i){}try{const t=await Promise.resolve().then((()=>L));if(this.createRootFn=t.createRoot||(null==(e=t.default)?void 0:e.createRoot),this.createRootFn)return this.isReady=!0,void this.log("Using dynamic import for react-dom/client")}catch(i){}try{const e=require("react-dom");if(e&&e.render)return this.legacyRender=e,this.isReady=!0,void this.log("Using legacy ReactDOM.render")}catch(i){}try{const e=await import("react-dom"),i=e.render||(null==(t=e.default)?void 0:t.render);if(i&&"function"==typeof i)return this.legacyRender=e.default||e,this.isReady=!0,void this.log("Using dynamic import for legacy ReactDOM")}catch(i){console.error("[Quala] All React DOM loading methods failed")}}}createRoot(e){if(!this.isReady)throw new Error("[Quala] Renderer not ready. Call initialize() first.");if(this.createRootFn)return this.createRootFn(e);if(this.legacyRender)return{render:t=>{this.legacyRender.render(t,e)},unmount:()=>{this.legacyRender.unmountComponentAtNode&&this.legacyRender.unmountComponentAtNode(e)}};throw new Error("[Quala] No React rendering method available")}isInitialized(){return this.isReady}async ensureReady(){this.isReady||await this.initialize()}};n(a,"instance");let l=a;const d=class e{constructor(e=!1){n(this,"consoleErrors",[]),n(this,"failedRequests",[]),n(this,"userActions",[]),n(this,"pageStartTime",Date.now()),n(this,"debug",!1),n(this,"isCapturing",!1),n(this,"qualaContainerSelectors",["[data-quala-widget]","[data-quala-micro-widget]","[data-quala-container]",".quala-widget",".quala-micro-widget",".quala-container",".quala-modal",".quala-overlay"]),this.debug=e}log(e,...t){this.debug&&console.log(`[Quala Context] ${e}`,...t)}isQualaElement(e){var t;if(!(e&&e instanceof Element))return!1;let i=e;for(;i;){if(i.hasAttribute("data-quala-widget")||i.hasAttribute("data-quala-micro-widget")||i.hasAttribute("data-quala-container"))return this.log("🎯 Quala element detected - inside container:",i.tagName),!0;if(i.className&&"string"==typeof i.className){if(i.className.split(" ").some((e=>"quala-widget"===e||"quala-micro-widget"===e||"quala-container"===e||"quala-modal"===e||"quala-overlay"===e)))return this.log("🎯 Quala element detected - inside CSS container:",i.className),!0}if("DIV"===i.tagName||"FORM"===i.tagName){const e=(null==(t=i.textContent)?void 0:t.toLowerCase())||"";if((e.includes("send feedback")||e.includes("submit feedback"))&&e.length<200)return this.log("🎯 Quala element detected - content pattern container"),!0;if(i.querySelector('textarea[placeholder*="explain"], textarea[placeholder*="feedback"], textarea[placeholder*="improve"]'))return this.log("🎯 Quala element detected - feedback form container"),!0}i=i.parentElement}return!1}isQualaRequest(e){try{const t=new URL(e,window.location.origin);return t.pathname.includes("/api/widget")||t.hostname.includes("getquala.xyz")||t.pathname.includes("quala")}catch{return e.includes("quala")||e.includes("/api/widget")}}initialize(){"undefined"==typeof window||this.isCapturing||(this.isCapturing=!0,this.captureConsoleErrors(),this.captureNetworkFailures(),this.captureUserActions(),this.trackPageVisibility(),this.log("Enhanced technical context capture initialized with improved Quala component filtering"))}captureConsoleErrors(){const e=console.error,t=console.warn;console.error=(...t)=>{const i=t.join(" ").toLowerCase();i.includes("[quala")||i.includes("quala sdk")||this.addConsoleError("error",t),e.apply(console,t)},console.warn=(...e)=>{const i=e.join(" ").toLowerCase();i.includes("[quala")||i.includes("quala sdk")||this.addConsoleError("warn",e),t.apply(console,e)},window.addEventListener("error",(e=>{var t,i,r;this.isQualaElement(e.target)||(null==(t=e.filename)?void 0:t.includes("quala"))||(null==(i=e.message)?void 0:i.toLowerCase().includes("quala"))||(this.addConsoleError("error",[e.message],null==(r=e.error)?void 0:r.stack),this.addUserAction("error","window",{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno}))})),window.addEventListener("unhandledrejection",(e=>{var t;String(e.reason).toLowerCase().includes("quala")||(this.addConsoleError("error",[e.reason],null==(t=e.reason)?void 0:t.stack),this.addUserAction("error","promise",{reason:String(e.reason)}))}))}captureNetworkFailures(){const e=window.fetch;window.fetch=async(...t)=>{const i=this.getRequestUrl(t[0]),r=this.isQualaRequest(i);try{const o=await e.apply(window,t);return o.ok||r||this.addFailedRequest(i,o.status,this.getRequestMethod(t[1]),(new Date).toISOString()),o}catch(o){throw r||this.addFailedRequest(i,0,this.getRequestMethod(t[1]),(new Date).toISOString()),o}},this.interceptXHR()}interceptXHR(){const t=XMLHttpRequest.prototype.open,i=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,r){return this._quala_method=i,this._quala_url=r,this._quala_is_quala_request=e.getInstance().isQualaRequest(r),t.apply(this,arguments)},XMLHttpRequest.prototype.send=function(){const t=e.getInstance(),r=this._quala_is_quala_request;return this.addEventListener("error",(()=>{this._quala_url&&!r&&t.addFailedRequest(this._quala_url,this.status||0,this._quala_method||"GET",(new Date).toISOString())})),this.addEventListener("load",(()=>{this.status>=400&&this._quala_url&&!r&&t.addFailedRequest(this._quala_url,this.status,this._quala_method||"GET",(new Date).toISOString())})),i.apply(this,arguments)}}getRequestUrl(e){return"string"==typeof e?e:e instanceof URL?e.toString():e instanceof Request?e.url:"unknown"}getRequestMethod(e){return(null==e?void 0:e.method)||"GET"}captureUserActions(){let e,t=0;document.addEventListener("click",(e=>{const i=Date.now();if(i-t>100&&!this.isQualaElement(e.target)){const r=e.target,o=this.getElementDetails(r);this.addUserAction("click",this.getElementSelector(r),{x:e.clientX,y:e.clientY,button:e.button},o),t=i}})),document.addEventListener("input",(e=>{if(!this.isQualaElement(e.target)){const t=e.target;if("INPUT"===t.tagName||"TEXTAREA"===t.tagName){const e=this.getElementDetails(t);this.addUserAction("input",this.getElementSelector(t),{inputType:t.type,valueLength:t.value.length},e)}}})),document.addEventListener("submit",(e=>{if(!this.isQualaElement(e.target)){const t=e.target,i=this.getElementDetails(t);this.addUserAction("form_submit",this.getElementSelector(t),{action:t.action,method:t.method,elementCount:t.elements.length},i)}})),document.addEventListener("scroll",(()=>{clearTimeout(e),e=setTimeout((()=>{this.addUserAction("scroll","window",{scrollY:window.scrollY,scrollX:window.scrollX,scrollPercentage:Math.round(window.scrollY/(document.documentElement.scrollHeight-window.innerHeight)*100)})}),200)})),document.addEventListener("focusin",(e=>{if(!this.isQualaElement(e.target)){const t=e.target,i=this.getElementDetails(t);this.addUserAction("focus",this.getElementSelector(t),{},i)}}))}trackPageVisibility(){document.addEventListener("visibilitychange",(()=>{this.addUserAction("navigation","page",{visibility:document.visibilityState,timeOnPage:Date.now()-this.pageStartTime})}))}getElementDetails(e){var t;if(!e)return{tagName:"unknown"};const i={tagName:e.tagName.toLowerCase(),id:e.id||void 0,className:e.className||void 0},r=null==(t=e.textContent)?void 0:t.trim();if(r&&r.length>0&&(i.text=r.substring(0,100)),e instanceof HTMLInputElement?(i.type=e.type,i.name=e.name||void 0,i.placeholder=e.placeholder||void 0,e.value&&"password"!==e.type&&(i.value="email"===e.type?"[email]":"tel"===e.type?"[phone]":"number"===e.type?"[number]":e.value.length>0?`[${e.value.length} chars]`:void 0)):e instanceof HTMLTextAreaElement?(i.name=e.name||void 0,i.placeholder=e.placeholder||void 0,i.value=e.value.length>0?`[${e.value.length} chars]`:void 0):e instanceof HTMLSelectElement?(i.name=e.name||void 0,i.value=e.value||void 0):e instanceof HTMLButtonElement&&(i.type=e.type,i.name=e.name||void 0),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement){const t=this.getElementLabel(e);t&&!i.text&&(i.text=t)}const o=e.getAttribute("aria-label");o&&!i.text&&(i.ariaLabel=o.substring(0,50),i.text=o.substring(0,50));const n=e.getAttribute("title");if(n&&!i.text&&(i.title=n.substring(0,50),i.text=n.substring(0,50)),e instanceof HTMLButtonElement&&!i.text){const t=Array.from(e.children).map((e=>{var t;return null==(t=e.textContent)?void 0:t.trim()})).filter((e=>e&&e.length>0)).join(" ");t&&(i.text=t.substring(0,50))}return i}getElementLabel(e){var t,i,r,o,n,s,a,l;if(e.id){const i=document.querySelector(`label[for="${e.id}"]`);if(i)return null==(t=i.textContent)?void 0:t.trim().substring(0,50)}const d=e.closest("label");if(d){const e=Array.from(d.childNodes).filter((e=>e.nodeType===Node.TEXT_NODE)).map((e=>{var t;return null==(t=e.textContent)?void 0:t.trim()})).filter((e=>e&&e.length>0)).join(" ");return e?e.substring(0,50):null==(i=d.textContent)?void 0:i.trim().substring(0,50)}if(e.getAttribute("aria-label"))return null==(r=e.getAttribute("aria-label"))?void 0:r.substring(0,50);const c=e.getAttribute("aria-labelledby");if(c){const e=document.getElementById(c);if(e)return null==(o=e.textContent)?void 0:o.trim().substring(0,50)}const g=e.previousElementSibling;if(g&&("SPAN"===g.tagName||"DIV"===g.tagName)){const e=null==(n=g.textContent)?void 0:n.trim();if(e&&e.length>0&&e.length<100)return e.substring(0,50)}let u=e.previousSibling;for(;u&&u!==(null==(s=e.parentElement)?void 0:s.firstChild);){if(u.nodeType===Node.TEXT_NODE){const e=null==(a=u.textContent)?void 0:a.trim();if(e&&e.length>0)return e.substring(0,50)}else if(u.nodeType===Node.ELEMENT_NODE){const e=null==(l=u.textContent)?void 0:l.trim();if(e&&e.length>0&&e.length<100)return e.substring(0,50)}u=u.previousSibling}}getElementSelector(e){if(!e)return"unknown";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${e.className?`.${e.className.toString().split(" ").filter((e=>e)).slice(0,2).join(".")}`:""}`.substring(0,100)}addConsoleError(e,t,i){this.consoleErrors.push({message:t.map((e=>this.serializeArgument(e))).join(" ").substring(0,500),stack:null==i?void 0:i.substring(0,1e3),timestamp:(new Date).toISOString(),level:e}),this.consoleErrors.length>10&&(this.consoleErrors=this.consoleErrors.slice(-10)),this.log(`Captured ${e}:`,t[0])}serializeArgument(e){var t;if(null===e)return"null";if(void 0===e)return"undefined";if(e instanceof Error)return`${e.name}: ${e.message}${e.stack?"\n"+e.stack:""}`;if("object"==typeof e)try{return e.toString&&e.toString!==Object.prototype.toString?e.toString():JSON.stringify(e,null,2)}catch(i){return`[Object: ${(null==(t=e.constructor)?void 0:t.name)||"Unknown"}]`}return String(e)}addFailedRequest(e,t,i,r){const o=this.sanitizeUrl(e);this.failedRequests.push({url:o,status:t,method:i,timestamp:r}),this.failedRequests.length>5&&(this.failedRequests=this.failedRequests.slice(-5)),this.log(`Captured failed request: ${i} ${o} - ${t}`)}addUserAction(e,t,i,r){this.userActions.push({type:e,element:t,timestamp:(new Date).toISOString(),data:i,elementDetails:r}),this.userActions.length>20&&(this.userActions=this.userActions.slice(-20))}sanitizeUrl(e){try{const t=new URL(e,window.location.origin);return["password","token","key","secret","auth","session","api_key","access_token","refresh_token","jwt","bearer","credential","ssn","social_security","credit_card","ccn","cvv"].forEach((e=>{t.searchParams.has(e)&&t.searchParams.set(e,"[REDACTED]")})),t.toString()}catch{return e.length>200?e.substring(0,200)+"...":e}}getPerformanceMetrics(){if("undefined"==typeof window||!window.performance)return{};const e=window.performance.getEntriesByType("navigation")[0],t=window.performance.getEntriesByType("paint"),i={};e&&(i.pageLoadTime=e.loadEventEnd-e.startTime),t.forEach((e=>{"first-contentful-paint"===e.name&&(i.firstContentfulPaint=e.startTime)}));try{if("PerformanceObserver"in window){new PerformanceObserver((e=>{e.getEntries().forEach((e=>{"largest-contentful-paint"===e.name&&(i.largestContentfulPaint=e.startTime)}))})).observe({entryTypes:["largest-contentful-paint"]})}}catch(r){}return i}getDeviceInfo(){var e;const t=navigator.userAgent;return{userAgent:t,viewport:`${window.innerWidth}x${window.innerHeight}`,screenResolution:`${window.screen.width}x${window.screen.height}`,devicePixelRatio:window.devicePixelRatio||1,connectionType:(null==(e=navigator.connection)?void 0:e.effectiveType)||"unknown",deviceType:this.detectDeviceType(t),operatingSystem:this.detectOperatingSystem(t),browser:this.detectBrowser(t).name,browserVersion:this.detectBrowser(t).version,isTouchDevice:this.detectTouchDevice(),language:navigator.language||"unknown",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||"unknown"}}detectDeviceType(e){return/iPad|Android(?=.*Tablet)|Tablet/i.test(e)?"tablet":/Mobile|Android|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e)||window.screen.width<=768?"mobile":window.screen.width<=1024?"tablet":"desktop"}detectOperatingSystem(e){if(/Windows NT 10.0/i.test(e))return"Windows 10/11";if(/Windows NT 6.3/i.test(e))return"Windows 8.1";if(/Windows NT 6.2/i.test(e))return"Windows 8";if(/Windows NT 6.1/i.test(e))return"Windows 7";if(/Windows/i.test(e))return"Windows";if(/iPhone OS|iOS/i.test(e)){const t=e.match(/OS (\d+_\d+)/);return t?`iOS ${t[1].replace("_",".")}`:"iOS"}if(/Android/i.test(e)){const t=e.match(/Android (\d+\.?\d*)/);return t?`Android ${t[1]}`:"Android"}if(/Mac OS X/i.test(e)){const t=e.match(/Mac OS X (\d+_\d+_?\d*)/);return t?`macOS ${t[1].replace(/_/g,".")}`:"macOS"}return/Linux/i.test(e)?"Linux":/CrOS/i.test(e)?"Chrome OS":"Unknown"}detectBrowser(e){if(/Edg\//i.test(e)){const t=e.match(/Edg\/(\d+\.?\d*)/);return{name:"Edge",version:(null==t?void 0:t[1])||"Unknown"}}if(/Chrome/i.test(e)&&!/Chromium/i.test(e)){const t=e.match(/Chrome\/(\d+\.?\d*)/);return{name:"Chrome",version:(null==t?void 0:t[1])||"Unknown"}}if(/Safari/i.test(e)&&!/Chrome/i.test(e)){const t=e.match(/Version\/(\d+\.?\d*)/);return{name:"Safari",version:(null==t?void 0:t[1])||"Unknown"}}if(/Firefox/i.test(e)){const t=e.match(/Firefox\/(\d+\.?\d*)/);return{name:"Firefox",version:(null==t?void 0:t[1])||"Unknown"}}if(/OPR/i.test(e)){const t=e.match(/OPR\/(\d+\.?\d*)/);return{name:"Opera",version:(null==t?void 0:t[1])||"Unknown"}}return{name:"Unknown",version:"Unknown"}}detectTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}getPageContext(){return{url:window.location.href,referrer:document.referrer,timestamp:(new Date).toISOString(),scrollPosition:window.scrollY,timeOnPage:Date.now()-this.pageStartTime}}getContext(){return{consoleErrors:[...this.consoleErrors],failedRequests:[...this.failedRequests],performanceMetrics:this.getPerformanceMetrics(),deviceInfo:this.getDeviceInfo(),pageContext:this.getPageContext(),userActions:[...this.userActions.slice(-10)]}}getRecentErrors(e=5){return this.consoleErrors.slice(-e)}getRecentFailures(e=3){return this.failedRequests.slice(-e)}hasRecentActivity(){const e=Date.now()-6e4;return this.userActions.some((t=>new Date(t.timestamp).getTime()>e))}addQualaContainerSelector(e){this.qualaContainerSelectors.includes(e)||(this.qualaContainerSelectors.push(e),this.log(`Added custom Quala container selector: ${e}`))}checkIsQualaElement(e){return this.isQualaElement(e)}getDetectionInfo(){return{containerSelectors:[...this.qualaContainerSelectors],isCapturing:this.isCapturing}}static getInstance(){return e.instance||(e.instance=new e),e.instance}static initialize(t=!1){return e.instance=new e(t),e.instance.initialize(),e.instance}destroy(){this.isCapturing=!1,this.log("Technical context collector destroyed")}};n(d,"instance");let c=d;const g={family:"'Inter', system-ui, -apple-system, 'Segoe UI', 'Roboto', sans-serif",sizes:{xs:"10px",sm:"12px",base:"14px",lg:"16px",xl:"18px","2xl":"20px"},weights:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeights:{normal:"1.5"}},u=(e,t="normal")=>({fontFamily:g.family,fontSize:g.sizes[e],fontWeight:g.weights[t],lineHeight:g.lineHeights.normal,letterSpacing:"-0.01em"});u("lg","semibold"),u("base","normal"),u("sm","normal");const h={light:{background:"rgba(252, 252, 253, 0.98)",border:"rgba(226, 232, 240, 0.8)",text:{primary:"#0f172a",secondary:"#334155",tertiary:"#64748b"},gradient:{from:"rgba(248, 250, 252, 0.8)",to:"rgba(241, 245, 249, 0.8)"},button:{hover:"rgba(241, 245, 249, 0.8)",active:"rgba(226, 232, 240, 0.8)"},input:{background:"rgba(248, 250, 252, 0.8)",border:"rgba(226, 232, 240, 0.8)",focus:{border:"#0EA5E9",shadow:"rgba(14, 165, 233, 0.15)"}}},dark:{background:"rgba(15, 23, 42, 0.98)",border:"rgba(51, 65, 85, 0.8)",text:{primary:"#f8fafc",secondary:"#e2e8f0",tertiary:"#94a3b8"},gradient:{from:"rgba(30, 41, 59, 0.8)",to:"rgba(15, 23, 42, 0.8)"},button:{hover:"rgba(30, 41, 59, 0.8)",active:"rgba(51, 65, 85, 0.8)"},input:{background:"rgba(30, 41, 59, 0.8)",border:"rgba(51, 65, 85, 0.8)",focus:{border:"#38BDF8",shadow:"rgba(56, 189, 248, 0.15)"}}}},p=({triggerText:e="Start Trial",title:r="Before you start your trial...",questions:o,onSubmit:n,onClose:s,onCancel:a,open:l,onComplete:d,modalStyle:c={},theme:u="light",showPoweredBy:p=!0})=>{const f=h[u],m=void 0!==l,[y,b]=t.useState(!1),x=m?l:y,[w,v]=t.useState({}),[k,S]=t.useState({}),[C,T]=t.useState(!1),[W,E]=t.useState(!1),[j,I]=t.useState(0),M=t.useRef(null),q=t.useRef(null),R=t.useCallback((()=>{q.current&&(q.current.style.height="auto",q.current.style.height=`${q.current.scrollHeight}px`)}),[]);t.useEffect((()=>{var e,t;if(x){const i=o[j];"textarea"===(null==i?void 0:i.type)?null==(e=q.current)||e.focus():"text"===(null==i?void 0:i.type)&&(null==(t=M.current)||t.focus()),R()}}),[x,j,R]),t.useEffect((()=>{R()}),[w,R]),t.useEffect((()=>{const e=e=>{"Escape"===e.key&&x&&_()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[x]);const A=(e,t)=>{v((i=>({...i,[e]:t}))),S((t=>({...t,[e]:""})));const i=o[j];(null==i?void 0:i.id)!==e||"rating"!==i.type&&"boolean"!==i.type||setTimeout((()=>{j<o.length-1&&I(j+1)}),800)},L=async()=>{if((()=>{const e={};return o.forEach((({id:t,text:i,required:r,type:o="text"})=>{const n=w[t];!r||n&&("text"!==o&&"textarea"!==o||n.trim())||(e[t]=`${i} is required`)})),S(e),0===Object.keys(e).length})()){T(!0);try{await n(w),E(!0)}catch{S({form:"Submission failed. Please try again."})}finally{T(!1)}}},_=()=>{m||b(!1),W?null==d||d({answers:w}):null==a||a(),v({}),S({}),T(!1),E(!1),I(0),null==s||s()},O=(j+1)/o.length*100,D=t.useCallback((e=>{const t=o[e],i=w[t.id],r=t.type||"text";!t.required||i&&("text"!==r&&"textarea"!==r||i.trim())?(S((e=>({...e,[t.id]:""}))),I(e+1)):S((e=>({...e,[t.id]:`${t.text} is required`})))}),[o,w]);return i.jsxs("div",{style:{fontFamily:g.family},children:[!m&&i.jsx("button",{onClick:()=>{m||b(!0)},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"8px 16px",borderRadius:"8px",border:"none",fontSize:"14px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:"#0EA5E9",color:"white",...c.triggerColor&&{backgroundColor:c.triggerColor}},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#0369A1",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#0EA5E9",e.currentTarget.style.transform="translateY(0)"},children:e}),i.jsx("div",{"data-quala-widget":!0,className:"quala-widget",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"light"===u?"rgba(0, 0, 0, 0.15)":"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:x?1:0,visibility:x?"visible":"hidden",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)"},onClick:e=>{e.target===e.currentTarget&&_()},children:i.jsxs("div",{style:{backgroundColor:f.background,border:`1px solid ${f.border}`,borderRadius:"12px",padding:"16px",width:"100%",maxWidth:"360px",maxHeight:"90vh",overflowY:"auto",position:"relative",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",margin:"16px",transform:x?"scale(1) translateY(0)":"scale(0.95) translateY(10px)",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:[i.jsx("button",{onClick:_,style:{position:"absolute",top:"8px",right:"8px",width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s ease",color:f.text.secondary},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgba(14, 165, 233, 0.1)",e.currentTarget.style.color="#0EA5E9"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.color=f.text.secondary},"aria-label":"Close modal",children:i.jsx("svg",{style:{width:"14px",height:"14px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),W?i.jsxs("div",{style:{textAlign:"center",padding:"24px 0"},children:[i.jsxs("div",{style:{marginBottom:"24px"},children:[i.jsx("div",{style:{width:"48px",height:"48px",backgroundColor:"rgba(14, 165, 233, 0.1)",color:"#0EA5E9",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:"scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:i.jsx("svg",{style:{width:"24px",height:"24px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("h3",{style:{fontSize:"18px",fontWeight:"600",color:f.text.primary,margin:0,marginBottom:"8px",animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:"Thank you for your feedback!"}),i.jsx("p",{style:{fontSize:"14px",color:f.text.secondary,margin:0,lineHeight:"1.5",animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both"},children:"We appreciate you taking the time to share your thoughts with us."})]}),i.jsxs("button",{onClick:_,style:{padding:"10px 20px",fontSize:"14px",backgroundColor:"#0EA5E9",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",gap:"8px"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#0369A1",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#0EA5E9",e.currentTarget.style.transform="translateY(0)"},children:["Close",i.jsx("svg",{style:{width:"16px",height:"16px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{marginBottom:"16px"},children:[i.jsx("h3",{style:{fontSize:"16px",fontWeight:"600",color:f.text.primary,margin:0,marginBottom:"8px"},children:r}),i.jsx("div",{style:{width:"100%",height:"4px",backgroundColor:f.input.border,borderRadius:"2px",overflow:"hidden"},children:i.jsx("div",{style:{height:"100%",background:"linear-gradient(90deg, #0EA5E9 0%, #22D3EE 100%)",borderRadius:"2px",transition:"width 0.5s cubic-bezier(0.4, 0, 0.2, 1)",width:`${O}%`,animation:"gradientMove 2s ease infinite"}})}),i.jsxs("p",{style:{fontSize:"11px",color:f.text.secondary,margin:"6px 0 0 0"},children:["Step ",j+1," of ",o.length]})]}),i.jsxs("form",{onSubmit:e=>{e.preventDefault(),L()},style:{display:"flex",flexDirection:"column",gap:"16px"},children:[o.map((({id:e,text:t,required:r,type:n="text",options:s,placeholder:a},l)=>i.jsxs("div",{style:{opacity:l===j?1:0,display:l===j?"block":"none",transition:"opacity 0.3s ease"},children:[i.jsxs("label",{style:{fontSize:"13px",fontWeight:"500",color:f.text.primary,marginBottom:"6px",display:"block"},children:[t," ",r&&i.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),"text"===n&&i.jsx("input",{ref:l===j?M:null,type:"text",placeholder:a||"Your answer...",style:{width:"100%",boxSizing:"border-box",padding:"10px 12px",fontSize:"13px",border:`1px solid ${f.input.border}`,borderRadius:"8px",backgroundColor:f.input.background,color:f.text.primary,transition:"all 0.2s ease",outline:"none",...k[e]&&{borderColor:"#ef4444",boxShadow:"0 0 0 3px rgba(239, 68, 68, 0.15)"},fontFamily:g.family},value:w[e]||"",onChange:t=>A(e,t.target.value),onFocus:e=>{e.target.style.borderColor="#0EA5E9",e.target.style.boxShadow="0 0 0 3px rgba(14, 165, 233, 0.15)"},onBlur:t=>{k[e]||(t.target.style.borderColor=f.input.border,t.target.style.boxShadow="none")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),j<o.length-1?D(l):L())},required:r}),"textarea"===n&&i.jsx("textarea",{ref:l===j?q:null,placeholder:a||"Tell us more...",style:{width:"100%",boxSizing:"border-box",padding:"10px 12px",fontSize:"13px",border:`1px solid ${f.input.border}`,borderRadius:"8px",backgroundColor:f.input.background,color:f.text.primary,transition:"all 0.2s ease",outline:"none",resize:"none",minHeight:"80px",fontFamily:g.family,...k[e]&&{borderColor:"#ef4444",boxShadow:"0 0 0 3px rgba(239, 68, 68, 0.15)"}},value:w[e]||"",onChange:t=>{A(e,t.target.value),R()},onFocus:e=>{e.target.style.borderColor="#0EA5E9",e.target.style.boxShadow="0 0 0 3px rgba(14, 165, 233, 0.15)"},onBlur:t=>{k[e]||(t.target.style.borderColor=f.input.border,t.target.style.boxShadow="none")},onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),j<o.length-1?D(l):L())},required:r}),"rating"===n&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[i.jsx("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[1,2,3,4,5].map((t=>i.jsxs("button",{type:"button",style:{width:"40px",height:"40px",cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",border:"none",background:"none",fontSize:"24px",color:w[e]&&parseInt(w[e])>=t?"#0EA5E9":f.text.secondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px",position:"relative",fontFamily:g.family},onClick:()=>A(e,t.toString()),onMouseEnter:e=>{e.currentTarget.style.transform="scale(1.1)",e.currentTarget.style.color="#0EA5E9",e.currentTarget.style.backgroundColor="rgba(14, 165, 233, 0.1)"},onMouseLeave:i=>{i.currentTarget.style.transform="scale(1)",i.currentTarget.style.backgroundColor="transparent",(!w[e]||parseInt(w[e])<t)&&(i.currentTarget.style.color=f.text.secondary)},children:[i.jsx("span",{style:{position:"absolute",fontSize:"10px",fontWeight:"500",color:f.text.secondary,bottom:"-16px",opacity:0,transition:"all 0.2s ease",transform:"translateY(4px)"},children:t}),i.jsx("span",{style:{position:"relative",display:"inline-block",transition:"all 0.2s ease"},children:"★"})]},t)))}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:f.text.secondary,marginTop:"8px",padding:"0 4px"},children:[i.jsx("span",{style:{opacity:.8},children:"Very Poor"}),i.jsx("span",{style:{opacity:.8},children:"Excellent"})]}),w[e]&&i.jsx("div",{style:{textAlign:"center",fontSize:"13px",color:"#0EA5E9",fontWeight:"500",marginTop:"4px",animation:"fadeInUp 0.3s ease",fontFamily:g.family},children:(()=>{const t=parseInt(w[e]);return`${{1:"Very Poor",2:"Poor",3:"Average",4:"Good",5:"Excellent"}[t]} (${t}/5)`})()})]}),"multiple_choice"===n&&s&&i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(((t,r)=>i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${f.input.border}`,backgroundColor:w[e]===t?"rgba(14, 165, 233, 0.1)":f.input.background,cursor:"pointer",transition:"all 0.2s ease",fontFamily:g.family},onMouseEnter:i=>{w[e]!==t&&(i.currentTarget.style.backgroundColor="rgba(14, 165, 233, 0.05)",i.currentTarget.style.borderColor="#0EA5E9")},onMouseLeave:i=>{w[e]!==t&&(i.currentTarget.style.backgroundColor=f.input.background,i.currentTarget.style.borderColor=f.input.border)},children:[i.jsx("input",{type:"radio",name:`choice-${e}`,style:{width:"16px",height:"16px",accentColor:"#0EA5E9"},checked:w[e]===t,onChange:()=>A(e,t)}),i.jsx("span",{style:{flex:1,fontSize:"13px",color:f.text.primary},children:t})]},r)))}),"boolean"===n&&i.jsxs("div",{style:{display:"flex",gap:"8px"},children:[i.jsxs("label",{style:{flex:1,display:"flex",alignItems:"center",gap:"8px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${f.input.border}`,backgroundColor:"true"===w[e]?"rgba(14, 165, 233, 0.1)":f.input.background,cursor:"pointer",transition:"all 0.2s ease",fontFamily:g.family},children:[i.jsx("input",{type:"radio",name:`bool-${e}`,style:{width:"16px",height:"16px",accentColor:"#0EA5E9"},checked:"true"===w[e],onChange:()=>A(e,"true")}),i.jsx("span",{style:{fontSize:"13px",color:f.text.primary},children:"Yes"})]}),i.jsxs("label",{style:{flex:1,display:"flex",alignItems:"center",gap:"8px",padding:"10px 12px",borderRadius:"8px",border:`1px solid ${f.input.border}`,backgroundColor:"false"===w[e]?"rgba(14, 165, 233, 0.1)":f.input.background,cursor:"pointer",transition:"all 0.2s ease",fontFamily:g.family},children:[i.jsx("input",{type:"radio",name:`bool-${e}`,style:{width:"16px",height:"16px",accentColor:"#0EA5E9"},checked:"false"===w[e],onChange:()=>A(e,"false")}),i.jsx("span",{style:{fontSize:"13px",color:f.text.primary},children:"No"})]})]}),k[e]&&i.jsxs("div",{style:{fontSize:"11px",color:"#ef4444",marginTop:"4px",display:"flex",alignItems:"center",gap:"4px",fontFamily:g.family},children:[i.jsx("svg",{style:{width:"10px",height:"10px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),k[e]]})]},e))),k.form&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"10px",borderRadius:"6px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.2)",color:"#ef4444",fontSize:"13px",fontFamily:g.family},children:[i.jsx("svg",{style:{width:"14px",height:"14px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),k.form]}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"8px",marginTop:"16px"},children:[j>0&&i.jsxs("button",{type:"button",onClick:()=>I(j-1),style:{padding:"8px 16px",fontSize:"13px",color:"#0EA5E9",border:"1px solid #0EA5E9",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",fontWeight:"500",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"6px",fontFamily:g.family},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgba(14, 165, 233, 0.1)",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.transform="translateY(0)"},children:[i.jsx("svg",{style:{width:"14px",height:"14px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back"]}),j<o.length-1?i.jsxs("button",{type:"button",onClick:e=>{e.preventDefault(),D(j)},style:{padding:"8px 16px",fontSize:"13px",backgroundColor:"#0EA5E9",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s ease",marginLeft:"auto",display:"flex",alignItems:"center",gap:"6px",fontFamily:g.family},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#0369A1",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#0EA5E9",e.currentTarget.style.transform="translateY(0)"},children:["Next",i.jsx("svg",{style:{width:"14px",height:"14px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}):i.jsx("button",{type:"submit",disabled:C,style:{padding:"8px 16px",fontSize:"13px",backgroundColor:"#0EA5E9",color:"white",border:"none",borderRadius:"6px",cursor:C?"not-allowed":"pointer",fontWeight:"500",transition:"all 0.2s ease",opacity:C?.7:1,marginLeft:"auto",display:"flex",alignItems:"center",gap:"6px",minWidth:"100px",justifyContent:"center",fontFamily:g.family},onMouseEnter:e=>{C||(e.currentTarget.style.backgroundColor="#0369A1",e.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:e=>{C||(e.currentTarget.style.backgroundColor="#0EA5E9",e.currentTarget.style.transform="translateY(0)")},children:C?i.jsxs(i.Fragment,{children:[i.jsx("svg",{style:{width:"14px",height:"14px",animation:"spin 1s linear infinite"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,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"})}),"Submitting..."]}):i.jsxs(i.Fragment,{children:["Submit",i.jsx("svg",{style:{width:"14px",height:"14px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})})]})]})]}),p&&i.jsxs("div",{style:{textAlign:"center",fontSize:"11px",color:f.text.tertiary,marginTop:"16px",fontFamily:g.family},children:["Powered by ",i.jsx("a",{href:"https://getquala.xyz",target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none",transition:"color 0.2s ease",cursor:"pointer"},onMouseEnter:e=>e.currentTarget.style.color=f.text.secondary,onMouseLeave:e=>e.currentTarget.style.color=f.text.tertiary,children:"Quala"})]})]})}),i.jsx("style",{children:"\n @keyframes scaleIn {\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n }\n\n @keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes bounceIn {\n 0% {\n opacity: 0;\n transform: scale(0.3);\n }\n 50% {\n opacity: 1;\n transform: scale(1.1);\n }\n 70% {\n transform: scale(0.9);\n }\n 100% {\n transform: scale(1);\n }\n }\n\n @keyframes gradientMove {\n 0% {\n background-position: 0% 50%;\n }\n 50% {\n background-position: 100% 50%;\n }\n 100% {\n background-position: 0% 50%;\n }\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n "})]})},f=[{title:"Thanks for your feedback!",subtitle:"We appreciate your input"},{title:"You're awesome!",subtitle:"Thanks for helping us improve"},{title:"Feedback received!",subtitle:"You're making a difference"},{title:"Thank you! 🎉",subtitle:"Your input helps us grow"},{title:"You rock! ✨",subtitle:"Thanks for sharing your thoughts"}],m=[{title:"What could be improved?",subtitle:"Help us make this better"},{title:"Tell us more",subtitle:"Your feedback helps us improve"},{title:"What's not working?",subtitle:"We want to fix it"},{title:"Help us understand",subtitle:"What could be better?"},{title:"We're listening",subtitle:"What needs improvement?"}],y={"😕":[{title:"What was confusing?",subtitle:"Where did you get stuck?"},{title:"What wasn't clear?",subtitle:"Help us make it easier to understand"},{title:"What needs clarification?",subtitle:"We want to make it crystal clear"}],"😤":[{title:"What frustrated you?",subtitle:"What didn't work as expected?"},{title:"What was annoying?",subtitle:"We want to make it smoother"},{title:"What made you frustrated?",subtitle:"Let's fix what's bothering you"}],"🐞":[{title:"Did something break?",subtitle:"What went wrong?"},{title:"What's not working?",subtitle:"Help us fix the issue"},{title:"What's broken?",subtitle:"We'll get it working again"}],"😐":[{title:"What's missing?",subtitle:"How can we make it better?"},{title:"What would make it great?",subtitle:"Help us improve your experience"},{title:"What could be better?",subtitle:"We want to exceed your expectations"}]},b={"😕":["What part was unclear or confusing?","Where did you get stuck or lost?","What would have made it easier to understand?","What information was missing or unclear?","What could we explain better?"],"😤":["What didn't work as you expected?","What was frustrating about the experience?","What made you feel annoyed or irritated?","What would have made it less frustrating?","What specific issues did you encounter?"],"🐞":["What exactly went wrong?","What error or issue did you encounter?","What steps led to the problem?","What were you trying to do when it broke?","What would have helped prevent this issue?"],"😐":["What would make this experience better?","What features or improvements would you like to see?","What's missing from this experience?","How could we make this more useful for you?","What would make you love using this?"]},x=["What was confusing or could be better?","What would make this experience better?","What specific issues did you encounter?","How can we improve this for you?","What would you like to see changed?"],w=e=>e[Math.floor(Math.random()*e.length)],v={light:{background:"rgba(255, 255, 255, 0.98)",border:"rgba(229, 231, 235, 0.8)",text:{primary:"#374151",secondary:"#6b7280",tertiary:"#9ca3af"},gradient:{from:"rgba(248, 250, 252, 0.8)",to:"rgba(241, 245, 249, 0.8)"},button:{hover:"rgba(249, 250, 251, 0.8)",active:"rgba(243, 244, 246, 0.8)"},input:{background:"rgba(249, 250, 251, 0.8)",border:"rgba(229, 231, 235, 0.8)",focus:{border:"#0EA5E9",shadow:"rgba(14, 165, 233, 0.2)"}}},dark:{background:"rgba(17, 24, 39, 0.98)",border:"rgba(55, 65, 81, 0.8)",text:{primary:"#f3f4f6",secondary:"#d1d5db",tertiary:"#9ca3af"},gradient:{from:"rgba(31, 41, 55, 0.8)",to:"rgba(17, 24, 39, 0.8)"},button:{hover:"rgba(31, 41, 55, 0.8)",active:"rgba(55, 65, 81, 0.8)"},input:{background:"rgba(31, 41, 55, 0.8)",border:"rgba(55, 65, 81, 0.8)",focus:{border:"#38BDF8",shadow:"rgba(56, 189, 248, 0.2)"}}}},k=({question:e="How was your experience with this step?",isVisible:r=!1,onFeedback:o=()=>{},onDismiss:n=()=>{},position:s="bottom-right",autoHide:a=!0,hideDelay:l=2e3,emojiSet:d="default",className:c,style:u,theme:h="light"})=>{const p="auto"===h?"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,k=v[p],[S,C]=t.useState("hidden"),[T,W]=t.useState(null),[E,j]=t.useState(""),[I,M]=t.useState(!1),[q,R]=t.useState(null),[A,L]=t.useState(w(f)),[_,O]=t.useState(w(m)),[D,Q]=t.useState(x[Math.floor(Math.random()*x.length)]),P={default:[{emoji:"😍",label:"Love it",value:"love",isPositive:!0},{emoji:"😊",label:"Good",value:"good",isPositive:!0},{emoji:"😐",label:"Okay",value:"neutral",isPositive:!1},{emoji:"😕",label:"Poor",value:"poor",isPositive:!1},{emoji:"😤",label:"Bad",value:"bad",isPositive:!1}],simple:[{emoji:"👍",label:"Good",value:"good",isPositive:!0},{emoji:"👎",label:"Need help",value:"bad",isPositive:!1}],detailed:[{emoji:"🤩",label:"Amazing",value:"amazing",isPositive:!0,color:"#16a34a"},{emoji:"😊",label:"Good",value:"good",isPositive:!0,color:"#16a34a"},{emoji:"😐",label:"Okay",value:"neutral",isPositive:!1,color:"#ca8a04"},{emoji:"😕",label:"Confusing",value:"confusing",isPositive:!1,color:"#dc2626"},{emoji:"😠",label:"Frustrating",value:"frustrating",isPositive:!1,color:"#dc2626"},{emoji:"🐞",label:"Broken",value:"broken",isPositive:!1,color:"#dc2626"}],"exit-focused":[{emoji:"👍",label:"All good",value:"satisfied",isPositive:!0},{emoji:"🤷",label:"Just browsing",value:"browsing",isPositive:!1},{emoji:"😕",label:"Something's wrong",value:"issue",isPositive:!1}],technical:[{emoji:"✅",label:"Working fine",value:"working",isPositive:!0},{emoji:"🤔",label:"Something's off",value:"confused",isPositive:!1},{emoji:"🐞",label:"It's broken",value:"broken",isPositive:!1}]},F=P[d]||P.default;t.useCallback(((e,t)=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),z(t))}),[]);const z=t.useCallback((t=>{W(t),C("responding"),t.isPositive?setTimeout((()=>{C("submitted"),o({emoji:t.value,value:t.value,label:t.label,isPositive:!0,timestamp:(new Date).toISOString(),question:e}),a&&setTimeout((()=>{C("fadeOut"),n()}),l)}),300):setTimeout((()=>{C("visible")}),300)}),[a,l,n,o]),$=t.useCallback((()=>{T&&(C("submitted"),o({emoji:T.value,value:T.value,label:T.label,isPositive:!1,detail:E.trim(),timestamp:(new Date).toISOString(),question:e}),a&&setTimeout((()=>{C("fadeOut"),n()}),l))}),[T,E,a,l,n,o]),U=t.useCallback((()=>{C("fadeOut"),n()}),[n,T]);if(t.useCallback((()=>{T&&(o({emoji:T.value,value:T.value,label:T.label,isPositive:!1,detail:E.trim(),timestamp:(new Date).toISOString(),question:e}),W(null),j(""))}),[T,E,o]),t.useEffect((()=>{r&&!I?requestAnimationFrame((()=>{C("visible")})):r||(C("hidden"),M(!1),T||(W(null),j("")))}),[r,I,T]),t.useEffect((()=>{T&&!T.isPositive&&(O((e=>{const t=y[e];return t?t[Math.floor(Math.random()*t.length)]:w(m)})(T.emoji)),Q((e=>{const t=b[e];return t?t[Math.floor(Math.random()*t.length)]:x[Math.floor(Math.random()*x.length)]})(T.emoji)))}),[T]),"hidden"===S)return null;const N="modal"===s,B=F.length>=6?3:F.length<=2?2:F.length<=3?3:F.length<=4?4:5;return i.jsxs(i.Fragment,{children:[N&&i.jsx("div",{role:"presentation",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"light"===p?"rgba(0, 0, 0, 0.15)":"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:40,transition:"opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1)",opacity:"visible"===S||"responding"===S||"submitted"===S?1:0,willChange:"opacity"},onClick:U}),i.jsx("div",{"data-quala-micro-widget":!0,className:`quala-micro-widget ${c||""}`,style:{...(()=>{const e={position:"fixed",zIndex:50,maxWidth:"100%",maxHeight:"100vh",overflow:"hidden",...u},t="simple"===d?"240px":"320px";switch(s){case"bottom-center":return{...e,bottom:"16px",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 32px)",maxWidth:t};case"bottom-right":default:return{...e,bottom:"16px",right:"16px",width:"calc(100% - 32px)",maxWidth:t};case"modal":return{...e,top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"calc(100% - 32px)",maxWidth:t}}})(),fontFamily:g.family},role:"dialog","aria-label":"Feedback widget",children:i.jsx("div",{style:(()=>{const e={willChange:"transform, opacity",backfaceVisibility:"hidden",perspective:"1000px",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1)"};switch(S){case"visible":case"submitted":return{...e,transform:"translate3d(0, 0, 0) scale(1)",opacity:1};case"responding":return{...e,transform:"translate3d(0, 0, 0) scale(0.98)",opacity:.9};case"fadeOut":return{...e,transform:"translate3d(0, 8px, 0) scale(0.95)",opacity:0};default:return{...e,transform:"translate3d(0, 16px, 0) scale(0.98)",opacity:0,transition:"none"}}})(),children:"submitted"===S?i.jsxs("div",{style:{backgroundColor:k.background,border:`1px solid ${k.border}`,borderRadius:"12px",padding:"12px 16px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",display:"flex",alignItems:"center",gap:"12px",backdropFilter:"blur(8px)"},children:[i.jsx("div",{style:{width:"32px",height:"32px",backgroundColor:"light"===p?"#dcfce7":"#064e3b",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",animation:"scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:i.jsx("svg",{style:{width:"16px",height:"16px",color:"light"===p?"#16a34a":"#34d399"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsxs("div",{children:[i.jsx("p",{style:{fontSize:"14px",fontWeight:"600",color:k.text.primary,margin:0,animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:A.title}),i.jsx("p",{style:{fontSize:"12px",color:k.text.secondary,margin:"2px 0 0 0",animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both"},children:A.subtitle}),i.jsx("p",{style:{fontSize:"10px",color:k.text.tertiary,margin:"4px 0 0 0",animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.15s both"},children:i.jsx("a",{href:"https://www.getquala.xyz/",target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none",transition:"color 0.2s ease",cursor:"pointer"},onMouseEnter:e=>e.currentTarget.style.color=k.text.secondary,onMouseLeave:e=>e.currentTarget.style.color=k.text.tertiary,children:"Powered by Quala"})})]})]}):T&&!T.isPositive&&"visible"===S?i.jsxs("div",{style:{backgroundColor:k.background,border:`1px solid ${k.border}`,borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",overflow:"hidden",backdropFilter:"blur(8px)"},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${k.border}`,display:"flex",alignItems:"center",gap:"10px",background:`linear-gradient(to right, ${k.gradient.from}, ${k.gradient.to})`},children:[i.jsx("div",{style:{fontSize:"20px",animation:"bounceIn 0.5s cubic-bezier(0.4, 0, 0.2, 1)"},children:T.emoji}),i.jsxs("div",{style:{flex:1},children:[i.jsx("p",{style:{fontSize:"14px",fontWeight:"600",color:k.text.primary,margin:0,animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1)"},children:_.title}),i.jsx("p",{style:{fontSize:"12px",color:k.text.secondary,margin:"2px 0 0 0",animation:"fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both"},children:_.subtitle})]}),i.jsx("button",{onClick:U,style:{width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"none",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s ease",color:k.text.secondary},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=k.button.hover,e.currentTarget.style.color=k.text.primary},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.color=k.text.secondary},children:i.jsx("svg",{style:{width:"12px",height:"12px"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{style:{padding:"12px 16px"},children:[i.jsx("textarea",{value:E,onChange:e=>j(e.target.value),placeholder:D,style:{width:"100%",padding:"10px 12px",fontSize:"13px",border:`1px solid ${k.input.border}`,borderRadius:"8px",resize:"none",outline:"none",backgroundColor:k.input.background,color:k.text.primary,fontFamily:"system-ui, -apple-system, sans-serif",boxSizing:"border-box",transition:"all 0.2s ease",minHeight:"60px",maxHeight:"100px",overflow:"auto"},rows:2,autoFocus:!0,onFocus:e=>{e.target.style.borderColor=k.input.focus.border,e.target.style.boxShadow=`0 0 0 3px ${k.input.focus.shadow}`},onBlur:e=>{e.target.style.borderColor=k.input.border,e.target.style.boxShadow="none"}}),i.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"12px"},children:[i.jsx("button",{onClick:()=>{W(null),C("visible")},style:{padding:"6px 12px",fontSize:"12px",color:k.text.secondary,border:`1px solid ${k.border}`,borderRadius:"8px",backgroundColor:"transparent",cursor:"pointer",transition:"all 0.2s ease",fontWeight:"500"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=k.button.hover,e.currentTarget.style.color=k.text.primary},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.color=k.text.secondary},children:"Back"}),i.jsx("button",{onClick:$,style:{flex:1,padding:"6px 12px",fontSize:"12px",backgroundColor:"light"===p?"#0EA5E9":"#38BDF8",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontWeight:"500",transition:"all 0.2s ease"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="light"===p?"#0369A1":"#0EA5E9",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="light"===p?"#0EA5E9":"#38BDF8",e.currentTarget.style.transform="translateY(0)"},children:E.trim()?"Send feedback":"Skip"})]})]})]}):i.jsxs("div",{style:{backgroundColor:k.background,border:`1px solid ${k.border}`,borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",overflow:"hidden",backdropFilter:"blur(8px)"},children:[i.jsxs("div",{style:{position:"relative",padding:"simple"===d?"8px 12px":"12px 16px",b