ripplo 0.10.0 → 0.11.0
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 +105 -47
- package/dist/assets/rrweb-replay.js +1 -1
- package/dist/assets/rrweb.js +1 -1
- package/dist/capture-worker.js +20 -14
- package/dist/chunk-3HAQCJRK.js +4 -0
- package/dist/{chunk-5E62BCS7.js → chunk-47LLHHJH.js} +2 -2
- package/dist/chunk-4YAC72LW.js +7 -0
- package/dist/chunk-5HFJIZLI.js +4 -0
- package/dist/chunk-6U2LNGSV.js +51 -0
- package/dist/{chunk-LL4HUOJP.js → chunk-6WFJZ5L6.js} +1 -1
- package/dist/chunk-7JKCHASU.js +4 -0
- package/dist/{chunk-CEVQ5RNC.js → chunk-7RREARGA.js} +2 -2
- package/dist/{chunk-WNAVYV4P.js → chunk-AXROBTLA.js} +1 -1
- package/dist/chunk-BGY5F3IU.js +5 -0
- package/dist/{chunk-IPSXNIXC.js → chunk-C7SV6AR2.js} +4 -4
- package/dist/chunk-CI6273ZU.js +107 -0
- package/dist/chunk-DY7ZW6QZ.js +9 -0
- package/dist/chunk-E6ZBZIIS.js +4 -0
- package/dist/chunk-G6J2WIHJ.js +4 -0
- package/dist/{chunk-4OSYMIH6.js → chunk-GYBY7EOO.js} +1 -1
- package/dist/{chunk-LOEAZGYO.js → chunk-HEOMRXZE.js} +1 -1
- package/dist/chunk-IK3ROREL.js +6 -0
- package/dist/{chunk-7W237JFM.js → chunk-JS3DLVVI.js} +1 -1
- package/dist/{chunk-TPHOSZAK.js → chunk-KH4QH23U.js} +1 -1
- package/dist/{chunk-QAR7FZO3.js → chunk-LEFODI2H.js} +1 -1
- package/dist/{chunk-43C7VPGA.js → chunk-LWMXGWS2.js} +1 -1
- package/dist/chunk-O45YB6YY.js +354 -0
- package/dist/{chunk-YQ2RBEOJ.js → chunk-PXXURBGC.js} +2 -2
- package/dist/{chunk-OAU4HUD2.js → chunk-PYDYI3AA.js} +2 -2
- package/dist/{chunk-R3DZ6JPY.js → chunk-RIASQHPG.js} +1 -1
- package/dist/chunk-S2K5KILQ.js +8 -0
- package/dist/chunk-SXVWB7TZ.js +6 -0
- package/dist/{chunk-5X4M4MTG.js → chunk-UH5CQF5R.js} +3 -3
- package/dist/{chunk-UDPKOYZT.js → chunk-VKAZQPJJ.js} +1 -1
- package/dist/chunk-WAGXAEB4.js +13 -0
- package/dist/chunk-WBKSJU63.js +83 -0
- package/dist/{chunk-AGK6XOX2.js → chunk-XAMVRZJH.js} +2 -2
- package/dist/chunk-ZHDR7LXB.js +56 -0
- package/dist/{cli-error-AHNJULLG.js → cli-error-6PUIWNIT.js} +1 -1
- package/dist/{compile-write-OLQOR3OK.js → compile-write-KUUFWSI4.js} +1 -1
- package/dist/daemon-2ZTZXQW6.js +4 -0
- package/dist/daemon-GP3EIISA.js +152 -0
- package/dist/{daemon-lock-OAARBZ4O.js → daemon-lock-RPKO5SNE.js} +1 -1
- package/dist/dsl-loader-WPAKMON7.js +4 -0
- package/dist/dsl-typecheck-worker.js +6 -0
- package/dist/{exit-plan-gate-CJ3IXWTN.js → exit-plan-gate-44YWEKYS.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +207 -260
- package/dist/{plan-reminder-EPCNBFY3.js → plan-reminder-PP5DQAQZ.js} +1 -1
- package/dist/post-edit-R7KN424T.js +4 -0
- package/dist/post-edit-analyze-UURDL3AH.js +4 -0
- package/dist/post-edit-flag-stubs-I7AUGN4D.js +4 -0
- package/dist/pre-bash-run-gate-MIEM2DBB.js +4 -0
- package/dist/pre-edit-C4MGURNO.js +4 -0
- package/dist/pre-edit-ripplo-skill-gate-A6ETC3QN.js +4 -0
- package/dist/pre-edit-scope-gate-M5IQSVGF.js +4 -0
- package/dist/{pre-edit-watch-gate-BUFWLXR3.js → pre-edit-watch-gate-ORQP7MSW.js} +1 -1
- package/dist/prompt-submit-6KNOFK4W.js +4 -0
- package/dist/scope-reminder-A6GVTTVE.js +4 -0
- package/dist/session-preamble-IZQPIWST.js +4 -0
- package/dist/status-PG4EBZRM.js +4 -0
- package/dist/{stop-enforce-4XV6LK7Z.js → stop-enforce-CO5GYI3G.js} +9 -9
- package/dist/tasks-reminder-TDWPD3KV.js +4 -0
- package/dist/{track-skill-load-CJ74GD3Q.js → track-skill-load-SXSDMHFO.js} +1 -1
- package/dist/{track-skill-prompt-YSB6OOQN.js → track-skill-prompt-7N4TQAD2.js} +1 -1
- package/package.json +2 -4
- package/dist/chunk-26A42N75.js +0 -55
- package/dist/chunk-44GHUVW6.js +0 -8
- package/dist/chunk-67YR3QHA.js +0 -6
- package/dist/chunk-6NKSEWP6.js +0 -224
- package/dist/chunk-6TCK75ER.js +0 -83
- package/dist/chunk-73TKORK6.js +0 -8
- package/dist/chunk-CB74TAUC.js +0 -5
- package/dist/chunk-FXCBWBN5.js +0 -4
- package/dist/chunk-GOZWOCTE.js +0 -7
- package/dist/chunk-IONMYZ3K.js +0 -4
- package/dist/chunk-LB65USNP.js +0 -73
- package/dist/chunk-M3CXHDFV.js +0 -9
- package/dist/chunk-MOI4L3EX.js +0 -4
- package/dist/chunk-N2OBRCPQ.js +0 -6
- package/dist/chunk-OWN4P2K7.js +0 -4
- package/dist/chunk-SNU66GSR.js +0 -4
- package/dist/chunk-VDAFHS7J.js +0 -7
- package/dist/chunk-VOZOP7MQ.js +0 -55
- package/dist/daemon-BJAGK2Q3.js +0 -152
- package/dist/daemon-H4P5PCVH.js +0 -4
- package/dist/dsl-loader-LXH6PUY5.js +0 -4
- package/dist/post-edit-ZVCYZ62V.js +0 -4
- package/dist/post-edit-analyze-J2H3I3IO.js +0 -4
- package/dist/post-edit-flag-stubs-E22KT2LD.js +0 -4
- package/dist/pre-bash-run-gate-B42YNDQF.js +0 -4
- package/dist/pre-edit-TEN3AFRK.js +0 -4
- package/dist/pre-edit-ripplo-skill-gate-QHUD7QGU.js +0 -4
- package/dist/pre-edit-scope-gate-2YIFSEDY.js +0 -4
- package/dist/prompt-submit-DJFWNGYC.js +0 -4
- package/dist/scope-reminder-DIDCHDAA.js +0 -4
- package/dist/session-preamble-ZYVRDSGA.js +0 -4
- package/dist/status-FDM2RK37.js +0 -4
- package/dist/tasks-reminder-SDS6RNLP.js +0 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{$ as Wu,A as Pu,B as Ou,C as Lo,D as No,Da as Gu,E as Mu,F as Tu,G as vs,Ga as Et,H as Iu,I as Lu,J as Oe,Ja as gn,K as Nu,L as Fo,M as Fu,N as Du,O as Bu,P as $u,Q as ju,R as Vu,W as _u,_ as Uu,a as Le,aa as qu,b as x,ba as zu,c as hu,ca as Jt,d as gr,da as Ku,e as gu,ea as Gt,f as Su,fa as yn,g,ga as Ge,h as bu,i as Ru,ia as Do,j as vu,ja as Rt,k as Mo,ka as Ne,l as ot,la as hn,m as Sr,n as fe,o as To,p as wu,q as Io,qa as vt,r as Eu,ra as Bo,s as br,sa as $o,t as Rr,ta as ws,u as at,ua as Hu,v as xu,va as jo,w as ku,wa as wr,x as Cu,xa as wt,y as Au,ya as Ju,z as vr}from"./chunk-ZHDR7LXB.js";import{a as yu}from"./chunk-NNH3YVVO.js";import{a as $R,b as Rs}from"./chunk-KMZ3L5YA.js";var _f=$R((H$,tl)=>{"use strict";var la=process||{},jf=la.argv||[],sa=la.env||{},LE=!(sa.NO_COLOR||jf.includes("--no-color"))&&(!!sa.FORCE_COLOR||jf.includes("--color")||la.platform==="win32"||(la.stdout||{}).isTTY&&sa.TERM!=="dumb"||!!sa.CI),NE=(e,t,r=e)=>n=>{let o=""+n,a=o.indexOf(t,e.length);return~a?e+FE(o,t,r,a)+t:e+o+t},FE=(e,t,r,n)=>{let o="",a=0;do o+=e.substring(a,n)+r,a=n+t.length,n=e.indexOf(t,a);while(~n);return o+e.substring(a)},Vf=(e=LE)=>{let t=e?NE:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};tl.exports=Vf();tl.exports.createColors=Vf});function Es({onlyFirst:e=!1}={}){let o="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(o,e?void 0:"g")}var jR=Es();function xs(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(jR,"")}import{z as F}from"zod";function Cs(e,t,r){return{detail:r,kind:"engine-http",path:e,status:t}}function bn(e,t){return{code:rp(t)??null,kind:"engine-network",message:kr(t),path:e}}function As(e,t){return{kind:"app-not-ready",readyKey:e,timeoutMs:t}}function A(e,t){return{kind:"engine-decode",message:kr(t),path:e}}function me(e){return{kind:"driver-launch",message:kr(e)}}function Ps({observedMatches:e,source:t,workflowMatches:r}){return{kind:"actor-resolution",observedMatches:e,source:t,workflowMatches:r}}function Rn(e){return{kind:"run-failed",message:kr(e)}}function Er({path:e,record:t}){return{kind:"state-effect-reference",path:[...e],record:t}}var ks=class extends Error{kind;reason;stepIndex;test;constructor({reason:t,stepIndex:r,test:n}){super("workflow planning failed"),this.kind="workflow-plan",this.reason=t,this.stepIndex=r,this.test=n}};function Os(e){return new ks(e)}function xr(e){return{kind:"page-read",message:kr(e)}}function vn(e){return{kind:"state-mismatch",mismatches:[...e]}}function Ms(e,t){return{action:e,failure:t,kind:"action-failed"}}function Ts(e){return{kind:"unclassified",message:kr(e)}}function Is(){return{kind:"aborted"}}var VR=["aborted","action-failed","actor-resolution","page-read","app-not-ready","check-failed","driver-launch","state-effect-reference","run-failed","workflow-plan","engine-decode","engine-http","engine-network","engine-unreachable","state-mismatch"],_R=new Set(VR);function Vo(e){if(typeof e!="object"||e==null||!("kind"in e))return!1;let{kind:t}=e;return typeof t=="string"&&_R.has(t)}var UR=["actor-resolution","app-not-ready","driver-launch","engine-decode","engine-http","engine-network","engine-unreachable","state-effect-reference"],ep=new Set(UR);function _o(e){return ep.has(e.kind)}function tp(e){return ep.has(e)}var Yu=300,WR={"no-effect":"the declared state change is not provably different from the current state","required-state-unsatisfied":"the state declared by earlier steps does not satisfy this step's requirements",unresolvable:"the step references a value that has not been created or bound yet"};function Yt(e){switch(e.kind){case"actor-resolution":{let t=Xu({count:e.observedMatches,noun:"state row"}),r=Xu({count:e.workflowMatches,noun:"workflow record"});return`the signed-in actor from ${e.source} could not be matched to one current workflow record. Ripplo found ${t} and ${r}`}case"engine-http":return`engine ${e.path} returned ${String(e.status)}: ${e.detail.trim()}${QR(e.status)}`;case"engine-network":return`engine ${e.path} request failed: ${xt(e.message)}${YR(e.code)}${XR(e.code,e.message)}`;case"app-not-ready":return`the app never called ready() within ${String(e.timeoutMs)}ms of loading the page. Call ready() from @ripplo/testing once your app is interactive \u2014 see setup.`;case"engine-decode":return`engine ${e.path} response could not be used: ${av(e.message)}`;case"engine-unreachable":return`the engine at ${e.url} did not respond in time \u2014 the dev server may still be recompiling. Re-run once it settles.`;case"driver-launch":return`browser driver failed to launch: ${xt(e.message)} \u2014 check that the Playwright browser is installed and the browser launch configuration is valid`;case"state-effect-reference":return`the declared state change needs ${qR({path:e.path,record:e.record})}, but that value was not available when the action ran`;case"run-failed":return`workflow execution failed unexpectedly: ${xt(e.message)}`;case"workflow-plan":return`workflow planning stopped before step ${String(e.stepIndex+1)} of ${e.test}: ${WR[e.reason]}`;case"page-read":return`reading the page failed: ${xt(e.message)} \u2014 check the page and browser logs around this step`;case"state-mismatch":return zR(e.mismatches);case"action-failed":return`action "${e.action}" failed: ${Zu(e.failure)}`;case"check-failed":return`check failed: ${Zu(e.failure)}`;case"aborted":return"run aborted"}}function Zu(e){switch(e.kind){case"notFound":return"the element was not found";case"multipleMatches":return`the locator matched ${String(e.count)} elements`;case"covered":return`the element is covered by ${e.by}`;case"notPossible":return"the action is not possible on this element";case"wrongState":return`the element is ${e.observed.value?"":"not "}${e.observed.checkKind}`;case"wrongContent":return`the content was "${e.observed}"`;case"unclassified":return xt(e.message)}}function ge(){}function Xu({count:e,noun:t}){return`${String(e)} matching ${t}${e===1?"":"s"}`}function qR({path:e,record:t}){let r=e.join(".");return t==="$ripplo.params"?`generated step value "${r}"`:`a value from "${t}.${r}"`}function zR(e){let t=e[0];if(t==null)throw new TypeError("state-mismatch-empty");let r=e.length-1,n=r===0?"":`, plus ${String(r)} more`;return xt(`${KR(t)}${n}`)}function KR(e){let t=[e.selector.source,...e.selector.path].join(".");return e.kind==="constraint"?HR({location:t,mismatch:e}):e.kind==="effect"?`state at ${t} did not match the declared change \u2014 expected ${kt(e.effect)}, observed ${Sn(e.actual)}`:`state at ${t} changed unexpectedly \u2014 before ${Sn(e.before)}, after ${Sn(e.actual)}`}function HR({location:e,mismatch:t}){let{constraint:r}=t;return r.kind==="equals"?`starting state at ${e} was ${Sn(t.actual)}, expected ${kt(r.value)}`:r.kind==="absent-path"?`starting state at ${e} was present but should have been absent`:r.kind==="required-record"?`starting state at ${e} did not contain a record matching ${kt(r.fields)}`:r.kind==="absent-record"?`starting state at ${e} contained a record matching ${kt(r.fields)}, but it should have been absent`:JR({actual:t.actual,expected:r.rows,location:e})}function JR({actual:e,expected:t,location:r}){let n=GR(e);return n!=null&&n!==t.length?`starting state at ${r} had ${String(n)} ${Qu(n)}, expected exactly ${String(t.length)} ${Qu(t.length)}`:`starting state at ${r} had different records than expected \u2014 expected ${kt(t)}, observed ${Sn(e)}`}function GR(e){if(!(!e.present||typeof e.value!="object"||e.value==null))return Array.isArray(e.value)?void 0:Object.keys(e.value).length}function Qu(e){return e===1?"record":"records"}function Sn(e){return e.present?kt(e.value):"nothing"}function xt(e){let t=e.replaceAll(/\s+/gu," ").trim();return t.length<=Yu?t:`${t.slice(0,Yu)}\u2026 [truncated]`}function YR(e){return e==null?"":` (${e})`}var ZR=new Set(["EAI_AGAIN","ECONNREFUSED","ENOTFOUND"]);function XR(e,t){return e!=null&&ZR.has(e)?" \u2014 nothing accepted the connection at the engine URL. Check that the app's dev server is running and RIPPLO_ENGINE_URL points at it.":t.toLowerCase().includes("timeout")?" \u2014 the app took too long to respond. On a dev server the first hit to a route compiles it on demand and can blow the timeout \u2014 warm the route or raise the setup budget. A hung seed/read impl does the same, so check the app logs if it persists.":" \u2014 the app dropped the connection mid-request. A thrown error in the engine route or a seed/read impl can cause this \u2014 check the app logs."}function QR(e){return e===404?" \u2014 the engine adapter is not mounted at RIPPLO_ENGINE_URL or the mount path differs. Verify the adapter is wired into the app server and ENABLE_RIPPLO_TESTING=true. `npx ripplo doctor` checks the endpoint.":e===403||e===401?" \u2014 the adapter rejected the request: ENABLE_RIPPLO_TESTING is not true in the app's env, or RIPPLO_WEBHOOK_SECRET differs between the app and .ripplo env.":""}function rp(e){if(!(typeof e!="object"||e==null))return"code"in e&&typeof e.code=="string"?e.code:"cause"in e?rp(e.cause):void 0}function kr(e){let t=e instanceof Error?e.message:kt(e);return xs(t)}function kt(e){if(typeof e=="string"||e===void 0||typeof e=="function"||typeof e=="symbol")return String(e);if(typeof e=="bigint")return e.toString();try{return JSON.stringify(e)}catch{return"unserializable diagnostic value"}}var ev=F.discriminatedUnion("issue",[F.object({issue:F.literal("unresolved-optional")}).strict(),F.object({issue:F.literal("duplicate-operation")}).strict(),F.object({dependency:F.string(),issue:F.literal("browser-http-dependency"),operation:F.string()}).strict(),F.object({issue:F.literal("cyclic-operations"),operations:F.array(F.string())}).strict(),F.object({issue:F.literal("materialized-input-mismatch"),operation:F.string()}).strict(),F.object({issue:F.literal("browser-record-setup-not-supported"),source:F.string()}).strict(),F.object({issue:F.literal("state-budget"),stateBudget:F.unknown()}).strict()]),tv=F.object({operation:F.string(),path:F.array(F.string())}).strict(),rv=F.object({operation:F.string()}).strict(),nv=F.object({source:F.string()}).strict(),ov=F.object({slot:F.string()}).strict();function av(e){let t=sv(e),r=ev.safeParse(t);if(r.success)return xt(iv(r.data));let n=tv.safeParse(t);if(n.success){let s=n.data.path.join(".");return`setup operation "${n.data.operation}" did not return referenced path "${s}"`}let o=rv.safeParse(t);if(o.success)return`setup operation "${o.data.operation}" could not be resolved or verified`;let a=nv.safeParse(t);if(a.success)return`state source "${a.data.source}" was missing or returned a mismatched contract`;let i=ov.safeParse(t);return i.success?`generated setup value "${i.data.slot}" was not resolved`:xt(e)}function iv(e){switch(e.issue){case"unresolved-optional":return"the starting state plan contains an unresolved optional value";case"duplicate-operation":return"the starting state plan contains duplicate setup operation IDs";case"browser-http-dependency":return`HTTP setup operation "${e.operation}" depends on browser setup operation "${e.dependency}". HTTP state must be set up before Ripplo signs in and sets up browser state`;case"cyclic-operations":return`setup operations depend on each other: ${e.operations.join(", ")}`;case"materialized-input-mismatch":return`setup operation "${e.operation}" returned state that did not include its requested input`;case"browser-record-setup-not-supported":return`browser state source "${e.source}" can only set up its full state, but the plan requested one record`;case"state-budget":return`state exceeded its size or depth limit: ${kt(e.stateBudget)}`}}function sv(e){try{return JSON.parse(e)}catch{return}}function oe(e){return`${e.workflow}/${e.slug}`}var np=new WeakMap;function J(e){let t=np.get(e);if(t!=null)return t;let r=e.workflows.flatMap(n=>n.tests.map(o=>({ref:oe(o),test:o,workflow:n})));return np.set(e,r),r}import{createHash as eE}from"crypto";import{z as lv}from"zod";import{stringify as PB}from"safe-stable-stringify";var cv=lv.string().brand();function U(e){return typeof e=="object"&&e!==null&&"deferred"in e}var Ye=new Set;function z(e){return cv.parse(e)}function st(e){return typeof e=="object"&&e!==null&&"ref"in e&&typeof e.ref=="string"}function Ct(e){let t=e.lastIndexOf(".");return t===-1?void 0:{alias:e.slice(0,t),field:e.slice(t+1)}}function op(e){return typeof e=="object"&&e!==null&&"template"in e}var G=class extends Error{subject;constructor(t){super(t),this.subject=t}};function Fe(e){return{deferred:Ye,env:e,stateExpression:void 0}}function ap(e,t){return lp(e).every(r=>t.has(z(r)))}function ip(e,t){return lp(e).every(r=>t.env.has(z(r))||sp({ref:r},t))}function sp(e,t){let r=Ct(e.ref);return r!=null&&t.deferred.has(r.alias)}function De(e,t){return typeof e=="string"?e:st(e)?cp(e,t):pv(e,t)}function At(e,t){return e===null||typeof e=="number"||typeof e=="boolean"?e:st(e)?dp(e,t):De(e,t)}function lp(e){return e==null||typeof e!="object"?[]:op(e)?e.template.flatMap(t=>typeof t=="string"?[]:"ref"in t?[t.ref]:it(t)):[e.ref]}function it(e){switch(e.kind){case"reference":return dv(e);case"count":return uv(e.selection);case"add":return[...it(e.left),...it(e.right)];case"divide":return[...it(e.dividend),...it(e.divisor)];case"concat":return e.values.flatMap(t=>it(t));case"invert":return it(e.value);case"after":case"before":case"path":case"value":return[]}}function dv(e){let t=e.path[0];return e.record==="$ripplo.params"&&e.path.length===1&&t!=null?[t]:[]}function uv(e){return e.relation==null?[]:Uo(e.relation)}function Uo(e){return e.kind==="not"?Uo(e.relation):e.kind==="and"||e.kind==="or"?e.relations.flatMap(t=>Uo(t)):e.kind==="exists"?e.selection.relation==null?[]:Uo(e.selection.relation):[...it(e.left),...it(e.right)]}function cp(e,t){let r=dp(e,t);return U(r)?r:String(r)}function dp(e,t){if(sp(e,t))return{...e,deferred:!0};let r=z(e.ref);if(t.env.has(r))return t.env.get(r)??null;throw new G(r)}function pv(e,t){let r=e.template.map(o=>fv(o,t)),n=r.flatMap(o=>U(o)?[]:[o]);return n.length===r.length?n.join(""):{deferred:!0,template:r.map(o=>mv(o))}}function fv(e,t){if(typeof e=="string")return e;if("ref"in e)return cp(e,t);let r=t.stateExpression?.(e);if(r===void 0)throw new G("state expression");let n=Le.safeParse(r);if(!n.success)throw new G("scalar state expression");return String(n.data)}function mv(e){if(!U(e)||"ref"in e)return e;throw new G("nested template")}function ue(e,t){return e.by==="role"?{by:"role",name:e.name==null?void 0:De(e.name,t),role:e.role}:e.by==="inside"?{by:"inside",scope:ue(e.scope,t),target:ue(e.target,t)}:e.by==="surface"?{by:"surface",container:ue(e.container,t),overlay:e.overlay}:e.by==="frame"?{by:"frame",element:ue(e.element,t)}:{by:"testId",value:De(e.value,t)}}function wn({actorAlias:e,current:t,deferred:r,env:n}){return{deferred:r,env:n,stateExpression:t==null?void 0:o=>yv({actorAlias:e,current:t,env:n,expression:o})}}function up({actorAlias:e,current:t,env:r,relation:n}){let o=pp({constraints:t.constraints,env:r});return vt(n,{after:void 0,before:void 0,parameters:yp(r),records:hp({actorAlias:e,state:o}),state:o})}function yv({actorAlias:e,current:t,env:r,expression:n}){let o=pp({constraints:t.constraints,env:r}),a=Bo(n,{after:void 0,before:void 0,parameters:yp(r),records:hp({actorAlias:e,state:o}),state:o});return a.known?a.value:void 0}function pp({constraints:e,env:t}){return e.reduce((r,n)=>hv({constraint:n,env:t,state:r}),{})}function hv({constraint:e,env:t,state:r}){return e.kind==="equals"?gv({constraint:e,env:t,state:r}):e.kind==="required-record"?Sv({constraint:e,env:t,state:r}):e.kind==="closed-record"&&e.operations.length===0?Ls({selector:e.selector,state:r,value:{}}):r}function gv({constraint:e,env:t,state:r}){let n=Wo({env:t,expression:e.value,fallbackPath:void 0});return n===void 0?r:Ls({selector:e.selector,state:r,value:n})}function Sv({constraint:e,env:t,state:r}){let n=bv({alias:e.alias,env:t,fields:e.fields});return n==null?r:vv({alias:e.alias,row:n,selector:e.selector,state:r})}function bv({alias:e,env:t,fields:r}){let n=Object.entries(r).map(([o,a])=>[o,Wo({env:t,expression:a,fallbackPath:`${e}.${o}`})]);return{...Rv({alias:e,env:t}),...Object.fromEntries(n.flatMap(([o,a])=>a===void 0?[]:[[o,a]]))}}function Rv({alias:e,env:t}){let r=`${e}.`;return Object.fromEntries([...t].flatMap(([n,o])=>{let a=String(n);if(!a.startsWith(r))return[];let i=a.slice(r.length);return i.length===0||i.includes(".")?[]:[[i,o]]}))}function Wo({env:e,expression:t,fallbackPath:r}){switch(t.kind){case"value":return t.value;case"generate":return r==null?void 0:e.get(z(r));case"reference":{let n=t.operation===at?t.path.join("."):[t.operation,...t.path].join(".");return e.get(Ev(n))}case"array":{let n=t.items.map((o,a)=>Wo({env:e,expression:o,fallbackPath:r==null?void 0:`${r}.${String(a)}`}));return xv(n)}case"object":{let n=Object.entries(t.fields).map(([o,a])=>[o,Wo({env:e,expression:a,fallbackPath:r==null?void 0:`${r}.${o}`})]);return kv(n)}}}function Ls({selector:e,state:t,value:r}){let o=t[e.source]??{};return{...t,[e.source]:fp({current:o,path:e.path,value:r})}}function vv({alias:e,row:t,selector:r,state:n}){let o=wv(n,r),a=x(o)?o:{};return Ls({selector:r,state:n,value:{...a,[e]:t}})}function fp(e){let{current:t,path:r,value:n}=e,[o,...a]=r;if(o==null)return n;let i=x(t)?t:{},s=i[o]??{};return{...i,[o]:fp({current:s,path:a,value:n})}}function wv(e,t){let r=e[t.source];return r==null?void 0:mp(r,t.path)}function mp(e,t){let[r,...n]=t;if(r==null)return e;if(!x(e))return;let o=e[r];return o==null?void 0:mp(o,n)}function yp(e){return Object.fromEntries([...e].filter(([t])=>!t.includes(".")))}function hp({actorAlias:e,state:t}){let r=Object.values(t).reduce((o,a)=>({...o,...gp(a)}),{});if(typeof e!="string")return r;let n=r[e];return n===void 0?r:{...r,[gr]:n}}function gp(e){return x(e)?{...Object.values(e).reduce((r,n)=>({...r,...gp(n)}),{}),...e}:{}}function Ev(e){return z(e)}function xv(e){if(!e.includes(void 0))return e.flatMap(t=>t===void 0?[]:[t])}function kv(e){if(!e.some(([,t])=>t===void 0))return Object.fromEntries(e.flatMap(([t,r])=>r===void 0?[]:[[t,r]]))}var Cv="https://ripplo.invalid";var Sp={hash:void 0,path:void 0,query:{},title:void 0,viewport:void 0};function Rp(e){return e.kind!=="title"&&e.kind!=="viewport"}function Zt(e){return e.kind==="query"?`url query "${e.key}"`:e.kind==="title"||e.kind==="viewport"?e.kind:`url ${e.kind}`}function qo(e,t){return e==="title"?{kind:"title"}:e==="viewport"?{kind:"viewport"}:t===void 0||t.kind==="path"?{kind:"path"}:t.kind==="hash"?{kind:"hash"}:{key:t.key,kind:"query"}}function En(e){let t=new URL(e,Cv),r=Object.fromEntries(t.searchParams.entries());return{hash:t.hash.length>0?t.hash.slice(1):void 0,path:t.pathname,query:r,title:void 0,viewport:void 0}}function vp(e){if(typeof e=="string")return bp(En(e));let t=st(e)?[e]:e.template,r=t.findIndex(c=>typeof c=="string"&&/[?#]/.test(c)),n=t[r];if(r===-1||typeof n!="string")return{...Sp,path:e};let o=[...t.slice(0,r),n.slice(0,n.search(/[?#]/))].filter(c=>typeof c!="string"||c.length>0),a=t.slice(r),i={template:o};if(a.some(c=>typeof c!="string"))return{...Sp,path:i};let s=a.filter(c=>typeof c=="string").join(""),l=En(`/p${s.slice(s.search(/[?#]/))}`);return{...bp(l),path:i}}function wp(e){let r=[[{kind:"path"},e.path],[{kind:"hash"},e.hash],[{kind:"title"},e.title],[{kind:"viewport"},e.viewport]].flatMap(([o,a])=>a===void 0?[]:[{clause:a,key:o}]),n=Object.entries(e.query).map(([o,a])=>({clause:a,key:{key:o,kind:"query"}}));return[...r,...n]}function bp(e){return{hash:e.hash,path:e.path,query:e.query,title:e.title,viewport:e.viewport}}function Ep(e){return e.expect==="absent"?e:U(e.value)?void 0:{expect:e.expect,value:e.value}}var lt=new Map;function v(e){return e.kind!=="element"?g(e):Sr(e.locator,e.state)}function ct(e,t){return new Map([...xp(e,t),[v(t.subject),t]])}function Ns(e,t){return new Map([...xp(e,t),[v(t.subject),t]])}function Be(e,t){return new Map([...e,...t])}function Fs(e){return e.kind==="element"}function Pt(e){return e.kind==="path"||e.kind==="query"||e.kind==="hash"}function Y(e,t){let r=e.get(v(t));if(!(r==null||r.expect.expect!=="is"))return U(r.expect.value)?void 0:r.expect.value}function Ar(e){let t=En(e),r=[[{kind:"path"},t.path],[{kind:"hash"},t.hash],...Object.entries(t.query).map(n=>[{key:n[0],kind:"query"},n[1]])];return new Map(r.flatMap(([n,o])=>o===void 0?[]:[[v(n),{declared:!0,expect:{expect:"is",value:o},subject:n}]]))}function Ds(e){return[...e].toSorted(([t],[r])=>t.localeCompare(r))}function xp(e,t){return Av(t)?Pv(e,t.subject):Mv(t)?Tv(e,t.subject):e}function Av(e){return e.subject.kind==="element"&&e.subject.state==="visible"&&e.expect.expect==="is"&&e.expect.value===!1}function Pv(e,t){if(t.kind!=="element")return e;let r=g(fe(t.locator)),n=[...e].filter(([,o])=>Ov(o,r));return n.length===e.size?e:new Map(n)}function Ov(e,t){if(e.subject.kind!=="element")return!0;let r=fe(e.subject.locator);return xn(r,t)?!1:g(r)!==t?!0:e.subject.state!=="text"&&e.subject.state!=="value"}function xn(e,t){return e.by==="frame"?g(e.element)===t||xn(e.element,t):e.by!=="inside"?!1:g(e.scope)===t||g(e.target)===t||xn(e.scope,t)||xn(e.target,t)}function Mv(e){return e.subject.kind==="element"&&e.subject.state==="visible"&&e.expect.expect==="is"&&e.expect.value===!0&&kp(e.subject.locator)}function kp(e){return e.by==="surface"&&e.overlay}function Tv(e,t){if(t.kind!=="element")return e;let r=g(fe(t.locator)),n=[...e].filter(([,o])=>Iv(o,r));return n.length===e.size?e:new Map(n)}function Iv(e,t){if(e.subject.kind!=="element"||kp(e.subject.locator))return!0;let r=fe(e.subject.locator);return g(r)===t||xn(r,t)}function Ot({declared:e,entry:t,scope:r}){let n=t.subject.kind==="element"?{...t.subject,locator:ue(t.subject.locator,r)}:t.subject;if(t.expect.expect==="absent")return{declared:e,expect:{expect:"absent"},subject:n};let o=At(t.expect.value,r);return{declared:e,expect:{expect:t.expect.expect,value:Cp(o,n)},subject:n}}function Cp(e,t){return U(e)||!Dv(t)||typeof e!="number"?e:String(e)}function Ap({expect:e,scope:t,subject:r}){return e.expect==="absent"?{expect:"absent"}:{expect:e.expect,value:Cp(At(e.value,t),r)}}function kn({got:e,subject:t,want:r}){if(r.expect==="absent")return e===void 0?"holds":"fails";let n=Lv({got:e,subject:t,want:r.value});if(n==="unknown")return"unknown";let o=r.expect==="is";return n==="equal"===o?"holds":"fails"}function Lv({got:e,subject:t,want:r}){return e!==void 0&&U(e)?U(r)&&g(r)===g(e)?"equal":"unknown":U(r)?"unknown":Pp({got:e,subject:t,want:{expect:"is",value:r}})?"equal":"different"}function Pp({got:e,subject:t,want:r}){if(r.expect==="absent")return e===void 0;if(Nv(t)){let n=Fv(e,r.value);return r.expect==="is"?n:!n}return r.expect==="is"?e===r.value:e!==r.value}function Nv(e){return e.kind==="element"&&e.state==="text"}function Cr(e){return e.replaceAll(/\s+/gu," ").trim()}function Fv(e,t){return typeof e=="string"&&typeof t=="string"&&Cr(e)===Cr(t)}function Dv(e){return e.kind==="element"&&(e.state==="value"||e.state==="text")}function Bs({pattern:e,snapshot:t}){let r=Ko(t);return e.actor.kind==="any"?!0:e.actor.kind==="anonymous"?r==null:r===e.actor.alias}function zo(e,t){return $s({base:new Map,deferred:Ye,logical:void 0,pattern:e,snapshot:t})}function $s({base:e,deferred:t,logical:r,pattern:n,snapshot:o}){return Mp(n,o)?jv({deferred:t,env:e,logical:r,pattern:n.scalars,snapshot:o}):null}function Op({base:e,deferred:t,logical:r,pattern:n,snapshot:o}){return Mp(n,o)?$v({deferred:t,env:e,logical:r,pattern:n.scalars,snapshot:o}).unmet:Bv(n,o)}function Mp(e,t){let r=Ko(t);return e.actor.kind==="user"?r!=null:e.actor.kind==="anonymous"?r==null:!0}function Ko(e){let t=e.scalars.get(v({kind:"actor"})),r=t!=null&&t.expect.expect==="is"?t.expect.value:null;return typeof r=="string"?r:null}function Bv(e,t){return{got:Ko(t)??void 0,kind:"scalar",subject:{kind:"actor"},want:e.actor.kind==="anonymous"?"signed out":"a signed-in user"}}function Tp({deferred:e,entry:t,env:r,logical:n,snapshot:o}){let a=Lp({deferred:e,env:r,logical:n,snapshot:o}),i=Ip(t.subject,a);return i==null?null:Uv({entry:t.expect,got:Np(o,i),scope:a,subject:i})}function $v({deferred:e,env:t,logical:r,pattern:n,snapshot:o}){return[...n.values()].reduce((a,i)=>{if(a.unmet!=null)return a;let s=Tp({deferred:e,entry:i,env:a.env,logical:r,snapshot:o});if(s!=null)return{env:s,unmet:null};let l=Lp({deferred:e,env:a.env,logical:r,snapshot:o}),c=Ip(i.subject,l),d=c==null?void 0:Np(o,c),u=i.expect.expect==="absent"?null:i.expect.value;return{env:a.env,unmet:{got:d,kind:"scalar",subject:i.subject,want:u}}},{env:t,unmet:null})}function jv({deferred:e,env:t,logical:r,pattern:n,snapshot:o}){return[...n.values()].reduce((a,i)=>a==null?null:Tp({deferred:e,entry:i,env:a,logical:r,snapshot:o}),t)}function Vv({clause:e,scope:t,subject:r}){return!(r.kind==="element"&&(r.state==="value"||r.state==="text"))||!st(e)||ap(e,t.env)?!1:!_v(e,t)}function _v(e,t){if(!st(e))return!1;let r=Ct(e.ref);return r!=null&&t.deferred.has(r.alias)}function Uv({entry:e,got:t,scope:r,subject:n}){if(e.expect!=="absent"&&Vv({clause:e.value,scope:r,subject:n}))return qv({clause:e.value,got:t,scope:r});let o=Wv({entry:e,scope:r,subject:n});return o==null||kn({got:t,subject:n,want:o})==="fails"?null:r.env}function Wv({entry:e,scope:t,subject:r}){try{return Ap({expect:e,scope:t,subject:r})}catch(n){if(n instanceof G)return null;throw n}}function qv({clause:e,got:t,scope:r}){return t===void 0||U(t)?null:new Map([...r.env,[z(zv(e)),t]])}function zv(e){if(!st(e))throw new Error("expected a ref clause");return e.ref}function Ip(e,t){return e.kind!=="element"?e:Kv(e.locator,t)?{...e,locator:ue(e.locator,t)}:null}function Kv(e,t){return Do(e).every(r=>ip(r,t))}function Lp({deferred:e,env:t,logical:r,snapshot:n}){return wn({actorAlias:Ko(n)??void 0,current:r,deferred:e,env:t})}function Np(e,t){let r=e.scalars.get(v(t));return r==null||r.expect.expect!=="is"?void 0:r.expect.value}function $e(e,t){return[...new Map(e.map(r=>[t(r),r])).values()]}function Ho(e){return[...Hv(e.action),...e.effects.flatMap(t=>Jv(t)),...e.expect.flatMap(t=>dt(t))]}function dt(e){switch(e.kind){case"visible":case"unobstructed":case"disabled":case"enabled":case"focused":case"checked":case"expanded":case"pressed":return Ne(e.locator);case"value":case"text":{let t=ot(e.value)?e.value.value:e.value;return[...Ne(e.locator),...Rt(t)]}case"browser":return Rt(e.value);case"not":return dt(e.predicate);case"when":return e.branches.flatMap(t=>[...t.condition==null?[]:dt(t.condition),...t.consequence.flatMap(r=>dt(r))]);case"and":case"or":return e.predicates.flatMap(t=>dt(t));case"optional-path":case"optional-record":case"state-compare":case"state-equals":return[];case"state-relation":return Xt(e.relation);case"actor":return e.target.kind==="anonymous"?[]:[e.target.ref.ref]}}function Pr(e){return[...e.scalars.values()].flatMap(t=>Vs(t))}function Vs(e){let t=e.subject.kind==="element"?Ne(e.subject.locator):[],r=e.expect.expect==="absent"?[]:Rt(e.expect.value);return[...t,...r]}function Jo(e){return e.flatMap(t=>No(t).flatMap(r=>Ou(r)))}function Hv(e){return e.kind==="goto"?Rt(e.url):e.kind==="actor"?[e.ref.ref]:e.kind==="fill"||e.kind==="select"?[...Ne(e.locator),...Rt(e.value)]:e.kind==="press"?e.locator==null?[]:Ne(e.locator):e.kind==="drag"?[...Ne(e.source),...Ne(e.target)]:Ne(e.locator)}function Jv(e){switch(e.kind){case"create-record":return Object.values(e.fields).flatMap(t=>Fp(t));case"update-selected-records":return[...js(e.selection),...Object.values(e.changes).flatMap(t=>Fp(t))];case"delete-selected-records":return js(e.selection);case"transform":return Xt(e.relation);case"create-path":case"delete-path":case"set":return[]}}function Fp(e){return e.kind==="reference"?Gv(e):e.kind==="transform"?Xt(e.relation):[]}function Gv({path:e,record:t}){let r=e[0];return t===at&&e.length===1&&r!=null?[r]:[]}function Xt(e){return e.kind==="not"?Xt(e.relation):e.kind==="and"||e.kind==="or"?e.relations.flatMap(t=>Xt(t)):e.kind==="exists"?e.selection.relation==null?[]:Xt(e.selection.relation):[...Mt(e.left),...Mt(e.right)]}function Mt(e){switch(e.kind){case"reference":return Yv(e);case"count":return js(e.selection);case"add":return[...Mt(e.left),...Mt(e.right)];case"divide":return[...Mt(e.dividend),...Mt(e.divisor)];case"concat":return e.values.flatMap(t=>Mt(t));case"invert":return Mt(e.value);case"after":case"before":case"path":case"value":return[]}}function Yv(e){let t=e.path[0];return e.record===at&&e.path.length===1&&t!=null?[t]:[]}function js(e){return e.relation==null?[]:Xt(e.relation)}function Or(e){return e.flatMap(t=>t.kind==="and"?Or(t.predicates):[t])}function Mr(e){return Or(e).filter(t=>!Jt(t))}function Go(e){return e.action.kind==="goto"?!0:_s(e.expect).some(t=>t.kind==="browser"&&t.name==="url"&&t.value!==null)}function Qt(e){return e.action.kind==="goto"?!0:_s(e.expect).some(t=>t.kind==="browser"&&t.name==="url"&&t.value!==null&&(t.part===void 0||t.part.kind==="path"))}function _s(e){return e.flatMap(t=>t.kind==="and"?_s(t.predicates):[t])}function Ze(e,t){return t.reduce((r,n)=>{let o=[...nw(n),...Tt(n),...ow(n)],a=Zv(n,r,o)?rw(r):r;return o.reduce((i,s)=>Ns(i,s),a)},e)}function ie(e){return e.kind==="not"?Xv(e.predicate):Qv(e)}function Cn(e){return wp(vp(e)).map(({clause:t,key:r})=>({expect:t===null?{expect:"absent"}:{expect:"is",value:t},subject:r}))}function Zv(e,t,r){if(e.action.kind==="goto")return!0;if(!Qt(e))return!1;let n=t.get(v({kind:"path"})),o=r.find(a=>a.subject.kind==="path");return o==null?!1:n==null||g(n.expect)!==g(o.expect)}function Xv(e){return e.kind==="value"||e.kind==="text"?ot(e.value)?null:{expect:{expect:"not",value:e.value},subject:{kind:"element",locator:e.locator,state:e.kind}}:Dp(e,!0)}function Dp(e,t){if(e.kind==="value"||e.kind==="text")return ot(e.value)?null:{expect:{expect:"is",value:e.value},subject:{kind:"element",locator:e.locator,state:e.kind}};let r=ew(e);return r==null?null:{expect:{expect:"is",value:r.value!==t},subject:{kind:"element",locator:r.locator,state:r.state}}}function Qv(e){return e.kind==="browser"?{expect:e.value===null?{expect:"absent"}:{expect:"is",value:e.value},subject:qo(e.name,e.part)}:e.kind==="actor"?e.target.kind==="anonymous"?{expect:{expect:"absent"},subject:{kind:"actor"}}:{expect:{expect:"is",value:{ref:`${e.target.ref.ref}.id`}},subject:{kind:"actor"}}:Dp(e,!1)}function Tt(e){let t=e.action;return!("locator"in t)||t.locator==null?[]:t.kind==="check"||t.kind==="uncheck"?[{expect:{expect:"is",value:t.kind==="check"},subject:{kind:"element",locator:t.locator,state:"checked"}}]:t.kind==="clear"?[{expect:{expect:"is",value:""},subject:{kind:"element",locator:t.locator,state:"value"}}]:t.kind==="fill"||t.kind==="select"?[{expect:{expect:"is",value:t.value},subject:{kind:"element",locator:t.locator,state:"value"}}]:[]}function ew(e){return tw(e)?e.kind==="disabled"?{locator:e.locator,state:"enabled",value:!1}:{locator:e.locator,state:e.kind,value:!0}:null}function tw(e){return e.kind==="visible"||e.kind==="disabled"||e.kind==="enabled"||e.kind==="focused"||e.kind==="checked"||e.kind==="expanded"||e.kind==="pressed"}function rw(e){return new Map([...e].filter(([,t])=>t.subject.kind==="variable"||t.subject.kind==="viewport"))}function nw(e){return e.action.kind==="goto"?Cn(e.action.url):[]}function ow(e){return Mr(e.expect).flatMap(t=>{let r=ie(t);return r==null?[]:[r]})}function Us(e){return e.includes("async")?"async":e.includes("slow")?"slow":"fast"}var An={async:12e4,fast:5e3,slow:3e4},Ce={async:{backoffMs:[500,1e3,2e3,5e3],timeoutMs:An.async},fast:{backoffMs:[100,250,500,1e3],timeoutMs:An.fast},slow:{backoffMs:[250,500,1e3,2e3],timeoutMs:An.slow}};function Yo(e,t){return e.backoffMs[Math.min(t,e.backoffMs.length-1)]??0}function Bp({constraint:e,effect:t,parameters:r}){if(g(e.selector)!==g(t.selector))return[e];if(e.kind!=="equals"||e.value.kind!=="value")return[];let n=ws({before:e.value.value,context:{parameters:r,records:{},state:{}},relation:t.relation});return n.known?[{...e,value:{kind:"value",value:n.value}}]:[]}function $p({changes:e,fields:t,parameters:r}){let n=Object.fromEntries(Object.entries(e).flatMap(([a,i])=>{let s=aw({before:t[a],expression:i,parameters:r});return s==null?[]:[[a,s]]}));return{...Object.fromEntries(Object.entries(t).filter(([a])=>!(a in e))),...n}}function aw({before:e,expression:t,parameters:r}){if(t.kind==="value")return t;if(t.kind==="reference")return{kind:"reference",operation:t.record,path:t.path};let n={parameters:r,records:{},state:{}},o=e?.kind==="value"?ws({before:e.value,context:n,relation:t.relation}):Hu({context:n,relation:t.relation});return o.known?{kind:"value",value:o.value}:void 0}function jp({constraints:e,effect:t,parameters:r}){let n=_p(e),o=Up({parameters:r,records:n}),a=n.filter(i=>qp(i.constraint.selector,t.selector)).map(i=>({record:i,selected:Wp({context:o,record:i,selection:t.selection})}));return e.flatMap(i=>{if(!uw(t.selector,i.selector))return[i];if(i.kind!=="required-record")return[];let s=a.find(l=>l.record.alias===i.alias);return s==null||!s.selected.known?[]:s.selected.value?t.kind==="delete-selected-records"?[{fields:i.fields,kind:"absent-record",selector:i.selector}]:[{...i,fields:$p({changes:t.changes,fields:i.fields,parameters:r})}]:[i]})}function Vp({constraints:e,effect:t,parameters:r}){let n=_p(e),o=Up({parameters:r,records:n});return n.filter(a=>qp(a.constraint.selector,t.selector)).filter(a=>{let i=Wp({context:o,record:a,selection:t.selection});return i.known&&i.value}).every(a=>iw({context:o,effect:t,record:a}))}function iw({context:e,effect:t,record:r}){let n={...e.records,[t.selection.alias]:r.value};return Object.entries(t.changes).every(([o,a])=>{if(a.kind!=="transform")return!0;let i=r.constraint.fields[o];return i?.kind!=="value"?!0:jo({before:i.value,context:{...e,records:n},relation:a.relation}).kind!=="invalid"})}function _p(e){return e.flatMap(t=>{if(t.kind!=="required-record")return[];let r=sw(t.fields);return[{alias:t.alias,constraint:t,value:r}]})}function sw(e){return Object.fromEntries(Object.entries(e).flatMap(([t,r])=>r.kind==="value"?[[t,r.value]]:[]))}function Up({parameters:e,records:t}){return{after:void 0,before:void 0,parameters:e,records:Object.fromEntries(t.map(r=>[r.alias,r.value])),state:{}}}function Wp({context:e,record:t,selection:r}){if(r.relation==null)return{known:!0,value:!0};let n={...e,records:{...e.records,[r.alias]:t.value}};return Ws({context:n,record:t,relation:r.relation,selectionAlias:r.alias})}function Ws({context:e,record:t,relation:r,selectionAlias:n}){switch(r.kind){case"not":return lw({context:e,record:t,relation:r.relation,selectionAlias:n});case"and":case"or":{let o=r.relations.map(a=>Ws({context:e,record:t,relation:a,selectionAlias:n}));return dw({children:o,kind:r.kind})}case"exists":return{known:!1};case"compare":case"equals":case"text":return cw({context:e,record:t,relation:r,selectionAlias:n})}}function lw(e){let t=Ws(e);return t.known?{known:!0,value:!t.value}:t}function cw({context:e,record:t,relation:r,selectionAlias:n}){let o=Mo({relation:r,map:i=>i.record===n?{...i,record:t.alias}:i});return o.kind==="equals"&&g(o.left)===g(o.right)?{known:!0,value:!0}:Tr({context:e,expression:r.left})&&Tr({context:e,expression:r.right})?{known:!0,value:vt(r,e)}:{known:!1}}function dw({children:e,kind:t}){let r=e.find(n=>n.known&&n.value===(t==="or"));return r??(e.every(n=>n.known)?{known:!0,value:t==="and"}:{known:!1})}function Tr({context:e,expression:t}){return t.kind==="path"||t.kind==="count"?!1:t.kind==="add"?Tr({context:e,expression:t.left})&&Tr({context:e,expression:t.right}):t.kind==="concat"?t.values.every(r=>Tr({context:e,expression:r})):t.kind==="invert"?Tr({context:e,expression:t.value}):Bo(t,e).known}function qp(e,t){return g(e)===g(t)}function uw(e,t){if(e.source!==t.source)return!1;let r=Math.min(e.path.length,t.path.length);return e.path.slice(0,r).every((n,o)=>t.path[o]===n)}var Zo={constraints:[]},zp=new WeakMap,qs=new WeakMap;function Se({current:e,required:t}){let r=qs.get(e)?.get(t.constraints);if(r!=null)return r;let n=pw({current:e,required:t}),o=qs.get(e)??new WeakMap;return o.set(t.constraints,n),qs.set(e,o),n}function Zp({left:e,right:t}){return e.constraints.every(r=>t.constraints.every(n=>!xw(r,n)))}function Ks({alias:e,candidates:t,current:r}){let n=t.find(o=>zs(o)&&o.alias===e);return n==null?!1:r.constraints.some(o=>vw({candidate:n,known:o}))}function pw({current:e,required:t}){let r=Kp(t),n=Kp(e);return r.other.every(o=>e.constraints.some(a=>rf({known:a,required:o})))&&hw({known:n.records,required:r.records})}function Kp(e){let t=zp.get(e.constraints);if(t!=null)return t;let r={other:e.constraints.filter(n=>!Jp(n)),records:e.constraints.filter(n=>Jp(n))};return zp.set(e.constraints,r),r}function Xp({current:e,selector:t,value:r}){return e.constraints.some(n=>n.kind==="equals"&&Pn(n.selector,t)&&n.value.kind==="value"&&g(n.value.value)===g(r))}function Hs({current:e,op:t,selector:r,value:n}){return e.constraints.some(o=>{if(o.kind!=="equals"||!Pn(o.selector,r)||o.value.kind!=="value")return!1;let a=Le.safeParse(o.value.value);return a.success&&hu({left:a.data,op:t,right:n})})}function ut({effects:e,parameters:t,pattern:r}){return e.reduce((n,o)=>({constraints:ww({constraints:n.constraints,effect:o,parameters:t})}),r)}function Qp({after:e,before:t,env:r}){let n=Hp(t),o=Hp(e),a=[...r].filter(([i])=>mw({after:o.get(i),before:n.get(i)}));return new Map([...a,...yw(e)])}function ef({after:e,deferred:t,effects:r}){let n=fw(e),o=[...t].filter(a=>n.has(a));return new Set([...o,...Js(r)])}function Js(e){return e.flatMap(t=>t.kind==="create-record"?[t.as]:[])}function fw(e){return new Set(e.constraints.flatMap(t=>t.kind==="required-record"?[t.alias]:[]))}function Hp(e){return new Map(e.constraints.flatMap(t=>t.kind==="required-record"?Object.entries(t.fields).map(([r,n])=>[z(`${t.alias}.${r}`),{expression:n,selector:t.selector}]):[]))}function mw({after:e,before:t}){return t===void 0?!0:e===void 0||e.expression.kind==="value"?!1:g(e)===g(t)}function yw(e){return e.constraints.flatMap(t=>t.kind!=="required-record"?[]:Object.entries(t.fields).flatMap(([r,n])=>{if(n.kind!=="value")return[];let o=Le.safeParse(n.value);return o.success?[[z(`${t.alias}.${r}`),o.data]]:[]}))}function Jp(e){return e.kind==="required-record"}function hw({known:e,required:t}){if(t.length>e.length)return!1;let r=t.map(n=>gw({known:e,required:n})).toSorted((n,o)=>n.length-o.length);return tf({candidates:r,used:new Set})}function gw({known:e,required:t}){return e.flatMap((r,n)=>rf({known:r,required:t})?[n]:[])}function tf({candidates:e,used:t}){let[r,...n]=e;return r==null?!0:r.some(o=>!t.has(o)&&tf({candidates:n,used:new Set([...t,o])}))}function rf({known:e,required:t}){return zs(e)||zs(t)||!Pn(e.selector,t.selector)?!1:t.kind==="required-record"?Sw({known:e,required:t}):t.kind==="absent-record"?bw({known:e,required:t}):Rw({known:e,required:t})}function zs(e){return e.kind==="optional-path"||e.kind==="optional-record"}function Sw({known:e,required:t}){return e.kind==="required-record"&&t.kind==="required-record"&&nf({actual:e.fields,expected:t.fields})}function bw({known:e,required:t}){return e.kind==="absent-record"&&t.kind==="absent-record"&&nf({actual:t.fields,expected:e.fields})}function Rw({known:e,required:t}){return e.kind==="equals"&&t.kind==="equals"?Ir(e.value,t.value):e.kind==="absent-path"&&t.kind==="absent-path"?!0:e.kind==="closed-record"&&t.kind==="closed-record"&&g(e.operations)===g(t.operations)}function vw({candidate:e,known:t}){return Pn(e.selector,t.selector)?e.kind==="optional-path"?t.kind==="equals"&&Ir(e.value,t.value):t.kind==="required-record"&&t.alias===e.alias:!1}function ww({constraints:e,effect:t,parameters:r}){if(t.kind==="transform")return e.flatMap(o=>Bp({constraint:o,effect:t,parameters:r}));if(t.kind==="delete-selected-records"||t.kind==="update-selected-records")return jp({constraints:e,effect:t,parameters:r});let n=e.filter(o=>Ew(t,o));return t.kind==="set"||t.kind==="create-path"?[...n,{kind:"equals",selector:t.selector,value:Ow(t.value)}]:t.kind==="delete-path"?[...n,{kind:"absent-path",selector:t.selector}]:[...n,{alias:Tw(t),fields:Mw(t.fields),kind:"required-record",selector:t.selector}]}function Ew(e,t){return Gs(e.selector,t.selector)?e.kind==="create-record"?t.kind==="required-record":!1:!0}function xw(e,t){return Pn(e.selector,t.selector)?kw(e,t)||Cw(e,t):!1}function kw(e,t){return e.kind==="equals"&&t.kind==="equals"?!Ir(e.value,t.value):e.kind==="absent-path"&&t.kind==="equals"||e.kind==="equals"&&t.kind==="absent-path"}function Cw(e,t){return Gp(e,t)||Gp(t,e)?!0:e.kind==="required-record"?Yp(e,t):t.kind==="required-record"&&Yp(t,e)}function Gp(e,t){return e.kind==="closed-record"&&e.operations.length===0&&t.kind==="required-record"}function Yp(e,t){return t.kind==="required-record"?e.alias===t.alias&&Pw({left:e.fields,right:t.fields}):t.kind==="absent-record"&&Aw({fields:t.fields,record:e})}function Aw({fields:e,record:t}){return Object.entries(e).every(([r,n])=>{if(n.kind==="reference"&&n.operation===t.alias&&n.path.length===1&&n.path[0]===r)return!0;let o=t.fields[r];return o!=null&&Ir(o,n)})}function Gs(e,t){if(e.source!==t.source)return!1;let r=Math.min(e.path.length,t.path.length);return e.path.slice(0,r).every((n,o)=>t.path[o]===n)}function Pw({left:e,right:t}){return Object.entries(e).some(([r,n])=>{let o=t[r];return o!=null&&!Ir(n,o)})}function Ir(e,t){return g(e)===g(t)}function nf({actual:e,expected:t}){return Object.entries(t).every(([r,n])=>{let o=e[r];return o!=null&&Ir(o,n)})}function Ow(e){return{kind:"value",value:e}}function Mw(e){return Object.fromEntries(Object.entries(e).flatMap(([t,r])=>r.kind==="absent"||r.kind==="generated"?[]:[[t,r.kind==="value"?r:{kind:"reference",operation:r.record,path:r.path}]]))}function Pn(e,t){return g(e)===g(t)}function Tw(e){return e.as}function On(e){return{constraints:e.constraints.map(t=>af({constraint:t,fieldsOf:Iw,plan:e}))}}function of(e){return{constraints:e.constraints.map(t=>af({constraint:t,fieldsOf:Lw,plan:e}))}}function af({constraint:e,fieldsOf:t,plan:r}){if(e.kind!=="required-record")return e;let n=r.operations.find(o=>o.id===e.alias);return n?.input.kind!=="object"?e:{...e,fields:{...t(n.input),...e.fields}}}function Iw(e){return e.fields}function Lw(e){return Object.fromEntries(Object.entries(e.fields).filter(([,t])=>Ys(t)))}function Ys(e){switch(e.kind){case"array":return e.items.every(t=>Ys(t));case"object":return Object.values(e.fields).every(t=>Ys(t));case"generate":return!1;case"reference":case"value":return!0}}import{createHash as $w}from"crypto";function cf({prior:e,step:t}){let r=Tt(t);if(r.length===0||Zs(t).length===0)return null;let n=gn({aligned:!0,patterns:[e,lf(r)]}),o=r.some(a=>gn({aligned:!0,patterns:[e,lf([Bw(a)])]}));return n===o?"undecided":n?"same":"different"}function df({effects:e,prior:t}){let r=e.map(n=>Fw({effect:n,prior:t}));return r.length===0||r.includes("undecided")?"undecided":r.every(n=>n==="same")?"same":"different"}function uf(e){return e.every((t,r)=>e.slice(r+1).filter(n=>v(n.subject)===v(t.subject)).every(n=>Dw({left:t,right:n})))}function Zs(e){let t=Tt(e);return Or(e.expect).filter(r=>{let n=ie(r);return n==null||!t.some(o=>Nw({left:o,right:n}))})}function Nw({left:e,right:t}){return v(e.subject)===v(t.subject)&&g(e.expect)===g(t.expect)}function Fw({effect:e,prior:t}){if(e.expect.expect!=="is")return"undecided";let r=t.get(v(e.subject));if(r==null||r.expect.expect==="absent")return"undecided";let n=g(r.expect.value)===g(e.expect.value);return r.expect.expect==="is"?n?"same":"different":n?"different":"undecided"}function Dw({left:e,right:t}){return e.expect.expect==="absent"?t.expect.expect!=="is":t.expect.expect==="absent"?e.expect.expect!=="is":e.expect.expect===t.expect.expect?e.expect.expect==="not"||sf({left:e,right:t}):!sf({left:e,right:t})}function sf({left:e,right:t}){return e.expect.expect==="absent"||t.expect.expect==="absent"?!1:g(e.expect.value)===g(t.expect.value)}function lf(e){return yn({scalars:new Map(e.map(t=>[v(t.subject),t]))})}function Bw(e){return{...e,expect:{expect:e.expect.expect==="is"?"not":"is",value:e.expect.value}}}function er(e){return`${e.test}#${String(e.index)}`}function Xo(e){let t=J(e).flatMap(r=>tr(e,r.test));return $e(t,r=>r.id)}function tr(e,t){let r=yf(t),n=pf(t.actor,t.viewport),o=Xw(t),a=t.steps,i=Ww(e,t),s=Qw(t.steps),l=zw(n,s,r),c=jw(of(t.startingState).constraints,s);return l.reduce((d,{chunk:u,requiredState:f},y)=>({offset:d.offset+u.length,transitions:[...d.transitions,Gw({chunk:u,index:y,intent:t.intent,logicalCandidates:i,logicalRequiredState:Vw(c,y),namespace:r.namespace,paramSpaceOf:o,requiredState:f,testRef:oe(t),whenChunk:a.slice(d.offset,d.offset+u.length)})]}),{offset:0,transitions:[]}).transitions}function jw(e,t){return t.reduce((r,n)=>({current:ut({effects:n.flatMap(o=>o.effects),parameters:{},pattern:{constraints:r.current}}).constraints,required:[...r.required,r.current]}),{current:e,required:[]}).required}function Vw(e,t){let r=e[t];if(r==null)throw new Error("logical required state missing");return r}function _w(e){return[v({kind:"viewport"}),{expect:{expect:"is",value:e},subject:{kind:"viewport"}}]}var Uw=v({kind:"viewport"});function Qo(e){let t=e.scalars.get(Uw);return t==null||t.expect.expect!=="is"||typeof t.expect.value!="string"?null:t.expect.value}function pf(e,t){return{actor:e,scalars:new Map([_w(t)])}}function Ww(e,t){return e.workflows.find(n=>n.name===t.workflow)?.startingState.constraints.filter(n=>n.kind==="optional-path"||n.kind==="optional-record")??[]}function Mn(e,t){return t.reduce((r,n)=>qw(n)??r,e)}function qw(e){if(e.action.kind==="actor")return{alias:e.action.ref.ref,kind:"user"};let t=e.expect.find(r=>r.kind==="actor");return t==null?null:t.target.kind==="anonymous"?Ku:{alias:t.target.ref.ref,kind:"user"}}function zw(e,t,r){return t.reduce((n,o)=>({requiredState:Kw(n.requiredState,o,r),withRequiredState:[...n.withRequiredState,{chunk:o,requiredState:Hw(n.requiredState,o)}]}),{requiredState:e,withRequiredState:[]}).withRequiredState}function Kw(e,t,r){return{...e,actor:Mn(e.actor,t),scalars:Ze(e.scalars,t)}}function Hw(e,t){return t[0]?.action.kind!=="goto"?e:{...e,scalars:new Map([...e.scalars].filter(([,r])=>r.subject.kind==="variable"||r.subject.kind==="viewport"))}}function ff(e,t){return{namespace:yf(t).namespace,requiredState:pf(t.actor,t.viewport)}}function mf(e,t){return[...new Set(e)].flatMap(r=>Jw(r,t))}function yf(e){return{namespace:new Map(e.startingState.operations.map(t=>[t.id,`$state.${t.source}.${t.target.kind==="state"?"state":t.target.path.join(".")}`]))}}function Jw(e,t){let r=Ct(e);if(r==null)return[];let n=t.get(r.alias);return n==null?[]:[{aliasPath:r.alias,field:r.field,recordPath:n,ref:e}]}function Gw(e){let t=e.chunk.findIndex(s=>s.action.kind!=="goto"),r=t===-1?e.chunk:e.chunk.slice(0,t),n=e.chunk.slice(r.length),o=n.at(-1)??e.chunk.at(-1);if(o==null)throw new Error("empty transition chunk");let a=[...new Set([...e.chunk.flatMap(s=>Ho(s)),...Pr(e.requiredState),...Jo(e.logicalRequiredState)])],i={actionRelationship:cf({prior:e.requiredState,step:o}),effectStep:o,intent:e.intent,logicalCandidates:e.logicalCandidates,logicalRequiredState:e.logicalRequiredState,namespace:e.namespace,nav:r,paramSpaces:Object.fromEntries(a.filter(s=>e.paramSpaceOf.has(s)).map(s=>[s,e.paramSpaceOf.get(s)])),requiredState:e.requiredState,steps:n,test:e.testRef,wait:Us(e.chunk.flatMap(s=>Yw(s))),whenSteps:e.whenChunk};return{...i,id:Zw(i),index:e.index}}function Yw(e){return Go(e)?["slow"]:[]}function Zw(e){let t=g({...e,namespace:[...e.namespace].toSorted(([r],[n])=>r.localeCompare(n)),requiredState:Ge(e.requiredState)});return`transition_${$w("sha256").update(t).digest("base64url")}`}function Xw(e){return new Map(Object.entries(e.params).map(([t,r])=>[t,r.space]))}function Qw(e){return e.map(t=>[t])}function hf(e,t){if(e.when.length>0)throw new Error(`fact "${e.name}" uses conditions that cannot be represented`);let r=yn({});return e.expect.map(n=>({consequence:n,localConsequence:!1,logicalWhen:Zo,origin:{kind:"declared",name:e.name},refs:new Set,when:r}))}function Xe(e){return e.surfaces.filter(t=>t.by==="surface"&&t.overlay)}function ea(e,t){return{...e,scalars:ta(e.scalars,t)}}function ta(e,t){return bf(e,t,r=>({expect:{expect:"is",value:!1},subject:{kind:"element",locator:r,state:"visible"}}))}function Sf(e,t){let r=bf(e.scalars,t,n=>({declared:!1,expect:{expect:"is",value:!1},subject:{kind:"element",locator:ue(n,Fe(new Map)),state:"visible"}}));return{...e,scalars:r}}function bf(e,t,r){let n=t.filter(o=>!e.has(gf(o))).map(o=>[gf(o),r(o)]);return n.length===0?e:new Map([...e,...n])}function gf(e){return v({kind:"element",locator:e,state:"visible"})}var Rf=new WeakMap;function pt(e){let t=Rf.get(e);if(t!=null)return t;let r=eE("sha256").update(g({consequence:e.consequence,logicalWhen:e.logicalWhen,when:Ge(e.when)})).digest("base64");return Rf.set(e,r),r}function na(e){let t=e.facts.flatMap(a=>hf(a,e)),r=new Set(Xe(e).map(a=>g(fe(a)))),n=J(e).map(a=>Qs(e,a)),o=$e(n.flatMap(a=>a.steps.flatMap(i=>i.facts)),pt).filter(a=>!tE(a.consequence,r));return[...t,...o]}function Xs(e,t){return e.filter(r=>!aE(r)||iE(r)===t)}function oa(e){return e.kind==="not"?oa(e.predicate):e.kind==="visible"||e.kind==="disabled"||e.kind==="enabled"||e.kind==="focused"||e.kind==="checked"||e.kind==="expanded"||e.kind==="pressed"||e.kind==="value"||e.kind==="text"}function tE(e,t){if(e.kind!=="visible")return!1;let r=fe(e.locator);return t.has(g(r))?!0:r.by==="inside"&&t.has(g(fe(r.scope)))}function Lr(e){let{model:t,snapshot:r}=e;if(t.facts.length===0)return r;let n=Tn(e);return n.size===0?r:{...r,scalars:Be(n,r.scalars)}}function Tn({logical:e,model:t,snapshot:r}){let n=Sf(r,t.overlays),o=t.facts.flatMap(s=>{if(!Se({current:e,required:s.logicalWhen}))return[];let l=zo(s.when,n);if(l==null)return[];let c=rE(s.consequence,l);return c==null?[]:[{entry:c,factKey:pt(s),key:v(c.subject)}]}),a=o.filter(s=>!oE({m:s,matched:o,overrides:t.overrides})),i=nE(a);return a.reduce((s,l)=>i.has(l.key)?s:ct(s,l.entry),lt)}function rE(e,t){let r=ie(e);if(r==null)return null;try{return Ot({declared:!0,entry:r,scope:Fe(t)})}catch{return null}}function nE(e){let t=e.reduce((r,n)=>new Map([...r,[n.key,[...r.get(n.key)??[],g(n.entry.expect)]]]),new Map);return new Set([...t].flatMap(([r,n])=>new Set(n).size>1?[r]:[]))}function oE({m:e,matched:t,overrides:r}){let n=r.get(e.factKey);return n==null?!1:t.some(o=>o.key===e.key&&n.has(o.factKey))}function aE(e){return e.origin?.kind==="test"&&e.localConsequence}function iE(e){let{origin:t}=e;if(!(t==null||t.kind!=="test"))return t.test}var vf=new WeakMap;function Qs(e,t){let r=vf.get(t);if(r!=null)return r;let n=sE(e,t);return vf.set(t,n),n}function sE(e,{test:t,workflow:r}){let n=ff(e,t),o=Xe(e),a=lE(r.steps),i=t.steps.reduce((s,l)=>{let c=dE(s.requiredState,l,o),d=ut({effects:l.effects,parameters:{},pattern:s.logicalRequiredState}),u=uE({branchConditions:a,logicalPost:d,namespace:n.namespace,origin:{kind:"test",test:oe(t)},paramNames:new Set(Object.keys(t.params)),post:c,pre:s.requiredState,step:l});return{logicalRequiredState:d,requiredState:c,steps:[...s.steps,{facts:u,logicalPost:d,post:c}]}},{logicalRequiredState:{constraints:t.startingState.constraints},requiredState:ea(n.requiredState,o),steps:[]});return{initial:ea(n.requiredState,o),logicalInitial:{constraints:t.startingState.constraints},steps:i.steps}}function lE(e){return e.flatMap(r=>r.expect).flatMap(r=>ra(r)).reduce((r,n)=>{let o=g(n.consequence),a=r.get(o),i=a==null?n.condition:{kind:"or",predicates:[a,n.condition]};return new Map([...r,[o,i]])},new Map)}function ra(e){return e.kind==="not"?ra(e.predicate):e.kind==="and"||e.kind==="or"?e.predicates.flatMap(t=>ra(t)):e.kind!=="when"?[]:e.branches.flatMap((t,r)=>{let n=cE(e.branches,r);return t.consequence.flatMap(o=>[{condition:n,consequence:o},...ra(o)])})}function cE(e,t){let r=e.slice(0,t).flatMap(a=>a.condition==null?[]:[a.condition]).map(a=>({kind:"not",predicate:a})),n=e[t]?.condition,o=n==null?r:[...r,n];return o.length===1&&o[0]!=null?o[0]:{kind:"and",predicates:o}}function dE(e,t,r){let n=Ze(e.scalars,[t]),o=Mn(e.actor,[t]);return ea({...e,actor:o,scalars:n},r)}function uE(e){return Mr(e.step.expect).filter(t=>oa(t)).flatMap(t=>pE(t,e))}function pE(e,t){let r=ie(e);if(r==null)return[];if(dt(e).some(i=>t.paramNames.has(i)))return[];let n=v(r.subject);if(t.branchConditions.has(g(e)))return[];let o={...t.post,scalars:new Map([...t.post.scalars].filter(([i])=>i!==n))},a=fE(o,t.pre,t.paramNames);return a==null?[]:Ge(a)===Ge(t.pre)?[]:[{consequence:e,localConsequence:dt(e).length>0||r.subject.kind==="element"&&Do(r.subject.locator).some(i=>typeof i!="string"),logicalWhen:t.logicalPost,origin:t.origin,refs:new Set(mf([...yE(a),...dt(e)],t.namespace).map(i=>i.aliasPath)),when:a}]}function fE(e,t,r){let n=[...e.scalars.values()].map(o=>mE(o,t,r));return n.some(o=>o==null)?null:{...e,scalars:new Map(n.flatMap(o=>o==null?[]:[[v(o.subject),o]]))}}function mE(e,t,r){if(!wf(e,r))return e;if(e.subject.kind!=="element"||e.expect.expect==="absent"||Ne(e.subject.locator).some(o=>r.has(o)))return null;let n=t.scalars.get(v(e.subject));return n==null||n.expect.expect!=="is"||wf(n,r)?null:{expect:{expect:"not",value:n.expect.value},subject:e.subject}}function wf(e,t){return Vs(e).some(r=>t.has(r))}function yE(e){return[...e.scalars.values()].flatMap(t=>Pt(t.subject)&&t.expect.expect!=="absent"?Rt(t.expect.value):[])}function Ef(e,t,r){let n=o=>e(o,...t);return r===void 0?n:Object.assign(n,{lazy:r,lazyArgs:t})}function xf(e,t,r){let n=e.length-t.length;if(n===0)return e(...t);if(n===1)return Ef(e,t,r);throw Error("Wrong number of arguments")}function In(...e){return xf(hE,e)}var hE=(e,t)=>{let r=Object.create(null);for(let n=0;n<e.length;n++){let o=e[n],a=t(o,n,e);if(a!==void 0){let i=r[a];i===void 0?r[a]=[o]:i.push(o)}}return Object.setPrototypeOf(r,Object.prototype),r};var Cf=new Map;function aa({facts:e}){let t=In(e.filter(o=>ie(o.consequence)!=null),o=>gE(o));return Object.values(t).flatMap(o=>o.flatMap(a=>o.filter(i=>i!==a).map(i=>({general:a,specific:i})))).reduce((o,{general:a,specific:i})=>{if(!(Et({general:a.when,specific:i.when})&&Se({current:i.logicalWhen,required:a.logicalWhen}))||Et({general:i.when,specific:a.when})&&Se({current:a.logicalWhen,required:i.logicalWhen}))return o;let c=pt(a),d=o.get(c)??new Set;return new Map([...o,[c,new Set([...d,pt(i)])]])},Cf)}function Af(e){let t=ie(e.consequence);if(t==null)return null;try{let r=Ot({declared:!0,entry:t,scope:Fe(new Map)});return v(r.subject)}catch{return null}}function gE(e){let t=ie(e.consequence);if(t==null)throw new Error("fact consequence has no pattern entry");return v(t.subject)}function Pf(e){let t;return r=>{if(t!==void 0&&t.input===r)return t.output;let n=e(r);return t={input:r,output:n},n}}var ia=Pf(e=>{let t=na(e);return{facts:t,overrides:aa({facts:t})}});function Of(e,t){let{pool:r,timelines:n}=bE(e,t),o=r.map(i=>Qo(i.fact.when)),a=[...n.values()].map(i=>{let s=i.locked.test.viewport,l=r.filter((c,d)=>o[d]==null||o[d]===s);try{return RE({entry:i,pool:l,resolve:SE})}catch(c){let d=c instanceof Error?c.message:String(c);throw new Error(`fact report for ${i.locked.ref}: ${d}`)}});return{pool:r,reports:a}}function Mf(e,t){return{...Tf(e.consequence),declared:e.origin?.kind==="test",key:pt(e),label:Lu(e.consequence),labelTokens:Ju(e.consequence),origins:t}}function SE(e,t){return Et({general:e,specific:t})}function bE(e,t){let r=J(e),n=new Map(r.map(i=>[i.ref,{locked:i,timeline:Qs(e,i)}])),o=EE(n);return{pool:xE({facts:t,originSites:o}),timelines:n}}function RE(e){let{entry:t,pool:r,resolve:n}=e,{locked:o}=t,a=new Set(t.timeline.steps.flatMap(c=>c.facts.map(d=>g(d.consequence)))),i=r.filter(c=>!c.originWorkflows.has(o.test.workflow)).filter(c=>!a.has(c.consequenceKey)),s=vE({candidates:i,resolve:n,timeline:t.timeline});return{steps:t.timeline.steps.map((c,d)=>({borrowed:s.filter(u=>u.stepIndex===d).map(u=>u.borrowed),stepIndex:d})),testRef:o.ref,testSlug:o.test.slug,workflowSlug:o.test.workflow}}function vE({candidates:e,resolve:t,timeline:r}){let o=[{logical:r.logicalInitial,snapshot:r.initial},...r.steps.map(a=>({logical:a.logicalPost,snapshot:a.post}))].reduce((a,i,s)=>{let d=e.filter(f=>!a.has(f)).filter(f=>Se({current:i.logical,required:f.fact.logicalWhen})).filter(f=>t(f.fact.when,i.snapshot)),u=s===0?0:s-1;return new Map([...a,...d.map(f=>[f,u])])},new Map);return r.steps.length===0?[]:[...o].map(([a,i])=>({borrowed:a.borrowed,stepIndex:i}))}function wE(e,t){return{stepIndex:t,testRef:e.ref,testSlug:e.test.slug,workflowIntent:e.workflow.intent,workflowSlug:e.test.workflow}}function EE(e){let t=[...e.values()].flatMap(r=>r.timeline.steps.flatMap((n,o)=>n.facts.map(a=>[pt(a),wE(r.locked,o)])));return new Map(Object.entries(In(t,([r])=>r)).map(([r,n])=>[r,n.map(([,o])=>o)]))}function xE({facts:e,originSites:t}){return e.filter(r=>!(r.origin?.kind==="test"&&r.localConsequence)).map(r=>{let n=pt(r),a=r.origin?.kind==="test"?t.get(n)??[]:[];return{borrowed:Mf(r,a),consequenceKey:g(r.consequence),fact:r,originWorkflows:new Set(a.map(i=>i.workflowSlug))}}).filter(r=>r.borrowed.origins.length>0)}function Tf(e){if(e.kind==="not"){let t=Tf(e.predicate);return{...t,negated:!t.negated}}return"locator"in e?{checkKind:e.kind,negated:!1,subject:kE(e.locator)}:{checkKind:void 0,negated:!1,subject:void 0}}function kE(e){try{return Fo(ue(e,Fe(new Map)))}catch(t){if(t instanceof G)return Nu(e);throw t}}function Nf(e){let t=$e(e,Ge),r=$e(t.flatMap(a=>[...a.scalars.values()]),g),n=If(r,g),o=If(t,Ge);return{patternTable:t.map(a=>({actor:a.actor,scalars:[...a.scalars.values()].map(i=>Lf(n,g(i)))})),scalarTable:r.map(a=>({expect:a.expect,subject:a.subject})),indexOf:a=>Lf(o,Ge(a))}}function Ff(e){return e.patternTable.map(t=>({actor:t.actor,scalars:new Map(t.scalars.map(r=>{let n=el(e.scalarTable,r);return[v(n.subject),n]}))}))}function el(e,t){let r=e[t];if(r==null)throw new Error("compiled checks table index out of range \u2014 recompile");return r}function If(e,t){return new Map(e.map((r,n)=>[t(r),n]))}function Lf(e,t){let r=e.get(t);if(r==null)throw new Error("compiled checks pattern missing from table");return r}function Bf(e){let t=ia(e),{pool:r,reports:n}=Of(e,t.facts),o=Nf(t.facts.flatMap(s=>OE(s))),a=new Map(t.facts.map((s,l)=>[s,l])),i=new Map(r.map((s,l)=>[s.borrowed,l]));return{factPool:r.map(s=>({fact:$f(a,s.fact),origins:s.borrowed.origins.map(l=>({...l}))})),factReports:n.map(s=>IE(s,i)),facts:t.facts.map(s=>ME(s,o)),overrides:TE(t.overrides),patternTable:o.patternTable,scalarTable:o.scalarTable}}var Df=new WeakMap;function Nr(e){let t=Df.get(e);if(t!=null)return t;let r=CE(e),n=Ff(r),o={facts:r.facts.map(a=>AE(a,n)),overrides:PE(r.overrides)};return Df.set(e,o),o}function CE(e){return e.checks}function $f(e,t){let r=e.get(t);if(r==null)throw new Error("compiled checks item missing from index");return r}function AE(e,t){return{consequence:e.consequence,localConsequence:e.localConsequence,logicalWhen:{constraints:e.logicalWhen},origin:e.origin,refs:new Set(e.refs),when:el(t,e.when)}}function PE(e){return new Map(Object.entries(e).map(([t,r])=>[t,new Set(r)]))}function OE(e){return[e.when]}function ME(e,t){return{consequence:e.consequence,localConsequence:e.localConsequence,logicalWhen:[...e.logicalWhen.constraints],origin:e.origin,refs:[...e.refs],when:t.indexOf(e.when)}}function TE(e){return Object.fromEntries([...e].map(([t,r])=>[t,[...r].toSorted((n,o)=>n.localeCompare(o))]).toSorted(([t],[r])=>t.localeCompare(r)))}function IE(e,t){return{steps:e.steps.map(r=>({borrowed:r.borrowed.map(n=>$f(t,n)),stepIndex:r.stepIndex})),testRef:e.testRef,testSlug:e.testSlug,workflowSlug:e.workflowSlug}}var M=Rs(_f(),1),Me={actual:e=>M.default.red(e),bad:e=>M.default.red(M.default.bold(e)),bold:e=>M.default.bold(e),dim:e=>M.default.dim(e),expected:e=>M.default.green(e),good:e=>M.default.green(M.default.bold(e)),heading:e=>M.default.bold(M.default.cyan(e)),path:e=>M.default.cyan(M.default.underline(e)),warn:e=>M.default.yellow(M.default.bold(e))},DE={action:M.default.yellow,assertion:M.default.yellow,consistency:M.default.magenta,"data rule":M.default.yellow,driver:M.default.red,fact:M.default.yellow,"impossible action":M.default.cyan,precondition:M.default.yellow,reachability:M.default.yellow,redundancy:M.default.yellow,skipped:M.default.red,state:M.default.magenta,surface:M.default.yellow,value:M.default.yellow,"workflow gap":M.default.red};function ce(e){return`${M.default.red(M.default.bold("\u2717"))} ${DE[e](M.default.bold(e))}`}var BE=M.default.red("\u2717"),J$=M.default.green("\u2713"),$E=M.default.dim("\u203A"),jE=8;function Uf(e,t,r){let n=r==null?"":` ${Me.dim(r)}`;return` ${Me.dim(e.padStart(jE))} ${t}${n}`}function Wf(e){let t=[...e.scalars.values()].find(r=>r.subject.kind==="path"&&r.expect.expect==="is")?.expect;return t==null||t.expect==="absent"?"(any view)":VE(t.value)}function VE(e){return typeof e!="object"||e==null?String(e):"template"in e?e.template.map(t=>typeof t=="string"?t:"ref"in t?`{${t.ref}}`:`{${Iu(t)}}`).join(""):`{${e.ref}}`}function ca(e){let t=[...e.scalars.values()].filter(r=>r.subject.kind!=="path").filter(r=>!zf(r)).map(r=>da(r));return t.length===0?"always":t.join(" \u2227 ")}function da(e){let t=_E(e.subject);return e.expect.expect==="absent"?`${t} absent`:e.subject.kind==="element"&&UE(e.expect.value)?e.expect.value?t:`not ${t}`:`${t} ${e.expect.expect==="not"?"\u2260":"="} ${It(e.expect.value)}`}function se(e){return e.by==="role"?e.name==null?e.role:`${e.role} ${It(e.name)}`:e.by==="inside"?`${se(e.scope)} \u25B8 ${se(e.target)}`:e.by==="surface"?se(e.container):e.by==="frame"?`frame ${se(e.element)}`:It(e.value)}function It(e){return e===null?"\u2205":typeof e=="string"?`"${e}"`:typeof e!="object"?String(e):"ref"in e?`{${e.ref}}`:rl(e)}function rl(e){return e.template.map(t=>typeof t=="string"?t:":id").join("")}function qf(e,t){let r=new Set(t.scalars.keys()),n=[...e.scalars].filter(([o])=>!r.has(o)).map(([,o])=>o).filter(o=>o.subject.kind!=="path"&&!zf(o)).map(o=>da(o));return n.length===0?"nothing beyond the shared state":n.join(" \u2227 ")}function zf(e){return e.subject.kind==="element"&&e.subject.locator.by==="surface"&&e.subject.locator.overlay&&e.subject.state==="visible"&&e.expect.expect==="is"&&e.expect.value===!1}function _E(e){return e.kind==="variable"?e.name:e.kind==="element"?`${e.state} ${se(e.locator)}`:e.kind==="query"?`url query "${e.key}"`:e.kind==="title"||e.kind==="viewport"?e.kind:`url ${e.kind}`}function UE(e){return typeof e=="boolean"}function te(e){return e.by==="testId"?`testId=${Oe(e.value)}`:e.by==="inside"?`${te(e.scope)} \u25B8 ${te(e.target)}`:e.by==="surface"?te(e.container):e.by==="frame"?`frame ${te(e.element)}`:e.name==null?e.role:`${e.role} "${Oe(e.name)}"`}function Ln(e){return e.kind==="variable"?`global variable "${e.name}"`:e.kind==="element"?`${e.state} ${te(e.locator)}`:e.kind==="query"?`url query "${e.key}"`:e.kind==="title"||e.kind==="viewport"?e.kind:e.kind==="actor"?"signed-in actor":`url ${e.kind}`}function ua(e){return e.url!=null?`${e.kind} ${Oe(e.url)}`:e.locator!=null?`${e.kind} ${te(e.locator)}`:e.kind}function Lt(e){return e==null?"\u2205":JSON.stringify(e)}function pa(e){let t=e.want==null?"absent":It(e.want),r=e.got===void 0?"absent":It(e.got);return`${WE(e.subject)} needed ${t} but was ${r}`}function WE(e){return e.kind==="element"?`${e.state} ${se(e.locator)}`:e.kind==="variable"?`"${e.name}"`:e.kind==="query"?`url query "${e.key}"`:e.kind==="actor"?"signed-in actor":`url ${e.kind}`}var qE={"no-effect":"the action has no observable effect from this state","required-state-unsatisfied":"the live state doesn't satisfy the step's required state",unresolvable:"a step references a value that doesn't exist yet (e.g. a not-yet-created id)"};function nl(e){return qE[e]}function Kf({debugDir:e,runId:t}){let r=`${e}/${t}`;return Uf("behavior",Me.path(`${r}/behavior.jsonl`),void 0)}function Nt(e){return e.kind==="drag"?`drag ${se(e.source)} to ${se(e.target)}`:"locator"in e&&e.locator!=null?`${e.kind} ${se(e.locator)}`:"url"in e?`${e.kind} ${zE(e.url)}`:e.kind}function zE(e){return typeof e=="string"?e:"ref"in e?`{${e.ref}}`:rl(e)}function je(e){return e.kind==="not"?`not ${je(e.predicate)}`:e.kind==="and"?e.predicates.map(t=>je(t)).join(" \u2227 "):e.kind==="when"?e.branches.map(t=>t.name).join(" | "):KE(e)}function KE(e){return"locator"in e?HE(e):e.kind==="browser"?`${e.name}=${It(e.value)}`:e.kind==="actor"?e.target.kind==="anonymous"?"actor is signed out":`actor is ${e.target.ref.ref}`:""}function HE(e){let t=se(e.locator);if(e.kind==="value"||e.kind==="text"){let r=ot(e.value)?e.value.value:e.value;return`${e.kind} ${t}=${It(r)}`}return`${e.kind} ${t}`}function Hf({contradiction:e,evidencePath:t}){let r=JE(e);return t==null?r:`${r} Evidence: ${Me.path(t)}`}function fa(e){return`${YE(e)}.`}function ma(e){return lx(ZE(e))}function JE(e){switch(e.kind){case"check":{let t=` After "${e.step.intent}".`;return`${GE(e.record.body)} ${fa(e.record.body)}${t}`}case"stepError":return`${ce("driver")} Run stopped at "${e.step.intent}" \u2014 ${Yt(e.record.error)}.`;case"finding":return ax(e.finding)}}function GE(e){switch(e.family){case"element":case"content":case"scalar":return ce("assertion");case"state":case"frame":return ce("state");case"action":return ce("action");case"dataRule":return ce("data rule")}}function YE(e){switch(e.family){case"element":return`Expected ${e.subject} ${e.negated?"not ":""}${e.checkKind} \u2014 ${XE(e)}`;case"content":return`Expected ${e.subject} ${e.checkKind} ${ox(e.match)} ${JSON.stringify(e.expected)}${e.negated?" to not hold":""} \u2014 ${QE(e)}`;case"scalar":return`Expected ${e.subject} to ${e.negated?"not ":""}be ${Jf(e.expected)} \u2014 ${ex(e)}`;case"state":return`Expected ${e.subject} ${e.assertion} \u2014 ${tx(e)}`;case"frame":return`Unexpected change \u2014 ${rx(e)}`;case"action":return`Could not ${e.actionKind} ${e.subject} \u2014 ${nx(e)}`;case"dataRule":return`Data rule ${e.rule} broke \u2014 a referenced row went missing`}}function ZE(e){switch(e.kind){case"check":return qu(e.record.body)??fa(e.record.body);case"stepError":return`run stopped at "${e.step.intent}": ${Yt(e.record.error)}`;case"finding":return ix(e.finding)}}function ol(e){switch(e.kind){case"wrongValue":return`${e.entity}.${e.field} [${e.key}] showed ${Me.actual(e.observed)}, expected ${Me.expected(e.expected)}`;case"missingRow":return`${e.entity} row "${e.key}" never appeared`;case"unexpectedRow":return`${e.entity} row "${e.key}" is present but the test expected none`;case"unexpectedlyDeleted":return`${e.entity} row "${e.key}" disappeared`;case"neverChanged":return e.direction!=null?`${e.entity}.${e.field} [${e.key}] didn't ${e.direction==="increased"?"increase":"decrease"} from ${e.from} (showed ${Me.actual(e.observed)})`:`${e.entity}.${e.field} [${e.key}] never changed from ${Me.actual(e.observed)}`;case"wrongCount":return`found ${String(e.observed)} ${e.entity} rows, expected ${String(e.expected)}`}}function Fr(e){let{outcome:t}=e;return t.kind==="passed"?null:t.reason}function XE(e){let t=Fr(e);if(t==null)return"held";switch(t.kind){case"notFound":return"the element was not visible";case"multipleMatches":return`the locator matched ${String(t.count)} elements`;case"wrongState":return`the element ${t.observed.value?"stayed":"was never"} ${t.observed.checkKind}`;case"covered":return`the element is covered by ${t.by}`;case"unclassified":return t.message}}function QE(e){let t=Fr(e);if(t==null)return"held";switch(t.kind){case"notFound":return"the element was not visible";case"multipleMatches":return`the locator matched ${String(t.count)} elements`;case"wrongContent":return`it showed ${JSON.stringify(t.observed)}`;case"unclassified":return t.message}}function ex(e){let t=Fr(e);return t==null?"held":`it showed ${Jf(t.observed)}`}function Jf(e){return e??"absent"}function tx(e){let t=Fr(e);return t==null?"held":ol(t)}function rx(e){let t=Fr(e);return t==null?"none was seen":zu(t)}function nx(e){let t=Fr(e);if(t==null)return"it succeeded";switch(t.kind){case"notFound":return"the element was not visible";case"multipleMatches":return`the locator matched ${String(t.count)} elements`;case"covered":return`the element is covered by ${t.by}`;case"notPossible":return"the current test state does not allow this action";case"unclassified":return t.message}}function ox(e){switch(e){case"exact":return"to equal";case"contains":return"to contain";case"startsWith":return"to start with"}}function ax(e){switch(e.kind){case"impossible-action":return`${ce("impossible action")} "${e.step.intent}" ran ${ua(e.step.action)} from a state the test calls impossible.`;case"unrunnable":return`${ce("workflow gap")} "${e.intent}" couldn't run here \u2014 ${Gf(e)}.`;case"lift-visibility":return`${ce("reachability")} ${se(e.locator)} is visible by step ${String(e.visibleIndex+1)} but declared at step ${String(e.declaredIndex+1)}.`}}function Gf(e){return e.unmet==null?nl(e.reason):pa(e.unmet)}function ix(e){switch(e.kind){case"impossible-action":return`"${e.step.intent}" ran from a state the test says can't happen`;case"unrunnable":return`workflow gap: "${e.intent}" could not run here \u2014 ${Gf(e)}. Add the missing before-state declaration, then run npx ripplo compile`;case"lift-visibility":return`visible(${se(e.locator)}) declared at step ${String(e.declaredIndex+1)} but already visible at step ${String(e.visibleIndex+1)}`}}var sx=new RegExp(`${String.fromCodePoint(27)}\\[[0-9;]*m`,"g");function lx(e){return e.replaceAll(sx,"").replaceAll(/\s+/g," ").trim()}import{performance as Ea}from"perf_hooks";function Yf(e,{clears:t,forget:r,sets:n}){let o=new Set(t),a=cx(e,r,n),i=[...e.scalars].filter(([l,c])=>!o.has(l)&&!(a&&(Fs(c.subject)||dx(c.subject)))),s=[...n.values()].reduce((l,c)=>ct(l,c),new Map(i));return{...e,scalars:s}}function cx(e,t,r){if(t==="hard")return!0;if(t==="none")return!1;let n=Y(e.scalars,{kind:"path"}),o=Y(r,{kind:"path"});return o!==void 0&&o!==n}function dx(e){return e.kind==="query"||e.kind==="hash"}function al(e){return e.kind==="not"?al(e.inner):e.kind==="browser"&&Rp(e.key)}function Br(e,t){let{executedBranches:r,step:n}=e,{env:o}=t,a=Vu({executedBranches:r,expect:n.expect}),i=t.logical,s=t.snapshot==null?void 0:Y(t.snapshot.scalars,{kind:"actor"}),l=wn({actorAlias:s,current:i?.current,deferred:t.deferred,env:o}),c=wn({actorAlias:s,current:i?.current,deferred:new Set([...t.deferred,...Js(n.effects)]),env:o}),{actionScalars:d,clears:u,sets:f}=gx({leaves:a,scope:c,step:n}),y=Go(n),m=bx(n.action,l),h=ux(n,a);return{action:m,actionScalars:d,assertedScalars:[...f.keys()],executedBranches:r,expectationScalars:fx(a,c),label:n.action.kind,pendingChecks:a.flatMap(p=>wx(p,c,y)),scalarChecks:a.flatMap(p=>mx(p,c)),urlChecks:a.flatMap(p=>vx(Dr(p),c)),effect:p=>Yf(p,{clears:u,forget:h,sets:f})}}function ux(e,t){return e.action.kind==="goto"||e.action.kind==="actor"||px(t)?"hard":Qt(e)?"soft-path":"none"}function px(e){return e.some(t=>t.predicate.kind==="actor")}function fx(e,t){return e.flatMap(r=>{let n=ie(Dr(r));if(n==null)return[];let o=sl({declared:!0,entry:n,scope:t});return o==null?[]:[o]})}function Dr(e){return e.negated?{kind:"not",predicate:e.predicate}:e.predicate}function mx(e,t){let{predicate:r}=e;if(r.kind!=="browser"&&r.kind!=="actor")return[];let n=ie(Dr(e));if(n==null)return[];try{let o=Ot({declared:!0,entry:n,scope:t});return Ep(o.expect)==null?[]:[{entry:o,negated:e.negated,ref:{branch:e.branch,ordinal:e.ordinal}}]}catch(o){if(o instanceof G)return[];throw o}}function il(e,t){if(e.kind==="visible"||e.kind==="unobstructed"||e.kind==="disabled"||e.kind==="enabled"||e.kind==="focused"||e.kind==="checked"||e.kind==="expanded"||e.kind==="pressed")return{kind:e.kind,locator:ue(e.locator,t)};if(e.kind==="not"){let r=il(e.predicate,t);return r==null?null:{inner:r,kind:"not"}}return e.kind==="value"||e.kind==="text"?yx(e,t):e.kind!=="browser"?null:{key:qo(e.name,e.part),kind:"browser",value:e.value===null?null:De(e.value,t)}}function yx(e,t){let r=ot(e.value);return{kind:e.kind,locator:ue(e.locator,t),match:r?e.value.kind:"exact",value:De(r?e.value.value:e.value,t)}}function hx(e){return e.action.kind!=="actor"?null:{expect:{expect:"is",value:e.action.ref.ref},subject:{kind:"actor"}}}function gx({leaves:e,scope:t,step:r}){let n=r.action.kind==="goto"?Cn(r.action.url):[],o=hx(r),a=e.filter(c=>!Jt(Dr(c))).flatMap(c=>{let d=ie(Dr(c));return d==null?[]:[d]}),i=[...n,...a,...o==null?[]:[o]].map(c=>({declared:!0,entry:c})),s=Tt(r).map(c=>({declared:!1,entry:c}));return{...[...s,...i].reduce((c,{declared:d,entry:u})=>Sx({acc:c,declared:d,entry:u,scope:t}),{actionScalars:[],clears:[],sets:lt}),actionScalars:s.flatMap(({declared:c,entry:d})=>{let u=sl({declared:c,entry:d,scope:t});return u==null?[]:[u]})}}function Sx({acc:e,declared:t,entry:r,scope:n}){let o=sl({declared:t,entry:r,scope:n});return o==null?e:o.expect.expect==="absent"&&!Pt(o.subject)?{...e,clears:[...e.clears,v(o.subject)]}:{...e,sets:ct(e.sets,o)}}function sl({declared:e,entry:t,scope:r}){try{return Ot({declared:e,entry:t,scope:r})}catch(n){if(n instanceof G)return;throw n}}function bx(e,t){return{actorRef:e.kind==="actor"?e.ref.ref:void 0,files:e.kind==="upload"?e.files:void 0,key:e.kind==="press"?e.key:void 0,kind:e.kind,locator:Rx(e,t),target:e.kind==="drag"?ue(e.target,t):void 0,url:e.kind==="goto"?De(e.url,t):void 0,value:"value"in e?At(e.value,t):void 0}}function Rx(e,t){if(e.kind==="drag")return ue(e.source,t);if(!(!("locator"in e)||e.locator==null))return ue(e.locator,t)}function vx(e,t){if(e.kind!=="browser"&&e.kind!=="not")return[];let r=il(e,t);return r!=null&&al(r)?[r]:[]}function wx(e,t,r){let n=Dr(e),o=il(n,t);return e.predicate.kind==="browser"&&o!=null&&!Zf(o)?[]:Ex({check:o,leaf:e,navigates:r,predicate:n})}function Zf(e){return e.kind==="not"?Zf(e.inner):e.kind!=="browser"?!1:e.value!==null&&U(e.value)}function Ex({check:e,leaf:t,navigates:r,predicate:n}){return e==null?[]:[{budget:xx(t.predicate,r),check:e,ephemeral:Jt(n),ref:{branch:t.branch,ordinal:t.ordinal}}]}function xx(e,t){return"wait"in e&&e.wait!=null?e.wait:t?"slow":"fast"}function Xf(e,t,r){return e.reduce((n,o)=>{let a={...r,logical:n.logical,snapshot:n.snapshot},i=Px(o,n.snapshot,a),s=Ox(o,i);return{logical:Qf(s,n.logical),resolved:[...n.resolved,{executedBranches:i,step:s}],snapshot:n.snapshot}},{logical:r.logical,resolved:[],snapshot:t}).resolved}function ya(e,t){return e.kind==="not"?!ya(e.predicate,t):e.kind==="or"?e.predicates.some(r=>ya(r,t)):e.kind==="and"?e.predicates.every(r=>ya(r,t)):kx(e,t)}function kx(e,t){return e.kind==="state-relation"?t.logical!=null&&up({actorAlias:Y(t.snapshot.scalars,{kind:"actor"}),current:t.logical.current,env:t.env,relation:e.relation}):e.kind==="state-compare"||e.kind==="state-equals"?Cx({condition:e,logical:t.logical}):Ax(e,t.logical)}function Cx({condition:e,logical:t}){return t==null?!1:e.kind==="state-compare"?Hs({current:t.current,op:e.op,selector:e.selector,value:e.value}):Xp({current:t.current,selector:e.selector,value:e.value})}function Ax(e,t){return t!=null&&Ks({alias:e.alias,candidates:t.candidates,current:t.current})}function Px(e,t,r){let n=Qf(e,r.logical);return e.expect.filter(o=>o.kind==="when").flatMap(o=>{let a=o.branches.find(i=>i.condition==null||ya(i.condition,{env:r.env,logical:n,snapshot:t}));return a==null?[]:[a.name]})}function Qf(e,t){if(t!=null)return{candidates:t.candidates,current:ut({effects:e.effects,parameters:{},pattern:t.current})}}function Ox(e,t){return{...e,effects:[...e.effects,...ju({executedBranches:t,expect:e.expect})]}}function Nn(e,t,r){let n=Object.keys(r).length===0?t.base:ll({base:t.base,params:r});return Mx({state:{...t,base:n},transition:e})}function Mx({state:e,transition:t}){let r=$s({base:e.base,deferred:e.deferred,logical:e.logical,pattern:t.requiredState,snapshot:e.snapshot});return r==null?null:new Map([...e.base,...r])}function ll({base:e,params:t}){return new Map([...e,...Object.entries(t).map(([r,n])=>[z(r),n])])}function Fn(e,t,r){let n={deferred:r.deferred,env:t,logical:{candidates:e.logicalCandidates,current:r.logical},snapshot:r.snapshot},o=Xf(e.whenSteps,r.snapshot,n),a=o.at(-1)??{executedBranches:[],step:e.effectStep},i=Br(a,n),s=Tx(e,n),l=o.reduce((c,d)=>{let u=Br(d,{...n,snapshot:c.current});return{current:u.effect(c.current),steps:[...c.steps,{action:u.action,actionScalars:u.actionScalars,assertedScalars:u.assertedScalars,effect:u.effect,executedBranches:d.executedBranches,expectationScalars:u.expectationScalars,pendingChecks:u.pendingChecks,scalarChecks:u.scalarChecks,source:d.step,urlChecks:u.urlChecks}]}},{current:r.snapshot,steps:[]});return{effect:Ix(i.effect,s),steps:l.steps}}function ha(e,t,r){return Ft(t(r))!==Ft(r)||e.steps.length>0}var em=new WeakMap;function Ft(e){let t=em.get(e);if(t!=null)return t;let r=g({scalars:Ds(e.scalars).map(([n,o])=>[n,o.expect])});return em.set(e,r),r}function Tx(e,t){let r=e.nav.at(-1);if(r==null)return;let n=Br({executedBranches:[],step:r},t).action.url;return n==null||U(n)?void 0:n}function Ix(e,t){if(t==null)return e;let r=Ar(t);return n=>{let o={...n,scalars:Be(n.scalars,r)};return e(o)}}function tm({effects:e,parameters:t,pattern:r}){return e.every(n=>Lx({effect:n,parameters:t,pattern:r}))}function Lx({effect:e,parameters:t,pattern:r}){return e.kind==="update-selected-records"?Vp({constraints:r.constraints,effect:e,parameters:t}):e.kind!=="transform"?!0:r.constraints.filter(n=>n.kind==="equals"&&g(n.selector)===g(e.selector)&&n.value.kind==="value").every(n=>n.kind!=="equals"||n.value.kind!=="value"||jo({before:n.value.value,context:{parameters:t,records:{},state:{}},relation:e.relation}).kind!=="invalid")}function rr(e,t,r){let n=rm(e,t);return n==null?null:nm({context:n,params:r,rule:e,state:t})}var cl=new WeakMap;function rm(e,t){if(!Bs({pattern:e.requiredState,snapshot:t.snapshot}))return null;if(Nx(e))return Se({current:t.logical,required:{constraints:e.logicalRequiredState}})?{env:void 0}:null;let r=om({params:{},rule:e,state:t});return r==null?null:Se({current:t.logical,required:{constraints:e.logicalRequiredState}})?{env:r}:null}function Nx(e){let t=cl.get(e);if(t!=null)return t;if(Object.keys(e.paramSpaces).length===0)return cl.set(e,!1),!1;let r=new Set(Object.keys(e.paramSpaces)),n=Pr(e.requiredState).some(o=>r.has(o));return cl.set(e,n),n}function Dn(e,t,r){if(!Bs({pattern:e.requiredState,snapshot:t.snapshot})||!Se({current:t.logical,required:{constraints:e.logicalRequiredState}}))return"required-state-unsatisfied";try{let n=Nn(e,t,r);return n==null?"required-state-unsatisfied":(Fn(e,n,t),"no-effect")}catch(n){if(n instanceof G)return"unresolvable";throw n}}function nm({context:e,params:t,rule:r,state:n}){let o=e.env==null?om({params:t,rule:r,state:n}):ll({base:e.env,params:t});if(o==null)return null;let a=Bx(r,o,n);if(a==null||!Fx(a)||!Dx({resolved:a,rule:r,state:n})||!ha(r,a.effect,n.snapshot))return null;let i=a.steps.flatMap(l=>l.source.effects);if(!tm({effects:i,parameters:t,pattern:n.logical}))return null;let s=ut({effects:i,parameters:t,pattern:n.logical});return{next:{base:Qp({after:s,before:n.logical,env:n.base}),deferred:ef({after:s,deferred:n.deferred,effects:i}),logical:s,snapshot:a.effect(n.snapshot)},resolved:a}}function Fx(e){return e.steps.every(t=>uf(t.expectationScalars))}function Dx({resolved:e,rule:t,state:r}){if(t.actionRelationship==null)return!0;if(t.actionRelationship==="undecided")return!1;let n=e.steps.at(-1);return n==null?!1:df({effects:n.actionScalars,prior:r.snapshot.scalars})===t.actionRelationship}function om({params:e,rule:t,state:r}){try{return Nn(t,r,e)}catch(n){if(n instanceof G)return null;throw n}}function Bx(e,t,r){try{return Fn(e,t,r)}catch(n){if(n instanceof G)return null;throw n}}function dl({attempts:e,paramsForAttempt:t,rule:r,state:n}){return am({attempts:e,paramsForAttempt:t,rule:r,state:n}).prepared}function am({attempts:e,paramsForAttempt:t,rule:r,state:n}){let o=rm(r,n);return o==null?{parameterAttempts:0,prepared:null}:sm({attempt:0,attempts:e,context:o,paramsForAttempt:t,rule:r,state:n})}function im(e,t,r){return e.reduce((n,o)=>{if(n.runs.length===r.limit)return n;let a=am({attempts:r.attemptsFor(o),rule:o,state:t,paramsForAttempt:s=>r.paramsFor(o,s)}),i=a.prepared;return i==null?{parameterAttempts:n.parameterAttempts+a.parameterAttempts,rulesConsidered:n.rulesConsidered+1,runs:n.runs}:{parameterAttempts:n.parameterAttempts+a.parameterAttempts,rulesConsidered:n.rulesConsidered+1,runs:[...n.runs,{label:er(o),parameterAttempt:i.parameterAttempt,params:i.params,stepRun:i.stepRun,transitionId:o.id}]}},{parameterAttempts:0,rulesConsidered:0,runs:[]})}function sm({attempt:e,attempts:t,context:r,paramsForAttempt:n,rule:o,state:a}){if(e===t)return{parameterAttempts:t,prepared:null};let i=n(e),s=nm({context:r,params:i,rule:o,state:a});return s==null?sm({attempt:e+1,attempts:t,context:r,paramsForAttempt:n,rule:o,state:a}):{parameterAttempts:e+1,prepared:{parameterAttempt:e,params:i,stepRun:s}}}import{okAsync as Hx}from"neverthrow";function cm({plan:e,state:t}){let r=dm({pending:e.operations,results:{},state:t});return new Map(Object.entries(r).flatMap(([n,o])=>x(o)?Object.entries(o).flatMap(([a,i])=>Kx(i)?[[z(`${n}.${a}`),i]]:[]):[]))}function dm({pending:e,results:t,state:r}){if(e.length===0)return t;let n=e.filter(a=>vr(a.input).every(i=>Object.hasOwn(t,i)));if(n.length===0)return t;let o=Object.fromEntries(n.flatMap(a=>{let i=ul({expression:a.input,results:t});return i.found?[[a.id,$x({operation:a,state:r,value:i.value}).value]]:[]}));return dm({pending:e.filter(a=>!n.some(i=>i.id===a.id)),results:{...t,...o},state:r})}function $x({operation:e,state:t,value:r}){let n=jx({operation:e,state:t}).value,o=um({schema:n,token:`${e.id}.`});return o.found?fm({base:r,overlay:o.value}):ye(r)}function jx({operation:e,state:t}){let r=lm({key:e.source,schema:t.jsonSchema}).value;if(e.target.kind==="state")return ye(r);let n=e.target.path.reduce((a,i)=>lm({key:i,schema:a}).value,r),o=Ve({key:"additionalProperties",value:n}).value;if(o===void 0||typeof o=="boolean")throw new TypeError(`state schema record ${e.target.path.join(".")} has no row`);return ye(o)}function lm({key:e,schema:t}){let r=Ve({key:"properties",value:t}).value,n=Ve({key:e,value:r}).value;if(n===void 0)throw new TypeError(`state schema has no property ${e}`);return ye(n)}function Ve({key:e,value:t}){return{value:x(t)?t[e]:void 0}}function um({schema:e,token:t}){if(Vx(e).value==="generated")return $r(pm({schema:e,token:t}).value);let r=Ve({key:"properties",value:e}).value;if(!x(r))return nr();let n=Object.fromEntries(Object.entries(r).flatMap(([o,a])=>{let i=um({schema:a,token:`${t}${o}.`});return i.found?[[o,i.value]]:[]}));return Object.keys(n).length===0?nr():$r(n)}function Vx(e){let t=Ve({key:"ripplo",value:e}).value,r=Ve({key:"setup",value:t}).value;return{value:typeof r=="string"?r:void 0}}function pm({schema:e,token:t}){let r=Ve({key:"const",value:e}).value;if(r!==void 0)return ye(r);let n=Ve({key:"enum",value:e}).value;if(Array.isArray(n)&&n[0]!==void 0)return ye(n[0]);let o=Ve({key:"type",value:e}).value;return _x({schema:e,token:t,type:o})}function _x({schema:e,token:t,type:r}){return r==="boolean"?ye(t.length%2===0):r==="integer"||r==="number"?ye(Ux(t)):r==="null"?ye(null):r==="array"?ye([]):r==="object"?Wx({schema:e,token:t}):ye(`__ripplo_generated_${t.slice(0,-1)}`)}function Ux(e){return Buffer.from(e).reduce((t,r)=>(t*31+r)%1000003,17)}function Wx({schema:e,token:t}){let r=Ve({key:"properties",value:e}).value,n=Ve({key:"required",value:e}).value;return!x(r)||!Array.isArray(n)?ye({}):ye(Object.fromEntries(n.flatMap(o=>{if(typeof o!="string")return[];let a=r[o];return a===void 0?[]:[[o,pm({schema:a,token:`${t}${o}.`}).value]]})))}function fm({base:e,overlay:t}){return!x(e)||!x(t)?ye(t):ye(Object.fromEntries([...new Set([...Object.keys(e),...Object.keys(t)])].map(r=>[r,qx({base:e,key:r,overlay:t}).value])))}function qx({base:e,key:t,overlay:r}){let n=r[t],o=e[t];if(n===void 0){if(o===void 0)throw new TypeError(`state operation field ${t} is missing`);return ye(o)}return o===void 0?ye(n):fm({base:o,overlay:n})}function ul({expression:e,results:t}){if(e.kind==="value")return $r(e.value);if(e.kind==="generate")return nr();if(e.kind==="reference")return zx({operation:e.operation,path:e.path,results:t});if(e.kind==="array"){let r=e.items.map(n=>ul({expression:n,results:t}));return r.every(n=>n.found)?$r(r.map(n=>n.value)):nr()}return $r(Object.fromEntries(Object.entries(e.fields).flatMap(([r,n])=>{let o=ul({expression:n,results:t});return o.found?[[r,o.value]]:[]})))}function zx({operation:e,path:t,results:r}){let n=r[e];return n===void 0?nr():mm({path:t,value:n})}function mm({path:e,value:t}){let[r,...n]=e;if(r==null)return $r(t);if(!x(t))return nr();let o=t[r];return o===void 0?nr():mm({path:n,value:o})}function $r(e){return{found:!0,value:e}}function nr(){return{found:!1}}function Kx(e){return e==null||["boolean","number","string"].includes(typeof e)}function ye(e){return{value:e}}function jr({generate:e,params:t,state:r,test:n}){let o={generate:e,params:t},a=new Map([...Jx(pl({...o,test:n})),...cm({plan:n.startingState,state:r})]);return Hx({env:a,snapshot:{scalars:new Map([Gx(n),...Yx(n,a)])}})}function pl({generate:e,params:t,test:r}){return Object.fromEntries(Object.entries(r.params).map(([n,o])=>{let a=t?.[n];return a!=null?[n,a]:[n,e.value({nullable:!1,seed:n,space:o.space,type:To(o.space),valueSpace:o.space.name})]}))}function Jx(e){return Object.entries(e).map(([t,r])=>[z(t),r])}function Gx(e){let t={kind:"viewport"};return[v(t),{declared:!1,expect:{expect:"is",value:e.viewport},subject:t}]}function Yx(e,t){if(e.actor.kind==="anonymous")return[];let r={kind:"actor"};return[[v(r),{declared:!1,expect:{expect:"is",value:e.actor.alias},subject:r}]]}var Zx=24301,Xx=256;function hm(e){return g({active:e.active==null?null:{params:Object.entries(e.active.params).toSorted(([t],[r])=>t.localeCompare(r)),spaces:Object.entries(e.active.spaces).toSorted(([t],[r])=>t.localeCompare(r)),test:e.active.test},completedDraws:[...e.completedDraws].toSorted(([t],[r])=>t.localeCompare(r))})}function Sa({generate:e,test:t,testRef:r}){return Bn({params:pl({generate:e,params:void 0,test:t}),test:t,testRef:r})}function Bn({params:e,test:t,testRef:r}){return{active:{params:e,spaces:Object.fromEntries(Object.entries(t.params).map(([n,o])=>[n,o.space])),test:r},completedDraws:new Map}}function or({action:e,attempt:t,state:r}){let n=fl({action:e,state:r}),o=n?r.completedDraws:bm(r),a=n?gm(e,r.active):{};return{...Qx({attempt:t,drawnBefore:o,spaces:Sm(e.paramSpaces,a)}),...a}}function Dt({action:e,params:t,state:r}){let n=fl({action:e,state:r}),o=n?r.completedDraws:bm(r),a=n&&r.active!=null?r.active.params:{},i=n&&r.active!=null?r.active.spaces:{};return{active:{params:{...a,...t},spaces:{...i,...e.paramSpaces},test:e.test},completedDraws:o}}function Vr({action:e,state:t}){let r=fl({action:e,state:t})?gm(e,t.active):{};return ek(Sm(e.paramSpaces,r))}function Qx({attempt:e,drawnBefore:t,spaces:r}){let n=Object.entries(r);return Object.fromEntries(n.map(([o,a],i)=>{let s=a?.name==null?0:t.get(a.name)??0;return[o,nk(a,s+tk({attempt:e,entries:n,index:i})).value]}))}function ek(e){return Math.min(128,Object.values(e).reduce((t,r)=>t*ga(r),1))}function fl({action:e,state:t}){return t.active!=null&&t.active.test===e.test}function gm(e,t){return t==null?{}:Object.fromEntries(Object.keys(e.paramSpaces).flatMap(r=>{let n=t.params[r];return n===void 0?[]:[[r,n]]}))}function Sm(e,t){return Object.fromEntries(Object.entries(e).filter(([r])=>t[r]===void 0))}function bm(e){return e.active==null?e.completedDraws:ak(e.completedDraws,e.active.spaces)}function tk({attempt:e,entries:t,index:r}){let n=t.slice(0,r).reduce((o,a)=>o*ga(a[1]),1);return Math.floor(e/n)%ga(t[r]?.[1])}function ga(e){return e?.kind==="enum"?e.values.length:e?.kind==="boolean"?2:e?.kind==="number"?Math.min(e.max-e.min+1,16):16}var rk={probe:0,values:[]},ym=new Map;function nk(e,t){let r=t%ga(e),n=e==null?"untyped":g(e),o=Rm({requiredLength:r+1,sequence:ym.get(n)??rk,space:e});ym.set(n,o);let a=o.values[r%o.values.length];if(a===void 0)throw new Error("arbitrary produced no sample");return a}function Rm({requiredLength:e,sequence:t,space:r}){if(t.values.length>=e||t.probe===Xx)return t;let n=ok(r,t.probe),o=t.values.some(a=>Object.is(a.value,n.value))?t.values:[...t.values,n];return Rm({requiredLength:e,sequence:{probe:t.probe+1,values:o},space:r})}function ok(e,t){let r=br.value({nullable:!1,seed:String(Zx+t),space:e,type:e==null?"string":To(e),valueSpace:e?.name??"explore.untyped"});if(r===null)throw new Error("non-null exploration arbitrary produced null");return{value:r}}function ak(e,t){return Object.values(t).reduce((r,n)=>n==null?r:new Map([...r,[n.name,(r.get(n.name)??0)+1]]),e)}import{createHash as Dm}from"crypto";import{performance as Ur}from"perf_hooks";import{createHash as Em}from"crypto";function ba({corpus:e,logical:t,patterns:r,startingLogical:n,steps:o}){let a=o.map(i=>wm({corpus:e,step:i}));return{actionKinds:a.map(i=>i.effectStep.action.kind),actorStates:a.map(i=>i.requiredState.actor.kind),cardinalityShapes:t.constraints.flatMap(i=>uk(i)),effectKinds:a.flatMap(i=>i.steps.flatMap(s=>s.effects.map(l=>l.kind))),parameterShapes:o.flatMap(i=>sk({step:i,transition:wm({corpus:e,step:i})})),patterns:[...r].toSorted((i,s)=>i.localeCompare(s)),relationShapes:t.constraints.map(i=>g(vm(i))),routeShapes:a.flatMap(i=>[...i.requiredState.scalars.values()].flatMap(s=>s.subject.kind==="path"||s.subject.kind==="query"||s.subject.kind==="hash"||s.subject.kind==="title"?[g(s.subject)]:[])),startingStateShapes:n.constraints.map(i=>g(vm(i))),surfaceShapes:a.flatMap(i=>[...i.requiredState.scalars.values()].flatMap(s=>s.subject.kind==="element"?[g({locator:s.subject.locator,state:s.subject.state})]:[])),transitionIds:o.map(i=>i.transitionId),transitionPairs:ik(o),workflowRefs:a.map(i=>i.test)}}function vm(e){return e.kind==="closed-record"?{kind:e.kind,records:xm(e.operations.length),selector:e.selector}:e}function ik(e){return e.slice(1).map((t,r)=>{let n=e[r];if(n===void 0)throw new Error("coverage transition pair has no preceding step");return`${n.transitionId}:${t.transitionId}`})}function sk({step:e,transition:t}){return Object.entries(e.params).toSorted(([r],[n])=>r.localeCompare(n)).map(([r,n])=>g({name:r,shape:lk({space:t.paramSpaces[r],value:n})}))}function lk({space:e,value:t}){if(e==null)return{kind:"untyped",value:t};switch(e.kind){case"enum":case"boolean":return{kind:e.kind,value:t};case"number":return{band:ck({max:e.max,min:e.min,value:t}),kind:"number"};case"datetime":case"pattern":return{kind:e.kind,probe:dk(t),space:e.name}}}function Ra(e){return Em("sha256").update(g(e)).digest("base64url")}function ck({max:e,min:t,value:r}){if(typeof r!="number")throw new TypeError("number parameter space produced a non-number value");if(r===t)return"minimum";if(r===e)return"maximum";let n=e-t,o=n===0?0:(r-t)/n;return o<1/3?"lower":o>2/3?"upper":"middle"}function dk(e){let r=Em("sha256").update(g(e)).digest()[0];if(r===void 0)throw new Error("parameter probe hash was empty");return r%8}function uk(e){return e.kind==="required-record"?[`${e.selector.source}:${e.selector.path.join(".")}:present`]:e.kind==="optional-record"?[`${e.selector.source}:${e.selector.path.join(".")}:optional`]:e.kind==="absent-record"?[`${e.selector.source}:${e.selector.path.join(".")}:absent`]:e.kind==="closed-record"?[`${e.selector.source}:${e.selector.path.join(".")}:${xm(e.operations.length)}`]:[]}function xm(e){return e===0?"empty":e===1?"one":"many"}function wm({corpus:e,step:t}){let r=e.find(n=>n.id===t.transitionId);if(r==null)throw new Error(`planner transition ${t.transitionId} is missing`);return r}function _r({corpus:e,steps:t}){let r=t.flatMap(a=>{let i=e.find(s=>s.id===a.transitionId);return i==null?[]:[i]}),n=r.flatMap(a=>a.steps.flatMap(i=>i.effects.map(s=>s.kind))),o=r.map(a=>a.effectStep.action.kind);return[...Bt({condition:pk({kinds:n,ordered:["create-record","update-selected-records","delete-selected-records"]}),pattern:"create-modify-delete"}),...Bt({condition:n.filter(a=>a==="create-record").length>=2&&n.includes("delete-selected-records"),pattern:"parent-child-delete"}),...Bt({condition:o.includes("actor")&&o.some(a=>a!=="actor"&&a!=="goto"),pattern:"role-attempt"}),...Bt({condition:n.includes("transform")&&o.length>=2,pattern:"threshold-gate"}),...Bt({condition:n.includes("delete-selected-records")&&o.includes("goto"),pattern:"last-record-navigation"}),...Bt({condition:n.length>=3,pattern:"lifecycle"}),...Bt({condition:new Set(r.map(a=>a.test)).size>=2,pattern:"cross-workflow"}),...Bt({condition:fk({actionKinds:o,effectKinds:n}),pattern:"overlay-mutate-close"})]}function pk({kinds:e,ordered:t}){return t.reduce((r,n)=>{if(r==null)return null;let o=e.indexOf(n,r);return o===-1?null:o+1},0)!=null}function fk({actionKinds:e,effectKinds:t}){return e.filter(r=>r==="click").length>=2&&t.length>0&&e.length>=3}function Bt({condition:e,pattern:t}){return e?[t]:[]}function km({corpus:e,node:t,transition:r}){return t.steps.length===0||!mk({corpus:e,node:t,transition:r})||t.causalTransitionIds.has(r.id)?t.causalTransitionIds:new Set([...t.causalTransitionIds,r.id])}function mk(e){return yk(e)||gk(e)||Sk(e)}function yk({node:e,transition:t}){return hk(t).some(r=>{let n=z(r);return e.startingPoint.env.has(n)!==e.state.base.has(n)||e.startingPoint.env.get(n)!==e.state.base.get(n)})}function hk(e){return[...new Set([...e.whenSteps.flatMap(t=>Ho(t)),...Pr(e.requiredState),...Jo(e.logicalRequiredState)])]}function gk({node:e,transition:t}){if(t.requiredState.actor.kind==="any")return!1;let r=Y(e.startingPoint.snapshot.scalars,{kind:"actor"}),n=Y(e.state.snapshot.scalars,{kind:"actor"});return r!==n}function Sk({corpus:e,node:t,transition:r}){return t.steps.some(n=>{let o=e.find(i=>i.id===n.transitionId);if(o==null)throw new Error(`causal transition ${n.transitionId} is missing`);let a=o.steps.flatMap(i=>i.effects.map(s=>s.selector));return r.logicalRequiredState.some(i=>a.some(s=>Gs(s,i.selector)))})}import{createHash as bk}from"crypto";var Cm=new WeakMap,Am=new WeakMap;function Pm(e){let t=Am.get(e);if(t!=null)return t;let r=ml({base:[...e.state.base].toSorted(([n],[o])=>n.localeCompare(o)),logical:e.state.logical.constraints,parameters:hm(e.parameters),snapshot:Ft(e.state.snapshot)});return Am.set(e,r),r}function Om(e){let t=Cm.get(e);if(t!=null)return t;let r=ml({state:Pm(e),visited:[...e.visited].toSorted((n,o)=>n.localeCompare(o))});return Cm.set(e,r),r}function Mm({node:e,params:t,transitionId:r}){return ml({params:t,state:Pm(e),transitionId:r})}function ml(e){return bk("sha256").update(g(e)).digest("base64url")}function Tm(e){let{params:t,patterns:r,steps:n}=e,o=wa(n,t.corpus),a=Lm({causalLinks:e.causalLinks,steps:n,transitions:o}),i=va({corpus:t.corpus,targetId:t.agenda.primaryTransitionId,transitions:o}),s=t.agenda.secondaryTransitionId==null?0:va({corpus:t.corpus,targetId:t.agenda.secondaryTransitionId,transitions:o});return[n.some(l=>l.transitionId===t.agenda.primaryTransitionId)?1:0,i,t.agenda.secondaryTransitionId!=null&&n.some(l=>l.transitionId===t.agenda.secondaryTransitionId)?1:0,s,r.includes(t.agenda.pattern)?1:0,a.causalLinks,a.uniqueInteractions,a.uniquePairs,a.effectKinds,a.deleteEffect,a.tests,-a.postEntryGotos]}function Im(e){let t=wa(e.steps,e.params.corpus),r=Lm({causalLinks:e.causalLinks,steps:e.steps,transitions:t});return[e.steps.length,r.causalLinks,r.uniqueInteractions,r.uniquePairs,r.effectKinds,r.deleteEffect,r.tests,-r.postEntryGotos]}function yl(e,t){let r=hl({index:0,left:e.searchPriority,right:t.searchPriority});return r===0?e.tie.localeCompare(t.tie):r}function $n(e,t){let r=hl({index:0,left:e.selectionPriority,right:t.selectionPriority});return r===0?e.tie.localeCompare(t.tie):r}function jn(e,t){return e.steps.some(r=>r.transitionId===t)}function va({corpus:e,targetId:t,transitions:r}){let n=e.find(o=>o.id===t);if(n==null)throw new Error(`exploration target transition ${t} is missing`);return r.filter(o=>o.test===n.test&&o.index<=n.index).reduce((o,a)=>Math.max(o,a.index+1),0)}function wa(e,t){return e.map(r=>{let n=t.find(o=>o.id===r.transitionId);if(n==null)throw new Error(`exploration transition ${r.transitionId} is missing`);return n})}function hl({index:e,left:t,right:r}){let n=t[e],o=r[e];if(n===void 0&&o===void 0)return 0;if(n===void 0||o===void 0)throw new Error("exploration candidate priorities have different lengths");let a=o-n;return a===0?hl({index:e+1,left:t,right:r}):a}function Lm({causalLinks:e,steps:t,transitions:r}){let n=r.filter(a=>a.effectStep.action.kind!=="goto"),o=r.flatMap(a=>a.steps.flatMap(i=>i.effects.map(s=>s.kind)));return{causalLinks:e,deleteEffect:o.includes("delete-selected-records")?1:0,effectKinds:new Set(o).size,postEntryGotos:r.slice(1).filter(a=>a.effectStep.action.kind==="goto").length,tests:new Set(r.map(a=>a.test)).size,uniqueInteractions:new Set(n.map(a=>a.id)).size,uniquePairs:new Set(t.slice(1).flatMap((a,i)=>{let s=t[i]?.transitionId;return s==null||s===a.transitionId?[]:[`${s}:${a.transitionId}`]})).size}}var Bm=4096,Rk=8,vk=32,wk=2,Nm=4;function $m(e){let t=e.startingPoints.map(r=>Mk(r));return jm({params:e,state:{candidates:[],depths:[],expanded:0,frontier:t,rejectedCycles:0,stopReason:void 0,telemetry:{beamMs:0,candidateMs:0,expansionMs:0}}})}function jm({params:e,state:t}){let r=xk({params:e,state:t});if(r!=null)return{...t,stopReason:r};let n=Ur.now(),o=kk({frontier:t.frontier,limit:Bm-t.expanded,params:e}),a=Ur.now()-n,i=o.nodes,s=i.filter(b=>!b.repeatedVisit),l=t.rejectedCycles+i.length-s.length,c=Ur.now(),d=s.map(b=>Nk({node:b,params:e})),u=Lk({entries:d,existing:t.candidates,primaryTransitionId:e.agenda.primaryTransitionId}),f=Ur.now()-c,y=Ur.now(),m=u.some(b=>Ek({candidate:b,params:e})),h=Fk({entries:d,params:e,width:m?wk:Rk}),p=Ur.now()-y;return jm({params:e,state:{candidates:u,depths:[...t.depths,{depth:t.frontier[0]?.steps.length??0,expanded:i.length,parameterAttempts:o.parameterAttempts,primaryProgress:h.reduce((b,w)=>Math.max(b,va({corpus:e.corpus,targetId:e.agenda.primaryTransitionId,transitions:wa(w.steps,e.corpus)})),0),retained:h.length,rulesConsidered:o.rulesConsidered}],expanded:t.expanded+i.length,frontier:h,rejectedCycles:l,stopReason:void 0,telemetry:{beamMs:t.telemetry.beamMs+p,candidateMs:t.telemetry.candidateMs+f,expansionMs:t.telemetry.expansionMs+a}}})}function Ek({candidate:e,params:t}){let r=e.steps.some(o=>o.transitionId===t.agenda.primaryTransitionId),n=t.agenda.secondaryTransitionId==null||e.steps.some(o=>o.transitionId===t.agenda.secondaryTransitionId);return r&&n&&e.patterns.includes(t.agenda.pattern)}function xk({params:e,state:t}){if(t.frontier.length===0)return"frontierExhausted";let r=t.frontier[0]?.steps.length;return r!=null&&r>=e.strategy.maxAttemptLength?"targetReached":t.expanded>=Bm?"budgetExhausted":void 0}function kk({frontier:e,limit:t,params:r}){if(t<=0||e.length===0)return{nodes:[],parameterAttempts:0,rulesConsidered:0};let n=Math.max(1,Math.floor(t/e.length)),o=e.map(a=>Ck({node:a,params:r})).reduce((a,i)=>({nodes:[...a.nodes,...i.nodes.slice(0,n)].slice(0,t),parameterAttempts:a.parameterAttempts+i.parameterAttempts,rulesConsidered:a.rulesConsidered+i.rulesConsidered}),{nodes:[],parameterAttempts:0,rulesConsidered:0});return{...o,nodes:o.nodes.slice(0,t)}}function Ck({node:e,params:t}){let r=Lr({logical:e.state.logical,model:t.facts,snapshot:e.state.snapshot}),n=Ak({corpus:Pk({node:e,params:t}),node:e,proven:r});return{nodes:n.runs.map(a=>{let i=Tk(t.corpus,a.transitionId),s=km({corpus:t.corpus,node:e,transition:i}),l=Mm({node:e,params:a.params,transitionId:a.transitionId}),c=[...e.steps,{params:a.params,transitionId:a.transitionId}];return{causalTransitionIds:s,parameters:Dt({action:i,params:a.params,state:e.parameters}),repeatedVisit:e.visited.has(l),startingPoint:e.startingPoint,state:a.stepRun.next,steps:c,visited:new Set([...e.visited,l])}}),parameterAttempts:n.parameterAttempts,rulesConsidered:n.rulesConsidered}}function Ak({corpus:e,node:t,proven:r}){let n=t.steps.length===0,o=e.filter(l=>l.effectStep.action.kind==="goto");if(n)return gl({corpus:o,limit:Nm,node:t,proven:r});let a=e.filter(l=>l.effectStep.action.kind!=="goto"),i=gl({corpus:a,limit:Nm,node:t,proven:r});if(i.runs.length>0)return i;let s=gl({corpus:o,limit:1,node:t,proven:r});return{parameterAttempts:i.parameterAttempts+s.parameterAttempts,rulesConsidered:i.rulesConsidered+s.rulesConsidered,runs:[...i.runs,...s.runs]}}function gl({corpus:e,limit:t,node:r,proven:n}){return im(e,{...r.state,snapshot:n},{limit:t,attemptsFor:o=>Vr({action:o,state:r.parameters}),paramsFor:(o,a)=>or({action:o,attempt:a,state:r.parameters})})}function Pk({node:e,params:t}){let r=Fm({corpus:t.corpus,targetId:t.agenda.primaryTransitionId}),n=t.agenda.secondaryTransitionId==null?[]:Fm({corpus:t.corpus,targetId:t.agenda.secondaryTransitionId}),o=new Set([...r,...n].map(s=>s.id)),a=t.corpus.filter(s=>!o.has(s.id)),i=Ok({length:a.length,node:e,seed:t.assignmentSeed});return[...r,...n,...a.slice(i),...a.slice(0,i)]}function Fm({corpus:e,targetId:t}){let r=e.find(n=>n.id===t);if(r==null)throw new Error(`exploration target transition ${t} is missing`);return e.filter(n=>n.test===r.test&&n.index<=r.index).toSorted((n,o)=>n.index-o.index)}function Ok({length:e,node:t,seed:r}){if(e===0)return 0;let n=Dm("sha256").update(`${r}:${t.startingPoint.name}:${Ft(t.state.snapshot)}`).digest("hex");return Number.parseInt(n.slice(0,8),16)%e}function Mk(e){return{causalTransitionIds:new Set,parameters:e.parameters,repeatedVisit:!1,startingPoint:e,state:{base:e.env,deferred:Ye,logical:e.logical,snapshot:e.snapshot},steps:[],visited:new Set}}function Tk(e,t){let r=e.find(n=>n.id===t);if(r==null)throw new Error(`exploration transition ${t} is missing`);return r}function Ik({node:e,params:t}){let r=_r({corpus:t.corpus,steps:e.steps}),n=ba({corpus:t.corpus,logical:e.state.logical,patterns:r,startingLogical:e.startingPoint.logical,steps:e.steps}),o=Ra(n);return{causalLinks:e.causalTransitionIds.size,coverageSignature:o,patterns:r,searchPriority:Tm({causalLinks:e.causalTransitionIds.size,params:t,patterns:r,steps:e.steps}),selectionPriority:Im({causalLinks:e.causalTransitionIds.size,params:t,patterns:r,steps:e.steps}),startingPoint:e.startingPoint,steps:e.steps,tie:Dm("sha256").update(`${t.assignmentSeed}:${o}`).digest("base64url")}}function Vm(){return{candidates:[],depths:[],expanded:0,frontier:[],rejectedCycles:0,stopReason:void 0,telemetry:{beamMs:0,candidateMs:0,expansionMs:0}}}function Lk({entries:e,existing:t,primaryTransitionId:r}){return[...[...t,...e.map(a=>a.candidate)].filter(a=>jn(a,r)).reduce((a,i)=>{let s=a.get(i.coverageSignature),l=s==null||$n(i,s)<0?i:s;return new Map([...a,[i.coverageSignature,l]])},new Map).values()].toSorted($n).slice(0,vk)}function Nk({node:e,params:t}){return{candidate:Ik({node:e,params:t}),node:e}}function Fk({entries:e,params:t,width:r}){return[...e.reduce((o,a)=>{let i=Dk({entry:a,params:t}),s=o.get(i),l=s==null||yl(a.candidate,s.candidate)<0?a:s;return new Map([...o,[i,l]])},new Map).values()].toSorted((o,a)=>yl(o.candidate,a.candidate)).slice(0,r).map(o=>o.node)}function Dk({entry:e,params:t}){let r=t.agenda.secondaryTransitionId;return g({future:Om(e.node),patternReached:e.candidate.patterns.includes(t.agenda.pattern),primaryReached:e.node.steps.some(n=>n.transitionId===t.agenda.primaryTransitionId),secondaryReached:r==null?"none":e.node.steps.some(n=>n.transitionId===r)})}function xa(e){if(e.startingPoints.length===0||e.corpus.length===0)return bl({agenda:e.agenda,reason:"modelEmpty",rejectedReplays:0,searched:Vm(),startingPoints:e.startingPoints});let t=Ea.now(),r=$m(e),n=Ea.now()-t,o=Ea.now(),a=Bk({params:e,searched:r});return{...a,telemetry:{...a.telemetry,searchMs:n,selectionMs:Ea.now()-o}}}function _m({corpus:e,facts:t,startingPoint:r,steps:n}){let o={base:r.env,deferred:Ye,logical:r.logical,snapshot:r.snapshot};return n.reduce((i,s,l)=>{if(i.result.kind==="unrunnable")return i;let c=e.find(y=>y.id===s.transitionId);if(c==null||l===0&&c.effectStep.action.kind!=="goto")return{...i,result:{kind:"unrunnable",stepIndex:l}};let d=Lr({logical:i.result.state.logical,model:t,snapshot:i.result.state.snapshot}),u={...s.params},f=rr(c,{...i.result.state,snapshot:d},u);return f==null?{...i,result:{kind:"unrunnable",stepIndex:l}}:{parameters:Dt({action:c,params:u,state:i.parameters}),result:{kind:"legal",state:f.next}}},{parameters:r.parameters,result:{kind:"legal",state:o}}).result}function Bk({params:e,searched:t}){let r=t.candidates.toSorted($n),n=$k({agenda:e.agenda,candidates:r}),o=n.filter(d=>!e.reservedSignatures.has(d.candidate.coverageSignature)),a=Sl({params:e,selections:o});if(a.selection!=null)return{kind:"candidate",startingPoint:a.selection.candidate.startingPoint.name,steps:a.selection.candidate.steps,telemetry:qm(t),trace:Wm({agenda:e.agenda,rejectedReplays:a.rejected,searched:t,selectedCausalTransitions:a.selection.candidate.causalLinks,selectedCoverageSignature:a.selection.candidate.coverageSignature,selectedSteps:a.selection.candidate.steps.length,selectionTier:a.selection.tier,startingPoints:e.startingPoints})};let i=n.filter(d=>e.reservedSignatures.has(d.candidate.coverageSignature)),s=Sl({params:e,selections:i}),l=a.rejected+s.rejected;if(s.selection!=null)return bl({agenda:e.agenda,reason:"allReserved",rejectedReplays:l,searched:t,startingPoints:e.startingPoints});let c=e.corpus.some(d=>d.effectStep.action.kind==="goto");return bl({agenda:e.agenda,reason:jk({hasEntry:c,searched:t}),rejectedReplays:l,searched:t,startingPoints:e.startingPoints})}function $k({agenda:e,candidates:t}){let r=s=>jn(s,e.primaryTransitionId),n=s=>e.secondaryTransitionId!=null&&jn(s,e.secondaryTransitionId),o=s=>s.patterns.includes(e.pattern),i=[{tier:"primary-secondary-pattern",accepts:s=>r(s)&&n(s)&&o(s)},{tier:"primary-pattern",accepts:s=>r(s)&&o(s)},{tier:"primary-secondary",accepts:s=>r(s)&&n(s)},{accepts:r,tier:"primary"}].flatMap(s=>t.filter(l=>s.accepts(l)).map(l=>({candidate:l,tier:s.tier})));return i.filter((s,l)=>i.findIndex(c=>c.candidate.coverageSignature===s.candidate.coverageSignature)===l)}function Sl({params:e,selections:t}){let[r,...n]=t;if(r==null)return{rejected:0,selection:void 0};if(_m({corpus:e.corpus,facts:e.facts,startingPoint:r.candidate.startingPoint,steps:r.candidate.steps}).kind==="legal")return{rejected:0,selection:r};let a=Sl({params:e,selections:n});return{rejected:a.rejected+1,selection:a.selection}}function bl({agenda:e,reason:t,rejectedReplays:r,searched:n,startingPoints:o}){return{kind:"no-candidate",reason:t,telemetry:qm(n),trace:Wm({agenda:e,rejectedReplays:r,searched:n,selectedCausalTransitions:void 0,selectedCoverageSignature:void 0,selectedSteps:void 0,selectionTier:void 0,startingPoints:o})}}function Um(e){return[{kind:"agenda",pattern:e.agenda.pattern,primaryTransitionId:e.agenda.primaryTransitionId,secondaryTransitionId:e.agenda.secondaryTransitionId},{count:e.envelopes.length,kind:"envelope-candidates",refs:e.envelopes},...e.depths.map(t=>({...t,kind:"beam-depth"})),{count:e.rejectedCycles,kind:"cycle-rejections"},{count:e.rejectedReplays,kind:"replay-rejections"},{kind:"search-stop",reason:e.searchStopReason},{candidates:e.candidates,causalTransitions:e.selectedCausalTransitions,coverageSignature:e.selectedCoverageSignature,kind:"selection",steps:e.selectedSteps,tier:e.selectionTier}]}function Wm({agenda:e,rejectedReplays:t,searched:r,selectedCausalTransitions:n,selectedCoverageSignature:o,selectedSteps:a,selectionTier:i,startingPoints:s}){return{agenda:e,candidates:r.candidates.length,depths:r.depths,envelopes:s.map(l=>l.name),expanded:r.expanded,rejectedCycles:r.rejectedCycles,rejectedReplays:t,searchStopReason:r.stopReason,selectedCausalTransitions:n,selectedCoverageSignature:o,selectedSteps:a,selectionTier:i}}function qm(e){return{...e.telemetry,searchMs:0,selectionMs:0}}function jk({hasEntry:e,searched:t}){switch(t.stopReason){case"budgetExhausted":return"budgetExhausted";case"frontierExhausted":return e?"noLegalExpansion":"noEntry";case"targetReached":return"trailLengthExhausted";case void 0:throw new Error("exploration search did not record why it stopped")}}function zm({changes:e,next:t,previous:r,state:n}){return Object.entries(e).every(([o,a])=>{let i=t[o];if(i===void 0)return!1;if(a.kind==="transform"){let s=r[o];return s!==void 0&&vt(a.relation,{after:i,before:s,parameters:{},records:{},state:n})}return a.kind==="value"&&g(a.value)===g(i)})}function ka({after:e,before:t}){let r=Object.keys(e).filter(a=>t[a]===void 0).flatMap(a=>{let i=e[a];return i===void 0?[]:[i]}),n=Object.keys(t).filter(a=>e[a]===void 0).flatMap(a=>{let i=t[a];return i===void 0?[]:[i]}),o=Object.keys(t).filter(a=>{let i=t[a],s=e[a];return i!==void 0&&s!==void 0&&g(i)!==g(s)});return{added:r,changed:o,removed:n}}function Rl(e,t){return x(e)?Object.entries(t).every(([r,n])=>{let o=e[r];return o!==void 0&&g(o)===g(n)}):!1}function Hm(e){let t=e.effects.filter(r=>r.kind==="delete-selected-records"||r.kind==="update-selected-records");return Vk({...e,selected:t})}function Vk({actual:e,before:t,effects:r,pre:n,selected:o}){if(!e.present||!t.present||!x(e.value)||!x(t.value))return!1;let a=e.value,i=t.value,s=o.flatMap(f=>_k({effect:f,pre:n}));if(Uk(s))return!1;let l=ka({after:a,before:i}),c=s.flatMap(f=>f.effect.kind==="delete-selected-records"?[f.key]:[]),d=s.filter(f=>f.effect.kind==="update-selected-records"),u=r.filter(f=>f.kind==="create-record");return l.added.length===u.length&&Ym({effects:u,rows:l.added})&&Wk({after:a,before:i,expected:c})&&l.changed.every(f=>d.some(y=>y.key===f))&&d.every(f=>zk({after:a,before:i,effect:f.effect,key:f.key,state:n}))}function _k({effect:e,pre:t}){return $o(e.selection,{after:void 0,before:void 0,parameters:{},records:{},state:t}).map(r=>({effect:e,key:r.key}))}function Uk(e){return e.some((t,r)=>e.slice(r+1).some(n=>{if(t.key!==n.key)return!1;if(t.effect.kind==="delete-selected-records"||n.effect.kind==="delete-selected-records")return!0;let o=t.effect.changes,a=n.effect.changes;return Object.keys(o).some(i=>i in a)}))}function Wk({after:e,before:t,expected:r}){let n=Object.keys(t).filter(o=>e[o]===void 0).toSorted((o,a)=>o.localeCompare(a));return g(n)===g([...r].toSorted((o,a)=>o.localeCompare(a)))}function Jm({after:e,before:t,bindings:r,effects:n}){return Gm({after:e,before:t,bindings:r,remaining:n.filter(o=>o.kind==="create-record"),used:new Set})}function Gm({after:e,before:t,bindings:r,remaining:n,used:o}){if(n.length===0)return r;let a=n.filter(s=>Jk({bindings:r,effect:s})).map(s=>({candidates:Hk({after:e,before:t,effect:s}).filter(l=>!o.has(l.id)&&Zm({bindings:r,effect:s,row:l.value})),effect:s})),i=qk(a);return i==null?r:Gm({after:e,before:t,bindings:{...r,[i.effect.as]:i.candidate.value},remaining:n.filter(s=>s!==i.effect),used:new Set([...o,i.candidate.id])})}function qk(e){let t=e.find(n=>n.candidates.length===1),r=t?.candidates[0];return t!=null&&r!=null?{candidate:r,effect:t.effect}:e.flatMap(n=>n.candidates.filter(o=>Kk({candidate:o,choices:e})).map(o=>({candidate:o,effect:n.effect})))[0]}function zk({after:e,before:t,effect:r,key:n,state:o}){let a=t[n],i=e[n];if(a===void 0||i===void 0||!x(a)||!x(i)||!zm({changes:r.changes,next:i,previous:a,state:o}))return!1;let s=Object.fromEntries(Object.keys(r.changes).flatMap(l=>{let c=i[l];return c===void 0?[]:[[l,c]]}));return g(i)===g({...a,...s})}function Kk({candidate:e,choices:t}){return t.filter(r=>r.candidates.some(n=>n.id===e.id)).length===1}function Hk({after:e,before:t,effect:r}){let n=Km(e,r.selector),o=Km(t,r.selector);if(!n.present||!o.present||!x(n.value)||!x(o.value))return[];let a=n.value,i=o.value,s=g(r.selector);return Object.keys(a).filter(l=>i[l]===void 0).flatMap(l=>{let c=a[l];return c===void 0?[]:[{id:`${s}:${l}`,value:c}]})}function Ym({effects:e,rows:t}){let[r,...n]=e;return r==null?t.length===0:t.some((o,a)=>Zm({bindings:{},effect:r,row:o})?Ym({effects:n,rows:t.filter((i,s)=>s!==a)}):!1)}function Zm({bindings:e,effect:t,row:r}){return x(r)?Object.entries(t.fields).every(([n,o])=>{let a=r[n];if(o.kind==="absent")return a===void 0;if(o.kind==="generated")return a!==void 0;let i=Xm({bindings:e,expression:o});return i.present&&a!==void 0&&g(a)===g(i.value)}):!1}function Jk({bindings:e,effect:t}){return Object.values(t.fields).every(r=>r.kind==="absent"||r.kind==="generated"||Xm({bindings:e,expression:r}).present)}function Xm({bindings:e,expression:t}){if(t.kind==="value")return{present:!0,value:t.value};if(t.kind==="transform"||t.kind==="absent"||t.kind==="generated")return{present:!1};let r=e[t.record];return r===void 0?{present:!1}:vl(r,t.path)}function vl(e,t){let[r,...n]=t;if(r==null)return{present:!0,value:e};if(!x(e))return{present:!1};let o=e[r];return o===void 0?{present:!1}:vl(o,n)}function Km(e,t){let r=e[t.source];return r===void 0?{present:!1}:vl(r,t.path)}function Vn({observed:e,plan:t,pre:r}){let n=t.constraints.flatMap(s=>{let l=ar(r,s.selector);return ey(l,s)?[]:[{actual:l,constraint:s,kind:"constraint",selector:s.selector}]}),o=Yk({effects:t.effects,observed:e,pre:r}),i=Qk(r,e).filter(s=>!t.effects.some(l=>tC(l.selector,s.selector))).map(s=>({actual:s.after,before:s.before,kind:"unexpected-change",selector:s.selector}));return{mismatches:[...n,...o,...i],requiredStateHolds:n.length===0}}function ar(e,t){let r=e[t.source];return r===void 0?{present:!1}:ty(r,t.path)}function El({after:e,before:t,bindings:r,effects:n}){return Jm({after:e,before:t,bindings:r,effects:n})}function Gk({effect:e,observed:t,pre:r}){let n=ar(t,e.selector),o=ar(r,e.selector);return Xk({actual:n,before:o,effect:e,observed:t,pre:r})?[]:[{actual:n,before:o,effect:e,kind:"effect",selector:e.selector,targetKeys:Qm({effect:e,pre:r})}]}function Yk({effects:e,observed:t,pre:r}){let n=e.filter(s=>s.kind==="create-record"||s.kind==="delete-selected-records"||s.kind==="update-selected-records"),o=e.filter(s=>s.kind!=="create-record"&&s.kind!=="delete-selected-records"&&s.kind!=="update-selected-records").flatMap(s=>Gk({effect:s,observed:t,pre:r})),i=[...new Map(n.map(s=>[g(s.selector),s.selector])).values()].flatMap(s=>{let l=n.filter(u=>g(u.selector)===g(s)),c=ar(t,s),d=ar(r,s);return Hm({actual:c,before:d,effects:l,observed:t,pre:r})?[]:l.map(u=>({actual:c,before:d,effect:u,kind:"effect",selector:s,targetKeys:Qm({effect:u,pre:r})}))});return[...o,...i]}function Qm({effect:e,pre:t}){return e.kind!=="delete-selected-records"&&e.kind!=="update-selected-records"?[]:$o(e.selection,{after:void 0,before:void 0,parameters:{},records:{},state:t}).map(r=>r.key)}function xl(e,t){return t.every(r=>ey(ar(e,r.selector),r))}function ey(e,t){if(t.kind==="absent-path")return!e.present;if(t.kind==="equals")return wl(e,t.value);if(!e.present||!x(e.value))return!1;let r=Object.values(e.value);return t.kind==="required-record"?r.some(n=>Rl(n,t.fields)):t.kind==="absent-record"?r.every(n=>!Rl(n,t.fields)):Zk(r,t.rows)}function Zk(e,t){let r=n=>n.map(o=>g(o)).toSorted((o,a)=>o.localeCompare(a));return g(r(e))===g(r(t))}function Xk({actual:e,before:t,effect:r,pre:n}){if(r.kind==="set")return wl(e,r.value);if(r.kind==="transform")return e.present&&t.present&&vt(r.relation,{after:e.value,before:t.value,parameters:{},records:{},state:n});if(r.kind==="create-path")return!t.present&&wl(e,r.value);if(r.kind==="delete-path")return t.present&&!e.present;throw new TypeError("record-effect-group-required")}function ty(e,t){let[r,...n]=t;if(r==null)return{present:!0,value:e};if(!x(e))return{present:!1};let o=e[r];return o===void 0?{present:!1}:ty(o,n)}function Qk(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].toSorted((n,o)=>n.localeCompare(o)).flatMap(n=>ry({after:Ca(t[n]),before:Ca(e[n]),selector:{path:[],source:n}}))}function ry({after:e,before:t,selector:r}){if(!t.present||!e.present)return eC(t,e)?[]:[{after:e,before:t,selector:r}];if(!x(t.value)||!x(e.value))return kl(t.value,e.value)?[{after:e,before:t,selector:r}]:[];let n=t.value,o=e.value;return[...new Set([...Object.keys(n),...Object.keys(o)])].toSorted((i,s)=>i.localeCompare(s)).flatMap(i=>ry({after:Ca(o[i]),before:Ca(n[i]),selector:{path:[...r.path,i],source:r.source}}))}function eC(e,t){return!e.present||!t.present?e.present===t.present:!kl(e.value,t.value)}function kl(e,t){return g(e)!==g(t)}function Ca(e){return e===void 0?{present:!1}:{present:!0,value:e}}function tC(e,t){return e.source===t.source&&e.path.every((r,n)=>t.path[n]===r)}function wl(e,t){return e.present&&!kl(e.value,t)}function Oa({bindings:e,selection:t}){let r=Cl(t),n=bu(t).find(o=>r.has(o.record)?!1:!Pa({bindings:e,reference:o}).ok);return n!=null?{ok:!1,path:n.path,record:n.record}:{ok:!0,selection:vu({selection:t,map:o=>{if(r.has(o.record))return o;let a=Pa({bindings:e,reference:o});if(!a.ok)throw new TypeError("state-selection-reference-unresolved");return{kind:"value",value:a.value}}})}}function Ma({bindings:e,relation:t}){let r=new Set(Aa(t)),n=Ru(t).find(o=>!r.has(o.record)&&!Pa({bindings:e,reference:o}).ok);return n!=null?{ok:!1,path:n.path,record:n.record}:{ok:!0,relation:Mo({relation:t,map:o=>rC({aliases:r,bindings:e,reference:o})})}}function Cl(e){return new Set([e.alias,...e.relation==null?[]:Aa(e.relation)])}function Aa(e){return e.kind==="not"?Aa(e.relation):e.kind==="and"||e.kind==="or"?e.relations.flatMap(t=>Aa(t)):e.kind==="exists"?[...Cl(e.selection)]:[...Wr(e.left),...Wr(e.right)]}function Wr(e){return e.kind==="count"?[...Cl(e.selection)]:e.kind==="add"?[...Wr(e.left),...Wr(e.right)]:e.kind==="concat"?e.values.flatMap(t=>Wr(t)):e.kind==="invert"?Wr(e.value):[]}function rC({aliases:e,bindings:t,reference:r}){if(e.has(r.record))return r;let n=Pa({bindings:t,reference:r});if(!n.ok)throw new TypeError("state-relation-reference-unresolved");return{kind:"value",value:n.value}}function Pa({bindings:e,reference:t}){let r=e[t.record];if(r===void 0)return{ok:!1};let n=ny({path:t.path,value:r});if(!n.ok)return n;let o=Le.safeParse(n.value);return o.success?{ok:!0,value:o.data}:{ok:!1}}function ny({path:e,value:t}){let[r,...n]=e;if(r==null)return{ok:!0,value:t};if(!x(t))return{ok:!1};let o=t[r];return o===void 0?{ok:!1}:ny({path:n,value:o})}var $t={};function Al({bindings:e,effects:t}){let r=t.flatMap(a=>Object.values(oy(a))).find(a=>a.kind==="reference"&&!Pl({bindings:e,expression:a}).present);if(r!=null&&r.kind==="reference")return{ok:!1,path:r.path,record:r.record};let n=t.flatMap(a=>a.kind==="delete-selected-records"||a.kind==="update-selected-records"?[Oa({bindings:e,selection:a.selection})]:[]).find(a=>!a.ok);if(n!=null)return{ok:!1,path:n.path,record:n.record};let o=nC(t).map(a=>Ma({bindings:e,relation:a})).find(a=>!a.ok);return o!=null?{ok:!1,path:o.path,record:o.record}:{effects:t.map(a=>oC({bindings:e,effect:a})),ok:!0}}function nC(e){return e.flatMap(t=>[...t.kind==="transform"?[t.relation]:[],...Object.values(oy(t)).flatMap(r=>r.kind==="transform"?[r.relation]:[])])}function oC({bindings:e,effect:t}){switch(t.kind){case"transform":return aC({bindings:e,effect:t});case"update-selected-records":return iC({bindings:e,effect:t});case"delete-selected-records":return sC({bindings:e,effect:t});case"create-record":return{...t,fields:lC({bindings:e,expressions:t.fields})};case"create-path":case"delete-path":case"set":return t}}function aC({bindings:e,effect:t}){let r=Ma({bindings:e,relation:t.relation});if(!r.ok)throw new TypeError("state-transform-reference-unresolved");return{...t,relation:r.relation}}function iC({bindings:e,effect:t}){let r=Oa({bindings:e,selection:t.selection});if(!r.ok)throw new TypeError("state-selection-reference-unresolved");return{...t,changes:cC({bindings:e,expressions:t.changes}),selection:r.selection}}function sC({bindings:e,effect:t}){let r=Oa({bindings:e,selection:t.selection});if(!r.ok)throw new TypeError("state-selection-reference-unresolved");return{...t,selection:r.selection}}function oy(e){return e.kind==="create-record"?e.fields:e.kind==="update-selected-records"?e.changes:{}}function lC({bindings:e,expressions:t}){return Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.kind!=="reference")return[r,n];let o=Pl({bindings:e,expression:n});if(!o.present)throw new TypeError("state-effect-reference-unresolved");return[r,{kind:"value",value:o.value}]}))}function cC({bindings:e,expressions:t}){return Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.kind==="transform"){let a=Ma({bindings:e,relation:n.relation});if(!a.ok)throw new TypeError("state-transform-reference-unresolved");return[r,{kind:"transform",relation:a.relation}]}if(n.kind!=="reference")return[r,n];let o=Pl({bindings:e,expression:n});if(!o.present)throw new TypeError("state-effect-reference-unresolved");return[r,{kind:"value",value:o.value}]}))}function Pl({bindings:e,expression:t}){let r=e[t.record];return r===void 0?{present:!1}:ay(r,t.path)}function ay(e,t){let[r,...n]=t;if(r==null)return{present:!0,value:e};if(!x(e))return{present:!1};let o=e[r];return o===void 0?{present:!1}:ay(o,n)}function jt(e){return new Map(Object.entries(e).flatMap(([t,r])=>dC({id:t,state:r})))}function dC({id:e,state:t}){return[[z(e),e],...Ol({prefix:e,value:t})]}function Ol({prefix:e,value:t}){return uC(t)?[[z(e),t]]:Array.isArray(t)?t.flatMap((r,n)=>Ol({prefix:`${e}.${String(n)}`,value:r})):x(t)?Object.entries(t).flatMap(([r,n])=>Ol({prefix:`${e}.${r}`,value:n})):[]}function uC(e){return e==null||["boolean","number","string"].includes(typeof e)}function qr(e,t){let r=De(e,Fe(t));if(U(r))throw new G(wt(e));return r}function iy(e,t){let r=At(e,Fe(t));if(U(r))throw new G(wt(e));return r}function _e(e,t){return e.by==="role"?{by:"role",name:e.name==null?void 0:qr(e.name,t),role:e.role}:e.by==="inside"?{by:"inside",scope:_e(e.scope,t),target:_e(e.target,t)}:e.by==="surface"?{by:"surface",container:_e(e.container,t),overlay:e.overlay}:e.by==="frame"?{by:"frame",element:_e(e.element,t)}:{by:"testId",value:qr(e.value,t)}}function Ta(e,t){return e.kind==="not"?{inner:Ta(e.inner,t),kind:"not"}:e.kind==="browser"?{key:e.key,kind:e.kind,value:e.value===null?null:qr(e.value,t)}:e.kind==="value"||e.kind==="text"?{kind:e.kind,locator:_e(e.locator,t),match:e.match,value:qr(e.value,t)}:{kind:e.kind,locator:_e(e.locator,t)}}function Ml(e,t){return{...e,locator:e.locator==null?void 0:_e(e.locator,t),target:e.target==null?void 0:_e(e.target,t),url:e.url==null?void 0:qr(e.url,t),value:e.value===void 0?void 0:iy(e.value,t)}}var Qe=class extends Error{name="AbortError";constructor(){super("aborted")}};function _n(e){return e instanceof Error&&e.name==="AbortError"}function he(e){if(e.aborted)throw new Qe}function et(e,t){return t.aborted?Promise.reject(new Qe):new Promise((r,n)=>{let o=()=>{clearTimeout(a),n(new Qe)},a=setTimeout(()=>{t.removeEventListener("abort",o),r()},e);t.addEventListener("abort",o,{once:!0})})}async function Tl({bindings:e,classify:t,initialState:r,observe:n,step:o},a){if(he(a),!xl(r,o.plan.constraints))return{kind:"required-state-unsatisfied",state:r};let i=await o.perform().match(()=>null,l=>l);if(i!=null)return{error:i,kind:"perform-failed",state:r};let s=Ce[o.sync];return ly({attempt:0,bindings:e,classify:t,deadline:Date.now()+s.timeoutMs,observe:n,plan:o.plan,pre:r,signal:a,sync:o.sync})}async function ly(e){he(e.signal);let t=await pC(e.observe);if(!t.ok)return{error:t.error,kind:"observe-failed",state:e.pre};let r=El({after:t.state,before:e.pre,bindings:e.bindings,effects:e.plan.effects}),n=Al({bindings:r,effects:e.plan.effects});if(!n.ok)return Date.now()>=e.deadline?{kind:"unresolved-reference",path:n.path,record:n.record,state:t.state}:sy(e);let o=Vn({observed:t.state,plan:{...e.plan,effects:[...n.effects]},pre:e.pre});return o.mismatches.length===0||Date.now()>=e.deadline?{bindings:r,kind:"observed",observation:o,state:t.state}:o.mismatches.some(i=>!fC(i)&&e.classify(i)==="strict")?{bindings:r,kind:"observed",observation:o,state:t.state}:sy(e)}function pC(e){return e().match(t=>({ok:!0,state:t}),t=>({error:t,ok:!1}))}async function sy(e){let t=Ce[e.sync];return await et(Yo(t,e.attempt),e.signal),ly({...e,attempt:e.attempt+1})}function fC(e){return e.kind==="constraint"?!1:g(e.actual)===g(e.before)}function zr(e){let t=Y(e.scalars,{kind:"path"});return typeof t=="string"?t:null}function Ia(e,t){switch(e.kind){case"step":return{checkId:$u(e.ref,t),kind:"step"};case"effect":return{checkId:Bu(t,e.effectIndex),kind:"step"};case"action":return{checkId:Fu(t),kind:"step"};case"frame":return{checkId:Du(t),kind:"step"};case"fact":return{factId:e.factId,kind:"fact"};case"dataRule":return{kind:"dataRule",ruleId:e.ruleId}}}function cy(e){return e.body.outcome.kind==="failed"}function Il(e){return g(e)}function Na({actual:e,pre:t,predicted:r,urlReset:n}){return mC(t.scalars,r.scalars,e.scalars,n)}function mC(e,t,r,n){let o=tt(r,v({kind:"path"}))!==void 0;return[...[...t.entries()].flatMap(([i,s])=>{if(s.subject.kind==="actor")return[];let l=tt(r,i),c=o&&Pt(s.subject)&&s.expect.expect!=="absent",d=l===void 0&&c?null:l;if(!s.declared||d===void 0||kn({got:d,subject:s.subject,want:s.expect})!=="fails")return[];let u=tt(e,i);return[{mismatch:{kind:"scalar-mismatch",subject:s.subject,sut:d,want:s.expect},pending:u!==void 0&&La(u,d)}]}),...yC(e,t,r,n),...hC(e,t,r)]}function tt(e,t){let r=e.get(t);if(!(r==null||r.expect.expect!=="is"))return U(r.expect.value)?void 0:r.expect.value}function La(e,t){return dy(e)===dy(t)}function dy(e){return e==null?"\u2205":JSON.stringify(e)}function yC(e,t,r,n){let o=v({kind:"path"});if(tt(r,o)===void 0)return[];let a=!La(tt(e,o),tt(r,o));return[...new Set([...e.keys(),...r.keys()])].flatMap(s=>{let l=(e.get(s)??r.get(s))?.subject;if(l==null||!Pt(l)||t.has(s))return[];let d=(a||n)&&l.kind!=="path"?null:tt(e,s)??null,u=tt(r,s)??null;return La(d,u)?[]:[{mismatch:{kind:"scalar-mismatch",subject:l,sut:u,want:{expect:"is",value:d}},pending:!1}]})}function hC(e,t,r){let n=v({kind:"actor"}),o=t.get(n);if(o==null)return[];let a=tt(r,n);if(kn({got:a,subject:{kind:"actor"},want:o.expect})!=="fails")return[];let i=tt(e,n);return[{mismatch:{kind:"scalar-mismatch",subject:{kind:"actor"},sut:a??null,want:o.expect},pending:i!==void 0&&La(i,a)}]}var Fa=()=>"strict";var Ll=()=>"strict";function Nl(e){return t=>t.kind==="effect"&&gC({effect:t.effect,eventualPaths:e})?"eventual":"strict"}function gC({effect:e,eventualPaths:t}){if(e.kind==="set"||e.kind==="transform")return SC({eventualPaths:t,selector:e.selector});if(e.kind!=="update-selected-records")return!1;let r=Object.keys(e.changes);return r.length>0&&r.every(n=>bC({eventualPaths:t,field:n,selector:e.selector}))}function SC({eventualPaths:e,selector:t}){return e.some(r=>wu({pattern:r,selector:t}))}function bC({eventualPaths:e,field:t,selector:r}){return e.some(n=>n.source===r.source&&n.recordKeyIndex===r.path.length&&RC(n.path,[...r.path,t]))}function RC(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function Fl({check:e,ephemeral:t,failure:r,rrwebIds:n,waitedMs:o}){let{check:a,negated:i}=uy(e,!1),s={ephemeral:t,rrwebIds:[...n],waitedMs:o};switch(a.kind){case"visible":case"unobstructed":case"disabled":case"enabled":case"focused":case"checked":case"expanded":case"pressed":return{...s,checkKind:a.kind,family:"element",negated:i,outcome:r==null?{kind:"passed"}:{kind:"failed",reason:wC(r)},subject:te(a.locator)};case"value":case"text":return{...s,checkKind:a.kind,expected:Oe(a.value),family:"content",match:a.match,negated:i,outcome:r==null?{kind:"passed"}:{kind:"failed",reason:EC(r)},subject:te(a.locator)};case"browser":return{...s,expected:vC(a.value),family:"scalar",negated:i,outcome:r==null?{kind:"passed"}:{kind:"failed",reason:xC(r)},subject:Zt(a.key),subjectKey:v(a.key),subjectKind:a.key.kind}}}function vC(e){return e===null?null:Oe(e)}function uy(e,t){return e.kind==="not"?uy(e.inner,!t):{check:e,negated:t}}function wC(e){return e.kind==="wrongContent"?{kind:"unclassified",message:py(e)}:e}function py(e){switch(e.kind){case"notFound":return"element not found";case"multipleMatches":return`matched ${String(e.count)} elements`;case"covered":return`covered by ${e.by}`;case"wrongState":return`element ${e.observed.value?"is":"is not"} ${e.observed.checkKind}`;case"wrongContent":return`content was "${e.observed}"`;case"unclassified":return e.message}}function EC(e){return e.kind==="wrongState"||e.kind==="covered"?{kind:"unclassified",message:py(e)}:e}function Dl({observed:e,passed:t,planned:r,waitedMs:n}){return{ephemeral:!1,expected:Bl(r.entry.expect),family:"scalar",negated:r.entry.expect.expect==="not",outcome:t?{kind:"passed"}:{kind:"failed",reason:{kind:"wrongScalar",observed:e}},rrwebIds:[],subject:Ln(r.entry.subject),subjectKey:v(r.entry.subject),subjectKind:r.entry.subject.kind,waitedMs:n}}function Bl(e){switch(e.expect){case"absent":return null;case"is":case"not":return U(e.value)?wt(e.value):Lt(e.value)}}function xC(e){return e.kind==="wrongContent"?{kind:"wrongScalar",observed:e.observed}:{kind:"wrongScalar",observed:null}}function Da({failure:e,waitedMs:t}){return{ephemeral:!1,family:"frame",outcome:e==null?{kind:"passed"}:{kind:"failed",reason:e},rrwebIds:[],waitedMs:t}}function $l({action:e,failure:t,rrwebIds:r,waitedMs:n}){return{actionKind:e.kind,ephemeral:!1,family:"action",outcome:t==null?{kind:"passed"}:{kind:"failed",reason:t},rrwebIds:[...r],subject:CC(e),value:AC(e),waitedMs:n}}function jl(e){let t=e.subject;return t.kind==="element"?kC(e,t):{expected:Bl(e.want),kind:"wrongScalar",observed:e.sut==null?null:Lt(e.sut),subject:Ln(t),subjectKey:v(t)}}function kC(e,t){let r=te(t.locator),n=v(t);return t.state==="text"||t.state==="value"?{checkKind:t.state,expected:Bl(e.want),kind:"wrongElementContent",observed:e.sut==null?null:Lt(e.sut),subject:r,subjectKey:n}:{checkKind:t.state,kind:"wrongElementState",observed:e.sut===!0,subject:r,subjectKey:n}}function CC(e){return e.locator!=null?te(e.locator):e.url!=null?Oe(e.url):""}function AC(e){return e.value!=null?wt(e.value):e.key!=null?e.key:null}async function Vl({onRemaining:e,pendingChecks:t,signal:r,windowStartMs:n}){let o=[...new Map(t.map(s=>[Il(s.source),s])).values()];e?.(o);let a=o.map((s,l)=>({ordinal:l,pendingCheck:s,result:(async()=>{let c=await IC({pendingCheck:s,signal:r,windowStartMs:n}),d=Date.now(),u=await s.targetIds();return{atMs:d,ordinal:l,outcome:c,pendingCheck:s,rrwebIds:u}})()})),i=await fy({onRemaining:e,pending:a});return{checks:i.flatMap(s=>s.outcome.kind==="error"?[]:[PC({atMs:s.atMs,outcome:s.outcome,pendingCheck:s.pendingCheck,rrwebIds:s.rrwebIds,windowStartMs:n})]),stepErrors:i.flatMap(s=>s.outcome.kind==="error"?[{atMs:s.atMs,error:s.outcome.error}]:[])}}async function fy({onRemaining:e,pending:t}){if(t.length===0)return[];let r=await Promise.race(t.map(({result:a})=>a)),n=t.filter(({ordinal:a})=>a!==r.ordinal);e?.(n.map(({pendingCheck:a})=>a));let o=await fy({onRemaining:e,pending:n});return[r,...o].toSorted((a,i)=>a.ordinal-i.ordinal)}function PC({atMs:e,outcome:t,pendingCheck:r,rrwebIds:n,windowStartMs:o}){let a=Math.max(0,e-o);return{atMs:e,body:Fl({check:r.source.check,ephemeral:r.ephemeral,failure:OC(t),rrwebIds:n,waitedMs:a}),target:MC(r.source)}}function OC(e){return e.kind==="passed"?null:e.failure??{kind:"unclassified",message:"check failed without diagnosis"}}function MC(e){switch(e.kind){case"step":return{kind:"step",ref:e.ref};case"fact":return{factId:Il(e),kind:"fact"}}}var TC=250;async function IC({pendingCheck:e,windowStartMs:t}){let r=e.check;if(r.kind==="decided")return r.passed?{kind:"passed"}:{failure:null,kind:"failed"};let n=Date.now()-t,o=Math.max(TC,Ce[e.budget].timeoutMs-n);return r.wait(o).match(async a=>a?{kind:"passed"}:LC(r.diagnose),a=>Promise.resolve(my(a)))}function LC(e){return e().match(t=>({failure:t,kind:"failed"}),t=>my(t))}function my(e){if(e.kind==="aborted")throw new Qe;return{error:e,kind:"error"}}function yy(e){let t=NC(e);return[...BC(e,t),...$C(e,t)]}function NC(e){return e.mismatches.reduce((t,r)=>FC(t,r.mismatch,e),{frame:[],scalar:new Map})}function FC(e,t,r){return DC(e,t,r)}function DC(e,t,r){let n=v(t.subject),o=r.scalarChecks.find(a=>!e.scalar.has(a)&&v(a.entry.subject)===n);return o!=null?{...e,scalar:new Map([...e.scalar,[o,t]])}:r.pendingElementKeys.has(n)?e:{...e,frame:[...e.frame,t]}}function BC(e,t){return e.scalarChecks.map(r=>{let n=t.scalar.get(r),o=n?.sut==null?null:Lt(n.sut);return{atMs:e.atMs,body:Dl({observed:o,passed:n==null,planned:r,waitedMs:e.waitedMs}),target:{kind:"step",ref:r.ref}}})}function $C(e,t){return t.frame.length===0?[{atMs:e.atMs,body:Da({failure:null,waitedMs:e.waitedMs}),target:{kind:"frame"}}]:t.frame.map(r=>({atMs:e.atMs,body:Da({failure:jl(r),waitedMs:e.waitedMs}),target:{kind:"frame"}}))}async function by({claimed:e,classify:t,observe:r,pre:n,predicted:o,signal:a,step:i}){let s=Ce[i.sync],l=Date.now()+s.timeoutMs,c=i.source.action.kind==="goto",d=Be(n.scalars,o.scalars),u=new Map([...d].filter(([p,b])=>b.declared&&(b.subject.kind!=="element"||e.has(p)))),f=()=>r(u),y=await gy(f);if(!y.ok)return{mismatches:[],snapshot:o,stepError:{atMs:Date.now(),error:y.error}};let m=Sy({pre:n,predicted:o,urlReset:c},y.observed),h=0;for(;Date.now()<l;){he(a);let p=hy(m,i,t);if(p!=null)return p;await et(Yo(s,h),a),h+=1;let b=await gy(f);if(!b.ok)return{mismatches:m.probed,snapshot:m.adopted,stepError:{atMs:Date.now(),error:b.error}};m=Sy({pre:n,predicted:o,urlReset:c},b.observed)}return hy(m,i,t)??{mismatches:m.probed,snapshot:m.adopted,stepError:null}}function hy(e,t,r){let n=new Set(t.urlChecks.flatMap(a=>Ry(a))),o=e.probed.filter(a=>!a.pending&&!jC(a,n)&&r(a.mismatch)==="strict");return o.length>0?{mismatches:o,snapshot:e.adopted,stepError:null}:e.probed.length===0?{mismatches:[],snapshot:e.adopted,stepError:null}:null}function gy(e){return e().match(t=>({observed:t,ok:!0}),t=>({error:t,ok:!1}))}function Sy({pre:e,predicted:t,urlReset:r},n){return{adopted:t,probed:Na({actual:n.snapshot,pre:e,predicted:t,urlReset:r})}}function Ry(e){return e.kind==="not"?Ry(e.inner):e.kind==="browser"?[v(e.key)]:[]}function jC(e,t){return t.has(v(e.mismatch.subject))}function Ul({atMs:e,effects:t,mismatches:r,waitedMs:n}){let o=VC({effects:t,mismatches:r}),a=new Set(o.map(l=>l.mismatch)),i=t.map((l,c)=>({atMs:e,body:UC({effect:l,mismatch:o.find(d=>d.effectIndex===c)?.mismatch,waitedMs:n}),target:{effectIndex:c,kind:"effect"}})),s=r.filter(l=>l.kind!=="effect"||!a.has(l)).map(l=>({atMs:e,body:QC({mismatch:l,waitedMs:n}),target:{kind:"frame"}}));return[...i,...s]}function VC({effects:e,mismatches:t}){return t.filter(r=>r.kind==="effect").reduce((r,n)=>{let o=e.findIndex((a,i)=>!r.used.has(i)&&_C({effect:a,mismatch:n}));return o===-1?r:{indexed:[...r.indexed,{effectIndex:o,mismatch:n}],used:new Set([...r.used,o])}},{indexed:[],used:new Set}).indexed}function _C({effect:e,mismatch:t}){return e.kind===t.effect.kind&&g(e.selector)===g(t.selector)}function UC({effect:e,mismatch:t,waitedMs:r}){return Wl(e)?WC({effect:e,mismatch:t,waitedMs:r}):zC({effect:e,mismatch:t,waitedMs:r})}function Wl(e){return e.kind==="create-record"||e.kind==="delete-selected-records"||e.kind==="update-selected-records"}function WC({effect:e,mismatch:t,waitedMs:r}){let n=Ey(e.selector);return{assertion:qC(e),entity:n,ephemeral:!1,family:"state",outcome:t==null?{kind:"passed"}:{kind:"failed",reason:HC(t)},rrwebIds:[],subject:KC({effect:e,entity:n}),waitedMs:r}}function qC(e){return e.kind==="create-record"?"created":e.kind==="delete-selected-records"?"deleted":"updated"}function zC({effect:e,mismatch:t,waitedMs:r}){return{ephemeral:!1,expected:vy(e),family:"scalar",negated:!1,outcome:t==null?{kind:"passed"}:{kind:"failed",reason:{kind:"wrongScalar",observed:ql(t.actual)}},rrwebIds:[],subject:wy(e.selector),subjectKey:g(e.selector),subjectKind:"variable",waitedMs:r}}function KC({effect:e,entity:t}){return e.kind==="create-record"?`${t} ${e.as}`:vs(e.selection)}function vy(e){return e.kind==="delete-path"?null:e.kind==="transform"?Tu(e.relation):Ue(e.value)}function HC(e){let{effect:t}=e,r=Ey(t.selector);return Wl(t)?t.kind==="create-record"?JC({effect:t,entity:r,mismatch:e}):t.kind==="delete-selected-records"?GC({entity:r,mismatch:e}):YC({effect:t,entity:r,mismatch:e}):{entity:r,key:r,kind:"missingRow"}}function JC({effect:e,entity:t,mismatch:r}){let o=XC({actual:r.actual,before:r.before})?.added[0];if(o!=null&&x(o)){let a=Object.entries(e.fields).find(([i,s])=>s.kind==="value"&&g(o[i])!==g(s.value));if(a!=null&&a[1].kind==="value")return{entity:t,expected:Ue(a[1].value),field:a[0],key:e.as,kind:"wrongValue",observed:Ue(o[a[0]])}}return{entity:t,key:e.as,kind:"missingRow"}}function GC({entity:e,mismatch:t}){let r=t.targetKeys.find(n=>_l({key:n,observed:t.actual}).present);return{entity:e,key:r??t.targetKeys[0]??e,kind:"unexpectedRow"}}function YC({effect:e,entity:t,mismatch:r}){return r.targetKeys.flatMap(o=>ZC({effect:e,entity:t,key:o,mismatch:r}))[0]??{entity:t,key:r.targetKeys[0]??vs(e.selection),kind:"missingRow"}}function ZC({effect:e,entity:t,key:r,mismatch:n}){let o=_l({key:r,observed:n.before});if(!o.present||!x(o.value))return[{entity:t,key:r,kind:"missingRow"}];let a=o.value,i=_l({key:r,observed:n.actual});if(!i.present||!x(i.value))return[{entity:t,key:r,kind:"unexpectedlyDeleted"}];let s=i.value,l=Object.entries(e.changes).flatMap(([d,u])=>{let f=s[d];return u.kind!=="value"||g(u.value)===g(f)?[]:[{entity:t,expected:Ue(u.value),field:d,key:r,kind:"wrongValue",observed:Ue(f)}]})[0];if(l!=null)return[l];let c=Object.keys({...a,...s}).find(d=>!(d in e.changes)&&g(a[d])!==g(s[d]));return c!=null?[{entity:t,expected:Ue(a[c]),field:c,key:r,kind:"wrongValue",observed:Ue(s[c])}]:[]}function _l({key:e,observed:t}){if(!t.present||!x(t.value))return{present:!1};let r=t.value[e];return r===void 0?{present:!1}:{present:!0,value:r}}function XC({actual:e,before:t}){if(!(!e.present||!t.present||!x(e.value)||!x(t.value)))return ka({after:e.value,before:t.value})}function QC({mismatch:e,waitedMs:t}){return{ephemeral:!1,family:"frame",outcome:{kind:"failed",reason:{expected:eA(e),kind:"wrongScalar",observed:ql(e.actual),subject:wy(e.selector),subjectKey:g(e.selector)}},rrwebIds:[],waitedMs:t}}function eA(e){return e.kind==="unexpected-change"?ql(e.before):e.kind==="constraint"?tA(e.constraint):Wl(e.effect)?e.effect.kind:vy(e.effect)}function ql(e){return e.present?Ue(e.value):null}function Ue(e){return e===void 0?"\u2205":JSON.stringify(e)}function tA(e){return e.kind==="absent-path"||e.kind==="absent-record"?null:e.kind==="equals"?Ue(e.value):e.kind==="required-record"?Ue(e.fields):Ue(e.rows)}function wy(e){return e.path.join(".")}function Ey(e){return e.path.at(-1)??e.source}function Kr(e){if(e.kind==="not")return Kr(e.inner);if(e.kind!=="browser")return e.locator}function zl(e){switch(e.kind){case"goto":return{kind:e.kind,path:rA(Oe(Un(e.url)))};case"fill":case"clear":case"click":case"dblclick":case"select":case"check":case"uncheck":case"hover":case"upload":return{kind:e.kind,target:te(Un(e.locator))};case"press":return{key:Un(e.key),kind:e.kind,target:e.locator==null?null:te(e.locator)};case"drag":return{kind:e.kind,source:te(Un(e.locator)),target:te(Un(e.target))};case"actor":return{kind:e.kind}}}function Kl({check:e,id:t}){return xy({check:e,id:t,negated:!1})}function xy({check:e,id:t,negated:r}){return e.kind==="not"?xy({check:e.inner,id:t,negated:!r}):e.kind==="browser"?{id:t,kind:e.kind,negated:r,subject:Zt(e.key)}:e.kind==="text"||e.kind==="value"?{check:e.kind,id:t,kind:"content",negated:r,target:te(e.locator)}:{check:e.kind,id:t,kind:"element",negated:r,target:te(e.locator)}}function rA(e){let t=e.split(/[?#]/u)[0];return t==null||t.length===0?"/":t}function Un(e){if(e===void 0)throw new TypeError("resolved-progress-value-required");return e}function ky({params:e,startMs:t,step:r}){let n=zl(r.step.action);Ba({deadlineAt:Wn(t,Ce[r.sync].timeoutMs),params:e,stage:{action:n,kind:"performingAction"}}),n.kind==="goto"&&Ba({deadlineAt:Wn(t,Ce[r.sync].timeoutMs),params:e,stage:{kind:"waitingForApp",path:n.path}})}function Hl({deadlineAt:e,kind:t,params:r}){Ba({deadlineAt:e,params:r,stage:{kind:t}})}function Jl({params:e,remaining:t,startMs:r,step:n}){Ba({deadlineAt:oA({remaining:t,startMs:r}),params:e,stage:{kind:"checkingExpectations",remaining:t.map(o=>nA({pendingCheck:o,step:n}))}})}function nA({pendingCheck:e,step:t}){let r=t.pendingChecks.indexOf(e);if(r===-1)throw new TypeError("pending-progress-check-not-found");return Kl({check:e.source.check,id:`expectation-${String(r)}`})}function oA({remaining:e,startMs:t}){let r=e.reduce((n,o)=>Math.max(n,Ce[o.budget].timeoutMs),0);return r===0?null:Wn(t,r)}function Wn(e,t){return new Date(e+t).toISOString()}function Ba({deadlineAt:e,params:t,stage:r}){t.onProgress?.({activity:{kind:"executingStep",stage:r,stepCount:t.stepCount,stepIndex:t.stepBase+t.index},deadlineAt:e,retry:null})}function aA(e){return e.stepError!=null||e.findings.length>0||e.checks.some(t=>cy(t))}var iA=()=>lt;async function ja({classify:e,derive:t,initialSnapshot:r,observe:n,onProgress:o,onStep:a,stepBase:i,stepCount:s,steps:l,stopAfterStep:c},d){return Cy({classify:e,derive:t??iA,failed:!1,findings:[],index:0,observe:n,onProgress:o,onStep:a,signal:d,snapshot:r,stepBase:i,stepCount:s,steps:l,stopAfterStep:c})}async function Cy(e){let{index:t,signal:r,snapshot:n,steps:o}=e;he(r);let a=o[t];if(a==null)return{failed:e.failed,finalModel:n,findings:e.findings};let i=Date.now();ky({params:e,startMs:i,step:a});let s=await a.targetIds();if(!a.requiredState(n)){let l={kind:"impossible-action",step:a.step};return Gl(e.onStep,{checks:[$a({failure:{kind:"notPossible"},rrwebIds:s,startMs:i,step:a})],endMs:Date.now(),executedBranches:a.executedBranches,findings:[l],index:t,post:n,pre:n,source:a.source,startMs:i,stateBindings:$t,step:a.step,stepError:null,url:zr(n)}),{failed:!0,finalModel:n,findings:[...e.findings,l]}}return a.perform().match(l=>cA({params:e,performed:l,rrwebIds:s,startMs:i,step:a}),l=>sA({error:l,params:e,rrwebIds:s,startMs:i,step:a}))}async function sA({error:e,params:t,rrwebIds:r,startMs:n,step:o}){let{checks:a,stepError:i}=lA({error:e,rrwebIds:r,startMs:n,step:o}),s=e.kind==="state-mismatch"?await Vl({pendingChecks:o.pendingChecks,signal:t.signal,windowStartMs:n,onRemaining:l=>{Jl({params:t,remaining:l,startMs:n,step:o})}}):{checks:[],stepErrors:[]};return Gl(t.onStep,{checks:[...a,...s.checks],endMs:Date.now(),executedBranches:o.executedBranches,findings:[],index:t.index,post:t.snapshot,pre:t.snapshot,source:o.source,startMs:n,stateBindings:$t,step:o.step,stepError:Py([...i==null?[]:[i],...s.stepErrors]),url:zr(t.snapshot)}),{failed:!0,finalModel:t.snapshot,findings:t.findings}}function lA({error:e,rrwebIds:t,startMs:r,step:n}){if(e.kind==="action-failed")return{checks:[$a({failure:e.failure,rrwebIds:t,startMs:r,step:n})],stepError:null};if(e.kind==="state-mismatch"){let o=Date.now();return{checks:[$a({failure:null,rrwebIds:t,startMs:r,step:n}),...Ul({atMs:o,effects:n.source.effects,mismatches:e.mismatches,waitedMs:Math.max(0,o-r)})],stepError:null}}return{checks:[],stepError:{atMs:Date.now(),error:e}}}function $a({failure:e,rrwebIds:t,startMs:r,step:n}){let o=Date.now();return{atMs:o,body:$l({action:n.step.action,failure:e,rrwebIds:t,waitedMs:Math.max(0,o-r)}),target:{kind:"action"}}}async function cA({params:e,performed:t,rrwebIds:r,startMs:n,step:o}){let{snapshot:a}=e,i=o.effect(a),s=e.derive(i),l={...i,scalars:Be(s,i.scalars)};Hl({deadlineAt:Wn(n,Ce[o.sync].timeoutMs),kind:"readingState",params:e});let c=await by({claimed:new Set([...o.assertedScalars,...s.keys()]),classify:e.classify,observe:e.observe,pre:a,predicted:l,signal:e.signal,step:o}),d={...c.snapshot,scalars:new Map([...[...c.snapshot.scalars].filter(([,E])=>E.subject.kind!=="element"),...[...i.scalars].filter(([,E])=>E.subject.kind==="element")])},u=Date.now();Hl({deadlineAt:null,kind:"verifyingEffects",params:e});let f=await Vl({pendingChecks:o.pendingChecks,signal:e.signal,windowStartMs:n,onRemaining:E=>{Jl({params:e,remaining:E,startMs:n,step:o})}}),y=$a({failure:null,rrwebIds:r,startMs:n,step:o}),m=t.stateEffectsVerified?Ul({atMs:u,effects:o.source.effects,mismatches:[],waitedMs:Math.max(0,u-n)}):[],h=yy({atMs:u,mismatches:c.mismatches,pendingElementKeys:dA(o.pendingChecks),scalarChecks:o.scalarChecks,waitedMs:Math.max(0,u-n)}),p=[y,...f.checks,...m,...h],b=Py([...c.stepError==null?[]:[c.stepError],...f.stepErrors]),w={checks:p,endMs:Date.now(),executedBranches:o.executedBranches,findings:[],index:e.index,post:c.snapshot,pre:a,source:o.source,startMs:n,stateBindings:t.stateBindings,step:o.step,stepError:b,url:zr(c.snapshot)};return Gl(e.onStep,w),aA(w)?{failed:!0,finalModel:d,findings:e.findings}:e.stopAfterStep!=null&&e.index+1>=e.stopAfterStep?{failed:!1,finalModel:d,findings:e.findings}:Cy({...e,index:e.index+1,snapshot:d})}function dA(e){return new Set(e.flatMap(t=>{if(!("check"in t.source))return[];let r=Kr(t.source.check);return r==null?[]:uA(t.source.check,r)}))}function uA(e,t){let r=Ay(e);return r==="browser"||r==="unobstructed"||r==="disabled"?[]:[Sr(t,r)]}function Ay(e){return e.kind==="not"?Ay(e.inner):e.kind}function Py(e){return e.at(0)??null}function Gl(e,t){e?.(t)}function Yl(e,t){return{singletons:[...t.scalars.values()].flatMap(n=>{if(n.subject.kind!=="variable"||n.expect.expect!=="is")return[];let o=n.expect.value;if(U(o))return[];let a=n.subject.name;return[{changed:Y(e.scalars,n.subject)!==o,name:a,value:o}]})}}function Hr({driver:e,parameters:t,resolved:r,transition:n}){return r.steps.map(o=>({assertedScalars:o.assertedScalars,executedBranches:o.executedBranches,pendingChecks:o.pendingChecks.map(a=>({budget:a.budget,check:{kind:"poll",diagnose:()=>e.diagnoseCheck(a.check),wait:i=>e.awaitCheck(a.check,i)},ephemeral:a.ephemeral,source:{check:a.check,kind:"step",ref:a.ref},targetIds:()=>e.locateIds(Kr(a.check))})),scalarChecks:o.scalarChecks,source:o.source,step:{action:o.action,intent:n.intent,test:n.test},sync:n.wait,urlChecks:o.urlChecks,effect:a=>pA({driver:e,pendingChecks:o.pendingChecks,snapshot:o.effect(a)}),perform:()=>e.perform({action:o.action,effects:o.source.effects,parameters:t,sync:n.wait}),requiredState:()=>!0,targetIds:()=>e.locateIds(o.action.locator)}))}function pA({driver:e,pendingChecks:t,snapshot:r}){let n=t.reduce((o,a)=>{let i=e.resolveCheck(a.check),s=i==null?null:Oy({check:i,negated:!1});return s==null?o:ct(o,s)},r.scalars);return n===r.scalars?r:{...r,scalars:n}}function Oy({check:e,negated:t}){return e.kind==="not"?Oy({check:e.inner,negated:!t}):e.kind!=="browser"||e.value!==null&&U(e.value)?null:e.value===null?{declared:!0,expect:{expect:"absent"},subject:e.key}:{declared:!0,expect:t?{expect:"not",value:e.value}:{expect:"is",value:e.value},subject:e.key}}async function My({current:e,driver:t,index:r,next:n,state:o}){if(n==null||fA(n))return[];if(Qt(e.transition.effectStep))return[];let a=rr(n.transition,o,n.params);if(a==null)return[];let i=Hr({driver:t,parameters:n.params,resolved:a.resolved,transition:n.transition}).flatMap(c=>c.pendingChecks.flatMap(d=>{let u=mA(d.source);return u==null?[]:[u]}));if(i.length===0)return[];let s=new Map(i.map(c=>{let d={kind:"element",locator:c,state:"visible"};return[v(d),{declared:!0,expect:{expect:"is",value:!0},subject:d}]})),l=await t.observe(s).match(c=>c,()=>null);return l==null?[]:i.filter(c=>{let d={kind:"element",locator:c,state:"visible"},u=Y(l.snapshot.scalars,d)===!0,f=Y(o.snapshot.scalars,d)===!1;return u&&f}).map(c=>({declaredIndex:r+1,kind:"lift-visibility",locator:c,visibleIndex:r}))}function fA(e){return e.transition.nav.length>0||e.transition.steps.some(t=>t.action.kind==="goto"||Qt(t))}function mA(e){return e.check.kind==="visible"?e.check.locator:void 0}function Va(e){let t=e.findings.map(n=>({finding:n,kind:"finding"})),r=e.step;return r==null?t:[...e.checks.filter(n=>n.body.outcome.kind==="failed").map(n=>({kind:"check",record:n,step:r,stepIndex:e.index})),...e.stepError==null?[]:[{kind:"stepError",record:e.stepError,step:r,stepIndex:e.index}],...t]}function _a(e){return e.filter(t=>t.kind!=="finding"||t.finding.kind!=="unrunnable")}function qn(e){return _a(e).filter(t=>t.kind!=="finding"||t.finding.kind!=="lift-visibility")}function zn(e){return e.filter(t=>t.kind==="finding"&&t.finding.kind==="lift-visibility")}async function Xl(e,t){let{params:r,transition:n}=e.stepRun,o={base:e.state.base,deferred:e.state.deferred,logical:e.state.logical,snapshot:Lr({logical:e.state.logical,model:e.facts,snapshot:e.state.snapshot})},a=rr(n,o,r);if(a==null){let s=Dn(n,o,r),l={intent:n.intent,kind:"unrunnable",reason:s,test:n.test,unmet:s==="required-state-unsatisfied"?Op({base:o.base,deferred:o.deferred,logical:o.logical,pattern:n.requiredState,snapshot:o.snapshot})??void 0:void 0};return{label:er(n),next:e.state,result:{failed:!0,finalModel:e.state.snapshot,findings:[l]}}}let i=await ja({classify:e.classify,initialSnapshot:e.state.snapshot,observe:e.driver.observe,onProgress:e.onProgress,onStep:e.onStep,stepBase:e.stepBase,stepCount:e.stepCount,steps:Hr({driver:e.driver,parameters:e.stepRun.params,resolved:a.resolved,transition:e.stepRun.transition}),stopAfterStep:e.stopAfterStep==null?void 0:e.stopAfterStep-e.stepBase,derive:s=>Tn({logical:a.next.logical,model:e.facts,snapshot:s})},t);return{label:er(e.stepRun.transition),next:{base:a.next.base,deferred:a.next.deferred,logical:a.next.logical,snapshot:i.finalModel},result:i}}function Ua(e,t){return Zl({acc:{contradictions:[],failed:!1,findings:[],ran:[]},index:0,params:e,signal:t,state:e.initialState,stepBase:0})}function yA(e){return e.reduce((t,r)=>t+r.transition.nav.length+r.transition.steps.length,0)}async function Zl({acc:e,index:t,params:r,signal:n,state:o,stepBase:a}){he(n);let i=r.sequence[t];if(i==null)return e;let s=Date.now(),l=[],c=[],d=await Xl({classify:r.classify,driver:r.driver,facts:r.facts,onProgress:r.onProgress,state:o,stepBase:a,stepCount:yA(r.sequence),stepRun:i,stopAfterStep:r.stopAfterStep,onStep:m=>{l.push(m.index);let h={checks:m.checks,endMs:m.endMs,executedBranches:m.executedBranches,findings:m.findings,index:a+m.index,kind:"step",source:m.source,startMs:m.startMs,state:Yl(m.pre,m.post),stateBindings:m.stateBindings,step:m.step,stepError:m.stepError,url:m.url};c.push(...Va(h)),r.onEvent(h)}},n);if(d==null)return Zl({acc:e,index:t+1,params:r,signal:n,state:o,stepBase:a});r.onEvent({endMs:Date.now(),intent:i.transition.intent,kind:"ran",startMs:s});let u=await hA({index:t,outcome:d,params:r,signal:n,state:o,stepBase:a,stepRun:i},l),f=l.length>0?[]:d.result.findings,y={contradictions:[...e.contradictions,...c,...f.map(m=>({finding:m,kind:"finding"})),...u.map(m=>({finding:m,kind:"finding"}))],failed:e.failed||d.result.failed||c.length>0||u.length>0,findings:[...e.findings,...d.result.findings,...u],ran:[...e.ran,d.label]};return d.result.failed||c.length>0||u.length>0||r.stopAfterStep!=null&&a+l.length>=r.stopAfterStep?y:Zl({acc:y,index:t+1,params:r,signal:n,state:d.next,stepBase:a+l.length})}async function hA(e,t){let{index:r,outcome:n,params:o,stepBase:a,stepRun:i}=e,s=t.length>0;!s&&n.result.findings.length>0&&Ty(o,i,e.state,a,n.result.findings);let l=o.sequence[r+1],c=s?await My({current:i,driver:o.driver,index:r,next:l,state:n.next}):[];return n.result.findings.forEach(d=>{o.onEvent({finding:d,kind:"finding"})}),c.forEach(d=>{o.onEvent({finding:d,kind:"finding"})}),c.length>0&&l!=null&&Ty(o,l,n.next,a+t.length,c),c}function Ty(e,t,r,n,o){let a=Date.now(),i=Y(r.snapshot.scalars,{kind:"path"});e.onEvent({checks:[],endMs:a,executedBranches:[],findings:o,index:n,kind:"step",source:t.transition.steps[0]??t.transition.effectStep,startMs:a,state:Yl(r.snapshot,r.snapshot),stateBindings:$t,step:null,stepError:null,url:typeof i=="string"?i:null})}function Ly(e){let t=new Map;return e.forEach(r=>{gA(r).forEach(n=>{Kn(n,t)})}),t}function ec(e,t){let r=SA(e.consequence,t);if(r.length===0)return e.when;let n=new Map(e.when.scalars);return r.forEach(o=>n.set(v(o.subject),o)),{...e.when,scalars:n}}function gA(e){let t=[...e.when.scalars.values()].flatMap(n=>n.subject.kind==="element"?[n.subject.locator]:[]),r=Ny(e.consequence);return r==null?t:[...t,r]}function Ny(e){return e.kind==="not"?Ny(e.predicate):"locator"in e?e.locator:void 0}function Kn(e,t){if(e.by==="inside"){let r=Fy(Ql(e.scope));t.set(r,[...t.get(r)??[],e]),Kn(e.scope,t),Kn(e.target,t);return}if(e.by==="surface"){Kn(e.container,t);return}e.by==="frame"&&Kn(e.element,t)}function Fy(e){return Sr(e,"visible")}function Ql(e){return e.by==="frame"?e.element:e}function SA(e,t){let r=bA(e);if(r!=null)return(t.get(Fy(Ql(r)))??[]).map(o=>Iy(o,!1));let n=RA(e);return n==null?[]:[Iy(Ql(n),!0)]}function bA(e){return e.kind!=="not"||e.predicate.kind!=="visible"?null:e.predicate.locator}function Iy(e,t){return{expect:{expect:"is",value:t},subject:{kind:"element",locator:e,state:"visible"}}}function RA(e){return e.kind!=="visible"||e.locator.by!=="inside"?null:e.locator.scope}function Hn(e){return e.origin==null||e.origin.kind==="declared"?[]:[{test:e.origin.test,when:e.when}]}function jy({facts:e}){let r=[...e.reduce((a,i)=>{let s=ie(i.consequence);if(s==null)return a;let l=v(s.subject);return new Map([...a,[l,[...a.get(l)??[],i]]])},new Map).values()].flatMap(a=>a.flatMap((i,s)=>a.slice(s+1).filter(l=>vA(i,l)&&wA(i.consequence,l.consequence)).map(l=>[i,l]))),n=Ly(e),o=r.map(([a,i])=>{let s=Et({general:a.when,specific:i.when})&&Se({current:i.logicalWhen,required:a.logicalWhen}),l=Et({general:i.when,specific:a.when})&&Se({current:a.logicalWhen,required:i.logicalWhen});return s!==l?null:Zp({left:a.logicalWhen,right:i.logicalWhen})&&(s||gn({aligned:!0,patterns:[ec(a,n),ec(i,n)]}))?kA(a,i):null});return CA(o.filter(a=>a!=null))}function vA(e,t){let r=Dy(e),n=Dy(t);return r==null||n==null||r===n}function Dy(e){return e.localConsequence&&e.origin?.kind==="test"?e.origin.test:void 0}function wA(e,t){let r=ie(e),n=ie(t);return r==null||n==null||v(r.subject)!==v(n.subject)?!1:EA(r,n)}function EA(e,t){return xA(e)?$y(e,t):e.expect.expect==="is"&&t.expect.expect==="is"?g(e.expect.value)!==g(t.expect.value):$y(e,t)}function xA(e){return e.subject.kind==="element"&&e.subject.state==="text"}function kA(e,t){let r=Hn(e),n=Hn(t);return{a:e.consequence,aProducers:r,b:t.consequence,bProducers:n,tests:[...new Set([...By(e),...By(t)])],when:e.when}}function By(e){return e.origin==null?[]:e.origin.kind==="declared"?[]:[e.origin.test]}function CA(e){return[...e.reduce((r,n)=>{let o=[g(n.a),g(n.b)].toSorted((s,l)=>s.localeCompare(l)).join("|"),a=r.get(o),i=a==null?n:{...a,tests:[...new Set([...a.tests,...n.tests])]};return new Map([...r,[o,i]])},new Map).values()]}function $y(e,t){let r=[e.expect,t.expect],n=r.find(a=>a.expect==="is"),o=r.find(a=>a.expect==="not");return n==null||o==null?!1:g(n.value)===g(o.value)}function Vy(e){return e.workflows.flatMap(t=>Gu({workflow:t}))}function _y(e){return J(e).flatMap(({test:t})=>tr(e,t).flatMap(r=>r.actionRelationship!=="undecided"?[]:[{action:r.effectStep.action,expectations:Zs(r.effectStep),stepIndex:r.index,test:r.test}]))}function Uy(e){return J(e).flatMap(({test:t})=>AA(t.steps,oe(t)))}function AA(e,t){return e.reduce((r,n)=>{let o=PA(n.action).filter(a=>!OA(a,r.pre)).map(a=>({action:n.action,ephemeralOnly:r.ephemeralKeys.has(g(fe(a))),target:a,test:t}));return{ephemeralKeys:new Set([...r.ephemeralKeys,...MA(n)]),pre:Ze(r.pre,[n]),violations:[...r.violations,...o]}},{ephemeralKeys:new Set,pre:Gt,violations:[]}).violations}function PA(e){return e.kind==="goto"||e.kind==="upload"?[]:e.kind==="drag"?[e.source,e.target]:"locator"in e&&e.locator!=null?[e.locator]:[]}function OA(e,t){let r=g(fe(e)),n=[...t.values()].filter(a=>a.subject.kind==="element"&&g(fe(a.subject.locator))===r);if(n.length===0)return!1;let o=a=>n.some(i=>i.subject.kind==="element"&&i.subject.state===a&&i.expect.expect==="is"&&i.expect.value===!1);return!o("visible")&&!o("enabled")}function MA(e){return Or(e.expect).filter(t=>Jt(t)).flatMap(t=>Wy(t)).map(t=>g(fe(t)))}function Wy(e){return e.kind==="not"?Wy(e.predicate):"locator"in e?[e.locator]:[]}function qy(e){let t=Xe(e);return J(e).flatMap(({test:r})=>[...NA(r.steps,oe(r),t),...TA(r.steps,r.actor,oe(r))])}function TA(e,t,r){return e.reduce((n,o,a)=>{let i=o.action.kind==="actor"?{alias:o.action.ref.ref,kind:"user"}:n.actor,s=IA(o).filter(l=>LA(l.target,i)).map(l=>({predicate:l,stepIndex:a,test:r}));return{actor:Mn(n.actor,[o]),flagged:[...n.flagged,...s]}},{actor:t,flagged:[]}).flagged}function IA(e){return e.expect.filter(t=>t.kind==="actor")}function LA(e,t){return e.kind==="anonymous"?t.kind==="anonymous":t.kind==="user"&&t.alias===e.ref.ref}function NA(e,t,r){let n=ta(Gt,r),o=new Set(n.keys());return e.reduce((a,i,s)=>{let l=jA(i),c=FA({acc:a,assertions:l,stateChanged:zy(i),stepIndex:s,test:t}),d=ta(Ze(a.pattern,[i]),r),u=new Set([...DA({acc:a,assertions:l,pattern:d,step:i}),...o]);return{assertedKeys:u,dynamicKeys:BA({acc:a,assertedKeys:u,assertions:l}),pattern:d,redundant:[...a.redundant,...c]}},{assertedKeys:o,dynamicKeys:new Set,pattern:n,redundant:[]}).redundant}function FA({acc:e,assertions:t,stateChanged:r,stepIndex:n,test:o}){return t.reduce((a,{entry:i,predicate:s})=>{let l=v(i.subject),c=g(i.expect),d=e.pattern.get(l),f=!(r&&e.dynamicKeys.has(l))&&d!=null&&e.assertedKeys.has(l)&&g(d.expect)===c,y=a.seen.get(l)===c;return{flagged:f||y?[...a.flagged,{predicate:s,stepIndex:n,test:o}]:a.flagged,seen:new Map([...a.seen,[l,c]])}},{flagged:[],seen:new Map}).flagged}function DA({acc:e,assertions:t,pattern:r,step:n}){let o=new Set([...$A(n),...Tt(n)].map(l=>v(l.subject))),a=zy(n)?e.dynamicKeys:new Set,i=[...e.assertedKeys].filter(l=>r.has(l)&&!o.has(l)&&!a.has(l)),s=t.map(({entry:l})=>v(l.subject)).filter(l=>r.has(l));return new Set([...i,...s])}function BA({acc:e,assertedKeys:t,assertions:r}){let n=[...e.dynamicKeys].filter(a=>t.has(a)),o=r.filter(({dynamic:a})=>a).map(({entry:a})=>v(a.subject));return new Set([...n,...o])}function $A(e){return e.action.kind==="goto"?Cn(e.action.url):[]}function jA(e){return Mr(e.expect).flatMap(t=>{if(t.kind==="actor")return[];let r=ie(t);return r==null?[]:[{dynamic:VA(t),entry:r,predicate:t}]})}function VA(e){return"locator"in e&&Jn(e.locator)}function Jn(e){return e.by==="role"?e.name!=null&&typeof e.name!="string":e.by==="testId"?typeof e.value!="string":e.by==="inside"?Jn(e.scope)||Jn(e.target):e.by==="surface"?Jn(e.container):Jn(e.element)}function zy(e){return e.effects.length>0}var _A=2;function Ky(e){return J(e).flatMap(({test:t})=>t.steps.reduce((n,o,a)=>{let i=UA(o,n.pre),s=i.length>=_A?[...n.violations,{hidden:i,stepIndex:a,test:oe(t)}]:n.violations;return{pre:Ze(n.pre,[o]),violations:s}},{pre:Gt,violations:[]}).violations)}function UA(e,t){return e.expect.flatMap(r=>{let n=WA(r);return n!=null&&!tc(n)&&qA(n,t)?[n]:[]})}function WA(e){return e.kind!=="not"||e.predicate.kind!=="visible"?null:e.predicate.locator}function tc(e){return e.by==="surface"?!0:e.by==="inside"?tc(e.scope)||tc(e.target):!1}function qA(e,t){let r=t.get(v({kind:"element",locator:e,state:"visible"}));return r!=null&&r.expect.expect==="is"&&r.expect.value===!0}var zA="[object Object]";function Hy(e){return J(e).flatMap(({test:t})=>{let r=oe(t);return t.steps.flatMap((n,o)=>KA(n).map(a=>({stepIndex:o,test:r,value:a})))})}function KA(e){return[...new Set(rc(e).filter(t=>t.includes(zA)))]}function rc(e){return typeof e=="string"?[e]:Array.isArray(e)?e.flatMap(t=>rc(t)):typeof e!="object"||e===null?[]:Object.values(e).flatMap(t=>rc(t))}function Gy(e){return J(e).flatMap(({test:t})=>{let r=oe(t);return t.steps.reduce((n,o,a)=>HA(n,o,a,r),{found:[],open:new Set}).found})}function HA(e,t,r,n){let o=t.action.kind==="goto"?new Set:e.open,a=Jy(t,JA),i=Jy(t,GA),s=new Set([...o,...a].filter(c=>!i.has(c))),l=YA(t).flatMap(c=>s.has(g(fe(c.surface)))?[]:[{...c,stepIndex:r,test:n}]);return{found:[...e.found,...l],open:s}}function Jy(e,t){return new Set(e.expect.flatMap(r=>{let n=t(r);return n==null?[]:[g(fe(n))]}))}function JA(e){return e.kind!=="visible"?null:e.locator.by==="surface"?e.locator:null}function GA(e){return e.kind!=="not"||e.predicate.kind!=="visible"?null:e.predicate.locator.by==="surface"?e.predicate.locator:null}function YA(e){return e.expect.flatMap(t=>{if(t.kind!=="visible"||t.locator.by!=="inside")return[];let r=Yy(t.locator);return r==null?[]:[{content:t.locator,surface:r}]})}function Yy(e){return e.by!=="inside"?null:e.scope.by==="surface"?e.scope:Yy(e.scope)}function Xy(e){switch(e.kind){case"unreachable-interaction":{let{violation:t}=e,r=se(t.target);return t.ephemeralOnly?`${ce("reachability")} ${t.test}: ${Nt(t.action)}, but ${r} was only declared inside ephemeral(...), which grants no reachability. Assert a durable visible(...) first.`:`${ce("reachability")} ${t.test}: ${Nt(t.action)}, but no prior step declared ${r} reachable. Assert visible(...) on it first.`}case"redundant-assertion":{let{redundancy:t}=e;return`${ce("redundancy")} ${t.test}: step ${String(t.stepIndex+1)} restates "${je(t.predicate)}" \u2014 already asserted and unchanged since. Delete it.`}case"fact-conflict":return ZA(e.conflict);case"possible-noop-effect":return XA(e.effect);case"undecided-action-consequence":return eP(e.consequence);case"unmodeled-surface":{let{surface:t}=e,r=t.hidden.map(n=>se(n)).join(", ");return`${ce("surface")} ${t.test}: step ${String(t.stepIndex+1)} hides ${String(t.hidden.length)} elements at once (${r}). Elements hidden together are one surface \u2014 declare surface(...) and scope them to it.`}case"stringified-binding":{let{binding:t}=e;return`${ce("value")} ${t.test}: step ${String(t.stepIndex+1)} uses the literal "${t.value}" \u2014 a handle was turned into a string with String(...) or template concatenation instead of staying connected to state. Use s\`\${handle}\` so the value comes from the record.`}case"unpinned-surface-content":{let{content:t}=e,r=se(t.surface);return`${ce("surface")} ${t.test}: step ${String(t.stepIndex+1)} asserts ${se(t.content)} but never opens ${r}. A content fact holds only while its surface is active \u2014 assert visible(${r}) here or on a prior open step.`}}}function ZA(e){return[`${ce("fact")} Two facts contradict on overlapping states \u2014 "${je(e.a)}" vs "${je(e.b)}".`,` Shared state: ${ca(e.when)}.`,Zy(e.a,e.aProducers,e.when),Zy(e.b,e.bProducers,e.when),"These declarations overlap on this state. Add the missing distinguishing state to the broader declaration, or split the outcome with a when branch."].join(`
|
|
5
|
+
`)}function Zy(e,t,r){let n=t.map(o=>` - ${o.test} adds ${qf(o.when,r)}`);return[` "${je(e)}" declared by:`,...n].join(`
|
|
6
|
+
`)}function XA(e){let t=e.branch==null?"":` in branch "${e.branch}"`,r=[e.effect.selector.source,...e.effect.selector.path].join(".");return`${ce("precondition")} ${e.workflow}: step ${String(e.stepIndex+1)}${t} declares an effect on ${r}, but the state may stay unchanged. ${QA(e.effect)} Declare a transform that excludes equality, split state-dependent outcomes with a when branch, or add the least-specific precondition this behavior requires. Do not fix an unrelated starting value just to make the effect change.`}function QA(e){switch(e.kind){case"set":return`${e.selector.path.at(-1)??e.selector.source} may already be ${JSON.stringify(e.value)}.`;case"transform":return"The transform may permit the same value before and after.";case"create-path":return"The path may already exist.";case"delete-path":return"The path may already be absent.";case"delete-selected-records":return"The selection may match no records.";case"update-selected-records":return"The selection may match no records or write values they already contain."}}function eP(e){let t=e.expectations[0];if(t==null)throw new Error("undecided action consequence has no expectation");let r=e.expectations.length===1?`"${je(t)}"`:`${String(e.expectations.length)} outcomes including "${je(t)}"`,n="locator"in e.action&&e.action.locator!=null?se(e.action.locator):"the control";return`${ce("precondition")} ${e.test}: step ${String(e.stepIndex+1)} ${Nt(e.action)} and declares ${r}, but the previous state allows ${n} to already have the action's result or a different state. ${tP(e.action)} Add branches if the outcomes differ.`}function tP(e){return e.kind==="fill"||e.kind==="select"||e.kind==="clear"?"Declare value(...) or not(value(...)) before this step.":e.kind==="check"||e.kind==="uncheck"?"Declare checked(...) or not(checked(...)) before this step.":"Declare the action's result or its negation before this step."}function Jr({corpus:e,planned:t}){return t.reduce((r,n)=>{if(r==null)return null;let o=e.find(a=>a.id===n.transitionId);return o==null?null:[...r,{params:{...n.params},transition:o}]},[])}function nc(e){switch(e.kind){case"stepError":return"crash";case"check":return rP(e);case"finding":return e.finding.kind==="unrunnable"?"model-drift":"frame"}}function rP(e){switch(e.record.target.kind){case"dataRule":return"data-rule";case"fact":return"fact";case"effect":case"step":case"action":case"frame":return"frame"}}function Gn(e){let t=e.map(o=>({contradiction:o,line:ma(o),part:aP(o)})).toSorted((o,a)=>g(o.part).localeCompare(g(a.part))),r=t.map(o=>o.part),n=t.at(0)?.contradiction;return{layer:lP(r),signature:g({parts:r.map(o=>g(o))}),sourceTest:n==null?void 0:nP(n),title:t.at(0)?.line}}function nP(e){switch(e.kind){case"check":case"stepError":return e.step.test;case"finding":return oP(e)}}function oP(e){let{finding:t}=e;switch(t.kind){case"impossible-action":return t.step.test;case"unrunnable":return t.test;case"lift-visibility":return}}var eh={crash:0,"data-rule":1,fact:2,frame:3,"model-drift":4};function aP(e){let t=nc(e);switch(e.kind){case"check":{let{body:r}=e.record;return{family:r.family,kind:"check",layer:t,reason:iP(r),step:{intent:e.step.intent,test:e.step.test},subject:"subject"in r?r.subject:""}}case"stepError":return{error:e.record.error.kind,kind:"stepError",layer:t,step:e.step.intent};case"finding":return sP(e,t)}}function iP(e){return e.outcome.kind==="failed"?e.outcome.reason.kind:"passed"}function sP(e,t){let{finding:r}=e;switch(r.kind){case"unrunnable":return{intent:r.intent,kind:"unrunnable",layer:t,reason:r.reason,test:r.test};case"impossible-action":return{kind:"impossible-action",layer:t,step:r.step.intent};case"lift-visibility":return{declaredIndex:r.declaredIndex,kind:"lift-visibility",layer:t,subject:te(r.locator),visibleIndex:r.visibleIndex}}}function lP(e){return e.map(r=>r.layer).toSorted((r,n)=>eh[r]-eh[n]).at(0)??"frame"}import{z as th}from"zod";var rh=th.object({maxAttemptLength:th.number().int().positive()}),oc={even:{maxAttemptLength:12}};function nh(e){return oc[e]}import{z as Re}from"zod";var cP=Re.strictObject({value:Re.string().min(1)}),dP=Re.strictObject({kind:Re.literal("dev-session"),value:Re.string().min(1)}),Wa=Re.enum(["create-modify-delete","cross-workflow","last-record-navigation","lifecycle","overlay-mutate-close","parent-child-delete","role-attempt","threshold-gate"]),uP=Re.strictObject({params:Re.record(Re.string(),Le),transitionId:Re.string().min(1)}),oh=Re.strictObject({assignmentSeed:cP,coverageSignature:Re.string().min(1),envelopeRef:Re.string().min(1),modelHash:Re.string().min(1),steps:Re.array(uP).min(1),targetGeneration:dP});function qa({attemptOrdinal:e,corpus:t}){let n=t.filter(l=>l.effectStep.action.kind!=="goto").toSorted((l,c)=>l.id.localeCompare(c.id)),o=n[e%n.length];if(o==null)return null;let a=Math.floor(e/n.length),i=Wa.options[(e+a)%Wa.options.length];if(i==null)throw new Error("exploration pattern catalog is empty");let s=fP({attemptOrdinal:e,ordered:n,primaryId:o.id});return{objectives:[{kind:"transition",transitionId:o.id},{kind:"pattern",pattern:i},...pP(s)],pattern:i,primaryTransitionId:o.id,secondaryTransitionId:s?.id}}function pP(e){return e==null?[]:[{kind:"transition",transitionId:e.id}]}function fP({attemptOrdinal:e,ordered:t,primaryId:r}){if(t.length<2)return;let n=1+e%(t.length-1),o=t.findIndex(a=>a.id===r);return t[(o+n)%t.length]}function ah(e){switch(e){case"modelEmpty":case"noEntry":return!0;case"allReserved":case"budgetExhausted":case"noLegalExpansion":case"trailLengthExhausted":return!1}}function ih(e){return Math.max(9e4,e*1e4)}import{z as ft}from"zod";var ac=1,mP=ft.strictObject({params:ft.record(ft.string(),Le),transitionId:ft.string().min(1)}),ic=ft.strictObject({envelopeRef:ft.string().min(1),seed:ft.string().min(1),steps:ft.array(mP).min(1),version:ft.literal(ac)});function sh(e){try{let t=JSON.parse(e),r=ic.safeParse(t);return r.success?{kind:"valid",repro:r.data}:{kind:"rejected",reason:"schema-mismatch"}}catch{return{kind:"rejected",reason:"invalid-json"}}}import{z as k}from"zod";var yP=k.strictObject({test:k.string().min(1),text:k.string()}),Yn=k.strictObject({baseLabel:k.string(),baseState:k.string().min(1),durationMs:k.number().int().nonnegative(),signature:k.string().optional(),steps:k.array(yP)}),hP=k.enum(["driver","infra","trail"]),gP=k.enum(["envelope-missing","format-unsupported","model-changed","target-changed","transition-missing"]),SP=k.discriminatedUnion("source",[k.strictObject({source:k.literal("empty-trail")}),k.strictObject({reason:gP,source:k.literal("assignment-rejected")}),k.strictObject({detail:k.string(),source:k.literal("config")}),k.strictObject({source:k.literal("lockfile-stale")}),k.strictObject({detail:k.string(),source:k.literal("transport")}),k.strictObject({category:hP,detail:k.string().min(1),kind:k.string(),source:k.literal("runtime")})]);function lh(e){switch(e.source){case"empty-trail":case"assignment-rejected":return"trail";case"config":case"lockfile-stale":case"transport":return"infra";case"runtime":return e.category}}var ch=k.discriminatedUnion("kind",[k.strictObject({kind:k.literal("aborted"),ranCount:k.number().int().nonnegative()}),k.strictObject({error:SP,kind:k.literal("error")}),k.strictObject({kind:k.literal("clean"),trail:Yn}),k.strictObject({kind:k.literal("coverage-gap"),runId:k.string().optional(),trail:Yn}),k.strictObject({kind:k.literal("flaky"),trail:Yn}),k.strictObject({kind:k.literal("seen"),trail:Yn}),k.strictObject({kind:k.literal("finding"),runId:k.string().optional(),trail:Yn})]);function dh({assignment:e,corpus:t,currentModelHash:r,currentTargetGeneration:n,envelopeRefs:o}){if(e.modelHash!==r)return{kind:"rejected",reason:"model-changed"};if(e.targetGeneration.value!==n.value)return{kind:"rejected",reason:"target-changed"};if(!o.has(e.envelopeRef))return{kind:"rejected",reason:"envelope-missing"};let a=new Set(t.map(i=>i.id));return e.steps.some(i=>!a.has(i.transitionId))?{kind:"rejected",reason:"transition-missing"}:{kind:"valid"}}import{createHash as bP}from"crypto";import{performance as Ja}from"perf_hooks";function za(e){return g({a:e.actor,l:e.startingState,v:e.viewport})}function Ka(e,t){return $e(J(e),r=>za(r.test)).map(r=>({name:r.ref,test:r.test}))}function Ha(e,t,r){return jr({...r,state:e.state,test:t.test})}var RP="symbolic-bug-finder-v2";function Ga(e){let t=Xo(e),r=Ka(e,{sweep:!1});if(!t.some(i=>i.effectStep.action.kind!=="goto")||r.length===0)return{kind:"model-empty"};let o=Nr(e),a=new Map(r.map(i=>[za(i.test),i]));return{kind:"prepared",value:{baseSpecByTest:new Map(J(e).flatMap(i=>{let s=a.get(za(i.test));return s==null?[]:[[i.ref,s]]})),baseSpecs:r,corpus:t,facts:{facts:o.facts.filter(i=>!i.localConsequence),overlays:Xe(e),overrides:o.overrides},lockfile:e,startingPointTests:new Map(r.map(i=>[i.name,i.test]))}}}async function Ya({attemptOrdinal:e,modelHash:t,prepared:r,reservedSignatures:n,strategy:o,targetGeneration:a}){let i=Ja.now(),s=EP({attemptOrdinal:e,modelHash:t}),l=qa({attemptOrdinal:e,corpus:r.corpus});if(l==null)throw new Error("prepared exploration has an empty transition corpus");let c=ph({agenda:l,attemptOrdinal:e,prepared:r}),d=Ja.now(),u=await wP({lockfile:r.lockfile,seed:s,specs:c}),f=Ja.now()-d,y=xa({agenda:l,assignmentSeed:s,corpus:r.corpus,facts:r.facts,reservedSignatures:n,startingPoints:u,strategy:o}),m={beamMs:y.telemetry.beamMs,candidateMs:y.telemetry.candidateMs,envelopesMs:f,expansionMs:y.telemetry.expansionMs,searchMs:y.telemetry.searchMs,selectionMs:y.telemetry.selectionMs,totalMs:Ja.now()-i};if(y.kind==="no-candidate")return{...y,timing:m};let h=r.startingPointTests.get(y.startingPoint),p=y.trace.selectedCoverageSignature;if(h==null||p==null)throw new Error("planner selected an incomplete assignment");return{assignment:{assignmentSeed:{value:s},coverageSignature:p,envelopeRef:y.startingPoint,modelHash:t,steps:[...y.steps],targetGeneration:a},kind:"assignment",timing:m,trace:y.trace}}var vP=8;function ph({agenda:e,attemptOrdinal:t,prepared:r}){let n=uh(r.corpus,e.primaryTransitionId),o=Qo(n.requiredState),a=r.baseSpecs.filter(c=>o==null||c.test.viewport===o).toSorted((c,d)=>c.name.localeCompare(d.name));if(a.length===0)return[];let i=t%a.length,s=[...a.slice(i),...a.slice(0,i)],l=[e.primaryTransitionId,e.secondaryTransitionId].flatMap(c=>{if(c==null)return[];let d=uh(r.corpus,c),u=r.baseSpecByTest.get(d.test);return u==null||o!=null&&u.test.viewport!==o?[]:[u]});return $e([...l,...s],c=>c.name).slice(0,vP)}function uh(e,t){let r=e.find(n=>n.id===t);if(r==null)throw new Error(`exploration agenda transition ${t} is missing`);return r}async function wP({lockfile:e,seed:t,specs:r}){let n={generate:Rr(br,t),params:void 0};return(await Promise.all(r.map(async a=>{let i=Lo({plan:a.test.startingState,seed:t}),s={...a,test:{...a.test,startingState:i}};return(await Ha(e,s,n)).match(c=>({env:c.env,logical:On(i),name:a.name,parameters:Sa({generate:n.generate,test:s.test,testRef:a.name}),snapshot:c.snapshot}),()=>null)}))).flatMap(a=>a==null?[]:[a])}function EP({attemptOrdinal:e,modelHash:t}){return bP("sha256").update(`${RP}:${t}:${String(e)}`).digest("base64url")}async function yh({attempts:e,modelHash:t,prepared:r,strategy:n}){let o=await AP({attempts:e,modelHash:t,prepared:r,strategy:n}),a=o.flatMap(p=>p.kind==="assignment"?[p.assignment]:[]),s=a.flatMap(p=>p.steps.map(b=>b.transitionId)).reduce((p,b)=>new Map([...p,[b,(p.get(b)??0)+1]]),new Map),l=new Set(o.map(p=>p.trace.agenda.primaryTransitionId)),c=r.corpus.filter(p=>l.has(p.id)&&!s.has(p.id)),d=r.corpus.filter(p=>l.has(p.id)&&s.get(p.id)===1),u=new Set(a.flatMap(p=>p.steps.flatMap((b,w,S)=>{let E=S[w+1];return E==null?[]:[`${b.transitionId}:${E.transitionId}`]}))),f=new Set(a.flatMap(p=>_r({corpus:r.corpus,steps:p.steps}))),y=a.filter(p=>new Set(p.steps.map(b=>PP(r.corpus,b.transitionId))).size>1).length,m=r.corpus.filter(p=>p.steps.some(b=>b.effects.some(w=>w.kind==="transform"))),h=OP(o);return{attempts:e,composablePairs:u.size,crossWorkflowPaths:y,effectKinds:[...new Set(r.corpus.flatMap(p=>p.steps.flatMap(b=>b.effects.map(w=>w.kind))))].toSorted((p,b)=>p.localeCompare(b)),envelopesReached:new Set(a.map(p=>p.envelopeRef)).size,isolatedTransitions:c.map(p=>sc(p)),noCandidates:h,opaqueTransforms:m.map(p=>sc(p)),patternsReached:[...f].toSorted((p,b)=>p.localeCompare(b)),plannedPaths:a.length,planningDepth:xP({assignments:a,results:o,strategy:n}),planningPerformance:MP(o),planningWork:TP(o),recommendations:IP({isolated:c,noCandidates:h,plannedPaths:a.length}),targetsAnalyzed:l.size,transitionCount:r.corpus.length,transitionsReached:s.size,weaklyConnectedTransitions:d.map(p=>sc(p))}}function xP({assignments:e,results:t,strategy:r}){let n=e.map(a=>a.steps.length),o=t.map(a=>kP(a.trace));return{averagePlannedSteps:fh(n),averageSearchedSteps:fh(o),maxPlannedSteps:mh(n),maxSearchedSteps:mh(o),searchStops:CP(t),targetSteps:r.maxAttemptLength}}function kP(e){return e.depths.reduce((t,r)=>Math.max(t,r.depth+(r.retained>0?1:0)),0)}function fh(e){return e.length===0?0:Za(e)}function Za(e){return e.reduce((t,r)=>t+r,0)/e.length}function mh(e){return e.length===0?0:Math.max(...e)}function CP(e){return e.reduce((t,r)=>{let n=r.trace.searchStopReason??"notStarted";return{...t,[n]:t[n]+1}},{budgetExhausted:0,frontierExhausted:0,notStarted:0,targetReached:0})}async function AP({attempts:e,modelHash:t,prepared:r,strategy:n}){return Array.from({length:e},(o,a)=>a).reduce(async(o,a)=>[...await o,await Ya({attemptOrdinal:a,modelHash:t,prepared:r,reservedSignatures:new Set,strategy:n,targetGeneration:{kind:"dev-session",value:"analysis"}})],Promise.resolve([]))}function PP(e,t){let r=e.find(n=>n.id===t);if(r==null)throw new Error(`analysis transition ${t} is missing`);return r.test}function OP(e){return e.reduce((t,r)=>r.kind==="assignment"?t:{...t,[r.reason]:t[r.reason]+1},{allReserved:0,budgetExhausted:0,modelEmpty:0,noEntry:0,noLegalExpansion:0,trailLengthExhausted:0})}function sc(e){return{action:Nt(e.effectStep.action),id:e.id,intent:e.intent,test:e.test}}function MP(e){return{beam:ir(e.map(t=>t.timing.beamMs)),candidates:ir(e.map(t=>t.timing.candidateMs)),envelopes:ir(e.map(t=>t.timing.envelopesMs)),expansion:ir(e.map(t=>t.timing.expansionMs)),search:ir(e.map(t=>t.timing.searchMs)),selection:ir(e.map(t=>t.timing.selectionMs)),total:ir(e.map(t=>t.timing.totalMs))}}function ir(e){if(e.length===0)return{averageMs:0,maxMs:0,p95Ms:0};let t=e.toSorted((o,a)=>o-a),r=t.at(Math.ceil(t.length*.95)-1),n=t.at(-1);if(r==null||n==null)throw new Error("exploration analysis timing sample is missing");return{averageMs:e.reduce((o,a)=>o+a,0)/e.length,maxMs:n,p95Ms:r}}function TP(e){return e.length===0?{averageExpandedNodes:0,averageParameterAttempts:0,averageRulesConsidered:0}:{averageExpandedNodes:Za(e.map(t=>t.trace.expanded)),averageParameterAttempts:Za(e.map(t=>t.trace.depths.reduce((r,n)=>r+n.parameterAttempts,0))),averageRulesConsidered:Za(e.map(t=>t.trace.depths.reduce((r,n)=>r+n.rulesConsidered,0)))}}function IP({isolated:e,noCandidates:t,plannedPaths:r}){return[...r===0?["No complete path could be proved. Add an entry navigation and declare every surface needed by the next action."]:[],...t.noEntry>0?["Some agendas have no modeled entry. Start those journeys with a declared navigation step."]:[],...e.length>0?[`${String(e.length)} targeted transitions could not be reached. Add the missing before-state declarations that connect them to earlier user actions.`]:[]]}import{createServer as JP}from"http";import{mkdir as GP,rm as YP,writeFile as ZP}from"fs/promises";import XP from"path";import{z as B}from"zod";var QP="otlp-port",gh=B.object({key:B.string(),value:B.object({boolValue:B.boolean().optional(),doubleValue:B.number().optional(),intValue:B.union([B.string(),B.number()]).optional(),stringValue:B.string().optional()})}),eO=B.object({attributes:B.array(gh).default([]),endTimeUnixNano:B.string(),kind:B.number().default(0),name:B.string(),parentSpanId:B.string().optional(),spanId:B.string(),startTimeUnixNano:B.string(),status:B.object({code:B.number(),message:B.string().optional()}).optional(),traceId:B.string()}),tO=B.object({resourceSpans:B.array(B.object({resource:B.object({attributes:B.array(gh).default([])}).optional(),scopeSpans:B.array(B.object({spans:B.array(eO).default([])})).default([])})).default([])});async function lc({localDir:e,onRrwebBatch:t,onSpan:r,writePortFile:n}){let{port:o,server:a}=await rO({onRrwebBatch:t,onSpan:r}),i=XP.join(e,QP);return n&&(await GP(e,{recursive:!0}),await ZP(i,String(o),{encoding:"utf8"})),{port:o,stop:async()=>{n&&await YP(i,{force:!0}),await sO(a)}}}function rO(e){return new Promise((t,r)=>{let n=JP((o,a)=>{nO(o,a,e)});n.on("error",r),n.listen(0,()=>{let o=n.address();if(o==null||typeof o=="string"){r(new Error("otlp_receiver_no_port"));return}t({port:o.port,server:n})})})}function nO(e,t,r){let n=oO(e.url);if(n!=null){hh(e).then(o=>{r.onRrwebBatch(n,o),Xa(t)}).catch(()=>{Xa(t)});return}hh(e).then(o=>{aO(tO.parse(JSON.parse(o.toString("utf8"))),r.onSpan),Xa(t)}).catch(()=>{Xa(t)})}function oO(e){if(e==null||!e.startsWith("/rrweb/"))return;let t=decodeURIComponent(e.slice(7));return t.length===0?void 0:t}function hh(e){return new Promise((t,r)=>{let n=[];e.on("data",o=>{n.push(o)}),e.on("end",()=>{t(Buffer.concat(n))}),e.on("error",r)})}function Xa(e){e.writeHead(200,{"content-type":"application/json"}),e.end("{}")}function aO(e,t){e.resourceSpans.flatMap(r=>r.scopeSpans).flatMap(r=>r.spans).forEach(r=>{t({attributes:iO(r.attributes),durationMs:Number((BigInt(r.endTimeUnixNano)-BigInt(r.startTimeUnixNano))/1000000n),kind:"span",name:r.name,parentSpanId:r.parentSpanId,source:"server",spanId:r.spanId,spanKind:Uu(r.kind),status:{code:Wu(r.status?.code??0),message:r.status?.message},timeNanos:r.startTimeUnixNano,traceId:r.traceId})})}function iO(e){return Object.fromEntries(e.map(({key:t,value:r})=>[t,String(r.stringValue??r.intValue??r.doubleValue??r.boolValue??"")]))}function sO(e){return new Promise((t,r)=>{e.close(n=>{if(n==null){t();return}r(n)}),e.closeAllConnections()})}import{err as Ih,errAsync as LO,ok as Lh,ResultAsync as Yr}from"neverthrow";function Vt(e,t,r){if(t==null)throw new Error("action requires a locator");return mt(e,t,r)}function mt(e,t,r){if(t.by==="inside"){if(t.scope.by==="frame"){let a=mt(e,t.scope.element,{visibleOnly:!1});return mt(a.contentFrame(),t.target,r)}let o=mt(e,t.scope,r);return mt(o,t.target,r)}if(t.by==="surface")return mt(e,t.container,r);if(t.by==="frame")return mt(e,t.element,r);let n=t.by==="testId"?e.getByTestId(t.value):e.locator(cc(t.role,t.name));return r.visibleOnly?n.filter({visible:!0}):n}function cc(e,t){return t==null?`role=${e}`:`role=${e}[name=${JSON.stringify(t)}i]`}var _t=class extends Error{readyKey;timeoutMs;constructor(t,r){super("app-not-ready"),this.readyKey=t,this.timeoutMs=r}};async function Sh({page:e,readiness:t,signal:r}){if(!await bh(e,r,t.budgetMs))throw new _t(hn,t.budgetMs)}async function Qa({page:e,readiness:t,signal:r,startMs:n,tries:o,url:a}){if(he(r),!await lO(e,a)){if(Date.now()-n>=t.budgetMs)throw new _t(hn,t.budgetMs);let s=t.backoffMs[Math.min(o,t.backoffMs.length-1)]??8e3;await et(s,r),await Qa({page:e,readiness:t,signal:r,startMs:n,tries:o+1,url:a});return}let i=Math.max(0,t.budgetMs-(Date.now()-n));if(!await bh(e,r,Math.min(i,dO(t,o)))){if(Date.now()-n>=t.budgetMs)throw new _t(hn,t.budgetMs);await Qa({page:e,readiness:t,signal:r,startMs:n,tries:o+1,url:a})}}function dc(e){let t=e instanceof Error?e.message:String(e);return/net::ERR_|ERR_HTTP_RESPONSE_CODE_FAILURE|ECONNREFUSED|ECONNRESET|socket hang up|fetch failed|page\.goto: Timeout/.test(t)}function Gr(e){let t=e instanceof Error?e.message:String(e);return/Execution context was destroyed|Cannot find context with specified id|[Ff]rame was detached|frame got detached/.test(t)}async function lO(e,t){let r=await cO(e,t);return r==="net-error"?!1:r==null||r.status()<400}async function cO(e,t){try{return await e.goto(t,{waitUntil:"domcontentloaded"})}catch(r){if(dc(r))return"net-error";throw r}}function dO(e,t){return t===0?e.budgetMs/2:e.budgetMs}var uO=50;async function bh(e,t,r){let n=fO({signal:t,timeoutMs:r}),o=Date.now()+r;try{return await Promise.race([pO({deadline:o,page:e,signal:t}),n.promise])}finally{n.clear()}}async function pO({deadline:e,page:t,signal:r}){for(;Date.now()<e;){if(he(r),await mO(t))return!0;await et(uO,r)}return!1}function ei(e){return new Promise(t=>{setTimeout(t,e)})}function fO({signal:e,timeoutMs:t}){let r,n;return{promise:new Promise((a,i)=>{n=()=>{i(new Qe)},r=setTimeout(()=>{a(!1)},Math.max(0,t)),e.addEventListener("abort",n,{once:!0})}),clear:()=>{clearTimeout(r),n!=null&&e.removeEventListener("abort",n)}}}async function mO(e){try{return await e.evaluate(yO,hn)}catch(t){if(Gr(t))return!1;throw t}}function yO(e){return Reflect.get(globalThis,e)===!0}async function uc(e,t,r){if(r.kind==="browser")return SO(e,t,r.key,r.value);if(r.kind==="not")return!await uc(e,t,r.inner);let n=Vt(e,r.locator,{visibleOnly:!0});if(r.kind==="value"){let o=await ti(n,"value");return o!=null&&Rh(o,r.value,r.match)}if(r.kind==="text"){let o=await ti(n,"text");return o!=null&&Rh(o,r.value,r.match)}return r.kind==="unobstructed"?wh(n):Eh({kind:r.kind,loc:n})}var hO=/locator\.(?:evaluate|inputValue|isChecked|isDisabled|isEnabled|isVisible|textContent): Timeout \d+ms exceeded[\s\S]*waiting for locator/u;async function pc(e,t){return t==="text"||await e.evaluate(r=>r.isContentEditable)?await e.textContent()??"":e.inputValue()}function vh(e){let t=e instanceof Error?e.message:String(e);return hO.test(t)}async function ti(e,t){if(await e.count()!==1)return null;try{return await pc(e,t)}catch(r){if(vh(r))return null;throw r}}function Rh(e,t,r){let n=Cr(e),o=Cr(t);return r==="contains"?n.includes(o):r==="startsWith"?n.startsWith(o):n===o}function wh(e){return e.evaluate(t=>{let r=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;if(n==null||r.width<=0||r.height<=0)return!1;let o=2,a=Math.min(9,Math.max(3,Math.round(r.width/12))),i=Math.min(5,Math.max(2,Math.round(r.height/12))),s=(d,u,f)=>Array.from({length:f},(y,m)=>d+o+(u-o*2)*m/(f-1)),c=s(r.left,r.width,a).flatMap(d=>s(r.top,r.height,i).map(u=>({x:d,y:u}))).filter(d=>d.x>=0&&d.y>=0&&d.x<=n.innerWidth&&d.y<=n.innerHeight);return c.length===0?!1:c.every(d=>{let u=t.ownerDocument.elementFromPoint(d.x,d.y);return u!=null&&(u===t||t.contains(u)||u.contains(t))})})}async function Eh({kind:e,loc:t}){if(await t.count()!==1)return!1;try{return await gO({kind:e,loc:t})}catch(r){if(vh(r))return!1;throw r}}function gO({kind:e,loc:t}){return e==="visible"?t.isVisible():e==="disabled"?t.isDisabled():e==="enabled"?t.isEnabled():e==="checked"?t.isChecked():e==="expanded"?t.evaluate(r=>r.getAttribute("aria-expanded")==="true"):e==="pressed"?t.evaluate(r=>r.getAttribute("aria-pressed")==="true"):t.evaluate(r=>r===r.ownerDocument.activeElement)}async function SO(e,t,r,n){let o=await t.read(e),a=Y(o.scalars,r);return n===null?a===void 0:a===n}async function xh(e,t,r){let n=kh(r,!1);if(n.check.kind==="browser"){let i=await t.read(e),s=Y(i.scalars,n.check.key);return{kind:"wrongContent",observed:s===void 0?"":String(s)}}let o=Vt(e,n.check.locator,{visibleOnly:!0}),a=await o.count();return a>1?{count:a,kind:"multipleMatches"}:a===0?{kind:"notFound"}:bO(o,n.check)}function kh(e,t){return e.kind==="not"?kh(e.inner,!t):{check:e,negated:t}}async function bO(e,t){switch(t.kind){case"value":{let r=await ti(e,"value");return r==null?{kind:"notFound"}:{kind:"wrongContent",observed:r}}case"text":{let r=await ti(e,"text");return r==null?{kind:"notFound"}:{kind:"wrongContent",observed:r}}case"unobstructed":{let r=await RO(e);return r==null?{kind:"wrongState",observed:{checkKind:"unobstructed",value:await wh(e)}}:{by:r,kind:"covered"}}case"visible":case"disabled":case"enabled":case"focused":case"checked":case"expanded":case"pressed":return{kind:"wrongState",observed:{checkKind:t.kind,value:await Eh({kind:t.kind,loc:e})}}}}function RO(e){return e.evaluate(t=>{let r=t.getBoundingClientRect(),n=t.ownerDocument.elementFromPoint(r.left+r.width/2,r.top+r.height/2);return n==null||n===t||t.contains(n)||n.contains(t)?null:"another element"})}import{err as ri,ok as vO,ResultAsync as wO}from"neverthrow";function Ch({bindings:e,classify:t,effects:r,observe:n,perform:o,signal:a,sync:i}){return n().andThen(s=>wO.fromSafePromise(Tl({bindings:e,classify:t,initialState:s,observe:n,step:{perform:o,plan:{constraints:[],effects:[...r]},sync:i}},a)).andThen(l=>EO(l)))}function EO(e){return e.kind==="perform-failed"||e.kind==="observe-failed"?ri(e.error):e.kind==="required-state-unsatisfied"?ri(Rn(new Error("the action ran while its declared state requirements were unmet"))):e.kind==="unresolved-reference"?ri(Er({path:e.path,record:e.record})):e.observation.mismatches.length===0?vO(e.bindings):ri(vn(e.observation.mismatches))}function xO(e){let t=globalThis.__ripploRrwebMirror;if(t!=null)return t.getId(e);let r=globalThis.top;if(r==null||typeof r!="object"||!("__ripploRrwebMirror"in r))return-1;let n=r.__ripploRrwebMirror;if(n==null||typeof n!="object"||!("getId"in n))return-1;let o=n.getId;if(typeof o!="function")return-1;let a=o.call(n,e);return typeof a=="number"?a:-1}async function Ah(e,t){if(t==null)return[];try{let r=mt(e,t,{visibleOnly:!1});if(await r.count()===0)return[];let n=await r.first().evaluate(xO);return n>0?[n]:[]}catch{return[]}}var kO=[250,750,2e3];async function fc(e,t,r,n,o){try{await CO(e,t,n,o.readiness,o.switchActor)}catch(a){let i=kO[r];if(i==null||!dc(a))throw a;await ei(i),await fc(e,t,r+1,n,o)}}async function CO(e,t,r,n,o){if(t.kind==="actor"){if(o==null)throw new Error("this driver cannot switch actors");await o(Ut(t.actorRef,t,"actorRef"));return}if(t.kind==="goto"){await Qa({page:e,readiness:n,signal:r,startMs:Date.now(),tries:0,url:Ut(t.url,t,"url")});return}if(t.kind==="press"&&t.locator==null){await e.keyboard.press(Ut(t.key,t,"key"));return}let a=t.kind!=="upload";await AO(e,Vt(e,t.locator,{visibleOnly:a}),t)}function Ut(e,t,r){if(e==null)throw new Error(`action "${t.kind}" requires ${r}`);return e}function AO(e,t,r){switch(r.kind){case"goto":throw new Error("goto must not be located");case"fill":return t.fill(String(Ut(r.value,r,"value")));case"clear":return t.clear();case"click":return t.click();case"dblclick":return t.dblclick();case"check":return t.check();case"uncheck":return t.uncheck();case"hover":return t.hover();case"select":return PO(e,t,String(Ut(r.value,r,"value")));case"upload":return t.setInputFiles(Ut(r.files,r,"files"));case"press":return t.press(Ut(r.key,r,"key"));case"drag":return t.dragTo(Vt(e,Ut(r.target,r,"target"),{visibleOnly:!0}));case"actor":throw new Error("actor switch must not be located")}}async function PO(e,t,r){if(await t.evaluate(o=>o.tagName==="SELECT")){await t.selectOption(r);return}await t.click(),await t.fill(r),await e.locator(cc("option",r)).filter({visible:!0}).click()}import{okAsync as OO}from"neverthrow";function Ph({readActor:e,session:t}){return e==null||t==null?OO({scalars:lt}):e(t).map(r=>({scalars:new Map(MO(r))}))}function MO(e){return e==null?[]:[[v({kind:"actor"}),{declared:!1,expect:{expect:"is",value:e},subject:{kind:"actor"}}]]}function Oh({action:e,bindings:t,parameters:r}){let n={...t,[at]:r};if(e.kind!=="actor"||e.actorRef==null)return n;let o=n[e.actorRef];return o===void 0?n:{...n,[gr]:o}}import{okAsync as TO}from"neverthrow";function Mh({initialState:e,observe:t}){if(t==null)return;let r=e;return()=>{if(r==null)return t();let n=r;return r=void 0,TO(n)}}var oi={backoffMs:[500,1e3,2e3,4e3,8e3],budgetMs:6e4},NO={classifyLogicalState:Ll,initialLogicalState:void 0,initialStateEffectBindings:$t,readiness:oi,readLogicalState:void 0,readSession:void 0,switchActor:void 0};function yc(e,t,r,n,{classifyLogicalState:o,initialLogicalState:a,initialStateEffectBindings:i,readiness:s,readLogicalState:l,readSession:c,switchActor:d}=NO){let u=i,f=Mh({initialState:a,observe:l});return{awaitCheck:(y,m)=>ni({bindings:u,check:y}).asyncAndThen(h=>Yr.fromPromise(HO({check:h,page:e,pageState:r,signal:n,timeoutMs:m}),p=>_n(p)?{kind:"aborted"}:Zn(p))),diagnoseCheck:y=>ni({bindings:u,check:y}).asyncAndThen(m=>Yr.fromPromise(mc(xh(e,r,m),`diagnose ${y.kind}`),Zn)),evaluate:y=>ni({bindings:u,check:y}).asyncAndThen(m=>Yr.fromPromise(mc(hc(e,r,m),`check ${y.kind}`),Zn)),locateIds:y=>Ah(e,Fh(y,jt(u))),observe:y=>Yr.fromPromise(c==null?Promise.resolve(void 0):c(),Zn).andThen(m=>VO(Ph({readActor:t,session:m}))).andThen(m=>Yr.fromPromise(mc(JO({backend:m,env:jt(u),page:e,pageState:r,tracked:y}),"observe"),Zn)),perform:y=>DO({bindings:u,classifyLogicalState:o,options:y,page:e,readiness:s,readLogicalState:f,signal:n,switchActor:d}).map(m=>(u=m.bindings,{stateBindings:m.bindings,stateEffectsVerified:m.stateEffectsVerified})),resolveCheck:y=>ni({bindings:u,check:y}).unwrapOr(null)}}function ni({bindings:e,check:t}){try{return Lh(Ta(t,jt(e)))}catch(r){return Ih(Nh(r))}}function Nh(e){if(!(e instanceof G))throw e;let t=e.subject,r=Ct(t);return r==null?Er({path:[],record:t}):Er({path:[r.field],record:r.alias})}function Fh(e,t){if(e!=null)try{return _e(e,t)}catch(r){if(r instanceof G)return;throw r}}function FO(e,t){try{return Lh(Ml(e,jt(t)))}catch(r){return Ih(Nh(r))}}function DO(e){let{bindings:t,options:r}=e,n=Oh({action:r.action,bindings:t,parameters:r.parameters});return FO(r.action,n).match(o=>BO({...e,action:o,actionBindings:n}),o=>LO(o))}function BO({action:e,actionBindings:t,classifyLogicalState:r,options:n,page:o,readiness:a,readLogicalState:i,signal:s,switchActor:l}){let c=()=>Yr.fromPromise(fc(o,e,0,s,{readiness:a,switchActor:l}),d=>UO(e,d));return i==null?c().map(()=>({bindings:t,stateEffectsVerified:!1})):Ch({bindings:t,classify:r,effects:n.effects,observe:i,perform:c,signal:s,sync:n.sync}).map(d=>({bindings:d,stateEffectsVerified:!0}))}function Zn(e){return xr(e)}async function hc(e,t,r){try{return await uc(e,t,r)}catch(n){if(Gr(n)||jO(n))return!1;throw n}}var $O=/strict mode violation/;function jO(e){return e instanceof Error&&$O.test(e.message)}function VO(e){return e.mapErr(t=>t.kind==="action-failed"||t.kind==="check-failed"?xr(new Error(_O(t.kind))):t)}function _O(e){return`unexpected ${e} while reading app state`}function UO(e,t){return t instanceof _t?As(t.readyKey,t.timeoutMs):Ms(e.kind,zO(t))}var WO=/resolved to (\d+) elements/,qO=/intercepts pointer events/;function zO(e){let t=e instanceof Error?e.message:String(e),r=WO.exec(t);return r?.[1]!=null?{count:Number(r[1]),kind:"multipleMatches"}:qO.test(t)?{by:"another element",kind:"covered"}:e instanceof Error&&e.name==="TimeoutError"&&t.includes("waiting for")?{kind:"notFound"}:Ts(e)}var KO=75;function HO(e){return Dh(e,Date.now()+e.timeoutMs)}async function Dh(e,t){return he(e.signal),await hc(e.page,e.pageState,e.check)?!0:Date.now()>=t?!1:(await et(KO,e.signal),Dh(e,t))}async function JO({backend:e,env:t,page:r,pageState:n,tracked:o}){let a=await Bh(r,n,0),i=await GO({env:t,page:r,pageState:n,tracked:o});return{snapshot:{...e,scalars:new Map([...e.scalars,...a.scalars,...i])}}}async function GO({env:e,page:t,pageState:r,tracked:n}){let o=await Promise.all([...n.values()].filter(a=>a.subject.kind==="element").map(async a=>{let i=await YO({env:e,page:t,pageState:r,subject:a.subject});return i===void 0?[]:[[v(a.subject),{declared:!0,expect:{expect:"is",value:i},subject:a.subject}]]}));return new Map(o.flat())}async function YO({env:e,page:t,pageState:r,subject:n}){let o=Fh(n.locator,e);if(o!==void 0)return n.state==="value"||n.state==="text"?ZO(t,o,n.state):hc(t,r,{kind:n.state,locator:o})}async function ZO(e,t,r){try{return await pc(Vt(e,t,{visibleOnly:!0}),r)}catch{return""}}var XO=[100,250,500];async function Bh(e,t,r){try{return await t.read(e)}catch(n){let o=XO[r];if(o==null||!Gr(n))throw n;return await ei(o),Bh(e,t,r+1)}}var Th=35e3;function mc(e,t){let r,n=new Promise((o,a)=>{r=setTimeout(()=>{a(new Error(`driver op "${t}" exceeded ${String(Th)}ms`))},Th)});return Promise.race([e,n]).finally(()=>{clearTimeout(r)})}import nM from"path";var $h={read:QO};async function QO(e){return{scalars:Be(Ar(e.url()),eM([[{kind:"title"},await e.title()],[{kind:"viewport"},rM(e.viewportSize())]]))}}function eM(e){return new Map(e.flatMap(([t,r])=>r===void 0?[]:[[v(t),{declared:!0,expect:{expect:"is",value:r},subject:t}]]))}var tM=768;function rM(e){return e==null?"":e.width<tM?"mobile":"desktop"}var Vh={desktop:{height:720,width:1280},mobile:{height:844,width:390}};function ai(e){return Vh[e]}var rH=Vh.desktop;async function gc({attachBrowser:e,baseUrl:t,browser:r,browserStateSeed:n,capture:o,eventualStatePaths:a,fixturesDir:i,networkHeaders:s,prepared:l,readActor:c,readLogicalState:d,releaseBrowser:u,session:f,signal:y,signInActor:m,stateEffectBindings:h,viewport:p}){let b=await iM({baseUrl:t,browser:r,networkHeaders:s,prepared:l,session:f,viewport:p});l==null&&await qh({browserStateSeed:n,context:b});let w=l?.page??await b.newPage(),S=w;e(S),await u().match(()=>{},W=>{throw new Error(`Ripplo could not release browser state: ${W.kind}`)});let E=l==null?void 0:await oM({page:w,pageLike:S,readLogicalState:d,signal:y}),L=o==null?uM():await o.hub.attach(b,o.runId);L.onPage(w);let V=lM({baseUrl:t,context:b,page:w,signInActor:m}),ne=c==null?void 0:cM(t,b);return{context:b,driver:mM(pM(yc(S,c,$h,y,{classifyLogicalState:Nl(a),initialLogicalState:E,initialStateEffectBindings:h,readiness:oi,readLogicalState:d,readSession:ne,switchActor:V}),i),L),emitStepOutcome:L.emitStepOutcome,close:()=>yM({context:b,handle:L})}}async function oM({page:e,pageLike:t,readLogicalState:r,signal:n}){await Sh({page:t,readiness:oi,signal:n});let o=await aM({readLogicalState:r});return await e.goto("about:blank",{waitUntil:"domcontentloaded"}),o}async function aM({readLogicalState:e}){if(e!=null)return e().match(t=>t,t=>{throw new Error(`Ripplo could not read browser-backed state before starting the workflow: ${Yt(t)}`)})}async function iM({baseUrl:e,browser:t,networkHeaders:r,prepared:n,session:o,viewport:a}){let i=n?.context??await t.newContext({baseURL:e,ignoreHTTPSErrors:!0,reducedMotion:"reduce",storageState:o==null?void 0:{cookies:ii(o.cookies,e),origins:o.origins},viewport:a});return r!=null&&await dM(i,e,r),o?.headers!=null&&await i.setExtraHTTPHeaders(o.headers),i}async function _h({attachBrowser:e,baseUrl:t,browser:r,browserStateSeed:n,viewport:o}){let a=await r.newContext({baseURL:t,ignoreHTTPSErrors:!0,reducedMotion:"reduce",viewport:o});await qh({browserStateSeed:n,context:a});let i=await a.newPage();return e(i),{context:a,page:i}}async function Uh({baseUrl:e,prepared:t,session:r}){r!=null&&(await t.context.addCookies(ii(r.cookies,e)),r.headers!=null&&await t.context.setExtraHTTPHeaders(r.headers)),await t.page.goto(e,{waitUntil:"domcontentloaded"}),r!=null&&await sM({baseUrl:e,page:t.page,session:r})}async function sM({baseUrl:e,page:t,session:r}){let n=new URL(e).origin,o=r.origins.find(a=>a.origin===n);o!=null&&(await t.evaluate(a=>{a.forEach(({name:i,value:s})=>{localStorage.setItem(i,s)})},o.localStorage),await t.reload({waitUntil:"domcontentloaded"}))}async function Sc(e,t){let r=await zh(e,void 0);try{return await t(r)}finally{await r.close()}}async function Wh(e){let{chromium:t}=await import("playwright");return t.launchPersistentContext(e,{headless:!1,viewport:null})}async function qh({browserStateSeed:e,context:t}){await t.addInitScript("globalThis.__name = globalThis.__name ?? ((target) => target);"),await t.addInitScript(`globalThis[${JSON.stringify(ku)}] = ${JSON.stringify(e)};`)}function lM({baseUrl:e,context:t,page:r,signInActor:n}){if(n!=null)return async o=>{let a=await n(o).match(i=>i,i=>{throw new Error(`actor switch failed: ${i.kind}`)});await t.clearCookies(),await t.addCookies(ii(a.cookies,e)),a.headers!=null&&await t.setExtraHTTPHeaders(a.headers),await r.reload()}}function ii(e,t){let r=new URL(t).hostname;return e.map(n=>({...n,domain:r}))}function cM(e,t){return async()=>{let r=await t.cookies();return{cookies:ii(r,e),headers:void 0,origins:[]}}}async function dM(e,t,r){let n=new URL(t).host;await e.route(o=>o.host===n,o=>o.continue({headers:{...o.request().headers(),...r}}))}function uM(){return{emitAction:()=>{},emitStepOutcome:()=>{},finish:()=>Promise.resolve(),onPage:()=>{}}}async function zh(e,t){let{chromium:r}=await import("playwright"),n=t==null?[]:[`--disk-cache-dir=${t}`,"--disk-cache-size=268435456"];return r.launch({args:n,headless:!e})}function si({cacheDir:e,headed:t}){let r;return{acquire:async()=>{let a=r;if(a!=null){let i=await a.catch(()=>{});if(i?.isConnected()===!0)return i;r===a&&(r=void 0)}return r??=zh(t,e),r},close:async()=>{let a=r;r=void 0,a!=null&&await a.then(i=>i.close()).catch(()=>{})}}}function pM(e,t){return{...e,perform:r=>e.perform({...r,action:fM(r.action,t)})}}function fM(e,t){return e.kind!=="upload"||e.files==null?e:{...e,files:e.files.map(r=>nM.join(t,r))}}function mM(e,t){return{...e,perform:r=>(t.emitAction(r.action),e.perform(r))}}async function yM({context:e,handle:t}){await jh(t.finish()),await jh(e.close())}var hM=15e3;async function jh(e){let t,r=new Promise(n=>{t=setTimeout(n,hM)});await Promise.race([e.catch(()=>{}),r]).finally(()=>{clearTimeout(t)})}import{err as eo,ok as to,ResultAsync as wg}from"neverthrow";import{z as eT}from"zod";import{err as ig,errAsync as sg,ok as cg,okAsync as tT,ResultAsync as rT}from"neverthrow";var Gh=Rs(yu(),1);import{err as Xn,ok as bc}from"neverthrow";import gM from"crypto";import{err as SM,errAsync as Kh,ok as bM,ResultAsync as li}from"neverthrow";var RM=1e4,vM=[250,750,2e3];function ci({response:e,schemaHash:t,source:r}){return e.schemaHash===t&&e.source===r}function sr(e){return Hh(e.retry,()=>CM(e),0)}function Hh(e,t,r){return t().orElse(n=>{let o=vM[r];return o==null||!EM(n,e)?Kh(n):li.fromSafePromise(kM(o)).andThen(()=>Hh(e,t,r+1))})}var wM=new Set(["EAI_AGAIN","ECONNREFUSED","ENOTFOUND"]);function EM(e,t){return e.kind==="aborted"?!1:xM(e)?!0:t==="connection"?!1:e.kind==="engine-network"||e.kind==="engine-http"&&e.status>=500}function xM(e){return e.kind==="engine-network"&&e.code!=null&&wM.has(e.code)}function kM(e){return new Promise(t=>{setTimeout(t,e)})}function CM({baseUrl:e,body:t,extraHeaders:r,path:n,schema:o,signal:a,webhook:i}){let s=JSON.stringify(t);return li.fromPromise(fetch(`${e}${n}`,{body:s,headers:{...r,"Content-Type":"application/json",...AM(i,s)},method:"PUT",signal:PM(a)}),l=>bn(n,l)).andThen(l=>OM(l,n)).andThen(l=>MM(o,l,n)).mapErr(l=>a?.aborted===!0?Is():l)}function AM(e,t){let r=`msg_${gM.randomUUID()}`,n=new Date;return{"webhook-id":r,"webhook-signature":e.sign(r,n,t),"webhook-timestamp":String(Math.floor(n.getTime()/1e3))}}function PM(e){let t=AbortSignal.timeout(RM);return e==null?t:AbortSignal.any([e,t])}function OM(e,t){return e.ok?li.fromPromise(e.json(),r=>bn(t,r)):li.fromPromise(e.text().catch(()=>""),r=>bn(t,r)).andThen(r=>Kh(Cs(t,e.status,r)))}function MM(e,t,r){let n=e.safeParse(t);return n.success?bM(n.data):SM(A(r,n.error))}function Yh({baseUrl:e,extraHeaders:t,runId:r,schema:n,schemaHash:o,secret:a,setupCapable:i,source:s},l){let c=new Gh.Webhook(a);return{setup:i?({input:d,target:u})=>sr({baseUrl:e,body:{input:d,runId:r,schemaHash:o,source:s,target:u},extraHeaders:t,path:"/setup",retry:"connection",schema:Au,signal:l,webhook:c}).andThen(f=>ci({response:f,schemaHash:o,source:s})?Jh({path:"/setup",value:f.state}):Xn(A("/setup",f))):void 0,source:s,teardown:i?()=>TM({baseUrl:e,extraHeaders:t,runId:r,schemaHash:o,source:s,webhook:c}):void 0,read:()=>sr({baseUrl:e,body:{runId:r,schemaHash:o,source:s},extraHeaders:t,path:"/state",retry:"transient",schema:Cu,signal:l,webhook:c}).andThen(d=>ci({response:d,schemaHash:o,source:s})?Jh({path:"/state",value:d.state}).andThen(u=>{let f=n.safeParse(u);return f.success?bc({[s]:u}):Xn(A("/state",f.error))}):Xn(A("/state",d)))}}function TM({baseUrl:e,extraHeaders:t,runId:r,schemaHash:n,source:o,webhook:a}){return sr({baseUrl:e,body:{runId:r,schemaHash:n,source:o},extraHeaders:t,path:"/teardown",retry:"connection",schema:Mu,signal:void 0,webhook:a}).andThen(i=>ci({response:i,schemaHash:n,source:o})?bc(void 0):Xn(A("/teardown",i)))}function Jh({path:e,value:t}){let r=wr(t);return r==null?bc(t):Xn(A(e,{issue:"state-budget",stateBudget:r}))}import{err as Ee,errAsync as Qn,ok as Wt,okAsync as NM,Result as vc,ResultAsync as wc}from"neverthrow";function Zh({afterHttpSetup:e,browserSources:t,clients:r,operations:n,setupOperations:o,teardown:a,verify:i}){let s=IM({browserSources:t,clients:r,operations:n});return a(s.httpClients).andThen(()=>o({pending:s.httpOperations,results:{}})).andThen(l=>e(l).map(c=>({checkpoint:c,results:l}))).andThen(l=>LM({http:l,phases:s,setupOperations:o,teardown:a})).andThen(({checkpoint:l,results:c})=>i(c).map(d=>({checkpoint:l,setup:d})))}function IM({browserSources:e,clients:t,operations:r}){return{browserClients:t.filter(n=>e.has(n.source)),browserOperations:r.filter(n=>e.has(n.source)),httpClients:t.filter(n=>!e.has(n.source)),httpOperations:r.filter(n=>!e.has(n.source))}}function LM({http:e,phases:t,setupOperations:r,teardown:n}){return n(t.browserClients).andThen(()=>r({pending:t.browserOperations,results:e.results})).map(o=>({checkpoint:e.checkpoint,results:o}))}function Xh({browserSources:e,clients:t,datetimePaths:r}){return KM(t),{read:()=>Qh({clients:t,datetimePaths:r}),setup:n=>FM({browserSources:e,clients:t,datetimePaths:r,...n}),teardown:()=>kc(t)}}function Qh({clients:e,datetimePaths:t}){return wc.combine(e.map(r=>r.read())).map(r=>Io({datetimePaths:t,state:r.reduce((n,o)=>({...n,...o}),{})}))}function FM({afterHttpSetup:e,browserSources:t,clients:r,datetimePaths:n,plan:o}){return UM({browserSources:t,clients:r,plan:o}).match(()=>Zh({afterHttpSetup:e,browserSources:t,clients:r,operations:o.operations,teardown:kc,setupOperations:({pending:a,results:i})=>tg({clients:r,datetimePaths:n,pending:a,results:i}),verify:a=>Qh({clients:r,datetimePaths:n}).andThen(i=>BM({plan:o,results:a,state:i}))}).orElse(a=>DM({clients:r,error:a})),a=>Qn(a))}function DM({clients:e,error:t}){return kc(e).andThen(()=>Qn(t)).orElse(()=>Qn(t))}function BM({plan:e,results:t,state:r}){let n=e.operations.find(o=>{let a=t[o.id];return a===void 0||!_M({operation:o,result:a,state:r})});return n!=null?Ee(A("/state",{operation:n.id})):$M({constraints:e.constraints,results:t}).andThen(o=>{let a=Vn({observed:r,plan:{constraints:[...o],effects:[]},pre:r});return a.requiredStateHolds?Wt({constraints:o,results:t,state:r}):Ee(vn(a.mismatches))})}function $M({constraints:e,results:t}){return vc.combine(e.map(r=>jM({constraint:r,results:t})))}function jM({constraint:e,results:t}){switch(e.kind){case"optional-path":case"optional-record":return Ee(A("/setup",{issue:"unresolved-optional"}));case"equals":return di({expression:e.value,results:t}).map(r=>({kind:"equals",selector:e.selector,value:r}));case"absent-path":return Wt(e);case"closed-record":return VM({operations:e.operations,results:t}).map(r=>({kind:"closed-record",rows:r,selector:e.selector}));case"required-record":return Rc({fields:e.fields,results:t}).map(r=>({alias:e.alias,fields:r,kind:"required-record",selector:e.selector}));case"absent-record":return Rc({fields:e.fields,results:t}).map(r=>({fields:r,kind:"absent-record",selector:e.selector}))}}function VM({operations:e,results:t}){return vc.combine(e.map(r=>{let n=t[r];return n===void 0?Ee(A("/setup",{operation:r})):Wt(n)}))}function Rc({fields:e,results:t}){return Object.entries(e).reduce((r,[n,o])=>r.andThen(a=>di({expression:o,results:t}).map(i=>({...a,[n]:i}))),Wt({}))}function _M({operation:e,result:t,state:r}){let n=r[e.source];if(n===void 0)return!1;if(e.target.kind==="state")return Ec({actual:n,expected:t});let o=xc({path:e.target.path,value:n});return o.found&&x(o.value)&&Object.values(o.value).some(a=>g(a)===g(t))}function Ec({actual:e,expected:t}){return x(t)?x(e)?Object.entries(t).every(([r,n])=>{let o=e[r];return o!==void 0&&Ec({actual:o,expected:n})}):!1:g(e)===g(t)}function UM({browserSources:e,clients:t,plan:r}){if(r.operations.some(c=>c.optional)||r.constraints.some(c=>c.kind==="optional-path"||c.kind==="optional-record"))return Ee(A("/setup",{issue:"unresolved-optional"}));let n=r.operations.map(c=>c.id);if(new Set(n).size!==n.length)return Ee(A("/setup",{issue:"duplicate-operation"}));let o=e==null?void 0:Pu({browserSources:e,operations:r.operations})[0];if(o!=null)return Ee(A("/setup",{dependency:o.dependency.id,issue:"browser-http-dependency",operation:o.operation.id}));let a=new Set(n),i=[...WM(r).flatMap(c=>vr(c)),...r.constraints.flatMap(c=>c.kind==="closed-record"?c.operations:[])].find(c=>!a.has(c));if(i!=null)return Ee(A("/setup",{operation:i}));if(!eg({completed:[],pending:r.operations}))return Ee(A("/setup",{issue:"cyclic-operations",operations:r.operations.map(({id:c})=>c)}));let l=[...r.operations.map(c=>c.source),...r.constraints.map(c=>c.selector.source)].find(c=>!t.some(d=>d.source===c));return l==null?Wt({}):Ee(A("/setup",{source:l}))}function WM(e){return[...e.operations.map(t=>t.input),...e.constraints.flatMap(t=>No(t))]}function eg({completed:e,pending:t}){if(t.length===0)return!0;let r=new Set(e),n=t.filter(o=>vr(o.input).every(a=>r.has(a)));return n.length>0&&eg({completed:[...e,...n.map(({id:o})=>o)],pending:t.filter(o=>!n.some(a=>a.id===o.id))})}function tg({clients:e,datetimePaths:t,pending:r,results:n}){if(r.length===0)return NM(n);let o=r.filter(a=>vr(a.input).every(i=>Object.hasOwn(n,i)));return o.length===0?Qn(A("/setup",{issue:"cyclic-operations",operations:r.map(({id:a})=>a)})):wc.combine(o.map(a=>qM({clients:e,datetimePaths:t,operation:a,results:n}))).andThen(a=>tg({clients:e,datetimePaths:t,pending:r.filter(i=>!o.some(s=>s.id===i.id)),results:a.reduce((i,s)=>({...i,[s.id]:s.state}),n)}))}function qM({clients:e,datetimePaths:t,operation:r,results:n}){let a=e.find(({source:i})=>i===r.source)?.setup;return a==null?Qn(A("/setup",{source:r.source})):di({expression:r.input,results:n}).asyncAndThen(i=>a({input:i,target:r.target}).andThen(s=>{let l=Eu({datetimePaths:t,path:r.target.kind==="state"?[]:[...r.target.path,r.id],source:r.source,value:s});return Ec({actual:l,expected:i})?Wt({id:r.id,state:l}):Ee(A("/setup",{issue:"materialized-input-mismatch",operation:r.id}))}))}function di({expression:e,results:t}){switch(e.kind){case"value":return Wt(e.value);case"reference":return zM({operation:e.operation,path:e.path,results:t});case"generate":return Ee(A("/setup",{slot:e.name}));case"array":return vc.combine(e.items.map(r=>di({expression:r,results:t})));case"object":return Rc({fields:e.fields,results:t})}}function zM({operation:e,path:t,results:r}){let n=r[e];if(n===void 0)return Ee(A("/setup",{operation:e}));let o=xc({path:t,value:n});return o.found?Wt(o.value):Ee(A("/setup",{operation:e,path:t}))}function xc({path:e,value:t}){let[r,...n]=e;if(r==null)return{found:!0,value:t};if(!x(t))return{found:!1};let o=t[r];return o===void 0?{found:!1}:xc({path:n,value:o})}function kc(e){return wc.combine(e.flatMap(t=>t.teardown==null?[]:[t.teardown()])).map(()=>{})}function KM(e){let t=e.map(r=>r.source);if(new Set(t).size!==t.length)throw new TypeError("state-source-duplicate")}import{errAsync as pi,okAsync as rg,ResultAsync as ng}from"neverthrow";import{z as Cc}from"zod";function og(e){let t=Cc.fromJSONSchema(e.jsonSchema),r,n=()=>{if(r==null||r.url()==="about:blank")throw new TypeError(`Browser state source "${e.name}" is not mounted`);return r};return{client:{setup:e.setupCapable?({input:o,target:a})=>ui({mountedPage:n,request:{input:o,kind:"setup",source:e.name,target:a}}).andThen(i=>XM(i)):void 0,source:e.name,teardown:e.setupCapable?()=>ui({mountedPage:n,request:{kind:"teardown",source:e.name}}).map(()=>{}):void 0,read:()=>ui({mountedPage:n,request:{kind:"read",source:e.name}}).andThen(o=>ZM({definition:e,schema:t,value:o}))},attach:o=>{r=o},mounted:()=>r!=null&&r.url()!=="about:blank",release:()=>ui({mountedPage:n,request:{kind:"release",source:e.name}}).map(()=>{})}}function ui({mountedPage:e,request:t}){return ng.fromPromise(Promise.resolve().then(e),r=>A(`/browser-state/${t.kind}`,r)).andThen(r=>GM({page:r,request:t}))}var HM=3e4,JM=25;function GM({page:e,request:t}){return ng.fromPromise(ag({deadline:Date.now()+HM,page:e,request:t}),r=>A(`/browser-state/${t.kind}`,r))}async function ag({deadline:e,page:t,request:r}){try{return await t.evaluate(QM,{mountKey:xu,request:r,timeoutMs:Math.max(0,e-Date.now())})}catch(n){if(!Gr(n)||Date.now()>=e)throw n;return await YM(JM),ag({deadline:e,page:t,request:r})}}function YM(e){return new Promise(t=>setTimeout(t,e))}function ZM({definition:e,schema:t,value:r}){let n=wr(r);if(n!=null)return pi(A("/state",{issue:"state-budget",stateBudget:n}));let o=t.safeParse(r);if(!o.success)return pi(A("/state",o.error));let a=Cc.json().safeParse(o.data);return a.success?rg({[e.name]:a.data}):pi(A("/state",a.error))}function XM(e){let t=Cc.json().safeParse(e);return t.success?rg(t.data):pi(A("/setup",t.error))}async function QM({request:e,timeoutMs:t}){let r=Date.now()+t;for(;globalThis.__ripploBrowserStateMount==null&&Date.now()<r;)await new Promise(o=>setTimeout(o,25));let n=globalThis.__ripploBrowserStateMount;if(n==null)throw new TypeError("The browser state source did not mount before setup timed out");switch(e.kind){case"read":return n.readSource(e.source);case"release":return await n.releaseSource(e.source),null;case"setup":return n.setupSource(e);case"teardown":return await n.teardownSource(e.source),null}}function dg({baseUrl:e,extraHeaders:t,runId:r,secret:n,state:o},a){let i=o.sources.filter(d=>d.transport==="browser").map(d=>og(d)),s=Xh({browserSources:new Set(i.map(({client:{source:d}})=>d)),clients:[...o.sources.filter(d=>d.transport==="http").map(d=>Yh({baseUrl:e,extraHeaders:t,runId:r,schema:lg(d.jsonSchema),schemaHash:d.schemaHash,secret:n,setupCapable:d.setupCapable,source:d.name},a)),...i.map(d=>d.client)],datetimePaths:o.datetimePaths}),l=lg(o.jsonSchema),c=d=>oT({datetimePaths:o.datetimePaths,logicalState:d,schema:l});return{usesBrowser:i.length>0,attachBrowser:d=>{i.forEach(u=>{u.attach(d)})},read:()=>s.read().andThen(d=>i.every(u=>u.mounted())?c(d):cg(d)),releaseBrowser:()=>rT.combine(i.map(d=>d.release())).map(()=>{}),setup:d=>s.setup(d).andThen(({checkpoint:u,setup:f})=>nT({client:s,setup:f,validate:c}).map(y=>({checkpoint:u,setup:y}))),teardown:()=>s.teardown()}}function nT({client:e,setup:t,validate:r}){return r(t.state).match(n=>tT({...t,state:n}),n=>e.teardown().andThen(()=>sg(n)).orElse(()=>sg(n)))}function oT({datetimePaths:e,logicalState:t,schema:r}){let n=wr(t);if(n!=null)return ig(A("/state",{issue:"state-budget",stateBudget:n}));let o=r.safeParse(t);return o.success?cg(Io({datetimePaths:e,state:t})):ig(A("/state",o.error))}function lg(e){return eT.fromJSONSchema(e)}var ug=Rs(yu(),1);import{err as aT,ok as iT}from"neverthrow";function pg({baseUrl:e,extraHeaders:t,runId:r,secret:n,signal:o}){let a=new ug.Webhook(n);return{currentActor:i=>sr({baseUrl:e,body:{runId:r,session:i},extraHeaders:t,path:"/current-actor",retry:"transient",schema:Su,signal:o,webhook:a}).map(s=>s.actor==null?null:{row:s.actor.row,selector:{path:s.actor.path,source:s.actor.source}}),signIn:({actor:i,schemaHash:s,selector:l})=>sr({baseUrl:e,body:{actor:i,path:l.path,runId:r,schemaHash:s,source:l.source},extraHeaders:t,path:"/sign-in",retry:"connection",schema:gu,signal:o,webhook:a}).andThen(c=>sT({response:c,schemaHash:s,selector:l})?iT(c.session):aT(A("/sign-in",c)))}}function sT({response:e,schemaHash:t,selector:r}){return e.schemaHash===t&&e.source===r.source&&e.path.join(".")===r.path.join(".")}function Ac({lockfile:e,options:t,runId:r,signal:n}){let o=dg({baseUrl:t.engineUrl,extraHeaders:void 0,runId:r,secret:t.secret,state:e.state},n),a=pg({baseUrl:t.engineUrl,extraHeaders:void 0,runId:r,secret:t.secret,signal:n});return{attachBrowser:o.attachBrowser,authentication:a,releaseBrowser:o.releaseBrowser,setupState:o.setup,teardown:o.teardown,usesBrowser:o.usesBrowser,readState:()=>o.read().mapErr(lT)}}function lT(e){return e.kind==="action-failed"||e.kind==="check-failed"?xr(e):e}function fg({corpus:e,parameterOverrides:t,parameters:r,preferred:n,state:o}){return n!=null?n.map(i=>({...i,params:{...i.params,...t}})):e.reduce((i,s,l)=>{let c=u=>({...or({action:s,attempt:u,state:i.parameters}),...t}),d=dl({attempts:Vr({action:s,state:i.parameters}),paramsForAttempt:c,rule:s,state:i.state});if(d==null)throw Os({reason:Dn(s,i.state,c(0)),stepIndex:l,test:s.test});return{parameters:Dt({action:s,params:d.params,state:i.parameters}),sequence:[...i.sequence,{params:d.params,transition:s}],state:d.stepRun.next}},{parameters:r,sequence:[],state:o}).sequence}function lr(e,t){e?.({activity:t,deadlineAt:null,retry:null})}function fi({env:e,test:t}){return Object.fromEntries(Object.keys(t.params).map(r=>{let n=e.get(z(r));if(n===void 0)throw new TypeError(`parameter "${r}" was not materialized`);return[r,n]}))}import{errAsync as fT,ResultAsync as Zr}from"neverthrow";import{errAsync as Pc,okAsync as Tc}from"neverthrow";function mg({actor:e,authentication:t,constraints:r,results:n,state:o}){return e.kind==="anonymous"?Tc(void 0):hg({alias:e.alias,authentication:t,constraints:r,results:n,state:o}).map(({row:a,session:i})=>({alias:e.alias,row:a,session:i}))}function yg({authentication:e,setup:t,state:r}){return n=>hg({alias:n,authentication:e,constraints:t.constraints,results:t.results,state:r}).map(({session:o})=>o)}function hg({alias:e,authentication:t,constraints:r,results:n,state:o}){let a=n[e],i=gg({alias:e,constraints:r}),s=o.sources.find(l=>l.name===i?.source);return a==null||i==null||s==null?Pc(me(new Error(`Ripplo could not find materialized actor "${e}"`))):s.transport!=="http"?Pc(me(new Error(`Actor "${e}" belongs to a browser state source. Authentication engines require an HTTP state source.`))):t.signIn({actor:a,schemaHash:s.schemaHash,selector:i}).map(l=>({row:a,session:l}))}function gg({alias:e,constraints:t}){return t.find(r=>r.kind==="required-record"&&r.alias===e)?.selector}function Sg({base:e,results:t}){return new Map([...e,...jt(t)])}function bg(e){if(e==null)return[];let t={declared:!1,expect:{expect:"is",value:e.alias},subject:{kind:"actor"}};return[[v(t.subject),t]]}function Rg({authentication:e,readState:t,setup:r}){return n=>e.currentActor(n).andThen(o=>o==null?Tc(null):t().andThen(a=>cT({current:o,observed:a,setup:r})))}function cT({current:e,observed:t,setup:r}){let n=pT({selector:e.selector,state:t}).filter(i=>g(i)===g(e.row)),o=dT({current:e,observed:t,setup:r}),a=o[0];return n.length!==1||o.length!==1||a==null?Pc(Ps({observedMatches:n.length,source:Mc(e.selector),workflowMatches:o.length})):Tc(a)}function dT({current:e,observed:t,setup:r}){return Object.entries(r.results).filter(([n,o])=>uT({alias:n,current:e,observed:t,row:o,setup:r})).map(([n])=>n)}function uT({alias:e,current:t,observed:r,row:n,setup:o}){let a=gg({alias:e,constraints:o.constraints});if(a==null||Mc(a)!==Mc(t.selector))return!1;let i=Oc({selector:a,state:o.state}).filter(c=>g(c.row)===g(n)).map(c=>c.key),s=i[0];if(i.length!==1||s==null)return!1;let l=Oc({selector:a,state:r}).find(c=>c.key===s)?.row;return l!=null&&g(l)===g(t.row)}function pT({selector:e,state:t}){return Oc({selector:e,state:t}).map(r=>r.row)}function Oc({selector:e,state:t}){let r=t[e.source],n=e.path.reduce((o,a)=>o!=null&&!Array.isArray(o)&&typeof o=="object"?o[a]:void 0,r);return n==null||Array.isArray(n)||typeof n!="object"?[]:Object.entries(n).map(([o,a])=>({key:o,row:a}))}function Mc(e){return`${e.source}.${e.path.join(".")}`}function Ic({browser:e,client:t,request:r}){return mT({browser:e,client:t,request:r}).andThen(n=>yT({client:t,prepared:n,request:r}).map(o=>({established:o,prepared:n})).orElse(o=>hT(n).andThen(()=>fT(o))))}function mT({browser:e,client:t,request:r}){return t.usesBrowser?Zr.fromPromise(_h({attachBrowser:t.attachBrowser,baseUrl:r.options.baseUrl,browser:e,browserStateSeed:{runId:r.runId},viewport:ai(r.test.viewport)}),me):Zr.fromSafePromise(Promise.resolve(void 0))}function yT({client:e,prepared:t,request:r}){let n=Date.now(),o=Lo({plan:r.test.startingState,seed:r.startingStateSeed}),a={...r.test,startingState:o};return jr({generate:Rr(r.options.generate,r.startingStateSeed),params:r.params,state:r.lockfile.state,test:a}).andThen(i=>gT({client:e,prepared:t,request:r,setup:i,startingState:o,worldStart:n}))}function hT(e){return Zr.fromPromise(e==null?Promise.resolve():e.context.close(),me)}function gT({client:e,prepared:t,request:r,setup:n,startingState:o,worldStart:a}){let i=[...new Set(o.operations.map(({source:l})=>l))],s=ST({activeSources:i,sources:r.lockfile.state.sources});return vg({activeSources:s.http,onProgress:r.onProgress}),e.setupState({plan:o,afterHttpSetup:l=>RT({browserSources:s.browser,client:e,prepared:t,request:r,results:l,startingState:o})}).andThen(({checkpoint:l,setup:c})=>{lr(r.onProgress,{activeSources:i,kind:"settingUpState",stage:"verifying"});let d=yg({authentication:e.authentication,setup:c,state:r.lockfile.state});return bT({authentication:l,client:e,logicalSetup:c,request:r,setup:n,signInActor:d,startingState:o,worldStart:a})})}function ST({activeSources:e,sources:t}){let r=new Set(t.filter(({transport:n})=>n==="browser").map(({name:n})=>n));return{browser:e.filter(n=>r.has(n)),http:e.filter(n=>!r.has(n))}}function vg({activeSources:e,onProgress:t}){e.length!==0&&lr(t,{activeSources:[...e],kind:"settingUpState",stage:"materializing"})}function bT({authentication:e,client:t,logicalSetup:r,request:n,setup:o,signInActor:a,startingState:i,worldStart:s}){return n.onPhase?.("world",Date.now()-s),n.onEvent?.({kind:"state-setup",results:r.results}),Zr.fromSafePromise(Promise.resolve(wT({authentication:e,client:t,logical:On(i),logicalSetup:r,params:fi({env:o.env,test:n.test}),runId:n.runId,setup:o,signInActor:a})))}function RT({browserSources:e,client:t,prepared:r,request:n,results:o,startingState:a}){return n.test.actor.kind==="user"&&lr(n.onProgress,{kind:"signingIn"}),mg({actor:n.test.actor,authentication:t.authentication,constraints:a.constraints,results:o,state:n.lockfile.state}).andThen(i=>vT({authentication:i,prepared:r,request:n})).map(i=>(vg({activeSources:e,onProgress:n.onProgress}),i))}function vT({authentication:e,prepared:t,request:r}){return t==null?Zr.fromSafePromise(Promise.resolve(e)):Zr.fromPromise(Uh({baseUrl:r.options.baseUrl,prepared:t,session:e?.session}),me).map(()=>e)}function wT({authentication:e,client:t,logical:r,logicalSetup:n,params:o,runId:a,setup:i,signInActor:s}){let l=bg(e),c=n.results;return{attachBrowser:t.attachBrowser,auth:e?.session,browserStateSeed:{runId:a},env:Sg({base:i.env,results:c}),logical:r,readActor:Rg({authentication:t.authentication,readState:t.readState,setup:n}),readLogicalState:t.readState,releaseBrowser:t.releaseBrowser,signInActor:s,snapshot:{...i.snapshot,scalars:new Map([...i.snapshot.scalars,...l])},stateEffectBindings:{...c,...e==null?{}:{[gr]:e.row},[at]:o},teardown:t.teardown}}function ro(e){return{aborted:!0,contradictions:[],failed:!1,findings:[],ran:[],teardown:e}}function Nc(e,t){return new wg(PT(e,t))}function ET(e,t){return new wg(xT(e,t))}async function xT(e,t){let r=kT(e),n=Ac({lockfile:e.lockfile,options:e.options,runId:e.runId,signal:t}),o=async({established:s,prepared:l})=>{try{return to(await CT({browser:i,closeBrowser:a.close,established:s,params:e,prepared:l,signal:t}))}catch(c){await s.teardown().match(ge,ge),c instanceof cr&&await c.session.close().catch(ge),await a.close();let d=c instanceof cr?c.cause:c;return eo(Vo(d)?d:me(d))}},a=si({cacheDir:void 0,headed:!0}),i=await a.acquire();return Ic({browser:i,client:n,request:r}).match(o,async s=>(await Fc(n.teardown),await a.close(),eo(s)))}function kT(e){return{capture:!1,lockfile:e.lockfile,onEvent:void 0,onPhase:void 0,onProgress:void 0,options:e.options,params:void 0,runId:e.runId,sequence:e.sequence,startingStateSeed:e.runId,test:e.test}}async function CT({browser:e,closeBrowser:t,established:r,params:n,prepared:o,signal:a}){let{result:i,session:s}=await Eg({browser:e,capture:null,established:r,lockfile:n.lockfile,onEvent:void 0,onPhase:void 0,onProgress:void 0,options:n.options,parameterOverrides:void 0,prepared:o,sequence:n.sequence,signal:a,stopAfterStep:n.stopAfterStep,test:n.test,viewport:null});return i.failed?(await r.teardown().match(ge,ge),await s.close().catch(ge),await t(),{contradictions:i.contradictions,kind:"failed"}):(n.onReady(),await AT(e,s.context),await r.teardown().match(ge,ge),await t(),{kind:"handed-over",ran:i.ran.length})}function AT(e,t){return new Promise(r=>{let n=()=>{r()};e.on("disconnected",n),t.on("close",n),t.on("page",o=>o.on("close",n)),t.pages().forEach(o=>o.on("close",n))})}async function PT({browser:e,hub:t,request:r},n){if(n.aborted)return to(ro("skipped"));let o=Ac({lockfile:r.lockfile,options:r.options,runId:r.runId,signal:n}),a=async({established:i,prepared:s})=>{try{return await MT({browser:e,established:i,hub:t,prepared:s,request:r,signal:n})}catch(l){return eo(Vo(l)?l:Rn(l))}};return Ic({browser:e,client:o,request:r}).match(a,i=>OT(i,o.teardown))}async function OT(e,t){return e.kind!=="aborted"?eo(e):to(ro(await Fc(t)))}function Fc(e){return e().match(()=>"done",()=>"failed")}async function MT(e){let t=await IT(e);if(t.kind==="completed"){let n=Date.now();lr(e.request.onProgress,{kind:"finishing",stage:"cleaningUp"});let o=await e.established.teardown().match(()=>(e.request.onPhase?.("teardown",Date.now()-n),to({aborted:!1,...t.result})),a=>eo(a));return await t.session.close().catch(ge),o}let r=await Fc(e.established.teardown);if(t.session!=null&&await t.session.close().catch(ge),t.kind==="aborted")return to(ro(r));throw t.error}async function Eg(e){let{established:t,lockfile:r,signal:n}=e,o=Date.now();lr(e.onProgress,{kind:"startingBrowser"});let a=await TT(e);e.onPhase?.("browser",Date.now()-o);try{let i=Nr(r),s=Date.now(),l={base:t.env,deferred:Ye,logical:t.logical,snapshot:t.snapshot},c=fg({corpus:e.sequence==null?tr(r,e.test):e.sequence.map(u=>u.transition),parameterOverrides:e.parameterOverrides,parameters:Bn({params:fi({env:t.env,test:e.test}),test:e.test,testRef:oe(e.test)}),preferred:e.sequence,state:l}),d=await Ua({classify:Fa,driver:a.driver,facts:{facts:Xs(i.facts,oe(e.test)),overlays:Xe(r),overrides:i.overrides},initialState:l,onProgress:e.onProgress,sequence:c,stopAfterStep:e.stopAfterStep,onEvent:u=>{u.kind==="step"&&a.emitStepOutcome({checks:u.checks,stepError:u.stepError,stepIndex:u.index}),e.onEvent?.(u)}},n);return e.onPhase?.("drive",Date.now()-s),{result:d,session:a}}catch(i){throw new cr({cause:i,session:a})}}var cr=class extends Error{cause;session;constructor({cause:t,session:r}){super("sequence drive failed"),this.cause=t,this.session=r}};async function TT(e){let{established:t,lockfile:r,signal:n}=e;try{return await gc({attachBrowser:t.attachBrowser,baseUrl:e.options.baseUrl,browser:e.browser,browserStateSeed:t.browserStateSeed,capture:e.capture,eventualStatePaths:r.state.eventualPaths,fixturesDir:e.options.fixturesDir,networkHeaders:void 0,prepared:e.prepared,readActor:t.readActor,readLogicalState:t.readLogicalState,releaseBrowser:t.releaseBrowser,session:t.auth,signal:n,signInActor:t.signInActor,stateEffectBindings:t.stateEffectBindings,viewport:e.viewport})}catch(o){throw new Lc(o)}}var Lc=class extends Error{kind;constructor(t){let r=me(t);super(r.message),this.kind=r.kind}};async function IT({browser:e,established:t,hub:r,prepared:n,request:o,signal:a}){try{he(a);let{result:i,session:s}=await Eg({browser:e,capture:o.capture?{hub:r,runId:o.runId}:null,established:t,lockfile:o.lockfile,onEvent:o.onEvent,onPhase:o.onPhase,onProgress:o.onProgress,options:o.options,parameterOverrides:o.params,prepared:n,sequence:o.sequence,signal:a,stopAfterStep:void 0,test:o.test,viewport:ai(o.test.viewport)});return{kind:"completed",result:i,session:s}}catch(i){return LT(i)}}function LT(e){let t=e instanceof cr?e.cause:e,r=e instanceof cr?e.session:void 0;return _n(t)?{kind:"aborted",session:r}:{error:t,kind:"threw",session:r}}import ID from"path";import{err as AR,ok as LD,ResultAsync as ND}from"neverthrow";import CR from"path";import{z as Ke}from"zod";import NT from"path";function xg({debugDir:e,runId:t,worker:r}){let n=NT.join(e,t,"behavior.jsonl");return r.open({file:n,headerLine:_u(),runId:t}),{close:o=>r.close({noticeLineIfNoRrweb:o?.noticeIfNoRrweb==null?"":JSON.stringify(FT(o.noticeIfNoRrweb)),runId:t}),emit:o=>{let a={...o,timestamp:DT(o.timeNanos)};r.line({line:JSON.stringify(a),runId:t,timeNanos:o.timeNanos})},emitRrwebBatch:o=>{r.rrwebBatch({data:o,runId:t})}}}function dr(e){return String(BigInt(Math.round(e))*1000000n)}function FT(e){return{kind:"notice",message:e,source:"capture",timeNanos:"0"}}function DT(e){return Number(BigInt(e)/1000000n)}import{existsSync as BT}from"fs";import{createRequire as $T}from"module";import{fileURLToPath as jT}from"url";import{Worker as VT}from"worker_threads";var _T=$T(import.meta.url);function kg(e){let t=new VT(UT(),{workerData:e});t.unref();let r=new Map,n={next:0};t.on("message",a=>{let i=r.get(a.seq);i!=null&&(r.delete(a.seq),i())});let o=a=>{t.postMessage(a)};return{close:({noticeLineIfNoRrweb:a,runId:i})=>{let s=n.next;return n.next+=1,new Promise(l=>{r.set(s,l),o({noticeLineIfNoRrweb:a,runId:i,seq:s,t:"close"})})},line:({line:a,runId:i,timeNanos:s})=>{o({line:a,runId:i,t:"line",timeNanos:s})},open:({file:a,headerLine:i,runId:s})=>{o({file:a,headerLine:i,runId:s,t:"open"})},rrwebBatch:({data:a,runId:i})=>{o({data:a,runId:i,t:"rrweb-batch"})},terminate:async()=>{await t.terminate()}}}function UT(){try{return _T.resolve("@ripplo/runtime/capture-worker")}catch{let e=["../../dist/capture-worker.js","./capture-worker.js"].map(r=>jT(new URL(r,import.meta.url))),t=e.find(r=>BT(r));if(t==null)throw new Error(`capture-worker.js not found; looked at: ${e.join(", ")}`);return t}}import{readFile as WT}from"fs/promises";import{createRequire as qT}from"module";import{fileURLToPath as zT}from"url";var KT=qT(import.meta.url);function Dc(e,t){try{return KT.resolve(e)}catch{return zT(new URL(`assets/${t}`,import.meta.url))}}function Bc(e){let t;return()=>(t??=WT(e,"utf8"),t)}var HT=Bc(Dc("@ripplo/browser-trace/bundle","browser-trace.js"));async function Cg(e,t){await e.addInitScript(`globalThis.__ripploRunId = ${JSON.stringify(t)};`),await e.addInitScript(await HT())}var JT=Object.defineProperty,GT=(e,t,r)=>t in e?JT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t,r)=>GT(e,typeof t!="symbol"?t+"":t,r),Ag,YT=Object.defineProperty,ZT=(e,t,r)=>t in e?YT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pg=(e,t,r)=>ZT(e,typeof t!="symbol"?t+"":t,r),de=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(de||{}),Og={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Mg={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},mi={},XT=()=>!!globalThis.Zone;function _d(e){if(mi[e])return mi[e];let t=globalThis[e],r=t.prototype,n=e in Og?Og[e]:void 0,o=!!(n&&n.every(s=>{var l,c;return!!((c=(l=Object.getOwnPropertyDescriptor(r,s))==null?void 0:l.get)!=null&&c.toString().includes("[native code]"))})),a=e in Mg?Mg[e]:void 0,i=!!(a&&a.every(s=>{var l;return typeof r[s]=="function"&&((l=r[s])==null?void 0:l.toString().includes("[native code]"))}));if(o&&i&&!XT())return mi[e]=t.prototype,t.prototype;try{let s=document.createElement("iframe");document.body.appendChild(s);let l=s.contentWindow;if(!l)return t.prototype;let c=l[e].prototype;return document.body.removeChild(s),c?mi[e]=c:r}catch{return r}}var $c={};function St(e,t,r){var n;let o=`${e}.${String(r)}`;if($c[o])return $c[o].call(t);let a=_d(e),i=(n=Object.getOwnPropertyDescriptor(a,r))==null?void 0:n.get;return i?($c[o]=i,i.call(t)):t[r]}var jc={};function AS(e,t,r){let n=`${e}.${String(r)}`;if(jc[n])return jc[n].bind(t);let a=_d(e)[r];return typeof a!="function"?t[r]:(jc[n]=a,a.bind(t))}function QT(e){return St("Node",e,"ownerDocument")}function eI(e){return St("Node",e,"childNodes")}function tI(e){return St("Node",e,"parentNode")}function rI(e){return St("Node",e,"parentElement")}function nI(e){return St("Node",e,"textContent")}function oI(e,t){return AS("Node",e,"contains")(t)}function aI(e){return AS("Node",e,"getRootNode")()}function iI(e){return!e||!("host"in e)?null:St("ShadowRoot",e,"host")}function sI(e){return e.styleSheets}function lI(e){return!e||!("shadowRoot"in e)?null:St("Element",e,"shadowRoot")}function cI(e,t){return St("Element",e,"querySelector")(t)}function dI(e,t){return St("Element",e,"querySelectorAll")(t)}function uI(){return _d("MutationObserver").constructor}function pI(e,t,r){try{if(!(t in e))return()=>{};let n=e[t],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,()=>{e[t]=n}}catch{return()=>{}}}var be={ownerDocument:QT,childNodes:eI,parentNode:tI,parentElement:rI,textContent:nI,contains:oI,getRootNode:aI,host:iI,styleSheets:sI,shadowRoot:lI,querySelector:cI,querySelectorAll:dI,mutationObserver:uI,patch:pI};function PS(e){return e.nodeType===e.ELEMENT_NODE}function lo(e){let t=e&&"host"in e&&"mode"in e&&be.host(e)||null;return!!(t&&"shadowRoot"in t&&be.shadowRoot(t)===e)}function co(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function fI(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function mI(e){let{cssText:t}=e;if(t.split('"').length<3)return t;let r=["@import",`url(${JSON.stringify(e.href)})`];return e.layerName===""?r.push("layer"):e.layerName&&r.push(`layer(${e.layerName})`),e.supportsText&&r.push(`supports(${e.supportsText})`),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}function Xc(e){try{let t=e.rules||e.cssRules;if(!t)return null;let r=e.href;!r&&e.ownerNode&&(r=e.ownerNode.baseURI);let n=Array.from(t,o=>OS(o,r)).join("");return fI(n)}catch{return null}}function OS(e,t){if(hI(e)){let r;try{r=Xc(e.styleSheet)||mI(e)}catch{r=e.cssText}return e.styleSheet.href?Ki(r,e.styleSheet.href):r}else{let r=e.cssText;return gI(e)&&e.selectorText.includes(":")&&(r=yI(r)),t?Ki(r,t):r}}function yI(e){let t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}function hI(e){return"styleSheet"in e}function gI(e){return"selectorText"in e}var Wi=class{constructor(){Pg(this,"idNodeMap",new Map),Pg(this,"nodeMetaMap",new WeakMap)}getId(t){var r;return t?((r=this.getMeta(t))==null?void 0:r.id)??-1:-1}getNode(t){return this.idNodeMap.get(t)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(t){return this.nodeMetaMap.get(t)||null}removeNodeFromMap(t){let r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(n=>this.removeNodeFromMap(n))}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,r){let n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)}replace(t,r){let n=this.getNode(t);if(n){let o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(r,o)}this.idNodeMap.set(t,r)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function SI(){return new Wi}function qi({element:e,maskInputOptions:t,tagName:r,type:n,value:o,maskInputFn:a}){let i=o||"",s=n&&pr(n);return(t[r.toLowerCase()]||s&&t[s])&&(a?i=a(i,e):i="*".repeat(i.length)),i}function pr(e){return e.toLowerCase()}var Tg="__rrweb_original__";function bI(e){let t=e.getContext("2d");if(!t)return!0;let r=50;for(let n=0;n<e.width;n+=r)for(let o=0;o<e.height;o+=r){let a=t.getImageData,i=Tg in a?a[Tg]:a;if(new Uint32Array(i.call(t,n,o,Math.min(r,e.width-n),Math.min(r,e.height-o)).data.buffer).some(l=>l!==0))return!1}return!0}function zi(e){let t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?pr(t):null}function MS(e,t){let r;try{r=new URL(e,t??window.location.href)}catch{return null}let n=/\.([0-9a-z]+)(?:$)/i,o=r.pathname.match(n);return o?.[1]??null}function RI(e){let t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var vI=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,wI=/^(?:[a-z+]+:)?\/\//i,EI=/^www\..*/i,xI=/^(data:)([^,]*),(.*)/i;function Ki(e,t){return(e||"").replace(vI,(r,n,o,a,i,s)=>{let l=o||i||s,c=n||a||"";if(!l)return r;if(wI.test(l)||EI.test(l))return`url(${c}${l}${c})`;if(xI.test(l))return`url(${c}${l}${c})`;if(l[0]==="/")return`url(${c}${RI(t)+l}${c})`;let d=t.split("/"),u=l.split("/");d.pop();for(let f of u)f!=="."&&(f===".."?d.pop():d.push(f));return`url(${c}${d.join("/")}${c})`})}function yi(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function kI(e,t,r=!1){let n=Array.from(t.childNodes),o=[],a=0;if(n.length>1&&e&&typeof e=="string"){let i=yi(e,r),s=i.length/e.length;for(let l=1;l<n.length;l++)if(n[l].textContent&&typeof n[l].textContent=="string"){let c=yi(n[l].textContent,r),d=100,u=3;for(;u<c.length&&(c[u].match(/[a-zA-Z0-9]/)||c.indexOf(c.substring(0,u),1)!==-1);u++);for(;u<c.length;u++){let f=c.substring(0,u),y=i.split(f),m=-1;if(y.length===2)m=y[0].length;else if(y.length>2&&y[0]===""&&n[l-1].textContent!=="")m=i.indexOf(f,1);else if(y.length===1){if(f=f.substring(0,f.length-1),y=i.split(f),y.length<=1)return o.push(e),o;u=d+1}else u===c.length-1&&(m=i.indexOf(f));if(y.length>=2&&u>d){let h=n[l-1].textContent;if(h&&typeof h=="string"){let p=yi(h).length;m=i.indexOf(f,p)}m===-1&&(m=y[0].length)}if(m!==-1){let h=Math.floor(m/s);for(;h>0&&h<e.length;){if(a+=1,a>50*n.length)return o.push(e),o;let p=yi(e.substring(0,h),r);if(p.length===m){o.push(e.substring(0,h)),e=e.substring(h),i=i.substring(m);break}else p.length<m?h+=Math.max(1,Math.floor((m-p.length)/s)):h-=Math.max(1,Math.floor((p.length-m)*s))}break}}}}return o.push(e),o}function CI(e,t){return kI(e,t).join("/* rr_split */")}var AI=1,PI=new RegExp("[^a-z0-9-_:]"),po=-2;function TS(){return AI++}function OI(e){if(e instanceof HTMLFormElement)return"form";let t=pr(e.tagName);return PI.test(t)?"div":t}var Xr,Ig,MI=/^[^ \t\n\r\u000c]+/,TI=/^[, \t\n\r\u000c]+/;function II(e,t){if(t.trim()==="")return t;let r=0;function n(a){let i,s=a.exec(t.substring(r));return s?(i=s[0],r+=i.length,i):""}let o=[];for(;n(TI),!(r>=t.length);){let a=n(MI);if(a.slice(-1)===",")a=tn(e,a.substring(0,a.length-1)),o.push(a);else{let i="";a=tn(e,a);let s=!1;for(;;){let l=t.charAt(r);if(l===""){o.push((a+i).trim());break}else if(s)l===")"&&(s=!1);else if(l===","){r+=1,o.push((a+i).trim());break}else l==="("&&(s=!0);i+=l,r+=1}}}return o.join(", ")}var Lg=new WeakMap;function tn(e,t){return!t||t.trim()===""?t:Ud(e,t)}function LI(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function Ud(e,t){let r=Lg.get(e);if(r||(r=e.createElement("a"),Lg.set(e,r)),!t)t="";else if(t.startsWith("blob:")||t.startsWith("data:"))return t;return r.setAttribute("href",t),r.href}function IS(e,t,r,n){return n&&(r==="src"||r==="href"&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n[0]!=="#"||r==="background"&&["table","td","th"].includes(t)?tn(e,n):r==="srcset"?II(e,n):r==="style"?Ki(n,Ud(e)):t==="object"&&r==="data"?tn(e,n):n)}function LS(e,t,r){return["video","audio"].includes(e)&&t==="autoplay"}function NI(e,t,r){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){let o=e.classList[n];if(t.test(o))return!0}if(r)return e.matches(r)}catch{}return!1}function Hi(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Hi(be.parentNode(e),t,r):!1;for(let n=e.classList.length;n--;){let o=e.classList[n];if(t.test(o))return!0}return r?Hi(be.parentNode(e),t,r):!1}function NS(e,t,r,n){let o;if(PS(e)){if(o=e,!be.childNodes(o).length)return!1}else{if(be.parentElement(e)===null)return!1;o=be.parentElement(e)}try{if(typeof t=="string"){if(n){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(Hi(o,t,n))return!0;if(r){if(n){if(o.closest(r))return!0}else if(o.matches(r))return!0}}catch{}return!1}function FI(e,t,r){let n=e.contentWindow;if(!n)return;let o=!1,a;try{a=n.document.readyState}catch{return}if(a!=="complete"){let s=setTimeout(()=>{o||(t(),o=!0)},r);e.addEventListener("load",()=>{clearTimeout(s),o=!0,t()});return}let i="about:blank";if(n.location.href!==i||e.src===i||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}function DI(e,t,r){let n=!1,o;try{o=e.sheet}catch{return}if(o)return;let a=setTimeout(()=>{n||(t(),n=!0)},r);e.addEventListener("load",()=>{clearTimeout(a),n=!0,t()})}function BI(e,t){let{doc:r,mirror:n,blockClass:o,blockSelector:a,needsMask:i,inlineStylesheet:s,maskInputOptions:l={},maskTextFn:c,maskInputFn:d,dataURLOptions:u={},inlineImages:f,recordCanvas:y,keepIframeSrcFn:m,newlyAddedElement:h=!1,cssCaptured:p=!1}=t,b=$I(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:de.Document,childNodes:[],compatMode:e.compatMode}:{type:de.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:de.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return VI(e,{doc:r,blockClass:o,blockSelector:a,inlineStylesheet:s,maskInputOptions:l,maskInputFn:d,dataURLOptions:u,inlineImages:f,recordCanvas:y,keepIframeSrcFn:m,newlyAddedElement:h,rootId:b});case e.TEXT_NODE:return jI(e,{doc:r,needsMask:i,maskTextFn:c,rootId:b,cssCaptured:p});case e.CDATA_SECTION_NODE:return{type:de.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:de.Comment,textContent:be.textContent(e)||"",rootId:b};default:return!1}}function $I(e,t){if(!t.hasNode(e))return;let r=t.getId(e);return r===1?void 0:r}function jI(e,t){let{needsMask:r,maskTextFn:n,rootId:o,cssCaptured:a}=t,i=be.parentNode(e),s=i&&i.tagName,l="",c=s==="STYLE"?!0:void 0,d=s==="SCRIPT"?!0:void 0;return d?l="SCRIPT_PLACEHOLDER":a||(l=be.textContent(e),c&&l&&(l=Ki(l,Ud(t.doc)))),!c&&!d&&l&&r&&(l=n?n(l,be.parentElement(e)):l.replace(/[\S]/g,"*")),{type:de.Text,textContent:l||"",rootId:o}}function VI(e,t){let{doc:r,blockClass:n,blockSelector:o,inlineStylesheet:a,maskInputOptions:i={},maskInputFn:s,dataURLOptions:l={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:f=!1,rootId:y}=t,m=NI(e,n,o),h=OI(e),p={},b=e.attributes.length;for(let S=0;S<b;S++){let E=e.attributes[S];LS(h,E.name,E.value)||(p[E.name]=IS(r,h,pr(E.name),E.value))}if(h==="link"&&a){let S=Array.from(r.styleSheets).find(L=>L.href===e.href),E=null;S&&(E=Xc(S)),E&&(delete p.rel,delete p.href,p._cssText=E)}if(h==="style"&&e.sheet){let S=Xc(e.sheet);S&&(e.childNodes.length>1&&(S=CI(S,e)),p._cssText=S)}if(["input","textarea","select"].includes(h)){let S=e.value,E=e.checked;p.type!=="radio"&&p.type!=="checkbox"&&p.type!=="submit"&&p.type!=="button"&&S?p.value=qi({element:e,type:zi(e),tagName:h,value:S,maskInputOptions:i,maskInputFn:s}):E&&(p.checked=E)}if(h==="option"&&(e.selected&&!i.select?p.selected=!0:delete p.selected),h==="dialog"&&e.open&&(p.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"),h==="canvas"&&d){if(e.__context==="2d")bI(e)||(p.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){let S=e.toDataURL(l.type,l.quality),E=r.createElement("canvas");E.width=e.width,E.height=e.height;let L=E.toDataURL(l.type,l.quality);S!==L&&(p.rr_dataURL=S)}}if(h==="img"&&c){Xr||(Xr=r.createElement("canvas"),Ig=Xr.getContext("2d"));let S=e,E=S.currentSrc||S.getAttribute("src")||"<unknown-src>",L=S.crossOrigin,V=()=>{S.removeEventListener("load",V);try{Xr.width=S.naturalWidth,Xr.height=S.naturalHeight,Ig.drawImage(S,0,0),p.rr_dataURL=Xr.toDataURL(l.type,l.quality)}catch(ne){if(S.crossOrigin!=="anonymous"){S.crossOrigin="anonymous",S.complete&&S.naturalWidth!==0?V():S.addEventListener("load",V);return}else console.warn(`Cannot inline img src=${E}! Error: ${ne}`)}S.crossOrigin==="anonymous"&&(L?p.crossOrigin=L:S.removeAttribute("crossorigin"))};S.complete&&S.naturalWidth!==0?V():S.addEventListener("load",V)}if(["audio","video"].includes(h)){let S=p;S.rr_mediaState=e.paused?"paused":"played",S.rr_mediaCurrentTime=e.currentTime,S.rr_mediaPlaybackRate=e.playbackRate,S.rr_mediaMuted=e.muted,S.rr_mediaLoop=e.loop,S.rr_mediaVolume=e.volume}if(f||(e.scrollLeft&&(p.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(p.rr_scrollTop=e.scrollTop)),m){let{width:S,height:E}=e.getBoundingClientRect();p={class:p.class,rr_width:`${S}px`,rr_height:`${E}px`}}h==="iframe"&&!u(p.src)&&(e.contentDocument||(p.rr_src=p.src),delete p.src);let w;try{customElements.get(h)&&(w=!0)}catch{}return{type:de.Element,tagName:h,attributes:p,childNodes:[],isSVG:LI(e)||void 0,needBlock:m,rootId:y,isCustom:w}}function q(e){return e==null?"":e.toLowerCase()}function FS(e){return e===!0||e==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:e==="all",headMetaDescKeywords:e==="all",headTitleMutations:e==="all"}:e||{}}function _I(e,t){if(t.comment&&e.type===de.Comment)return!0;if(e.type===de.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"&&e.attributes.as==="script"||e.attributes.rel==="modulepreload")||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&MS(e.attributes.href)==="js"))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(q(e.attributes.name).match(/^msapplication-tile(image|color)$/)||q(e.attributes.name)==="application-name"||q(e.attributes.rel)==="icon"||q(e.attributes.rel)==="apple-touch-icon"||q(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&q(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(q(e.attributes.property).match(/^(og|twitter|fb):/)||q(e.attributes.name).match(/^(og|twitter):/)||q(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(q(e.attributes.name)==="robots"||q(e.attributes.name)==="googlebot"||q(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(q(e.attributes.name)==="author"||q(e.attributes.name)==="generator"||q(e.attributes.name)==="framework"||q(e.attributes.name)==="publisher"||q(e.attributes.name)==="progid"||q(e.attributes.property).match(/^article:/)||q(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(q(e.attributes.name)==="google-site-verification"||q(e.attributes.name)==="yandex-verification"||q(e.attributes.name)==="csrf-token"||q(e.attributes.name)==="p:domain_verify"||q(e.attributes.name)==="verify-v1"||q(e.attributes.name)==="verification"||q(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function rn(e,t){let{doc:r,mirror:n,blockClass:o,blockSelector:a,maskTextClass:i,maskTextSelector:s,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:f,slimDOMOptions:y,dataURLOptions:m={},inlineImages:h=!1,recordCanvas:p=!1,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:S=5e3,onStylesheetLoad:E,stylesheetLoadTimeout:L=5e3,keepIframeSrcFn:V=()=>!1,newlyAddedElement:ne=!1,cssCaptured:W=!1}=t,{needsMask:ae}=t,{preserveWhiteSpace:pe=!0}=t;ae||(ae=NS(e,i,s,ae===void 0));let Ae=BI(e,{doc:r,mirror:n,blockClass:o,blockSelector:a,needsMask:ae,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:f,dataURLOptions:m,inlineImages:h,recordCanvas:p,keepIframeSrcFn:V,newlyAddedElement:ne,cssCaptured:W});if(!Ae)return console.warn(e,"not serialized"),null;let He;n.hasNode(e)?He=n.getId(e):_I(Ae,y)||!pe&&Ae.type===de.Text&&!Ae.textContent.replace(/^\s+|\s+$/gm,"").length?He=po:He=TS();let N=Object.assign(Ae,{id:He});if(n.add(e,N),He===po)return null;b&&b(e);let fn=!l;if(N.type===de.Element){fn=fn&&!N.needBlock,delete N.needBlock;let le=be.shadowRoot(e);le&&co(le)&&(N.isShadowHost=!0)}if((N.type===de.Document||N.type===de.Element)&&fn){y.headWhitespace&&N.type===de.Element&&N.tagName==="head"&&(pe=!1);let le={doc:r,mirror:n,blockClass:o,blockSelector:a,needsMask:ae,maskTextClass:i,maskTextSelector:s,skipChild:l,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:f,slimDOMOptions:y,dataURLOptions:m,inlineImages:h,recordCanvas:p,preserveWhiteSpace:pe,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:S,onStylesheetLoad:E,stylesheetLoadTimeout:L,keepIframeSrcFn:V,cssCaptured:!1};if(!(N.type===de.Element&&N.tagName==="textarea"&&N.attributes.value!==void 0)){N.type===de.Element&&N.attributes._cssText!==void 0&&typeof N.attributes._cssText=="string"&&(le.cssCaptured=!0);for(let zt of Array.from(be.childNodes(e))){let Je=rn(zt,le);Je&&N.childNodes.push(Je)}}let Pe=null;if(PS(e)&&(Pe=be.shadowRoot(e)))for(let zt of Array.from(be.childNodes(Pe))){let Je=rn(zt,le);Je&&(co(Pe)&&(Je.isShadow=!0),N.childNodes.push(Je))}}let mn=be.parentNode(e);return mn&&lo(mn)&&co(mn)&&(N.isShadow=!0),N.type===de.Element&&N.tagName==="iframe"&&FI(e,()=>{let le=e.contentDocument;if(le&&w){let Pe=rn(le,{doc:le,mirror:n,blockClass:o,blockSelector:a,needsMask:ae,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:f,slimDOMOptions:y,dataURLOptions:m,inlineImages:h,recordCanvas:p,preserveWhiteSpace:pe,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:S,onStylesheetLoad:E,stylesheetLoadTimeout:L,keepIframeSrcFn:V});Pe&&w(e,Pe)}},S),N.type===de.Element&&N.tagName==="link"&&typeof N.attributes.rel=="string"&&(N.attributes.rel==="stylesheet"||N.attributes.rel==="preload"&&typeof N.attributes.href=="string"&&MS(N.attributes.href)==="css")&&DI(e,()=>{if(E){let le=rn(e,{doc:r,mirror:n,blockClass:o,blockSelector:a,needsMask:ae,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:f,slimDOMOptions:y,dataURLOptions:m,inlineImages:h,recordCanvas:p,preserveWhiteSpace:pe,onSerialize:b,onIframeLoad:w,iframeLoadTimeout:S,onStylesheetLoad:E,stylesheetLoadTimeout:L,keepIframeSrcFn:V});le&&E(e,le)}},L),N}function UI(e,t){let{mirror:r=new Wi,blockClass:n="rr-block",blockSelector:o=null,maskTextClass:a="rr-mask",maskTextSelector:i=null,inlineStylesheet:s=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:f,slimDOM:y=!1,dataURLOptions:m,preserveWhiteSpace:h,onSerialize:p,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:S,stylesheetLoadTimeout:E,keepIframeSrcFn:L=()=>!1}=t||{},V=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:d===!1?{password:!0}:d,ne=FS(y);return rn(e,{doc:e,mirror:r,blockClass:n,blockSelector:o,maskTextClass:a,maskTextSelector:i,skipChild:!1,inlineStylesheet:s,maskInputOptions:V,maskTextFn:u,maskInputFn:f,slimDOMOptions:ne,dataURLOptions:m,inlineImages:l,recordCanvas:c,preserveWhiteSpace:h,onSerialize:p,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:S,stylesheetLoadTimeout:E,keepIframeSrcFn:L,newlyAddedElement:!1})}var WI=/(max|min)-device-(width|height)/,CJ=new RegExp(WI.source,"g");function qI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zI(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),r}var Wd={exports:{}},K=String,DS=function(){return{isColorSupported:!1,reset:K,bold:K,dim:K,italic:K,underline:K,inverse:K,hidden:K,strikethrough:K,black:K,red:K,green:K,yellow:K,blue:K,magenta:K,cyan:K,white:K,gray:K,bgBlack:K,bgRed:K,bgGreen:K,bgYellow:K,bgBlue:K,bgMagenta:K,bgCyan:K,bgWhite:K}};Wd.exports=DS();Wd.exports.createColors=DS;var KI=Wd.exports,HI={},JI=Object.freeze(Object.defineProperty({__proto__:null,default:HI},Symbol.toStringTag,{value:"Module"})),qe=zI(JI),Ng=KI,Fg=qe,Qc=class BS extends Error{constructor(t,r,n,o,a,i){super(t),this.name="CssSyntaxError",this.reason=t,a&&(this.file=a),o&&(this.source=o),i&&(this.plugin=i),typeof r<"u"&&typeof n<"u"&&(typeof r=="number"?(this.line=r,this.column=n):(this.line=r.line,this.column=r.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,BS)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",typeof this.line<"u"&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(t){if(!this.source)return"";let r=this.source;t==null&&(t=Ng.isColorSupported),Fg&&t&&(r=Fg(r));let n=r.split(/\r?\n/),o=Math.max(this.line-3,0),a=Math.min(this.line+2,n.length),i=String(a).length,s,l;if(t){let{bold:c,gray:d,red:u}=Ng.createColors(!0);s=f=>c(u(f)),l=f=>d(f)}else s=l=c=>c;return n.slice(o,a).map((c,d)=>{let u=o+1+d,f=" "+(" "+u).slice(-i)+" | ";if(u===this.line){let y=l(f.replace(/\d/g," "))+c.slice(0,this.column-1).replace(/[^\t]/g," ");return s(">")+l(f)+c+`
|
|
7
|
+
`+y+s("^")}return" "+l(f)+c}).join(`
|
|
8
|
+
`)}toString(){let t=this.showSourceCode();return t&&(t=`
|
|
9
|
+
|
|
10
|
+
`+t+`
|
|
11
|
+
`),this.name+": "+this.message+t}},qd=Qc;Qc.default=Qc;var wo={};wo.isClean=Symbol("isClean");wo.my=Symbol("my");var Dg={after:`
|
|
12
|
+
`,beforeClose:`
|
|
13
|
+
`,beforeComment:`
|
|
14
|
+
`,beforeDecl:`
|
|
15
|
+
`,beforeOpen:" ",beforeRule:`
|
|
16
|
+
`,colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};function GI(e){return e[0].toUpperCase()+e.slice(1)}var ed=class{constructor(t){this.builder=t}atrule(t,r){let n="@"+t.name,o=t.params?this.rawValue(t,"params"):"";if(typeof t.raws.afterName<"u"?n+=t.raws.afterName:o&&(n+=" "),t.nodes)this.block(t,n+o);else{let a=(t.raws.between||"")+(r?";":"");this.builder(n+o+a,t)}}beforeAfter(t,r){let n;t.type==="decl"?n=this.raw(t,null,"beforeDecl"):t.type==="comment"?n=this.raw(t,null,"beforeComment"):r==="before"?n=this.raw(t,null,"beforeRule"):n=this.raw(t,null,"beforeClose");let o=t.parent,a=0;for(;o&&o.type!=="root";)a+=1,o=o.parent;if(n.includes(`
|
|
17
|
+
`)){let i=this.raw(t,null,"indent");if(i.length)for(let s=0;s<a;s++)n+=i}return n}block(t,r){let n=this.raw(t,"between","beforeOpen");this.builder(r+n+"{",t,"start");let o;t.nodes&&t.nodes.length?(this.body(t),o=this.raw(t,"after")):o=this.raw(t,"after","emptyBody"),o&&this.builder(o),this.builder("}",t,"end")}body(t){let r=t.nodes.length-1;for(;r>0&&t.nodes[r].type==="comment";)r-=1;let n=this.raw(t,"semicolon");for(let o=0;o<t.nodes.length;o++){let a=t.nodes[o],i=this.raw(a,"before");i&&this.builder(i),this.stringify(a,r!==o||n)}}comment(t){let r=this.raw(t,"left","commentLeft"),n=this.raw(t,"right","commentRight");this.builder("/*"+r+t.text+n+"*/",t)}decl(t,r){let n=this.raw(t,"between","colon"),o=t.prop+n+this.rawValue(t,"value");t.important&&(o+=t.raws.important||" !important"),r&&(o+=";"),this.builder(o,t)}document(t){this.body(t)}raw(t,r,n){let o;if(n||(n=r),r&&(o=t.raws[r],typeof o<"u"))return o;let a=t.parent;if(n==="before"&&(!a||a.type==="root"&&a.first===t||a&&a.type==="document"))return"";if(!a)return Dg[n];let i=t.root();if(i.rawCache||(i.rawCache={}),typeof i.rawCache[n]<"u")return i.rawCache[n];if(n==="before"||n==="after")return this.beforeAfter(t,n);{let s="raw"+GI(n);this[s]?o=this[s](i,t):i.walk(l=>{if(o=l.raws[r],typeof o<"u")return!1})}return typeof o>"u"&&(o=Dg[n]),i.rawCache[n]=o,o}rawBeforeClose(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length>0&&typeof n.raws.after<"u")return r=n.raws.after,r.includes(`
|
|
18
|
+
`)&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawBeforeComment(t,r){let n;return t.walkComments(o=>{if(typeof o.raws.before<"u")return n=o.raws.before,n.includes(`
|
|
19
|
+
`)&&(n=n.replace(/[^\n]+$/,"")),!1}),typeof n>"u"?n=this.raw(r,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(t,r){let n;return t.walkDecls(o=>{if(typeof o.raws.before<"u")return n=o.raws.before,n.includes(`
|
|
20
|
+
`)&&(n=n.replace(/[^\n]+$/,"")),!1}),typeof n>"u"?n=this.raw(r,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(t){let r;return t.walk(n=>{if(n.type!=="decl"&&(r=n.raws.between,typeof r<"u"))return!1}),r}rawBeforeRule(t){let r;return t.walk(n=>{if(n.nodes&&(n.parent!==t||t.first!==n)&&typeof n.raws.before<"u")return r=n.raws.before,r.includes(`
|
|
21
|
+
`)&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawColon(t){let r;return t.walkDecls(n=>{if(typeof n.raws.between<"u")return r=n.raws.between.replace(/[^\s:]/g,""),!1}),r}rawEmptyBody(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length===0&&(r=n.raws.after,typeof r<"u"))return!1}),r}rawIndent(t){if(t.raws.indent)return t.raws.indent;let r;return t.walk(n=>{let o=n.parent;if(o&&o!==t&&o.parent&&o.parent===t&&typeof n.raws.before<"u"){let a=n.raws.before.split(`
|
|
22
|
+
`);return r=a[a.length-1],r=r.replace(/\S/g,""),!1}}),r}rawSemicolon(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length&&n.last.type==="decl"&&(r=n.raws.semicolon,typeof r<"u"))return!1}),r}rawValue(t,r){let n=t[r],o=t.raws[r];return o&&o.value===n?o.raw:n}root(t){this.body(t),t.raws.after&&this.builder(t.raws.after)}rule(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")}stringify(t,r){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,r)}},$S=ed;ed.default=ed;var YI=$S;function td(e,t){new YI(t).stringify(e)}var is=td;td.default=td;var{isClean:hi,my:ZI}=wo,XI=qd,QI=$S,eL=is;function rd(e,t){let r=new e.constructor;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n)||n==="proxyCache")continue;let o=e[n],a=typeof o;n==="parent"&&a==="object"?t&&(r[n]=t):n==="source"?r[n]=o:Array.isArray(o)?r[n]=o.map(i=>rd(i,r)):(a==="object"&&o!==null&&(o=rd(o)),r[n]=o)}return r}var nd=class{constructor(t={}){this.raws={},this[hi]=!1,this[ZI]=!0;for(let r in t)if(r==="nodes"){this.nodes=[];for(let n of t[r])typeof n.clone=="function"?this.append(n.clone()):this.append(n)}else this[r]=t[r]}addToError(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){let r=this.source;t.stack=t.stack.replace(/\n\s{4}at /,`$&${r.input.from}:${r.start.line}:${r.start.column}$&`)}return t}after(t){return this.parent.insertAfter(this,t),this}assign(t={}){for(let r in t)this[r]=t[r];return this}before(t){return this.parent.insertBefore(this,t),this}cleanRaws(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between}clone(t={}){let r=rd(this);for(let n in t)r[n]=t[n];return r}cloneAfter(t={}){let r=this.clone(t);return this.parent.insertAfter(this,r),r}cloneBefore(t={}){let r=this.clone(t);return this.parent.insertBefore(this,r),r}error(t,r={}){if(this.source){let{end:n,start:o}=this.rangeBy(r);return this.source.input.error(t,{column:o.column,line:o.line},{column:n.column,line:n.line},r)}return new XI(t)}getProxyProcessor(){return{get(t,r){return r==="proxyOf"?t:r==="root"?()=>t.root().toProxy():t[r]},set(t,r,n){return t[r]===n||(t[r]=n,(r==="prop"||r==="value"||r==="name"||r==="params"||r==="important"||r==="text")&&t.markDirty()),!0}}}markDirty(){if(this[hi]){this[hi]=!1;let t=this;for(;t=t.parent;)t[hi]=!1}}next(){if(!this.parent)return;let t=this.parent.index(this);return this.parent.nodes[t+1]}positionBy(t,r){let n=this.source.start;if(t.index)n=this.positionInside(t.index,r);else if(t.word){r=this.toString();let o=r.indexOf(t.word);o!==-1&&(n=this.positionInside(o,r))}return n}positionInside(t,r){let n=r||this.toString(),o=this.source.start.column,a=this.source.start.line;for(let i=0;i<t;i++)n[i]===`
|
|
23
|
+
`?(o=1,a+=1):o+=1;return{column:o,line:a}}prev(){if(!this.parent)return;let t=this.parent.index(this);return this.parent.nodes[t-1]}rangeBy(t){let r={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:r.column+1,line:r.line};if(t.word){let o=this.toString(),a=o.indexOf(t.word);a!==-1&&(r=this.positionInside(a,o),n=this.positionInside(a+t.word.length,o))}else t.start?r={column:t.start.column,line:t.start.line}:t.index&&(r=this.positionInside(t.index)),t.end?n={column:t.end.column,line:t.end.line}:typeof t.endIndex=="number"?n=this.positionInside(t.endIndex):t.index&&(n=this.positionInside(t.index+1));return(n.line<r.line||n.line===r.line&&n.column<=r.column)&&(n={column:r.column+1,line:r.line}),{end:n,start:r}}raw(t,r){return new QI().raw(this,t,r)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...t){if(this.parent){let r=this,n=!1;for(let o of t)o===this?n=!0:n?(this.parent.insertAfter(r,o),r=o):this.parent.insertBefore(r,o);n||this.remove()}return this}root(){let t=this;for(;t.parent&&t.parent.type!=="document";)t=t.parent;return t}toJSON(t,r){let n={},o=r==null;r=r||new Map;let a=0;for(let i in this){if(!Object.prototype.hasOwnProperty.call(this,i)||i==="parent"||i==="proxyCache")continue;let s=this[i];if(Array.isArray(s))n[i]=s.map(l=>typeof l=="object"&&l.toJSON?l.toJSON(null,r):l);else if(typeof s=="object"&&s.toJSON)n[i]=s.toJSON(null,r);else if(i==="source"){let l=r.get(s.input);l==null&&(l=a,r.set(s.input,a),a++),n[i]={end:s.end,inputId:l,start:s.start}}else n[i]=s}return o&&(n.inputs=[...r.keys()].map(i=>i.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(t=eL){t.stringify&&(t=t.stringify);let r="";return t(this,n=>{r+=n}),r}warn(t,r,n){let o={node:this};for(let a in n)o[a]=n[a];return t.warn(r,o)}get proxyOf(){return this}},ss=nd;nd.default=nd;var tL=ss,od=class extends tL{constructor(t){t&&typeof t.value<"u"&&typeof t.value!="string"&&(t={...t,value:String(t.value)}),super(t),this.type="decl"}get variable(){return this.prop.startsWith("--")||this.prop[0]==="$"}},ls=od;od.default=od;var rL="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",nL=(e,t=21)=>(r=t)=>{let n="",o=r;for(;o--;)n+=e[Math.random()*e.length|0];return n},oL=(e=21)=>{let t="",r=e;for(;r--;)t+=rL[Math.random()*64|0];return t},aL={nanoid:oL,customAlphabet:nL},{SourceMapConsumer:Bg,SourceMapGenerator:$g}=qe,{existsSync:iL,readFileSync:sL}=qe,{dirname:Vc,join:lL}=qe;function cL(e){return Buffer?Buffer.from(e,"base64").toString():window.atob(e)}var ad=class{constructor(t,r){if(r.map===!1)return;this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");let n=r.map?r.map.prev:void 0,o=this.loadMap(r.from,n);!this.mapFile&&r.from&&(this.mapFile=r.from),this.mapFile&&(this.root=Vc(this.mapFile)),o&&(this.text=o)}consumer(){return this.consumerCache||(this.consumerCache=new Bg(this.text)),this.consumerCache}decodeInline(t){let r=/^data:application\/json;charset=utf-?8;base64,/,n=/^data:application\/json;base64,/,o=/^data:application\/json;charset=utf-?8,/,a=/^data:application\/json,/;if(o.test(t)||a.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(r.test(t)||n.test(t))return cL(t.substr(RegExp.lastMatch.length));let i=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+i)}getAnnotationURL(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(t){return typeof t!="object"?!1:typeof t.mappings=="string"||typeof t._mappings=="string"||Array.isArray(t.sections)}loadAnnotation(t){let r=t.match(/\/\*\s*# sourceMappingURL=/gm);if(!r)return;let n=t.lastIndexOf(r.pop()),o=t.indexOf("*/",n);n>-1&&o>-1&&(this.annotation=this.getAnnotationURL(t.substring(n,o)))}loadFile(t){if(this.root=Vc(t),iL(t))return this.mapFile=t,sL(t,"utf-8").toString().trim()}loadMap(t,r){if(r===!1)return!1;if(r){if(typeof r=="string")return r;if(typeof r=="function"){let n=r(t);if(n){let o=this.loadFile(n);if(!o)throw new Error("Unable to load previous source map: "+n.toString());return o}}else{if(r instanceof Bg)return $g.fromSourceMap(r).toString();if(r instanceof $g)return r.toString();if(this.isMap(r))return JSON.stringify(r);throw new Error("Unsupported previous source map format: "+r.toString())}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let n=this.annotation;return t&&(n=lL(Vc(t),n)),this.loadFile(n)}}}startWith(t,r){return t?t.substr(0,r.length)===r:!1}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},jS=ad;ad.default=ad;var{SourceMapConsumer:dL,SourceMapGenerator:uL}=qe,{fileURLToPath:jg,pathToFileURL:gi}=qe,{isAbsolute:id,resolve:sd}=qe,{nanoid:pL}=aL,_c=qe,Vg=qd,fL=jS,Uc=Symbol("fromOffsetCache"),mL=!!(dL&&uL),_g=!!(sd&&id),Ji=class{constructor(t,r={}){if(t===null||typeof t>"u"||typeof t=="object"&&!t.toString)throw new Error(`PostCSS received ${t} instead of CSS string`);if(this.css=t.toString(),this.css[0]==="\uFEFF"||this.css[0]==="\uFFFE"?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,r.from&&(!_g||/^\w+:\/\//.test(r.from)||id(r.from)?this.file=r.from:this.file=sd(r.from)),_g&&mL){let n=new fL(this.css,r);if(n.text){this.map=n;let o=n.consumer().file;!this.file&&o&&(this.file=this.mapResolve(o))}}this.file||(this.id="<input css "+pL(6)+">"),this.map&&(this.map.file=this.from)}error(t,r,n,o={}){let a,i,s;if(r&&typeof r=="object"){let c=r,d=n;if(typeof c.offset=="number"){let u=this.fromOffset(c.offset);r=u.line,n=u.col}else r=c.line,n=c.column;if(typeof d.offset=="number"){let u=this.fromOffset(d.offset);i=u.line,s=u.col}else i=d.line,s=d.column}else if(!n){let c=this.fromOffset(r);r=c.line,n=c.col}let l=this.origin(r,n,i,s);return l?a=new Vg(t,l.endLine===void 0?l.line:{column:l.column,line:l.line},l.endLine===void 0?l.column:{column:l.endColumn,line:l.endLine},l.source,l.file,o.plugin):a=new Vg(t,i===void 0?r:{column:n,line:r},i===void 0?n:{column:s,line:i},this.css,this.file,o.plugin),a.input={column:n,endColumn:s,endLine:i,line:r,source:this.css},this.file&&(gi&&(a.input.url=gi(this.file).toString()),a.input.file=this.file),a}fromOffset(t){let r,n;if(this[Uc])n=this[Uc];else{let a=this.css.split(`
|
|
24
|
+
`);n=new Array(a.length);let i=0;for(let s=0,l=a.length;s<l;s++)n[s]=i,i+=a[s].length+1;this[Uc]=n}r=n[n.length-1];let o=0;if(t>=r)o=n.length-1;else{let a=n.length-2,i;for(;o<a;)if(i=o+(a-o>>1),t<n[i])a=i-1;else if(t>=n[i+1])o=i+1;else{o=i;break}}return{col:t-n[o]+1,line:o+1}}mapResolve(t){return/^\w+:\/\//.test(t)?t:sd(this.map.consumer().sourceRoot||this.map.root||".",t)}origin(t,r,n,o){if(!this.map)return!1;let a=this.map.consumer(),i=a.originalPositionFor({column:r,line:t});if(!i.source)return!1;let s;typeof n=="number"&&(s=a.originalPositionFor({column:o,line:n}));let l;id(i.source)?l=gi(i.source):l=new URL(i.source,this.map.consumer().sourceRoot||gi(this.map.mapFile));let c={column:i.column,endColumn:s&&s.column,endLine:s&&s.line,line:i.line,url:l.toString()};if(l.protocol==="file:")if(jg)c.file=jg(l);else throw new Error("file: protocol is not available in this PostCSS build");let d=a.sourceContentFor(i.source);return d&&(c.source=d),c}toJSON(){let t={};for(let r of["hasBOM","css","file","id"])this[r]!=null&&(t[r]=this[r]);return this.map&&(t.map={...this.map},t.map.consumerCache&&(t.map.consumerCache=void 0)),t}get from(){return this.file||this.id}},cs=Ji;Ji.default=Ji;_c&&_c.registerInput&&_c.registerInput(Ji);var{SourceMapConsumer:VS,SourceMapGenerator:Bi}=qe,{dirname:$i,relative:_S,resolve:US,sep:WS}=qe,{pathToFileURL:Ug}=qe,yL=cs,hL=!!(VS&&Bi),gL=!!($i&&US&&_S&&WS),SL=class{constructor(t,r,n,o){this.stringify=t,this.mapOpts=n.map||{},this.root=r,this.opts=n,this.css=o,this.originalCSS=o,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){let t;this.isInline()?t="data:application/json;base64,"+this.toBase64(this.map.toString()):typeof this.mapOpts.annotation=="string"?t=this.mapOpts.annotation:typeof this.mapOpts.annotation=="function"?t=this.mapOpts.annotation(this.opts.to,this.root):t=this.outputFile()+".map";let r=`
|
|
25
|
+
`;this.css.includes(`\r
|
|
26
|
+
`)&&(r=`\r
|
|
27
|
+
`),this.css+=r+"/*# sourceMappingURL="+t+" */"}applyPrevMaps(){for(let t of this.previous()){let r=this.toUrl(this.path(t.file)),n=t.root||$i(t.file),o;this.mapOpts.sourcesContent===!1?(o=new VS(t.text),o.sourcesContent&&(o.sourcesContent=null)):o=t.consumer(),this.map.applySourceMap(o,r,this.toUrl(this.path(n)))}}clearAnnotation(){if(this.mapOpts.annotation!==!1)if(this.root){let t;for(let r=this.root.nodes.length-1;r>=0;r--)t=this.root.nodes[r],t.type==="comment"&&t.text.indexOf("# sourceMappingURL=")===0&&this.root.removeChild(r)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),gL&&hL&&this.isMap())return this.generateMap();{let t="";return this.stringify(this.root,r=>{t+=r}),[t]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=Bi.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new Bi({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new Bi({file:this.outputFile(),ignoreInvalidMapping:!0});let t=1,r=1,n="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""},a,i;this.stringify(this.root,(s,l,c)=>{if(this.css+=s,l&&c!=="end"&&(o.generated.line=t,o.generated.column=r-1,l.source&&l.source.start?(o.source=this.sourcePath(l),o.original.line=l.source.start.line,o.original.column=l.source.start.column-1,this.map.addMapping(o)):(o.source=n,o.original.line=1,o.original.column=0,this.map.addMapping(o))),a=s.match(/\n/g),a?(t+=a.length,i=s.lastIndexOf(`
|
|
28
|
+
`),r=s.length-i):r+=s.length,l&&c!=="start"){let d=l.parent||{raws:{}};(!(l.type==="decl"||l.type==="atrule"&&!l.nodes)||l!==d.last||d.raws.semicolon)&&(l.source&&l.source.end?(o.source=this.sourcePath(l),o.original.line=l.source.end.line,o.original.column=l.source.end.column-1,o.generated.line=t,o.generated.column=r-2,this.map.addMapping(o)):(o.source=n,o.original.line=1,o.original.column=0,o.generated.line=t,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(t=>t.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let t=this.mapOpts.annotation;return typeof t<"u"&&t!==!0?!1:this.previous().length?this.previous().some(r=>r.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(t=>t.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(t){if(this.mapOpts.absolute||t.charCodeAt(0)===60||/^\w+:\/\//.test(t))return t;let r=this.memoizedPaths.get(t);if(r)return r;let n=this.opts.to?$i(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(n=$i(US(n,this.mapOpts.annotation)));let o=_S(n,t);return this.memoizedPaths.set(t,o),o}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(t=>{if(t.source&&t.source.input.map){let r=t.source.input.map;this.previousMaps.includes(r)||this.previousMaps.push(r)}});else{let t=new yL(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps}setSourcesContent(){let t={};if(this.root)this.root.walk(r=>{if(r.source){let n=r.source.input.from;if(n&&!t[n]){t[n]=!0;let o=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(o,r.source.input.css)}}});else if(this.css){let r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}}sourcePath(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))}toBase64(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))}toFileUrl(t){let r=this.memoizedFileURLs.get(t);if(r)return r;if(Ug){let n=Ug(t).toString();return this.memoizedFileURLs.set(t,n),n}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(t){let r=this.memoizedURLs.get(t);if(r)return r;WS==="\\"&&(t=t.replace(/\\/g,"/"));let n=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,n),n}},qS=SL,bL=ss,ld=class extends bL{constructor(t){super(t),this.type="comment"}},ds=ld;ld.default=ld;var{isClean:zS,my:KS}=wo,HS=ls,JS=ds,RL=ss,GS,zd,Kd,YS;function ZS(e){return e.map(t=>(t.nodes&&(t.nodes=ZS(t.nodes)),delete t.source,t))}function XS(e){if(e[zS]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)XS(t)}var ht=class QS extends RL{append(...t){for(let r of t){let n=this.normalize(r,this.last);for(let o of n)this.proxyOf.nodes.push(o)}return this.markDirty(),this}cleanRaws(t){if(super.cleanRaws(t),this.nodes)for(let r of this.nodes)r.cleanRaws(t)}each(t){if(!this.proxyOf.nodes)return;let r=this.getIterator(),n,o;for(;this.indexes[r]<this.proxyOf.nodes.length&&(n=this.indexes[r],o=t(this.proxyOf.nodes[n],n),o!==!1);)this.indexes[r]+=1;return delete this.indexes[r],o}every(t){return this.nodes.every(t)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let t=this.lastEach;return this.indexes[t]=0,t}getProxyProcessor(){return{get(t,r){return r==="proxyOf"?t:t[r]?r==="each"||typeof r=="string"&&r.startsWith("walk")?(...n)=>t[r](...n.map(o=>typeof o=="function"?(a,i)=>o(a.toProxy(),i):o)):r==="every"||r==="some"?n=>t[r]((o,...a)=>n(o.toProxy(),...a)):r==="root"?()=>t.root().toProxy():r==="nodes"?t.nodes.map(n=>n.toProxy()):r==="first"||r==="last"?t[r].toProxy():t[r]:t[r]},set(t,r,n){return t[r]===n||(t[r]=n,(r==="name"||r==="params"||r==="selector")&&t.markDirty()),!0}}}index(t){return typeof t=="number"?t:(t.proxyOf&&(t=t.proxyOf),this.proxyOf.nodes.indexOf(t))}insertAfter(t,r){let n=this.index(t),o=this.normalize(r,this.proxyOf.nodes[n]).reverse();n=this.index(t);for(let i of o)this.proxyOf.nodes.splice(n+1,0,i);let a;for(let i in this.indexes)a=this.indexes[i],n<a&&(this.indexes[i]=a+o.length);return this.markDirty(),this}insertBefore(t,r){let n=this.index(t),o=n===0?"prepend":!1,a=this.normalize(r,this.proxyOf.nodes[n],o).reverse();n=this.index(t);for(let s of a)this.proxyOf.nodes.splice(n,0,s);let i;for(let s in this.indexes)i=this.indexes[s],n<=i&&(this.indexes[s]=i+a.length);return this.markDirty(),this}normalize(t,r){if(typeof t=="string")t=ZS(GS(t).nodes);else if(typeof t>"u")t=[];else if(Array.isArray(t)){t=t.slice(0);for(let o of t)o.parent&&o.parent.removeChild(o,"ignore")}else if(t.type==="root"&&this.type!=="document"){t=t.nodes.slice(0);for(let o of t)o.parent&&o.parent.removeChild(o,"ignore")}else if(t.type)t=[t];else if(t.prop){if(typeof t.value>"u")throw new Error("Value field is missed in node creation");typeof t.value!="string"&&(t.value=String(t.value)),t=[new HS(t)]}else if(t.selector)t=[new zd(t)];else if(t.name)t=[new Kd(t)];else if(t.text)t=[new JS(t)];else throw new Error("Unknown node type in node creation");return t.map(o=>(o[KS]||QS.rebuild(o),o=o.proxyOf,o.parent&&o.parent.removeChild(o),o[zS]&&XS(o),typeof o.raws.before>"u"&&r&&typeof r.raws.before<"u"&&(o.raws.before=r.raws.before.replace(/\S/g,"")),o.parent=this.proxyOf,o))}prepend(...t){t=t.reverse();for(let r of t){let n=this.normalize(r,this.first,"prepend").reverse();for(let o of n)this.proxyOf.nodes.unshift(o);for(let o in this.indexes)this.indexes[o]=this.indexes[o]+n.length}return this.markDirty(),this}push(t){return t.parent=this,this.proxyOf.nodes.push(t),this}removeAll(){for(let t of this.proxyOf.nodes)t.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(t){t=this.index(t),this.proxyOf.nodes[t].parent=void 0,this.proxyOf.nodes.splice(t,1);let r;for(let n in this.indexes)r=this.indexes[n],r>=t&&(this.indexes[n]=r-1);return this.markDirty(),this}replaceValues(t,r,n){return n||(n=r,r={}),this.walkDecls(o=>{r.props&&!r.props.includes(o.prop)||r.fast&&!o.value.includes(r.fast)||(o.value=o.value.replace(t,n))}),this.markDirty(),this}some(t){return this.nodes.some(t)}walk(t){return this.each((r,n)=>{let o;try{o=t(r,n)}catch(a){throw r.addToError(a)}return o!==!1&&r.walk&&(o=r.walk(t)),o})}walkAtRules(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="atrule"&&t.test(n.name))return r(n,o)}):this.walk((n,o)=>{if(n.type==="atrule"&&n.name===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="atrule")return r(n,o)}))}walkComments(t){return this.walk((r,n)=>{if(r.type==="comment")return t(r,n)})}walkDecls(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="decl"&&t.test(n.prop))return r(n,o)}):this.walk((n,o)=>{if(n.type==="decl"&&n.prop===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="decl")return r(n,o)}))}walkRules(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="rule"&&t.test(n.selector))return r(n,o)}):this.walk((n,o)=>{if(n.type==="rule"&&n.selector===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="rule")return r(n,o)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};ht.registerParse=e=>{GS=e};ht.registerRule=e=>{zd=e};ht.registerAtRule=e=>{Kd=e};ht.registerRoot=e=>{YS=e};var fr=ht;ht.default=ht;ht.rebuild=e=>{e.type==="atrule"?Object.setPrototypeOf(e,Kd.prototype):e.type==="rule"?Object.setPrototypeOf(e,zd.prototype):e.type==="decl"?Object.setPrototypeOf(e,HS.prototype):e.type==="comment"?Object.setPrototypeOf(e,JS.prototype):e.type==="root"&&Object.setPrototypeOf(e,YS.prototype),e[KS]=!0,e.nodes&&e.nodes.forEach(t=>{ht.rebuild(t)})};var vL=fr,eb,tb,fo=class extends vL{constructor(t){super({type:"document",...t}),this.nodes||(this.nodes=[])}toResult(t={}){return new eb(new tb,this,t).stringify()}};fo.registerLazyResult=e=>{eb=e};fo.registerProcessor=e=>{tb=e};var Hd=fo;fo.default=fo;var Wg={},rb=function(t){Wg[t]||(Wg[t]=!0,typeof console<"u"&&console.warn&&console.warn(t))},cd=class{constructor(t,r={}){if(this.type="warning",this.text=t,r.node&&r.node.source){let n=r.node.rangeBy(r);this.line=n.start.line,this.column=n.start.column,this.endLine=n.end.line,this.endColumn=n.end.column}for(let n in r)this[n]=r[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},nb=cd;cd.default=cd;var wL=nb,dd=class{constructor(t,r,n){this.processor=t,this.messages=[],this.root=r,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(t,r={}){r.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(r.plugin=this.lastPlugin.postcssPlugin);let n=new wL(t,r);return this.messages.push(n),n}warnings(){return this.messages.filter(t=>t.type==="warning")}get content(){return this.css}},Jd=dd;dd.default=dd;var Wc=39,qg=34,Si=92,zg=47,bi=10,no=32,Ri=12,vi=9,wi=13,EL=91,xL=93,kL=40,CL=41,AL=123,PL=125,OL=59,ML=42,TL=58,IL=64,Ei=/[\t\n\f\r "#'()/;[\\\]{}]/g,xi=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,LL=/.[\r\n"'(/\\]/,Kg=/[\da-f]/i,NL=function(t,r={}){let n=t.css.valueOf(),o=r.ignoreErrors,a,i,s,l,c,d,u,f,y,m,h=n.length,p=0,b=[],w=[];function S(){return p}function E(W){throw t.error("Unclosed "+W,p)}function L(){return w.length===0&&p>=h}function V(W){if(w.length)return w.pop();if(p>=h)return;let ae=W?W.ignoreUnclosed:!1;switch(a=n.charCodeAt(p),a){case bi:case no:case vi:case wi:case Ri:{i=p;do i+=1,a=n.charCodeAt(i);while(a===no||a===bi||a===vi||a===wi||a===Ri);m=["space",n.slice(p,i)],p=i-1;break}case EL:case xL:case AL:case PL:case TL:case OL:case CL:{let pe=String.fromCharCode(a);m=[pe,pe,p];break}case kL:{if(f=b.length?b.pop()[1]:"",y=n.charCodeAt(p+1),f==="url"&&y!==Wc&&y!==qg&&y!==no&&y!==bi&&y!==vi&&y!==Ri&&y!==wi){i=p;do{if(d=!1,i=n.indexOf(")",i+1),i===-1)if(o||ae){i=p;break}else E("bracket");for(u=i;n.charCodeAt(u-1)===Si;)u-=1,d=!d}while(d);m=["brackets",n.slice(p,i+1),p,i],p=i}else i=n.indexOf(")",p+1),l=n.slice(p,i+1),i===-1||LL.test(l)?m=["(","(",p]:(m=["brackets",l,p,i],p=i);break}case Wc:case qg:{s=a===Wc?"'":'"',i=p;do{if(d=!1,i=n.indexOf(s,i+1),i===-1)if(o||ae){i=p+1;break}else E("string");for(u=i;n.charCodeAt(u-1)===Si;)u-=1,d=!d}while(d);m=["string",n.slice(p,i+1),p,i],p=i;break}case IL:{Ei.lastIndex=p+1,Ei.test(n),Ei.lastIndex===0?i=n.length-1:i=Ei.lastIndex-2,m=["at-word",n.slice(p,i+1),p,i],p=i;break}case Si:{for(i=p,c=!0;n.charCodeAt(i+1)===Si;)i+=1,c=!c;if(a=n.charCodeAt(i+1),c&&a!==zg&&a!==no&&a!==bi&&a!==vi&&a!==wi&&a!==Ri&&(i+=1,Kg.test(n.charAt(i)))){for(;Kg.test(n.charAt(i+1));)i+=1;n.charCodeAt(i+1)===no&&(i+=1)}m=["word",n.slice(p,i+1),p,i],p=i;break}default:{a===zg&&n.charCodeAt(p+1)===ML?(i=n.indexOf("*/",p+2)+1,i===0&&(o||ae?i=n.length:E("comment")),m=["comment",n.slice(p,i+1),p,i],p=i):(xi.lastIndex=p+1,xi.test(n),xi.lastIndex===0?i=n.length-1:i=xi.lastIndex-2,m=["word",n.slice(p,i+1),p,i],b.push(m),p=i);break}}return p++,m}function ne(W){w.push(W)}return{back:ne,endOfFile:L,nextToken:V,position:S}},ob=fr,Gi=class extends ob{constructor(t){super(t),this.type="atrule"}append(...t){return this.proxyOf.nodes||(this.nodes=[]),super.append(...t)}prepend(...t){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...t)}},Gd=Gi;Gi.default=Gi;ob.registerAtRule(Gi);var ab=fr,ib,sb,on=class extends ab{constructor(t){super(t),this.type="root",this.nodes||(this.nodes=[])}normalize(t,r,n){let o=super.normalize(t);if(r){if(n==="prepend")this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(let a of o)a.raws.before=r.raws.before}return o}removeChild(t,r){let n=this.index(t);return!r&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(t)}toResult(t={}){return new ib(new sb,this,t).stringify()}};on.registerLazyResult=e=>{ib=e};on.registerProcessor=e=>{sb=e};var Eo=on;on.default=on;ab.registerRoot(on);var mo={comma(e){return mo.split(e,[","],!0)},space(e){let t=[" ",`
|
|
29
|
+
`," "];return mo.split(e,t)},split(e,t,r){let n=[],o="",a=!1,i=0,s=!1,l="",c=!1;for(let d of e)c?c=!1:d==="\\"?c=!0:s?d===l&&(s=!1):d==='"'||d==="'"?(s=!0,l=d):d==="("?i+=1:d===")"?i>0&&(i-=1):i===0&&t.includes(d)&&(a=!0),a?(o!==""&&n.push(o.trim()),o="",a=!1):o+=d;return(r||o!=="")&&n.push(o.trim()),n}},lb=mo;mo.default=mo;var cb=fr,FL=lb,Yi=class extends cb{constructor(t){super(t),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return FL.comma(this.selector)}set selectors(t){let r=this.selector?this.selector.match(/,\s*/):null,n=r?r[0]:","+this.raw("between","beforeOpen");this.selector=t.join(n)}},Yd=Yi;Yi.default=Yi;cb.registerRule(Yi);var DL=ls,BL=NL,$L=ds,jL=Gd,VL=Eo,Hg=Yd,Jg={empty:!0,space:!0};function _L(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=r[3]||r[2];if(n)return n}}var UL=class{constructor(t){this.input=t,this.root=new VL,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}atrule(t){let r=new jL;r.name=t[1].slice(1),r.name===""&&this.unnamedAtrule(r,t),this.init(r,t[2]);let n,o,a,i=!1,s=!1,l=[],c=[];for(;!this.tokenizer.endOfFile();){if(t=this.tokenizer.nextToken(),n=t[0],n==="("||n==="["?c.push(n==="("?")":"]"):n==="{"&&c.length>0?c.push("}"):n===c[c.length-1]&&c.pop(),c.length===0)if(n===";"){r.source.end=this.getPosition(t[2]),r.source.end.offset++,this.semicolon=!0;break}else if(n==="{"){s=!0;break}else if(n==="}"){if(l.length>0){for(a=l.length-1,o=l[a];o&&o[0]==="space";)o=l[--a];o&&(r.source.end=this.getPosition(o[3]||o[2]),r.source.end.offset++)}this.end(t);break}else l.push(t);else l.push(t);if(this.tokenizer.endOfFile()){i=!0;break}}r.raws.between=this.spacesAndCommentsFromEnd(l),l.length?(r.raws.afterName=this.spacesAndCommentsFromStart(l),this.raw(r,"params",l),i&&(t=l[l.length-1],r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++,this.spaces=r.raws.between,r.raws.between="")):(r.raws.afterName="",r.params=""),s&&(r.nodes=[],this.current=r)}checkMissedSemicolon(t){let r=this.colon(t);if(r===!1)return;let n=0,o;for(let a=r-1;a>=0&&(o=t[a],!(o[0]!=="space"&&(n+=1,n===2)));a--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}colon(t){let r=0,n,o,a;for(let[i,s]of t.entries()){if(n=s,o=n[0],o==="("&&(r+=1),o===")"&&(r-=1),r===0&&o===":")if(!a)this.doubleColon(n);else{if(a[0]==="word"&&a[1]==="progid")continue;return i}a=n}return!1}comment(t){let r=new $L;this.init(r,t[2]),r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++;let n=t[1].slice(2,-2);if(/^\s*$/.test(n))r.text="",r.raws.left=n,r.raws.right="";else{let o=n.match(/^(\s*)([^]*\S)(\s*)$/);r.text=o[2],r.raws.left=o[1],r.raws.right=o[3]}}createTokenizer(){this.tokenizer=BL(this.input)}decl(t,r){let n=new DL;this.init(n,t[0][2]);let o=t[t.length-1];for(o[0]===";"&&(this.semicolon=!0,t.pop()),n.source.end=this.getPosition(o[3]||o[2]||_L(t)),n.source.end.offset++;t[0][0]!=="word";)t.length===1&&this.unknownWord(t),n.raws.before+=t.shift()[1];for(n.source.start=this.getPosition(t[0][2]),n.prop="";t.length;){let c=t[0][0];if(c===":"||c==="space"||c==="comment")break;n.prop+=t.shift()[1]}n.raws.between="";let a;for(;t.length;)if(a=t.shift(),a[0]===":"){n.raws.between+=a[1];break}else a[0]==="word"&&/\w/.test(a[1])&&this.unknownWord([a]),n.raws.between+=a[1];(n.prop[0]==="_"||n.prop[0]==="*")&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let i=[],s;for(;t.length&&(s=t[0][0],!(s!=="space"&&s!=="comment"));)i.push(t.shift());this.precheckMissedSemicolon(t);for(let c=t.length-1;c>=0;c--){if(a=t[c],a[1].toLowerCase()==="!important"){n.important=!0;let d=this.stringFrom(t,c);d=this.spacesFromEnd(t)+d,d!==" !important"&&(n.raws.important=d);break}else if(a[1].toLowerCase()==="important"){let d=t.slice(0),u="";for(let f=c;f>0;f--){let y=d[f][0];if(u.trim().indexOf("!")===0&&y!=="space")break;u=d.pop()[1]+u}u.trim().indexOf("!")===0&&(n.important=!0,n.raws.important=u,t=d)}if(a[0]!=="space"&&a[0]!=="comment")break}t.some(c=>c[0]!=="space"&&c[0]!=="comment")&&(n.raws.between+=i.map(c=>c[1]).join(""),i=[]),this.raw(n,"value",i.concat(t),r),n.value.includes(":")&&!r&&this.checkMissedSemicolon(t)}doubleColon(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})}emptyRule(t){let r=new Hg;this.init(r,t[2]),r.selector="",r.raws.between="",this.current=r}end(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(t){if(this.spaces+=t[1],this.current.nodes){let r=this.current.nodes[this.current.nodes.length-1];r&&r.type==="rule"&&!r.raws.ownSemicolon&&(r.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(t){let r=this.input.fromOffset(t);return{column:r.col,line:r.line,offset:t}}init(t,r){this.current.push(t),t.source={input:this.input,start:this.getPosition(r)},t.raws.before=this.spaces,this.spaces="",t.type!=="comment"&&(this.semicolon=!1)}other(t){let r=!1,n=null,o=!1,a=null,i=[],s=t[1].startsWith("--"),l=[],c=t;for(;c;){if(n=c[0],l.push(c),n==="("||n==="[")a||(a=c),i.push(n==="("?")":"]");else if(s&&o&&n==="{")a||(a=c),i.push("}");else if(i.length===0)if(n===";")if(o){this.decl(l,s);return}else break;else if(n==="{"){this.rule(l);return}else if(n==="}"){this.tokenizer.back(l.pop()),r=!0;break}else n===":"&&(o=!0);else n===i[i.length-1]&&(i.pop(),i.length===0&&(a=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(r=!0),i.length>0&&this.unclosedBracket(a),r&&o){if(!s)for(;l.length&&(c=l[l.length-1][0],!(c!=="space"&&c!=="comment"));)this.tokenizer.back(l.pop());this.decl(l,s)}else this.unknownWord(l)}parse(){let t;for(;!this.tokenizer.endOfFile();)switch(t=this.tokenizer.nextToken(),t[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t);break}this.endFile()}precheckMissedSemicolon(){}raw(t,r,n,o){let a,i,s=n.length,l="",c=!0,d,u;for(let f=0;f<s;f+=1)a=n[f],i=a[0],i==="space"&&f===s-1&&!o?c=!1:i==="comment"?(u=n[f-1]?n[f-1][0]:"empty",d=n[f+1]?n[f+1][0]:"empty",!Jg[u]&&!Jg[d]?l.slice(-1)===","?c=!1:l+=a[1]:c=!1):l+=a[1];if(!c){let f=n.reduce((y,m)=>y+m[1],"");t.raws[r]={raw:f,value:l}}t[r]=l}rule(t){t.pop();let r=new Hg;this.init(r,t[0][2]),r.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(r,"selector",t),this.current=r}spacesAndCommentsFromEnd(t){let r,n="";for(;t.length&&(r=t[t.length-1][0],!(r!=="space"&&r!=="comment"));)n=t.pop()[1]+n;return n}spacesAndCommentsFromStart(t){let r,n="";for(;t.length&&(r=t[0][0],!(r!=="space"&&r!=="comment"));)n+=t.shift()[1];return n}spacesFromEnd(t){let r,n="";for(;t.length&&(r=t[t.length-1][0],r==="space");)n=t.pop()[1]+n;return n}stringFrom(t,r){let n="";for(let o=r;o<t.length;o++)n+=t[o][1];return t.splice(r,t.length-r),n}unclosedBlock(){let t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)}unclosedBracket(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})}unexpectedClose(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})}unknownWord(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})}unnamedAtrule(t,r){throw this.input.error("At-rule without name",{offset:r[2]},{offset:r[2]+r[1].length})}},WL=UL,qL=fr,zL=WL,KL=cs;function Zi(e,t){let r=new KL(e,t),n=new zL(r);try{n.parse()}catch(o){throw process.env.NODE_ENV!=="production"&&o.name==="CssSyntaxError"&&t&&t.from&&(/\.scss$/i.test(t.from)?o.message+=`
|
|
30
|
+
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser`:/\.sass/i.test(t.from)?o.message+=`
|
|
31
|
+
You tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser`:/\.less$/i.test(t.from)&&(o.message+=`
|
|
32
|
+
You tried to parse Less with the standard CSS parser; try again with the postcss-less parser`)),o}return n.root}var Zd=Zi;Zi.default=Zi;qL.registerParse(Zi);var{isClean:rt,my:HL}=wo,JL=qS,GL=is,YL=fr,ZL=Hd,XL=rb,Gg=Jd,QL=Zd,e0=Eo,t0={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},r0={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},n0={Once:!0,postcssPlugin:!0,prepare:!0},an=0;function oo(e){return typeof e=="object"&&typeof e.then=="function"}function db(e){let t=!1,r=t0[e.type];return e.type==="decl"?t=e.prop.toLowerCase():e.type==="atrule"&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,an,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,an,r+"Exit"]:[r,r+"Exit"]}function Yg(e){let t;return e.type==="document"?t=["Document",an,"DocumentExit"]:e.type==="root"?t=["Root",an,"RootExit"]:t=db(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function ud(e){return e[rt]=!1,e.nodes&&e.nodes.forEach(t=>ud(t)),e}var pd={},sn=class ub{constructor(t,r,n){this.stringified=!1,this.processed=!1;let o;if(typeof r=="object"&&r!==null&&(r.type==="root"||r.type==="document"))o=ud(r);else if(r instanceof ub||r instanceof Gg)o=ud(r.root),r.map&&(typeof n.map>"u"&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{let a=QL;n.syntax&&(a=n.syntax.parse),n.parser&&(a=n.parser),a.parse&&(a=a.parse);try{o=a(r,n)}catch(i){this.processed=!0,this.error=i}o&&!o[HL]&&YL.rebuild(o)}this.result=new Gg(t,o,n),this.helpers={...pd,postcss:pd,result:this.result},this.plugins=this.processor.plugins.map(a=>typeof a=="object"&&a.prepare?{...a,...a.prepare(this.result)}:a)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(t,r){let n=this.result.lastPlugin;try{if(r&&r.addToError(t),this.error=t,t.name==="CssSyntaxError"&&!t.plugin)t.plugin=n.postcssPlugin,t.setMessage();else if(n.postcssVersion&&process.env.NODE_ENV!=="production"){let o=n.postcssPlugin,a=n.postcssVersion,i=this.result.processor.version,s=a.split("."),l=i.split(".");(s[0]!==l[0]||parseInt(s[1])>parseInt(l[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+i+", but "+o+" uses "+a+". Perhaps this is the source of the error below.")}}catch(o){console&&console.error&&console.error(o)}return t}prepareVisitors(){this.listeners={};let t=(r,n,o)=>{this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push([r,o])};for(let r of this.plugins)if(typeof r=="object")for(let n in r){if(!r0[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${r.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!n0[n])if(typeof r[n]=="object")for(let o in r[n])o==="*"?t(r,n,r[n][o]):t(r,n+"-"+o.toLowerCase(),r[n][o]);else typeof r[n]=="function"&&t(r,n,r[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let t=0;t<this.plugins.length;t++){let r=this.plugins[t],n=this.runOnRoot(r);if(oo(n))try{await n}catch(o){throw this.handleError(o)}}if(this.prepareVisitors(),this.hasListener){let t=this.result.root;for(;!t[rt];){t[rt]=!0;let r=[Yg(t)];for(;r.length>0;){let n=this.visitTick(r);if(oo(n))try{await n}catch(o){let a=r[r.length-1].node;throw this.handleError(o,a)}}}if(this.listeners.OnceExit)for(let[r,n]of this.listeners.OnceExit){this.result.lastPlugin=r;try{if(t.type==="document"){let o=t.nodes.map(a=>n(a,this.helpers));await Promise.all(o)}else await n(t,this.helpers)}catch(o){throw this.handleError(o)}}}return this.processed=!0,this.stringify()}runOnRoot(t){this.result.lastPlugin=t;try{if(typeof t=="object"&&t.Once){if(this.result.root.type==="document"){let r=this.result.root.nodes.map(n=>t.Once(n,this.helpers));return oo(r[0])?Promise.all(r):r}return t.Once(this.result.root,this.helpers)}else if(typeof t=="function")return t(this.result.root,this.result)}catch(r){throw this.handleError(r)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let t=this.result.opts,r=GL;t.syntax&&(r=t.syntax.stringify),t.stringifier&&(r=t.stringifier),r.stringify&&(r=r.stringify);let o=new JL(r,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let t of this.plugins){let r=this.runOnRoot(t);if(oo(r))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let t=this.result.root;for(;!t[rt];)t[rt]=!0,this.walkSync(t);if(this.listeners.OnceExit)if(t.type==="document")for(let r of t.nodes)this.visitSync(this.listeners.OnceExit,r);else this.visitSync(this.listeners.OnceExit,t)}return this.result}then(t,r){return process.env.NODE_ENV!=="production"&&("from"in this.opts||XL("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,r)}toString(){return this.css}visitSync(t,r){for(let[n,o]of t){this.result.lastPlugin=n;let a;try{a=o(r,this.helpers)}catch(i){throw this.handleError(i,r.proxyOf)}if(r.type!=="root"&&r.type!=="document"&&!r.parent)return!0;if(oo(a))throw this.getAsyncError()}}visitTick(t){let r=t[t.length-1],{node:n,visitors:o}=r;if(n.type!=="root"&&n.type!=="document"&&!n.parent){t.pop();return}if(o.length>0&&r.visitorIndex<o.length){let[i,s]=o[r.visitorIndex];r.visitorIndex+=1,r.visitorIndex===o.length&&(r.visitors=[],r.visitorIndex=0),this.result.lastPlugin=i;try{return s(n.toProxy(),this.helpers)}catch(l){throw this.handleError(l,n)}}if(r.iterator!==0){let i=r.iterator,s;for(;s=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!s[rt]){s[rt]=!0,t.push(Yg(s));return}r.iterator=0,delete n.indexes[i]}let a=r.events;for(;r.eventIndex<a.length;){let i=a[r.eventIndex];if(r.eventIndex+=1,i===an){n.nodes&&n.nodes.length&&(n[rt]=!0,r.iterator=n.getIterator());return}else if(this.listeners[i]){r.visitors=this.listeners[i];return}}t.pop()}walkSync(t){t[rt]=!0;let r=db(t);for(let n of r)if(n===an)t.nodes&&t.each(o=>{o[rt]||this.walkSync(o)});else{let o=this.listeners[n];if(o&&this.visitSync(o,t.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};sn.registerPostcss=e=>{pd=e};var pb=sn;sn.default=sn;e0.registerLazyResult(sn);ZL.registerLazyResult(sn);var o0=qS,a0=is,i0=rb,s0=Zd,l0=Jd,fd=class{constructor(t,r,n){r=r.toString(),this.stringified=!1,this._processor=t,this._css=r,this._opts=n,this._map=void 0;let o,a=a0;this.result=new l0(this._processor,o,this._opts),this.result.css=r;let i=this;Object.defineProperty(this.result,"root",{get(){return i.root}});let s=new o0(a,o,this._opts,r);if(s.isMap()){let[l,c]=s.generate();l&&(this.result.css=l),c&&(this.result.map=c)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}sync(){if(this.error)throw this.error;return this.result}then(t,r){return process.env.NODE_ENV!=="production"&&("from"in this._opts||i0("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,r)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let t,r=s0;try{t=r(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=t,t}get[Symbol.toStringTag](){return"NoWorkResult"}},c0=fd;fd.default=fd;var d0=c0,u0=pb,p0=Hd,f0=Eo,yo=class{constructor(t=[]){this.version="8.4.38",this.plugins=this.normalize(t)}normalize(t){let r=[];for(let n of t)if(n.postcss===!0?n=n():n.postcss&&(n=n.postcss),typeof n=="object"&&Array.isArray(n.plugins))r=r.concat(n.plugins);else if(typeof n=="object"&&n.postcssPlugin)r.push(n);else if(typeof n=="function")r.push(n);else if(typeof n=="object"&&(n.parse||n.stringify)){if(process.env.NODE_ENV!=="production")throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}else throw new Error(n+" is not a PostCSS plugin");return r}process(t,r={}){return!this.plugins.length&&!r.parser&&!r.stringifier&&!r.syntax?new d0(this,t,r):new u0(this,t,r)}use(t){return this.plugins=this.plugins.concat(this.normalize([t])),this}},m0=yo;yo.default=yo;f0.registerProcessor(yo);p0.registerProcessor(yo);var y0=ls,h0=jS,g0=ds,S0=Gd,b0=cs,R0=Eo,v0=Yd;function ho(e,t){if(Array.isArray(e))return e.map(o=>ho(o));let{inputs:r,...n}=e;if(r){t=[];for(let o of r){let a={...o,__proto__:b0.prototype};a.map&&(a.map={...a.map,__proto__:h0.prototype}),t.push(a)}}if(n.nodes&&(n.nodes=e.nodes.map(o=>ho(o,t))),n.source){let{inputId:o,...a}=n.source;n.source=a,o!=null&&(n.source.input=t[o])}if(n.type==="root")return new R0(n);if(n.type==="decl")return new y0(n);if(n.type==="rule")return new v0(n);if(n.type==="comment")return new g0(n);if(n.type==="atrule")return new S0(n);throw new Error("Unknown node type: "+e.type)}var w0=ho;ho.default=ho;var E0=qd,fb=ls,x0=pb,k0=fr,Xd=m0,C0=is,A0=w0,mb=Hd,P0=nb,yb=ds,hb=Gd,O0=Jd,M0=cs,T0=Zd,I0=lb,gb=Yd,Sb=Eo,L0=ss;function $(...e){return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new Xd(e)}$.plugin=function(t,r){let n=!1;function o(...i){console&&console.warn&&!n&&(n=!0,console.warn(t+`: postcss.plugin was deprecated. Migration guide:
|
|
33
|
+
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(t+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
|
|
34
|
+
https://www.w3ctech.com/topic/2226`));let s=r(...i);return s.postcssPlugin=t,s.postcssVersion=new Xd().version,s}let a;return Object.defineProperty(o,"postcss",{get(){return a||(a=o()),a}}),o.process=function(i,s,l){return $([o(l)]).process(i,s)},o};$.stringify=C0;$.parse=T0;$.fromJSON=A0;$.list=I0;$.comment=e=>new yb(e);$.atRule=e=>new hb(e);$.decl=e=>new fb(e);$.rule=e=>new gb(e);$.root=e=>new Sb(e);$.document=e=>new mb(e);$.CssSyntaxError=E0;$.Declaration=fb;$.Container=k0;$.Processor=Xd;$.Document=mb;$.Comment=yb;$.Warning=P0;$.AtRule=hb;$.Result=O0;$.Input=M0;$.Rule=gb;$.Root=Sb;$.Node=L0;x0.registerPostcss($);var N0=$;$.default=$;var Z=qI(N0);Z.stringify;Z.fromJSON;Z.plugin;Z.parse;Z.list;Z.document;Z.comment;Z.atRule;Z.rule;Z.decl;Z.root;Z.CssSyntaxError;Z.Declaration;Z.Container;Z.Processor;Z.Document;Z.Comment;Z.Warning;Z.AtRule;Z.Result;Z.Input;Z.Rule;Z.Root;Z.Node;var F0=Object.defineProperty,D0=(e,t,r)=>t in e?F0(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Te=(e,t,r)=>D0(e,typeof t!="symbol"?t+"":t,r);function B0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function $0(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),r}var Qd={exports:{}},H=String,bb=function(){return{isColorSupported:!1,reset:H,bold:H,dim:H,italic:H,underline:H,inverse:H,hidden:H,strikethrough:H,black:H,red:H,green:H,yellow:H,blue:H,magenta:H,cyan:H,white:H,gray:H,bgBlack:H,bgRed:H,bgGreen:H,bgYellow:H,bgBlue:H,bgMagenta:H,bgCyan:H,bgWhite:H}};Qd.exports=bb();Qd.exports.createColors=bb;var j0=Qd.exports,V0={},_0=Object.freeze(Object.defineProperty({__proto__:null,default:V0},Symbol.toStringTag,{value:"Module"})),ze=$0(_0),Zg=j0,Xg=ze,md=class Rb extends Error{constructor(t,r,n,o,a,i){super(t),this.name="CssSyntaxError",this.reason=t,a&&(this.file=a),o&&(this.source=o),i&&(this.plugin=i),typeof r<"u"&&typeof n<"u"&&(typeof r=="number"?(this.line=r,this.column=n):(this.line=r.line,this.column=r.column,this.endLine=n.line,this.endColumn=n.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,Rb)}setMessage(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",typeof this.line<"u"&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason}showSourceCode(t){if(!this.source)return"";let r=this.source;t==null&&(t=Zg.isColorSupported),Xg&&t&&(r=Xg(r));let n=r.split(/\r?\n/),o=Math.max(this.line-3,0),a=Math.min(this.line+2,n.length),i=String(a).length,s,l;if(t){let{bold:c,gray:d,red:u}=Zg.createColors(!0);s=f=>c(u(f)),l=f=>d(f)}else s=l=c=>c;return n.slice(o,a).map((c,d)=>{let u=o+1+d,f=" "+(" "+u).slice(-i)+" | ";if(u===this.line){let y=l(f.replace(/\d/g," "))+c.slice(0,this.column-1).replace(/[^\t]/g," ");return s(">")+l(f)+c+`
|
|
35
|
+
`+y+s("^")}return" "+l(f)+c}).join(`
|
|
36
|
+
`)}toString(){let t=this.showSourceCode();return t&&(t=`
|
|
37
|
+
|
|
38
|
+
`+t+`
|
|
39
|
+
`),this.name+": "+this.message+t}},eu=md;md.default=md;var xo={};xo.isClean=Symbol("isClean");xo.my=Symbol("my");var Qg={after:`
|
|
40
|
+
`,beforeClose:`
|
|
41
|
+
`,beforeComment:`
|
|
42
|
+
`,beforeDecl:`
|
|
43
|
+
`,beforeOpen:" ",beforeRule:`
|
|
44
|
+
`,colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};function U0(e){return e[0].toUpperCase()+e.slice(1)}var yd=class{constructor(t){this.builder=t}atrule(t,r){let n="@"+t.name,o=t.params?this.rawValue(t,"params"):"";if(typeof t.raws.afterName<"u"?n+=t.raws.afterName:o&&(n+=" "),t.nodes)this.block(t,n+o);else{let a=(t.raws.between||"")+(r?";":"");this.builder(n+o+a,t)}}beforeAfter(t,r){let n;t.type==="decl"?n=this.raw(t,null,"beforeDecl"):t.type==="comment"?n=this.raw(t,null,"beforeComment"):r==="before"?n=this.raw(t,null,"beforeRule"):n=this.raw(t,null,"beforeClose");let o=t.parent,a=0;for(;o&&o.type!=="root";)a+=1,o=o.parent;if(n.includes(`
|
|
45
|
+
`)){let i=this.raw(t,null,"indent");if(i.length)for(let s=0;s<a;s++)n+=i}return n}block(t,r){let n=this.raw(t,"between","beforeOpen");this.builder(r+n+"{",t,"start");let o;t.nodes&&t.nodes.length?(this.body(t),o=this.raw(t,"after")):o=this.raw(t,"after","emptyBody"),o&&this.builder(o),this.builder("}",t,"end")}body(t){let r=t.nodes.length-1;for(;r>0&&t.nodes[r].type==="comment";)r-=1;let n=this.raw(t,"semicolon");for(let o=0;o<t.nodes.length;o++){let a=t.nodes[o],i=this.raw(a,"before");i&&this.builder(i),this.stringify(a,r!==o||n)}}comment(t){let r=this.raw(t,"left","commentLeft"),n=this.raw(t,"right","commentRight");this.builder("/*"+r+t.text+n+"*/",t)}decl(t,r){let n=this.raw(t,"between","colon"),o=t.prop+n+this.rawValue(t,"value");t.important&&(o+=t.raws.important||" !important"),r&&(o+=";"),this.builder(o,t)}document(t){this.body(t)}raw(t,r,n){let o;if(n||(n=r),r&&(o=t.raws[r],typeof o<"u"))return o;let a=t.parent;if(n==="before"&&(!a||a.type==="root"&&a.first===t||a&&a.type==="document"))return"";if(!a)return Qg[n];let i=t.root();if(i.rawCache||(i.rawCache={}),typeof i.rawCache[n]<"u")return i.rawCache[n];if(n==="before"||n==="after")return this.beforeAfter(t,n);{let s="raw"+U0(n);this[s]?o=this[s](i,t):i.walk(l=>{if(o=l.raws[r],typeof o<"u")return!1})}return typeof o>"u"&&(o=Qg[n]),i.rawCache[n]=o,o}rawBeforeClose(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length>0&&typeof n.raws.after<"u")return r=n.raws.after,r.includes(`
|
|
46
|
+
`)&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawBeforeComment(t,r){let n;return t.walkComments(o=>{if(typeof o.raws.before<"u")return n=o.raws.before,n.includes(`
|
|
47
|
+
`)&&(n=n.replace(/[^\n]+$/,"")),!1}),typeof n>"u"?n=this.raw(r,null,"beforeDecl"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeDecl(t,r){let n;return t.walkDecls(o=>{if(typeof o.raws.before<"u")return n=o.raws.before,n.includes(`
|
|
48
|
+
`)&&(n=n.replace(/[^\n]+$/,"")),!1}),typeof n>"u"?n=this.raw(r,null,"beforeRule"):n&&(n=n.replace(/\S/g,"")),n}rawBeforeOpen(t){let r;return t.walk(n=>{if(n.type!=="decl"&&(r=n.raws.between,typeof r<"u"))return!1}),r}rawBeforeRule(t){let r;return t.walk(n=>{if(n.nodes&&(n.parent!==t||t.first!==n)&&typeof n.raws.before<"u")return r=n.raws.before,r.includes(`
|
|
49
|
+
`)&&(r=r.replace(/[^\n]+$/,"")),!1}),r&&(r=r.replace(/\S/g,"")),r}rawColon(t){let r;return t.walkDecls(n=>{if(typeof n.raws.between<"u")return r=n.raws.between.replace(/[^\s:]/g,""),!1}),r}rawEmptyBody(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length===0&&(r=n.raws.after,typeof r<"u"))return!1}),r}rawIndent(t){if(t.raws.indent)return t.raws.indent;let r;return t.walk(n=>{let o=n.parent;if(o&&o!==t&&o.parent&&o.parent===t&&typeof n.raws.before<"u"){let a=n.raws.before.split(`
|
|
50
|
+
`);return r=a[a.length-1],r=r.replace(/\S/g,""),!1}}),r}rawSemicolon(t){let r;return t.walk(n=>{if(n.nodes&&n.nodes.length&&n.last.type==="decl"&&(r=n.raws.semicolon,typeof r<"u"))return!1}),r}rawValue(t,r){let n=t[r],o=t.raws[r];return o&&o.value===n?o.raw:n}root(t){this.body(t),t.raws.after&&this.builder(t.raws.after)}rule(t){this.block(t,this.rawValue(t,"selector")),t.raws.ownSemicolon&&this.builder(t.raws.ownSemicolon,t,"end")}stringify(t,r){if(!this[t.type])throw new Error("Unknown AST node type "+t.type+". Maybe you need to change PostCSS stringifier.");this[t.type](t,r)}},vb=yd;yd.default=yd;var W0=vb;function hd(e,t){new W0(t).stringify(e)}var us=hd;hd.default=hd;var{isClean:ki,my:q0}=xo,z0=eu,K0=vb,H0=us;function gd(e,t){let r=new e.constructor;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n)||n==="proxyCache")continue;let o=e[n],a=typeof o;n==="parent"&&a==="object"?t&&(r[n]=t):n==="source"?r[n]=o:Array.isArray(o)?r[n]=o.map(i=>gd(i,r)):(a==="object"&&o!==null&&(o=gd(o)),r[n]=o)}return r}var Sd=class{constructor(t={}){this.raws={},this[ki]=!1,this[q0]=!0;for(let r in t)if(r==="nodes"){this.nodes=[];for(let n of t[r])typeof n.clone=="function"?this.append(n.clone()):this.append(n)}else this[r]=t[r]}addToError(t){if(t.postcssNode=this,t.stack&&this.source&&/\n\s{4}at /.test(t.stack)){let r=this.source;t.stack=t.stack.replace(/\n\s{4}at /,`$&${r.input.from}:${r.start.line}:${r.start.column}$&`)}return t}after(t){return this.parent.insertAfter(this,t),this}assign(t={}){for(let r in t)this[r]=t[r];return this}before(t){return this.parent.insertBefore(this,t),this}cleanRaws(t){delete this.raws.before,delete this.raws.after,t||delete this.raws.between}clone(t={}){let r=gd(this);for(let n in t)r[n]=t[n];return r}cloneAfter(t={}){let r=this.clone(t);return this.parent.insertAfter(this,r),r}cloneBefore(t={}){let r=this.clone(t);return this.parent.insertBefore(this,r),r}error(t,r={}){if(this.source){let{end:n,start:o}=this.rangeBy(r);return this.source.input.error(t,{column:o.column,line:o.line},{column:n.column,line:n.line},r)}return new z0(t)}getProxyProcessor(){return{get(t,r){return r==="proxyOf"?t:r==="root"?()=>t.root().toProxy():t[r]},set(t,r,n){return t[r]===n||(t[r]=n,(r==="prop"||r==="value"||r==="name"||r==="params"||r==="important"||r==="text")&&t.markDirty()),!0}}}markDirty(){if(this[ki]){this[ki]=!1;let t=this;for(;t=t.parent;)t[ki]=!1}}next(){if(!this.parent)return;let t=this.parent.index(this);return this.parent.nodes[t+1]}positionBy(t,r){let n=this.source.start;if(t.index)n=this.positionInside(t.index,r);else if(t.word){r=this.toString();let o=r.indexOf(t.word);o!==-1&&(n=this.positionInside(o,r))}return n}positionInside(t,r){let n=r||this.toString(),o=this.source.start.column,a=this.source.start.line;for(let i=0;i<t;i++)n[i]===`
|
|
51
|
+
`?(o=1,a+=1):o+=1;return{column:o,line:a}}prev(){if(!this.parent)return;let t=this.parent.index(this);return this.parent.nodes[t-1]}rangeBy(t){let r={column:this.source.start.column,line:this.source.start.line},n=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:r.column+1,line:r.line};if(t.word){let o=this.toString(),a=o.indexOf(t.word);a!==-1&&(r=this.positionInside(a,o),n=this.positionInside(a+t.word.length,o))}else t.start?r={column:t.start.column,line:t.start.line}:t.index&&(r=this.positionInside(t.index)),t.end?n={column:t.end.column,line:t.end.line}:typeof t.endIndex=="number"?n=this.positionInside(t.endIndex):t.index&&(n=this.positionInside(t.index+1));return(n.line<r.line||n.line===r.line&&n.column<=r.column)&&(n={column:r.column+1,line:r.line}),{end:n,start:r}}raw(t,r){return new K0().raw(this,t,r)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...t){if(this.parent){let r=this,n=!1;for(let o of t)o===this?n=!0:n?(this.parent.insertAfter(r,o),r=o):this.parent.insertBefore(r,o);n||this.remove()}return this}root(){let t=this;for(;t.parent&&t.parent.type!=="document";)t=t.parent;return t}toJSON(t,r){let n={},o=r==null;r=r||new Map;let a=0;for(let i in this){if(!Object.prototype.hasOwnProperty.call(this,i)||i==="parent"||i==="proxyCache")continue;let s=this[i];if(Array.isArray(s))n[i]=s.map(l=>typeof l=="object"&&l.toJSON?l.toJSON(null,r):l);else if(typeof s=="object"&&s.toJSON)n[i]=s.toJSON(null,r);else if(i==="source"){let l=r.get(s.input);l==null&&(l=a,r.set(s.input,a),a++),n[i]={end:s.end,inputId:l,start:s.start}}else n[i]=s}return o&&(n.inputs=[...r.keys()].map(i=>i.toJSON())),n}toProxy(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache}toString(t=H0){t.stringify&&(t=t.stringify);let r="";return t(this,n=>{r+=n}),r}warn(t,r,n){let o={node:this};for(let a in n)o[a]=n[a];return t.warn(r,o)}get proxyOf(){return this}},ps=Sd;Sd.default=Sd;var J0=ps,bd=class extends J0{constructor(t){t&&typeof t.value<"u"&&typeof t.value!="string"&&(t={...t,value:String(t.value)}),super(t),this.type="decl"}get variable(){return this.prop.startsWith("--")||this.prop[0]==="$"}},fs=bd;bd.default=bd;var G0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Y0=(e,t=21)=>(r=t)=>{let n="",o=r;for(;o--;)n+=e[Math.random()*e.length|0];return n},Z0=(e=21)=>{let t="",r=e;for(;r--;)t+=G0[Math.random()*64|0];return t},X0={nanoid:Z0,customAlphabet:Y0},{SourceMapConsumer:eS,SourceMapGenerator:tS}=ze,{existsSync:Q0,readFileSync:eN}=ze,{dirname:qc,join:tN}=ze;function rN(e){return Buffer?Buffer.from(e,"base64").toString():window.atob(e)}var Rd=class{constructor(t,r){if(r.map===!1)return;this.loadAnnotation(t),this.inline=this.startWith(this.annotation,"data:");let n=r.map?r.map.prev:void 0,o=this.loadMap(r.from,n);!this.mapFile&&r.from&&(this.mapFile=r.from),this.mapFile&&(this.root=qc(this.mapFile)),o&&(this.text=o)}consumer(){return this.consumerCache||(this.consumerCache=new eS(this.text)),this.consumerCache}decodeInline(t){let r=/^data:application\/json;charset=utf-?8;base64,/,n=/^data:application\/json;base64,/,o=/^data:application\/json;charset=utf-?8,/,a=/^data:application\/json,/;if(o.test(t)||a.test(t))return decodeURIComponent(t.substr(RegExp.lastMatch.length));if(r.test(t)||n.test(t))return rN(t.substr(RegExp.lastMatch.length));let i=t.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+i)}getAnnotationURL(t){return t.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()}isMap(t){return typeof t!="object"?!1:typeof t.mappings=="string"||typeof t._mappings=="string"||Array.isArray(t.sections)}loadAnnotation(t){let r=t.match(/\/\*\s*# sourceMappingURL=/gm);if(!r)return;let n=t.lastIndexOf(r.pop()),o=t.indexOf("*/",n);n>-1&&o>-1&&(this.annotation=this.getAnnotationURL(t.substring(n,o)))}loadFile(t){if(this.root=qc(t),Q0(t))return this.mapFile=t,eN(t,"utf-8").toString().trim()}loadMap(t,r){if(r===!1)return!1;if(r){if(typeof r=="string")return r;if(typeof r=="function"){let n=r(t);if(n){let o=this.loadFile(n);if(!o)throw new Error("Unable to load previous source map: "+n.toString());return o}}else{if(r instanceof eS)return tS.fromSourceMap(r).toString();if(r instanceof tS)return r.toString();if(this.isMap(r))return JSON.stringify(r);throw new Error("Unsupported previous source map format: "+r.toString())}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){let n=this.annotation;return t&&(n=tN(qc(t),n)),this.loadFile(n)}}}startWith(t,r){return t?t.substr(0,r.length)===r:!1}withContent(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)}},wb=Rd;Rd.default=Rd;var{SourceMapConsumer:nN,SourceMapGenerator:oN}=ze,{fileURLToPath:rS,pathToFileURL:Ci}=ze,{isAbsolute:vd,resolve:wd}=ze,{nanoid:aN}=X0,zc=ze,nS=eu,iN=wb,Kc=Symbol("fromOffsetCache"),sN=!!(nN&&oN),oS=!!(wd&&vd),Xi=class{constructor(t,r={}){if(t===null||typeof t>"u"||typeof t=="object"&&!t.toString)throw new Error(`PostCSS received ${t} instead of CSS string`);if(this.css=t.toString(),this.css[0]==="\uFEFF"||this.css[0]==="\uFFFE"?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,r.from&&(!oS||/^\w+:\/\//.test(r.from)||vd(r.from)?this.file=r.from:this.file=wd(r.from)),oS&&sN){let n=new iN(this.css,r);if(n.text){this.map=n;let o=n.consumer().file;!this.file&&o&&(this.file=this.mapResolve(o))}}this.file||(this.id="<input css "+aN(6)+">"),this.map&&(this.map.file=this.from)}error(t,r,n,o={}){let a,i,s;if(r&&typeof r=="object"){let c=r,d=n;if(typeof c.offset=="number"){let u=this.fromOffset(c.offset);r=u.line,n=u.col}else r=c.line,n=c.column;if(typeof d.offset=="number"){let u=this.fromOffset(d.offset);i=u.line,s=u.col}else i=d.line,s=d.column}else if(!n){let c=this.fromOffset(r);r=c.line,n=c.col}let l=this.origin(r,n,i,s);return l?a=new nS(t,l.endLine===void 0?l.line:{column:l.column,line:l.line},l.endLine===void 0?l.column:{column:l.endColumn,line:l.endLine},l.source,l.file,o.plugin):a=new nS(t,i===void 0?r:{column:n,line:r},i===void 0?n:{column:s,line:i},this.css,this.file,o.plugin),a.input={column:n,endColumn:s,endLine:i,line:r,source:this.css},this.file&&(Ci&&(a.input.url=Ci(this.file).toString()),a.input.file=this.file),a}fromOffset(t){let r,n;if(this[Kc])n=this[Kc];else{let a=this.css.split(`
|
|
52
|
+
`);n=new Array(a.length);let i=0;for(let s=0,l=a.length;s<l;s++)n[s]=i,i+=a[s].length+1;this[Kc]=n}r=n[n.length-1];let o=0;if(t>=r)o=n.length-1;else{let a=n.length-2,i;for(;o<a;)if(i=o+(a-o>>1),t<n[i])a=i-1;else if(t>=n[i+1])o=i+1;else{o=i;break}}return{col:t-n[o]+1,line:o+1}}mapResolve(t){return/^\w+:\/\//.test(t)?t:wd(this.map.consumer().sourceRoot||this.map.root||".",t)}origin(t,r,n,o){if(!this.map)return!1;let a=this.map.consumer(),i=a.originalPositionFor({column:r,line:t});if(!i.source)return!1;let s;typeof n=="number"&&(s=a.originalPositionFor({column:o,line:n}));let l;vd(i.source)?l=Ci(i.source):l=new URL(i.source,this.map.consumer().sourceRoot||Ci(this.map.mapFile));let c={column:i.column,endColumn:s&&s.column,endLine:s&&s.line,line:i.line,url:l.toString()};if(l.protocol==="file:")if(rS)c.file=rS(l);else throw new Error("file: protocol is not available in this PostCSS build");let d=a.sourceContentFor(i.source);return d&&(c.source=d),c}toJSON(){let t={};for(let r of["hasBOM","css","file","id"])this[r]!=null&&(t[r]=this[r]);return this.map&&(t.map={...this.map},t.map.consumerCache&&(t.map.consumerCache=void 0)),t}get from(){return this.file||this.id}},ms=Xi;Xi.default=Xi;zc&&zc.registerInput&&zc.registerInput(Xi);var{SourceMapConsumer:Eb,SourceMapGenerator:ji}=ze,{dirname:Vi,relative:xb,resolve:kb,sep:Cb}=ze,{pathToFileURL:aS}=ze,lN=ms,cN=!!(Eb&&ji),dN=!!(Vi&&kb&&xb&&Cb),uN=class{constructor(t,r,n,o){this.stringify=t,this.mapOpts=n.map||{},this.root=r,this.opts=n,this.css=o,this.originalCSS=o,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}addAnnotation(){let t;this.isInline()?t="data:application/json;base64,"+this.toBase64(this.map.toString()):typeof this.mapOpts.annotation=="string"?t=this.mapOpts.annotation:typeof this.mapOpts.annotation=="function"?t=this.mapOpts.annotation(this.opts.to,this.root):t=this.outputFile()+".map";let r=`
|
|
53
|
+
`;this.css.includes(`\r
|
|
54
|
+
`)&&(r=`\r
|
|
55
|
+
`),this.css+=r+"/*# sourceMappingURL="+t+" */"}applyPrevMaps(){for(let t of this.previous()){let r=this.toUrl(this.path(t.file)),n=t.root||Vi(t.file),o;this.mapOpts.sourcesContent===!1?(o=new Eb(t.text),o.sourcesContent&&(o.sourcesContent=null)):o=t.consumer(),this.map.applySourceMap(o,r,this.toUrl(this.path(n)))}}clearAnnotation(){if(this.mapOpts.annotation!==!1)if(this.root){let t;for(let r=this.root.nodes.length-1;r>=0;r--)t=this.root.nodes[r],t.type==="comment"&&t.text.indexOf("# sourceMappingURL=")===0&&this.root.removeChild(r)}else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),dN&&cN&&this.isMap())return this.generateMap();{let t="";return this.stringify(this.root,r=>{t+=r}),[t]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let t=this.previous()[0].consumer();t.file=this.outputFile(),this.map=ji.fromSourceMap(t,{ignoreInvalidMapping:!0})}else this.map=new ji({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new ji({file:this.outputFile(),ignoreInvalidMapping:!0});let t=1,r=1,n="<no source>",o={generated:{column:0,line:0},original:{column:0,line:0},source:""},a,i;this.stringify(this.root,(s,l,c)=>{if(this.css+=s,l&&c!=="end"&&(o.generated.line=t,o.generated.column=r-1,l.source&&l.source.start?(o.source=this.sourcePath(l),o.original.line=l.source.start.line,o.original.column=l.source.start.column-1,this.map.addMapping(o)):(o.source=n,o.original.line=1,o.original.column=0,this.map.addMapping(o))),a=s.match(/\n/g),a?(t+=a.length,i=s.lastIndexOf(`
|
|
56
|
+
`),r=s.length-i):r+=s.length,l&&c!=="start"){let d=l.parent||{raws:{}};(!(l.type==="decl"||l.type==="atrule"&&!l.nodes)||l!==d.last||d.raws.semicolon)&&(l.source&&l.source.end?(o.source=this.sourcePath(l),o.original.line=l.source.end.line,o.original.column=l.source.end.column-1,o.generated.line=t,o.generated.column=r-2,this.map.addMapping(o)):(o.source=n,o.original.line=1,o.original.column=0,o.generated.line=t,o.generated.column=r-1,this.map.addMapping(o)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(t=>t.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let t=this.mapOpts.annotation;return typeof t<"u"&&t!==!0?!1:this.previous().length?this.previous().some(r=>r.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(t=>t.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(t){if(this.mapOpts.absolute||t.charCodeAt(0)===60||/^\w+:\/\//.test(t))return t;let r=this.memoizedPaths.get(t);if(r)return r;let n=this.opts.to?Vi(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(n=Vi(kb(n,this.mapOpts.annotation)));let o=xb(n,t);return this.memoizedPaths.set(t,o),o}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(t=>{if(t.source&&t.source.input.map){let r=t.source.input.map;this.previousMaps.includes(r)||this.previousMaps.push(r)}});else{let t=new lN(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps}setSourcesContent(){let t={};if(this.root)this.root.walk(r=>{if(r.source){let n=r.source.input.from;if(n&&!t[n]){t[n]=!0;let o=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(o,r.source.input.css)}}});else if(this.css){let r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}}sourcePath(t){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(t.source.input.from):this.toUrl(this.path(t.source.input.from))}toBase64(t){return Buffer?Buffer.from(t).toString("base64"):window.btoa(unescape(encodeURIComponent(t)))}toFileUrl(t){let r=this.memoizedFileURLs.get(t);if(r)return r;if(aS){let n=aS(t).toString();return this.memoizedFileURLs.set(t,n),n}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(t){let r=this.memoizedURLs.get(t);if(r)return r;Cb==="\\"&&(t=t.replace(/\\/g,"/"));let n=encodeURI(t).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(t,n),n}},Ab=uN,pN=ps,Ed=class extends pN{constructor(t){super(t),this.type="comment"}},ys=Ed;Ed.default=Ed;var{isClean:Pb,my:Ob}=xo,Mb=fs,Tb=ys,fN=ps,Ib,tu,ru,Lb;function Nb(e){return e.map(t=>(t.nodes&&(t.nodes=Nb(t.nodes)),delete t.source,t))}function Fb(e){if(e[Pb]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)Fb(t)}var gt=class Db extends fN{append(...t){for(let r of t){let n=this.normalize(r,this.last);for(let o of n)this.proxyOf.nodes.push(o)}return this.markDirty(),this}cleanRaws(t){if(super.cleanRaws(t),this.nodes)for(let r of this.nodes)r.cleanRaws(t)}each(t){if(!this.proxyOf.nodes)return;let r=this.getIterator(),n,o;for(;this.indexes[r]<this.proxyOf.nodes.length&&(n=this.indexes[r],o=t(this.proxyOf.nodes[n],n),o!==!1);)this.indexes[r]+=1;return delete this.indexes[r],o}every(t){return this.nodes.every(t)}getIterator(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;let t=this.lastEach;return this.indexes[t]=0,t}getProxyProcessor(){return{get(t,r){return r==="proxyOf"?t:t[r]?r==="each"||typeof r=="string"&&r.startsWith("walk")?(...n)=>t[r](...n.map(o=>typeof o=="function"?(a,i)=>o(a.toProxy(),i):o)):r==="every"||r==="some"?n=>t[r]((o,...a)=>n(o.toProxy(),...a)):r==="root"?()=>t.root().toProxy():r==="nodes"?t.nodes.map(n=>n.toProxy()):r==="first"||r==="last"?t[r].toProxy():t[r]:t[r]},set(t,r,n){return t[r]===n||(t[r]=n,(r==="name"||r==="params"||r==="selector")&&t.markDirty()),!0}}}index(t){return typeof t=="number"?t:(t.proxyOf&&(t=t.proxyOf),this.proxyOf.nodes.indexOf(t))}insertAfter(t,r){let n=this.index(t),o=this.normalize(r,this.proxyOf.nodes[n]).reverse();n=this.index(t);for(let i of o)this.proxyOf.nodes.splice(n+1,0,i);let a;for(let i in this.indexes)a=this.indexes[i],n<a&&(this.indexes[i]=a+o.length);return this.markDirty(),this}insertBefore(t,r){let n=this.index(t),o=n===0?"prepend":!1,a=this.normalize(r,this.proxyOf.nodes[n],o).reverse();n=this.index(t);for(let s of a)this.proxyOf.nodes.splice(n,0,s);let i;for(let s in this.indexes)i=this.indexes[s],n<=i&&(this.indexes[s]=i+a.length);return this.markDirty(),this}normalize(t,r){if(typeof t=="string")t=Nb(Ib(t).nodes);else if(typeof t>"u")t=[];else if(Array.isArray(t)){t=t.slice(0);for(let o of t)o.parent&&o.parent.removeChild(o,"ignore")}else if(t.type==="root"&&this.type!=="document"){t=t.nodes.slice(0);for(let o of t)o.parent&&o.parent.removeChild(o,"ignore")}else if(t.type)t=[t];else if(t.prop){if(typeof t.value>"u")throw new Error("Value field is missed in node creation");typeof t.value!="string"&&(t.value=String(t.value)),t=[new Mb(t)]}else if(t.selector)t=[new tu(t)];else if(t.name)t=[new ru(t)];else if(t.text)t=[new Tb(t)];else throw new Error("Unknown node type in node creation");return t.map(o=>(o[Ob]||Db.rebuild(o),o=o.proxyOf,o.parent&&o.parent.removeChild(o),o[Pb]&&Fb(o),typeof o.raws.before>"u"&&r&&typeof r.raws.before<"u"&&(o.raws.before=r.raws.before.replace(/\S/g,"")),o.parent=this.proxyOf,o))}prepend(...t){t=t.reverse();for(let r of t){let n=this.normalize(r,this.first,"prepend").reverse();for(let o of n)this.proxyOf.nodes.unshift(o);for(let o in this.indexes)this.indexes[o]=this.indexes[o]+n.length}return this.markDirty(),this}push(t){return t.parent=this,this.proxyOf.nodes.push(t),this}removeAll(){for(let t of this.proxyOf.nodes)t.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(t){t=this.index(t),this.proxyOf.nodes[t].parent=void 0,this.proxyOf.nodes.splice(t,1);let r;for(let n in this.indexes)r=this.indexes[n],r>=t&&(this.indexes[n]=r-1);return this.markDirty(),this}replaceValues(t,r,n){return n||(n=r,r={}),this.walkDecls(o=>{r.props&&!r.props.includes(o.prop)||r.fast&&!o.value.includes(r.fast)||(o.value=o.value.replace(t,n))}),this.markDirty(),this}some(t){return this.nodes.some(t)}walk(t){return this.each((r,n)=>{let o;try{o=t(r,n)}catch(a){throw r.addToError(a)}return o!==!1&&r.walk&&(o=r.walk(t)),o})}walkAtRules(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="atrule"&&t.test(n.name))return r(n,o)}):this.walk((n,o)=>{if(n.type==="atrule"&&n.name===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="atrule")return r(n,o)}))}walkComments(t){return this.walk((r,n)=>{if(r.type==="comment")return t(r,n)})}walkDecls(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="decl"&&t.test(n.prop))return r(n,o)}):this.walk((n,o)=>{if(n.type==="decl"&&n.prop===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="decl")return r(n,o)}))}walkRules(t,r){return r?t instanceof RegExp?this.walk((n,o)=>{if(n.type==="rule"&&t.test(n.selector))return r(n,o)}):this.walk((n,o)=>{if(n.type==="rule"&&n.selector===t)return r(n,o)}):(r=t,this.walk((n,o)=>{if(n.type==="rule")return r(n,o)}))}get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}};gt.registerParse=e=>{Ib=e};gt.registerRule=e=>{tu=e};gt.registerAtRule=e=>{ru=e};gt.registerRoot=e=>{Lb=e};var mr=gt;gt.default=gt;gt.rebuild=e=>{e.type==="atrule"?Object.setPrototypeOf(e,ru.prototype):e.type==="rule"?Object.setPrototypeOf(e,tu.prototype):e.type==="decl"?Object.setPrototypeOf(e,Mb.prototype):e.type==="comment"?Object.setPrototypeOf(e,Tb.prototype):e.type==="root"&&Object.setPrototypeOf(e,Lb.prototype),e[Ob]=!0,e.nodes&&e.nodes.forEach(t=>{gt.rebuild(t)})};var mN=mr,Bb,$b,go=class extends mN{constructor(t){super({type:"document",...t}),this.nodes||(this.nodes=[])}toResult(t={}){return new Bb(new $b,this,t).stringify()}};go.registerLazyResult=e=>{Bb=e};go.registerProcessor=e=>{$b=e};var nu=go;go.default=go;var iS={},jb=function(t){iS[t]||(iS[t]=!0,typeof console<"u"&&console.warn&&console.warn(t))},xd=class{constructor(t,r={}){if(this.type="warning",this.text=t,r.node&&r.node.source){let n=r.node.rangeBy(r);this.line=n.start.line,this.column=n.start.column,this.endLine=n.end.line,this.endColumn=n.end.column}for(let n in r)this[n]=r[n]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text}},Vb=xd;xd.default=xd;var yN=Vb,kd=class{constructor(t,r,n){this.processor=t,this.messages=[],this.root=r,this.opts=n,this.css=void 0,this.map=void 0}toString(){return this.css}warn(t,r={}){r.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(r.plugin=this.lastPlugin.postcssPlugin);let n=new yN(t,r);return this.messages.push(n),n}warnings(){return this.messages.filter(t=>t.type==="warning")}get content(){return this.css}},ou=kd;kd.default=kd;var Hc=39,sS=34,Ai=92,lS=47,Pi=10,ao=32,Oi=12,Mi=9,Ti=13,hN=91,gN=93,SN=40,bN=41,RN=123,vN=125,wN=59,EN=42,xN=58,kN=64,Ii=/[\t\n\f\r "#'()/;[\\\]{}]/g,Li=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,CN=/.[\r\n"'(/\\]/,cS=/[\da-f]/i,AN=function(t,r={}){let n=t.css.valueOf(),o=r.ignoreErrors,a,i,s,l,c,d,u,f,y,m,h=n.length,p=0,b=[],w=[];function S(){return p}function E(W){throw t.error("Unclosed "+W,p)}function L(){return w.length===0&&p>=h}function V(W){if(w.length)return w.pop();if(p>=h)return;let ae=W?W.ignoreUnclosed:!1;switch(a=n.charCodeAt(p),a){case Pi:case ao:case Mi:case Ti:case Oi:{i=p;do i+=1,a=n.charCodeAt(i);while(a===ao||a===Pi||a===Mi||a===Ti||a===Oi);m=["space",n.slice(p,i)],p=i-1;break}case hN:case gN:case RN:case vN:case xN:case wN:case bN:{let pe=String.fromCharCode(a);m=[pe,pe,p];break}case SN:{if(f=b.length?b.pop()[1]:"",y=n.charCodeAt(p+1),f==="url"&&y!==Hc&&y!==sS&&y!==ao&&y!==Pi&&y!==Mi&&y!==Oi&&y!==Ti){i=p;do{if(d=!1,i=n.indexOf(")",i+1),i===-1)if(o||ae){i=p;break}else E("bracket");for(u=i;n.charCodeAt(u-1)===Ai;)u-=1,d=!d}while(d);m=["brackets",n.slice(p,i+1),p,i],p=i}else i=n.indexOf(")",p+1),l=n.slice(p,i+1),i===-1||CN.test(l)?m=["(","(",p]:(m=["brackets",l,p,i],p=i);break}case Hc:case sS:{s=a===Hc?"'":'"',i=p;do{if(d=!1,i=n.indexOf(s,i+1),i===-1)if(o||ae){i=p+1;break}else E("string");for(u=i;n.charCodeAt(u-1)===Ai;)u-=1,d=!d}while(d);m=["string",n.slice(p,i+1),p,i],p=i;break}case kN:{Ii.lastIndex=p+1,Ii.test(n),Ii.lastIndex===0?i=n.length-1:i=Ii.lastIndex-2,m=["at-word",n.slice(p,i+1),p,i],p=i;break}case Ai:{for(i=p,c=!0;n.charCodeAt(i+1)===Ai;)i+=1,c=!c;if(a=n.charCodeAt(i+1),c&&a!==lS&&a!==ao&&a!==Pi&&a!==Mi&&a!==Ti&&a!==Oi&&(i+=1,cS.test(n.charAt(i)))){for(;cS.test(n.charAt(i+1));)i+=1;n.charCodeAt(i+1)===ao&&(i+=1)}m=["word",n.slice(p,i+1),p,i],p=i;break}default:{a===lS&&n.charCodeAt(p+1)===EN?(i=n.indexOf("*/",p+2)+1,i===0&&(o||ae?i=n.length:E("comment")),m=["comment",n.slice(p,i+1),p,i],p=i):(Li.lastIndex=p+1,Li.test(n),Li.lastIndex===0?i=n.length-1:i=Li.lastIndex-2,m=["word",n.slice(p,i+1),p,i],b.push(m),p=i);break}}return p++,m}function ne(W){w.push(W)}return{back:ne,endOfFile:L,nextToken:V,position:S}},_b=mr,Qi=class extends _b{constructor(t){super(t),this.type="atrule"}append(...t){return this.proxyOf.nodes||(this.nodes=[]),super.append(...t)}prepend(...t){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...t)}},au=Qi;Qi.default=Qi;_b.registerAtRule(Qi);var Ub=mr,Wb,qb,ln=class extends Ub{constructor(t){super(t),this.type="root",this.nodes||(this.nodes=[])}normalize(t,r,n){let o=super.normalize(t);if(r){if(n==="prepend")this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(let a of o)a.raws.before=r.raws.before}return o}removeChild(t,r){let n=this.index(t);return!r&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(t)}toResult(t={}){return new Wb(new qb,this,t).stringify()}};ln.registerLazyResult=e=>{Wb=e};ln.registerProcessor=e=>{qb=e};var ko=ln;ln.default=ln;Ub.registerRoot(ln);var So={comma(e){return So.split(e,[","],!0)},space(e){let t=[" ",`
|
|
57
|
+
`," "];return So.split(e,t)},split(e,t,r){let n=[],o="",a=!1,i=0,s=!1,l="",c=!1;for(let d of e)c?c=!1:d==="\\"?c=!0:s?d===l&&(s=!1):d==='"'||d==="'"?(s=!0,l=d):d==="("?i+=1:d===")"?i>0&&(i-=1):i===0&&t.includes(d)&&(a=!0),a?(o!==""&&n.push(o.trim()),o="",a=!1):o+=d;return(r||o!=="")&&n.push(o.trim()),n}},zb=So;So.default=So;var Kb=mr,PN=zb,es=class extends Kb{constructor(t){super(t),this.type="rule",this.nodes||(this.nodes=[])}get selectors(){return PN.comma(this.selector)}set selectors(t){let r=this.selector?this.selector.match(/,\s*/):null,n=r?r[0]:","+this.raw("between","beforeOpen");this.selector=t.join(n)}},iu=es;es.default=es;Kb.registerRule(es);var ON=fs,MN=AN,TN=ys,IN=au,LN=ko,dS=iu,uS={empty:!0,space:!0};function NN(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=r[3]||r[2];if(n)return n}}var FN=class{constructor(t){this.input=t,this.root=new LN,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:t,start:{column:1,line:1,offset:0}}}atrule(t){let r=new IN;r.name=t[1].slice(1),r.name===""&&this.unnamedAtrule(r,t),this.init(r,t[2]);let n,o,a,i=!1,s=!1,l=[],c=[];for(;!this.tokenizer.endOfFile();){if(t=this.tokenizer.nextToken(),n=t[0],n==="("||n==="["?c.push(n==="("?")":"]"):n==="{"&&c.length>0?c.push("}"):n===c[c.length-1]&&c.pop(),c.length===0)if(n===";"){r.source.end=this.getPosition(t[2]),r.source.end.offset++,this.semicolon=!0;break}else if(n==="{"){s=!0;break}else if(n==="}"){if(l.length>0){for(a=l.length-1,o=l[a];o&&o[0]==="space";)o=l[--a];o&&(r.source.end=this.getPosition(o[3]||o[2]),r.source.end.offset++)}this.end(t);break}else l.push(t);else l.push(t);if(this.tokenizer.endOfFile()){i=!0;break}}r.raws.between=this.spacesAndCommentsFromEnd(l),l.length?(r.raws.afterName=this.spacesAndCommentsFromStart(l),this.raw(r,"params",l),i&&(t=l[l.length-1],r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++,this.spaces=r.raws.between,r.raws.between="")):(r.raws.afterName="",r.params=""),s&&(r.nodes=[],this.current=r)}checkMissedSemicolon(t){let r=this.colon(t);if(r===!1)return;let n=0,o;for(let a=r-1;a>=0&&(o=t[a],!(o[0]!=="space"&&(n+=1,n===2)));a--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}colon(t){let r=0,n,o,a;for(let[i,s]of t.entries()){if(n=s,o=n[0],o==="("&&(r+=1),o===")"&&(r-=1),r===0&&o===":")if(!a)this.doubleColon(n);else{if(a[0]==="word"&&a[1]==="progid")continue;return i}a=n}return!1}comment(t){let r=new TN;this.init(r,t[2]),r.source.end=this.getPosition(t[3]||t[2]),r.source.end.offset++;let n=t[1].slice(2,-2);if(/^\s*$/.test(n))r.text="",r.raws.left=n,r.raws.right="";else{let o=n.match(/^(\s*)([^]*\S)(\s*)$/);r.text=o[2],r.raws.left=o[1],r.raws.right=o[3]}}createTokenizer(){this.tokenizer=MN(this.input)}decl(t,r){let n=new ON;this.init(n,t[0][2]);let o=t[t.length-1];for(o[0]===";"&&(this.semicolon=!0,t.pop()),n.source.end=this.getPosition(o[3]||o[2]||NN(t)),n.source.end.offset++;t[0][0]!=="word";)t.length===1&&this.unknownWord(t),n.raws.before+=t.shift()[1];for(n.source.start=this.getPosition(t[0][2]),n.prop="";t.length;){let c=t[0][0];if(c===":"||c==="space"||c==="comment")break;n.prop+=t.shift()[1]}n.raws.between="";let a;for(;t.length;)if(a=t.shift(),a[0]===":"){n.raws.between+=a[1];break}else a[0]==="word"&&/\w/.test(a[1])&&this.unknownWord([a]),n.raws.between+=a[1];(n.prop[0]==="_"||n.prop[0]==="*")&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let i=[],s;for(;t.length&&(s=t[0][0],!(s!=="space"&&s!=="comment"));)i.push(t.shift());this.precheckMissedSemicolon(t);for(let c=t.length-1;c>=0;c--){if(a=t[c],a[1].toLowerCase()==="!important"){n.important=!0;let d=this.stringFrom(t,c);d=this.spacesFromEnd(t)+d,d!==" !important"&&(n.raws.important=d);break}else if(a[1].toLowerCase()==="important"){let d=t.slice(0),u="";for(let f=c;f>0;f--){let y=d[f][0];if(u.trim().indexOf("!")===0&&y!=="space")break;u=d.pop()[1]+u}u.trim().indexOf("!")===0&&(n.important=!0,n.raws.important=u,t=d)}if(a[0]!=="space"&&a[0]!=="comment")break}t.some(c=>c[0]!=="space"&&c[0]!=="comment")&&(n.raws.between+=i.map(c=>c[1]).join(""),i=[]),this.raw(n,"value",i.concat(t),r),n.value.includes(":")&&!r&&this.checkMissedSemicolon(t)}doubleColon(t){throw this.input.error("Double colon",{offset:t[2]},{offset:t[2]+t[1].length})}emptyRule(t){let r=new dS;this.init(r,t[2]),r.selector="",r.raws.between="",this.current=r}end(t){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(t[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(t)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(t){if(this.spaces+=t[1],this.current.nodes){let r=this.current.nodes[this.current.nodes.length-1];r&&r.type==="rule"&&!r.raws.ownSemicolon&&(r.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(t){let r=this.input.fromOffset(t);return{column:r.col,line:r.line,offset:t}}init(t,r){this.current.push(t),t.source={input:this.input,start:this.getPosition(r)},t.raws.before=this.spaces,this.spaces="",t.type!=="comment"&&(this.semicolon=!1)}other(t){let r=!1,n=null,o=!1,a=null,i=[],s=t[1].startsWith("--"),l=[],c=t;for(;c;){if(n=c[0],l.push(c),n==="("||n==="[")a||(a=c),i.push(n==="("?")":"]");else if(s&&o&&n==="{")a||(a=c),i.push("}");else if(i.length===0)if(n===";")if(o){this.decl(l,s);return}else break;else if(n==="{"){this.rule(l);return}else if(n==="}"){this.tokenizer.back(l.pop()),r=!0;break}else n===":"&&(o=!0);else n===i[i.length-1]&&(i.pop(),i.length===0&&(a=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(r=!0),i.length>0&&this.unclosedBracket(a),r&&o){if(!s)for(;l.length&&(c=l[l.length-1][0],!(c!=="space"&&c!=="comment"));)this.tokenizer.back(l.pop());this.decl(l,s)}else this.unknownWord(l)}parse(){let t;for(;!this.tokenizer.endOfFile();)switch(t=this.tokenizer.nextToken(),t[0]){case"space":this.spaces+=t[1];break;case";":this.freeSemicolon(t);break;case"}":this.end(t);break;case"comment":this.comment(t);break;case"at-word":this.atrule(t);break;case"{":this.emptyRule(t);break;default:this.other(t);break}this.endFile()}precheckMissedSemicolon(){}raw(t,r,n,o){let a,i,s=n.length,l="",c=!0,d,u;for(let f=0;f<s;f+=1)a=n[f],i=a[0],i==="space"&&f===s-1&&!o?c=!1:i==="comment"?(u=n[f-1]?n[f-1][0]:"empty",d=n[f+1]?n[f+1][0]:"empty",!uS[u]&&!uS[d]?l.slice(-1)===","?c=!1:l+=a[1]:c=!1):l+=a[1];if(!c){let f=n.reduce((y,m)=>y+m[1],"");t.raws[r]={raw:f,value:l}}t[r]=l}rule(t){t.pop();let r=new dS;this.init(r,t[0][2]),r.raws.between=this.spacesAndCommentsFromEnd(t),this.raw(r,"selector",t),this.current=r}spacesAndCommentsFromEnd(t){let r,n="";for(;t.length&&(r=t[t.length-1][0],!(r!=="space"&&r!=="comment"));)n=t.pop()[1]+n;return n}spacesAndCommentsFromStart(t){let r,n="";for(;t.length&&(r=t[0][0],!(r!=="space"&&r!=="comment"));)n+=t.shift()[1];return n}spacesFromEnd(t){let r,n="";for(;t.length&&(r=t[t.length-1][0],r==="space");)n=t.pop()[1]+n;return n}stringFrom(t,r){let n="";for(let o=r;o<t.length;o++)n+=t[o][1];return t.splice(r,t.length-r),n}unclosedBlock(){let t=this.current.source.start;throw this.input.error("Unclosed block",t.line,t.column)}unclosedBracket(t){throw this.input.error("Unclosed bracket",{offset:t[2]},{offset:t[2]+1})}unexpectedClose(t){throw this.input.error("Unexpected }",{offset:t[2]},{offset:t[2]+1})}unknownWord(t){throw this.input.error("Unknown word",{offset:t[0][2]},{offset:t[0][2]+t[0][1].length})}unnamedAtrule(t,r){throw this.input.error("At-rule without name",{offset:r[2]},{offset:r[2]+r[1].length})}},DN=FN,BN=mr,$N=DN,jN=ms;function ts(e,t){let r=new jN(e,t),n=new $N(r);try{n.parse()}catch(o){throw process.env.NODE_ENV!=="production"&&o.name==="CssSyntaxError"&&t&&t.from&&(/\.scss$/i.test(t.from)?o.message+=`
|
|
58
|
+
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser`:/\.sass/i.test(t.from)?o.message+=`
|
|
59
|
+
You tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser`:/\.less$/i.test(t.from)&&(o.message+=`
|
|
60
|
+
You tried to parse Less with the standard CSS parser; try again with the postcss-less parser`)),o}return n.root}var su=ts;ts.default=ts;BN.registerParse(ts);var{isClean:nt,my:VN}=xo,_N=Ab,UN=us,WN=mr,qN=nu,zN=jb,pS=ou,KN=su,HN=ko,JN={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},GN={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},YN={Once:!0,postcssPlugin:!0,prepare:!0},cn=0;function io(e){return typeof e=="object"&&typeof e.then=="function"}function Hb(e){let t=!1,r=JN[e.type];return e.type==="decl"?t=e.prop.toLowerCase():e.type==="atrule"&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,cn,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,cn,r+"Exit"]:[r,r+"Exit"]}function fS(e){let t;return e.type==="document"?t=["Document",cn,"DocumentExit"]:e.type==="root"?t=["Root",cn,"RootExit"]:t=Hb(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function Cd(e){return e[nt]=!1,e.nodes&&e.nodes.forEach(t=>Cd(t)),e}var Ad={},dn=class Jb{constructor(t,r,n){this.stringified=!1,this.processed=!1;let o;if(typeof r=="object"&&r!==null&&(r.type==="root"||r.type==="document"))o=Cd(r);else if(r instanceof Jb||r instanceof pS)o=Cd(r.root),r.map&&(typeof n.map>"u"&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{let a=KN;n.syntax&&(a=n.syntax.parse),n.parser&&(a=n.parser),a.parse&&(a=a.parse);try{o=a(r,n)}catch(i){this.processed=!0,this.error=i}o&&!o[VN]&&WN.rebuild(o)}this.result=new pS(t,o,n),this.helpers={...Ad,postcss:Ad,result:this.result},this.plugins=this.processor.plugins.map(a=>typeof a=="object"&&a.prepare?{...a,...a.prepare(this.result)}:a)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(t,r){let n=this.result.lastPlugin;try{if(r&&r.addToError(t),this.error=t,t.name==="CssSyntaxError"&&!t.plugin)t.plugin=n.postcssPlugin,t.setMessage();else if(n.postcssVersion&&process.env.NODE_ENV!=="production"){let o=n.postcssPlugin,a=n.postcssVersion,i=this.result.processor.version,s=a.split("."),l=i.split(".");(s[0]!==l[0]||parseInt(s[1])>parseInt(l[1]))&&console.error("Unknown error from PostCSS plugin. Your current PostCSS version is "+i+", but "+o+" uses "+a+". Perhaps this is the source of the error below.")}}catch(o){console&&console.error&&console.error(o)}return t}prepareVisitors(){this.listeners={};let t=(r,n,o)=>{this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push([r,o])};for(let r of this.plugins)if(typeof r=="object")for(let n in r){if(!GN[n]&&/^[A-Z]/.test(n))throw new Error(`Unknown event ${n} in ${r.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!YN[n])if(typeof r[n]=="object")for(let o in r[n])o==="*"?t(r,n,r[n][o]):t(r,n+"-"+o.toLowerCase(),r[n][o]);else typeof r[n]=="function"&&t(r,n,r[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let t=0;t<this.plugins.length;t++){let r=this.plugins[t],n=this.runOnRoot(r);if(io(n))try{await n}catch(o){throw this.handleError(o)}}if(this.prepareVisitors(),this.hasListener){let t=this.result.root;for(;!t[nt];){t[nt]=!0;let r=[fS(t)];for(;r.length>0;){let n=this.visitTick(r);if(io(n))try{await n}catch(o){let a=r[r.length-1].node;throw this.handleError(o,a)}}}if(this.listeners.OnceExit)for(let[r,n]of this.listeners.OnceExit){this.result.lastPlugin=r;try{if(t.type==="document"){let o=t.nodes.map(a=>n(a,this.helpers));await Promise.all(o)}else await n(t,this.helpers)}catch(o){throw this.handleError(o)}}}return this.processed=!0,this.stringify()}runOnRoot(t){this.result.lastPlugin=t;try{if(typeof t=="object"&&t.Once){if(this.result.root.type==="document"){let r=this.result.root.nodes.map(n=>t.Once(n,this.helpers));return io(r[0])?Promise.all(r):r}return t.Once(this.result.root,this.helpers)}else if(typeof t=="function")return t(this.result.root,this.result)}catch(r){throw this.handleError(r)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let t=this.result.opts,r=UN;t.syntax&&(r=t.syntax.stringify),t.stringifier&&(r=t.stringifier),r.stringify&&(r=r.stringify);let o=new _N(r,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let t of this.plugins){let r=this.runOnRoot(t);if(io(r))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let t=this.result.root;for(;!t[nt];)t[nt]=!0,this.walkSync(t);if(this.listeners.OnceExit)if(t.type==="document")for(let r of t.nodes)this.visitSync(this.listeners.OnceExit,r);else this.visitSync(this.listeners.OnceExit,t)}return this.result}then(t,r){return process.env.NODE_ENV!=="production"&&("from"in this.opts||zN("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,r)}toString(){return this.css}visitSync(t,r){for(let[n,o]of t){this.result.lastPlugin=n;let a;try{a=o(r,this.helpers)}catch(i){throw this.handleError(i,r.proxyOf)}if(r.type!=="root"&&r.type!=="document"&&!r.parent)return!0;if(io(a))throw this.getAsyncError()}}visitTick(t){let r=t[t.length-1],{node:n,visitors:o}=r;if(n.type!=="root"&&n.type!=="document"&&!n.parent){t.pop();return}if(o.length>0&&r.visitorIndex<o.length){let[i,s]=o[r.visitorIndex];r.visitorIndex+=1,r.visitorIndex===o.length&&(r.visitors=[],r.visitorIndex=0),this.result.lastPlugin=i;try{return s(n.toProxy(),this.helpers)}catch(l){throw this.handleError(l,n)}}if(r.iterator!==0){let i=r.iterator,s;for(;s=n.nodes[n.indexes[i]];)if(n.indexes[i]+=1,!s[nt]){s[nt]=!0,t.push(fS(s));return}r.iterator=0,delete n.indexes[i]}let a=r.events;for(;r.eventIndex<a.length;){let i=a[r.eventIndex];if(r.eventIndex+=1,i===cn){n.nodes&&n.nodes.length&&(n[nt]=!0,r.iterator=n.getIterator());return}else if(this.listeners[i]){r.visitors=this.listeners[i];return}}t.pop()}walkSync(t){t[nt]=!0;let r=Hb(t);for(let n of r)if(n===cn)t.nodes&&t.each(o=>{o[nt]||this.walkSync(o)});else{let o=this.listeners[n];if(o&&this.visitSync(o,t.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};dn.registerPostcss=e=>{Ad=e};var Gb=dn;dn.default=dn;HN.registerLazyResult(dn);qN.registerLazyResult(dn);var ZN=Ab,XN=us,QN=jb,eF=su,tF=ou,Pd=class{constructor(t,r,n){r=r.toString(),this.stringified=!1,this._processor=t,this._css=r,this._opts=n,this._map=void 0;let o,a=XN;this.result=new tF(this._processor,o,this._opts),this.result.css=r;let i=this;Object.defineProperty(this.result,"root",{get(){return i.root}});let s=new ZN(a,o,this._opts,r);if(s.isMap()){let[l,c]=s.generate();l&&(this.result.css=l),c&&(this.result.map=c)}else s.clearAnnotation(),this.result.css=s.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(t){return this.async().catch(t)}finally(t){return this.async().then(t,t)}sync(){if(this.error)throw this.error;return this.result}then(t,r){return process.env.NODE_ENV!=="production"&&("from"in this._opts||QN("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.")),this.async().then(t,r)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let t,r=eF;try{t=r(this._css,this._opts)}catch(n){this.error=n}if(this.error)throw this.error;return this._root=t,t}get[Symbol.toStringTag](){return"NoWorkResult"}},rF=Pd;Pd.default=Pd;var nF=rF,oF=Gb,aF=nu,iF=ko,bo=class{constructor(t=[]){this.version="8.4.38",this.plugins=this.normalize(t)}normalize(t){let r=[];for(let n of t)if(n.postcss===!0?n=n():n.postcss&&(n=n.postcss),typeof n=="object"&&Array.isArray(n.plugins))r=r.concat(n.plugins);else if(typeof n=="object"&&n.postcssPlugin)r.push(n);else if(typeof n=="function")r.push(n);else if(typeof n=="object"&&(n.parse||n.stringify)){if(process.env.NODE_ENV!=="production")throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.")}else throw new Error(n+" is not a PostCSS plugin");return r}process(t,r={}){return!this.plugins.length&&!r.parser&&!r.stringifier&&!r.syntax?new nF(this,t,r):new oF(this,t,r)}use(t){return this.plugins=this.plugins.concat(this.normalize([t])),this}},sF=bo;bo.default=bo;iF.registerProcessor(bo);aF.registerProcessor(bo);var lF=fs,cF=wb,dF=ys,uF=au,pF=ms,fF=ko,mF=iu;function Ro(e,t){if(Array.isArray(e))return e.map(o=>Ro(o));let{inputs:r,...n}=e;if(r){t=[];for(let o of r){let a={...o,__proto__:pF.prototype};a.map&&(a.map={...a.map,__proto__:cF.prototype}),t.push(a)}}if(n.nodes&&(n.nodes=e.nodes.map(o=>Ro(o,t))),n.source){let{inputId:o,...a}=n.source;n.source=a,o!=null&&(n.source.input=t[o])}if(n.type==="root")return new fF(n);if(n.type==="decl")return new lF(n);if(n.type==="rule")return new mF(n);if(n.type==="comment")return new dF(n);if(n.type==="atrule")return new uF(n);throw new Error("Unknown node type: "+e.type)}var yF=Ro;Ro.default=Ro;var hF=eu,Yb=fs,gF=Gb,SF=mr,lu=sF,bF=us,RF=yF,Zb=nu,vF=Vb,Xb=ys,Qb=au,wF=ou,EF=ms,xF=su,kF=zb,eR=iu,tR=ko,CF=ps;function j(...e){return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new lu(e)}j.plugin=function(t,r){let n=!1;function o(...i){console&&console.warn&&!n&&(n=!0,console.warn(t+`: postcss.plugin was deprecated. Migration guide:
|
|
61
|
+
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(t+`: \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:
|
|
62
|
+
https://www.w3ctech.com/topic/2226`));let s=r(...i);return s.postcssPlugin=t,s.postcssVersion=new lu().version,s}let a;return Object.defineProperty(o,"postcss",{get(){return a||(a=o()),a}}),o.process=function(i,s,l){return j([o(l)]).process(i,s)},o};j.stringify=bF;j.parse=xF;j.fromJSON=RF;j.list=kF;j.comment=e=>new Xb(e);j.atRule=e=>new Qb(e);j.decl=e=>new Yb(e);j.rule=e=>new eR(e);j.root=e=>new tR(e);j.document=e=>new Zb(e);j.CssSyntaxError=hF;j.Declaration=Yb;j.Container=SF;j.Processor=lu;j.Document=Zb;j.Comment=Xb;j.Warning=vF;j.AtRule=Qb;j.Result=wF;j.Input=EF;j.Rule=eR;j.Root=tR;j.Node=CF;gF.registerPostcss(j);var AF=j;j.default=j;var X=B0(AF);X.stringify;X.fromJSON;X.plugin;X.parse;X.list;X.document;X.comment;X.atRule;X.rule;X.decl;X.root;X.CssSyntaxError;X.Declaration;X.Container;X.Processor;X.Document;X.Comment;X.Warning;X.AtRule;X.Result;X.Input;X.Rule;X.Root;X.Node;var Od=class e{constructor(...t){Te(this,"parentElement",null),Te(this,"parentNode",null),Te(this,"ownerDocument"),Te(this,"firstChild",null),Te(this,"lastChild",null),Te(this,"previousSibling",null),Te(this,"nextSibling",null),Te(this,"ELEMENT_NODE",1),Te(this,"TEXT_NODE",3),Te(this,"nodeType"),Te(this,"nodeName"),Te(this,"RRNodeType")}get childNodes(){let t=[],r=this.firstChild;for(;r;)t.push(r),r=r.nextSibling;return t}contains(t){if(t instanceof e){if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0}else return!1;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};var mS={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},yS={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Ni={},PF=()=>!!globalThis.Zone;function cu(e){if(Ni[e])return Ni[e];let t=globalThis[e],r=t.prototype,n=e in mS?mS[e]:void 0,o=!!(n&&n.every(s=>{var l,c;return!!((c=(l=Object.getOwnPropertyDescriptor(r,s))==null?void 0:l.get)!=null&&c.toString().includes("[native code]"))})),a=e in yS?yS[e]:void 0,i=!!(a&&a.every(s=>{var l;return typeof r[s]=="function"&&((l=r[s])==null?void 0:l.toString().includes("[native code]"))}));if(o&&i&&!PF())return Ni[e]=t.prototype,t.prototype;try{let s=document.createElement("iframe");document.body.appendChild(s);let l=s.contentWindow;if(!l)return t.prototype;let c=l[e].prototype;return document.body.removeChild(s),c?Ni[e]=c:r}catch{return r}}var Jc={};function bt(e,t,r){var n;let o=`${e}.${String(r)}`;if(Jc[o])return Jc[o].call(t);let a=cu(e),i=(n=Object.getOwnPropertyDescriptor(a,r))==null?void 0:n.get;return i?(Jc[o]=i,i.call(t)):t[r]}var Gc={};function rR(e,t,r){let n=`${e}.${String(r)}`;if(Gc[n])return Gc[n].bind(t);let a=cu(e)[r];return typeof a!="function"?t[r]:(Gc[n]=a,a.bind(t))}function OF(e){return bt("Node",e,"ownerDocument")}function MF(e){return bt("Node",e,"childNodes")}function TF(e){return bt("Node",e,"parentNode")}function IF(e){return bt("Node",e,"parentElement")}function LF(e){return bt("Node",e,"textContent")}function NF(e,t){return rR("Node",e,"contains")(t)}function FF(e){return rR("Node",e,"getRootNode")()}function DF(e){return!e||!("host"in e)?null:bt("ShadowRoot",e,"host")}function BF(e){return e.styleSheets}function $F(e){return!e||!("shadowRoot"in e)?null:bt("Element",e,"shadowRoot")}function jF(e,t){return bt("Element",e,"querySelector")(t)}function VF(e,t){return bt("Element",e,"querySelectorAll")(t)}function nR(){return cu("MutationObserver").constructor}function yr(e,t,r){try{if(!(t in e))return()=>{};let n=e[t],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,()=>{e[t]=n}}catch{return()=>{}}}var C={ownerDocument:OF,childNodes:MF,parentNode:TF,parentElement:IF,textContent:LF,contains:NF,getRootNode:FF,host:DF,styleSheets:BF,shadowRoot:$F,querySelector:jF,querySelectorAll:VF,mutationObserver:nR,patch:yr};function ve(e,t,r=document){let n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}var Qr=`Please stop import mirror directly. Instead of that,\r
|
|
63
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
64
|
+
or you can use record.mirror to access the mirror instance during recording.`,hS={map:{},getId(){return console.error(Qr),-1},getNode(){return console.error(Qr),null},removeNodeFromMap(){console.error(Qr)},has(){return console.error(Qr),!1},reset(){console.error(Qr)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(hS=new Proxy(hS,{get(e,t,r){return t==="map"&&console.error(Qr),Reflect.get(e,t,r)}}));function vo(e,t,r={}){let n=null,o=0;return function(...a){let i=Date.now();!o&&r.leading===!1&&(o=i);let s=t-(i-o),l=this;s<=0||s>t?(n&&(clearTimeout(n),n=null),o=i,e.apply(l,a)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{o=r.leading===!1?0:Date.now(),n=null,e.apply(l,a)},s))}}function hs(e,t,r,n,o=window){let a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set(i){setTimeout(()=>{r.set.call(this,i)},0),a&&a.set&&a.set.call(this,i)}}),()=>hs(e,t,a||{},!0)}var rs=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(rs=()=>new Date().getTime());function oR(e){var t,r,n,o;let a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:a.documentElement.scrollLeft||a?.body&&((t=C.parentElement(a.body))==null?void 0:t.scrollLeft)||((r=a?.body)==null?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:a?.documentElement.scrollTop||a?.body&&((n=C.parentElement(a.body))==null?void 0:n.scrollTop)||((o=a?.body)==null?void 0:o.scrollTop)||0}}function aR(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function iR(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function sR(e){return e?e.nodeType===e.ELEMENT_NODE?e:C.parentElement(e):null}function we(e,t,r,n){if(!e)return!1;let o=sR(e);if(!o)return!1;try{if(typeof t=="string"){if(o.classList.contains(t)||n&&o.closest("."+t)!==null)return!0}else if(Hi(o,t,n))return!0}catch{}return!!(r&&(o.matches(r)||n&&o.closest(r)!==null))}function _F(e,t){return t.getId(e)!==-1}function Yc(e,t,r){return e.tagName==="TITLE"&&r.headTitleMutations?!0:t.getId(e)===po}function lR(e,t){if(lo(e))return!1;let r=t.getId(e);if(!t.has(r))return!0;let n=C.parentNode(e);return n&&n.nodeType===e.DOCUMENT_NODE?!1:n?lR(n,t):!0}function Md(e){return!!e.changedTouches}function UF(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}function cR(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function dR(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Td(e){return e?e instanceof Od&&"shadowRoot"in e?!!e.shadowRoot:!!C.shadowRoot(e):!1}var Id=class{constructor(){R(this,"id",1),R(this,"styleIDMap",new WeakMap),R(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function uR(e){var t;let r=null;return"getRootNode"in e&&((t=C.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&C.host(C.getRootNode(e))&&(r=C.host(C.getRootNode(e))),r}function WF(e){let t=e,r;for(;r=uR(t);)t=r;return t}function qF(e){let t=C.ownerDocument(e);if(!t)return!1;let r=WF(e);return C.contains(t,r)}function pR(e){let t=C.ownerDocument(e);return t?C.contains(t,e)||qF(e):!1}var T=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(T||{}),P=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(P||{}),xe=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(xe||{}),yt=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(yt||{}),un=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(un||{}),en=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(en||{});var fR=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(fR||{});function gS(e){return"__ln"in e}var Ld=class{constructor(){R(this,"length",0),R(this,"head",null),R(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=r?.next||null;return r}addNode(t){let r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&gS(t.previousSibling)){let n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&gS(t.nextSibling)&&t.nextSibling.__ln.previous){let n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){let r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}},SS=(e,t)=>`${e}@${t}`,Nd=class{constructor(){R(this,"frozen",!1),R(this,"locked",!1),R(this,"texts",[]),R(this,"attributes",[]),R(this,"attributeMap",new WeakMap),R(this,"removes",[]),R(this,"mapRemoves",[]),R(this,"movedMap",{}),R(this,"addedSet",new Set),R(this,"movedSet",new Set),R(this,"droppedSet",new Set),R(this,"removesSubTreeCache",new Set),R(this,"mutationCb"),R(this,"blockClass"),R(this,"blockSelector"),R(this,"maskTextClass"),R(this,"maskTextSelector"),R(this,"inlineStylesheet"),R(this,"maskInputOptions"),R(this,"maskTextFn"),R(this,"maskInputFn"),R(this,"keepIframeSrcFn"),R(this,"recordCanvas"),R(this,"inlineImages"),R(this,"slimDOMOptions"),R(this,"dataURLOptions"),R(this,"doc"),R(this,"mirror"),R(this,"iframeManager"),R(this,"stylesheetManager"),R(this,"shadowDomManager"),R(this,"canvasManager"),R(this,"processedNodeManager"),R(this,"unattachedDoc"),R(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),R(this,"emit",()=>{if(this.frozen||this.locked)return;let t=[],r=new Set,n=new Ld,o=l=>{let c=l,d=po;for(;d===po;)c=c&&c.nextSibling,d=c&&this.mirror.getId(c);return d},a=l=>{let c=C.parentNode(l);if(!c||!pR(l))return;let d=!1;if(l.nodeType===Node.TEXT_NODE){let m=c.tagName;if(m==="TEXTAREA")return;m==="STYLE"&&this.addedSet.has(c)&&(d=!0)}let u=lo(c)?this.mirror.getId(uR(l)):this.mirror.getId(c),f=o(l);if(u===-1||f===-1)return n.addNode(l);let y=rn(l,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:m=>{cR(m,this.mirror)&&this.iframeManager.addIframe(m),dR(m,this.mirror)&&this.stylesheetManager.trackLinkElement(m),Td(l)&&this.shadowDomManager.addShadowRoot(C.shadowRoot(l),this.doc)},onIframeLoad:(m,h)=>{this.iframeManager.attachIframe(m,h),this.shadowDomManager.observeAttachShadow(m)},onStylesheetLoad:(m,h)=>{this.stylesheetManager.attachLinkElement(m,h)},cssCaptured:d});y&&(t.push({parentId:u,nextId:f,node:y}),r.add(y.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let l of this.movedSet)bS(this.removesSubTreeCache,l,this.mirror)&&!this.movedSet.has(C.parentNode(l))||a(l);for(let l of this.addedSet)!RS(this.droppedSet,l)&&!bS(this.removesSubTreeCache,l,this.mirror)||RS(this.movedSet,l)?a(l):this.droppedSet.add(l);let i=null;for(;n.length;){let l=null;if(i){let c=this.mirror.getId(C.parentNode(i.value)),d=o(i.value);c!==-1&&d!==-1&&(l=i)}if(!l){let c=n.tail;for(;c;){let d=c;if(c=c.previous,d){let u=this.mirror.getId(C.parentNode(d.value));if(o(d.value)===-1)continue;if(u!==-1){l=d;break}else{let y=d.value,m=C.parentNode(y);if(m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let h=C.host(m);if(this.mirror.getId(h)!==-1){l=d;break}}}}}}if(!l){for(;n.head;)n.removeNode(n.head.value);break}i=l.previous,n.removeNode(l.value),a(l.value)}let s={texts:this.texts.map(l=>{let c=l.node,d=C.parentNode(c);return d&&d.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(d),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{let{attributes:c}=l;if(typeof c.style=="string"){let d=JSON.stringify(l.styleDiff),u=JSON.stringify(l._unchangedStyles);d.length<c.style.length&&(d+u).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};!s.texts.length&&!s.attributes.length&&!s.removes.length&&!s.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(s))}),R(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r));let n=Array.from(C.childNodes(t),o=>C.textContent(o)||"").join("");r.attributes.value=qi({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:zi(t),value:n,maskInputFn:this.maskInputFn})}),R(this,"processMutation",t=>{if(!Yc(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{let r=C.textContent(t.target);!we(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:NS(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,sR(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{let r=t.target,n=t.attributeName,o=t.target.getAttribute(n);if(n==="value"){let i=zi(r);o=qi({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:i,value:o,maskInputFn:this.maskInputFn})}if(we(t.target,this.blockClass,this.blockSelector,!1)||o===t.oldValue)return;let a=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&n==="src"&&!this.keepIframeSrcFn(o))if(!r.contentDocument)n="rr_src";else return;if(a||(a={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(a),this.attributeMap.set(t.target,a)),n==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!LS(r.tagName,n))if(a.attributes[n]=IS(this.doc,pr(r.tagName),pr(n),o),n==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}let i=this.unattachedDoc.createElement("span");t.oldValue&&i.setAttribute("style",t.oldValue);for(let s of Array.from(r.style)){let l=r.style.getPropertyValue(s),c=r.style.getPropertyPriority(s);l!==i.style.getPropertyValue(s)||c!==i.style.getPropertyPriority(s)?c===""?a.styleDiff[s]=l:a.styleDiff[s]=[l,c]:a._unchangedStyles[s]=[l,c]}for(let s of Array.from(i.style))r.style.getPropertyValue(s)===""&&(a.styleDiff[s]=!1)}else n==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?a.attributes.rr_open_mode="modal":a.attributes.rr_open_mode="non-modal");break}case"childList":{if(we(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(t.target);return}t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{let n=this.mirror.getId(r),o=lo(t.target)?this.mirror.getId(C.host(t.target)):this.mirror.getId(t.target);we(t.target,this.blockClass,this.blockSelector,!1)||Yc(r,this.mirror,this.slimDOMOptions)||!_F(r,this.mirror)||(this.addedSet.has(r)?(Fd(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||lR(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[SS(n,o)]?Fd(this.movedSet,r):(this.removes.push({parentId:o,id:n,isShadow:lo(t.target)&&co(t.target)?!0:void 0}),zF(r,this.removesSubTreeCache))),this.mapRemoves.push(r))});break}}}),R(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(Yc(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[SS(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);we(t,this.blockClass,this.blockSelector,!1)||(C.childNodes(t).forEach(n=>this.genAdds(n)),Td(t)&&C.childNodes(C.shadowRoot(t)).forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Fd(e,t){e.delete(t),C.childNodes(t).forEach(r=>Fd(e,r))}function zF(e,t){let r=[e];for(;r.length;){let n=r.pop();t.has(n)||(t.add(n),C.childNodes(n).forEach(o=>r.push(o)))}}function bS(e,t,r){return e.size===0?!1:KF(e,t)}function KF(e,t,r){let n=C.parentNode(t);return n?e.has(n):!1}function RS(e,t){return e.size===0?!1:mR(e,t)}function mR(e,t){let r=C.parentNode(t);return r?e.has(r)?!0:mR(e,r):!1}var uo;function HF(e){uo=e}function JF(){uo=void 0}var I=e=>uo?(...r)=>{try{return e(...r)}catch(n){if(uo&&uo(n)===!0)return;throw n}}:e,ur=[];function Co(e){try{if("composedPath"in e){let t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function yR(e,t){let r=new Nd;ur.push(r),r.init(e);let n=new(nR())(I(r.processMutations.bind(r)));return n.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function GF({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};let o=typeof t.mousemove=="number"?t.mousemove:50,a=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500,i=[],s,l=vo(I(u=>{let f=Date.now()-s;e(i.map(y=>(y.timeOffset-=f,y)),u),i=[],s=null}),a),c=I(vo(I(u=>{let f=Co(u),{clientX:y,clientY:m}=Md(u)?u.changedTouches[0]:u;s||(s=rs()),i.push({x:y,y:m,id:n.getId(f),timeOffset:rs()-s}),l(typeof DragEvent<"u"&&u instanceof DragEvent?P.Drag:u instanceof MouseEvent?P.MouseMove:P.TouchMove)}),o,{trailing:!1})),d=[ve("mousemove",c,r),ve("touchmove",c,r),ve("drag",c,r)];return I(()=>{d.forEach(u=>u())})}function YF({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:a}){if(a.mouseInteraction===!1)return()=>{};let i=a.mouseInteraction===!0||a.mouseInteraction===void 0?{}:a.mouseInteraction,s=[],l=null,c=d=>u=>{let f=Co(u);if(we(f,n,o,!0))return;let y=null,m=d;if("pointerType"in u){switch(u.pointerType){case"mouse":y=yt.Mouse;break;case"touch":y=yt.Touch;break;case"pen":y=yt.Pen;break}y===yt.Touch?xe[d]===xe.MouseDown?m="TouchStart":xe[d]===xe.MouseUp&&(m="TouchEnd"):yt.Pen}else Md(u)&&(y=yt.Touch);y!==null?(l=y,(m.startsWith("Touch")&&y===yt.Touch||m.startsWith("Mouse")&&y===yt.Mouse)&&(y=null)):xe[d]===xe.Click&&(y=l,l=null);let h=Md(u)?u.changedTouches[0]:u;if(!h)return;let p=r.getId(f),{clientX:b,clientY:w}=h;I(e)({type:xe[m],id:p,x:b,y:w,...y!==null&&{pointerType:y}})};return Object.keys(xe).filter(d=>Number.isNaN(Number(d))&&!d.endsWith("_Departed")&&i[d]!==!1).forEach(d=>{let u=pr(d),f=c(d);if(window.PointerEvent)switch(xe[d]){case xe.MouseDown:case xe.MouseUp:u=u.replace("mouse","pointer");break;case xe.TouchStart:case xe.TouchEnd:return}s.push(ve(u,f,t))}),I(()=>{s.forEach(d=>d())})}function hR({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:a}){let i=I(vo(I(s=>{let l=Co(s);if(!l||we(l,n,o,!0))return;let c=r.getId(l);if(l===t&&t.defaultView){let d=oR(t.defaultView);e({id:c,x:d.left,y:d.top})}else e({id:c,x:l.scrollLeft,y:l.scrollTop})}),a.scroll||100));return ve("scroll",i,t)}function ZF({viewportResizeCb:e},{win:t}){let r=-1,n=-1,o=I(vo(I(()=>{let a=aR(),i=iR();(r!==a||n!==i)&&(e({width:Number(i),height:Number(a)}),r=a,n=i)}),200));return ve("resize",o,t)}var XF=["INPUT","TEXTAREA","SELECT"],vS=new WeakMap;function QF({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,ignoreClass:a,ignoreSelector:i,maskInputOptions:s,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(w){let S=Co(w),E=w.isTrusted,L=S&&S.tagName;if(S&&L==="OPTION"&&(S=C.parentElement(S)),!S||!L||XF.indexOf(L)<0||we(S,n,o,!0)||S.classList.contains(a)||i&&S.matches(i))return;let V=S.value,ne=!1,W=zi(S)||"";W==="radio"||W==="checkbox"?ne=S.checked:(s[L.toLowerCase()]||s[W])&&(V=qi({element:S,maskInputOptions:s,tagName:L,type:W,value:V,maskInputFn:l})),f(S,d?{text:V,isChecked:ne,userTriggered:E}:{text:V,isChecked:ne});let ae=S.name;W==="radio"&&ae&&ne&&t.querySelectorAll(`input[type="radio"][name="${ae}"]`).forEach(pe=>{if(pe!==S){let Ae=pe.value;f(pe,d?{text:Ae,isChecked:!ne,userTriggered:!1}:{text:Ae,isChecked:!ne})}})}function f(w,S){let E=vS.get(w);if(!E||E.text!==S.text||E.isChecked!==S.isChecked){vS.set(w,S);let L=r.getId(w);I(e)({...S,id:L})}}let m=(c.input==="last"?["change"]:["input","change"]).map(w=>ve(w,I(u),t)),h=t.defaultView;if(!h)return()=>{m.forEach(w=>w())};let p=h.Object.getOwnPropertyDescriptor(h.HTMLInputElement.prototype,"value"),b=[[h.HTMLInputElement.prototype,"value"],[h.HTMLInputElement.prototype,"checked"],[h.HTMLSelectElement.prototype,"value"],[h.HTMLTextAreaElement.prototype,"value"],[h.HTMLSelectElement.prototype,"selectedIndex"],[h.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&m.push(...b.map(w=>hs(w[0],w[1],{set(){I(u)({target:this,isTrusted:!1})}},!1,h))),I(()=>{m.forEach(w=>w())})}function ns(e){let t=[];function r(n,o){if(Fi("CSSGroupingRule")&&n.parentRule instanceof CSSGroupingRule||Fi("CSSMediaRule")&&n.parentRule instanceof CSSMediaRule||Fi("CSSSupportsRule")&&n.parentRule instanceof CSSSupportsRule||Fi("CSSConditionRule")&&n.parentRule instanceof CSSConditionRule){let i=Array.from(n.parentRule.cssRules).indexOf(n);o.unshift(i)}else if(n.parentStyleSheet){let i=Array.from(n.parentStyleSheet.cssRules).indexOf(n);o.unshift(i)}return o}return r(e,t)}function qt(e,t,r){let n,o;return e?(e.ownerNode?n=t.getId(e.ownerNode):o=r.getId(e),{styleId:o,id:n}):{}}function eD({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return()=>{};let o=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:I((d,u,f)=>{let[y,m]=f,{id:h,styleId:p}=qt(u,t,r.styleMirror);return(h&&h!==-1||p&&p!==-1)&&e({id:h,styleId:p,adds:[{rule:y,index:m}]}),d.apply(u,f)})}),n.CSSStyleSheet.prototype.addRule=function(d,u,f=this.cssRules.length){let y=`${d} { ${u} }`;return n.CSSStyleSheet.prototype.insertRule.apply(this,[y,f])};let a=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=new Proxy(a,{apply:I((d,u,f)=>{let[y]=f,{id:m,styleId:h}=qt(u,t,r.styleMirror);return(m&&m!==-1||h&&h!==-1)&&e({id:m,styleId:h,removes:[{index:y}]}),d.apply(u,f)})}),n.CSSStyleSheet.prototype.removeRule=function(d){return n.CSSStyleSheet.prototype.deleteRule.apply(this,[d])};let i;n.CSSStyleSheet.prototype.replace&&(i=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:I((d,u,f)=>{let[y]=f,{id:m,styleId:h}=qt(u,t,r.styleMirror);return(m&&m!==-1||h&&h!==-1)&&e({id:m,styleId:h,replace:y}),d.apply(u,f)})}));let s;n.CSSStyleSheet.prototype.replaceSync&&(s=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(s,{apply:I((d,u,f)=>{let[y]=f,{id:m,styleId:h}=qt(u,t,r.styleMirror);return(m&&m!==-1||h&&h!==-1)&&e({id:m,styleId:h,replaceSync:y}),d.apply(u,f)})}));let l={};Di("CSSGroupingRule")?l.CSSGroupingRule=n.CSSGroupingRule:(Di("CSSMediaRule")&&(l.CSSMediaRule=n.CSSMediaRule),Di("CSSConditionRule")&&(l.CSSConditionRule=n.CSSConditionRule),Di("CSSSupportsRule")&&(l.CSSSupportsRule=n.CSSSupportsRule));let c={};return Object.entries(l).forEach(([d,u])=>{c[d]={insertRule:u.prototype.insertRule,deleteRule:u.prototype.deleteRule},u.prototype.insertRule=new Proxy(c[d].insertRule,{apply:I((f,y,m)=>{let[h,p]=m,{id:b,styleId:w}=qt(y.parentStyleSheet,t,r.styleMirror);return(b&&b!==-1||w&&w!==-1)&&e({id:b,styleId:w,adds:[{rule:h,index:[...ns(y),p||0]}]}),f.apply(y,m)})}),u.prototype.deleteRule=new Proxy(c[d].deleteRule,{apply:I((f,y,m)=>{let[h]=m,{id:p,styleId:b}=qt(y.parentStyleSheet,t,r.styleMirror);return(p&&p!==-1||b&&b!==-1)&&e({id:p,styleId:b,removes:[{index:[...ns(y),h]}]}),f.apply(y,m)})})}),I(()=>{n.CSSStyleSheet.prototype.insertRule=o,n.CSSStyleSheet.prototype.deleteRule=a,i&&(n.CSSStyleSheet.prototype.replace=i),s&&(n.CSSStyleSheet.prototype.replaceSync=s),Object.entries(l).forEach(([d,u])=>{u.prototype.insertRule=c[d].insertRule,u.prototype.deleteRule=c[d].deleteRule})})}function gR({mirror:e,stylesheetManager:t},r){var n,o,a;let i=null;r.nodeName==="#document"?i=e.getId(r):i=e.getId(C.host(r));let s=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(a=(o=r.ownerDocument)==null?void 0:o.defaultView)==null?void 0:a.ShadowRoot,l=s?.prototype?Object.getOwnPropertyDescriptor(s?.prototype,"adoptedStyleSheets"):void 0;return i===null||i===-1||!s||!l?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var d;let u=(d=l.set)==null?void 0:d.call(this,c);if(i!==null&&i!==-1)try{t.adoptStyleSheets(c,i)}catch{}return u}}),I(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}))}function tD({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:o}){let a=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:I((s,l,c)=>{var d;let[u,f,y]=c;if(r.has(u))return a.apply(l,[u,f,y]);let{id:m,styleId:h}=qt((d=l.parentRule)==null?void 0:d.parentStyleSheet,t,n.styleMirror);return(m&&m!==-1||h&&h!==-1)&&e({id:m,styleId:h,set:{property:u,value:f,priority:y},index:ns(l.parentRule)}),s.apply(l,c)})});let i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:I((s,l,c)=>{var d;let[u]=c;if(r.has(u))return i.apply(l,[u]);let{id:f,styleId:y}=qt((d=l.parentRule)==null?void 0:d.parentStyleSheet,t,n.styleMirror);return(f&&f!==-1||y&&y!==-1)&&e({id:f,styleId:y,remove:{property:u},index:ns(l.parentRule)}),s.apply(l,c)})}),I(()=>{o.CSSStyleDeclaration.prototype.setProperty=a,o.CSSStyleDeclaration.prototype.removeProperty=i})}function rD({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:o,doc:a}){let i=I(l=>vo(I(c=>{let d=Co(c);if(!d||we(d,t,r,!0))return;let{currentTime:u,volume:f,muted:y,playbackRate:m,loop:h}=d;e({type:l,id:n.getId(d),currentTime:u,volume:f,muted:y,playbackRate:m,loop:h})}),o.media||500)),s=[ve("play",i(en.Play),a),ve("pause",i(en.Pause),a),ve("seeked",i(en.Seeked),a),ve("volumechange",i(en.VolumeChange),a),ve("ratechange",i(en.RateChange),a)];return I(()=>{s.forEach(l=>l())})}function nD({fontCb:e,doc:t}){let r=t.defaultView;if(!r)return()=>{};let n=[],o=new WeakMap,a=r.FontFace;r.FontFace=function(l,c,d){let u=new a(l,c,d);return o.set(u,{family:l,buffer:typeof c!="string",descriptors:d,fontSource:typeof c=="string"?c:JSON.stringify(Array.from(new Uint8Array(c)))}),u};let i=yr(t.fonts,"add",function(s){return function(l){return setTimeout(I(()=>{let c=o.get(l);c&&(e(c),o.delete(l))}),0),s.apply(this,[l])}});return n.push(()=>{r.FontFace=a}),n.push(i),I(()=>{n.forEach(s=>s())})}function oD(e){let{doc:t,mirror:r,blockClass:n,blockSelector:o,selectionCb:a}=e,i=!0,s=I(()=>{let l=t.getSelection();if(!l||i&&l?.isCollapsed)return;i=l.isCollapsed||!1;let c=[],d=l.rangeCount||0;for(let u=0;u<d;u++){let f=l.getRangeAt(u),{startContainer:y,startOffset:m,endContainer:h,endOffset:p}=f;we(y,n,o,!0)||we(h,n,o,!0)||c.push({start:r.getId(y),startOffset:m,end:r.getId(h),endOffset:p})}a({ranges:c})});return s(),ve("selectionchange",s)}function aD({doc:e,customElementCb:t}){let r=e.defaultView;return!r||!r.customElements?()=>{}:yr(r.customElements,"define",function(o){return function(a,i,s){try{t({define:{name:a}})}catch{console.warn(`Custom element callback failed for ${a}`)}return o.apply(this,[a,i,s])}})}function iD(e,t){let{mutationCb:r,mousemoveCb:n,mouseInteractionCb:o,scrollCb:a,viewportResizeCb:i,inputCb:s,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:f,selectionCb:y,customElementCb:m}=e;e.mutationCb=(...h)=>{t.mutation&&t.mutation(...h),r(...h)},e.mousemoveCb=(...h)=>{t.mousemove&&t.mousemove(...h),n(...h)},e.mouseInteractionCb=(...h)=>{t.mouseInteraction&&t.mouseInteraction(...h),o(...h)},e.scrollCb=(...h)=>{t.scroll&&t.scroll(...h),a(...h)},e.viewportResizeCb=(...h)=>{t.viewportResize&&t.viewportResize(...h),i(...h)},e.inputCb=(...h)=>{t.input&&t.input(...h),s(...h)},e.mediaInteractionCb=(...h)=>{t.mediaInteaction&&t.mediaInteaction(...h),l(...h)},e.styleSheetRuleCb=(...h)=>{t.styleSheetRule&&t.styleSheetRule(...h),c(...h)},e.styleDeclarationCb=(...h)=>{t.styleDeclaration&&t.styleDeclaration(...h),d(...h)},e.canvasMutationCb=(...h)=>{t.canvasMutation&&t.canvasMutation(...h),u(...h)},e.fontCb=(...h)=>{t.font&&t.font(...h),f(...h)},e.selectionCb=(...h)=>{t.selection&&t.selection(...h),y(...h)},e.customElementCb=(...h)=>{t.customElement&&t.customElement(...h),m(...h)}}function sD(e,t={}){let r=e.doc.defaultView;if(!r)return()=>{};iD(e,t);let n;e.recordDOM&&(n=yR(e,e.doc));let o=GF(e),a=YF(e),i=hR(e),s=ZF(e,{win:r}),l=QF(e),c=rD(e),d=()=>{},u=()=>{},f=()=>{},y=()=>{};e.recordDOM&&(d=eD(e,{win:r}),u=gR(e,e.doc),f=tD(e,{win:r}),e.collectFonts&&(y=nD(e)));let m=oD(e),h=aD(e),p=[];for(let b of e.plugins)p.push(b.observer(b.callback,r,b.options));return I(()=>{ur.forEach(b=>b.reset()),n?.disconnect(),o(),a(),i(),s(),l(),c(),d(),u(),f(),y(),m(),h(),p.forEach(b=>b())})}function Fi(e){return typeof window[e]<"u"}function Di(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}var os=class{constructor(t){R(this,"iframeIdToRemoteIdMap",new WeakMap),R(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,n,o){let a=n||this.getIdToRemoteIdMap(t),i=o||this.getRemoteIdToIdMap(t),s=a.get(r);return s||(s=this.generateIdFn(),a.set(r,s),i.set(s,r)),s}getIds(t,r){let n=this.getIdToRemoteIdMap(t),o=this.getRemoteIdToIdMap(t);return r.map(a=>this.getId(t,a,n,o))}getRemoteId(t,r,n){let o=n||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;let a=o.get(r);return a||-1}getRemoteIds(t,r){let n=this.getRemoteIdToIdMap(t);return r.map(o=>this.getRemoteId(t,o,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}},Dd=class{constructor(t){R(this,"iframes",new WeakMap),R(this,"crossOriginIframeMap",new WeakMap),R(this,"crossOriginIframeMirror",new os(TS)),R(this,"crossOriginIframeStyleMirror"),R(this,"crossOriginIframeRootIdMap",new WeakMap),R(this,"mirror"),R(this,"mutationCb"),R(this,"wrappedEmit"),R(this,"loadListener"),R(this,"stylesheetManager"),R(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new os(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n,o;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((n=t.contentWindow)==null||n.addEventListener("message",this.handleMessage.bind(this))),(o=this.loadListener)==null||o.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){let r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;let o=this.crossOriginIframeMap.get(t.source);if(!o)return;let a=this.transformCrossOriginEvent(o,r.data.event);a&&this.wrappedEmit(a,r.data.isCheckout)}transformCrossOriginEvent(t,r){var n;switch(r.type){case T.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);let o=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,o),this.patchRootIdOnNode(r.data.node,o),{timestamp:r.timestamp,type:T.IncrementalSnapshot,data:{source:P.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case T.Meta:case T.Load:case T.DomContentLoaded:return!1;case T.Plugin:return r;case T.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case T.IncrementalSnapshot:switch(r.data.source){case P.Mutation:return r.data.adds.forEach(o=>{this.replaceIds(o,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(o.node,t);let a=this.crossOriginIframeRootIdMap.get(t);a&&this.patchRootIdOnNode(o.node,a)}),r.data.removes.forEach(o=>{this.replaceIds(o,t,["parentId","id"])}),r.data.attributes.forEach(o=>{this.replaceIds(o,t,["id"])}),r.data.texts.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case P.Drag:case P.TouchMove:case P.MouseMove:return r.data.positions.forEach(o=>{this.replaceIds(o,t,["id"])}),r;case P.ViewportResize:return!1;case P.MediaInteraction:case P.MouseInteraction:case P.Scroll:case P.CanvasMutation:case P.Input:return this.replaceIds(r.data,t,["id"]),r;case P.StyleSheetRule:case P.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case P.Font:return r;case P.Selection:return r.data.ranges.forEach(o=>{this.replaceIds(o,t,["start","end"])}),r;case P.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(o=>{this.replaceStyleIds(o,t,["styleId"])}),r}}return!1}replace(t,r,n,o){for(let a of o)!Array.isArray(r[a])&&typeof r[a]!="number"||(Array.isArray(r[a])?r[a]=t.getIds(n,r[a]):r[a]=t.getId(n,r[a]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}patchRootIdOnNode(t,r){t.type!==fR.Document&&!t.rootId&&(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(n=>{this.patchRootIdOnNode(n,r)})}},Bd=class{constructor(t){R(this,"shadowDoms",new WeakSet),R(this,"mutationCb"),R(this,"scrollCb"),R(this,"bypassOptions"),R(this,"mirror"),R(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!co(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);let n=yR({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(hR({...this.bypassOptions,scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(C.host(t))),this.restoreHandlers.push(gR({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){let n=this;this.restoreHandlers.push(yr(t.prototype,"attachShadow",function(o){return function(a){let i=o.call(this,a),s=C.shadowRoot(this);return s&&pR(this)&&n.addShadowRoot(s,r),i}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}},nn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lD=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(so=0;so<nn.length;so++)lD[nn.charCodeAt(so)]=so;var so,cD=function(e){var t=new Uint8Array(e),r,n=t.length,o="";for(r=0;r<n;r+=3)o+=nn[t[r]>>2],o+=nn[(t[r]&3)<<4|t[r+1]>>4],o+=nn[(t[r+1]&15)<<2|t[r+2]>>6],o+=nn[t[r+2]&63];return n%3===2?o=o.substring(0,o.length-1)+"=":n%3===1&&(o=o.substring(0,o.length-2)+"=="),o};var wS=new Map;function dD(e,t){let r=wS.get(e);return r||(r=new Map,wS.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}var SR=(e,t,r)=>{if(!e||!(RR(e,t)||typeof e=="object"))return;let n=e.constructor.name,o=dD(r,n),a=o.indexOf(e);return a===-1&&(a=o.length,o.push(e)),a};function _i(e,t,r){if(e instanceof Array)return e.map(n=>_i(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){let n=e.constructor.name,o=cD(e);return{rr_type:n,base64:o}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[_i(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let n=e.constructor.name,{src:o}=e;return{rr_type:n,src:o}}else if(e instanceof HTMLCanvasElement){let n="HTMLImageElement",o=e.toDataURL();return{rr_type:n,src:o}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[_i(e.data,t,r),e.width,e.height]};if(RR(e,t)||typeof e=="object"){let n=e.constructor.name,o=SR(e,t,r);return{rr_type:n,index:o}}}}return e}var bR=(e,t,r)=>e.map(n=>_i(n,t,r)),RR=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(o=>typeof t[o]=="function").find(o=>e instanceof t[o]);function uD(e,t,r,n){let o=[],a=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let i of a)try{if(typeof t.CanvasRenderingContext2D.prototype[i]!="function")continue;let s=yr(t.CanvasRenderingContext2D.prototype,i,function(l){return function(...c){return we(this.canvas,r,n,!0)||setTimeout(()=>{let d=bR(c,t,this);e(this.canvas,{type:un["2D"],property:i,args:d})},0),l.apply(this,c)}});o.push(s)}catch{let s=hs(t.CanvasRenderingContext2D.prototype,i,{set(l){e(this.canvas,{type:un["2D"],property:i,args:[l],setter:!0})}});o.push(s)}return()=>{o.forEach(i=>i())}}function pD(e){return e==="experimental-webgl"?"webgl":e}function ES(e,t,r,n){let o=[];try{let a=yr(e.HTMLCanvasElement.prototype,"getContext",function(i){return function(s,...l){if(!we(this,t,r,!0)){let c=pD(s);if("__context"in this||(this.__context=c),n&&["webgl","webgl2"].includes(c))if(l[0]&&typeof l[0]=="object"){let d=l[0];d.preserveDrawingBuffer||(d.preserveDrawingBuffer=!0)}else l.splice(0,1,{preserveDrawingBuffer:!0})}return i.apply(this,[s,...l])}});o.push(a)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach(a=>a())}}function xS(e,t,r,n,o,a){let i=[],s=Object.getOwnPropertyNames(e);for(let l of s)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof e[l]!="function")continue;let c=yr(e,l,function(d){return function(...u){let f=d.apply(this,u);if(SR(f,a,this),"tagName"in this.canvas&&!we(this.canvas,n,o,!0)){let y=bR(u,a,this),m={type:t,property:l,args:y};r(this.canvas,m)}return f}});i.push(c)}catch{let c=hs(e,l,{set(d){r(this.canvas,{type:t,property:l,args:[d],setter:!0})}});i.push(c)}return i}function fD(e,t,r,n){let o=[];return o.push(...xS(t.WebGLRenderingContext.prototype,un.WebGL,e,r,n,t)),typeof t.WebGL2RenderingContext<"u"&&o.push(...xS(t.WebGL2RenderingContext.prototype,un.WebGL2,e,r,n,t)),()=>{o.forEach(a=>a())}}var vR="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",mD=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),kS=typeof window<"u"&&window.Blob&&new Blob([mD(vR)],{type:"text/javascript;charset=utf-8"});function yD(e){let t;try{if(t=kS&&(window.URL||window.webkitURL).createObjectURL(kS),!t)throw"";let r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+vR,{name:e?.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var $d=class{constructor(t){R(this,"pendingCanvasMutations",new Map),R(this,"rafStamps",{latestId:0,invokeId:null}),R(this,"mirror"),R(this,"mutationCb"),R(this,"resetObservers"),R(this,"frozen",!1),R(this,"locked",!1),R(this,"processMutation",(l,c)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(c)});let{sampling:r="all",win:n,blockClass:o,blockSelector:a,recordCanvas:i,dataURLOptions:s}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,i&&r==="all"&&this.initCanvasMutationObserver(n,o,a),i&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,o,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,n,o,a){let i=ES(r,n,o,!0),s=new Map,l=new yD;l.onmessage=m=>{let{id:h}=m.data;if(s.set(h,!1),!("base64"in m.data))return;let{base64:p,type:b,width:w,height:S}=m.data;this.mutationCb({id:h,type:un["2D"],commands:[{property:"clearRect",args:[0,0,w,S]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:p}],type:b}]},0,0]}]})};let c=1e3/t,d=0,u,f=()=>{let m=[];return r.document.querySelectorAll("canvas").forEach(h=>{we(h,n,o,!0)||m.push(h)}),m},y=m=>{if(d&&m-d<c){u=requestAnimationFrame(y);return}d=m,f().forEach(async h=>{var p;let b=this.mirror.getId(h);if(s.get(b)||h.width===0||h.height===0)return;if(s.set(b,!0),["webgl","webgl2"].includes(h.__context)){let S=h.getContext(h.__context);((p=S?.getContextAttributes())==null?void 0:p.preserveDrawingBuffer)===!1&&S.clear(S.COLOR_BUFFER_BIT)}let w=await createImageBitmap(h);l.postMessage({id:b,bitmap:w,width:h.width,height:h.height,dataURLOptions:a.dataURLOptions},[w])}),u=requestAnimationFrame(y)};u=requestAnimationFrame(y),this.resetObservers=()=>{i(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let o=ES(t,r,n,!1),a=uD(this.processMutation.bind(this),t,r,n),i=fD(this.processMutation.bind(this),t,r,n);this.resetObservers=()=>{o(),a(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{let n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;let o=n.map(i=>{let{type:s,...l}=i;return l}),{type:a}=n[0];this.mutationCb({id:r,type:a,commands:o}),this.pendingCanvasMutations.delete(t)}},jd=class{constructor(t){R(this,"trackedLinkElements",new WeakSet),R(this,"mutationCb"),R(this,"adoptedStyleSheetCb"),R(this,"styleMirror",new Id),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;let n={id:r,styleIds:[]},o=[];for(let a of t){let i;this.styleMirror.has(a)?i=this.styleMirror.getId(a):(i=this.styleMirror.add(a),o.push({styleId:i,rules:Array.from(a.rules||CSSRule,(s,l)=>({rule:OS(s,a.href),index:l}))})),n.styleIds.push(i)}o.length>0&&(n.styles=o),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}},Vd=class{constructor(){R(this,"nodeMap",new WeakMap),R(this,"active",!1)}inOtherBuffer(t,r){let n=this.nodeMap.get(t);return n&&Array.from(n).some(o=>o!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}},re,Ui,Zc,as=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Ag=e.contentWindow)==null?void 0:Ag.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var We=SI();function hr(e={}){let{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:o="rr-block",blockSelector:a=null,ignoreClass:i="rr-ignore",ignoreSelector:s=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:f,slimDOMOptions:y,maskInputFn:m,maskTextFn:h,hooks:p,packFn:b,sampling:w={},dataURLOptions:S={},mousemoveWait:E,recordDOM:L=!0,recordCanvas:V=!1,recordCrossOriginIframes:ne=!1,recordAfter:W=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:ae=!1,collectFonts:pe=!1,inlineImages:Ae=!1,plugins:He,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:fn=new Set([]),errorHandler:mn}=e;HF(mn);let le=ne?window.parent===window:!0,Pe=!1;if(!le)try{window.parent.document&&(Pe=!1)}catch{Pe=!0}if(le&&!t)throw new Error("emit function is required");if(!le&&!Pe)return()=>{};E!==void 0&&w.mousemove===void 0&&(w.mousemove=E),We.reset();let zt=u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:f!==void 0?f:{password:!0},Je=FS(y);UF();let uu,gs=0,pu=D=>{for(let Ie of He||[])Ie.eventProcessor&&(D=Ie.eventProcessor(D));return b&&!Pe&&(D=b(D)),D};re=(D,Ie)=>{var Q;let ee=D;if(ee.timestamp=rs(),(Q=ur[0])!=null&&Q.isFrozen()&&ee.type!==T.FullSnapshot&&!(ee.type===T.IncrementalSnapshot&&ee.data.source===P.Mutation)&&ur.forEach(ke=>ke.unfreeze()),le)t?.(pu(ee),Ie);else if(Pe){let ke={type:"rrweb",event:pu(ee),origin:window.location.origin,isCheckout:Ie};window.parent.postMessage(ke,"*")}if(ee.type===T.FullSnapshot)uu=ee,gs=0;else if(ee.type===T.IncrementalSnapshot){if(ee.data.source===P.Mutation&&ee.data.isAttachIframe)return;gs++;let ke=n&&gs>=n,_=r&&ee.timestamp-uu.timestamp>r;(ke||_)&&Ui(!0)}};let Po=D=>{re({type:T.IncrementalSnapshot,data:{source:P.Mutation,...D}})},fu=D=>re({type:T.IncrementalSnapshot,data:{source:P.Scroll,...D}}),mu=D=>re({type:T.IncrementalSnapshot,data:{source:P.CanvasMutation,...D}}),BR=D=>re({type:T.IncrementalSnapshot,data:{source:P.AdoptedStyleSheet,...D}}),Kt=new jd({mutationCb:Po,adoptedStyleSheetCb:BR}),Ht=new Dd({mirror:We,mutationCb:Po,stylesheetManager:Kt,recordCrossOriginIframes:ne,wrappedEmit:re});for(let D of He||[])D.getMirror&&D.getMirror({nodeMirror:We,crossOriginIframeMirror:Ht.crossOriginIframeMirror,crossOriginIframeStyleMirror:Ht.crossOriginIframeStyleMirror});let Ss=new Vd;Zc=new $d({recordCanvas:V,mutationCb:mu,win:window,blockClass:o,blockSelector:a,mirror:We,sampling:w.canvas,dataURLOptions:S});let Oo=new Bd({mutationCb:Po,scrollCb:fu,bypassOptions:{blockClass:o,blockSelector:a,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:zt,dataURLOptions:S,maskTextFn:h,maskInputFn:m,recordCanvas:V,inlineImages:Ae,sampling:w,slimDOMOptions:Je,iframeManager:Ht,stylesheetManager:Kt,canvasManager:Zc,keepIframeSrcFn:N,processedNodeManager:Ss},mirror:We});Ui=(D=!1)=>{if(!L)return;re({type:T.Meta,data:{href:window.location.href,width:iR(),height:aR()}},D),Kt.reset(),Oo.init(),ur.forEach(Q=>Q.lock());let Ie=UI(document,{mirror:We,blockClass:o,blockSelector:a,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:zt,maskTextFn:h,maskInputFn:m,slimDOM:Je,dataURLOptions:S,recordCanvas:V,inlineImages:Ae,onSerialize:Q=>{cR(Q,We)&&Ht.addIframe(Q),dR(Q,We)&&Kt.trackLinkElement(Q),Td(Q)&&Oo.addShadowRoot(C.shadowRoot(Q),document)},onIframeLoad:(Q,ee)=>{Ht.attachIframe(Q,ee),Oo.observeAttachShadow(Q)},onStylesheetLoad:(Q,ee)=>{Kt.attachLinkElement(Q,ee)},keepIframeSrcFn:N});if(!Ie)return console.warn("Failed to snapshot the document");re({type:T.FullSnapshot,data:{node:Ie,initialOffset:oR(window)}},D),ur.forEach(Q=>Q.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Kt.adoptStyleSheets(document.adoptedStyleSheets,We.getId(document))};try{let D=[],Ie=ee=>{var ke;return I(sD)({mutationCb:Po,mousemoveCb:(_,bs)=>re({type:T.IncrementalSnapshot,data:{source:bs,positions:_}}),mouseInteractionCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.MouseInteraction,..._}}),scrollCb:fu,viewportResizeCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.ViewportResize,..._}}),inputCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.Input,..._}}),mediaInteractionCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.MediaInteraction,..._}}),styleSheetRuleCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.StyleSheetRule,..._}}),styleDeclarationCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.StyleDeclaration,..._}}),canvasMutationCb:mu,fontCb:_=>re({type:T.IncrementalSnapshot,data:{source:P.Font,..._}}),selectionCb:_=>{re({type:T.IncrementalSnapshot,data:{source:P.Selection,..._}})},customElementCb:_=>{re({type:T.IncrementalSnapshot,data:{source:P.CustomElement,..._}})},blockClass:o,ignoreClass:i,ignoreSelector:s,maskTextClass:l,maskTextSelector:c,maskInputOptions:zt,inlineStylesheet:d,sampling:w,recordDOM:L,recordCanvas:V,inlineImages:Ae,userTriggeredOnInput:ae,collectFonts:pe,doc:ee,maskInputFn:m,maskTextFn:h,keepIframeSrcFn:N,blockSelector:a,slimDOMOptions:Je,dataURLOptions:S,mirror:We,iframeManager:Ht,stylesheetManager:Kt,shadowDomManager:Oo,processedNodeManager:Ss,canvasManager:Zc,ignoreCSSAttributes:fn,plugins:((ke=He?.filter(_=>_.observer))==null?void 0:ke.map(_=>({observer:_.observer,options:_.options,callback:bs=>re({type:T.Plugin,data:{plugin:_.name,payload:bs}})})))||[]},p)};Ht.addLoadListener(ee=>{try{D.push(Ie(ee.contentDocument))}catch(ke){console.warn(ke)}});let Q=()=>{Ui(),D.push(Ie(document)),as=!0};return["interactive","complete"].includes(document.readyState)?Q():(D.push(ve("DOMContentLoaded",()=>{re({type:T.DomContentLoaded,data:{}}),W==="DOMContentLoaded"&&Q()})),D.push(ve("load",()=>{re({type:T.Load,data:{}}),W==="load"&&Q()},window))),()=>{D.forEach(ee=>{try{ee()}catch(ke){String(ke).toLowerCase().includes("cross-origin")||console.warn(ke)}}),Ss.destroy(),as=!1,JF()}}catch(D){console.warn(D)}}hr.addCustomEvent=(e,t)=>{if(!as)throw new Error("please add custom event after start recording");re({type:T.Custom,data:{tag:e,payload:t}})};hr.freezePage=()=>{ur.forEach(e=>e.freeze())};hr.takeFullSnapshot=e=>{if(!as)throw new Error("please take full snapshot after start recording");Ui(e)};hr.mirror=We;var CS;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(CS||(CS={}));var aG=5*1e3;var{addCustomEvent:iG}=hr,{freezePage:sG}=hr,{takeFullSnapshot:lG}=hr;var ER="__ripploEmitRrwebEvent";function xR(){return{eventTypes:wR(T),incrementalSources:wR(P)}}function wR(e){return Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="number").map(([t,r])=>[r,t]))}var kR=Bc(Dc("@ripplo/rrweb-bundle/bundle","rrweb.js"));async function Ao({clientVersion:e,debugDir:t,writeOtlpPortFile:r}){let n=new Map,o=kg(xR()),a=await lc({localDir:CR.join(CR.dirname(t),".local"),writePortFile:r,onRrwebBatch:(l,c)=>{n.get(l)?.emitRrwebBatch(c)},onSpan:l=>{let c=l.attributes["ripplo.run"];c!=null&&n.get(c)?.emit(l)}}),i=await kR();return{attach:async(l,c)=>{let d=xg({debugDir:t,runId:c,worker:o});d.emit({clientVersion:e,kind:"meta",source:"capture",timeNanos:"0"}),n.set(c,d),await Cg(l,c),await l.addInitScript(`globalThis.__ripploCapturePort = ${String(a.port)};`),await l.addInitScript(i),await gD(l,d),await RD(l,d);let u=[];return{emitAction:f=>{ED(d,f)},emitStepOutcome:f=>{xD(d,f)},finish:()=>vD(d,{pages:u,registry:n,runId:c}),onPage:f=>{u.push(f),wD(d,i,f)}}},debugDir:t,close:async()=>{await a.stop(),await o.terminate()},injectSpan:(l,c)=>{n.get(l)?.emit(c)}}}async function hD(e){await Promise.all(e.map(t=>t.evaluate("globalThis.__ripploFlushRrweb ? globalThis.__ripploFlushRrweb() : undefined").catch(()=>{})))}async function gD(e,t){await e.exposeBinding(ER,(r,n)=>{let o=typeof n=="string"?n:JSON.stringify(n);t.emitRrwebBatch(Buffer.from(o,"utf8"))})}var SD="__ripploEventPush",bD=Ke.discriminatedUnion("kind",[Ke.object({kind:Ke.literal("console"),level:Ke.string(),text:Ke.string(),timestamp:Ke.number()}),Ke.object({kind:Ke.literal("error"),message:Ke.string(),stack:Ke.string().optional(),timestamp:Ke.number()})]);async function RD(e,t){await e.exposeBinding(SD,(r,n)=>{let o=bD.safeParse(n);if(!o.success)return;let a=o.data;if(a.kind==="console"){t.emit({kind:"console",level:a.level,source:"browser",text:a.text,timeNanos:dr(a.timestamp)});return}t.emit({kind:"error",message:a.message,source:"browser",stack:a.stack,timeNanos:dr(a.timestamp)})})}async function vD(e,t){await hD(t.pages),t.registry.delete(t.runId),await e.close({noticeIfNoRrweb:"rrweb capture unavailable: recorder never pushed an event \u2014 page never loaded the recorder (blank page, failed navigation, or CSP block)"})}function wD(e,t,r){r.on("requestfinished",n=>{MD(e,n).catch(()=>{})}),r.url()!=="about:blank"&&r.addScriptTag({content:t}).catch(()=>{})}function ED(e,t){e.emit({action:t.kind,kind:"action",source:"test",target:AD(t),timeNanos:dr(Date.now()),value:PD(t)})}function xD(e,t){t.checks.forEach(r=>{e.emit(kD(r,t.stepIndex))}),t.stepError!=null&&e.emit(CD(t.stepError,t.stepIndex))}function kD(e,t){return{...e.body,kind:"check",origin:Ia(e.target,t),source:"verifier",stepIndex:t,timeNanos:dr(e.atMs)}}function CD(e,t){return{error:e.error,kind:"stepError",source:"verifier",stepIndex:t,timeNanos:dr(e.atMs)}}function AD(e){if(e.url!=null)return Oe(e.url);if(e.locator!=null)return Fo(e.locator)}function PD(e){return e.value!=null?wt(e.value):e.key}var OD=/^http:\/\/127\.0\.0\.1:\d+\/rrweb\//;async function MD(e,t){if(OD.test(t.url()))return;let r=await t.response();if(r==null)return;let n=t.resourceType(),o=n==="fetch"||n==="xhr",a=t.timing(),i=t.headers().traceparent?.split("-"),s=a.startTime;e.emit({durationMs:Math.max(0,a.responseEnd),kind:"network",method:t.method(),requestBody:o?t.postData()??void 0:void 0,resourceType:n,responseBody:o?await TD(r):void 0,source:"browser",spanId:i?.[2],status:r.status(),timeNanos:dr(s>0?s:Date.now()),traceId:i?.[1],url:r.url()})}async function TD(e){try{return await e.text()}catch{return}}function FD(e,t){return new ND(DD(e,t))}async function DD(e,t){let r=await Wh(e.profileDir).catch(()=>{});if(r==null)return AR(me(new Error("launch")));try{return LD(await BD({context:r,params:e,signal:t}))}catch(n){return AR(me(n))}finally{await r.close().catch(ge)}}async function BD({context:e,params:t,signal:r}){let n=e.pages()[0]??await e.newPage(),o=await Ao({clientVersion:t.clientVersion,debugDir:t.debugDir,writeOtlpPortFile:!0}),a=await o.attach(e,t.runId);return a.onPage(n),e.on("page",i=>{a.onPage(i)}),await n.goto(t.startUrl).catch(ge),t.onReady(),await $D(e,r),await a.finish(),await o.close(),{behaviorPath:ID.join(t.debugDir,t.runId,"behavior.jsonl")}}function $D(e,t){return new Promise(r=>{let n=()=>{r()};t.addEventListener("abort",n,{once:!0}),e.on("close",n),e.browser()?.on("disconnected",n),e.on("page",o=>o.on("close",n)),e.pages().forEach(o=>o.on("close",n))})}import{err as jD,ok as VD,ResultAsync as _D}from"neverthrow";function UD({cacheDir:e,clientVersion:t,debugDir:r,headed:n,writeOtlpPortFile:o}){let a=si({cacheDir:e,headed:n}),i,s,l=async()=>(i??=Ao({clientVersion:t,debugDir:r,writeOtlpPortFile:o}),s=await i,s),c=async(f,y)=>{if(y.aborted)return VD(ro("skipped"));try{let m=await l();if(f.options.headed&&!n)return await Sc(!0,async p=>Nc({browser:p,hub:m,request:f},y));let h=await a.acquire();return await Nc({browser:h,hub:m,request:f},y)}catch(m){return jD(me(m))}};return{close:async()=>{await a.close();let f=i;i=void 0,s=void 0,f!=null&&await f.then(y=>y.close()).catch(()=>{})},prewarm:async()=>{await l(),await a.acquire()},injectSpan:(f,y)=>{s?.injectSpan(f,y)},runOnce:(f,y)=>new _D(c(f,y))}}import{z as O}from"zod";function WD(e){let t=e.split(`
|
|
65
|
+
`).map(o=>aB(o)).filter(o=>o!=null),r=QD(t),n=t.map(o=>HD(o,r)).filter(o=>o!=null).filter(o=>o.kind==="input"||o.element!=null);return qD(n)}function qD(e){return e.filter((t,r)=>{let n=e[r+1];return!(t.kind==="input"&&n?.kind==="input"&&zD(t.element,n.element))})}function zD(e,t){return e?.testId===t?.testId&&e?.ariaLabel===t?.ariaLabel&&e?.placeholder===t?.placeholder}var KD={2:"click",3:"contextmenu",4:"dblclick"};function HD(e,t){return e.rrwebType==="IncrementalSnapshot:MouseInteraction"?JD(e,t):e.rrwebType==="IncrementalSnapshot:Input"?GD(e,t):null}function JD(e,t){let r=uB.safeParse(e.event.data);if(!r.success)return null;let n=KD[r.data.type];if(n==null)return null;let o=PR(r.data.id,t.nodes);return{element:OR(o,t),kind:n,timeNanos:e.timeNanos,value:void 0}}function GD(e,t){let r=pB.safeParse(e.event.data);return r.success?{element:OR(r.data.id,t),kind:"input",timeNanos:e.timeNanos,value:r.data.text??YD(r.data.isChecked)}:null}function YD(e){return e==null?void 0:String(e)}var ZD=new Set(["button","a","input","select","textarea","summary"]);function PR(e,t){let r=t.get(e);if(r!=null)return XD(r)?e:r.parentId==null?void 0:PR(r.parentId,t)}function XD(e){return e.attrs["data-testid"]!=null||e.attrs["aria-label"]!=null||e.attrs.role!=null||ZD.has(e.tag??"")}function OR(e,t){let r=e==null?void 0:t.nodes.get(e);if(!(r==null||e==null))return{ariaLabel:pn(r,"aria-label"),href:pn(r,"href"),name:pn(r,"name"),placeholder:pn(r,"placeholder"),role:pn(r,"role"),tag:r.tag,testId:pn(r,"data-testid"),text:MR(e,t)}}function pn(e,t){let r=e.attrs[t];return typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"?String(r):void 0}function MR(e,t){let r=t.nodes.get(e);if(r==null)return;let n=r.text?.trim()??"",a=(t.children.get(e)??[]).map(s=>MR(s,t)??""),i=[n,...a].filter(s=>s.length>0).join(" ");return i.length===0?void 0:i.slice(0,100)}function QD(e){let t=e.flatMap(o=>eB(o).flatMap(a=>du(a,void 0))),r=e.flatMap(o=>tB(o).flatMap(a=>du(a.node,a.parentId??void 0))),n=nB(new Map([...t,...r]),e);return{children:rB(n),nodes:n}}function eB(e){if(e.rrwebType!=="FullSnapshot")return[];let t=lB.safeParse(e.event.data);return t.success?[t.data.node]:[]}function tB(e){if(e.rrwebType!=="IncrementalSnapshot:Mutation")return[];let t=TR.safeParse(e.event.data);return t.success?t.data.adds.flatMap(r=>{let n=cB.safeParse(r);return n.success?[n.data]:[]}):[]}function rB(e){let t=new Map;return e.forEach((r,n)=>{r.parentId!=null&&t.set(r.parentId,[...t.get(r.parentId)??[],n])}),t}function du(e,t){let r=sB.safeParse(e);if(!r.success)return[];let n=r.data,o=n.childNodes??[];return[[n.id,{attrs:{...n.attributes},parentId:t,tag:n.tagName,text:n.textContent}],...o.flatMap(i=>du(i,n.id))]}function nB(e,t){return t.flatMap(n=>oB(n)).reduce((n,o)=>{let a=n.get(o.id);return a==null?n:new Map(n).set(o.id,{...a,attrs:{...a.attrs,...o.attributes}})},e)}function oB(e){if(e.rrwebType!=="IncrementalSnapshot:Mutation")return[];let t=TR.safeParse(e.event.data);return t.success?t.data.attributes.flatMap(r=>{let n=dB.safeParse(r);return n.success?[n.data]:[]}):[]}function aB(e){if(e.trim().length===0)return null;let t=fB.safeParse(iB(e));return t.success?t.data:null}function iB(e){try{return JSON.parse(e)}catch{return null}}var sB=O.object({attributes:O.record(O.string(),O.unknown()).optional(),childNodes:O.array(O.unknown()).optional(),id:O.number(),tagName:O.string().optional(),textContent:O.string().optional()}),lB=O.object({node:O.unknown()}),cB=O.object({node:O.unknown(),parentId:O.number().nullable().default(null)}),dB=O.object({attributes:O.record(O.string(),O.unknown()),id:O.number()}),TR=O.object({adds:O.array(O.unknown()).default([]),attributes:O.array(O.unknown()).default([])}),uB=O.object({id:O.number(),type:O.number()}),pB=O.object({id:O.number(),isChecked:O.boolean().optional(),text:O.string().optional()}),fB=O.object({event:O.object({data:O.unknown()}),kind:O.literal("rrweb"),rrwebType:O.string(),timeNanos:O.string()});function IR(e){let t=r=>e.find(n=>n.phase===r)?.ms??0;return{browserMs:t("browser"),driveMs:t("drive"),engineMs:t("engine"),teardownMs:t("teardown"),worldMs:t("world")}}async function mB(e,t){let r=await FR({attemptIndex:0,capture:!1,params:e,stepRuns:e.stepRuns},t);if(r.kind!=="completed")return LR(r,void 0);let n=NR(r.contradictions);if(n!=null)return{error:n,kind:"error"};let o=yB(r.contradictions);if(o==null)return{kind:"clean",ranCount:r.ranCount,timing:{confirm:void 0,detect:r.timing}};let a=Gn(o.contradictions);return e.seenSignature!=null&&await e.seenSignature(a.signature)?{kind:"seen",ranCount:r.ranCount,signature:a.signature,timing:{confirm:void 0,detect:r.timing},title:a.title,verifierLayer:a.layer}:hB({detect:r.timing,digest:a,discoveryKind:o.kind,params:e,signal:t})}function yB(e){let t=qn(e);if(t.length>0)return{contradictions:t,kind:"finding"};let r=zn(e);return r.length>0?{contradictions:r,kind:"coverage-gap"}:null}function LR(e,t){return e.kind==="error"?{error:e.error,kind:"error"}:{kind:"aborted",ranCount:e.ranCount,timing:{confirm:t==null?void 0:e.timing,detect:t??e.timing}}}function NR(e){let t=e.find(r=>r.kind==="stepError"&&_o(r.record.error));return t!=null&&t.kind==="stepError"?t.record.error:void 0}async function hB({detect:e,digest:t,discoveryKind:r,params:n,signal:o}){let a=await FR({attemptIndex:1,capture:!0,params:n,stepRuns:n.stepRuns},o);if(a.kind!=="completed")return LR(a,e);let i=NR(a.contradictions);if(i!=null)return{error:i,kind:"error"};let s={confirm:a.timing,detect:e},l=r==="finding"?qn(a.contradictions):zn(a.contradictions);return l.length===0||Gn(l).signature!==t.signature?{kind:"flaky",ranCount:a.ranCount,timing:s}:{baseState:n.baseState.name,captureEvents:a.events,kind:r,ranCount:a.ranCount,runId:a.runId,signature:t.signature,sourceTest:t.sourceTest,timing:s,title:t.title,verifierLayer:t.layer}}async function FR({attemptIndex:e,capture:t,params:r,stepRuns:n},o){let a=r.runIdFor(e),i=[],s=[];return(await r.session.runOnce({capture:t,lockfile:r.lockfile,onEvent:t?c=>{i.push(c)}:void 0,onProgress:void 0,options:r.options,params:void 0,runId:a,sequence:gB(r,n),startingStateSeed:r.startingStateSeed,test:r.baseState.test,onPhase:(c,d)=>{s.push({ms:d,phase:c})}},o)).match(c=>c.aborted?{kind:"aborted",ranCount:c.ran.length,timing:IR(s)}:{contradictions:c.contradictions,events:i,kind:"completed",ranCount:c.ran.length,runId:a,timing:IR(s)},c=>({error:c,kind:"error"}))}function gB(e,t){let r=Jr({corpus:e.corpus,planned:t});if(r==null)throw new Error("explore-transition-unavailable");return r}function DR(e,t){let r=Ga(e);if(r.kind==="model-empty")return{kind:"unplannable"};let n=r.value,o=n.startingPointTests.get(t.envelopeRef);if(o==null)return{kind:"unplannable"};let a=Jr({corpus:n.corpus,planned:t.steps});return a==null?{kind:"unplannable"}:{baseTest:o,kind:"ok",sequence:a}}async function SB({capture:e,lockfile:t,onEvent:r,options:n,repro:o,runId:a,session:i,signal:s}){let l=DR(t,o);return l.kind==="unplannable"?{kind:"unplannable"}:(await i.runOnce({capture:e,lockfile:t,onEvent:r,onPhase:void 0,onProgress:void 0,options:n,params:void 0,runId:a,sequence:l.sequence,startingStateSeed:o.seed,test:l.baseTest},s)).match(d=>{if(d.aborted)return{kind:"aborted"};let u=_a(d.contradictions);return u.length>0?{contradictions:u,kind:"still-fails"}:{kind:"resolved"}},d=>({kind:"state-unavailable",reason:d.kind}))}export{_o as a,tp as b,Yt as c,Me as d,Wf as e,ca as f,ua as g,pa as h,Kf as i,Nt as j,je as k,oe as l,J as m,Xo as n,na as o,Va as p,Af as q,ia as r,Bf as s,jy as t,Vy as u,_y as v,Uy as w,qy as x,Ky as y,Hy as z,Gy as A,Hf as B,fa as C,ma as D,Xy as E,nh as F,oh as G,Um as H,ah as I,ih as J,ac as K,sh as L,lh as M,ch as N,dh as O,Ka as P,Ga as Q,Ya as R,yh as S,ET as T,Dc as U,Bc as V,lc as W,FD as X,UD as Y,WD as Z,mB as _,DR as $,SB as aa};
|
|
66
|
+
/*! Bundled license information:
|
|
67
|
+
|
|
68
|
+
rrweb/dist/rrweb.js:
|
|
69
|
+
(*! *****************************************************************************
|
|
70
|
+
Copyright (c) Microsoft Corporation.
|
|
71
|
+
|
|
72
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
73
|
+
purpose with or without fee is hereby granted.
|
|
74
|
+
|
|
75
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
76
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
77
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
78
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
79
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
80
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
81
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
82
|
+
***************************************************************************** *)
|
|
83
|
+
*/
|