gotcha-feedback 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/screenshot-KRQM47Z4.mjs +15 -0
- package/dist/screenshot-KRQM47Z4.mjs.map +1 -0
- package/package.json +6 -4
- package/dist/screenshot-CTLYS27H.mjs +0 -2
- package/dist/screenshot-CTLYS27H.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -296,7 +296,7 @@ interface GotchaProps {
|
|
|
296
296
|
enableBugFlag?: boolean;
|
|
297
297
|
/** Custom label for the bug flag toggle (default: "Report an issue") */
|
|
298
298
|
bugFlagLabel?: string;
|
|
299
|
-
/** Enable screenshot capture when bug flag is toggled (
|
|
299
|
+
/** Enable screenshot capture when bug flag is toggled (uses modern-screenshot, bundled — no extra install needed) */
|
|
300
300
|
enableScreenshot?: boolean;
|
|
301
301
|
/** When true and user has already responded, show submitted state and allow review/edit instead of new submission */
|
|
302
302
|
onePerUser?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -296,7 +296,7 @@ interface GotchaProps {
|
|
|
296
296
|
enableBugFlag?: boolean;
|
|
297
297
|
/** Custom label for the bug flag toggle (default: "Report an issue") */
|
|
298
298
|
bugFlagLabel?: string;
|
|
299
|
-
/** Enable screenshot capture when bug flag is toggled (
|
|
299
|
+
/** Enable screenshot capture when bug flag is toggled (uses modern-screenshot, bundled — no extra install needed) */
|
|
300
300
|
enableScreenshot?: boolean;
|
|
301
301
|
/** When true and user has already responded, show submitted state and allow review/edit instead of new submission */
|
|
302
302
|
onePerUser?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var At=Object.defineProperty;var Mt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Gt=(e,t)=>{for(var o in t)At(e,o,{get:t[o],enumerable:true});};var ot={};Gt(ot,{captureScreenshot:()=>sr});async function sr(){try{let e=(await new Function('return import("html2canvas")')()).default,t=await e(document.body,{logging:!1,useCORS:!0,scale:1,width:window.innerWidth,height:window.innerHeight,windowWidth:window.innerWidth,windowHeight:window.innerHeight});return et(t)}catch{}try{if(!navigator.mediaDevices?.getDisplayMedia||typeof ImageCapture>"u")return null;let t=(await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"}})).getVideoTracks()[0],r=await new ImageCapture(t).grabFrame();t.stop();let n=document.createElement("canvas");n.width=r.width,n.height=r.height;let p=n.getContext("2d");return p?(p.drawImage(r,0,0),et(n)):null}catch{return null}}function et(e){let t=e.toDataURL("image/jpeg",.7);if(t.length>2097152&&(t=e.toDataURL("image/jpeg",.4)),t.length>2097152){let r=document.createElement("canvas");r.width=e.width*.5,r.height=e.height*.5;let n=r.getContext("2d");n&&(n.drawImage(e,0,0,r.width,r.height),t=r.toDataURL("image/jpeg",.5));}return t}var tt=Mt(()=>{});var Co="https://gotcha.cx/api/v1";var Y={ANONYMOUS_ID:"gotcha_anonymous_id",OFFLINE_QUEUE:"gotcha_offline_queue",HIDDEN_UNTIL:"gotcha_hidden",VISIT_COUNT:"gotcha_visits"},J={POSITION:"top-right",SIZE:"md",THEME:"light",SHOW_ON_HOVER:true,TOUCH_BEHAVIOR:"always-visible",SUBMIT_TEXT:"Submit",THANK_YOU_MESSAGE:"Gotcha!"},Pe={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function Z(e){if(typeof window>"u")return null;try{return localStorage.getItem(e)}catch{return null}}function ee(e,t){if(!(typeof window>"u"))try{localStorage.setItem(e,t);}catch{}}function oe(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}function Ue(){let e=Z(Y.ANONYMOUS_ID);if(e)return e;let t=`anon_${oe()}`;return ee(Y.ANONYMOUS_ID,t),t}var $e=[],Oe=false;function Eo(e,t){let o={message:e.slice(0,200),source:t?.slice(0,200),timestamp:Date.now()};$e.push(o),$e.length>10&&$e.shift();}function Ro(e){Eo(e.message,e.filename);}function Bo(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason);Eo(t);}function Io(){typeof window>"u"||Oe||(window.addEventListener("error",Ro),window.addEventListener("unhandledrejection",Bo),Oe=true);}function Ao(){typeof window>"u"||!Oe||(window.removeEventListener("error",Ro),window.removeEventListener("unhandledrejection",Bo),Oe=false);}function Mo(){return [...$e].reverse()}function Go(){return typeof window>"u"?{}:{url:window.location.origin+window.location.pathname,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenResolution:{width:screen.width,height:screen.height},recentErrors:Mo()}}var Dt=50,Ft=10080*60*1e3;function Ce(){let e=Z(Y.OFFLINE_QUEUE);if(!e)return [];try{let t=JSON.parse(e),o=Date.now();return t.filter(r=>o-r.queuedAt<Ft)}catch{return []}}function Je(e){ee(Y.OFFLINE_QUEUE,JSON.stringify(e));}function Ze(e,t="create"){let o=Ce();o.length>=Dt||(o.push({id:oe(),payload:e,type:t,queuedAt:Date.now(),retries:0}),Je(o));}function Do(e){let t=Ce().filter(o=>o.id!==e);Je(t);}function Fo(){return Ce()}function Lo(){return Ce().length}function zo(e){let t=Ce().map(o=>o.id===e?{...o,retries:o.retries+1}:o);Je(t.filter(o=>o.retries<=5));}var ue={maxRetries:Pe.MAX_RETRIES,baseDelayMs:Pe.BASE_DELAY_MS,maxDelayMs:Pe.MAX_DELAY_MS};async function Ee(e,t,o=ue,r=false){let n=null;for(let p=0;p<=o.maxRetries;p++){try{r&&p>0&&console.log(`[Gotcha] Retry attempt ${p}/${o.maxRetries}`);let l=await fetch(e,t);if(l.status>=400&&l.status<500&&l.status!==429||l.ok)return l;n=new Error(`HTTP ${l.status}`);}catch(l){n=l,r&&console.log(`[Gotcha] Network error: ${n.message}`);}if(p<o.maxRetries){let l=Math.min(o.baseDelayMs*Math.pow(2,p),o.maxDelayMs);await new Promise(u=>setTimeout(u,l));}}throw n}function Po(e){let{apiKey:t,baseUrl:o=Co,debug:r=false}=e,n=false,p={"Content-Type":"application/json",Authorization:`Bearer ${t}`};async function l(u,g,a){let s=`${o}${g}`,h=oe();r&&console.log(`[Gotcha] ${u} ${g}`,a);let d=await Ee(s,{method:u,headers:{...p,"Idempotency-Key":h},body:a?JSON.stringify(a):void 0},ue,r),i;try{i=await d.json();}catch{throw {code:"PARSE_ERROR",message:"Invalid response from server",status:d.status}}if(!d.ok){let c=i.error;throw r&&console.error(`[Gotcha] Error: ${c.code} - ${c.message}`),c}return r&&console.log("[Gotcha] Response:",i),i}return {async submitResponse(u){let g=u.user||{};g.id||(g.id=Ue());let a={...u,user:g,context:Go(),...u.isBug?{isBug:true}:{}};if(typeof navigator<"u"&&!navigator.onLine)return Ze(a,"create"),{id:oe(),status:"queued",createdAt:new Date().toISOString()};try{return await l("POST","/responses",a)}catch(s){if(s instanceof TypeError&&typeof navigator<"u"&&!navigator.onLine)return Ze(a,"create"),{id:oe(),status:"queued",createdAt:new Date().toISOString()};throw s}},async checkExistingResponse(u,g){let a=`${o}/responses/check?elementId=${encodeURIComponent(u)}&userId=${encodeURIComponent(g)}`;r&&console.log("[Gotcha] GET /responses/check");let s=await Ee(a,{method:"GET",headers:p},ue,r),h=await s.json();if(!s.ok){let d=h.error;throw r&&console.error(`[Gotcha] Error: ${d.code} - ${d.message}`),d}return h.exists?(r&&console.log("[Gotcha] Found existing response:",h.response),h.response):null},async updateResponse(u,g,a){let s=`${o}/responses/${u}${a?`?userId=${encodeURIComponent(a)}`:""}`;r&&console.log(`[Gotcha] PATCH /responses/${u}`,g);let h=await Ee(s,{method:"PATCH",headers:p,body:JSON.stringify(g)},ue,r),d=await h.json();if(!h.ok){let i=d.error;throw r&&console.error(`[Gotcha] Error: ${i.code} - ${i.message}`),i}return r&&console.log("[Gotcha] Response updated:",d),d},async getScore(u){let g=`${o}/scores/${encodeURIComponent(u)}`;r&&console.log(`[Gotcha] GET /scores/${u}`);let a=await Ee(g,{method:"GET",headers:p},ue,r),s=await a.json();if(!a.ok){let h=s.error;throw r&&console.error(`[Gotcha] Error: ${h.code} - ${h.message}`),h}return r&&console.log("[Gotcha] Score:",s),s},async flagAsBug(u){let g=`${o}/responses/${encodeURIComponent(u)}/bug`;r&&console.log(`[Gotcha] POST /responses/${u}/bug`);let a=await Ee(g,{method:"POST",headers:p},ue,r),s=await a.json();if(!a.ok){let h=s.error;throw r&&console.error(`[Gotcha] Error: ${h.code} - ${h.message}`),h}return r&&console.log("[Gotcha] Bug flagged:",s),s},async flushQueue(){if(!n){n=true;try{let u=Fo();for(let g of u)try{if(g.type==="update"&&g.payload.responseId){let{responseId:a,...s}=g.payload;await l("PATCH",`/responses/${a}`,s);}else await l("POST","/responses",g.payload);Do(g.id);}catch{zo(g.id);}}finally{n=false;}}},getQueueLength:Lo,getBaseUrl(){return o}}}var Lt=new Set(["__proto__","constructor","prototype"]);function ce(e,t){let o={...e};for(let r of Object.keys(t)){if(Lt.has(r))continue;let n=t[r];n!=null&&typeof n=="object"&&!Array.isArray(n)?o[r]=ce(e[r]??{},n):n!==void 0&&(o[r]=n);}return o}var Uo=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],eo={colors:{primary:"#1e293b",primaryHover:"#334155",primaryText:"#ffffff",background:"#ffffff",backgroundGradient:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)",surface:"#fafbfc",surfaceHover:"#ffffff",text:"#111827",textSecondary:"#374151",textDisabled:"#94a3b8",border:"#e2e8f0",borderFocus:"#1e293b",success:"#059669",successSurface:"rgba(5,150,105,0.08)",error:"#dc2626",errorSurface:"#fef2f2",errorBorder:"rgba(220,38,38,0.1)",warning:"#d97706",warningActive:"#b45309",warningSurface:"rgba(251,191,36,0.08)",warningBorder:"rgba(217,119,6,0.25)",starFilled:"#f59e0b",starEmpty:"#e2e8f0",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.06)",voteUpBorder:"rgba(16,185,129,0.25)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.06)",voteDownBorder:"rgba(239,68,68,0.25)",npsColors:Uo,buttonBackground:"#1e293b",buttonBackgroundHover:"#334155",buttonBackgroundDisabled:"#e2e8f0",buttonColor:"#ffffff",buttonColorDisabled:"#94a3b8",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.4)",closeButton:"#9ca3af",closeButtonHover:"#6b7280",closeButtonBg:"rgba(0,0,0,0.04)",glassBackground:"linear-gradient(160deg, rgba(255,255,255,0.7) 0%, rgba(200,210,230,0.4) 40%, rgba(180,192,220,0.5) 100%)",glassBorder:"none",glassColor:"rgba(0,0,0,0.75)",glassShadow:"0 3px 12px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2)",glassHoverShadow:"0 6px 20px rgba(0,0,0,0.18), 0 0 1px rgba(0,0,0,0.25)",inputBackground:"#fafbfc",inputBackgroundFocus:"#ffffff",inputBorder:"#e2e8f0",inputBorderFocus:"#1e293b",inputFocusRing:"rgba(30,41,59,0.15)",pollBorder:"#e2e8f0",pollSelectedBorder:"rgba(30,41,59,0.25)",pollBackground:"#fafbfc",pollSelectedBackground:"rgba(30,41,59,0.05)",pollColor:"#374151",pollSelectedColor:"#1e293b",pollCheckBorder:"#cbd5e1",pollCheckSelectedBorder:"#1e293b",pollCheckSelectedBg:"#1e293b"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.04)",md:"0 4px 12px rgba(0,0,0,0.06)",lg:"0 12px 32px rgba(0,0,0,0.06)",modal:"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06), 0 24px 48px rgba(0,0,0,0.04)",button:"0 2px 8px rgba(0,0,0,0.06)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}},oo={colors:{primary:"#e2e8f0",primaryHover:"#cbd5e1",primaryText:"#1e293b",background:"#1a1f2e",backgroundGradient:"linear-gradient(180deg, #1a1f2e 0%, #151925 100%)",surface:"rgba(55,65,81,0.5)",surfaceHover:"rgba(55,65,81,0.7)",text:"#f9fafb",textSecondary:"#d1d5db",textDisabled:"#6b7280",border:"rgba(255,255,255,0.08)",borderFocus:"rgba(255,255,255,0.2)",success:"#10b981",successSurface:"rgba(16,185,129,0.1)",error:"#fecaca",errorSurface:"rgba(127,29,29,0.3)",errorBorder:"rgba(254,202,202,0.1)",warning:"#fbbf24",warningActive:"#fbbf24",warningSurface:"rgba(245,158,11,0.08)",warningBorder:"rgba(245,158,11,0.3)",starFilled:"#f59e0b",starEmpty:"rgba(255,255,255,0.12)",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.08)",voteUpBorder:"rgba(16,185,129,0.3)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.08)",voteDownBorder:"rgba(239,68,68,0.3)",npsColors:Uo,buttonBackground:"#e2e8f0",buttonBackgroundHover:"#cbd5e1",buttonBackgroundDisabled:"#374151",buttonColor:"#1e293b",buttonColorDisabled:"#6b7280",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.5)",closeButton:"#6b7280",closeButtonHover:"#9ca3af",closeButtonBg:"rgba(255,255,255,0.06)",glassBackground:"linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 60%, rgba(0,0,0,0.05) 100%)",glassBorder:"1px solid rgba(255,255,255,0.15)",glassColor:"rgba(255,255,255,0.88)",glassShadow:"0 4px 14px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.35)",glassHoverShadow:"0 8px 24px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4)",inputBackground:"rgba(55,65,81,0.5)",inputBackgroundFocus:"rgba(55,65,81,0.7)",inputBorder:"rgba(255,255,255,0.08)",inputBorderFocus:"rgba(255,255,255,0.2)",inputFocusRing:"rgba(255,255,255,0.06)",pollBorder:"rgba(255,255,255,0.08)",pollSelectedBorder:"rgba(226,232,240,0.25)",pollBackground:"rgba(55,65,81,0.5)",pollSelectedBackground:"rgba(226,232,240,0.08)",pollColor:"#d1d5db",pollSelectedColor:"#e2e8f0",pollCheckBorder:"rgba(255,255,255,0.2)",pollCheckSelectedBorder:"#e2e8f0",pollCheckSelectedBg:"#e2e8f0"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.2)",md:"0 4px 12px rgba(0,0,0,0.3)",lg:"0 12px 32px rgba(0,0,0,0.2)",modal:"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2), 0 24px 48px rgba(0,0,0,0.15)",button:"0 2px 8px rgba(0,0,0,0.15)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}};function zt(e,t){return ce(e==="dark"?oo:eo,t)}function te(e,t,o){let n=(e==="auto"||e==="custom"?t:e)==="dark"?ce({},oo):ce({},eo);return o&&(n=ce(n,o)),n}var $o="gotcha-styles",Oo="gotcha-dm-sans",Ho="gotcha-carter-one",Pt=`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var xr=Object.defineProperty;var Wt=(e,t)=>()=>(e&&(t=e(e=0)),t);var vr=(e,t)=>{for(var o in t)xr(e,o,{get:t[o],enumerable:true});};function Qr(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}function Xr(){let e=new Int32Array(256);for(let t=0;t<256;t++){let o=t;for(let r=0;r<8;r++)o=o&1?3988292384^o>>>1:o>>>1;e[t]=o;}return e}function Jr(e){let t=-1;St||(St=Xr());for(let o=0;o<e.length;o++)t=St[(t^e[o])&255]^t>>>8;return t^-1}function Zr(e){let t=e.length-1;for(let o=t;o>=4;o--)if(e[o-4]===9&&e[o-3]===Ro&&e[o-2]===Ao&&e[o-1]===Io&&e[o]===Bo)return o-3;return 0}function en(e,t,o=false){let r=new Uint8Array(13);t*=39.3701,r[0]=Ro,r[1]=Ao,r[2]=Io,r[3]=Bo,r[4]=t>>>24,r[5]=t>>>16,r[6]=t>>>8,r[7]=t&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;let s=Jr(r),a=new Uint8Array(4);if(a[0]=s>>>24,a[1]=s>>>16,a[2]=s>>>8,a[3]=s&255,o){let l=Zr(e);return e.set(r,l),e.set(a,l+13),e}else {let l=new Uint8Array(4);l[0]=0,l[1]=0,l[2]=0,l[3]=9;let n=new Uint8Array(54);return n.set(e,0),n.set(l,33),n.set(r,37),n.set(a,50),n}}function nn(e){let t=e.indexOf(tn);return t===-1&&(t=e.indexOf(on)),t===-1&&(t=e.indexOf(rn)),t}function kn(e){let t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}function Po(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(se&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!se)return e;let o=ot().implementation.createHTMLDocument(),r=o.createElement("base"),s=o.createElement("a");return o.head.appendChild(r),o.body.appendChild(s),t&&(r.href=t),s.href=e,s.href}function ot(e){return (e&&j(e)?e?.ownerDocument:e)??window.document}function Cn(e,t,o){let r=ot(o).createElementNS(rt,"svg");return r.setAttributeNS(null,"width",e.toString()),r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),r}function Rn(e,t){let o=new XMLSerializer().serializeToString(e);return t&&(o=o.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`}function An(e,t){return new Promise((o,r)=>{let s=new FileReader;s.onload=()=>o(s.result),s.onerror=()=>r(s.error),s.onabort=()=>r(new Error(`Failed read blob to ${t}`)),s.readAsDataURL(e);})}function he(e,t){let o=ot(t).createElement("img");return o.decoding="sync",o.loading="eager",o.src=e,o}function Fe(e,t){return new Promise(o=>{let{timeout:r,ownerDocument:s,onError:a,onWarn:l}=t??{},n=typeof e=="string"?he(e,ot(s)):e,g=null,c=null;function i(){o(n),g&&clearTimeout(g),c?.();}if(r&&(g=setTimeout(i,r)),tt(n)){let p=n.currentSrc||n.src;if(!p)return n.poster?Fe(n.poster,t).then(o):i();if(n.readyState>=2)return i();let u=i,d=m=>{l?.("Failed video load",p,m),a?.(m),i();};c=()=>{n.removeEventListener("loadeddata",u),n.removeEventListener("error",d);},n.addEventListener("loadeddata",u,{once:true}),n.addEventListener("error",d,{once:true});}else {let p=Fo(n)?n.href.baseVal:n.currentSrc||n.src;if(!p)return i();let u=async()=>{if(be(n)&&"decode"in n)try{await n.decode();}catch(m){l?.("Failed to decode image, trying to render anyway",n.dataset.originalSrc||p,m);}i();},d=m=>{l?.("Failed image load",n.dataset.originalSrc||p,m),i();};if(be(n)&&n.complete)return u();c=()=>{n.removeEventListener("load",u),n.removeEventListener("error",d);},n.addEventListener("load",u,{once:true}),n.addEventListener("error",d,{once:true});}})}async function Bn(e,t){De(e)&&(be(e)||tt(e)?await Fe(e,t):await Promise.all(["img","video"].flatMap(o=>Array.from(e.querySelectorAll(o)).map(r=>Fe(r,t)))));}function Go(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}function Mn(e){let t=`${Mo}[#${xo}]`;return xo++,{time:o=>e&&console.time(`${t} ${o}`),timeEnd:o=>e&&console.timeEnd(`${t} ${o}`),warn:(...o)=>e&&En(...o)}}function Dn(e){return {cache:e?"no-cache":"force-cache"}}async function nt(e,t){return cn(e)?e:Fn(e,{...t,autoDestruct:true})}async function Fn(e,t){let{scale:o=1,workerUrl:r,workerNumber:s=1}=t||{},a=!!t?.debug,l=t?.features??true,n=e.ownerDocument??(se?window.document:void 0),g=e.ownerDocument?.defaultView??(se?window:void 0),c=new Map,i={width:0,height:0,quality:1,type:"image/png",scale:o,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:a,fetch:{requestInit:Dn(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:Mn(a),node:e,ownerDocument:n,ownerWindow:g,dpi:o===1?null:96*o,svgStyleElement:No(n),svgDefsElement:n?.createElementNS(rt,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:sn&&r&&s?s:0})].map(()=>{try{let d=new Worker(r);return d.onmessage=async m=>{let{url:f,result:h}=m.data;h?c.get(f)?.resolve?.(h):c.get(f)?.reject?.(new Error(`Error receiving message from worker: ${f}`));},d.onmessageerror=m=>{let{url:f}=m.data;c.get(f)?.reject?.(new Error(`Error receiving message from worker: ${f}`));},d}catch(d){return i.log.warn("Failed to new Worker",d),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[kn(n)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:c,drawImageCount:0,tasks:[],features:l,isEnable:d=>d==="restoreScrollPosition"?typeof l=="boolean"?false:l[d]??false:typeof l=="boolean"?l:l[d]??true,shadowRoots:[]};i.log.time("wait until load"),await Bn(e,{timeout:i.timeout,onWarn:i.log.warn}),i.log.timeEnd("wait until load");let{width:p,height:u}=Pn(e,i);return i.width=p,i.height=u,i}function No(e){if(!e)return;let t=e.createElement("style"),o=t.ownerDocument.createTextNode(`
|
|
2
|
+
.______background-clip--text {
|
|
3
|
+
background-clip: text;
|
|
4
|
+
-webkit-background-clip: text;
|
|
5
|
+
}
|
|
6
|
+
`);return t.appendChild(o),t}function Pn(e,t){let{width:o,height:r}=t;if(j(e)&&(!o||!r)){let s=e.getBoundingClientRect();o=o||s.width||Number(e.getAttribute("width"))||0,r=r||s.height||Number(e.getAttribute("height"))||0;}return {width:o,height:r}}async function Ln(e,t){let{log:o,timeout:r,drawImageCount:s,drawImageInterval:a}=t;o.time("image to canvas");let l=await Fe(e,{timeout:r,onWarn:t.log.warn}),{canvas:n,context2d:g}=Gn(e.ownerDocument,t),c=()=>{try{g?.drawImage(l,0,0,n.width,n.height);}catch(i){t.log.warn("Failed to drawImage",i);}};if(c(),t.isEnable("fixSvgXmlDecode"))for(let i=0;i<s;i++)await new Promise(p=>{setTimeout(()=>{g?.clearRect(0,0,n.width,n.height),c(),p();},i+a);});return t.drawImageCount=0,o.timeEnd("image to canvas"),n}function Gn(e,t){let{width:o,height:r,scale:s,backgroundColor:a,maximumCanvasSize:l}=t,n=e.createElement("canvas");n.width=Math.floor(o*s),n.height=Math.floor(r*s),n.style.width=`${o}px`,n.style.height=`${r}px`,l&&(n.width>l||n.height>l)&&(n.width>l&&n.height>l?n.width>n.height?(n.height*=l/n.width,n.width=l):(n.width*=l/n.height,n.height=l):n.width>l?(n.height*=l/n.width,n.width=l):(n.width*=l/n.height,n.height=l));let g=n.getContext("2d");return g&&a&&(g.fillStyle=a,g.fillRect(0,0,n.width,n.height)),{canvas:n,context2d:g}}function Uo(e,t){if(e.ownerDocument)try{let a=e.toDataURL();if(a!=="data:,")return he(a,e.ownerDocument)}catch(a){t.log.warn("Failed to clone canvas",a);}let o=e.cloneNode(false),r=e.getContext("2d"),s=o.getContext("2d");try{return r&&s&&s.putImageData(r.getImageData(0,0,e.width,e.height),0,0),o}catch(a){t.log.warn("Failed to clone canvas",a);}return o}function Nn(e,t){try{if(e?.contentDocument?.body)return kt(e.contentDocument.body,t)}catch(o){t.log.warn("Failed to clone iframe",o);}return e.cloneNode(false)}function Un(e){let t=e.cloneNode(false);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function $n(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return he(e.poster,e.ownerDocument);let o=e.cloneNode(false);o.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(o.src=e.currentSrc);let r=o.ownerDocument;if(r){let s=true;if(await Fe(o,{onError:()=>s=false,onWarn:t.log.warn}),!s)return e.poster?he(e.poster,e.ownerDocument):o;o.currentTime=e.currentTime,await new Promise(l=>{o.addEventListener("seeked",l,{once:true});});let a=r.createElement("canvas");a.width=e.offsetWidth,a.height=e.offsetHeight;try{let l=a.getContext("2d");l&&l.drawImage(o,0,0,a.width,a.height);}catch(l){return t.log.warn("Failed to clone video",l),e.poster?he(e.poster,e.ownerDocument):o}return Uo(a,t)}return o}function zn(e,t){return hn(e)?Uo(e,t):Tn(e)?Nn(e,t):be(e)?Un(e):tt(e)?$n(e,t):e.cloneNode(false)}function On(e){let t=e.sandbox;if(!t){let{ownerDocument:o}=e;try{o&&(t=o.createElement("iframe"),t.id=`__SANDBOX__${Lo()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",o.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t);}catch(r){e.log.warn("Failed to getSandBox",r);}}return t}function $o(e,t,o){let{defaultComputedStyles:r}=o,s=e.nodeName.toLowerCase(),a=Le(e)&&s!=="svg",l=a?Hn.map(f=>[f,e.getAttribute(f)]).filter(([,f])=>f!==null):[],n=[a&&"svg",s,l.map((f,h)=>`${f}=${h}`).join(","),t].filter(Boolean).join(":");if(r.has(n))return r.get(n);let c=On(o)?.contentWindow;if(!c)return new Map;let i=c?.document,p,u;a?(p=i.createElementNS(rt,"svg"),u=p.ownerDocument.createElementNS(p.namespaceURI,s),l.forEach(([f,h])=>{u.setAttributeNS(null,f,h);}),p.appendChild(u)):p=u=i.createElement(s),u.textContent=" ",i.body.appendChild(p);let d=c.getComputedStyle(u,t),m=new Map;for(let f=d.length,h=0;h<f;h++){let b=d.item(h);_n.includes(b)||m.set(b,d.getPropertyValue(b));}return i.body.removeChild(p),r.set(n,m),m}function zo(e,t,o){let r=new Map,s=[],a=new Map;if(o)for(let n of o)l(n);else for(let n=e.length,g=0;g<n;g++){let c=e.item(g);l(c);}for(let n=s.length,g=0;g<n;g++)a.get(s[g])?.forEach((c,i)=>r.set(i,c));function l(n){let g=e.getPropertyValue(n),c=e.getPropertyPriority(n),i=n.lastIndexOf("-"),p=i>-1?n.substring(0,i):void 0;if(p){let u=a.get(p);u||(u=new Map,a.set(p,u)),u.set(n,[g,c]);}t.get(n)===g&&!c||(p?s.push(p):r.set(n,[g,c]));}return r}function Wn(e,t,o,r){let{ownerWindow:s,includeStyleProperties:a,currentParentNodeStyle:l}=r,n=t.style,g=s.getComputedStyle(e),c=$o(e,null,r);l?.forEach((p,u)=>{c.delete(u);});let i=zo(g,c,a);i.delete("transition-property"),i.delete("all"),i.delete("d"),i.delete("content"),o&&(i.delete("margin-top"),i.delete("margin-right"),i.delete("margin-bottom"),i.delete("margin-left"),i.delete("margin-block-start"),i.delete("margin-block-end"),i.delete("margin-inline-start"),i.delete("margin-inline-end"),i.set("box-sizing",["border-box",""])),i.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),Do&&(i.has("font-kerning")||i.set("font-kerning",["normal",""]),(i.get("overflow-x")?.[0]==="hidden"||i.get("overflow-y")?.[0]==="hidden")&&i.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&i.set("text-overflow",["clip",""]));for(let p=n.length,u=0;u<p;u++)n.removeProperty(n.item(u));return i.forEach(([p,u],d)=>{n.setProperty(d,p,u);}),i}function Vn(e,t){(bn(e)||yn(e)||xn(e))&&t.setAttribute("value",e.value);}function qn(e,t,o,r,s){let{ownerWindow:a,svgStyleElement:l,svgStyles:n,currentNodeStyle:g}=r;if(!l||!a)return;function c(i){let p=a.getComputedStyle(e,i),u=p.getPropertyValue("content");if(!u||u==="none")return;s?.(u),u=u.replace(/(')|(")|(counter\(.+\))/g,"");let d=[Lo()],m=$o(e,i,r);g?.forEach((w,k)=>{m.delete(k);});let f=zo(p,m,r.includeStyleProperties);f.delete("content"),f.delete("-webkit-locale"),f.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");let h=[`content: '${u}';`];if(f.forEach(([w,k],R)=>{h.push(`${R}: ${w}${k?" !important":""};`);}),h.length===1)return;try{t.className=[t.className,...d].join(" ");}catch(w){r.log.warn("Failed to copyPseudoClass",w);return}let b=h.join(`
|
|
7
|
+
`),v=n.get(b);v||(v=[],n.set(b,v)),v.push(`.${d[0]}${i}`);}jn.forEach(c),o&&Yn.forEach(c);}async function To(e,t,o,r,s){if(j(o)&&(wn(o)||Sn(o))||r.filter&&!r.filter(o))return;vo.has(t.nodeName)||vo.has(o.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;let a=await kt(o,r,false,s);r.isEnable("restoreScrollPosition")&&Kn(e,a),t.appendChild(a);}async function Eo(e,t,o,r){let s=e.firstChild;j(e)&&e.shadowRoot&&(s=e.shadowRoot?.firstChild,o.shadowRoots.push(e.shadowRoot));for(let a=s;a;a=a.nextSibling)if(!pn(a))if(j(a)&&vn(a)&&typeof a.assignedNodes=="function"){let l=a.assignedNodes();for(let n=0;n<l.length;n++)await To(e,t,l[n],o,r);}else await To(e,t,a,o,r);}function Kn(e,t){if(!De(e)||!De(t))return;let{scrollTop:o,scrollLeft:r}=e;if(!o&&!r)return;let{transform:s}=t.style,a=new DOMMatrix(s),{a:l,b:n,c:g,d:c}=a;a.a=1,a.b=0,a.c=0,a.d=1,a.translateSelf(-r,-o),a.a=l,a.b=n,a.c=g,a.d=c,t.style.transform=a.toString();}function Qn(e,t){let{backgroundColor:o,width:r,height:s,style:a}=t,l=e.style;if(o&&l.setProperty("background-color",o,"important"),r&&l.setProperty("width",`${r}px`,"important"),s&&l.setProperty("height",`${s}px`,"important"),a)for(let n in a)l[n]=a[n];}async function kt(e,t,o=false,r){let{ownerDocument:s,ownerWindow:a,fontFamilies:l,onCloneEachNode:n}=t;if(s&&mn(e))return r&&/\S/.test(e.data)&&r(e.data),s.createTextNode(e.data);if(s&&a&&j(e)&&(De(e)||Le(e))){let c=await zn(e,t);if(t.isEnable("removeAbnormalAttributes")){let f=c.getAttributeNames();for(let h=f.length,b=0;b<h;b++){let v=f[b];Xn.test(v)||c.removeAttribute(v);}}let i=t.currentNodeStyle=Wn(e,c,o,t);o&&Qn(c,t);let p=false;if(t.isEnable("copyScrollbar")){let f=[i.get("overflow-x")?.[0],i.get("overflow-y")?.[0]];p=f.includes("scroll")||(f.includes("auto")||f.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);}let u=i.get("text-transform")?.[0],d=Go(i.get("font-family")?.[0]),m=d?f=>{u==="uppercase"?f=f.toUpperCase():u==="lowercase"?f=f.toLowerCase():u==="capitalize"&&(f=f[0].toUpperCase()+f.substring(1)),d.forEach(h=>{let b=l.get(h);b||l.set(h,b=new Set),f.split("").forEach(v=>b.add(v));});}:void 0;return qn(e,c,p,t,m),Vn(e,c),tt(e)||await Eo(e,c,t,m),await n?.(c),c}let g=e.cloneNode(false);return await Eo(e,g,t),await n?.(g),g}function Jn(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove();}catch(t){e.log.warn("Failed to destroyContext",t);}e.sandbox=void 0;}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[];}function Zn(e){let{url:t,timeout:o,responseType:r,...s}=e,a=new AbortController,l=o?setTimeout(()=>a.abort(),o):void 0;return fetch(t,{signal:a.signal,...s}).then(n=>{if(!n.ok)throw new Error("Failed fetch, not 2xx response",{cause:n});switch(r){case "arrayBuffer":return n.arrayBuffer();case "dataUrl":return n.blob().then(In);default:return n.text()}}).finally(()=>clearTimeout(l))}function Pe(e,t){let{url:o,requestType:r="text",responseType:s="text",imageDom:a}=t,l=o,{timeout:n,acceptOfImage:g,requests:c,fetchFn:i,fetch:{requestInit:p,bypassingCache:u,placeholderImage:d},font:m,workers:f,fontFamilies:h}=e;r==="image"&&(et||Et)&&e.drawImageCount++;let b=c.get(o);if(!b){u&&u instanceof RegExp&&u.test(l)&&(l+=(/\?/.test(l)?"&":"?")+new Date().getTime());let v=r.startsWith("font")&&m&&m.minify,w=new Set;v&&r.split(";")[1].split(",").forEach(E=>{h.has(E)&&h.get(E).forEach(A=>w.add(A));});let k=v&&w.size,R={url:l,timeout:n,responseType:k?"arrayBuffer":s,headers:r==="image"?{accept:g}:void 0,...p};b={type:r,resolve:void 0,reject:void 0,response:null},b.response=(async()=>{if(i&&r==="image"){let S=await i(o);if(S)return S}return !et&&o.startsWith("http")&&f.length?new Promise((S,E)=>{f[c.size&f.length-1].postMessage({rawUrl:o,...R}),b.resolve=S,b.reject=E;}):Zn(R)})().catch(S=>{if(c.delete(o),r==="image"&&d)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",l),typeof d=="string"?d:d(a);throw S}),c.set(o,b);}return b.response}async function Oo(e,t,o,r){if(!_o(e))return e;for(let[s,a]of es(e,t))try{let l=await Pe(o,{url:a,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(ts(s),`$1${l}$3`);}catch(l){o.log.warn("Failed to fetch css data url",s,l);}return e}function _o(e){return /url\((['"]?)([^'"]+?)\1\)/.test(e)}function es(e,t){let o=[];return e.replace(Ho,(r,s,a)=>(o.push([a,Po(a,t)]),r)),o.filter(([r])=>!xt(r))}function ts(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function rs(e,t){return os.map(o=>{let r=e.getPropertyValue(o);return !r||r==="none"?null:((et||Et)&&t.drawImageCount++,Oo(r,null,t,true).then(s=>{!s||r===s||e.setProperty(o,s,e.getPropertyPriority(o));}))}).filter(Boolean)}function ns(e,t){if(be(e)){let o=e.currentSrc||e.src;if(!xt(o))return [Pe(t,{url:o,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.srcset="",e.dataset.originalSrc=o,e.src=r||"");})];(et||Et)&&t.drawImageCount++;}else if(Le(e)&&!xt(e.href.baseVal)){let o=e.href.baseVal;return [Pe(t,{url:o,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.dataset.originalSrc=o,e.href.baseVal=r||"");})]}return []}function ss(e,t){let{ownerDocument:o,svgDefsElement:r}=t,s=e.getAttribute("href")??e.getAttribute("xlink:href");if(!s)return [];let[a,l]=s.split("#");if(l){let n=`#${l}`,g=t.shadowRoots.reduce((c,i)=>c??i.querySelector(`svg ${n}`),o?.querySelector(`svg ${n}`));if(a&&e.setAttribute("href",n),r?.querySelector(n))return [];if(g)return r?.appendChild(g.cloneNode(true)),[];if(a)return [Pe(t,{url:a,responseType:"text"}).then(c=>{r?.insertAdjacentHTML("beforeend",c);})]}return []}function Wo(e,t){let{tasks:o}=t;j(e)&&((be(e)||Fo(e))&&o.push(...ns(e,t)),fn(e)&&o.push(...ss(e,t))),De(e)&&o.push(...rs(e.style,t)),e.childNodes.forEach(r=>{Wo(r,t);});}async function as(e,t){let{ownerDocument:o,svgStyleElement:r,fontFamilies:s,fontCssTexts:a,tasks:l,font:n}=t;if(!(!o||!r||!s.size))if(n&&n.cssText){let g=Co(n.cssText,t);r.appendChild(o.createTextNode(`${g}
|
|
8
|
+
`));}else {let g=Array.from(o.styleSheets).filter(i=>{try{return "cssRules"in i&&!!i.cssRules.length}catch(p){return t.log.warn(`Error while reading CSS rules from ${i.href}`,p),false}});await Promise.all(g.flatMap(i=>Array.from(i.cssRules).map(async(p,u)=>{if(dn(p)){let d=u+1,m=p.href,f="";try{f=await Pe(t,{url:m,requestType:"text",responseType:"text"});}catch(b){t.log.warn(`Error fetch remote css import from ${m}`,b);}let h=f.replace(Ho,(b,v,w)=>b.replace(w,Po(w,m)));for(let b of ls(h))try{i.insertRule(b,b.startsWith("@import")?d+=1:i.cssRules.length);}catch(v){t.log.warn("Error inserting rule from remote css import",{rule:b,error:v});}}})));let c=[];g.forEach(i=>{vt(i.cssRules,c);}),c.filter(i=>un(i)&&_o(i.style.getPropertyValue("src"))&&Go(i.style.getPropertyValue("font-family"))?.some(p=>s.has(p))).forEach(i=>{let p=i,u=a.get(p.cssText);u?r.appendChild(o.createTextNode(`${u}
|
|
9
|
+
`)):l.push(Oo(p.cssText,p.parentStyleSheet?p.parentStyleSheet.href:null,t).then(d=>{d=Co(d,t),a.set(p.cssText,d),r.appendChild(o.createTextNode(`${d}
|
|
10
|
+
`));}));});}}function ls(e){if(e==null)return [];let t=[],o=e.replace(is,"");for(;;){let a=ko.exec(o);if(!a)break;t.push(a[0]);}o=o.replace(ko,"");let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let a=r.exec(o);if(a)s.lastIndex=r.lastIndex;else if(a=s.exec(o),a)r.lastIndex=s.lastIndex;else break;t.push(a[0]);}return t}function Co(e,t){let{font:o}=t,r=o?o?.preferredFormat:void 0;return r?e.replace(us,s=>{for(;;){let[a,,l]=cs.exec(s)||[];if(!l)return "";if(l===r)return `src: ${a};`}}):e}function vt(e,t=[]){for(let o of Array.from(e))gn(o)?t.push(...vt(o.cssRules)):"cssRules"in o?vt(o.cssRules,t):t.push(o);return t}async function ds(e,t){let o=await nt(e,t);if(j(o.node)&&Le(o.node))return o.node;let{ownerDocument:r,log:s,tasks:a,svgStyleElement:l,svgDefsElement:n,svgStyles:g,font:c,progress:i,autoDestruct:p,onCloneNode:u,onEmbedNode:d,onCreateForeignObjectSvg:m}=o;s.time("clone node");let f=await kt(o.node,o,true);if(l&&r){let k="";g.forEach((R,S)=>{k+=`${R.join(`,
|
|
11
|
+
`)} {
|
|
12
|
+
${S}
|
|
13
|
+
}
|
|
14
|
+
`;}),l.appendChild(r.createTextNode(k));}s.timeEnd("clone node"),await u?.(f),c!==false&&j(f)&&(s.time("embed web font"),await as(f,o),s.timeEnd("embed web font")),s.time("embed node"),Wo(f,o);let h=a.length,b=0,v=async()=>{for(;;){let k=a.pop();if(!k)break;try{await k;}catch(R){o.log.warn("Failed to run task",R);}i?.(++b,h);}};i?.(b,h),await Promise.all([...Array.from({length:4})].map(v)),s.timeEnd("embed node"),await d?.(f);let w=gs(f,o);return n&&w.insertBefore(n,w.children[0]),l&&w.insertBefore(l,w.children[0]),p&&Jn(o),await m?.(w),w}function gs(e,t){let{width:o,height:r}=t,s=Cn(o,r,e.ownerDocument),a=s.ownerDocument.createElementNS(s.namespaceURI,"foreignObject");return a.setAttributeNS(null,"x","0%"),a.setAttributeNS(null,"y","0%"),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.append(e),s.appendChild(a),s}async function fs(e,t){let o=await nt(e,t),r=await ds(o),s=Rn(r,o.isEnable("removeControlCharacter"));o.autoDestruct||(o.svgStyleElement=No(o.ownerDocument),o.svgDefsElement=o.ownerDocument?.createElementNS(rt,"defs"),o.svgStyles.clear());let a=he(s,r.ownerDocument);return await Ln(a,o)}async function ps(e,t){let o=await nt(e,t),{log:r,quality:s,type:a,dpi:l}=o,n=await fs(o);r.time("canvas to data url");let g=n.toDataURL(a,s);if(["image/png","image/jpeg"].includes(a)&&l&&an&&ln){let[c,i]=g.split(","),p=0,u=false;if(a==="image/png"){let w=nn(i);w>=0?(p=Math.ceil((w+28)/3)*4,u=true):p=33/3*4;}else a==="image/jpeg"&&(p=18/3*4);let d=i.substring(0,p),m=i.substring(p),f=window.atob(d),h=new Uint8Array(f.length);for(let w=0;w<h.length;w++)h[w]=f.charCodeAt(w);let b=a==="image/png"?en(h,l,u):Qr(h,l),v=window.btoa(String.fromCharCode(...b));g=[c,",",v,m].join("");}return r.timeEnd("canvas to data url"),g}async function Ct(e,t){return ps(await nt(e,{...t,type:"image/jpeg"}))}var Ro,Ao,Io,Bo,St,tn,on,rn,Mo,se,sn,an,ln,Tt,Do,et,Et,cn,un,dn,gn,j,Le,Fo,fn,De,pn,mn,be,tt,hn,bn,yn,wn,Sn,xn,vn,Tn,En,xt,rt,In,Lo,xo,_n,Hn,jn,Yn,vo,Xn,Ho,os,is,ko,cs,us,Vo=Wt(()=>{Ro=112,Ao=72,Io=89,Bo=115;tn="AAlwSFlz",on="AAAJcEhZ",rn="AAAACXBI";Mo="[modern-screenshot]",se=typeof window<"u",sn=se&&"Worker"in window,an=se&&"atob"in window,ln=se&&"btoa"in window,Tt=se?window.navigator?.userAgent:"",Do=Tt.includes("Chrome"),et=Tt.includes("AppleWebKit")&&!Do,Et=Tt.includes("Firefox"),cn=e=>e&&"__CONTEXT__"in e,un=e=>e.constructor.name==="CSSFontFaceRule",dn=e=>e.constructor.name==="CSSImportRule",gn=e=>e.constructor.name==="CSSLayerBlockRule",j=e=>e.nodeType===1,Le=e=>typeof e.className=="object",Fo=e=>e.tagName==="image",fn=e=>e.tagName==="use",De=e=>j(e)&&typeof e.style<"u"&&!Le(e),pn=e=>e.nodeType===8,mn=e=>e.nodeType===3,be=e=>e.tagName==="IMG",tt=e=>e.tagName==="VIDEO",hn=e=>e.tagName==="CANVAS",bn=e=>e.tagName==="TEXTAREA",yn=e=>e.tagName==="INPUT",wn=e=>e.tagName==="STYLE",Sn=e=>e.tagName==="SCRIPT",xn=e=>e.tagName==="SELECT",vn=e=>e.tagName==="SLOT",Tn=e=>e.tagName==="IFRAME",En=(...e)=>console.warn(Mo,...e);xt=e=>e.startsWith("data:");rt="http://www.w3.org/2000/svg";In=e=>An(e,"dataUrl");Lo=(function(){let t=0,o=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return ()=>(t+=1,`u${o()}${t}`)})();xo=0;_n=["width","height","-webkit-text-fill-color"],Hn=["stroke","fill"];jn=["::before","::after"],Yn=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];vo=new Set(["symbol"]);Xn=/^[\w-:]+$/;Ho=/url\((['"]?)([^'"]+?)\1\)/g;os=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];is=/(\/\*[\s\S]*?\*\/)/g,ko=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;cs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,us=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;});var jo={};vr(jo,{captureScreenshot:()=>hs});async function hs(){try{let e=await Ct(document.body,{scale:1,quality:.7,width:window.innerWidth,height:window.innerHeight});return e.length>ms&&(e=await Ct(document.body,{scale:.5,quality:.5,width:window.innerWidth,height:window.innerHeight})),e}catch{return null}}var ms,Yo=Wt(()=>{Vo();ms=2*1024*1024;});var Vt="https://gotcha.cx/api/v1";var V={ANONYMOUS_ID:"gotcha_anonymous_id",OFFLINE_QUEUE:"gotcha_offline_queue",HIDDEN_UNTIL:"gotcha_hidden",VISIT_COUNT:"gotcha_visits"},ee={POSITION:"top-right",SIZE:"md",THEME:"light",SHOW_ON_HOVER:true,TOUCH_BEHAVIOR:"always-visible",SUBMIT_TEXT:"Submit",THANK_YOU_MESSAGE:"Gotcha!"},je={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function te(e){if(typeof window>"u")return null;try{return localStorage.getItem(e)}catch{return null}}function oe(e,t){if(!(typeof window>"u"))try{localStorage.setItem(e,t);}catch{}}function re(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}function Ye(){let e=te(V.ANONYMOUS_ID);if(e)return e;let t=`anon_${re()}`;return oe(V.ANONYMOUS_ID,t),t}var qe=[],Ke=false;function jt(e,t){let o={message:e.slice(0,200),source:t?.slice(0,200),timestamp:Date.now()};qe.push(o),qe.length>10&&qe.shift();}function Yt(e){jt(e.message,e.filename);}function qt(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason);jt(t);}function Kt(){typeof window>"u"||Ke||(window.addEventListener("error",Yt),window.addEventListener("unhandledrejection",qt),Ke=true);}function Qt(){typeof window>"u"||!Ke||(window.removeEventListener("error",Yt),window.removeEventListener("unhandledrejection",qt),Ke=false);}function Xt(){return [...qe].reverse()}function Jt(){return typeof window>"u"?{}:{url:window.location.origin+window.location.pathname,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenResolution:{width:screen.width,height:screen.height},recentErrors:Xt()}}var Tr=50,Er=10080*60*1e3;function Be(){let e=te(V.OFFLINE_QUEUE);if(!e)return [];try{let t=JSON.parse(e),o=Date.now();return t.filter(r=>o-r.queuedAt<Er)}catch{return []}}function dt(e){oe(V.OFFLINE_QUEUE,JSON.stringify(e));}function gt(e,t="create"){let o=Be();o.length>=Tr||(o.push({id:re(),payload:e,type:t,queuedAt:Date.now(),retries:0}),dt(o));}function Zt(e){let t=Be().filter(o=>o.id!==e);dt(t);}function eo(){return Be()}function to(){return Be().length}function oo(e){let t=Be().map(o=>o.id===e?{...o,retries:o.retries+1}:o);dt(t.filter(o=>o.retries<=5));}var pe={maxRetries:je.MAX_RETRIES,baseDelayMs:je.BASE_DELAY_MS,maxDelayMs:je.MAX_DELAY_MS};async function Me(e,t,o=pe,r=false){let s=null;for(let a=0;a<=o.maxRetries;a++){try{r&&a>0&&console.log(`[Gotcha] Retry attempt ${a}/${o.maxRetries}`);let l=await fetch(e,t);if(l.status>=400&&l.status<500&&l.status!==429||l.ok)return l;s=new Error(`HTTP ${l.status}`);}catch(l){s=l,r&&console.log(`[Gotcha] Network error: ${s.message}`);}if(a<o.maxRetries){let l=Math.min(o.baseDelayMs*Math.pow(2,a),o.maxDelayMs);await new Promise(n=>setTimeout(n,l));}}throw s}function ro(e){let{apiKey:t,baseUrl:o=Vt,debug:r=false}=e,s=false,a={"Content-Type":"application/json",Authorization:`Bearer ${t}`};async function l(n,g,c){let i=`${o}${g}`,p=re();r&&console.log(`[Gotcha] ${n} ${g}`,c);let u=await Me(i,{method:n,headers:{...a,"Idempotency-Key":p},body:c?JSON.stringify(c):void 0},pe,r),d;try{d=await u.json();}catch{throw {code:"PARSE_ERROR",message:"Invalid response from server",status:u.status}}if(!u.ok){let m=d.error;throw r&&console.error(`[Gotcha] Error: ${m.code} - ${m.message}`),m}return r&&console.log("[Gotcha] Response:",d),d}return {async submitResponse(n){let g=n.user||{};g.id||(g.id=Ye());let c={...n,user:g,context:Jt(),...n.isBug?{isBug:true}:{}};if(typeof navigator<"u"&&!navigator.onLine)return gt(c,"create"),{id:re(),status:"queued",createdAt:new Date().toISOString()};try{return await l("POST","/responses",c)}catch(i){if(i instanceof TypeError&&typeof navigator<"u"&&!navigator.onLine)return gt(c,"create"),{id:re(),status:"queued",createdAt:new Date().toISOString()};throw i}},async checkExistingResponse(n,g){let c=`${o}/responses/check?elementId=${encodeURIComponent(n)}&userId=${encodeURIComponent(g)}`;r&&console.log("[Gotcha] GET /responses/check");let i=await Me(c,{method:"GET",headers:a},pe,r),p=await i.json();if(!i.ok){let u=p.error;throw r&&console.error(`[Gotcha] Error: ${u.code} - ${u.message}`),u}return p.exists?(r&&console.log("[Gotcha] Found existing response:",p.response),p.response):null},async updateResponse(n,g,c){let i=`${o}/responses/${n}${c?`?userId=${encodeURIComponent(c)}`:""}`;r&&console.log(`[Gotcha] PATCH /responses/${n}`,g);let p=await Me(i,{method:"PATCH",headers:a,body:JSON.stringify(g)},pe,r),u=await p.json();if(!p.ok){let d=u.error;throw r&&console.error(`[Gotcha] Error: ${d.code} - ${d.message}`),d}return r&&console.log("[Gotcha] Response updated:",u),u},async getScore(n){let g=`${o}/scores/${encodeURIComponent(n)}`;r&&console.log(`[Gotcha] GET /scores/${n}`);let c=await Me(g,{method:"GET",headers:a},pe,r),i=await c.json();if(!c.ok){let p=i.error;throw r&&console.error(`[Gotcha] Error: ${p.code} - ${p.message}`),p}return r&&console.log("[Gotcha] Score:",i),i},async flagAsBug(n){let g=`${o}/responses/${encodeURIComponent(n)}/bug`;r&&console.log(`[Gotcha] POST /responses/${n}/bug`);let c=await Me(g,{method:"POST",headers:a},pe,r),i=await c.json();if(!c.ok){let p=i.error;throw r&&console.error(`[Gotcha] Error: ${p.code} - ${p.message}`),p}return r&&console.log("[Gotcha] Bug flagged:",i),i},async flushQueue(){if(!s){s=true;try{let n=eo();for(let g of n)try{if(g.type==="update"&&g.payload.responseId){let{responseId:c,...i}=g.payload;await l("PATCH",`/responses/${c}`,i);}else await l("POST","/responses",g.payload);Zt(g.id);}catch{oo(g.id);}}finally{s=false;}}},getQueueLength:to,getBaseUrl(){return o}}}var kr=new Set(["__proto__","constructor","prototype"]);function de(e,t){let o={...e};for(let r of Object.keys(t)){if(kr.has(r))continue;let s=t[r];s!=null&&typeof s=="object"&&!Array.isArray(s)?o[r]=de(e[r]??{},s):s!==void 0&&(o[r]=s);}return o}var no=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],ft={colors:{primary:"#1e293b",primaryHover:"#334155",primaryText:"#ffffff",background:"#ffffff",backgroundGradient:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)",surface:"#fafbfc",surfaceHover:"#ffffff",text:"#111827",textSecondary:"#374151",textDisabled:"#94a3b8",border:"#e2e8f0",borderFocus:"#1e293b",success:"#059669",successSurface:"rgba(5,150,105,0.08)",error:"#dc2626",errorSurface:"#fef2f2",errorBorder:"rgba(220,38,38,0.1)",warning:"#d97706",warningActive:"#b45309",warningSurface:"rgba(251,191,36,0.08)",warningBorder:"rgba(217,119,6,0.25)",starFilled:"#f59e0b",starEmpty:"#e2e8f0",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.06)",voteUpBorder:"rgba(16,185,129,0.25)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.06)",voteDownBorder:"rgba(239,68,68,0.25)",npsColors:no,buttonBackground:"#1e293b",buttonBackgroundHover:"#334155",buttonBackgroundDisabled:"#e2e8f0",buttonColor:"#ffffff",buttonColorDisabled:"#94a3b8",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.4)",closeButton:"#9ca3af",closeButtonHover:"#6b7280",closeButtonBg:"rgba(0,0,0,0.04)",glassBackground:"linear-gradient(160deg, rgba(255,255,255,0.7) 0%, rgba(200,210,230,0.4) 40%, rgba(180,192,220,0.5) 100%)",glassBorder:"none",glassColor:"rgba(0,0,0,0.75)",glassShadow:"0 3px 12px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2)",glassHoverShadow:"0 6px 20px rgba(0,0,0,0.18), 0 0 1px rgba(0,0,0,0.25)",inputBackground:"#fafbfc",inputBackgroundFocus:"#ffffff",inputBorder:"#e2e8f0",inputBorderFocus:"#1e293b",inputFocusRing:"rgba(30,41,59,0.15)",pollBorder:"#e2e8f0",pollSelectedBorder:"rgba(30,41,59,0.25)",pollBackground:"#fafbfc",pollSelectedBackground:"rgba(30,41,59,0.05)",pollColor:"#374151",pollSelectedColor:"#1e293b",pollCheckBorder:"#cbd5e1",pollCheckSelectedBorder:"#1e293b",pollCheckSelectedBg:"#1e293b"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.04)",md:"0 4px 12px rgba(0,0,0,0.06)",lg:"0 12px 32px rgba(0,0,0,0.06)",modal:"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06), 0 24px 48px rgba(0,0,0,0.04)",button:"0 2px 8px rgba(0,0,0,0.06)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}},pt={colors:{primary:"#e2e8f0",primaryHover:"#cbd5e1",primaryText:"#1e293b",background:"#1a1f2e",backgroundGradient:"linear-gradient(180deg, #1a1f2e 0%, #151925 100%)",surface:"rgba(55,65,81,0.5)",surfaceHover:"rgba(55,65,81,0.7)",text:"#f9fafb",textSecondary:"#d1d5db",textDisabled:"#6b7280",border:"rgba(255,255,255,0.08)",borderFocus:"rgba(255,255,255,0.2)",success:"#10b981",successSurface:"rgba(16,185,129,0.1)",error:"#fecaca",errorSurface:"rgba(127,29,29,0.3)",errorBorder:"rgba(254,202,202,0.1)",warning:"#fbbf24",warningActive:"#fbbf24",warningSurface:"rgba(245,158,11,0.08)",warningBorder:"rgba(245,158,11,0.3)",starFilled:"#f59e0b",starEmpty:"rgba(255,255,255,0.12)",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.08)",voteUpBorder:"rgba(16,185,129,0.3)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.08)",voteDownBorder:"rgba(239,68,68,0.3)",npsColors:no,buttonBackground:"#e2e8f0",buttonBackgroundHover:"#cbd5e1",buttonBackgroundDisabled:"#374151",buttonColor:"#1e293b",buttonColorDisabled:"#6b7280",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.5)",closeButton:"#6b7280",closeButtonHover:"#9ca3af",closeButtonBg:"rgba(255,255,255,0.06)",glassBackground:"linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 60%, rgba(0,0,0,0.05) 100%)",glassBorder:"1px solid rgba(255,255,255,0.15)",glassColor:"rgba(255,255,255,0.88)",glassShadow:"0 4px 14px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.35)",glassHoverShadow:"0 8px 24px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4)",inputBackground:"rgba(55,65,81,0.5)",inputBackgroundFocus:"rgba(55,65,81,0.7)",inputBorder:"rgba(255,255,255,0.08)",inputBorderFocus:"rgba(255,255,255,0.2)",inputFocusRing:"rgba(255,255,255,0.06)",pollBorder:"rgba(255,255,255,0.08)",pollSelectedBorder:"rgba(226,232,240,0.25)",pollBackground:"rgba(55,65,81,0.5)",pollSelectedBackground:"rgba(226,232,240,0.08)",pollColor:"#d1d5db",pollSelectedColor:"#e2e8f0",pollCheckBorder:"rgba(255,255,255,0.2)",pollCheckSelectedBorder:"#e2e8f0",pollCheckSelectedBg:"#e2e8f0"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.2)",md:"0 4px 12px rgba(0,0,0,0.3)",lg:"0 12px 32px rgba(0,0,0,0.2)",modal:"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2), 0 24px 48px rgba(0,0,0,0.15)",button:"0 2px 8px rgba(0,0,0,0.15)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}};function Cr(e,t){return de(e==="dark"?pt:ft,t)}function ne(e,t,o){let s=(e==="auto"||e==="custom"?t:e)==="dark"?de({},pt):de({},ft);return o&&(s=de(s,o)),s}var so="gotcha-styles",ao="gotcha-dm-sans",io="gotcha-carter-one",Rr=`
|
|
2
15
|
@font-face {
|
|
3
16
|
font-family: 'Carter One';
|
|
4
17
|
font-style: normal;
|
|
@@ -6,7 +19,7 @@
|
|
|
6
19
|
font-display: block;
|
|
7
20
|
src: url(data:font/woff2;base64,d09GMgABAAAAAAK4AA4AAAAABOwAAAJlAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhQbXhwaBmAANBEICoFUgW8BNgIkAwgLBgAEIAWCUgcgGwoEUVQMHgC+OLCNaQVfBAoIrXGAIhjLIIM0CxavPfqMrzmLh6/9fufu20XEQyQzNNPOUEmimUZJpKLdIu3RKOU3O1hXc5D3YTdAbu+mRHU5AAIwC231R25qGGbpnwecyr34QQKM3gHMKMzOM4ogDSwQSreJE9bjISamQdCMwAAgeI0+S7qoy5j8TCDK8Ff4Fwm5+ecJhCwh9EgmsJiTo6S+/WkCPCU8DpCqr+hWKM/FBMRyfLPqV2LSlzBEIhqLxeGhIADg+rwoHxx58Oipm4301FUpgID4K8fAChoJFSYwAhNYKyDLAjudDimd9wA18hGDDvNkBE6AByBJiLpXVM2jgyht94hWK9yPQD+5lb948fAQKnfCK1PjBQWRayfW+hltCzAs9B8eX54Xd5g7vrzpiTswCeXB/VG5PNObmFr711KPrLKC6/mxys5avigCA+uFj8HGq+ErmaRDt/31k1XtfRtcI0pNluOCFEOOmVEOTg5eYn77Hq9Y0SJxu+bSBW5skqWS0VLXOvNJxgyRhVECycL7u2cb2pmOGdolPK+ORsLma1IHQCAY6I5NjWKsNzQVPeDnvzc7Pth+aTYMKHpqoEcCwSM4A6sVYPt/AIoeTckToLx4hELyieAj16Z4TKDbKYzIJOAW2JNhIptMhjyRlbXedjaymDv75i5jb1xkyVYiV4okyfIhmnG0EGNDIyMkVgmkUIJcmbJkQmLEi5Ehjz7iJF06pJeel1ETYiCBP/+OePouYuTKlyAX4iVTAl8JkhRIFyN3UpqAdTHa1nfVAy3Kk3LL2Ejf0Gch0McAqJNIAwAA) format('woff2');
|
|
8
21
|
unicode-range: U+0047;
|
|
9
|
-
}`.trim();function
|
|
22
|
+
}`.trim();function Ar(){if(typeof document>"u"||document.getElementById(io))return;let e=document.createElement("style");e.id=io,e.textContent=Rr,document.head.appendChild(e);}Ar();function me(e){return e.replace(/[{}<>;@\\]/g,"")}function Ir(e){let t={default:me(e.animation.easing.default),spring:me(e.animation.easing.spring)},o={normal:me(e.animation.duration.normal)},r=me(e.typography.fontFamily),s=me(e.colors.textDisabled),a=me(e.colors.border);return `
|
|
10
23
|
/* \u2500\u2500 Gotcha Keyframe Animations \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
11
24
|
|
|
12
25
|
@keyframes gotcha-modal-in {
|
|
@@ -118,11 +131,11 @@
|
|
|
118
131
|
|
|
119
132
|
[data-gotcha] button:focus-visible {
|
|
120
133
|
outline: none;
|
|
121
|
-
box-shadow: 0 0 0 2px ${
|
|
134
|
+
box-shadow: 0 0 0 2px ${a};
|
|
122
135
|
}
|
|
123
136
|
|
|
124
137
|
.gotcha-root textarea::placeholder {
|
|
125
|
-
color: ${
|
|
138
|
+
color: ${s};
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
/* \u2500\u2500 Animation Utilities \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
@@ -156,6 +169,6 @@
|
|
|
156
169
|
transition-duration: 0.01ms !important;
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
|
-
`.trim()}function He(e){if(typeof document>"u")return;if(!document.getElementById(Oo)){let o=document.createElement("link");o.rel="preconnect",o.href="https://fonts.googleapis.com",document.head.appendChild(o);let r=document.createElement("link");r.rel="preconnect",r.href="https://fonts.gstatic.com",r.crossOrigin="anonymous",document.head.appendChild(r);let n=document.createElement("link");n.id=Oo,n.rel="stylesheet",n.href="https://fonts.googleapis.com/css2?family=Carter+One&family=DM+Sans:wght@400;500;600;700&display=swap",document.head.appendChild(n);}let t=document.getElementById($o);t||(t=document.createElement("style"),t.id=$o,document.head.appendChild(t)),t.textContent=$t(e);}var No=react.createContext(null),Nt={};function Wt({apiKey:e,children:t,baseUrl:o,debug:r=false,disabled:n=false,defaultUser:p,themeConfig:l}){let[u,g]=react.useState(null);o&&!o.startsWith("https://")&&!o.startsWith("/")&&!o.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",o);let a=react.useMemo(()=>Po({apiKey:e,baseUrl:o,debug:r}),[e,o,r]),s=react.useMemo(()=>p??Nt,[JSON.stringify(p)]);react.useEffect(()=>{let c=te("light","light",l);He(c);},[l]),react.useEffect(()=>(Io(),()=>Ao()),[]),react.useEffect(()=>{a.flushQueue();let c=()=>a.flushQueue();return window.addEventListener("online",c),()=>window.removeEventListener("online",c)},[a]);let h=react.useCallback(c=>{g(c);},[]),d=react.useCallback(()=>{g(null);},[]),i=react.useMemo(()=>({client:a,disabled:n,defaultUser:s,debug:r,activeModalId:u,openModal:h,closeModal:d,themeConfig:l}),[a,n,s,r,u,h,d,l]);return jsxRuntime.jsx(No.Provider,{value:i,children:t})}function D(){let e=react.useContext(No);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function Qt(e,t){let o=new Date(e).getTime();if(isNaN(o))return true;let r=Date.now()-o,n=t*24*60*60*1e3;return r>=n}function Wo(e){let{client:t,defaultUser:o}=D(),[r,n]=react.useState(false),[p,l]=react.useState(false),[u,g]=react.useState(null),[a,s]=react.useState(null);return react.useEffect(()=>{process.env.NODE_ENV!=="production"&&e.cooldownDays&&!e.onePerUser&&console.warn("[Gotcha] cooldownDays has no effect without onePerUser=true");let d=e.user?.id||o?.id;if(!d||!e.onePerUser){s(null);return}let i=false;return (async()=>{l(true);try{let f=await t.checkExistingResponse(e.elementId,d);i||(f&&e.cooldownDays&&e.cooldownDays>0&&Qt(f.createdAt,e.cooldownDays)?s(null):s(f));}catch{i||s(null);}finally{i||l(false);}})(),()=>{i=true;}},[t,e.elementId,e.user?.id,o?.id,e.onePerUser,e.cooldownDays]),{submit:react.useCallback(async d=>{n(true),g(null);try{let i=e.user?.id||o?.id,c;return e.onePerUser&&a&&i?c=await t.updateResponse(a.id,{content:d.content,title:d.title,rating:d.rating,vote:d.vote,pollSelected:d.pollSelected},i):c=await t.submitResponse({elementId:e.elementId,mode:e.mode,content:d.content,title:d.title,rating:d.rating,vote:d.vote,pollOptions:e.pollOptions,pollSelected:d.pollSelected,isBug:d.isBug,screenshot:d.screenshot,user:{...o,...e.user}}),e.onePerUser&&s({id:c.id,mode:e.mode,content:d.content??null,title:d.title??null,rating:d.rating??null,vote:d.vote??null,pollSelected:d.pollSelected??null,createdAt:c.createdAt}),e.onSuccess?.(c),c}catch(i){let c=i instanceof Error?i.message:"Something went wrong";throw g(c),e.onError?.(i instanceof Error?i:new Error(c)),i}finally{n(false);}},[t,o,e,a]),isLoading:r,isCheckingExisting:p,error:u,existingResponse:a,isEditing:!!a,clearError:()=>g(null)}}function Vo(e,t){return `${Y.HIDDEN_UNTIL}_${e}_${t}`}function Yo(e,t,o){if(!o||o<=0)return false;let r=Vo(e,t),n=Z(r);return n?new Date(n).getTime()>Date.now():false}function Ko(e){let{elementId:t,userId:o,hideAfterSubmitDays:r}=e,n=react.useMemo(()=>o||Ue(),[o]),[p,l]=react.useState(()=>Yo(t,n,r));react.useEffect(()=>{l(Yo(t,n,r));},[t,n,r]);let u=react.useCallback(()=>{if(!r||r<=0)return;let g=Vo(t,n),a=new Date(Date.now()+r*24*60*60*1e3);ee(g,a.toISOString()),l(true);},[t,n,r]);return {isHidden:p,markHidden:u}}function Zt(e){return `${Y.VISIT_COUNT}_${e}`}function jo(e){let{elementId:t,showAfterSeconds:o,showAfterScrollPercent:r,showAfterVisits:n}=e,p=o!=null||r!=null||n!=null,[l,u]=react.useState(!o),[g,a]=react.useState(!r),[s]=react.useState(()=>{if(!n)return true;let h=Zt(t),i=parseInt(Z(h)||"0",10)+1;return ee(h,String(i)),i>=n});return react.useEffect(()=>{if(!o||o<=0)return;let h=Date.now(),d=o*1e3,i=()=>{Date.now()-h>=d?u(true):c=setTimeout(i,Math.min(1e3,d-(Date.now()-h)));},c=setTimeout(i,Math.min(1e3,d));return ()=>clearTimeout(c)},[o]),react.useEffect(()=>{if(!r||r<=0)return;let h=()=>{let d=document.documentElement.scrollHeight,i=window.innerHeight;if(d<=i){a(true);return}(window.scrollY+i)/d*100>=r&&a(true);};if(h(),!g)return window.addEventListener("scroll",h,{passive:true}),()=>window.removeEventListener("scroll",h)},[r,g]),{conditionsMet:!p||l&&g&&s}}function Ne(...e){return e.filter(Boolean).join(" ")}var O=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,Xo=(e,t)=>{let o={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return t?o[e].mobile:o[e].desktop};function or(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qo({size:e,theme:t,customStyles:o,showOnHover:r,touchBehavior:n,onClick:p,isOpen:l,isParentHovered:u=false,animated:g=true,queuedCount:a=0}){let[s,h]=react.useState(false),[d,i]=react.useState(false),[c,f]=react.useState(or),[S,x]=react.useState(false),[B,k]=react.useState(false),[I,F]=react.useState(false),{themeConfig:y}=D();react.useEffect(()=>{if(h(O()),typeof window>"u")return;let $=window.matchMedia("(prefers-color-scheme: dark)"),b=N=>f(N.matches?"dark":"light");return $.addEventListener("change",b),()=>$.removeEventListener("change",b)},[]);let w=l?true:!s&&r?u:s&&n==="tap-to-reveal"?d:true;react.useEffect(()=>{if(w&&!I){let $=setTimeout(()=>F(true),600);return ()=>clearTimeout($)}},[w,I]);let E=()=>{if(s&&n==="tap-to-reveal"&&!d){i(true);return}p();},T=Xo(e,s),v=react.useMemo(()=>te(t,c,y),[t,c,y]),L=()=>w?B?"scale(0.95)":S?"scale(1.08)":"scale(1)":"scale(0.6)",ae={width:T,height:T,borderRadius:"50%",border:v.colors.glassBorder,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:v.colors.glassBackground,backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",color:v.colors.glassColor,boxShadow:S?v.colors.glassHoverShadow:v.colors.glassShadow,transition:I?`all 0.3s ${v.animation.easing.spring}`:"none",opacity:w?1:0,transform:L(),filter:B?"brightness(0.95)":"brightness(1)",pointerEvents:w?"auto":"none",...g&&w&&!I?{animation:"gotcha-bubble-pop 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both, gotcha-arrive-glow 1200ms ease-in-out 600ms both"}:{},...o?.button};return jsxRuntime.jsxs("button",{type:"button",onClick:E,onMouseEnter:()=>x(true),onMouseLeave:()=>{x(false),k(false);},onMouseDown:()=>k(true),onMouseUp:()=>k(false),onTouchStart:()=>k(true),onTouchEnd:()=>k(false),style:ae,className:Ne("gotcha-button",l&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":l,"aria-haspopup":"dialog",children:[jsxRuntime.jsx(tr,{size:T*.65,animated:g}),a>0&&jsxRuntime.jsx("div",{"aria-label":`${a} queued`,style:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",backgroundColor:v.colors.warning,border:"1.5px solid rgba(255,255,255,0.9)"}})]})}function tr({size:e,animated:t=true}){let[o,r]=react.useState(false);return react.useEffect(()=>{r(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:"'Carter One', cursive",fontSize:e,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",marginTop:e*.05,marginRight:e*.05,userSelect:"none",opacity:t?0:o?1:0,...t&&o?{animation:"gotcha-letter-in 350ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 200ms both"}:{}},children:"G"})}function P({size:e=16,color:t="currentColor"}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function Zo({src:e,onRemove:t,resolvedTheme:o}){return jsxRuntime.jsxs("div",{style:{position:"relative",marginTop:10,borderRadius:o.borders.radius.md,overflow:"hidden",border:`1px solid ${o.colors.border}`},children:[jsxRuntime.jsx("img",{src:e,alt:"Screenshot",style:{display:"block",width:"100%",maxHeight:120,objectFit:"cover"}}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":"Remove screenshot",style:{position:"absolute",top:4,right:4,width:22,height:22,borderRadius:"50%",border:"none",backgroundColor:"rgba(0,0,0,0.6)",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,lineHeight:1},children:jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]})}function rt({resolvedTheme:e,placeholder:t,submitText:o,isLoading:r,onSubmit:n,customStyles:p,initialValues:l,isEditing:u=false,showText:g=true,showRating:a=true,enableBugFlag:s=false,bugFlagLabel:h,enableScreenshot:d=false}){let[i,c]=react.useState(l?.content||""),[f,S]=react.useState(l?.rating??null),[x,B]=react.useState(false),[k,I]=react.useState(false),[F,y]=react.useState(null),[w,E]=react.useState(false);react.useEffect(()=>{I(O());},[]),react.useEffect(()=>{l?.content!==void 0&&c(l.content||""),l?.rating!==void 0&&S(l.rating??null);},[l?.content,l?.rating]);let T=g&&a?i.trim().length>0||f!==null:g?i.trim().length>0:a?f!==null:false,v=async()=>{E(true);try{let{captureScreenshot:b}=await Promise.resolve().then(()=>(tt(),ot)),N=await b();N&&y(N);}catch{}finally{E(false);}},L=b=>{b.preventDefault(),T&&n({content:g&&i.trim()?i.trim():void 0,rating:a&&f!==null?f:void 0,isBug:x||void 0,screenshot:F||void 0});},ae={width:"100%",padding:k?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:k?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:k?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)",...p?.input},$={width:"100%",padding:k?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:e.colors.buttonBackground,color:e.colors.buttonColor,fontSize:k?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",...p?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:L,children:[a&&jsxRuntime.jsx("div",{style:{marginBottom:g?k?16:12:0,...g?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(lr,{value:f,onChange:S,theme:e,isTouch:k,large:!g})}),g&&jsxRuntime.jsx("textarea",{value:i,onChange:b=>c(b.target.value),placeholder:t||"Share your thoughts...",maxLength:5e3,style:ae,disabled:r,"aria-label":"Your feedback",onFocus:b=>{b.currentTarget.style.borderColor=e.colors.inputBorderFocus,b.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,b.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:b=>{b.currentTarget.style.borderColor=e.colors.inputBorder,b.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",b.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),s&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":x,onClick:()=>B(!x),style:{display:"flex",alignItems:"center",gap:7,width:"100%",marginTop:10,padding:"7px 10px",border:`1px solid ${x?e.colors.warningBorder:e.colors.border}`,borderRadius:7,backgroundColor:x?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...p?.bugFlag},onMouseEnter:b=>{x||(b.currentTarget.style.backgroundColor=e.colors.surfaceHover===e.colors.inputBackgroundFocus?"rgba(0,0,0,0.02)":e.colors.surfaceHover);},onMouseLeave:b=>{x||(b.currentTarget.style.backgroundColor="transparent");},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:x?e.colors.warningActive:e.colors.textDisabled,strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:`stroke ${e.animation.duration.fast}`},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:x?e.typography.fontWeight.medium:e.typography.fontWeight.normal,color:x?e.colors.warningActive:e.colors.textDisabled,transition:`color ${e.animation.duration.fast}`,letterSpacing:"0.01em"},children:x?"Issue reported":h||"Report an issue"}),jsxRuntime.jsx("div",{style:{marginLeft:"auto",width:28,height:16,borderRadius:8,backgroundColor:x?e.colors.warning:e.colors.border,position:"relative",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,flexShrink:0},children:jsxRuntime.jsx("div",{style:{position:"absolute",top:2,left:x?14:2,width:12,height:12,borderRadius:"50%",backgroundColor:x?"#ffffff":e.colors.textDisabled,transition:`left ${e.animation.duration.fast} ${e.animation.easing.default}, background-color ${e.animation.duration.fast}`,boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}})})]}),s&&d&&x&&!F&&jsxRuntime.jsxs("button",{type:"button",onClick:v,disabled:w,style:{display:"flex",alignItems:"center",gap:6,width:"100%",marginTop:8,padding:"7px 10px",border:`1px solid ${e.colors.border}`,borderRadius:7,backgroundColor:"transparent",cursor:w?"not-allowed":"pointer",fontFamily:e.typography.fontFamily,fontSize:12,color:e.colors.textSecondary,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},onMouseEnter:b=>{b.currentTarget.style.backgroundColor=e.colors.surfaceHover;},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent";},children:[w?jsxRuntime.jsx(P,{size:14,color:e.colors.textSecondary}):jsxRuntime.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"10",r:"3"}),jsxRuntime.jsx("path",{d:"M2 17l4-4 3 3 4-4 9 9"})]}),w?"Capturing...":"Capture screenshot"]}),s&&d&&x&&F&&jsxRuntime.jsx(Zo,{src:F,onRemove:()=>y(null),resolvedTheme:e}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!T,style:{...$,marginTop:12,opacity:r?.8:1,backgroundColor:T?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:T?e.colors.buttonColor:e.colors.buttonColorDisabled,display:"flex",alignItems:"center",justifyContent:"center",gap:8,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:b=>{b.currentTarget.disabled||(b.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,b.currentTarget.style.transform="translateY(-1px)",b.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:b=>{b.currentTarget.disabled||(b.currentTarget.style.backgroundColor=e.colors.buttonBackground,b.currentTarget.style.transform="translateY(0)",b.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:k?18:16,color:e.colors.buttonColor}),r?u?"Updating...":"Submitting...":u?"Update":o]})]})}function lr({value:e,onChange:t,theme:o,isTouch:r,large:n=false}){let[p,l]=react.useState(null),[u,g]=react.useState(null),a=react.useRef(),s=n?r?36:28:r?28:18,h=n?r?8:5:r?8:3;react.useEffect(()=>()=>{clearTimeout(a.current);},[]);let d=i=>{g(i),t(i),clearTimeout(a.current),a.current=setTimeout(()=>g(null),300);};return jsxRuntime.jsx("div",{style:{display:"flex",gap:n?r?8:6:r?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(i=>{let c=(p??e??0)>=i;return jsxRuntime.jsx("button",{type:"button",onClick:()=>d(i),onMouseEnter:()=>l(i),onMouseLeave:()=>l(null),"aria-label":`Rate ${i} out of 5`,"aria-pressed":e===i,style:{background:"none",border:"none",cursor:"pointer",padding:h,color:c?o.colors.starFilled:o.colors.starEmpty,transition:`color 0.15s ${o.animation.easing.default}`,transform:u===i?"scale(1)":p!==null&&p>=i?"scale(1.1)":"scale(1)",animation:u===i?`gotcha-star-pulse 0.3s ${o.animation.easing.spring}`:"none",filter:c?`drop-shadow(0 0 3px ${o.colors.starFilled}40)`:"none",transitionDelay:`${(i-1)*30}ms`},children:jsxRuntime.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},i)})})}function nt({resolvedTheme:e,isLoading:t,onSubmit:o,initialVote:r,isEditing:n=false,labels:p}){let[l,u]=react.useState(false),[g,a]=react.useState(r||null),[s,h]=react.useState(r||null);react.useEffect(()=>{u(O());},[]),react.useEffect(()=>{r!==void 0&&(h(r),a(r));},[r]),react.useEffect(()=>{!t&&!n&&a(null);},[t,n]);let d=f=>{a(f),o({vote:f});},i=f=>{let S=s===f,x=f==="up"?e.colors.voteUp:e.colors.voteDown,B=f==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,k=f==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,overflow:"hidden",padding:l?"14px 18px":"10px 14px",border:S?`2px solid ${k}`:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.lg-2,background:S?`linear-gradient(135deg, ${B}, ${B})`:e.colors.surface,color:S?x:e.colors.textSecondary,fontSize:l?28:24,fontFamily:e.typography.fontFamily,cursor:t?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:l?10:8}},c=l?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:l?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>d("up"),disabled:t,style:i("up"),"aria-label":"Vote up - I like this","aria-pressed":s==="up",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:n?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(cr,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:p?.up||(s==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>d("down"),disabled:t,style:i("down"),"aria-label":"Vote down - I don't like this","aria-pressed":s==="down",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:n?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(dr,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:p?.down||(s==="down"?"Disliked":"Dislike")})]})})]})}function cr({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function dr({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function it({resolvedTheme:e,options:t,allowMultiple:o,isLoading:r,onSubmit:n,initialSelected:p,isEditing:l=false}){let[u,g]=react.useState(p||[]),[a,s]=react.useState(false);react.useEffect(()=>{s(O());},[]),react.useEffect(()=>{p&&g(p);},[p]);let h=c=>{g(o?f=>f.includes(c)?f.filter(S=>S!==c):[...f,c]:f=>f.includes(c)?[]:[c]);},d=()=>{u.length!==0&&n({pollSelected:u});},i=(c,f)=>{let S=u.includes(c);return {width:"100%",padding:a?"12px 14px":"9px 12px",border:`1px solid ${S?e.colors.pollSelectedBorder:e.colors.pollBorder}`,borderRadius:e.borders.radius.lg-2,backgroundColor:S?e.colors.pollSelectedBackground:e.colors.pollBackground,color:S?e.colors.pollSelectedColor:e.colors.pollColor,fontSize:a?15:e.typography.fontSize.sm,fontWeight:S?e.typography.fontWeight.semibold:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8,animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${f*.05}s`}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:a?8:6},role:"group","aria-label":o?"Select one or more options":"Select an option",children:t.map((c,f)=>{let S=u.includes(c);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>h(c),disabled:r,style:i(c,f),"aria-pressed":S,onMouseEnter:x=>{r||(x.currentTarget.style.transform="translateX(2px)");},onMouseLeave:x=>{x.currentTarget.style.transform="translateX(0)";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:o?4:"50%",border:`2px solid ${S?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:S?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast}`},children:S&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),c]},c)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,disabled:r||u.length===0,style:{width:"100%",marginTop:12,padding:a?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:u.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:u.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:a?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||u.length===0?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=u.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,c.currentTarget.style.transform="translateY(0)",c.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:a?18:16,color:e.colors.buttonColor}),r?l?"Updating...":"Submitting...":l?"Update":"Submit"]})]})}function ct({resolvedTheme:e,submitText:t,isLoading:o,onSubmit:r,customStyles:n,showFollowUp:p=true,followUpPlaceholder:l,lowLabel:u="Not likely",highLabel:g="Very likely",initialValues:a,isEditing:s=false}){let[h,d]=react.useState(a?.rating??null),[i,c]=react.useState(a?.content||""),[f,S]=react.useState(false),[x,B]=react.useState(null);react.useEffect(()=>{S(O());},[]),react.useEffect(()=>{a?.rating!==void 0&&d(a.rating??null),a?.content!==void 0&&c(a.content||"");},[a?.rating,a?.content]);let k=h!==null,I=e.colors.npsColors;return jsxRuntime.jsxs("form",{onSubmit:y=>{y.preventDefault(),k&&r({rating:h??void 0,content:p&&i.trim()?i.trim():void 0});},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:f?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(y,w)=>{let E=h===w,T=x===w,v=I[w];return jsxRuntime.jsx("button",{type:"button",onClick:()=>d(w),onMouseEnter:()=>B(w),onMouseLeave:()=>B(null),"aria-label":`Score ${w} out of 10`,"aria-pressed":E,style:{flex:1,minWidth:0,height:f?34:32,borderRadius:e.borders.radius.sm,border:E?`2px solid ${v}`:`1.5px solid ${v}25`,backgroundColor:E?v:T?`${v}25`:`${v}0c`,color:E?"#fff":T?v:`${v}bb`,fontSize:12,fontWeight:E?e.typography.fontWeight.bold:e.typography.fontWeight.semibold,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`all 0.2s ${e.animation.easing.spring}`,transform:E?"scale(1.08)":T?"scale(1.04)":"scale(1)",boxShadow:E?`0 0 12px ${v}40`:"none",...n?.npsButton,...E?n?.npsButtonSelected:{}},children:w},w)})}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...n?.npsLabels},children:[jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:u}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g})]})]}),p&&h!==null&&jsxRuntime.jsx("textarea",{value:i,onChange:y=>c(y.target.value),placeholder:l||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:f?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:f?80:60,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,animation:`gotcha-expand-in 0.3s ${e.animation.easing.default} both`,overflow:"hidden",...n?.input},disabled:o,"aria-label":"Follow-up feedback",onFocus:y=>{y.currentTarget.style.borderColor=e.colors.inputBorderFocus,y.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,y.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:y=>{y.currentTarget.style.borderColor=e.colors.inputBorder,y.currentTarget.style.boxShadow="none",y.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!k,style:{width:"100%",padding:f?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:k?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:k?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",opacity:o?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...o?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{},...n?.submitButton},onMouseEnter:y=>{y.currentTarget.disabled||(y.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,y.currentTarget.style.transform="translateY(-1px)",y.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:y=>{y.currentTarget.disabled||(y.currentTarget.style.backgroundColor=k?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,y.currentTarget.style.transform="translateY(0)",y.currentTarget.style.boxShadow="none");},children:[o&&jsxRuntime.jsx(P,{size:f?18:16,color:e.colors.buttonColor}),o?s?"Updating...":"Submitting...":s?"Update":t]})]})}function gt({resolvedTheme:e,promptText:t,placeholder:o,isLoading:r,onSubmit:n}){let[p,l]=react.useState(""),[u,g]=react.useState(false);return react.useEffect(()=>{g(O());},[]),jsxRuntime.jsxs("form",{onSubmit:s=>{s.preventDefault(),p.trim()&&n(p.trim());},children:[jsxRuntime.jsx("p",{style:{margin:"0 0 12px 0",fontSize:e.typography.fontSize.sm,color:e.colors.textSecondary,lineHeight:1.4,fontFamily:e.typography.fontFamily},children:t}),jsxRuntime.jsx("textarea",{value:p,onChange:s=>l(s.target.value),placeholder:o||"Tell us more...",maxLength:5e3,disabled:r,"aria-label":"Follow-up feedback",style:{width:"100%",padding:u?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:u?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:u?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)"},onFocus:s=>{s.currentTarget.style.borderColor=e.colors.inputBorderFocus,s.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,s.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:s=>{s.currentTarget.style.borderColor=e.colors.inputBorder,s.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",s.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!p.trim(),style:{width:"100%",marginTop:12,padding:u?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:p.trim()?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:p.trim()?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:u?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1},onMouseEnter:s=>{s.currentTarget.disabled||(s.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,s.currentTarget.style.transform="translateY(-1px)",s.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:s=>{s.currentTarget.disabled||(s.currentTarget.style.backgroundColor=e.colors.buttonBackground,s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:u?18:16,color:e.colors.buttonColor}),r?"Sending...":"Submit"]})]})}function mo({mode:e,theme:t,customStyles:o,promptText:r,placeholder:n,submitText:p,thankYouMessage:l,isLoading:u,isCheckingExisting:g=false,isSubmitted:a,phase:s="form",followUpConfig:h,followUpLoading:d=false,onFollowUpSubmit:i,error:c,existingResponse:f,isEditing:S=false,showText:x=true,showRating:B=true,voteLabels:k,options:I,allowMultiple:F=false,npsQuestion:y,npsFollowUp:w=true,npsFollowUpPlaceholder:E,npsLowLabel:T,npsHighLabel:v,enableBugFlag:L=false,bugFlagLabel:ae,enableScreenshot:$=false,onSubmit:b,onClose:N,anchorRect:V,useFixedPosition:je=false}){let De=react.useRef(null),Fe=react.useRef(null),fe=react.useRef(N);fe.current=N;let[z,Xe]=react.useState(false),[Le,ze]=react.useState("light"),{themeConfig:me}=D();react.useEffect(()=>{Xe(window.innerWidth<640);let A=window.matchMedia("(prefers-color-scheme: dark)");ze(A.matches?"dark":"light");let H=_=>ze(_.matches?"dark":"light");return A.addEventListener("change",H),()=>A.removeEventListener("change",H)},[]);let m=react.useMemo(()=>te(t,Le,me),[t,Le,me]);react.useEffect(()=>{He(m);},[m]);let he=typeof window>"u"||!V?false:window.innerHeight-V.bottom<300;react.useEffect(()=>{let A=De.current;if(!A)return;Fe.current?.focus();let H=_=>{if(_.key==="Escape"){fe.current();return}if(_.key==="Tab"){let X=A.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),Se=X[0],xe=X[X.length-1];_.shiftKey&&document.activeElement===Se?(_.preventDefault(),xe?.focus()):!_.shiftKey&&document.activeElement===xe&&(_.preventDefault(),Se?.focus());}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[]);let se=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?y||"How likely are you to recommend us?":"What do you think of this feature?",be=z?24:20,ie=e==="nps"?420:340,qe=z?"gotcha-modal-enter-center":he?"gotcha-modal-enter-above":"gotcha-modal-enter",ye=typeof window<"u"?window.innerHeight:0,K=z?{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:ie,padding:be,borderRadius:m.borders.radius.lg+2,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:9999,fontFamily:m.typography.fontFamily,...o?.modal,textAlign:"left"}:je&&V&&ye?(()=>{let A=window.innerWidth,H=24,X=V.left+V.width/2-ie/2;return {position:"fixed",left:Math.max(H,Math.min(X,A-ie-H)),width:ie,padding:be,borderRadius:m.borders.radius.lg,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:99999,fontFamily:m.typography.fontFamily,...he?{bottom:ye-V.top+8}:{top:V.bottom+8},...o?.modal,textAlign:"left"}})():{position:"absolute",left:"50%",width:ie,padding:be,borderRadius:m.borders.radius.lg,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:9999,fontFamily:m.typography.fontFamily,...he?{bottom:"100%",marginBottom:8,transform:"translateX(-50%)"}:{top:"100%",marginTop:8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"},Q=A=>z?{}:{animation:`gotcha-fade-up ${m.animation.duration.normal} ${m.animation.easing.default} both`,animationDelay:`${A*.05}s`},le=l==="Gotcha!"||l==="Thanks for your feedback!";return jsxRuntime.jsxs("div",{ref:De,role:"dialog","aria-modal":"true","aria-label":a?"Feedback submitted":void 0,"aria-labelledby":a?void 0:"gotcha-modal-title","data-gotcha":true,style:K,className:Ne("gotcha-modal",qe),children:[jsxRuntime.jsx("button",{ref:Fe,type:"button",onClick:N,"aria-label":"Close feedback form",style:{position:"absolute",top:z?10:6,right:z?10:6,width:z?40:36,height:z?40:36,border:"none",background:"transparent",outline:"none",cursor:"pointer",zIndex:10,color:m.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:m.borders.radius.sm,transition:`all ${m.animation.duration.fast} ${m.animation.easing.default}`,...o?.closeButton},onMouseEnter:A=>{A.currentTarget.style.backgroundColor=m.colors.closeButtonBg,A.currentTarget.style.color=m.colors.closeButtonHover;},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="transparent",A.currentTarget.style.color=m.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:z?16:14,height:z?16:14,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!a&&jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:z?m.typography.fontSize.lg:m.typography.fontSize.md,fontWeight:m.typography.fontWeight.semibold,paddingRight:z?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:m.typography.fontFamily,...Q(0),...o?.title},children:r||se}),a&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsxRuntime.jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:m.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${m.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...o?.successIcon},children:jsxRuntime.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:m.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:le?22:m.typography.fontSize.md,fontWeight:le?m.typography.fontWeight.bold:m.typography.fontWeight.medium,color:m.colors.text,fontFamily:le?"'Carter One', cursive":m.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...o?.successMessage},children:le?"Gotcha!":l}),le&&jsxRuntime.jsx("p",{style:{margin:"6px 0 0",fontSize:m.typography.fontSize.sm,fontWeight:m.typography.fontWeight.normal,color:m.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),c&&!a&&jsxRuntime.jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:m.borders.radius.sm,backgroundColor:m.colors.errorSurface,border:`1px solid ${m.colors.errorBorder}`,color:m.colors.error,fontSize:m.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...Q(1),...o?.errorMessage},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),c]}),s==="followUp"&&h&&i&&jsxRuntime.jsx("div",{style:Q(1),children:jsxRuntime.jsx(gt,{resolvedTheme:m,promptText:h.promptText,placeholder:h.placeholder,isLoading:d,onSubmit:i})}),s==="form"&&g&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"24px 0",...Q(1)},children:jsxRuntime.jsx(P,{size:24,color:m.colors.textSecondary})}),s==="form"&&!g&&jsxRuntime.jsxs("div",{style:Q(1),children:[e==="feedback"&&jsxRuntime.jsx(rt,{resolvedTheme:m,placeholder:n,submitText:p,isLoading:u,onSubmit:b,customStyles:o,initialValues:f?{content:f.content,rating:f.rating}:void 0,isEditing:S,showText:x,showRating:B,enableBugFlag:L,bugFlagLabel:ae,enableScreenshot:$}),e==="vote"&&jsxRuntime.jsx(nt,{resolvedTheme:m,isLoading:u,onSubmit:b,initialVote:f?.vote||void 0,isEditing:S,labels:k}),e==="nps"&&jsxRuntime.jsx(ct,{resolvedTheme:m,submitText:p,isLoading:u,onSubmit:b,showFollowUp:w,followUpPlaceholder:E,lowLabel:T,highLabel:v,customStyles:o,initialValues:f?{rating:f.rating,content:f.content}:void 0,isEditing:S}),e==="poll"&&I&&I.length>0&&jsxRuntime.jsx(it,{resolvedTheme:m,options:I,allowMultiple:F,isLoading:u,onSubmit:b,initialSelected:f?.pollSelected||void 0,isEditing:S})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[a&&"Thank you! Your feedback has been submitted.",c&&`Error: ${c}`]})]})}function pr({elementId:e,user:t,mode:o="feedback",showText:r=true,showRating:n=true,voteLabels:p,options:l,allowMultiple:u=false,npsQuestion:g,npsFollowUp:a=true,npsFollowUpPlaceholder:s,npsLowLabel:h,npsHighLabel:d,enableBugFlag:i=false,bugFlagLabel:c,enableScreenshot:f=false,onePerUser:S=false,cooldownDays:x,hideAfterSubmitDays:B,showAfterSeconds:k,showAfterScrollPercent:I,showAfterVisits:F,followUp:y,animated:w=true,position:E=J.POSITION,size:T=J.SIZE,theme:v=J.THEME,customStyles:L,visible:ae=true,showOnHover:$=J.SHOW_ON_HOVER,touchBehavior:b=J.TOUCH_BEHAVIOR,promptText:N,placeholder:V,submitText:je=J.SUBMIT_TEXT,thankYouMessage:De=J.THANK_YOU_MESSAGE,onSubmit:Fe,onOpen:fe,onClose:z,onError:Xe}){let{disabled:Le,activeModalId:ze,openModal:me,closeModal:m,defaultUser:he,client:se}=D(),{conditionsMet:be}=jo({elementId:e,showAfterSeconds:k,showAfterScrollPercent:I,showAfterVisits:F}),{isHidden:ie,markHidden:qe}=Ko({elementId:e,userId:t?.id||he?.id,hideAfterSubmitDays:B}),[ye,K]=react.useState("form"),[Q,le]=react.useState(null),[A,H]=react.useState(false),[_,X]=react.useState(0),[Se,xe]=react.useState(false),[bt,yt]=react.useState(null),[ve,St]=react.useState(false),[yo,xt]=react.useState(false),we=react.useRef(null),ke=react.useRef(),Te=react.useRef(null);react.useEffect(()=>(xt(true),St(window.innerWidth<640),()=>{clearTimeout(ke.current);}),[]),react.useEffect(()=>{X(se.getQueueLength());let C=()=>{setTimeout(()=>X(se.getQueueLength()),2e3);};return window.addEventListener("online",C),()=>window.removeEventListener("online",C)},[se]);let q=ze===e;react.useEffect(()=>{q||(K("form"),clearTimeout(ke.current));},[q]),react.useEffect(()=>{if(!q||!ve)return;let C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C;}},[q,ve]),react.useEffect(()=>{if(!$)return;let C=we.current;if(!C)return;let W=C.parentElement;if(!W)return;let ko=()=>xe(true),To=()=>xe(false);return W.addEventListener("mouseenter",ko),W.addEventListener("mouseleave",To),()=>{W.removeEventListener("mouseenter",ko),W.removeEventListener("mouseleave",To);}},[$]);let{submit:So,isLoading:vt,isCheckingExisting:wt,error:kt,existingResponse:Tt,isEditing:xo}=Wo({elementId:e,mode:o,pollOptions:l,user:t,onePerUser:S,cooldownDays:x,onSuccess:C=>{le(C.id),B&&qe(),Fe?.(C),y&&Te.current&&(y.ratingThreshold!=null&&Te.current.rating!=null&&Te.current.rating<=y.ratingThreshold||y.onNegativeVote&&Te.current.vote==="down")&&o!=="poll"?K("followUp"):(K("success"),ke.current=setTimeout(()=>{m(),K("form");},3e3));},onError:C=>{console.warn("[Gotcha] Submission failed:",C instanceof Error?C.message:C),Xe?.(C);}}),Ct=react.useCallback(()=>{if(we.current){let C=we.current.querySelector("button");yt((C??we.current).getBoundingClientRect());}me(e),fe?.();},[e,me,fe]),vo=react.useCallback(()=>{clearTimeout(ke.current),m(),K("form"),z?.();},[m,z]),Et=react.useCallback(C=>{Te.current={rating:C.rating,vote:C.vote},So(C);},[So]),Rt=react.useCallback(async C=>{if(Q){H(true);try{await se.updateResponse(Q,{content:C});}catch(W){console.warn("[Gotcha] Follow-up submission failed:",W instanceof Error?W.message:W);}finally{H(false),K("success"),ke.current=setTimeout(()=>{m(),K("form");},3e3);}}},[Q,m,se]),Bt=S&&xo?"Update":je;if(Le||!ae||ie||!be)return null;let It={"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}},wo={mode:o,theme:v,customStyles:L,promptText:N,placeholder:V,submitText:Bt,thankYouMessage:De,isLoading:vt,isCheckingExisting:S&&wt,isSubmitted:ye==="success",phase:ye,followUpConfig:y,followUpLoading:A,onFollowUpSubmit:Rt,error:kt,existingResponse:S?Tt:null,isEditing:S&&xo,showText:r,showRating:n,voteLabels:p,options:l,allowMultiple:u,npsQuestion:g,npsFollowUp:a,npsFollowUpPlaceholder:s,npsLowLabel:h,npsHighLabel:d,enableBugFlag:i,bugFlagLabel:c,enableScreenshot:f,onSubmit:Et,onClose:vo,anchorRect:bt||void 0,useFixedPosition:!ve};return jsxRuntime.jsxs("div",{ref:we,style:{...It[E],zIndex:q?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(qo,{size:T,theme:v,customStyles:L,showOnHover:$,touchBehavior:b,onClick:Ct,isOpen:q,isParentHovered:Se,animated:w,queuedCount:_}),q&&!ve&&yo&&reactDom.createPortal(jsxRuntime.jsx(mo,{...wo}),document.body),q&&ve&&yo&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},className:"gotcha-overlay-enter",onClick:vo,children:jsxRuntime.jsx("div",{onClick:C=>C.stopPropagation(),children:jsxRuntime.jsx(mo,{...wo})})}),document.body)]})}function mt({elementId:e,refreshInterval:t}){let{client:o}=D(),[r,n]=react.useState(null),[p,l]=react.useState(true),[u,g]=react.useState(null);return react.useEffect(()=>{let a=false,s=async()=>{try{let d=await o.getScore(e);a||(n(d),g(null));}catch(d){a||g(d instanceof Error?d.message:"Failed to load score");}finally{a||l(false);}};s();let h;return t&&t>0&&(h=setInterval(s,t)),()=>{a=true,h&&clearInterval(h);}},[o,e,t]),{score:r,isLoading:p,error:u}}var Sr={sm:{fontSize:11,ratingFontSize:13,starSize:13,gap:5,pillPx:8,pillPy:4,barHeight:3,iconSize:12},md:{fontSize:12.5,ratingFontSize:15,starSize:15,gap:6,pillPx:10,pillPy:5,barHeight:4,iconSize:14},lg:{fontSize:14,ratingFontSize:18,starSize:18,gap:8,pillPx:12,pillPy:6,barHeight:5,iconSize:16}};function xr({rating:e,size:t,filledColor:o,emptyColor:r}){let n=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,p=[];for(let l=1;l<=5;l++){let u=Math.min(1,Math.max(0,e-(l-1))),g=`${n}-${l}`;p.push(jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:g,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*u,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:r}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:o,clipPath:`url(#${g})`})]},l));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,t*.08),alignItems:"center"},children:p})}function vr({rate:e,height:t,filledColor:o,trackColor:r}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:t,borderRadius:t,backgroundColor:r,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:t,background:o,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function wr({size:e,color:t}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:t,style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66a4.8 4.8 0 00-.88-1.12L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})})}function kr({elementId:e,variant:t="stars",showCount:o=true,size:r="md",theme:n="auto",refreshInterval:p,style:l}){let{score:u,isLoading:g}=mt({elementId:e,refreshInterval:p}),[a,s]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let T=window.matchMedia("(prefers-color-scheme: dark)");s(T.matches?"dark":"light");let v=L=>s(L.matches?"dark":"light");return T.addEventListener("change",v),()=>T.removeEventListener("change",v)},[]);let{themeConfig:h}=D(),d=react.useMemo(()=>te(n,a,h),[n,a,h]);if(g||!u)return null;let i=Sr[r],c=d.colors.text,f=d.colors.textDisabled,S=d.colors.starFilled,x=d.colors.starEmpty,B=d.colors.voteUp,k=d.colors.starEmpty,I={display:"inline-flex",alignItems:"center",gap:i.gap,fontFamily:d.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...l},F=(T,v)=>{let L=T===1?v:`${v}s`;return `${T.toLocaleString()} ${L}`};if(t==="votes"){let{voteCount:T,positiveRate:v}=u,L=T.up+T.down;return L===0?null:jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx(wr,{size:i.iconSize,color:B}),jsxRuntime.jsxs("span",{style:{fontSize:i.ratingFontSize,fontWeight:600,color:B,fontVariantNumeric:"tabular-nums"},children:[v,"%"]}),jsxRuntime.jsx(vr,{rate:v??0,height:i.barHeight,filledColor:B,trackColor:k}),o&&jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:F(L,"vote")})]})}let{averageRating:y,totalResponses:w}=u;if(y===null||w===0)return null;let E=y.toFixed(1);return t==="compact"?jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx("svg",{width:i.starSize,height:i.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:S})}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",w.toLocaleString(),")"]})]}):t==="number"?jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:"/ 5"}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400,marginLeft:2},children:["(",F(w,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx(xr,{rating:y,size:i.starSize,filledColor:S,emptyColor:x}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",F(w,"response"),")"]})]})}function Tr(){let{client:e,disabled:t,defaultUser:o,debug:r,openModal:n,closeModal:p,activeModalId:l}=D();return {client:e,disabled:t,defaultUser:o,debug:r,submitFeedback:e.submitResponse.bind(e),openModal:n,closeModal:p,activeModalId:l}}function Cr(e){let{activeModalId:t,openModal:o,closeModal:r}=D(),n=react.useCallback(()=>o(e),[o,e]),p=react.useCallback(()=>r(),[r]);return {open:n,close:p,isOpen:t===e}}
|
|
160
|
-
exports.Gotcha=
|
|
172
|
+
`.trim()}function Qe(e){if(typeof document>"u")return;if(!document.getElementById(ao)){let o=document.createElement("link");o.rel="preconnect",o.href="https://fonts.googleapis.com",document.head.appendChild(o);let r=document.createElement("link");r.rel="preconnect",r.href="https://fonts.gstatic.com",r.crossOrigin="anonymous",document.head.appendChild(r);let s=document.createElement("link");s.id=ao,s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Carter+One&family=DM+Sans:wght@400;500;600;700&display=swap",document.head.appendChild(s);}let t=document.getElementById(so);t||(t=document.createElement("style"),t.id=so,document.head.appendChild(t)),t.textContent=Ir(e);}var co=react.createContext(null),Fr={};function Pr({apiKey:e,children:t,baseUrl:o,debug:r=false,disabled:s=false,defaultUser:a,themeConfig:l}){let[n,g]=react.useState(null);o&&!o.startsWith("https://")&&!o.startsWith("/")&&!o.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",o);let c=react.useMemo(()=>ro({apiKey:e,baseUrl:o,debug:r}),[e,o,r]),i=react.useMemo(()=>a??Fr,[JSON.stringify(a)]);react.useEffect(()=>{let m=ne("light","light",l);Qe(m);},[l]),react.useEffect(()=>(Kt(),()=>Qt()),[]),react.useEffect(()=>{c.flushQueue();let m=()=>c.flushQueue();return window.addEventListener("online",m),()=>window.removeEventListener("online",m)},[c]);let p=react.useCallback(m=>{g(m);},[]),u=react.useCallback(()=>{g(null);},[]),d=react.useMemo(()=>({client:c,disabled:s,defaultUser:i,debug:r,activeModalId:n,openModal:p,closeModal:u,themeConfig:l}),[c,s,i,r,n,p,u,l]);return jsxRuntime.jsx(co.Provider,{value:d,children:t})}function L(){let e=react.useContext(co);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function Ur(e,t){let o=new Date(e).getTime();if(isNaN(o))return true;let r=Date.now()-o,s=t*24*60*60*1e3;return r>=s}function uo(e){let{client:t,defaultUser:o}=L(),[r,s]=react.useState(false),[a,l]=react.useState(false),[n,g]=react.useState(null),[c,i]=react.useState(null);return react.useEffect(()=>{process.env.NODE_ENV!=="production"&&e.cooldownDays&&!e.onePerUser&&console.warn("[Gotcha] cooldownDays has no effect without onePerUser=true");let u=e.user?.id||o?.id;if(!u||!e.onePerUser){i(null);return}let d=false;return (async()=>{l(true);try{let f=await t.checkExistingResponse(e.elementId,u);d||(f&&e.cooldownDays&&e.cooldownDays>0&&Ur(f.createdAt,e.cooldownDays)?i(null):i(f));}catch{d||i(null);}finally{d||l(false);}})(),()=>{d=true;}},[t,e.elementId,e.user?.id,o?.id,e.onePerUser,e.cooldownDays]),{submit:react.useCallback(async u=>{s(true),g(null);try{let d=e.user?.id||o?.id,m;return e.onePerUser&&c&&d?m=await t.updateResponse(c.id,{content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollSelected:u.pollSelected},d):m=await t.submitResponse({elementId:e.elementId,mode:e.mode,content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollOptions:e.pollOptions,pollSelected:u.pollSelected,isBug:u.isBug,screenshot:u.screenshot,user:{...o,...e.user}}),e.onePerUser&&i({id:m.id,mode:e.mode,content:u.content??null,title:u.title??null,rating:u.rating??null,vote:u.vote??null,pollSelected:u.pollSelected??null,createdAt:m.createdAt}),e.onSuccess?.(m),m}catch(d){let m=d instanceof Error?d.message:"Something went wrong";throw g(m),e.onError?.(d instanceof Error?d:new Error(m)),d}finally{s(false);}},[t,o,e,c]),isLoading:r,isCheckingExisting:a,error:n,existingResponse:c,isEditing:!!c,clearError:()=>g(null)}}function fo(e,t){return `${V.HIDDEN_UNTIL}_${e}_${t}`}function go(e,t,o){if(!o||o<=0)return false;let r=fo(e,t),s=te(r);return s?new Date(s).getTime()>Date.now():false}function po(e){let{elementId:t,userId:o,hideAfterSubmitDays:r}=e,s=react.useMemo(()=>o||Ye(),[o]),[a,l]=react.useState(()=>go(t,s,r));react.useEffect(()=>{l(go(t,s,r));},[t,s,r]);let n=react.useCallback(()=>{if(!r||r<=0)return;let g=fo(t,s),c=new Date(Date.now()+r*24*60*60*1e3);oe(g,c.toISOString()),l(true);},[t,s,r]);return {isHidden:a,markHidden:n}}function Hr(e){return `${V.VISIT_COUNT}_${e}`}function ho(e){let{elementId:t,showAfterSeconds:o,showAfterScrollPercent:r,showAfterVisits:s}=e,a=o!=null||r!=null||s!=null,[l,n]=react.useState(!o),[g,c]=react.useState(!r),[i]=react.useState(()=>{if(!s)return true;let p=Hr(t),d=parseInt(te(p)||"0",10)+1;return oe(p,String(d)),d>=s});return react.useEffect(()=>{if(!o||o<=0)return;let p=Date.now(),u=o*1e3,d=()=>{Date.now()-p>=u?n(true):m=setTimeout(d,Math.min(1e3,u-(Date.now()-p)));},m=setTimeout(d,Math.min(1e3,u));return ()=>clearTimeout(m)},[o]),react.useEffect(()=>{if(!r||r<=0)return;let p=()=>{let u=document.documentElement.scrollHeight,d=window.innerHeight;if(u<=d){c(true);return}(window.scrollY+d)/u*100>=r&&c(true);};if(p(),!g)return window.addEventListener("scroll",p,{passive:true}),()=>window.removeEventListener("scroll",p)},[r,g]),{conditionsMet:!a||l&&g&&i}}function Je(...e){return e.filter(Boolean).join(" ")}var z=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,bo=(e,t)=>{let o={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return t?o[e].mobile:o[e].desktop};function Vr(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yo({size:e,theme:t,customStyles:o,showOnHover:r,touchBehavior:s,onClick:a,isOpen:l,isParentHovered:n=false,animated:g=true,queuedCount:c=0}){let[i,p]=react.useState(false),[u,d]=react.useState(false),[m,f]=react.useState(Vr),[h,b]=react.useState(false),[v,w]=react.useState(false),[k,R]=react.useState(false),{themeConfig:S}=L();react.useEffect(()=>{if(p(z()),typeof window>"u")return;let $=window.matchMedia("(prefers-color-scheme: dark)"),O=Y=>f(Y.matches?"dark":"light");return $.addEventListener("change",O),()=>$.removeEventListener("change",O)},[]);let E=l?true:!i&&r?n:i&&s==="tap-to-reveal"?u:true;react.useEffect(()=>{if(E&&!k){let $=setTimeout(()=>R(true),600);return ()=>clearTimeout($)}},[E,k]);let A=()=>{if(i&&s==="tap-to-reveal"&&!u){d(true);return}a();},I=bo(e,i),T=react.useMemo(()=>ne(t,m,S),[t,m,S]),P=()=>E?v?"scale(0.95)":h?"scale(1.08)":"scale(1)":"scale(0.6)",ie={width:I,height:I,borderRadius:"50%",border:T.colors.glassBorder,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:T.colors.glassBackground,backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",color:T.colors.glassColor,boxShadow:h?T.colors.glassHoverShadow:T.colors.glassShadow,transition:k?`all 0.3s ${T.animation.easing.spring}`:"none",opacity:E?1:0,transform:P(),filter:v?"brightness(0.95)":"brightness(1)",pointerEvents:E?"auto":"none",...g&&E&&!k?{animation:"gotcha-bubble-pop 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both, gotcha-arrive-glow 1200ms ease-in-out 600ms both"}:{},...o?.button};return jsxRuntime.jsxs("button",{type:"button",onClick:A,onMouseEnter:()=>b(true),onMouseLeave:()=>{b(false),w(false);},onMouseDown:()=>w(true),onMouseUp:()=>w(false),onTouchStart:()=>w(true),onTouchEnd:()=>w(false),style:ie,className:Je("gotcha-button",l&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":l,"aria-haspopup":"dialog",children:[jsxRuntime.jsx(jr,{size:I*.65,animated:g}),c>0&&jsxRuntime.jsx("div",{"aria-label":`${c} queued`,style:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",backgroundColor:T.colors.warning,border:"1.5px solid rgba(255,255,255,0.9)"}})]})}function jr({size:e,animated:t=true}){let[o,r]=react.useState(false);return react.useEffect(()=>{r(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:"'Carter One', cursive",fontSize:e,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",marginTop:e*.05,marginRight:e*.05,userSelect:"none",opacity:t?0:o?1:0,...t&&o?{animation:"gotcha-letter-in 350ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 200ms both"}:{}},children:"G"})}function N({size:e=16,color:t="currentColor"}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function So({src:e,onRemove:t,resolvedTheme:o}){return jsxRuntime.jsxs("div",{style:{position:"relative",marginTop:10,borderRadius:o.borders.radius.md,overflow:"hidden",border:`1px solid ${o.colors.border}`},children:[jsxRuntime.jsx("img",{src:e,alt:"Screenshot",style:{display:"block",width:"100%",maxHeight:120,objectFit:"cover"}}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":"Remove screenshot",style:{position:"absolute",top:4,right:4,width:22,height:22,borderRadius:"50%",border:"none",backgroundColor:"rgba(0,0,0,0.6)",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,lineHeight:1},children:jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]})}function qo({resolvedTheme:e,placeholder:t,submitText:o,isLoading:r,onSubmit:s,customStyles:a,initialValues:l,isEditing:n=false,showText:g=true,showRating:c=true,enableBugFlag:i=false,bugFlagLabel:p,enableScreenshot:u=false}){let[d,m]=react.useState(l?.content||""),[f,h]=react.useState(l?.rating??null),[b,v]=react.useState(false),[w,k]=react.useState(false),[R,S]=react.useState(null),[E,A]=react.useState(false),[I,T]=react.useState(false);react.useEffect(()=>{k(z());},[]),react.useEffect(()=>{l?.content!==void 0&&m(l.content||""),l?.rating!==void 0&&h(l.rating??null);},[l?.content,l?.rating]);let P=g&&c?d.trim().length>0||f!==null:g?d.trim().length>0:c?f!==null:false,ie=async()=>{A(true),T(false);try{let{captureScreenshot:x}=await Promise.resolve().then(()=>(Yo(),jo)),fe=await x();fe?S(fe):(T(!0),setTimeout(()=>T(!1),3e3));}catch{T(true),setTimeout(()=>T(false),3e3);}finally{A(false);}},$=x=>{x.preventDefault(),P&&s({content:g&&d.trim()?d.trim():void 0,rating:c&&f!==null?f:void 0,isBug:b||void 0,screenshot:R||void 0});},O={width:"100%",padding:w?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:w?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:w?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)",...a?.input},Y={width:"100%",padding:w?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:e.colors.buttonBackground,color:e.colors.buttonColor,fontSize:w?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",...a?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:$,children:[c&&jsxRuntime.jsx("div",{style:{marginBottom:g?w?16:12:0,...g?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(ys,{value:f,onChange:h,theme:e,isTouch:w,large:!g})}),g&&jsxRuntime.jsx("textarea",{value:d,onChange:x=>m(x.target.value),placeholder:t||"Share your thoughts...",maxLength:5e3,style:O,disabled:r,"aria-label":"Your feedback",onFocus:x=>{x.currentTarget.style.borderColor=e.colors.inputBorderFocus,x.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,x.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:x=>{x.currentTarget.style.borderColor=e.colors.inputBorder,x.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",x.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),i&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":b,onClick:()=>v(!b),style:{display:"flex",alignItems:"center",gap:7,width:"100%",marginTop:10,padding:"7px 10px",border:`1px solid ${b?e.colors.warningBorder:e.colors.border}`,borderRadius:7,backgroundColor:b?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...a?.bugFlag},onMouseEnter:x=>{b||(x.currentTarget.style.backgroundColor=e.colors.surfaceHover===e.colors.inputBackgroundFocus?"rgba(0,0,0,0.02)":e.colors.surfaceHover);},onMouseLeave:x=>{b||(x.currentTarget.style.backgroundColor="transparent");},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:b?e.colors.warningActive:e.colors.textDisabled,strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:`stroke ${e.animation.duration.fast}`},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:b?e.typography.fontWeight.medium:e.typography.fontWeight.normal,color:b?e.colors.warningActive:e.colors.textDisabled,transition:`color ${e.animation.duration.fast}`,letterSpacing:"0.01em"},children:b?"Issue reported":p||"Report an issue"}),jsxRuntime.jsx("div",{style:{marginLeft:"auto",width:28,height:16,borderRadius:8,backgroundColor:b?e.colors.warning:e.colors.border,position:"relative",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,flexShrink:0},children:jsxRuntime.jsx("div",{style:{position:"absolute",top:2,left:b?14:2,width:12,height:12,borderRadius:"50%",backgroundColor:b?"#ffffff":e.colors.textDisabled,transition:`left ${e.animation.duration.fast} ${e.animation.easing.default}, background-color ${e.animation.duration.fast}`,boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}})})]}),i&&u&&b&&!R&&jsxRuntime.jsxs("button",{type:"button",onClick:ie,disabled:E,style:{display:"flex",alignItems:"center",gap:6,width:"100%",marginTop:8,padding:"7px 10px",border:`1px solid ${e.colors.border}`,borderRadius:7,backgroundColor:"transparent",cursor:E?"not-allowed":"pointer",fontFamily:e.typography.fontFamily,fontSize:12,color:e.colors.textSecondary,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},onMouseEnter:x=>{x.currentTarget.style.backgroundColor=e.colors.surfaceHover;},onMouseLeave:x=>{x.currentTarget.style.backgroundColor="transparent";},children:[E?jsxRuntime.jsx(N,{size:14,color:e.colors.textSecondary}):jsxRuntime.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"10",r:"3"}),jsxRuntime.jsx("path",{d:"M2 17l4-4 3 3 4-4 9 9"})]}),E?"Capturing...":"Capture screenshot"]}),I&&jsxRuntime.jsx("div",{style:{fontSize:11,color:e.colors.textSecondary,marginTop:4,padding:"4px 0",fontFamily:e.typography.fontFamily},children:"Screenshot capture unavailable"}),i&&u&&b&&R&&jsxRuntime.jsx(So,{src:R,onRemove:()=>S(null),resolvedTheme:e}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!P,style:{...Y,marginTop:12,opacity:r?.8:1,backgroundColor:P?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:P?e.colors.buttonColor:e.colors.buttonColorDisabled,display:"flex",alignItems:"center",justifyContent:"center",gap:8,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:x=>{x.currentTarget.disabled||(x.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,x.currentTarget.style.transform="translateY(-1px)",x.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:x=>{x.currentTarget.disabled||(x.currentTarget.style.backgroundColor=e.colors.buttonBackground,x.currentTarget.style.transform="translateY(0)",x.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(N,{size:w?18:16,color:e.colors.buttonColor}),r?n?"Updating...":"Submitting...":n?"Update":o]})]})}function ys({value:e,onChange:t,theme:o,isTouch:r,large:s=false}){let[a,l]=react.useState(null),[n,g]=react.useState(null),c=react.useRef(),i=s?r?36:28:r?28:18,p=s?r?8:5:r?8:3;react.useEffect(()=>()=>{clearTimeout(c.current);},[]);let u=d=>{g(d),t(d),clearTimeout(c.current),c.current=setTimeout(()=>g(null),300);};return jsxRuntime.jsx("div",{style:{display:"flex",gap:s?r?8:6:r?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(d=>{let m=(a??e??0)>=d;return jsxRuntime.jsx("button",{type:"button",onClick:()=>u(d),onMouseEnter:()=>l(d),onMouseLeave:()=>l(null),"aria-label":`Rate ${d} out of 5`,"aria-pressed":e===d,style:{background:"none",border:"none",cursor:"pointer",padding:p,color:m?o.colors.starFilled:o.colors.starEmpty,transition:`color 0.15s ${o.animation.easing.default}`,transform:n===d?"scale(1)":a!==null&&a>=d?"scale(1.1)":"scale(1)",animation:n===d?`gotcha-star-pulse 0.3s ${o.animation.easing.spring}`:"none",filter:m?`drop-shadow(0 0 3px ${o.colors.starFilled}40)`:"none",transitionDelay:`${(d-1)*30}ms`},children:jsxRuntime.jsx("svg",{width:i,height:i,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},d)})})}function Ko({resolvedTheme:e,isLoading:t,onSubmit:o,initialVote:r,isEditing:s=false,labels:a}){let[l,n]=react.useState(false),[g,c]=react.useState(r||null),[i,p]=react.useState(r||null);react.useEffect(()=>{n(z());},[]),react.useEffect(()=>{r!==void 0&&(p(r),c(r));},[r]),react.useEffect(()=>{!t&&!s&&c(null);},[t,s]);let u=f=>{c(f),o({vote:f});},d=f=>{let h=i===f,b=f==="up"?e.colors.voteUp:e.colors.voteDown,v=f==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,w=f==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,overflow:"hidden",padding:l?"14px 18px":"10px 14px",border:h?`2px solid ${w}`:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.lg-2,background:h?`linear-gradient(135deg, ${v}, ${v})`:e.colors.surface,color:h?b:e.colors.textSecondary,fontSize:l?28:24,fontFamily:e.typography.fontFamily,cursor:t?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:l?10:8}},m=l?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:l?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>u("up"),disabled:t,style:d("up"),"aria-label":"Vote up - I like this","aria-pressed":i==="up",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(N,{size:m,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ws,{size:m}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:a?.up||(i==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u("down"),disabled:t,style:d("down"),"aria-label":"Vote down - I don't like this","aria-pressed":i==="down",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(N,{size:m,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ss,{size:m}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:a?.down||(i==="down"?"Disliked":"Dislike")})]})})]})}function ws({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function Ss({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function Jo({resolvedTheme:e,options:t,allowMultiple:o,isLoading:r,onSubmit:s,initialSelected:a,isEditing:l=false}){let[n,g]=react.useState(a||[]),[c,i]=react.useState(false);react.useEffect(()=>{i(z());},[]),react.useEffect(()=>{a&&g(a);},[a]);let p=m=>{g(o?f=>f.includes(m)?f.filter(h=>h!==m):[...f,m]:f=>f.includes(m)?[]:[m]);},u=()=>{n.length!==0&&s({pollSelected:n});},d=(m,f)=>{let h=n.includes(m);return {width:"100%",padding:c?"12px 14px":"9px 12px",border:`1px solid ${h?e.colors.pollSelectedBorder:e.colors.pollBorder}`,borderRadius:e.borders.radius.lg-2,backgroundColor:h?e.colors.pollSelectedBackground:e.colors.pollBackground,color:h?e.colors.pollSelectedColor:e.colors.pollColor,fontSize:c?15:e.typography.fontSize.sm,fontWeight:h?e.typography.fontWeight.semibold:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8,animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${f*.05}s`}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:c?8:6},role:"group","aria-label":o?"Select one or more options":"Select an option",children:t.map((m,f)=>{let h=n.includes(m);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>p(m),disabled:r,style:d(m,f),"aria-pressed":h,onMouseEnter:b=>{r||(b.currentTarget.style.transform="translateX(2px)");},onMouseLeave:b=>{b.currentTarget.style.transform="translateX(0)";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:o?4:"50%",border:`2px solid ${h?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:h?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast}`},children:h&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),m]},m)})}),jsxRuntime.jsxs("button",{type:"button",onClick:u,disabled:r||n.length===0,style:{width:"100%",marginTop:12,padding:c?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:n.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:n.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:c?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||n.length===0?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=n.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(N,{size:c?18:16,color:e.colors.buttonColor}),r?l?"Updating...":"Submitting...":l?"Update":"Submit"]})]})}function er({resolvedTheme:e,submitText:t,isLoading:o,onSubmit:r,customStyles:s,showFollowUp:a=true,followUpPlaceholder:l,lowLabel:n="Not likely",highLabel:g="Very likely",initialValues:c,isEditing:i=false}){let[p,u]=react.useState(c?.rating??null),[d,m]=react.useState(c?.content||""),[f,h]=react.useState(false),[b,v]=react.useState(null);react.useEffect(()=>{h(z());},[]),react.useEffect(()=>{c?.rating!==void 0&&u(c.rating??null),c?.content!==void 0&&m(c.content||"");},[c?.rating,c?.content]);let w=p!==null,k=e.colors.npsColors;return jsxRuntime.jsxs("form",{onSubmit:S=>{S.preventDefault(),w&&r({rating:p??void 0,content:a&&d.trim()?d.trim():void 0});},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:f?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(S,E)=>{let A=p===E,I=b===E,T=k[E];return jsxRuntime.jsx("button",{type:"button",onClick:()=>u(E),onMouseEnter:()=>v(E),onMouseLeave:()=>v(null),"aria-label":`Score ${E} out of 10`,"aria-pressed":A,style:{flex:1,minWidth:0,height:f?34:32,borderRadius:e.borders.radius.sm,border:A?`2px solid ${T}`:`1.5px solid ${T}25`,backgroundColor:A?T:I?`${T}25`:`${T}0c`,color:A?"#fff":I?T:`${T}bb`,fontSize:12,fontWeight:A?e.typography.fontWeight.bold:e.typography.fontWeight.semibold,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`all 0.2s ${e.animation.easing.spring}`,transform:A?"scale(1.08)":I?"scale(1.04)":"scale(1)",boxShadow:A?`0 0 12px ${T}40`:"none",...s?.npsButton,...A?s?.npsButtonSelected:{}},children:E},E)})}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...s?.npsLabels},children:[jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:n}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g})]})]}),a&&p!==null&&jsxRuntime.jsx("textarea",{value:d,onChange:S=>m(S.target.value),placeholder:l||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:f?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:f?80:60,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,animation:`gotcha-expand-in 0.3s ${e.animation.easing.default} both`,overflow:"hidden",...s?.input},disabled:o,"aria-label":"Follow-up feedback",onFocus:S=>{S.currentTarget.style.borderColor=e.colors.inputBorderFocus,S.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,S.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:S=>{S.currentTarget.style.borderColor=e.colors.inputBorder,S.currentTarget.style.boxShadow="none",S.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!w,style:{width:"100%",padding:f?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:w?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:w?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",opacity:o?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...o?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{},...s?.submitButton},onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,S.currentTarget.style.transform="translateY(-1px)",S.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:S=>{S.currentTarget.disabled||(S.currentTarget.style.backgroundColor=w?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,S.currentTarget.style.transform="translateY(0)",S.currentTarget.style.boxShadow="none");},children:[o&&jsxRuntime.jsx(N,{size:f?18:16,color:e.colors.buttonColor}),o?i?"Updating...":"Submitting...":i?"Update":t]})]})}function rr({resolvedTheme:e,promptText:t,placeholder:o,isLoading:r,onSubmit:s}){let[a,l]=react.useState(""),[n,g]=react.useState(false);return react.useEffect(()=>{g(z());},[]),jsxRuntime.jsxs("form",{onSubmit:i=>{i.preventDefault(),a.trim()&&s(a.trim());},children:[jsxRuntime.jsx("p",{style:{margin:"0 0 12px 0",fontSize:e.typography.fontSize.sm,color:e.colors.textSecondary,lineHeight:1.4,fontFamily:e.typography.fontFamily},children:t}),jsxRuntime.jsx("textarea",{value:a,onChange:i=>l(i.target.value),placeholder:o||"Tell us more...",maxLength:5e3,disabled:r,"aria-label":"Follow-up feedback",style:{width:"100%",padding:n?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:n?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:n?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)"},onFocus:i=>{i.currentTarget.style.borderColor=e.colors.inputBorderFocus,i.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,i.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:i=>{i.currentTarget.style.borderColor=e.colors.inputBorder,i.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",i.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!a.trim(),style:{width:"100%",marginTop:12,padding:n?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:a.trim()?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:a.trim()?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:n?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1},onMouseEnter:i=>{i.currentTarget.disabled||(i.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,i.currentTarget.style.transform="translateY(-1px)",i.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:i=>{i.currentTarget.disabled||(i.currentTarget.style.backgroundColor=e.colors.buttonBackground,i.currentTarget.style.transform="translateY(0)",i.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(N,{size:n?18:16,color:e.colors.buttonColor}),r?"Sending...":"Submit"]})]})}function Pt({mode:e,theme:t,customStyles:o,promptText:r,placeholder:s,submitText:a,thankYouMessage:l,isLoading:n,isCheckingExisting:g=false,isSubmitted:c,phase:i="form",followUpConfig:p,followUpLoading:u=false,onFollowUpSubmit:d,error:m,existingResponse:f,isEditing:h=false,showText:b=true,showRating:v=true,voteLabels:w,options:k,allowMultiple:R=false,npsQuestion:S,npsFollowUp:E=true,npsFollowUpPlaceholder:A,npsLowLabel:I,npsHighLabel:T,enableBugFlag:P=false,bugFlagLabel:ie,enableScreenshot:$=false,onSubmit:O,onClose:Y,anchorRect:x,useFixedPosition:fe=false}){let _e=react.useRef(null),He=react.useRef(null),we=react.useRef(Y);we.current=Y;let[G,ct]=react.useState(false),[We,Ve]=react.useState("light"),{themeConfig:Se}=L();react.useEffect(()=>{ct(window.innerWidth<640);let M=window.matchMedia("(prefers-color-scheme: dark)");Ve(M.matches?"dark":"light");let _=H=>Ve(H.matches?"dark":"light");return M.addEventListener("change",_),()=>M.removeEventListener("change",_)},[]);let y=react.useMemo(()=>ne(t,We,Se),[t,We,Se]);react.useEffect(()=>{Qe(y);},[y]);let xe=typeof window>"u"||!x?false:window.innerHeight-x.bottom<300;react.useEffect(()=>{let M=_e.current;if(!M)return;He.current?.focus();let _=H=>{if(H.key==="Escape"){we.current();return}if(H.key==="Tab"){let J=M.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),Ee=J[0],ke=J[J.length-1];H.shiftKey&&document.activeElement===Ee?(H.preventDefault(),ke?.focus()):!H.shiftKey&&document.activeElement===ke&&(H.preventDefault(),Ee?.focus());}};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[]);let le=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?S||"How likely are you to recommend us?":"What do you think of this feature?",ve=G?24:20,ce=e==="nps"?420:340,ut=G?"gotcha-modal-enter-center":xe?"gotcha-modal-enter-above":"gotcha-modal-enter",Te=typeof window<"u"?window.innerHeight:0,q=G?{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:ce,padding:ve,borderRadius:y.borders.radius.lg+2,background:y.colors.backgroundGradient,color:y.colors.text,boxShadow:y.shadows.modal,border:`${y.borders.width}px solid ${y.colors.border}`,zIndex:9999,fontFamily:y.typography.fontFamily,...o?.modal,textAlign:"left"}:fe&&x&&Te?(()=>{let M=window.innerWidth,_=24,J=x.left+x.width/2-ce/2;return {position:"fixed",left:Math.max(_,Math.min(J,M-ce-_)),width:ce,padding:ve,borderRadius:y.borders.radius.lg,background:y.colors.backgroundGradient,color:y.colors.text,boxShadow:y.shadows.modal,border:`${y.borders.width}px solid ${y.colors.border}`,zIndex:99999,fontFamily:y.typography.fontFamily,...xe?{bottom:Te-x.top+8}:{top:x.bottom+8},...o?.modal,textAlign:"left"}})():{position:"absolute",left:"50%",width:ce,padding:ve,borderRadius:y.borders.radius.lg,background:y.colors.backgroundGradient,color:y.colors.text,boxShadow:y.shadows.modal,border:`${y.borders.width}px solid ${y.colors.border}`,zIndex:9999,fontFamily:y.typography.fontFamily,...xe?{bottom:"100%",marginBottom:8,transform:"translateX(-50%)"}:{top:"100%",marginTop:8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"},K=M=>G?{}:{animation:`gotcha-fade-up ${y.animation.duration.normal} ${y.animation.easing.default} both`,animationDelay:`${M*.05}s`},ue=l==="Gotcha!"||l==="Thanks for your feedback!";return jsxRuntime.jsxs("div",{ref:_e,role:"dialog","aria-modal":"true","aria-label":c?"Feedback submitted":void 0,"aria-labelledby":c?void 0:"gotcha-modal-title","data-gotcha":true,style:q,className:Je("gotcha-modal",ut),children:[jsxRuntime.jsx("button",{ref:He,type:"button",onClick:Y,"aria-label":"Close feedback form",style:{position:"absolute",top:G?10:6,right:G?10:6,width:G?40:36,height:G?40:36,border:"none",background:"transparent",outline:"none",cursor:"pointer",zIndex:10,color:y.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:y.borders.radius.sm,transition:`all ${y.animation.duration.fast} ${y.animation.easing.default}`,...o?.closeButton},onMouseEnter:M=>{M.currentTarget.style.backgroundColor=y.colors.closeButtonBg,M.currentTarget.style.color=y.colors.closeButtonHover;},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="transparent",M.currentTarget.style.color=y.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:G?16:14,height:G?16:14,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!c&&jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:G?y.typography.fontSize.lg:y.typography.fontSize.md,fontWeight:y.typography.fontWeight.semibold,paddingRight:G?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:y.typography.fontFamily,...K(0),...o?.title},children:r||le}),c&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsxRuntime.jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:y.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${y.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...o?.successIcon},children:jsxRuntime.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:y.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:ue?22:y.typography.fontSize.md,fontWeight:ue?y.typography.fontWeight.bold:y.typography.fontWeight.medium,color:y.colors.text,fontFamily:ue?"'Carter One', cursive":y.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...o?.successMessage},children:ue?"Gotcha!":l}),ue&&jsxRuntime.jsx("p",{style:{margin:"6px 0 0",fontSize:y.typography.fontSize.sm,fontWeight:y.typography.fontWeight.normal,color:y.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),m&&!c&&jsxRuntime.jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:y.borders.radius.sm,backgroundColor:y.colors.errorSurface,border:`1px solid ${y.colors.errorBorder}`,color:y.colors.error,fontSize:y.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...K(1),...o?.errorMessage},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),m]}),i==="followUp"&&p&&d&&jsxRuntime.jsx("div",{style:K(1),children:jsxRuntime.jsx(rr,{resolvedTheme:y,promptText:p.promptText,placeholder:p.placeholder,isLoading:u,onSubmit:d})}),i==="form"&&g&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"24px 0",...K(1)},children:jsxRuntime.jsx(N,{size:24,color:y.colors.textSecondary})}),i==="form"&&!g&&jsxRuntime.jsxs("div",{style:K(1),children:[e==="feedback"&&jsxRuntime.jsx(qo,{resolvedTheme:y,placeholder:s,submitText:a,isLoading:n,onSubmit:O,customStyles:o,initialValues:f?{content:f.content,rating:f.rating}:void 0,isEditing:h,showText:b,showRating:v,enableBugFlag:P,bugFlagLabel:ie,enableScreenshot:$}),e==="vote"&&jsxRuntime.jsx(Ko,{resolvedTheme:y,isLoading:n,onSubmit:O,initialVote:f?.vote||void 0,isEditing:h,labels:w}),e==="nps"&&jsxRuntime.jsx(er,{resolvedTheme:y,submitText:a,isLoading:n,onSubmit:O,showFollowUp:E,followUpPlaceholder:A,lowLabel:I,highLabel:T,customStyles:o,initialValues:f?{rating:f.rating,content:f.content}:void 0,isEditing:h}),e==="poll"&&k&&k.length>0&&jsxRuntime.jsx(Jo,{resolvedTheme:y,options:k,allowMultiple:R,isLoading:n,onSubmit:O,initialSelected:f?.pollSelected||void 0,isEditing:h})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[c&&"Thank you! Your feedback has been submitted.",m&&`Error: ${m}`]})]})}function Ts({elementId:e,user:t,mode:o="feedback",showText:r=true,showRating:s=true,voteLabels:a,options:l,allowMultiple:n=false,npsQuestion:g,npsFollowUp:c=true,npsFollowUpPlaceholder:i,npsLowLabel:p,npsHighLabel:u,enableBugFlag:d=false,bugFlagLabel:m,enableScreenshot:f=false,onePerUser:h=false,cooldownDays:b,hideAfterSubmitDays:v,showAfterSeconds:w,showAfterScrollPercent:k,showAfterVisits:R,followUp:S,animated:E=true,position:A=ee.POSITION,size:I=ee.SIZE,theme:T=ee.THEME,customStyles:P,visible:ie=true,showOnHover:$=ee.SHOW_ON_HOVER,touchBehavior:O=ee.TOUCH_BEHAVIOR,promptText:Y,placeholder:x,submitText:fe=ee.SUBMIT_TEXT,thankYouMessage:_e=ee.THANK_YOU_MESSAGE,onSubmit:He,onOpen:we,onClose:G,onError:ct}){let{disabled:We,activeModalId:Ve,openModal:Se,closeModal:y,defaultUser:xe,client:le}=L(),{conditionsMet:ve}=ho({elementId:e,showAfterSeconds:w,showAfterScrollPercent:k,showAfterVisits:R}),{isHidden:ce,markHidden:ut}=po({elementId:e,userId:t?.id||xe?.id,hideAfterSubmitDays:v}),[Te,q]=react.useState("form"),[K,ue]=react.useState(null),[M,_]=react.useState(false),[H,J]=react.useState(0),[Ee,ke]=react.useState(false),[lr,cr]=react.useState(null),[Ce,ur]=react.useState(false),[Nt,dr]=react.useState(false),Re=react.useRef(null),Ae=react.useRef(),Ie=react.useRef(null);react.useEffect(()=>(dr(true),ur(window.innerWidth<640),()=>{clearTimeout(Ae.current);}),[]),react.useEffect(()=>{J(le.getQueueLength());let C=()=>{setTimeout(()=>J(le.getQueueLength()),2e3);};return window.addEventListener("online",C),()=>window.removeEventListener("online",C)},[le]);let Z=Ve===e;react.useEffect(()=>{Z||(q("form"),clearTimeout(Ae.current));},[Z]),react.useEffect(()=>{if(!Z||!Ce)return;let C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C;}},[Z,Ce]),react.useEffect(()=>{if(!$)return;let C=Re.current;if(!C)return;let W=C.parentElement;if(!W)return;let _t=()=>ke(true),Ht=()=>ke(false);return W.addEventListener("mouseenter",_t),W.addEventListener("mouseleave",Ht),()=>{W.removeEventListener("mouseenter",_t),W.removeEventListener("mouseleave",Ht);}},[$]);let{submit:Ut,isLoading:gr,isCheckingExisting:fr,error:pr,existingResponse:mr,isEditing:$t}=uo({elementId:e,mode:o,pollOptions:l,user:t,onePerUser:h,cooldownDays:b,onSuccess:C=>{ue(C.id),v&&ut(),He?.(C),S&&Ie.current&&(S.ratingThreshold!=null&&Ie.current.rating!=null&&Ie.current.rating<=S.ratingThreshold||S.onNegativeVote&&Ie.current.vote==="down")&&o!=="poll"?q("followUp"):(q("success"),Ae.current=setTimeout(()=>{y(),q("form");},3e3));},onError:C=>{console.warn("[Gotcha] Submission failed:",C instanceof Error?C.message:C),ct?.(C);}}),hr=react.useCallback(()=>{if(Re.current){let C=Re.current.querySelector("button");cr((C??Re.current).getBoundingClientRect());}Se(e),we?.();},[e,Se,we]),zt=react.useCallback(()=>{clearTimeout(Ae.current),y(),q("form"),G?.();},[y,G]),br=react.useCallback(C=>{Ie.current={rating:C.rating,vote:C.vote},Ut(C);},[Ut]),yr=react.useCallback(async C=>{if(K){_(true);try{await le.updateResponse(K,{content:C});}catch(W){console.warn("[Gotcha] Follow-up submission failed:",W instanceof Error?W.message:W);}finally{_(false),q("success"),Ae.current=setTimeout(()=>{y(),q("form");},3e3);}}},[K,y,le]),wr=h&&$t?"Update":fe;if(We||!ie||ce||!ve)return null;let Sr={"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}},Ot={mode:o,theme:T,customStyles:P,promptText:Y,placeholder:x,submitText:wr,thankYouMessage:_e,isLoading:gr,isCheckingExisting:h&&fr,isSubmitted:Te==="success",phase:Te,followUpConfig:S,followUpLoading:M,onFollowUpSubmit:yr,error:pr,existingResponse:h?mr:null,isEditing:h&&$t,showText:r,showRating:s,voteLabels:a,options:l,allowMultiple:n,npsQuestion:g,npsFollowUp:c,npsFollowUpPlaceholder:i,npsLowLabel:p,npsHighLabel:u,enableBugFlag:d,bugFlagLabel:m,enableScreenshot:f,onSubmit:br,onClose:zt,anchorRect:lr||void 0,useFixedPosition:!Ce};return jsxRuntime.jsxs("div",{ref:Re,style:{...Sr[A],zIndex:Z?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(yo,{size:I,theme:T,customStyles:P,showOnHover:$,touchBehavior:O,onClick:hr,isOpen:Z,isParentHovered:Ee,animated:E,queuedCount:H}),Z&&!Ce&&Nt&&reactDom.createPortal(jsxRuntime.jsx(Pt,{...Ot}),document.body),Z&&Ce&&Nt&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},className:"gotcha-overlay-enter",onClick:zt,children:jsxRuntime.jsx("div",{onClick:C=>C.stopPropagation(),children:jsxRuntime.jsx(Pt,{...Ot})})}),document.body)]})}function ar({elementId:e,refreshInterval:t}){let{client:o}=L(),[r,s]=react.useState(null),[a,l]=react.useState(true),[n,g]=react.useState(null);return react.useEffect(()=>{let c=false,i=async()=>{try{let u=await o.getScore(e);c||(s(u),g(null));}catch(u){c||g(u instanceof Error?u.message:"Failed to load score");}finally{c||l(false);}};i();let p;return t&&t>0&&(p=setInterval(i,t)),()=>{c=true,p&&clearInterval(p);}},[o,e,t]),{score:r,isLoading:a,error:n}}var Is={sm:{fontSize:11,ratingFontSize:13,starSize:13,gap:5,pillPx:8,pillPy:4,barHeight:3,iconSize:12},md:{fontSize:12.5,ratingFontSize:15,starSize:15,gap:6,pillPx:10,pillPy:5,barHeight:4,iconSize:14},lg:{fontSize:14,ratingFontSize:18,starSize:18,gap:8,pillPx:12,pillPy:6,barHeight:5,iconSize:16}};function Bs({rating:e,size:t,filledColor:o,emptyColor:r}){let s=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,a=[];for(let l=1;l<=5;l++){let n=Math.min(1,Math.max(0,e-(l-1))),g=`${s}-${l}`;a.push(jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:g,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*n,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:r}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:o,clipPath:`url(#${g})`})]},l));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,t*.08),alignItems:"center"},children:a})}function Ms({rate:e,height:t,filledColor:o,trackColor:r}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:t,borderRadius:t,backgroundColor:r,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:t,background:o,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function Ds({size:e,color:t}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:t,style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66a4.8 4.8 0 00-.88-1.12L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})})}function Fs({elementId:e,variant:t="stars",showCount:o=true,size:r="md",theme:s="auto",refreshInterval:a,style:l}){let{score:n,isLoading:g}=ar({elementId:e,refreshInterval:a}),[c,i]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)");i(I.matches?"dark":"light");let T=P=>i(P.matches?"dark":"light");return I.addEventListener("change",T),()=>I.removeEventListener("change",T)},[]);let{themeConfig:p}=L(),u=react.useMemo(()=>ne(s,c,p),[s,c,p]);if(g||!n)return null;let d=Is[r],m=u.colors.text,f=u.colors.textDisabled,h=u.colors.starFilled,b=u.colors.starEmpty,v=u.colors.voteUp,w=u.colors.starEmpty,k={display:"inline-flex",alignItems:"center",gap:d.gap,fontFamily:u.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...l},R=(I,T)=>{let P=I===1?T:`${T}s`;return `${I.toLocaleString()} ${P}`};if(t==="votes"){let{voteCount:I,positiveRate:T}=n,P=I.up+I.down;return P===0?null:jsxRuntime.jsxs("span",{style:k,children:[jsxRuntime.jsx(Ds,{size:d.iconSize,color:v}),jsxRuntime.jsxs("span",{style:{fontSize:d.ratingFontSize,fontWeight:600,color:v,fontVariantNumeric:"tabular-nums"},children:[T,"%"]}),jsxRuntime.jsx(Ms,{rate:T??0,height:d.barHeight,filledColor:v,trackColor:w}),o&&jsxRuntime.jsx("span",{style:{fontSize:d.fontSize,color:f,fontWeight:400},children:R(P,"vote")})]})}let{averageRating:S,totalResponses:E}=n;if(S===null||E===0)return null;let A=S.toFixed(1);return t==="compact"?jsxRuntime.jsxs("span",{style:k,children:[jsxRuntime.jsx("svg",{width:d.starSize,height:d.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:h})}),jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:m,fontVariantNumeric:"tabular-nums"},children:A}),o&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:f,fontWeight:400},children:["(",E.toLocaleString(),")"]})]}):t==="number"?jsxRuntime.jsxs("span",{style:k,children:[jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:m,fontVariantNumeric:"tabular-nums"},children:A}),jsxRuntime.jsx("span",{style:{fontSize:d.fontSize,color:f,fontWeight:400},children:"/ 5"}),o&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:f,fontWeight:400,marginLeft:2},children:["(",R(E,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:k,children:[jsxRuntime.jsx(Bs,{rating:S,size:d.starSize,filledColor:h,emptyColor:b}),jsxRuntime.jsx("span",{style:{fontSize:d.ratingFontSize,fontWeight:700,color:m,fontVariantNumeric:"tabular-nums"},children:A}),o&&jsxRuntime.jsxs("span",{style:{fontSize:d.fontSize,color:f,fontWeight:400},children:["(",R(E,"response"),")"]})]})}function Ps(){let{client:e,disabled:t,defaultUser:o,debug:r,openModal:s,closeModal:a,activeModalId:l}=L();return {client:e,disabled:t,defaultUser:o,debug:r,submitFeedback:e.submitResponse.bind(e),openModal:s,closeModal:a,activeModalId:l}}function Ls(e){let{activeModalId:t,openModal:o,closeModal:r}=L(),s=react.useCallback(()=>o(e),[o,e]),a=react.useCallback(()=>r(),[r]);return {open:s,close:a,isOpen:t===e}}
|
|
173
|
+
exports.Gotcha=Ts;exports.GotchaProvider=Pr;exports.GotchaScore=Fs;exports.createTheme=Cr;exports.useGotcha=Ps;exports.useGotchaTrigger=Ls;//# sourceMappingURL=index.js.map
|
|
161
174
|
//# sourceMappingURL=index.js.map
|