@lightworkai.official/debug-capture 0.13.0 → 0.14.1

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var k2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,z)=>(typeof require<"u"?require:$)[z]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var f2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},x=null;function E2(J){let $=[];if(!J.host?.trim())$.push("host");if(!J.realmKey?.trim())$.push("realmKey");if(!J.app?.name?.trim())$.push("app.name");if(typeof J.module!=="function")$.push("module");if($.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${$.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");x=J}function w(){if(!x)throw Error("[debug-capture] configureDebugCapture() has not been called");return x}function K0(){return x!==null}function m(){let J=w().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??h2()}}function h2(){if(typeof window>"u")return"unknown";let J=window.location.hostname;if(J==="localhost"||J==="127.0.0.1"||J.endsWith(".local"))return"development";return"production"}function v(J){let $=x?.capture?.[J];return typeof $==="number"?$:f2[J]}function U0(J){let $=x?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function P0(){let J=x?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function P1(){return x?.capture?.overlaySelectors??[]}var m2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',g2="[data-lw-mask]",U1={fps:1,quality:0.5};function W0(){let J=x?.replay;if(!J)return null;let $=J===!0?{}:J,z=(Z,W)=>typeof Z==="number"&&Z>0?Z:W,Q=$.maskInputs!==!1,j=$.recordCanvas?{fps:z(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,U1.fps),quality:z(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,U1.quality)}:null;return{seconds:z($.seconds,60),maskInputs:Q,maskTextSelector:$.maskTextSelector?.trim()||(Q?m2:g2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:z($.maxBytes,4000000),canvas:j}}function M1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(b2($))return!1;if($.origin===window.location.origin)return!0;return(x?.capture?.bodyOrigins??[]).some((z)=>{try{return new URL(z).origin===$.origin}catch{return!1}})}function b2(J){if(!x?.host)return!1;try{if(new URL(x.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function y2(J){let $=Object.entries(J).map(([z,Q])=>[z.replace(/\/+$/,"")||"/",Q]).sort((z,Q)=>Q[0].length-z[0].length);return(z)=>{let Q=(z||"/").replace(/\/+$/,"")||"/";for(let[j,Z]of $)if(Q===j||Q.startsWith(`${j}/`))return{key:j,label:Z};return null}}var r="‹redacted›",v2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,p2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),u2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,d2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,c2=/\d(?:[\d\s-]{7,})\d/g;function n(J){return J.replace(d2,r).replace(c2,r)}function i2(J){if(v2.test(J))return!0;return P0().headers.some((z)=>z.toLowerCase()===J.toLowerCase())}function s(J){let $={};for(let[z,Q]of Object.entries(J))$[z]=i2(z)?r:Q;return $}function g(J){try{let $=/^https?:\/\//i.test(J),z=new URL(J,$?void 0:"http://local.invalid"),Q=!1;if(z.searchParams.forEach((j,Z)=>{if(p2.has(Z.toLowerCase())||P0().queryKeys.includes(Z.toLowerCase()))z.searchParams.set(Z,r),Q=!0}),!Q)return J;return $?z.toString():`${z.pathname}${z.search}`}catch{return J}}function L0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((Q)=>L0(Q,$+1));let z={};for(let[Q,j]of Object.entries(J)){let Z=u2.test(Q)||P0().bodyKeys.some((W)=>Q.toLowerCase().includes(W));z[Q]=Z?r:L0(j,$+1)}return z}function a(J,$){if(J==null)return null;let z=J,Q=J.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let j=JSON.parse(Q);z=JSON.stringify(L0(j,0))}catch{}if(z.length>$)return`${z.slice(0,$)}… [truncated ${z.length-$} chars]`;return z}var A0=120,x0=40,e=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,T0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},t=[],D1=0,I1=!1;function Y0(J,$,z,Q){let j=e($,A0),Z=t[t.length-1];if(J==="navigate"&&Z?.kind==="click"){let G=j.replace(/^ไปที่\s*/,"");if(Z.detail.includes(`→ ${G}`))return Z.at=new Date().toISOString(),Z;let F=G.split(/[?#]/)[0]??G,P=Z.source?T0(Z.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(F===P||F.startsWith(P)))return Z.detail=e(`${Z.detail} → ${G}`,A0),Z.source=void 0,Z.at=new Date().toISOString(),Z}if(Z&&Z.kind===J&&Z.detail===j){if(Z.at=new Date().toISOString(),J!=="navigate")Z.count=(Z.count??1)+1;return Z}D1+=1;let W={id:`act_${D1}`,at:new Date().toISOString(),kind:J,detail:j,count:1,source:z,html:D0(Q)};t.push(W);while(t.length>v("maxActions"))o2(t.shift());return W}var l2=200000,G0=0;function D0(J){if(!J)return;if(G0+J.length>l2)return;return G0+=J.length,J}function o2(J){if(!J)return;if(G0-=(J.html?.length??0)+(J.afterHtml?.length??0),G0<0)G0=0}function k0(J){return J&&J>1?` (×${J})`:""}function M0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var r2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',n2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},C1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function s2(J){let $=J.getAttribute("role");if($&&C1[$])return C1[$];return n2[J.tagName.toLowerCase()]??"ปุ่ม"}function a2(J,$){try{let z=J,Q=0;while(z&&Q<=$){let j=O1(z);if(j&&typeof j.memoizedProps?.onClick==="function")return z;z=z.parentElement,Q+=1}}catch{}return null}function t2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let z=J.getAttribute("title")?.trim();if(z)return z;if(J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||J instanceof HTMLSelectElement)return(J.getAttribute("placeholder")||J.getAttribute("name")||"").trim();if(J instanceof HTMLImageElement)return(J.getAttribute("alt")||"").trim();let Q=(J.textContent??"").replace(/\s+/g," ").trim();if(Q)return Q;if(J instanceof HTMLAnchorElement){let j=J.getAttribute("href");if(j?.startsWith("/"))return T0(j)}return""}function e2(J){if(!(J instanceof Element))return null;let $=J.closest(r2)??a2(J,4);if(!$)return null;let z=$.tagName.toLowerCase();if(z==="html"||z==="body")return null;return $}function J4(J){let $=n(t2(J));if(!$)return null;return`${s2(J)} “${e($,x0)}”`}var S1=6000,$4=4000,z4=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function Q4(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((j)=>j.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let j of $){for(let W of Array.from(j.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))j.removeAttribute(W.name)}if(j instanceof HTMLAnchorElement)j.setAttribute("href","#");if(j instanceof HTMLImageElement)j.removeAttribute("src");let Z=j.getAttribute("class");if(Z){let W=Z.replace(z4," ").replace(/\s+/g," ").trim();if(W)j.setAttribute("class",W);else j.removeAttribute("class")}}let z=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),Q=z.nextNode();while(Q){if(Q.nodeValue)Q.nodeValue=n(Q.nodeValue);Q=z.nextNode()}}function f0(J,$,z){try{let Q=J.outerHTML;if(!Q||Q.length>$)return;let j=J.cloneNode(!0);Q4(j);let Z=j.outerHTML;return Z&&Z.length<=z?Z:void 0}catch{return}}var j4=(J)=>f0(J,S1,$4),Z4=150000,K4=40000,N1=(J)=>f0(J,Z4,K4);function W4(J){if(!(J instanceof HTMLInputElement)&&!(J instanceof HTMLTextAreaElement)&&!(J instanceof HTMLSelectElement))return null;let $=J.name||J.id||J.getAttribute("aria-label")||J.getAttribute("placeholder")||J.tagName.toLowerCase();return`ช่อง “${n($)}”`}var q1=80;function O1(J){let $=Object.keys(J).find((z)=>z.startsWith("__reactFiber$")||z.startsWith("__reactInternalInstance$"));return $?J[$]:null}function Y4(J){if(typeof J!=="function")return null;try{let $=Function.prototype.toString.call(J);return($.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??$.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function B1(J){if(!J)return;return`→ ${J.length>q1?`${J.slice(0,q1)}…`:J}`}function G4(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return B1($);let z=O1(J),Q=0;while(z&&Q<30){if(typeof z.memoizedProps?.onClick==="function")return B1(Y4(z.memoizedProps.onClick));z=z.return,Q+=1}return}catch{return}}var V4='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function X4(){let J=P1();return J.length?J.join(", "):V4}function F4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function H4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let z=J.getAttribute("aria-labelledby");if(z){let Z=z.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(Z)return Z}let j=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(j)return j;return(J.textContent??"").replace(/\s+/g," ").trim()}function _1(J){let $=n(H4(J)),z=F4(J);return $?`เปิด ${z} “${e($,x0)}”`:`เปิด ${z}`}var U4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',P4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function M4(J){if(J.querySelector(U4))return!0;return P4.test(J.textContent??"")}var D4=400,I4=250,C4=8000;function N4(J,$){if(typeof MutationObserver>"u"){$.html=D0(N1(J));return}let z=Date.now(),Q=!1,j=()=>{Q=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},Z=()=>{if(Q)return;if(j(),!J.isConnected)return;$.detail=e(_1(J),A0),$.html=D0(N1(J))},W=new MutationObserver(()=>{z=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(Q)return;if(!J.isConnected){j();return}if(Date.now()-z>=D4&&!M4(J))Z()},I4),F=window.setTimeout(Z,C4)}function q4(J){if(M0(J))return;let $=Y0("ui",_1(J));if($)N4(J,$)}function B4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((z)=>{for(let Q of z)for(let j of Array.from(Q.addedNodes)){if(!(j instanceof Element))continue;let Z=X4(),W=j.matches(Z)?[j]:Array.from(j.querySelectorAll(Z));for(let G of W){if(J.has(G))continue;J.add(G),q4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var w4=1600,S4=2500;function w1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:e((J.textContent??"").replace(/\s+/g," ").trim(),x0)}}function O4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function _4(J,$){if(typeof MutationObserver>"u")return;let z=w1(J),Q=!1,j=(G,F)=>{if(Q)return;if(Q=!0,Z.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=D0(f0(J,S1,S4))},Z=new MutationObserver(()=>{if(!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=O4(z,w1(J));if(G)j(G,!0)});Z.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!Q&&!J.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}Q=!0,Z.disconnect()},w4)}function R1(){if(I1||typeof window>"u")return;I1=!0,document.addEventListener("click",(Q)=>{if(M0(Q.target))return;let j=e2(Q.target);if(!j)return;let Z=J4(j);if(!Z)return;let W=Y0("click",`คลิก ${Z}`,G4(j),j4(j));if(W)_4(j,W)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(M0(Q.target))return;let j=W4(Q.target);if(j)Y0("input",`แก้ไข ${j}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(M0(Q.target))return;Y0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Y0("navigate",`ไปที่ ${T0(g(location.pathname+location.search))}`),$=history.pushState.bind(history),z=history.replaceState.bind(history);history.pushState=(...Q)=>{let j=$(...Q);return J(),j},history.replaceState=(...Q)=>{let j=z(...Q);return J(),j},window.addEventListener("popstate",J),B4()}function E0(){return t.map((J)=>({...J}))}var L1=2000,I0=[],A1=0,x1=!1;function h0(J,$){A1+=1,I0.push({id:`log_${A1}`,at:new Date().toISOString(),level:J,message:$.length>L1?`${$.slice(0,L1)}…`:$});while(I0.length>v("maxConsoleEntries"))I0.shift()}function R4(){let J=new WeakSet;return($,z)=>{if(typeof z==="object"&&z!==null){if(J.has(z))return"[Circular]";J.add(z)}if(typeof z==="bigint")return z.toString();return z}}function T1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,R4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function k1(){if(x1||typeof window>"u")return;x1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let z=console[$].bind(console);console[$]=(...Q)=>{h0($,Q.map(T1).join(" ")),z(...Q)}}window.addEventListener("error",($)=>{let z=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";h0("exception",`${$.message}${z}`)}),window.addEventListener("unhandledrejection",($)=>{let z=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:T1($.reason);h0("unhandledrejection",z)})}function m0(){return I0.map((J)=>({...J}))}var f1=new Set,E1=new Set;function h1(J,$){return J.add($),()=>J.delete($)}function m1(J,$){for(let z of[...J])z($)}function g0(J){return h1(f1,J)}function b0(J={type:"manual"}){m1(f1,J)}function y0(J){return h1(E1,J)}function v0(J){m1(E1,J)}var L4=15000,A4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],g1=!1,b1=0;function x4(J){return A4.some(($)=>J.includes($))}function y1(J){let $=J.message??"";if(!$||x4($))return;let z=Date.now();if(z-b1<L4)return;b1=z,v0({...J,message:$})}function v1(){if(g1||typeof window>"u")return;g1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;y1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;y1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var c1=4000,T4=1e6,k4=1e7,C0=[],p1=0,u1=!1;function i1(J){C0.push(J);while(C0.length>v("maxRequests"))C0.shift()}function l1(){return p1+=1,`req_${p1}`}function d1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((z,Q)=>{$[Q]=z});else if(Array.isArray(J))for(let[z,Q]of J)$[z]=Q;else Object.assign($,J);return $}function f4(J){let $={};return J.forEach((z,Q)=>{$[Q]=z}),$}function E4(J){if(J==null)return null;if(typeof J==="string")return J;if(J instanceof URLSearchParams)return J.toString();if(typeof FormData<"u"&&J instanceof FormData)return`[FormData: ${Array.from(J.keys()).join(", ")}]`;if(typeof Blob<"u"&&J instanceof Blob)return`[Blob ${J.size} bytes]`;if(J instanceof ArrayBuffer)return`[ArrayBuffer ${J.byteLength} bytes]`;return"[binary]"}function h4(J,$){let z="",Q="GET",j={},Z=null;if(typeof J==="string")z=J;else if(J instanceof URL)z=J.toString();else z=J.url,Q=J.method||Q,j=d1(J.headers);if($){if($.method)Q=$.method;if($.headers)j={...j,...d1($.headers)};if($.body!==void 0)Z=E4($.body)}return{method:Q.toUpperCase(),url:z,headers:j,body:Z}}function o1(J){return!M1(J)}function m4(J,$){if(o1($.url)){$.responseSnippet="[body not captured for this origin]";return}let z=J.headers.get("content-type")??"",Q=Number(J.headers.get("content-length")??"0"),j=Q?`, ~${Q} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(z)){$.responseSnippet=`[binary ${z||"unknown"}${j}]`;return}if(Q>T4){$.responseSnippet=`[response ${z||"text"}${j} — omitted]`;return}try{J.clone().text().then((Z)=>{$.responseSnippet=a(Z,v("maxBodyChars"))}).catch(()=>{})}catch{}}function r1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let z of Object.keys($)){let Q=z.toLowerCase();if(Q==="rsc"||Q==="next-router-prefetch"||Q==="next-router-state-tree")return!0}return!1}function g4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,z)=>{let Q=h4($,z);if(r1(Q.url,Q.headers))return J($,z);let j={id:l1(),startedAt:new Date().toISOString(),method:Q.method,url:g(Q.url),requestHeaders:s(Q.headers),requestBody:a(Q.body,c1),status:null,statusText:null,durationMs:null,via:"fetch"};i1(j);let Z=performance.now();try{let W=await J($,z);return j.status=W.status,j.statusText=W.statusText,j.durationMs=Math.round(performance.now()-Z),j.responseHeaders=s(f4(W.headers)),m4(W,j),W}catch(W){throw j.durationMs=Math.round(performance.now()-Z),j.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function b4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,z=J.send,Q=function(Z,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=r1(G,{})?void 0:{id:l1(),startedAt:"",method:(Z||"GET").toUpperCase(),url:g(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},j=function(Z){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof Z==="string"?a(Z,c1):Z==null?null:"[non-string body]";let G=performance.now();i1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),o1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=a(this.responseText||"",v("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return z.apply(this,arguments)};J.open=Q,J.send=j}function n1(){if(u1)return;u1=!0,g4(),b4()}function p0(){let J=C0.map((z)=>({...z})),$=0;for(let z=J.length-1;z>=0;z-=1){let Q=J[z],j=Q?.responseSnippet;if(!Q||typeof j!=="string"||j.length===0)continue;if($+j.length>k4)Q.responseSnippet=`[response omitted — report size budget reached (${j.length.toLocaleString()} chars)]`;else $+=j.length}return J}var y4=4,s1=3,v4=4000,p4="[data-debug-reporter]",u4=()=>import("@rrweb/record");var T=[],J0=null,N0=!1;function a1(){if(typeof window>"u"||J0||N0)return;let J=W0();if(!J)return;N0=!0;let $=()=>void d4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function d4(J){let $;try{$=(await u4()).record}catch(z){N0=!1,console.warn("[debug-capture] session replay could not start:",z);return}if(J0)return;try{J0=$({emit:(z)=>c4(z),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:v4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${p4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...J.canvas?{canvas:J.canvas.fps}:{}},recordCanvas:J.canvas!==null,...J.canvas?{dataURLOptions:{type:"image/webp",quality:J.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(z){console.warn("[debug-capture] session replay could not start:",z)}finally{N0=!1}}function c4(J){if(J.type===y4||T.length===0){if(T.push([]),T.length>s1)T=T.slice(-s1)}T[T.length-1].push(J)}function u0(J=Date.now()){let $=W0();if(!$||!T.length)return null;let z=J-$.seconds*1000,Q=T.length-1;while(Q>0&&(T[Q][0]?.timestamp??J)>z)Q-=1;let j=T.slice(Q).flat(),Z=j[0]?.timestamp,W=j[j.length-1]?.timestamp;if(Z===void 0||W===void 0)return null;return{events:j,startedAt:new Date(Z).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-Z)}}function i4(){return J0!==null}function l4(){J0?.(),J0=null,T=[]}var o4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่",chooseTitle:"ต้องการให้ทีมช่วยเรื่องอะไร",chooseProblem:"แจ้งปัญหา",chooseProblemHint:"มีอะไรเสียหรือใช้งานไม่ได้ — แนบภาพหน้าจอ",chooseRequest:"ขอให้ทีมดำเนินการ",chooseRequestHint:"ขอสิทธิ์ ขอแก้ข้อมูล หรือขอให้ทีมทำบางอย่าง",requestTitle:"ขอให้ทีมดำเนินการ",requestTypeLabel:"เรื่องที่ขอ",requestTarget:"ทีมตั้งใจให้เสร็จภายใน {time}",requestSummaryLabel:"หัวข้อ",requestSummaryPlaceholder:"ขออะไร — สั้น ๆ",requestDetailLabel:"รายละเอียด (ไม่บังคับ)",requestDetailPlaceholder:"สิ่งที่ทีมต้องรู้เพื่อดำเนินการ",requestSubmit:"ส่งคำขอ",requestSubmitted:"ส่งคำขอแล้ว",back:"ย้อนกลับ",days:"{n} วัน",hours:"{n} ชั่วโมง"},r4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab",chooseTitle:"How can the team help?",chooseProblem:"Report a problem",chooseProblemHint:"Something is broken or not working — with a screenshot",chooseRequest:"Ask the team",chooseRequestHint:"Access, a data change, or something done for you",requestTitle:"Ask the team",requestTypeLabel:"What you need",requestTarget:"The team aims to finish within {time}",requestSummaryLabel:"Subject",requestSummaryPlaceholder:"What do you need — briefly",requestDetailLabel:"Details (optional)",requestDetailPlaceholder:"What the team needs to know to do it",requestSubmit:"Send request",requestSubmitted:"Request sent",back:"Back",days:"{n} days",hours:"{n} hours"};function l(J){return J==="en"?r4:o4}var n4="lw-debug-toasts",s4=6000,a4=`
1
+ var m2=((z)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(z,{get:(J,$)=>(typeof require<"u"?require:J)[$]}):z)(function(z){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+z+'" is not supported')});var b2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},E=null;function g2(z){let J=[];if(!z.host?.trim())J.push("host");if(!z.realmKey?.trim())J.push("realmKey");if(!z.app?.name?.trim())J.push("app.name");if(typeof z.module!=="function")J.push("module");if(J.length)throw Error(`[debug-capture] configureDebugCapture is missing: ${J.join(", ")}. `+"See the README — `module` maps a pathname to the part of your app it belongs to.");E=z}function _(){if(!E)throw Error("[debug-capture] configureDebugCapture() has not been called");return E}function U0(){return E!==null}function u(){let z=_().app;return{name:z.name,version:z.version??"0.0.0",environment:z.environment??p2()}}function p2(){if(typeof window>"u")return"unknown";let z=window.location.hostname;if(z==="localhost"||z==="127.0.0.1"||z.endsWith(".local"))return"development";return"production"}function t(z){let J=E?.capture?.[z];return typeof J==="number"?J:b2[z]}function C0(z){let J=E?.module;if(!J)return null;try{return J(z)??null}catch{return null}}function x0(){let z=E?.redact;return{headers:z?.headers??[],queryKeys:(z?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:(z?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function N1(){return E?.capture?.overlaySelectors??[]}var y2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',v2="[data-lw-mask]",B1={fps:1,quality:0.5};function M0(){let z=E?.replay;if(!z)return null;let J=z===!0?{}:z,$=(Z,Y)=>typeof Z==="number"&&Z>0?Z:Y,Q=J.maskInputs!==!1,j=J.recordCanvas?{fps:$(typeof J.recordCanvas==="object"?J.recordCanvas.fps:void 0,B1.fps),quality:$(typeof J.recordCanvas==="object"?J.recordCanvas.quality:void 0,B1.quality)}:null;return{seconds:$(J.seconds,60),maskInputs:Q,maskTextSelector:J.maskTextSelector?.trim()||(Q?y2:v2),maskText:J.maskText===!0,blockSelector:J.blockSelector?.trim()||"[data-lw-private]",maxBytes:$(J.maxBytes,4000000),canvas:j}}function q1(z){if(typeof window>"u")return!1;let J;try{J=new URL(z,window.location.href)}catch{return!1}if(u2(J))return!1;if(J.origin===window.location.origin)return!0;return(E?.capture?.bodyOrigins??[]).some(($)=>{try{return new URL($).origin===J.origin}catch{return!1}})}function u2(z){if(!E?.host)return!1;try{if(new URL(E.host).origin!==z.origin)return!1}catch{return!1}return z.pathname.startsWith("/ingest/")}function d2(z){let J=Object.entries(z).map(([$,Q])=>[$.replace(/\/+$/,"")||"/",Q]).sort(($,Q)=>Q[0].length-$[0].length);return($)=>{let Q=($||"/").replace(/\/+$/,"")||"/";for(let[j,Z]of J)if(Q===j||Q.startsWith(`${j}/`))return{key:j,label:Z};return null}}var Z0="‹redacted›",c2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,i2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),l2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,o2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,r2=/\d(?:[\d\s-]{7,})\d/g;function K0(z){return z.replace(o2,Z0).replace(r2,Z0)}function n2(z){if(c2.test(z))return!0;return x0().headers.some(($)=>$.toLowerCase()===z.toLowerCase())}function Y0(z){let J={};for(let[$,Q]of Object.entries(z))J[$]=n2($)?Z0:Q;return J}function i(z){try{let J=/^https?:\/\//i.test(z),$=new URL(z,J?void 0:"http://local.invalid"),Q=!1;if($.searchParams.forEach((j,Z)=>{if(i2.has(Z.toLowerCase())||x0().queryKeys.includes(Z.toLowerCase()))$.searchParams.set(Z,Z0),Q=!0}),!Q)return z;return J?$.toString():`${$.pathname}${$.search}`}catch{return z}}function y0(z,J){if(J>6||z===null||typeof z!=="object")return z;if(Array.isArray(z))return z.map((Q)=>y0(Q,J+1));let $={};for(let[Q,j]of Object.entries(z)){let Z=l2.test(Q)||x0().bodyKeys.some((Y)=>Q.toLowerCase().includes(Y));$[Q]=Z?Z0:y0(j,J+1)}return $}function X0(z,J){if(z==null)return null;let $=z,Q=z.trim();if(Q.startsWith("{")||Q.startsWith("["))try{let j=JSON.parse(Q);$=JSON.stringify(y0(j,0))}catch{}if($.length>J)return`${$.slice(0,J)}… [truncated ${$.length-J} chars]`;return $}var v0=120,u0=40,V0=(z,J)=>z.length>J?`${z.slice(0,J)}…`:z,d0=(z)=>{try{return decodeURIComponent(z)}catch{return z}},G0=[],w1=0,C1=!1;function D0(z,J,$,Q){let j=V0(J,v0),Z=G0[G0.length-1];if(z==="navigate"&&Z?.kind==="click"){let V=j.replace(/^ไปที่\s*/,"");if(Z.detail.includes(`→ ${V}`))return Z.at=new Date().toISOString(),Z;let P=V.split(/[?#]/)[0]??V,M=Z.source?d0(Z.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(P===M||P.startsWith(M)))return Z.detail=V0(`${Z.detail} → ${V}`,v0),Z.source=void 0,Z.at=new Date().toISOString(),Z}if(Z&&Z.kind===z&&Z.detail===j){if(Z.at=new Date().toISOString(),z!=="navigate")Z.count=(Z.count??1)+1;return Z}w1+=1;let Y={id:`act_${w1}`,at:new Date().toISOString(),kind:z,detail:j,count:1,source:$,html:O0(Q)};G0.push(Y);while(G0.length>t("maxActions"))a2(G0.shift());return Y}var s2=200000,I0=0;function O0(z){if(!z)return;if(I0+z.length>s2)return;return I0+=z.length,z}function a2(z){if(!z)return;if(I0-=(z.html?.length??0)+(z.afterHtml?.length??0),I0<0)I0=0}function c0(z){return z&&z>1?` (×${z})`:""}function S0(z){return z instanceof Element&&Boolean(z.closest("[data-debug-reporter]"))}var t2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',e2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},x1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function z4(z){let J=z.getAttribute("role");if(J&&x1[J])return x1[J];return e2[z.tagName.toLowerCase()]??"ปุ่ม"}function J4(z,J){try{let $=z,Q=0;while($&&Q<=J){let j=k1($);if(j&&typeof j.memoizedProps?.onClick==="function")return $;$=$.parentElement,Q+=1}}catch{}return null}function $4(z){let J=z.getAttribute("aria-label")?.trim();if(J)return J;let $=z.getAttribute("title")?.trim();if($)return $;if(z instanceof HTMLInputElement||z instanceof HTMLTextAreaElement||z instanceof HTMLSelectElement)return(z.getAttribute("placeholder")||z.getAttribute("name")||"").trim();if(z instanceof HTMLImageElement)return(z.getAttribute("alt")||"").trim();let Q=(z.textContent??"").replace(/\s+/g," ").trim();if(Q)return Q;if(z instanceof HTMLAnchorElement){let j=z.getAttribute("href");if(j?.startsWith("/"))return d0(j)}return""}function Q4(z){if(!(z instanceof Element))return null;let J=z.closest(t2)??J4(z,4);if(!J)return null;let $=J.tagName.toLowerCase();if($==="html"||$==="body")return null;return J}function j4(z){let J=K0($4(z));if(!J)return null;return`${z4(z)} “${V0(J,u0)}”`}var L1=6000,Z4=4000,K4=/(?:^|\s)!?(?:fixed|absolute|sticky|inset-\S+|z-\S+|top-\S+|bottom-\S+|left-\S+|right-\S+|w-screen|h-screen|min-h-screen|max-h-screen|translate-\S+|scale-\S+)(?=\s|$)/g;function Y4(z){z.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((j)=>j.remove());let J=[z,...Array.from(z.querySelectorAll("*"))];for(let j of J){for(let Y of Array.from(j.attributes)){let V=Y.name.toLowerCase();if(V.startsWith("on")||V==="srcdoc"||V==="value"||V.startsWith("data-"))j.removeAttribute(Y.name)}if(j instanceof HTMLAnchorElement)j.setAttribute("href","#");if(j instanceof HTMLImageElement)j.removeAttribute("src");let Z=j.getAttribute("class");if(Z){let Y=Z.replace(K4," ").replace(/\s+/g," ").trim();if(Y)j.setAttribute("class",Y);else j.removeAttribute("class")}}let $=document.createTreeWalker(z,NodeFilter.SHOW_TEXT),Q=$.nextNode();while(Q){if(Q.nodeValue)Q.nodeValue=K0(Q.nodeValue);Q=$.nextNode()}}function i0(z,J,$){try{let Q=z.outerHTML;if(!Q||Q.length>J)return;let j=z.cloneNode(!0);Y4(j);let Z=j.outerHTML;return Z&&Z.length<=$?Z:void 0}catch{return}}var X4=(z)=>i0(z,L1,Z4),G4=150000,V4=40000,S1=(z)=>i0(z,G4,V4);function W4(z){if(!(z instanceof HTMLInputElement)&&!(z instanceof HTMLTextAreaElement)&&!(z instanceof HTMLSelectElement))return null;let J=z.name||z.id||z.getAttribute("aria-label")||z.getAttribute("placeholder")||z.tagName.toLowerCase();return`ช่อง “${K0(J)}”`}var O1=80;function k1(z){let J=Object.keys(z).find(($)=>$.startsWith("__reactFiber$")||$.startsWith("__reactInternalInstance$"));return J?z[J]:null}function F4(z){if(typeof z!=="function")return null;try{let J=Function.prototype.toString.call(z);return(J.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??J.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function _1(z){if(!z)return;return`→ ${z.length>O1?`${z.slice(0,O1)}…`:z}`}function H4(z){try{let J=z.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return _1(J);let $=k1(z),Q=0;while($&&Q<30){if(typeof $.memoizedProps?.onClick==="function")return _1(F4($.memoizedProps.onClick));$=$.return,Q+=1}return}catch{return}}var P4='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function U4(){let z=N1();return z.length?z.join(", "):P4}function M4(z){let J=z.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function D4(z){let J=z.getAttribute("aria-label")?.trim();if(J)return J;let $=z.getAttribute("aria-labelledby");if($){let Z=$.split(/\s+/).map((Y)=>document.getElementById(Y)?.textContent?.trim()??"").filter(Boolean).join(" ");if(Z)return Z}let j=z.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(j)return j;return(z.textContent??"").replace(/\s+/g," ").trim()}function A1(z){let J=K0(D4(z)),$=M4(z);return J?`เปิด ${$} “${V0(J,u0)}”`:`เปิด ${$}`}var I4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',B4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function N4(z){if(z.querySelector(I4))return!0;return B4.test(z.textContent??"")}var q4=400,w4=250,C4=8000;function x4(z,J){if(typeof MutationObserver>"u"){J.html=O0(S1(z));return}let $=Date.now(),Q=!1,j=()=>{Q=!0,Y.disconnect(),window.clearInterval(V),window.clearTimeout(P)},Z=()=>{if(Q)return;if(j(),!z.isConnected)return;J.detail=V0(A1(z),v0),J.html=O0(S1(z))},Y=new MutationObserver(()=>{$=Date.now()});Y.observe(z,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let V=window.setInterval(()=>{if(Q)return;if(!z.isConnected){j();return}if(Date.now()-$>=q4&&!N4(z))Z()},w4),P=window.setTimeout(Z,C4)}function S4(z){if(S0(z))return;let J=D0("ui",A1(z));if(J)x4(z,J)}function O4(){if(typeof MutationObserver>"u")return;let z=new WeakSet;new MutationObserver(($)=>{for(let Q of $)for(let j of Array.from(Q.addedNodes)){if(!(j instanceof Element))continue;let Z=U4(),Y=j.matches(Z)?[j]:Array.from(j.querySelectorAll(Z));for(let V of Y){if(z.has(V))continue;z.add(V),S4(V)}}}).observe(document.body,{childList:!0,subtree:!0})}var _4=1600,R4=2500;function R1(z){return{disabled:z.hasAttribute("disabled")||z.getAttribute("aria-disabled")==="true",busy:z.getAttribute("aria-busy")==="true",text:V0((z.textContent??"").replace(/\s+/g," ").trim(),u0)}}function L4(z,J){if(!z.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!z.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(z.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function k4(z,J){if(typeof MutationObserver>"u")return;let $=R1(z),Q=!1,j=(V,P)=>{if(Q)return;if(Q=!0,Z.disconnect(),window.clearTimeout(Y),J.afterNote=V,P)J.afterHtml=O0(i0(z,L1,R4))},Z=new MutationObserver(()=>{if(!z.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}let V=L4($,R1(z));if(V)j(V,!0)});Z.observe(z,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let Y=window.setTimeout(()=>{if(!Q&&!z.isConnected){j("องค์ประกอบหายไปจากหน้าจอ",!1);return}Q=!0,Z.disconnect()},_4)}function T1(){if(C1||typeof window>"u")return;C1=!0,document.addEventListener("click",(Q)=>{if(S0(Q.target))return;let j=Q4(Q.target);if(!j)return;let Z=j4(j);if(!Z)return;let Y=D0("click",`คลิก ${Z}`,H4(j),X4(j));if(Y)k4(j,Y)},{capture:!0,passive:!0}),document.addEventListener("change",(Q)=>{if(S0(Q.target))return;let j=W4(Q.target);if(j)D0("input",`แก้ไข ${j}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(Q)=>{if(S0(Q.target))return;D0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let z=()=>D0("navigate",`ไปที่ ${d0(i(location.pathname+location.search))}`),J=history.pushState.bind(history),$=history.replaceState.bind(history);history.pushState=(...Q)=>{let j=J(...Q);return z(),j},history.replaceState=(...Q)=>{let j=$(...Q);return z(),j},window.addEventListener("popstate",z),O4()}function l0(){return G0.map((z)=>({...z}))}var f1=2000,_0=[],E1=0,h1=!1;function o0(z,J){E1+=1,_0.push({id:`log_${E1}`,at:new Date().toISOString(),level:z,message:J.length>f1?`${J.slice(0,f1)}…`:J});while(_0.length>t("maxConsoleEntries"))_0.shift()}function A4(){let z=new WeakSet;return(J,$)=>{if(typeof $==="object"&&$!==null){if(z.has($))return"[Circular]";z.add($)}if(typeof $==="bigint")return $.toString();return $}}function m1(z){if(typeof z==="string")return z;if(z instanceof Error)return`${z.name}: ${z.message}`;try{let J=JSON.stringify(z,A4());if(J!==void 0)return J}catch{}try{return String(z)}catch{}try{return Object.prototype.toString.call(z)}catch{return`[${typeof z}]`}}function b1(){if(h1||typeof window>"u")return;h1=!0;let z=["log","info","warn","error","debug"];for(let J of z){let $=console[J].bind(console);console[J]=(...Q)=>{o0(J,Q.map(m1).join(" ")),$(...Q)}}window.addEventListener("error",(J)=>{let $=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";o0("exception",`${J.message}${$}`)}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:m1(J.reason);o0("unhandledrejection",$)})}function r0(){return _0.map((z)=>({...z}))}var g1=new Set,p1=new Set;function y1(z,J){return z.add(J),()=>z.delete(J)}function v1(z,J){for(let $ of[...z])$(J)}function n0(z){return y1(g1,z)}function s0(z={type:"manual"}){v1(g1,z)}function a0(z){return y1(p1,z)}function t0(z){v1(p1,z)}var T4=15000,f4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],u1=!1,d1=0;function E4(z){return f4.some((J)=>z.includes(J))}function c1(z){let J=z.message??"";if(!J||E4(J))return;let $=Date.now();if($-d1<T4)return;d1=$,t0({...z,message:J})}function i1(){if(u1||typeof window>"u")return;u1=!0,window.addEventListener("error",(z)=>{if(!z.message&&!z.error)return;let J=z.error instanceof Error?z.error:null;c1({type:"runtime-error",message:z.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",(z)=>{let J=z.reason;c1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var n1=4000,h4=1e6,m4=1e7,R0=[],l1=0,o1=!1;function s1(z){R0.push(z);while(R0.length>t("maxRequests"))R0.shift()}function a1(){return l1+=1,`req_${l1}`}function r1(z){let J={};if(!z)return J;if(z instanceof Headers)z.forEach(($,Q)=>{J[Q]=$});else if(Array.isArray(z))for(let[$,Q]of z)J[$]=Q;else Object.assign(J,z);return J}function b4(z){let J={};return z.forEach(($,Q)=>{J[Q]=$}),J}function g4(z){if(z==null)return null;if(typeof z==="string")return z;if(z instanceof URLSearchParams)return z.toString();if(typeof FormData<"u"&&z instanceof FormData)return`[FormData: ${Array.from(z.keys()).join(", ")}]`;if(typeof Blob<"u"&&z instanceof Blob)return`[Blob ${z.size} bytes]`;if(z instanceof ArrayBuffer)return`[ArrayBuffer ${z.byteLength} bytes]`;return"[binary]"}function p4(z,J){let $="",Q="GET",j={},Z=null;if(typeof z==="string")$=z;else if(z instanceof URL)$=z.toString();else $=z.url,Q=z.method||Q,j=r1(z.headers);if(J){if(J.method)Q=J.method;if(J.headers)j={...j,...r1(J.headers)};if(J.body!==void 0)Z=g4(J.body)}return{method:Q.toUpperCase(),url:$,headers:j,body:Z}}function t1(z){return!q1(z)}function y4(z,J){if(t1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let $=z.headers.get("content-type")??"",Q=Number(z.headers.get("content-length")??"0"),j=Q?`, ~${Q} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test($)){J.responseSnippet=`[binary ${$||"unknown"}${j}]`;return}if(Q>h4){J.responseSnippet=`[response ${$||"text"}${j} — omitted]`;return}try{z.clone().text().then((Z)=>{J.responseSnippet=X0(Z,t("maxBodyChars"))}).catch(()=>{})}catch{}}function e1(z,J){if(/[?&]_rsc=/.test(z))return!0;for(let $ of Object.keys(J)){let Q=$.toLowerCase();if(Q==="rsc"||Q==="next-router-prefetch"||Q==="next-router-state-tree")return!0}return!1}function v4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let z=window.fetch.bind(window);window.fetch=Object.assign(async(J,$)=>{let Q=p4(J,$);if(e1(Q.url,Q.headers))return z(J,$);let j={id:a1(),startedAt:new Date().toISOString(),method:Q.method,url:i(Q.url),requestHeaders:Y0(Q.headers),requestBody:X0(Q.body,n1),status:null,statusText:null,durationMs:null,via:"fetch"};s1(j);let Z=performance.now();try{let Y=await z(J,$);return j.status=Y.status,j.statusText=Y.statusText,j.durationMs=Math.round(performance.now()-Z),j.responseHeaders=Y0(b4(Y.headers)),y4(Y,j),Y}catch(Y){throw j.durationMs=Math.round(performance.now()-Z),j.error=Y instanceof Error?`${Y.name}: ${Y.message}`:String(Y),Y}},z)}function u4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let z=XMLHttpRequest.prototype,J=z.open,$=z.send,Q=function(Z,Y){let V=typeof Y==="string"?Y:Y.toString();return this.__lwEntry=e1(V,{})?void 0:{id:a1(),startedAt:"",method:(Z||"GET").toUpperCase(),url:i(V),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},j=function(Z){let Y=this.__lwEntry;if(Y){Y.startedAt=new Date().toISOString(),Y.requestBody=typeof Z==="string"?X0(Z,n1):Z==null?null:"[non-string body]";let V=performance.now();s1(Y),this.addEventListener("loadend",()=>{if(Y.status=this.status||null,Y.statusText=this.statusText||null,Y.durationMs=Math.round(performance.now()-V),t1(Y.url))Y.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{Y.responseSnippet=X0(this.responseText||"",t("maxBodyChars"))}catch{}else{let P=this.getResponseHeader("content-type")??this.responseType;Y.responseSnippet=`[binary ${P}]`}})}return $.apply(this,arguments)};z.open=Q,z.send=j}function z2(){if(o1)return;o1=!0,v4(),u4()}function e0(){let z=R0.map(($)=>({...$})),J=0;for(let $=z.length-1;$>=0;$-=1){let Q=z[$],j=Q?.responseSnippet;if(!Q||typeof j!=="string"||j.length===0)continue;if(J+j.length>m4)Q.responseSnippet=`[response omitted — report size budget reached (${j.length.toLocaleString()} chars)]`;else J+=j.length}return z}var d4=4,J2=3,c4=4000,i4="[data-debug-reporter]",l4=()=>import("@rrweb/record");var h=[],W0=null,L0=!1;function $2(){if(typeof window>"u"||W0||L0)return;let z=M0();if(!z)return;L0=!0;let J=()=>void o4(z);if("requestIdleCallback"in window)window.requestIdleCallback(J,{timeout:3000});else setTimeout(J,1000)}async function o4(z){let J;try{J=(await l4()).record}catch($){L0=!1,console.warn("[debug-capture] session replay could not start:",$);return}if(W0)return;try{W0=J({emit:($)=>r4($),checkoutEveryNms:Math.max(1000,z.seconds*1000/2),checkoutEveryNth:c4,maskAllInputs:z.maskInputs,maskTextSelector:z.maskText?"*":z.maskTextSelector,blockSelector:`${z.blockSelector}, ${i4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...z.canvas?{canvas:z.canvas.fps}:{}},recordCanvas:z.canvas!==null,...z.canvas?{dataURLOptions:{type:"image/webp",quality:z.canvas.quality}}:{},errorHandler:()=>!0})??null}catch($){console.warn("[debug-capture] session replay could not start:",$)}finally{L0=!1}}function r4(z){if(z.type===d4||h.length===0){if(h.push([]),h.length>J2)h=h.slice(-J2)}h[h.length-1].push(z)}function z1(z=Date.now()){let J=M0();if(!J||!h.length)return null;let $=z-J.seconds*1000,Q=h.length-1;while(Q>0&&(h[Q][0]?.timestamp??z)>$)Q-=1;let j=h.slice(Q).flat(),Z=j[0]?.timestamp,Y=j[j.length-1]?.timestamp;if(Z===void 0||Y===void 0)return null;return{events:j,startedAt:new Date(Z).toISOString(),endedAt:new Date(Y).toISOString(),durationMs:Math.max(0,Y-Z)}}function n4(){return W0!==null}function s4(){W0?.(),W0=null,h=[]}var a4={title:"รายงานปัญหา",summaryLabel:"หัวข้อปัญหา",summaryRequired:"(ต้องกรอกก่อนแจ้งปัญหา)",summaryPlaceholder:"สรุปปัญหาสั้น ๆ เช่น กดบันทึกร่างแล้ว error",detailLabel:"อธิบายปัญหา (ไม่บังคับ)",detailPlaceholder:"เกิดอะไรขึ้น? กำลังทำอะไรอยู่ตอนที่พบปัญหา?",annotateTitle:"วาดบนรูป",annotateHint:"ทำเครื่องหมายจุดที่มีปัญหาก่อนแนบ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",annotateApply:"ใช้รูปนี้",cancel:"ยกเลิก",toolRect:"กรอบ",toolArrow:"ลูกศร",toolHighlight:"ไฮไลต์",toolText:"ข้อความ",deleteSelected:"ลบที่เลือก",clearAll:"ล้างทั้งหมด",annotateHelp:"เลือกเครื่องมือแล้วลากบนรูป · ไม่ได้เลือกเครื่องมือ = ย้าย/ปรับขนาดสิ่งที่วาดไว้ · กดกากบาทมุมขวาบนของรูปทรงเพื่อลบ",capturing:"กำลังเก็บภาพหน้าจอ…",noScreenshot:"ไม่มีภาพหน้าจอ — ยังส่งรายงานได้",cancelled:"ยกเลิกการเก็บภาพหน้าจอแล้ว",close:"ปิด",submit:"แจ้งปัญหา",submitting:"กำลังส่ง…",submitted:"แจ้งปัญหาสำเร็จ",crashed:"เกิดข้อผิดพลาดในระบบ",crashAction:"แจ้งปัญหา",failed:"ส่งรายงานไม่สำเร็จ",failedOffline:"ส่งไม่สำเร็จ — เชื่อมต่อเซิร์ฟเวอร์ไม่ได้ ข้อความที่พิมพ์ไว้ยังอยู่ ตรวจสอบอินเทอร์เน็ตแล้วลองใหม่",failedUnavailable:"ส่งไม่สำเร็จ — ระบบกำลังปรับปรุงชั่วคราว ข้อความที่พิมพ์ไว้ยังอยู่ ลองใหม่ในอีกสักครู่",failedTooMany:"แจ้งปัญหาถี่เกินไป — ลองใหม่ในอีก {seconds} วินาที",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่",chooseTitle:"ต้องการให้ทีมช่วยเรื่องอะไร",kindProblem:"แจ้งปัญหา",kindProblemHint:"มีอะไรเสีย หรือใช้งานไม่ได้",kindRequest:"คำขอ",kindRequestHint:"ขอให้ทีมทำ เช่น ขอสิทธิ์ ขอแก้ข้อมูล",requestTitle:"ขอให้ทีมดำเนินการ",requestTypeLabel:"เรื่องที่ขอ",requestTarget:"ทีมตั้งใจให้เสร็จภายใน {time}",requestSummaryLabel:"หัวข้อ",requestSummaryPlaceholder:"ขออะไร — สั้น ๆ",requestDetailLabel:"รายละเอียด (ไม่บังคับ)",requestDetailPlaceholder:"สิ่งที่ทีมต้องรู้เพื่อดำเนินการ",requestSubmit:"ส่งคำขอ",requestSubmitted:"ส่งคำขอแล้ว",requestWithShot:"แนบภาพหน้าจอนี้ไปกับคำขอ",requestAnnotateHint:"ทำเครื่องหมายสิ่งที่ขอบนภาพ — วงกรอบ ชี้ลูกศร ไฮไลต์ หรือพิมพ์ข้อความ",draftRestored:"ข้อความที่พิมพ์ไว้ครั้งก่อน ยังไม่ได้ส่ง",draftClear:"ล้าง",requestLeaves:"ไม่ส่งไปกับคำขอ",requestLeavesWhat:"บันทึกการใช้งานของหน้านี้ — ใช้กับการแจ้งปัญหาเท่านั้น",days:"{n} วัน",hours:"{n} ชั่วโมง"},t4={title:"Report a problem",summaryLabel:"Summary",summaryRequired:"(required)",summaryPlaceholder:"One line, e.g. saving a draft returns an error",detailLabel:"Details (optional)",detailPlaceholder:"What happened? What were you doing at the time?",annotateTitle:"Draw on the image",annotateHint:"Mark what went wrong before attaching — box it, point at it, highlight it, or type on it",annotateApply:"Use this image",cancel:"Cancel",toolRect:"Box",toolArrow:"Arrow",toolHighlight:"Highlight",toolText:"Text",deleteSelected:"Delete selected",clearAll:"Clear all",annotateHelp:"Pick a tool and drag on the image · no tool selected = move/resize what you drew · press the ✕ on a shape to delete it",capturing:"Capturing the screen…",noScreenshot:"No screenshot — you can still send the report",cancelled:"Screen capture cancelled",close:"Close",submit:"Send report",submitting:"Sending…",submitted:"Report sent",crashed:"Something went wrong",crashAction:"Report it",failed:"Could not send the report",failedOffline:"Could not send — the server could not be reached. What you wrote is still here; check your connection and try again.",failedUnavailable:"Could not send — the system is being updated. What you wrote is still here; try again in a moment.",failedTooMany:"Too many reports — try again in {seconds} seconds.",captured:"Captured",reporter:"Reporter",page:"Page",replay:"activity log",handoffTitle:"Opening the support portal",handoffBody:"You will be signed in automatically to see what you reported",handoffGo:"Go now",handoffPreparing:"Preparing…",handoffFailed:"Could not open your reports",handoffBlocked:"Your browser blocked the new tab",handoffOpen:"Open in a new tab",chooseTitle:"How can the team help?",kindProblem:"Report a problem",kindProblemHint:"Something is broken or not working",kindRequest:"Request",kindRequestHint:"Ask the team to do something, like access or a data change",requestTitle:"Ask the team",requestTypeLabel:"What you need",requestTarget:"The team aims to finish within {time}",requestSummaryLabel:"Subject",requestSummaryPlaceholder:"What do you need — briefly",requestDetailLabel:"Details (optional)",requestDetailPlaceholder:"What the team needs to know to do it",requestSubmit:"Send request",requestSubmitted:"Request sent",requestWithShot:"Attach this screenshot to the request",requestAnnotateHint:"Mark what you are asking about — box it, point at it, highlight it, or type on it",draftRestored:"What you typed last time, not sent yet",draftClear:"Clear",requestLeaves:"Not sent with a request",requestLeavesWhat:"this page's activity log — it is for problem reports only",days:"{n} days",hours:"{n} hours"};function J0(z){return z==="en"?t4:a4}var e4="lw-debug-toasts",z6=6000,J6=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,15 +30,15 @@ var k2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,z)=
30
30
  }
31
31
  @keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
32
32
  @media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
33
- `,d0=null;function t4(){if(typeof document>"u")return null;if(d0?.isConnected)return d0;let J=document.createElement(n4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),z=document.createElement("style");z.textContent=a4;let Q=document.createElement("div");return Q.className="stack",Q.setAttribute("role","status"),Q.setAttribute("aria-live","polite"),$.append(z,Q),document.body.append(J),d0=Q,Q}function p(J,$="success",z){let Q=K0()?w().toast:void 0;if(Q){Q({message:J,tone:$,...z?{action:z}:{}});return}let j=t4();if(!j)return;let Z=document.createElement("div");Z.className="toast",Z.dataset.tone=$;let W=document.createElement("span");W.className="dot";let G=document.createElement("span");G.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(q),Z.remove()};F.addEventListener("click",P);let q=$==="error"||z?0:window.setTimeout(P,s4);if(Z.append(W,G),z){let M=document.createElement("button");M.type="button",M.className="action",M.textContent=z.label,M.addEventListener("click",()=>{P(),z.onClick()}),Z.append(M)}Z.append(F),j.append(Z)}function t1(J,$,z){let Q=J.filter((Z)=>Boolean(Z.error)||Z.status!=null&&Z.status>=400).slice(-20).map((Z)=>({method:Z.method,url:Z.url,status:Z.status,error:Z.error,at:Z.startedAt})),j=$.filter((Z)=>Z.level==="error"||Z.level==="exception"||Z.level==="unhandledrejection").slice(-20).map((Z)=>Z.message);return{failedRequests:Q,errors:j,erroredQueries:z.slice(0,20)}}function e1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function e4(){let J={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return J;let $=performance.memory;if($)J.memoryUsedMb=Math.round($.usedJSHeapSize/1024/1024),J.memoryLimitMb=Math.round($.jsHeapSizeLimit/1024/1024);let[z]=performance.getEntriesByType("navigation");if(z)J.domContentLoadedMs=Math.round(z.domContentLoadedEventEnd),J.loadEventMs=Math.round(z.loadEventEnd);return J}function c0(J,$){if(!J)return $;try{return J()}catch{return $}}function J2(){let J=w(),{pathname:$,search:z,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:$,search:z},module:U0($),user:c0(J.user,{}),apiHeaders:s(c0(J.headers,{})),app:{name:m().name,version:m().version,environment:m().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:e4(),extra:c0(J.extra,{})}}var J6=2,$6={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function i0(J){let $=p0(),z=m0();return{context:J2(),reason:J.reason,note:J.note,cause:t1($,z,J.erroredQueries),actionTrail:E0(),network:$,console:z,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:u0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:J6}}}function $2(J){return J.replace(/'/g,"'\\''")}function z2(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[z,Q]of Object.entries(J.requestHeaders))$.push(` -H '${z}: ${$2(Q)}'`);if(J.requestBody)$.push(` --data '${$2(J.requestBody)}'`);return $.join(" \\\n")}function z6(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function Q6(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let z=$.durationMs!=null?`${$.durationMs}ms`:"—",Q=`# [${z6($)}] ${$.method} ${$.url} (${z}, ${$.startedAt})`,j=$.responseSnippet?`
34
- # response: ${$.responseSnippet}`:"";return`${Q}
35
- ${z2($)}${j}`}).join(`
33
+ `,J1=null;function $6(){if(typeof document>"u")return null;if(J1?.isConnected)return J1;let z=document.createElement(e4);z.dataset.debugReporter="true";let J=z.attachShadow({mode:"open"}),$=document.createElement("style");$.textContent=J6;let Q=document.createElement("div");return Q.className="stack",Q.setAttribute("role","status"),Q.setAttribute("aria-live","polite"),J.append($,Q),document.body.append(z),J1=Q,Q}function $0(z,J="success",$){let Q=U0()?_().toast:void 0;if(Q){Q({message:z,tone:J,...$?{action:$}:{}});return}let j=$6();if(!j)return;let Z=document.createElement("div");Z.className="toast",Z.dataset.tone=J;let Y=document.createElement("span");Y.className="dot";let V=document.createElement("span");V.textContent=z;let P=document.createElement("button");P.type="button",P.className="close",P.textContent="✕",P.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(B),Z.remove()};P.addEventListener("click",M);let B=J==="error"||$?0:window.setTimeout(M,z6);if(Z.append(Y,V),$){let N=document.createElement("button");N.type="button",N.className="action",N.textContent=$.label,N.addEventListener("click",()=>{M(),$.onClick()}),Z.append(N)}Z.append(P),j.append(Z)}function Q2(z,J,$){let Q=z.filter((Z)=>Boolean(Z.error)||Z.status!=null&&Z.status>=400).slice(-20).map((Z)=>({method:Z.method,url:Z.url,status:Z.status,error:Z.error,at:Z.startedAt})),j=J.filter((Z)=>Z.level==="error"||Z.level==="exception"||Z.level==="unhandledrejection").slice(-20).map((Z)=>Z.message);return{failedRequests:Q,errors:j,erroredQueries:$.slice(0,20)}}function j2(z){return z.failedRequests.length+z.errors.length+z.erroredQueries.length}function Q6(){let z={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return z;let J=performance.memory;if(J)z.memoryUsedMb=Math.round(J.usedJSHeapSize/1024/1024),z.memoryLimitMb=Math.round(J.jsHeapSizeLimit/1024/1024);let[$]=performance.getEntriesByType("navigation");if($)z.domContentLoadedMs=Math.round($.domContentLoadedEventEnd),z.loadEventMs=Math.round($.loadEventEnd);return z}function $1(z,J){if(!z)return J;try{return z()}catch{return J}}function Z2(){let z=_(),{pathname:J,search:$,href:Q}=window.location;return{capturedAt:new Date().toISOString(),route:{href:Q,pathname:J,search:$},module:C0(J),user:$1(z.user,{}),apiHeaders:Y0($1(z.headers,{})),app:{name:u().name,version:u().version,environment:u().environment},client:{userAgent:navigator.userAgent,language:navigator.language,platform:navigator.platform,online:navigator.onLine,viewport:{width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio},screen:{width:window.screen.width,height:window.screen.height}},performance:Q6(),extra:$1(z.extra,{})}}var j6=2,Z6={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function Q1(z){let J=e0(),$=r0();return{context:Z2(),reason:z.reason,note:z.note,cause:Q2(J,$,z.erroredQueries),actionTrail:l0(),network:J,console:$,screenshotDataUrl:z.screenshotDataUrl,screenshotMethod:z.screenshotMethod,replay:z1()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:j6}}}function K2(z){return z.replace(/'/g,"'\\''")}function Y2(z){let J=[`curl -X ${z.method} '${z.url}'`];for(let[$,Q]of Object.entries(z.requestHeaders))J.push(` -H '${$}: ${K2(Q)}'`);if(z.requestBody)J.push(` --data '${K2(z.requestBody)}'`);return J.join(" \\\n")}function K6(z){if(z.error)return`ERR ${z.error}`;return`${z.status??"—"} ${z.statusText??""}`.trim()}function Y6(z){if(z.length===0)return"No network activity captured.";return z.map((J)=>{let $=J.durationMs!=null?`${J.durationMs}ms`:"—",Q=`# [${K6(J)}] ${J.method} ${J.url} (${$}, ${J.startedAt})`,j=J.responseSnippet?`
34
+ # response: ${J.responseSnippet}`:"";return`${Q}
35
+ ${Y2(J)}${j}`}).join(`
36
36
 
37
- `)}function j6(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
- `)}function Z6(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((z)=>{let Q=z.source?` (${z.source})`:"",j=`${z.detail}${k0(z.count)}${Q}`;if(z.kind==="ui")return` ↳ [${z.at}] ${j}`;$+=1;let Z=`${$}. [${z.at}] ${j}`;return z.afterNote?`${Z}
39
- ↳ ${z.afterNote}`:Z}).join(`
40
- `)}function K6(J){let $=[];for(let z of J.failedRequests)$.push(`✗ ${z.status??z.error??"ERR"} ${z.method} ${z.url}`);for(let z of J.errors)$.push(`⚠ ${z}`);for(let z of J.erroredQueries)$.push(`⚠ React Query error: ${z.key} — ${z.error}`);return $}function W6(J){let{context:$}=J;return[`User : ${$.user.fullName??"—"} (${$.user.email??"—"})`,`Unit : ${$.user.unit??"—"}`,`Roles : ${$.user.roles?.join(", ")||"—"}`,`Route : ${$.route.href}`,`Module : ${$.module?`${$.module.label} (${$.module.key})`:"—"}`,`App : ${$.app.name} v${$.app.version} · ${$.app.environment}`,`Memory : ${$.performance.memoryUsedMb??"—"}/${$.performance.memoryLimitMb??"—"} MB`,`Client : ${$.client.userAgent}`,`Viewport : ${$.client.viewport.width}×${$.client.viewport.height} @${$.client.viewport.dpr}x`,`Reason : ${$6[J.reason.type]}${J.reason.message?` — ${J.reason.message}`:""}`,`Captured : ${J.network.length} requests · ${J.console.length} console · ${J.actionTrail.length} actions · screenshot=${J.screenshotMethod}${J.replay?` · replay=${Math.round(J.replay.durationMs/1000)}s`:""}`]}function Y6(J){let $=K6(J.cause),z=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...W6(J).map((Q)=>`- ${Q.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)z.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return z.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",Z6(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",Q6(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",j6(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),z.join(`
41
- `)}function G6(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function V6(J,$){return`debug-report_${G6(J.context.capturedAt)}.${$}`}function X6(J){return e1(J.cause)>0}async function l0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let z=await F6();if(z.status==="ok")return{dataUrl:z.dataUrl,method:"display-media"};if(z.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await P6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function F6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let z=await H6(J);return z?{status:"ok",dataUrl:z}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function H6(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((W)=>{let G=!1,F=()=>{if(G)return;G=!0,W()};$.onloadedmetadata=()=>{$.play().then(F).catch(F)},window.setTimeout(F,1500)}),await U6($);let{videoWidth:z,videoHeight:Q}=$;if(!z||!Q)return null;let j=document.createElement("canvas");j.width=z,j.height=Q;let Z=j.getContext("2d");if(!Z)return null;Z.drawImage($,0,0,z,Q),$.pause(),$.srcObject=null;try{return j.toDataURL("image/png")}catch{return null}}function U6(J){return new Promise(($)=>{let z=!1,Q=()=>{if(z)return;z=!0,$()},j=J;if(typeof j.requestVideoFrameCallback==="function")j.requestVideoFrameCallback(()=>Q()),window.setTimeout(Q,1000);else window.setTimeout(Q,250)})}async function P6(){let J=w().screenshotFallback;if(!J)return null;let $=await J().catch(()=>null);if(!$)return null;try{return await $(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(z)=>!(z instanceof HTMLElement&&z.dataset?.debugReporter==="true")})}catch{return null}}var M6=2000,D6=0.82,I6=3000000;function C6(J){return new Promise(($,z)=>{let Q=new Image;Q.onload=()=>$(Q),Q.onerror=()=>z(Error("could not read the screenshot")),Q.src=J})}async function Q2(J){try{let $=await C6(J),z=Math.max($.naturalWidth,$.naturalHeight),Q=Math.min(1,M6/z),j=document.createElement("canvas");j.width=Math.max(1,Math.round($.naturalWidth*Q)),j.height=Math.max(1,Math.round($.naturalHeight*Q));let Z=j.getContext("2d");if(!Z)return J;Z.fillStyle="#fff",Z.fillRect(0,0,j.width,j.height),Z.drawImage($,0,0,j.width,j.height);let W=D6,G=j.toDataURL("image/jpeg",W);while(G.length>I6&&W>0.4)W-=0.15,G=j.toDataURL("image/jpeg",W);return G}catch{return J}}var N6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,q6=/^\d+$/,B6=/^[0-9a-f]{16,}$/i;function o0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let z;try{z=new URL($.url,"http://x").pathname}catch{z=$.url}let Q=z.split("/").map((Z)=>N6.test(Z)||q6.test(Z)||B6.test(Z)?":id":Z).join("/"),j=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${Q} ${j}`}var r0=2000000;function q0(J){let{screenshotDataUrl:$,replay:z,...Q}=J;return JSON.stringify(Q).length}function n0(J,$=2000000){if(q0(J)<=$)return J;let z=J.network.map((j)=>({...j})),Q={...J,network:z};for(let j of z){if(q0(Q)<=$)return Q;if(typeof j.responseSnippet==="string"&&j.responseSnippet.length>35)j.responseSnippet="[body dropped — report size budget]";if(typeof j.requestBody==="string"&&j.requestBody.length>35)j.requestBody="[body dropped — report size budget]"}while(Q.network.length>1&&q0(Q)>$)Q.network=Q.network.slice(1);while(Q.console.length>1&&q0(Q)>$)Q.console=Q.console.slice(1);return Q}function V0(J){let $="";for(let z=0;z<J.length;z+=32768)$+=String.fromCharCode(...J.subarray(z,z+32768));return btoa($)}var w6=4,S6=2,O6=3,_6=0,R6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),L6=/^\s*javascript:/i;function A6(J,$){let z=J.toLowerCase();if(z.startsWith("on")||z==="srcdoc")return!0;return typeof $==="string"&&L6.test($)}function j2(J,$=!1){if(!J)return;for(let z of Object.keys(J)){let Q=J[z];if(A6(z,Q)){if($)J[z]=null;else delete J[z];continue}if(typeof Q!=="string"||!R6.has(z)||!Q.includes("?"))continue;J[z]=g(Q)}}function s0(J){if(!J)return;j2(J.attributes);for(let $ of J.childNodes??[])s0($)}function Z2(J){let $=JSON.parse(JSON.stringify(J));for(let z of $){let Q=z.data;if(!Q||typeof Q!=="object")continue;if(z.type===w6&&typeof Q.href==="string")Q.href=g(Q.href);else if(z.type===S6)s0(Q.node);else if(z.type===O6&&Q.source===_6){for(let j of Q.adds??[])s0(j.node);for(let j of Q.attributes??[])j2(j.attributes,!0)}}return $}var W2="session-replay.json.gz",x6="session-replay.json";function T6(J){return Boolean(J&&J.events.length>0)}async function k6(J){if(typeof CompressionStream>"u")return null;try{let $=new Blob([J]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response($).arrayBuffer())}catch{return null}}async function a0(J,$){if(!T6(J))return{summary:{omitted:"empty"}};let Q={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},j=Z2(J.events),Z=await K2(j),W=!1;if(Z.bytes.byteLength>$&&h6(j))j=m6(j),Z=await K2(j),W=!0;let{bytes:G,compressed:F}=Z;if(G.byteLength>$)return{summary:{...Q,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${V0(G)}`,filename:F?W2:x6,summary:{...Q,events:j.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function K2(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),z=await k6($);return z?{bytes:z,compressed:!0}:{bytes:$,compressed:!1}}var f6=3,Y2=2,E6=9;function G2(J){return J.type===f6&&J.data?.source===E6}function h6(J){return J.some(G2)||J.some(($)=>$.type===Y2&&V2($.data.node))}function V2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some(V2)}function X2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])X2($)}function m6(J){let $=[];for(let z of J){if(G2(z))continue;if(z.type===Y2)X2(z.data.node);$.push(z)}return $}var g6=new Set([502,503,504]);class b extends Error{kind;retryAfter;status;constructor(J,$,z,Q){super(J);this.kind=$;this.retryAfter=z;this.status=Q;this.name="ReportError"}}function b6(J){let{screenshotDataUrl:$,replay:z,...Q}=J;return{dataUri:`data:application/json;base64,${V0(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function t0(){let J=w().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function e0(J,$){let z=w(),Q=n0($,r0),{context:j,note:Z}=Q,W=[];if(Q.screenshotDataUrl){let I=await Q2(Q.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(b6(Q));let G,F=W0();if(F){let I=await a0(Q.replay,F.maxBytes);if(G=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let P=o0(Q),q={title:J,description:Z.trim()||void 0,appName:m().name,category:j.module?.label,routeUrl:j.route.href,priority:"MEDIUM",requesterEmail:j.user.email??void 0,requesterName:j.user.fullName??void 0,customFields:{unit:j.user.unit??"",appVersion:j.app.version,environment:j.app.environment,reasonType:Q.reason.type,appName:m().name,module:j.module?.label??""},context:{...P?{signature:P}:{},capturedAt:j.capturedAt,reason:Q.reason,cause:Q.cause,actionTrail:Q.actionTrail,client:j.client,performance:j.performance,apiHeaders:j.apiHeaders,extra:j.extra,counts:{network:Q.network.length,console:Q.console.length,actions:Q.actionTrail.length},screenshotMethod:Q.screenshotMethod,...G?{replay:G}:{}},attachments:W},M=await fetch(`${z.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":z.realmKey,...await t0()},body:JSON.stringify(q)}).catch(()=>{throw new b("report never left the browser","offline")});if(!M.ok)throw await J1(M);return await M.json()}async function J1(J){let $=J.headers.get("retry-after"),z=await J.json().then((Q)=>Q.error).catch(()=>null);if(J.status===429)return new b("rate limited","rateLimited",$??void 0);if(g6.has(J.status))return new b("desk unavailable","unavailable");return new b(z??`Report failed (${J.status})`,"rejected",void 0,J.status)}var B0=null,X0=null,F2=()=>w().host.replace(/\/$/,"");function $1(){return B0}function $0(){if(X0)return X0;return X0=(async()=>{try{let J=await fetch(`${F2()}/ingest/request-types`,{headers:{"x-realm-key":w().realmKey}}),$=J.ok?await J.json():null;B0=Array.isArray($?.types)?$.types.filter(y6):[]}catch{B0=[],X0=null}return B0??[]})(),X0}function y6(J){let $=J;return!!$&&typeof $.id==="string"&&typeof $.name==="string"}async function z1(J){let $=w(),z={};try{z=$.user?.()??{}}catch{z={}}let Q=typeof window>"u"?null:window.location,j={title:J.title,description:J.description.trim()||void 0,ticketTypeId:J.ticketTypeId,appName:m().name,category:Q?U0(Q.pathname)?.label:void 0,routeUrl:Q?.href,priority:"MEDIUM",requesterEmail:z.email??void 0,requesterName:z.fullName??void 0},Z=await fetch(`${F2()}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":$.realmKey,...await t0()},body:JSON.stringify(j)}).catch(()=>{throw new b("request never left the browser","offline")});if(!Z.ok)throw await J1(Z);return await Z.json()}var F0=Math.PI/6;function H2(J,$,z){let Q=$.x-J.x,j=$.y-J.y,Z=Math.hypot(Q,j),W=Math.atan2(j,Q),G=[{x:$.x,y:$.y},{x:$.x-z*Math.cos(W-F0),y:$.y-z*Math.sin(W-F0)},{x:$.x-z*Math.cos(W+F0),y:$.y-z*Math.sin(W+F0)}],F=z*Math.cos(F0)*0.92;if(Z<=F)return{shaft:null,head:G};return{shaft:{from:J,to:{x:$.x-F*Math.cos(W),y:$.y-F*Math.sin(W)}},head:G}}var Q1="#f44336",v6="rgba(250, 204, 21, 0.4)",j1=22,U2="#2563eb",P2=9,M2=11,D2=18,I2=4,w0=8,p6=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function Z1(J,$,z){let Q=[],j=null,Z=-1,W=null,G=null,F=J.getContext("2d");function P(){let K=J.getBoundingClientRect().width;return K>0?J.width/K:1}function q(K){let Y=J.getBoundingClientRect();return{x:(K.clientX-Y.left)/Y.width*J.width,y:(K.clientY-Y.top)/Y.height*J.height}}function M(K){let Y=K.size??j1;if(!F)return(K.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(K.text??"").width;return F.restore(),X}function I(K){if(K.tool==="text"){let Y=K.size??j1;return{left:K.x1,top:K.y1,right:K.x1+M(K),bottom:K.y1+Y*1.25}}return{left:Math.min(K.x1,K.x2),top:Math.min(K.y1,K.y2),right:Math.max(K.x1,K.x2),bottom:Math.max(K.y1,K.y2)}}function O(K){if(K.tool==="arrow")return[{id:"tail",x:K.x1,y:K.y1,cursor:"move"},{id:"head",x:K.x2,y:K.y2,cursor:"move"}];let Y=I(K);if(K.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return p6.map((X)=>({id:X.id,x:Y.left+(Y.right-Y.left)*X.fx,y:Y.top+(Y.bottom-Y.top)*X.fy,cursor:X.cursor}))}function C(K){let Y=I(K);return{x:Y.right+D2*P(),y:Y.top-D2*P()}}function R(K,Y,X){let{shaft:V,head:H}=H2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)K.lineCap="butt",K.beginPath(),K.moveTo(V.from.x,V.from.y),K.lineTo(V.to.x,V.to.y),K.stroke();K.beginPath(),K.moveTo(H[0].x,H[0].y),K.lineTo(H[1].x,H[1].y),K.lineTo(H[2].x,H[2].y),K.closePath(),K.fill()}function L(K,Y,X){K.save(),K.lineWidth=Math.max(2,3*X),K.strokeStyle=Q1,K.fillStyle=Q1;let V=I(Y);if(Y.tool==="rect")K.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(K,Y,X);else if(Y.tool==="highlight")K.fillStyle=v6,K.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??j1;K.font=`600 ${H}px system-ui, sans-serif`,K.textBaseline="top";let U=H*0.22;K.fillStyle="rgba(255,255,255,0.92)",K.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),K.fillStyle=Q1,K.fillText(Y.text,V.left,V.top)}K.restore()}function D(K,Y,X){let V=I(Y);K.save(),K.strokeStyle=U2,K.lineWidth=Math.max(1,1.5*X),K.setLineDash([6*X,4*X]),K.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),K.setLineDash([]);let H=P2*X;for(let f of O(Y))K.fillStyle="#fff",K.strokeStyle=U2,K.lineWidth=Math.max(1,1.5*X),K.beginPath(),K.rect(f.x-H/2,f.y-H/2,H,H),K.fill(),K.stroke();let U=C(Y),B=M2*X;K.beginPath(),K.arc(U.x,U.y,B,0,Math.PI*2),K.fillStyle="#dc2626",K.fill(),K.strokeStyle="#fff",K.lineWidth=Math.max(1.5,2*X),K.beginPath(),K.moveTo(U.x-B*0.4,U.y-B*0.4),K.lineTo(U.x+B*0.4,U.y+B*0.4),K.moveTo(U.x+B*0.4,U.y-B*0.4),K.lineTo(U.x-B*0.4,U.y+B*0.4),K.stroke(),K.restore()}function N(){if(!F)return;let K=P();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),Q.forEach((X,V)=>{if(V!==d)L(F,X,K)}),W)L(F,W,K);let Y=Q[Z];if(Y&&!W)D(F,Y,K)}function k(K,Y,X,V,H){return Math.abs(K-X)<=H&&Math.abs(Y-V)<=H}function j0(K,Y){let X=Q[Z];if(!X)return null;let V=P2*P()/2+3*P();for(let H of O(X))if(k(K,Y,H.x,H.y,V))return H.id;return null}function o(K,Y){let X=Q[Z];if(!X)return!1;let V=C(X);return k(K,Y,V.x,V.y,M2*P())}function y(K,Y){let X=6*P();for(let V=Q.length-1;V>=0;V-=1){let H=Q[V];if(H.tool==="arrow"){let B=H.x2-H.x1,f=H.y2-H.y1,c=Math.hypot(B,f)||1,i=Math.max(0,Math.min(1,((K-H.x1)*B+(Y-H.y1)*f)/(c*c)));if(Math.hypot(K-(H.x1+i*B),Y-(H.y1+i*f))<=X+4*P())return V;continue}let U=I(H);if(K>=U.left-X&&K<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function u(K,Y,X,V,H){if(Y==="tail"){K.x1=X.x1+V,K.y1=X.y1+H;return}if(Y==="head"){K.x2=X.x2+V,K.y2=X.y2+H;return}if(Y==="size"){let T2=(X.size??24)+H;K.size=Math.max(10,T2);return}let U=I(X),{left:B,top:f,right:c,bottom:i}=U;if(Y.includes("w"))B=Math.min(c-w0,B+V);if(Y.includes("e"))c=Math.max(B+w0,c+V);if(Y.includes("n"))f=Math.min(i-w0,f+H);if(Y.includes("s"))i=Math.max(f+w0,i+H);K.x1=B,K.y1=f,K.x2=c,K.y2=i}function _0(K,Y,X,V){K.x1=Y.x1+X,K.y1=Y.y1+V,K.x2=Y.x2+X,K.y2=Y.y2+V}let A=null,d=-1,_={x:0,y:0,size:24};function h(){let K=J.getBoundingClientRect().width;return K>0?K/J.width:1}function x2(K,Y){if(!F)return K.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(K||" ").width;return F.restore(),X}function Y1(){if(!A)return;let K=J.parentElement;if(!K)return;let Y=J.getBoundingClientRect(),X=K.getBoundingClientRect(),V=h(),H=_.size*V;A.style.left=`${Y.left-X.left+_.x*V}px`,A.style.top=`${Y.top-X.top+_.y*V}px`,A.style.fontSize=`${H}px`,A.style.width=`${Math.max(40,x2(A.value,H)+H)}px`}function Z0(K){let Y=A;if(!Y)return;A=null;let X=Y.value.trim(),V=d;if(d=-1,Y.remove(),K&&X){if(V>=0&&Q[V])Q[V].text=X,Z=V;else Q.push({tool:"text",x1:_.x,y1:_.y,x2:_.x,y2:_.y,text:X,size:_.size}),Z=Q.length-1;z()}else if(V>=0)Z=V;J.focus(),N()}function G1(K,Y,X=-1){Z0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?Q[X]:void 0;d=X,_={x:H?.x1??K,y:H?.y1??Y,size:H?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",A=U,V.append(U),Y1(),U.addEventListener("input",Y1),U.addEventListener("keydown",(B)=>{if(B.stopPropagation(),B.key==="Enter")Z0(!0);else if(B.key==="Escape")Z0(!1)}),requestAnimationFrame(()=>{if(A!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>Z0(!0))}),N()}function V1(K){let{x:Y,y:X}=q(K);if(J.setPointerCapture(K.pointerId),o(Y,X)){R0();return}let V=j0(Y,X);if(V&&Q[Z]){G={grip:V,x:Y,y:X,start:{...Q[Z]}};return}if(j==="text"){if(K.preventDefault(),J.hasPointerCapture(K.pointerId))J.releasePointerCapture(K.pointerId);j=null,z(),G1(Y,X);return}if(j){W={tool:j,x1:Y,y1:X,x2:Y,y2:X},Z=-1;return}let H=y(Y,X);Z=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...Q[H]}}:null,N()}function X1(K){let{x:Y,y:X}=q(K);if(W){W.x2=Y,W.y2=X,N();return}if(G){let H=Q[Z];if(!H)return;let U=Y-G.x,B=X-G.y;if(G.grip==="body")_0(H,G.start,U,B);else u(H,G.grip,G.start,U,B);N();return}if(j){J.style.cursor="crosshair";return}if(o(Y,X)){J.style.cursor="pointer";return}let V=j0(Y,X);if(V){let H=Q[Z]?O(Q[Z]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=y(Y,X)>=0?"move":"default"}function H0(){if(W){if(!(Math.abs(W.x2-W.x1)<I2&&Math.abs(W.y2-W.y1)<I2))Q.push(W),Z=Q.length-1,j=null,z();W=null}if(G)G=null,z();N()}function F1(K){let Y=J.getBoundingClientRect(),X=(K.clientX-Y.left)/Y.width*J.width,V=(K.clientY-Y.top)/Y.height*J.height,H=y(X,V),U=Q[H];if(!U||U.tool!=="text")return;K.preventDefault(),G1(U.x1,U.y1,H)}function H1(K){if(Z<0)return;if(K.key==="Delete"||K.key==="Backspace")K.preventDefault(),R0();else if(K.key==="Escape")Z=-1,N()}function R0(){if(Z<0)return;Q.splice(Z,1),Z=-1,z(),N()}return J.addEventListener("pointerdown",V1),J.addEventListener("pointermove",X1),J.addEventListener("pointerup",H0),J.addEventListener("pointercancel",H0),J.addEventListener("dblclick",F1),J.tabIndex=0,J.addEventListener("keydown",H1),N(),{setTool(K){j=K,Z=-1,J.style.cursor=K?"crosshair":"default",N()},deleteSelected:R0,clear(){Q.length=0,Z=-1,z(),N()},hasShapes:()=>Q.length>0,hasSelection:()=>Z>=0,toDataUrl(){let K=document.createElement("canvas");K.width=$.naturalWidth,K.height=$.naturalHeight;let Y=K.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=P();for(let V of Q)L(Y,V,X);return K.toDataURL("image/png")},destroy(){Z0(!1),J.removeEventListener("pointerdown",V1),J.removeEventListener("pointermove",X1),J.removeEventListener("pointerup",H0),J.removeEventListener("pointercancel",H0),J.removeEventListener("dblclick",F1),J.removeEventListener("keydown",H1)}}}var u6=["keydown","keyup","keypress"];function S0(J){for(let $ of u6)J.addEventListener($,(z)=>z.stopPropagation())}var C2=`
37
+ `)}function X6(z){if(z.length===0)return"No console output captured.";return z.map((J)=>`[${J.at}] ${J.level.toUpperCase()}: ${J.message}`).join(`
38
+ `)}function G6(z){if(z.length===0)return"No user actions captured.";let J=0;return z.map(($)=>{let Q=$.source?` (${$.source})`:"",j=`${$.detail}${c0($.count)}${Q}`;if($.kind==="ui")return` ↳ [${$.at}] ${j}`;J+=1;let Z=`${J}. [${$.at}] ${j}`;return $.afterNote?`${Z}
39
+ ↳ ${$.afterNote}`:Z}).join(`
40
+ `)}function V6(z){let J=[];for(let $ of z.failedRequests)J.push(`✗ ${$.status??$.error??"ERR"} ${$.method} ${$.url}`);for(let $ of z.errors)J.push(`⚠ ${$}`);for(let $ of z.erroredQueries)J.push(`⚠ React Query error: ${$.key} — ${$.error}`);return J}function W6(z){let{context:J}=z;return[`User : ${J.user.fullName??"—"} (${J.user.email??"—"})`,`Unit : ${J.user.unit??"—"}`,`Roles : ${J.user.roles?.join(", ")||"—"}`,`Route : ${J.route.href}`,`Module : ${J.module?`${J.module.label} (${J.module.key})`:"—"}`,`App : ${J.app.name} v${J.app.version} · ${J.app.environment}`,`Memory : ${J.performance.memoryUsedMb??"—"}/${J.performance.memoryLimitMb??"—"} MB`,`Client : ${J.client.userAgent}`,`Viewport : ${J.client.viewport.width}×${J.client.viewport.height} @${J.client.viewport.dpr}x`,`Reason : ${Z6[z.reason.type]}${z.reason.message?` — ${z.reason.message}`:""}`,`Captured : ${z.network.length} requests · ${z.console.length} console · ${z.actionTrail.length} actions · screenshot=${z.screenshotMethod}${z.replay?` · replay=${Math.round(z.replay.durationMs/1000)}s`:""}`]}function F6(z){let J=V6(z.cause),$=[`## \uD83D\uDC1E ${z.context.app.name} — Debug Report`,`**Generated:** ${z.context.capturedAt}`,"",...W6(z).map((Q)=>`- ${Q.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${z.note.trim()||"(ไม่มี)"}`];if(J.length>0)$.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...J,"```");return $.push("",`<details><summary>ขั้นตอน (${z.actionTrail.length})</summary>`,"","```",G6(z.actionTrail),"```","</details>","",`<details><summary>Network (${z.network.length})</summary>`,"","```",Y6(z.network),"```","</details>","",`<details><summary>Console (${z.console.length})</summary>`,"","```",X6(z.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),$.join(`
41
+ `)}function H6(z){return z.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function P6(z,J){return`debug-report_${H6(z.context.capturedAt)}.${J}`}function U6(z){return j2(z.cause)>0}async function j1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let $=await M6();if($.status==="ok")return{dataUrl:$.dataUrl,method:"display-media"};if($.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await B6();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function M6(){let z=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};z=await navigator.mediaDevices.getDisplayMedia(J);let $=await D6(z);return $?{status:"ok",dataUrl:$}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{z?.getTracks().forEach((J)=>J.stop())}}async function D6(z){let J=document.createElement("video");J.srcObject=z,J.muted=!0,J.playsInline=!0,await new Promise((Y)=>{let V=!1,P=()=>{if(V)return;V=!0,Y()};J.onloadedmetadata=()=>{J.play().then(P).catch(P)},window.setTimeout(P,1500)}),await I6(J);let{videoWidth:$,videoHeight:Q}=J;if(!$||!Q)return null;let j=document.createElement("canvas");j.width=$,j.height=Q;let Z=j.getContext("2d");if(!Z)return null;Z.drawImage(J,0,0,$,Q),J.pause(),J.srcObject=null;try{return j.toDataURL("image/png")}catch{return null}}function I6(z){return new Promise((J)=>{let $=!1,Q=()=>{if($)return;$=!0,J()},j=z;if(typeof j.requestVideoFrameCallback==="function")j.requestVideoFrameCallback(()=>Q()),window.setTimeout(Q,1000);else window.setTimeout(Q,250)})}async function B6(){let z=_().screenshotFallback;if(!z)return null;let J=await z().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:($)=>!($ instanceof HTMLElement&&$.dataset?.debugReporter==="true")})}catch{return null}}var N6=2000,q6=0.82,w6=3000000;function C6(z){return new Promise((J,$)=>{let Q=new Image;Q.onload=()=>J(Q),Q.onerror=()=>$(Error("could not read the screenshot")),Q.src=z})}async function k0(z){try{let J=await C6(z),$=Math.max(J.naturalWidth,J.naturalHeight),Q=Math.min(1,N6/$),j=document.createElement("canvas");j.width=Math.max(1,Math.round(J.naturalWidth*Q)),j.height=Math.max(1,Math.round(J.naturalHeight*Q));let Z=j.getContext("2d");if(!Z)return z;Z.fillStyle="#fff",Z.fillRect(0,0,j.width,j.height),Z.drawImage(J,0,0,j.width,j.height);let Y=q6,V=j.toDataURL("image/jpeg",Y);while(V.length>w6&&Y>0.4)Y-=0.15,V=j.toDataURL("image/jpeg",Y);return V}catch{return z}}var x6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,S6=/^\d+$/,O6=/^[0-9a-f]{16,}$/i;function Z1(z){if(z.reason.type==="manual")return null;let J=z.cause?.failedRequests?.[0];if(!J?.url)return null;let $;try{$=new URL(J.url,"http://x").pathname}catch{$=J.url}let Q=$.split("/").map((Z)=>x6.test(Z)||S6.test(Z)||O6.test(Z)?":id":Z).join("/"),j=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${Q} ${j}`}var K1=2000000;function A0(z){let{screenshotDataUrl:J,replay:$,...Q}=z;return JSON.stringify(Q).length}function Y1(z,J=2000000){if(A0(z)<=J)return z;let $=z.network.map((j)=>({...j})),Q={...z,network:$};for(let j of $){if(A0(Q)<=J)return Q;if(typeof j.responseSnippet==="string"&&j.responseSnippet.length>35)j.responseSnippet="[body dropped — report size budget]";if(typeof j.requestBody==="string"&&j.requestBody.length>35)j.requestBody="[body dropped — report size budget]"}while(Q.network.length>1&&A0(Q)>J)Q.network=Q.network.slice(1);while(Q.console.length>1&&A0(Q)>J)Q.console=Q.console.slice(1);return Q}function B0(z){let J="";for(let $=0;$<z.length;$+=32768)J+=String.fromCharCode(...z.subarray($,$+32768));return btoa(J)}var _6=4,R6=2,L6=3,k6=0,A6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),T6=/^\s*javascript:/i;function f6(z,J){let $=z.toLowerCase();if($.startsWith("on")||$==="srcdoc")return!0;return typeof J==="string"&&T6.test(J)}function X2(z,J=!1){if(!z)return;for(let $ of Object.keys(z)){let Q=z[$];if(f6($,Q)){if(J)z[$]=null;else delete z[$];continue}if(typeof Q!=="string"||!A6.has($)||!Q.includes("?"))continue;z[$]=i(Q)}}function X1(z){if(!z)return;X2(z.attributes);for(let J of z.childNodes??[])X1(J)}function G2(z){let J=JSON.parse(JSON.stringify(z));for(let $ of J){let Q=$.data;if(!Q||typeof Q!=="object")continue;if($.type===_6&&typeof Q.href==="string")Q.href=i(Q.href);else if($.type===R6)X1(Q.node);else if($.type===L6&&Q.source===k6){for(let j of Q.adds??[])X1(j.node);for(let j of Q.attributes??[])X2(j.attributes,!0)}}return J}var W2="session-replay.json.gz",E6="session-replay.json";function h6(z){return Boolean(z&&z.events.length>0)}async function m6(z){if(typeof CompressionStream>"u")return null;try{let J=new Blob([z]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(J).arrayBuffer())}catch{return null}}async function G1(z,J){if(!h6(z))return{summary:{omitted:"empty"}};let Q={seconds:Math.round(z.durationMs/1000),events:z.events.length,startedAt:z.startedAt,endedAt:z.endedAt},j=G2(z.events),Z=await V2(j),Y=!1;if(Z.bytes.byteLength>J&&p6(j))j=y6(j),Z=await V2(j),Y=!0;let{bytes:V,compressed:P}=Z;if(V.byteLength>J)return{summary:{...Q,bytes:V.byteLength,omitted:"too-large"}};return{dataUri:`data:${P?"application/gzip":"application/json"};base64,${B0(V)}`,filename:P?W2:E6,summary:{...Q,events:j.length,bytes:V.byteLength,compressed:P,...Y?{canvasDropped:Y}:{}}}}async function V2(z){let J=new TextEncoder().encode(JSON.stringify({events:z})),$=await m6(J);return $?{bytes:$,compressed:!0}:{bytes:J,compressed:!1}}var b6=3,F2=2,g6=9;function H2(z){return z.type===b6&&z.data?.source===g6}function p6(z){return z.some(H2)||z.some((J)=>J.type===F2&&P2(J.data.node))}function P2(z){if(!z)return!1;if(z.attributes&&"rr_dataURL"in z.attributes)return!0;return(z.childNodes??[]).some(P2)}function U2(z){if(!z)return;if(z.attributes&&"rr_dataURL"in z.attributes)delete z.attributes.rr_dataURL;for(let J of z.childNodes??[])U2(J)}function y6(z){let J=[];for(let $ of z){if(H2($))continue;if($.type===F2)U2($.data.node);J.push($)}return J}var v6=new Set([502,503,504]);class l extends Error{kind;retryAfter;status;constructor(z,J,$,Q){super(z);this.kind=J;this.retryAfter=$;this.status=Q;this.name="ReportError"}}function u6(z){let{screenshotDataUrl:J,replay:$,...Q}=z;return{dataUri:`data:application/json;base64,${B0(new TextEncoder().encode(JSON.stringify(Q)))}`,filename:"debug-bundle.json"}}async function V1(){let z=_().identity;if(!z)return{};try{let J=await z();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function W1(z,J){let $=_(),Q=Y1(J,K1),{context:j,note:Z}=Q,Y=[];if(Q.screenshotDataUrl){let q=await k0(Q.screenshotDataUrl);Y.push({dataUri:q,filename:"screenshot.jpg"})}Y.push(u6(Q));let V,P=M0();if(P){let q=await G1(Q.replay,P.maxBytes);if(V=q.summary,"dataUri"in q)Y.push({dataUri:q.dataUri,filename:q.filename})}let M=Z1(Q),B={title:z,description:Z.trim()||void 0,appName:u().name,category:j.module?.label,routeUrl:j.route.href,priority:"MEDIUM",requesterEmail:j.user.email??void 0,requesterName:j.user.fullName??void 0,customFields:{unit:j.user.unit??"",appVersion:j.app.version,environment:j.app.environment,reasonType:Q.reason.type,appName:u().name,module:j.module?.label??""},context:{...M?{signature:M}:{},capturedAt:j.capturedAt,reason:Q.reason,cause:Q.cause,actionTrail:Q.actionTrail,client:j.client,performance:j.performance,apiHeaders:j.apiHeaders,extra:j.extra,counts:{network:Q.network.length,console:Q.console.length,actions:Q.actionTrail.length},screenshotMethod:Q.screenshotMethod,...V?{replay:V}:{}},attachments:Y},N=await fetch(`${$.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":$.realmKey,...await V1()},body:JSON.stringify(B)}).catch(()=>{throw new l("report never left the browser","offline")});if(!N.ok)throw await F1(N);return await N.json()}async function F1(z){let J=z.headers.get("retry-after"),$=await z.json().then((Q)=>Q.error).catch(()=>null);if(z.status===429)return new l("rate limited","rateLimited",J??void 0);if(v6.has(z.status))return new l("desk unavailable","unavailable");return new l($??`Report failed (${z.status})`,"rejected",void 0,z.status)}var T0=null,N0=null,M2=()=>_().host.replace(/\/$/,"");function f0(){return T0}function Q0(){if(N0)return N0;return N0=(async()=>{try{let z=await fetch(`${M2()}/ingest/request-types`,{headers:{"x-realm-key":_().realmKey}}),J=z.ok?await z.json():null;T0=Array.isArray(J?.types)?J.types.filter(d6):[]}catch{T0=[],N0=null}return T0??[]})(),N0}function d6(z){let J=z;return!!J&&typeof J.id==="string"&&typeof J.name==="string"}async function H1(z){let J=_(),$={};try{$=J.user?.()??{}}catch{$={}}let Q=typeof window>"u"?null:window.location,j={title:z.title,description:z.description.trim()||void 0,ticketTypeId:z.ticketTypeId,appName:u().name,category:Q?C0(Q.pathname)?.label:void 0,routeUrl:Q?.href,priority:"MEDIUM",requesterEmail:$.email??void 0,requesterName:$.fullName??void 0,attachments:z.screenshotDataUrl?[{dataUri:await k0(z.screenshotDataUrl),filename:"screenshot.jpg"}]:void 0},Z=await fetch(`${M2()}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":J.realmKey,...await V1()},body:JSON.stringify(j)}).catch(()=>{throw new l("request never left the browser","offline")});if(!Z.ok)throw await F1(Z);return await Z.json()}var q0=Math.PI/6;function D2(z,J,$){let Q=J.x-z.x,j=J.y-z.y,Z=Math.hypot(Q,j),Y=Math.atan2(j,Q),V=[{x:J.x,y:J.y},{x:J.x-$*Math.cos(Y-q0),y:J.y-$*Math.sin(Y-q0)},{x:J.x-$*Math.cos(Y+q0),y:J.y-$*Math.sin(Y+q0)}],P=$*Math.cos(q0)*0.92;if(Z<=P)return{shaft:null,head:V};return{shaft:{from:z,to:{x:J.x-P*Math.cos(Y),y:J.y-P*Math.sin(Y)}},head:V}}var P1="#f44336",c6="rgba(250, 204, 21, 0.4)",U1=22,I2="#2563eb",B2=9,N2=11,q2=18,w2=4,E0=8,i6=[{id:"nw",fx:0,fy:0,cursor:"nwse-resize"},{id:"n",fx:0.5,fy:0,cursor:"ns-resize"},{id:"ne",fx:1,fy:0,cursor:"nesw-resize"},{id:"e",fx:1,fy:0.5,cursor:"ew-resize"},{id:"se",fx:1,fy:1,cursor:"nwse-resize"},{id:"s",fx:0.5,fy:1,cursor:"ns-resize"},{id:"sw",fx:0,fy:1,cursor:"nesw-resize"},{id:"w",fx:0,fy:0.5,cursor:"ew-resize"}];function M1(z,J,$){let Q=[],j=null,Z=-1,Y=null,V=null,P=z.getContext("2d");function M(){let K=z.getBoundingClientRect().width;return K>0?z.width/K:1}function B(K){let G=z.getBoundingClientRect();return{x:(K.clientX-G.left)/G.width*z.width,y:(K.clientY-G.top)/G.height*z.height}}function N(K){let G=K.size??U1;if(!P)return(K.text?.length??0)*G*0.6;P.save(),P.font=`600 ${G}px system-ui, sans-serif`;let F=P.measureText(K.text??"").width;return P.restore(),F}function q(K){if(K.tool==="text"){let G=K.size??U1;return{left:K.x1,top:K.y1,right:K.x1+N(K),bottom:K.y1+G*1.25}}return{left:Math.min(K.x1,K.x2),top:Math.min(K.y1,K.y2),right:Math.max(K.x1,K.x2),bottom:Math.max(K.y1,K.y2)}}function R(K){if(K.tool==="arrow")return[{id:"tail",x:K.x1,y:K.y1,cursor:"move"},{id:"head",x:K.x2,y:K.y2,cursor:"move"}];let G=q(K);if(K.tool==="text")return[{id:"size",x:G.right,y:G.bottom,cursor:"nwse-resize"}];return i6.map((F)=>({id:F.id,x:G.left+(G.right-G.left)*F.fx,y:G.top+(G.bottom-G.top)*F.fy,cursor:F.cursor}))}function O(K){let G=q(K);return{x:G.right+q2*M(),y:G.top-q2*M()}}function A(K,G,F){let{shaft:W,head:X}=D2({x:G.x1,y:G.y1},{x:G.x2,y:G.y2},Math.max(10,16*F));if(W)K.lineCap="butt",K.beginPath(),K.moveTo(W.from.x,W.from.y),K.lineTo(W.to.x,W.to.y),K.stroke();K.beginPath(),K.moveTo(X[0].x,X[0].y),K.lineTo(X[1].x,X[1].y),K.lineTo(X[2].x,X[2].y),K.closePath(),K.fill()}function T(K,G,F){K.save(),K.lineWidth=Math.max(2,3*F),K.strokeStyle=P1,K.fillStyle=P1;let W=q(G);if(G.tool==="rect")K.strokeRect(W.left,W.top,W.right-W.left,W.bottom-W.top);else if(G.tool==="arrow")A(K,G,F);else if(G.tool==="highlight")K.fillStyle=c6,K.fillRect(W.left,W.top,W.right-W.left,W.bottom-W.top);else if(G.tool==="text"&&G.text){let X=G.size??U1;K.font=`600 ${X}px system-ui, sans-serif`,K.textBaseline="top";let H=X*0.22;K.fillStyle="rgba(255,255,255,0.92)",K.fillRect(W.left-H,W.top-H,W.right-W.left+H*2,W.bottom-W.top+H*2),K.fillStyle=P1,K.fillText(G.text,W.left,W.top)}K.restore()}function C(K,G,F){let W=q(G);K.save(),K.strokeStyle=I2,K.lineWidth=Math.max(1,1.5*F),K.setLineDash([6*F,4*F]),K.strokeRect(W.left,W.top,W.right-W.left,W.bottom-W.top),K.setLineDash([]);let X=B2*F;for(let w of R(G))K.fillStyle="#fff",K.strokeStyle=I2,K.lineWidth=Math.max(1,1.5*F),K.beginPath(),K.rect(w.x-X/2,w.y-X/2,X,X),K.fill(),K.stroke();let H=O(G),U=N2*F;K.beginPath(),K.arc(H.x,H.y,U,0,Math.PI*2),K.fillStyle="#dc2626",K.fill(),K.strokeStyle="#fff",K.lineWidth=Math.max(1.5,2*F),K.beginPath(),K.moveTo(H.x-U*0.4,H.y-U*0.4),K.lineTo(H.x+U*0.4,H.y+U*0.4),K.moveTo(H.x+U*0.4,H.y-U*0.4),K.lineTo(H.x-U*0.4,H.y+U*0.4),K.stroke(),K.restore()}function D(){if(!P)return;let K=M();if(P.clearRect(0,0,z.width,z.height),P.drawImage(J,0,0,z.width,z.height),Q.forEach((F,W)=>{if(W!==y)T(P,F,K)}),Y)T(P,Y,K);let G=Q[Z];if(G&&!Y)C(P,G,K)}function p(K,G,F,W,X){return Math.abs(K-F)<=X&&Math.abs(G-W)<=X}function f(K,G){let F=Q[Z];if(!F)return null;let W=B2*M()/2+3*M();for(let X of R(F))if(p(K,G,X.x,X.y,W))return X.id;return null}function d(K,G){let F=Q[Z];if(!F)return!1;let W=O(F);return p(K,G,W.x,W.y,N2*M())}function m(K,G){let F=6*M();for(let W=Q.length-1;W>=0;W-=1){let X=Q[W];if(X.tool==="arrow"){let U=X.x2-X.x1,w=X.y2-X.y1,x=Math.hypot(U,w)||1,v=Math.max(0,Math.min(1,((K-X.x1)*U+(G-X.y1)*w)/(x*x)));if(Math.hypot(K-(X.x1+v*U),G-(X.y1+v*w))<=F+4*M())return W;continue}let H=q(X);if(K>=H.left-F&&K<=H.right+F&&G>=H.top-F&&G<=H.bottom+F)return W}return-1}function b(K,G,F,W,X){if(G==="tail"){K.x1=F.x1+W,K.y1=F.y1+X;return}if(G==="head"){K.x2=F.x2+W,K.y2=F.y2+X;return}if(G==="size"){let h2=(F.size??24)+X;K.size=Math.max(10,h2);return}let H=q(F),{left:U,top:w,right:x,bottom:v}=H;if(G.includes("w"))U=Math.min(x-E0,U+W);if(G.includes("e"))x=Math.max(U+E0,x+W);if(G.includes("n"))w=Math.min(v-E0,w+X);if(G.includes("s"))v=Math.max(w+E0,v+X);K.x1=U,K.y1=w,K.x2=x,K.y2=v}function j0(K,G,F,W){K.x1=G.x1+F,K.y1=G.y1+W,K.x2=G.x2+F,K.y2=G.y2+W}let L=null,y=-1,I={x:0,y:0,size:24};function k(){let K=z.getBoundingClientRect().width;return K>0?K/z.width:1}function H0(K,G){if(!P)return K.length*G*0.6;P.save(),P.font=`600 ${G}px system-ui, sans-serif`;let F=P.measureText(K||" ").width;return P.restore(),F}function P0(){if(!L)return;let K=z.parentElement;if(!K)return;let G=z.getBoundingClientRect(),F=K.getBoundingClientRect(),W=k(),X=I.size*W;L.style.left=`${G.left-F.left+I.x*W}px`,L.style.top=`${G.top-F.top+I.y*W}px`,L.style.fontSize=`${X}px`,L.style.width=`${Math.max(40,H0(L.value,X)+X)}px`}function g(K){let G=L;if(!G)return;L=null;let F=G.value.trim(),W=y;if(y=-1,G.remove(),K&&F){if(W>=0&&Q[W])Q[W].text=F,Z=W;else Q.push({tool:"text",x1:I.x,y1:I.y,x2:I.x,y2:I.y,text:F,size:I.size}),Z=Q.length-1;$()}else if(W>=0)Z=W;z.focus(),D()}function r(K,G,F=-1){g(!0);let W=z.parentElement;if(!W)return;if(getComputedStyle(W).position==="static")W.style.position="relative";let X=F>=0?Q[F]:void 0;y=F,I={x:X?.x1??K,y:X?.y1??G,size:X?.size??Math.round(24*M())};let H=document.createElement("input");H.type="text",H.className="text-edit",H.value=X?.text??"",H.setAttribute("aria-label","ข้อความบนภาพ"),H.placeholder="ข้อความ",L=H,W.append(H),P0(),H.addEventListener("input",P0),H.addEventListener("keydown",(U)=>{if(U.stopPropagation(),U.key==="Enter")g(!0);else if(U.key==="Escape")g(!1)}),requestAnimationFrame(()=>{if(L!==H)return;H.focus(),H.select(),H.addEventListener("blur",()=>g(!0))}),D()}function n(K){let{x:G,y:F}=B(K);if(z.setPointerCapture(K.pointerId),d(G,F)){a();return}let W=f(G,F);if(W&&Q[Z]){V={grip:W,x:G,y:F,start:{...Q[Z]}};return}if(j==="text"){if(K.preventDefault(),z.hasPointerCapture(K.pointerId))z.releasePointerCapture(K.pointerId);j=null,$(),r(G,F);return}if(j){Y={tool:j,x1:G,y1:F,x2:G,y2:F},Z=-1;return}let X=m(G,F);Z=X,V=X>=0?{grip:"body",x:G,y:F,start:{...Q[X]}}:null,D()}function s(K){let{x:G,y:F}=B(K);if(Y){Y.x2=G,Y.y2=F,D();return}if(V){let X=Q[Z];if(!X)return;let H=G-V.x,U=F-V.y;if(V.grip==="body")j0(X,V.start,H,U);else b(X,V.grip,V.start,H,U);D();return}if(j){z.style.cursor="crosshair";return}if(d(G,F)){z.style.cursor="pointer";return}let W=f(G,F);if(W){let X=Q[Z]?R(Q[Z]).find((H)=>H.id===W):null;z.style.cursor=X?.cursor??"pointer";return}z.style.cursor=m(G,F)>=0?"move":"default"}function z0(){if(Y){if(!(Math.abs(Y.x2-Y.x1)<w2&&Math.abs(Y.y2-Y.y1)<w2))Q.push(Y),Z=Q.length-1,j=null,$();Y=null}if(V)V=null,$();D()}function w0(K){let G=z.getBoundingClientRect(),F=(K.clientX-G.left)/G.width*z.width,W=(K.clientY-G.top)/G.height*z.height,X=m(F,W),H=Q[X];if(!H||H.tool!=="text")return;K.preventDefault(),r(H.x1,H.y1,X)}function c(K){if(Z<0)return;if(K.key==="Delete"||K.key==="Backspace")K.preventDefault(),a();else if(K.key==="Escape")K.preventDefault(),Z=-1,D()}function a(){if(Z<0)return;Q.splice(Z,1),Z=-1,$(),D()}return z.addEventListener("pointerdown",n),z.addEventListener("pointermove",s),z.addEventListener("pointerup",z0),z.addEventListener("pointercancel",z0),z.addEventListener("dblclick",w0),z.tabIndex=0,z.addEventListener("keydown",c),D(),{setTool(K){j=K,Z=-1,z.style.cursor=K?"crosshair":"default",D()},deleteSelected:a,clear(){Q.length=0,Z=-1,$(),D()},hasShapes:()=>Q.length>0,hasSelection:()=>Z>=0,toDataUrl(){let K=document.createElement("canvas");K.width=J.naturalWidth,K.height=J.naturalHeight;let G=K.getContext("2d");if(!G)return z.toDataURL("image/png");G.drawImage(J,0,0);let F=M();for(let W of Q)T(G,W,F);return K.toDataURL("image/png")},destroy(){g(!1),z.removeEventListener("pointerdown",n),z.removeEventListener("pointermove",s),z.removeEventListener("pointerup",z0),z.removeEventListener("pointercancel",z0),z.removeEventListener("dblclick",w0),z.removeEventListener("keydown",c)}}}var l6=["keydown","keyup","keypress"];function h0(z){for(let J of l6)z.addEventListener(J,($)=>$.stopPropagation())}var C2=`
42
42
  :host { all: initial; }
43
43
  * { box-sizing: border-box; }
44
44
 
@@ -122,19 +122,58 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
122
122
  }
123
123
  .foot .grow { flex: 1; }
124
124
 
125
- /* ขอให้ทีมดำเนินการ: the chooser and the request form — a smaller dialog, no image in it. */
126
- .panel.narrow { width: min(560px, 100%); }
127
- .choices { display: grid; gap: 10px; padding-bottom: 24px; }
128
- button.choice {
129
- display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
130
- width: 100%; padding: 14px 16px; text-align: left; border-radius: 12px;
131
- }
132
- button.choice b { font-size: 15px; font-weight: 600; }
133
- button.choice span { font-size: 13px; font-weight: 400; color: #64748b; }
134
- button.choice:focus-visible { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }
135
- .panel.narrow p { margin: 0; }
136
- .ask-type { font-size: 14px; font-weight: 600; margin-top: -8px; }
137
- `;var Q0="lw-debug-reporter";function N2(J,$){if(J instanceof b){if(J.kind==="offline")return $.failedOffline;if(J.kind==="unavailable")return $.failedUnavailable;if(J.kind==="rateLimited")return $.failedTooMany.replace("{seconds}",J.retryAfter??"60");return J.message||$.failed}return $.failed}var B2=()=>[];function d6(J){B2=J}var c6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function i6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"}),S0(this.root)}connectedCallback(){this.dataset.debugReporter="true",this.stop=g0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let z=l(w().locale);if($.type==="manual"){let Q=$1();if(Q?.length){this.renderChooser(z,$,Q);return}if(Q===null)$0()}await this.report($,z)}async report($,z){let Q=await l0();if(Q.method==="cancelled"){this.close();return}this.bundle=i0({reason:$,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:l6()}),this.renderForm(z)}renderChooser($,z,Q){let j=this.shell($);j.classList.add("narrow"),j.setAttribute("aria-label",$.chooseTitle);let Z=S("div","head"),W=E("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),Z.append(S("h2","",$.chooseTitle),W);let G=q2($.chooseProblem,$.chooseProblemHint);G.dataset.choose="problem",G.addEventListener("click",()=>{this.root.replaceChildren(),this.report(z,$)});let F=q2($.chooseRequest,$.chooseRequestHint);F.dataset.choose="request",F.addEventListener("click",()=>this.renderRequestForm($,z,Q));let P=S("div","choices");P.append(G,F),j.append(Z,P),G.focus()}renderRequestForm($,z,Q){let j=this.shell($);j.classList.add("narrow"),j.setAttribute("aria-label",$.requestTitle);let Z=S("div","head"),W=E("✕","icon");W.setAttribute("aria-label",$.close),W.addEventListener("click",()=>this.close()),Z.append(S("h2","",$.requestTitle),W);let G=Q[0],F=S("p","status",""),P=()=>{let D=[G.description,G.targetHours?$.requestTarget.replace("{time}",o6($,G.targetHours)):""].filter(Boolean);F.textContent=D.join(" · ")},q=[z0($.requestTypeLabel,"",!0)];if(Q.length>1){let D=document.createElement("select");D.dataset.requestType="";for(let N of Q){let k=document.createElement("option");k.value=N.id,k.textContent=N.name,D.append(k)}D.addEventListener("change",()=>{G=Q.find((N)=>N.id===D.value)??G,P()}),q.push(D)}else q.push(S("p","ask-type",G.name));P();let M=document.createElement("input");M.type="text",M.placeholder=$.requestSummaryPlaceholder,M.maxLength=300;let I=document.createElement("textarea");I.placeholder=$.requestDetailPlaceholder;let O=S("p","status",""),C=E($.requestSubmit,"primary");C.disabled=!0,M.addEventListener("input",()=>{C.disabled=M.value.trim().length===0});let R=E($.back);R.addEventListener("click",()=>this.renderChooser($,z,Q));let L=S("div","foot");L.append(R,O,S("span","grow"),C),j.append(Z,...q,F,z0($.requestSummaryLabel,"",!0),M,z0($.requestDetailLabel),I,L),C.addEventListener("click",async()=>{C.disabled=!0,O.dataset.tone="",O.textContent=$.submitting;try{let D=await z1({ticketTypeId:G.id,title:M.value.trim(),description:I.value}),N=this.dispatchEvent(new CustomEvent("lw-request-submitted",{detail:D,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),N)p(`${$.requestSubmitted} — #${D.number}`,"success")}catch(D){let N=N2(D,$);O.dataset.tone="error",O.textContent=N,p(N,"error"),C.disabled=!1}}),M.focus()}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let z=document.createElement("style");z.textContent=C2;let Q=document.createElement("div");Q.className="backdrop";let j=document.createElement("div");return j.className="panel",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","true"),j.setAttribute("aria-label",$.title),Q.append(j),this.root.replaceChildren(z,Q),j}renderShell($,z){let Q=this.shell($),j=S("div","head");j.append(S("h2","",$.title)),Q.append(j,S("p","status",z))}renderForm($){let z=this.bundle;if(!z)return;let Q=this.shell($),j=S("div","head"),Z=E("✕","icon");Z.setAttribute("aria-label",$.close),Z.addEventListener("click",()=>this.close()),j.append(S("h2","",$.title),Z);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=z0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let P=S("div","meta");P.innerHTML="";let{context:q}=z;for(let[R,L]of[[$.reporter,`${q.user.fullName??"—"} (${q.user.email??"—"})`],[$.page,q.route.href],[$.captured,`${z.network.length} network · ${z.console.length} console · ${z.actionTrail.length} actions${z.replay?` · ${$.replay} ${Math.round(z.replay.durationMs/1000)}s`:""}`]]){let D=document.createElement("div"),N=document.createElement("b");N.textContent=`${R}: `,D.append(N,document.createTextNode(L)),P.append(D)}let M=S("p","status",""),I=E($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),Q.append(j,G,W,z0($.detailLabel),F,P),z.screenshotDataUrl)Q.append(...this.screenshotSection($,z.screenshotDataUrl));else Q.append(S("p","status",$.noScreenshot));let O=S("div","foot"),C=E($.close);C.addEventListener("click",()=>this.close()),O.append(C,M,S("span","grow"),I),Q.append(O),I.addEventListener("click",async()=>{I.disabled=!0,M.dataset.tone="",M.textContent=$.submitting;try{let R=await e0(W.value.trim(),{...z,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():z.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)p(`${$.submitted} — #${R.number}`,"success")}catch(R){let L=N2(R,$);M.dataset.tone="error",M.textContent=L,p(L,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,z){let Q=z0($.annotateHint),j=S("div","tools"),Z=document.createElement("canvas"),W=S("div","shot");W.append(Z);let G=[],F=(I)=>{for(let O of G)O.setAttribute("aria-pressed",String(O===I))};for(let{tool:I,key:O}of c6){let C=E($[O]);C.setAttribute("aria-pressed","false"),C.addEventListener("click",()=>{let R=C.getAttribute("aria-pressed")==="true";F(R?null:C),this.annotator?.setTool(R?null:I)}),G.push(C),j.append(C)}j.append(S("span","sep"));let P=E($.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let q=E($.clearAll);q.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),j.append(P,q);let M=new Image;return M.onload=()=>{Z.width=M.naturalWidth,Z.height=M.naturalHeight,this.annotator=Z1(Z,M,()=>{F(null),P.disabled=!this.annotator?.hasSelection()})},M.src=z,[Q,j,S("p","status",$.annotateHelp),W]}}}function l6(){try{return B2()}catch{return[]}}function S(J,$="",z=""){let Q=document.createElement(J);if($)Q.className=$;if(z)Q.textContent=z;return Q}function o6(J,$){return $>=24&&$%24===0?J.days.replace("{n}",String($/24)):J.hours.replace("{n}",String($))}function q2(J,$){let z=E("","choice"),Q=document.createElement("b");Q.textContent=J;let j=document.createElement("span");return j.textContent=$,z.append(Q,j),z}function E(J,$=""){let z=document.createElement("button");if(z.type="button",z.textContent=J,$)z.className=$;return z}function z0(J,$="",z=!1){let Q=document.createElement("label");if(Q.append(document.createTextNode(J)),z){let j=document.createElement("span");j.className="req",j.textContent=" *",Q.append(j)}if($){let j=document.createElement("span");j.className="hint",j.textContent=` ${$}`,Q.append(j)}return Q}function K1(){if(typeof window>"u"||customElements.get(Q0))return;customElements.define(Q0,i6())}var w2=!1;function r6(J={}){if(w2||typeof window>"u")return;if(!K0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(w2=!0,n1(),k1(),R1(),v1(),a1(),J.ui===!1)return;let $=l(w().locale);if(y0((Q)=>{p(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>b0(Q)})}),K1(),!document.querySelector(Q0))document.body.append(document.createElement(Q0));let z=window.requestIdleCallback;if(z)z(()=>void $0(),{timeout:5000});else setTimeout(()=>void $0(),2000)}var n6=new Set(["error","exception","unhandledrejection"]);function S2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function W1(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function s6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function a6(J,$,z){let Q=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let j=J.map((W)=>W1(W.at)),Z=(W)=>{for(let G=W+1;G<j.length;G+=1){let F=j[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=j[G]??null,P=(G>0?j[G-1]:null)??null,q=F!==null&&P!==null?Math.max(0,F-P):null;if(F===null)return Q(q);let M=F,I=Math.max(M,Z(G)),O=(D)=>D!==null&&D>=M&&(D<I||I===Number.POSITIVE_INFINITY),C=$.filter((D)=>O(W1(D.startedAt))),R=z.filter((D)=>n6.has(D.level)&&O(W1(D.at))),L=C.map((D)=>D.durationMs).filter((D)=>typeof D==="number");return{elapsedMs:q,requests:C,failedRequests:C.filter(S2),consoleErrors:R,slowestMs:L.length>0?Math.max(...L):null}})}function t6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function e6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let z=Math.floor($/60),Q=Math.round($%60);return Q===0?`${z} นาที`:`${z} นาที ${Q} วิ`}var J8="lw-portal-handoff",O2=138.23,$8=`
125
+ /* ขอให้ทีมดำเนินการ — the same dialog turned into a request (docs/WIDGET-ASK-PLAN.md):
126
+ แจ้งปัญหา · คำขอ as two cards under the heading, the way the desk's own
127
+ สร้างเวิร์กโฟลว์ asks it; what is asked for as cards, the way the portal lists it. */
128
+ [hidden] { display: none !important; }
129
+ .kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: -4px; }
130
+ button.kind {
131
+ position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
132
+ padding: 12px 34px 12px 14px; text-align: left; border-radius: 12px;
133
+ }
134
+ .kind-top { display: flex; align-items: center; gap: 8px; font-size: 15px; }
135
+ .kind-top b { font-weight: 600; }
136
+ .kind-hint { font-size: 13px; font-weight: 400; line-height: 1.5; color: #64748b; }
137
+ button.kind .icon { width: 18px; height: 18px; flex-shrink: 0; color: #64748b; }
138
+ button.kind[data-kind="request"] .icon { color: #1d4ed8; }
139
+ button.kind .tick { position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; color: #2563eb; opacity: 0; }
140
+ button.kind[aria-checked="true"], button.kind[aria-checked="true"]:hover:not(:disabled) {
141
+ border-color: #2563eb; background: #eff6ff; box-shadow: inset 0 0 0 1px #2563eb;
142
+ }
143
+ button.kind[aria-checked="true"] .tick { opacity: 1; }
144
+ button.kind:focus-visible, button.type:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }
145
+ button.kind[aria-checked="true"]:focus-visible { box-shadow: inset 0 0 0 1px #2563eb, 0 0 0 3px rgba(37, 99, 235, 0.25); }
146
+ .types { display: grid; gap: 8px; }
147
+ button.type {
148
+ display: flex; align-items: flex-start; gap: 10px; width: 100%;
149
+ padding: 10px 12px; text-align: left; border-radius: 10px;
150
+ }
151
+ button.type .icon { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; color: #64748b; }
152
+ button.type[aria-checked="true"], button.type[aria-checked="true"]:hover:not(:disabled) { border-color: #2563eb; background: #eff6ff; }
153
+ button.type[aria-checked="true"] .icon { color: #2563eb; }
154
+ .type-body { display: grid; gap: 2px; min-width: 0; }
155
+ .type-body b { font-size: 14px; font-weight: 600; }
156
+ .type-hint { font-size: 13px; font-weight: 400; color: #64748b; }
157
+ .type-due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 400; color: #64748b; }
158
+ button.type .type-due .icon { width: 12px; height: 12px; margin: 0; }
159
+ /* A phone: the two kinds still side by side — their names are the choice; the hints stay short. */
160
+ @media (max-width: 480px) {
161
+ .kind-hint { font-size: 12px; }
162
+ button.kind { padding: 10px 30px 10px 12px; }
163
+ }
164
+ button.link {
165
+ display: inline; padding: 0; border: 0; border-radius: 4px; background: none;
166
+ font-size: 13px; font-weight: 600; color: #2563eb;
167
+ text-decoration: underline; text-underline-offset: 3px;
168
+ }
169
+ button.link:hover:not(:disabled) { background: none; color: #1d4ed8; }
170
+ button.link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
171
+ .ask p { margin: 0; }
172
+ .shot-choice { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
173
+ .shot-choice input { width: 16px; height: 16px; margin: 0; accent-color: #2563eb; }
174
+ .dropped { opacity: 0.35; pointer-events: none; }
175
+ .draft { margin: -8px 0 0; padding: 8px 12px; border-radius: 10px; background: #eff6ff; font-size: 13px; color: #1e3a8a; }
176
+ `;var F0="lw-debug-reporter",e=null;function o6(z,J){if(z instanceof l){if(z.kind==="offline")return J.failedOffline;if(z.kind==="unavailable")return J.failedUnavailable;if(z.kind==="rateLimited")return J.failedTooMany.replace("{seconds}",z.retryAfter??"60");return z.message||J.failed}return J.failed}var _2=()=>[];function r6(z){_2=z}var n6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function s6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;keep=null;returnFocus=null;constructor(){super();this.root=this.attachShadow({mode:"open"}),h0(this.root),this.root.addEventListener("keydown",(J)=>{let $=J;if($.key!=="Escape"||$.defaultPrevented||!this.root.querySelector("[role=dialog]"))return;$.preventDefault(),this.close()})}connectedCallback(){this.dataset.debugReporter="true",this.stop=n0((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let $=document.activeElement;this.returnFocus=$ instanceof HTMLElement&&$!==document.body?$:null;let Q=J0(_().locale);if(f0()===null)Q0();await this.report(J,Q)}async report(J,$){let Q=await j1();if(Q.method==="cancelled"){this.close();return}this.bundle=Q1({reason:J,note:"",screenshotDataUrl:Q.dataUrl,screenshotMethod:Q.method,erroredQueries:a6()}),this.renderForm($,J)}close(J=!1){if(J)e=null;else if(this.keep)e=this.keep()??e;this.keep=null,this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren();let $=this.returnFocus;if(this.returnFocus=null,$?.isConnected)$.focus()}shell(J){let $=document.createElement("style");$.textContent=C2;let Q=document.createElement("div");Q.className="backdrop";let j=document.createElement("div");return j.className="panel",j.setAttribute("role","dialog"),j.setAttribute("aria-modal","true"),j.setAttribute("aria-label",J.title),Q.append(j),this.root.replaceChildren($,Q),j}renderShell(J,$){let Q=this.shell(J),j=S("div","head");j.append(S("h2","",J.title)),Q.append(j,S("p","status",$))}renderForm(J,$){let Q=this.bundle;if(!Q)return;let j=this.shell(J),Z="problem",Y=null,V=S("div","head"),P=S("h2","",J.title),M=o("✕","icon");M.setAttribute("aria-label",J.close),M.addEventListener("click",()=>this.close()),V.append(P,M);let B=S("div","kinds");B.hidden=!0,B.setAttribute("role","radiogroup"),B.setAttribute("aria-label",J.chooseTitle);let N=(X,H,U,w)=>{let x=o("","kind");x.setAttribute("role","radio"),x.dataset.kind=X;let v=S("span","kind-top");return v.append(m0(H),S("b","",U)),x.append(v,S("span","kind-hint",w),m0(J8,"tick")),x.addEventListener("click",()=>z0(X)),x},q=N("problem",e6,J.kindProblem,J.kindProblemHint),R=N("request",S2,J.kindRequest,J.kindRequestHint);B.append(q,R),B.addEventListener("keydown",(X)=>{if(!x2.includes(X.key))return;X.preventDefault(),z0(Z==="problem"?"request":"problem"),(Z==="problem"?q:R).focus()});let O=S("div","ask");O.hidden=!0;let A=S("div","types");A.setAttribute("role","radiogroup"),A.setAttribute("aria-label",J.requestTypeLabel),O.append(b0(J.requestTypeLabel,"",!0),A);let T=[],C=()=>{for(let X of T){let H=X.dataset.requestType===Y?.id;X.setAttribute("aria-checked",String(H)),X.tabIndex=H?0:-1}},D=document.createElement("input");D.type="text";let p=b0(""),f=document.createElement("textarea"),d=b0(""),m=S("div","meta"),{context:b}=Q,j0=`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${J.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`,L=(X,H)=>{let U=document.createElement("div"),w=document.createElement("b");w.textContent=`${X}: `;let x=document.createTextNode(H);return U.append(w,x),m.append(U),{b:w,v:x}};L(J.reporter,`${b.user.fullName??"—"} (${b.user.email??"—"})`),L(J.page,b.route.href);let y=L(J.captured,j0),I=document.createElement("label");I.className="shot-choice",I.hidden=!0;let k=document.createElement("input");k.type="checkbox",k.checked=!0,k.dataset.requestShot="",I.append(k,document.createTextNode(` ${J.requestWithShot}`));let H0=Q.screenshotDataUrl?this.screenshotSection(J,Q.screenshotDataUrl):[S("p","status",J.noScreenshot)],P0=Q.screenshotDataUrl?H0[0]:null;if(!Q.screenshotDataUrl)I.replaceChildren();let g=S("p","status",""),r=o(J.submit,"primary"),n=()=>{r.disabled=D.value.trim().length===0||Z==="request"&&!Y};D.addEventListener("input",n);let s=()=>{let X=Z==="request";P.textContent=B.hidden?J.title:J.chooseTitle,j.setAttribute("aria-label",X?J.requestTitle:J.title);for(let[H,U]of[[q,!X],[R,X]])H.setAttribute("aria-checked",String(U)),H.tabIndex=U?0:-1;if(O.hidden=!X,g0(p,X?J.requestSummaryLabel:J.summaryLabel,X?"":J.summaryRequired,!0),D.placeholder=X?J.requestSummaryPlaceholder:J.summaryPlaceholder,g0(d,X?J.requestDetailLabel:J.detailLabel),f.placeholder=X?J.requestDetailPlaceholder:J.detailPlaceholder,y.b.textContent=`${X?J.requestLeaves:J.captured}: `,y.v.textContent=X?J.requestLeavesWhat:j0,I.hidden=!X||!Q.screenshotDataUrl,P0)g0(P0,X?J.requestAnnotateHint:J.annotateHint);for(let H of H0)H.classList.toggle("dropped",X&&!k.checked);r.textContent=X?J.requestSubmit:J.submit,n()};k.addEventListener("change",s);function z0(X){if(X===Z)return;Z=X,s()}let w0=(X)=>{if(this.bundle!==Q||$.type!=="manual"||!X.length)return;Y=X[0],T.length=0;for(let H of X){let U=o("","type");U.setAttribute("role","radio"),U.dataset.requestType=H.id;let w=S("span","type-body");if(w.append(S("b","",H.name)),H.description)w.append(S("span","type-hint",H.description));if(H.targetHours){let x=S("span","type-due");x.append(m0(z8),document.createTextNode(J.requestTarget.replace("{time}",t6(J,H.targetHours)))),w.append(x)}U.append(m0(S2),w),U.addEventListener("click",()=>{Y=H,C(),n()}),T.push(U)}A.replaceChildren(...T),A.onkeydown=(H)=>{if(!x2.includes(H.key)||!Y)return;H.preventDefault();let U=X.findIndex((x)=>x.id===Y.id),w=H.key==="ArrowUp"||H.key==="ArrowLeft"?-1:1;Y=X[(U+w+X.length)%X.length],C(),T.find((x)=>x.dataset.requestType===Y.id)?.focus()},C(),B.hidden=!1,s()},c=e&&(e.title||e.detail)?e:null,a=S("p","draft");if(a.hidden=!c,c){D.value=c.title,f.value=c.detail;let X=o(J.draftClear,"link");X.dataset.draftClear="",X.addEventListener("click",()=>{D.value="",f.value="",e=null,a.hidden=!0,n(),D.focus()}),a.append(document.createTextNode(`${J.draftRestored} · `),X)}let K=f0(),G=(X)=>{if(w0(X),!c?.asking||B.hidden)return;let H=X.find((U)=>U.id===c.typeId);if(H)Y=H,C();Z="request",s()};if(K)G(K);else if($.type==="manual")Q0().then(G);this.keep=()=>({title:D.value,detail:f.value,asking:Z==="request",typeId:Y?.id??null}),j.append(V,B,a,O,p,D,d,f,m,I,...H0);let F=S("div","foot"),W=o(J.close);W.addEventListener("click",()=>this.close()),F.append(W,g,S("span","grow"),r),j.append(F),s(),r.addEventListener("click",async()=>{r.disabled=!0,g.dataset.tone="",g.textContent=J.submitting;let X=()=>this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl;try{if(Z==="request"&&Y){let w=await H1({ticketTypeId:Y.id,title:D.value.trim(),description:f.value,screenshotDataUrl:k.checked?X():null}),x=this.dispatchEvent(new CustomEvent("lw-request-submitted",{detail:w,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(!0),x)$0(`${J.requestSubmitted} — #${w.number}`,"success");return}let H=await W1(D.value.trim(),{...Q,note:f.value,screenshotDataUrl:X()}),U=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:H,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(!0),U)$0(`${J.submitted} — #${H.number}`,"success")}catch(H){let U=o6(H,J);g.dataset.tone="error",g.textContent=U,$0(U,"error"),n()}}),D.focus()}screenshotSection(J,$){let Q=b0(J.annotateHint),j=S("div","tools"),Z=document.createElement("canvas"),Y=S("div","shot");Y.append(Z);let V=[],P=(q)=>{for(let R of V)R.setAttribute("aria-pressed",String(R===q))};for(let{tool:q,key:R}of n6){let O=o(J[R]);O.setAttribute("aria-pressed","false"),O.addEventListener("click",()=>{let A=O.getAttribute("aria-pressed")==="true";P(A?null:O),this.annotator?.setTool(A?null:q)}),V.push(O),j.append(O)}j.append(S("span","sep"));let M=o(J.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let B=o(J.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),P(null)}),j.append(M,B);let N=new Image;return N.onload=()=>{Z.width=N.naturalWidth,Z.height=N.naturalHeight,this.annotator=M1(Z,N,()=>{P(null),M.disabled=!this.annotator?.hasSelection()})},N.src=$,[Q,j,S("p","status",J.annotateHelp),Y]}}}function a6(){try{return _2()}catch{return[]}}function S(z,J="",$=""){let Q=document.createElement(z);if(J)Q.className=J;if($)Q.textContent=$;return Q}function t6(z,J){return J>=24&&J%24===0?z.days.replace("{n}",String(J/24)):z.hours.replace("{n}",String(J))}var x2=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"],e6=[["path",{d:"M12 20v-9"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}],["path",{d:"M14.12 3.88 16 2"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}],["path",{d:"M22 13h-4"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}],["path",{d:"M6 13H2"}],["path",{d:"m8 2 1.88 1.88"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"}]],S2=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2"}]],z8=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]],J8=[["path",{d:"M20 6 9 17l-5-5"}]],O2="http://www.w3.org/2000/svg";function m0(z,J="icon"){let $=document.createElementNS(O2,"svg");for(let[Q,j]of Object.entries({viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",class:J}))$.setAttribute(Q,j);for(let[Q,j]of z){let Z=document.createElementNS(O2,Q);for(let[Y,V]of Object.entries(j))Z.setAttribute(Y,V);$.append(Z)}return $}function o(z,J=""){let $=document.createElement("button");if($.type="button",$.textContent=z,J)$.className=J;return $}function b0(z,J="",$=!1){return g0(document.createElement("label"),z,J,$)}function g0(z,J,$="",Q=!1){if(z.replaceChildren(document.createTextNode(J)),Q){let j=document.createElement("span");j.className="req",j.textContent=" *",z.append(j)}if($){let j=document.createElement("span");j.className="hint",j.textContent=` ${$}`,z.append(j)}return z}function D1(){if(typeof window>"u"||customElements.get(F0))return;customElements.define(F0,s6())}var R2=!1;function $8(z={}){if(R2||typeof window>"u")return;if(!U0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(R2=!0,z2(),b1(),T1(),i1(),$2(),z.ui===!1)return;let J=J0(_().locale);if(a0((Q)=>{$0(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>s0(Q)})}),D1(),!document.querySelector(F0))document.body.append(document.createElement(F0));let $=window.requestIdleCallback;if($)$(()=>void Q0(),{timeout:5000});else setTimeout(()=>void Q0(),2000)}var Q8=new Set(["error","exception","unhandledrejection"]);function L2(z){if(z.error)return!0;return z.status!==null&&z.status>=400}function I1(z){if(!z)return null;let J=Date.parse(z);return Number.isNaN(J)?null:J}function j8(z){try{let{pathname:J}=new URL(z,"http://x");try{return decodeURIComponent(J)}catch{return J}}catch{return z.split(/[?#]/)[0]??z}}function Z8(z,J,$){let Q=(Y)=>({elapsedMs:Y,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(z.length===0)return[];let j=z.map((Y)=>I1(Y.at)),Z=(Y)=>{for(let V=Y+1;V<j.length;V+=1){let P=j[V];if(P!=null)return P}return Number.POSITIVE_INFINITY};return z.map((Y,V)=>{let P=j[V]??null,M=(V>0?j[V-1]:null)??null,B=P!==null&&M!==null?Math.max(0,P-M):null;if(P===null)return Q(B);let N=P,q=Math.max(N,Z(V)),R=(C)=>C!==null&&C>=N&&(C<q||q===Number.POSITIVE_INFINITY),O=J.filter((C)=>R(I1(C.startedAt))),A=$.filter((C)=>Q8.has(C.level)&&R(I1(C.at))),T=O.map((C)=>C.durationMs).filter((C)=>typeof C==="number");return{elapsedMs:B,requests:O,failedRequests:O.filter(L2),consoleErrors:A,slowestMs:T.length>0?Math.max(...T):null}})}function K8(z,J){return z.requests.length===0&&z.consoleErrors.length===0&&(z.elapsedMs===null||z.elapsedMs<J)}function Y8(z){if(z<1000)return`${Math.round(z)} มิลลิวินาที`;let J=z/1000;if(J<10)return`${J.toFixed(1)} วิ`;if(J<60)return`${Math.round(J)} วิ`;let $=Math.floor(J/60),Q=Math.round(J%60);return Q===0?`${$} นาที`:`${$} นาที ${Q} วิ`}var X8="lw-portal-handoff",k2=138.23,G8=`
138
177
  :host { all: initial; }
139
178
  .backdrop {
140
179
  position: fixed; inset: 0; z-index: 2147483002;
@@ -164,10 +203,10 @@ button.choice:focus-visible { outline: none; border-color: #2563eb; box-shadow:
164
203
  .ring .track { stroke: #e2e8f0; }
165
204
  .ring .bar {
166
205
  stroke: #0ea5e9; transform: rotate(-90deg); transform-origin: 50% 50%;
167
- stroke-dasharray: ${O2}; stroke-dashoffset: 0;
206
+ stroke-dasharray: ${k2}; stroke-dashoffset: 0;
168
207
  animation: deplete var(--secs, 3s) linear forwards;
169
208
  }
170
- @keyframes deplete { to { stroke-dashoffset: ${O2}; } }
209
+ @keyframes deplete { to { stroke-dashoffset: ${k2}; } }
171
210
  .count {
172
211
  position: absolute; inset: 0; display: grid; place-items: center;
173
212
  font-size: 18px; font-weight: 600; color: #0f172a;
@@ -211,7 +250,7 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
211
250
  .ring .bar { animation: none; stroke-dashoffset: 0; }
212
251
  .spinner { animation-duration: 2s; }
213
252
  }
214
- `;function _2(J){if(typeof document>"u")return J.prepare().then((D)=>void J.go(D),()=>{return});let $=l(w().locale),z=Math.max(1,Math.floor(J.seconds??3)),Q=document.createElement(J8),j=Q.attachShadow({mode:"open"});S0(j);let Z=document.createElement("style");Z.textContent=$8,j.append(Z);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
253
+ `;function A2(z){if(typeof document>"u")return z.prepare().then((C)=>void z.go(C),()=>{return});let J=J0(_().locale),$=Math.max(1,Math.floor(z.seconds??3)),Q=document.createElement(X8),j=Q.attachShadow({mode:"open"});h0(j);let Z=document.createElement("style");Z.textContent=G8,j.append(Z);let Y=document.createElement("div");Y.className="backdrop",Y.innerHTML=`
215
254
  <div class="card" role="dialog" aria-modal="true" aria-labelledby="lw-ho-title">
216
255
  <div class="dial">
217
256
  <svg class="ring" viewBox="0 0 52 52" aria-hidden="true">
@@ -227,4 +266,4 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
227
266
  <button type="button" class="cancel"></button>
228
267
  <button type="button" class="go"></button>
229
268
  </div>
230
- </div>`,j.append(W);let G=(D)=>W.querySelector(D),F=G(".card"),P=G(".bar"),q=G(".count"),M=G("h2"),I=G(".body"),O=G(".host"),C=G(".go"),R=G(".cancel");M.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{O.textContent=new URL(w().host).host}catch{O.textContent=""}C.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${z}s`),q.textContent=String(z),document.body.append(Q),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let L=document.activeElement;return C.focus({preventScroll:!0}),new Promise((D)=>{let N=!1,k=null,j0=!1,o=Date.now()+z*1000,y=window.setInterval(()=>{let _=Math.ceil((o-Date.now())/1000);if(q.textContent=String(Math.max(0,_)),Date.now()>=o)A()},100);function u(_){if(N)return;if(N=!0,window.clearInterval(y),document.removeEventListener("keydown",d,!0),W.removeAttribute("data-open"),window.setTimeout(()=>Q.remove(),200),!_)L?.focus?.({preventScroll:!0});D()}function _0(_){window.clearInterval(y),P.classList.remove("spinner"),P.style.animation="none",q.textContent="",M.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let h=document.createElement("a");h.className="go",h.href=_,h.target="_blank",h.rel="noopener noreferrer",h.textContent=$.handoffOpen,h.addEventListener("click",()=>u(!0)),C.replaceWith(h),h.focus({preventScroll:!0})}function A(){if(N||j0)return;if(k)return J.go(k)?u(!0):_0(k);window.clearInterval(y),q.textContent="",P.classList.add("spinner"),M.textContent=$.handoffPreparing}function d(_){if(_.key==="Escape")_.stopPropagation(),u(!1)}document.addEventListener("keydown",d,!0),C.addEventListener("click",A),R.addEventListener("click",()=>u(!1)),W.addEventListener("click",(_)=>{if(_.target===W)u(!1)}),J.prepare().then((_)=>{if(k=_,!N&&Date.now()>=o)A()},()=>{j0=!0,window.clearInterval(y),F.classList.add("error"),P.classList.remove("spinner"),P.style.animation="none",q.textContent="",M.textContent=$.handoffFailed,I.textContent=$.handoffBody,C.remove(),R.textContent=$.close})})}var z8="/sso";function A2(J,$,z,Q){let j=new URL(z8,J.endsWith("/")?J:`${J}/`);if(j.searchParams.set("realm",$),j.searchParams.set("token",z),Q)j.searchParams.set("return",Q);return j.toString()}class O0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function R2(J){let $=w();if(!$.identity)throw new O0;let z=await $.identity();if(!z)throw new O0;return A2($.host,$.realmKey,z,J)}function L2(J,$){if($==="_self")return window.location.assign(J),!0;let z=window.open(J,"_blank");if(!z)return!1;try{z.opener=null}catch{}return!0}async function Q8(J={}){if(J.announce===!1){L2(await R2(J.returnTo),J.target);return}await _2({seconds:J.seconds,prepare:()=>R2(J.returnTo),go:($)=>L2($,J.target)})}export{n0 as trimToBudget,z2 as toCurl,u0 as takeReplay,A2 as supportPortalUrl,z1 as submitRequest,e0 as submitBundle,l4 as stopReplay,p as showToast,d6 as setErroredQueriesSource,$1 as requestTypesNow,s6 as requestPath,l as reporterStrings,g as redactUrl,n as redactLabel,s as redactHeaders,a as redactBody,a0 as packReplay,Q8 as openSupportPortal,g0 as onLaunch,y0 as onCrash,y2 as moduleResolver,$0 as loadRequestTypes,b0 as launch,i4 as isReplayRecording,t6 as isQuietStep,S2 as isFailedRequest,K0 as isConfigured,r6 as installDebugCapture,X6 as hasCause,p0 as getNetworkLog,m0 as getConsoleLog,w as getConfig,E0 as getActionTrail,e6 as formatDuration,o0 as errorSignature,v0 as emitCrash,K1 as defineReporterElement,Z1 as createAnnotator,a6 as correlateActionTrail,E2 as configureDebugCapture,l0 as captureScreen,Y6 as bundleToMarkdown,V6 as bundleFileName,i0 as buildBundle,m as appInfo,k0 as actionCountSuffix,Q0 as REPORTER_TAG,W2 as REPLAY_FILENAME,r as REDACTED,O0 as NoIdentityError,r0 as BUNDLE_BUDGET_BYTES};
269
+ </div>`,j.append(Y);let V=(C)=>Y.querySelector(C),P=V(".card"),M=V(".bar"),B=V(".count"),N=V("h2"),q=V(".body"),R=V(".host"),O=V(".go"),A=V(".cancel");N.textContent=J.handoffTitle,q.textContent=J.handoffBody;try{R.textContent=new URL(_().host).host}catch{R.textContent=""}O.textContent=J.handoffGo,A.textContent=J.cancel,P.style.setProperty("--secs",`${$}s`),B.textContent=String($),document.body.append(Q),requestAnimationFrame(()=>Y.setAttribute("data-open","1"));let T=document.activeElement;return O.focus({preventScroll:!0}),new Promise((C)=>{let D=!1,p=null,f=!1,d=Date.now()+$*1000,m=window.setInterval(()=>{let I=Math.ceil((d-Date.now())/1000);if(B.textContent=String(Math.max(0,I)),Date.now()>=d)L()},100);function b(I){if(D)return;if(D=!0,window.clearInterval(m),document.removeEventListener("keydown",y,!0),Y.removeAttribute("data-open"),window.setTimeout(()=>Q.remove(),200),!I)T?.focus?.({preventScroll:!0});C()}function j0(I){window.clearInterval(m),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",N.textContent=J.handoffBlocked,q.textContent=J.handoffBody;let k=document.createElement("a");k.className="go",k.href=I,k.target="_blank",k.rel="noopener noreferrer",k.textContent=J.handoffOpen,k.addEventListener("click",()=>b(!0)),O.replaceWith(k),k.focus({preventScroll:!0})}function L(){if(D||f)return;if(p)return z.go(p)?b(!0):j0(p);window.clearInterval(m),B.textContent="",M.classList.add("spinner"),N.textContent=J.handoffPreparing}function y(I){if(I.key==="Escape")I.stopPropagation(),b(!1)}document.addEventListener("keydown",y,!0),O.addEventListener("click",L),A.addEventListener("click",()=>b(!1)),Y.addEventListener("click",(I)=>{if(I.target===Y)b(!1)}),z.prepare().then((I)=>{if(p=I,!D&&Date.now()>=d)L()},()=>{f=!0,window.clearInterval(m),P.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",N.textContent=J.handoffFailed,q.textContent=J.handoffBody,O.remove(),A.textContent=J.close})})}var V8="/sso";function E2(z,J,$,Q){let j=new URL(V8,z.endsWith("/")?z:`${z}/`);if(j.searchParams.set("realm",J),j.searchParams.set("token",$),Q)j.searchParams.set("return",Q);return j.toString()}class p0 extends Error{constructor(z="No identity provider is configured, or nobody is signed in"){super(z);this.name="NoIdentityError"}}async function T2(z){let J=_();if(!J.identity)throw new p0;let $=await J.identity();if(!$)throw new p0;return E2(J.host,J.realmKey,$,z)}function f2(z,J){if(J==="_self")return window.location.assign(z),!0;let $=window.open(z,"_blank");if(!$)return!1;try{$.opener=null}catch{}return!0}async function W8(z={}){if(z.announce===!1){f2(await T2(z.returnTo),z.target);return}await A2({seconds:z.seconds,prepare:()=>T2(z.returnTo),go:(J)=>f2(J,z.target)})}export{Y1 as trimToBudget,Y2 as toCurl,z1 as takeReplay,E2 as supportPortalUrl,H1 as submitRequest,W1 as submitBundle,s4 as stopReplay,$0 as showToast,r6 as setErroredQueriesSource,f0 as requestTypesNow,j8 as requestPath,J0 as reporterStrings,i as redactUrl,K0 as redactLabel,Y0 as redactHeaders,X0 as redactBody,G1 as packReplay,W8 as openSupportPortal,n0 as onLaunch,a0 as onCrash,d2 as moduleResolver,Q0 as loadRequestTypes,s0 as launch,n4 as isReplayRecording,K8 as isQuietStep,L2 as isFailedRequest,U0 as isConfigured,$8 as installDebugCapture,U6 as hasCause,e0 as getNetworkLog,r0 as getConsoleLog,_ as getConfig,l0 as getActionTrail,Y8 as formatDuration,Z1 as errorSignature,t0 as emitCrash,D1 as defineReporterElement,M1 as createAnnotator,Z8 as correlateActionTrail,g2 as configureDebugCapture,j1 as captureScreen,F6 as bundleToMarkdown,P6 as bundleFileName,Q1 as buildBundle,u as appInfo,c0 as actionCountSuffix,F0 as REPORTER_TAG,W2 as REPLAY_FILENAME,Z0 as REDACTED,p0 as NoIdentityError,K1 as BUNDLE_BUDGET_BYTES};
@@ -26,4 +26,5 @@ export declare function submitRequest(input: {
26
26
  ticketTypeId: string;
27
27
  title: string;
28
28
  description: string;
29
+ screenshotDataUrl?: string | null;
29
30
  }): Promise<FiledTicket>;
@@ -65,10 +65,10 @@ export interface Strings {
65
65
  handoffBlocked: string;
66
66
  handoffOpen: string;
67
67
  chooseTitle: string;
68
- chooseProblem: string;
69
- chooseProblemHint: string;
70
- chooseRequest: string;
71
- chooseRequestHint: string;
68
+ kindProblem: string;
69
+ kindProblemHint: string;
70
+ kindRequest: string;
71
+ kindRequestHint: string;
72
72
  requestTitle: string;
73
73
  requestTypeLabel: string;
74
74
  /** Carries `{time}`. */
@@ -79,7 +79,15 @@ export interface Strings {
79
79
  requestDetailPlaceholder: string;
80
80
  requestSubmit: string;
81
81
  requestSubmitted: string;
82
- back: string;
82
+ /** The picture, a request's to keep or take off. */
83
+ requestWithShot: string;
84
+ requestAnnotateHint: string;
85
+ /** What was typed last time and not sent, back in the form — and the way to clear it. */
86
+ draftRestored: string;
87
+ draftClear: string;
88
+ /** In the captured row, turned: what a request does NOT send. */
89
+ requestLeaves: string;
90
+ requestLeavesWhat: string;
83
91
  /** Carry `{n}`. */
84
92
  days: string;
85
93
  hours: string;
@@ -10,4 +10,4 @@
10
10
  * Everything is explicit for the same reason: the host's `body` font and colours
11
11
  * do not inherit past the boundary, so stating them is not belt-and-braces.
12
12
  */
13
- export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; }\n\n.backdrop {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; align-items: center; justify-content: center;\n padding: 24px; background: rgba(15, 23, 42, 0.55);\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Noto Sans Thai\", sans-serif;\n color: #0f172a;\n}\n.panel {\n display: flex; flex-direction: column; gap: 16px;\n width: min(820px, 100%); max-height: 90vh; overflow-y: auto;\n /* No bottom padding: the footer supplies its own and sits flush, so it can\n stick to the panel's edge without a gap under it. */\n padding: 24px 24px 0; border-radius: 16px; background: #fff;\n box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);\n}\n.head { display: flex; align-items: flex-start; gap: 12px; }\nh2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }\nlabel { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }\n.req { color: #dc2626; }\n.hint { font-weight: 400; color: #64748b; }\ninput[type=\"text\"], textarea, select {\n width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\ninput[type=\"text\"]:focus, textarea:focus, select:focus {\n outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);\n}\ntextarea { min-height: 88px; resize: vertical; }\n\n.meta {\n padding: 12px 14px; border-radius: 10px; background: #f8fafc;\n font-size: 13px; line-height: 1.7; color: #475569; word-break: break-all;\n}\n.meta b { color: #0f172a; font-weight: 600; }\n\n.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }\n.sep { width: 1px; align-self: stretch; background: #e2e8f0; margin: 0 4px; }\nbutton {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\nbutton:hover:not(:disabled) { background: #f1f5f9; }\nbutton:disabled { opacity: 0.5; cursor: not-allowed; }\nbutton[aria-pressed=\"true\"] { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }\nbutton.primary { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.primary:hover:not(:disabled) { background: #1d4ed8; }\nbutton.icon { padding: 6px 10px; border-color: transparent; font-size: 18px; line-height: 1; }\n\n/* The on-image text editor. Absolutely placed over the canvas and matched to\n the shape it becomes \u2014 same weight, same red, same white plate \u2014 so what you\n type is what gets drawn, at the position you clicked. Sized in JS, because\n the font size tracks the image's own scale. */\n.text-edit {\n position: absolute; z-index: 2; margin: 0; padding: 2px 4px;\n font-family: system-ui, sans-serif; font-weight: 600; line-height: 1.25;\n color: #e11d48; background: rgba(255, 255, 255, 0.92);\n border: 1px dashed #e11d48; border-radius: 4px; outline: none;\n box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);\n}\n.text-edit::placeholder { color: rgba(225, 29, 72, 0.45); }\n\ncanvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; border-radius: 10px; touch-action: none; }\n.shot { position: relative; }\n.status { font-size: 13px; color: #64748b; }\n.status[data-tone=\"error\"] { color: #dc2626; }\n/* Pinned to the bottom of the scrolling panel.\n A screenshot is tall \u2014 often taller than the viewport \u2014 so \u0E41\u0E08\u0E49\u0E07\u0E1B\u0E31\u0E0D\u0E2B\u0E32 sat\n below the fold and the last step of filing a report was \"scroll to the end\n and find the button\". Sticky, with its own ground and a rule above it so the\n annotated image scrolls underneath rather than bleeding into it. */\n.foot {\n position: sticky; bottom: 0; z-index: 3;\n display: flex; align-items: center; gap: 12px;\n margin: 4px -24px 0; padding: 12px 24px;\n background: #fff; border-top: 1px solid #e2e8f0;\n border-radius: 0 0 16px 16px;\n}\n.foot .grow { flex: 1; }\n\n/* \u0E02\u0E2D\u0E43\u0E2B\u0E49\u0E17\u0E35\u0E21\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23: the chooser and the request form \u2014 a smaller dialog, no image in it. */\n.panel.narrow { width: min(560px, 100%); }\n.choices { display: grid; gap: 10px; padding-bottom: 24px; }\nbutton.choice {\n display: flex; flex-direction: column; align-items: flex-start; gap: 2px;\n width: 100%; padding: 14px 16px; text-align: left; border-radius: 12px;\n}\nbutton.choice b { font-size: 15px; font-weight: 600; }\nbutton.choice span { font-size: 13px; font-weight: 400; color: #64748b; }\nbutton.choice:focus-visible { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18); }\n.panel.narrow p { margin: 0; }\n.ask-type { font-size: 14px; font-weight: 600; margin-top: -8px; }\n";
13
+ export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; }\n\n.backdrop {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; align-items: center; justify-content: center;\n padding: 24px; background: rgba(15, 23, 42, 0.55);\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Noto Sans Thai\", sans-serif;\n color: #0f172a;\n}\n.panel {\n display: flex; flex-direction: column; gap: 16px;\n width: min(820px, 100%); max-height: 90vh; overflow-y: auto;\n /* No bottom padding: the footer supplies its own and sits flush, so it can\n stick to the panel's edge without a gap under it. */\n padding: 24px 24px 0; border-radius: 16px; background: #fff;\n box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);\n}\n.head { display: flex; align-items: flex-start; gap: 12px; }\nh2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }\nlabel { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }\n.req { color: #dc2626; }\n.hint { font-weight: 400; color: #64748b; }\ninput[type=\"text\"], textarea, select {\n width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\ninput[type=\"text\"]:focus, textarea:focus, select:focus {\n outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);\n}\ntextarea { min-height: 88px; resize: vertical; }\n\n.meta {\n padding: 12px 14px; border-radius: 10px; background: #f8fafc;\n font-size: 13px; line-height: 1.7; color: #475569; word-break: break-all;\n}\n.meta b { color: #0f172a; font-weight: 600; }\n\n.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }\n.sep { width: 1px; align-self: stretch; background: #e2e8f0; margin: 0 4px; }\nbutton {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\nbutton:hover:not(:disabled) { background: #f1f5f9; }\nbutton:disabled { opacity: 0.5; cursor: not-allowed; }\nbutton[aria-pressed=\"true\"] { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }\nbutton.primary { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.primary:hover:not(:disabled) { background: #1d4ed8; }\nbutton.icon { padding: 6px 10px; border-color: transparent; font-size: 18px; line-height: 1; }\n\n/* The on-image text editor. Absolutely placed over the canvas and matched to\n the shape it becomes \u2014 same weight, same red, same white plate \u2014 so what you\n type is what gets drawn, at the position you clicked. Sized in JS, because\n the font size tracks the image's own scale. */\n.text-edit {\n position: absolute; z-index: 2; margin: 0; padding: 2px 4px;\n font-family: system-ui, sans-serif; font-weight: 600; line-height: 1.25;\n color: #e11d48; background: rgba(255, 255, 255, 0.92);\n border: 1px dashed #e11d48; border-radius: 4px; outline: none;\n box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);\n}\n.text-edit::placeholder { color: rgba(225, 29, 72, 0.45); }\n\ncanvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; border-radius: 10px; touch-action: none; }\n.shot { position: relative; }\n.status { font-size: 13px; color: #64748b; }\n.status[data-tone=\"error\"] { color: #dc2626; }\n/* Pinned to the bottom of the scrolling panel.\n A screenshot is tall \u2014 often taller than the viewport \u2014 so \u0E41\u0E08\u0E49\u0E07\u0E1B\u0E31\u0E0D\u0E2B\u0E32 sat\n below the fold and the last step of filing a report was \"scroll to the end\n and find the button\". Sticky, with its own ground and a rule above it so the\n annotated image scrolls underneath rather than bleeding into it. */\n.foot {\n position: sticky; bottom: 0; z-index: 3;\n display: flex; align-items: center; gap: 12px;\n margin: 4px -24px 0; padding: 12px 24px;\n background: #fff; border-top: 1px solid #e2e8f0;\n border-radius: 0 0 16px 16px;\n}\n.foot .grow { flex: 1; }\n\n/* \u0E02\u0E2D\u0E43\u0E2B\u0E49\u0E17\u0E35\u0E21\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23 \u2014 the same dialog turned into a request (docs/WIDGET-ASK-PLAN.md):\n \u0E41\u0E08\u0E49\u0E07\u0E1B\u0E31\u0E0D\u0E2B\u0E32 \u00B7 \u0E04\u0E33\u0E02\u0E2D as two cards under the heading, the way the desk's own\n \u0E2A\u0E23\u0E49\u0E32\u0E07\u0E40\u0E27\u0E34\u0E23\u0E4C\u0E01\u0E42\u0E1F\u0E25\u0E27\u0E4C asks it; what is asked for as cards, the way the portal lists it. */\n[hidden] { display: none !important; }\n.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: -4px; }\nbutton.kind {\n position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;\n padding: 12px 34px 12px 14px; text-align: left; border-radius: 12px;\n}\n.kind-top { display: flex; align-items: center; gap: 8px; font-size: 15px; }\n.kind-top b { font-weight: 600; }\n.kind-hint { font-size: 13px; font-weight: 400; line-height: 1.5; color: #64748b; }\nbutton.kind .icon { width: 18px; height: 18px; flex-shrink: 0; color: #64748b; }\nbutton.kind[data-kind=\"request\"] .icon { color: #1d4ed8; }\nbutton.kind .tick { position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; color: #2563eb; opacity: 0; }\nbutton.kind[aria-checked=\"true\"], button.kind[aria-checked=\"true\"]:hover:not(:disabled) {\n border-color: #2563eb; background: #eff6ff; box-shadow: inset 0 0 0 1px #2563eb;\n}\nbutton.kind[aria-checked=\"true\"] .tick { opacity: 1; }\nbutton.kind:focus-visible, button.type:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }\nbutton.kind[aria-checked=\"true\"]:focus-visible { box-shadow: inset 0 0 0 1px #2563eb, 0 0 0 3px rgba(37, 99, 235, 0.25); }\n.types { display: grid; gap: 8px; }\nbutton.type {\n display: flex; align-items: flex-start; gap: 10px; width: 100%;\n padding: 10px 12px; text-align: left; border-radius: 10px;\n}\nbutton.type .icon { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; color: #64748b; }\nbutton.type[aria-checked=\"true\"], button.type[aria-checked=\"true\"]:hover:not(:disabled) { border-color: #2563eb; background: #eff6ff; }\nbutton.type[aria-checked=\"true\"] .icon { color: #2563eb; }\n.type-body { display: grid; gap: 2px; min-width: 0; }\n.type-body b { font-size: 14px; font-weight: 600; }\n.type-hint { font-size: 13px; font-weight: 400; color: #64748b; }\n.type-due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 400; color: #64748b; }\nbutton.type .type-due .icon { width: 12px; height: 12px; margin: 0; }\n/* A phone: the two kinds still side by side \u2014 their names are the choice; the hints stay short. */\n@media (max-width: 480px) {\n .kind-hint { font-size: 12px; }\n button.kind { padding: 10px 30px 10px 12px; }\n}\nbutton.link {\n display: inline; padding: 0; border: 0; border-radius: 4px; background: none;\n font-size: 13px; font-weight: 600; color: #2563eb;\n text-decoration: underline; text-underline-offset: 3px;\n}\nbutton.link:hover:not(:disabled) { background: none; color: #1d4ed8; }\nbutton.link:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }\n.ask p { margin: 0; }\n.shot-choice { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }\n.shot-choice input { width: 16px; height: 16px; margin: 0; accent-color: #2563eb; }\n.dropped { opacity: 0.35; pointer-events: none; }\n.draft { margin: -8px 0 0; padding: 8px 12px; border-radius: 10px; background: #eff6ff; font-size: 13px; color: #1e3a8a; }\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "description": "Report-a-problem widget: rolling network/console/action capture, optional rrweb session replay, annotated screenshot, and submission to a Lightwork Support host",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",