@lightworkai.official/debug-capture 0.12.3 → 0.12.5

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/README.md CHANGED
@@ -123,7 +123,9 @@ replays exist to see exactly what happened:
123
123
  the replay still goes (`context.replay.canvasDropped`). `{ fps, quality }`
124
124
  tunes it.
125
125
  - URLs in links and images go through the same redaction as the network log
126
- (`token`, `signature`, `code`, …).
126
+ (`token`, `signature`, `code`, …), and nothing that could run travels:
127
+ inline handlers (`on*`), `javascript:` URLs and `srcdoc` are dropped from
128
+ every snapshot and mutation (the recorder already leaves scripts out).
127
129
 
128
130
  It is taken the way the network and console logs are — part of the capture,
129
131
  listed in the dialog's "เก็บข้อมูลแล้ว" row, not a question put to the reporter.
@@ -274,8 +276,16 @@ await openSupportPortal(); // announces, then a new tab
274
276
  await openSupportPortal({ seconds: 5 }); // a longer countdown
275
277
  await openSupportPortal({ announce: false }); // go on the spot, no dialog
276
278
  await openSupportPortal({ target: "_self" }); // take over this tab instead
279
+ await openSupportPortal({ returnTo: "/me/tickets/<id>" }); // land on one ticket
277
280
  ```
278
281
 
282
+ **`returnTo` is for links that name a ticket.** Your own notification about a
283
+ reply ("ACME-5158 · ทีมงานตอบกลับแล้ว") points at that ticket, and a person who
284
+ follows it should arrive there, not on a list they then have to search. It is a
285
+ hint: the portal accepts only a path under its reporter pages (`/me…`) and lands
286
+ on the list for anything else, so a host cannot send someone off-site through
287
+ it.
288
+
279
289
  **A new tab by default.** Checking on a report is an interruption to something
280
290
  else; replacing the page costs someone their place to answer a question that
281
291
  takes ten seconds. A tab opened after a countdown can be refused — the click's
@@ -299,7 +309,7 @@ cannot reach it. With it, a failure is reported *in* it and the call resolves;
299
309
  with `announce: false` there is nowhere to put the message, so the error is
300
310
  thrown for you to handle.
301
311
 
302
- `supportPortalUrl(host, realmKey, token)` is pure and safe to call on a server.
312
+ `supportPortalUrl(host, realmKey, token, returnTo?)` is pure and safe to call on a server.
303
313
 
304
314
 
305
315
  ## Installing
@@ -1,4 +1,10 @@
1
1
  import type { ReplayEvent } from "../types";
2
+ /**
3
+ * Could this attribute run code on the desk? Handlers, script URLs, and a
4
+ * frame's inline document. In a mutation the answer is "set it to null",
5
+ * which the player applies as a removal; in a snapshot the key goes.
6
+ */
7
+ export declare function isExecutable(name: string, value: unknown): boolean;
2
8
  /**
3
9
  * In place, on a copy: the recorder's buffers are live and a report may be
4
10
  * filed again, so the events handed in are cloned before anything is masked.
@@ -1,4 +1,4 @@
1
- (()=>{var H2=(($)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy($,{get:(J,Q)=>(typeof require<"u"?require:J)[Q]}):$)(function($){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var U2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},O=null;function y0($){let J=[];if(!$.host?.trim())J.push("host");if(!$.realmKey?.trim())J.push("realmKey");if(!$.app?.name?.trim())J.push("app.name");if(typeof $.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.");O=$}function N(){if(!O)throw Error("[debug-capture] configureDebugCapture() has not been called");return O}function Q0(){return O!==null}function g(){let $=N().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??M2()}}function M2(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function x($){let J=O?.capture?.[$];return typeof J==="number"?J:U2[$]}function b0($){let J=O?.module;if(!J)return null;try{return J($)??null}catch{return null}}function j0(){let $=O?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function p0(){return O?.capture?.overlaySelectors??[]}var P2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',I2="[data-lw-mask]",g0={fps:1,quality:0.5};function u(){let $=O?.replay;if(!$)return null;let J=$===!0?{}:$,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=J.maskInputs!==!1,z=J.recordCanvas?{fps:Q(typeof J.recordCanvas==="object"?J.recordCanvas.fps:void 0,g0.fps),quality:Q(typeof J.recordCanvas==="object"?J.recordCanvas.quality:void 0,g0.quality)}:null;return{seconds:Q(J.seconds,60),maskInputs:j,maskTextSelector:J.maskTextSelector?.trim()||(j?P2:I2),maskText:J.maskText===!0,blockSelector:J.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q(J.maxBytes,4000000),canvas:z}}function v0($){if(typeof window>"u")return!1;let J;try{J=new URL($,window.location.href)}catch{return!1}if(q2(J))return!1;if(J.origin===window.location.origin)return!0;return(O?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===J.origin}catch{return!1}})}function q2($){if(!O?.host)return!1;try{if(new URL(O.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function u0($){let J=Object.entries($).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of J)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var d="‹redacted›",B2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,C2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),N2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,D2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,w2=/\d(?:[\d\s-]{7,})\d/g;function i($){return $.replace(D2,d).replace(w2,d)}function k2($){if(B2.test($))return!0;return j0().headers.some((Q)=>Q.toLowerCase()===$.toLowerCase())}function c($){let J={};for(let[Q,j]of Object.entries($))J[Q]=k2(Q)?d:j;return J}function E($){try{let J=/^https?:\/\//i.test($),Q=new URL($,J?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(C2.has(K.toLowerCase())||j0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,d),j=!0}),!j)return $;return J?Q.toString():`${Q.pathname}${Q.search}`}catch{return $}}function M0($,J){if(J>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((j)=>M0(j,J+1));let Q={};for(let[j,z]of Object.entries($)){let K=N2.test(j)||j0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?d:M0(z,J+1)}return Q}function o($,J){if($==null)return null;let Q=$,j=$.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(M0(z,0))}catch{}if(Q.length>J)return`${Q.slice(0,J)}… [truncated ${Q.length-J} chars]`;return Q}var P0=120,I0=40,b=($,J)=>$.length>J?`${$.slice(0,J)}…`:$,q0=($)=>{try{return decodeURIComponent($)}catch{return $}},y=[],d0=0,i0=!1;function l($,J,Q,j){let z=b(J,P0),K=y[y.length-1];if($==="navigate"&&K?.kind==="click"){let X=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${X}`))return K.at=new Date().toISOString(),K;let H=X.split(/[?#]/)[0]??X,M=K.source?q0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(H===M||H.startsWith(M)))return K.detail=b(`${K.detail} → ${X}`,P0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===$&&K.detail===z){if(K.at=new Date().toISOString(),$!=="navigate")K.count=(K.count??1)+1;return K}d0+=1;let W={id:`act_${d0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:Q,html:Z0(j)};y.push(W);while(y.length>x("maxActions"))O2(y.shift());return W}var S2=200000,r=0;function Z0($){if(!$)return;if(r+$.length>S2)return;return r+=$.length,$}function O2($){if(!$)return;if(r-=($.html?.length??0)+($.afterHtml?.length??0),r<0)r=0}function z0($){return $ instanceof Element&&Boolean($.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',_2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},c0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function T2($){let J=$.getAttribute("role");if(J&&c0[J])return c0[J];return _2[$.tagName.toLowerCase()]??"ปุ่ม"}function L2($,J){try{let Q=$,j=0;while(Q&&j<=J){let z=a0(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function A2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("title")?.trim();if(Q)return Q;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let j=($.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return q0(z)}return""}function f2($){if(!($ instanceof Element))return null;let J=$.closest(R2)??L2($,4);if(!J)return null;let Q=J.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return J}function x2($){let J=i(A2($));if(!J)return null;return`${T2($)} “${b(J,I0)}”`}var n0=6000,E2=4000,h2=/(?:^|\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 m2($){$.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let J=[$,...Array.from($.querySelectorAll("*"))];for(let z of J){for(let W of Array.from(z.attributes)){let X=W.name.toLowerCase();if(X.startsWith("on")||X==="srcdoc"||X==="value"||X.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(h2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=i(j.nodeValue);j=Q.nextNode()}}function B0($,J,Q){try{let j=$.outerHTML;if(!j||j.length>J)return;let z=$.cloneNode(!0);m2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var g2=($)=>B0($,n0,E2),y2=150000,b2=40000,o0=($)=>B0($,y2,b2);function p2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let J=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${i(J)}”`}var l0=80;function a0($){let J=Object.keys($).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return J?$[J]:null}function v2($){if(typeof $!=="function")return null;try{let J=Function.prototype.toString.call($);return(J.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??J.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function r0($){if(!$)return;return`→ ${$.length>l0?`${$.slice(0,l0)}…`:$}`}function u2($){try{let J=$.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return r0(J);let Q=a0($),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return r0(v2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var d2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function i2(){let $=p0();return $.length?$.join(", "):d2}function c2($){let J=$.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function o2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=$.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return($.textContent??"").replace(/\s+/g," ").trim()}function t0($){let J=i(o2($)),Q=c2($);return J?`เปิด ${Q} “${b(J,I0)}”`:`เปิด ${Q}`}var l2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',r2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function s2($){if($.querySelector(l2))return!0;return r2.test($.textContent??"")}var n2=400,a2=250,t2=8000;function e2($,J){if(typeof MutationObserver>"u"){J.html=Z0(o0($));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(X),window.clearTimeout(H)},K=()=>{if(j)return;if(z(),!$.isConnected)return;J.detail=b(t0($),P0),J.html=Z0(o0($))},W=new MutationObserver(()=>{Q=Date.now()});W.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let X=window.setInterval(()=>{if(j)return;if(!$.isConnected){z();return}if(Date.now()-Q>=n2&&!s2($))K()},a2),H=window.setTimeout(K,t2)}function $4($){if(z0($))return;let J=l("ui",t0($));if(J)e2($,J)}function J4(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=i2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let X of W){if($.has(X))continue;$.add(X),$4(X)}}}).observe(document.body,{childList:!0,subtree:!0})}var Q4=1600,j4=2500;function s0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:b(($.textContent??"").replace(/\s+/g," ").trim(),I0)}}function z4($,J){if(!$.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function Z4($,J){if(typeof MutationObserver>"u")return;let Q=s0($),j=!1,z=(X,H)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),J.afterNote=X,H)J.afterHtml=Z0(B0($,n0,j4))},K=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let X=z4(Q,s0($));if(X)z(X,!0)});K.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},Q4)}function e0(){if(i0||typeof window>"u")return;i0=!0,document.addEventListener("click",(j)=>{if(z0(j.target))return;let z=f2(j.target);if(!z)return;let K=x2(z);if(!K)return;let W=l("click",`คลิก ${K}`,u2(z),g2(z));if(W)Z4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(z0(j.target))return;let z=p2(j.target);if(z)l("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(z0(j.target))return;l("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>l("navigate",`ไปที่ ${q0(E(location.pathname+location.search))}`),J=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=J(...j);return $(),z},history.replaceState=(...j)=>{let z=Q(...j);return $(),z},window.addEventListener("popstate",$),J4()}function $1(){return y.map(($)=>({...$}))}var J1=2000,K0=[],Q1=0,j1=!1;function C0($,J){Q1+=1,K0.push({id:`log_${Q1}`,at:new Date().toISOString(),level:$,message:J.length>J1?`${J.slice(0,J1)}…`:J});while(K0.length>x("maxConsoleEntries"))K0.shift()}function K4(){let $=new WeakSet;return(J,Q)=>{if(typeof Q==="object"&&Q!==null){if($.has(Q))return"[Circular]";$.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function z1($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{let J=JSON.stringify($,K4());if(J!==void 0)return J}catch{}try{return String($)}catch{}try{return Object.prototype.toString.call($)}catch{return`[${typeof $}]`}}function Z1(){if(j1||typeof window>"u")return;j1=!0;let $=["log","info","warn","error","debug"];for(let J of $){let Q=console[J].bind(console);console[J]=(...j)=>{C0(J,j.map(z1).join(" ")),Q(...j)}}window.addEventListener("error",(J)=>{let Q=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";C0("exception",`${J.message}${Q}`)}),window.addEventListener("unhandledrejection",(J)=>{let Q=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:z1(J.reason);C0("unhandledrejection",Q)})}function K1(){return K0.map(($)=>({...$}))}var W1=new Set,G1=new Set;function V1($,J){return $.add(J),()=>$.delete(J)}function Y1($,J){for(let Q of[...$])Q(J)}function X1($){return V1(W1,$)}function W0($={type:"manual"}){Y1(W1,$)}function F1($){return V1(G1,$)}function H1($){Y1(G1,$)}var W4=15000,G4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],U1=!1,M1=0;function V4($){return G4.some((J)=>$.includes(J))}function P1($){let J=$.message??"";if(!J||V4(J))return;let Q=Date.now();if(Q-M1<W4)return;M1=Q,H1({...$,message:J})}function I1(){if(U1||typeof window>"u")return;U1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let J=$.error instanceof Error?$.error:null;P1({type:"runtime-error",message:$.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",($)=>{let J=$.reason;P1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var N1=4000,Y4=1e6,X4=1e7,G0=[],q1=0,B1=!1;function D1($){G0.push($);while(G0.length>x("maxRequests"))G0.shift()}function w1(){return q1+=1,`req_${q1}`}function C1($){let J={};if(!$)return J;if($ instanceof Headers)$.forEach((Q,j)=>{J[j]=Q});else if(Array.isArray($))for(let[Q,j]of $)J[Q]=j;else Object.assign(J,$);return J}function F4($){let J={};return $.forEach((Q,j)=>{J[j]=Q}),J}function H4($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof URLSearchParams)return $.toString();if(typeof FormData<"u"&&$ instanceof FormData)return`[FormData: ${Array.from($.keys()).join(", ")}]`;if(typeof Blob<"u"&&$ instanceof Blob)return`[Blob ${$.size} bytes]`;if($ instanceof ArrayBuffer)return`[ArrayBuffer ${$.byteLength} bytes]`;return"[binary]"}function U4($,J){let Q="",j="GET",z={},K=null;if(typeof $==="string")Q=$;else if($ instanceof URL)Q=$.toString();else Q=$.url,j=$.method||j,z=C1($.headers);if(J){if(J.method)j=J.method;if(J.headers)z={...z,...C1(J.headers)};if(J.body!==void 0)K=H4(J.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function k1($){return!v0($)}function M4($,J){if(k1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let Q=$.headers.get("content-type")??"",j=Number($.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){J.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>Y4){J.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{$.clone().text().then((K)=>{J.responseSnippet=o(K,x("maxBodyChars"))}).catch(()=>{})}catch{}}function S1($,J){if(/[?&]_rsc=/.test($))return!0;for(let Q of Object.keys(J)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function P4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(J,Q)=>{let j=U4(J,Q);if(S1(j.url,j.headers))return $(J,Q);let z={id:w1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:c(j.headers),requestBody:o(j.body,N1),status:null,statusText:null,durationMs:null,via:"fetch"};D1(z);let K=performance.now();try{let W=await $(J,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=c(F4(W.headers)),M4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},$)}function I4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,J=$.open,Q=$.send,j=function(K,W){let X=typeof W==="string"?W:W.toString();return this.__lwEntry=S1(X,{})?void 0:{id:w1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(X),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?o(K,N1):K==null?null:"[non-string body]";let X=performance.now();D1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-X),k1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=o(this.responseText||"",x("maxBodyChars"))}catch{}else{let H=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${H}]`}})}return Q.apply(this,arguments)};$.open=j,$.send=z}function O1(){if(B1)return;B1=!0,P4(),I4()}function R1(){let $=G0.map((Q)=>({...Q})),J=0;for(let Q=$.length-1;Q>=0;Q-=1){let j=$[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if(J+z.length>X4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else J+=z.length}return $}var q4=4,_1=3,B4=4000,C4="[data-debug-reporter]",T1=()=>import("@rrweb/record");function L1($){T1=$}var _=[],N0=null,V0=!1;function A1(){if(typeof window>"u"||N0||V0)return;let $=u();if(!$)return;V0=!0;let J=()=>void N4($);if("requestIdleCallback"in window)window.requestIdleCallback(J,{timeout:3000});else setTimeout(J,1000)}async function N4($){let J;try{J=(await T1()).record}catch(Q){V0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(N0)return;try{N0=J({emit:(Q)=>D4(Q),checkoutEveryNms:Math.max(1000,$.seconds*1000/2),checkoutEveryNth:B4,maskAllInputs:$.maskInputs,maskTextSelector:$.maskText?"*":$.maskTextSelector,blockSelector:`${$.blockSelector}, ${C4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...$.canvas?{canvas:$.canvas.fps}:{}},recordCanvas:$.canvas!==null,...$.canvas?{dataURLOptions:{type:"image/webp",quality:$.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{V0=!1}}function D4($){if($.type===q4||_.length===0){if(_.push([]),_.length>_1)_=_.slice(-_1)}_[_.length-1].push($)}function f1($=Date.now()){let J=u();if(!J||!_.length)return null;let Q=$-J.seconds*1000,j=_.length-1;while(j>0&&(_[j][0]?.timestamp??$)>Q)j-=1;let z=_.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}var w4={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:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกหน้าจอ",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},k4={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",captured:"Captured",reporter:"Reporter",page:"Page",replay:"replay",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"};function Y0($){return $==="en"?k4:w4}var S4="lw-debug-toasts",O4=6000,R4=`
1
+ (()=>{var H2=(($)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy($,{get:(J,Q)=>(typeof require<"u"?require:J)[Q]}):$)(function($){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var U2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},k=null;function y0($){let J=[];if(!$.host?.trim())J.push("host");if(!$.realmKey?.trim())J.push("realmKey");if(!$.app?.name?.trim())J.push("app.name");if(typeof $.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.");k=$}function N(){if(!k)throw Error("[debug-capture] configureDebugCapture() has not been called");return k}function Q0(){return k!==null}function g(){let $=N().app;return{name:$.name,version:$.version??"0.0.0",environment:$.environment??P2()}}function P2(){if(typeof window>"u")return"unknown";let $=window.location.hostname;if($==="localhost"||$==="127.0.0.1"||$.endsWith(".local"))return"development";return"production"}function x($){let J=k?.capture?.[$];return typeof J==="number"?J:U2[$]}function p0($){let J=k?.module;if(!J)return null;try{return J($)??null}catch{return null}}function j0(){let $=k?.redact;return{headers:$?.headers??[],queryKeys:($?.queryKeys??[]).map((J)=>J.toLowerCase()),bodyKeys:($?.bodyKeys??[]).map((J)=>J.toLowerCase())}}function b0(){return k?.capture?.overlaySelectors??[]}var I2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',M2="[data-lw-mask]",g0={fps:1,quality:0.5};function u(){let $=k?.replay;if(!$)return null;let J=$===!0?{}:$,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=J.maskInputs!==!1,z=J.recordCanvas?{fps:Q(typeof J.recordCanvas==="object"?J.recordCanvas.fps:void 0,g0.fps),quality:Q(typeof J.recordCanvas==="object"?J.recordCanvas.quality:void 0,g0.quality)}:null;return{seconds:Q(J.seconds,60),maskInputs:j,maskTextSelector:J.maskTextSelector?.trim()||(j?I2:M2),maskText:J.maskText===!0,blockSelector:J.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q(J.maxBytes,4000000),canvas:z}}function v0($){if(typeof window>"u")return!1;let J;try{J=new URL($,window.location.href)}catch{return!1}if(q2(J))return!1;if(J.origin===window.location.origin)return!0;return(k?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===J.origin}catch{return!1}})}function q2($){if(!k?.host)return!1;try{if(new URL(k.host).origin!==$.origin)return!1}catch{return!1}return $.pathname.startsWith("/ingest/")}function u0($){let J=Object.entries($).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of J)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var d="‹redacted›",B2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,C2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),N2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,D2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,w2=/\d(?:[\d\s-]{7,})\d/g;function i($){return $.replace(D2,d).replace(w2,d)}function O2($){if(B2.test($))return!0;return j0().headers.some((Q)=>Q.toLowerCase()===$.toLowerCase())}function c($){let J={};for(let[Q,j]of Object.entries($))J[Q]=O2(Q)?d:j;return J}function E($){try{let J=/^https?:\/\//i.test($),Q=new URL($,J?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(C2.has(K.toLowerCase())||j0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,d),j=!0}),!j)return $;return J?Q.toString():`${Q.pathname}${Q.search}`}catch{return $}}function P0($,J){if(J>6||$===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((j)=>P0(j,J+1));let Q={};for(let[j,z]of Object.entries($)){let K=N2.test(j)||j0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?d:P0(z,J+1)}return Q}function o($,J){if($==null)return null;let Q=$,j=$.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(P0(z,0))}catch{}if(Q.length>J)return`${Q.slice(0,J)}… [truncated ${Q.length-J} chars]`;return Q}var I0=120,M0=40,p=($,J)=>$.length>J?`${$.slice(0,J)}…`:$,q0=($)=>{try{return decodeURIComponent($)}catch{return $}},y=[],d0=0,i0=!1;function l($,J,Q,j){let z=p(J,I0),K=y[y.length-1];if($==="navigate"&&K?.kind==="click"){let X=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${X}`))return K.at=new Date().toISOString(),K;let H=X.split(/[?#]/)[0]??X,P=K.source?q0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(P&&(H===P||H.startsWith(P)))return K.detail=p(`${K.detail} → ${X}`,I0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===$&&K.detail===z){if(K.at=new Date().toISOString(),$!=="navigate")K.count=(K.count??1)+1;return K}d0+=1;let W={id:`act_${d0}`,at:new Date().toISOString(),kind:$,detail:z,count:1,source:Q,html:Z0(j)};y.push(W);while(y.length>x("maxActions"))k2(y.shift());return W}var S2=200000,r=0;function Z0($){if(!$)return;if(r+$.length>S2)return;return r+=$.length,$}function k2($){if(!$)return;if(r-=($.html?.length??0)+($.afterHtml?.length??0),r<0)r=0}function z0($){return $ instanceof Element&&Boolean($.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',_2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},c0={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function T2($){let J=$.getAttribute("role");if(J&&c0[J])return c0[J];return _2[$.tagName.toLowerCase()]??"ปุ่ม"}function L2($,J){try{let Q=$,j=0;while(Q&&j<=J){let z=a0(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function A2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("title")?.trim();if(Q)return Q;if($ instanceof HTMLInputElement||$ instanceof HTMLTextAreaElement||$ instanceof HTMLSelectElement)return($.getAttribute("placeholder")||$.getAttribute("name")||"").trim();if($ instanceof HTMLImageElement)return($.getAttribute("alt")||"").trim();let j=($.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if($ instanceof HTMLAnchorElement){let z=$.getAttribute("href");if(z?.startsWith("/"))return q0(z)}return""}function f2($){if(!($ instanceof Element))return null;let J=$.closest(R2)??L2($,4);if(!J)return null;let Q=J.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return J}function x2($){let J=i(A2($));if(!J)return null;return`${T2($)} “${p(J,M0)}”`}var n0=6000,E2=4000,h2=/(?:^|\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 m2($){$.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let J=[$,...Array.from($.querySelectorAll("*"))];for(let z of J){for(let W of Array.from(z.attributes)){let X=W.name.toLowerCase();if(X.startsWith("on")||X==="srcdoc"||X==="value"||X.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(h2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=i(j.nodeValue);j=Q.nextNode()}}function B0($,J,Q){try{let j=$.outerHTML;if(!j||j.length>J)return;let z=$.cloneNode(!0);m2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var g2=($)=>B0($,n0,E2),y2=150000,p2=40000,o0=($)=>B0($,y2,p2);function b2($){if(!($ instanceof HTMLInputElement)&&!($ instanceof HTMLTextAreaElement)&&!($ instanceof HTMLSelectElement))return null;let J=$.name||$.id||$.getAttribute("aria-label")||$.getAttribute("placeholder")||$.tagName.toLowerCase();return`ช่อง “${i(J)}”`}var l0=80;function a0($){let J=Object.keys($).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return J?$[J]:null}function v2($){if(typeof $!=="function")return null;try{let J=Function.prototype.toString.call($);return(J.match(/\.(?:push|replace)\(\s*['"`]([^'"`]+)['"`]/)??J.match(/redirect\(\s*['"`]([^'"`]+)['"`]/))?.[1]??null}catch{return null}}function r0($){if(!$)return;return`→ ${$.length>l0?`${$.slice(0,l0)}…`:$}`}function u2($){try{let J=$.closest("a[href]")?.getAttribute("href");if(J&&J.startsWith("/"))return r0(J);let Q=a0($),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return r0(v2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var d2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function i2(){let $=b0();return $.length?$.join(", "):d2}function c2($){let J=$.getAttribute("role");if(J==="status"||J==="alert")return"ข้อความแจ้งเตือน";if(J==="menu")return"เมนู";if(J==="listbox")return"รายการตัวเลือก";if(J==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function o2($){let J=$.getAttribute("aria-label")?.trim();if(J)return J;let Q=$.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=$.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return($.textContent??"").replace(/\s+/g," ").trim()}function t0($){let J=i(o2($)),Q=c2($);return J?`เปิด ${Q} “${p(J,M0)}”`:`เปิด ${Q}`}var l2='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',r2=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function s2($){if($.querySelector(l2))return!0;return r2.test($.textContent??"")}var n2=400,a2=250,t2=8000;function e2($,J){if(typeof MutationObserver>"u"){J.html=Z0(o0($));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(X),window.clearTimeout(H)},K=()=>{if(j)return;if(z(),!$.isConnected)return;J.detail=p(t0($),I0),J.html=Z0(o0($))},W=new MutationObserver(()=>{Q=Date.now()});W.observe($,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let X=window.setInterval(()=>{if(j)return;if(!$.isConnected){z();return}if(Date.now()-Q>=n2&&!s2($))K()},a2),H=window.setTimeout(K,t2)}function $4($){if(z0($))return;let J=l("ui",t0($));if(J)e2($,J)}function J4(){if(typeof MutationObserver>"u")return;let $=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=i2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let X of W){if($.has(X))continue;$.add(X),$4(X)}}}).observe(document.body,{childList:!0,subtree:!0})}var Q4=1600,j4=2500;function s0($){return{disabled:$.hasAttribute("disabled")||$.getAttribute("aria-disabled")==="true",busy:$.getAttribute("aria-busy")==="true",text:p(($.textContent??"").replace(/\s+/g," ").trim(),M0)}}function z4($,J){if(!$.disabled&&J.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!$.busy&&J.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if($.text!==J.text&&J.text)return`ข้อความเปลี่ยนเป็น “${J.text}”`;return null}function Z4($,J){if(typeof MutationObserver>"u")return;let Q=s0($),j=!1,z=(X,H)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),J.afterNote=X,H)J.afterHtml=Z0(B0($,n0,j4))},K=new MutationObserver(()=>{if(!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let X=z4(Q,s0($));if(X)z(X,!0)});K.observe($,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!$.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},Q4)}function e0(){if(i0||typeof window>"u")return;i0=!0,document.addEventListener("click",(j)=>{if(z0(j.target))return;let z=f2(j.target);if(!z)return;let K=x2(z);if(!K)return;let W=l("click",`คลิก ${K}`,u2(z),g2(z));if(W)Z4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(z0(j.target))return;let z=b2(j.target);if(z)l("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(z0(j.target))return;l("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let $=()=>l("navigate",`ไปที่ ${q0(E(location.pathname+location.search))}`),J=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=J(...j);return $(),z},history.replaceState=(...j)=>{let z=Q(...j);return $(),z},window.addEventListener("popstate",$),J4()}function $1(){return y.map(($)=>({...$}))}var J1=2000,K0=[],Q1=0,j1=!1;function C0($,J){Q1+=1,K0.push({id:`log_${Q1}`,at:new Date().toISOString(),level:$,message:J.length>J1?`${J.slice(0,J1)}…`:J});while(K0.length>x("maxConsoleEntries"))K0.shift()}function K4(){let $=new WeakSet;return(J,Q)=>{if(typeof Q==="object"&&Q!==null){if($.has(Q))return"[Circular]";$.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function z1($){if(typeof $==="string")return $;if($ instanceof Error)return`${$.name}: ${$.message}`;try{let J=JSON.stringify($,K4());if(J!==void 0)return J}catch{}try{return String($)}catch{}try{return Object.prototype.toString.call($)}catch{return`[${typeof $}]`}}function Z1(){if(j1||typeof window>"u")return;j1=!0;let $=["log","info","warn","error","debug"];for(let J of $){let Q=console[J].bind(console);console[J]=(...j)=>{C0(J,j.map(z1).join(" ")),Q(...j)}}window.addEventListener("error",(J)=>{let Q=J.filename?` (${J.filename}:${J.lineno}:${J.colno})`:"";C0("exception",`${J.message}${Q}`)}),window.addEventListener("unhandledrejection",(J)=>{let Q=J.reason instanceof Error?`${J.reason.name}: ${J.reason.message}`:z1(J.reason);C0("unhandledrejection",Q)})}function K1(){return K0.map(($)=>({...$}))}var W1=new Set,G1=new Set;function Y1($,J){return $.add(J),()=>$.delete(J)}function V1($,J){for(let Q of[...$])Q(J)}function X1($){return Y1(W1,$)}function W0($={type:"manual"}){V1(W1,$)}function F1($){return Y1(G1,$)}function H1($){V1(G1,$)}var W4=15000,G4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],U1=!1,P1=0;function Y4($){return G4.some((J)=>$.includes(J))}function I1($){let J=$.message??"";if(!J||Y4(J))return;let Q=Date.now();if(Q-P1<W4)return;P1=Q,H1({...$,message:J})}function M1(){if(U1||typeof window>"u")return;U1=!0,window.addEventListener("error",($)=>{if(!$.message&&!$.error)return;let J=$.error instanceof Error?$.error:null;I1({type:"runtime-error",message:$.message||(J?J.message:"Unknown error"),stack:J?.stack})}),window.addEventListener("unhandledrejection",($)=>{let J=$.reason;I1({type:"unhandledrejection",message:J instanceof Error?J.message:String(J),stack:J instanceof Error?J.stack:void 0})})}var N1=4000,V4=1e6,X4=1e7,G0=[],q1=0,B1=!1;function D1($){G0.push($);while(G0.length>x("maxRequests"))G0.shift()}function w1(){return q1+=1,`req_${q1}`}function C1($){let J={};if(!$)return J;if($ instanceof Headers)$.forEach((Q,j)=>{J[j]=Q});else if(Array.isArray($))for(let[Q,j]of $)J[Q]=j;else Object.assign(J,$);return J}function F4($){let J={};return $.forEach((Q,j)=>{J[j]=Q}),J}function H4($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof URLSearchParams)return $.toString();if(typeof FormData<"u"&&$ instanceof FormData)return`[FormData: ${Array.from($.keys()).join(", ")}]`;if(typeof Blob<"u"&&$ instanceof Blob)return`[Blob ${$.size} bytes]`;if($ instanceof ArrayBuffer)return`[ArrayBuffer ${$.byteLength} bytes]`;return"[binary]"}function U4($,J){let Q="",j="GET",z={},K=null;if(typeof $==="string")Q=$;else if($ instanceof URL)Q=$.toString();else Q=$.url,j=$.method||j,z=C1($.headers);if(J){if(J.method)j=J.method;if(J.headers)z={...z,...C1(J.headers)};if(J.body!==void 0)K=H4(J.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function O1($){return!v0($)}function P4($,J){if(O1(J.url)){J.responseSnippet="[body not captured for this origin]";return}let Q=$.headers.get("content-type")??"",j=Number($.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){J.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>V4){J.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{$.clone().text().then((K)=>{J.responseSnippet=o(K,x("maxBodyChars"))}).catch(()=>{})}catch{}}function S1($,J){if(/[?&]_rsc=/.test($))return!0;for(let Q of Object.keys(J)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function I4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let $=window.fetch.bind(window);window.fetch=Object.assign(async(J,Q)=>{let j=U4(J,Q);if(S1(j.url,j.headers))return $(J,Q);let z={id:w1(),startedAt:new Date().toISOString(),method:j.method,url:E(j.url),requestHeaders:c(j.headers),requestBody:o(j.body,N1),status:null,statusText:null,durationMs:null,via:"fetch"};D1(z);let K=performance.now();try{let W=await $(J,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=c(F4(W.headers)),P4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},$)}function M4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let $=XMLHttpRequest.prototype,J=$.open,Q=$.send,j=function(K,W){let X=typeof W==="string"?W:W.toString();return this.__lwEntry=S1(X,{})?void 0:{id:w1(),startedAt:"",method:(K||"GET").toUpperCase(),url:E(X),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},J.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?o(K,N1):K==null?null:"[non-string body]";let X=performance.now();D1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-X),O1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=o(this.responseText||"",x("maxBodyChars"))}catch{}else{let H=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${H}]`}})}return Q.apply(this,arguments)};$.open=j,$.send=z}function k1(){if(B1)return;B1=!0,I4(),M4()}function R1(){let $=G0.map((Q)=>({...Q})),J=0;for(let Q=$.length-1;Q>=0;Q-=1){let j=$[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if(J+z.length>X4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else J+=z.length}return $}var q4=4,_1=3,B4=4000,C4="[data-debug-reporter]",T1=()=>import("@rrweb/record");function L1($){T1=$}var _=[],N0=null,Y0=!1;function A1(){if(typeof window>"u"||N0||Y0)return;let $=u();if(!$)return;Y0=!0;let J=()=>void N4($);if("requestIdleCallback"in window)window.requestIdleCallback(J,{timeout:3000});else setTimeout(J,1000)}async function N4($){let J;try{J=(await T1()).record}catch(Q){Y0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(N0)return;try{N0=J({emit:(Q)=>D4(Q),checkoutEveryNms:Math.max(1000,$.seconds*1000/2),checkoutEveryNth:B4,maskAllInputs:$.maskInputs,maskTextSelector:$.maskText?"*":$.maskTextSelector,blockSelector:`${$.blockSelector}, ${C4}`,slimDOMOptions:"all",inlineStylesheet:!0,sampling:{mousemove:50,scroll:150,media:800,input:"last",...$.canvas?{canvas:$.canvas.fps}:{}},recordCanvas:$.canvas!==null,...$.canvas?{dataURLOptions:{type:"image/webp",quality:$.canvas.quality}}:{},errorHandler:()=>!0})??null}catch(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{Y0=!1}}function D4($){if($.type===q4||_.length===0){if(_.push([]),_.length>_1)_=_.slice(-_1)}_[_.length-1].push($)}function f1($=Date.now()){let J=u();if(!J||!_.length)return null;let Q=$-J.seconds*1000,j=_.length-1;while(j>0&&(_[j][0]?.timestamp??$)>Q)j-=1;let z=_.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}var w4={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:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},O4={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",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"};function V0($){return $==="en"?O4:w4}var S4="lw-debug-toasts",k4=6000,R4=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,7 +30,7 @@
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 _4(){if(typeof document>"u")return null;if(D0?.isConnected)return D0;let $=document.createElement(S4);$.dataset.debugReporter="true";let J=$.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=R4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),J.append(Q,j),document.body.append($),D0=j,j}function s($,J="success",Q){let j=Q0()?N().toast:void 0;if(j){j({message:$,tone:J,...Q?{action:Q}:{}});return}let z=_4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=J;let W=document.createElement("span");W.className="dot";let X=document.createElement("span");X.textContent=$;let H=document.createElement("button");H.type="button",H.className="close",H.textContent="✕",H.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(w),K.remove()};H.addEventListener("click",M);let w=J==="error"||Q?0:window.setTimeout(M,O4);if(K.append(W,X),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),K.append(P)}K.append(H),z.append(K)}function x1($,J,Q){let j=$.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=J.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function T4(){let $={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return $;let J=performance.memory;if(J)$.memoryUsedMb=Math.round(J.usedJSHeapSize/1024/1024),$.memoryLimitMb=Math.round(J.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)$.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),$.loadEventMs=Math.round(Q.loadEventEnd);return $}function w0($,J){if(!$)return J;try{return $()}catch{return J}}function E1(){let $=N(),{pathname:J,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:J,search:Q},module:b0(J),user:w0($.user,{}),apiHeaders:c(w0($.headers,{})),app:{name:g().name,version:g().version,environment:g().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:T4(),extra:w0($.extra,{})}}var L4=2;function h1($){let J=R1(),Q=K1();return{context:E1(),reason:$.reason,note:$.note,cause:x1(J,Q,$.erroredQueries),actionTrail:$1(),network:J,console:Q,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,replay:f1()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:L4}}}async function m1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await A4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await E4();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function A4(){let $=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(J);let Q=await f4($);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((J)=>J.stop())}}async function f4($){let J=document.createElement("video");J.srcObject=$,J.muted=!0,J.playsInline=!0,await new Promise((W)=>{let X=!1,H=()=>{if(X)return;X=!0,W()};J.onloadedmetadata=()=>{J.play().then(H).catch(H)},window.setTimeout(H,1500)}),await x4(J);let{videoWidth:Q,videoHeight:j}=J;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage(J,0,0,Q,j),J.pause(),J.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function x4($){return new Promise((J)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,J()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function E4(){let $=N().screenshotFallback;if(!$)return null;let J=await $().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var h4=2000,m4=0.82,g4=3000000;function y4($){return new Promise((J,Q)=>{let j=new Image;j.onload=()=>J(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=$})}async function g1($){try{let J=await y4($),Q=Math.max(J.naturalWidth,J.naturalHeight),j=Math.min(1,h4/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round(J.naturalWidth*j)),z.height=Math.max(1,Math.round(J.naturalHeight*j));let K=z.getContext("2d");if(!K)return $;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage(J,0,0,z.width,z.height);let W=m4,X=z.toDataURL("image/jpeg",W);while(X.length>g4&&W>0.4)W-=0.15,X=z.toDataURL("image/jpeg",W);return X}catch{return $}}var b4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,p4=/^\d+$/,v4=/^[0-9a-f]{16,}$/i;function y1($){if($.reason.type==="manual")return null;let J=$.cause?.failedRequests?.[0];if(!J?.url)return null;let Q;try{Q=new URL(J.url,"http://x").pathname}catch{Q=J.url}let j=Q.split("/").map((K)=>b4.test(K)||p4.test(K)||v4.test(K)?":id":K).join("/"),z=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${j} ${z}`}var b1=2000000;function X0($){let{screenshotDataUrl:J,replay:Q,...j}=$;return JSON.stringify(j).length}function p1($,J=2000000){if(X0($)<=J)return $;let Q=$.network.map((z)=>({...z})),j={...$,network:Q};for(let z of Q){if(X0(j)<=J)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&X0(j)>J)j.network=j.network.slice(1);while(j.console.length>1&&X0(j)>J)j.console=j.console.slice(1);return j}function n($){let J="";for(let Q=0;Q<$.length;Q+=32768)J+=String.fromCharCode(...$.subarray(Q,Q+32768));return btoa(J)}var u4=4,d4=2,i4=3,c4=0,o4=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]);function v1($){if(!$)return;for(let J of Object.keys($)){let Q=$[J];if(typeof Q!=="string"||!o4.has(J)||!Q.includes("?"))continue;$[J]=E(Q)}}function k0($){if(!$)return;v1($.attributes);for(let J of $.childNodes??[])k0(J)}function u1($){let J=JSON.parse(JSON.stringify($));for(let Q of J){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===u4&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===d4)k0(j.node);else if(Q.type===i4&&j.source===c4){for(let z of j.adds??[])k0(z.node);for(let z of j.attributes??[])v1(z.attributes)}}return J}var l4="session-replay.json.gz",r4="session-replay.json";function s4($){return Boolean($&&$.events.length>0)}async function n4($){if(typeof CompressionStream>"u")return null;try{let J=new Blob([$]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(J).arrayBuffer())}catch{return null}}async function i1($,J){if(!s4($))return{summary:{omitted:"empty"}};let j={seconds:Math.round($.durationMs/1000),events:$.events.length,startedAt:$.startedAt,endedAt:$.endedAt},z=u1($.events),K=await d1(z),W=!1;if(K.bytes.byteLength>J&&e4(z))z=$6(z),K=await d1(z),W=!0;let{bytes:X,compressed:H}=K;if(X.byteLength>J)return{summary:{...j,bytes:X.byteLength,omitted:"too-large"}};return{dataUri:`data:${H?"application/gzip":"application/json"};base64,${n(X)}`,filename:H?l4:r4,summary:{...j,events:z.length,bytes:X.byteLength,compressed:H,...W?{canvasDropped:W}:{}}}}async function d1($){let J=new TextEncoder().encode(JSON.stringify({events:$})),Q=await n4(J);return Q?{bytes:Q,compressed:!0}:{bytes:J,compressed:!1}}var a4=3,c1=2,t4=9;function o1($){return $.type===a4&&$.data?.source===t4}function e4($){return $.some(o1)||$.some((J)=>J.type===c1&&l1(J.data.node))}function l1($){if(!$)return!1;if($.attributes&&"rr_dataURL"in $.attributes)return!0;return($.childNodes??[]).some(l1)}function r1($){if(!$)return;if($.attributes&&"rr_dataURL"in $.attributes)delete $.attributes.rr_dataURL;for(let J of $.childNodes??[])r1(J)}function $6($){let J=[];for(let Q of $){if(o1(Q))continue;if(Q.type===c1)r1(Q.data.node);J.push(Q)}return J}function J6($){let{screenshotDataUrl:J,replay:Q,...j}=$;return{dataUri:`data:application/json;base64,${n(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function Q6(){let $=N().identity;if(!$)return{};try{let J=await $();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function s1($,J){let Q=N(),j=p1(J,b1),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let I=await g1(j.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(J6(j));let X,H=u();if(H){let I=await i1(j.replay,H.maxBytes);if(X=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let M=y1(j),w={title:$,description:K.trim()||void 0,appName:g().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:g().name,module:z.module?.label??""},context:{...M?{signature:M}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...X?{replay:X}:{}},attachments:W},P=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await Q6()},body:JSON.stringify(w)});if(!P.ok){let I=P.headers.get("retry-after"),k=await P.json().then((B)=>B.error).catch(()=>null);throw Error(P.status===429?`Too many reports — try again in ${I??"a moment"}s`:k??`Report failed (${P.status})`)}return await P.json()}var a=Math.PI/6;function n1($,J,Q){let j=J.x-$.x,z=J.y-$.y,K=Math.hypot(j,z),W=Math.atan2(z,j),X=[{x:J.x,y:J.y},{x:J.x-Q*Math.cos(W-a),y:J.y-Q*Math.sin(W-a)},{x:J.x-Q*Math.cos(W+a),y:J.y-Q*Math.sin(W+a)}],H=Q*Math.cos(a)*0.92;if(K<=H)return{shaft:null,head:X};return{shaft:{from:$,to:{x:J.x-H*Math.cos(W),y:J.y-H*Math.sin(W)}},head:X}}var S0="#f44336",j6="rgba(250, 204, 21, 0.4)",O0=22,a1="#2563eb",t1=9,e1=11,$2=18,J2=4,F0=8,z6=[{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 Q2($,J,Q){let j=[],z=null,K=-1,W=null,X=null,H=$.getContext("2d");function M(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function w(Z){let G=$.getBoundingClientRect();return{x:(Z.clientX-G.left)/G.width*$.width,y:(Z.clientY-G.top)/G.height*$.height}}function P(Z){let G=Z.size??O0;if(!H)return(Z.text?.length??0)*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let Y=H.measureText(Z.text??"").width;return H.restore(),Y}function I(Z){if(Z.tool==="text"){let G=Z.size??O0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+G*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function k(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let G=I(Z);if(Z.tool==="text")return[{id:"size",x:G.right,y:G.bottom,cursor:"nwse-resize"}];return z6.map((Y)=>({id:Y.id,x:G.left+(G.right-G.left)*Y.fx,y:G.top+(G.bottom-G.top)*Y.fy,cursor:Y.cursor}))}function B(Z){let G=I(Z);return{x:G.right+$2*M(),y:G.top-$2*M()}}function S(Z,G,Y){let{shaft:V,head:F}=n1({x:G.x1,y:G.y1},{x:G.x2,y:G.y2},Math.max(10,16*Y));if(V)Z.lineCap="butt",Z.beginPath(),Z.moveTo(V.from.x,V.from.y),Z.lineTo(V.to.x,V.to.y),Z.stroke();Z.beginPath(),Z.moveTo(F[0].x,F[0].y),Z.lineTo(F[1].x,F[1].y),Z.lineTo(F[2].x,F[2].y),Z.closePath(),Z.fill()}function L(Z,G,Y){Z.save(),Z.lineWidth=Math.max(2,3*Y),Z.strokeStyle=S0,Z.fillStyle=S0;let V=I(G);if(G.tool==="rect")Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(G.tool==="arrow")S(Z,G,Y);else if(G.tool==="highlight")Z.fillStyle=j6,Z.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(G.tool==="text"&&G.text){let F=G.size??O0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let U=F*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),Z.fillStyle=S0,Z.fillText(G.text,V.left,V.top)}Z.restore()}function e(Z,G,Y){let V=I(G);Z.save(),Z.strokeStyle=a1,Z.lineWidth=Math.max(1,1.5*Y),Z.setLineDash([6*Y,4*Y]),Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),Z.setLineDash([]);let F=t1*Y;for(let R of k(G))Z.fillStyle="#fff",Z.strokeStyle=a1,Z.lineWidth=Math.max(1,1.5*Y),Z.beginPath(),Z.rect(R.x-F/2,R.y-F/2,F,F),Z.fill(),Z.stroke();let U=B(G),q=e1*Y;Z.beginPath(),Z.arc(U.x,U.y,q,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*Y),Z.beginPath(),Z.moveTo(U.x-q*0.4,U.y-q*0.4),Z.lineTo(U.x+q*0.4,U.y+q*0.4),Z.moveTo(U.x+q*0.4,U.y-q*0.4),Z.lineTo(U.x-q*0.4,U.y+q*0.4),Z.stroke(),Z.restore()}function C(){if(!H)return;let Z=M();if(H.clearRect(0,0,$.width,$.height),H.drawImage(J,0,0,$.width,$.height),j.forEach((Y,V)=>{if(V!==$0)L(H,Y,Z)}),W)L(H,W,Z);let G=j[K];if(G&&!W)e(H,G,Z)}function _0(Z,G,Y,V,F){return Math.abs(Z-Y)<=F&&Math.abs(G-V)<=F}function T0(Z,G){let Y=j[K];if(!Y)return null;let V=t1*M()/2+3*M();for(let F of k(Y))if(_0(Z,G,F.x,F.y,V))return F.id;return null}function L0(Z,G){let Y=j[K];if(!Y)return!1;let V=B(Y);return _0(Z,G,V.x,V.y,e1*M())}function H0(Z,G){let Y=6*M();for(let V=j.length-1;V>=0;V-=1){let F=j[V];if(F.tool==="arrow"){let q=F.x2-F.x1,R=F.y2-F.y1,h=Math.hypot(q,R)||1,m=Math.max(0,Math.min(1,((Z-F.x1)*q+(G-F.y1)*R)/(h*h)));if(Math.hypot(Z-(F.x1+m*q),G-(F.y1+m*R))<=Y+4*M())return V;continue}let U=I(F);if(Z>=U.left-Y&&Z<=U.right+Y&&G>=U.top-Y&&G<=U.bottom+Y)return V}return-1}function G2(Z,G,Y,V,F){if(G==="tail"){Z.x1=Y.x1+V,Z.y1=Y.y1+F;return}if(G==="head"){Z.x2=Y.x2+V,Z.y2=Y.y2+F;return}if(G==="size"){let F2=(Y.size??24)+F;Z.size=Math.max(10,F2);return}let U=I(Y),{left:q,top:R,right:h,bottom:m}=U;if(G.includes("w"))q=Math.min(h-F0,q+V);if(G.includes("e"))h=Math.max(q+F0,h+V);if(G.includes("n"))R=Math.min(m-F0,R+F);if(G.includes("s"))m=Math.max(R+F0,m+F);Z.x1=q,Z.y1=R,Z.x2=h,Z.y2=m}function V2(Z,G,Y,V){Z.x1=G.x1+Y,Z.y1=G.y1+V,Z.x2=G.x2+Y,Z.y2=G.y2+V}let A=null,$0=-1,f={x:0,y:0,size:24};function Y2(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function X2(Z,G){if(!H)return Z.length*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let Y=H.measureText(Z||" ").width;return H.restore(),Y}function A0(){if(!A)return;let Z=$.parentElement;if(!Z)return;let G=$.getBoundingClientRect(),Y=Z.getBoundingClientRect(),V=Y2(),F=f.size*V;A.style.left=`${G.left-Y.left+f.x*V}px`,A.style.top=`${G.top-Y.top+f.y*V}px`,A.style.fontSize=`${F}px`,A.style.width=`${Math.max(40,X2(A.value,F)+F)}px`}function v(Z){let G=A;if(!G)return;A=null;let Y=G.value.trim(),V=$0;if($0=-1,G.remove(),Z&&Y){if(V>=0&&j[V])j[V].text=Y,K=V;else j.push({tool:"text",x1:f.x,y1:f.y,x2:f.x,y2:f.y,text:Y,size:f.size}),K=j.length-1;Q()}else if(V>=0)K=V;$.focus(),C()}function f0(Z,G,Y=-1){v(!0);let V=$.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let F=Y>=0?j[Y]:void 0;$0=Y,f={x:F?.x1??Z,y:F?.y1??G,size:F?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=F?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",A=U,V.append(U),A0(),U.addEventListener("input",A0),U.addEventListener("keydown",(q)=>{if(q.stopPropagation(),q.key==="Enter")v(!0);else if(q.key==="Escape")v(!1)}),requestAnimationFrame(()=>{if(A!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>v(!0))}),C()}function x0(Z){let{x:G,y:Y}=w(Z);if($.setPointerCapture(Z.pointerId),L0(G,Y)){U0();return}let V=T0(G,Y);if(V&&j[K]){X={grip:V,x:G,y:Y,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,Q(),f0(G,Y);return}if(z){W={tool:z,x1:G,y1:Y,x2:G,y2:Y},K=-1;return}let F=H0(G,Y);K=F,X=F>=0?{grip:"body",x:G,y:Y,start:{...j[F]}}:null,C()}function E0(Z){let{x:G,y:Y}=w(Z);if(W){W.x2=G,W.y2=Y,C();return}if(X){let F=j[K];if(!F)return;let U=G-X.x,q=Y-X.y;if(X.grip==="body")V2(F,X.start,U,q);else G2(F,X.grip,X.start,U,q);C();return}if(z){$.style.cursor="crosshair";return}if(L0(G,Y)){$.style.cursor="pointer";return}let V=T0(G,Y);if(V){let F=j[K]?k(j[K]).find((U)=>U.id===V):null;$.style.cursor=F?.cursor??"pointer";return}$.style.cursor=H0(G,Y)>=0?"move":"default"}function J0(){if(W){if(!(Math.abs(W.x2-W.x1)<J2&&Math.abs(W.y2-W.y1)<J2))j.push(W),K=j.length-1,z=null,Q();W=null}if(X)X=null,Q();C()}function h0(Z){let G=$.getBoundingClientRect(),Y=(Z.clientX-G.left)/G.width*$.width,V=(Z.clientY-G.top)/G.height*$.height,F=H0(Y,V),U=j[F];if(!U||U.tool!=="text")return;Z.preventDefault(),f0(U.x1,U.y1,F)}function m0(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),U0();else if(Z.key==="Escape")K=-1,C()}function U0(){if(K<0)return;j.splice(K,1),K=-1,Q(),C()}return $.addEventListener("pointerdown",x0),$.addEventListener("pointermove",E0),$.addEventListener("pointerup",J0),$.addEventListener("pointercancel",J0),$.addEventListener("dblclick",h0),$.tabIndex=0,$.addEventListener("keydown",m0),C(),{setTool(Z){z=Z,K=-1,$.style.cursor=Z?"crosshair":"default",C()},deleteSelected:U0,clear(){j.length=0,K=-1,Q(),C()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=J.naturalWidth,Z.height=J.naturalHeight;let G=Z.getContext("2d");if(!G)return $.toDataURL("image/png");G.drawImage(J,0,0);let Y=M();for(let V of j)L(G,V,Y);return Z.toDataURL("image/png")},destroy(){v(!1),$.removeEventListener("pointerdown",x0),$.removeEventListener("pointermove",E0),$.removeEventListener("pointerup",J0),$.removeEventListener("pointercancel",J0),$.removeEventListener("dblclick",h0),$.removeEventListener("keydown",m0)}}}var j2=`
33
+ `,D0=null;function _4(){if(typeof document>"u")return null;if(D0?.isConnected)return D0;let $=document.createElement(S4);$.dataset.debugReporter="true";let J=$.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=R4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),J.append(Q,j),document.body.append($),D0=j,j}function s($,J="success",Q){let j=Q0()?N().toast:void 0;if(j){j({message:$,tone:J,...Q?{action:Q}:{}});return}let z=_4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=J;let W=document.createElement("span");W.className="dot";let X=document.createElement("span");X.textContent=$;let H=document.createElement("button");H.type="button",H.className="close",H.textContent="✕",H.setAttribute("aria-label","ปิด");let P=()=>{window.clearTimeout(w),K.remove()};H.addEventListener("click",P);let w=J==="error"||Q?0:window.setTimeout(P,k4);if(K.append(W,X),Q){let I=document.createElement("button");I.type="button",I.className="action",I.textContent=Q.label,I.addEventListener("click",()=>{P(),Q.onClick()}),K.append(I)}K.append(H),z.append(K)}function x1($,J,Q){let j=$.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=J.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function T4(){let $={memoryUsedMb:null,memoryLimitMb:null,domContentLoadedMs:null,loadEventMs:null};if(typeof performance>"u")return $;let J=performance.memory;if(J)$.memoryUsedMb=Math.round(J.usedJSHeapSize/1024/1024),$.memoryLimitMb=Math.round(J.jsHeapSizeLimit/1024/1024);let[Q]=performance.getEntriesByType("navigation");if(Q)$.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),$.loadEventMs=Math.round(Q.loadEventEnd);return $}function w0($,J){if(!$)return J;try{return $()}catch{return J}}function E1(){let $=N(),{pathname:J,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:J,search:Q},module:p0(J),user:w0($.user,{}),apiHeaders:c(w0($.headers,{})),app:{name:g().name,version:g().version,environment:g().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:T4(),extra:w0($.extra,{})}}var L4=2;function h1($){let J=R1(),Q=K1();return{context:E1(),reason:$.reason,note:$.note,cause:x1(J,Q,$.erroredQueries),actionTrail:$1(),network:J,console:Q,screenshotDataUrl:$.screenshotDataUrl,screenshotMethod:$.screenshotMethod,replay:f1()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:L4}}}async function m1(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await A4();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let J=await E4();if(J)return{dataUrl:J,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function A4(){let $=null;try{let J={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};$=await navigator.mediaDevices.getDisplayMedia(J);let Q=await f4($);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch(J){if(J instanceof DOMException&&(J.name==="NotAllowedError"||J.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{$?.getTracks().forEach((J)=>J.stop())}}async function f4($){let J=document.createElement("video");J.srcObject=$,J.muted=!0,J.playsInline=!0,await new Promise((W)=>{let X=!1,H=()=>{if(X)return;X=!0,W()};J.onloadedmetadata=()=>{J.play().then(H).catch(H)},window.setTimeout(H,1500)}),await x4(J);let{videoWidth:Q,videoHeight:j}=J;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage(J,0,0,Q,j),J.pause(),J.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function x4($){return new Promise((J)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,J()},z=$;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function E4(){let $=N().screenshotFallback;if(!$)return null;let J=await $().catch(()=>null);if(!J)return null;try{return await J(document.body,{cacheBust:!0,pixelRatio:Math.min(window.devicePixelRatio||1,2),filter:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var h4=2000,m4=0.82,g4=3000000;function y4($){return new Promise((J,Q)=>{let j=new Image;j.onload=()=>J(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=$})}async function g1($){try{let J=await y4($),Q=Math.max(J.naturalWidth,J.naturalHeight),j=Math.min(1,h4/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round(J.naturalWidth*j)),z.height=Math.max(1,Math.round(J.naturalHeight*j));let K=z.getContext("2d");if(!K)return $;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage(J,0,0,z.width,z.height);let W=m4,X=z.toDataURL("image/jpeg",W);while(X.length>g4&&W>0.4)W-=0.15,X=z.toDataURL("image/jpeg",W);return X}catch{return $}}var p4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,b4=/^\d+$/,v4=/^[0-9a-f]{16,}$/i;function y1($){if($.reason.type==="manual")return null;let J=$.cause?.failedRequests?.[0];if(!J?.url)return null;let Q;try{Q=new URL(J.url,"http://x").pathname}catch{Q=J.url}let j=Q.split("/").map((K)=>p4.test(K)||b4.test(K)||v4.test(K)?":id":K).join("/"),z=J.status??(J.error?"ERR":"?");return`${J.method??"REQ"} ${j} ${z}`}var p1=2000000;function X0($){let{screenshotDataUrl:J,replay:Q,...j}=$;return JSON.stringify(j).length}function b1($,J=2000000){if(X0($)<=J)return $;let Q=$.network.map((z)=>({...z})),j={...$,network:Q};for(let z of Q){if(X0(j)<=J)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&X0(j)>J)j.network=j.network.slice(1);while(j.console.length>1&&X0(j)>J)j.console=j.console.slice(1);return j}function n($){let J="";for(let Q=0;Q<$.length;Q+=32768)J+=String.fromCharCode(...$.subarray(Q,Q+32768));return btoa(J)}var u4=4,d4=2,i4=3,c4=0,o4=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),l4=/^\s*javascript:/i;function r4($,J){let Q=$.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof J==="string"&&l4.test(J)}function v1($,J=!1){if(!$)return;for(let Q of Object.keys($)){let j=$[Q];if(r4(Q,j)){if(J)$[Q]=null;else delete $[Q];continue}if(typeof j!=="string"||!o4.has(Q)||!j.includes("?"))continue;$[Q]=E(j)}}function O0($){if(!$)return;v1($.attributes);for(let J of $.childNodes??[])O0(J)}function u1($){let J=JSON.parse(JSON.stringify($));for(let Q of J){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===u4&&typeof j.href==="string")j.href=E(j.href);else if(Q.type===d4)O0(j.node);else if(Q.type===i4&&j.source===c4){for(let z of j.adds??[])O0(z.node);for(let z of j.attributes??[])v1(z.attributes,!0)}}return J}var s4="session-replay.json.gz",n4="session-replay.json";function a4($){return Boolean($&&$.events.length>0)}async function t4($){if(typeof CompressionStream>"u")return null;try{let J=new Blob([$]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(J).arrayBuffer())}catch{return null}}async function i1($,J){if(!a4($))return{summary:{omitted:"empty"}};let j={seconds:Math.round($.durationMs/1000),events:$.events.length,startedAt:$.startedAt,endedAt:$.endedAt},z=u1($.events),K=await d1(z),W=!1;if(K.bytes.byteLength>J&&J6(z))z=Q6(z),K=await d1(z),W=!0;let{bytes:X,compressed:H}=K;if(X.byteLength>J)return{summary:{...j,bytes:X.byteLength,omitted:"too-large"}};return{dataUri:`data:${H?"application/gzip":"application/json"};base64,${n(X)}`,filename:H?s4:n4,summary:{...j,events:z.length,bytes:X.byteLength,compressed:H,...W?{canvasDropped:W}:{}}}}async function d1($){let J=new TextEncoder().encode(JSON.stringify({events:$})),Q=await t4(J);return Q?{bytes:Q,compressed:!0}:{bytes:J,compressed:!1}}var e4=3,c1=2,$6=9;function o1($){return $.type===e4&&$.data?.source===$6}function J6($){return $.some(o1)||$.some((J)=>J.type===c1&&l1(J.data.node))}function l1($){if(!$)return!1;if($.attributes&&"rr_dataURL"in $.attributes)return!0;return($.childNodes??[]).some(l1)}function r1($){if(!$)return;if($.attributes&&"rr_dataURL"in $.attributes)delete $.attributes.rr_dataURL;for(let J of $.childNodes??[])r1(J)}function Q6($){let J=[];for(let Q of $){if(o1(Q))continue;if(Q.type===c1)r1(Q.data.node);J.push(Q)}return J}function j6($){let{screenshotDataUrl:J,replay:Q,...j}=$;return{dataUri:`data:application/json;base64,${n(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function z6(){let $=N().identity;if(!$)return{};try{let J=await $();return J?{authorization:`Bearer ${J}`}:{}}catch{return{}}}async function s1($,J){let Q=N(),j=b1(J,p1),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let M=await g1(j.screenshotDataUrl);W.push({dataUri:M,filename:"screenshot.jpg"})}W.push(j6(j));let X,H=u();if(H){let M=await i1(j.replay,H.maxBytes);if(X=M.summary,"dataUri"in M)W.push({dataUri:M.dataUri,filename:M.filename})}let P=y1(j),w={title:$,description:K.trim()||void 0,appName:g().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:g().name,module:z.module?.label??""},context:{...P?{signature:P}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...X?{replay:X}:{}},attachments:W},I=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await z6()},body:JSON.stringify(w)});if(!I.ok){let M=I.headers.get("retry-after"),O=await I.json().then((B)=>B.error).catch(()=>null);throw Error(I.status===429?`Too many reports — try again in ${M??"a moment"}s`:O??`Report failed (${I.status})`)}return await I.json()}var a=Math.PI/6;function n1($,J,Q){let j=J.x-$.x,z=J.y-$.y,K=Math.hypot(j,z),W=Math.atan2(z,j),X=[{x:J.x,y:J.y},{x:J.x-Q*Math.cos(W-a),y:J.y-Q*Math.sin(W-a)},{x:J.x-Q*Math.cos(W+a),y:J.y-Q*Math.sin(W+a)}],H=Q*Math.cos(a)*0.92;if(K<=H)return{shaft:null,head:X};return{shaft:{from:$,to:{x:J.x-H*Math.cos(W),y:J.y-H*Math.sin(W)}},head:X}}var S0="#f44336",Z6="rgba(250, 204, 21, 0.4)",k0=22,a1="#2563eb",t1=9,e1=11,$2=18,J2=4,F0=8,K6=[{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 Q2($,J,Q){let j=[],z=null,K=-1,W=null,X=null,H=$.getContext("2d");function P(){let Z=$.getBoundingClientRect().width;return Z>0?$.width/Z:1}function w(Z){let G=$.getBoundingClientRect();return{x:(Z.clientX-G.left)/G.width*$.width,y:(Z.clientY-G.top)/G.height*$.height}}function I(Z){let G=Z.size??k0;if(!H)return(Z.text?.length??0)*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let V=H.measureText(Z.text??"").width;return H.restore(),V}function M(Z){if(Z.tool==="text"){let G=Z.size??k0;return{left:Z.x1,top:Z.y1,right:Z.x1+I(Z),bottom:Z.y1+G*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function O(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let G=M(Z);if(Z.tool==="text")return[{id:"size",x:G.right,y:G.bottom,cursor:"nwse-resize"}];return K6.map((V)=>({id:V.id,x:G.left+(G.right-G.left)*V.fx,y:G.top+(G.bottom-G.top)*V.fy,cursor:V.cursor}))}function B(Z){let G=M(Z);return{x:G.right+$2*P(),y:G.top-$2*P()}}function S(Z,G,V){let{shaft:Y,head:F}=n1({x:G.x1,y:G.y1},{x:G.x2,y:G.y2},Math.max(10,16*V));if(Y)Z.lineCap="butt",Z.beginPath(),Z.moveTo(Y.from.x,Y.from.y),Z.lineTo(Y.to.x,Y.to.y),Z.stroke();Z.beginPath(),Z.moveTo(F[0].x,F[0].y),Z.lineTo(F[1].x,F[1].y),Z.lineTo(F[2].x,F[2].y),Z.closePath(),Z.fill()}function L(Z,G,V){Z.save(),Z.lineWidth=Math.max(2,3*V),Z.strokeStyle=S0,Z.fillStyle=S0;let Y=M(G);if(G.tool==="rect")Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(G.tool==="arrow")S(Z,G,V);else if(G.tool==="highlight")Z.fillStyle=Z6,Z.fillRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top);else if(G.tool==="text"&&G.text){let F=G.size??k0;Z.font=`600 ${F}px system-ui, sans-serif`,Z.textBaseline="top";let U=F*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(Y.left-U,Y.top-U,Y.right-Y.left+U*2,Y.bottom-Y.top+U*2),Z.fillStyle=S0,Z.fillText(G.text,Y.left,Y.top)}Z.restore()}function e(Z,G,V){let Y=M(G);Z.save(),Z.strokeStyle=a1,Z.lineWidth=Math.max(1,1.5*V),Z.setLineDash([6*V,4*V]),Z.strokeRect(Y.left,Y.top,Y.right-Y.left,Y.bottom-Y.top),Z.setLineDash([]);let F=t1*V;for(let R of O(G))Z.fillStyle="#fff",Z.strokeStyle=a1,Z.lineWidth=Math.max(1,1.5*V),Z.beginPath(),Z.rect(R.x-F/2,R.y-F/2,F,F),Z.fill(),Z.stroke();let U=B(G),q=e1*V;Z.beginPath(),Z.arc(U.x,U.y,q,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*V),Z.beginPath(),Z.moveTo(U.x-q*0.4,U.y-q*0.4),Z.lineTo(U.x+q*0.4,U.y+q*0.4),Z.moveTo(U.x+q*0.4,U.y-q*0.4),Z.lineTo(U.x-q*0.4,U.y+q*0.4),Z.stroke(),Z.restore()}function C(){if(!H)return;let Z=P();if(H.clearRect(0,0,$.width,$.height),H.drawImage(J,0,0,$.width,$.height),j.forEach((V,Y)=>{if(Y!==$0)L(H,V,Z)}),W)L(H,W,Z);let G=j[K];if(G&&!W)e(H,G,Z)}function _0(Z,G,V,Y,F){return Math.abs(Z-V)<=F&&Math.abs(G-Y)<=F}function T0(Z,G){let V=j[K];if(!V)return null;let Y=t1*P()/2+3*P();for(let F of O(V))if(_0(Z,G,F.x,F.y,Y))return F.id;return null}function L0(Z,G){let V=j[K];if(!V)return!1;let Y=B(V);return _0(Z,G,Y.x,Y.y,e1*P())}function H0(Z,G){let V=6*P();for(let Y=j.length-1;Y>=0;Y-=1){let F=j[Y];if(F.tool==="arrow"){let q=F.x2-F.x1,R=F.y2-F.y1,h=Math.hypot(q,R)||1,m=Math.max(0,Math.min(1,((Z-F.x1)*q+(G-F.y1)*R)/(h*h)));if(Math.hypot(Z-(F.x1+m*q),G-(F.y1+m*R))<=V+4*P())return Y;continue}let U=M(F);if(Z>=U.left-V&&Z<=U.right+V&&G>=U.top-V&&G<=U.bottom+V)return Y}return-1}function G2(Z,G,V,Y,F){if(G==="tail"){Z.x1=V.x1+Y,Z.y1=V.y1+F;return}if(G==="head"){Z.x2=V.x2+Y,Z.y2=V.y2+F;return}if(G==="size"){let F2=(V.size??24)+F;Z.size=Math.max(10,F2);return}let U=M(V),{left:q,top:R,right:h,bottom:m}=U;if(G.includes("w"))q=Math.min(h-F0,q+Y);if(G.includes("e"))h=Math.max(q+F0,h+Y);if(G.includes("n"))R=Math.min(m-F0,R+F);if(G.includes("s"))m=Math.max(R+F0,m+F);Z.x1=q,Z.y1=R,Z.x2=h,Z.y2=m}function Y2(Z,G,V,Y){Z.x1=G.x1+V,Z.y1=G.y1+Y,Z.x2=G.x2+V,Z.y2=G.y2+Y}let A=null,$0=-1,f={x:0,y:0,size:24};function V2(){let Z=$.getBoundingClientRect().width;return Z>0?Z/$.width:1}function X2(Z,G){if(!H)return Z.length*G*0.6;H.save(),H.font=`600 ${G}px system-ui, sans-serif`;let V=H.measureText(Z||" ").width;return H.restore(),V}function A0(){if(!A)return;let Z=$.parentElement;if(!Z)return;let G=$.getBoundingClientRect(),V=Z.getBoundingClientRect(),Y=V2(),F=f.size*Y;A.style.left=`${G.left-V.left+f.x*Y}px`,A.style.top=`${G.top-V.top+f.y*Y}px`,A.style.fontSize=`${F}px`,A.style.width=`${Math.max(40,X2(A.value,F)+F)}px`}function v(Z){let G=A;if(!G)return;A=null;let V=G.value.trim(),Y=$0;if($0=-1,G.remove(),Z&&V){if(Y>=0&&j[Y])j[Y].text=V,K=Y;else j.push({tool:"text",x1:f.x,y1:f.y,x2:f.x,y2:f.y,text:V,size:f.size}),K=j.length-1;Q()}else if(Y>=0)K=Y;$.focus(),C()}function f0(Z,G,V=-1){v(!0);let Y=$.parentElement;if(!Y)return;if(getComputedStyle(Y).position==="static")Y.style.position="relative";let F=V>=0?j[V]:void 0;$0=V,f={x:F?.x1??Z,y:F?.y1??G,size:F?.size??Math.round(24*P())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=F?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",A=U,Y.append(U),A0(),U.addEventListener("input",A0),U.addEventListener("keydown",(q)=>{if(q.stopPropagation(),q.key==="Enter")v(!0);else if(q.key==="Escape")v(!1)}),requestAnimationFrame(()=>{if(A!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>v(!0))}),C()}function x0(Z){let{x:G,y:V}=w(Z);if($.setPointerCapture(Z.pointerId),L0(G,V)){U0();return}let Y=T0(G,V);if(Y&&j[K]){X={grip:Y,x:G,y:V,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),$.hasPointerCapture(Z.pointerId))$.releasePointerCapture(Z.pointerId);z=null,Q(),f0(G,V);return}if(z){W={tool:z,x1:G,y1:V,x2:G,y2:V},K=-1;return}let F=H0(G,V);K=F,X=F>=0?{grip:"body",x:G,y:V,start:{...j[F]}}:null,C()}function E0(Z){let{x:G,y:V}=w(Z);if(W){W.x2=G,W.y2=V,C();return}if(X){let F=j[K];if(!F)return;let U=G-X.x,q=V-X.y;if(X.grip==="body")Y2(F,X.start,U,q);else G2(F,X.grip,X.start,U,q);C();return}if(z){$.style.cursor="crosshair";return}if(L0(G,V)){$.style.cursor="pointer";return}let Y=T0(G,V);if(Y){let F=j[K]?O(j[K]).find((U)=>U.id===Y):null;$.style.cursor=F?.cursor??"pointer";return}$.style.cursor=H0(G,V)>=0?"move":"default"}function J0(){if(W){if(!(Math.abs(W.x2-W.x1)<J2&&Math.abs(W.y2-W.y1)<J2))j.push(W),K=j.length-1,z=null,Q();W=null}if(X)X=null,Q();C()}function h0(Z){let G=$.getBoundingClientRect(),V=(Z.clientX-G.left)/G.width*$.width,Y=(Z.clientY-G.top)/G.height*$.height,F=H0(V,Y),U=j[F];if(!U||U.tool!=="text")return;Z.preventDefault(),f0(U.x1,U.y1,F)}function m0(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),U0();else if(Z.key==="Escape")K=-1,C()}function U0(){if(K<0)return;j.splice(K,1),K=-1,Q(),C()}return $.addEventListener("pointerdown",x0),$.addEventListener("pointermove",E0),$.addEventListener("pointerup",J0),$.addEventListener("pointercancel",J0),$.addEventListener("dblclick",h0),$.tabIndex=0,$.addEventListener("keydown",m0),C(),{setTool(Z){z=Z,K=-1,$.style.cursor=Z?"crosshair":"default",C()},deleteSelected:U0,clear(){j.length=0,K=-1,Q(),C()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=J.naturalWidth,Z.height=J.naturalHeight;let G=Z.getContext("2d");if(!G)return $.toDataURL("image/png");G.drawImage(J,0,0);let V=P();for(let Y of j)L(G,Y,V);return Z.toDataURL("image/png")},destroy(){v(!1),$.removeEventListener("pointerdown",x0),$.removeEventListener("pointermove",E0),$.removeEventListener("pointerup",J0),$.removeEventListener("pointercancel",J0),$.removeEventListener("dblclick",h0),$.removeEventListener("keydown",m0)}}}var j2=`
34
34
  :host { all: initial; }
35
35
  * { box-sizing: border-box; }
36
36
 
@@ -113,4 +113,4 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
113
113
  border-radius: 0 0 16px 16px;
114
114
  }
115
115
  .foot .grow { flex: 1; }
116
- `;var t="lw-debug-reporter",Z6=()=>[];var K6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function W6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=X1((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let Q=Y0(N().locale),j=await m1();if(j.method==="cancelled"){this.close();return}this.bundle=h1({reason:J,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:G6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(J){let Q=document.createElement("style");Q.textContent=j2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",J.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell(J,Q){let j=this.shell(J),z=D("div","head");z.append(D("h2","",J.title)),j.append(z,D("p","status",Q))}renderForm(J){let Q=this.bundle;if(!Q)return;let j=this.shell(J),z=D("div","head"),K=p("✕","icon");K.setAttribute("aria-label",J.close),K.addEventListener("click",()=>this.close()),z.append(D("h2","",J.title),K);let W=document.createElement("input");W.type="text",W.placeholder=J.summaryPlaceholder;let X=R0(J.summaryLabel,J.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=J.detailPlaceholder;let M=D("div","meta");M.innerHTML="";let{context:w}=Q;for(let[S,L]of[[J.reporter,`${w.user.fullName??"—"} (${w.user.email??"—"})`],[J.page,w.route.href],[J.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${J.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let e=document.createElement("div"),C=document.createElement("b");C.textContent=`${S}: `,e.append(C,document.createTextNode(L)),M.append(e)}let P=D("p","status",""),I=p(J.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,X,W,R0(J.detailLabel),H,M),Q.screenshotDataUrl)j.append(...this.screenshotSection(J,Q.screenshotDataUrl));else j.append(D("p","status",J.noScreenshot));let k=D("div","foot"),B=p(J.close);B.addEventListener("click",()=>this.close()),k.append(B,P,D("span","grow"),I),j.append(k),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=J.submitting;try{let S=await s1(W.value.trim(),{...Q,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:S,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)s(`${J.submitted} — #${S.number}`,"success")}catch(S){let L=S instanceof Error?S.message:J.failed;P.dataset.tone="error",P.textContent=L,s(`${J.failed} — ${L}`,"error"),I.disabled=!1}}),W.focus()}screenshotSection(J,Q){let j=R0(J.annotateHint),z=D("div","tools"),K=document.createElement("canvas"),W=D("div","shot");W.append(K);let X=[],H=(I)=>{for(let k of X)k.setAttribute("aria-pressed",String(k===I))};for(let{tool:I,key:k}of K6){let B=p(J[k]);B.setAttribute("aria-pressed","false"),B.addEventListener("click",()=>{let S=B.getAttribute("aria-pressed")==="true";H(S?null:B),this.annotator?.setTool(S?null:I)}),X.push(B),z.append(B)}z.append(D("span","sep"));let M=p(J.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let w=p(J.clearAll);w.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(M,w);let P=new Image;return P.onload=()=>{K.width=P.naturalWidth,K.height=P.naturalHeight,this.annotator=Q2(K,P,()=>{H(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[j,z,D("p","status",J.annotateHelp),W]}}}function G6(){try{return Z6()}catch{return[]}}function D($,J="",Q=""){let j=document.createElement($);if(J)j.className=J;if(Q)j.textContent=Q;return j}function p($,J=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=$,J)Q.className=J;return Q}function R0($,J="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode($)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if(J){let z=document.createElement("span");z.className="hint",z.textContent=` ${J}`,j.append(z)}return j}function z2(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,W6())}var Z2=!1;function K2($={}){if(Z2||typeof window>"u")return;if(!Q0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(Z2=!0,O1(),Z1(),e0(),I1(),A1(),$.ui===!1)return;let J=Y0(N().locale);if(F1((Q)=>{s(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>W0(Q)})}),z2(),!document.querySelector(t))document.body.append(document.createElement(t))}var W2=document.currentScript,T=W2?.dataset??{},V6="rrweb-record.mjs";L1(()=>import(new URL(V6,W2?.src??location.href).href));function Y6($){if(!$)return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};return Object.fromEntries(Object.entries(J).filter(([,Q])=>typeof Q==="string"&&Q.trim()))}catch{return{}}}if(T.host&&T.realmKey)y0({host:T.host,realmKey:T.realmKey,app:{name:T.appName??document.title??"app",version:T.appVersion??"0.0.0",environment:T.environment??"production"},module:u0(Y6(T.modules)),locale:T.locale==="en"?"en":"th",...T.replay!==void 0?{replay:{seconds:Number(T.replay)||void 0}}:{}}),K2();window.lwReportProblem=W0;})();
116
+ `;var t="lw-debug-reporter",W6=()=>[];var G6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function Y6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=X1((J)=>void this.open(J))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open(J){if(this.busy)return;this.busy=!0;let Q=V0(N().locale),j=await m1();if(j.method==="cancelled"){this.close();return}this.bundle=h1({reason:J,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:V6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell(J){let Q=document.createElement("style");Q.textContent=j2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",J.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell(J,Q){let j=this.shell(J),z=D("div","head");z.append(D("h2","",J.title)),j.append(z,D("p","status",Q))}renderForm(J){let Q=this.bundle;if(!Q)return;let j=this.shell(J),z=D("div","head"),K=b("✕","icon");K.setAttribute("aria-label",J.close),K.addEventListener("click",()=>this.close()),z.append(D("h2","",J.title),K);let W=document.createElement("input");W.type="text",W.placeholder=J.summaryPlaceholder;let X=R0(J.summaryLabel,J.summaryRequired,!0),H=document.createElement("textarea");H.placeholder=J.detailPlaceholder;let P=D("div","meta");P.innerHTML="";let{context:w}=Q;for(let[S,L]of[[J.reporter,`${w.user.fullName??"—"} (${w.user.email??"—"})`],[J.page,w.route.href],[J.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${J.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let e=document.createElement("div"),C=document.createElement("b");C.textContent=`${S}: `,e.append(C,document.createTextNode(L)),P.append(e)}let I=D("p","status",""),M=b(J.submit,"primary");if(M.disabled=!0,W.addEventListener("input",()=>{M.disabled=W.value.trim().length===0}),j.append(z,X,W,R0(J.detailLabel),H,P),Q.screenshotDataUrl)j.append(...this.screenshotSection(J,Q.screenshotDataUrl));else j.append(D("p","status",J.noScreenshot));let O=D("div","foot"),B=b(J.close);B.addEventListener("click",()=>this.close()),O.append(B,I,D("span","grow"),M),j.append(O),M.addEventListener("click",async()=>{M.disabled=!0,I.dataset.tone="",I.textContent=J.submitting;try{let S=await s1(W.value.trim(),{...Q,note:H.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),L=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:S,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),L)s(`${J.submitted} — #${S.number}`,"success")}catch(S){let L=S instanceof Error?S.message:J.failed;I.dataset.tone="error",I.textContent=L,s(`${J.failed} — ${L}`,"error"),M.disabled=!1}}),W.focus()}screenshotSection(J,Q){let j=R0(J.annotateHint),z=D("div","tools"),K=document.createElement("canvas"),W=D("div","shot");W.append(K);let X=[],H=(M)=>{for(let O of X)O.setAttribute("aria-pressed",String(O===M))};for(let{tool:M,key:O}of G6){let B=b(J[O]);B.setAttribute("aria-pressed","false"),B.addEventListener("click",()=>{let S=B.getAttribute("aria-pressed")==="true";H(S?null:B),this.annotator?.setTool(S?null:M)}),X.push(B),z.append(B)}z.append(D("span","sep"));let P=b(J.deleteSelected);P.addEventListener("click",()=>this.annotator?.deleteSelected());let w=b(J.clearAll);w.addEventListener("click",()=>{this.annotator?.clear(),H(null)}),z.append(P,w);let I=new Image;return I.onload=()=>{K.width=I.naturalWidth,K.height=I.naturalHeight,this.annotator=Q2(K,I,()=>{H(null),P.disabled=!this.annotator?.hasSelection()})},I.src=Q,[j,z,D("p","status",J.annotateHelp),W]}}}function V6(){try{return W6()}catch{return[]}}function D($,J="",Q=""){let j=document.createElement($);if(J)j.className=J;if(Q)j.textContent=Q;return j}function b($,J=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=$,J)Q.className=J;return Q}function R0($,J="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode($)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if(J){let z=document.createElement("span");z.className="hint",z.textContent=` ${J}`,j.append(z)}return j}function z2(){if(typeof window>"u"||customElements.get(t))return;customElements.define(t,Y6())}var Z2=!1;function K2($={}){if(Z2||typeof window>"u")return;if(!Q0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(Z2=!0,k1(),Z1(),e0(),M1(),A1(),$.ui===!1)return;let J=V0(N().locale);if(F1((Q)=>{s(Q.message??J.crashed,"error",{label:J.crashAction,onClick:()=>W0(Q)})}),z2(),!document.querySelector(t))document.body.append(document.createElement(t))}var W2=document.currentScript,T=W2?.dataset??{},X6="rrweb-record.mjs";L1(()=>import(new URL(X6,W2?.src??location.href).href));function F6($){if(!$)return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};return Object.fromEntries(Object.entries(J).filter(([,Q])=>typeof Q==="string"&&Q.trim()))}catch{return{}}}if(T.host&&T.realmKey)y0({host:T.host,realmKey:T.realmKey,app:{name:T.appName??document.title??"app",version:T.appVersion??"0.0.0",environment:T.environment??"production"},module:u0(F6(T.modules)),locale:T.locale==="en"?"en":"th",...T.replay!==void 0?{replay:{seconds:Number(T.replay)||void 0}}:{}}),K2();window.lwReportProblem=W0;})();
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var B2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},T=null;function N2(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.");T=J}function S(){if(!T)throw Error("[debug-capture] configureDebugCapture() has not been called");return T}function j0(){return T!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??S2()}}function S2(){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 g(J){let $=T?.capture?.[J];return typeof $==="number"?$:B2[J]}function Z1(J){let $=T?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function G0(){let J=T?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function K1(){return T?.capture?.overlaySelectors??[]}var R2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',w2="[data-lw-mask]",z1={fps:1,quality:0.5};function z0(){let J=T?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,z1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,z1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?R2:w2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function W1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(O2($))return!1;if($.origin===window.location.origin)return!0;return(T?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function O2(J){if(!T?.host)return!1;try{if(new URL(T.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function _2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",L2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,k2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),T2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,A2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,x2=/\d(?:[\d\s-]{7,})\d/g;function l(J){return J.replace(A2,i).replace(x2,i)}function E2(J){if(L2.test(J))return!0;return G0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function o(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=E2(Q)?i:j;return $}function f(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(k2.has(K.toLowerCase())||G0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function B0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>B0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=T2.test(j)||G0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:B0(z,$+1)}return Q}function r(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(B0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var N0=120,S0=40,n=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,R0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},s=[],Y1=0,V1=!1;function Z0(J,$,Q,j){let z=n($,N0),K=s[s.length-1];if(J==="navigate"&&K?.kind==="click"){let V=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${V}`))return K.at=new Date().toISOString(),K;let F=V.split(/[?#]/)[0]??V,M=K.source?R0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(F===M||F.startsWith(M)))return K.detail=n(`${K.detail} → ${V}`,N0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}Y1+=1;let W={id:`act_${Y1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:F0(j)};s.push(W);while(s.length>g("maxActions"))h2(s.shift());return W}var f2=200000,K0=0;function F0(J){if(!J)return;if(K0+J.length>f2)return;return K0+=J.length,J}function h2(J){if(!J)return;if(K0-=(J.html?.length??0)+(J.afterHtml?.length??0),K0<0)K0=0}function w0(J){return J&&J>1?` (×${J})`:""}function X0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var m2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',g2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},G1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function y2(J){let $=J.getAttribute("role");if($&&G1[$])return G1[$];return g2[J.tagName.toLowerCase()]??"ปุ่ม"}function b2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=P1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function v2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;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 j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return R0(z)}return""}function p2(J){if(!(J instanceof Element))return null;let $=J.closest(m2)??b2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function u2(J){let $=l(v2(J));if(!$)return null;return`${y2(J)} “${n($,S0)}”`}var M1=6000,d2=4000,c2=/(?:^|\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 i2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let V=W.name.toLowerCase();if(V.startsWith("on")||V==="srcdoc"||V==="value"||V.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(c2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=l(j.nodeValue);j=Q.nextNode()}}function O0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);i2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var l2=(J)=>O0(J,M1,d2),o2=150000,r2=40000,X1=(J)=>O0(J,o2,r2);function s2(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`ช่อง “${l($)}”`}var F1=80;function P1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function n2(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 H1(J){if(!J)return;return`→ ${J.length>F1?`${J.slice(0,F1)}…`:J}`}function a2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return H1($);let Q=P1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return H1(n2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var t2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function e2(){let J=K1();return J.length?J.join(", "):t2}function J4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function $4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=l($4(J)),Q=J4(J);return $?`เปิด ${Q} “${n($,S0)}”`:`เปิด ${Q}`}var Q4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',j4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function z4(J){if(J.querySelector(Q4))return!0;return j4.test(J.textContent??"")}var Z4=400,K4=250,W4=8000;function Y4(J,$){if(typeof MutationObserver>"u"){$.html=F0(X1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(V),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=n(I1(J),N0),$.html=F0(X1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let V=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=Z4&&!z4(J))K()},K4),F=window.setTimeout(K,W4)}function V4(J){if(X0(J))return;let $=Z0("ui",I1(J));if($)Y4(J,$)}function G4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=e2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let V of W){if(J.has(V))continue;J.add(V),V4(V)}}}).observe(document.body,{childList:!0,subtree:!0})}var X4=1600,F4=2500;function U1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:n((J.textContent??"").replace(/\s+/g," ").trim(),S0)}}function H4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function U4(J,$){if(typeof MutationObserver>"u")return;let Q=U1(J),j=!1,z=(V,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=V,F)$.afterHtml=F0(O0(J,M1,F4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let V=H4(Q,U1(J));if(V)z(V,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},X4)}function C1(){if(V1||typeof window>"u")return;V1=!0,document.addEventListener("click",(j)=>{if(X0(j.target))return;let z=p2(j.target);if(!z)return;let K=u2(z);if(!K)return;let W=Z0("click",`คลิก ${K}`,a2(z),l2(z));if(W)U4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(X0(j.target))return;let z=s2(j.target);if(z)Z0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(X0(j.target))return;Z0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Z0("navigate",`ไปที่ ${R0(f(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),G4()}function _0(){return s.map((J)=>({...J}))}var D1=2000,H0=[],q1=0,B1=!1;function L0(J,$){q1+=1,H0.push({id:`log_${q1}`,at:new Date().toISOString(),level:J,message:$.length>D1?`${$.slice(0,D1)}…`:$});while(H0.length>g("maxConsoleEntries"))H0.shift()}function M4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function N1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,M4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function S1(){if(B1||typeof window>"u")return;B1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{L0($,j.map(N1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";L0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:N1($.reason);L0("unhandledrejection",Q)})}function k0(){return H0.map((J)=>({...J}))}var R1=new Set,w1=new Set;function O1(J,$){return J.add($),()=>J.delete($)}function _1(J,$){for(let Q of[...J])Q($)}function T0(J){return O1(R1,J)}function A0(J={type:"manual"}){_1(R1,J)}function x0(J){return O1(w1,J)}function E0(J){_1(w1,J)}var P4=15000,I4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],L1=!1,k1=0;function C4(J){return I4.some(($)=>J.includes($))}function T1(J){let $=J.message??"";if(!$||C4($))return;let Q=Date.now();if(Q-k1<P4)return;k1=Q,E0({...J,message:$})}function A1(){if(L1||typeof window>"u")return;L1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;T1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;T1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var h1=4000,D4=1e6,q4=1e7,U0=[],x1=0,E1=!1;function m1(J){U0.push(J);while(U0.length>g("maxRequests"))U0.shift()}function g1(){return x1+=1,`req_${x1}`}function f1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function B4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function N4(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 S4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=f1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...f1($.headers)};if($.body!==void 0)K=N4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function y1(J){return!W1(J)}function R4(J,$){if(y1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>D4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=r(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function b1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function w4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=S4($,Q);if(b1(j.url,j.headers))return J($,Q);let z={id:g1(),startedAt:new Date().toISOString(),method:j.method,url:f(j.url),requestHeaders:o(j.headers),requestBody:r(j.body,h1),status:null,statusText:null,durationMs:null,via:"fetch"};m1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(B4(W.headers)),R4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function O4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let V=typeof W==="string"?W:W.toString();return this.__lwEntry=b1(V,{})?void 0:{id:g1(),startedAt:"",method:(K||"GET").toUpperCase(),url:f(V),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?r(K,h1):K==null?null:"[non-string body]";let V=performance.now();m1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-V),y1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=r(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function v1(){if(E1)return;E1=!0,w4(),O4()}function f0(){let J=U0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>q4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var _4=4,p1=3,L4=4000,k4="[data-debug-reporter]",T4=()=>import("@rrweb/record");var A=[],a=null,M0=!1;function u1(){if(typeof window>"u"||a||M0)return;let J=z0();if(!J)return;M0=!0;let $=()=>void A4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function A4(J){let $;try{$=(await T4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(a)return;try{a=$({emit:(Q)=>x4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:L4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${k4}`,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(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function x4(J){if(J.type===_4||A.length===0){if(A.push([]),A.length>p1)A=A.slice(-p1)}A[A.length-1].push(J)}function h0(J=Date.now()){let $=z0();if(!$||!A.length)return null;let Q=J-$.seconds*1000,j=A.length-1;while(j>0&&(A[j][0]?.timestamp??J)>Q)j-=1;let z=A.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function E4(){return a!==null}function f4(){a?.(),a=null,A=[]}var h4={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:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกหน้าจอ",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},m4={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",captured:"Captured",reporter:"Reporter",page:"Page",replay:"replay",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"};function d(J){return J==="en"?m4:h4}var g4="lw-debug-toasts",y4=6000,b4=`
1
+ var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=>(typeof require<"u"?require:$)[Q]}):J)(function(J){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+J+'" is not supported')});var B2={maxRequests:60,maxConsoleEntries:120,maxActions:80,maxBodyChars:20000},A=null;function N2(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.");A=J}function S(){if(!A)throw Error("[debug-capture] configureDebugCapture() has not been called");return A}function j0(){return A!==null}function m(){let J=S().app;return{name:J.name,version:J.version??"0.0.0",environment:J.environment??S2()}}function S2(){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 g(J){let $=A?.capture?.[J];return typeof $==="number"?$:B2[J]}function Z1(J){let $=A?.module;if(!$)return null;try{return $(J)??null}catch{return null}}function V0(){let J=A?.redact;return{headers:J?.headers??[],queryKeys:(J?.queryKeys??[]).map(($)=>$.toLowerCase()),bodyKeys:(J?.bodyKeys??[]).map(($)=>$.toLowerCase())}}function K1(){return A?.capture?.overlaySelectors??[]}var w2='[contenteditable]:not([contenteditable="false"]), [data-lw-mask]',O2="[data-lw-mask]",z1={fps:1,quality:0.5};function z0(){let J=A?.replay;if(!J)return null;let $=J===!0?{}:J,Q=(K,W)=>typeof K==="number"&&K>0?K:W,j=$.maskInputs!==!1,z=$.recordCanvas?{fps:Q(typeof $.recordCanvas==="object"?$.recordCanvas.fps:void 0,z1.fps),quality:Q(typeof $.recordCanvas==="object"?$.recordCanvas.quality:void 0,z1.quality)}:null;return{seconds:Q($.seconds,60),maskInputs:j,maskTextSelector:$.maskTextSelector?.trim()||(j?w2:O2),maskText:$.maskText===!0,blockSelector:$.blockSelector?.trim()||"[data-lw-private]",maxBytes:Q($.maxBytes,4000000),canvas:z}}function W1(J){if(typeof window>"u")return!1;let $;try{$=new URL(J,window.location.href)}catch{return!1}if(R2($))return!1;if($.origin===window.location.origin)return!0;return(A?.capture?.bodyOrigins??[]).some((Q)=>{try{return new URL(Q).origin===$.origin}catch{return!1}})}function R2(J){if(!A?.host)return!1;try{if(new URL(A.host).origin!==J.origin)return!1}catch{return!1}return J.pathname.startsWith("/ingest/")}function _2(J){let $=Object.entries(J).map(([Q,j])=>[Q.replace(/\/+$/,"")||"/",j]).sort((Q,j)=>j[0].length-Q[0].length);return(Q)=>{let j=(Q||"/").replace(/\/+$/,"")||"/";for(let[z,K]of $)if(j===z||j.startsWith(`${z}/`))return{key:z,label:K};return null}}var i="‹redacted›",L2=/^(authorization|proxy-authorization|cookie|set-cookie|x-[a-z-]*token|x-csrf[a-z-]*|x-xsrf[a-z-]*)$/i,k2=new Set(["access_token","token","id_token","refresh_token","code","secret","client_secret","password","apikey","api_key","signature","x-amz-signature","x-amz-credential"]),A2=/(password|passwd|token|secret|authorization|refresh|client_secret|otp|pin)/i,T2=/[\w.+-]+@[\w-]+\.[\w.-]+/g,x2=/\d(?:[\d\s-]{7,})\d/g;function l(J){return J.replace(T2,i).replace(x2,i)}function E2(J){if(L2.test(J))return!0;return V0().headers.some((Q)=>Q.toLowerCase()===J.toLowerCase())}function o(J){let $={};for(let[Q,j]of Object.entries(J))$[Q]=E2(Q)?i:j;return $}function f(J){try{let $=/^https?:\/\//i.test(J),Q=new URL(J,$?void 0:"http://local.invalid"),j=!1;if(Q.searchParams.forEach((z,K)=>{if(k2.has(K.toLowerCase())||V0().queryKeys.includes(K.toLowerCase()))Q.searchParams.set(K,i),j=!0}),!j)return J;return $?Q.toString():`${Q.pathname}${Q.search}`}catch{return J}}function B0(J,$){if($>6||J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((j)=>B0(j,$+1));let Q={};for(let[j,z]of Object.entries(J)){let K=A2.test(j)||V0().bodyKeys.some((W)=>j.toLowerCase().includes(W));Q[j]=K?i:B0(z,$+1)}return Q}function r(J,$){if(J==null)return null;let Q=J,j=J.trim();if(j.startsWith("{")||j.startsWith("["))try{let z=JSON.parse(j);Q=JSON.stringify(B0(z,0))}catch{}if(Q.length>$)return`${Q.slice(0,$)}… [truncated ${Q.length-$} chars]`;return Q}var N0=120,S0=40,n=(J,$)=>J.length>$?`${J.slice(0,$)}…`:J,w0=(J)=>{try{return decodeURIComponent(J)}catch{return J}},s=[],Y1=0,G1=!1;function Z0(J,$,Q,j){let z=n($,N0),K=s[s.length-1];if(J==="navigate"&&K?.kind==="click"){let G=z.replace(/^ไปที่\s*/,"");if(K.detail.includes(`→ ${G}`))return K.at=new Date().toISOString(),K;let F=G.split(/[?#]/)[0]??G,M=K.source?w0(K.source.replace(/^→\s*/,"")).split(/[?#]/)[0]:null;if(M&&(F===M||F.startsWith(M)))return K.detail=n(`${K.detail} → ${G}`,N0),K.source=void 0,K.at=new Date().toISOString(),K}if(K&&K.kind===J&&K.detail===z){if(K.at=new Date().toISOString(),J!=="navigate")K.count=(K.count??1)+1;return K}Y1+=1;let W={id:`act_${Y1}`,at:new Date().toISOString(),kind:J,detail:z,count:1,source:Q,html:F0(j)};s.push(W);while(s.length>g("maxActions"))h2(s.shift());return W}var f2=200000,K0=0;function F0(J){if(!J)return;if(K0+J.length>f2)return;return K0+=J.length,J}function h2(J){if(!J)return;if(K0-=(J.html?.length??0)+(J.afterHtml?.length??0),K0<0)K0=0}function O0(J){return J&&J>1?` (×${J})`:""}function X0(J){return J instanceof Element&&Boolean(J.closest("[data-debug-reporter]"))}var m2='button, a[href], [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], [role="checkbox"], [role="radio"], [role="link"], summary, input, select, textarea',g2={button:"ปุ่ม",a:"ลิงก์",input:"ช่อง",textarea:"ช่อง",select:"ตัวเลือก",summary:"ส่วนขยาย"},V1={button:"ปุ่ม",tab:"แท็บ",menuitem:"เมนู",option:"ตัวเลือก",switch:"สวิตช์",checkbox:"ช่องเลือก",radio:"ตัวเลือก",link:"ลิงก์"};function y2(J){let $=J.getAttribute("role");if($&&V1[$])return V1[$];return g2[J.tagName.toLowerCase()]??"ปุ่ม"}function b2(J,$){try{let Q=J,j=0;while(Q&&j<=$){let z=P1(Q);if(z&&typeof z.memoizedProps?.onClick==="function")return Q;Q=Q.parentElement,j+=1}}catch{}return null}function v2(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("title")?.trim();if(Q)return Q;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 j=(J.textContent??"").replace(/\s+/g," ").trim();if(j)return j;if(J instanceof HTMLAnchorElement){let z=J.getAttribute("href");if(z?.startsWith("/"))return w0(z)}return""}function p2(J){if(!(J instanceof Element))return null;let $=J.closest(m2)??b2(J,4);if(!$)return null;let Q=$.tagName.toLowerCase();if(Q==="html"||Q==="body")return null;return $}function u2(J){let $=l(v2(J));if(!$)return null;return`${y2(J)} “${n($,S0)}”`}var M1=6000,d2=4000,c2=/(?:^|\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 i2(J){J.querySelectorAll("script, style, link, iframe, object, embed, noscript, canvas, video, audio").forEach((z)=>z.remove());let $=[J,...Array.from(J.querySelectorAll("*"))];for(let z of $){for(let W of Array.from(z.attributes)){let G=W.name.toLowerCase();if(G.startsWith("on")||G==="srcdoc"||G==="value"||G.startsWith("data-"))z.removeAttribute(W.name)}if(z instanceof HTMLAnchorElement)z.setAttribute("href","#");if(z instanceof HTMLImageElement)z.removeAttribute("src");let K=z.getAttribute("class");if(K){let W=K.replace(c2," ").replace(/\s+/g," ").trim();if(W)z.setAttribute("class",W);else z.removeAttribute("class")}}let Q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),j=Q.nextNode();while(j){if(j.nodeValue)j.nodeValue=l(j.nodeValue);j=Q.nextNode()}}function R0(J,$,Q){try{let j=J.outerHTML;if(!j||j.length>$)return;let z=J.cloneNode(!0);i2(z);let K=z.outerHTML;return K&&K.length<=Q?K:void 0}catch{return}}var l2=(J)=>R0(J,M1,d2),o2=150000,r2=40000,X1=(J)=>R0(J,o2,r2);function s2(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`ช่อง “${l($)}”`}var F1=80;function P1(J){let $=Object.keys(J).find((Q)=>Q.startsWith("__reactFiber$")||Q.startsWith("__reactInternalInstance$"));return $?J[$]:null}function n2(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 H1(J){if(!J)return;return`→ ${J.length>F1?`${J.slice(0,F1)}…`:J}`}function a2(J){try{let $=J.closest("a[href]")?.getAttribute("href");if($&&$.startsWith("/"))return H1($);let Q=P1(J),j=0;while(Q&&j<30){if(typeof Q.memoizedProps?.onClick==="function")return H1(n2(Q.memoizedProps.onClick));Q=Q.return,j+=1}return}catch{return}}var t2='[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="status"], [role="alert"]';function e2(){let J=K1();return J.length?J.join(", "):t2}function J4(J){let $=J.getAttribute("role");if($==="status"||$==="alert")return"ข้อความแจ้งเตือน";if($==="menu")return"เมนู";if($==="listbox")return"รายการตัวเลือก";if($==="alertdialog")return"กล่องยืนยัน";return"กล่องโต้ตอบ"}function $4(J){let $=J.getAttribute("aria-label")?.trim();if($)return $;let Q=J.getAttribute("aria-labelledby");if(Q){let K=Q.split(/\s+/).map((W)=>document.getElementById(W)?.textContent?.trim()??"").filter(Boolean).join(" ");if(K)return K}let z=J.querySelector('[data-slot="dialog-title"], h1, h2, h3, [role="heading"]')?.textContent?.replace(/\s+/g," ").trim();if(z)return z;return(J.textContent??"").replace(/\s+/g," ").trim()}function I1(J){let $=l($4(J)),Q=J4(J);return $?`เปิด ${Q} “${n($,S0)}”`:`เปิด ${Q}`}var Q4='[aria-busy="true"], [role="progressbar"], [data-loading="true"], .animate-pulse, .animate-spin',j4=/กำลังโหลด|กำลังค้นหา|กำลังดำเนินการ|\bloading\b/i;function z4(J){if(J.querySelector(Q4))return!0;return j4.test(J.textContent??"")}var Z4=400,K4=250,W4=8000;function Y4(J,$){if(typeof MutationObserver>"u"){$.html=F0(X1(J));return}let Q=Date.now(),j=!1,z=()=>{j=!0,W.disconnect(),window.clearInterval(G),window.clearTimeout(F)},K=()=>{if(j)return;if(z(),!J.isConnected)return;$.detail=n(I1(J),N0),$.html=F0(X1(J))},W=new MutationObserver(()=>{Q=Date.now()});W.observe(J,{childList:!0,subtree:!0,attributes:!0,characterData:!0});let G=window.setInterval(()=>{if(j)return;if(!J.isConnected){z();return}if(Date.now()-Q>=Z4&&!z4(J))K()},K4),F=window.setTimeout(K,W4)}function G4(J){if(X0(J))return;let $=Z0("ui",I1(J));if($)Y4(J,$)}function V4(){if(typeof MutationObserver>"u")return;let J=new WeakSet;new MutationObserver((Q)=>{for(let j of Q)for(let z of Array.from(j.addedNodes)){if(!(z instanceof Element))continue;let K=e2(),W=z.matches(K)?[z]:Array.from(z.querySelectorAll(K));for(let G of W){if(J.has(G))continue;J.add(G),G4(G)}}}).observe(document.body,{childList:!0,subtree:!0})}var X4=1600,F4=2500;function U1(J){return{disabled:J.hasAttribute("disabled")||J.getAttribute("aria-disabled")==="true",busy:J.getAttribute("aria-busy")==="true",text:n((J.textContent??"").replace(/\s+/g," ").trim(),S0)}}function H4(J,$){if(!J.disabled&&$.disabled)return"ปุ่มถูกปิดใช้งานหลังคลิก";if(!J.busy&&$.busy)return"ปุ่มเข้าสู่สถานะกำลังโหลด";if(J.text!==$.text&&$.text)return`ข้อความเปลี่ยนเป็น “${$.text}”`;return null}function U4(J,$){if(typeof MutationObserver>"u")return;let Q=U1(J),j=!1,z=(G,F)=>{if(j)return;if(j=!0,K.disconnect(),window.clearTimeout(W),$.afterNote=G,F)$.afterHtml=F0(R0(J,M1,F4))},K=new MutationObserver(()=>{if(!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}let G=H4(Q,U1(J));if(G)z(G,!0)});K.observe(J,{attributes:!0,attributeFilter:["disabled","aria-disabled","aria-busy","class"],childList:!0,subtree:!0,characterData:!0});let W=window.setTimeout(()=>{if(!j&&!J.isConnected){z("องค์ประกอบหายไปจากหน้าจอ",!1);return}j=!0,K.disconnect()},X4)}function C1(){if(G1||typeof window>"u")return;G1=!0,document.addEventListener("click",(j)=>{if(X0(j.target))return;let z=p2(j.target);if(!z)return;let K=u2(z);if(!K)return;let W=Z0("click",`คลิก ${K}`,a2(z),l2(z));if(W)U4(z,W)},{capture:!0,passive:!0}),document.addEventListener("change",(j)=>{if(X0(j.target))return;let z=s2(j.target);if(z)Z0("input",`แก้ไข ${z}`)},{capture:!0,passive:!0}),document.addEventListener("submit",(j)=>{if(X0(j.target))return;Z0("submit","ส่งฟอร์ม")},{capture:!0,passive:!0});let J=()=>Z0("navigate",`ไปที่ ${w0(f(location.pathname+location.search))}`),$=history.pushState.bind(history),Q=history.replaceState.bind(history);history.pushState=(...j)=>{let z=$(...j);return J(),z},history.replaceState=(...j)=>{let z=Q(...j);return J(),z},window.addEventListener("popstate",J),V4()}function _0(){return s.map((J)=>({...J}))}var D1=2000,H0=[],q1=0,B1=!1;function L0(J,$){q1+=1,H0.push({id:`log_${q1}`,at:new Date().toISOString(),level:J,message:$.length>D1?`${$.slice(0,D1)}…`:$});while(H0.length>g("maxConsoleEntries"))H0.shift()}function M4(){let J=new WeakSet;return($,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}if(typeof Q==="bigint")return Q.toString();return Q}}function N1(J){if(typeof J==="string")return J;if(J instanceof Error)return`${J.name}: ${J.message}`;try{let $=JSON.stringify(J,M4());if($!==void 0)return $}catch{}try{return String(J)}catch{}try{return Object.prototype.toString.call(J)}catch{return`[${typeof J}]`}}function S1(){if(B1||typeof window>"u")return;B1=!0;let J=["log","info","warn","error","debug"];for(let $ of J){let Q=console[$].bind(console);console[$]=(...j)=>{L0($,j.map(N1).join(" ")),Q(...j)}}window.addEventListener("error",($)=>{let Q=$.filename?` (${$.filename}:${$.lineno}:${$.colno})`:"";L0("exception",`${$.message}${Q}`)}),window.addEventListener("unhandledrejection",($)=>{let Q=$.reason instanceof Error?`${$.reason.name}: ${$.reason.message}`:N1($.reason);L0("unhandledrejection",Q)})}function k0(){return H0.map((J)=>({...J}))}var w1=new Set,O1=new Set;function R1(J,$){return J.add($),()=>J.delete($)}function _1(J,$){for(let Q of[...J])Q($)}function A0(J){return R1(w1,J)}function T0(J={type:"manual"}){_1(w1,J)}function x0(J){return R1(O1,J)}function E0(J){_1(O1,J)}var P4=15000,I4=["ResizeObserver loop","Script error.","Non-Error promise rejection captured"],L1=!1,k1=0;function C4(J){return I4.some(($)=>J.includes($))}function A1(J){let $=J.message??"";if(!$||C4($))return;let Q=Date.now();if(Q-k1<P4)return;k1=Q,E0({...J,message:$})}function T1(){if(L1||typeof window>"u")return;L1=!0,window.addEventListener("error",(J)=>{if(!J.message&&!J.error)return;let $=J.error instanceof Error?J.error:null;A1({type:"runtime-error",message:J.message||($?$.message:"Unknown error"),stack:$?.stack})}),window.addEventListener("unhandledrejection",(J)=>{let $=J.reason;A1({type:"unhandledrejection",message:$ instanceof Error?$.message:String($),stack:$ instanceof Error?$.stack:void 0})})}var h1=4000,D4=1e6,q4=1e7,U0=[],x1=0,E1=!1;function m1(J){U0.push(J);while(U0.length>g("maxRequests"))U0.shift()}function g1(){return x1+=1,`req_${x1}`}function f1(J){let $={};if(!J)return $;if(J instanceof Headers)J.forEach((Q,j)=>{$[j]=Q});else if(Array.isArray(J))for(let[Q,j]of J)$[Q]=j;else Object.assign($,J);return $}function B4(J){let $={};return J.forEach((Q,j)=>{$[j]=Q}),$}function N4(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 S4(J,$){let Q="",j="GET",z={},K=null;if(typeof J==="string")Q=J;else if(J instanceof URL)Q=J.toString();else Q=J.url,j=J.method||j,z=f1(J.headers);if($){if($.method)j=$.method;if($.headers)z={...z,...f1($.headers)};if($.body!==void 0)K=N4($.body)}return{method:j.toUpperCase(),url:Q,headers:z,body:K}}function y1(J){return!W1(J)}function w4(J,$){if(y1($.url)){$.responseSnippet="[body not captured for this origin]";return}let Q=J.headers.get("content-type")??"",j=Number(J.headers.get("content-length")??"0"),z=j?`, ~${j} bytes`:"";if(!/json|text|xml|html|javascript|urlencoded/i.test(Q)){$.responseSnippet=`[binary ${Q||"unknown"}${z}]`;return}if(j>D4){$.responseSnippet=`[response ${Q||"text"}${z} — omitted]`;return}try{J.clone().text().then((K)=>{$.responseSnippet=r(K,g("maxBodyChars"))}).catch(()=>{})}catch{}}function b1(J,$){if(/[?&]_rsc=/.test(J))return!0;for(let Q of Object.keys($)){let j=Q.toLowerCase();if(j==="rsc"||j==="next-router-prefetch"||j==="next-router-state-tree")return!0}return!1}function O4(){if(typeof window>"u"||typeof window.fetch!=="function")return;let J=window.fetch.bind(window);window.fetch=Object.assign(async($,Q)=>{let j=S4($,Q);if(b1(j.url,j.headers))return J($,Q);let z={id:g1(),startedAt:new Date().toISOString(),method:j.method,url:f(j.url),requestHeaders:o(j.headers),requestBody:r(j.body,h1),status:null,statusText:null,durationMs:null,via:"fetch"};m1(z);let K=performance.now();try{let W=await J($,Q);return z.status=W.status,z.statusText=W.statusText,z.durationMs=Math.round(performance.now()-K),z.responseHeaders=o(B4(W.headers)),w4(W,z),W}catch(W){throw z.durationMs=Math.round(performance.now()-K),z.error=W instanceof Error?`${W.name}: ${W.message}`:String(W),W}},J)}function R4(){if(typeof window>"u"||typeof window.XMLHttpRequest!=="function")return;let J=XMLHttpRequest.prototype,$=J.open,Q=J.send,j=function(K,W){let G=typeof W==="string"?W:W.toString();return this.__lwEntry=b1(G,{})?void 0:{id:g1(),startedAt:"",method:(K||"GET").toUpperCase(),url:f(G),requestHeaders:{},requestBody:null,status:null,statusText:null,durationMs:null,via:"xhr"},$.apply(this,arguments)},z=function(K){let W=this.__lwEntry;if(W){W.startedAt=new Date().toISOString(),W.requestBody=typeof K==="string"?r(K,h1):K==null?null:"[non-string body]";let G=performance.now();m1(W),this.addEventListener("loadend",()=>{if(W.status=this.status||null,W.statusText=this.statusText||null,W.durationMs=Math.round(performance.now()-G),y1(W.url))W.responseSnippet="[body not captured for this origin]";else if(this.responseType===""||this.responseType==="text")try{W.responseSnippet=r(this.responseText||"",g("maxBodyChars"))}catch{}else{let F=this.getResponseHeader("content-type")??this.responseType;W.responseSnippet=`[binary ${F}]`}})}return Q.apply(this,arguments)};J.open=j,J.send=z}function v1(){if(E1)return;E1=!0,O4(),R4()}function f0(){let J=U0.map((Q)=>({...Q})),$=0;for(let Q=J.length-1;Q>=0;Q-=1){let j=J[Q],z=j?.responseSnippet;if(!j||typeof z!=="string"||z.length===0)continue;if($+z.length>q4)j.responseSnippet=`[response omitted — report size budget reached (${z.length.toLocaleString()} chars)]`;else $+=z.length}return J}var _4=4,p1=3,L4=4000,k4="[data-debug-reporter]",A4=()=>import("@rrweb/record");var T=[],a=null,M0=!1;function u1(){if(typeof window>"u"||a||M0)return;let J=z0();if(!J)return;M0=!0;let $=()=>void T4(J);if("requestIdleCallback"in window)window.requestIdleCallback($,{timeout:3000});else setTimeout($,1000)}async function T4(J){let $;try{$=(await A4()).record}catch(Q){M0=!1,console.warn("[debug-capture] session replay could not start:",Q);return}if(a)return;try{a=$({emit:(Q)=>x4(Q),checkoutEveryNms:Math.max(1000,J.seconds*1000/2),checkoutEveryNth:L4,maskAllInputs:J.maskInputs,maskTextSelector:J.maskText?"*":J.maskTextSelector,blockSelector:`${J.blockSelector}, ${k4}`,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(Q){console.warn("[debug-capture] session replay could not start:",Q)}finally{M0=!1}}function x4(J){if(J.type===_4||T.length===0){if(T.push([]),T.length>p1)T=T.slice(-p1)}T[T.length-1].push(J)}function h0(J=Date.now()){let $=z0();if(!$||!T.length)return null;let Q=J-$.seconds*1000,j=T.length-1;while(j>0&&(T[j][0]?.timestamp??J)>Q)j-=1;let z=T.slice(j).flat(),K=z[0]?.timestamp,W=z[z.length-1]?.timestamp;if(K===void 0||W===void 0)return null;return{events:z,startedAt:new Date(K).toISOString(),endedAt:new Date(W).toISOString(),durationMs:Math.max(0,W-K)}}function E4(){return a!==null}function f4(){a?.(),a=null,T=[]}var h4={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:"ส่งรายงานไม่สำเร็จ",captured:"เก็บข้อมูลแล้ว",reporter:"ผู้แจ้ง",page:"หน้า",replay:"บันทึกการใช้งาน",handoffTitle:"กำลังพาไปที่ระบบแจ้งปัญหา",handoffBody:"ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",handoffGo:"ไปเลย",handoffPreparing:"กำลังเตรียม…",handoffFailed:"เปิดรายการที่แจ้งไว้ไม่สำเร็จ",handoffBlocked:"เบราว์เซอร์บล็อกการเปิดแท็บใหม่",handoffOpen:"เปิดในแท็บใหม่"},m4={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",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"};function d(J){return J==="en"?m4:h4}var g4="lw-debug-toasts",y4=6000,b4=`
2
2
  :host { all: initial; }
3
3
  .stack {
4
4
  position: fixed; top: 16px; right: 16px; z-index: 2147483001;
@@ -30,15 +30,15 @@ var q2=((J)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(J,{get:($,Q)=
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
- `,m0=null;function v4(){if(typeof document>"u")return null;if(m0?.isConnected)return m0;let J=document.createElement(g4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=b4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),m0=j,j}function t(J,$="success",Q){let j=j0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=v4();if(!z)return;let K=document.createElement("div");K.className="toast",K.dataset.tone=$;let W=document.createElement("span");W.className="dot";let V=document.createElement("span");V.textContent=J;let F=document.createElement("button");F.type="button",F.className="close",F.textContent="✕",F.setAttribute("aria-label","ปิด");let M=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",M);let B=$==="error"||Q?0:window.setTimeout(M,y4);if(K.append(W,V),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),K.append(P)}K.append(F),z.append(K)}function d1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function c1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function p4(){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[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function g0(J,$){if(!J)return $;try{return J()}catch{return $}}function i1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:Z1($),user:g0(J.user,{}),apiHeaders:o(g0(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:p4(),extra:g0(J.extra,{})}}var u4=2,d4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function y0(J){let $=f0(),Q=k0();return{context:i1(),reason:J.reason,note:J.note,cause:d1($,Q,J.erroredQueries),actionTrail:_0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:h0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:u4}}}function l1(J){return J.replace(/'/g,"'\\''")}function o1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${l1(j)}'`);if(J.requestBody)$.push(` --data '${l1(J.requestBody)}'`);return $.join(" \\\n")}function c4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function i4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${c4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
33
+ `,m0=null;function v4(){if(typeof document>"u")return null;if(m0?.isConnected)return m0;let J=document.createElement(g4);J.dataset.debugReporter="true";let $=J.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=b4;let j=document.createElement("div");return j.className="stack",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),$.append(Q,j),document.body.append(J),m0=j,j}function t(J,$="success",Q){let j=j0()?S().toast:void 0;if(j){j({message:J,tone:$,...Q?{action:Q}:{}});return}let z=v4();if(!z)return;let K=document.createElement("div");K.className="toast",K.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 M=()=>{window.clearTimeout(B),K.remove()};F.addEventListener("click",M);let B=$==="error"||Q?0:window.setTimeout(M,y4);if(K.append(W,G),Q){let P=document.createElement("button");P.type="button",P.className="action",P.textContent=Q.label,P.addEventListener("click",()=>{M(),Q.onClick()}),K.append(P)}K.append(F),z.append(K)}function d1(J,$,Q){let j=J.filter((K)=>Boolean(K.error)||K.status!=null&&K.status>=400).slice(-20).map((K)=>({method:K.method,url:K.url,status:K.status,error:K.error,at:K.startedAt})),z=$.filter((K)=>K.level==="error"||K.level==="exception"||K.level==="unhandledrejection").slice(-20).map((K)=>K.message);return{failedRequests:j,errors:z,erroredQueries:Q.slice(0,20)}}function c1(J){return J.failedRequests.length+J.errors.length+J.erroredQueries.length}function p4(){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[Q]=performance.getEntriesByType("navigation");if(Q)J.domContentLoadedMs=Math.round(Q.domContentLoadedEventEnd),J.loadEventMs=Math.round(Q.loadEventEnd);return J}function g0(J,$){if(!J)return $;try{return J()}catch{return $}}function i1(){let J=S(),{pathname:$,search:Q,href:j}=window.location;return{capturedAt:new Date().toISOString(),route:{href:j,pathname:$,search:Q},module:Z1($),user:g0(J.user,{}),apiHeaders:o(g0(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:p4(),extra:g0(J.extra,{})}}var u4=2,d4={manual:"ผู้ใช้แจ้งเอง","runtime-error":"ข้อผิดพลาด runtime (auto)",unhandledrejection:"Promise rejection (auto)","framework-error":"หน้าจอค้าง/พัง (auto)"};function y0(J){let $=f0(),Q=k0();return{context:i1(),reason:J.reason,note:J.note,cause:d1($,Q,J.erroredQueries),actionTrail:_0(),network:$,console:Q,screenshotDataUrl:J.screenshotDataUrl,screenshotMethod:J.screenshotMethod,replay:h0()??void 0,meta:{generatedBy:"lightwork-debug-capture",schemaVersion:u4}}}function l1(J){return J.replace(/'/g,"'\\''")}function o1(J){let $=[`curl -X ${J.method} '${J.url}'`];for(let[Q,j]of Object.entries(J.requestHeaders))$.push(` -H '${Q}: ${l1(j)}'`);if(J.requestBody)$.push(` --data '${l1(J.requestBody)}'`);return $.join(" \\\n")}function c4(J){if(J.error)return`ERR ${J.error}`;return`${J.status??"—"} ${J.statusText??""}`.trim()}function i4(J){if(J.length===0)return"No network activity captured.";return J.map(($)=>{let Q=$.durationMs!=null?`${$.durationMs}ms`:"—",j=`# [${c4($)}] ${$.method} ${$.url} (${Q}, ${$.startedAt})`,z=$.responseSnippet?`
34
34
  # response: ${$.responseSnippet}`:"";return`${j}
35
35
  ${o1($)}${z}`}).join(`
36
36
 
37
37
  `)}function l4(J){if(J.length===0)return"No console output captured.";return J.map(($)=>`[${$.at}] ${$.level.toUpperCase()}: ${$.message}`).join(`
38
- `)}function o4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let j=Q.source?` (${Q.source})`:"",z=`${Q.detail}${w0(Q.count)}${j}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${z}`;$+=1;let K=`${$}. [${Q.at}] ${z}`;return Q.afterNote?`${K}
38
+ `)}function o4(J){if(J.length===0)return"No user actions captured.";let $=0;return J.map((Q)=>{let j=Q.source?` (${Q.source})`:"",z=`${Q.detail}${O0(Q.count)}${j}`;if(Q.kind==="ui")return` ↳ [${Q.at}] ${z}`;$+=1;let K=`${$}. [${Q.at}] ${z}`;return Q.afterNote?`${K}
39
39
  ↳ ${Q.afterNote}`:K}).join(`
40
40
  `)}function r4(J){let $=[];for(let Q of J.failedRequests)$.push(`✗ ${Q.status??Q.error??"ERR"} ${Q.method} ${Q.url}`);for(let Q of J.errors)$.push(`⚠ ${Q}`);for(let Q of J.erroredQueries)$.push(`⚠ React Query error: ${Q.key} — ${Q.error}`);return $}function s4(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 : ${d4[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 n4(J){let $=r4(J.cause),Q=[`## \uD83D\uDC1E ${J.context.app.name} — Debug Report`,`**Generated:** ${J.context.capturedAt}`,"",...s4(J).map((j)=>`- ${j.replace(/\s{2,}:/,":")}`),"",`**หมายเหตุจากผู้แจ้ง:** ${J.note.trim()||"(ไม่มี)"}`];if($.length>0)Q.push("","### ⚠ สาเหตุที่น่าจะเป็น","```",...$,"```");return Q.push("",`<details><summary>ขั้นตอน (${J.actionTrail.length})</summary>`,"","```",o4(J.actionTrail),"```","</details>","",`<details><summary>Network (${J.network.length})</summary>`,"","```",i4(J.network),"```","</details>","",`<details><summary>Console (${J.console.length})</summary>`,"","```",l4(J.console),"```","</details>","","_ข้อมูลลับ (token, cookie) ถูกปกปิดอัตโนมัติ · ภาพหน้าจออยู่ในไฟล์ .zip_"),Q.join(`
41
- `)}function a4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function t4(J,$){return`debug-report_${a4(J.context.capturedAt)}.${$}`}function e4(J){return c1(J.cause)>0}async function b0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await J6();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await j6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function J6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await $6(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function $6(J){let $=document.createElement("video");$.srcObject=J,$.muted=!0,$.playsInline=!0,await new Promise((W)=>{let V=!1,F=()=>{if(V)return;V=!0,W()};$.onloadedmetadata=()=>{$.play().then(F).catch(F)},window.setTimeout(F,1500)}),await Q6($);let{videoWidth:Q,videoHeight:j}=$;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage($,0,0,Q,j),$.pause(),$.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function Q6(J){return new Promise(($)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,$()},z=J;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function j6(){let J=S().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:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var z6=2000,Z6=0.82,K6=3000000;function W6(J){return new Promise(($,Q)=>{let j=new Image;j.onload=()=>$(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=J})}async function r1(J){try{let $=await W6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,z6/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round($.naturalWidth*j)),z.height=Math.max(1,Math.round($.naturalHeight*j));let K=z.getContext("2d");if(!K)return J;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage($,0,0,z.width,z.height);let W=Z6,V=z.toDataURL("image/jpeg",W);while(V.length>K6&&W>0.4)W-=0.15,V=z.toDataURL("image/jpeg",W);return V}catch{return J}}var Y6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,V6=/^\d+$/,G6=/^[0-9a-f]{16,}$/i;function v0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let j=Q.split("/").map((K)=>Y6.test(K)||V6.test(K)||G6.test(K)?":id":K).join("/"),z=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${j} ${z}`}var p0=2000000;function P0(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return JSON.stringify(j).length}function u0(J,$=2000000){if(P0(J)<=$)return J;let Q=J.network.map((z)=>({...z})),j={...J,network:Q};for(let z of Q){if(P0(j)<=$)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&P0(j)>$)j.network=j.network.slice(1);while(j.console.length>1&&P0(j)>$)j.console=j.console.slice(1);return j}function W0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var X6=4,F6=2,H6=3,U6=0,M6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]);function s1(J){if(!J)return;for(let $ of Object.keys(J)){let Q=J[$];if(typeof Q!=="string"||!M6.has($)||!Q.includes("?"))continue;J[$]=f(Q)}}function d0(J){if(!J)return;s1(J.attributes);for(let $ of J.childNodes??[])d0($)}function n1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===X6&&typeof j.href==="string")j.href=f(j.href);else if(Q.type===F6)d0(j.node);else if(Q.type===H6&&j.source===U6){for(let z of j.adds??[])d0(z.node);for(let z of j.attributes??[])s1(z.attributes)}}return $}var t1="session-replay.json.gz",P6="session-replay.json";function I6(J){return Boolean(J&&J.events.length>0)}async function C6(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 c0(J,$){if(!I6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=n1(J.events),K=await a1(z),W=!1;if(K.bytes.byteLength>$&&B6(z))z=N6(z),K=await a1(z),W=!0;let{bytes:V,compressed:F}=K;if(V.byteLength>$)return{summary:{...j,bytes:V.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${W0(V)}`,filename:F?t1:P6,summary:{...j,events:z.length,bytes:V.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function a1(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),Q=await C6($);return Q?{bytes:Q,compressed:!0}:{bytes:$,compressed:!1}}var D6=3,e1=2,q6=9;function J2(J){return J.type===D6&&J.data?.source===q6}function B6(J){return J.some(J2)||J.some(($)=>$.type===e1&&$2($.data.node))}function $2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some($2)}function Q2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])Q2($)}function N6(J){let $=[];for(let Q of J){if(J2(Q))continue;if(Q.type===e1)Q2(Q.data.node);$.push(Q)}return $}function S6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${W0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function R6(){let J=S().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function i0(J,$){let Q=S(),j=u0($,p0),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let I=await r1(j.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(S6(j));let V,F=z0();if(F){let I=await c0(j.replay,F.maxBytes);if(V=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let M=v0(j),B={title:J,description:K.trim()||void 0,appName:m().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:m().name,module:z.module?.label??""},context:{...M?{signature:M}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...V?{replay:V}:{}},attachments:W},P=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await R6()},body:JSON.stringify(B)});if(!P.ok){let I=P.headers.get("retry-after"),R=await P.json().then((D)=>D.error).catch(()=>null);throw Error(P.status===429?`Too many reports — try again in ${I??"a moment"}s`:R??`Report failed (${P.status})`)}return await P.json()}var Y0=Math.PI/6;function j2(J,$,Q){let j=$.x-J.x,z=$.y-J.y,K=Math.hypot(j,z),W=Math.atan2(z,j),V=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(W-Y0),y:$.y-Q*Math.sin(W-Y0)},{x:$.x-Q*Math.cos(W+Y0),y:$.y-Q*Math.sin(W+Y0)}],F=Q*Math.cos(Y0)*0.92;if(K<=F)return{shaft:null,head:V};return{shaft:{from:J,to:{x:$.x-F*Math.cos(W),y:$.y-F*Math.sin(W)}},head:V}}var l0="#f44336",w6="rgba(250, 204, 21, 0.4)",o0=22,z2="#2563eb",Z2=9,K2=11,W2=18,Y2=4,I0=8,O6=[{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 r0(J,$,Q){let j=[],z=null,K=-1,W=null,V=null,F=J.getContext("2d");function M(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function B(Z){let Y=J.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*J.width,y:(Z.clientY-Y.top)/Y.height*J.height}}function P(Z){let Y=Z.size??o0;if(!F)return(Z.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z.text??"").width;return F.restore(),X}function I(Z){if(Z.tool==="text"){let Y=Z.size??o0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+Y*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function R(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let Y=I(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return O6.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 D(Z){let Y=I(Z);return{x:Y.right+W2*M(),y:Y.top-W2*M()}}function O(Z,Y,X){let{shaft:G,head:H}=j2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(G)Z.lineCap="butt",Z.beginPath(),Z.moveTo(G.from.x,G.from.y),Z.lineTo(G.to.x,G.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,Y,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=l0,Z.fillStyle=l0;let G=I(Y);if(Y.tool==="rect")Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(Y.tool==="arrow")O(Z,Y,X);else if(Y.tool==="highlight")Z.fillStyle=w6,Z.fillRect(G.left,G.top,G.right-G.left,G.bottom-G.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??o0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(G.left-U,G.top-U,G.right-G.left+U*2,G.bottom-G.top+U*2),Z.fillStyle=l0,Z.fillText(Y.text,G.left,G.top)}Z.restore()}function q(Z,Y,X){let G=I(Y);Z.save(),Z.strokeStyle=z2,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(G.left,G.top,G.right-G.left,G.bottom-G.top),Z.setLineDash([]);let H=Z2*X;for(let x of R(Y))Z.fillStyle="#fff",Z.strokeStyle=z2,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(Y),C=K2*X;Z.beginPath(),Z.arc(U.x,U.y,C,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(U.x-C*0.4,U.y-C*0.4),Z.lineTo(U.x+C*0.4,U.y+C*0.4),Z.moveTo(U.x+C*0.4,U.y-C*0.4),Z.lineTo(U.x-C*0.4,U.y+C*0.4),Z.stroke(),Z.restore()}function w(){if(!F)return;let Z=M();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((X,G)=>{if(G!==v)_(F,X,Z)}),W)_(F,W,Z);let Y=j[K];if(Y&&!W)q(F,Y,Z)}function y(Z,Y,X,G,H){return Math.abs(Z-X)<=H&&Math.abs(Y-G)<=H}function $0(Z,Y){let X=j[K];if(!X)return null;let G=Z2*M()/2+3*M();for(let H of R(X))if(y(Z,Y,H.x,H.y,G))return H.id;return null}function c(Z,Y){let X=j[K];if(!X)return!1;let G=D(X);return y(Z,Y,G.x,G.y,K2*M())}function h(Z,Y){let X=6*M();for(let G=j.length-1;G>=0;G-=1){let H=j[G];if(H.tool==="arrow"){let C=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(C,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*C+(Y-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*C),Y-(H.y1+u*x))<=X+4*M())return G;continue}let U=I(H);if(Z>=U.left-X&&Z<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return G}return-1}function b(Z,Y,X,G,H){if(Y==="tail"){Z.x1=X.x1+G,Z.y1=X.y1+H;return}if(Y==="head"){Z.x2=X.x2+G,Z.y2=X.y2+H;return}if(Y==="size"){let D2=(X.size??24)+H;Z.size=Math.max(10,D2);return}let U=I(X),{left:C,top:x,right:p,bottom:u}=U;if(Y.includes("w"))C=Math.min(p-I0,C+G);if(Y.includes("e"))p=Math.max(C+I0,p+G);if(Y.includes("n"))x=Math.min(u-I0,x+H);if(Y.includes("s"))u=Math.max(x+I0,u+H);Z.x1=C,Z.y1=x,Z.x2=p,Z.y2=u}function D0(Z,Y,X,G){Z.x1=Y.x1+X,Z.y1=Y.y1+G,Z.x2=Y.x2+X,Z.y2=Y.y2+G}let L=null,v=-1,N={x:0,y:0,size:24};function E(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function C2(Z,Y){if(!F)return Z.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z||" ").width;return F.restore(),X}function t0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let Y=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),G=E(),H=N.size*G;L.style.left=`${Y.left-X.left+N.x*G}px`,L.style.top=`${Y.top-X.top+N.y*G}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,C2(L.value,H)+H)}px`}function Q0(Z){let Y=L;if(!Y)return;L=null;let X=Y.value.trim(),G=v;if(v=-1,Y.remove(),Z&&X){if(G>=0&&j[G])j[G].text=X,K=G;else j.push({tool:"text",x1:N.x,y1:N.y,x2:N.x,y2:N.y,text:X,size:N.size}),K=j.length-1;Q()}else if(G>=0)K=G;J.focus(),w()}function e0(Z,Y,X=-1){Q0(!0);let G=J.parentElement;if(!G)return;if(getComputedStyle(G).position==="static")G.style.position="relative";let H=X>=0?j[X]:void 0;v=X,N={x:H?.x1??Z,y:H?.y1??Y,size:H?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,G.append(U),t0(),U.addEventListener("input",t0),U.addEventListener("keydown",(C)=>{if(C.stopPropagation(),C.key==="Enter")Q0(!0);else if(C.key==="Escape")Q0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>Q0(!0))}),w()}function J1(Z){let{x:Y,y:X}=B(Z);if(J.setPointerCapture(Z.pointerId),c(Y,X)){q0();return}let G=$0(Y,X);if(G&&j[K]){V={grip:G,x:Y,y:X,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),e0(Y,X);return}if(z){W={tool:z,x1:Y,y1:X,x2:Y,y2:X},K=-1;return}let H=h(Y,X);K=H,V=H>=0?{grip:"body",x:Y,y:X,start:{...j[H]}}:null,w()}function $1(Z){let{x:Y,y:X}=B(Z);if(W){W.x2=Y,W.y2=X,w();return}if(V){let H=j[K];if(!H)return;let U=Y-V.x,C=X-V.y;if(V.grip==="body")D0(H,V.start,U,C);else b(H,V.grip,V.start,U,C);w();return}if(z){J.style.cursor="crosshair";return}if(c(Y,X)){J.style.cursor="pointer";return}let G=$0(Y,X);if(G){let H=j[K]?R(j[K]).find((U)=>U.id===G):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(Y,X)>=0?"move":"default"}function V0(){if(W){if(!(Math.abs(W.x2-W.x1)<Y2&&Math.abs(W.y2-W.y1)<Y2))j.push(W),K=j.length-1,z=null,Q();W=null}if(V)V=null,Q();w()}function Q1(Z){let Y=J.getBoundingClientRect(),X=(Z.clientX-Y.left)/Y.width*J.width,G=(Z.clientY-Y.top)/Y.height*J.height,H=h(X,G),U=j[H];if(!U||U.tool!=="text")return;Z.preventDefault(),e0(U.x1,U.y1,H)}function j1(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),q0();else if(Z.key==="Escape")K=-1,w()}function q0(){if(K<0)return;j.splice(K,1),K=-1,Q(),w()}return J.addEventListener("pointerdown",J1),J.addEventListener("pointermove",$1),J.addEventListener("pointerup",V0),J.addEventListener("pointercancel",V0),J.addEventListener("dblclick",Q1),J.tabIndex=0,J.addEventListener("keydown",j1),w(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",w()},deleteSelected:q0,clear(){j.length=0,K=-1,Q(),w()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let Y=Z.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=M();for(let G of j)_(Y,G,X);return Z.toDataURL("image/png")},destroy(){Q0(!1),J.removeEventListener("pointerdown",J1),J.removeEventListener("pointermove",$1),J.removeEventListener("pointerup",V0),J.removeEventListener("pointercancel",V0),J.removeEventListener("dblclick",Q1),J.removeEventListener("keydown",j1)}}}var V2=`
41
+ `)}function a4(J){return J.replace(/[:.]/g,"-").replace("T","_").slice(0,19)}function t4(J,$){return`debug-report_${a4(J.context.capturedAt)}.${$}`}function e4(J){return c1(J.cause)>0}async function b0(){if(typeof navigator<"u"&&Boolean(navigator.mediaDevices?.getDisplayMedia)){let Q=await J6();if(Q.status==="ok")return{dataUrl:Q.dataUrl,method:"display-media"};if(Q.status==="cancelled")return{dataUrl:null,method:"cancelled"}}let $=await j6();if($)return{dataUrl:$,method:"html-to-image"};return{dataUrl:null,method:"none"}}async function J6(){let J=null;try{let $={video:{frameRate:30},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude"};J=await navigator.mediaDevices.getDisplayMedia($);let Q=await $6(J);return Q?{status:"ok",dataUrl:Q}:{status:"error"}}catch($){if($ instanceof DOMException&&($.name==="NotAllowedError"||$.name==="AbortError"))return{status:"cancelled"};return{status:"error"}}finally{J?.getTracks().forEach(($)=>$.stop())}}async function $6(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 Q6($);let{videoWidth:Q,videoHeight:j}=$;if(!Q||!j)return null;let z=document.createElement("canvas");z.width=Q,z.height=j;let K=z.getContext("2d");if(!K)return null;K.drawImage($,0,0,Q,j),$.pause(),$.srcObject=null;try{return z.toDataURL("image/png")}catch{return null}}function Q6(J){return new Promise(($)=>{let Q=!1,j=()=>{if(Q)return;Q=!0,$()},z=J;if(typeof z.requestVideoFrameCallback==="function")z.requestVideoFrameCallback(()=>j()),window.setTimeout(j,1000);else window.setTimeout(j,250)})}async function j6(){let J=S().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:(Q)=>!(Q instanceof HTMLElement&&Q.dataset?.debugReporter==="true")})}catch{return null}}var z6=2000,Z6=0.82,K6=3000000;function W6(J){return new Promise(($,Q)=>{let j=new Image;j.onload=()=>$(j),j.onerror=()=>Q(Error("could not read the screenshot")),j.src=J})}async function r1(J){try{let $=await W6(J),Q=Math.max($.naturalWidth,$.naturalHeight),j=Math.min(1,z6/Q),z=document.createElement("canvas");z.width=Math.max(1,Math.round($.naturalWidth*j)),z.height=Math.max(1,Math.round($.naturalHeight*j));let K=z.getContext("2d");if(!K)return J;K.fillStyle="#fff",K.fillRect(0,0,z.width,z.height),K.drawImage($,0,0,z.width,z.height);let W=Z6,G=z.toDataURL("image/jpeg",W);while(G.length>K6&&W>0.4)W-=0.15,G=z.toDataURL("image/jpeg",W);return G}catch{return J}}var Y6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,G6=/^\d+$/,V6=/^[0-9a-f]{16,}$/i;function v0(J){if(J.reason.type==="manual")return null;let $=J.cause?.failedRequests?.[0];if(!$?.url)return null;let Q;try{Q=new URL($.url,"http://x").pathname}catch{Q=$.url}let j=Q.split("/").map((K)=>Y6.test(K)||G6.test(K)||V6.test(K)?":id":K).join("/"),z=$.status??($.error?"ERR":"?");return`${$.method??"REQ"} ${j} ${z}`}var p0=2000000;function P0(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return JSON.stringify(j).length}function u0(J,$=2000000){if(P0(J)<=$)return J;let Q=J.network.map((z)=>({...z})),j={...J,network:Q};for(let z of Q){if(P0(j)<=$)return j;if(typeof z.responseSnippet==="string"&&z.responseSnippet.length>35)z.responseSnippet="[body dropped — report size budget]";if(typeof z.requestBody==="string"&&z.requestBody.length>35)z.requestBody="[body dropped — report size budget]"}while(j.network.length>1&&P0(j)>$)j.network=j.network.slice(1);while(j.console.length>1&&P0(j)>$)j.console=j.console.slice(1);return j}function W0(J){let $="";for(let Q=0;Q<J.length;Q+=32768)$+=String.fromCharCode(...J.subarray(Q,Q+32768));return btoa($)}var X6=4,F6=2,H6=3,U6=0,M6=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset"]),P6=/^\s*javascript:/i;function I6(J,$){let Q=J.toLowerCase();if(Q.startsWith("on")||Q==="srcdoc")return!0;return typeof $==="string"&&P6.test($)}function s1(J,$=!1){if(!J)return;for(let Q of Object.keys(J)){let j=J[Q];if(I6(Q,j)){if($)J[Q]=null;else delete J[Q];continue}if(typeof j!=="string"||!M6.has(Q)||!j.includes("?"))continue;J[Q]=f(j)}}function d0(J){if(!J)return;s1(J.attributes);for(let $ of J.childNodes??[])d0($)}function n1(J){let $=JSON.parse(JSON.stringify(J));for(let Q of $){let j=Q.data;if(!j||typeof j!=="object")continue;if(Q.type===X6&&typeof j.href==="string")j.href=f(j.href);else if(Q.type===F6)d0(j.node);else if(Q.type===H6&&j.source===U6){for(let z of j.adds??[])d0(z.node);for(let z of j.attributes??[])s1(z.attributes,!0)}}return $}var t1="session-replay.json.gz",C6="session-replay.json";function D6(J){return Boolean(J&&J.events.length>0)}async function q6(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 c0(J,$){if(!D6(J))return{summary:{omitted:"empty"}};let j={seconds:Math.round(J.durationMs/1000),events:J.events.length,startedAt:J.startedAt,endedAt:J.endedAt},z=n1(J.events),K=await a1(z),W=!1;if(K.bytes.byteLength>$&&S6(z))z=w6(z),K=await a1(z),W=!0;let{bytes:G,compressed:F}=K;if(G.byteLength>$)return{summary:{...j,bytes:G.byteLength,omitted:"too-large"}};return{dataUri:`data:${F?"application/gzip":"application/json"};base64,${W0(G)}`,filename:F?t1:C6,summary:{...j,events:z.length,bytes:G.byteLength,compressed:F,...W?{canvasDropped:W}:{}}}}async function a1(J){let $=new TextEncoder().encode(JSON.stringify({events:J})),Q=await q6($);return Q?{bytes:Q,compressed:!0}:{bytes:$,compressed:!1}}var B6=3,e1=2,N6=9;function J2(J){return J.type===B6&&J.data?.source===N6}function S6(J){return J.some(J2)||J.some(($)=>$.type===e1&&$2($.data.node))}function $2(J){if(!J)return!1;if(J.attributes&&"rr_dataURL"in J.attributes)return!0;return(J.childNodes??[]).some($2)}function Q2(J){if(!J)return;if(J.attributes&&"rr_dataURL"in J.attributes)delete J.attributes.rr_dataURL;for(let $ of J.childNodes??[])Q2($)}function w6(J){let $=[];for(let Q of J){if(J2(Q))continue;if(Q.type===e1)Q2(Q.data.node);$.push(Q)}return $}function O6(J){let{screenshotDataUrl:$,replay:Q,...j}=J;return{dataUri:`data:application/json;base64,${W0(new TextEncoder().encode(JSON.stringify(j)))}`,filename:"debug-bundle.json"}}async function R6(){let J=S().identity;if(!J)return{};try{let $=await J();return $?{authorization:`Bearer ${$}`}:{}}catch{return{}}}async function i0(J,$){let Q=S(),j=u0($,p0),{context:z,note:K}=j,W=[];if(j.screenshotDataUrl){let I=await r1(j.screenshotDataUrl);W.push({dataUri:I,filename:"screenshot.jpg"})}W.push(O6(j));let G,F=z0();if(F){let I=await c0(j.replay,F.maxBytes);if(G=I.summary,"dataUri"in I)W.push({dataUri:I.dataUri,filename:I.filename})}let M=v0(j),B={title:J,description:K.trim()||void 0,appName:m().name,category:z.module?.label,routeUrl:z.route.href,priority:"MEDIUM",requesterEmail:z.user.email??void 0,requesterName:z.user.fullName??void 0,customFields:{unit:z.user.unit??"",appVersion:z.app.version,environment:z.app.environment,reasonType:j.reason.type,appName:m().name,module:z.module?.label??""},context:{...M?{signature:M}:{},capturedAt:z.capturedAt,reason:j.reason,cause:j.cause,actionTrail:j.actionTrail,client:z.client,performance:z.performance,apiHeaders:z.apiHeaders,extra:z.extra,counts:{network:j.network.length,console:j.console.length,actions:j.actionTrail.length},screenshotMethod:j.screenshotMethod,...G?{replay:G}:{}},attachments:W},P=await fetch(`${Q.host.replace(/\/$/,"")}/ingest/tickets`,{method:"POST",headers:{"content-type":"application/json","x-realm-key":Q.realmKey,...await R6()},body:JSON.stringify(B)});if(!P.ok){let I=P.headers.get("retry-after"),w=await P.json().then((D)=>D.error).catch(()=>null);throw Error(P.status===429?`Too many reports — try again in ${I??"a moment"}s`:w??`Report failed (${P.status})`)}return await P.json()}var Y0=Math.PI/6;function j2(J,$,Q){let j=$.x-J.x,z=$.y-J.y,K=Math.hypot(j,z),W=Math.atan2(z,j),G=[{x:$.x,y:$.y},{x:$.x-Q*Math.cos(W-Y0),y:$.y-Q*Math.sin(W-Y0)},{x:$.x-Q*Math.cos(W+Y0),y:$.y-Q*Math.sin(W+Y0)}],F=Q*Math.cos(Y0)*0.92;if(K<=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 l0="#f44336",_6="rgba(250, 204, 21, 0.4)",o0=22,z2="#2563eb",Z2=9,K2=11,W2=18,Y2=4,I0=8,L6=[{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 r0(J,$,Q){let j=[],z=null,K=-1,W=null,G=null,F=J.getContext("2d");function M(){let Z=J.getBoundingClientRect().width;return Z>0?J.width/Z:1}function B(Z){let Y=J.getBoundingClientRect();return{x:(Z.clientX-Y.left)/Y.width*J.width,y:(Z.clientY-Y.top)/Y.height*J.height}}function P(Z){let Y=Z.size??o0;if(!F)return(Z.text?.length??0)*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z.text??"").width;return F.restore(),X}function I(Z){if(Z.tool==="text"){let Y=Z.size??o0;return{left:Z.x1,top:Z.y1,right:Z.x1+P(Z),bottom:Z.y1+Y*1.25}}return{left:Math.min(Z.x1,Z.x2),top:Math.min(Z.y1,Z.y2),right:Math.max(Z.x1,Z.x2),bottom:Math.max(Z.y1,Z.y2)}}function w(Z){if(Z.tool==="arrow")return[{id:"tail",x:Z.x1,y:Z.y1,cursor:"move"},{id:"head",x:Z.x2,y:Z.y2,cursor:"move"}];let Y=I(Z);if(Z.tool==="text")return[{id:"size",x:Y.right,y:Y.bottom,cursor:"nwse-resize"}];return L6.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 D(Z){let Y=I(Z);return{x:Y.right+W2*M(),y:Y.top-W2*M()}}function R(Z,Y,X){let{shaft:V,head:H}=j2({x:Y.x1,y:Y.y1},{x:Y.x2,y:Y.y2},Math.max(10,16*X));if(V)Z.lineCap="butt",Z.beginPath(),Z.moveTo(V.from.x,V.from.y),Z.lineTo(V.to.x,V.to.y),Z.stroke();Z.beginPath(),Z.moveTo(H[0].x,H[0].y),Z.lineTo(H[1].x,H[1].y),Z.lineTo(H[2].x,H[2].y),Z.closePath(),Z.fill()}function _(Z,Y,X){Z.save(),Z.lineWidth=Math.max(2,3*X),Z.strokeStyle=l0,Z.fillStyle=l0;let V=I(Y);if(Y.tool==="rect")Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="arrow")R(Z,Y,X);else if(Y.tool==="highlight")Z.fillStyle=_6,Z.fillRect(V.left,V.top,V.right-V.left,V.bottom-V.top);else if(Y.tool==="text"&&Y.text){let H=Y.size??o0;Z.font=`600 ${H}px system-ui, sans-serif`,Z.textBaseline="top";let U=H*0.22;Z.fillStyle="rgba(255,255,255,0.92)",Z.fillRect(V.left-U,V.top-U,V.right-V.left+U*2,V.bottom-V.top+U*2),Z.fillStyle=l0,Z.fillText(Y.text,V.left,V.top)}Z.restore()}function q(Z,Y,X){let V=I(Y);Z.save(),Z.strokeStyle=z2,Z.lineWidth=Math.max(1,1.5*X),Z.setLineDash([6*X,4*X]),Z.strokeRect(V.left,V.top,V.right-V.left,V.bottom-V.top),Z.setLineDash([]);let H=Z2*X;for(let x of w(Y))Z.fillStyle="#fff",Z.strokeStyle=z2,Z.lineWidth=Math.max(1,1.5*X),Z.beginPath(),Z.rect(x.x-H/2,x.y-H/2,H,H),Z.fill(),Z.stroke();let U=D(Y),C=K2*X;Z.beginPath(),Z.arc(U.x,U.y,C,0,Math.PI*2),Z.fillStyle="#dc2626",Z.fill(),Z.strokeStyle="#fff",Z.lineWidth=Math.max(1.5,2*X),Z.beginPath(),Z.moveTo(U.x-C*0.4,U.y-C*0.4),Z.lineTo(U.x+C*0.4,U.y+C*0.4),Z.moveTo(U.x+C*0.4,U.y-C*0.4),Z.lineTo(U.x-C*0.4,U.y+C*0.4),Z.stroke(),Z.restore()}function O(){if(!F)return;let Z=M();if(F.clearRect(0,0,J.width,J.height),F.drawImage($,0,0,J.width,J.height),j.forEach((X,V)=>{if(V!==v)_(F,X,Z)}),W)_(F,W,Z);let Y=j[K];if(Y&&!W)q(F,Y,Z)}function y(Z,Y,X,V,H){return Math.abs(Z-X)<=H&&Math.abs(Y-V)<=H}function $0(Z,Y){let X=j[K];if(!X)return null;let V=Z2*M()/2+3*M();for(let H of w(X))if(y(Z,Y,H.x,H.y,V))return H.id;return null}function c(Z,Y){let X=j[K];if(!X)return!1;let V=D(X);return y(Z,Y,V.x,V.y,K2*M())}function h(Z,Y){let X=6*M();for(let V=j.length-1;V>=0;V-=1){let H=j[V];if(H.tool==="arrow"){let C=H.x2-H.x1,x=H.y2-H.y1,p=Math.hypot(C,x)||1,u=Math.max(0,Math.min(1,((Z-H.x1)*C+(Y-H.y1)*x)/(p*p)));if(Math.hypot(Z-(H.x1+u*C),Y-(H.y1+u*x))<=X+4*M())return V;continue}let U=I(H);if(Z>=U.left-X&&Z<=U.right+X&&Y>=U.top-X&&Y<=U.bottom+X)return V}return-1}function b(Z,Y,X,V,H){if(Y==="tail"){Z.x1=X.x1+V,Z.y1=X.y1+H;return}if(Y==="head"){Z.x2=X.x2+V,Z.y2=X.y2+H;return}if(Y==="size"){let D2=(X.size??24)+H;Z.size=Math.max(10,D2);return}let U=I(X),{left:C,top:x,right:p,bottom:u}=U;if(Y.includes("w"))C=Math.min(p-I0,C+V);if(Y.includes("e"))p=Math.max(C+I0,p+V);if(Y.includes("n"))x=Math.min(u-I0,x+H);if(Y.includes("s"))u=Math.max(x+I0,u+H);Z.x1=C,Z.y1=x,Z.x2=p,Z.y2=u}function D0(Z,Y,X,V){Z.x1=Y.x1+X,Z.y1=Y.y1+V,Z.x2=Y.x2+X,Z.y2=Y.y2+V}let L=null,v=-1,N={x:0,y:0,size:24};function E(){let Z=J.getBoundingClientRect().width;return Z>0?Z/J.width:1}function C2(Z,Y){if(!F)return Z.length*Y*0.6;F.save(),F.font=`600 ${Y}px system-ui, sans-serif`;let X=F.measureText(Z||" ").width;return F.restore(),X}function t0(){if(!L)return;let Z=J.parentElement;if(!Z)return;let Y=J.getBoundingClientRect(),X=Z.getBoundingClientRect(),V=E(),H=N.size*V;L.style.left=`${Y.left-X.left+N.x*V}px`,L.style.top=`${Y.top-X.top+N.y*V}px`,L.style.fontSize=`${H}px`,L.style.width=`${Math.max(40,C2(L.value,H)+H)}px`}function Q0(Z){let Y=L;if(!Y)return;L=null;let X=Y.value.trim(),V=v;if(v=-1,Y.remove(),Z&&X){if(V>=0&&j[V])j[V].text=X,K=V;else j.push({tool:"text",x1:N.x,y1:N.y,x2:N.x,y2:N.y,text:X,size:N.size}),K=j.length-1;Q()}else if(V>=0)K=V;J.focus(),O()}function e0(Z,Y,X=-1){Q0(!0);let V=J.parentElement;if(!V)return;if(getComputedStyle(V).position==="static")V.style.position="relative";let H=X>=0?j[X]:void 0;v=X,N={x:H?.x1??Z,y:H?.y1??Y,size:H?.size??Math.round(24*M())};let U=document.createElement("input");U.type="text",U.className="text-edit",U.value=H?.text??"",U.setAttribute("aria-label","ข้อความบนภาพ"),U.placeholder="ข้อความ",L=U,V.append(U),t0(),U.addEventListener("input",t0),U.addEventListener("keydown",(C)=>{if(C.stopPropagation(),C.key==="Enter")Q0(!0);else if(C.key==="Escape")Q0(!1)}),requestAnimationFrame(()=>{if(L!==U)return;U.focus(),U.select(),U.addEventListener("blur",()=>Q0(!0))}),O()}function J1(Z){let{x:Y,y:X}=B(Z);if(J.setPointerCapture(Z.pointerId),c(Y,X)){q0();return}let V=$0(Y,X);if(V&&j[K]){G={grip:V,x:Y,y:X,start:{...j[K]}};return}if(z==="text"){if(Z.preventDefault(),J.hasPointerCapture(Z.pointerId))J.releasePointerCapture(Z.pointerId);z=null,Q(),e0(Y,X);return}if(z){W={tool:z,x1:Y,y1:X,x2:Y,y2:X},K=-1;return}let H=h(Y,X);K=H,G=H>=0?{grip:"body",x:Y,y:X,start:{...j[H]}}:null,O()}function $1(Z){let{x:Y,y:X}=B(Z);if(W){W.x2=Y,W.y2=X,O();return}if(G){let H=j[K];if(!H)return;let U=Y-G.x,C=X-G.y;if(G.grip==="body")D0(H,G.start,U,C);else b(H,G.grip,G.start,U,C);O();return}if(z){J.style.cursor="crosshair";return}if(c(Y,X)){J.style.cursor="pointer";return}let V=$0(Y,X);if(V){let H=j[K]?w(j[K]).find((U)=>U.id===V):null;J.style.cursor=H?.cursor??"pointer";return}J.style.cursor=h(Y,X)>=0?"move":"default"}function G0(){if(W){if(!(Math.abs(W.x2-W.x1)<Y2&&Math.abs(W.y2-W.y1)<Y2))j.push(W),K=j.length-1,z=null,Q();W=null}if(G)G=null,Q();O()}function Q1(Z){let Y=J.getBoundingClientRect(),X=(Z.clientX-Y.left)/Y.width*J.width,V=(Z.clientY-Y.top)/Y.height*J.height,H=h(X,V),U=j[H];if(!U||U.tool!=="text")return;Z.preventDefault(),e0(U.x1,U.y1,H)}function j1(Z){if(K<0)return;if(Z.key==="Delete"||Z.key==="Backspace")Z.preventDefault(),q0();else if(Z.key==="Escape")K=-1,O()}function q0(){if(K<0)return;j.splice(K,1),K=-1,Q(),O()}return J.addEventListener("pointerdown",J1),J.addEventListener("pointermove",$1),J.addEventListener("pointerup",G0),J.addEventListener("pointercancel",G0),J.addEventListener("dblclick",Q1),J.tabIndex=0,J.addEventListener("keydown",j1),O(),{setTool(Z){z=Z,K=-1,J.style.cursor=Z?"crosshair":"default",O()},deleteSelected:q0,clear(){j.length=0,K=-1,Q(),O()},hasShapes:()=>j.length>0,hasSelection:()=>K>=0,toDataUrl(){let Z=document.createElement("canvas");Z.width=$.naturalWidth,Z.height=$.naturalHeight;let Y=Z.getContext("2d");if(!Y)return J.toDataURL("image/png");Y.drawImage($,0,0);let X=M();for(let V of j)_(Y,V,X);return Z.toDataURL("image/png")},destroy(){Q0(!1),J.removeEventListener("pointerdown",J1),J.removeEventListener("pointermove",$1),J.removeEventListener("pointerup",G0),J.removeEventListener("pointercancel",G0),J.removeEventListener("dblclick",Q1),J.removeEventListener("keydown",j1)}}}var G2=`
42
42
  :host { all: initial; }
43
43
  * { box-sizing: border-box; }
44
44
 
@@ -121,7 +121,7 @@ canvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; b
121
121
  border-radius: 0 0 16px 16px;
122
122
  }
123
123
  .foot .grow { flex: 1; }
124
- `;var J0="lw-debug-reporter",G2=()=>[];function _6(J){G2=J}var L6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function k6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=T0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(S().locale),j=await b0();if(j.method==="cancelled"){this.close();return}this.bundle=y0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:T6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=V2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=e("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let V=s0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let M=k("div","meta");M.innerHTML="";let{context:B}=Q;for(let[O,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),w=document.createElement("b");w.textContent=`${O}: `,q.append(w,document.createTextNode(_)),M.append(q)}let P=k("p","status",""),I=e($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,V,W,s0($.detailLabel),F,M),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let R=k("div","foot"),D=e($.close);D.addEventListener("click",()=>this.close()),R.append(D,P,k("span","grow"),I),j.append(R),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=$.submitting;try{let O=await i0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:O,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)t(`${$.submitted} — #${O.number}`,"success")}catch(O){let _=O instanceof Error?O.message:$.failed;P.dataset.tone="error",P.textContent=_,t(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=s0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let V=[],F=(I)=>{for(let R of V)R.setAttribute("aria-pressed",String(R===I))};for(let{tool:I,key:R}of L6){let D=e($[R]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let O=D.getAttribute("aria-pressed")==="true";F(O?null:D),this.annotator?.setTool(O?null:I)}),V.push(D),z.append(D)}z.append(k("span","sep"));let M=e($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let B=e($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(M,B);let P=new Image;return P.onload=()=>{K.width=P.naturalWidth,K.height=P.naturalHeight,this.annotator=r0(K,P,()=>{F(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function T6(){try{return G2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function e(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function s0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function n0(){if(typeof window>"u"||customElements.get(J0))return;customElements.define(J0,k6())}var X2=!1;function A6(J={}){if(X2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(X2=!0,v1(),S1(),C1(),A1(),u1(),J.ui===!1)return;let $=d(S().locale);if(x0((Q)=>{t(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>A0(Q)})}),n0(),!document.querySelector(J0))document.body.append(document.createElement(J0))}var x6=new Set(["error","exception","unhandledrejection"]);function F2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function a0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function E6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function f6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>a0(W.at)),K=(W)=>{for(let V=W+1;V<z.length;V+=1){let F=z[V];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,V)=>{let F=z[V]??null,M=(V>0?z[V-1]:null)??null,B=F!==null&&M!==null?Math.max(0,F-M):null;if(F===null)return j(B);let P=F,I=Math.max(P,K(V)),R=(q)=>q!==null&&q>=P&&(q<I||I===Number.POSITIVE_INFINITY),D=$.filter((q)=>R(a0(q.startedAt))),O=Q.filter((q)=>x6.has(q.level)&&R(a0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(F2),consoleErrors:O,slowestMs:_.length>0?Math.max(..._):null}})}function h6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function m6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var g6="lw-portal-handoff",H2=138.23,y6=`
124
+ `;var J0="lw-debug-reporter",V2=()=>[];function k6(J){V2=J}var A6=[{tool:"rect",key:"toolRect"},{tool:"arrow",key:"toolArrow"},{tool:"highlight",key:"toolHighlight"},{tool:"text",key:"toolText"}];function T6(){return class extends HTMLElement{root;stop=null;annotator=null;bundle=null;busy=!1;constructor(){super();this.root=this.attachShadow({mode:"open"})}connectedCallback(){this.dataset.debugReporter="true",this.stop=A0(($)=>void this.open($))}disconnectedCallback(){this.stop?.(),this.stop=null,this.close()}async open($){if(this.busy)return;this.busy=!0;let Q=d(S().locale),j=await b0();if(j.method==="cancelled"){this.close();return}this.bundle=y0({reason:$,note:"",screenshotDataUrl:j.dataUrl,screenshotMethod:j.method,erroredQueries:x6()}),this.renderForm(Q)}close(){this.annotator?.destroy(),this.annotator=null,this.bundle=null,this.busy=!1,this.root.replaceChildren()}shell($){let Q=document.createElement("style");Q.textContent=G2;let j=document.createElement("div");j.className="backdrop";let z=document.createElement("div");return z.className="panel",z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",$.title),j.append(z),this.root.replaceChildren(Q,j),z}renderShell($,Q){let j=this.shell($),z=k("div","head");z.append(k("h2","",$.title)),j.append(z,k("p","status",Q))}renderForm($){let Q=this.bundle;if(!Q)return;let j=this.shell($),z=k("div","head"),K=e("✕","icon");K.setAttribute("aria-label",$.close),K.addEventListener("click",()=>this.close()),z.append(k("h2","",$.title),K);let W=document.createElement("input");W.type="text",W.placeholder=$.summaryPlaceholder;let G=s0($.summaryLabel,$.summaryRequired,!0),F=document.createElement("textarea");F.placeholder=$.detailPlaceholder;let M=k("div","meta");M.innerHTML="";let{context:B}=Q;for(let[R,_]of[[$.reporter,`${B.user.fullName??"—"} (${B.user.email??"—"})`],[$.page,B.route.href],[$.captured,`${Q.network.length} network · ${Q.console.length} console · ${Q.actionTrail.length} actions${Q.replay?` · ${$.replay} ${Math.round(Q.replay.durationMs/1000)}s`:""}`]]){let q=document.createElement("div"),O=document.createElement("b");O.textContent=`${R}: `,q.append(O,document.createTextNode(_)),M.append(q)}let P=k("p","status",""),I=e($.submit,"primary");if(I.disabled=!0,W.addEventListener("input",()=>{I.disabled=W.value.trim().length===0}),j.append(z,G,W,s0($.detailLabel),F,M),Q.screenshotDataUrl)j.append(...this.screenshotSection($,Q.screenshotDataUrl));else j.append(k("p","status",$.noScreenshot));let w=k("div","foot"),D=e($.close);D.addEventListener("click",()=>this.close()),w.append(D,P,k("span","grow"),I),j.append(w),I.addEventListener("click",async()=>{I.disabled=!0,P.dataset.tone="",P.textContent=$.submitting;try{let R=await i0(W.value.trim(),{...Q,note:F.value,screenshotDataUrl:this.annotator?.hasShapes()?this.annotator.toDataUrl():Q.screenshotDataUrl}),_=this.dispatchEvent(new CustomEvent("lw-report-submitted",{detail:R,bubbles:!0,composed:!0,cancelable:!0}));if(this.close(),_)t(`${$.submitted} — #${R.number}`,"success")}catch(R){let _=R instanceof Error?R.message:$.failed;P.dataset.tone="error",P.textContent=_,t(`${$.failed} — ${_}`,"error"),I.disabled=!1}}),W.focus()}screenshotSection($,Q){let j=s0($.annotateHint),z=k("div","tools"),K=document.createElement("canvas"),W=k("div","shot");W.append(K);let G=[],F=(I)=>{for(let w of G)w.setAttribute("aria-pressed",String(w===I))};for(let{tool:I,key:w}of A6){let D=e($[w]);D.setAttribute("aria-pressed","false"),D.addEventListener("click",()=>{let R=D.getAttribute("aria-pressed")==="true";F(R?null:D),this.annotator?.setTool(R?null:I)}),G.push(D),z.append(D)}z.append(k("span","sep"));let M=e($.deleteSelected);M.addEventListener("click",()=>this.annotator?.deleteSelected());let B=e($.clearAll);B.addEventListener("click",()=>{this.annotator?.clear(),F(null)}),z.append(M,B);let P=new Image;return P.onload=()=>{K.width=P.naturalWidth,K.height=P.naturalHeight,this.annotator=r0(K,P,()=>{F(null),M.disabled=!this.annotator?.hasSelection()})},P.src=Q,[j,z,k("p","status",$.annotateHelp),W]}}}function x6(){try{return V2()}catch{return[]}}function k(J,$="",Q=""){let j=document.createElement(J);if($)j.className=$;if(Q)j.textContent=Q;return j}function e(J,$=""){let Q=document.createElement("button");if(Q.type="button",Q.textContent=J,$)Q.className=$;return Q}function s0(J,$="",Q=!1){let j=document.createElement("label");if(j.append(document.createTextNode(J)),Q){let z=document.createElement("span");z.className="req",z.textContent=" *",j.append(z)}if($){let z=document.createElement("span");z.className="hint",z.textContent=` ${$}`,j.append(z)}return j}function n0(){if(typeof window>"u"||customElements.get(J0))return;customElements.define(J0,T6())}var X2=!1;function E6(J={}){if(X2||typeof window>"u")return;if(!j0()){console.error("[debug-capture] configureDebugCapture() must be called before install");return}if(X2=!0,v1(),S1(),C1(),T1(),u1(),J.ui===!1)return;let $=d(S().locale);if(x0((Q)=>{t(Q.message??$.crashed,"error",{label:$.crashAction,onClick:()=>T0(Q)})}),n0(),!document.querySelector(J0))document.body.append(document.createElement(J0))}var f6=new Set(["error","exception","unhandledrejection"]);function F2(J){if(J.error)return!0;return J.status!==null&&J.status>=400}function a0(J){if(!J)return null;let $=Date.parse(J);return Number.isNaN($)?null:$}function h6(J){try{let{pathname:$}=new URL(J,"http://x");try{return decodeURIComponent($)}catch{return $}}catch{return J.split(/[?#]/)[0]??J}}function m6(J,$,Q){let j=(W)=>({elapsedMs:W,requests:[],failedRequests:[],consoleErrors:[],slowestMs:null});if(J.length===0)return[];let z=J.map((W)=>a0(W.at)),K=(W)=>{for(let G=W+1;G<z.length;G+=1){let F=z[G];if(F!=null)return F}return Number.POSITIVE_INFINITY};return J.map((W,G)=>{let F=z[G]??null,M=(G>0?z[G-1]:null)??null,B=F!==null&&M!==null?Math.max(0,F-M):null;if(F===null)return j(B);let P=F,I=Math.max(P,K(G)),w=(q)=>q!==null&&q>=P&&(q<I||I===Number.POSITIVE_INFINITY),D=$.filter((q)=>w(a0(q.startedAt))),R=Q.filter((q)=>f6.has(q.level)&&w(a0(q.at))),_=D.map((q)=>q.durationMs).filter((q)=>typeof q==="number");return{elapsedMs:B,requests:D,failedRequests:D.filter(F2),consoleErrors:R,slowestMs:_.length>0?Math.max(..._):null}})}function g6(J,$){return J.requests.length===0&&J.consoleErrors.length===0&&(J.elapsedMs===null||J.elapsedMs<$)}function y6(J){if(J<1000)return`${Math.round(J)} มิลลิวินาที`;let $=J/1000;if($<10)return`${$.toFixed(1)} วิ`;if($<60)return`${Math.round($)} วิ`;let Q=Math.floor($/60),j=Math.round($%60);return j===0?`${Q} นาที`:`${Q} นาที ${j} วิ`}var b6="lw-portal-handoff",H2=138.23,v6=`
125
125
  :host { all: initial; }
126
126
  .backdrop {
127
127
  position: fixed; inset: 0; z-index: 2147483002;
@@ -198,7 +198,7 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
198
198
  .ring .bar { animation: none; stroke-dashoffset: 0; }
199
199
  .spinner { animation-duration: 2s; }
200
200
  }
201
- `;function U2(J){if(typeof document>"u")return J.prepare().then((q)=>void J.go(q),()=>{return});let $=d(S().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(g6),z=j.attachShadow({mode:"open"}),K=document.createElement("style");K.textContent=y6,z.append(K);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
201
+ `;function U2(J){if(typeof document>"u")return J.prepare().then((q)=>void J.go(q),()=>{return});let $=d(S().locale),Q=Math.max(1,Math.floor(J.seconds??3)),j=document.createElement(b6),z=j.attachShadow({mode:"open"}),K=document.createElement("style");K.textContent=v6,z.append(K);let W=document.createElement("div");W.className="backdrop",W.innerHTML=`
202
202
  <div class="card" role="dialog" aria-modal="true" aria-labelledby="lw-ho-title">
203
203
  <div class="dial">
204
204
  <svg class="ring" viewBox="0 0 52 52" aria-hidden="true">
@@ -214,4 +214,4 @@ p { margin: 0; font-size: 13px; line-height: 1.6; color: #475569; }
214
214
  <button type="button" class="cancel"></button>
215
215
  <button type="button" class="go"></button>
216
216
  </div>
217
- </div>`,z.append(W);let V=(q)=>W.querySelector(q),F=V(".card"),M=V(".bar"),B=V(".count"),P=V("h2"),I=V(".body"),R=V(".host"),D=V(".go"),O=V(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{R.textContent=new URL(S().host).host}catch{R.textContent=""}D.textContent=$.handoffGo,O.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let w=!1,y=null,$0=!1,c=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((c-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=c)L()},100);function b(N){if(w)return;if(w=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function D0(N){window.clearInterval(h),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=N,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>b(!0)),D.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(w||$0)return;if(y)return J.go(y)?b(!0):D0(y);window.clearInterval(h),B.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),O.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!w&&Date.now()>=c)L()},()=>{$0=!0,window.clearInterval(h),F.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,D.remove(),O.textContent=$.close})})}var b6="/sso";function I2(J,$,Q){let j=new URL(b6,J.endsWith("/")?J:`${J}/`);return j.searchParams.set("realm",$),j.searchParams.set("token",Q),j.toString()}class C0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function M2(){let J=S();if(!J.identity)throw new C0;let $=await J.identity();if(!$)throw new C0;return I2(J.host,J.realmKey,$)}function P2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function v6(J={}){if(J.announce===!1){P2(await M2(),J.target);return}await U2({seconds:J.seconds,prepare:M2,go:($)=>P2($,J.target)})}export{u0 as trimToBudget,o1 as toCurl,h0 as takeReplay,I2 as supportPortalUrl,i0 as submitBundle,f4 as stopReplay,t as showToast,_6 as setErroredQueriesSource,E6 as requestPath,d as reporterStrings,f as redactUrl,l as redactLabel,o as redactHeaders,r as redactBody,c0 as packReplay,v6 as openSupportPortal,T0 as onLaunch,x0 as onCrash,_2 as moduleResolver,A0 as launch,E4 as isReplayRecording,h6 as isQuietStep,F2 as isFailedRequest,j0 as isConfigured,A6 as installDebugCapture,e4 as hasCause,f0 as getNetworkLog,k0 as getConsoleLog,S as getConfig,_0 as getActionTrail,m6 as formatDuration,v0 as errorSignature,E0 as emitCrash,n0 as defineReporterElement,r0 as createAnnotator,f6 as correlateActionTrail,N2 as configureDebugCapture,b0 as captureScreen,n4 as bundleToMarkdown,t4 as bundleFileName,y0 as buildBundle,m as appInfo,w0 as actionCountSuffix,J0 as REPORTER_TAG,t1 as REPLAY_FILENAME,i as REDACTED,C0 as NoIdentityError,p0 as BUNDLE_BUDGET_BYTES};
217
+ </div>`,z.append(W);let G=(q)=>W.querySelector(q),F=G(".card"),M=G(".bar"),B=G(".count"),P=G("h2"),I=G(".body"),w=G(".host"),D=G(".go"),R=G(".cancel");P.textContent=$.handoffTitle,I.textContent=$.handoffBody;try{w.textContent=new URL(S().host).host}catch{w.textContent=""}D.textContent=$.handoffGo,R.textContent=$.cancel,F.style.setProperty("--secs",`${Q}s`),B.textContent=String(Q),document.body.append(j),requestAnimationFrame(()=>W.setAttribute("data-open","1"));let _=document.activeElement;return D.focus({preventScroll:!0}),new Promise((q)=>{let O=!1,y=null,$0=!1,c=Date.now()+Q*1000,h=window.setInterval(()=>{let N=Math.ceil((c-Date.now())/1000);if(B.textContent=String(Math.max(0,N)),Date.now()>=c)L()},100);function b(N){if(O)return;if(O=!0,window.clearInterval(h),document.removeEventListener("keydown",v,!0),W.removeAttribute("data-open"),window.setTimeout(()=>j.remove(),200),!N)_?.focus?.({preventScroll:!0});q()}function D0(N){window.clearInterval(h),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffBlocked,I.textContent=$.handoffBody;let E=document.createElement("a");E.className="go",E.href=N,E.target="_blank",E.rel="noopener noreferrer",E.textContent=$.handoffOpen,E.addEventListener("click",()=>b(!0)),D.replaceWith(E),E.focus({preventScroll:!0})}function L(){if(O||$0)return;if(y)return J.go(y)?b(!0):D0(y);window.clearInterval(h),B.textContent="",M.classList.add("spinner"),P.textContent=$.handoffPreparing}function v(N){if(N.key==="Escape")N.stopPropagation(),b(!1)}document.addEventListener("keydown",v,!0),D.addEventListener("click",L),R.addEventListener("click",()=>b(!1)),W.addEventListener("click",(N)=>{if(N.target===W)b(!1)}),J.prepare().then((N)=>{if(y=N,!O&&Date.now()>=c)L()},()=>{$0=!0,window.clearInterval(h),F.classList.add("error"),M.classList.remove("spinner"),M.style.animation="none",B.textContent="",P.textContent=$.handoffFailed,I.textContent=$.handoffBody,D.remove(),R.textContent=$.close})})}var p6="/sso";function I2(J,$,Q,j){let z=new URL(p6,J.endsWith("/")?J:`${J}/`);if(z.searchParams.set("realm",$),z.searchParams.set("token",Q),j)z.searchParams.set("return",j);return z.toString()}class C0 extends Error{constructor(J="No identity provider is configured, or nobody is signed in"){super(J);this.name="NoIdentityError"}}async function M2(J){let $=S();if(!$.identity)throw new C0;let Q=await $.identity();if(!Q)throw new C0;return I2($.host,$.realmKey,Q,J)}function P2(J,$){if($==="_self")return window.location.assign(J),!0;let Q=window.open(J,"_blank");if(!Q)return!1;try{Q.opener=null}catch{}return!0}async function u6(J={}){if(J.announce===!1){P2(await M2(J.returnTo),J.target);return}await U2({seconds:J.seconds,prepare:()=>M2(J.returnTo),go:($)=>P2($,J.target)})}export{u0 as trimToBudget,o1 as toCurl,h0 as takeReplay,I2 as supportPortalUrl,i0 as submitBundle,f4 as stopReplay,t as showToast,k6 as setErroredQueriesSource,h6 as requestPath,d as reporterStrings,f as redactUrl,l as redactLabel,o as redactHeaders,r as redactBody,c0 as packReplay,u6 as openSupportPortal,A0 as onLaunch,x0 as onCrash,_2 as moduleResolver,T0 as launch,E4 as isReplayRecording,g6 as isQuietStep,F2 as isFailedRequest,j0 as isConfigured,E6 as installDebugCapture,e4 as hasCause,f0 as getNetworkLog,k0 as getConsoleLog,S as getConfig,_0 as getActionTrail,y6 as formatDuration,v0 as errorSignature,E0 as emitCrash,n0 as defineReporterElement,r0 as createAnnotator,m6 as correlateActionTrail,N2 as configureDebugCapture,b0 as captureScreen,n4 as bundleToMarkdown,t4 as bundleFileName,y0 as buildBundle,m as appInfo,O0 as actionCountSuffix,J0 as REPORTER_TAG,t1 as REPLAY_FILENAME,i as REDACTED,C0 as NoIdentityError,p0 as BUNDLE_BUDGET_BYTES};
package/dist/portal.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * tested without a browser, and so a host that wants its own link element
4
4
  * rather than our button has something to point it at.
5
5
  */
6
- export declare function supportPortalUrl(host: string, realmKey: string, token: string): string;
6
+ export declare function supportPortalUrl(host: string, realmKey: string, token: string, returnTo?: string): string;
7
7
  export declare class NoIdentityError extends Error {
8
8
  constructor(message?: string);
9
9
  }
@@ -19,6 +19,16 @@ export interface OpenPortalOptions {
19
19
  announce?: boolean;
20
20
  /** How long the dialog counts down. Default 3. */
21
21
  seconds?: number;
22
+ /**
23
+ * Where on the portal to land, as a path — `/me/tickets/<id>` behind a
24
+ * notification about that ticket, say. Without it the person arrives at
25
+ * their ticket list, which is right for a button and wrong for a link that
26
+ * named one ticket: they would then have to find it again.
27
+ *
28
+ * A hint, not a redirect. The portal accepts only a path on itself, under
29
+ * the reporter's own pages, and falls back to the list for anything else.
30
+ */
31
+ returnTo?: string;
22
32
  }
23
33
  /**
24
34
  * Open the portal, signed in as the current user.
@@ -38,7 +38,10 @@ export interface Strings {
38
38
  captured: string;
39
39
  reporter: string;
40
40
  page: string;
41
- /** In the captured row: "… · replay 14s". */
41
+ /**
42
+ * In the captured row: "… · บันทึกการใช้งาน 14s". A log of the page and
43
+ * the actions — not "screen recording", which the lead read as a video.
44
+ */
42
45
  replay: string;
43
46
  /** The hand-off dialog, shown before leaving for the support portal. */
44
47
  handoffTitle: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
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",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The widget's URL policy, applied to the replay.
2
+ * The widget's URL policy, applied to the replay — and nothing that runs.
3
3
  *
4
4
  * rrweb records the page as it is, and a page is full of URLs: every link's
5
5
  * href, every image's src, the address bar in the Meta event. The network
@@ -11,6 +11,14 @@
11
11
  * passed through the same function. Text is untouched: what the page SAYS
12
12
  * is what a replay is for, and a host whose text is itself the secret has
13
13
  * `maskText`.
14
+ *
15
+ * The same walk drops what could EXECUTE on the desk: inline handlers
16
+ * (`on*`), `javascript:` URLs and `srcdoc`. The recorder already leaves
17
+ * scripts out (slimDOM) and the player turns any that remain into
18
+ * <noscript> and disarms `onclick`/`onload`/`onmouse*` — but not the rest,
19
+ * and a replay that draws canvas frames plays in an iframe that allows
20
+ * scripts. A recorded page is whatever the reporter's page held, which is
21
+ * not ours to trust; the desk scrubs again on its side.
14
22
  */
15
23
  import { redactUrl } from "./redact";
16
24
  import type { ReplayEvent } from "../types";
@@ -27,10 +35,28 @@ interface SerializedNode {
27
35
  childNodes?: SerializedNode[];
28
36
  }
29
37
 
30
- function redactAttributes(attributes: Record<string, unknown> | undefined): void {
38
+ const JAVASCRIPT_URL = /^\s*javascript:/i;
39
+
40
+ /**
41
+ * Could this attribute run code on the desk? Handlers, script URLs, and a
42
+ * frame's inline document. In a mutation the answer is "set it to null",
43
+ * which the player applies as a removal; in a snapshot the key goes.
44
+ */
45
+ export function isExecutable(name: string, value: unknown): boolean {
46
+ const key = name.toLowerCase();
47
+ if (key.startsWith("on") || key === "srcdoc") return true;
48
+ return typeof value === "string" && JAVASCRIPT_URL.test(value);
49
+ }
50
+
51
+ function redactAttributes(attributes: Record<string, unknown> | undefined, inMutation = false): void {
31
52
  if (!attributes) return;
32
53
  for (const key of Object.keys(attributes)) {
33
54
  const value = attributes[key];
55
+ if (isExecutable(key, value)) {
56
+ if (inMutation) attributes[key] = null;
57
+ else delete attributes[key];
58
+ continue;
59
+ }
34
60
  if (typeof value !== "string" || !URL_ATTRIBUTES.has(key) || !value.includes("?")) continue;
35
61
  attributes[key] = redactUrl(value);
36
62
  }
@@ -61,7 +87,7 @@ export function redactReplay(events: readonly ReplayEvent[]): ReplayEvent[] {
61
87
  } else if (event.type === INCREMENTAL && data.source === MUTATION) {
62
88
  for (const add of (data.adds as Array<{ node?: SerializedNode }> | undefined) ?? []) walk(add.node);
63
89
  for (const change of (data.attributes as Array<{ attributes?: Record<string, unknown> }> | undefined) ?? []) {
64
- redactAttributes(change.attributes);
90
+ redactAttributes(change.attributes, true);
65
91
  }
66
92
  }
67
93
  }
package/src/portal.ts CHANGED
@@ -25,10 +25,13 @@ const PORTAL_PATH = "/sso";
25
25
  * tested without a browser, and so a host that wants its own link element
26
26
  * rather than our button has something to point it at.
27
27
  */
28
- export function supportPortalUrl(host: string, realmKey: string, token: string): string {
28
+ export function supportPortalUrl(host: string, realmKey: string, token: string, returnTo?: string): string {
29
29
  const url = new URL(PORTAL_PATH, host.endsWith("/") ? host : `${host}/`);
30
30
  url.searchParams.set("realm", realmKey);
31
31
  url.searchParams.set("token", token);
32
+ // Same parameter, same rule, as the OIDC link documented beside this one:
33
+ // a path on the portal, checked there — a host cannot send someone off-site.
34
+ if (returnTo) url.searchParams.set("return", returnTo);
32
35
  return url.toString();
33
36
  }
34
37
 
@@ -51,10 +54,20 @@ export interface OpenPortalOptions {
51
54
  announce?: boolean;
52
55
  /** How long the dialog counts down. Default 3. */
53
56
  seconds?: number;
57
+ /**
58
+ * Where on the portal to land, as a path — `/me/tickets/<id>` behind a
59
+ * notification about that ticket, say. Without it the person arrives at
60
+ * their ticket list, which is right for a button and wrong for a link that
61
+ * named one ticket: they would then have to find it again.
62
+ *
63
+ * A hint, not a redirect. The portal accepts only a path on itself, under
64
+ * the reporter's own pages, and falls back to the list for anything else.
65
+ */
66
+ returnTo?: string;
54
67
  }
55
68
 
56
69
  /** Build the destination. Separated so it can run UNDER the countdown. */
57
- async function prepareUrl(): Promise<string> {
70
+ async function prepareUrl(returnTo?: string): Promise<string> {
58
71
  const config = getConfig();
59
72
  if (!config.identity) throw new NoIdentityError();
60
73
 
@@ -63,7 +76,7 @@ async function prepareUrl(): Promise<string> {
63
76
  // login screen and we do not know where it is.
64
77
  if (!token) throw new NoIdentityError();
65
78
 
66
- return supportPortalUrl(config.host, config.realmKey, token);
79
+ return supportPortalUrl(config.host, config.realmKey, token, returnTo);
67
80
  }
68
81
 
69
82
  /** False when the browser refused — a popup blocker, almost always. */
@@ -124,12 +137,12 @@ function navigate(url: string, target: OpenPortalOptions["target"]): boolean {
124
137
  */
125
138
  export async function openSupportPortal(options: OpenPortalOptions = {}): Promise<void> {
126
139
  if (options.announce === false) {
127
- navigate(await prepareUrl(), options.target);
140
+ navigate(await prepareUrl(options.returnTo), options.target);
128
141
  return;
129
142
  }
130
143
  await showHandoff({
131
144
  seconds: options.seconds,
132
- prepare: prepareUrl,
145
+ prepare: () => prepareUrl(options.returnTo),
133
146
  go: (url) => navigate(url, options.target),
134
147
  });
135
148
  }
package/src/ui/strings.ts CHANGED
@@ -38,7 +38,10 @@ export interface Strings {
38
38
  captured: string;
39
39
  reporter: string;
40
40
  page: string;
41
- /** In the captured row: "… · replay 14s". */
41
+ /**
42
+ * In the captured row: "… · บันทึกการใช้งาน 14s". A log of the page and
43
+ * the actions — not "screen recording", which the lead read as a video.
44
+ */
42
45
  replay: string;
43
46
  /** The hand-off dialog, shown before leaving for the support portal. */
44
47
  handoffTitle: string;
@@ -82,7 +85,7 @@ const th: Strings = {
82
85
  captured: "เก็บข้อมูลแล้ว",
83
86
  reporter: "ผู้แจ้ง",
84
87
  page: "หน้า",
85
- replay: "บันทึกหน้าจอ",
88
+ replay: "บันทึกการใช้งาน",
86
89
  handoffTitle: "กำลังพาไปที่ระบบแจ้งปัญหา",
87
90
  handoffBody: "ระบบจะลงชื่อเข้าใช้ให้อัตโนมัติ เพื่อดูเรื่องที่คุณแจ้งไว้",
88
91
  handoffGo: "ไปเลย",
@@ -124,7 +127,7 @@ const en: Strings = {
124
127
  captured: "Captured",
125
128
  reporter: "Reporter",
126
129
  page: "Page",
127
- replay: "replay",
130
+ replay: "activity log",
128
131
  handoffTitle: "Opening the support portal",
129
132
  handoffBody: "You will be signed in automatically to see what you reported",
130
133
  handoffGo: "Go now",