@2digits/oxlint-plugin 0.10.0 → 0.12.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/NOTICE +7 -0
- package/README.md +33 -0
- package/dist/index.d.mts +7 -3
- package/dist/index.mjs +6 -6
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{AST as e,Diagnostic as t,Plugin as n,Rule as r,RuleContext as i,Scope as a,SourceCode as o,Visitor as s}from"effect-oxlint";import*as c from"effect/Array";import*as l from"effect/Record";import*as u from"effect/Struct";import*as d from"effect/Effect";import*as f from"effect/Option";import*as p from"effect/Ref";import*as m from"effect/Schema";import*as h from"effect/String";import*as g from"effect/Function";import*as _ from"effect/Match";import*as v from"effect/Tuple";import*as y from"effect/Equivalence";import*as b from"effect/Predicate";import*as x from"effect/HashSet";import*as ee from"effect/Result";import*as S from"effect/Duration";import*as te from"effect/Number";import*as ne from"effect/HashMap";import*as re from"effect/Order";import*as ie from"effect/http/HttpMethod";import*as ae from"effect/http/HttpStatus";const oe=m.Literals([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]),se=m.is(oe),ce=m.Literals([`==`,`===`,`!=`,`!==`]),le=m.is(ce),ue=m.Literals([`ArrowFunctionExpression`,`FunctionExpression`]),de=m.is(ue),fe=_.type().pipe(_.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e})),C=_.type().pipe(_.when({computed:!1,property:{type:`Identifier`}},({property:e})=>f.some(e.name)),_.when({computed:!0,property:{type:`Literal`,value:h.isString}},({property:e})=>f.some(e.value)),_.orElse(()=>f.none()));function w(e){let t=e.type===`ChainExpression`?e.expression:e;return t.type===`Identifier`?f.some(c.of(t.name)):t.type===`MemberExpression`?f.zipWith(w(t.object),C(t),(e,t)=>c.append(e,t)):f.none()}const T=_.type().pipe(_.when({computed:!1,key:{type:`Identifier`}},({key:e})=>f.some(e.name)),_.when({key:{type:`Literal`,value:h.isString}},({key:e})=>f.some(e.value)),_.orElse(()=>f.none())),pe=_.type().pipe(_.when({type:`Property`,computed:!1,method:!1,kind:`init`},f.some),_.orElse(()=>f.none())),E=g.dual(2,(e,t)=>c.findFirst(e.properties,e=>e.type===`Property`&&f.contains(T(e),t)));function D(e,t){return f.filter(c.get(e.arguments,t),e=>e.type!==`SpreadElement`)}function me(e){return c.findFirst(e.arguments,e=>e.type===`ObjectExpression`)}function he(e){return se(e.type)}function O(e){return he(e)?O(e.expression):e}const ge=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function _e(e){return c.isArray(e)?e:c.map(c.filter(l.toEntries(e),([e])=>!ge.has(e)),([,e])=>e)}function ve(e){return b.hasProperty(e,`type`)&&b.isString(e.type)}function k(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;c.isArrayNonEmpty(n);){let e=n.pop();if(b.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),ve(e)&&t(e))return!0;n.push(..._e(e))}}return!1}function ye(e,t){return k(e,e=>e.type===`Identifier`&&e.name===t)}function A(e){return b.isNotNullish(e)&&de(e.type)}const be=_.type().pipe(_.when({type:`VariableDeclaration`,kind:`const`},g.constTrue),_.orElse(g.constFalse));function xe(e){return f.filter(c.head(e.params),e=>e.type===`Identifier`)}function Se(e){return f.exists(xe(e),t=>b.isNotNullish(e.body)&&!h.startsWith(`_`)(t.name)&&ye(e.body,t.name))}function j(e){return f.fromNullishOr(e.parent)}function M(t,n){return f.filter(j(t),t=>f.isSome(e.narrow(t,n)))}function Ce(e,t){return f.flatMap(j(e),e=>t(e)?f.some(e):Ce(e,t))}function we(e){return Ce(e,A)}function Te(e){return f.filter(M(e,`CallExpression`),t=>F(t.arguments,e))}function Ee(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function N(e){return e.type===`Literal`&&h.isString(e.value)}const P=g.dual(2,(e,t)=>e.type===`Literal`&&e.value===t);function De(e){return f.exists(j(e),t=>t.type===`ExpressionStatement`||t.type===`UnaryExpression`&&t.operator===`void`||t.type===`SequenceExpression`&&f.exists(c.last(t.expressions),t=>t!==e))}function Oe(e){return w(e.callee).pipe(f.map(c.lastNonEmpty),f.exists(h.endsWith(`Error`)))}function F(e,t){return c.containsWith(y.strictEqual())(e,t)}function I(e,t){return f.containsWith(y.strictEqual())(e,t)}function L(e,t,n){return a.findVariableUp(e.getScope(t),n)}function ke(e,t){return d.map(o.getScope(e),a.findVariableUp(t))}function Ae(e){return e.pipe(f.filter(({defs:e})=>e.length===1),f.flatMap(({defs:e})=>c.head(e)))}function R(e,t,n){return t.type===`Identifier`&&t.name===n&&!f.exists(a.findVariableUp(e,n),({defs:e})=>c.isArrayNonEmpty(e))}function je(e,t){return e.type===`Identifier`&&e.name===t?d.map(o.getScope(e),n=>R(n,e,t)):d.succeed(!1)}function z(e,t){return w(t).pipe(f.flatMap(n=>L(e,t,c.headNonEmpty(n))),f.exists(({defs:e})=>c.some(e,({type:e,node:t})=>e===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`))))}function Me(e){return d.map(d.service(i),({sourceCode:t})=>z(t,e))}const Ne=d.map(d.service(i),({sourceCode:e})=>new Set(c.flatMap(e.scopeManager.scopes,e=>[...c.map(e.variables,({name:e})=>e),...c.map(e.references,({identifier:e})=>e.name)]))),Pe=m.Array(m.String),Fe=g.dual(2,(e,t)=>e.length===2&&f.contains(c.head(e),t)?c.get(e,1):f.none());var Ie=class extends m.Class(`ImportBindings`)({bindings:m.ReadonlyMap(m.String,Pe),hasEffectImport:m.Boolean}){path(e){return f.flatMap(w(e),([e,...t])=>f.fromNullishOr(this.bindings.get(e)).pipe(f.map(e=>[...e,...t])))}isApi(e,t,n){let r=h.isString(n)?[n]:n;return f.exists(this.member(e,t),e=>c.contains(r,e))}member(e,t){return f.flatMap(this.path(e),Fe(t))}isApiPath(e,t){return f.exists(this.path(e),e=>c.makeEquivalence(h.Equivalence)(e,t))}};const Le=m.String.check(m.isPattern(/^(?:effect(?:\/.*)?|@effect\/.*)$/u)),Re=m.is(Le);function ze(e){let t=c.lastNonEmpty(h.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const Be=_.type().pipe(_.when(`alchemy`,()=>f.some([`Alchemy`])),_.when(`@alchemy.run/domain`,()=>f.some([`Domain`])),_.when(_.is(`effect`,`@effect/platform`),()=>f.some([])),_.whenOr(h.startsWith(`effect/`),h.startsWith(`alchemy/`),h.startsWith(`@effect/`),e=>f.some(ze(e))),_.orElse(()=>f.none()));function Ve(e,t){return c.map(e.specifiers,e=>v.make(e.local.name,e.type===`ImportSpecifier`?[...t,fe(e.imported)]:t))}function He(e){let t=c.filter(e.body,e=>e.type===`ImportDeclaration`);return Ie.make({bindings:new Map(c.flatMap(t,e=>f.match(Be(e.source.value),{onNone:()=>[],onSome:t=>Ve(e,t)}))),hasEffectImport:c.some(t,e=>Re(e.source.value))})}function Ue(e,t,n){let r=c.flatMap(e.ast.body,e=>e.type===`ImportDeclaration`&&c.contains(n,e.source.value)?e.specifiers:[]),i=f.flatMap(w(t),([e,...t])=>f.flatMap(c.findFirst(r,({local:t})=>t.name===e),e=>e.type===`ImportSpecifier`?c.isReadonlyArrayEmpty(t)?f.some(fe(e.imported)):f.none():t.length===1?c.head(t):f.none()));return f.filter(i,()=>z(e,t))}const B=d.map(d.service(i),e=>He(e.sourceCode.ast));function V(e){let{url:t,docs:n,...i}=e;return r.meta({schema:[],...i,docs:{recommended:!0,...t===void 0?{}:{url:t},...n}})}const We=m.Literals([`Aggregate`,`Api`,`Command`,`Event`,`ExternalSystem`,`Model`,`Policy`,`Projection`,`Rejection`,`RequestContext`,`Saga`,`Stream`,`View`]),Ge=m.is(We);function Ke(e,t,n){return f.exists(Ae(L(e,t,n)),({type:e})=>e===`ImportBinding`)}function qe(e,t){return w(e).pipe(f.filter(n=>Ke(t.sourceCode,e,c.headNonEmpty(n))),f.flatMap(()=>t.imports.path(e)))}function Je(e,t){return qe(e.callee,t).pipe(f.flatMap(Fe(`Domain`)),f.filter(Ge))}function Ye(e,t){let{parent:n}=e;return n.type===`MemberExpression`&&n.property===e&&!n.computed||n.type===`Property`&&n.key===e&&n.value!==e?!1:Ke(t,n,e.name)}function Xe(e){return b.isNotNull(e)&&se(e.type)?Xe(e.parent):e}function Ze(e,t){if(e.type!==`ObjectExpression`)return f.none();let n=Xe(e.parent);return n?.type===`CallExpression`&&f.exists(D(n,1),t=>O(t)===e)?Je(n,t):f.none()}function Qe(e,t){return f.flatMap(j(e),n=>{let r=n.type===`Property`&&n.value===e?Ze(n.parent,t):f.none();return f.match(r,{onNone:()=>Qe(n,t),onSome:e=>f.map(T(n),t=>({block:e,section:t}))})})}const $e={Aggregate:`aggregate`,Api:`api`,Command:`command`,ExternalSystem:`external`,Model:`model`,Policy:`policy`,Projection:`projection`,RequestContext:`context`,Saga:`saga`,Stream:`stream`,View:`view`},et={Event:`event`,Rejection:`rejection`},tt=m.is(m.Literals([`command`,`external`,`stream`])),nt=m.String.check(m.isPattern(/\.(?:test|spec|stories?)\.[cm]?[jt]sx?$/u)),rt=m.is(nt),it=r.define({name:`alchemy-domain-block-file-name`,meta:V({type:`suggestion`,description:"Require one Alchemy Domain block per file, named `<Noun>.<kind>.ts`.",messages:{fileName:"Declare this {{block}} in its own `<Noun>.{{kind}}.ts` file.",oneBlock:"Move this {{block}} to its own `<Noun>.{{kind}}.ts` file. Each file declares one Domain block."},url:`https://alchemy.run/domain`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*B},r=c.lastNonEmpty(h.split(e.filename,/[/\\]/u));if(rt(r))return{};let a=h.split(r,`.`),o=a.length>=3&&h.isNonEmpty(c.headNonEmpty(a))?c.get(a,a.length-2):f.none(),u=f.exists(o,tt),m=yield*p.make(!1),g=yield*p.make(!1);function _(e){return e.type===`CallExpression`?f.flatMap(Je(e,n),t=>l.get($e,t).pipe(f.orElse(()=>l.get(et,t)),f.map(n=>({node:e.callee,block:t,kind:n})))):f.none()}function v({block:e}){return u&&l.has(et,e)}function y(n,{node:r,block:i,kind:a}){return e.report(t.fromId({node:r,messageId:n,data:{block:i,kind:a}}))}let b=yield*s.accumulate(`CallExpression`,e=>f.filter(_(e),v),e=>d.flatMap(p.get(g),t=>t?d.void:d.forEach(e,e=>y(`fileName`,e),{concurrency:1,discard:!0}))),x=d.fnUntraced(function*(e){let t=f.contains(o,e.kind);t&&u&&(yield*p.set(g,!0)),(yield*p.getAndSet(m,!0))?yield*y(`oneBlock`,e):t||(yield*y(`fileName`,e))});return s.merge(b,s.on(`CallExpression`,e=>_(e).pipe(f.filter(e=>!v(e)),f.match({onNone:()=>d.void,onSome:x}))))}}),at={"Date.now":`time`,"performance.now":`time`,"performance.timeOrigin":`time`,"Math.random":`random`,"crypto.randomUUID":`random`,"crypto.getRandomValues":`random`},ot={Clock:`time`,Random:`random`,SecureRandom:`random`},st={"DateTime.now":`time`,"DateTime.nowAsDate":`time`,"DateTime.nowInCurrentZone":`time`,"DateTime.nowUnsafe":`time`,"DateTime.isFuture":`time`,"DateTime.isFutureUnsafe":`time`,"DateTime.isPast":`time`,"DateTime.isPastUnsafe":`time`,"Aead.Aead":`random`,"Cipher.Cipher":`random`,"Signature.Signature":`random`,"KeyAgreement.KeyAgreement":`random`,"KeyWrap.KeyWrap":`random`,"Jwk.generateKeyPair":`random`,"Jwk.generateSecret":`random`,"Jwe.encrypt":`random`,"Jws.sign":`random`,"Jws.verifyWithKeySet":`io`,"Jwt.sign":`random`,"Jwt.encrypt":`random`,"Jwt.verify":`time`,"Jwt.verifyWithKeySet":`time`,"Jwt.decrypt":`time`,"Jwks.Jwks":`io`,"Jwks.makeRemote":`io`,"Jwks.layerRemote":`io`},ct=m.is(m.Literals([`promise`,`tryPromise`]));function lt(e){let t=e;for(;t.type===`MemberExpression`||t.type===`ChainExpression`;)t=t.type===`ChainExpression`?t.expression:t.object;return t}const ut=r.define({name:`alchemy-domain-pure-decide`,meta:V({type:`problem`,description:`Require Alchemy Domain aggregate decide handlers to be pure.`,messages:{time:"`decide` reads time from its `now` argument, not {{api}}. Replays must decide the same way.",random:"`decide` must be deterministic, so it cannot use {{api}}. Take the value from the command input instead.",io:"`decide` never performs I/O such as {{api}}. Call external systems from a policy or saga and send the result as a command."},url:`https://alchemy.run/domain/aggregate`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*B};function r(t,n){return R(e.sourceCode.getScope(t),t,n)}function a(r,i,a){return i.pipe(f.filter(()=>f.exists(Qe(r,n),({section:e})=>e===`decide`)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:n,data:{api:a}}))}))}function o(e){return qe(e,n).pipe(f.filter(e=>e.length===2),f.match({onNone:()=>d.void,onSome:t=>{let n=c.join(t,`.`);return a(e,f.orElse(l.get(st,n),()=>f.flatMap(c.head(t),e=>l.get(ot,e))),n)}}))}function u(e){return e.type===`Identifier`?r(e,e.name)?f.some(e.name):f.none():e.type===`MemberExpression`&&r(e.object,`globalThis`)?w(e).pipe(f.filter(e=>e.length===2),f.flatMap(e=>c.get(e,1))):f.none()}return s.merge(s.on(`MemberExpression`,e=>{let t=f.getOrElse(w(e),()=>[]),n=c.head(t),i=f.contains(n,`globalThis`)?t.slice(1):t,s=lt(e);if(i.length!==2||!f.exists(n,e=>r(s,e)))return o(e);let u=c.join(i,`.`),d=e.parent.type===`CallExpression`&&e.parent.callee===e;return a(e,l.get(at,u),d?`${u}()`:u)}),s.on(`Identifier`,t=>Ye(t,e.sourceCode)?o(t):d.void),s.on(`NewExpression`,e=>c.isReadonlyArrayEmpty(e.arguments)&&f.contains(u(e.callee),`Date`)?a(e,f.some(`time`),`new Date()`):d.void),s.on(`CallExpression`,e=>_.value(f.getOrElse(u(e.callee),()=>``)).pipe(_.when(`Date`,()=>a(e,f.some(`time`),`Date()`)),_.when(`fetch`,()=>a(e,f.some(`io`),`fetch()`)),_.orElse(()=>qe(e.callee,n).pipe(f.flatMap(Fe(`Effect`)),f.filter(ct),f.match({onNone:()=>d.void,onSome:t=>a(e,f.some(`io`),`Effect.${t}`)}))))))}}),dt=m.String.check(m.isPattern(/\.(?:aggregate|api|command|context|event|external|id|middleware|model|policy|projection|rejection|saga|stream|view)\.[cm]?tsx?$/u)),ft=m.is(dt),pt=`@alchemy.run/domain`;function mt(e){return h.startsWith(`.`)(e)||e===`effect`||h.startsWith(`effect/`)(e)||e===pt||h.startsWith(`${pt}/`)(e)}function ht(e){return c.some(e.body,e=>e.type===`ImportDeclaration`&&e.source.value===pt)}const gt=r.define({name:`alchemy-domain-pure-imports`,meta:V({type:`problem`,description:"Restrict Alchemy Domain block files to imports from `@alchemy.run/domain`, `effect` and the domain package itself.",messages:{import:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, not `{{source}}`. Put code that touches infrastructure in the server package.",dynamic:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, so its import sources must be string literals."},url:`https://alchemy.run/domain`}),*create(){let e=yield*i;if(!ft(e.filename)||!ht(e.sourceCode.ast))return{};function n(n,r){return mt(r)?d.void:e.report(t.fromId({node:n,messageId:`import`,data:{source:r}}))}function r(e){return b.isNull(e.source)?d.void:n(e.source,e.source.value)}function a(r){return N(r)?n(r,r.value):e.report(t.fromId({node:r,messageId:`dynamic`}))}return s.merge(s.on(`ImportDeclaration`,r),s.on(`ExportAllDeclaration`,r),s.on(`ExportNamedDeclaration`,r),s.on(`ImportExpression`,e=>a(e.source)),s.on(`TSImportEqualsDeclaration`,e=>e.moduleReference.type===`TSExternalModuleReference`?a(e.moduleReference.expression):d.void),s.on(`CallExpression`,e=>f.match(D(e,0),{onNone:()=>d.void,onSome:t=>d.flatMap(je(e.callee,`require`),e=>e?a(t):d.void)})))}});function _t(e,t){return c.some(e.properties.slice(e.properties.indexOf(t)+1),e=>e.type===`SpreadElement`)}const vt=r.define({name:`alchemy-domain-require-view-version`,meta:V({type:`suggestion`,description:`Require Alchemy Domain views to declare their version.`,messages:{missing:"Declare `version` on this view (`version: 0` keeps the current default). Bump it whenever `evolve`, `emit`, `keyOf`, `state` or `from` changes, so the deploy rebuilds the view from its events.",overridden:"Move `version` after the spread, so the spread cannot override the version this view declares."},url:`https://alchemy.run/domain/model#change-a-view-bump-its-version`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*B};function r(n,r){return f.match(E(r,`version`),{onNone:()=>e.report(t.fromId({node:n.callee,messageId:`missing`})),onSome:n=>_t(r,n)?e.report(t.fromId({node:n,messageId:`overridden`})):d.void})}return s.on(`CallExpression`,e=>D(e,1).pipe(f.map(O),f.filter(e=>e.type===`ObjectExpression`),f.filter(()=>f.contains(Je(e,n),`View`)),f.match({onNone:()=>d.void,onSome:t=>r(e,t)})))}}),yt={Aggregate:[`evolve`,`reply`],View:[`evolve`]},bt=m.is(m.Literals([`Option`,`Result`])),xt=m.is(m.Literals([`getOrThrow`,`getOrThrowWith`])),St=r.define({name:`alchemy-domain-total-handlers`,meta:V({type:`problem`,description:`Require Alchemy Domain evolve and reply handlers to be total, and decide handlers to reject instead of throwing.`,messages:{partial:'`{{section}}` must be total and never fail: {{api}} throws when the state is not what it expects. Keep any state the event cannot follow, such as `s._tag === "Open" ? { ...s, ... } : s`.',reject:"`decide` never throws: {{api}} becomes a defect the caller cannot handle. Return a rejection the command lists in `rejects` instead, or `return yield* rejection` in an `Effect.fn`."},url:`https://alchemy.run/domain/aggregate`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*B};function r(r,i){return f.match(Qe(r,n),{onNone:()=>d.void,onSome:({block:n,section:a})=>n===`Aggregate`&&a===`decide`?e.report(t.fromId({node:r,messageId:`reject`,data:{api:i}})):f.exists(l.get(yt,n),c.contains(a))?e.report(t.fromId({node:r,messageId:`partial`,data:{section:a,api:i}})):d.void})}function a(e){return qe(e,n).pipe(f.filter(e=>e.length===2&&f.exists(c.head(e),bt)&&f.exists(c.get(e,1),xt)),f.match({onNone:()=>d.void,onSome:t=>r(e,`\`${c.join(t,`.`)}\``)}))}return s.merge(s.on(`ThrowStatement`,e=>r(e,"`throw`")),s.on(`MemberExpression`,a),s.on(`Identifier`,t=>Ye(t,e.sourceCode)?a(t):d.void))}}),Ct=m.Literals([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),wt=m.is(Ct),Tt=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Et(e,t){return c.some(Tt,n=>t.isApiPath(e,n))}function Dt(e,t){return Ce(e,e=>e.type===`CallExpression`&&Et(e.callee,t))}function Ot(e,t){return we(e).pipe(f.flatMap(Te),f.filter(e=>t.isApi(e.callee,`Effect`,`gen`)))}function kt(e){return f.flatMap(j(e),e=>{if(A(e))return f.none();let t=e.type===`Property`?f.filter(T(e),wt):f.none();return f.orElse(t,()=>kt(e))})}const At=r.define({name:`alchemy-no-cloudflare-init-finalizer`,meta:V({type:`problem`,description:`Disallow finalizers in Cloudflare Worker initialization, where workerd never runs them.`,messages:{finalizer:`A Cloudflare Worker init finalizer never runs because workerd has no isolate teardown hook. Acquire disposable resources inside an event handler.`},url:`https://alchemy.run/cloudflare/compute/workers`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`addFinalizer`)&&f.exists(Ot(r,n),e=>f.exists(Dt(e,n),t=>F(t.arguments,e)))?e.report(t.fromId({node:r,messageId:`finalizer`})):d.void)}});function jt(e,t,n){let r=c.flatMap(t.body,e=>e.type===`ImportDeclaration`&&e.source.value===n&&e.importKind!==`type`?c.filter(e.specifiers,e=>e.type===`ImportNamespaceSpecifier`):[]);return d.map(d.filter(r,t=>d.map(ke(e,t.local.name),e=>f.exists(e,({defs:e})=>c.some(e,e=>e.node===t)))),e=>f.map(c.head(e),e=>e.local.name))}function Mt(e,t,n=1){let r=n===1?e:`${e}${n}`;return t.has(r)?Mt(e,t,n+1):r}function Nt(e,n){return f.match(c.findFirst(e.body,e=>e.type!==`ExpressionStatement`||!N(e.expression)),{onNone:()=>t.insertAfter(e,`\n${n}`),onSome:e=>t=>t.insertTextBefore(e,n)})}const Pt=d.fn(`namespaceImport`)(function*(e,t,n){let{sourceCode:r}=yield*i,a=r.ast,o=yield*jt(e,a,t);if(f.isSome(o))return{name:o.value,fix:f.none()};let s=Mt(n,yield*Ne);return{name:s,fix:f.some(Nt(a,`import * as ${s} from '${t}';\n`))}}),Ft=d.fn(`replaceWithNamespace`)(function*(e,n,r,i){let a=yield*Pt(e,n,r);return t.composeFixes(...f.toArray(a.fix),t.replaceText(e,i(a.name)))});function H(e,t){let n=e.getText(t);return t.type===`SequenceExpression`?`(${n})`:n}function It(e,t){let n=c.map(e.properties,e=>pe(e).pipe(f.filter(e=>e.key.type===`Identifier`||e.key.type===`Literal`),f.flatMap(e=>e.key.type===`Literal`?f.some(String(e.key.value)):T(e)))),r=c.getSomes(n);return r.length===n.length&&!c.contains(r,t)&&c.dedupe(r).length===r.length}function Lt(e,n){return f.match(n,{onNone:()=>e,onSome:n=>t.withFix(e,n)})}const Rt=r.define({name:`alchemy-no-deprecated-docker-constraints`,meta:V({type:`problem`,description:`Disallow the deprecated top-level Docker Service constraints property.`,messages:{constraints:`Docker.Service constraints is deprecated. Move it to placement: { constraints: ... }.`},url:`https://alchemy.run/providers/docker/service`,fixable:`code`}),*create(){let e=yield*i,n=yield*B,r=d.fnUntraced(function*(n,r,i){let a=yield*Me(n.callee),o=f.liftPredicate(t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`),()=>a&&It(r,`placement`));yield*e.report(Lt(t.fromId({node:i,messageId:`constraints`}),o))});return s.on(`CallExpression`,e=>n.isApi(e.callee,`Docker`,`Service`)?f.filter(D(e,1),e=>e.type===`ObjectExpression`).pipe(f.flatMap(e=>f.map(E(e,`constraints`),t=>[e,t])),f.match({onNone:()=>d.void,onSome:([t,n])=>r(e,t,n)})):d.void)}}),zt={"Cloudflare.Access.Bookmark":`Cloudflare.Access.Application with type: "bookmark"`,"AWS.RDSData.ExecuteSql":`AWS.RDSData.ExecuteStatement`,"AWS.EKS.Deployment":`Kubernetes.Deployment from alchemy/Kubernetes`,"AWS.EKS.HelmChart":`Kubernetes.HelmChart from alchemy/Kubernetes`,"AWS.EKS.Job":`Kubernetes.Job from alchemy/Kubernetes`,"AWS.EKS.Manifest":`Kubernetes.Manifest from alchemy/Kubernetes`},Bt=r.define({name:`alchemy-no-deprecated-resource`,meta:V({type:`problem`,description:`Disallow deprecated Alchemy resource APIs that have supported replacements.`,messages:{deprecated:`{{api}} is deprecated. Use {{replacement}}.`},url:`https://alchemy.run/llms-full.txt`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.path(r.callee).pipe(f.flatMap(e=>{let t=c.join(e,`.`);return f.map(l.get(zt,t),e=>({api:t,replacement:e}))}),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r.callee,messageId:`deprecated`,data:n}))})))}});function Vt(e,t){let n=O(e);return N(n)||n.type===`TemplateLiteral`||f.exists(w(n),([e,t])=>e===`process`&&t===`env`)||n.type===`CallExpression`&&t.isApi(n.callee,`Config`,`string`)}const Ht=r.define({name:`alchemy-no-plaintext-github-secret`,meta:V({type:`problem`,description:`Require singular GitHub Secret values to use Redacted.`,messages:{plaintext:`GitHub.Secret value must be Redacted so it stays out of logs and state. Use Redacted.make(...) or Config.redacted(...).`},url:`https://alchemy.run/providers/github/secret`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>D(r,1).pipe(f.filter(()=>n.isApi(r.callee,`GitHub`,`Secret`)),f.filter(e=>e.type===`ObjectExpression`),f.flatMap(E(`value`)),f.map(({value:e})=>e),f.filter(e=>Vt(e,n)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`plaintext`}))})))}}),Ut=m.is(m.Literals([`Secret`,`Variable`])),Wt=r.define({name:`alchemy-no-removed-config-api`,meta:V({type:`problem`,description:`Disallow removed Alchemy Secret and Variable APIs.`,messages:{removed:`Alchemy.{{api}} was removed. Use effect/Config (Config.redacted for secrets, Config.string for variables).`},url:`https://alchemy.run/blog/2026-05-29-beta-45`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.path(r.callee).pipe(f.filter(e=>f.contains(c.head(e),`Alchemy`)),f.flatMap(e=>c.get(e,1)),f.filter(Ut),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r.callee,messageId:`removed`,data:{api:n}}))})))}}),Gt=r.define({name:`alchemy-no-reserved-eventbridge-default-name`,meta:V({type:`problem`,description:`Disallow creating an EventBridge bus with the reserved default name.`,messages:{reserved:`EventBridge reserves the name "default". Omit the bus argument to use the account default, or choose another name.`},url:`https://alchemy.run/aws/messaging/eventbridge`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>D(r,1).pipe(f.filter(()=>n.isApiPath(r.callee,[`AWS`,`EventBridge`,`EventBus`])),f.filter(e=>e.type===`ObjectExpression`),f.flatMap(E(`name`)),f.map(({value:e})=>e),f.filter(P(`default`)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`reserved`}))})))}}),Kt=r.define({name:`alchemy-no-runtime-config`,meta:V({type:`problem`,description:`Require Effect Config values to be resolved during Alchemy Worker initialization.`,messages:{runtime:`Config resolved inside the {{handler}} handler is invisible to Alchemy deployment. Resolve it in Worker init and close over the value, or put it in env.`},url:`https://alchemy.run/environments/secrets`}),*create(){let e=yield*i,n=yield*B;return s.on(`YieldExpression`,r=>{let i=r.argument;if(i?.type!==`CallExpression`||!f.exists(n.path(i.callee),([e])=>e===`Config`))return d.void;let a=f.flatMap(Ot(r,n),e=>f.filter(kt(e),()=>f.isSome(Dt(e,n))));return f.match(a,{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:i,messageId:`runtime`,data:{handler:n}}))})})}}),qt={"alchemy/aws":`alchemy/AWS`,"alchemy/cloudflare":`alchemy/Cloudflare`},Jt=r.define({name:`alchemy-no-v1-import`,meta:V({type:`problem`,description:`Disallow Alchemy v1 imports that bypass the Effect-based Stack API.`,messages:{defaultImport:`The default alchemy() API is from v1. Use import * as Alchemy and Alchemy.Stack.`,providerImport:`Use the v2 provider entrypoint {{replacement}} (capitalization is significant).`},url:`https://alchemy.run/migrating-from-v1`}),*create(){let e=yield*i;function n(n,r,i){return e.report(t.fromId({node:n,messageId:r,...b.isUndefined(i)?{}:{data:i}}))}return s.on(`ImportDeclaration`,e=>{let t=e.source.value,r=t===`alchemy`?f.map(c.findFirst(e.specifiers,e=>e.type===`ImportDefaultSpecifier`),e=>n(e,`defaultImport`)):f.map(l.get(qt,t),t=>n(e.source,`providerImport`,{replacement:t}));return f.getOrElse(r,()=>d.void)})}}),Yt=[[`entrypoint`,`main`],[`bindings`,`env`]],Xt=r.define({name:`alchemy-no-v1-worker-properties`,meta:V({type:`problem`,description:`Disallow Alchemy v1 Cloudflare Worker property names.`,messages:{property:`Cloudflare.Worker {{old}} was replaced in v2. Use {{replacement}}.`},url:`https://alchemy.run/migrating-from-v1`,fixable:`code`}),*create(){let e=yield*i,n=yield*B,r=d.fnUntraced(function*(n,r){let i=yield*Me(n.callee),a=c.flatMap(Yt,([e,t])=>E(r,e).pipe(f.map(n=>({old:e,replacement:t,property:n})),f.toArray));yield*d.forEach(a,({old:n,replacement:a,property:o})=>e.report(Lt(t.fromId({node:o,messageId:`property`,data:{old:n,replacement:a}}),f.liftPredicate(t.replaceText(o.key,o.shorthand?`${a}: ${n}`:a),()=>i&&It(r,a)))),{concurrency:1,discard:!0})});return s.on(`CallExpression`,e=>D(e,1).pipe(f.filter(()=>Et(e.callee,n)),f.filter(e=>e.type===`ObjectExpression`),f.match({onNone:()=>d.void,onSome:t=>r(e,t)})))}}),Zt=r.define({name:`avoid-data-tagged-error`,meta:V({type:`suggestion`,description:`Prefer schema-based tagged errors so errors have a serializable contract.`,messages:{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Data`,`TaggedError`)?e.report(t.fromId({node:r.callee,messageId:`taggedError`})):d.void)}}),Qt=m.Literals([`error`,`err`,`e`,`cause`,`exception`,`ex`]),$t=m.is(Qt);function en(e){return e?.type===`Identifier`&&$t(e.name)?f.some(e.name):f.none()}function tn(e){return e.arguments.length===1&&f.exists(w(e.callee),e=>c.lastNonEmpty(e)===`String`&&e.length<=2)}function nn(e){return f.exists(M(e,`NewExpression`),t=>I(c.head(t.arguments),e)&&Oe(t))}function rn(e){return tn(e)?nn(e)?f.none():f.flatMap(c.head(e.arguments),en):e.callee.type===`MemberExpression`&&c.isReadonlyArrayEmpty(e.arguments)&&f.exists(w(e.callee),e=>c.lastNonEmpty(e)===`toString`)?en(e.callee.object):f.none()}function an(e){let[t,n]=e.quasis;return e.quasis.length===2&&t?.value.raw===``&&n?.value.raw===``?f.flatMap(c.head(e.expressions),en):f.none()}const on=r.define({name:`ban-error-string`,meta:V({type:`problem`,description:`Disallow string coercion that discards an error value’s stack, type, and cause chain.`,messages:{errorString:`Do not stringify {{name}}. Preserve the original error as an Error cause instead.`,useCause:`Replace {{pattern}} with {{replacement}} to preserve the original error.`},hasSuggestions:!0}),*create(){let e=yield*i;function n(n,r){return f.match(r,{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`errorString`,data:{name:r}}))})}function r(n,r){let i=e.sourceCode.getText(r),a=`'Error occurred', { cause: ${i} }`;return e.report(t.withSuggestions(t.fromId({node:n,messageId:`errorString`,data:{name:i}}),[{messageId:`useCause`,data:{pattern:e.sourceCode.getText(n),replacement:a},fix:t.replaceText(n,a)}]))}return s.merge(s.on(`NewExpression`,e=>D(e,0).pipe(f.filter(t=>t.type===`CallExpression`&&tn(t)&&Oe(e)),f.match({onNone:()=>d.void,onSome:e=>f.match(D(e,0),{onNone:()=>d.void,onSome:t=>r(e,t)})}))),s.on(`CallExpression`,e=>n(e,rn(e))),s.on(`TemplateLiteral`,e=>n(e,an(e))))}}),sn=m.is(m.Literals(/* @__PURE__ */ `flip.fromFormData.fromJsonString.fromURLSearchParams.mutable.mutableKey.NullishOr.NullOr.optional.optionalKey.OptionFromNullishOr.OptionFromNullOr.OptionFromOptional.OptionFromOptionalKey.OptionFromOptionalNullOr.OptionFromUndefinedOr.readonlyKey.RedactedFromValue.required.requiredKey.toCodecArrayFromSingle.toCodecGoJson.toCodecIso.toCodecJson.toCodecStringTree.toEncoded.toType.UndefinedOr`.split(`.`))),cn=m.is(m.Literals([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`])),ln=m.is(m.Literals(/* @__PURE__ */ `annotate.annotateEncoded.annotateKey.brand.catchDecoding.catchDecodingWithContext.catchEncoding.catchEncodingWithContext.check.decode.decodeTo.encode.encodeKeys.encodeTo.extendTo.fieldsAssign.fromBrand.middlewareDecoding.middlewareEncoding.overrideToCodecIso.overrideToEquivalence.overrideToFormatter.refine.toTaggedUnion.withConstructorDefault.withDecodingDefault.withDecodingDefaultKey.withDecodingDefaultType.withDecodingDefaultTypeKey`.split(`.`))),un=m.is(m.Literals([`annotate`,`annotateKey`,`check`,`mapFields`])),dn=m.is(m.Literals([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`])),fn=m.is(m.Literals([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`])),pn=m.String.check(m.isPattern(/^\p{Lu}/u)),mn=m.is(pn);function hn(e){return sn(e)||cn(e)}function gn(e,t){return f.filter(t.imports.member(e,`Schema`),()=>f.exists(w(e),e=>e.length===2)&&z(t.sourceCode,e))}function _n(e,t){return c.every(e,e=>b.isNull(e)||U(e,t))}function U(e,t){return fn(e.type)||_.value(e).pipe(_.discriminators(`type`)({MemberExpression:({object:e,computed:n,property:r})=>U(e,t)&&(!n||U(r,t)),TemplateLiteral:({expressions:e})=>_n(e,t),ArrayExpression:({elements:e})=>_n(e,t),ObjectExpression:({properties:e})=>c.every(e,e=>e.type===`SpreadElement`?U(e.argument,t):(!e.computed||U(e.key,t))&&U(e.value,t)),CallExpression:e=>{let n=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return f.isSome(gn(n,t))&&(e.callee===n||U(e.callee,t))&&_n(e.arguments,t)}}),_.orElse(g.constFalse))}function vn(e,t){return e.type===`Identifier`?f.fromNullishOr(t.bindings.get(e.name)):e.type===`TSQualifiedName`?f.map(vn(e.left,t),t=>[...t,e.right.name]):f.none()}function yn(e,t){return j(t).pipe(f.flatMap(t=>{let n=`typeParameters`in t&&t.typeParameters?.type===`TSTypeParameterDeclaration`?c.findFirst(t.typeParameters.params,t=>t.name.name===e):f.none();return f.orElse(n,()=>yn(e,t))}))}function bn(e,t,n,r=[]){let i=c.isReadonlyArrayEmpty(r)?f.none():f.some(!1);if(e?.type!==`TSTypeReference`)return i;let a=f.flatMap(vn(e.typeName,n),Fe(`Schema`));if(f.isSome(a))return f.some(!h.startsWith(`Constraint`)(a.value));let{typeName:o}=e,s=f.filter(o.type===`Identifier`?yn(o.name,t):f.none(),e=>!F(r,e));return f.match(s,{onNone:()=>i,onSome:e=>bn(e.constraint,e,n,[...r,e])})}function xn(e,t){return L(t.sourceCode,e,e.name).pipe(f.flatMap(({defs:e})=>c.head(e)),f.flatMapNullishOr(({name:e})=>`typeAnnotation`in e?e.typeAnnotation:void 0))}function Sn(e){return e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`?Sn(e.expression):e}function Cn(e,t){let n=Sn(e);return n.type===`TSAsExpression`?f.contains(bn(n.typeAnnotation,n,t.imports),!1):f.exists(n.type===`Identifier`?xn(n,t):f.none(),e=>f.contains(bn(e.typeAnnotation,e,t.imports),!1))}function wn(e){return c.some(e.arguments,e=>e.type===`SpreadElement`)}function Tn(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&f.contains(C(e.callee),`pipe`)&&!e.typeArguments&&!wn(e)}function En(e,t){return(t.imports.isApiPath(e.callee,[`pipe`])||t.imports.isApiPath(e.callee,[`Function`,`pipe`]))&&z(t.sourceCode,e.callee)}function Dn(e,t){return f.exists(gn(e,t),hn)||e.type===`CallExpression`&&f.exists(gn(e.callee,t),ln)}function On(e,t){return f.exists(gn(e,t),mn)||f.isSome(Nn(e,t))?!0:e.type===`CallExpression`&&f.match(gn(e.callee,t),{onSome:e=>mn(e)||hn(e),onNone:()=>e.callee.type===`MemberExpression`&&f.exists(C(e.callee),un)&&On(e.callee.object,t)})}function kn(e,t){let[n,r]=e.arguments;return b.isUndefined(n)||b.isUndefined(r)||n.type===`SpreadElement`||e.typeArguments||wn(e)||!On(n,t)&&!Dn(r,t)?f.none():f.some([n,e.arguments.slice(1)])}function An(e,t,n,r,i){let a=Pn(e,i);return{head:a.head,steps:[...a.steps,...t],violation:f.orElse(a.violation,()=>n),reordersEffects:a.reordersEffects||r}}function jn(e,t){let n=e.arguments.length===1&&!e.typeArguments?D(e,0):f.none();return f.flatMap(n,n=>{let r={text:t.sourceCode.getText(e.callee),wrapper:!1};function i(){return(e.callee.type===`CallExpression`?gn(e.callee.callee,t):f.none()).pipe(f.filter(ln),f.map(i=>An(n,[r],f.some({kind:`dataLastCall`,name:i}),!U(e.callee,t)&&!U(n,t),t)))}return gn(e.callee,t).pipe(f.filter(hn),f.match({onNone:i,onSome:e=>{let i=cn(e);return f.some(An(n,[u.assign(r,{wrapper:i})],i?f.none():f.some({kind:`modifierCall`,name:e}),!1,t))}}))})}function Mn(e,t){let n=En(e,t),r=n?kn(e,t):Tn(e)?f.some([e.callee.object,e.arguments]):f.none();return f.map(r,([e,r])=>{let i=c.map(r,e=>gn(e,t)),a=c.findFirstIndex(i,f.exists(cn)),o=f.exists(a,e=>c.some(r.slice(e+1),e=>!U(e,t))),s=n?f.some({kind:`functionPipe`}):a.pipe(f.flatMap(e=>f.flatten(c.get(i,e))),f.map(e=>({kind:`wrapperPipe`,name:e})));return An(e,c.map(r,(e,n)=>({text:t.sourceCode.getText(e),wrapper:c.get(i,n).pipe(f.flatten,f.exists(cn))})),s,o,t)})}function Nn(e,t){return e.type===`CallExpression`?f.orElse(jn(e,t),()=>Mn(e,t)):f.none()}function Pn(e,t){return f.getOrElse(Nn(e,t),()=>({head:e,steps:[],violation:f.none(),reordersEffects:!1}))}function Fn(e,t){let n=e.parent;return n.type===`MemberExpression`&&n.object===e&&n.parent.type===`CallExpression`?n.parent.callee===n&&Tn(n.parent):n.type===`CallExpression`&&I(D(n,0),e)&&(En(n,t)||!Tn(n))&&f.isSome(Nn(n,t))}function In(e,t,n){return c.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!dn(n.type)?`(\0)`:e}.pipe(${c.join(t,`, `)})`:e}function Ln(e,t){let{target:n,pending:r}=c.reduce(t,{target:`\0`,pending:[]},({target:t,pending:n},r)=>{if(!r.wrapper)return{target:t,pending:[...n,r.text]};let i=In(t,n,e),a=i===`\0`&&e.type===`SequenceExpression`?`(${i})`:i;return{target:`${r.text}(${a})`,pending:[]}});return In(n,r,e)}const Rn=r.define({name:`consistent-schema-pipe`,meta:V({type:`suggestion`,description:"Apply Schema modifiers with `.pipe(...)` and call Schema wrappers directly.",messages:{modifierCall:"Apply Schema.{{name}} with `.pipe(...)` instead of calling it.",dataLastCall:"Apply Schema.{{name}}(...) with `.pipe(...)` instead of calling it on the schema.",functionPipe:"Call `.pipe(...)` on the schema instead of passing it to `pipe(...)`.",wrapperPipe:`Call Schema.{{name}}(...) directly instead of piping into it.`},url:`https://github.com/2digits-agency/configs/blob/main/docs/adr/0001-schema-modifiers-pipe-wrappers-call.md`,fixable:`code`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r={sourceCode:e.sourceCode,imports:n};function a(n,r,i){let{head:a}=r,o=c.some(e.sourceCode.getCommentsInside(n),e=>!Ee(a,e)),[s,l=``]=h.split(Ln(a,r.steps),`\0`),u=t.fromId({node:n,messageId:i.kind,data:{name:i.name??``}});return e.report(o||r.reordersEffects?u:t.withFix(u,t.composeFixes(e=>e.replaceTextRange([v.get(n.range,0),v.get(a.range,0)],s),e=>e.replaceTextRange([v.get(a.range,1),v.get(n.range,1)],l))))}return s.on(`CallExpression`,e=>f.filter(Nn(e,r),({head:e,steps:t})=>!f.exists(c.head(t),({wrapper:e})=>!e)||!Cn(e,r)).pipe(f.flatMap(e=>f.map(e.violation,t=>[e,t])),f.filter(()=>!Fn(e,r)),f.match({onNone:()=>d.void,onSome:([t,n])=>a(e,t,n)})))}});function zn(e){let t=O(e);return P(t,`*`)||t.type===`ArrayExpression`&&(c.isReadonlyArrayEmpty(t.elements)||c.some(t.elements,e=>b.isNotNull(e)&&P(e,`*`)))}function Bn(e,t){return t.isApi(e,`HttpMiddleware`,`cors`)||t.isApi(e,`HttpRouter`,`cors`)||t.isApi(e,`HttpApiBuilder`,`middlewareCors`)}function Vn(e){let t=E(e,`credentials`).pipe(f.match({onSome:({value:e})=>e,onNone:()=>e}));return P(t,!0)&&f.match(E(e,`allowedOrigins`),{onNone:()=>!0,onSome:({value:e})=>zn(e)})}const Hn=r.define({name:`cors-credentials-with-wildcard`,meta:V({type:`problem`,description:`Disallow credentialed CORS with wildcard origins because browsers reject that combination.`,messages:{wildcard:`Credentialed CORS cannot use a wildcard origin. Set allowedOrigins to explicit trusted origins or disable credentials.`},url:`https://github.com/Effect-TS/tsgo/issues/400`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>Bn(r.callee,n)&&f.exists(me(r),Vn)?e.report(t.fromId({node:r,messageId:`wildcard`})):d.void)}});function Un(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const Wn=r.define({name:`dual-numeric-arity-with-optional-parameter`,meta:V({type:`problem`,description:`Disallow numeric dual arity with optional or rest parameters because dispatch becomes ambiguous.`,messages:{unsafeArity:`Function.dual with numeric arity misdispatches an implementation with optional/default/rest parameters. Use predicate dispatch.`},url:`https://github.com/Effect-TS/tsgo/issues/401`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Function`,`dual`)?D(r,0).pipe(f.filter(e=>e.type===`Literal`&&b.isNumber(e.value)&&f.exists(D(r,1),e=>A(e)&&c.some(e.params,Un))),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`unsafeArity`}))})):d.void)}}),Gn=r.define({name:`effect-promise-vs-trypromise`,meta:V({type:`problem`,description:`Require Effect.tryPromise so Promise rejections enter the typed error channel.`,messages:{tryPromise:`Use Effect.tryPromise instead of Effect.promise so rejections are typed failures.`}}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`promise`)?e.report(t.fromId({node:r.callee,messageId:`tryPromise`})):d.void)}});function Kn(e,t){return _.value(e.parent).pipe(_.withReturnType(),_.when({type:`Property`,parent:{type:`ObjectExpression`,parent:{type:`CallExpression`}}},e=>f.contains(T(e),t)?f.some(e.parent.parent):f.none()),_.orElse(()=>f.none()))}function qn(e,t){return f.flatMap(Te(e),e=>t.path(e.callee))}function Jn(e){return e.type===`CallExpression`?Jn(e.callee):e}function Yn(e,t){let n=e.parent.type===`Property`&&e.parent.value===e?e.parent.parent:e;return j(n).pipe(f.filter(e=>(e.type===`CallExpression`||e.type===`NewExpression`)&&F(e.arguments,n)),f.exists(e=>f.isNone(t.path(Jn(e.callee)))))}const Xn=m.Literals([`catch`,`finally`,`then`]),Zn=m.is(Xn),Qn=_.type().pipe(_.discriminators(`type`)({CallExpression:({callee:e})=>f.exists(w(e),e=>c.join(e,`.`)===`fetch`||c.headNonEmpty(e)===`Promise`&&e[1]!==`withResolvers`||Zn(c.lastNonEmpty(e)))||A(e)&&e.async,NewExpression:({callee:e})=>f.exists(w(e),e=>c.join(e,`.`)===`Promise`)}),_.orElse(g.constFalse));function $n(e){return Qn(O(e))}function W(e){return f.fromNullishOr(e.body).pipe(f.flatMap(e=>e.type===`BlockStatement`?c.head(e.body).pipe(f.filter(()=>e.body.length===1),f.flatMapNullishOr(e=>e.type===`ReturnStatement`?e.argument:void 0),f.map(O)):f.some(O(e))))}function er(e){return e.pipe(f.flatMap(e=>e.type===`ObjectExpression`?f.map(E(e,`try`),({value:e})=>e):f.some(e)),f.filter(A))}const tr=r.define({name:`no-already-started-promise`,meta:V({type:`problem`,description:`Ensure Effect Promise thunks start fresh asynchronous work rather than reusing an already-started Promise.`,messages:{prestarted:`This thunk returns an already-started Promise. Start the asynchronous work inside the thunk so retries and repeats run it again.`},url:`https://github.com/Effect-TS/tsgo/issues/475`}),*create(){let e=yield*i,n=yield*B,r=yield*p.make(x.empty());return s.merge(s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&$n(e.init)?p.update(r,x.add(e.id.name)):d.void),s.on(`CallExpression`,i=>d.gen(function*(){if(!n.isApi(i.callee,`Effect`,[`promise`,`tryPromise`]))return;let a=f.flatMap(er(D(i,0)),W);if(f.isNone(a)||a.value.type!==`Identifier`)return;let o=yield*p.get(r);x.has(o,a.value.name)&&(yield*e.report(t.fromId({node:a.value,messageId:`prestarted`})))})))}}),nr=r.define({name:`no-async-effect-try`,meta:V({type:`problem`,description:`Disallow async thunks in Effect.try because rejected Promises bypass its catch mapper.`,messages:{asyncTry:`Effect.try does not await Promises. Use Effect.tryPromise so rejection enters the typed error channel.`},url:`https://github.com/Effect-TS/tsgo/issues/657`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`try`)?D(r,0).pipe(f.flatMap(e=>A(e)?f.some(e):e.type===`ObjectExpression`?E(e,`try`).pipe(f.map(({value:e})=>e),f.filter(A)):f.none()),f.filter(e=>e.async||f.exists(W(e),$n)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`asyncTry`}))})):d.void)}}),rr=r.define({name:`no-discarded-run-promise`,meta:V({type:`problem`,description:`Disallow discarded Effect.runPromise results that can become unhandled rejections.`,messages:{discarded:`The Promise returned by Effect.runPromise is discarded. Await/return/handle it, or use Effect.runFork for fire-and-forget work.`},url:`https://github.com/Effect-TS/tsgo/issues/643`}),*create(){let e=yield*i,n=yield*B;function r(e){return n.isApi(e,`Effect`,`runPromise`)||e.type===`CallExpression`&&n.isApi(e.callee,`Effect`,`runPromiseWith`)}return s.on(`CallExpression`,n=>r(n.callee)&&De(n)?e.report(t.fromId({node:n,messageId:`discarded`})):d.void)}}),ir=m.Literals([`mapElements`,`mapFields`,`mapMembers`]),ar=m.is(ir);function or(e,t){let n=O(e);return n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&f.contains(C(n.callee),t)}function sr(e){return e.callee.type!==`MemberExpression`||!or(e.callee.object,`check`)||me(e).pipe(f.flatMap(E(`unsafePreserveChecks`)),f.exists(e=>P(e.value,!0)))?f.none():f.filter(C(e.callee),ar)}const cr=r.define({name:`no-discarded-schema-checks`,meta:V({type:`problem`,description:`Disallow schema mapping that silently drops checks attached to the receiver.`,messages:{discarded:`{{method}} creates a new schema and drops the preceding check. Re-attach the check after mapping or explicitly preserve it.`},url:`https://github.com/Effect-TS/tsgo/issues/435`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.on(`CallExpression`,n=>f.match(sr(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`discarded`,data:{method:r}}))})):{}}}),lr={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},ur=m.String.check(m.isPattern(/^\p{Lu}[^_]*$/u)),dr=m.is(ur),fr=m.String.check(m.isPattern(/^@effect\/vitest(?:\/.*)?$/u)),pr=m.is(fr),mr=m.String.check(m.isPattern(/^@effect\/[^/]+$/u)),hr=m.is(mr),gr=m.String.check(m.isPattern(/^@effect\/[^/]+\//u)),_r=m.is(gr);function vr(e,t){return e.importKind===`type`||t?.importKind===`type`}function yr(e){return f.getOrElse(l.get(lr,e),()=>e)}function br(e,t){return _.value(e).pipe(_.when(_.is(`effect`,`alchemy`),()=>f.some(`${e}/${t}`)),_.when(e=>hr(e)&&!pr(e),()=>f.some(`${e}/${t}`)),_.orElse(()=>f.none()))}function xr(e){return!pr(e)&&(h.startsWith(`effect/`)(e)||h.startsWith(`alchemy/`)(e)||_r(e))?f.liftPredicate(c.lastNonEmpty(h.split(e,`/`)),dr):f.none()}function Sr(e,n){let r=n.specifiers;if(c.isReadonlyArrayNonEmpty(e.getCommentsInside(n))||c.isReadonlyArrayNonEmpty(n.attributes)||!c.every(r,e=>e.type===`ImportSpecifier`))return f.none();let[i,a]=c.partition(r,t=>{let r=fe(t.imported),i=dr(r)&&!vr(n,t)?br(n.source.value,r):f.none();return f.match(i,{onNone:()=>ee.fail(e.getText(t)),onSome:e=>ee.succeed(`import * as ${t.local.name} from '${e}';`)})}),o=c.isReadonlyArrayNonEmpty(a)?c.prepend(i,`import { ${c.join(a,`, `)} } from ${e.getText(n.source)};`):i;return f.some(t.replaceText(n,c.join(o,`
|
|
2
|
-
`)))}function Cr(e,n,r){let i=c.dedupeWith(e.references,(e,t)=>v.get(e.identifier.range,0)===v.get(t.identifier.range,0));return f.all(c.map(i,e=>{let i=e.identifier,a=i.parent;if(e.isWrite()||a.type===`ExportSpecifier`||h.startsWith(`JSX`)(a.type))return f.none();let o=a.type===`CallExpression`&&a.callee===i||a.type===`TaggedTemplateExpression`&&a.tag===i,s=r&&o?`(0, ${n})`:a.type===`Property`&&a.shorthand?`${i.name}: ${n}`:n;return f.some(t.replaceText(i,s))}))}function wr(e,t,n){return f.flatMap(c.findFirst(t,t=>t.name===e.local.name),t=>e.type===`ImportNamespaceSpecifier`?Cr(t,n,!1):e.imported.type===`Identifier`?Cr(t,`${n}.${e.imported.name}`,!0):f.none())}function Tr(e,t,n){function r(e){return I(n,e)}return!c.some(e.scopeManager.scopes,e=>c.some(e.variables,e=>e.name===t&&!r(e))||c.some(e.references,e=>e.identifier.name===t&&!r(e.resolved)))}function Er(e,n){return f.flatMap(xr(n.source.value),r=>{if(c.isReadonlyArrayNonEmpty(n.attributes)||c.isReadonlyArrayNonEmpty(e.getCommentsInside(n)))return f.none();let i=yr(r),a=e.getDeclaredVariables(n);if(!Tr(e,i,c.findFirst(a,e=>e.name===i)))return f.none();let o=c.filter(n.specifiers,e=>e.type===`ImportSpecifier`&&vr(n,e));if(c.some(n.specifiers,e=>e.type===`ImportDefaultSpecifier`)||c.some(o,e=>e.local.name===i))return f.none();let s=c.filter(n.specifiers,e=>e.type!==`ImportDefaultSpecifier`&&!F(o,e));return f.all(c.map(s,e=>wr(e,a,i))).pipe(f.map(r=>{let a=e.getText(n.source),s=c.isReadonlyArrayEmpty(o)?``:`\nimport { ${c.join(c.map(o,t=>e.getText(t)),`, `)} } from ${a};`;return t.composeFixes(t.replaceText(n,`import * as ${i} from ${a};${s}`),...c.flatten(r))}))})}const Dr=r.define({name:`no-effect-alchemy-barrel-imports`,meta:V({type:`suggestion`,description:`Import Effect and Alchemy module namespaces from their submodule entrypoints instead of root barrels.`,messages:{barrelImport:'Import this module as `import * as {{alias}} from "{{source}}"` instead of from the root barrel.'},url:`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/diagnostics/importFromBarrel.ts`,fixable:`code`}),*create(){let e=yield*i;function n(n,r){let i=fe(r.imported);return f.match(dr(i)?br(n.source.value,i):f.none(),{onNone:()=>d.void,onSome:a=>e.report(Lt(t.fromId({node:r,messageId:`barrelImport`,data:{alias:yr(i),source:a}}),Sr(e.sourceCode,n)))})}return s.on(`ImportDeclaration`,e=>d.forEach(c.filter(e.specifiers,t=>t.type===`ImportSpecifier`&&!vr(e,t)),t=>n(e,t),{concurrency:1,discard:!0}))}}),Or=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],kr=[`debug`,`error`,`info`,`log`,`trace`,`warn`],Ar=[`as`,`asSome`,`asVoid`];function jr(e,t){let n=O(e);if(n.type!==`CallExpression`)return f.none();let r=O(n.callee);return r.type===`CallExpression`&&t.isApiPath(r.callee,[`Effect`,`logWithLevel`])?f.some(`Effect.logWithLevel`):t.isApi(r,`Effect`,Or)||t.isApi(r,`Console`,kr)?f.some(t.path(r).pipe(f.getOrElse(()=>[]),c.join(`.`))):f.none()}function Mr(e,t){return f.flatMapNullishOr(t.path(e),([,e])=>e)}function Nr(e,t){let n=O(e);return n.type===`CallExpression`&&n.arguments.length===1&&t.isApiPath(n.callee,[`Effect`,`as`])?f.some(`as`):t.isApi(n,`Effect`,[`asSome`,`asVoid`])?Mr(n,t):f.none()}function Pr(e,t){return t.isApiPath(e,[`pipe`])||t.isApiPath(e,[`Function`,`pipe`])}function Fr(e,t,n){return f.flatMap(t,t=>e.pipe(f.flatMap(e=>jr(e,n)),f.zipWith(Nr(t,n),(e,n)=>({logger:e,method:n,node:t}))))}function Ir(e,t){let n=O(e.callee);return n.type===`MemberExpression`&&f.contains(C(n),`pipe`)?Fr(f.some(n.object),D(e,0),t):Pr(n,t)?Fr(D(e,0),D(e,1),t):(t.isApi(n,`Effect`,Ar)?Mr(n,t):f.none()).pipe(f.filter(t=>t!==`as`||e.arguments.length===2),f.flatMap(n=>D(e,0).pipe(f.flatMap(e=>jr(e,t)),f.map(t=>({logger:t,method:n,node:e})))))}const Lr=r.define({name:`no-effect-as-on-log`,meta:V({type:`suggestion`,description:`Disallow Effect.as, Effect.asSome and Effect.asVoid on log effects.`,messages:{asOnLog:"Do not swap the result of {{logger}} with Effect.{{method}}. Use Effect.gen: `yield*` the log, then return the value.",asVoidOnLog:`{{logger}} already succeeds with void; remove Effect.asVoid.`}}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>f.match(Ir(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n.node,messageId:n.method===`asVoid`?`asVoidOnLog`:`asOnLog`,data:{logger:n.logger,method:n.method}}))}))}}),Rr=r.define({name:`no-empty-effect-callback`,meta:V({type:`suggestion`,description:`Prefer Effect.never to an empty Effect.callback registration.`,messages:{emptyCallback:`An empty Effect.callback registration is Effect.never. Use the explicit primitive.`},url:`https://github.com/Effect-TS/tsgo/issues/636`,fixable:`code`}),*create(){let e=yield*i,n=yield*B,r=d.fnUntraced(function*(n,r){if(n.arguments.length!==1||r.async||r.generator||c.some(r.params,e=>e.type!==`Identifier`)||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(n))||!(yield*Me(n.callee)))return f.none();let i=yield*Pt(n,`effect/Effect`,`Effect`);return f.some(t.composeFixes(...f.toArray(i.fix),t.replaceText(n,`${i.name}.never`)))});function a(e){return n.isApi(e,`Effect`,`callback`)||n.isApi(e,`Effect`,`async`)}return s.on(`CallExpression`,n=>a(n.callee)?D(n,0).pipe(f.filter(e=>A(e)&&e.body?.type===`BlockStatement`&&c.isReadonlyArrayEmpty(e.body.body)),f.match({onNone:()=>d.void,onSome:i=>d.flatMap(r(n,i),r=>e.report(Lt(t.fromId({node:n,messageId:`emptyCallback`}),r)))})):d.void)}}),zr=r.define({name:`no-empty-schema-struct`,meta:V({type:`problem`,description:`Disallow Schema.Struct({}), which accepts every non-null object-like value.`,messages:{emptyStruct:`Schema.Struct({}) does not validate an exact empty object. Define the intended fields explicitly.`},url:`https://github.com/Effect-TS/tsgo/issues/403`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Schema`,`Struct`)&&f.exists(D(r,0),e=>e.type===`ObjectExpression`&&c.isReadonlyArrayEmpty(e.properties))?e.report(t.fromId({node:r,messageId:`emptyStruct`})):d.void)}}),Br=[`Base64`,`Base64Url`,`Hex`],Vr=[`decode`,`decodeString`],Hr=[`getOrThrow`,`getOrThrowWith`];function Ur(e,t){let n=e.type===`ChainExpression`?e.expression:O(e);return n.type===`CallExpression`?t.path(n.callee).pipe(f.filter(e=>e.length===2&&c.contains(Br,e[0])&&c.contains(Vr,e[1])),f.map(c.join(`.`))):f.none()}function Wr(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.filter(t.member(n,`Result`),e=>c.contains(Hr,e))}function Gr(e,t){let n=f.filter(t.member(e.callee,`Result`),e=>c.contains(Hr,e));if(f.isSome(n))return D(e,0).pipe(f.flatMap(e=>Ur(e,t)),f.map(e=>({decoder:e,method:n.value})));let r=e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`pipe`)?f.some({source:e.callee.object,steps:e.arguments}):t.isApi(e.callee,`Function`,`pipe`)||e.callee.type===`Identifier`&&e.callee.name===`pipe`?f.map(c.head(e.arguments),t=>({source:t,steps:c.drop(e.arguments,1)})):f.none();return f.flatMap(r,({source:e,steps:n})=>f.zipWith(Ur(e,t),f.flatMap(c.findFirst(n,e=>e.type!==`CallExpression`||!t.isApi(e.callee,`Result`,`map`)),e=>Wr(e,t)),(e,t)=>({decoder:e,method:t})))}const Kr=r.define({name:`no-encoding-get-or-throw`,meta:V({type:`problem`,description:`Disallow throwing away the typed EncodingError of Effect Base64, Base64Url, and Hex decoders.`,messages:{getOrThrow:`Result.{{method}} turns the EncodingError of {{decoder}} into an untyped exception. Keep it typed with yield* Effect.fromResult(…), or handle it with Result.match or Result.getOrElse.`},url:`https://effect.website/docs/v4/api/effect/encoding/EncodingError`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>f.match(Gr(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`getOrThrow`,data:n}))}))}});function qr(e,t=[]){let n=O(e);return n.type===`Identifier`?d.flatMap(ke(n,n.name),e=>{let n=f.flatMap(e,n=>f.flatMap(Ae(e),e=>{let r=e.node;return F(t,n)||r.type!==`VariableDeclarator`||r.id.type!==`Identifier`||!be(e.parent)||!r.init||c.some(n.references,e=>e.isWrite()&&!e.init)?f.none():f.some([n,r.init])}));return f.match(n,{onNone:()=>d.succeedNone,onSome:([e,n])=>qr(n,[...t,e])})}):d.succeedSome(n)}function Jr(e){return e.arguments.length===2?D(e,0):e.arguments.length===1?M(e,`CallExpression`).pipe(f.filter(t=>I(D(t,0),e)&&t.callee.type===`MemberExpression`&&f.contains(C(t.callee),`pipe`)),f.flatMap(e=>e.callee.type===`MemberExpression`?f.some(e.callee.object):f.none())):f.none()}const Yr=r.define({name:`no-function-config-default`,meta:V({type:`problem`,description:`Disallow obsolete lazy callbacks passed to the now-eager Config.withDefault API.`,messages:{functionDefault:`Config.withDefault takes an eager value. This callback becomes the configured value; pass the returned value directly.`},url:`https://github.com/Effect-TS/tsgo/issues/408`}),*create(){let e=yield*i,n=yield*B,r=d.fnUntraced(function*(e){let t=Jr(e),r=f.isSome(t)?yield*qr(t.value):f.none();if(f.isNone(r)||r.value.type!==`CallExpression`||!n.isApi(r.value.callee,`Config`,`succeed`))return!1;let i=r.value;return(yield*Me(i.callee))&&f.exists(D(i,0),A)});return s.on(`CallExpression`,i=>d.gen(function*(){if(!n.isApi(i.callee,`Config`,`withDefault`)||!(yield*Me(i.callee))||(yield*r(i)))return;let a=D(i,i.arguments.length-1);f.isSome(a)&&A(a.value)&&c.isReadonlyArrayEmpty(a.value.params)&&(yield*e.report(t.fromId({node:a.value,messageId:`functionDefault`})))}))}}),Xr=m.Literals([`delete`,`get`,`has`,`set`]),Zr=m.is(Xr);function Qr(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Hash`,`hash`)}const $r=r.define({name:`no-hash-as-identity`,meta:V({type:`problem`,description:`Disallow using Hash.hash output as collision-free identity.`,messages:{hashIdentity:`Hash.hash is a bucketing hint, not a unique identity. Use HashMap/Equal.equals or a real identifier instead.`},url:`https://github.com/Effect-TS/tsgo/issues/482`}),*create(){let e=yield*i,n=yield*B,r=yield*p.make(x.empty());function a(e){return Qr(e,n)?d.succeed(!0):e.type===`Identifier`?d.map(p.get(r),x.has(e.name)):d.succeed(!1)}function o(n,r){return d.when(e.report(t.fromId({node:n,messageId:`hashIdentity`})),r)}return s.merge(s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&Qr(e.init,n)?p.update(r,x.add(e.id.name)):d.void),s.on(`CallExpression`,e=>e.callee.type===`MemberExpression`&&f.exists(w(e.callee),e=>Zr(c.lastNonEmpty(e)))?f.match(D(e,0),{onNone:()=>d.void,onSome:e=>o(e,a(e))}):d.void),s.on(`BinaryExpression`,e=>le(e.operator)?o(e,d.map(d.all([a(e.left),a(e.right)],{concurrency:1}),c.every(Boolean))):d.void),s.on(`MemberExpression`,e=>e.computed?o(e.property,a(e.property)):d.void))}}),ei=m.Literals(/* @__PURE__ */ `asserts.decodeEffect.decodeExit.decodeOption.decodePromise.decodeResult.decodeSync.decodeUnknownEffect.decodeUnknownExit.decodeUnknownOption.decodeUnknownPromise.decodeUnknownResult.decodeUnknownSync.encodeEffect.encodeExit.encodeOption.encodePromise.encodeResult.encodeSync.encodeUnknownEffect.encodeUnknownExit.encodeUnknownOption.encodeUnknownPromise.encodeUnknownResult.encodeUnknownSync.is`.split(`.`)),ti=m.is(ei),ni=m.is(m.Literals([`global`,`module`])),ri=m.is(m.Literals([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`])),ii=m.is(m.Literals([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`])),ai=m.is(m.Literals([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]));function oi(e,t,n){let r=f.filter(t.member(e,`Schema`),ti);return w(e).pipe(f.flatMap(([t])=>L(n,e,t)),f.exists(({defs:e})=>c.every(e,e=>e.type===`ImportBinding`)))?r:f.none()}function si(e,t=e){return f.exists(j(t),n=>ai(n.type)&&b.isNotNullish(n.parent)?si(e,n):n.type===`CallExpression`&&n.callee===t)}function ci(e){return j(e).pipe(f.filter(t=>t.type===`MemberExpression`&&t.object===e),f.match({onNone:()=>e,onSome:ci}))}function li(e){let t=ci(e);return t!==e&&f.exists(j(t),e=>e.type===`AssignmentExpression`&&e.left===t||e.type===`UpdateExpression`&&e.argument===t||e.type===`UnaryExpression`&&e.operator===`delete`&&e.argument===t)}function ui(e){return c.every(e.references,e=>(!e.isWrite()||e.init)&&!li(e.identifier))}function di(e,t,n,r){return f.match(L(r,e,t),{onNone:()=>!0,onSome:e=>Ee(n,e.scope.block)||ni(e.scope.type)&&ui(e)})}function fi(e){return f.exists(j(e),t=>t.type===`MemberExpression`&&t.property===e&&!t.computed||t.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand)}function pi(e,t){return e!==t&&f.exists(j(e),e=>e!==t&&(ri(e.type)||pi(e,t)))}function mi(e,t,n){return pi(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?f.isNone(n.path(e.callee)):ii(e.type)}function hi(e,t,n){return!k(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||mi(r,e,t)||r.type===`Identifier`&&!fi(r)&&!di(r,r.name,e,n))}function gi(e,t,n){let[r]=e.arguments;if(b.isUndefined(r)||c.some(e.arguments,e=>e.type===`SpreadElement`)||!si(e)||f.isNone(Ce(e,e=>ri(e.type))))return f.none();let i=O(r),a=i.type===`CallExpression`&&f.exists(t.path(i.callee),e=>f.contains(c.head(e),`Schema`));return!a&&i.type!==`Identifier`&&i.type!==`MemberExpression`||!c.every(e.arguments,e=>hi(e,t,n))?f.none():f.some(a?`inlineSchema`:`inlineCompile`)}const _i=r.define({name:`no-inline-schema-compile`,meta:V({type:`problem`,description:`Disallow compiling Schema decoders, encoders, and guards inside function bodies.`,messages:{inlineSchema:`Hoist Schema.{{method}}(...) to module scope: both the inline schema and the compiled function are rebuilt on every call. Move the compiled function to a module-level const.`,inlineCompile:`Hoist Schema.{{method}}(...) to module scope: the compiled function is rebuilt on every call. Move it to a module-level const.`},url:`https://github.com/pingdotgg/t3code/blob/main/oxlint-plugin-t3code/rules/no-inline-schema-compile.ts`}),*create(){let e=yield*i,n=yield*B;return n.hasEffectImport?s.on(`CallExpression`,r=>f.zipWith(oi(r.callee,n,e.sourceCode),gi(r,n,e.sourceCode),(e,t)=>({method:e,messageId:t})).pipe(f.match({onNone:()=>d.void,onSome:({method:n,messageId:i})=>e.report(t.fromId({node:r.callee,messageId:i,data:{method:n}}))}))):{}}}),vi=m.Literals([`catch`,`catchIf`,`catchTag`,`orElseSucceed`,`catchAll`,`catchAllCause`,`catchSome`,`catchSomeCause`,`orElse`,`orElseFail`]),yi=m.is(vi),bi=m.Literals([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]),xi=m.is(bi);function Si(e,t){return e.pipe(f.filter(([e,n])=>e===`Effect`&&t(n)),f.flatMapNullishOr(([,e])=>e))}function Ci(e,t){return f.flatMap(j(e),e=>{let n=A(e)?Te(e).pipe(f.filter(t=>I(c.last(t.arguments),e)),f.flatMap(e=>Si(t.path(e.callee),yi))):f.none();return f.orElse(n,()=>Ci(e,t))})}const wi=r.define({name:`no-logging-in-catch`,meta:V({type:`suggestion`,description:`Keep logging separate from Effect recovery handlers.`,messages:{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>{let i=n.path(r.callee);return f.zipWith(Si(i,xi),Ci(r,n),(e,t)=>t).pipe(f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`logging`,data:{logger:i.pipe(f.getOrElse(()=>[]),c.join(`.`)),catchMethod:n}}))}))})}}),Ti=m.Literals([`catch`,`catchAll`,`catchIf`]),Ei=m.Literals([`when`,`not`]);function Di(e,t){return _.type().pipe(_.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:e},property:{type:`Identifier`,name:t}},g.constTrue),_.orElse(g.constFalse))}const Oi=Di(`Effect`,m.is(Ti)),ki=Di(`Match`,m.is(Ei)),Ai=/* @__PURE__ */ new Set([`_tag`]);function ji(e,t=Ai){return e.type===`MemberExpression`&&f.exists(C(e),e=>t.has(e))}function Mi(e,t=Ai){return le(e.operator)?c.findFirst([v.make(e.left,e.right),v.make(e.right,e.left)],([e,n])=>ji(e,t)&&N(n)).pipe(f.map(([e])=>e)):f.none()}function Ni(e){return we(e).pipe(f.flatMap(Te),f.exists(e=>Oi(e.callee)))}function Pi(e){return e.object.type===`MemberExpression`&&f.contains(C(e.object),`reason`)}function Fi(e){return f.exists(M(e,`CallExpression`),t=>F(t.arguments,e)&&ki(t.callee))}const Ii=r.define({name:`no-manual-effect-error-tag`,meta:V({type:`problem`,description:"Use Effect tagged error handlers instead of manually branching on `_tag` in a catch handler.",messages:{tag:`Use Effect.catchTag or Effect.catchTags instead of manually discriminating a tagged error in a broad Effect catch handler.`,reason:"Use Effect.catchReason or Effect.catchReasons instead of manually discriminating a tagged `reason` in a broad Effect catch handler."},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-effect-error-tag.ts`}),*create(){let e=yield*i;function n(n,r){return Ni(n)?e.report(t.fromId({node:n,messageId:Pi(r)?`reason`:`tag`})):d.void}return s.merge(s.on(`BinaryExpression`,e=>f.match(Mi(e),{onNone:()=>d.void,onSome:t=>n(e,t)})),s.on(`SwitchStatement`,e=>ji(e.discriminant)?n(e,e.discriminant):d.void))}}),Li=m.Literals([`replace`,`replaceAll`]),Ri=m.is(Li);function zi(e,t){return e.type===`CallExpression`&&e.callee.type===`MemberExpression`&&f.exists(C(e.callee),t)}function Bi(e){return zi(e,Ri)}function Vi(e){if(N(e))return f.some(e.value);if(e.type!==`Literal`||!(`regex`in e))return f.none();let{pattern:t}=e.regex,n=/^\[(\\?.)\]$/u.exec(t)?.[1]??t;return f.some(n.length===2&&h.startsWith(`\\`)(n)?h.slice(1)(n):n)}function Hi(e){return f.all([f.flatMap(D(e,0),Vi),D(e,1)]).pipe(f.flatMap(([e,t])=>N(t)&&e.length===1&&t.value.length===1?f.some(`${e}${t.value}`):f.none()))}function Ui(e){return Bi(e)?[...f.toArray(Hi(e)),...Ui(O(e.callee.object))]:[]}function Wi(e){let{parent:t}=e;return t.type!==`MemberExpression`||t.object!==e||!Bi(t.parent)||t.parent.callee!==t}function Gi(e,t){let n=Bi(e)?Wi(e)?Ui(e):[]:Ki(e,t);return(c.contains(n,`+-`)||c.contains(n,`-+`))&&(c.contains(n,`/_`)||c.contains(n,`_/`))}function Ki(e,t){return!(e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`pipe`))&&!Yi(e.callee,t)?[]:c.flatMap(e.arguments,e=>e.type===`CallExpression`&&t.isApi(e.callee,`String`,[`replace`,`replaceAll`])?f.toArray(Hi(e)):[])}function qi(e){return f.exists(D(e,0),P(2))&&f.exists(D(e,1),P(`0`))}function Ji(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`String`,`padStart`)&&qi(e)}function Yi(e,t){return t.isApi(e,`Function`,`pipe`)||e.type===`Identifier`&&e.name===`pipe`}function Xi(e,t){let{parent:n}=e;return n.type===`MemberExpression`?n.object===e&&f.contains(C(n),`padStart`)&&n.parent.type===`CallExpression`&&n.parent.callee===n&&qi(n.parent):n.type!==`CallExpression`||!I(D(n,0),e)?!1:Ji(n.callee,t)||Yi(n.callee,t)&&f.exists(D(n,1),e=>Ji(e,t))}function Zi(e){return zi(e,e=>e===`toString`)&&e.arguments.length===1&&f.exists(D(e,0),P(16))}const Qi=r.define({name:`no-manual-encoding`,meta:V({type:`suggestion`,description:`Disallow hand-written Base64Url and hexadecimal conversions in Effect projects.`,messages:{base64Url:`Swapping '+'/'-' and '/'/'_' by hand converts between Base64 and Base64Url. Use Base64Url.encode or Base64Url.decode from effect/encoding.`,hex:`Padding each byte's toString(16) to two digits hand-writes hexadecimal encoding. Use Hex.encode from effect/encoding.`},url:`https://effect.website/docs/v4/api/effect/encoding/Base64Url`}),*create(){let e=yield*i,n=yield*B;return n.hasEffectImport?s.on(`CallExpression`,r=>Gi(r,n)?e.report(t.fromId({node:r,messageId:`base64Url`})):Zi(r)&&Xi(r,n)?e.report(t.fromId({node:r,messageId:`hex`})):d.void):{}}}),$i=m.String.check(m.isPattern(/(?:^|[\n\r])(?:data|event|id|retry):.*(?:\r?\n){2}$/su)),ea=m.is($i),ta=m.Literals([`data: `,`event: `,`id: `,`retry: `]),na=m.is(ta);function ra(e){if(e.type===`PrivateIdentifier`)return`\0`;let t=O(e);return N(t)?t.value:t.type===`TemplateLiteral`?c.join(c.map(t.quasis,({value:e})=>e.cooked??e.raw),`\0`):t.type===`BinaryExpression`&&t.operator===`+`?ra(t.left)+ra(t.right):`\0`}function ia(e){return e.type===`BinaryExpression`&&e.operator===`+`}const aa=r.define({name:`no-manual-sse`,meta:V({type:`suggestion`,description:`Disallow writing or parsing Server-Sent Events text by hand in Effect projects.`,messages:{frame:"Write events with Sse.encoder.write, Sse.encode or HttpApiSchema.StreamSse: a hand-written frame breaks on a line break in `data` and lets `id` or `event` inject fields.",parse:"Parse events with Sse.decode, Sse.decodeSchema or Sse.makeParser: matching `{{prefix}}` by hand misses fields without a space, multi-line data, comments and CR line endings."},url:`https://www.effect.website/docs/v4/api/effect/encoding/Sse`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r({callee:e}){return n.isApi(e,`String`,`startsWith`)||e.type===`MemberExpression`&&f.contains(C(e),`startsWith`)}function a(n){return!f.exists(j(n),ia)&&ea(ra(n))?e.report(t.fromId({node:n,messageId:`frame`})):d.void}return s.merge(s.on(`Literal`,e=>N(e)?a(e):d.void),s.on(`TemplateLiteral`,a),s.on(`BinaryExpression`,e=>ia(e)?a(e):d.void),s.on(`CallExpression`,n=>D(n,0).pipe(f.filter(N),f.match({onNone:()=>d.void,onSome:({value:i})=>na(i)&&r(n)?e.report(t.fromId({node:n,messageId:`parse`,data:{prefix:i}})):d.void}))))}}),oa=m.Struct({discriminants:m.Array(m.String).annotate({description:"Discriminant properties checked in addition to `_tag`. Replaces the default `['kind', 'status']`."}).pipe(m.optionalKey)}),sa=r.define({name:`no-manual-tag-comparison`,meta:V({type:`problem`,description:"Use Effect Match or Predicate helpers instead of manually branching on `_tag` or another configured discriminant.",messages:{manualComparison:`Use Match.tag/Match.tags for tagged-value branching, or Predicate.isTagged for a simple reusable predicate.`,manualSwitch:"Use Match.value(value).pipe(Match.tag/Match.tags/Match.tagsExhaustive) or the tagged enum `$match` helper instead of switching on `_tag`.",manualDiscriminantComparison:"Use Match.discriminator('{{discriminant}}')/Match.discriminators('{{discriminant}}') or a Match.when pattern instead of comparing `{{discriminant}}` manually.",manualDiscriminantSwitch:"Use Match.type or Match.value with Match.discriminatorsExhaustive('{{discriminant}}') instead of switching on `{{discriminant}}`.",isTagged:`Replace with {{replacement}}.`},hasSuggestions:!0,url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tag-comparison.ts`,schema:[{type:`object`,properties:{discriminants:{type:`array`,items:{type:`string`,minLength:1},uniqueItems:!0,description:"Discriminant properties to check in addition to `_tag`. Replaces the default list."}},additionalProperties:!1}],defaultOptions:[{discriminants:[`kind`,`status`]}]}),options:oa.pipe(m.UndefinedOr),*create(e){let n=yield*i,r=/* @__PURE__ */ new Set([`_tag`,...e?.discriminants??[]]);function a(e,n,r){return t.fromId({node:e,messageId:ji(n)?`manual${r}`:`manualDiscriminant${r}`,data:{discriminant:f.getOrElse(C(n),()=>``)}})}function o(e,t){return ji(t)&&Ni(e)}let l=d.fnUntraced(function*(e,r){let i=a(e,r,`Comparison`),o=r===e.left?e.right:e.left;if(!ji(r)||!N(o)||c.isReadonlyArrayNonEmpty(n.sourceCode.getCommentsInside(e)))return yield*n.report(i);let s=e.operator===`!==`||e.operator===`!=`?`!`:``,l=`${H(n.sourceCode,r.object)}, ${n.sourceCode.getText(o)}`;function u(e){return`${s}${e}.isTagged(${l})`}let d=yield*Ft(e,`effect/Predicate`,`P`,u);return yield*n.report(t.withSuggestions(i,[{messageId:`isTagged`,data:{replacement:u(`P`)},fix:d}]))});return s.merge(s.on(`BinaryExpression`,e=>f.match(Mi(e,r),{onNone:()=>d.void,onSome:t=>o(e,t)?d.void:l(e,t)})),s.on(`SwitchStatement`,e=>ji(e.discriminant,r)&&!o(e,e.discriminant)?n.report(a(e,e.discriminant,`Switch`)):d.void))}}),ca=r.define({name:`no-manual-tagged-construction`,meta:V({type:`problem`,description:"Construct tagged values with their existing Effect constructor instead of writing `_tag` manually.",messages:{manualConstruction:"Use the existing Schema tagged `.make`, tagged class/error constructor, or Data.taggedEnum variant constructor instead of writing a literal `_tag` object."},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tagged-construction.ts`}),*create(){let e=yield*i;return s.on(`ObjectExpression`,n=>Fi(n)?d.void:f.match(c.findFirst(n.properties,e=>e.type===`Property`&&f.contains(T(e),`_tag`)&&N(e.value)),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`manualConstruction`}))}))}}),la=/* @__PURE__ */ new Map([[`Effect.cachedInvalidateWithTTL`,`last`],[`Effect.cachedWithTTL`,`last`],[`Effect.delay`,`last`],[`Effect.sleep`,`last`],[`Effect.timeout`,`last`],[`Effect.timeoutOption`,`last`],[`Effect.timeoutOrElse`,`options.duration`],[`Schedule.duration`,`last`],[`Schedule.during`,`last`],[`Schedule.exponential`,`first`],[`Schedule.fibonacci`,`last`],[`Schedule.fixed`,`last`],[`Schedule.spaced`,`last`],[`Schedule.windowed`,`last`],[`Stream.debounce`,`last`],[`Stream.groupedWithin`,`last`],[`Stream.throttle`,`options.duration`],[`Stream.timeout`,`last`],[`TestClock.adjust`,`last`]]),ua=_.type().pipe(_.withReturnType(),_.when(`first`,()=>e=>D(e,0)),_.when(`last`,()=>e=>D(e,e.arguments.length-1)),_.when(`options.duration`,()=>e=>D(e,e.arguments.length-1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(E(`duration`)),f.map(({value:e})=>e))),_.exhaustive);function da(e,t){return f.match(t.path(e.callee).pipe(f.flatMapNullishOr(e=>la.get(c.join(e,`.`)))),{onNone:()=>d.succeedNone,onSome:t=>d.map(Me(e.callee),n=>n?ua(t)(e):f.none())})}const fa=_.type().pipe(_.withReturnType(),_.when(`*`,()=>f.some(te.multiply)),_.when(`+`,()=>f.some(te.sum)),_.when(`-`,()=>f.some(te.subtract)),_.when(`/`,()=>f.some(te.divideUnsafe)),_.when(`%`,()=>f.some(te.remainder)),_.when(`**`,()=>f.some((e,t)=>e**t)),_.orElse(()=>f.none()));function pa(e){return e.type===`Literal`&&b.isNumber(e.value)?f.some(e.value):f.none()}function ma(e){let t=O(e);if(t.type===`Literal`)return pa(t);if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`))return f.map(ma(t.argument),e=>t.operator===`+`?e:-e);if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return f.none();let{left:n,right:r,operator:i}=t;return f.flatMap(fa(i),e=>f.zipWith(ma(n),ma(r),(t,n)=>e(t,n)))}function ha(e){let t=O(e);return t.type===`Literal`?f.map(pa(t),c.of):t.type===`BinaryExpression`&&t.operator===`*`?f.zipWith(ha(t.left),ha(t.right),(e,t)=>[...e,...t]):f.none()}const ga=m.is(m.Literals([6e4,36e5,864e5])),_a=m.is(m.Literals([60,3600,86400])),va=m.is(m.Literals([7,24,60,1e3,3600,86400]));function ya(e){return ha(e).pipe(f.filter(e=>e.length>=2&&(c.some(e,ga)||c.some(e,_a)&&c.filter(e,va).length>=2)),f.map(e=>({millis:c.contains(e,1e3)||c.some(e,e=>e%6e4==0)})))}const ba=g.flow(h.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),c.filter(h.isNonEmpty),c.map(h.toLowerCase));m.Literals([`duration`,`instant`]);const xa=m.is(m.Literals([`millis`,`milliseconds`,`ms`])),Sa=m.is(m.Literals([`at`,`created`,`deadline`,`end`,`ended`,`epoch`,`last`,`now`,`since`,`start`,`started`,`timestamp`,`until`,`updated`]));function Ca(e){let t=ba(e);return c.last(t).pipe(f.filter(xa),f.map(()=>c.some(t,Sa)?`instant`:`duration`))}const wa={weeks:S.weeks,days:S.days,hours:S.hours,minutes:S.minutes,seconds:S.seconds,millis:S.millis},Ta=[[`weeks`,S.toWeeks],[`days`,S.toDays],[`hours`,S.toHours],[`minutes`,S.toMinutes],[`seconds`,S.toSeconds],[`millis`,S.toMillis]];function Ea(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):h.replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)(String(e))}function Da(e,t){let n=wa[t](e);return S.isZero(n)?`Duration.zero`:c.findFirst(Ta,([,e])=>Number.isSafeInteger(e(n))).pipe(f.match({onNone:()=>`Duration.millis(${n.pipe(S.toMillis,Ea)})`,onSome:([e,t])=>`Duration.${e}(${Ea(t(n))})`}))}const Oa=m.is(m.Literals([`*`,`+`,`-`,`/`])),ka={"!==":`Duration.equals`,"*":`Duration.times`,"+":`Duration.sum`,"-":`Duration.subtract`,"/":`Duration.divide`,"<":`Duration.isLessThan`,"<=":`Duration.isLessThanOrEqualTo`,"===":`Duration.equals`,">":`Duration.isGreaterThan`,">=":`Duration.isGreaterThanOrEqualTo`},Aa={"!==":`DateTime.Equivalence`,"+":`DateTime.addDuration`,"-":`DateTime.subtractDuration`,"<":`DateTime.isLessThan`,"<=":`DateTime.isLessThanOrEqualTo`,"===":`DateTime.Equivalence`,">":`DateTime.isGreaterThan`,">=":`DateTime.isGreaterThanOrEqualTo`},ja=`Duration.isPositive, Duration.isNegative or Duration.isZero`,Ma={"!==":`Duration.isZero`,"<":ja,"<=":ja,"===":`Duration.isZero`,">":ja,">=":ja};function Na(e){let t=O(e);return t.type===`TemplateLiteral`||t.type===`Literal`&&b.isString(t.value)?!0:t.type===`BinaryExpression`&&t.operator===`+`&&(Na(t.left)||Na(t.right))}function Pa(e){let t=O(e);return t.type===`Identifier`&&t.name===`undefined`||t.type===`Literal`&&!b.isNumber(t.value)}function Fa(e,t){let n=e.name.parent;return(n.type===`AssignmentPattern`?n.parent:n).type===`Property`||e.type===`Parameter`&&f.exists(we(e.name),e=>Yn(e,t))}function Ia(e){return f.contains(e,`instant`)}function La(e,t){let{left:n,right:r}=t;return e===`+`?Ia(n)===Ia(r)?`duration`:`instant`:e===`-`&&Ia(n)&&!Ia(r)?`instant`:`duration`}function Ra(e,t){let n=Ia(t.left)||Ia(t.right);if(Ia(t.right)&&e.operator===`-`)return`DateTime.distance`;if(P(e.right,1e3)&&e.operator===`/`)return n?`DateTime.toEpochSeconds`:`Duration.toSeconds`;let r=!n&&(P(e.left,0)||P(e.right,0));return l.get(Ma,e.operator).pipe(f.filter(()=>r),f.orElse(()=>f.filter(l.get(Aa,e.operator),()=>n)),f.orElse(()=>l.get(ka,e.operator)),f.getOrElse(()=>`Duration`))}function za(e){return e.type===`BinaryExpression`&&e.left.type!==`PrivateIdentifier`}function Ba(e){return f.flatMap(j(e),e=>se(e.type)?Ba(e):f.liftPredicate(e,za))}const Va=r.define({name:`no-millis-arithmetic`,meta:V({type:`suggestion`,description:`Disallow arithmetic and comparisons on millisecond numbers where Effect Duration or DateTime can do the math.`,messages:{millisArithmetic:`{{operand}} is {{what}} in milliseconds. Keep it as a {{module}} and use {{suggestion}}; convert to milliseconds only where a non-Effect API needs them.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r(e,t){return d.map(Me(e),e=>e?f.some(t):f.none())}function a(e){return n.isApiPath(e,[`Duration`,`toMillis`])?r(e,`duration`):n.isApiPath(e,[`DateTime`,`toEpochMillis`])?r(e,`instant`):d.succeedNone}let o=d.fnUntraced(function*(e,t){let r=Ae(yield*ke(e,e.name));if(f.exists(r,e=>Fa(e,n)))return f.none();let i=Ca(e.name);if(f.isSome(i))return i;let a=f.flatMap(r,({node:e,name:t})=>e.type===`VariableDeclarator`&&be(e.parent)&&e.id===t&&b.isNotNull(e.init)?f.some(e.init):f.none());return f.isSome(a)?yield*c(a.value,t+1):f.none()});function c(e,t){if(t>4)return d.succeedNone;let i=O(e);if(i.type===`Identifier`)return o(i,t);if(i.type===`MemberExpression`)return d.succeed(i.object.type===`ThisExpression`?f.flatMap(C(i),Ca):f.none());if(i.type===`CallExpression`)return a(i.callee);if(i.type===`YieldExpression`){let e=i.argument;return b.isNotNull(e)&&i.delegate&&n.isApiPath(e,[`Clock`,`currentTimeMillis`])?r(e,`instant`):d.succeedNone}return!za(i)||!Oa(i.operator)?d.succeedNone:d.map(u(i,t),f.map(e=>La(i.operator,e)))}function u(e,t){return!l.has(ka,e.operator)||e.operator===`+`&&(Na(e.left)||Na(e.right))||(e.operator===`===`||e.operator===`!==`)&&(Pa(e.left)||Pa(e.right))?d.succeedNone:d.map(d.all({left:c(e.left,t),right:c(e.right,t)},{concurrency:1}),e=>f.isNone(e.left)&&f.isNone(e.right)?f.none():f.some(e))}function p(n,r){let i=Ia(r.left)||Ia(r.right);return e.report(t.fromId({node:n,messageId:`millisArithmetic`,data:{operand:e.sourceCode.getText(f.match(r.left,{onNone:()=>n.right,onSome:()=>n.left})),what:i?`a timestamp`:`a duration`,module:i?`DateTime`:`Duration`,suggestion:Ra(n,r)}}))}return s.on(`BinaryExpression`,d.fnUntraced(function*(e){if(!za(e))return;let t=yield*u(e,0);if(f.isNone(t))return;let n=Ba(e),r=f.isSome(n)?yield*u(n.value,0):f.none();f.isSome(r)||(yield*p(e,t.value))}))}}),Ha={addEventListener:1,on:1,setInterval:0};function Ua(e){return f.exists(D(e,2),e=>e.type===`ObjectExpression`&&f.exists(E(e,`once`),e=>P(e.value,!0)))}function Wa(e,t){return w(e.callee).pipe(f.map(c.lastNonEmpty),f.exists(n=>f.exists(l.get(Ha,n),r=>(n!==`addEventListener`||!Ua(e))&&f.exists(D(e,r),e=>ye(e,t)))))}function Ga(e){return f.exists(D(e,0),e=>{if(!A(e)||b.isNullish(e.body))return!1;let t=e.body;return f.exists(xe(e),({name:e})=>k(t,t=>t.type===`CallExpression`&&Wa(t,e)))})}const Ka=r.define({name:`no-multi-shot-effect-callback`,meta:V({type:`problem`,description:`Disallow attaching Effect.callback resume to repeating event sources.`,messages:{multiShot:`Effect.callback is single-shot, but this source emits repeatedly. Use a once-style subscription or Stream.callback.`},url:`https://github.com/Effect-TS/tsgo/issues/484`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`callback`)&&Ga(r)?e.report(t.fromId({node:r,messageId:`multiShot`})):d.void)}}),qa=m.Literals([`NaN`,`Infinity`,`undefined`]),Ja=m.is(qa),Ya=m.Literals([`annotate`,`annotateEncoded`,`annotateKey`]),Xa=m.is(Ya),Za=[`default`,`examples`];function Qa(e){return e.type===`Literal`&&b.isBigInt(e.value)||e.type===`Identifier`&&Ja(e.name)||A(e)||e.type===`CallExpression`&&f.exists(w(e.callee),e=>c.lastNonEmpty(e)===`Symbol`)}function $a(e){return e.type===`ArrayExpression`?c.filter(e.elements,e=>b.isNotNull(e)&&e.type!==`SpreadElement`):e.type===`ObjectExpression`?c.flatMap(e.properties,e=>e.type===`Property`?[e.value]:[]):[]}function eo(e){let t=O(e);return Qa(t)?f.some(t):c.findFirst(c.reverse($a(t)),eo)}function to(e,t){let n=e.callee.type===`MemberExpression`?C(e.callee):t.path(e.callee).pipe(f.filter(([e])=>e===`Schema`),f.flatMapNullishOr(([,e])=>e));return f.filter(n,Xa)}function no(e){return me(e).pipe(f.filter(e=>f.isNone(E(e,`jsonSchema`))),f.match({onNone:()=>[],onSome:e=>c.getSomes(c.map(Za,t=>f.flatMap(E(e,t),({value:e})=>eo(e))))}))}const ro=r.define({name:`no-non-json-schema-annotation`,meta:V({type:`problem`,description:`Disallow schema examples and defaults that cannot be represented in JSON Schema.`,messages:{nonJson:`This schema annotation value is not JSON-serializable and will be omitted from or corrupt generated JSON Schema.`},url:`https://github.com/Effect-TS/tsgo/issues/440`}),*create(){let e=yield*i,n=yield*B;return n.hasEffectImport?s.on(`CallExpression`,r=>f.match(to(r,n),{onNone:()=>d.void,onSome:()=>d.forEach(no(r),n=>e.report(t.fromId({node:n,messageId:`nonJson`})),{concurrency:1,discard:!0})})):{}}}),io=[`option`,`either`];function ao(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`service`)}function oo(e,t){let n=D(e,0);return t.isApi(e.callee,`Effect`,io)?f.exists(n,e=>ao(e,t)):e.callee.type===`MemberExpression`&&f.exists(w(e.callee),e=>c.lastNonEmpty(e)===`pipe`)&&ao(O(e.callee.object),t)&&f.exists(n,e=>t.isApi(e,`Effect`,io))}const so=r.define({name:`no-option-of-service`,meta:V({type:`problem`,description:`Disallow wrapping infallible Effect.service access in Option or Either.`,messages:{mandatory:`Effect.service never fails, so this wrapper is always present and keeps the service requirement. Use Effect.serviceOption.`},url:`https://github.com/Effect-TS/tsgo/issues/648`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>oo(r,n)?e.report(t.fromId({node:r,messageId:`mandatory`})):d.void)}}),co=r.define({name:`no-overwritten-discriminant`,meta:V({type:`problem`,description:`Ensure a later object spread cannot overwrite an explicitly assigned _tag.`,messages:{overwritten:`A later spread can overwrite _tag at runtime. Move _tag after all spreads.`},url:`https://github.com/Effect-TS/tsgo/issues/426`}),*create(){let e=yield*i;return s.on(`ObjectExpression`,n=>c.findFirstWithIndex(n.properties,e=>e.type===`Property`&&f.contains(T(e),`_tag`)).pipe(f.filter(([,e])=>c.some(c.drop(n.properties,e+1),e=>e.type===`SpreadElement`)),f.match({onNone:()=>d.void,onSome:([n])=>e.report(t.fromId({node:n,messageId:`overwritten`}))})))}}),lo=m.is(m.String.check(m.isPattern(/\.(?:test|spec)\.[cm]?[jt]sx?$/u))),uo=m.is(m.String.check(m.isPattern(/^make[A-Z]/u))),fo=m.is(m.String.check(m.isPattern(/^\.\.?\//u))),po=r.define({name:`no-service-constructor-imports`,meta:V({type:`problem`,description:`Disallow project-local make<CapabilityName> imports outside test and spec files.`,messages:{serviceConstructorImport:`Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.`},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-service-constructor-imports.ts`}),*create(){let e=yield*i;return lo(h.replaceAll(`\\`,`/`)(e.filename))?{}:s.on(`ImportDeclaration`,n=>fo(n.source.value)?d.forEach(c.filter(n.specifiers,e=>e.type===`ImportSpecifier`),n=>{let r=fe(n.imported);return uo(r)?e.report(t.fromId({node:n,messageId:`serviceConstructorImport`,data:{name:r}})):d.void},{concurrency:1,discard:!0}):d.void)}}),mo=[`getOrThrow`,`getOrThrowWith`];function ho(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`serviceOption`)}function go(e,t){return t.isApi(e.callee,`Option`,mo)?f.exists(D(e,0),e=>e.type===`YieldExpression`?b.isNotNullish(e.argument)&&ho(e.argument,t):ho(e,t)):e.callee.type===`MemberExpression`&&f.exists(w(e.callee),e=>c.lastNonEmpty(e)===`pipe`)&&ho(O(e.callee.object),t)&&f.exists(D(e,0),e=>e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`map`)&&f.exists(D(e,0),e=>t.isApi(e,`Option`,mo)))}const _o=r.define({name:`no-service-option-get-or-throw`,meta:V({type:`problem`,description:`Disallow turning missing Effect services into untyped Option defects.`,messages:{getOrThrow:`Option.getOrThrow after Effect.serviceOption hides a mandatory service until runtime. Use Effect.service so it remains a typed requirement.`},url:`https://github.com/Effect-TS/tsgo/issues/650`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>go(r,n)?e.report(t.fromId({node:r,messageId:`getOrThrow`})):d.void)}}),vo=m.Literals([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),yo=m.is(vo),bo=r.define({name:`no-throw-in-effect-callback`,meta:V({type:`problem`,description:`Disallow throw in Effect callbacks that cannot add the thrown value to the typed error channel.`,messages:{callbackThrow:`Throwing in this Effect callback creates an untyped defect. Return Effect.fail(...) or return the mapped error value instead.`},url:`https://github.com/Effect-TS/tsgo/issues/406`}),*create(){let e=yield*i,n=yield*B;return s.on(`ThrowStatement`,r=>f.exists(we(r),e=>f.exists(qn(e,n),([e,t])=>e===`Effect`&&yo(t))||f.exists(Kn(e,`catch`),e=>n.isApi(e.callee,`Effect`,[`try`,`tryPromise`])))?e.report(t.fromId({node:r,messageId:`callbackThrow`})):d.void)}}),xo=m.Literals([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]),So=m.is(xo),Co=m.is(m.String.check(m.isPattern(/[A-Z]/u)));function wo(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||vr(n,r.type===`ImportSpecifier`?r:void 0))return!1;let i=n.source.value;return r.type===`ImportNamespaceSpecifier`?i===`effect/unstable/httpapi/HttpApiEndpoint`&&t.length===2||i===`effect/unstable/httpapi`&&t.length===3&&t[1]===`HttpApiEndpoint`:r.type===`ImportSpecifier`&&r.imported.type===`Identifier`&&r.imported.name===`HttpApiEndpoint`&&i===`effect/unstable/httpapi`&&t.length===2}function To(e){return w(e.callee).pipe(f.filter(e=>So(c.lastNonEmpty(e))),f.match({onNone:()=>d.succeed(!1),onSome:t=>d.map(ke(e,c.headNonEmpty(t)),e=>f.exists(Ae(e),e=>wo(e,t)))}))}function Eo(e){return f.orElse(T(e),()=>e.key.type===`Literal`&&b.isNumber(e.key.value)?f.some(String(e.key.value)):f.none())}function Do(e){return e.pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(e=>f.all(c.map(e.properties,pe))),f.filter(e=>f.all(c.map(e,Eo)).pipe(f.exists(e=>c.dedupe(e).length===e.length))))}function Oo(e){return D(e,2).pipe(Do,f.flatMap(e=>c.findFirst(e,e=>f.contains(T(e),`headers`))),f.map(({value:e})=>e),Do)}const ko=r.define({name:`no-uppercase-http-api-header`,meta:V({type:`problem`,description:`Require lowercase static keys in Effect v4 endpoint header field schemas.`,messages:{uppercase:`Header schema key "{{name}}" contains ASCII uppercase letters. Incoming headers use exact lowercase runtime lookup; review the schema and its consumers before renaming this key.`},url:`https://github.com/Effect-TS/tsgo/issues/413`}),*create(){let e=yield*i;function n(n){return d.forEach(n,n=>T(n).pipe(f.filter(Co),f.match({onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n.key,messageId:`uppercase`,data:{name:r}}))})),{concurrency:1,discard:!0})}return s.on(`CallExpression`,e=>c.some(e.arguments,e=>e.type===`SpreadElement`)?d.void:d.flatMap(To(e),t=>t?f.match(Oo(e),{onNone:()=>d.void,onSome:n}):d.void))}}),Ao=r.define({name:`no-zero-retry-times`,meta:V({type:`problem`,description:`Disallow no-op retry and repeat wrappers with times: 0.`,messages:{zeroTimes:`times: 0 performs no retries or repeats. Remove the wrapper or use a positive count.`},url:`https://github.com/Effect-TS/tsgo/issues/412`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,[`retry`,`repeat`])?me(r).pipe(f.flatMap(E(`times`)),f.filter(e=>P(e.value,0)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`zeroTimes`}))})):d.void)}}),jo={Exit:[`isSuccess`,`isFailure`],Result:[`isSuccess`,`isFailure`],Option:[`isSome`,`isNone`]};function Mo(e,t){let n=O(e.type===`UnaryExpression`&&e.operator===`!`?e.argument:e);return n.type!==`CallExpression`||n.arguments.length!==1?f.none():f.flatMap(t.path(n.callee),e=>{let[t,n]=e;return e.length===2&&b.isNotUndefined(t)&&b.isNotUndefined(n)&&f.exists(l.get(jo,t),c.contains(n))?f.some([t,n]):f.none()})}function No(e){return k(e,e=>e.type===`YieldExpression`||e.type===`AwaitExpression`)}function Po(e){return f.exists(e,e=>f.exists(e.type===`BlockStatement`?c.last(e.body):f.some(e),t=>t.type===`ReturnStatement`&&b.isNotNull(t.argument)&&!No(e)))}function Fo(e){return j(e).pipe(f.filter(e=>e.type===`BlockStatement`||e.type===`Program`),f.flatMap(t=>{let n=t.body;return f.filter(c.get(n,n.indexOf(e)+1),e=>e.type===`ReturnStatement`)}))}const Io=r.define({name:`prefer-data-match`,meta:V({type:`suggestion`,description:`Use Exit.match, Result.match or Option.match instead of branching on their guards to produce a value.`,messages:{preferMatch:"Use `{{module}}.match` instead of branching on `{{module}}.{{guard}}` and producing a value in both branches."},url:`https://www.effect.website/docs/v4/api/effect/Option`}),*create(){let e=yield*i,n=yield*B;function r(r,i,a){return Mo(i,n).pipe(f.filter(a),f.match({onNone:()=>d.void,onSome:([n,i])=>e.report(t.fromId({node:r,messageId:`preferMatch`,data:{module:n,guard:i}}))}))}return s.merge(s.on(`ConditionalExpression`,e=>r(e,e.test,()=>!No(e.consequent)&&!No(e.alternate))),s.on(`IfStatement`,e=>r(e,e.test,()=>Po(f.some(e.consequent))&&Po(f.fromNullishOr(e.alternate).pipe(f.orElse(()=>Fo(e)))))))}}),Lo=m.is(m.String.check(m.isPattern(/^is\p{Lu}/u)));function Ro(e){return e.type===`Identifier`?f.some(e.name):e.type===`RestElement`&&e.argument.type===`Identifier`?f.some(e.argument.name):f.none()}function zo(e,t){return k(e,e=>e.type===`ThisExpression`||e.type===`Identifier`&&c.contains(t,e.name))}function Bo(e,t){let n=c.last(t.params).pipe(f.filter(e=>e.type===`RestElement`),f.flatMap(Ro));return e.type===`SpreadElement`?f.filter(n,t=>e.argument.type===`Identifier`&&e.argument.name===t):e.type===`Identifier`&&!f.contains(n,e.name)?f.some(e.name):f.none()}function Vo(e,t,n){return f.all(c.flatMap(e.arguments,e=>Bo(e,t).pipe(f.filter(e=>c.contains(n,e)),f.match({onSome:e=>[f.some(e)],onNone:()=>A(e)||zo(e,n)?[f.none()]:[]}))))}function Ho(e){return e.async||e.generator||e.typeParameters?f.none():f.zipWith(f.filter(f.all(c.map(e.params,Ro)),c.isReadonlyArrayNonEmpty),f.filter(W(e),e=>e.type===`CallExpression`&&!e.optional),(e,t)=>({names:e,call:t})).pipe(f.flatMap(({names:t,call:n})=>n.callee.type===`Super`||zo(n.callee,t)?f.none():Vo(n,e,t).pipe(f.filter(e=>c.makeEquivalence(h.Equivalence)(e,t)),f.map(()=>({call:n,exact:n.arguments.length===t.length})))))}function Uo(e){return e.returnType?.typeAnnotation.type===`TSTypePredicate`}function Wo(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.exists(t.path(n),e=>c.get(e,1).pipe(f.filter(()=>e.length===2),f.exists(t=>f.contains(c.head(e),`Schema`)?t===`is`:Lo(t))))}function Go(e,t){return e.type===`Identifier`?!0:e.type===`MemberExpression`?f.isSome(t.path(e)):e.type===`CallExpression`&&e.callee.type!==`Identifier`&&Go(e.callee,t)}function Ko(e,t){return Ee(t,e.name)?!1:e.type!==`Variable`&&e.type!==`ClassName`?!0:e.type===`Variable`&&!be(e.parent)?!1:v.get(e.node.range,1)<=v.get(t.range,0)&&!qo(t,e.node)}function qo(e,t){let n=e.parent;return!n||Ee(n,t)?!1:n.type===`FunctionDeclaration`||qo(n,t)}function Jo(e,t,n){return c.every(c.filter(e.getScope(t).references,({identifier:e})=>Ee(t,e)),({resolved:e})=>!e||!c.some(e.references,e=>e.isWrite()&&!e.init)&&c.every(e.defs,e=>Ko(e,n)))}const Yo={"Array.filter":2,"Array.findFirst":2,"Array.findFirstIndex":2,"Array.flatMap":2,"Array.flatten":1,"Array.head":1,"Array.isArrayEmpty":1,"Array.isArrayNonEmpty":1,"Array.isReadonlyArrayEmpty":1,"Array.isReadonlyArrayNonEmpty":1,"Array.last":1,"Array.length":1,"Array.map":2,"Array.reverse":1,"Option.filter":2,"Option.flatMap":2,"Option.flatten":1,"Option.getFailure":1,"Option.getOrElse":2,"Option.getOrNull":1,"Option.getOrUndefined":1,"Option.getSuccess":1,"Option.isNone":1,"Option.isSome":1,"Option.map":2,"Option.match":2,"Option.orElse":2,"Option.some":1,"Result.flatMap":2,"Result.getFailure":1,"Result.getOrElse":2,"Result.getSuccess":1,"Result.isFailure":1,"Result.isSuccess":1,"Result.map":2,"Result.mapError":2};function Xo(e,t){return t.path(e).pipe(f.filter(e=>e.length===2),f.flatMap(e=>{let t=c.join(e,`.`);return f.map(l.get(Yo,t),e=>v.make(t,e))}))}function Zo(e,t,n){return(e.type===`Identifier`||e.type===`MemberExpression`)&&f.exists(n.path(e),e=>c.join(e,`.`)===t)}function Qo(e){return e.optional||b.isNotNullish(e.typeArguments)||c.some(e.arguments,e=>e.type===`SpreadElement`)?f.none():f.some(e.arguments)}function $o(e,t){return e.type===`CallExpression`?f.product(Xo(e.callee,t),Qo(e)).pipe(f.flatMap(([[t,n],r])=>r.length===n?f.map(c.head(r),n=>({self:n,step:{api:t,node:e,callee:e.callee,args:c.drop(r,1)}})):f.none())):f.none()}function es(e,t){return e.type===`CallExpression`?f.product(Xo(e.callee,t),Qo(e)).pipe(f.flatMap(([[t,n],r])=>r.length+1===n?f.some({api:t,node:e,callee:e.callee,args:r}):f.none())):e.type===`Identifier`||e.type===`MemberExpression`?f.flatMap(Xo(e,t),([t,n])=>n===1?f.some({api:t,node:e,callee:e,args:[]}):f.none()):f.none()}function ts(e,t){if(e.type!==`CallExpression`)return f.none();let n=e.callee;return f.flatMap(Qo(e),r=>n.type===`MemberExpression`&&n.object.type!==`Super`&&f.contains(C(n),`pipe`)?f.some({kind:`pipe`,call:e,subject:f.some(n.object),steps:r}):t.isApi(n,`Function`,`pipe`)||t.isApiPath(n,[`pipe`])?f.some({kind:`pipe`,call:e,subject:c.head(r),steps:c.drop(r,1)}):t.isApi(n,`Function`,`flow`)||t.isApiPath(n,[`flow`])?f.some({kind:`flow`,call:e,subject:f.none(),steps:r}):f.none())}function ns(e,t){return c.map(t,t=>H(e.sourceCode,t))}function G(e,t={}){return(n,r)=>f.some({api:e,negate:t.negate??!1,safety:t.safety?.(n,r)??`fix`,args:t.args?.(n,r)??ns(r,[...n.inner.args,...n.outer.args])})}function rs(e,t){return({inner:n,outer:r},i)=>{let[a=``,o=``]=ns(i,[...n.args,...r.args]);return[`{ ${e}: ${a}, ${t}: ${o} }`]}}function K(e){return c.head(e.args)}function is(e){return e.type===`ArrowFunctionExpression`&&!e.async&&c.isReadonlyArrayEmpty(e.params)}function as(e){return is(e)&&e.expression&&P(e.body,!1)}function os(e){return e.type===`CallExpression`?os(e.callee):e}const ss=/* @__PURE__ */ new Set([`contains`,`endsWith`,`every`,`exists`,`has`,`includes`,`is`,`some`,`startsWith`]),cs=/* @__PURE__ */ new Set([`!=`,`!==`,`<`,`<=`,`==`,`===`,`>`,`>=`,`in`,`instanceof`]);function ls(e,t){return _.value(e).pipe(_.discriminators(`type`)({BinaryExpression:({operator:e})=>cs.has(e),UnaryExpression:({operator:e})=>e===`!`,Literal:({value:e})=>b.isBoolean(e),LogicalExpression:({operator:e,left:n,right:r})=>e!==`??`&&ls(n,t)&&ls(r,t),ConditionalExpression:({consequent:e,alternate:n})=>ls(e,t)&&ls(n,t),CallExpression:e=>t.path(os(e)).pipe(f.flatMap(e=>c.get(e,1)),f.exists(e=>ss.has(e)||/^is\p{Lu}/u.test(e)))}),_.orElse(g.constFalse))}function us(e,t){return e.type===`ConditionalExpression`?us(e.consequent,t)||us(e.alternate,t):e.type===`CallExpression`&&!ls(e,t)&&f.exists(t.path(os(e)),e=>f.contains(c.head(e),`Option`))}function ds(e){return A(e)&&!e.async&&!e.generator?W(e):f.none()}function fs(e,t){return f.exists(K(e.inner),e=>ps(e,t.imports))?`fix`:`boolean`}function ps(e,t){return Wo(e,t)||f.exists(ds(e),e=>ls(e,t))}const ms=/* @__PURE__ */ new Set(/* @__PURE__ */ `append.appendAll.dedupe.drop.empty.filter.filterMap.flatMap.flatMapNullishOr.flatten.fromIterable.getFailures.getSomes.getSuccesses.make.map.of.prepend.prependAll.range.replicate.reverse.sort.sortBy.sortWith.take`.split(`.`));function hs(e,t){return e.type===`ArrayExpression`||t.isApi(e.type===`CallExpression`?e.callee:e,`Array`,[...ms])}function gs(e){return(t,n)=>f.map(e(t,n),e=>e.safety===`fix`&&!f.exists(t.input,e=>hs(e,n.imports))?u.assign(e,{safety:`array`}):e)}function _s(e){return A(e)&&e.params.length<=1&&c.every(e.params,e=>e.type!==`RestElement`)&&(e.type===`ArrowFunctionExpression`||!ye(e,`arguments`))}function vs(e){return A(e)||e.type===`Literal`||e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)||f.isSome(w(e))}function ys(e){return(t,n)=>K(t.inner).pipe(f.flatMap(ds),f.exists(e=>us(e,n.imports)))?f.none():e(t,n)}function bs(e,t){if(e.type!==`ArrowFunctionExpression`||e.async||!e.expression||e.params.length!==1)return!1;let[n]=e.params,r=e.body;return n?.type===`Identifier`&&r.type===`MemberExpression`&&!r.optional&&r.object.type===`Identifier`&&r.object.name===n.name&&f.contains(C(r),t)}const xs=[{guard:`Option.isSome`,field:`value`,getter:f.some(`Option.getOrThrow`),api:`Array.getSomes`},{guard:`Result.isSuccess`,field:`success`,getter:f.some(`Result.getOrThrow`),api:`Array.getSuccesses`},{guard:`Result.isFailure`,field:`failure`,getter:f.none(),api:`Array.getFailures`}];function Ss(e,t){return f.product(K(e.inner),K(e.outer)).pipe(f.flatMap(([e,n])=>c.findFirst(xs,r=>Zo(e,r.guard,t.imports)&&(bs(n,r.field)||f.exists(r.getter,e=>Zo(n,e,t.imports))))),f.flatMap(({api:n})=>G(n,{args:()=>[]})(e,t)))}function Cs(e,t){return f.exists(K(e.outer),e=>f.exists(t.imports.path(e),e=>c.join(e,`.`)===`Predicate.isNotNullish`))?G(`Array.flatMapNullishOr`,{args:({inner:e})=>ns(t,e.args),safety:({inner:e})=>f.exists(K(e),_s)?`fix`:`none`})(e,t):f.none()}const ws=[`Option.getSuccess`,`Result.getSuccess`],Ts=[`Option.getFailure`,`Result.getFailure`],Es=[{inner:[`Option.some`],outer:[`Option.filter`],rewrite:G(`Option.liftPredicate`)},{inner:[`Option.filter`],outer:[`Option.isSome`],rewrite:G(`Option.exists`)},{inner:[`Option.filter`],outer:[`Option.isNone`],rewrite:G(`Option.exists`,{negate:!0})},{inner:[`Option.map`],outer:[`Option.flatten`],rewrite:G(`Option.flatMap`)},{inner:[`Option.map`],outer:[`Option.getOrElse`],rewrite:(e,t)=>f.exists(K(e.outer),as)&&f.exists(K(e.inner),e=>ps(e,t.imports))?G(`Option.exists`,{args:({inner:e})=>ns(t,e.args)})(e,t):G(`Option.match`,{args:rs(`onSome`,`onNone`)})(e,t)},{inner:ws,outer:[`Option.isSome`],rewrite:G(`Result.isSuccess`)},{inner:ws,outer:[`Option.isNone`],rewrite:G(`Result.isFailure`)},{inner:Ts,outer:[`Option.isSome`],rewrite:G(`Result.isFailure`)},{inner:Ts,outer:[`Option.isNone`],rewrite:G(`Result.isSuccess`)},{inner:ws,outer:[`Option.getOrNull`],rewrite:G(`Result.getOrNull`)},{inner:ws,outer:[`Option.getOrUndefined`],rewrite:G(`Result.getOrUndefined`)},{inner:ws,outer:[`Option.getOrElse`],rewrite:G(`Result.getOrElse`,{safety:({outer:e})=>f.exists(K(e),is)?`fix`:`none`})},{inner:[`Array.findFirst`],outer:[`Option.isSome`],rewrite:ys(gs(G(`Array.some`,{safety:fs})))},{inner:[`Array.findFirst`],outer:[`Option.isNone`],rewrite:ys(gs(G(`Array.some`,{negate:!0,safety:fs})))},{inner:[`Array.findFirstIndex`],outer:[`Option.isSome`],rewrite:gs(G(`Array.some`))},{inner:[`Array.findFirstIndex`],outer:[`Option.isNone`],rewrite:gs(G(`Array.some`,{negate:!0}))},{inner:[`Array.filter`],outer:[`Array.head`],rewrite:G(`Array.findFirst`,{safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.isArrayNonEmpty`,`Array.isReadonlyArrayNonEmpty`],rewrite:G(`Array.some`,{safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.isArrayEmpty`,`Array.isReadonlyArrayEmpty`],rewrite:G(`Array.some`,{negate:!0,safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.length`],rewrite:G(`Array.countBy`)},{inner:[`Array.filter`],outer:[`Array.map`],rewrite:Ss},{inner:[`Array.map`],outer:[`Array.filter`],rewrite:Cs},{inner:[`Array.map`],outer:[`Array.flatten`],rewrite:G(`Array.flatMap`)},{inner:[`Array.head`,`Array.last`],outer:[`Option.isSome`],rewrite:G(`Array.isReadonlyArrayNonEmpty`)},{inner:[`Array.head`,`Array.last`],outer:[`Option.isNone`],rewrite:G(`Array.isReadonlyArrayEmpty`)},{inner:[`Array.reverse`],outer:[`Array.head`],rewrite:gs(G(`Array.last`))},{inner:[`Result.map`],outer:[`Result.getOrElse`],rewrite:G(`Result.match`,{args:rs(`onSuccess`,`onFailure`)})},{inner:[`Result.map`],outer:[`Result.mapError`],rewrite:G(`Result.mapBoth`,{args:rs(`onSuccess`,`onFailure`)})},{inner:[`Result.mapError`],outer:[`Result.map`],rewrite:G(`Result.mapBoth`,{args:rs(`onFailure`,`onSuccess`)})}];function Ds(e,t){let n=e.nested&&c.isReadonlyArrayNonEmpty(e.inner.args)&&!c.every(e.outer.args,vs);return c.findFirst(Es,n=>c.contains(n.inner,e.inner.api)&&c.contains(n.outer,e.outer.api)?n.rewrite(e,t):f.none()).pipe(f.map(e=>n?u.assign(e,{safety:`none`}):e))}function Os(e){if(!A(e)||e.async||e.generator||b.isNullish(e.body))return f.none();let t=e.body,n=t.type===`BlockStatement`?c.head(t.body).pipe(f.filter(e=>t.body.length===1&&e.type===`ReturnStatement`),f.flatMapNullishOr(e=>e.argument)):f.some(t);return f.filter(n,e=>e.type===`CallExpression`)}function ks(e,t,n=!1){return(r,{imports:i,sourceCode:a})=>Os(r).pipe(f.filter(t=>A(r)&&b.isNullish(r.returnType)&&(!n||_s(r))&&As(t,e,i)),f.flatMap(e=>Qo(e).pipe(f.filter(e=>e.length===1),f.flatMap(c.head),f.map(n=>{let i=H(a,n),o=n.type===`ObjectExpression`&&r.type===`ArrowFunctionExpression`&&r.body===e?`(${i})`:i;return{api:t,callback:`a callback that returns ${a.getText(e.callee)}(…)`,argument:f.some(js(a,r,e.range,o))}}))))}function As(e,t,n){return f.exists(n.path(e.callee),e=>c.join(e,`.`)===t)}function js(e,t,n,r){let i=e.text,[a,o]=t.range;return`${h.slice(a,v.get(n,0))(i)}${r}${h.slice(v.get(n,1),o)(i)}`}function Ms(e){return(t,{imports:n,sourceCode:r})=>{let i=t.type===`ArrowFunctionExpression`&&!t.async&&t.expression?f.some(t.body):f.none(),a=f.exists(i,e=>e.type===`Literal`&&e.raw===`null`)||n.isApi(t,`Function`,`constNull`),o=f.exists(i,e=>R(r.getScope(e),e,`undefined`))||n.isApi(t,`Function`,`constUndefined`);if(!a&&!o)return f.none();let s=a?`null`:`undefined`;return f.some({api:a?`${e}.getOrNull`:`${e}.getOrUndefined`,callback:`a fallback of ${s}`,argument:f.none()})}}function Ns(e,{imports:t,sourceCode:n}){if(e.type!==`ObjectExpression`||e.properties.length!==2)return f.none();let r=c.getSomes(c.map(e.properties,pe));function i(e){return c.findFirst(r,t=>f.contains(T(t),e)&&!t.shorthand)}return i(`onNone`).pipe(f.filter(e=>r.length===2&&as(e.value)),f.flatMap(()=>i(`onSome`)),f.filter(e=>ps(e.value,t)),f.map(e=>({api:`Option.exists`,callback:"`onNone: () => false`",argument:f.some(H(n,e.value))})))}function Ps(e,{imports:t,sourceCode:n}){return e.type===`CallExpression`&&As(e,`Filter.toOption`,t)?Qo(e).pipe(f.filter(e=>e.length===1),f.flatMap(c.head),f.map(t=>({api:`Option.filterMap`,callback:`${n.getText(e.callee)}(…)`,argument:f.some(H(n,t))}))):f.none()}const Fs=[{apis:[`Option.flatMap`],rewrite:ks(`Option.fromNullishOr`,`Option.flatMapNullishOr`)},{apis:[`Option.flatMap`],rewrite:ks(`Option.some`,`Option.map`)},{apis:[`Option.flatMap`],rewrite:Ps},{apis:[`Option.orElse`],rewrite:ks(`Option.some`,`Option.orElseSome`)},{apis:[`Option.getOrElse`],rewrite:Ms(`Option`)},{apis:[`Option.match`],rewrite:Ns},{apis:[`Result.flatMap`],rewrite:ks(`Result.succeed`,`Result.map`)},{apis:[`Result.getOrElse`],rewrite:Ms(`Result`)},{apis:[`Array.flatMap`],rewrite:ks(`Array.fromNullishOr`,`Array.flatMapNullishOr`,!0)}];function Is(e,t){return f.flatMap(K(e),n=>c.findFirst(Fs,r=>c.contains(r.apis,e.api)?r.rewrite(n,t):f.none()))}const Ls={"Option.getSuccess":`Filter.toOption`,"Result.getSuccess":`Filter.toOption`,"Result.isSuccess":`Filter.toPredicate`};function Rs(e,t){let[n]=e.params;if(e.async||e.generator||e.typeParameters||e.params.length!==1||n?.type!==`Identifier`)return f.none();let r=f.flatMap(W(e),e=>$o(e,t).pipe(f.map(({step:e,self:t})=>v.make(e,t)),f.orElse(()=>ts(e,t).pipe(f.filter(({kind:e,steps:t})=>e===`pipe`&&t.length===1),f.flatMap(({subject:e,steps:n})=>c.head(n).pipe(f.flatMap(e=>es(e,t)),f.product(e)))))));return f.flatMap(r,([e,t])=>f.flatMap(l.get(Ls,e.api),r=>{let[i]=t.type===`CallExpression`?t.arguments:[];return t.type===`CallExpression`&&!t.optional&&t.callee.type!==`Super`&&t.arguments.length===1&&i?.type===`Identifier`&&i.name===n.name&&!k(t.callee,e=>e.type===`ThisExpression`||e.type===`Identifier`&&e.name===n.name)?f.some({check:e,filter:t,api:r}):f.none()}))}function zs(e){return!!e.returnType||c.some(e.params,e=>e.type===`Identifier`&&!!e.typeAnnotation)}function Bs(e){let[t,n=``]=h.split(e,`.`);return[t,n]}function Vs(e,t){return`${e}(${c.join(t,`, `)})`}function Hs(e,t){return c.isReadonlyArrayEmpty(t)?e:Vs(e,t)}function Us(e,t){let n=t.parent;return n?.type===`MemberExpression`&&n.object===t||(n?.type===`CallExpression`||n?.type===`NewExpression`)&&n.callee===t||n?.type===`TaggedTemplateExpression`||n?.type===`BinaryExpression`&&n.operator===`**`&&n.left===t?`(!${e})`:`!${e}`}const Ws={array:`pairIfArray`,boolean:`pairIfBoolean`,fix:`pair`,none:`pair`,pure:`pairIfPure`},Gs=r.define({name:`prefer-direct-effect-combinators`,meta:V({type:`suggestion`,description:`Prefer the direct Effect Option, Array, Result and Filter API over an indirect chain of calls.`,messages:{pair:`Use {{direct}} instead of {{inner}} followed by {{outer}}.`,pairIfPure:`Use {{direct}} instead of {{inner}} followed by {{outer}}. It stops at the first match, so check that the callback has no side effects or exceptions that relied on running for every element.`,pairIfBoolean:`Use {{direct}} instead of {{inner}} followed by {{outer}} if the callback returns a boolean. {{inner}} also accepts a callback that returns an Option, which {{direct}} would treat as a match.`,pairIfArray:`Use {{direct}} instead of {{inner}} followed by {{outer}} if the input is an array. {{direct}} takes an array, while {{inner}} also takes other iterables, such as a Set.`,callback:`Use {{direct}} instead of {{outer}} with {{callback}}.`,filterCheck:`Use {{direct}}({{filter}}) instead of a function that applies {{check}} to the Result of {{filter}}.`,replace:`Replace with {{direct}}.`},url:`https://www.effect.website/docs/v4/api/effect/Option`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let{sourceCode:r}=e,a={imports:n,sourceCode:r};function o(e){return H(r,e)}function l(e){return c.some(r.getAllComments(),t=>c.some(e,e=>Ee({range:e.range},t)))}let p=d.fnUntraced(function*(n){let[r,i]=Bs(n.api),a=yield*f.match(m(n.callees,r),{onNone:()=>Pt(n.node,`effect/${r}`,yr(r)),onSome:e=>d.succeed({name:e,fix:f.none()})}),o=`${a.name}.${i}`,s=n.negate?`!${o}`:o,p=t.fromId({node:n.node,messageId:n.messageId,data:u.assign(n.data,{direct:s})}),h=n.edits(o).pipe(f.filter(e=>!l(e)),f.filter(()=>n.safety!==`none`));if(f.isNone(h))return yield*e.report(p);let g=t.composeFixes(...f.toArray(a.fix),...c.map(h.value,e=>t.replaceText({range:e.range},e.text)));return yield*e.report(n.safety===`fix`?t.withFix(p,g):t.withSuggestions(p,[{messageId:`replace`,data:{direct:s},fix:g}]))});function m(e,t){return c.findFirst(e,e=>e.type===`MemberExpression`&&!e.computed&&f.exists(n.path(e.object),e=>e.length===1&&f.contains(c.head(e),t))?f.some(r.getText(e.object)):f.none())}function h(e,t,n){return f.match(Ds(t,a),{onNone:()=>d.void,onSome:i=>p({node:e,messageId:Ws[i.safety],data:{inner:r.getText(t.inner.callee),outer:r.getText(t.outer.callee)},api:i.api,negate:i.negate,safety:i.safety,edits:e=>n(i,e),callees:[t.inner.callee,t.outer.callee]})})}function g(e,t,n){return e.negate?Us(t,n):t}function _(e){return $o(e,n).pipe(f.flatMap(e=>f.map($o(e.self,n),t=>({outer:e.step,inner:t}))),f.match({onNone:()=>d.void,onSome:({outer:t,inner:n})=>h(e,{inner:n.step,outer:t,input:f.some(n.self),nested:!0},(t,r)=>f.some([{range:e.range,text:g(t,Vs(r,[o(n.self),...t.args]),e)}]))}))}function y({call:e,subject:t,steps:r}){return t.pipe(f.flatMap(e=>$o(e,n)),f.product(f.flatMap(c.head(r),e=>es(e,n))),f.match({onNone:()=>d.void,onSome:([n,i])=>h(i.node,{inner:n.step,outer:i,input:f.some(n.self),nested:!1},(a,s)=>{let l=Vs(s,[o(n.self),...a.args]);return r.length===1?f.some([{range:e.range,text:g(a,l,e)}]):a.negate?f.none():f.product(t,c.get(r,1)).pipe(f.map(([e,t])=>[{range:e.range,text:l},{range:[v.get(i.node.range,0),v.get(t.range,0)],text:``}]))})}))}function x(e){let{kind:t,call:i,steps:a}=e,o=c.map(a,e=>es(e,n));return d.forEach(c.zip(c.dropRight(o,1),c.drop(o,1)),([n,o],s)=>f.product(n,o).pipe(f.match({onNone:()=>d.void,onSome:([n,o])=>h(o.node,{inner:n,outer:o,input:s===0?e.subject:c.get(a,s-1),nested:!1},(e,c)=>{let l=Hs(c,e.args),u=[v.get(n.node.range,0),v.get(o.node.range,1)];return e.negate?t===`pipe`&&s+2===a.length?f.some([{range:i.range,text:Us(js(r,i,u,l),i)}]):f.none():f.some([{range:u,text:l}])})})),{concurrency:1,discard:!0})}function ee(e){return $o(e,n).pipe(f.map(({step:e,self:t})=>v.make(e,f.some(t))),f.orElse(()=>f.map(es(e,n),e=>v.make(e,f.none()))),f.flatMap(([e,t])=>f.map(Is(e,a),n=>({step:e,self:t,rewrite:n}))),f.match({onNone:()=>d.void,onSome:({step:t,self:n,rewrite:i})=>p({node:e,messageId:`callback`,data:{outer:r.getText(t.callee),callback:i.callback},api:i.api,negate:!1,safety:`fix`,edits:t=>{let r=[...n.pipe(f.map(o),f.toArray),...f.toArray(i.argument)];return f.some([{range:e.range,text:f.match(n,{onNone:()=>Hs(t,r),onSome:()=>Vs(t,r)})}])},callees:[t.callee]})}))}function S(e){return f.match(Rs(e,n),{onNone:()=>d.void,onSome:({check:t,filter:i,api:a})=>{let o=b.isNullish(i.typeArguments)&&Go(i.callee,n)&&Jo(r,i.callee,e);return p({node:e,messageId:`filterCheck`,data:{check:r.getText(t.callee),filter:r.getText(i.callee)},api:a,negate:!1,safety:o?zs(e)?`suggest`:`fix`:`none`,edits:t=>f.some([{range:e.range,text:Vs(t,[H(r,i.callee)])}]),callees:[i.callee]})}})}return s.merge(s.on(`CallExpression`,e=>d.andThen(d.all([_(e),ee(e)],{concurrency:1,discard:!0}),f.match(ts(e,n),{onNone:()=>d.void,onSome:e=>d.all([y(e),x(e)],{concurrency:1,discard:!0})}))),s.on(`ArrowFunctionExpression`,S),s.on(`FunctionExpression`,S))}}),Ks=r.define({name:`prefer-effect-alchemy-namespace-imports`,meta:V({type:`suggestion`,description:`Use consistently aliased namespace imports for Effect and Alchemy submodule entrypoints.`,messages:{alias:"Import {{source}} as the canonical namespace alias `{{alias}}`.",namespace:'Use `import * as {{alias}} from "{{source}}"` instead of importing values directly.'},url:`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/core/AutoImport.ts`,fixable:`code`}),*create(){let e=yield*i;function n(n,r){let i={alias:r,source:n.source.value};function a(r,a){return e.report(Lt(t.fromId({node:r,messageId:a,data:i}),Er(e.sourceCode,n)))}return d.forEach(c.filter(n.specifiers,e=>e.type!==`ImportSpecifier`||!vr(n,e)),e=>e.type===`ImportNamespaceSpecifier`?e.local.name===r?d.void:a(e.local,`alias`):a(e,`namespace`),{concurrency:1,discard:!0})}return s.on(`ImportDeclaration`,e=>xr(e.source.value).pipe(f.filter(()=>e.importKind!==`type`),f.match({onNone:()=>d.void,onSome:t=>n(e,yr(t))})))}});function qs(e){let[t,n]=h.split(e,`/`);return b.isNotUndefined(n)&&h.startsWith(`@`)(t)?`${t}/${n}`:t}function Js(e){return e.importKind===`type`||c.isReadonlyArrayNonEmpty(e.specifiers)&&c.every(e.specifiers,e=>e.type===`ImportSpecifier`&&e.importKind===`type`)}function Ys(e){return s.merge(s.on(`ImportDeclaration`,t=>Js(t)?d.void:e(t.source,f.some(t))),s.on(`ImportExpression`,({source:t})=>N(t)?e(t,f.none()):d.void))}const Xs={"@zip.js/zip.js":`Zip`,"adm-zip":`Zip`,archiver:`Zip or Tar`,"client-zip":`Zip`,jszip:`Zip`,"js-untar":`Tar`,"modern-tar":`Tar`,nanotar:`Tar`,"node-stream-zip":`Zip`,"tar-js":`Tar`,"tar-stream":`Tar`,unzipper:`Zip`,yauzl:`Zip`,"yauzl-promise":`Zip`,yazl:`Zip`,"zip-stream":`Zip`},Zs=m.Literals([`AsyncUnzipInflate`,`AsyncZipDeflate`,`Unzip`,`UnzipInflate`,`UnzipPassThrough`,`Zip`,`ZipDeflate`,`ZipPassThrough`,`unzip`,`unzipSync`,`zip`,`zipSync`]),Qs=m.is(Zs);function $s(e){return f.match(e,{onNone:()=>[],onSome:({specifiers:e})=>c.filter(e,e=>e.type===`ImportSpecifier`&&e.importKind!==`type`&&Qs(fe(e.imported)))})}const ec=r.define({name:`prefer-effect-archive`,meta:V({type:`suggestion`,description:`Prefer Effect Tar and Zip over tar and zip libraries in Effect projects.`,messages:{archive:`Use {{module}} from effect/encoding instead of {{source}}: its decode and encode channels stream entries without buffering whole bodies.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Zip`}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};function n(n,r,i){return e.report(t.fromId({node:n,messageId:`archive`,data:{module:i,source:r}}))}return Ys((e,t)=>{let r=qs(e.value);return r===`fflate`?d.forEach($s(t),e=>n(e,`fflate`,`Zip`),{concurrency:1,discard:!0}):f.match(l.get(Xs,r),{onNone:()=>d.void,onSome:t=>n(e,e.value,t)})})}});function tc(e,t){return e?.type===`NewExpression`&&e.arguments.length===1&&R(t,e.callee,`Set`)}function nc(e,t){if(e.type===`ArrayExpression`){let[n]=e.elements;return e.elements.length===1&&n?.type===`SpreadElement`&&tc(n.argument,t)}return e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`from`)&&R(t,e.callee.object,`Array`)&&e.arguments.length===1&&f.exists(D(e,0),e=>tc(e,t))}function rc(e){let t=e.parent;return t.type===`AssignmentExpression`&&t.left===e||t.type===`UpdateExpression`||t.type===`UnaryExpression`&&t.operator===`delete`}function ic(e,t){let n=t.getText(e.object);return k(f.getOrElse(we(e),()=>t.ast),e=>e.type===`MemberExpression`&&e.computed&&e.property.type===`Literal`&&b.isNumber(e.property.value)&&e.property.value!==0&&t.getText(e.object)===n)}function ac(e){return e.type===`MemberExpression`&&f.contains(C(e),`length`)}const oc={"!=":`nonEmpty`,"!==":`nonEmpty`,"==":`empty`,"===":`empty`};function sc(e){let t=O(e.left),n=O(e.right);return ac(t)&&P(n,0)?e.operator===`>`?f.some(`nonEmpty`):l.get(oc,e.operator):P(t,0)&&ac(n)?e.operator===`<`?f.some(`nonEmpty`):l.get(oc,e.operator):f.none()}function cc(e){let t=e.callee;return t.type===`MemberExpression`?C(t):t.type===`Identifier`?f.some(t.name):f.none()}function lc(e){if(e.type!==`ArrowFunctionExpression`||e.async||!e.expression||e.params.length!==1)return f.none();let[t]=e.params,n=O(e.body);return t?.type===`Identifier`&&n.type===`MemberExpression`&&n.object.type===`Identifier`&&n.object.name===t.name?C(n):f.none()}const uc=r.define({name:`prefer-effect-array-ops`,meta:V({type:`suggestion`,description:`Prefer Effect Array and Struct helpers over hand-written array idioms in Effect files.`,messages:{dedupe:`Use Arr.dedupe instead of deduplicating through a Set.`,head:`Use Arr.head, which returns an Option, instead of indexing the first element (Tuple.get for tuples).`,empty:"Use Arr.isReadonlyArrayEmpty (Str.isEmpty for strings) instead of comparing `.length` with 0.",nonEmpty:"Use Arr.isReadonlyArrayNonEmpty (Str.isNonEmpty for strings), which narrows to a non-empty array, instead of comparing `.length` with 0.",structGet:`Use Struct.get('{{key}}') instead of a property accessor lambda.`},url:`https://www.effect.website/docs/v4/api/effect/Array`}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};function n(n){return d.flatMap(o.getScope(n),r=>nc(n,r)?e.report(t.fromId({node:n,messageId:`dedupe`})):d.void)}function r(n){return f.contains(cc(n),`map`)?d.forEach(n.arguments,n=>f.match(lc(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`structGet`,data:{key:r}}))}),{concurrency:1,discard:!0}):d.void}return s.merge(s.on(`ArrayExpression`,n),s.on(`CallExpression`,n=>d.flatMap(o.getScope(n),i=>nc(n,i)?e.report(t.fromId({node:n,messageId:`dedupe`})):r(n))),s.on(`MemberExpression`,n=>n.computed&&P(n.property,0)&&!rc(n)&&!ic(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`head`})):d.void),s.on(`BinaryExpression`,n=>f.match(sc(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:r}))})))}}),dc=r.define({name:`prefer-effect-array-sort`,meta:V({type:`suggestion`,description:`Prefer immutable, Order-based Effect Array sorting in Effect projects.`,messages:{effectArraySort:`Use Arr.sort with an Order instead of the mutable native Array.sort method.`},url:`https://www.effect.website/docs/v4/api/effect/Array#sort`}),*create(){let e=yield*i,n=yield*B;return n.hasEffectImport?s.on(`CallExpression`,r=>r.callee.type===`MemberExpression`&&f.contains(C(r.callee),`sort`)&&!n.isApi(r.callee,`Array`,`sort`)?e.report(t.fromId({node:r,messageId:`effectArraySort`})):d.void):{}}}),fc=m.Literals([`cookie`,`set-cookie`]),pc=m.is(fc),mc=m.Literals([`split`,`match`,`matchAll`]),hc=m.is(mc),gc=m.Literals([`includes`,`startsWith`,`endsWith`]),_c=m.is(gc),vc=/;\s*(?:HttpOnly|Secure|Partitioned|(?:Path|Domain|Max-Age|Expires|SameSite)=)/iu,yc=/^(?:;\s*(?:HttpOnly|Secure|Partitioned|Path|Domain|Max-Age|Expires|SameSite)\b|HttpOnly$|Max-Age=|SameSite=)/iu;function bc(e){return h.includes(`cookie`)(h.toLowerCase(e))}function xc(e){let t=O(e),n=t.type===`ChainExpression`?f.some(t.expression):t.type===`LogicalExpression`?f.some(t.left):t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`String`?D(t,0):f.none();return f.match(n,{onNone:()=>t,onSome:xc})}const Sc=_.type().pipe(_.discriminators(`type`)({Identifier:({name:e})=>bc(e),MemberExpression:e=>f.exists(C(e),bc),CallExpression:e=>f.contains(wc(e),`get`)&&c.some(e.arguments,e=>N(e)&&pc(h.toLowerCase(e.value)))}),_.orElse(g.constFalse));function Cc(e){return Sc(xc(e))}function wc(e){return e.callee.type===`MemberExpression`?C(e.callee):f.none()}function Tc(e){return e.callee.type===`MemberExpression`&&e.callee.object.type!==`Super`?f.some(e.callee.object):f.none()}function Ec(e){return f.exists(wc(e),t=>hc(t)?f.exists(Tc(e),Cc):t===`exec`&&f.exists(D(e,0),Cc))}function Dc(e,t){let n=f.orElse(wc(e),()=>t.member(e.callee,`String`));return f.exists(n,_c)&&f.exists(D(e,0),e=>N(e)&&yc.test(e.value))}function Oc(e){return c.isReadonlyArrayNonEmpty(e.expressions)&&c.some(e.quasis,e=>vc.test(e.value.cooked??e.value.raw))}function kc(e){return N(e)&&vc.test(e.value)}const Ac=r.define({name:`prefer-effect-cookies`,meta:V({type:`suggestion`,description:`Prefer the Effect Cookies module over parsing, building and inspecting cookie strings by hand.`,messages:{documentCookie:`document.cookie is one unparsed string. Parse it with Cookies.parseHeader, and write cookies from the server with HttpServerResponse.setCookie.`,parseCookies:`Read request cookies with HttpServerRequest cookies or schemaCookies, or parse a header with Cookies.parseHeader or Cookies.fromSetCookie, instead of splitting or matching it by hand.`,serializeCookie:`Build cookies with Cookies.makeCookie and Cookies.serializeCookie, or HttpServerResponse.setCookie, which validate names, values and attributes.`,inspectCookie:`Parse Set-Cookie headers with Cookies.fromSetCookie and read the attributes from Cookies.get(…).options, instead of searching the string for them.`},url:`https://www.effect.website/docs/v4/api/effect/http/Cookies`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r(n,r){return e.report(t.fromId({node:n,messageId:r}))}function a(e){return!f.exists(M(e,`CallExpression`),t=>F(t.arguments,e)&&f.isSome(n.member(t.callee,`Cookies`)))&&f.contains(C(e),`cookie`)?je(e.object,`document`):d.succeed(!1)}return s.merge(s.on(`MemberExpression`,e=>d.when(r(e,`documentCookie`),a(e))),s.on(`CallExpression`,e=>Ec(e)?r(e,`parseCookies`):Dc(e,n)?r(e,`inspectCookie`):d.void),s.on(`TemplateLiteral`,e=>Oc(e)&&e.parent.type!==`TaggedTemplateExpression`?r(e,`serializeCookie`):d.void),s.on(`BinaryExpression`,e=>e.operator===`+`&&(kc(e.right)&&!N(e.left)||kc(e.left)&&!N(e.right))?r(e,`serializeCookie`):d.void))}});function jc(e){return N(e)?f.some(e.value):e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)?f.flatMapNullishOr(c.head(e.quasis),({value:e})=>e.cooked):f.none()}function Mc(e){return e.type===`Literal`&&`regex`in e&&b.isNotNullish(e.regex)?f.some(e.regex.pattern):f.none()}const Nc=/^(?:\(\?:|[()|?*+[\]]|\\r|\\n)+$/u;function Pc(e){return f.exists(jc(e),e=>e===`
|
|
1
|
+
import"effect/schema/SchemaJITCompiler/enable";import{AST as e,Diagnostic as t,Plugin as n,Rule as r,RuleContext as i,Scope as a,SourceCode as o,Visitor as s}from"effect-oxlint";import*as c from"effect/Array";import*as l from"effect/Record";import*as u from"effect/Struct";import*as d from"effect/Effect";import*as f from"effect/Option";import*as p from"effect/Ref";import*as m from"effect/Schema";import*as h from"effect/String";import*as g from"effect/Match";import*as _ from"effect/Tuple";import*as ee from"effect/Equivalence";import*as v from"effect/Function";import*as y from"effect/Predicate";import*as b from"effect/HashSet";import*as te from"effect/Result";import*as x from"effect/Duration";import*as ne from"effect/Number";import*as re from"effect/HashMap";import*as ie from"effect/Order";import*as ae from"effect/http/HttpMethod";import*as oe from"effect/http/HttpStatus";const se=m.Literals([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]),ce=se.pick([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]),le=m.Literals([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),ue=le.pick([`ArrowFunctionExpression`,`FunctionExpression`]),de=m.Literals([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),fe=m.Literals([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),pe=m.Literals([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]),me=m.Literals([`TSNullKeyword`,`TSNumberKeyword`,`TSUndefinedKeyword`]),he=m.Literals([`==`,`===`,`!=`,`!==`]),ge=he.pick([`!==`,`!=`]),_e=m.Literals([`*`,`+`,`-`,`/`]),ve=m.Literals([`global`,`module`]),ye=m.is(se),be=m.is(he),xe=m.is(ue),Se=g.type().pipe(g.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e})),S=g.type().pipe(g.when({computed:!1,property:{type:`Identifier`}},({property:e})=>f.some(e.name)),g.when({computed:!0,property:{type:`Literal`,value:h.isString}},({property:e})=>f.some(e.value)),g.orElse(()=>f.none()));function C(e){let t=e.type===`ChainExpression`?e.expression:e;return t.type===`Identifier`?f.some(c.of(t.name)):t.type===`MemberExpression`?f.zipWith(C(t.object),S(t),(e,t)=>c.append(e,t)):f.none()}const Ce=v.dual(2,(e,t)=>e.length===2&&f.contains(c.head(e),t)?c.get(e,1):f.none()),w=g.type().pipe(g.when({computed:!1,key:{type:`Identifier`}},({key:e})=>f.some(e.name)),g.when({key:{type:`Literal`,value:h.isString}},({key:e})=>f.some(e.value)),g.orElse(()=>f.none())),we=g.type().pipe(g.when({type:`Property`,computed:!1,method:!1,kind:`init`},f.some),g.orElse(()=>f.none())),T=v.dual(2,(e,t)=>c.findFirst(e.properties,e=>e.type===`Property`&&f.contains(w(e),t)));function E(e,t){return f.filter(c.get(e.arguments,t),e=>e.type!==`SpreadElement`)}function Te(e){return c.findFirst(e.arguments,e=>e.type===`ObjectExpression`)}function Ee(e){return ye(e.type)}function D(e){return Ee(e)?D(e.expression):e}const De=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function Oe(e){return c.isArray(e)?e:c.map(c.filter(l.toEntries(e),([e])=>!De.has(e)),([,e])=>e)}function ke(e){return y.hasProperty(e,`type`)&&y.isString(e.type)}function O(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;c.isArrayNonEmpty(n);){let e=n.pop();if(y.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),ke(e)&&t(e))return!0;n.push(...Oe(e))}}return!1}function Ae(e,t){return O(e,e=>e.type===`Identifier`&&e.name===t)}function k(e){return y.isNotNullish(e)&&xe(e.type)}const je=g.type().pipe(g.when({type:`VariableDeclaration`,kind:`const`},v.constTrue),g.orElse(v.constFalse));function Me(e){return f.filter(c.head(e.params),e=>e.type===`Identifier`)}function Ne(e){return f.exists(Me(e),t=>y.isNotNullish(e.body)&&!h.startsWith(`_`)(t.name)&&Ae(e.body,t.name))}function A(e){return f.fromNullishOr(e.parent)}function j(t,n){return f.filter(A(t),t=>f.isSome(e.narrow(t,n)))}function Pe(e,t){return f.flatMap(A(e),e=>t(e)?f.some(e):Pe(e,t))}function Fe(e){return Pe(e,k)}function Ie(e){return f.filter(j(e,`CallExpression`),t=>P(t.arguments,e))}function Le(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function M(e){return e.type===`Literal`&&h.isString(e.value)}const N=v.dual(2,(e,t)=>e.type===`Literal`&&e.value===t);function Re(e){return f.exists(A(e),t=>t.type===`ExpressionStatement`||t.type===`UnaryExpression`&&t.operator===`void`||t.type===`SequenceExpression`&&f.exists(c.last(t.expressions),t=>t!==e))}function ze(e){return C(e.callee).pipe(f.map(c.lastNonEmpty),f.exists(h.endsWith(`Error`)))}function P(e,t){return c.containsWith(ee.strictEqual())(e,t)}function F(e,t){return f.containsWith(ee.strictEqual())(e,t)}const Be=m.String.check(m.isPattern(/^(?:effect(?:\/.*)?|@effect\/.*)$/u)),Ve=m.String.check(m.isPattern(/^@effect\/vitest(?:\/.*)?$/u)),He=m.String.check(m.isPattern(/^@effect\/[^/]+$/u)),Ue=m.String.check(m.isPattern(/^@effect\/[^/]+\//u)),We=m.String.check(m.isPattern(/^\.\.?\//u)),Ge=m.Literals([`fs`,`fs/promises`]),Ke=m.Union([Ge,m.TemplateLiteral([`node:`,Ge])]),qe=m.Literal(`path`),Je=m.Union([qe,m.TemplateLiteral([`node:`,qe])]),Ye=m.Literals([`@tsndr/cloudflare-worker-jwt`,`fast-jwt`,`hono/jwt`,`jose`,`jsonwebtoken`,`jwt-decode`,`jwt-simple`]),Xe=m.Literals([`ip`,`ip-address`,`ip-range-check`,`ip-regex`,`ipaddr.js`,`is-ip`,`is-localhost-ip`,`netmask`,`private-ip`]),Ze=m.Literals([`@microsoft/fetch-event-source`,`better-sse`,`event-source-polyfill`,`eventsource`,`eventsource-client`,`eventsource-parser`,`extended-eventsource`,`fetch-event-stream`,`reconnecting-eventsource`,`sse.js`]),Qe=m.Literals([`appdirsjs`,`application-config-path`,`env-paths`,`os-homedir`,`platform-folders`,`user-home`,`xdg-app-paths`,`xdg-basedir`]),$e=m.Literals([`AsyncUnzipInflate`,`AsyncZipDeflate`,`Unzip`,`UnzipInflate`,`UnzipPassThrough`,`Zip`,`ZipDeflate`,`ZipPassThrough`,`unzip`,`unzipSync`,`zip`,`zipSync`]),et=m.Array(m.String);var tt=class extends m.Class(`ImportBindings`)({bindings:m.ReadonlyMap(m.String,et),hasEffectImport:m.Boolean}){path(e){return f.flatMap(C(e),([e,...t])=>f.fromNullishOr(this.bindings.get(e)).pipe(f.map(e=>[...e,...t])))}isApi(e,t,n){let r=h.isString(n)?[n]:n;return f.exists(this.member(e,t),e=>c.contains(r,e))}member(e,t){return f.flatMap(this.path(e),Ce(t))}isApiPath(e,t){return f.exists(this.path(e),e=>c.makeEquivalence(h.Equivalence)(e,t))}};function I(e,t,n){return a.findVariableUp(e.getScope(t),n)}function nt(e,t){return d.map(o.getScope(e),a.findVariableUp(t))}function rt(e){return e.pipe(f.filter(({defs:e})=>e.length===1),f.flatMap(({defs:e})=>c.head(e)))}function L(e,t,n){return t.type===`Identifier`&&t.name===n&&!f.exists(a.findVariableUp(e,n),({defs:e})=>c.isArrayNonEmpty(e))}function it(e,t){return e.type===`Identifier`&&e.name===t?d.map(o.getScope(e),n=>L(n,e,t)):d.succeed(!1)}function R(e,t){return C(t).pipe(f.flatMap(n=>I(e,t,c.headNonEmpty(n))),f.exists(({defs:e})=>c.some(e,({type:e,node:t})=>e===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`))))}function at(e){return d.map(d.service(i),({sourceCode:t})=>R(t,e))}const ot=d.map(d.service(i),({sourceCode:e})=>new Set(c.flatMap(e.scopeManager.scopes,e=>[...c.map(e.variables,({name:e})=>e),...c.map(e.references,({identifier:e})=>e.name)]))),st=m.is(Be);function ct(e){let t=c.lastNonEmpty(h.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const lt=g.type().pipe(g.when(`alchemy`,()=>f.some([`Alchemy`])),g.when(`@alchemy.run/domain`,()=>f.some([`Domain`])),g.when(g.is(`effect`,`@effect/platform`),()=>f.some([])),g.whenOr(h.startsWith(`effect/`),h.startsWith(`alchemy/`),h.startsWith(`@effect/`),e=>f.some(ct(e))),g.orElse(()=>f.none()));function ut(e,t){return c.map(e.specifiers,e=>_.make(e.local.name,e.type===`ImportSpecifier`?[...t,Se(e.imported)]:t))}function dt(e){let t=c.filter(e.body,e=>e.type===`ImportDeclaration`);return tt.make({bindings:new Map(c.flatMap(t,e=>f.match(lt(e.source.value),{onNone:()=>[],onSome:t=>ut(e,t)}))),hasEffectImport:c.some(t,e=>st(e.source.value))})}function ft(e,t,n){let r=c.flatMap(e.ast.body,e=>e.type===`ImportDeclaration`&&c.contains(n,e.source.value)?e.specifiers:[]),i=f.flatMap(C(t),([e,...t])=>f.flatMap(c.findFirst(r,({local:t})=>t.name===e),e=>e.type===`ImportSpecifier`?c.isReadonlyArrayEmpty(t)?f.some(Se(e.imported)):f.none():t.length===1?c.head(t):f.none()));return f.filter(i,()=>R(e,t))}const z=d.map(d.service(i),e=>dt(e.sourceCode.ast));function B(e){let{url:t,docs:n,...i}=e;return r.meta({schema:[],...i,docs:{recommended:!0,...t===void 0?{}:{url:t},...n}})}const pt=m.Literals([`Aggregate`,`Api`,`Command`,`Event`,`ExternalSystem`,`Model`,`Policy`,`Projection`,`Rejection`,`RequestContext`,`Saga`,`Stream`,`View`]),mt=m.String.check(m.isPattern(/\.(?:aggregate|api|command|context|event|external|id|middleware|model|policy|projection|rejection|saga|stream|view)\.[cm]?tsx?$/u)),ht=m.Literals([`command`,`external`,`stream`]),gt=m.Literals([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),_t=m.Literals([`Secret`,`Variable`]),vt=m.String.check(m.isPattern(/\.(?:test|spec)\.[cm]?[jt]sx?$/u)),yt=m.String.check(m.isPattern(/\.stories?\.[cm]?[jt]sx?$/u)),bt=m.Union([vt,yt]),xt=m.String.check(m.isPattern(/\.d\.[cm]?ts$/u)),St=m.String.check(m.isPattern(/\.[cm]?tsx?$/u)),Ct=m.String.check(m.isPattern(/^\p{Lu}/u)),wt=m.Union([Ct,m.String.check(m.isPattern(/^use\p{Lu}/u))]),Tt=m.String.check(m.isPattern(/^_?[A-Z]/u)),Et=m.String.check(m.isPattern(/^use[A-Z0-9]/u)),Dt=m.String.check(m.isPattern(/^is\p{Lu}/u)),Ot=m.String.check(m.isPattern(/^make[A-Z]/u)),kt=m.String.check(m.isPattern(/^\p{Lu}[^_]*$/u)),At=m.Literals([`min`,`max`]),jt=m.String.check(m.isPattern(/min|max|lower|upper|bound|limit|^(?:lo|hi|low|high)$/iu)),Mt=m.Literals([`error`,`err`,`e`,`cause`,`exception`,`ex`]),Nt=m.Literals([`status`,`statusCode`]),Pt=m.String.check(m.isPattern(/[A-Z]/u)),Ft=m.Literals([`Extract`,`Exclude`]),It=m.is(pt);function Lt(e,t,n){return f.exists(rt(I(e,t,n)),({type:e})=>e===`ImportBinding`)}function Rt(e,t){return C(e).pipe(f.filter(n=>Lt(t.sourceCode,e,c.headNonEmpty(n))),f.flatMap(()=>t.imports.path(e)))}function zt(e,t){return Rt(e.callee,t).pipe(f.flatMap(Ce(`Domain`)),f.filter(It))}function Bt(e,t){let{parent:n}=e;return n.type===`MemberExpression`&&n.property===e&&!n.computed||n.type===`Property`&&n.key===e&&n.value!==e?!1:Lt(t,n,e.name)}function Vt(e){return y.isNotNull(e)&&ye(e.type)?Vt(e.parent):e}function Ht(e,t){if(e.type!==`ObjectExpression`)return f.none();let n=Vt(e.parent);return n?.type===`CallExpression`&&f.exists(E(n,1),t=>D(t)===e)?zt(n,t):f.none()}function Ut(e,t){return f.flatMap(A(e),n=>{let r=n.type===`Property`&&n.value===e?Ht(n.parent,t):f.none();return f.match(r,{onNone:()=>Ut(n,t),onSome:e=>f.map(w(n),t=>({block:e,section:t}))})})}const Wt={Aggregate:`aggregate`,Api:`api`,Command:`command`,ExternalSystem:`external`,Model:`model`,Policy:`policy`,Projection:`projection`,RequestContext:`context`,Saga:`saga`,Stream:`stream`,View:`view`},Gt={Event:`event`,Rejection:`rejection`},Kt=m.is(ht),qt=m.is(bt),Jt=r.define({name:`alchemy-domain-block-file-name`,meta:B({type:`suggestion`,description:"Require one Alchemy Domain block per file, named `<Noun>.<kind>.ts`.",messages:{fileName:"Declare this {{block}} in its own `<Noun>.{{kind}}.ts` file.",oneBlock:"Move this {{block}} to its own `<Noun>.{{kind}}.ts` file. Each file declares one Domain block."},url:`https://alchemy.run/domain`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*z},r=c.lastNonEmpty(h.split(e.filename,/[/\\]/u));if(qt(r))return{};let a=h.split(r,`.`),o=a.length>=3&&h.isNonEmpty(c.headNonEmpty(a))?c.get(a,a.length-2):f.none(),u=f.exists(o,Kt),m=yield*p.make(!1),g=yield*p.make(!1);function _(e){return e.type===`CallExpression`?f.flatMap(zt(e,n),t=>l.get(Wt,t).pipe(f.orElse(()=>l.get(Gt,t)),f.map(n=>({node:e.callee,block:t,kind:n})))):f.none()}function ee({block:e}){return u&&l.has(Gt,e)}function v(n,{node:r,block:i,kind:a}){return e.report(t.fromId({node:r,messageId:n,data:{block:i,kind:a}}))}let y=yield*s.accumulate(`CallExpression`,e=>f.filter(_(e),ee),e=>d.flatMap(p.get(g),t=>t?d.void:d.forEach(e,e=>v(`fileName`,e),{concurrency:1,discard:!0}))),b=d.fnUntraced(function*(e){let t=f.contains(o,e.kind);t&&u&&(yield*p.set(g,!0)),(yield*p.getAndSet(m,!0))?yield*v(`oneBlock`,e):t||(yield*v(`fileName`,e))});return s.merge(y,s.on(`CallExpression`,e=>_(e).pipe(f.filter(e=>!ee(e)),f.match({onNone:()=>d.void,onSome:b}))))}}),Yt=m.Literals([`catch`,`catchIf`,`catchTag`,`orElseSucceed`,`catchAll`,`catchAllCause`,`catchSome`,`catchSomeCause`,`orElse`,`orElseFail`]),Xt=Yt.pick([`catch`,`catchAll`,`catchIf`]),Zt=m.Literals([...Yt.pick([`catch`,`catchAll`]).literals,`catchCause`,`mapError`]),Qt=m.Literals([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),$t=m.Literals([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]),en=m.Literals([`promise`,`tryPromise`]),tn=m.Literals([`when`,`not`]),nn=m.Literals([`Option`,`Result`]),rn=m.Literals([`getOrThrow`,`getOrThrowWith`]),an=m.Literals([`BigDecimal`,`Config`,`Data`,`DateTime`,`Duration`,`Effect`,`Equivalence`,`Exit`,`Function`,`Layer`,`Match`,`Option`,`Order`,`Predicate`,`Result`,`Schedule`,`Schema`,`Stream`,`String`,`Struct`,`flow`,`pipe`]),on=an.pick([`BigDecimal`,`Data`,`DateTime`,`Duration`,`Exit`,`Option`,`Result`,`String`,`Struct`,`pipe`]),sn=m.Literals([`pipe`,`value`,`valueTags`]),cn=m.Literals([`Array`,`Chunk`,`HashMap`,`HashSet`,`Iterable`,`MutableHashMap`,`MutableHashSet`,`MutableList`,`Record`,`Trie`,`Tuple`,`TxChunk`,`TxHashMap`]),ln=m.Literals(/* @__PURE__ */ `Channel.acquireRelease,Channel.acquireUseRelease,Channel.catchCauseFilter,Channel.catchReason,Channel.combine,Channel.filterArrayEffect,Channel.fromTransform,Channel.fromTransformBracket,Channel.map,Channel.mapAccum,Channel.mapEffect,Channel.runFold,Channel.runFoldEffect,Channel.scan,Channel.scanEffect,Channel.transformPull,Combiner.make,Duration.matchPair,Effect.acquireRelease,Effect.acquireUseRelease,Effect.catchCauseFilter,Effect.catchReason,Effect.effectify,Effect.filter,Effect.findFirst,Effect.findFirstFilter,Effect.forEach,Effect.onErrorFilter,Effect.onExitFilter,Effect.partition,Effect.reduce,Effect.repeatOrElse,Effect.retryOrElse,Effect.tapCauseFilter,Effect.validate,Effect.zipWith,Equivalence.make,Filter.zipWith,Graph.complement,Graph.findEdge,Graph.findEdges,Graph.floydWarshall,Layer.fromBuild,Layer.fromBuildMemo,Metric.mapInput,Optic.fromChecks,Optic.makeLens,Optic.makeOptional,Option.containsWith,Option.lift2,Option.reduceCompact,Option.zipWith,Order.make,Reducer.make,RequestResolver.around,RequestResolver.make,RequestResolver.makeGrouped,RequestResolver.makeWith,Schema.makeFilter,Schema.makeIsMultipleOf,Schema.middlewareDecoding,Schema.middlewareEncoding,SchemaGetter.checkEffect,SchemaGetter.fail,SchemaGetter.transformEffect,SchemaGetter.transformOptionalEffect,SchemaTransformation.transformEffect,Sink.fold,Sink.foldArray,Sink.foldUntil,Sink.fromTransform,Sink.reduce,Sink.reduceArray,Sink.reduceEffect,Sink.reduceWhile,Sink.reduceWhileArray,Sink.reduceWhileArrayEffect,Sink.reduceWhileEffect,Sink.summarized,Stream.catchCauseFilter,Stream.catchReason,Stream.changesWith,Stream.changesWithEffect,Stream.combine,Stream.combineArray,Stream.crossWith,Stream.dropUntil,Stream.dropUntilEffect,Stream.dropWhile,Stream.dropWhileEffect,Stream.filterEffect,Stream.map,Stream.mapAccum,Stream.mapAccumArray,Stream.mapAccumArrayEffect,Stream.mapAccumEffect,Stream.mapArray,Stream.mapArrayEffect,Stream.mapEffect,Stream.runFold,Stream.runFoldEffect,Stream.scan,Stream.scanEffect,Stream.takeUntil,Stream.takeUntilEffect,Stream.takeWhile,Stream.takeWhileEffect,Stream.transformPull,Stream.transformPullBracket,Stream.zipLatestWith,Stream.zipWith,Stream.zipWithArray,TextDiff.diffWith,TxHashSet.reduce`.split(`,`)),un=m.Literals([`Match`]),dn=m.Literals(/* @__PURE__ */ `flip.fromFormData.fromJsonString.fromURLSearchParams.mutable.mutableKey.NullishOr.NullOr.optional.optionalKey.OptionFromNullishOr.OptionFromNullOr.OptionFromOptional.OptionFromOptionalKey.OptionFromOptionalNullOr.OptionFromUndefinedOr.readonlyKey.RedactedFromValue.required.requiredKey.toCodecArrayFromSingle.toCodecGoJson.toCodecIso.toCodecJson.toCodecStringTree.toEncoded.toType.UndefinedOr`.split(`.`)),fn=dn.pick([`NullOr`,`NullishOr`,`UndefinedOr`,`optional`,`optionalKey`]),pn=m.Literals([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),mn=m.Literals(/* @__PURE__ */ `annotate.annotateEncoded.annotateKey.brand.catchDecoding.catchDecodingWithContext.catchEncoding.catchEncodingWithContext.check.decode.decodeTo.encode.encodeKeys.encodeTo.extendTo.fieldsAssign.fromBrand.middlewareDecoding.middlewareEncoding.overrideToCodecIso.overrideToEquivalence.overrideToFormatter.refine.toTaggedUnion.withConstructorDefault.withDecodingDefault.withDecodingDefaultKey.withDecodingDefaultType.withDecodingDefaultTypeKey`.split(`.`)),hn=mn.pick([`annotate`,`annotateEncoded`,`annotateKey`]),gn=mn.pick([`annotate`,`annotateKey`,`brand`,`check`,`withConstructorDefault`,`withDecodingDefault`,`withDecodingDefaultKey`]),_n=m.Literals([`annotate`,`annotateKey`,`check`,`mapFields`]),vn=_n.pick([`annotate`,`check`]),yn=m.Literals([`mapElements`,`mapFields`,`mapMembers`]),bn=m.Literals([`Finite`,`FiniteFromString`,`Int`,`Number`,`NumberFromString`]),xn=m.Literals(/* @__PURE__ */ `asserts.decodeEffect.decodeExit.decodeOption.decodePromise.decodeResult.decodeSync.decodeUnknownEffect.decodeUnknownExit.decodeUnknownOption.decodeUnknownPromise.decodeUnknownResult.decodeUnknownSync.encodeEffect.encodeExit.encodeOption.encodePromise.encodeResult.encodeSync.encodeUnknownEffect.encodeUnknownExit.encodeUnknownOption.encodeUnknownPromise.encodeUnknownResult.encodeUnknownSync.is`.split(`.`)),Sn={"Date.now":`time`,"performance.now":`time`,"performance.timeOrigin":`time`,"Math.random":`random`,"crypto.randomUUID":`random`,"crypto.getRandomValues":`random`},Cn={Clock:`time`,Random:`random`,SecureRandom:`random`},wn={"DateTime.now":`time`,"DateTime.nowAsDate":`time`,"DateTime.nowInCurrentZone":`time`,"DateTime.nowUnsafe":`time`,"DateTime.isFuture":`time`,"DateTime.isFutureUnsafe":`time`,"DateTime.isPast":`time`,"DateTime.isPastUnsafe":`time`,"Aead.Aead":`random`,"Cipher.Cipher":`random`,"Signature.Signature":`random`,"KeyAgreement.KeyAgreement":`random`,"KeyWrap.KeyWrap":`random`,"Jwk.generateKeyPair":`random`,"Jwk.generateSecret":`random`,"Jwe.encrypt":`random`,"Jws.sign":`random`,"Jws.verifyWithKeySet":`io`,"Jwt.sign":`random`,"Jwt.encrypt":`random`,"Jwt.verify":`time`,"Jwt.verifyWithKeySet":`time`,"Jwt.decrypt":`time`,"Jwks.Jwks":`io`,"Jwks.makeRemote":`io`,"Jwks.layerRemote":`io`},Tn=m.is(en);function En(e){let t=e;for(;t.type===`MemberExpression`||t.type===`ChainExpression`;)t=t.type===`ChainExpression`?t.expression:t.object;return t}const Dn=r.define({name:`alchemy-domain-pure-decide`,meta:B({type:`problem`,description:`Require Alchemy Domain aggregate decide handlers to be pure.`,messages:{time:"`decide` reads time from its `now` argument, not {{api}}. Replays must decide the same way.",random:"`decide` must be deterministic, so it cannot use {{api}}. Take the value from the command input instead.",io:"`decide` never performs I/O such as {{api}}. Call external systems from a policy or saga and send the result as a command."},url:`https://alchemy.run/domain/aggregate`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*z};function r(t,n){return L(e.sourceCode.getScope(t),t,n)}function a(r,i,a){return i.pipe(f.filter(()=>f.exists(Ut(r,n),({section:e})=>e===`decide`)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:n,data:{api:a}}))}))}function o(e){return Rt(e,n).pipe(f.filter(e=>e.length===2),f.match({onNone:()=>d.void,onSome:t=>{let n=c.join(t,`.`);return a(e,f.orElse(l.get(wn,n),()=>f.flatMap(c.head(t),e=>l.get(Cn,e))),n)}}))}function u(e){return e.type===`Identifier`?r(e,e.name)?f.some(e.name):f.none():e.type===`MemberExpression`&&r(e.object,`globalThis`)?C(e).pipe(f.filter(e=>e.length===2),f.flatMap(e=>c.get(e,1))):f.none()}return s.merge(s.on(`MemberExpression`,e=>{let t=f.getOrElse(C(e),()=>[]),n=c.head(t),i=f.contains(n,`globalThis`)?t.slice(1):t,s=En(e);if(i.length!==2||!f.exists(n,e=>r(s,e)))return o(e);let u=c.join(i,`.`),d=e.parent.type===`CallExpression`&&e.parent.callee===e;return a(e,l.get(Sn,u),d?`${u}()`:u)}),s.on(`Identifier`,t=>Bt(t,e.sourceCode)?o(t):d.void),s.on(`NewExpression`,e=>c.isReadonlyArrayEmpty(e.arguments)&&f.contains(u(e.callee),`Date`)?a(e,f.some(`time`),`new Date()`):d.void),s.on(`CallExpression`,e=>g.value(f.getOrElse(u(e.callee),()=>``)).pipe(g.when(`Date`,()=>a(e,f.some(`time`),`Date()`)),g.when(`fetch`,()=>a(e,f.some(`io`),`fetch()`)),g.orElse(()=>Rt(e.callee,n).pipe(f.flatMap(Ce(`Effect`)),f.filter(Tn),f.match({onNone:()=>d.void,onSome:t=>a(e,f.some(`io`),`Effect.${t}`)}))))))}}),On=m.is(mt),kn=`@alchemy.run/domain`;function An(e){return h.startsWith(`.`)(e)||e===`effect`||h.startsWith(`effect/`)(e)||e===kn||h.startsWith(`${kn}/`)(e)}function jn(e){return c.some(e.body,e=>e.type===`ImportDeclaration`&&e.source.value===kn)}const Mn=r.define({name:`alchemy-domain-pure-imports`,meta:B({type:`problem`,description:"Restrict Alchemy Domain block files to imports from `@alchemy.run/domain`, `effect` and the domain package itself.",messages:{import:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, not `{{source}}`. Put code that touches infrastructure in the server package.",dynamic:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, so its import sources must be string literals."},url:`https://alchemy.run/domain`}),*create(){let e=yield*i;if(!On(e.filename)||!jn(e.sourceCode.ast))return{};function n(n,r){return An(r)?d.void:e.report(t.fromId({node:n,messageId:`import`,data:{source:r}}))}function r(e){return y.isNull(e.source)?d.void:n(e.source,e.source.value)}function a(r){return M(r)?n(r,r.value):e.report(t.fromId({node:r,messageId:`dynamic`}))}return s.merge(s.on(`ImportDeclaration`,r),s.on(`ExportAllDeclaration`,r),s.on(`ExportNamedDeclaration`,r),s.on(`ImportExpression`,e=>a(e.source)),s.on(`TSImportEqualsDeclaration`,e=>e.moduleReference.type===`TSExternalModuleReference`?a(e.moduleReference.expression):d.void),s.on(`CallExpression`,e=>f.match(E(e,0),{onNone:()=>d.void,onSome:t=>d.flatMap(it(e.callee,`require`),e=>e?a(t):d.void)})))}});function Nn(e,t){return c.some(e.properties.slice(e.properties.indexOf(t)+1),e=>e.type===`SpreadElement`)}const Pn=r.define({name:`alchemy-domain-require-view-version`,meta:B({type:`suggestion`,description:`Require Alchemy Domain views to declare their version.`,messages:{missing:"Declare `version` on this view (`version: 0` keeps the current default). Bump it whenever `evolve`, `emit`, `keyOf`, `state` or `from` changes, so the deploy rebuilds the view from its events.",overridden:"Move `version` after the spread, so the spread cannot override the version this view declares."},url:`https://alchemy.run/domain/model#change-a-view-bump-its-version`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*z};function r(n,r){return f.match(T(r,`version`),{onNone:()=>e.report(t.fromId({node:n.callee,messageId:`missing`})),onSome:n=>Nn(r,n)?e.report(t.fromId({node:n,messageId:`overridden`})):d.void})}return s.on(`CallExpression`,e=>E(e,1).pipe(f.map(D),f.filter(e=>e.type===`ObjectExpression`),f.filter(()=>f.contains(zt(e,n),`View`)),f.match({onNone:()=>d.void,onSome:t=>r(e,t)})))}}),Fn={Aggregate:[`evolve`,`reply`],View:[`evolve`]},In=m.is(nn),Ln=m.is(rn),Rn=r.define({name:`alchemy-domain-total-handlers`,meta:B({type:`problem`,description:`Require Alchemy Domain evolve and reply handlers to be total, and decide handlers to reject instead of throwing.`,messages:{partial:'`{{section}}` must be total and never fail: {{api}} throws when the state is not what it expects. Keep any state the event cannot follow, such as `s._tag === "Open" ? { ...s, ... } : s`.',reject:"`decide` never throws: {{api}} becomes a defect the caller cannot handle. Return a rejection the command lists in `rejects` instead, or `return yield* rejection` in an `Effect.fn`."},url:`https://alchemy.run/domain/aggregate`}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*z};function r(r,i){return f.match(Ut(r,n),{onNone:()=>d.void,onSome:({block:n,section:a})=>n===`Aggregate`&&a===`decide`?e.report(t.fromId({node:r,messageId:`reject`,data:{api:i}})):f.exists(l.get(Fn,n),c.contains(a))?e.report(t.fromId({node:r,messageId:`partial`,data:{section:a,api:i}})):d.void})}function a(e){return Rt(e,n).pipe(f.filter(e=>e.length===2&&f.exists(c.head(e),In)&&f.exists(c.get(e,1),Ln)),f.match({onNone:()=>d.void,onSome:t=>r(e,`\`${c.join(t,`.`)}\``)}))}return s.merge(s.on(`ThrowStatement`,e=>r(e,"`throw`")),s.on(`MemberExpression`,a),s.on(`Identifier`,t=>Bt(t,e.sourceCode)?a(t):d.void))}}),zn=m.is(gt),Bn=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Vn(e,t){return c.some(Bn,n=>t.isApiPath(e,n))}function Hn(e,t){return Pe(e,e=>e.type===`CallExpression`&&Vn(e.callee,t))}function Un(e,t){return Fe(e).pipe(f.flatMap(Ie),f.filter(e=>t.isApi(e.callee,`Effect`,`gen`)))}function Wn(e){return f.flatMap(A(e),e=>{if(k(e))return f.none();let t=e.type===`Property`?f.filter(w(e),zn):f.none();return f.orElse(t,()=>Wn(e))})}const Gn=r.define({name:`alchemy-no-cloudflare-init-finalizer`,meta:B({type:`problem`,description:`Disallow finalizers in Cloudflare Worker initialization, where workerd never runs them.`,messages:{finalizer:`A Cloudflare Worker init finalizer never runs because workerd has no isolate teardown hook. Acquire disposable resources inside an event handler.`},url:`https://alchemy.run/cloudflare/compute/workers`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`addFinalizer`)&&f.exists(Un(r,n),e=>f.exists(Hn(e,n),t=>P(t.arguments,e)))?e.report(t.fromId({node:r,messageId:`finalizer`})):d.void)}});function Kn(e,t,n){let r=c.flatMap(t.body,e=>e.type===`ImportDeclaration`&&e.source.value===n&&e.importKind!==`type`?c.filter(e.specifiers,e=>e.type===`ImportNamespaceSpecifier`):[]);return d.map(d.filter(r,t=>d.map(nt(e,t.local.name),e=>f.exists(e,({defs:e})=>c.some(e,e=>e.node===t)))),e=>f.map(c.head(e),e=>e.local.name))}function qn(e,t,n=1){let r=n===1?e:`${e}${n}`;return t.has(r)?qn(e,t,n+1):r}function Jn(e,n){return f.match(c.findFirst(e.body,e=>e.type!==`ExpressionStatement`||!M(e.expression)),{onNone:()=>t.insertAfter(e,`\n${n}`),onSome:e=>t=>t.insertTextBefore(e,n)})}const Yn=d.fn(`namespaceImport`)(function*(e,t,n){let{sourceCode:r}=yield*i,a=r.ast,o=yield*Kn(e,a,t);if(f.isSome(o))return{name:o.value,fix:f.none()};let s=qn(n,yield*ot);return{name:s,fix:f.some(Jn(a,`import * as ${s} from '${t}';\n`))}}),Xn=d.fn(`replaceWithNamespace`)(function*(e,n,r,i){let a=yield*Yn(e,n,r);return t.composeFixes(...f.toArray(a.fix),t.replaceText(e,i(a.name)))});function V(e,t){let n=e.getText(t);return t.type===`SequenceExpression`?`(${n})`:n}function Zn(e,t){let n=c.map(e.properties,e=>we(e).pipe(f.filter(e=>e.key.type===`Identifier`||e.key.type===`Literal`),f.flatMap(e=>e.key.type===`Literal`?f.some(String(e.key.value)):w(e)))),r=c.getSomes(n);return r.length===n.length&&!c.contains(r,t)&&c.dedupe(r).length===r.length}function Qn(e,n){return f.match(n,{onNone:()=>e,onSome:n=>t.withFix(e,n)})}const $n=r.define({name:`alchemy-no-deprecated-docker-constraints`,meta:B({type:`problem`,description:`Disallow the deprecated top-level Docker Service constraints property.`,messages:{constraints:`Docker.Service constraints is deprecated. Move it to placement: { constraints: ... }.`},url:`https://alchemy.run/providers/docker/service`,fixable:`code`}),*create(){let e=yield*i,n=yield*z,r=d.fnUntraced(function*(n,r,i){let a=yield*at(n.callee),o=f.liftPredicate(t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`),()=>a&&Zn(r,`placement`));yield*e.report(Qn(t.fromId({node:i,messageId:`constraints`}),o))});return s.on(`CallExpression`,e=>n.isApi(e.callee,`Docker`,`Service`)?f.filter(E(e,1),e=>e.type===`ObjectExpression`).pipe(f.flatMap(e=>f.map(T(e,`constraints`),t=>[e,t])),f.match({onNone:()=>d.void,onSome:([t,n])=>r(e,t,n)})):d.void)}}),er={"Cloudflare.Access.Bookmark":`Cloudflare.Access.Application with type: "bookmark"`,"AWS.RDSData.ExecuteSql":`AWS.RDSData.ExecuteStatement`,"AWS.EKS.Deployment":`Kubernetes.Deployment from alchemy/Kubernetes`,"AWS.EKS.HelmChart":`Kubernetes.HelmChart from alchemy/Kubernetes`,"AWS.EKS.Job":`Kubernetes.Job from alchemy/Kubernetes`,"AWS.EKS.Manifest":`Kubernetes.Manifest from alchemy/Kubernetes`},tr=r.define({name:`alchemy-no-deprecated-resource`,meta:B({type:`problem`,description:`Disallow deprecated Alchemy resource APIs that have supported replacements.`,messages:{deprecated:`{{api}} is deprecated. Use {{replacement}}.`},url:`https://alchemy.run/llms-full.txt`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.path(r.callee).pipe(f.flatMap(e=>{let t=c.join(e,`.`);return f.map(l.get(er,t),e=>({api:t,replacement:e}))}),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r.callee,messageId:`deprecated`,data:n}))})))}});function nr(e,t){let n=D(e);return M(n)||n.type===`TemplateLiteral`||f.exists(C(n),([e,t])=>e===`process`&&t===`env`)||n.type===`CallExpression`&&t.isApi(n.callee,`Config`,`string`)}const rr=r.define({name:`alchemy-no-plaintext-github-secret`,meta:B({type:`problem`,description:`Require singular GitHub Secret values to use Redacted.`,messages:{plaintext:`GitHub.Secret value must be Redacted so it stays out of logs and state. Use Redacted.make(...) or Config.redacted(...).`},url:`https://alchemy.run/providers/github/secret`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>E(r,1).pipe(f.filter(()=>n.isApi(r.callee,`GitHub`,`Secret`)),f.filter(e=>e.type===`ObjectExpression`),f.flatMap(T(`value`)),f.map(({value:e})=>e),f.filter(e=>nr(e,n)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`plaintext`}))})))}}),ir=m.is(_t),ar=r.define({name:`alchemy-no-removed-config-api`,meta:B({type:`problem`,description:`Disallow removed Alchemy Secret and Variable APIs.`,messages:{removed:`Alchemy.{{api}} was removed. Use effect/Config (Config.redacted for secrets, Config.string for variables).`},url:`https://alchemy.run/blog/2026-05-29-beta-45`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.path(r.callee).pipe(f.filter(e=>f.contains(c.head(e),`Alchemy`)),f.flatMap(e=>c.get(e,1)),f.filter(ir),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r.callee,messageId:`removed`,data:{api:n}}))})))}}),or=r.define({name:`alchemy-no-reserved-eventbridge-default-name`,meta:B({type:`problem`,description:`Disallow creating an EventBridge bus with the reserved default name.`,messages:{reserved:`EventBridge reserves the name "default". Omit the bus argument to use the account default, or choose another name.`},url:`https://alchemy.run/aws/messaging/eventbridge`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>E(r,1).pipe(f.filter(()=>n.isApiPath(r.callee,[`AWS`,`EventBridge`,`EventBus`])),f.filter(e=>e.type===`ObjectExpression`),f.flatMap(T(`name`)),f.map(({value:e})=>e),f.filter(N(`default`)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`reserved`}))})))}}),sr=r.define({name:`alchemy-no-runtime-config`,meta:B({type:`problem`,description:`Require Effect Config values to be resolved during Alchemy Worker initialization.`,messages:{runtime:`Config resolved inside the {{handler}} handler is invisible to Alchemy deployment. Resolve it in Worker init and close over the value, or put it in env.`},url:`https://alchemy.run/environments/secrets`}),*create(){let e=yield*i,n=yield*z;return s.on(`YieldExpression`,r=>{let i=r.argument;if(i?.type!==`CallExpression`||!f.exists(n.path(i.callee),([e])=>e===`Config`))return d.void;let a=f.flatMap(Un(r,n),e=>f.filter(Wn(e),()=>f.isSome(Hn(e,n))));return f.match(a,{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:i,messageId:`runtime`,data:{handler:n}}))})})}}),cr={"alchemy/aws":`alchemy/AWS`,"alchemy/cloudflare":`alchemy/Cloudflare`},lr=r.define({name:`alchemy-no-v1-import`,meta:B({type:`problem`,description:`Disallow Alchemy v1 imports that bypass the Effect-based Stack API.`,messages:{defaultImport:`The default alchemy() API is from v1. Use import * as Alchemy and Alchemy.Stack.`,providerImport:`Use the v2 provider entrypoint {{replacement}} (capitalization is significant).`},url:`https://alchemy.run/migrating-from-v1`}),*create(){let e=yield*i;function n(n,r,i){return e.report(t.fromId({node:n,messageId:r,...y.isUndefined(i)?{}:{data:i}}))}return s.on(`ImportDeclaration`,e=>{let t=e.source.value,r=t===`alchemy`?f.map(c.findFirst(e.specifiers,e=>e.type===`ImportDefaultSpecifier`),e=>n(e,`defaultImport`)):f.map(l.get(cr,t),t=>n(e.source,`providerImport`,{replacement:t}));return f.getOrElse(r,()=>d.void)})}}),ur=[[`entrypoint`,`main`],[`bindings`,`env`]],dr=r.define({name:`alchemy-no-v1-worker-properties`,meta:B({type:`problem`,description:`Disallow Alchemy v1 Cloudflare Worker property names.`,messages:{property:`Cloudflare.Worker {{old}} was replaced in v2. Use {{replacement}}.`},url:`https://alchemy.run/migrating-from-v1`,fixable:`code`}),*create(){let e=yield*i,n=yield*z,r=d.fnUntraced(function*(n,r){let i=yield*at(n.callee),a=c.flatMap(ur,([e,t])=>T(r,e).pipe(f.map(n=>({old:e,replacement:t,property:n})),f.toArray));yield*d.forEach(a,({old:n,replacement:a,property:o})=>e.report(Qn(t.fromId({node:o,messageId:`property`,data:{old:n,replacement:a}}),f.liftPredicate(t.replaceText(o.key,o.shorthand?`${a}: ${n}`:a),()=>i&&Zn(r,a)))),{concurrency:1,discard:!0})});return s.on(`CallExpression`,e=>E(e,1).pipe(f.filter(()=>Vn(e.callee,n)),f.filter(e=>e.type===`ObjectExpression`),f.match({onNone:()=>d.void,onSome:t=>r(e,t)})))}}),fr=r.define({name:`avoid-data-tagged-error`,meta:B({type:`suggestion`,description:`Prefer schema-based tagged errors so errors have a serializable contract.`,messages:{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Data`,`TaggedError`)?e.report(t.fromId({node:r.callee,messageId:`taggedError`})):d.void)}}),pr=m.is(Mt);function mr(e){return e?.type===`Identifier`&&pr(e.name)?f.some(e.name):f.none()}function hr(e){return e.arguments.length===1&&f.exists(C(e.callee),e=>c.lastNonEmpty(e)===`String`&&e.length<=2)}function gr(e){return f.exists(j(e,`NewExpression`),t=>F(c.head(t.arguments),e)&&ze(t))}function _r(e){return hr(e)?gr(e)?f.none():f.flatMap(c.head(e.arguments),mr):e.callee.type===`MemberExpression`&&c.isReadonlyArrayEmpty(e.arguments)&&f.exists(C(e.callee),e=>c.lastNonEmpty(e)===`toString`)?mr(e.callee.object):f.none()}function vr(e){let[t,n]=e.quasis;return e.quasis.length===2&&t?.value.raw===``&&n?.value.raw===``?f.flatMap(c.head(e.expressions),mr):f.none()}const yr=r.define({name:`ban-error-string`,meta:B({type:`problem`,description:`Disallow string coercion that discards an error value’s stack, type, and cause chain.`,messages:{errorString:`Do not stringify {{name}}. Preserve the original error as an Error cause instead.`,useCause:`Replace {{pattern}} with {{replacement}} to preserve the original error.`},hasSuggestions:!0}),*create(){let e=yield*i;function n(n,r){return f.match(r,{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`errorString`,data:{name:r}}))})}function r(n,r){let i=e.sourceCode.getText(r),a=`'Error occurred', { cause: ${i} }`;return e.report(t.withSuggestions(t.fromId({node:n,messageId:`errorString`,data:{name:i}}),[{messageId:`useCause`,data:{pattern:e.sourceCode.getText(n),replacement:a},fix:t.replaceText(n,a)}]))}return s.merge(s.on(`NewExpression`,e=>E(e,0).pipe(f.filter(t=>t.type===`CallExpression`&&hr(t)&&ze(e)),f.match({onNone:()=>d.void,onSome:e=>f.match(E(e,0),{onNone:()=>d.void,onSome:t=>r(e,t)})}))),s.on(`CallExpression`,e=>n(e,_r(e))),s.on(`TemplateLiteral`,e=>n(e,vr(e))))}}),br=m.is(dn),xr=m.is(pn),Sr=m.is(mn),Cr=m.is(_n),wr=m.is(fe),Tr=m.is(pe),Er=m.is(Ct);function Dr(e){return br(e)||xr(e)}function Or(e,t){return f.filter(t.imports.member(e,`Schema`),()=>f.exists(C(e),e=>e.length===2)&&R(t.sourceCode,e))}function kr(e,t){return c.every(e,e=>y.isNull(e)||H(e,t))}function H(e,t){return Tr(e.type)||g.value(e).pipe(g.discriminators(`type`)({MemberExpression:({object:e,computed:n,property:r})=>H(e,t)&&(!n||H(r,t)),TemplateLiteral:({expressions:e})=>kr(e,t),ArrayExpression:({elements:e})=>kr(e,t),ObjectExpression:({properties:e})=>c.every(e,e=>e.type===`SpreadElement`?H(e.argument,t):(!e.computed||H(e.key,t))&&H(e.value,t)),CallExpression:e=>{let n=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return f.isSome(Or(n,t))&&(e.callee===n||H(e.callee,t))&&kr(e.arguments,t)}}),g.orElse(v.constFalse))}function Ar(e,t){return e.type===`Identifier`?f.fromNullishOr(t.bindings.get(e.name)):e.type===`TSQualifiedName`?f.map(Ar(e.left,t),t=>[...t,e.right.name]):f.none()}function jr(e,t){return A(t).pipe(f.flatMap(t=>{let n=`typeParameters`in t&&t.typeParameters?.type===`TSTypeParameterDeclaration`?c.findFirst(t.typeParameters.params,t=>t.name.name===e):f.none();return f.orElse(n,()=>jr(e,t))}))}function Mr(e,t,n,r=[]){let i=c.isReadonlyArrayEmpty(r)?f.none():f.some(!1);if(e?.type!==`TSTypeReference`)return i;let a=f.flatMap(Ar(e.typeName,n),Ce(`Schema`));if(f.isSome(a))return f.some(!h.startsWith(`Constraint`)(a.value));let{typeName:o}=e,s=f.filter(o.type===`Identifier`?jr(o.name,t):f.none(),e=>!P(r,e));return f.match(s,{onNone:()=>i,onSome:e=>Mr(e.constraint,e,n,[...r,e])})}function Nr(e,t){return I(t.sourceCode,e,e.name).pipe(f.flatMap(({defs:e})=>c.head(e)),f.flatMapNullishOr(({name:e})=>`typeAnnotation`in e?e.typeAnnotation:void 0))}function Pr(e){return e.type===`TSSatisfiesExpression`||e.type===`TSNonNullExpression`?Pr(e.expression):e}function Fr(e,t){let n=Pr(e);return n.type===`TSAsExpression`?f.contains(Mr(n.typeAnnotation,n,t.imports),!1):f.exists(n.type===`Identifier`?Nr(n,t):f.none(),e=>f.contains(Mr(e.typeAnnotation,e,t.imports),!1))}function Ir(e){return c.some(e.arguments,e=>e.type===`SpreadElement`)}function Lr(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&f.contains(S(e.callee),`pipe`)&&!e.typeArguments&&!Ir(e)}function Rr(e,t){return(t.imports.isApiPath(e.callee,[`pipe`])||t.imports.isApiPath(e.callee,[`Function`,`pipe`]))&&R(t.sourceCode,e.callee)}function zr(e,t){return f.exists(Or(e,t),Dr)||e.type===`CallExpression`&&f.exists(Or(e.callee,t),Sr)}function Br(e,t){return f.exists(Or(e,t),Er)||f.isSome(Gr(e,t))?!0:e.type===`CallExpression`&&f.match(Or(e.callee,t),{onSome:e=>Er(e)||Dr(e),onNone:()=>e.callee.type===`MemberExpression`&&f.exists(S(e.callee),Cr)&&Br(e.callee.object,t)})}function Vr(e,t){let[n,r]=e.arguments;return y.isUndefined(n)||y.isUndefined(r)||n.type===`SpreadElement`||e.typeArguments||Ir(e)||!Br(n,t)&&!zr(r,t)?f.none():f.some([n,e.arguments.slice(1)])}function Hr(e,t,n,r,i){let a=Kr(e,i);return{head:a.head,steps:[...a.steps,...t],violation:f.orElse(a.violation,()=>n),reordersEffects:a.reordersEffects||r}}function Ur(e,t){let n=e.arguments.length===1&&!e.typeArguments?E(e,0):f.none();return f.flatMap(n,n=>{let r={text:t.sourceCode.getText(e.callee),wrapper:!1};function i(){return(e.callee.type===`CallExpression`?Or(e.callee.callee,t):f.none()).pipe(f.filter(Sr),f.map(i=>Hr(n,[r],f.some({kind:`dataLastCall`,name:i}),!H(e.callee,t)&&!H(n,t),t)))}return Or(e.callee,t).pipe(f.filter(Dr),f.match({onNone:i,onSome:e=>{let i=xr(e);return f.some(Hr(n,[u.assign(r,{wrapper:i})],i?f.none():f.some({kind:`modifierCall`,name:e}),!1,t))}}))})}function Wr(e,t){let n=Rr(e,t),r=n?Vr(e,t):Lr(e)?f.some([e.callee.object,e.arguments]):f.none();return f.map(r,([e,r])=>{let i=c.map(r,e=>Or(e,t)),a=c.findFirstIndex(i,f.exists(xr)),o=f.exists(a,e=>c.some(r.slice(e+1),e=>!H(e,t))),s=n?f.some({kind:`functionPipe`}):a.pipe(f.flatMap(e=>f.flatten(c.get(i,e))),f.map(e=>({kind:`wrapperPipe`,name:e})));return Hr(e,c.map(r,(e,n)=>({text:t.sourceCode.getText(e),wrapper:c.get(i,n).pipe(f.flatten,f.exists(xr))})),s,o,t)})}function Gr(e,t){return e.type===`CallExpression`?f.orElse(Ur(e,t),()=>Wr(e,t)):f.none()}function Kr(e,t){return f.getOrElse(Gr(e,t),()=>({head:e,steps:[],violation:f.none(),reordersEffects:!1}))}function qr(e,t){let n=e.parent;return n.type===`MemberExpression`&&n.object===e&&n.parent.type===`CallExpression`?n.parent.callee===n&&Lr(n.parent):n.type===`CallExpression`&&F(E(n,0),e)&&(Rr(n,t)||!Lr(n))&&f.isSome(Gr(n,t))}function Jr(e,t,n){return c.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!wr(n.type)?`(\0)`:e}.pipe(${c.join(t,`, `)})`:e}function Yr(e,t){let{target:n,pending:r}=c.reduce(t,{target:`\0`,pending:[]},({target:t,pending:n},r)=>{if(!r.wrapper)return{target:t,pending:[...n,r.text]};let i=Jr(t,n,e),a=i===`\0`&&e.type===`SequenceExpression`?`(${i})`:i;return{target:`${r.text}(${a})`,pending:[]}});return Jr(n,r,e)}const Xr=r.define({name:`consistent-schema-pipe`,meta:B({type:`suggestion`,description:"Apply Schema modifiers with `.pipe(...)` and call Schema wrappers directly.",messages:{modifierCall:"Apply Schema.{{name}} with `.pipe(...)` instead of calling it.",dataLastCall:"Apply Schema.{{name}}(...) with `.pipe(...)` instead of calling it on the schema.",functionPipe:"Call `.pipe(...)` on the schema instead of passing it to `pipe(...)`.",wrapperPipe:`Call Schema.{{name}}(...) directly instead of piping into it.`},url:`https://github.com/2digits-agency/configs/blob/main/docs/adr/0001-schema-modifiers-pipe-wrappers-call.md`,fixable:`code`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r={sourceCode:e.sourceCode,imports:n};function a(n,r,i){let{head:a}=r,o=c.some(e.sourceCode.getCommentsInside(n),e=>!Le(a,e)),[s,l=``]=h.split(Yr(a,r.steps),`\0`),u=t.fromId({node:n,messageId:i.kind,data:{name:i.name??``}});return e.report(o||r.reordersEffects?u:t.withFix(u,t.composeFixes(e=>e.replaceTextRange([_.get(n.range,0),_.get(a.range,0)],s),e=>e.replaceTextRange([_.get(a.range,1),_.get(n.range,1)],l))))}return s.on(`CallExpression`,e=>f.filter(Gr(e,r),({head:e,steps:t})=>!f.exists(c.head(t),({wrapper:e})=>!e)||!Fr(e,r)).pipe(f.flatMap(e=>f.map(e.violation,t=>[e,t])),f.filter(()=>!qr(e,r)),f.match({onNone:()=>d.void,onSome:([t,n])=>a(e,t,n)})))}});function Zr(e){let t=D(e);return N(t,`*`)||t.type===`ArrayExpression`&&(c.isReadonlyArrayEmpty(t.elements)||c.some(t.elements,e=>y.isNotNull(e)&&N(e,`*`)))}function Qr(e,t){return t.isApi(e,`HttpMiddleware`,`cors`)||t.isApi(e,`HttpRouter`,`cors`)||t.isApi(e,`HttpApiBuilder`,`middlewareCors`)}function $r(e){let t=T(e,`credentials`).pipe(f.match({onSome:({value:e})=>e,onNone:()=>e}));return N(t,!0)&&f.match(T(e,`allowedOrigins`),{onNone:()=>!0,onSome:({value:e})=>Zr(e)})}const ei=r.define({name:`cors-credentials-with-wildcard`,meta:B({type:`problem`,description:`Disallow credentialed CORS with wildcard origins because browsers reject that combination.`,messages:{wildcard:`Credentialed CORS cannot use a wildcard origin. Set allowedOrigins to explicit trusted origins or disable credentials.`},url:`https://github.com/Effect-TS/tsgo/issues/400`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>Qr(r.callee,n)&&f.exists(Te(r),$r)?e.report(t.fromId({node:r,messageId:`wildcard`})):d.void)}});function ti(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const ni=r.define({name:`dual-numeric-arity-with-optional-parameter`,meta:B({type:`problem`,description:`Disallow numeric dual arity with optional or rest parameters because dispatch becomes ambiguous.`,messages:{unsafeArity:`Function.dual with numeric arity misdispatches an implementation with optional/default/rest parameters. Use predicate dispatch.`},url:`https://github.com/Effect-TS/tsgo/issues/401`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Function`,`dual`)?E(r,0).pipe(f.filter(e=>e.type===`Literal`&&y.isNumber(e.value)&&f.exists(E(r,1),e=>k(e)&&c.some(e.params,ti))),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`unsafeArity`}))})):d.void)}}),ri=r.define({name:`effect-promise-vs-trypromise`,meta:B({type:`problem`,description:`Require Effect.tryPromise so Promise rejections enter the typed error channel.`,messages:{tryPromise:`Use Effect.tryPromise instead of Effect.promise so rejections are typed failures.`}}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`promise`)?e.report(t.fromId({node:r.callee,messageId:`tryPromise`})):d.void)}}),ii=m.Literals([`replace`,`replaceAll`,`slice`,`split`,`substr`,`substring`]),ai=ii.pick([`replace`,`replaceAll`]),oi=m.Literals([`split`,`match`,`matchAll`]),si=m.Literals([`includes`,`startsWith`,`endsWith`]),ci=m.Literals([`every`,`filter`,`find`,`findIndex`,`findLast`,`findLastIndex`,`flatMap`,`forEach`,`map`,`reduce`,`reduceRight`,`some`,`sort`,`toSorted`]),li=m.Literals([`catch`,`finally`,`then`]),ui=m.Literals([`delete`,`get`,`has`,`set`]),di=m.Literals([`canParse`,`parse`]),fi=m.Literals([`document`,`localStorage`,`navigator`,`sessionStorage`,`window`]),pi=m.Literals([`atob`,`btoa`]),mi=m.Literals([`NaN`,`Infinity`,`undefined`]),hi=m.Literals([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]),gi=m.Literals([`cookie`,`set-cookie`]),_i=m.String.check(m.isPattern(/(?:^|[\n\r])(?:data|event|id|retry):.*(?:\r?\n){2}$/su)),vi=m.Literals([`data: `,`event: `,`id: `,`retry: `]),yi=m.Literals([`base64`,`base64url`,`hex`]),bi=m.Literals([`header`,`payload`,`signature`]),xi=m.Literals([`isIP`,`isIPv4`,`isIPv6`]),Si=m.Literals([`0.0.0.0`,`127.0.0.1`,`255.255.255.255`,`::`,`::1`]),Ci=m.Literals([`APPDATA`,`HOME`,`LOCALAPPDATA`,`USERPROFILE`,`XDG_CACHE_HOME`,`XDG_CONFIG_HOME`,`XDG_DATA_HOME`,`XDG_STATE_HOME`]),wi=m.Literals([`forwardRef`,`memo`]),Ti=m.String.check(m.isPattern(/^\s*use[\s_-]*(?:client|server|cache)\b/iu)),Ei=m.String.check(m.isPattern(/^use (?:client|server|cache(?:: [\w-]+)?)$/u));function Di(e,t){return g.value(e.parent).pipe(g.withReturnType(),g.when({type:`Property`,parent:{type:`ObjectExpression`,parent:{type:`CallExpression`}}},e=>f.contains(w(e),t)?f.some(e.parent.parent):f.none()),g.orElse(()=>f.none()))}function Oi(e,t){return f.flatMap(Ie(e),e=>t.path(e.callee))}function ki(e){return e.type===`CallExpression`?ki(e.callee):e}function Ai(e,t){let n=e.parent.type===`Property`&&e.parent.value===e?e.parent.parent:e;return A(n).pipe(f.filter(e=>(e.type===`CallExpression`||e.type===`NewExpression`)&&P(e.arguments,n)),f.exists(e=>f.isNone(t.path(ki(e.callee)))))}const ji=m.is(li),Mi=g.type().pipe(g.discriminators(`type`)({CallExpression:({callee:e})=>f.exists(C(e),e=>c.join(e,`.`)===`fetch`||c.headNonEmpty(e)===`Promise`&&e[1]!==`withResolvers`||ji(c.lastNonEmpty(e)))||k(e)&&e.async,NewExpression:({callee:e})=>f.exists(C(e),e=>c.join(e,`.`)===`Promise`)}),g.orElse(v.constFalse));function Ni(e){return Mi(D(e))}function U(e){return f.fromNullishOr(e.body).pipe(f.flatMap(e=>e.type===`BlockStatement`?c.head(e.body).pipe(f.filter(()=>e.body.length===1),f.flatMapNullishOr(e=>e.type===`ReturnStatement`?e.argument:void 0),f.map(D)):f.some(D(e))))}function Pi(e){return e.pipe(f.flatMap(e=>e.type===`ObjectExpression`?f.map(T(e,`try`),({value:e})=>e):f.some(e)),f.filter(k))}const Fi=r.define({name:`no-already-started-promise`,meta:B({type:`problem`,description:`Ensure Effect Promise thunks start fresh asynchronous work rather than reusing an already-started Promise.`,messages:{prestarted:`This thunk returns an already-started Promise. Start the asynchronous work inside the thunk so retries and repeats run it again.`},url:`https://github.com/Effect-TS/tsgo/issues/475`}),*create(){let e=yield*i,n=yield*z,r=yield*p.make(b.empty());return s.merge(s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&Ni(e.init)?p.update(r,b.add(e.id.name)):d.void),s.on(`CallExpression`,i=>d.gen(function*(){if(!n.isApi(i.callee,`Effect`,[`promise`,`tryPromise`]))return;let a=f.flatMap(Pi(E(i,0)),U);if(f.isNone(a)||a.value.type!==`Identifier`)return;let o=yield*p.get(r);b.has(o,a.value.name)&&(yield*e.report(t.fromId({node:a.value,messageId:`prestarted`})))})))}}),Ii=r.define({name:`no-async-effect-try`,meta:B({type:`problem`,description:`Disallow async thunks in Effect.try because rejected Promises bypass its catch mapper.`,messages:{asyncTry:`Effect.try does not await Promises. Use Effect.tryPromise so rejection enters the typed error channel.`},url:`https://github.com/Effect-TS/tsgo/issues/657`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`try`)?E(r,0).pipe(f.flatMap(e=>k(e)?f.some(e):e.type===`ObjectExpression`?T(e,`try`).pipe(f.map(({value:e})=>e),f.filter(k)):f.none()),f.filter(e=>e.async||f.exists(U(e),Ni)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`asyncTry`}))})):d.void)}}),Li=r.define({name:`no-discarded-run-promise`,meta:B({type:`problem`,description:`Disallow discarded Effect.runPromise results that can become unhandled rejections.`,messages:{discarded:`The Promise returned by Effect.runPromise is discarded. Await/return/handle it, or use Effect.runFork for fire-and-forget work.`},url:`https://github.com/Effect-TS/tsgo/issues/643`}),*create(){let e=yield*i,n=yield*z;function r(e){return n.isApi(e,`Effect`,`runPromise`)||e.type===`CallExpression`&&n.isApi(e.callee,`Effect`,`runPromiseWith`)}return s.on(`CallExpression`,n=>r(n.callee)&&Re(n)?e.report(t.fromId({node:n,messageId:`discarded`})):d.void)}}),Ri=m.is(yn);function zi(e,t){let n=D(e);return n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&f.contains(S(n.callee),t)}function Bi(e){return e.callee.type!==`MemberExpression`||!zi(e.callee.object,`check`)||Te(e).pipe(f.flatMap(T(`unsafePreserveChecks`)),f.exists(e=>N(e.value,!0)))?f.none():f.filter(S(e.callee),Ri)}const Vi=r.define({name:`no-discarded-schema-checks`,meta:B({type:`problem`,description:`Disallow schema mapping that silently drops checks attached to the receiver.`,messages:{discarded:`{{method}} creates a new schema and drops the preceding check. Re-attach the check after mapping or explicitly preserve it.`},url:`https://github.com/Effect-TS/tsgo/issues/435`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.on(`CallExpression`,n=>f.match(Bi(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`discarded`,data:{method:r}}))})):{}}}),Hi={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},Ui=m.is(kt),Wi=m.is(Ve),Gi=m.is(He),Ki=m.is(Ue);function qi(e,t){return e.importKind===`type`||t?.importKind===`type`}function Ji(e){return f.getOrElse(l.get(Hi,e),()=>e)}function Yi(e,t){return g.value(e).pipe(g.when(g.is(`effect`,`alchemy`),()=>f.some(`${e}/${t}`)),g.when(e=>Gi(e)&&!Wi(e),()=>f.some(`${e}/${t}`)),g.orElse(()=>f.none()))}function Xi(e){return!Wi(e)&&(h.startsWith(`effect/`)(e)||h.startsWith(`alchemy/`)(e)||Ki(e))?f.liftPredicate(c.lastNonEmpty(h.split(e,`/`)),Ui):f.none()}function Zi(e,n){let r=n.specifiers;if(c.isReadonlyArrayNonEmpty(e.getCommentsInside(n))||c.isReadonlyArrayNonEmpty(n.attributes)||!c.every(r,e=>e.type===`ImportSpecifier`))return f.none();let[i,a]=c.partition(r,t=>{let r=Se(t.imported),i=Ui(r)&&!qi(n,t)?Yi(n.source.value,r):f.none();return f.match(i,{onNone:()=>te.fail(e.getText(t)),onSome:e=>te.succeed(`import * as ${t.local.name} from '${e}';`)})}),o=c.isReadonlyArrayNonEmpty(a)?c.prepend(i,`import { ${c.join(a,`, `)} } from ${e.getText(n.source)};`):i;return f.some(t.replaceText(n,c.join(o,`
|
|
2
|
+
`)))}function Qi(e,n,r){let i=c.dedupeWith(e.references,(e,t)=>_.get(e.identifier.range,0)===_.get(t.identifier.range,0));return f.all(c.map(i,e=>{let i=e.identifier,a=i.parent;if(e.isWrite()||a.type===`ExportSpecifier`||h.startsWith(`JSX`)(a.type))return f.none();let o=a.type===`CallExpression`&&a.callee===i||a.type===`TaggedTemplateExpression`&&a.tag===i,s=r&&o?`(0, ${n})`:a.type===`Property`&&a.shorthand?`${i.name}: ${n}`:n;return f.some(t.replaceText(i,s))}))}function $i(e,t,n){return f.flatMap(c.findFirst(t,t=>t.name===e.local.name),t=>e.type===`ImportNamespaceSpecifier`?Qi(t,n,!1):e.imported.type===`Identifier`?Qi(t,`${n}.${e.imported.name}`,!0):f.none())}function ea(e,t,n){function r(e){return F(n,e)}return!c.some(e.scopeManager.scopes,e=>c.some(e.variables,e=>e.name===t&&!r(e))||c.some(e.references,e=>e.identifier.name===t&&!r(e.resolved)))}function ta(e,n){return f.flatMap(Xi(n.source.value),r=>{if(c.isReadonlyArrayNonEmpty(n.attributes)||c.isReadonlyArrayNonEmpty(e.getCommentsInside(n)))return f.none();let i=Ji(r),a=e.getDeclaredVariables(n);if(!ea(e,i,c.findFirst(a,e=>e.name===i)))return f.none();let o=c.filter(n.specifiers,e=>e.type===`ImportSpecifier`&&qi(n,e));if(c.some(n.specifiers,e=>e.type===`ImportDefaultSpecifier`)||c.some(o,e=>e.local.name===i))return f.none();let s=c.filter(n.specifiers,e=>e.type!==`ImportDefaultSpecifier`&&!P(o,e));return f.all(c.map(s,e=>$i(e,a,i))).pipe(f.map(r=>{let a=e.getText(n.source),s=c.isReadonlyArrayEmpty(o)?``:`\nimport { ${c.join(c.map(o,t=>e.getText(t)),`, `)} } from ${a};`;return t.composeFixes(t.replaceText(n,`import * as ${i} from ${a};${s}`),...c.flatten(r))}))})}const na=r.define({name:`no-effect-alchemy-barrel-imports`,meta:B({type:`suggestion`,description:`Import Effect and Alchemy module namespaces from their submodule entrypoints instead of root barrels.`,messages:{barrelImport:'Import this module as `import * as {{alias}} from "{{source}}"` instead of from the root barrel.'},url:`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/diagnostics/importFromBarrel.ts`,fixable:`code`}),*create(){let e=yield*i;function n(n,r){let i=Se(r.imported);return f.match(Ui(i)?Yi(n.source.value,i):f.none(),{onNone:()=>d.void,onSome:a=>e.report(Qn(t.fromId({node:r,messageId:`barrelImport`,data:{alias:Ji(i),source:a}}),Zi(e.sourceCode,n)))})}return s.on(`ImportDeclaration`,e=>d.forEach(c.filter(e.specifiers,t=>t.type===`ImportSpecifier`&&!qi(e,t)),t=>n(e,t),{concurrency:1,discard:!0}))}}),ra=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],ia=[`debug`,`error`,`info`,`log`,`trace`,`warn`],aa=[`as`,`asSome`,`asVoid`];function oa(e,t){let n=D(e);if(n.type!==`CallExpression`)return f.none();let r=D(n.callee);return r.type===`CallExpression`&&t.isApiPath(r.callee,[`Effect`,`logWithLevel`])?f.some(`Effect.logWithLevel`):t.isApi(r,`Effect`,ra)||t.isApi(r,`Console`,ia)?f.some(t.path(r).pipe(f.getOrElse(()=>[]),c.join(`.`))):f.none()}function sa(e,t){return f.flatMapNullishOr(t.path(e),([,e])=>e)}function ca(e,t){let n=D(e);return n.type===`CallExpression`&&n.arguments.length===1&&t.isApiPath(n.callee,[`Effect`,`as`])?f.some(`as`):t.isApi(n,`Effect`,[`asSome`,`asVoid`])?sa(n,t):f.none()}function la(e,t){return t.isApiPath(e,[`pipe`])||t.isApiPath(e,[`Function`,`pipe`])}function ua(e,t,n){return f.flatMap(t,t=>e.pipe(f.flatMap(e=>oa(e,n)),f.zipWith(ca(t,n),(e,n)=>({logger:e,method:n,node:t}))))}function da(e,t){let n=D(e.callee);return n.type===`MemberExpression`&&f.contains(S(n),`pipe`)?ua(f.some(n.object),E(e,0),t):la(n,t)?ua(E(e,0),E(e,1),t):(t.isApi(n,`Effect`,aa)?sa(n,t):f.none()).pipe(f.filter(t=>t!==`as`||e.arguments.length===2),f.flatMap(n=>E(e,0).pipe(f.flatMap(e=>oa(e,t)),f.map(t=>({logger:t,method:n,node:e})))))}const fa=r.define({name:`no-effect-as-on-log`,meta:B({type:`suggestion`,description:`Disallow Effect.as, Effect.asSome and Effect.asVoid on log effects.`,messages:{asOnLog:"Do not swap the result of {{logger}} with Effect.{{method}}. Use Effect.gen: `yield*` the log, then return the value.",asVoidOnLog:`{{logger}} already succeeds with void; remove Effect.asVoid.`}}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>f.match(da(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n.node,messageId:n.method===`asVoid`?`asVoidOnLog`:`asOnLog`,data:{logger:n.logger,method:n.method}}))}))}}),pa=r.define({name:`no-empty-effect-callback`,meta:B({type:`suggestion`,description:`Prefer Effect.never to an empty Effect.callback registration.`,messages:{emptyCallback:`An empty Effect.callback registration is Effect.never. Use the explicit primitive.`},url:`https://github.com/Effect-TS/tsgo/issues/636`,fixable:`code`}),*create(){let e=yield*i,n=yield*z,r=d.fnUntraced(function*(n,r){if(n.arguments.length!==1||r.async||r.generator||c.some(r.params,e=>e.type!==`Identifier`)||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(n))||!(yield*at(n.callee)))return f.none();let i=yield*Yn(n,`effect/Effect`,`Effect`);return f.some(t.composeFixes(...f.toArray(i.fix),t.replaceText(n,`${i.name}.never`)))});function a(e){return n.isApi(e,`Effect`,`callback`)||n.isApi(e,`Effect`,`async`)}return s.on(`CallExpression`,n=>a(n.callee)?E(n,0).pipe(f.filter(e=>k(e)&&e.body?.type===`BlockStatement`&&c.isReadonlyArrayEmpty(e.body.body)),f.match({onNone:()=>d.void,onSome:i=>d.flatMap(r(n,i),r=>e.report(Qn(t.fromId({node:n,messageId:`emptyCallback`}),r)))})):d.void)}}),ma=r.define({name:`no-empty-schema-struct`,meta:B({type:`problem`,description:`Disallow Schema.Struct({}), which accepts every non-null object-like value.`,messages:{emptyStruct:`Schema.Struct({}) does not validate an exact empty object. Define the intended fields explicitly.`},url:`https://github.com/Effect-TS/tsgo/issues/403`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Schema`,`Struct`)&&f.exists(E(r,0),e=>e.type===`ObjectExpression`&&c.isReadonlyArrayEmpty(e.properties))?e.report(t.fromId({node:r,messageId:`emptyStruct`})):d.void)}}),ha=[`Base64`,`Base64Url`,`Hex`],ga=[`decode`,`decodeString`],_a=[`getOrThrow`,`getOrThrowWith`];function va(e,t){let n=e.type===`ChainExpression`?e.expression:D(e);return n.type===`CallExpression`?t.path(n.callee).pipe(f.filter(e=>e.length===2&&c.contains(ha,e[0])&&c.contains(ga,e[1])),f.map(c.join(`.`))):f.none()}function ya(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.filter(t.member(n,`Result`),e=>c.contains(_a,e))}function ba(e,t){let n=f.filter(t.member(e.callee,`Result`),e=>c.contains(_a,e));if(f.isSome(n))return E(e,0).pipe(f.flatMap(e=>va(e,t)),f.map(e=>({decoder:e,method:n.value})));let r=e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`pipe`)?f.some({source:e.callee.object,steps:e.arguments}):t.isApi(e.callee,`Function`,`pipe`)||e.callee.type===`Identifier`&&e.callee.name===`pipe`?f.map(c.head(e.arguments),t=>({source:t,steps:c.drop(e.arguments,1)})):f.none();return f.flatMap(r,({source:e,steps:n})=>f.zipWith(va(e,t),f.flatMap(c.findFirst(n,e=>e.type!==`CallExpression`||!t.isApi(e.callee,`Result`,`map`)),e=>ya(e,t)),(e,t)=>({decoder:e,method:t})))}const xa=r.define({name:`no-encoding-get-or-throw`,meta:B({type:`problem`,description:`Disallow throwing away the typed EncodingError of Effect Base64, Base64Url, and Hex decoders.`,messages:{getOrThrow:`Result.{{method}} turns the EncodingError of {{decoder}} into an untyped exception. Keep it typed with yield* Effect.fromResult(…), or handle it with Result.match or Result.getOrElse.`},url:`https://effect.website/docs/v4/api/effect/encoding/EncodingError`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>f.match(ba(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`getOrThrow`,data:n}))}))}});function Sa(e,t=[]){let n=D(e);return n.type===`Identifier`?d.flatMap(nt(n,n.name),e=>{let n=f.flatMap(e,n=>f.flatMap(rt(e),e=>{let r=e.node;return P(t,n)||r.type!==`VariableDeclarator`||r.id.type!==`Identifier`||!je(e.parent)||!r.init||c.some(n.references,e=>e.isWrite()&&!e.init)?f.none():f.some([n,r.init])}));return f.match(n,{onNone:()=>d.succeedNone,onSome:([e,n])=>Sa(n,[...t,e])})}):d.succeedSome(n)}function Ca(e){return e.arguments.length===2?E(e,0):e.arguments.length===1?j(e,`CallExpression`).pipe(f.filter(t=>F(E(t,0),e)&&t.callee.type===`MemberExpression`&&f.contains(S(t.callee),`pipe`)),f.flatMap(e=>e.callee.type===`MemberExpression`?f.some(e.callee.object):f.none())):f.none()}const wa=r.define({name:`no-function-config-default`,meta:B({type:`problem`,description:`Disallow obsolete lazy callbacks passed to the now-eager Config.withDefault API.`,messages:{functionDefault:`Config.withDefault takes an eager value. This callback becomes the configured value; pass the returned value directly.`},url:`https://github.com/Effect-TS/tsgo/issues/408`}),*create(){let e=yield*i,n=yield*z,r=d.fnUntraced(function*(e){let t=Ca(e),r=f.isSome(t)?yield*Sa(t.value):f.none();if(f.isNone(r)||r.value.type!==`CallExpression`||!n.isApi(r.value.callee,`Config`,`succeed`))return!1;let i=r.value;return(yield*at(i.callee))&&f.exists(E(i,0),k)});return s.on(`CallExpression`,i=>d.gen(function*(){if(!n.isApi(i.callee,`Config`,`withDefault`)||!(yield*at(i.callee))||(yield*r(i)))return;let a=E(i,i.arguments.length-1);f.isSome(a)&&k(a.value)&&c.isReadonlyArrayEmpty(a.value.params)&&(yield*e.report(t.fromId({node:a.value,messageId:`functionDefault`})))}))}}),Ta=m.is(ui);function Ea(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Hash`,`hash`)}const Da=r.define({name:`no-hash-as-identity`,meta:B({type:`problem`,description:`Disallow using Hash.hash output as collision-free identity.`,messages:{hashIdentity:`Hash.hash is a bucketing hint, not a unique identity. Use HashMap/Equal.equals or a real identifier instead.`},url:`https://github.com/Effect-TS/tsgo/issues/482`}),*create(){let e=yield*i,n=yield*z,r=yield*p.make(b.empty());function a(e){return Ea(e,n)?d.succeed(!0):e.type===`Identifier`?d.map(p.get(r),b.has(e.name)):d.succeed(!1)}function o(n,r){return d.when(e.report(t.fromId({node:n,messageId:`hashIdentity`})),r)}return s.merge(s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&Ea(e.init,n)?p.update(r,b.add(e.id.name)):d.void),s.on(`CallExpression`,e=>e.callee.type===`MemberExpression`&&f.exists(C(e.callee),e=>Ta(c.lastNonEmpty(e)))?f.match(E(e,0),{onNone:()=>d.void,onSome:e=>o(e,a(e))}):d.void),s.on(`BinaryExpression`,e=>be(e.operator)?o(e,d.map(d.all([a(e.left),a(e.right)],{concurrency:1}),c.every(Boolean))):d.void),s.on(`MemberExpression`,e=>e.computed?o(e.property,a(e.property)):d.void))}}),Oa=m.is(xn),ka=m.is(ve),Aa=m.is(le),ja=m.is(de),Ma=m.is(ce);function Na(e,t,n){let r=f.filter(t.member(e,`Schema`),Oa);return C(e).pipe(f.flatMap(([t])=>I(n,e,t)),f.exists(({defs:e})=>c.every(e,e=>e.type===`ImportBinding`)))?r:f.none()}function Pa(e,t=e){return f.exists(A(t),n=>Ma(n.type)&&y.isNotNullish(n.parent)?Pa(e,n):n.type===`CallExpression`&&n.callee===t)}function Fa(e){return A(e).pipe(f.filter(t=>t.type===`MemberExpression`&&t.object===e),f.match({onNone:()=>e,onSome:Fa}))}function Ia(e){let t=Fa(e);return t!==e&&f.exists(A(t),e=>e.type===`AssignmentExpression`&&e.left===t||e.type===`UpdateExpression`&&e.argument===t||e.type===`UnaryExpression`&&e.operator===`delete`&&e.argument===t)}function La(e){return c.every(e.references,e=>(!e.isWrite()||e.init)&&!Ia(e.identifier))}function Ra(e,t,n,r){return f.match(I(r,e,t),{onNone:()=>!0,onSome:e=>Le(n,e.scope.block)||ka(e.scope.type)&&La(e)})}function za(e){return f.exists(A(e),t=>t.type===`MemberExpression`&&t.property===e&&!t.computed||t.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand)}function Ba(e,t){return e!==t&&f.exists(A(e),e=>e!==t&&(Aa(e.type)||Ba(e,t)))}function Va(e,t,n){return Ba(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?f.isNone(n.path(e.callee)):ja(e.type)}function Ha(e,t,n){return!O(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||Va(r,e,t)||r.type===`Identifier`&&!za(r)&&!Ra(r,r.name,e,n))}function Ua(e,t,n){let[r]=e.arguments;if(y.isUndefined(r)||c.some(e.arguments,e=>e.type===`SpreadElement`)||!Pa(e)||f.isNone(Pe(e,e=>Aa(e.type))))return f.none();let i=D(r),a=i.type===`CallExpression`&&f.exists(t.path(i.callee),e=>f.contains(c.head(e),`Schema`));return!a&&i.type!==`Identifier`&&i.type!==`MemberExpression`||!c.every(e.arguments,e=>Ha(e,t,n))?f.none():f.some(a?`inlineSchema`:`inlineCompile`)}const Wa=r.define({name:`no-inline-schema-compile`,meta:B({type:`problem`,description:`Disallow compiling Schema decoders, encoders, and guards inside function bodies.`,messages:{inlineSchema:`Hoist Schema.{{method}}(...) to module scope: both the inline schema and the compiled function are rebuilt on every call. Move the compiled function to a module-level const.`,inlineCompile:`Hoist Schema.{{method}}(...) to module scope: the compiled function is rebuilt on every call. Move it to a module-level const.`},url:`https://github.com/pingdotgg/t3code/blob/main/oxlint-plugin-t3code/rules/no-inline-schema-compile.ts`}),*create(){let e=yield*i,n=yield*z;return n.hasEffectImport?s.on(`CallExpression`,r=>f.zipWith(Na(r.callee,n,e.sourceCode),Ua(r,n,e.sourceCode),(e,t)=>({method:e,messageId:t})).pipe(f.match({onNone:()=>d.void,onSome:({method:n,messageId:i})=>e.report(t.fromId({node:r.callee,messageId:i,data:{method:n}}))}))):{}}}),Ga=m.is(Yt),Ka=m.is($t);function qa(e,t){return e.pipe(f.filter(([e,n])=>e===`Effect`&&t(n)),f.flatMapNullishOr(([,e])=>e))}function Ja(e,t){return f.flatMap(A(e),e=>{let n=k(e)?Ie(e).pipe(f.filter(t=>F(c.last(t.arguments),e)),f.flatMap(e=>qa(t.path(e.callee),Ga))):f.none();return f.orElse(n,()=>Ja(e,t))})}const Ya=r.define({name:`no-logging-in-catch`,meta:B({type:`suggestion`,description:`Keep logging separate from Effect recovery handlers.`,messages:{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>{let i=n.path(r.callee);return f.zipWith(qa(i,Ka),Ja(r,n),(e,t)=>t).pipe(f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`logging`,data:{logger:i.pipe(f.getOrElse(()=>[]),c.join(`.`)),catchMethod:n}}))}))})}});function Xa(e,t){return g.type().pipe(g.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:e},property:{type:`Identifier`,name:t}},v.constTrue),g.orElse(v.constFalse))}const Za=Xa(`Effect`,m.is(Xt)),Qa=Xa(`Match`,m.is(tn)),$a=/* @__PURE__ */ new Set([`_tag`]);function eo(e,t=$a){return e.type===`MemberExpression`&&f.exists(S(e),e=>t.has(e))}function to(e,t=$a){return be(e.operator)?c.findFirst([_.make(e.left,e.right),_.make(e.right,e.left)],([e,n])=>eo(e,t)&&M(n)).pipe(f.map(([e])=>e)):f.none()}function no(e){return Fe(e).pipe(f.flatMap(Ie),f.exists(e=>Za(e.callee)))}function ro(e){return e.type===`MemberExpression`&&f.contains(S(e),`reason`)}function io(e){return ro(e.object)}function ao(e){return f.exists(j(e,`CallExpression`),t=>P(t.arguments,e)&&Qa(t.callee))}const oo=r.define({name:`no-manual-effect-error-tag`,meta:B({type:`problem`,description:"Use Effect tagged error handlers instead of manually branching on `_tag` in a catch handler.",messages:{tag:`Use Effect.catchTag or Effect.catchTags instead of manually discriminating a tagged error in a broad Effect catch handler.`,reason:"Use Effect.catchReason or Effect.catchReasons instead of manually discriminating a tagged `reason` in a broad Effect catch handler."},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-effect-error-tag.ts`}),*create(){let e=yield*i;function n(n,r){return no(n)?e.report(t.fromId({node:n,messageId:io(r)?`reason`:`tag`})):d.void}return s.merge(s.on(`BinaryExpression`,e=>f.match(to(e),{onNone:()=>d.void,onSome:t=>n(e,t)})),s.on(`SwitchStatement`,e=>eo(e.discriminant)?n(e,e.discriminant):d.void))}}),so=m.is(ai);function co(e,t){return e.type===`CallExpression`&&e.callee.type===`MemberExpression`&&f.exists(S(e.callee),t)}function lo(e){return co(e,so)}function uo(e){if(M(e))return f.some(e.value);if(e.type!==`Literal`||!(`regex`in e))return f.none();let{pattern:t}=e.regex,n=/^\[(\\?.)\]$/u.exec(t)?.[1]??t;return f.some(n.length===2&&h.startsWith(`\\`)(n)?h.slice(1)(n):n)}function fo(e){return f.all([f.flatMap(E(e,0),uo),E(e,1)]).pipe(f.flatMap(([e,t])=>M(t)&&e.length===1&&t.value.length===1?f.some(`${e}${t.value}`):f.none()))}function po(e){return lo(e)?[...f.toArray(fo(e)),...po(D(e.callee.object))]:[]}function mo(e){let{parent:t}=e;return t.type!==`MemberExpression`||t.object!==e||!lo(t.parent)||t.parent.callee!==t}function ho(e,t){let n=lo(e)?mo(e)?po(e):[]:go(e,t);return(c.contains(n,`+-`)||c.contains(n,`-+`))&&(c.contains(n,`/_`)||c.contains(n,`_/`))}function go(e,t){return!(e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`pipe`))&&!yo(e.callee,t)?[]:c.flatMap(e.arguments,e=>e.type===`CallExpression`&&t.isApi(e.callee,`String`,[`replace`,`replaceAll`])?f.toArray(fo(e)):[])}function _o(e){return f.exists(E(e,0),N(2))&&f.exists(E(e,1),N(`0`))}function vo(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`String`,`padStart`)&&_o(e)}function yo(e,t){return t.isApi(e,`Function`,`pipe`)||e.type===`Identifier`&&e.name===`pipe`}function bo(e,t){let{parent:n}=e;return n.type===`MemberExpression`?n.object===e&&f.contains(S(n),`padStart`)&&n.parent.type===`CallExpression`&&n.parent.callee===n&&_o(n.parent):n.type!==`CallExpression`||!F(E(n,0),e)?!1:vo(n.callee,t)||yo(n.callee,t)&&f.exists(E(n,1),e=>vo(e,t))}function xo(e){return co(e,e=>e===`toString`)&&e.arguments.length===1&&f.exists(E(e,0),N(16))}const So=r.define({name:`no-manual-encoding`,meta:B({type:`suggestion`,description:`Disallow hand-written Base64Url and hexadecimal conversions in Effect projects.`,messages:{base64Url:`Swapping '+'/'-' and '/'/'_' by hand converts between Base64 and Base64Url. Use Base64Url.encode or Base64Url.decode from effect/encoding.`,hex:`Padding each byte's toString(16) to two digits hand-writes hexadecimal encoding. Use Hex.encode from effect/encoding.`},url:`https://effect.website/docs/v4/api/effect/encoding/Base64Url`}),*create(){let e=yield*i,n=yield*z;return n.hasEffectImport?s.on(`CallExpression`,r=>ho(r,n)?e.report(t.fromId({node:r,messageId:`base64Url`})):xo(r)&&bo(r,n)?e.report(t.fromId({node:r,messageId:`hex`})):d.void):{}}}),Co=m.is(_i),wo=m.is(vi);function To(e){if(e.type===`PrivateIdentifier`)return`\0`;let t=D(e);return M(t)?t.value:t.type===`TemplateLiteral`?c.join(c.map(t.quasis,({value:e})=>e.cooked??e.raw),`\0`):t.type===`BinaryExpression`&&t.operator===`+`?To(t.left)+To(t.right):`\0`}function Eo(e){return e.type===`BinaryExpression`&&e.operator===`+`}const Do=r.define({name:`no-manual-sse`,meta:B({type:`suggestion`,description:`Disallow writing or parsing Server-Sent Events text by hand in Effect projects.`,messages:{frame:"Write events with Sse.encoder.write, Sse.encode or HttpApiSchema.StreamSse: a hand-written frame breaks on a line break in `data` and lets `id` or `event` inject fields.",parse:"Parse events with Sse.decode, Sse.decodeSchema or Sse.makeParser: matching `{{prefix}}` by hand misses fields without a space, multi-line data, comments and CR line endings."},url:`https://www.effect.website/docs/v4/api/effect/encoding/Sse`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r({callee:e}){return n.isApi(e,`String`,`startsWith`)||e.type===`MemberExpression`&&f.contains(S(e),`startsWith`)}function a(n){return!f.exists(A(n),Eo)&&Co(To(n))?e.report(t.fromId({node:n,messageId:`frame`})):d.void}return s.merge(s.on(`Literal`,e=>M(e)?a(e):d.void),s.on(`TemplateLiteral`,a),s.on(`BinaryExpression`,e=>Eo(e)?a(e):d.void),s.on(`CallExpression`,n=>E(n,0).pipe(f.filter(M),f.match({onNone:()=>d.void,onSome:({value:i})=>wo(i)&&r(n)?e.report(t.fromId({node:n,messageId:`parse`,data:{prefix:i}})):d.void}))))}}),Oo=m.Struct({discriminants:m.Array(m.String).annotate({description:"Discriminant properties checked in addition to `_tag`. Replaces the default `['kind', 'status']`."}).pipe(m.optionalKey)}).pipe(m.UndefinedOr),ko=m.Struct({maxLines:m.Int.pipe(m.optionalKey)}).pipe(m.UndefinedOr),Ao=r.define({name:`no-manual-tag-comparison`,meta:B({type:`problem`,description:"Use Effect Match or Predicate helpers instead of manually branching on `_tag` or another configured discriminant.",messages:{manualComparison:`Use Match.tag/Match.tags for tagged-value branching, or Predicate.isTagged for a simple reusable predicate.`,manualSwitch:"Use Match.value(value).pipe(Match.tag/Match.tags/Match.tagsExhaustive) or the tagged enum `$match` helper instead of switching on `_tag`.",manualDiscriminantComparison:"Use Match.discriminator('{{discriminant}}')/Match.discriminators('{{discriminant}}') or a Match.when pattern instead of comparing `{{discriminant}}` manually.",manualDiscriminantSwitch:"Use Match.type or Match.value with Match.discriminatorsExhaustive('{{discriminant}}') instead of switching on `{{discriminant}}`.",isTagged:`Replace with {{replacement}}.`},hasSuggestions:!0,url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tag-comparison.ts`,schema:[{type:`object`,properties:{discriminants:{type:`array`,items:{type:`string`,minLength:1},uniqueItems:!0,description:"Discriminant properties to check in addition to `_tag`. Replaces the default list."}},additionalProperties:!1}],defaultOptions:[{discriminants:[`kind`,`status`]}]}),options:Oo,*create(e){let n=yield*i,r=/* @__PURE__ */ new Set([`_tag`,...e?.discriminants??[]]);function a(e,n,r){return t.fromId({node:e,messageId:eo(n)?`manual${r}`:`manualDiscriminant${r}`,data:{discriminant:f.getOrElse(S(n),()=>``)}})}function o(e,t){return eo(t)&&no(e)}let l=d.fnUntraced(function*(e,r){let i=a(e,r,`Comparison`),o=r===e.left?e.right:e.left;if(!eo(r)||!M(o)||c.isReadonlyArrayNonEmpty(n.sourceCode.getCommentsInside(e)))return yield*n.report(i);let s=e.operator===`!==`||e.operator===`!=`?`!`:``,l=`${V(n.sourceCode,r.object)}, ${n.sourceCode.getText(o)}`;function u(e){return`${s}${e}.isTagged(${l})`}let d=yield*Xn(e,`effect/Predicate`,`P`,u);return yield*n.report(t.withSuggestions(i,[{messageId:`isTagged`,data:{replacement:u(`P`)},fix:d}]))});return s.merge(s.on(`BinaryExpression`,e=>f.match(to(e,r),{onNone:()=>d.void,onSome:t=>o(e,t)?d.void:l(e,t)})),s.on(`SwitchStatement`,e=>eo(e.discriminant,r)&&!o(e,e.discriminant)?n.report(a(e,e.discriminant,`Switch`)):d.void))}}),jo=r.define({name:`no-manual-tagged-construction`,meta:B({type:`problem`,description:"Construct tagged values with their existing Effect constructor instead of writing `_tag` manually.",messages:{manualConstruction:"Use the existing Schema tagged `.make`, tagged class/error constructor, or Data.taggedEnum variant constructor instead of writing a literal `_tag` object."},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tagged-construction.ts`}),*create(){let e=yield*i;return s.on(`ObjectExpression`,n=>ao(n)?d.void:f.match(c.findFirst(n.properties,e=>e.type===`Property`&&f.contains(w(e),`_tag`)&&M(e.value)),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`manualConstruction`}))}))}}),Mo=m.is(vt),No=m.is(xt),Po=g.type().pipe(g.when({type:`TSLiteralType`,literal:{type:`Literal`,value:h.isString}},v.constTrue),g.when({type:`TSParenthesizedType`},({typeAnnotation:e})=>Po(e)),g.when({type:`TSUnionType`},({types:e})=>c.every(e,Po)),g.orElse(v.constFalse)),Fo=m.is(Ft);function Io(e){return f.match(f.filter(A(e),e=>e.type===`TSUnionType`||e.type===`TSParenthesizedType`),{onNone:()=>e,onSome:Io})}function Lo(e){let t=Io(e);return j(t,`TSTypeParameterInstantiation`).pipe(f.filter(e=>F(c.get(e.params,1),t)),f.flatMap(e=>j(e,`TSTypeReference`)),f.exists(({typeName:e})=>e.type===`Identifier`&&Fo(e.name)))}function Ro(e){return e.type===`TSModuleDeclaration`&&e.declare}const zo=r.define({name:`no-manual-tagged-type`,meta:B({type:`problem`,description:"Derive tagged types from a tagged Schema or Data constructor instead of declaring `_tag` in a type.",messages:{manualTaggedType:"Do not declare `_tag` by hand. Define the value with Schema.TaggedStruct, Schema.TaggedClass, Schema.TaggedError, Schema.TaggedUnion, Data.TaggedClass or Data.taggedEnum, then infer the type from it, such as `type X = typeof X.Type`."},url:`https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/no-manual-tagged-type.ts`}),*create(){let e=yield*i;return No(e.filename)?{}:s.on(`TSPropertySignature`,n=>f.contains(w(n),`_tag`)&&y.isNotNull(n.typeAnnotation)&&Po(n.typeAnnotation.typeAnnotation)&&!Lo(n.parent)&&f.isNone(Pe(n,Ro))?e.report(t.fromId({node:n,messageId:`manualTaggedType`})):d.void)}}),Bo=m.Literals([`day`,`hour`,`minute`,`second`,`week`]),Vo=m.Literals([`days`,`hours`,`millis`,`minutes`,`seconds`,`weeks`]),Ho=m.String.check(m.isPattern(/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i)),Uo=m.Literals([...Bo.literals,`backoff`,`cooldown`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`interval`,`lifetime`,`throttle`,`timeout`,`ttl`]),Wo=m.Literals([`at`,`created`,`deadline`,`end`,`ended`,`epoch`,`last`,`now`,`since`,`start`,`started`,`timestamp`,`until`,`updated`]),Go=m.Literals([...Wo.pick([`at`,`epoch`,`timestamp`]).literals,`per`]),Ko=m.Literals([`millis`,`milliseconds`,`ms`]);m.Literals([`duration`,`instant`]);const qo=m.Literals([6e4,36e5,864e5]),Jo=m.Literals([60,3600,86400]),Yo=m.Literals([7,24,1e3,...Jo.literals]),Xo=m.Literals([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),Zo=/* @__PURE__ */ new Map([[`Effect.cachedInvalidateWithTTL`,`last`],[`Effect.cachedWithTTL`,`last`],[`Effect.delay`,`last`],[`Effect.sleep`,`last`],[`Effect.timeout`,`last`],[`Effect.timeoutOption`,`last`],[`Effect.timeoutOrElse`,`options.duration`],[`Schedule.duration`,`last`],[`Schedule.during`,`last`],[`Schedule.exponential`,`first`],[`Schedule.fibonacci`,`last`],[`Schedule.fixed`,`last`],[`Schedule.spaced`,`last`],[`Schedule.windowed`,`last`],[`Stream.debounce`,`last`],[`Stream.groupedWithin`,`last`],[`Stream.throttle`,`options.duration`],[`Stream.timeout`,`last`],[`TestClock.adjust`,`last`]]),Qo=g.type().pipe(g.withReturnType(),g.when(`first`,()=>e=>E(e,0)),g.when(`last`,()=>e=>E(e,e.arguments.length-1)),g.when(`options.duration`,()=>e=>E(e,e.arguments.length-1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(T(`duration`)),f.map(({value:e})=>e))),g.exhaustive);function $o(e,t){return f.match(t.path(e.callee).pipe(f.flatMapNullishOr(e=>Zo.get(c.join(e,`.`)))),{onNone:()=>d.succeedNone,onSome:t=>d.map(at(e.callee),n=>n?Qo(t)(e):f.none())})}const es=g.type().pipe(g.withReturnType(),g.when(`*`,()=>f.some(ne.multiply)),g.when(`+`,()=>f.some(ne.sum)),g.when(`-`,()=>f.some(ne.subtract)),g.when(`/`,()=>f.some(ne.divideUnsafe)),g.when(`%`,()=>f.some(ne.remainder)),g.when(`**`,()=>f.some((e,t)=>e**t)),g.orElse(()=>f.none()));function ts(e){return e.type===`Literal`&&y.isNumber(e.value)?f.some(e.value):f.none()}function ns(e){let t=D(e);if(t.type===`Literal`)return ts(t);if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`))return f.map(ns(t.argument),e=>t.operator===`+`?e:-e);if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return f.none();let{left:n,right:r,operator:i}=t;return f.flatMap(es(i),e=>f.zipWith(ns(n),ns(r),(t,n)=>e(t,n)))}function rs(e){let t=D(e);return t.type===`Literal`?f.map(ts(t),c.of):t.type===`BinaryExpression`&&t.operator===`*`?f.zipWith(rs(t.left),rs(t.right),(e,t)=>[...e,...t]):f.none()}const is=m.is(qo),as=m.is(Jo),os=m.is(Yo);function ss(e){return rs(e).pipe(f.filter(e=>e.length>=2&&(c.some(e,is)||c.some(e,as)&&c.filter(e,os).length>=2)),f.map(e=>({millis:c.contains(e,1e3)||c.some(e,e=>e%6e4==0)})))}const cs=v.flow(h.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),c.filter(h.isNonEmpty),c.map(h.toLowerCase)),ls=m.is(Ko),us=m.is(Wo);function ds(e){let t=cs(e);return c.last(t).pipe(f.filter(ls),f.map(()=>c.some(t,us)?`instant`:`duration`))}const fs={weeks:x.weeks,days:x.days,hours:x.hours,minutes:x.minutes,seconds:x.seconds,millis:x.millis},ps=[[`weeks`,x.toWeeks],[`days`,x.toDays],[`hours`,x.toHours],[`minutes`,x.toMinutes],[`seconds`,x.toSeconds],[`millis`,x.toMillis]];function ms(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):h.replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)(String(e))}function hs(e,t){let n=fs[t](e);return x.isZero(n)?`Duration.zero`:c.findFirst(ps,([,e])=>Number.isSafeInteger(e(n))).pipe(f.match({onNone:()=>`Duration.millis(${n.pipe(x.toMillis,ms)})`,onSome:([e,t])=>`Duration.${e}(${ms(t(n))})`}))}const gs=m.is(_e),_s={"!==":`Duration.equals`,"*":`Duration.times`,"+":`Duration.sum`,"-":`Duration.subtract`,"/":`Duration.divide`,"<":`Duration.isLessThan`,"<=":`Duration.isLessThanOrEqualTo`,"===":`Duration.equals`,">":`Duration.isGreaterThan`,">=":`Duration.isGreaterThanOrEqualTo`},vs={"!==":`DateTime.Equivalence`,"+":`DateTime.addDuration`,"-":`DateTime.subtractDuration`,"<":`DateTime.isLessThan`,"<=":`DateTime.isLessThanOrEqualTo`,"===":`DateTime.Equivalence`,">":`DateTime.isGreaterThan`,">=":`DateTime.isGreaterThanOrEqualTo`},ys=`Duration.isPositive, Duration.isNegative or Duration.isZero`,bs={"!==":`Duration.isZero`,"<":ys,"<=":ys,"===":`Duration.isZero`,">":ys,">=":ys};function xs(e){let t=D(e);return t.type===`TemplateLiteral`||t.type===`Literal`&&y.isString(t.value)?!0:t.type===`BinaryExpression`&&t.operator===`+`&&(xs(t.left)||xs(t.right))}function Ss(e){let t=D(e);return t.type===`Identifier`&&t.name===`undefined`||t.type===`Literal`&&!y.isNumber(t.value)}function Cs(e,t){let n=e.name.parent;return(n.type===`AssignmentPattern`?n.parent:n).type===`Property`||e.type===`Parameter`&&f.exists(Fe(e.name),e=>Ai(e,t))}function W(e){return f.contains(e,`instant`)}function ws(e,t){let{left:n,right:r}=t;return e===`+`?W(n)===W(r)?`duration`:`instant`:e===`-`&&W(n)&&!W(r)?`instant`:`duration`}function Ts(e,t){let n=W(t.left)||W(t.right);if(W(t.right)&&e.operator===`-`)return`DateTime.distance`;if(N(e.right,1e3)&&e.operator===`/`)return n?`DateTime.toEpochSeconds`:`Duration.toSeconds`;let r=!n&&(N(e.left,0)||N(e.right,0));return l.get(bs,e.operator).pipe(f.filter(()=>r),f.orElse(()=>f.filter(l.get(vs,e.operator),()=>n)),f.orElse(()=>l.get(_s,e.operator)),f.getOrElse(()=>`Duration`))}function Es(e){return e.type===`BinaryExpression`&&e.left.type!==`PrivateIdentifier`}function Ds(e){return f.flatMap(A(e),e=>ye(e.type)?Ds(e):f.liftPredicate(e,Es))}const Os=r.define({name:`no-millis-arithmetic`,meta:B({type:`suggestion`,description:`Disallow arithmetic and comparisons on millisecond numbers where Effect Duration or DateTime can do the math.`,messages:{millisArithmetic:`{{operand}} is {{what}} in milliseconds. Keep it as a {{module}} and use {{suggestion}}; convert to milliseconds only where a non-Effect API needs them.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r(e,t){return d.map(at(e),e=>e?f.some(t):f.none())}function a(e){return n.isApiPath(e,[`Duration`,`toMillis`])?r(e,`duration`):n.isApiPath(e,[`DateTime`,`toEpochMillis`])?r(e,`instant`):d.succeedNone}let o=d.fnUntraced(function*(e,t){let r=rt(yield*nt(e,e.name));if(f.exists(r,e=>Cs(e,n)))return f.none();let i=ds(e.name);if(f.isSome(i))return i;let a=f.flatMap(r,({node:e,name:t})=>e.type===`VariableDeclarator`&&je(e.parent)&&e.id===t&&y.isNotNull(e.init)?f.some(e.init):f.none());return f.isSome(a)?yield*c(a.value,t+1):f.none()});function c(e,t){if(t>4)return d.succeedNone;let i=D(e);if(i.type===`Identifier`)return o(i,t);if(i.type===`MemberExpression`)return d.succeed(i.object.type===`ThisExpression`?f.flatMap(S(i),ds):f.none());if(i.type===`CallExpression`)return a(i.callee);if(i.type===`YieldExpression`){let e=i.argument;return y.isNotNull(e)&&i.delegate&&n.isApiPath(e,[`Clock`,`currentTimeMillis`])?r(e,`instant`):d.succeedNone}return!Es(i)||!gs(i.operator)?d.succeedNone:d.map(u(i,t),f.map(e=>ws(i.operator,e)))}function u(e,t){return!l.has(_s,e.operator)||e.operator===`+`&&(xs(e.left)||xs(e.right))||(e.operator===`===`||e.operator===`!==`)&&(Ss(e.left)||Ss(e.right))?d.succeedNone:d.map(d.all({left:c(e.left,t),right:c(e.right,t)},{concurrency:1}),e=>f.isNone(e.left)&&f.isNone(e.right)?f.none():f.some(e))}function p(n,r){let i=W(r.left)||W(r.right);return e.report(t.fromId({node:n,messageId:`millisArithmetic`,data:{operand:e.sourceCode.getText(f.match(r.left,{onNone:()=>n.right,onSome:()=>n.left})),what:i?`a timestamp`:`a duration`,module:i?`DateTime`:`Duration`,suggestion:Ts(n,r)}}))}return s.on(`BinaryExpression`,d.fnUntraced(function*(e){if(!Es(e))return;let t=yield*u(e,0);if(f.isNone(t))return;let n=Ds(e),r=f.isSome(n)?yield*u(n.value,0):f.none();f.isSome(r)||(yield*p(e,t.value))}))}}),ks={addEventListener:1,on:1,setInterval:0};function As(e){return f.exists(E(e,2),e=>e.type===`ObjectExpression`&&f.exists(T(e,`once`),e=>N(e.value,!0)))}function js(e,t){return C(e.callee).pipe(f.map(c.lastNonEmpty),f.exists(n=>f.exists(l.get(ks,n),r=>(n!==`addEventListener`||!As(e))&&f.exists(E(e,r),e=>Ae(e,t)))))}function Ms(e){return f.exists(E(e,0),e=>{if(!k(e)||y.isNullish(e.body))return!1;let t=e.body;return f.exists(Me(e),({name:e})=>O(t,t=>t.type===`CallExpression`&&js(t,e)))})}const Ns=r.define({name:`no-multi-shot-effect-callback`,meta:B({type:`problem`,description:`Disallow attaching Effect.callback resume to repeating event sources.`,messages:{multiShot:`Effect.callback is single-shot, but this source emits repeatedly. Use a once-style subscription or Stream.callback.`},url:`https://github.com/Effect-TS/tsgo/issues/484`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`callback`)&&Ms(r)?e.report(t.fromId({node:r,messageId:`multiShot`})):d.void)}}),Ps=m.is(mi),Fs=m.is(hn),Is=[`default`,`examples`];function Ls(e){return e.type===`Literal`&&y.isBigInt(e.value)||e.type===`Identifier`&&Ps(e.name)||k(e)||e.type===`CallExpression`&&f.exists(C(e.callee),e=>c.lastNonEmpty(e)===`Symbol`)}function Rs(e){return e.type===`ArrayExpression`?c.filter(e.elements,e=>y.isNotNull(e)&&e.type!==`SpreadElement`):e.type===`ObjectExpression`?c.flatMap(e.properties,e=>e.type===`Property`?[e.value]:[]):[]}function zs(e){let t=D(e);return Ls(t)?f.some(t):c.findFirst(c.reverse(Rs(t)),zs)}function Bs(e,t){let n=e.callee.type===`MemberExpression`?S(e.callee):t.path(e.callee).pipe(f.filter(([e])=>e===`Schema`),f.flatMapNullishOr(([,e])=>e));return f.filter(n,Fs)}function Vs(e){return Te(e).pipe(f.filter(e=>f.isNone(T(e,`jsonSchema`))),f.match({onNone:()=>[],onSome:e=>c.getSomes(c.map(Is,t=>f.flatMap(T(e,t),({value:e})=>zs(e))))}))}const Hs=r.define({name:`no-non-json-schema-annotation`,meta:B({type:`problem`,description:`Disallow schema examples and defaults that cannot be represented in JSON Schema.`,messages:{nonJson:`This schema annotation value is not JSON-serializable and will be omitted from or corrupt generated JSON Schema.`},url:`https://github.com/Effect-TS/tsgo/issues/440`}),*create(){let e=yield*i,n=yield*z;return n.hasEffectImport?s.on(`CallExpression`,r=>f.match(Bs(r,n),{onNone:()=>d.void,onSome:()=>d.forEach(Vs(r),n=>e.report(t.fromId({node:n,messageId:`nonJson`})),{concurrency:1,discard:!0})})):{}}}),Us=[`option`,`either`];function Ws(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`service`)}function Gs(e,t){let n=E(e,0);return t.isApi(e.callee,`Effect`,Us)?f.exists(n,e=>Ws(e,t)):e.callee.type===`MemberExpression`&&f.exists(C(e.callee),e=>c.lastNonEmpty(e)===`pipe`)&&Ws(D(e.callee.object),t)&&f.exists(n,e=>t.isApi(e,`Effect`,Us))}const Ks=r.define({name:`no-option-of-service`,meta:B({type:`problem`,description:`Disallow wrapping infallible Effect.service access in Option or Either.`,messages:{mandatory:`Effect.service never fails, so this wrapper is always present and keeps the service requirement. Use Effect.serviceOption.`},url:`https://github.com/Effect-TS/tsgo/issues/648`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>Gs(r,n)?e.report(t.fromId({node:r,messageId:`mandatory`})):d.void)}}),qs=r.define({name:`no-overwritten-discriminant`,meta:B({type:`problem`,description:`Ensure a later object spread cannot overwrite an explicitly assigned _tag.`,messages:{overwritten:`A later spread can overwrite _tag at runtime. Move _tag after all spreads.`},url:`https://github.com/Effect-TS/tsgo/issues/426`}),*create(){let e=yield*i;return s.on(`ObjectExpression`,n=>c.findFirstWithIndex(n.properties,e=>e.type===`Property`&&f.contains(w(e),`_tag`)).pipe(f.filter(([,e])=>c.some(c.drop(n.properties,e+1),e=>e.type===`SpreadElement`)),f.match({onNone:()=>d.void,onSome:([n])=>e.report(t.fromId({node:n,messageId:`overwritten`}))})))}}),Js=m.is(Ot),Ys=m.is(We),Xs=r.define({name:`no-service-constructor-imports`,meta:B({type:`problem`,description:`Disallow project-local make<CapabilityName> imports outside test and spec files.`,messages:{serviceConstructorImport:`Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.`},url:`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-service-constructor-imports.ts`}),*create(){let e=yield*i;return Mo(h.replaceAll(`\\`,`/`)(e.filename))?{}:s.on(`ImportDeclaration`,n=>Ys(n.source.value)?d.forEach(c.filter(n.specifiers,e=>e.type===`ImportSpecifier`),n=>{let r=Se(n.imported);return Js(r)?e.report(t.fromId({node:n,messageId:`serviceConstructorImport`,data:{name:r}})):d.void},{concurrency:1,discard:!0}):d.void)}}),Zs=[`getOrThrow`,`getOrThrowWith`];function Qs(e,t){return e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`serviceOption`)}function $s(e,t){return t.isApi(e.callee,`Option`,Zs)?f.exists(E(e,0),e=>e.type===`YieldExpression`?y.isNotNullish(e.argument)&&Qs(e.argument,t):Qs(e,t)):e.callee.type===`MemberExpression`&&f.exists(C(e.callee),e=>c.lastNonEmpty(e)===`pipe`)&&Qs(D(e.callee.object),t)&&f.exists(E(e,0),e=>e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,`map`)&&f.exists(E(e,0),e=>t.isApi(e,`Option`,Zs)))}const ec=r.define({name:`no-service-option-get-or-throw`,meta:B({type:`problem`,description:`Disallow turning missing Effect services into untyped Option defects.`,messages:{getOrThrow:`Option.getOrThrow after Effect.serviceOption hides a mandatory service until runtime. Use Effect.service so it remains a typed requirement.`},url:`https://github.com/Effect-TS/tsgo/issues/650`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>$s(r,n)?e.report(t.fromId({node:r,messageId:`getOrThrow`})):d.void)}}),tc=m.is(Qt),nc=r.define({name:`no-throw-in-effect-callback`,meta:B({type:`problem`,description:`Disallow throw in Effect callbacks that cannot add the thrown value to the typed error channel.`,messages:{callbackThrow:`Throwing in this Effect callback creates an untyped defect. Return Effect.fail(...) or return the mapped error value instead.`},url:`https://github.com/Effect-TS/tsgo/issues/406`}),*create(){let e=yield*i,n=yield*z;return s.on(`ThrowStatement`,r=>f.exists(Fe(r),e=>f.exists(Oi(e,n),([e,t])=>e===`Effect`&&tc(t))||f.exists(Di(e,`catch`),e=>n.isApi(e.callee,`Effect`,[`try`,`tryPromise`])))?e.report(t.fromId({node:r,messageId:`callbackThrow`})):d.void)}}),rc=m.is(hi),ic=m.is(Pt);function ac(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||qi(n,r.type===`ImportSpecifier`?r:void 0))return!1;let i=n.source.value;return r.type===`ImportNamespaceSpecifier`?i===`effect/unstable/httpapi/HttpApiEndpoint`&&t.length===2||i===`effect/unstable/httpapi`&&t.length===3&&t[1]===`HttpApiEndpoint`:r.type===`ImportSpecifier`&&r.imported.type===`Identifier`&&r.imported.name===`HttpApiEndpoint`&&i===`effect/unstable/httpapi`&&t.length===2}function oc(e){return C(e.callee).pipe(f.filter(e=>rc(c.lastNonEmpty(e))),f.match({onNone:()=>d.succeed(!1),onSome:t=>d.map(nt(e,c.headNonEmpty(t)),e=>f.exists(rt(e),e=>ac(e,t)))}))}function sc(e){return f.orElse(w(e),()=>e.key.type===`Literal`&&y.isNumber(e.key.value)?f.some(String(e.key.value)):f.none())}function cc(e){return e.pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(e=>f.all(c.map(e.properties,we))),f.filter(e=>f.all(c.map(e,sc)).pipe(f.exists(e=>c.dedupe(e).length===e.length))))}function lc(e){return E(e,2).pipe(cc,f.flatMap(e=>c.findFirst(e,e=>f.contains(w(e),`headers`))),f.map(({value:e})=>e),cc)}const uc=r.define({name:`no-uppercase-http-api-header`,meta:B({type:`problem`,description:`Require lowercase static keys in Effect v4 endpoint header field schemas.`,messages:{uppercase:`Header schema key "{{name}}" contains ASCII uppercase letters. Incoming headers use exact lowercase runtime lookup; review the schema and its consumers before renaming this key.`},url:`https://github.com/Effect-TS/tsgo/issues/413`}),*create(){let e=yield*i;function n(n){return d.forEach(n,n=>w(n).pipe(f.filter(ic),f.match({onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n.key,messageId:`uppercase`,data:{name:r}}))})),{concurrency:1,discard:!0})}return s.on(`CallExpression`,e=>c.some(e.arguments,e=>e.type===`SpreadElement`)?d.void:d.flatMap(oc(e),t=>t?f.match(lc(e),{onNone:()=>d.void,onSome:n}):d.void))}}),dc=r.define({name:`no-zero-retry-times`,meta:B({type:`problem`,description:`Disallow no-op retry and repeat wrappers with times: 0.`,messages:{zeroTimes:`times: 0 performs no retries or repeats. Remove the wrapper or use a positive count.`},url:`https://github.com/Effect-TS/tsgo/issues/412`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,[`retry`,`repeat`])?Te(r).pipe(f.flatMap(T(`times`)),f.filter(e=>N(e.value,0)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`zeroTimes`}))})):d.void)}}),fc={Exit:[`isSuccess`,`isFailure`],Result:[`isSuccess`,`isFailure`],Option:[`isSome`,`isNone`]};function pc(e,t){let n=D(e.type===`UnaryExpression`&&e.operator===`!`?e.argument:e);return n.type!==`CallExpression`||n.arguments.length!==1?f.none():f.flatMap(t.path(n.callee),e=>{let[t,n]=e;return e.length===2&&y.isNotUndefined(t)&&y.isNotUndefined(n)&&f.exists(l.get(fc,t),c.contains(n))?f.some([t,n]):f.none()})}function mc(e){return O(e,e=>e.type===`YieldExpression`||e.type===`AwaitExpression`)}function hc(e){return f.exists(e,e=>f.exists(e.type===`BlockStatement`?c.last(e.body):f.some(e),t=>t.type===`ReturnStatement`&&y.isNotNull(t.argument)&&!mc(e)))}function gc(e){return A(e).pipe(f.filter(e=>e.type===`BlockStatement`||e.type===`Program`),f.flatMap(t=>{let n=t.body;return f.filter(c.get(n,n.indexOf(e)+1),e=>e.type===`ReturnStatement`)}))}const _c=r.define({name:`prefer-data-match`,meta:B({type:`suggestion`,description:`Use Exit.match, Result.match or Option.match instead of branching on their guards to produce a value.`,messages:{preferMatch:"Use `{{module}}.match` instead of branching on `{{module}}.{{guard}}` and producing a value in both branches."},url:`https://www.effect.website/docs/v4/api/effect/Option`}),*create(){let e=yield*i,n=yield*z;function r(r,i,a){return pc(i,n).pipe(f.filter(a),f.match({onNone:()=>d.void,onSome:([n,i])=>e.report(t.fromId({node:r,messageId:`preferMatch`,data:{module:n,guard:i}}))}))}return s.merge(s.on(`ConditionalExpression`,e=>r(e,e.test,()=>!mc(e.consequent)&&!mc(e.alternate))),s.on(`IfStatement`,e=>r(e,e.test,()=>hc(f.some(e.consequent))&&hc(f.fromNullishOr(e.alternate).pipe(f.orElse(()=>gc(e)))))))}}),vc=m.is(Dt);function yc(e){return e.type===`Identifier`?f.some(e.name):e.type===`RestElement`&&e.argument.type===`Identifier`?f.some(e.argument.name):f.none()}function bc(e,t){return O(e,e=>e.type===`ThisExpression`||e.type===`Identifier`&&c.contains(t,e.name))}function xc(e,t){let n=c.last(t.params).pipe(f.filter(e=>e.type===`RestElement`),f.flatMap(yc));return e.type===`SpreadElement`?f.filter(n,t=>e.argument.type===`Identifier`&&e.argument.name===t):e.type===`Identifier`&&!f.contains(n,e.name)?f.some(e.name):f.none()}function Sc(e,t,n){return f.all(c.flatMap(e.arguments,e=>xc(e,t).pipe(f.filter(e=>c.contains(n,e)),f.match({onSome:e=>[f.some(e)],onNone:()=>k(e)||bc(e,n)?[f.none()]:[]}))))}function Cc(e){return e.async||e.generator||e.typeParameters?f.none():f.zipWith(f.filter(f.all(c.map(e.params,yc)),c.isReadonlyArrayNonEmpty),f.filter(U(e),e=>e.type===`CallExpression`&&!e.optional),(e,t)=>({names:e,call:t})).pipe(f.flatMap(({names:t,call:n})=>n.callee.type===`Super`||bc(n.callee,t)?f.none():Sc(n,e,t).pipe(f.filter(e=>c.makeEquivalence(h.Equivalence)(e,t)),f.map(()=>({call:n,exact:n.arguments.length===t.length})))))}function wc(e){return e.returnType?.typeAnnotation.type===`TSTypePredicate`}function Tc(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.exists(t.path(n),e=>c.get(e,1).pipe(f.filter(()=>e.length===2),f.exists(t=>f.contains(c.head(e),`Schema`)?t===`is`:vc(t))))}function Ec(e,t){return e.type===`Identifier`?!0:e.type===`MemberExpression`?f.isSome(t.path(e)):e.type===`CallExpression`&&e.callee.type!==`Identifier`&&Ec(e.callee,t)}function Dc(e,t){return Le(t,e.name)?!1:e.type!==`Variable`&&e.type!==`ClassName`?!0:e.type===`Variable`&&!je(e.parent)?!1:_.get(e.node.range,1)<=_.get(t.range,0)&&!Oc(t,e.node)}function Oc(e,t){let n=e.parent;return!n||Le(n,t)?!1:n.type===`FunctionDeclaration`||Oc(n,t)}function kc(e,t,n){return c.every(c.filter(e.getScope(t).references,({identifier:e})=>Le(t,e)),({resolved:e})=>!e||!c.some(e.references,e=>e.isWrite()&&!e.init)&&c.every(e.defs,e=>Dc(e,n)))}const Ac={"Array.filter":2,"Array.findFirst":2,"Array.findFirstIndex":2,"Array.flatMap":2,"Array.flatten":1,"Array.head":1,"Array.isArrayEmpty":1,"Array.isArrayNonEmpty":1,"Array.isReadonlyArrayEmpty":1,"Array.isReadonlyArrayNonEmpty":1,"Array.last":1,"Array.length":1,"Array.map":2,"Array.reverse":1,"Option.filter":2,"Option.flatMap":2,"Option.flatten":1,"Option.getFailure":1,"Option.getOrElse":2,"Option.getOrNull":1,"Option.getOrUndefined":1,"Option.getSuccess":1,"Option.isNone":1,"Option.isSome":1,"Option.map":2,"Option.match":2,"Option.orElse":2,"Option.some":1,"Result.flatMap":2,"Result.getFailure":1,"Result.getOrElse":2,"Result.getSuccess":1,"Result.isFailure":1,"Result.isSuccess":1,"Result.map":2,"Result.mapError":2};function jc(e,t){return t.path(e).pipe(f.filter(e=>e.length===2),f.flatMap(e=>{let t=c.join(e,`.`);return f.map(l.get(Ac,t),e=>_.make(t,e))}))}function Mc(e,t,n){return(e.type===`Identifier`||e.type===`MemberExpression`)&&f.exists(n.path(e),e=>c.join(e,`.`)===t)}function Nc(e){return e.optional||y.isNotNullish(e.typeArguments)||c.some(e.arguments,e=>e.type===`SpreadElement`)?f.none():f.some(e.arguments)}function Pc(e,t){return e.type===`CallExpression`?f.product(jc(e.callee,t),Nc(e)).pipe(f.flatMap(([[t,n],r])=>r.length===n?f.map(c.head(r),n=>({self:n,step:{api:t,node:e,callee:e.callee,args:c.drop(r,1)}})):f.none())):f.none()}function Fc(e,t){return e.type===`CallExpression`?f.product(jc(e.callee,t),Nc(e)).pipe(f.flatMap(([[t,n],r])=>r.length+1===n?f.some({api:t,node:e,callee:e.callee,args:r}):f.none())):e.type===`Identifier`||e.type===`MemberExpression`?f.flatMap(jc(e,t),([t,n])=>n===1?f.some({api:t,node:e,callee:e,args:[]}):f.none()):f.none()}function Ic(e,t){if(e.type!==`CallExpression`)return f.none();let n=e.callee;return f.flatMap(Nc(e),r=>n.type===`MemberExpression`&&n.object.type!==`Super`&&f.contains(S(n),`pipe`)?f.some({kind:`pipe`,call:e,subject:f.some(n.object),steps:r}):t.isApi(n,`Function`,`pipe`)||t.isApiPath(n,[`pipe`])?f.some({kind:`pipe`,call:e,subject:c.head(r),steps:c.drop(r,1)}):t.isApi(n,`Function`,`flow`)||t.isApiPath(n,[`flow`])?f.some({kind:`flow`,call:e,subject:f.none(),steps:r}):f.none())}function Lc(e,t){return c.map(t,t=>V(e.sourceCode,t))}function G(e,t={}){return(n,r)=>f.some({api:e,negate:t.negate??!1,safety:t.safety?.(n,r)??`fix`,args:t.args?.(n,r)??Lc(r,[...n.inner.args,...n.outer.args])})}function Rc(e,t){return({inner:n,outer:r},i)=>{let[a=``,o=``]=Lc(i,[...n.args,...r.args]);return[`{ ${e}: ${a}, ${t}: ${o} }`]}}function K(e){return c.head(e.args)}function zc(e){return e.type===`ArrowFunctionExpression`&&!e.async&&c.isReadonlyArrayEmpty(e.params)}function Bc(e){return zc(e)&&e.expression&&N(e.body,!1)}function Vc(e){return e.type===`CallExpression`?Vc(e.callee):e}const Hc=/* @__PURE__ */ new Set([`contains`,`endsWith`,`every`,`exists`,`has`,`includes`,`is`,`some`,`startsWith`]),Uc=/* @__PURE__ */ new Set([`!=`,`!==`,`<`,`<=`,`==`,`===`,`>`,`>=`,`in`,`instanceof`]);function Wc(e,t){return g.value(e).pipe(g.discriminators(`type`)({BinaryExpression:({operator:e})=>Uc.has(e),UnaryExpression:({operator:e})=>e===`!`,Literal:({value:e})=>y.isBoolean(e),LogicalExpression:({operator:e,left:n,right:r})=>e!==`??`&&Wc(n,t)&&Wc(r,t),ConditionalExpression:({consequent:e,alternate:n})=>Wc(e,t)&&Wc(n,t),CallExpression:e=>t.path(Vc(e)).pipe(f.flatMap(e=>c.get(e,1)),f.exists(e=>Hc.has(e)||/^is\p{Lu}/u.test(e)))}),g.orElse(v.constFalse))}function Gc(e,t){return e.type===`ConditionalExpression`?Gc(e.consequent,t)||Gc(e.alternate,t):e.type===`CallExpression`&&!Wc(e,t)&&f.exists(t.path(Vc(e)),e=>f.contains(c.head(e),`Option`))}function Kc(e){return k(e)&&!e.async&&!e.generator?U(e):f.none()}function qc(e,t){return f.exists(K(e.inner),e=>Jc(e,t.imports))?`fix`:`boolean`}function Jc(e,t){return Tc(e,t)||f.exists(Kc(e),e=>Wc(e,t))}const Yc=/* @__PURE__ */ new Set(/* @__PURE__ */ `append.appendAll.dedupe.drop.empty.filter.filterMap.flatMap.flatMapNullishOr.flatten.fromIterable.getFailures.getSomes.getSuccesses.make.map.of.prepend.prependAll.range.replicate.reverse.sort.sortBy.sortWith.take`.split(`.`));function Xc(e,t){return e.type===`ArrayExpression`||t.isApi(e.type===`CallExpression`?e.callee:e,`Array`,[...Yc])}function Zc(e){return(t,n)=>f.map(e(t,n),e=>e.safety===`fix`&&!f.exists(t.input,e=>Xc(e,n.imports))?u.assign(e,{safety:`array`}):e)}function Qc(e){return k(e)&&e.params.length<=1&&c.every(e.params,e=>e.type!==`RestElement`)&&(e.type===`ArrowFunctionExpression`||!Ae(e,`arguments`))}function $c(e){return k(e)||e.type===`Literal`||e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)||f.isSome(C(e))}function el(e){return(t,n)=>K(t.inner).pipe(f.flatMap(Kc),f.exists(e=>Gc(e,n.imports)))?f.none():e(t,n)}function tl(e,t){if(e.type!==`ArrowFunctionExpression`||e.async||!e.expression||e.params.length!==1)return!1;let[n]=e.params,r=e.body;return n?.type===`Identifier`&&r.type===`MemberExpression`&&!r.optional&&r.object.type===`Identifier`&&r.object.name===n.name&&f.contains(S(r),t)}const nl=[{guard:`Option.isSome`,field:`value`,getter:f.some(`Option.getOrThrow`),api:`Array.getSomes`},{guard:`Result.isSuccess`,field:`success`,getter:f.some(`Result.getOrThrow`),api:`Array.getSuccesses`},{guard:`Result.isFailure`,field:`failure`,getter:f.none(),api:`Array.getFailures`}];function rl(e,t){return f.product(K(e.inner),K(e.outer)).pipe(f.flatMap(([e,n])=>c.findFirst(nl,r=>Mc(e,r.guard,t.imports)&&(tl(n,r.field)||f.exists(r.getter,e=>Mc(n,e,t.imports))))),f.flatMap(({api:n})=>G(n,{args:()=>[]})(e,t)))}function il(e,t){return f.exists(K(e.outer),e=>f.exists(t.imports.path(e),e=>c.join(e,`.`)===`Predicate.isNotNullish`))?G(`Array.flatMapNullishOr`,{args:({inner:e})=>Lc(t,e.args),safety:({inner:e})=>f.exists(K(e),Qc)?`fix`:`none`})(e,t):f.none()}const al=[`Option.getSuccess`,`Result.getSuccess`],ol=[`Option.getFailure`,`Result.getFailure`],sl=[{inner:[`Option.some`],outer:[`Option.filter`],rewrite:G(`Option.liftPredicate`)},{inner:[`Option.filter`],outer:[`Option.isSome`],rewrite:G(`Option.exists`)},{inner:[`Option.filter`],outer:[`Option.isNone`],rewrite:G(`Option.exists`,{negate:!0})},{inner:[`Option.map`],outer:[`Option.flatten`],rewrite:G(`Option.flatMap`)},{inner:[`Option.map`],outer:[`Option.getOrElse`],rewrite:(e,t)=>f.exists(K(e.outer),Bc)&&f.exists(K(e.inner),e=>Jc(e,t.imports))?G(`Option.exists`,{args:({inner:e})=>Lc(t,e.args)})(e,t):G(`Option.match`,{args:Rc(`onSome`,`onNone`)})(e,t)},{inner:al,outer:[`Option.isSome`],rewrite:G(`Result.isSuccess`)},{inner:al,outer:[`Option.isNone`],rewrite:G(`Result.isFailure`)},{inner:ol,outer:[`Option.isSome`],rewrite:G(`Result.isFailure`)},{inner:ol,outer:[`Option.isNone`],rewrite:G(`Result.isSuccess`)},{inner:al,outer:[`Option.getOrNull`],rewrite:G(`Result.getOrNull`)},{inner:al,outer:[`Option.getOrUndefined`],rewrite:G(`Result.getOrUndefined`)},{inner:al,outer:[`Option.getOrElse`],rewrite:G(`Result.getOrElse`,{safety:({outer:e})=>f.exists(K(e),zc)?`fix`:`none`})},{inner:[`Array.findFirst`],outer:[`Option.isSome`],rewrite:el(Zc(G(`Array.some`,{safety:qc})))},{inner:[`Array.findFirst`],outer:[`Option.isNone`],rewrite:el(Zc(G(`Array.some`,{negate:!0,safety:qc})))},{inner:[`Array.findFirstIndex`],outer:[`Option.isSome`],rewrite:Zc(G(`Array.some`))},{inner:[`Array.findFirstIndex`],outer:[`Option.isNone`],rewrite:Zc(G(`Array.some`,{negate:!0}))},{inner:[`Array.filter`],outer:[`Array.head`],rewrite:G(`Array.findFirst`,{safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.isArrayNonEmpty`,`Array.isReadonlyArrayNonEmpty`],rewrite:G(`Array.some`,{safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.isArrayEmpty`,`Array.isReadonlyArrayEmpty`],rewrite:G(`Array.some`,{negate:!0,safety:()=>`pure`})},{inner:[`Array.filter`],outer:[`Array.length`],rewrite:G(`Array.countBy`)},{inner:[`Array.filter`],outer:[`Array.map`],rewrite:rl},{inner:[`Array.map`],outer:[`Array.filter`],rewrite:il},{inner:[`Array.map`],outer:[`Array.flatten`],rewrite:G(`Array.flatMap`)},{inner:[`Array.head`,`Array.last`],outer:[`Option.isSome`],rewrite:G(`Array.isReadonlyArrayNonEmpty`)},{inner:[`Array.head`,`Array.last`],outer:[`Option.isNone`],rewrite:G(`Array.isReadonlyArrayEmpty`)},{inner:[`Array.reverse`],outer:[`Array.head`],rewrite:Zc(G(`Array.last`))},{inner:[`Result.map`],outer:[`Result.getOrElse`],rewrite:G(`Result.match`,{args:Rc(`onSuccess`,`onFailure`)})},{inner:[`Result.map`],outer:[`Result.mapError`],rewrite:G(`Result.mapBoth`,{args:Rc(`onSuccess`,`onFailure`)})},{inner:[`Result.mapError`],outer:[`Result.map`],rewrite:G(`Result.mapBoth`,{args:Rc(`onFailure`,`onSuccess`)})}];function cl(e,t){let n=e.nested&&c.isReadonlyArrayNonEmpty(e.inner.args)&&!c.every(e.outer.args,$c);return c.findFirst(sl,n=>c.contains(n.inner,e.inner.api)&&c.contains(n.outer,e.outer.api)?n.rewrite(e,t):f.none()).pipe(f.map(e=>n?u.assign(e,{safety:`none`}):e))}function ll(e){if(!k(e)||e.async||e.generator||y.isNullish(e.body))return f.none();let t=e.body,n=t.type===`BlockStatement`?c.head(t.body).pipe(f.filter(e=>t.body.length===1&&e.type===`ReturnStatement`),f.flatMapNullishOr(e=>e.argument)):f.some(t);return f.filter(n,e=>e.type===`CallExpression`)}function ul(e,t,n=!1){return(r,{imports:i,sourceCode:a})=>ll(r).pipe(f.filter(t=>k(r)&&y.isNullish(r.returnType)&&(!n||Qc(r))&&dl(t,e,i)),f.flatMap(e=>Nc(e).pipe(f.filter(e=>e.length===1),f.flatMap(c.head),f.map(n=>{let i=V(a,n),o=n.type===`ObjectExpression`&&r.type===`ArrowFunctionExpression`&&r.body===e?`(${i})`:i;return{api:t,callback:`a callback that returns ${a.getText(e.callee)}(…)`,argument:f.some(fl(a,r,e.range,o))}}))))}function dl(e,t,n){return f.exists(n.path(e.callee),e=>c.join(e,`.`)===t)}function fl(e,t,n,r){let i=e.text,[a,o]=t.range;return`${h.slice(a,_.get(n,0))(i)}${r}${h.slice(_.get(n,1),o)(i)}`}function pl(e){return(t,{imports:n,sourceCode:r})=>{let i=t.type===`ArrowFunctionExpression`&&!t.async&&t.expression?f.some(t.body):f.none(),a=f.exists(i,e=>e.type===`Literal`&&e.raw===`null`)||n.isApi(t,`Function`,`constNull`),o=f.exists(i,e=>L(r.getScope(e),e,`undefined`))||n.isApi(t,`Function`,`constUndefined`);if(!a&&!o)return f.none();let s=a?`null`:`undefined`;return f.some({api:a?`${e}.getOrNull`:`${e}.getOrUndefined`,callback:`a fallback of ${s}`,argument:f.none()})}}function ml(e,{imports:t,sourceCode:n}){if(e.type!==`ObjectExpression`||e.properties.length!==2)return f.none();let r=c.getSomes(c.map(e.properties,we));function i(e){return c.findFirst(r,t=>f.contains(w(t),e)&&!t.shorthand)}return i(`onNone`).pipe(f.filter(e=>r.length===2&&Bc(e.value)),f.flatMap(()=>i(`onSome`)),f.filter(e=>Jc(e.value,t)),f.map(e=>({api:`Option.exists`,callback:"`onNone: () => false`",argument:f.some(V(n,e.value))})))}function hl(e,{imports:t,sourceCode:n}){return e.type===`CallExpression`&&dl(e,`Filter.toOption`,t)?Nc(e).pipe(f.filter(e=>e.length===1),f.flatMap(c.head),f.map(t=>({api:`Option.filterMap`,callback:`${n.getText(e.callee)}(…)`,argument:f.some(V(n,t))}))):f.none()}const gl=[{apis:[`Option.flatMap`],rewrite:ul(`Option.fromNullishOr`,`Option.flatMapNullishOr`)},{apis:[`Option.flatMap`],rewrite:ul(`Option.some`,`Option.map`)},{apis:[`Option.flatMap`],rewrite:hl},{apis:[`Option.orElse`],rewrite:ul(`Option.some`,`Option.orElseSome`)},{apis:[`Option.getOrElse`],rewrite:pl(`Option`)},{apis:[`Option.match`],rewrite:ml},{apis:[`Result.flatMap`],rewrite:ul(`Result.succeed`,`Result.map`)},{apis:[`Result.getOrElse`],rewrite:pl(`Result`)},{apis:[`Array.flatMap`],rewrite:ul(`Array.fromNullishOr`,`Array.flatMapNullishOr`,!0)}];function _l(e,t){return f.flatMap(K(e),n=>c.findFirst(gl,r=>c.contains(r.apis,e.api)?r.rewrite(n,t):f.none()))}const vl={"Option.getSuccess":`Filter.toOption`,"Result.getSuccess":`Filter.toOption`,"Result.isSuccess":`Filter.toPredicate`};function yl(e,t){let[n]=e.params;if(e.async||e.generator||e.typeParameters||e.params.length!==1||n?.type!==`Identifier`)return f.none();let r=f.flatMap(U(e),e=>Pc(e,t).pipe(f.map(({step:e,self:t})=>_.make(e,t)),f.orElse(()=>Ic(e,t).pipe(f.filter(({kind:e,steps:t})=>e===`pipe`&&t.length===1),f.flatMap(({subject:e,steps:n})=>c.head(n).pipe(f.flatMap(e=>Fc(e,t)),f.product(e)))))));return f.flatMap(r,([e,t])=>f.flatMap(l.get(vl,e.api),r=>{let[i]=t.type===`CallExpression`?t.arguments:[];return t.type===`CallExpression`&&!t.optional&&t.callee.type!==`Super`&&t.arguments.length===1&&i?.type===`Identifier`&&i.name===n.name&&!O(t.callee,e=>e.type===`ThisExpression`||e.type===`Identifier`&&e.name===n.name)?f.some({check:e,filter:t,api:r}):f.none()}))}function bl(e){return!!e.returnType||c.some(e.params,e=>e.type===`Identifier`&&!!e.typeAnnotation)}function xl(e){let[t,n=``]=h.split(e,`.`);return[t,n]}function Sl(e,t){return`${e}(${c.join(t,`, `)})`}function Cl(e,t){return c.isReadonlyArrayEmpty(t)?e:Sl(e,t)}function wl(e,t){let n=t.parent;return n?.type===`MemberExpression`&&n.object===t||(n?.type===`CallExpression`||n?.type===`NewExpression`)&&n.callee===t||n?.type===`TaggedTemplateExpression`||n?.type===`BinaryExpression`&&n.operator===`**`&&n.left===t?`(!${e})`:`!${e}`}const Tl={array:`pairIfArray`,boolean:`pairIfBoolean`,fix:`pair`,none:`pair`,pure:`pairIfPure`},El=r.define({name:`prefer-direct-effect-combinators`,meta:B({type:`suggestion`,description:`Prefer the direct Effect Option, Array, Result and Filter API over an indirect chain of calls.`,messages:{pair:`Use {{direct}} instead of {{inner}} followed by {{outer}}.`,pairIfPure:`Use {{direct}} instead of {{inner}} followed by {{outer}}. It stops at the first match, so check that the callback has no side effects or exceptions that relied on running for every element.`,pairIfBoolean:`Use {{direct}} instead of {{inner}} followed by {{outer}} if the callback returns a boolean. {{inner}} also accepts a callback that returns an Option, which {{direct}} would treat as a match.`,pairIfArray:`Use {{direct}} instead of {{inner}} followed by {{outer}} if the input is an array. {{direct}} takes an array, while {{inner}} also takes other iterables, such as a Set.`,callback:`Use {{direct}} instead of {{outer}} with {{callback}}.`,filterCheck:`Use {{direct}}({{filter}}) instead of a function that applies {{check}} to the Result of {{filter}}.`,replace:`Replace with {{direct}}.`},url:`https://www.effect.website/docs/v4/api/effect/Option`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let{sourceCode:r}=e,a={imports:n,sourceCode:r};function o(e){return V(r,e)}function l(e){return c.some(r.getAllComments(),t=>c.some(e,e=>Le({range:e.range},t)))}let p=d.fnUntraced(function*(n){let[r,i]=xl(n.api),a=yield*f.match(m(n.callees,r),{onNone:()=>Yn(n.node,`effect/${r}`,Ji(r)),onSome:e=>d.succeed({name:e,fix:f.none()})}),o=`${a.name}.${i}`,s=n.negate?`!${o}`:o,p=t.fromId({node:n.node,messageId:n.messageId,data:u.assign(n.data,{direct:s})}),h=n.edits(o).pipe(f.filter(e=>!l(e)),f.filter(()=>n.safety!==`none`));if(f.isNone(h))return yield*e.report(p);let g=t.composeFixes(...f.toArray(a.fix),...c.map(h.value,e=>t.replaceText({range:e.range},e.text)));return yield*e.report(n.safety===`fix`?t.withFix(p,g):t.withSuggestions(p,[{messageId:`replace`,data:{direct:s},fix:g}]))});function m(e,t){return c.findFirst(e,e=>e.type===`MemberExpression`&&!e.computed&&f.exists(n.path(e.object),e=>e.length===1&&f.contains(c.head(e),t))?f.some(r.getText(e.object)):f.none())}function h(e,t,n){return f.match(cl(t,a),{onNone:()=>d.void,onSome:i=>p({node:e,messageId:Tl[i.safety],data:{inner:r.getText(t.inner.callee),outer:r.getText(t.outer.callee)},api:i.api,negate:i.negate,safety:i.safety,edits:e=>n(i,e),callees:[t.inner.callee,t.outer.callee]})})}function g(e,t,n){return e.negate?wl(t,n):t}function ee(e){return Pc(e,n).pipe(f.flatMap(e=>f.map(Pc(e.self,n),t=>({outer:e.step,inner:t}))),f.match({onNone:()=>d.void,onSome:({outer:t,inner:n})=>h(e,{inner:n.step,outer:t,input:f.some(n.self),nested:!0},(t,r)=>f.some([{range:e.range,text:g(t,Sl(r,[o(n.self),...t.args]),e)}]))}))}function v({call:e,subject:t,steps:r}){return t.pipe(f.flatMap(e=>Pc(e,n)),f.product(f.flatMap(c.head(r),e=>Fc(e,n))),f.match({onNone:()=>d.void,onSome:([n,i])=>h(i.node,{inner:n.step,outer:i,input:f.some(n.self),nested:!1},(a,s)=>{let l=Sl(s,[o(n.self),...a.args]);return r.length===1?f.some([{range:e.range,text:g(a,l,e)}]):a.negate?f.none():f.product(t,c.get(r,1)).pipe(f.map(([e,t])=>[{range:e.range,text:l},{range:[_.get(i.node.range,0),_.get(t.range,0)],text:``}]))})}))}function b(e){let{kind:t,call:i,steps:a}=e,o=c.map(a,e=>Fc(e,n));return d.forEach(c.zip(c.dropRight(o,1),c.drop(o,1)),([n,o],s)=>f.product(n,o).pipe(f.match({onNone:()=>d.void,onSome:([n,o])=>h(o.node,{inner:n,outer:o,input:s===0?e.subject:c.get(a,s-1),nested:!1},(e,c)=>{let l=Cl(c,e.args),u=[_.get(n.node.range,0),_.get(o.node.range,1)];return e.negate?t===`pipe`&&s+2===a.length?f.some([{range:i.range,text:wl(fl(r,i,u,l),i)}]):f.none():f.some([{range:u,text:l}])})})),{concurrency:1,discard:!0})}function te(e){return Pc(e,n).pipe(f.map(({step:e,self:t})=>_.make(e,f.some(t))),f.orElse(()=>f.map(Fc(e,n),e=>_.make(e,f.none()))),f.flatMap(([e,t])=>f.map(_l(e,a),n=>({step:e,self:t,rewrite:n}))),f.match({onNone:()=>d.void,onSome:({step:t,self:n,rewrite:i})=>p({node:e,messageId:`callback`,data:{outer:r.getText(t.callee),callback:i.callback},api:i.api,negate:!1,safety:`fix`,edits:t=>{let r=[...n.pipe(f.map(o),f.toArray),...f.toArray(i.argument)];return f.some([{range:e.range,text:f.match(n,{onNone:()=>Cl(t,r),onSome:()=>Sl(t,r)})}])},callees:[t.callee]})}))}function x(e){return f.match(yl(e,n),{onNone:()=>d.void,onSome:({check:t,filter:i,api:a})=>{let o=y.isNullish(i.typeArguments)&&Ec(i.callee,n)&&kc(r,i.callee,e);return p({node:e,messageId:`filterCheck`,data:{check:r.getText(t.callee),filter:r.getText(i.callee)},api:a,negate:!1,safety:o?bl(e)?`suggest`:`fix`:`none`,edits:t=>f.some([{range:e.range,text:Sl(t,[V(r,i.callee)])}]),callees:[i.callee]})}})}return s.merge(s.on(`CallExpression`,e=>d.andThen(d.all([ee(e),te(e)],{concurrency:1,discard:!0}),f.match(Ic(e,n),{onNone:()=>d.void,onSome:e=>d.all([v(e),b(e)],{concurrency:1,discard:!0})}))),s.on(`ArrowFunctionExpression`,x),s.on(`FunctionExpression`,x))}}),Dl=r.define({name:`prefer-effect-alchemy-namespace-imports`,meta:B({type:`suggestion`,description:`Use consistently aliased namespace imports for Effect and Alchemy submodule entrypoints.`,messages:{alias:"Import {{source}} as the canonical namespace alias `{{alias}}`.",namespace:'Use `import * as {{alias}} from "{{source}}"` instead of importing values directly.'},url:`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/core/AutoImport.ts`,fixable:`code`}),*create(){let e=yield*i;function n(n,r){let i={alias:r,source:n.source.value};function a(r,a){return e.report(Qn(t.fromId({node:r,messageId:a,data:i}),ta(e.sourceCode,n)))}return d.forEach(c.filter(n.specifiers,e=>e.type!==`ImportSpecifier`||!qi(n,e)),e=>e.type===`ImportNamespaceSpecifier`?e.local.name===r?d.void:a(e.local,`alias`):a(e,`namespace`),{concurrency:1,discard:!0})}return s.on(`ImportDeclaration`,e=>Xi(e.source.value).pipe(f.filter(()=>e.importKind!==`type`),f.match({onNone:()=>d.void,onSome:t=>n(e,Ji(t))})))}});function Ol(e){let[t,n]=h.split(e,`/`);return y.isNotUndefined(n)&&h.startsWith(`@`)(t)?`${t}/${n}`:t}function kl(e){return e.importKind===`type`||c.isReadonlyArrayNonEmpty(e.specifiers)&&c.every(e.specifiers,e=>e.type===`ImportSpecifier`&&e.importKind===`type`)}function Al(e){return s.merge(s.on(`ImportDeclaration`,t=>kl(t)?d.void:e(t.source,f.some(t))),s.on(`ImportExpression`,({source:t})=>M(t)?e(t,f.none()):d.void))}const jl={"@zip.js/zip.js":`Zip`,"adm-zip":`Zip`,archiver:`Zip or Tar`,"client-zip":`Zip`,jszip:`Zip`,"js-untar":`Tar`,"modern-tar":`Tar`,nanotar:`Tar`,"node-stream-zip":`Zip`,"tar-js":`Tar`,"tar-stream":`Tar`,unzipper:`Zip`,yauzl:`Zip`,"yauzl-promise":`Zip`,yazl:`Zip`,"zip-stream":`Zip`},Ml=m.is($e);function Nl(e){return f.match(e,{onNone:()=>[],onSome:({specifiers:e})=>c.filter(e,e=>e.type===`ImportSpecifier`&&e.importKind!==`type`&&Ml(Se(e.imported)))})}const Pl=r.define({name:`prefer-effect-archive`,meta:B({type:`suggestion`,description:`Prefer Effect Tar and Zip over tar and zip libraries in Effect projects.`,messages:{archive:`Use {{module}} from effect/encoding instead of {{source}}: its decode and encode channels stream entries without buffering whole bodies.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Zip`}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};function n(n,r,i){return e.report(t.fromId({node:n,messageId:`archive`,data:{module:i,source:r}}))}return Al((e,t)=>{let r=Ol(e.value);return r===`fflate`?d.forEach(Nl(t),e=>n(e,`fflate`,`Zip`),{concurrency:1,discard:!0}):f.match(l.get(jl,r),{onNone:()=>d.void,onSome:t=>n(e,e.value,t)})})}});function Fl(e,t){return e?.type===`NewExpression`&&e.arguments.length===1&&L(t,e.callee,`Set`)}function Il(e,t){if(e.type===`ArrayExpression`){let[n]=e.elements;return e.elements.length===1&&n?.type===`SpreadElement`&&Fl(n.argument,t)}return e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`from`)&&L(t,e.callee.object,`Array`)&&e.arguments.length===1&&f.exists(E(e,0),e=>Fl(e,t))}function Ll(e){let t=e.parent;return t.type===`AssignmentExpression`&&t.left===e||t.type===`UpdateExpression`||t.type===`UnaryExpression`&&t.operator===`delete`}function Rl(e,t){let n=t.getText(e.object);return O(f.getOrElse(Fe(e),()=>t.ast),e=>e.type===`MemberExpression`&&e.computed&&e.property.type===`Literal`&&y.isNumber(e.property.value)&&e.property.value!==0&&t.getText(e.object)===n)}function zl(e){return e.type===`MemberExpression`&&f.contains(S(e),`length`)}const Bl={"!=":`nonEmpty`,"!==":`nonEmpty`,"==":`empty`,"===":`empty`};function Vl(e){let t=D(e.left),n=D(e.right);return zl(t)&&N(n,0)?e.operator===`>`?f.some(`nonEmpty`):l.get(Bl,e.operator):N(t,0)&&zl(n)?e.operator===`<`?f.some(`nonEmpty`):l.get(Bl,e.operator):f.none()}function Hl(e){let t=e.callee;return t.type===`MemberExpression`?S(t):t.type===`Identifier`?f.some(t.name):f.none()}function Ul(e){if(e.type!==`ArrowFunctionExpression`||e.async||!e.expression||e.params.length!==1)return f.none();let[t]=e.params,n=D(e.body);return t?.type===`Identifier`&&n.type===`MemberExpression`&&n.object.type===`Identifier`&&n.object.name===t.name?S(n):f.none()}const Wl=r.define({name:`prefer-effect-array-ops`,meta:B({type:`suggestion`,description:`Prefer Effect Array and Struct helpers over hand-written array idioms in Effect files.`,messages:{dedupe:`Use Arr.dedupe instead of deduplicating through a Set.`,head:`Use Arr.head, which returns an Option, instead of indexing the first element (Tuple.get for tuples).`,empty:"Use Arr.isReadonlyArrayEmpty (Str.isEmpty for strings) instead of comparing `.length` with 0.",nonEmpty:"Use Arr.isReadonlyArrayNonEmpty (Str.isNonEmpty for strings), which narrows to a non-empty array, instead of comparing `.length` with 0.",structGet:`Use Struct.get('{{key}}') instead of a property accessor lambda.`},url:`https://www.effect.website/docs/v4/api/effect/Array`}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};function n(n){return d.flatMap(o.getScope(n),r=>Il(n,r)?e.report(t.fromId({node:n,messageId:`dedupe`})):d.void)}function r(n){return f.contains(Hl(n),`map`)?d.forEach(n.arguments,n=>f.match(Ul(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`structGet`,data:{key:r}}))}),{concurrency:1,discard:!0}):d.void}return s.merge(s.on(`ArrayExpression`,n),s.on(`CallExpression`,n=>d.flatMap(o.getScope(n),i=>Il(n,i)?e.report(t.fromId({node:n,messageId:`dedupe`})):r(n))),s.on(`MemberExpression`,n=>n.computed&&N(n.property,0)&&!Ll(n)&&!Rl(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`head`})):d.void),s.on(`BinaryExpression`,n=>f.match(Vl(n),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:r}))})))}}),Gl=r.define({name:`prefer-effect-array-sort`,meta:B({type:`suggestion`,description:`Prefer immutable, Order-based Effect Array sorting in Effect projects.`,messages:{effectArraySort:`Use Arr.sort with an Order instead of the mutable native Array.sort method.`},url:`https://www.effect.website/docs/v4/api/effect/Array#sort`}),*create(){let e=yield*i,n=yield*z;return n.hasEffectImport?s.on(`CallExpression`,r=>r.callee.type===`MemberExpression`&&f.contains(S(r.callee),`sort`)&&!n.isApi(r.callee,`Array`,`sort`)?e.report(t.fromId({node:r,messageId:`effectArraySort`})):d.void):{}}}),Kl=m.is(gi),ql=m.is(oi),Jl=m.is(si),Yl=/;\s*(?:HttpOnly|Secure|Partitioned|(?:Path|Domain|Max-Age|Expires|SameSite)=)/iu,Xl=/^(?:;\s*(?:HttpOnly|Secure|Partitioned|Path|Domain|Max-Age|Expires|SameSite)\b|HttpOnly$|Max-Age=|SameSite=)/iu;function Zl(e){return h.includes(`cookie`)(h.toLowerCase(e))}function Ql(e){let t=D(e),n=t.type===`ChainExpression`?f.some(t.expression):t.type===`LogicalExpression`?f.some(t.left):t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`String`?E(t,0):f.none();return f.match(n,{onNone:()=>t,onSome:Ql})}const $l=g.type().pipe(g.discriminators(`type`)({Identifier:({name:e})=>Zl(e),MemberExpression:e=>f.exists(S(e),Zl),CallExpression:e=>f.contains(tu(e),`get`)&&c.some(e.arguments,e=>M(e)&&Kl(h.toLowerCase(e.value)))}),g.orElse(v.constFalse));function eu(e){return $l(Ql(e))}function tu(e){return e.callee.type===`MemberExpression`?S(e.callee):f.none()}function nu(e){return e.callee.type===`MemberExpression`&&e.callee.object.type!==`Super`?f.some(e.callee.object):f.none()}function ru(e){return f.exists(tu(e),t=>ql(t)?f.exists(nu(e),eu):t===`exec`&&f.exists(E(e,0),eu))}function iu(e,t){let n=f.orElse(tu(e),()=>t.member(e.callee,`String`));return f.exists(n,Jl)&&f.exists(E(e,0),e=>M(e)&&Xl.test(e.value))}function au(e){return c.isReadonlyArrayNonEmpty(e.expressions)&&c.some(e.quasis,e=>Yl.test(e.value.cooked??e.value.raw))}function ou(e){return M(e)&&Yl.test(e.value)}const su=r.define({name:`prefer-effect-cookies`,meta:B({type:`suggestion`,description:`Prefer the Effect Cookies module over parsing, building and inspecting cookie strings by hand.`,messages:{documentCookie:`document.cookie is one unparsed string. Parse it with Cookies.parseHeader, and write cookies from the server with HttpServerResponse.setCookie.`,parseCookies:`Read request cookies with HttpServerRequest cookies or schemaCookies, or parse a header with Cookies.parseHeader or Cookies.fromSetCookie, instead of splitting or matching it by hand.`,serializeCookie:`Build cookies with Cookies.makeCookie and Cookies.serializeCookie, or HttpServerResponse.setCookie, which validate names, values and attributes.`,inspectCookie:`Parse Set-Cookie headers with Cookies.fromSetCookie and read the attributes from Cookies.get(…).options, instead of searching the string for them.`},url:`https://www.effect.website/docs/v4/api/effect/http/Cookies`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r(n,r){return e.report(t.fromId({node:n,messageId:r}))}function a(e){return!f.exists(j(e,`CallExpression`),t=>P(t.arguments,e)&&f.isSome(n.member(t.callee,`Cookies`)))&&f.contains(S(e),`cookie`)?it(e.object,`document`):d.succeed(!1)}return s.merge(s.on(`MemberExpression`,e=>d.when(r(e,`documentCookie`),a(e))),s.on(`CallExpression`,e=>ru(e)?r(e,`parseCookies`):iu(e,n)?r(e,`inspectCookie`):d.void),s.on(`TemplateLiteral`,e=>au(e)&&e.parent.type!==`TaggedTemplateExpression`?r(e,`serializeCookie`):d.void),s.on(`BinaryExpression`,e=>e.operator===`+`&&(ou(e.right)&&!M(e.left)||ou(e.left)&&!M(e.right))?r(e,`serializeCookie`):d.void))}});function cu(e){return M(e)?f.some(e.value):e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)?f.flatMapNullishOr(c.head(e.quasis),({value:e})=>e.cooked):f.none()}function lu(e){return e.type===`Literal`&&`regex`in e&&y.isNotNullish(e.regex)?f.some(e.regex.pattern):f.none()}const uu=/^(?:\(\?:|[()|?*+[\]]|\\r|\\n)+$/u;function du(e){return f.exists(cu(e),e=>e===`
|
|
3
3
|
`||e===`\r
|
|
4
|
-
`)||f.exists(Mc(e),e=>h.includes(String.raw`\n`)(e)&&Nc.test(e))}const Fc=/* @__PURE__ */ new Set([`,`,`;`,` `]);function Ic(e){return jc(e).pipe(f.orElse(()=>Mc(e)),f.exists(e=>Fc.has(e===String.raw`\t`?` `:e)))}function Lc(e,t,n,r){if(e.type!==`CallExpression`)return f.none();if(r.isApi(e.callee,n,t))return e.arguments.length===1?f.map(D(e,0),e=>({separator:e,subject:f.none()})):f.map(D(e,1),t=>({separator:t,subject:D(e,0)}));let i=e.callee;return i.type===`MemberExpression`&&f.isNone(r.path(i))&&f.contains(C(i),t)&&e.arguments.length===1?f.map(D(e,0),e=>({separator:e,subject:f.some(i.object)})):f.none()}function Rc(e,t,n){return Lc(e,`split`,`String`,n).pipe(f.filter(e=>t(e.separator)),f.map(({subject:e})=>e))}function zc(e,t,n){return Lc(e,`join`,`Array`,n).pipe(f.filter(e=>t(e.separator)),f.map(({subject:e})=>e))}function Bc(e,t,n){return e.type===`MemberExpression`&&f.contains(C(e),t)&&R(n.getScope(e),e.object,`JSON`)}function Vc(e){return e.type===`Identifier`&&!f.exists(j(e),t=>t.type===`MemberExpression`&&t.property===e&&!t.computed||t.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand)}function Hc(e,t){let n=L(t.sourceCode,e,e.name);return Ae(n).pipe(f.filter(e=>e.type===`Variable`),f.flatMap(e=>e.node.type===`VariableDeclarator`&&e.node.id.type===`Identifier`&&b.isNotNullish(e.node.init)&&f.exists(n,({references:e})=>c.every(e,e=>!e.isWrite()||e.init))?f.some(e.node.init):f.none()))}const Uc=/* @__PURE__ */ new Set([`append`,`appendAll`,`concat`,`dedupe`,`drop`,`dropRight`,`filter`,`prepend`,`prependAll`,`reverse`,`slice`,`sort`,`sortWith`,`take`,`takeRight`,`toReversed`,`toSorted`]);function Wc(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.orElse(t.member(n,`Array`),()=>n.type===`MemberExpression`&&f.isNone(t.path(n))?C(n):f.none())}function Gc(e,t){return f.exists(Wc(e,t),e=>Uc.has(e))}function Kc(e,t){let n=e.callee;return f.match(t.path(n),{onSome:()=>e.arguments.length>1||f.exists(Wc(e,t),e=>e===`dedupe`||e===`reverse`)?D(e,0):f.none(),onNone:()=>n.type===`MemberExpression`?f.some(n.object):f.none()})}function qc(e,t,n,r){return f.exists(c.last(e),i=>{let a=c.dropRight(e,1);return c.isReadonlyArrayNonEmpty(a)&&!t.matches(i)?(i.type===`CallExpression`&&f.isNone(Kc(i,n.imports))||i.type===`MemberExpression`)&&(Gc(i,n.imports)||i.type===`CallExpression`&&t.preserves(i))&&qc(a,t,n,r):Jc(i,t,n,r)})}function Jc(e,t,n,r=3){let i=e.type===`SpreadElement`?e.argument:O(e);return t.matches(i)?!0:Vc(i)?r>0&&f.exists(Hc(i,n),e=>Jc(e,t,n,r-1)):i.type===`ArrayExpression`?c.some(i.elements,e=>e?.type===`SpreadElement`&&Jc(e,t,n,r)):i.type===`CallExpression`?Xc(i,n.imports)?qc([...i.callee.type===`MemberExpression`?[i.callee.object]:[],...i.arguments],t,n,r):(Gc(i,n.imports)||t.preserves(i))&&f.exists(Kc(i,n.imports),e=>Jc(e,t,n,r)):!1}function Yc(e){return{matches:t=>f.isSome(Rc(t,Pc,e.imports)),preserves:t=>nl(t,{mapper:t=>e.imports.isApi(t,`String`,$c),element:t=>el(t,e.imports)!==t})}}function Xc(e,t){return t.isApiPath(e.callee,[`pipe`])||t.isApiPath(e.callee,[`Function`,`pipe`])||e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`pipe`)}function Zc(e,t,n){let r=c.findFirstIndex(e.arguments,e=>e===t),i=f.match(r,{onNone:()=>[],onSome:t=>c.take(e.arguments,t)}),a=e.callee.type===`MemberExpression`&&f.isNone(n.path(e.callee))?[e.callee.object]:[],o=M(e,`CallExpression`).pipe(f.match({onNone:()=>[],onSome:t=>c.isReadonlyArrayEmpty(i)&&c.isReadonlyArrayEmpty(a)&&F(t.arguments,e)&&Xc(t,n)?[...t.callee.type===`MemberExpression`?[t.callee.object]:[],...c.takeWhile(t.arguments,t=>t!==e)]:[]}));return[...a,...i,...o]}function Qc(e,t){return M(e,`CallExpression`).pipe(f.filter(t=>F(t.arguments,e)),f.exists(n=>qc(Zc(n,e,t.imports),Yc(t),t,3)))}const $c=[`trim`,`trimEnd`,`trimStart`];function el(e,t){let n=O(e);return n.type===`CallExpression`?t.isApi(n.callee,`String`,$c)?f.match(D(n,0),{onNone:()=>n,onSome:e=>el(e,t)}):n.callee.type===`MemberExpression`&&f.exists(C(n.callee),e=>c.contains($c,e))&&c.isReadonlyArrayEmpty(n.arguments)?el(n.callee.object,t):n:n}function tl(e,t){let n=el(e,t.imports);return n.type===`Identifier`&&f.exists(Ae(L(t.sourceCode,n,n.name)),e=>{if(e.type===`Parameter`){let n=e.node;return A(n)&&I(c.head(n.params),e.name)&&Qc(n,t)}let n=e.parent?.parent;return e.type===`Variable`&&n?.type===`ForOfStatement`&&n.left===e.parent&&Jc(n.right,Yc(t),t)})}function nl(e,t){return e.type===`CallExpression`&&c.some(e.arguments,e=>t.mapper(e)||A(e)&&f.exists(W(e),t.element))}function rl(e,t,n){return qc(e,{matches:e=>nl(e,t),preserves:()=>!1},n,3)}function il(e,t,n){return f.match(t,{onSome:c.of,onNone:()=>Zc(e,e,n)})}const al=r.define({name:`prefer-effect-csv`,meta:V({type:`suggestion`,description:`Prefer Effect Csv over splitting lines into cells or joining cells and rows by hand.`,messages:{decode:`Use Csv.decodeString or Csv.decodeSchemaString from effect/encoding instead of splitting each line on a delimiter: quoted cells may contain the delimiter, quotes and line breaks.`,encode:`Use Csv.encodeString or Csv.encodeSchemaString from effect/encoding instead of joining cells and rows: joined cells are not quoted when they contain the delimiter, quotes or line breaks.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Csv`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r={imports:n,sourceCode:e.sourceCode},a={mapper:e=>f.exists(zc(e,Ic,n),f.isNone),element:e=>f.isSome(zc(e,Ic,n))};function o(e){return f.exists(Rc(e,Ic,n),t=>f.match(t,{onNone:()=>Qc(e,r),onSome:e=>tl(e,r)}))}function c(e){return f.exists(zc(e,Pc,n),t=>rl(il(e,t,n),a,r))}return s.on(`CallExpression`,n=>o(n)?e.report(t.fromId({node:n,messageId:`decode`})):c(n)?e.report(t.fromId({node:n,messageId:`encode`})):d.void)}}),ol=m.Literals([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),sl=m.is(ol),cl=r.define({name:`prefer-effect-datetime`,meta:V({type:`suggestion`,description:`Prefer Effect DateTime formatting so time-zone behavior is explicit and composable.`,messages:{effectDateTime:`Convert to DateTime and format it in an explicit zone: DateTime.setZone with DateTime.formatIsoDate, formatIsoOffset or formatIsoZoned, or DateTime.format with timeZone. DateTime.formatIso is UTC, like toISOString: use it only for UTC instants, never slice it for a local date.`},url:`https://www.effect.website/docs/v4/api/effect/DateTime`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.on(`CallExpression`,n=>n.callee.type===`MemberExpression`&&f.exists(C(n.callee),sl)?e.report(t.fromId({node:n,messageId:`effectDateTime`})):d.void):{}}}),ll=r.define({name:`prefer-effect-duration`,meta:V({type:`suggestion`,description:`Prefer explicit Effect Duration constructors over ambiguous millisecond literals.`,messages:{effectDuration:`Wrap this number with Duration.millis or use a more descriptive Duration constructor.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`,fixable:`code`}),*create(){let e=yield*i,n=yield*B,r=d.fnUntraced(function*(n,r){let i=yield*Pt(n,`effect/Duration`,`Duration`),a=t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`);yield*e.report(t.withFix(t.fromId({node:r,messageId:`effectDuration`}),t.composeFixes(...f.toArray(i.fix),a)))});return s.on(`CallExpression`,e=>d.flatMap(da(e,n),t=>t.pipe(f.filter(e=>f.isSome(ma(e))),f.match({onNone:()=>d.void,onSome:t=>r(e,t)}))))}}),ul={ms:`millis`,milli:`millis`,millis:`millis`,millisecond:`millis`,milliseconds:`millis`,sec:`seconds`,secs:`seconds`,seconds:`seconds`,mins:`minutes`,minutes:`minutes`,hr:`hours`,hrs:`hours`,hours:`hours`,days:`days`,weeks:`weeks`},dl=m.is(m.Literals([`day`,`hour`,`minute`,`second`,`week`])),fl=m.is(m.Literals([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`])),pl=m.is(m.Literals([`at`,`epoch`,`per`,`timestamp`])),ml=m.is(m.Literals([`days`,`hours`,`millis`,`minutes`,`seconds`,`weeks`]));function hl(e){let t=ba(e),n=t.indexOf(`in`);if(n>0&&n<t.length-1&&f.exists(c.get(t,n-1),e=>l.has(ul,e)||dl(e))||c.some(t,pl))return`excluded`;let r=c.get(t,t.length-2);return f.match(c.last(t),{onNone:()=>`none`,onSome:e=>f.match(l.get(ul,e),{onSome:e=>e,onNone:()=>fl(e)||e===`age`&&f.contains(r,`max`)||e===`in`&&f.contains(r,`expires`)?`unknown`:`none`})})}function gl(e){return e.type===`Identifier`?f.some(c.of(e.name)):e.type===`TSQualifiedName`?f.map(gl(e.left),t=>c.append(t,e.right.name)):f.none()}function _l(e,t,n){return k(e,e=>e.type===`TSTypeReference`&&f.exists(gl(e.typeName),([r,...i])=>f.exists(L(t,e,r),({defs:e})=>c.some(e,e=>e.type===`ImportBinding`))&&f.fromNullishOr(n.bindings.get(r)).pipe(f.exists(e=>f.contains(c.head([...e,...i]),`Duration`)))))}function vl(e){return e.type===`VariableDeclarator`&&be(e.parent)&&e.id.type===`Identifier`&&e.init!==null&&f.isSome(ma(e.init))}function yl(e){let t=O(e);return t.type===`Identifier`?d.map(ke(t,t.name),e=>Ae(e).pipe(f.map(({node:e})=>e),f.filter(vl))):d.succeedNone}const bl=re.mapInput(re.Number,([e])=>e),xl=r.define({name:`prefer-effect-duration-constants`,meta:V({type:`suggestion`,description:`Prefer Effect Duration values over plain-number duration constants.`,messages:{durationConstant:`{{name}} holds a duration as a plain number. Declare it as {{replacement}} and convert at non-Effect boundaries with Duration.toMillis or Duration.toSeconds.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*B,r=yield*p.make(ne.empty());function a(t,r){if(t.id.typeAnnotation&&_l(t.id.typeAnnotation,e.sourceCode,n))return f.none();let i=hl(t.id.name),a=f.liftPredicate(i,ml);if(r)return f.some(f.orElseSome(a,()=>`millis`));if(i===`excluded`||f.getOrElse(ma(t.init),()=>0)<=0)return f.none();if(f.isSome(a))return f.some(a);let o=ya(t.init);return f.exists(o,({millis:e})=>e)?f.some(f.some(`millis`)):i===`unknown`||f.isSome(o)?f.some(f.none()):f.none()}function o([,[n,r]]){return f.match(a(n,r),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n.id,messageId:`durationConstant`,data:{name:n.id.name,replacement:f.zipWith(ma(n.init),r,Da).pipe(f.getOrElse(()=>`a Duration constructor such as Duration.seconds`))}}))})}return s.merge(s.on(`VariableDeclarator`,e=>n.hasEffectImport&&vl(e)?p.update(r,t=>ne.has(t,v.get(e.range,0))?t:ne.set(t,v.get(e.range,0),[e,!1])):d.void),s.on(`CallExpression`,e=>da(e,n).pipe(d.flatMap(f.match({onNone:()=>d.succeedNone,onSome:yl})),d.flatMap(f.match({onNone:()=>d.void,onSome:e=>p.update(r,t=>ne.set(t,v.get(e.range,0),[e,!0]))})))),s.onExit(`Program`,()=>d.flatMap(p.get(r),e=>d.forEach(c.sort(ne.toEntries(e),bl),o,{concurrency:1,discard:!0}))))}}),Sl=m.is(m.Literals([`Finite`,`FiniteFromString`,`Int`,`Number`,`NumberFromString`])),Cl=m.is(m.Literals([`NullOr`,`NullishOr`,`UndefinedOr`,`optional`,`optionalKey`])),wl=m.is(m.Literals([`annotate`,`annotateKey`,`brand`,`check`,`withConstructorDefault`,`withDecodingDefault`,`withDecodingDefaultKey`])),Tl=m.is(m.Literals([`annotate`,`check`])),El=m.is(m.Literals([`TSNullKeyword`,`TSNumberKeyword`,`TSUndefinedKeyword`]));function Dl(e,t){return t.member(e,`Schema`)}function Ol(e,t){if(e.type===`SpreadElement`)return!1;let n=O(e);return n.type===`CallExpression`?f.exists(Dl(n.callee,t),wl):f.exists(Dl(n,t),Cl)}function kl(e,t){let n=O(e);if(n.type!==`CallExpression`)return f.exists(Dl(n,t),Sl);let r=n.callee;return f.exists(Dl(r,t),Cl)?f.exists(D(n,0),e=>kl(e,t)):r.type!==`MemberExpression`||r.object.type===`Super`||!kl(r.object,t)?!1:f.exists(C(r),e=>e===`pipe`?c.every(n.arguments,e=>Ol(e,t)):Tl(e))}function Al(e){let t=e?.typeAnnotation;return t?.type===`TSNumberKeyword`||t?.type===`TSUnionType`&&c.some(t.types,e=>e.type===`TSNumberKeyword`)&&c.every(t.types,e=>El(e.type))}function jl(e){return f.contains(Ca(e),`duration`)}function Ml(e){return e.computed?e.key.type===`Literal`&&h.isString(e.key.value)?f.some(e.key.value):f.none():e.key.type===`Identifier`?f.some(e.key.name):f.none()}const Nl=m.String.check(m.isPattern(/\.d\.[cm]?ts$/u)),Pl=m.is(Nl);function Fl(e){return b.hasProperty(e,`declare`)&&e.declare}function Il(e,t){return f.isSome(Ce(e,Fl))||f.exists(we(e),n=>Yn(n,t)&&c.some(n.params,t=>Ee(t,e)))}function Ll(e){let t=e.type===`TSParameterProperty`?e.parameter:e;if(t.type===`Identifier`)return Al(t.typeAnnotation)?f.some(t):f.none();if(t.type!==`AssignmentPattern`||t.left.type!==`Identifier`)return f.none();let n=O(t.right);return Al(t.left.typeAnnotation)||!t.left.typeAnnotation&&n.type===`Literal`&&b.isNumber(n.value)?f.some(t.left):f.none()}const Rl=r.define({name:`prefer-effect-duration-types`,meta:V({type:`suggestion`,description:`Prefer Duration types over plain numbers for millisecond parameters and fields.`,messages:{durationType:`{{name}} holds a duration as a number of milliseconds. Type it as Duration.Input (or Duration.Duration) and convert with Duration.toMillis only where a non-Effect API needs milliseconds.`,durationSchema:`{{name}} decodes a duration as a plain number. Use Schema.DurationFromMillis to keep milliseconds in the encoded data, or Schema.Duration.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r=Pl(e.filename);function a(n,r,i){return e.report(t.fromId({node:n,messageId:i,data:{name:r}}))}function o(e){return r||!e.body||Yn(e,n)||Il(e,n)?d.void:d.forEach(c.filter(c.getSomes(c.map(e.params,Ll)),({name:e})=>jl(e)),e=>a(e,e.name,`durationType`),{concurrency:1,discard:!0})}function l(e){return Ml(e).pipe(f.filter(t=>jl(t)&&Al(e.typeAnnotation)&&!r&&!Il(e,n)),f.match({onNone:()=>d.void,onSome:t=>a(e.key,t,`durationType`)}))}return s.merge(s.on(`ArrowFunctionExpression`,o),s.on(`FunctionDeclaration`,o),s.on(`FunctionExpression`,o),s.on(`PropertyDefinition`,l),s.on(`TSPropertySignature`,l),s.on(`Property`,e=>e.parent.type===`ObjectExpression`?T(e).pipe(f.filter(t=>jl(t)&&kl(e.value,n)),f.match({onNone:()=>d.void,onSome:t=>a(e.key,t,`durationSchema`)})):d.void))}}),zl=m.Literals([`base64`,`base64url`,`hex`]),Bl=m.is(zl),Vl={base64:`Base64`,base64url:`Base64Url`,hex:`Hex`};function Hl(e,t){return f.flatMap(D(e,t),e=>N(e)&&Bl(e.value)?f.some(e.value):f.none())}function Ul(e){return D(e,1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(E(`alphabet`)),f.exists(({value:e})=>P(e,`base64url`)))}function Wl(e){return e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`toString`)?f.map(Hl(e,0),e=>({messageId:`encode`,native:`toString('${e}')`,replacement:`${Vl[e]}.encode`})):f.flatMap(w(e.callee),t=>{let n=c.join(t,`.`);return n===`Buffer.from`?f.map(Hl(e,1),e=>({messageId:`decode`,native:`Buffer.from(…, '${e}')`,replacement:`${Vl[e]}.decode`})):n===`Uint8Array.fromHex`?f.some({messageId:`decode`,native:n,replacement:`Hex.decode`}):n===`Uint8Array.fromBase64`?f.some({messageId:`decode`,native:n,replacement:Ul(e)?`Base64Url.decode`:`Base64.decode`}):f.none()})}const Gl={atob:{messageId:`atob`,native:`atob`,replacement:`Base64.decode`},btoa:{messageId:`btoa`,native:`btoa`,replacement:`Base64.encode`}},Kl=m.Literals([`atob`,`btoa`]),ql=m.is(Kl),Jl=r.define({name:`prefer-effect-encoding`,meta:V({type:`suggestion`,description:`Prefer the Effect v4 Base64, Base64Url, and Hex modules over native binary encoding APIs.`,messages:{atob:`Use Base64.decode from effect/encoding instead of atob: it returns the bytes as a Uint8Array in a Result with an EncodingError, where atob returns a binary string and throws on invalid input. Use Base64.decodeString only for UTF-8 text.`,btoa:`Use Base64.encode from effect/encoding instead of btoa, and pass it the bytes rather than a binary string: btoa throws on characters above U+00FF, and Base64.encode encodes strings as UTF-8.`,decode:`Use {{replacement}} from effect/encoding instead of {{native}}: it returns a Result with an EncodingError instead of throwing on invalid input.`,encode:`Use {{replacement}} from effect/encoding instead of {{native}}: it accepts bytes or UTF-8 text and runs the same in Node.js, browsers, and Workers.`},url:`https://effect.website/docs/v4/api/effect/encoding/Base64`}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};function n(e){let t=e.callee.type===`MemberExpression`&&f.exists(w(e.callee),e=>e.length===2&&f.contains(c.head(e),`globalThis`))?e.callee.object:e.callee,n=w(e.callee).pipe(f.map(c.lastNonEmpty),f.filter(ql));return f.match(n,{onNone:()=>d.succeedNone,onSome:n=>d.map(je(t,t===e.callee?n:`globalThis`),t=>t&&c.isReadonlyArrayNonEmpty(e.arguments)?f.some(Gl[n]):f.none())})}return s.on(`CallExpression`,r=>d.flatMap(n(r),n=>n.pipe(f.orElse(()=>Wl(r)),f.match({onNone:()=>d.void,onSome:({messageId:n,native:i,replacement:a})=>e.report(t.fromId({node:r,messageId:n,data:{native:i,replacement:a}}))}))))}}),Yl=m.Literals([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),Xl=m.is(Yl),Zl=r.define({name:`prefer-effect-filesystem`,meta:V({type:`suggestion`,description:`Prefer the Effect FileSystem service over direct Node.js filesystem imports in Effect projects.`,messages:{effectFileSystem:`Use the FileSystem service from effect/FileSystem instead of {{source}}.`},url:`https://www.effect.website/docs/v4/api/effect/FileSystem`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.on(`ImportDeclaration`,({source:n})=>Xl(n.value)?e.report(t.fromId({node:n,messageId:`effectFileSystem`,data:{source:n.value}})):d.void):{}}});function Ql(e,t,n,r){return e.type===`CallExpression`&&r.isApi(e.callee,`Result`,t)&&f.exists(D(e,0),e=>e.type===`Identifier`&&e.name===n)}const $l=r.define({name:`prefer-effect-filter`,meta:V({type:`suggestion`,description:`Prefer Effect Filter constructors for reusable Result-valued predicates.`,messages:{effectFilter:`Use Filter.fromPredicate for this Result-valued predicate so it composes as a Filter.`},url:`https://www.effect.website/docs/v4/api/effect/Filter`}),*create(){let e=yield*i,n=yield*B;function r(r){return f.exists(xe(r),({name:e})=>f.exists(W(r),t=>t.type===`ConditionalExpression`&&Ql(t.consequent,`succeed`,e,n)&&Ql(t.alternate,`fail`,e,n)))?e.report(t.fromId({node:r,messageId:`effectFilter`})):d.void}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionExpression`,r))}}),eu={module:`Yaml`,members:[`load`,`parse`,`parseAllDocuments`,`parseDocument`]},tu={module:`Toml`,members:[`parse`]},q={module:`Csv`,members:`all`},nu={"@fast-csv/format":q,"@fast-csv/parse":q,"@iarna/toml":tu,"@streamparser/json":{module:`JsonArray`,members:`all`},"@xmldom/xmldom":{module:`Xml`,members:[`DOMParser`]},"comment-json":{module:`Jsonc`,members:[`parse`]},"csv-parse":q,"csv-parse/sync":q,"csv-parser":q,"csv-stringify":q,"csv-stringify/sync":q,"fast-csv":q,"fast-xml-parser":{module:`Xml`,members:[`XMLParser`]},ini:{module:`Ini`,members:[`decode`,`parse`]},"js-yaml":eu,json5:{module:`Json5`,members:[`parse`]},"jsonc-parser":{module:`Jsonc`,members:[`parse`]},ndjson:{module:`Ndjson`,members:`all`},papaparse:q,sax:{module:`Xml`,members:`all`},"smol-toml":tu,"stream-json":{module:`JsonArray`,members:`all`},"strip-json-comments":{module:`Jsonc`,members:`all`},toml:tu,xml2js:{module:`Xml`,members:[`Parser`,`parseString`,`parseStringPromise`]},yaml:eu};function ru(e,t){return e.members===`all`||c.contains(e.members,t)}const iu=r.define({name:`prefer-effect-format-parser`,meta:V({type:`suggestion`,description:`Prefer the effect/encoding modules over third-party YAML, TOML, INI, JSON5, JSONC, CSV, NDJSON, JSON array and XML parsers in Effect files.`,messages:{effectFormat:`Use {{module}} from effect/encoding instead of {{api}}.`},url:`https://www.effect.website/docs/v4/api/effect/encoding`}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};function n(n,r,i){return e.report(t.fromId({node:n,messageId:`effectFormat`,data:{module:r.module,api:i}}))}function r(t,r,i){let a=c.flatMap(e.sourceCode.getDeclaredVariables(t),({references:e})=>c.getSomes(c.map(e,({identifier:e})=>j(e).pipe(f.filter(t=>t.type===`MemberExpression`&&t.object===e),f.flatMap(e=>C(e).pipe(f.filter(e=>ru(r,e)),f.map(t=>[e,`${i} ${t}`])))))));return d.forEach(a,([e,t])=>n(e,r,t),{concurrency:1,discard:!0})}function a(e,t,i){let a=e.source.value;if(t.type===`ImportSpecifier`){let r=fe(t.imported);return!vr(e,t)&&ru(i,r)?n(t,i,`${a} ${r}`):d.void}return i.members===`all`?n(t,i,a):r(t,i,a)}return s.on(`ImportDeclaration`,e=>f.match(l.get(nu,e.source.value),{onNone:()=>d.void,onSome:t=>vr(e)?d.void:d.forEach(e.specifiers,n=>a(e,n,t),{concurrency:1,discard:!0})}))}}),au=r.define({name:`prefer-effect-headers`,meta:V({type:`suggestion`,description:`Prefer immutable Effect Headers values in Effect projects.`,messages:{effectHeaders:`Use Headers.fromInput to construct normalized, immutable Effect headers.`},url:`https://www.effect.website/docs/v4/api/effect/unstable/http/Headers`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`effectHeaders`})),je(n.callee,`Headers`))):{}}});function ou(e){return f.exists(f.all(e),e=>c.every(e,ie.isHttpMethod)&&new Set(e).size>=6)}const su=r.define({name:`prefer-effect-http-method`,meta:V({type:`suggestion`,description:`Prefer the Effect HttpMethod type and guards over hand-written lists of HTTP methods.`,messages:{methodList:`Use HttpMethod.HttpMethod, HttpMethod.all or HttpMethod.isHttpMethod instead of listing HTTP methods by hand. HttpMethod also includes TRACE and QUERY.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpMethod`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.merge(s.on(`ArrayExpression`,n=>ou(c.map(n.elements,e=>b.isNotNull(e)&&N(e)?f.some(e.value):f.none()))?e.report(t.fromId({node:n,messageId:`methodList`})):d.void),s.on(`TSUnionType`,n=>ou(c.map(n.types,e=>e.type===`TSLiteralType`&&N(e.literal)?f.some(e.literal.value):f.none()))?e.report(t.fromId({node:n,messageId:`methodList`})):d.void)):{}}}),cu=new Map(c.map(l.keys({Continue:!0,SwitchingProtocols:!0,Processing:!0,EarlyHints:!0,OK:!0,Created:!0,Accepted:!0,NonAuthoritativeInformation:!0,NoContent:!0,ResetContent:!0,PartialContent:!0,MultiStatus:!0,AlreadyReported:!0,ImUsed:!0,MultipleChoices:!0,MovedPermanently:!0,Found:!0,SeeOther:!0,NotModified:!0,TemporaryRedirect:!0,PermanentRedirect:!0,BadRequest:!0,Unauthorized:!0,PaymentRequired:!0,Forbidden:!0,NotFound:!0,MethodNotAllowed:!0,NotAcceptable:!0,ProxyAuthenticationRequired:!0,RequestTimeout:!0,Conflict:!0,Gone:!0,LengthRequired:!0,PreconditionFailed:!0,PayloadTooLarge:!0,UriTooLong:!0,UnsupportedMediaType:!0,RangeNotSatisfiable:!0,ExpectationFailed:!0,ImATeapot:!0,MisdirectedRequest:!0,UnprocessableEntity:!0,Locked:!0,FailedDependency:!0,TooEarly:!0,UpgradeRequired:!0,PreconditionRequired:!0,TooManyRequests:!0,RequestHeaderFieldsTooLarge:!0,UnavailableForLegalReasons:!0,InternalServerError:!0,NotImplemented:!0,BadGateway:!0,ServiceUnavailable:!0,GatewayTimeout:!0,HttpVersionNotSupported:!0,VariantAlsoNegotiates:!0,InsufficientStorage:!0,LoopDetected:!0,NotExtended:!0,NetworkAuthenticationRequired:!0}),e=>v.make(ae.fromLiteral(e),e)));function lu(e,t){return t.isApi(e.callee,`HttpApiSchema`,`status`)?D(e,0).pipe(f.toArray,c.map(e=>v.make(e,`statusName`))):t.isApi(e.callee,`HttpApiSchema`,`Empty`)?D(e,0).pipe(f.toArray,c.map(e=>v.make(e,`httpStatus`))):t.isApi(e.callee,`HttpServerResponse`,`setStatus`)?c.map(c.getSomes([D(e,0),D(e,1)]),e=>v.make(e,`httpStatus`)):f.flatMap(t.member(e.callee,`HttpServerResponse`),t=>D(e,t===`empty`?0:1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(E(`status`)))).pipe(f.toArray,c.map(({value:e})=>v.make(e,`httpStatus`)))}const uu=r.define({name:`prefer-effect-http-status`,meta:V({type:`suggestion`,description:`Prefer named HttpStatus literals over status code numbers passed to Effect HTTP APIs.`,messages:{statusName:`Pass the status name: HttpApiSchema.status('{{literal}}') instead of {{code}}.`,httpStatus:`Name the status: use HttpStatus.fromLiteral('{{literal}}') instead of {{code}}.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpStatus`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r(n,r){let i=O(n),a=i.type===`Literal`&&b.isNumber(i.value)?f.fromNullishOr(cu.get(i.value)):f.none();return f.match(a,{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:i,messageId:r,data:{code:e.sourceCode.getText(i),literal:n}}))})}return s.merge(s.on(`ObjectExpression`,e=>d.forEach(c.filter(c.getSomes(c.map(e.properties,pe)),e=>f.contains(T(e),`httpApiStatus`)),e=>r(e.value,`httpStatus`),{concurrency:1,discard:!0})),s.on(`CallExpression`,e=>d.forEach(lu(e,n),([e,t])=>r(e,t),{concurrency:1,discard:!0})))}}),du=m.Literals([`@tsndr/cloudflare-worker-jwt`,`fast-jwt`,`hono/jwt`,`jose`,`jsonwebtoken`,`jwt-decode`,`jwt-simple`]),fu=m.is(du),pu=m.Literals([`header`,`payload`,`signature`]),mu=m.is(pu);function hu(e){return P(e,`.`)}function gu(e){return f.exists(M(e,`VariableDeclarator`),({id:e})=>e.type===`ArrayPattern`&&c.some(e.elements,e=>e?.type===`Identifier`&&mu(e.name)))}const _u=r.define({name:`prefer-effect-jwt`,meta:V({type:`suggestion`,description:`Prefer Effect Jwt over JWT libraries and tokens split and decoded by hand in Effect projects.`,messages:{jwtLibrary:`Use Jwt from effect/jose instead of {{source}}: it decodes the claims with a Schema and fails with a typed JwtError.`,manualJwt:`Do not split a JWT on '.' by hand. Use Jwt.verify or Jwt.verifyWithKeySet from effect/jose, which check the signature, exp and nbf before decoding the claims with a Schema, and Jwt.decodeUnverified only to choose a key.`},url:`https://effect.website/docs/v4/api/effect/jose/Jwt`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r(e){return n.isApi(e.callee,`String`,`split`)?f.exists(D(e,1),hu)?D(e,0):f.none():e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`split`)&&f.exists(D(e,0),hu)?f.some(e.callee.object):f.none()}return s.merge(s.on(`ImportDeclaration`,({source:n})=>fu(n.value)?e.report(t.fromId({node:n,messageId:`jwtLibrary`,data:{source:n.value}})):d.void),s.on(`CallExpression`,n=>f.exists(r(n),e=>f.exists(w(e),e=>/jwt|token/iu.test(c.lastNonEmpty(e)))||gu(n))?e.report(t.fromId({node:n,messageId:`manualJwt`})):d.void))}});function vu(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)}function yu(e,t){return e.type!==`BinaryExpression`||!le(e.operator)?f.none():vu(e.left)?f.some(t.getText(e.right)):vu(e.right)?f.some(t.getText(e.left)):f.none()}function bu(e){return e?.type===`ConditionalExpression`||e?.type===`IfStatement`}function xu(e,t,n){return f.contains(yu(e.test,n),t)?bu(e.alternate)?f.map(xu(e.alternate,t,n),te.increment):f.some(1):f.none()}function Su(e,t){return yu(e.test,t).pipe(f.flatMap(n=>xu(e,n,t)),f.exists(e=>e>1))}const Cu=r.define({name:`prefer-effect-match`,meta:V({type:`suggestion`,description:`Prefer Effect Match for composable and exhaustive branching in Effect projects.`,messages:{effectMatch:`Use Match.type, Match.value, or Match.tags with Match.exhaustive instead of switch.`,preferMatch:`Use Match from Effect instead of a chained literal ternary.`,ifChain:"Use Match.type, Match.value, or Match.discriminators with Match.exhaustive instead of an `else if` chain comparing the same value against literals."},url:`https://www.effect.website/docs/v4/api/effect/Match`}),*create(){let e=yield*i,n=yield*B,r=s.on(`ConditionalExpression`,n=>n.parent.type!==`ConditionalExpression`&&Su(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`preferMatch`})):d.void);return n.hasEffectImport?s.merge(r,s.on(`SwitchStatement`,n=>e.report(t.fromId({node:n,messageId:`effectMatch`}))),s.on(`IfStatement`,n=>(n.parent.type!==`IfStatement`||n.parent.alternate!==n)&&Su(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`ifChain`})):d.void)):r}}),wu=m.Literals([`status`,`statusCode`]),Tu=m.is(wu),Eu={"<":`>`,"<=":`>=`,">":`<`,">=":`<=`};function Du(e){return e.type===`PrivateIdentifier`?e:O(e)}function Ou(e){let t=Du(e);return t.type===`MemberExpression`&&f.exists(C(t),Tu)}function ku(e){let t=Du(e);return t.type===`Literal`&&b.isNumber(t.value)?f.some(t.value):f.none()}function Au(e,t){let n=Du(e);if(n.type!==`BinaryExpression`||!(n.operator in Eu))return f.none();let[r,i,a]=Ou(n.left)?[n.left,n.right,n.operator]:[n.right,n.left,Eu[n.operator]??n.operator];return Ou(r)?f.flatMap(ku(i),e=>{let n=t(r);return e===200&&a===`>=`||e===199&&a===`>`?f.some({bound:`lower`,inRange:!0,status:n}):e===200&&a===`<`||e===199&&a===`<=`?f.some({bound:`lower`,inRange:!1,status:n}):e===300&&a===`<`||e===299&&a===`<=`?f.some({bound:`upper`,inRange:!0,status:n}):e===300&&a===`>=`||e===299&&a===`>`?f.some({bound:`upper`,inRange:!1,status:n}):f.none()}):f.none()}const ju=r.define({name:`prefer-effect-match-status`,meta:V({type:`suggestion`,description:`Prefer HttpClientResponse.filterStatusOk or matchStatus over hand-written 2xx status range checks.`,messages:{matchStatus:`Use HttpClientResponse.filterStatusOk, or HttpClientResponse.matchStatus with a '2xx' case, instead of checking the 2xx range by hand. On a native fetch Response, read response.ok.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpClientResponse`}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};function n(t){return e.sourceCode.getText(t)}return s.on(`LogicalExpression`,r=>{let i=r.operator===`&&`;return r.operator!==`??`&&f.exists(f.all([Au(r.left,n),Au(r.right,n)]),([e,t])=>e.status===t.status&&e.bound!==t.bound&&e.inRange===i&&t.inRange===i)?e.report(t.fromId({node:r,messageId:`matchStatus`})):d.void})}}),Mu=r.define({name:`prefer-effect-ndjson`,meta:V({type:`suggestion`,description:`Prefer Effect Ndjson over splitting lines and parsing or stringifying each one as JSON.`,messages:{decode:`Use Ndjson.decodeString or Ndjson.decodeSchemaString from effect/encoding instead of JSON.parse on each line: it handles CRLF, blank lines and lines split across chunks, and fails with an NdjsonError.`,encode:`Use Ndjson.encodeString or Ndjson.encodeSchemaString from effect/encoding instead of joining JSON.stringify results with line breaks.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Ndjson`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r={imports:n,sourceCode:e.sourceCode},a={mapper:t=>Bc(t,`stringify`,e.sourceCode),element:t=>t.type===`CallExpression`&&Bc(t.callee,`stringify`,e.sourceCode)};function o(t){return Bc(t.callee,`parse`,e.sourceCode)&&f.exists(D(t,0),e=>tl(e,r))}function c(e){return f.exists(zc(e,Pc,n),t=>rl(il(e,t,n),a,r))}return s.merge(s.on(`CallExpression`,n=>o(n)?e.report(t.fromId({node:n,messageId:`decode`})):c(n)?e.report(t.fromId({node:n,messageId:`encode`})):d.void),s.on(`MemberExpression`,n=>Bc(n,`parse`,e.sourceCode)&&Qc(n,r)?e.report(t.fromId({node:n,messageId:`decode`})):d.void))}}),Nu=m.Literals([`ip`,`ip-address`,`ip-range-check`,`ip-regex`,`ipaddr.js`,`is-ip`,`is-localhost-ip`,`netmask`,`private-ip`]),Pu=m.is(Nu),Fu=m.Literals([`isIP`,`isIPv4`,`isIPv6`]),Iu=m.is(Fu),Lu=[`net`,`node:net`],Ru=m.Literals([`0.0.0.0`,`127.0.0.1`,`255.255.255.255`,`::`,`::1`]),zu=m.is(Ru),Bu=/^(?:(?:0|10|127|169\.254|192\.168|172\.(?:1[6-9]|2\d|3[01])|100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7]))\.|fe80:|::ffff:)$/iu,Vu=[/(?:(?:\\d|\[0-9\])(?:\+|\{1,3\})\\\.){3}/u,/\((?:\?:)?(?:\\d|\[0-9\])(?:\+|\{1,3\})\\\.\)\{3\}/u,/^(?=[\s\S]*25\[0-5\])(?=[\s\S]*\\\.)/u,/^\^(?:\(\?:)?(?:0|10|100|127|169\\\.254|172|192\\\.168)(?:\|(?:0|10|100|127|169\\\.254|172|192\\\.168))*\)?\\\./u,/^\^\(?(?:\?:)?(?:fe80|fe\[89ab\]|f\[cd\]|fc\|fd|fd\|fc)/iu,/::ffff:/iu];function Hu(e){return f.match(j(e),{onNone:()=>e,onSome:t=>t.type===`Program`?e:Hu(t)})}const Uu=r.define({name:`prefer-effect-net-address`,meta:V({type:`suggestion`,description:`Prefer Effect NetAddress over IP addresses parsed and classified by hand in Effect projects.`,messages:{ipText:`Parse the address with NetAddress.ipFromString and classify it with NetAddress.isLoopback, isPrivate, isLinkLocal, isUniqueLocal, isUnspecified or isIpv4Mapped, or IpNetwork.contains, instead of matching IP text by hand.`,nodeIpCheck:`Use NetAddress.ipFromString, ipv4FromString or ipv6FromString from effect/net instead of net.{{name}}: they return a typed address to classify.`,library:`Use NetAddress and IpNetwork from effect/net instead of {{source}}.`},url:`https://effect.website/docs/v4/api/effect/net/NetAddress`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r=yield*p.make(x.empty());function a(n){let[i]=Hu(n).range;return d.gen(function*(){let a=yield*p.get(r);x.has(a,i)||(yield*p.update(r,x.add(i)),yield*e.report(t.fromId({node:n,messageId:`ipText`})))})}function o(e){return(e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`startsWith`)||n.isApi(e.callee,`String`,`startsWith`))&&f.exists(D(e,0),e=>N(e)&&Bu.test(e.value))}return s.merge(s.on(`ImportDeclaration`,({source:n})=>Pu(n.value)?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`CallExpression`,n=>Ue(e.sourceCode,n.callee,Lu).pipe(f.filter(Iu),f.match({onNone:()=>o(n)?a(n):d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`nodeIpCheck`,data:{name:r}}))}))),s.on(`Literal`,e=>`regex`in e&&c.some(Vu,t=>t.test(e.regex.pattern))?a(e):d.void),s.on(`BinaryExpression`,e=>le(e.operator)&&c.some([e.left,e.right],e=>N(e)&&zu(e.value))?a(e):d.void))}}),Wu={num:`Number`,opt:`Option`,order:`Order`},Gu=m.is(m.Literals([`min`,`max`])),Ku=m.is(m.String.check(m.isPattern(/min|max|lower|upper|bound|limit|^(?:lo|hi|low|high)$/iu))),qu=/* @__PURE__ */ new Set([`increment`,`decrement`,`order`,`between`]),Ju=m.is(m.String.check(m.isPattern(/\.[cm]?tsx?$/u)));function J(e){let t=O(e);return t.type===`Literal`?f.liftPredicate(t.value,b.isNumber):t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)?f.map(J(t.argument),e=>t.operator===`-`?-e:e):f.none()}function Y(e){return _.value(O(e)).pipe(_.discriminators(`type`)({Identifier:g.constTrue,Literal:g.constTrue,ThisExpression:g.constTrue,UnaryExpression:({operator:e,argument:t})=>e!==`delete`&&Y(t),BinaryExpression:({left:e,right:t})=>e.type!==`PrivateIdentifier`&&Y(e)&&Y(t),MemberExpression:({object:e,computed:t,property:n})=>Y(e)&&(!t||Y(n))}),_.orElse(g.constFalse))}function Yu(e,t,n,r){let i=O(e);return i.type!==`CallExpression`||i.optional||i.arguments.length!==r||i.callee.type!==`MemberExpression`||i.callee.optional||!R(t,i.callee.object,`Math`)||!f.contains(C(i.callee),n)?f.none():f.all(c.map(i.arguments,(e,t)=>D(i,t)))}function Xu(e,t,n){return f.flatMap(Yu(e,t,n,2),([e,t])=>b.isNotUndefined(e)&&b.isNotUndefined(t)?f.some([e,t]):f.none())}function Zu(e){return f.isSome(J(e))||w(O(e)).pipe(f.map(c.lastNonEmpty),f.exists(Ku))}function Qu(e){return c.every(e,Y)||c.countBy(e,e=>f.isNone(J(e)))<=1}function $u(e,t,n){return f.match(J(e),{onSome:e=>f.contains(J(t),e),onNone:()=>n.getText(O(e))===n.getText(O(t))})}function ed(e,t,n){let[r,i]=e;return r?.type===`Identifier`&&i?.type===`Identifier`&&r.name!==i.name&&t.type===`Identifier`&&n.type===`Identifier`&&(t.name===r.name&&n.name===i.name||t.name===i.name&&n.name===r.name)}function td(e,t){let n=O(e);if(n.type!==`CallExpression`||n.optional||n.arguments.length!==2)return f.none();let r=n.callee,i=r.type===`MemberExpression`&&!r.optional&&R(t.scope,r.object,`Math`)?C(r):f.filter(t.imports.member(r,`Number`),()=>z(t.sourceCode,r));return f.all([f.filter(i,Gu),D(n,0),D(n,1)]).pipe(f.map(([e,t,n])=>[e,[t,n]]))}function nd(e,t,n){return f.flatMap(td(e,n),([e,n])=>e===t?f.some(n):f.none())}function rd(e,t){let{sourceCode:n}=t;return td(e,t).pipe(f.flatMap(([e,[r,i]])=>{let a=e===`min`?`max`:`min`;return nd(i,a,t).pipe(f.map(e=>[r,e]),f.orElse(()=>f.map(nd(r,a,t),e=>[i,e])),f.flatMap(([t,[r,i]])=>{let a=Zu(r)===Zu(i),[o,s]=Zu(i)&&!Zu(r)?[i,r]:[r,i],[c,l]=e===`min`?[o,t]:[t,o];return f.exists(f.all([J(c),J(l)]),([e,t])=>e>t)?f.none():f.some({kind:`clamp`,mode:e===`max`&&a?`report`:Qu([t,r,i])?`fix`:`suggest`,replacement:({num:e})=>`${e}.clamp(${H(n,s)}, { minimum: ${H(n,c)}, maximum: ${H(n,l)} })`})}))}))}function id(e,t){let n=O(e);if(n.type===`BinaryExpression`&&n.operator===`**`)return f.contains(J(n.left),10)?f.some(n.right):f.none();let r=f.flatMap(Xu(n,t,`pow`),([e,t])=>f.contains(J(e),10)?f.some(t):f.none());return f.orElse(r,()=>J(n).pipe(f.map(Math.log10),f.map(Math.round),f.filter(e=>te.between(e,{minimum:1,maximum:22})&&f.contains(J(n),10**e))))}function ad(e,t,n){if(e.operator!==`/`)return f.none();let r=e.right;return Yu(e.left,t,`round`,1).pipe(f.flatMap(c.head),f.map(O),f.filter(e=>e.type===`BinaryExpression`&&e.operator===`*`),f.flatMap(({left:e,right:t})=>$u(t,r,n)?f.some([e,t,!1]):$u(e,r,n)?f.some([t,e,!0]):f.none()),f.flatMap(([e,r,i])=>f.map(id(r,t),t=>{let r=b.isNumber(t)?String(t):H(n,t);return{kind:`round`,mode:b.isNumber(t)||Y(t)&&(!i||Y(e))?`fix`:`report`,replacement:({num:t})=>`${t}.round(${H(n,e)}, ${r})`}})))}function od(e,t,n){let r=O(e);if(t.isApi(r,`Number`,`sum`)&&z(n,r))return f.some(`+`);if(t.isApi(r,`Number`,`multiply`)&&z(n,r))return f.some(`*`);if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`||r.async||r.generator||r.params.length!==2||b.isNull(r.body))return f.none();let i=r.body;return(i.type===`BlockStatement`?f.flatMap(f.liftPredicate(i.body,e=>e.length===1),e=>f.flatMap(c.head(e),e=>e.type===`ReturnStatement`&&b.isNotNullish(e.argument)?f.some(e.argument):f.none())):f.some(i)).pipe(f.map(O),f.filter(e=>e.type===`BinaryExpression`&&(e.operator===`+`||e.operator===`*`)),f.filter(({left:e,right:t})=>ed(r.params,O(e),O(t))),f.map(({operator:e})=>e===`+`?`+`:`*`))}function sd(e,t,n){return{kind:e,mode:e===`sumAll`?`fix`:`suggest`,replacement:({num:r})=>f.match(t,{onNone:()=>`${r}.${e}`,onSome:t=>`${r}.${e}(${H(n,t)})`})}}function cd(e,t){let n=e===`+`?0:1;return f.exists(J(t),e=>Object.is(e,n))?f.some(e===`+`?`sumAll`:`multiplyAll`):f.none()}function ld(e,t,n){if(t.isApi(e.callee,`Array`,`reduce`)&&z(n,e.callee)){if(e.arguments.length!==2&&e.arguments.length!==3)return f.none();let[r,i,a]=e.arguments.length===3?[D(e,0),D(e,1),D(e,2)]:[f.none(),D(e,0),D(e,1)];return f.all([i,a]).pipe(f.flatMap(([e,r])=>f.flatMap(od(r,t,n),t=>cd(t,e))),f.filter(()=>e.arguments.length===2||f.isSome(r)),f.map(e=>sd(e,r,n)))}let r=e.callee;return e.optional||e.arguments.length!==2||r.type!==`MemberExpression`||r.optional||r.object.type===`Super`||!f.contains(C(r),`reduce`)||f.isSome(t.path(r))?f.none():f.all([D(e,0),D(e,1)]).pipe(f.flatMap(([e,r])=>f.flatMap(od(e,t,n),e=>cd(e,r))),f.map(e=>sd(e,f.some(r.object),n)))}function ud(e){return e.type===`Identifier`&&(b.isNullish(e.typeAnnotation)||e.typeAnnotation.typeAnnotation.type===`TSNumberKeyword`)}function dd(e,t){if(e.type!==`ArrowFunctionExpression`||e.async||b.isNotNullish(e.returnType)||b.isNotNullish(e.typeParameters)||e.params.length!==t||e.body.type===`BlockStatement`)return f.none();let n=c.filter(e.params,ud);return n.length===t?f.some([n,O(e.body)]):f.none()}function fd(e,t){let n=O(e);return n.type===`Identifier`&&n.name===t}function pd(e,t){return e.type===`BinaryExpression`?md(e,t):e.type===`AssignmentExpression`?hd(e,t):e.type===`UpdateExpression`&&e.argument.type===`Identifier`&&e.argument.name===t?f.some([e.operator===`++`?`+`:`-`,e.prefix?`new`:`old`]):f.none()}function md(e,t){return e.type!==`BinaryExpression`||e.left.type===`PrivateIdentifier`?f.none():(e.operator===`+`||e.operator===`-`)&&fd(e.left,t)&&f.contains(J(e.right),1)?f.some([e.operator,`new`]):f.none()}function hd(e,t){return(e.operator===`+=`||e.operator===`-=`)&&e.left.type===`Identifier`&&e.left.name===t&&f.contains(J(e.right),1)?f.some([e.operator===`+=`?`+`:`-`,`new`]):f.none()}function gd(e){return dd(e,1).pipe(f.flatMap(([[e],t])=>b.isUndefined(e)?f.none():f.map(pd(t,e.name),n=>[n,e,t])),f.map(([[e,t],n,r])=>{let i=e===`+`?`increment`:`decrement`,a=e===`+`&&r.type!==`UpdateExpression`&&b.isNullish(n.typeAnnotation);return t===`new`?{kind:i,mode:a?`suggest`:`fix`,replacement:({num:e})=>`${e}.${i}`}:{kind:`unchangedStep`,mode:`report`,data:{step:e===`+`?`n++`:`n--`,api:`Num.${i}`},replacement:()=>``}}))}function _d(e,t){let n=e.callee;return t.imports.isApi(n,`Array`,`sort`)&&z(t.sourceCode,n)?e.arguments.length===1||e.arguments.length===2?D(e,e.arguments.length-1):f.none():!e.optional&&e.arguments.length===1&&n.type===`MemberExpression`&&!n.optional&&f.exists(C(n),e=>e===`sort`||e===`toSorted`)&&f.isNone(t.imports.path(n))?D(e,0):f.none()}function vd(e,t){return _d(e,t).pipe(f.flatMap(e=>dd(e,2).pipe(f.flatMap(([[t,n],r])=>b.isUndefined(t)||b.isUndefined(n)||t.name===n.name||r.type!==`BinaryExpression`||r.operator!==`-`?f.none():fd(r.left,t.name)&&fd(r.right,n.name)?f.some({kind:`order`,mode:`fix`,target:e,data:{order:`Num.Order`},replacement:({num:e})=>`${e}.Order`}):fd(r.left,n.name)&&fd(r.right,t.name)?f.some({kind:`order`,mode:`fix`,target:e,data:{order:`Order.flip(Num.Order)`},extra:[`order`],replacement:({num:e,order:t})=>`${t}.flip(${e}.Order)`}):f.none()))))}function yd(e,t){let n=O(e);if(n.type!==`BinaryExpression`||n.left.type===`PrivateIdentifier`)return f.none();let{operator:r,left:i,right:a}=n;return r===(t?`<`:`<=`)?f.some({small:i,big:a}):r===(t?`>`:`>=`)?f.some({small:a,big:i}):f.none()}function bd(e,t,n,r){return r.getText(O(e.small))===t?f.some([n?`lower`:`upper`,e.big]):r.getText(O(e.big))===t?f.some([n?`upper`:`lower`,e.small]):f.none()}function xd(e,t,n,r,i){let a=i.getText(O(e));return f.zipWith(bd(t,a,r,i),bd(n,a,r,i),([t,n],[r,i])=>t===r?f.none():f.some(t===`lower`?[e,n,i]:[e,i,n])).pipe(f.flatten)}function Sd(e){let t=O(e);return t.type===`TemplateLiteral`||t.type===`Literal`&&(b.isString(t.value)||b.isBigInt(t.value))}function Cd(e,t){if(e.operator!==`&&`&&e.operator!==`||`)return f.none();let n=e.operator===`||`;return f.all([yd(e.left,n),yd(e.right,n)]).pipe(f.flatMap(([e,r])=>c.findFirst(c.filter([e.small,e.big],e=>f.isNone(J(e))),i=>xd(i,e,r,n,t))),f.filter(e=>!c.some(e,Sd)),f.filter(([,e,t])=>c.every([e,t],Zu)),f.map(([e,r,i])=>({kind:`between`,mode:c.every([e,r,i],Y)?!n&&f.isSome(J(r))?`fix`:`suggest`:`report`,replacement:({num:a})=>`${n?`!`:``}${a}.between(${H(t,e)}, { minimum: ${H(t,r)}, maximum: ${H(t,i)} })`})))}function wd(e){return f.contains(J(e),0)}function Td(e){let t=O(e);return t.type!==`BinaryExpression`||t.operator!==`===`&&t.operator!==`!==`?f.none():(wd(t.right)?f.some(t.left):wd(t.left)?f.some(t.right):f.none()).pipe(f.filter(e=>f.isNone(J(e))),f.map(e=>[e,t.operator===`!==`]))}function Ed(e,t){return Td(e.test).pipe(f.flatMap(([n,r])=>{let[i,a]=r?[e.alternate,e.consequent]:[e.consequent,e.alternate],o=O(a);if(o.type!==`BinaryExpression`||o.operator!==`/`||t.getText(O(o.right))!==t.getText(O(n)))return f.none();let s=o.left,c=O(i).type===`ObjectExpression`?`(${t.getText(i)})`:H(t,i);return f.some({kind:`divide`,mode:Y(s)&&Y(n)&&!k(i,e=>e.type===`AwaitExpression`||e.type===`YieldExpression`)?`fix`:`report`,extra:[`opt`],replacement:({num:e,opt:r})=>`${r}.getOrElse(${e}.divide(${H(t,s)}, ${H(t,n)}), () => ${c})`})}))}function Dd(e,t){let n=e.callee;return e.optional||e.arguments.length!==1||!f.exists(c.head(e.arguments),e=>e.type===`SpreadElement`)||n.type!==`MemberExpression`||n.optional||!R(t.scope,n.object,`Math`)?f.none():C(n).pipe(f.filter(Gu),f.map(e=>({kind:`extreme`,mode:`report`,data:{api:`Arr.${e}`,math:`Math.${e}`,empty:e===`max`?`-Infinity`:`Infinity`},replacement:()=>``})))}function Od(e,t){let n=e.type===`CallExpression`?e:f.getOrNull(f.none());if(b.isNull(n)||n.optional||n.arguments.length!==1||n.callee.type!==`Identifier`)return f.none();let{name:r}=n.callee;return f.liftPredicate(r,e=>(e===`Number`||e===`parseFloat`)&&R(t.getScope(n),n.callee,e))}function kd(e,t){let n=e.callee;return!e.optional&&e.arguments.length===1&&(R(t.scope,n,`isNaN`)||n.type===`MemberExpression`&&!n.optional&&R(t.scope,n.object,`Number`)&&f.contains(C(n),`isNaN`))?D(e,0).pipe(f.map(O),f.flatMap(e=>e.type===`Identifier`?Ae(L(t.sourceCode,e,e.name)).pipe(f.flatMap(({node:e})=>e.type===`VariableDeclarator`&&b.isNotNullish(e.init)&&be(e.parent)?f.some(O(e.init)):f.none())):f.some(e))).pipe(f.flatMap(e=>Od(e,t.sourceCode)),f.map(e=>({kind:`parse`,mode:`report`,data:{conversion:`${e}(…)`},replacement:()=>``}))):f.none()}const Ad=r.define({name:`prefer-effect-number`,meta:V({type:`suggestion`,description:`Prefer Effect Number helpers over hand-written clamping, rounding, ranges, sums, products, comparators and parsing in Effect files.`,messages:{clamp:`Use Number.clamp from Effect instead of nesting min and max.`,round:`Use Number.round from Effect instead of scaling Math.round by a power of ten.`,sumAll:`Use Number.sumAll from Effect instead of summing with reduce.`,multiplyAll:`Use Number.multiplyAll from Effect instead of multiplying with reduce. It returns 0 at the first 0, even when NaN or Infinity follows.`,increment:`Use Number.increment from Effect instead of (n) => n + 1.`,decrement:`Use Number.decrement from Effect instead of (n) => n - 1.`,unchangedStep:`This callback returns n unchanged, because {{step}} returns the value before the update. Use {{api}} to return the next value.`,order:`Use {{order}} from Effect instead of a comparator that subtracts. It sorts the same, except NaN.`,between:`Use Number.between from Effect instead of comparing with both bounds.`,divide:`Use Number.divide from Effect, which returns none for a zero divisor, instead of checking for 0 first.`,extreme:`Use {{api}} with Number.Order instead of {{math}} over a spread. It needs a non-empty array, where {{math}} of an empty array is {{empty}}, and it skips NaN.`,parse:`Use Number.parse from Effect, which returns an Option, instead of {{conversion}} with a NaN check. Number.parse returns none for '' and '12px'.`,replace:`Replace with Number.{{api}}.`},url:`https://www.effect.website/docs/v4/api/effect/Number`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};let r=Ju(e.filename),a=d.fnUntraced(function*(n,i){let{kind:a}=i,o=!r&&i.mode===`fix`&&qu.has(a)?`suggest`:i.mode,s=i.target??n,u=t.fromId({node:s,messageId:a,data:i.data??{}});if(o===`report`||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(s)))return yield*e.report(u);let p=yield*d.forEach([`num`,...i.extra??[]],e=>d.map(Pt(s,`effect/${Wu[e]}`,yr(Wu[e])),t=>[e,t]),{concurrency:1}),m=l.map(Wu,(e,t)=>f.match(c.findFirst(p,([e])=>e===t),{onNone:()=>yr(e),onSome:([,e])=>e.name})),h=t.composeFixes(...c.flatMap(p,([,e])=>f.toArray(e.fix)),t.replaceText(s,i.replacement(m)));return yield*e.report(o===`fix`?t.withFix(u,h):t.withSuggestions(u,[{messageId:`replace`,data:{api:a},fix:h}]))});function u(e,t){return f.match(t,{onNone:()=>d.void,onSome:t=>a(e,t)})}function p(t){return d.map(o.getScope(t),t=>({sourceCode:e.sourceCode,imports:n,scope:t}))}return s.merge(s.on(`CallExpression`,t=>d.flatMap(p(t),r=>u(t,rd(t,r).pipe(f.orElse(()=>ld(t,n,e.sourceCode)),f.orElse(()=>vd(t,r)),f.orElse(()=>Dd(t,r)),f.orElse(()=>kd(t,r)))))),s.on(`BinaryExpression`,t=>d.flatMap(o.getScope(t),n=>u(t,ad(t,n,e.sourceCode)))),s.on(`ArrowFunctionExpression`,e=>u(e,gd(e))),s.on(`LogicalExpression`,t=>u(t,Cd(t,e.sourceCode))),s.on(`ConditionalExpression`,t=>u(t,Ed(t,e.sourceCode))))}}),jd=m.Literals([`node:path`,`path`]),Md=m.is(jd),Nd=r.define({name:`prefer-effect-path`,meta:V({type:`suggestion`,description:`Prefer the Effect Path service over direct Node.js path imports in Effect projects.`,messages:{effectPath:`Use the Path service from effect/Path instead of {{source}}.`},url:`https://www.effect.website/docs/v4/api/effect/Path`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.on(`ImportDeclaration`,({source:n})=>Md(n.value)?e.report(t.fromId({node:n,messageId:`effectPath`,data:{source:n.value}})):d.void):{}}}),Pd={Arr:`effect/Array`,P:`effect/Predicate`},Fd={bigint:`isBigInt`,boolean:`isBoolean`,function:`isFunction`,number:`isNumber`,object:`isObjectOrArray`,string:`isString`,symbol:`isSymbol`,undefined:`isUndefined`},Id={"!=":`isNotNullish`,"!==":`isNotNull`,"==":`isNullish`,"===":`isNull`},Ld={"!=":`isNotNullish`,"!==":`isNotUndefined`,"==":`isNullish`,"===":`isUndefined`},Rd={Array:[`Arr`,`isArray`,`similar`],BigInt:[`P`,`isBigInt`,`different`],Boolean:[`P`,`isBoolean`,`different`],Date:[`P`,`isDate`,`exact`],Error:[`P`,`isError`,`exact`],Function:[`P`,`isFunction`,`similar`],Map:[`P`,`isMap`,`similar`],Number:[`P`,`isNumber`,`different`],Promise:[`P`,`isPromise`,`similar`],RegExp:[`P`,`isRegExp`,`exact`],Set:[`P`,`isSet`,`similar`],String:[`P`,`isString`,`different`],Symbol:[`P`,`isSymbol`,`different`],Uint8Array:[`P`,`isUint8Array`,`exact`]},zd=m.Literals([`!==`,`!=`]),Bd=m.is(zd);function Vd(e){return e.type===`ArrowFunctionExpression`||e.type===`FunctionDeclaration`||e.type===`FunctionExpression`}function Hd(e,t,n,r){return(n.type===`Literal`&&b.isNull(n.value)?f.some(Id):f.liftPredicate(Ld,()=>R(r,n,`undefined`))).pipe(f.flatMap(l.get(e.operator)),f.map(e=>({namespace:`P`,member:e,subject:t,negated:!1,equivalence:`exact`})))}function Ud(e,t,n,r){if(t.type!==`UnaryExpression`||t.operator!==`typeof`||!N(n))return f.none();let i=O(t.argument);return i.type===`Identifier`&&R(r,i,i.name)?f.none():f.map(l.get(Fd,n.value),r=>{let i=n.value===`undefined`&&Bd(e.operator);return{namespace:`P`,member:i?`isNotUndefined`:r,subject:t.argument,negated:Bd(e.operator)&&!i,equivalence:n.value===`object`?`similar`:`exact`}})}function Wd(e,t){if(!le(e.operator))return f.none();let n=O(e.left),r=O(e.right);return Ud(e,n,r,t).pipe(f.orElse(()=>Ud(e,r,n,t)),f.orElse(()=>Hd(e,e.left,r,t)),f.orElse(()=>Hd(e,e.right,n,t)))}function Gd(e,t){let n=O(e.right);return n.type===`Identifier`&&R(t,n,n.name)?f.map(l.get(Rd,n.name),([t,n,r])=>({namespace:t,member:n,subject:e.left,negated:!1,equivalence:r})):f.none()}function Kd(e){return f.exists(Ce(e,Vd),e=>e.returnType?.typeAnnotation.type===`TSTypePredicate`)}const qd=r.define({name:`prefer-effect-predicate`,meta:V({type:`suggestion`,description:`Prefer Effect Predicate guards over typeof, instanceof, and nullish comparisons in Effect files.`,messages:{predicate:`Use {{predicate}} from Effect instead of this check. Decode unknown input with Schema.is or a Schema decoder instead of narrowing it by hand.`,objectPredicate:`Use {{predicate}} from Effect instead of this check. Unlike typeof x === 'object', it treats null as not an object.`,boxedInstance:"`instanceof {{constructor}}` only matches boxed objects such as `new {{constructor}}(…)`, never primitive values. To check for the primitive, use {{predicate}}.",replace:`Replace with {{predicate}}.`},url:`https://www.effect.website/docs/v4/api/effect/Predicate`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};let n=d.fnUntraced(function*(n,r){let{namespace:i,member:a,negated:o,equivalence:s}=r,l=o?`!`:``,u=`${l}${i}.${a}`,d=t.fromId(s===`different`?{node:n,messageId:`boxedInstance`,data:{constructor:e.sourceCode.getText(n.right),predicate:u}}:{node:n,messageId:a===`isObjectOrArray`?`objectPredicate`:`predicate`,data:{predicate:u}});if(s===`different`||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(n)))return yield*e.report(d);let f=yield*Ft(n,Pd[i],i,t=>`${l}${t}.${a}(${H(e.sourceCode,r.subject)})`);return yield*e.report(s===`exact`?t.withFix(d,f):t.withSuggestions(d,[{messageId:`replace`,data:{predicate:u},fix:f}]))});return s.on(`BinaryExpression`,e=>d.flatMap(o.getScope(e),t=>(e.operator===`instanceof`?Gd(e,t):Wd(e,t)).pipe(f.filter(()=>!Kd(e)),f.match({onNone:()=>d.void,onSome:t=>n(e,t)}))))}}),Jd=m.Literals([`@microsoft/fetch-event-source`,`better-sse`,`event-source-polyfill`,`eventsource`,`eventsource-client`,`eventsource-parser`,`extended-eventsource`,`fetch-event-stream`,`reconnecting-eventsource`,`sse.js`]),Yd=m.is(Jd),Xd=r.define({name:`prefer-effect-sse`,meta:V({type:`suggestion`,description:"Prefer Effect Sse over Server-Sent Events libraries and `EventSource` in Effect projects.",messages:{library:`Use Sse from effect/encoding instead of {{source}}: Sse.decode, Sse.decodeSchema or Sse.makeParser parse event streams, and Sse.encode or HttpApiSchema.StreamSse write them.`,eventSource:`Read the event stream with HttpClient and Sse.decode or Sse.decodeSchema, so events are schema-decoded and the stream is interruptible.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Sse`}),*create(){let e=yield*i;return(yield*B).hasEffectImport?s.merge(Ys(n=>Yd(qs(n.value))?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`eventSource`})),je(n.callee,`EventSource`)))):{}}}),Zd=m.Literals([`canParse`,`parse`]),Qd=m.is(Zd),$d=r.define({name:`prefer-effect-url`,meta:V({type:`suggestion`,description:`Prefer Effect Url helpers for safe URL parsing in Effect projects.`,messages:{effectUrl:`Use Url.fromString or Url.make so invalid URLs are represented as Result failures.`},url:`https://www.effect.website/docs/v4/api/effect/unstable/http/Url`}),*create(){let e=yield*i,n=yield*B;function r(n,r){return d.when(e.report(t.fromId({node:n,messageId:`effectUrl`})),je(r,`URL`))}return n.hasEffectImport?s.merge(s.on(`NewExpression`,e=>r(e,e.callee)),s.on(`CallExpression`,e=>f.exists(w(e.callee),e=>e.length===2&&e[0]===`URL`&&Qd(e[1]))&&e.callee.type===`MemberExpression`?r(e,e.callee.object):d.void)):{}}}),ef=/[?&][\w.%[\]-]+=$/u;function tf(e){return ef.test(e)}function nf(e){return c.some(c.take(e.quasis,e.expressions.length),e=>tf(e.value.cooked??e.value.raw))}function rf(e){return f.match(c.head(e.arguments),{onNone:()=>!0,onSome:e=>e.type===`ObjectExpression`||e.type===`ArrayExpression`})}const af=r.define({name:`prefer-effect-url-params`,meta:V({type:`suggestion`,description:`Prefer Effect UrlParams over URLSearchParams and hand-built query strings in Effect projects.`,messages:{urlSearchParams:`Use UrlParams.fromInput for immutable query parameters, and HttpClientRequest.setUrlParams or UrlParams.toString to apply them.`,manualQuery:`Build query strings with UrlParams.fromInput and UrlParams.toString, or HttpClientRequest.setUrlParams, which encode every value.`},url:`https://www.effect.website/docs/v4/api/effect/http/UrlParams`}),*create(){let e=yield*i;return!(yield*B).hasEffectImport||lo(e.filename)?{}:s.merge(s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`urlSearchParams`})),d.map(je(n.callee,`URLSearchParams`),e=>e&&rf(n)))),s.on(`TemplateLiteral`,n=>nf(n)&&n.parent.type!==`TaggedTemplateExpression`?e.report(t.fromId({node:n,messageId:`manualQuery`})):d.void),s.on(`BinaryExpression`,n=>{let r=n.left.type===`BinaryExpression`&&n.left.operator===`+`?n.left.right:n.left;return n.operator===`+`&&N(r)&&tf(r.value)?e.report(t.fromId({node:n,messageId:`manualQuery`})):d.void}))}}),of=m.Literals([`appdirsjs`,`application-config-path`,`env-paths`,`os-homedir`,`platform-folders`,`user-home`,`xdg-app-paths`,`xdg-basedir`]),sf=m.is(of),cf=m.Literals([`APPDATA`,`HOME`,`LOCALAPPDATA`,`USERPROFILE`,`XDG_CACHE_HOME`,`XDG_CONFIG_HOME`,`XDG_DATA_HOME`,`XDG_STATE_HOME`]),lf=m.is(cf),uf=[`node:os`,`os`],df=r.define({name:`prefer-effect-user-directories`,meta:V({type:`suggestion`,description:`Prefer the Effect UserDirectories service over home directories and XDG paths resolved by hand in Effect projects.`,messages:{homedir:`Use the UserDirectories service from effect/persistence instead of os.homedir(): dirs.config, dirs.data, dirs.cache and dirs.state resolve the platform directory, and dirs.home the home directory.`,variable:`Use the UserDirectories service from effect/persistence instead of reading {{name}}: it applies the XDG, macOS and Windows conventions and reads the environment through the ConfigProvider.`,library:`Use the UserDirectories service from effect/persistence instead of {{source}}.`},url:`https://effect.website/docs/v4/api/effect/persistence/UserDirectories`}),*create(){let e=yield*i,n=yield*B;if(!n.hasEffectImport)return{};function r(n,r){return e.report(t.fromId({node:n,messageId:`variable`,data:{name:r}}))}return s.merge(s.on(`ImportDeclaration`,({source:n})=>sf(n.value)?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`CallExpression`,i=>{if(f.contains(Ue(e.sourceCode,i.callee,uf),`homedir`))return e.report(t.fromId({node:i,messageId:`homedir`}));let a=n.isApi(i.callee,`Config`,[`String`,`NonEmptyString`,`Redacted`])&&z(e.sourceCode,i.callee)?D(i,0).pipe(f.filter(N),f.map(({value:e})=>e),f.filter(lf)):f.none();return f.match(a,{onNone:()=>d.void,onSome:e=>r(i,e)})}),s.on(`MemberExpression`,e=>{let t=e.parent.type===`AssignmentExpression`&&e.parent.left===e||!f.exists(w(e.object),e=>c.join(e,`.`)===`process.env`)?f.none():f.filter(C(e),lf);return f.match(t,{onNone:()=>d.void,onSome:t=>e.object.type===`MemberExpression`?d.when(r(e,t),je(e.object.object,`process`)):d.void})}))}}),ff={"&&":[`===`,`==`],"||":[`!==`,`!=`],"??":[]};function pf(e,t){let n=O(e);return n.type===`LogicalExpression`&&n.operator===t?[...pf(n.left,t),...pf(n.right,t)]:[n]}function mf(e,t,n){if(e.type!==`BinaryExpression`||!c.contains(t,e.operator)||e.left.type===`PrivateIdentifier`)return f.none();let r=O(e.left),i=O(e.right);if(r.type!==`MemberExpression`||i.type!==`MemberExpression`)return f.none();let a=n.getText(r.object),o=n.getText(i.object);return f.flatMap(C(r),e=>a===o||!f.contains(C(i),e)?f.none():f.some(a<o?`${a} and ${o}`:`${o} and ${a}`))}function hf(e,t){return we(e).pipe(f.flatMap(e=>qn(e,t)),f.exists(e=>e.length===2&&e[0]===`Equivalence`&&e[1]===`make`))}const gf=r.define({name:`prefer-equal`,meta:V({type:`suggestion`,description:`Prefer Equal.equals or an Equivalence over field-by-field comparisons in Effect files.`,messages:{preferEqual:`Compare {{pair}} with Equal.equals (Data and Schema classes implement Equal) or an Equivalence such as Equivalence.Struct instead of field by field.`},url:`https://www.effect.website/docs/v4/api/effect/Equal`}),*create(){let e=yield*i,n=yield*B;return n.hasEffectImport?s.on(`LogicalExpression`,r=>{let i=ff[r.operator],a=r.parent;if(c.isReadonlyArrayEmpty(i)||a.type===`LogicalExpression`&&a.operator===r.operator)return d.void;let o=c.getSomes(c.map(pf(r,r.operator),t=>mf(t,i,e.sourceCode)));return c.findFirst(o,(e,t)=>c.contains(c.take(o,t),e)).pipe(f.filter(()=>!hf(r,n)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`preferEqual`,data:{pair:n}}))}))}):{}}});function _f(e,t){return f.exists(e,e=>{let n=O(e);return n.type===`Identifier`&&n.name===t})}function vf(e,t,n){return e?.type===`CallExpression`&&e.arguments.length===1&&n.isApi(e.callee,`Match`,`value`)&&_f(D(e,0),t)}function yf(e,t,n){return e.callee.type===`MemberExpression`&&f.contains(C(e.callee),`pipe`)?vf(e.callee.object,t,n):(n.isApiPath(e.callee,[`pipe`])||n.isApiPath(e.callee,[`Function`,`pipe`]))&&f.exists(D(e,0),e=>vf(e,t,n))}function bf(e,t,n){if(n.isApi(e.callee,`Match`,`valueTags`))return e.arguments.length===2&&_f(D(e,0),t)?c.get(e.arguments,1):f.none();let r=e.callee;return r.type===`CallExpression`&&n.isApi(r.callee,`Match`,`valueTags`)&&r.arguments.length===1&&e.arguments.length===1&&_f(D(e,0),t)?c.head(r.arguments):f.none()}function xf(e){return e.type!==`ArrowFunctionExpression`&&b.isNotNull(e.id)||e.parent.type===`VariableDeclarator`&&e.parent.init===e}function Sf(e){let[t]=e.params;return e.params.length===1&&t?.type===`Identifier`&&!e.typeParameters&&!e.async&&!e.generator?f.some(t):f.none()}function Cf(e,t,n){return W(e).pipe(f.filter(e=>e.type===`CallExpression`&&!k(e,e=>e.type===`ThisExpression`)),f.flatMap(r=>yf(r,t,n)?f.some(`value`):f.exists(bf(r,t,n),n=>!xf(e)||ye(n,t))?f.some(`valueTags`):f.none()))}const wf=r.define({name:`prefer-hoisted-match`,meta:V({type:`suggestion`,description:`Hoist Effect matchers with Match.type or Match.typeTags instead of wrapping Match.value or Match.valueTags in a function.`,messages:{value:"Replace this function with a hoisted `Match.type<…>().pipe(…)` matcher instead of calling `Match.value({{parameter}})` on every call. Case handlers already receive the narrowed value.",valueTags:"Replace this function with a hoisted `Match.typeTags<…>()({…})` or `Match.type<…>().pipe(Match.tagsExhaustive({…}))` matcher instead of calling `Match.valueTags` with `{{parameter}}`. Case handlers already receive the narrowed value."},url:`https://www.effect.website/docs/v4/api/effect/Match`}),*create(){let e=yield*i,n=yield*B;function r(r){return f.match(Sf(r),{onNone:()=>d.void,onSome:({name:i})=>f.match(Cf(r,i,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:n,data:{parameter:i}}))})})}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionDeclaration`,r),s.on(`FunctionExpression`,r))}});function Tf(e){return e.type===`SpreadElement`}function Ef(e){if(!Tf(e))return!1;let t=O(e.argument);return t.type!==`ConditionalExpression`&&t.type!==`LogicalExpression`&&t.type!==`ObjectExpression`&&(t.type!==`MemberExpression`||!f.contains(C(t),`fields`))}function Df(e){return A(e)&&c.some(e.params,e=>e.type!==`AssignmentPattern`&&e.type!==`TSParameterProperty`&&!e.typeAnnotation)}function Of(e){return b.isNull(e)||e.type===`SpreadElement`?!1:_.value(O(e)).pipe(_.when({type:`Literal`},({value:e})=>b.isString(e)||b.isNumber(e)||b.isBoolean(e)),_.when({type:`TemplateLiteral`},({expressions:e})=>c.isReadonlyArrayEmpty(e)),_.when({type:`UnaryExpression`,operator:`-`},({argument:e})=>Of(e)),_.when({type:`ArrayExpression`},({elements:e})=>c.some(e,Of)),_.when({type:`ObjectExpression`},({properties:e})=>c.some(e,e=>e.type===`Property`&&Of(e.value))),_.orElse(g.constFalse))}function kf(e){return Df(e)||e.type===`CallExpression`&&c.some(e.arguments,Df)}const Af=_.type().pipe(_.when({type:`Property`,kind:`init`,method:!1},e=>{let t=O(e.value);return!kf(t)&&!Of(t)}),_.orElse(g.constFalse));function jf(e){let[t,...n]=e.properties;return b.isUndefined(t)||!Ef(t)||c.isReadonlyArrayEmpty(n)?f.none():c.every(n,Ef)?f.some(`merge`):c.every(n,Af)?f.some(`copy`):f.none()}function Mf(e,t){let[n,...r]=e.properties;if(!n||!Tf(n)||!c.isReadonlyArrayNonEmpty(r))return f.none();let i=H(t,n.argument),a=c.headNonEmpty(r);if(!c.every(r,Tf)){let e=h.slice(v.get(a.range,0),v.get(c.lastNonEmpty(r).range,1))(t.text);return f.some(`${i}, { ${e} }`)}return r.length===1&&Tf(a)?f.some(`${i}, ${H(t,a.argument)}`):f.none()}const Nf=r.define({name:`prefer-struct-assign`,meta:V({type:`suggestion`,description:`Prefer Struct.assign over object spread merges and copies in Effect files.`,messages:{merge:`Use Struct.assign(a, b) instead of merging objects with spreads.`,copy:`Use Struct.assign(value, { … }) instead of copying an object with spread overrides. Spreading a class instance drops its prototype; rebuild Schema and Data class instances with their constructor.`,assign:`Replace with Struct.assign.`},url:`https://www.effect.website/docs/v4/api/effect/Struct#assign`,hasSuggestions:!0}),*create(){let e=yield*i;if(!(yield*B).hasEffectImport)return{};let n=d.fnUntraced(function*(n,r){let i=t.fromId({node:n,messageId:r}),a=f.filter(Mf(n,e.sourceCode),()=>c.isReadonlyArrayEmpty(e.sourceCode.getCommentsInside(n)));if(f.isNone(a))return yield*e.report(i);let o=yield*Ft(n,`effect/Struct`,`Struct`,e=>`${e}.assign(${a.value})`);return yield*e.report(t.withSuggestions(i,[{messageId:`assign`,fix:o}]))});return s.on(`ObjectExpression`,e=>f.match(jf(e),{onNone:()=>d.void,onSome:t=>n(e,t)}))}}),Pf={interruptibleMask:`interruptible`,uninterruptibleMask:`uninterruptible`},Ff=r.define({name:`prefer-uninterruptible`,meta:V({type:`suggestion`,description:`Prefer the non-mask interruptibility API when the restore callback is unused.`,messages:{unusedRestore:`The mask callback never uses restore, so the mask is equivalent to {{replacement}} and misleadingly suggests a restored region.`},url:`https://github.com/Effect-TS/tsgo/issues/659`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>{let i=f.flatMap(n.member(r.callee,`Effect`),e=>l.get(Pf,e));return f.isSome(i)&&f.exists(D(r,0),e=>A(e)&&!Se(e))?e.report(t.fromId({node:r,messageId:`unusedRestore`,data:{replacement:`Effect.${i.value}`}})):d.void})}}),If=r.define({name:`prefer-with-span`,meta:V({type:`suggestion`,description:`Prefer Effect.withSpan when the callback does not use the span handle.`,messages:{unusedSpan:`The useSpan callback ignores its span. Use Effect.withSpan so nested spans are parented beneath this span.`},url:`https://github.com/Effect-TS/tsgo/issues/663`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`useSpan`)&&f.exists(D(r,r.arguments.length-1),e=>A(e)&&!Se(e))?e.report(t.fromId({node:r,messageId:`unusedSpan`})):d.void)}}),Lf=m.String.check(m.isPattern(/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i)),Rf=m.is(Lf);function zf(e,t){let n=O(e);return P(n,0)||t.isApi(n,`Duration`,`zero`)?!0:N(n)?Rf(n.value):n.type===`CallExpression`&&f.exists(t.path(n.callee),e=>f.contains(c.head(e),`Duration`))&&f.exists(D(n,0),P(0))}const Bf=r.define({name:`prefer-yield-now`,meta:V({type:`suggestion`,description:`Prefer scheduler yielding to a zero-duration Clock sleep.`,messages:{zeroSleep:`Effect.sleep(0) uses Clock and interacts with TestClock. Use Effect.yieldNow for a cooperative scheduler yield.`},url:`https://github.com/Effect-TS/tsgo/issues/661`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`sleep`)&&f.exists(D(r,0),e=>zf(e,n))?e.report(t.fromId({node:r,messageId:`zeroSleep`})):d.void)}}),Vf=m.Literals([`catch`,`mapError`,`catchAll`]),Hf=m.is(Vf);function Uf(e,t){return f.exists(qn(e,t),([e,t])=>e===`Effect`&&Hf(t))||f.exists(Kn(e,`catch`),e=>t.isApi(e.callee,`Effect`,[`try`,`tryPromise`]))}const Wf=r.define({name:`preserve-caught-error`,meta:V({type:`suggestion`,description:`Preserve the underlying cause when wrapping an Effect failure.`,messages:{droppedCause:`This handler constructs a new error but drops the caught failure. Accept it as a parameter and attach it as cause.`},url:`https://github.com/Effect-TS/tsgo/issues/490`}),*create(){let e=yield*i,n=yield*B;function r(r){let i=xe(r);return b.isNotNullish(r.body)&&Uf(r,n)&&k(r.body,e=>e.type===`NewExpression`&&Oe(e)&&!f.exists(i,({name:t})=>ye(e,t)))?e.report(t.fromId({node:r,messageId:`droppedCause`})):d.void}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionExpression`,r))}}),Gf=r.define({name:`require-schema-class-brand`,meta:V({type:`problem`,description:`Require Schema.Class declarations to carry a nominal brand.`,messages:{missingBrand:`Schema.Class without a second type parameter is structural. Add a unique brand so plain objects cannot masquerade as instances.`},url:`https://github.com/Effect-TS/tsgo/issues/468`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Schema`,`Class`)&&(r.typeArguments?.params.length??0)<2?e.report(t.fromId({node:r,messageId:`missingBrand`})):d.void)}}),Kf=r.define({name:`require-try-promise-abort-signal`,meta:V({type:`suggestion`,description:`Require Effect.tryPromise thunks to accept and use their AbortSignal for interruption.`,messages:{missingSignal:"Accept the AbortSignal parameter and pass it to the Promise API. Name it `_signal` only when cancellation is unsupported.",unusedSignal:"Pass this AbortSignal to the Promise API, or rename it to `_signal` to explicitly acknowledge that cancellation is unsupported."},url:`https://www.effect.website/docs/v4/api/effect/Effect#tryPromise`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`tryPromise`)?f.match(er(D(r,0)),{onNone:()=>d.void,onSome:n=>f.match(xe(n),{onNone:()=>e.report(t.fromId({node:n,messageId:`missingSignal`})),onSome:r=>h.startsWith(`_`)(r.name)||Se(n)?d.void:e.report(t.fromId({node:r,messageId:`unusedSignal`}))})}):d.void)}}),qf=[`fn`,`fnUntraced`,`gen`],Jf=[`fn`,`fnUntraced`],Yf=[`try`,`tryPromise`];function Xf(e,t){return _.value(e.parent).pipe(_.when({type:`CallExpression`},n=>I(D(n,0),e)&&t.isApi(n.callee,`Effect`,Yf)),_.when({type:`Property`,computed:!1,key:{type:`Identifier`,name:`try`},parent:{type:`ObjectExpression`,parent:{type:`CallExpression`}}},e=>t.isApi(e.parent.parent.callee,`Effect`,Yf)),_.orElse(()=>!1))}function Zf(e,t){return f.exists(Te(e),({callee:e})=>t.isApi(e,`Effect`,qf)||e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,Jf))}const Qf=r.define({name:`throw-in-effect-gen`,meta:V({type:`problem`,description:`Disallow throw in Effect generator APIs because it creates an untyped defect.`,messages:{throwInGen:`Use yield* Effect.fail(...) instead of throw so the failure stays in the typed error channel.`}}),*create(){let e=yield*i,n=yield*B;return s.on(`ThrowStatement`,r=>f.exists(we(r),e=>!Xf(e,n)&&Zf(e,n))?e.report(t.fromId({node:r,messageId:`throwInGen`})):d.void)}}),$f=m.is(m.Literals([`BigDecimal`,`Config`,`Data`,`DateTime`,`Duration`,`Effect`,`Equivalence`,`Exit`,`Function`,`Layer`,`Match`,`Option`,`Order`,`Predicate`,`Result`,`Schedule`,`Schema`,`Stream`,`String`,`Struct`,`flow`,`pipe`])),ep=m.is(m.Literals([`BigDecimal`,`Data`,`DateTime`,`Duration`,`Exit`,`Option`,`Result`,`String`,`Struct`,`pipe`])),tp=m.is(m.Literals([`pipe`,`value`,`valueTags`])),np=/^run|unsafe/iu;function rp(e,t){return Ae(L(t.sourceCode,e,e.name))}function ip(e,t){let n=e.callee,r=f.getOrElse(t.imports.path(n),()=>[]),i=f.exists(c.head(r),$f)&&!c.some(r,e=>np.test(e)),a=n.type===`MemberExpression`&&!n.computed&&f.contains(C(n),`pipe`)&&n.object.type===`CallExpression`&&ip(n.object,t)||n.type===`CallExpression`&&ip(n,t),o=f.exists(c.head(r),ep)||f.exists(c.get(r,1),tp);return!e.optional&&(i||a)&&c.every(e.arguments,e=>e.type!==`SpreadElement`&&X(e,t)&&(!o||!ap(e,t)))}function ap(e,t){return e.type===`Identifier`?f.exists(rp(e,t),e=>e.type===`FunctionName`||e.type===`ImportBinding`||e.type===`Variable`&&e.node.type===`VariableDeclarator`&&b.isNotNull(e.node.init)&&A(e.node.init)):A(e)}function X(e,t){return _.value(e).pipe(_.discriminators(`type`)({Literal:e=>!(`regex`in e),ArrowFunctionExpression:g.constTrue,FunctionExpression:g.constTrue,Identifier:e=>!f.exists(rp(e,t),e=>e.type===`Variable`&&e.parent?.type===`VariableDeclaration`&&!be(e.parent)),TemplateLiteral:({expressions:e})=>c.every(e,e=>X(e,t)),ParenthesizedExpression:({expression:e})=>X(e,t),TSAsExpression:({expression:e})=>X(e,t),TSSatisfiesExpression:({expression:e})=>X(e,t),TSNonNullExpression:({expression:e})=>X(e,t),MemberExpression:e=>f.isSome(t.imports.path(e))||e.object.type===`CallExpression`&&ip(e.object,t)&&(!e.computed||X(e.property,t)),UnaryExpression:({argument:e,operator:n})=>n!==`delete`&&X(e,t),BinaryExpression:({left:e,right:n})=>X(e,t)&&X(n,t),LogicalExpression:({left:e,right:n})=>X(e,t)&&X(n,t),ConditionalExpression:({alternate:e,consequent:n,test:r})=>X(r,t)&&X(n,t)&&X(e,t),ArrayExpression:({elements:e})=>c.every(e,e=>b.isNull(e)||X(e,t)),ObjectExpression:({properties:e})=>c.every(e,e=>e.type===`SpreadElement`?X(e.argument,t):(!e.computed||X(e.key,t))&&X(e.value,t)),CallExpression:e=>ip(e,t)}),_.orElse(g.constFalse))}function op(e,t){return e.type===`ObjectExpression`||e.type===`ArrayExpression`||A(e)||e.type===`Identifier`&&f.exists(rp(e,t),({type:e})=>e===`FunctionName`)}function sp(e,t){return c.isReadonlyArrayEmpty(e.params)&&!e.async&&!e.generator&&!e.typeParameters&&f.exists(W(e),e=>!op(e,t)&&X(e,t))}function cp(e,t,n){return f.exists(c.findFirst(e.getDeclaredVariables(t),e=>e.name===n),({references:e})=>c.some(e,({identifier:e,init:t})=>{let n=e.parent;return!t&&(n.type!==`CallExpression`||n.callee!==e)}))}function lp(e){return(e.parent?.type===`ExportNamedDeclaration`?e.parent:e).parent?.type===`Program`}const up=r.define({name:`no-constant-thunk`,meta:V({type:`suggestion`,description:`Disallow top-level functions without parameters that always return the same value.`,messages:{constantThunk:"`{{name}}` takes no parameters and always returns the same value. Make it a constant, or a static on its class."}}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*B};function r(r,i,a){return sp(i,n)&&!cp(e.sourceCode,r,a.name)?e.report(t.fromId({node:a,messageId:`constantThunk`,data:{name:a.name}})):d.void}return s.merge(s.on(`FunctionDeclaration`,e=>e.id&&e.body&&lp(e)?r(e,e,e.id):d.void),s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&A(e.init)&&lp(e.parent)?r(e,e.init,e.id):d.void))}}),dp=m.is(m.Literals([`Array`,`Chunk`,`HashMap`,`HashSet`,`Iterable`,`MutableHashMap`,`MutableHashSet`,`MutableList`,`Record`,`Trie`,`Tuple`,`TxChunk`,`TxHashMap`])),fp=m.is(m.Literals(/* @__PURE__ */ `Channel.acquireRelease,Channel.acquireUseRelease,Channel.catchCauseFilter,Channel.catchReason,Channel.combine,Channel.filterArrayEffect,Channel.fromTransform,Channel.fromTransformBracket,Channel.map,Channel.mapAccum,Channel.mapEffect,Channel.runFold,Channel.runFoldEffect,Channel.scan,Channel.scanEffect,Channel.transformPull,Combiner.make,Duration.matchPair,Effect.acquireRelease,Effect.acquireUseRelease,Effect.catchCauseFilter,Effect.catchReason,Effect.effectify,Effect.filter,Effect.findFirst,Effect.findFirstFilter,Effect.forEach,Effect.onErrorFilter,Effect.onExitFilter,Effect.partition,Effect.reduce,Effect.repeatOrElse,Effect.retryOrElse,Effect.tapCauseFilter,Effect.validate,Effect.zipWith,Equivalence.make,Filter.zipWith,Graph.complement,Graph.findEdge,Graph.findEdges,Graph.floydWarshall,Layer.fromBuild,Layer.fromBuildMemo,Metric.mapInput,Optic.fromChecks,Optic.makeLens,Optic.makeOptional,Option.containsWith,Option.lift2,Option.reduceCompact,Option.zipWith,Order.make,Reducer.make,RequestResolver.around,RequestResolver.make,RequestResolver.makeGrouped,RequestResolver.makeWith,Schema.makeFilter,Schema.makeIsMultipleOf,Schema.middlewareDecoding,Schema.middlewareEncoding,SchemaGetter.checkEffect,SchemaGetter.fail,SchemaGetter.transformEffect,SchemaGetter.transformOptionalEffect,SchemaTransformation.transformEffect,Sink.fold,Sink.foldArray,Sink.foldUntil,Sink.fromTransform,Sink.reduce,Sink.reduceArray,Sink.reduceEffect,Sink.reduceWhile,Sink.reduceWhileArray,Sink.reduceWhileArrayEffect,Sink.reduceWhileEffect,Sink.summarized,Stream.catchCauseFilter,Stream.catchReason,Stream.changesWith,Stream.changesWithEffect,Stream.combine,Stream.combineArray,Stream.crossWith,Stream.dropUntil,Stream.dropUntilEffect,Stream.dropWhile,Stream.dropWhileEffect,Stream.filterEffect,Stream.map,Stream.mapAccum,Stream.mapAccumArray,Stream.mapAccumArrayEffect,Stream.mapAccumEffect,Stream.mapArray,Stream.mapArrayEffect,Stream.mapEffect,Stream.runFold,Stream.runFoldEffect,Stream.scan,Stream.scanEffect,Stream.takeUntil,Stream.takeUntilEffect,Stream.takeWhile,Stream.takeWhileEffect,Stream.transformPull,Stream.transformPullBracket,Stream.zipLatestWith,Stream.zipWith,Stream.zipWithArray,TextDiff.diffWith,TxHashSet.reduce`.split(`,`))),pp=m.is(m.Literals([`Match`]));function mp(e,t){return t.type===`Identifier`&&f.exists(L(e,t,t.name),({defs:e})=>{let[t]=e;if(!t||e.length!==1)return!1;if(t.type===`FunctionName`)return t.node.type===`FunctionDeclaration`;let n=t.node;return t.type===`Variable`&&n.type===`VariableDeclarator`&&n.id.type===`Identifier`&&!n.id.typeAnnotation&&b.isNotNull(n.init)&&A(n.init)})}function hp(e){return!!e.returnType||c.some(e.params,e=>e.type===`Identifier`&&!!e.typeAnnotation)}const gp=r.define({name:`no-forwarding-lambda`,meta:V({type:`suggestion`,description:`Disallow Effect callbacks that only forward their parameters to another function.`,messages:{forwardingLambda:`This callback only passes its parameters to {{callee}}. Pass {{callee}} directly.`,passCallee:`Pass {{callee}} directly.`},fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*B,{sourceCode:r}=e,a=d.fnUntraced(function*(n,i){let a=r.getText(i.callee),o=h.includes(`
|
|
5
|
-
`)(a)?`the callee`:`\`${a}\``,s=t.fromId({node:n,messageId:`forwardingLambda`,data:{callee:o}});if(c.isReadonlyArrayNonEmpty(r.getCommentsInside(n))||!
|
|
6
|
-
`).length>o||s.length>o*120)return!1;let l=c.findFirst(a.getDeclaredVariables(n),e=>e.name===i.name).pipe(f.match({onSome:e=>c.filter(e.references,e=>!e.init),onNone:c.empty}));return l.length===1&&!c.some(l,e=>Ee(n,e.identifier))}return s.on(`Program`,e=>{let i=c.flatMap(e.body,e=>e.type===`ExportNamedDeclaration`&&!e.source?c.map(e.specifiers,e=>fe(e.local)):e.type===`ExportDefaultDeclaration`&&e.declaration.type===`Identifier`?[e.declaration.name]:[]);return d.forEach(c.filter(c.flatMap(e.body,e=>xp(e,r)),e=>l(e,i)),({name:e})=>n.report(t.fromId({node:e,messageId:`singleUse`,data:{name:e.name}})),{concurrency:1,discard:!0})})}});function Cp(e,t){let n=h.replaceAll(/\s+/gu,` `)(t.getText(e.callee));return n.length>60?`${h.slice(0,59)(n)}…`:n}function wp(e,t,n){return Uo(e)&&(!Wo(t,n)||c.some(e.params,e=>e.type===`Identifier`&&b.isNotNullish(e.typeAnnotation)&&e.typeAnnotation.typeAnnotation.type!==`TSUnknownKeyword`))}const Tp=r.define({name:`no-trivial-wrapper`,meta:V({type:`suggestion`,description:`Disallow named functions that only forward their parameters to another call.`,messages:{forwardsParameters:"`{{name}}` only passes its parameters to `{{callee}}`. Call `{{callee}}` directly, or assign it to a constant instead of wrapping it.",forwardsWithArguments:"`{{name}}` only passes its parameters to `{{callee}}` with fixed arguments. Call it inline, or hoist a constant built from those arguments, such as `Match.typeTags` or `Schema.is(Schema)`."}}),*create(){let e=yield*i,n=yield*B;function r(r,i){return Ho(r).pipe(f.filter(({call:e,exact:t})=>!wp(r,e.callee,n)&&Go(e.callee,n)&&(t||n.isApi(e.callee,`Match`,`valueTags`)||n.isApi(e.callee,`Function`,`pipe`)&&e.arguments.length===2)),f.match({onNone:()=>d.void,onSome:({call:n,exact:r})=>e.report(t.fromId({node:i,messageId:r?`forwardsParameters`:`forwardsWithArguments`,data:{name:i.name,callee:Cp(n,e.sourceCode)}}))}))}return s.merge(s.on(`FunctionDeclaration`,e=>e.id&&e.body?r(e,e.id):d.void),s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&A(e.init)?r(e.init,e.id):d.void))}}),Ep=m.is(m.Literals([`replace`,`replaceAll`,`slice`,`split`,`substr`,`substring`])),Dp=[`replace`,`replaceAll`,`slice`,`split`,`substring`,`takeLeft`,`takeRight`],Op=[`split`,`takeLeft`,`takeRight`],kp=[`flow`,`pipe`];function Ap(e){let t=O(e);return t.type===`ChainExpression`?t.expression:t}function jp(e,t){return t.isApi(Ap(e),`DateTime`,`formatIso`)}function Mp(e,t){let n=Ap(e);if(n.type!==`CallExpression`)return!1;let r=Ap(n.callee);return r.type===`MemberExpression`&&f.contains(C(r),`toISOString`)&&c.isReadonlyArrayEmpty(n.arguments)||jp(r,t)}function Np(e,t){let n=Ap(e);return n.type===`CallExpression`&&t.isApi(n.callee,`String`,Dp)}function Pp(e,t){return t.isApi(e,`Function`,kp)||t.isApiPath(e,[`pipe`])||t.isApiPath(e,[`flow`])}function Fp(e,t){let n=Ap(e.callee),r=c.filter(e.arguments,e=>e.type!==`SpreadElement`);return r.length===e.arguments.length?n.type===`MemberExpression`&&n.object.type!==`Super`&&f.contains(C(n),`pipe`)?f.some([n.object,...r]):Pp(n,t)?f.some(r):f.none():f.none()}function Ip(e,t){let n=Ap(e.callee),r=f.exists(D(e,0),e=>Mp(e,t));return n.type===`MemberExpression`&&f.exists(C(n),Ep)&&Mp(n.object,t)||e.arguments.length===2&&t.isApi(n,`String`,Op)&&r||e.arguments.length===1&&Np(n,t)&&r}function Lp(e,t){return Ip(e,t)?f.some(e):Fp(e,t).pipe(f.flatMap(e=>c.findFirst(c.zip(e,c.drop(e,1)),([e,n])=>Np(n,t)&&(Mp(e,t)||jp(e,t)))),f.map(([,e])=>e))}const Rp=r.define({name:`no-utc-iso-slicing`,meta:V({type:`problem`,description:`Disallow slicing or rewriting a UTC ISO string to get a local date or time.`,messages:{utcIsoSlicing:`toISOString() and DateTime.formatIso give UTC, so slicing or rewriting them gives the UTC date and time: in Europe/Amsterdam the previous day between 00:00 and 02:00, and +00:00 instead of +01:00/+02:00. Format in an explicit zone instead: DateTime.setZone with DateTime.formatIsoDate, formatIsoOffset or formatIsoZoned, or Intl.DateTimeFormat with timeZone.`},url:`https://www.effect.website/docs/v4/api/effect/DateTime`}),*create(){let e=yield*i,n=yield*B;return s.on(`CallExpression`,r=>f.match(Lp(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`utcIsoSlicing`}))}))}}),zp=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,Bp=String.raw`[^\S\r\n\u2028\u2029]*`,Vp=RegExp(`^(${Bp}${zp})(?:${Bp}${zp})+(${Bp};?)$`,`u`),Hp=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,Up=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),Wp=/* @__PURE__ */ new Set([`any`,`never`,`always`]),Gp=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),Kp=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),qp=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function Jp(e){return e.type===`Punctuator`&&e.value===`;`}function Yp(e,t){return e.loc.end.line===t.loc.start.line}function Xp(e){return e.loc.start.line===e.loc.end.line}function Zp(e){return Up.has(e.type)}function Qp(e){return e.type===`ChainExpression`?e.expression:e}function Z(e,t){let n=new Set(c.ensure(e));return(e,r)=>r.getFirstToken(e)?.value===t&&n.has(e.type)}function $p(e){return t=>t.type===e}function Q(e,t){return(n,r)=>e(n,r)&&Xp(n)===(t===`singleline`)}function em(e){if(e.type!==`ExpressionStatement`)return!1;let t=Qp(e.expression);if(t.type===`UnaryExpression`&&(t=Qp(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;)n=f.getOrThrowWith(c.last(n.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return Zp(n)}function tm(e){if(e.type!==`VariableDeclaration`)return!1;let t=f.getOrUndefined(c.head(e.declarations))?.init;if(b.isNullish(t))return!1;for(;t.type===`MemberExpression`;)t=t.object;return t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`require`}function nm(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||em(e))return!0;let n=t.getLastToken(e,e=>!Jp(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(v.get(n.range,0)):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function rm(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Zp(e.parent.parent))&&e.expression.type===`Literal`&&b.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function im(e,t){if(!rm(e,t)||!e.parent||!(`body`in e.parent)||!c.isArray(e.parent.body))return!1;let n=e.parent.body;return g.pipe(n,c.takeWhile(t=>t!==e),c.every(e=>rm(e,t)))}function am(e){if(e.type!==`ExpressionStatement`||e.expression.type!==`AssignmentExpression`)return!1;let t=e.expression.left;if(t.type!==`MemberExpression`)return!1;for(;t.object.type===`MemberExpression`;)t=t.object;return t.object.type===`Identifier`&&(t.object.name===`exports`||t.object.name===`module`&&t.property.type===`Identifier`&&t.property.name===`exports`)}function om(e,t){let n=f.fromNullOr(t.getLastToken(e)).pipe(f.getOrThrowWith(()=>/* @__PURE__ */ Error(`Padding rule invariant: statement has no token`))),r=t.getTokenBefore(n),i=t.getTokenAfter(n);return r&&i&&v.get(r.range,0)>=v.get(e.range,0)&&Jp(n)&&!Yp(r,n)&&Yp(n,i)?r:n}function sm(e,t){if(Xp(e))return e.loc;let n=e.loc.start.line,r=f.getOrThrowWith(c.get(t.lines,n-1),()=>/* @__PURE__ */ Error(`Padding rule invariant: statement source line is missing`));return{start:e.loc.start,end:{line:n,column:r.length}}}const cm=_.type().pipe(_.when({type:`VariableDeclaration`,kind:_.is(`using`,`await using`)},g.constTrue),_.orElse(g.constFalse)),$={"block-like":nm,expression:(e,t)=>e.type===`ExpressionStatement`&&!im(e,t),return:Z(`ReturnStatement`,`return`),export:Z([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:Z(`VariableDeclaration`,`var`),let:Z(`VariableDeclaration`,`let`),const:Z(`VariableDeclaration`,`const`),using:cm,type:Z(`TSTypeAliasDeclaration`,`type`)},lm={"*":()=>!0,exports:am,require:tm,directive:im,iife:em,block:$p(`BlockStatement`),empty:$p(`EmptyStatement`),function:$p(`FunctionDeclaration`),"ts-method":$p(`TSMethodSignature`),break:Z(`BreakStatement`,`break`),case:Z(`SwitchCase`,`case`),class:Z(`ClassDeclaration`,`class`),continue:Z(`ContinueStatement`,`continue`),debugger:Z(`DebuggerStatement`,`debugger`),default:Z([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:Z(`DoWhileStatement`,`do`),for:Z([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:Z(`IfStatement`,`if`),import:Z(`ImportDeclaration`,`import`),switch:Z(`SwitchStatement`,`switch`),throw:Z(`ThrowStatement`,`throw`),try:Z(`TryStatement`,`try`),while:Z([`WhileStatement`,`DoWhileStatement`],`while`),with:Z(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&Hp.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&f.exists(c.head(e.declarations),({init:e})=>b.isNotNullish(e)&&h.startsWith(`require(`)(t.getText(e))),enum:Z(`TSEnumDeclaration`,`enum`),interface:Z(`TSInterfaceDeclaration`,`interface`),"function-overload":$p(`TSDeclareFunction`),...$,"singleline-block-like":Q($[`block-like`],`singleline`),"multiline-block-like":Q($[`block-like`],`multiline`),"singleline-expression":Q($.expression,`singleline`),"multiline-expression":Q($.expression,`multiline`),"singleline-return":Q($.return,`singleline`),"multiline-return":Q($.return,`multiline`),"singleline-export":Q($.export,`singleline`),"multiline-export":Q($.export,`multiline`),"singleline-var":Q($.var,`singleline`),"multiline-var":Q($.var,`multiline`),"singleline-let":Q($.let,`singleline`),"multiline-let":Q($.let,`multiline`),"singleline-const":Q($.const,`singleline`),"multiline-const":Q($.const,`multiline`),"singleline-using":Q($.using,`singleline`),"multiline-using":Q($.using,`multiline`),"singleline-type":Q($.type,`singleline`),"multiline-type":Q($.type,`multiline`)};function um(e){return Gp.has(e)}function dm(e){return Wp.has(e)}function fm(e){return b.isString(e)&&l.has(lm,e)}function pm(e){return c.isArray(e)}function mm(e){if(fm(e))return e;if(b.isObject(e)&&b.isString(e.selector)&&c.every(l.keys(e),e=>qp.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(um(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function hm(e){if(!c.isArray(e))return mm(e);let t=e;if(!c.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return c.map(t,e=>mm(e))}function gm(e){return c.map(e,e=>{if(!b.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||c.some(l.keys(e),e=>!Kp.has(e))||!dm(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:hm(e.prev),next:hm(e.next)}})}function _m(e,t,n){let r=[],i=om(e,n);if(t.loc.start.line-i.loc.end.line>=2)do{let e=f.fromNullOr(n.getTokenAfter(i,{includeComments:!0})).pipe(f.getOrThrowWith(()=>/* @__PURE__ */ Error(`Padding rule invariant: next statement token is missing`)));e.loc.start.line-i.loc.end.line>=2&&r.push([i,e]),i=e}while(v.get(i.range,0)<v.get(t.range,0));return r}function vm(e,t,n){return d.gen(function*(){if(n===`any`)return yield*d.void;let r=yield*i,a=r.sourceCode,o=_m(e,t,a);return n===`never`?c.isArrayNonEmpty(o)?yield*r.report({node:t,messageId:`unexpectedBlankLine`,loc:sm(t,a),fix(e){if(o.length>=2)return null;let t=c.headNonEmpty(o),n=v.get(t[0].range,1),r=v.get(t[1].range,0);return e.replaceTextRange([n,r],g.pipe(a.text,h.slice(n,r),h.replace(Vp,`$1$2`)))}}):yield*d.void:c.isArrayNonEmpty(o)?yield*d.void:yield*r.report({node:t,messageId:`expectedBlankLine`,loc:sm(t,a),fix(n){let r=om(e,a),i=a.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!Yp(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,Yp(r,i)?`
|
|
4
|
+
`)||f.exists(lu(e),e=>h.includes(String.raw`\n`)(e)&&uu.test(e))}const fu=/* @__PURE__ */ new Set([`,`,`;`,` `]);function pu(e){return cu(e).pipe(f.orElse(()=>lu(e)),f.exists(e=>fu.has(e===String.raw`\t`?` `:e)))}function mu(e,t,n,r){if(e.type!==`CallExpression`)return f.none();if(r.isApi(e.callee,n,t))return e.arguments.length===1?f.map(E(e,0),e=>({separator:e,subject:f.none()})):f.map(E(e,1),t=>({separator:t,subject:E(e,0)}));let i=e.callee;return i.type===`MemberExpression`&&f.isNone(r.path(i))&&f.contains(S(i),t)&&e.arguments.length===1?f.map(E(e,0),e=>({separator:e,subject:f.some(i.object)})):f.none()}function hu(e,t,n){return mu(e,`split`,`String`,n).pipe(f.filter(e=>t(e.separator)),f.map(({subject:e})=>e))}function gu(e,t,n){return mu(e,`join`,`Array`,n).pipe(f.filter(e=>t(e.separator)),f.map(({subject:e})=>e))}function _u(e,t,n){return e.type===`MemberExpression`&&f.contains(S(e),t)&&L(n.getScope(e),e.object,`JSON`)}function vu(e){return e.type===`Identifier`&&!f.exists(A(e),t=>t.type===`MemberExpression`&&t.property===e&&!t.computed||t.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand)}function yu(e,t){let n=I(t.sourceCode,e,e.name);return rt(n).pipe(f.filter(e=>e.type===`Variable`),f.flatMap(e=>e.node.type===`VariableDeclarator`&&e.node.id.type===`Identifier`&&y.isNotNullish(e.node.init)&&f.exists(n,({references:e})=>c.every(e,e=>!e.isWrite()||e.init))?f.some(e.node.init):f.none()))}const bu=/* @__PURE__ */ new Set([`append`,`appendAll`,`concat`,`dedupe`,`drop`,`dropRight`,`filter`,`prepend`,`prependAll`,`reverse`,`slice`,`sort`,`sortWith`,`take`,`takeRight`,`toReversed`,`toSorted`]);function xu(e,t){let n=e.type===`CallExpression`?e.callee:e;return f.orElse(t.member(n,`Array`),()=>n.type===`MemberExpression`&&f.isNone(t.path(n))?S(n):f.none())}function Su(e,t){return f.exists(xu(e,t),e=>bu.has(e))}function Cu(e,t){let n=e.callee;return f.match(t.path(n),{onSome:()=>e.arguments.length>1||f.exists(xu(e,t),e=>e===`dedupe`||e===`reverse`)?E(e,0):f.none(),onNone:()=>n.type===`MemberExpression`?f.some(n.object):f.none()})}function wu(e,t,n,r){return f.exists(c.last(e),i=>{let a=c.dropRight(e,1);return c.isReadonlyArrayNonEmpty(a)&&!t.matches(i)?(i.type===`CallExpression`&&f.isNone(Cu(i,n.imports))||i.type===`MemberExpression`)&&(Su(i,n.imports)||i.type===`CallExpression`&&t.preserves(i))&&wu(a,t,n,r):Tu(i,t,n,r)})}function Tu(e,t,n,r=3){let i=e.type===`SpreadElement`?e.argument:D(e);return t.matches(i)?!0:vu(i)?r>0&&f.exists(yu(i,n),e=>Tu(e,t,n,r-1)):i.type===`ArrayExpression`?c.some(i.elements,e=>e?.type===`SpreadElement`&&Tu(e,t,n,r)):i.type===`CallExpression`?Du(i,n.imports)?wu([...i.callee.type===`MemberExpression`?[i.callee.object]:[],...i.arguments],t,n,r):(Su(i,n.imports)||t.preserves(i))&&f.exists(Cu(i,n.imports),e=>Tu(e,t,n,r)):!1}function Eu(e){return{matches:t=>f.isSome(hu(t,du,e.imports)),preserves:t=>Nu(t,{mapper:t=>e.imports.isApi(t,`String`,Au),element:t=>ju(t,e.imports)!==t})}}function Du(e,t){return t.isApiPath(e.callee,[`pipe`])||t.isApiPath(e.callee,[`Function`,`pipe`])||e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`pipe`)}function Ou(e,t,n){let r=c.findFirstIndex(e.arguments,e=>e===t),i=f.match(r,{onNone:()=>[],onSome:t=>c.take(e.arguments,t)}),a=e.callee.type===`MemberExpression`&&f.isNone(n.path(e.callee))?[e.callee.object]:[],o=j(e,`CallExpression`).pipe(f.match({onNone:()=>[],onSome:t=>c.isReadonlyArrayEmpty(i)&&c.isReadonlyArrayEmpty(a)&&P(t.arguments,e)&&Du(t,n)?[...t.callee.type===`MemberExpression`?[t.callee.object]:[],...c.takeWhile(t.arguments,t=>t!==e)]:[]}));return[...a,...i,...o]}function ku(e,t){return j(e,`CallExpression`).pipe(f.filter(t=>P(t.arguments,e)),f.exists(n=>wu(Ou(n,e,t.imports),Eu(t),t,3)))}const Au=[`trim`,`trimEnd`,`trimStart`];function ju(e,t){let n=D(e);return n.type===`CallExpression`?t.isApi(n.callee,`String`,Au)?f.match(E(n,0),{onNone:()=>n,onSome:e=>ju(e,t)}):n.callee.type===`MemberExpression`&&f.exists(S(n.callee),e=>c.contains(Au,e))&&c.isReadonlyArrayEmpty(n.arguments)?ju(n.callee.object,t):n:n}function Mu(e,t){let n=ju(e,t.imports);return n.type===`Identifier`&&f.exists(rt(I(t.sourceCode,n,n.name)),e=>{if(e.type===`Parameter`){let n=e.node;return k(n)&&F(c.head(n.params),e.name)&&ku(n,t)}let n=e.parent?.parent;return e.type===`Variable`&&n?.type===`ForOfStatement`&&n.left===e.parent&&Tu(n.right,Eu(t),t)})}function Nu(e,t){return e.type===`CallExpression`&&c.some(e.arguments,e=>t.mapper(e)||k(e)&&f.exists(U(e),t.element))}function Pu(e,t,n){return wu(e,{matches:e=>Nu(e,t),preserves:()=>!1},n,3)}function Fu(e,t,n){return f.match(t,{onSome:c.of,onNone:()=>Ou(e,e,n)})}const Iu=r.define({name:`prefer-effect-csv`,meta:B({type:`suggestion`,description:`Prefer Effect Csv over splitting lines into cells or joining cells and rows by hand.`,messages:{decode:`Use Csv.decodeString or Csv.decodeSchemaString from effect/encoding instead of splitting each line on a delimiter: quoted cells may contain the delimiter, quotes and line breaks.`,encode:`Use Csv.encodeString or Csv.encodeSchemaString from effect/encoding instead of joining cells and rows: joined cells are not quoted when they contain the delimiter, quotes or line breaks.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Csv`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r={imports:n,sourceCode:e.sourceCode},a={mapper:e=>f.exists(gu(e,pu,n),f.isNone),element:e=>f.isSome(gu(e,pu,n))};function o(e){return f.exists(hu(e,pu,n),t=>f.match(t,{onNone:()=>ku(e,r),onSome:e=>Mu(e,r)}))}function c(e){return f.exists(gu(e,du,n),t=>Pu(Fu(e,t,n),a,r))}return s.on(`CallExpression`,n=>o(n)?e.report(t.fromId({node:n,messageId:`decode`})):c(n)?e.report(t.fromId({node:n,messageId:`encode`})):d.void)}}),Lu=m.is(Xo),Ru=r.define({name:`prefer-effect-datetime`,meta:B({type:`suggestion`,description:`Prefer Effect DateTime formatting so time-zone behavior is explicit and composable.`,messages:{effectDateTime:`Convert to DateTime and format it in an explicit zone: DateTime.setZone with DateTime.formatIsoDate, formatIsoOffset or formatIsoZoned, or DateTime.format with timeZone. DateTime.formatIso is UTC, like toISOString: use it only for UTC instants, never slice it for a local date.`},url:`https://www.effect.website/docs/v4/api/effect/DateTime`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.on(`CallExpression`,n=>n.callee.type===`MemberExpression`&&f.exists(S(n.callee),Lu)?e.report(t.fromId({node:n,messageId:`effectDateTime`})):d.void):{}}}),zu=r.define({name:`prefer-effect-duration`,meta:B({type:`suggestion`,description:`Prefer explicit Effect Duration constructors over ambiguous millisecond literals.`,messages:{effectDuration:`Wrap this number with Duration.millis or use a more descriptive Duration constructor.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`,fixable:`code`}),*create(){let e=yield*i,n=yield*z,r=d.fnUntraced(function*(n,r){let i=yield*Yn(n,`effect/Duration`,`Duration`),a=t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`);yield*e.report(t.withFix(t.fromId({node:r,messageId:`effectDuration`}),t.composeFixes(...f.toArray(i.fix),a)))});return s.on(`CallExpression`,e=>d.flatMap($o(e,n),t=>t.pipe(f.filter(e=>f.isSome(ns(e))),f.match({onNone:()=>d.void,onSome:t=>r(e,t)}))))}}),Bu={ms:`millis`,milli:`millis`,millis:`millis`,millisecond:`millis`,milliseconds:`millis`,sec:`seconds`,secs:`seconds`,seconds:`seconds`,mins:`minutes`,minutes:`minutes`,hr:`hours`,hrs:`hours`,hours:`hours`,days:`days`,weeks:`weeks`},Vu=m.is(Bo),Hu=m.is(Uo),Uu=m.is(Go),Wu=m.is(Vo);function Gu(e){let t=cs(e),n=t.indexOf(`in`);if(n>0&&n<t.length-1&&f.exists(c.get(t,n-1),e=>l.has(Bu,e)||Vu(e))||c.some(t,Uu))return`excluded`;let r=c.get(t,t.length-2);return f.match(c.last(t),{onNone:()=>`none`,onSome:e=>f.match(l.get(Bu,e),{onSome:e=>e,onNone:()=>Hu(e)||e===`age`&&f.contains(r,`max`)||e===`in`&&f.contains(r,`expires`)?`unknown`:`none`})})}function Ku(e){return e.type===`Identifier`?f.some(c.of(e.name)):e.type===`TSQualifiedName`?f.map(Ku(e.left),t=>c.append(t,e.right.name)):f.none()}function qu(e,t,n){return O(e,e=>e.type===`TSTypeReference`&&f.exists(Ku(e.typeName),([r,...i])=>f.exists(I(t,e,r),({defs:e})=>c.some(e,e=>e.type===`ImportBinding`))&&f.fromNullishOr(n.bindings.get(r)).pipe(f.exists(e=>f.contains(c.head([...e,...i]),`Duration`)))))}function Ju(e){return e.type===`VariableDeclarator`&&je(e.parent)&&e.id.type===`Identifier`&&e.init!==null&&f.isSome(ns(e.init))}function Yu(e){let t=D(e);return t.type===`Identifier`?d.map(nt(t,t.name),e=>rt(e).pipe(f.map(({node:e})=>e),f.filter(Ju))):d.succeedNone}const Xu=ie.mapInput(ie.Number,([e])=>e),Zu=r.define({name:`prefer-effect-duration-constants`,meta:B({type:`suggestion`,description:`Prefer Effect Duration values over plain-number duration constants.`,messages:{durationConstant:`{{name}} holds a duration as a plain number. Declare it as {{replacement}} and convert at non-Effect boundaries with Duration.toMillis or Duration.toSeconds.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*z,r=yield*p.make(re.empty());function a(t,r){if(t.id.typeAnnotation&&qu(t.id.typeAnnotation,e.sourceCode,n))return f.none();let i=Gu(t.id.name),a=f.liftPredicate(i,Wu);if(r)return f.some(f.orElseSome(a,()=>`millis`));if(i===`excluded`||f.getOrElse(ns(t.init),()=>0)<=0)return f.none();if(f.isSome(a))return f.some(a);let o=ss(t.init);return f.exists(o,({millis:e})=>e)?f.some(f.some(`millis`)):i===`unknown`||f.isSome(o)?f.some(f.none()):f.none()}function o([,[n,r]]){return f.match(a(n,r),{onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n.id,messageId:`durationConstant`,data:{name:n.id.name,replacement:f.zipWith(ns(n.init),r,hs).pipe(f.getOrElse(()=>`a Duration constructor such as Duration.seconds`))}}))})}return s.merge(s.on(`VariableDeclarator`,e=>n.hasEffectImport&&Ju(e)?p.update(r,t=>re.has(t,_.get(e.range,0))?t:re.set(t,_.get(e.range,0),[e,!1])):d.void),s.on(`CallExpression`,e=>$o(e,n).pipe(d.flatMap(f.match({onNone:()=>d.succeedNone,onSome:Yu})),d.flatMap(f.match({onNone:()=>d.void,onSome:e=>p.update(r,t=>re.set(t,_.get(e.range,0),[e,!0]))})))),s.onExit(`Program`,()=>d.flatMap(p.get(r),e=>d.forEach(c.sort(re.toEntries(e),Xu),o,{concurrency:1,discard:!0}))))}}),Qu=m.is(bn),$u=m.is(fn),ed=m.is(gn),td=m.is(vn),nd=m.is(me);function rd(e,t){return t.member(e,`Schema`)}function id(e,t){if(e.type===`SpreadElement`)return!1;let n=D(e);return n.type===`CallExpression`?f.exists(rd(n.callee,t),ed):f.exists(rd(n,t),$u)}function ad(e,t){let n=D(e);if(n.type!==`CallExpression`)return f.exists(rd(n,t),Qu);let r=n.callee;return f.exists(rd(r,t),$u)?f.exists(E(n,0),e=>ad(e,t)):r.type!==`MemberExpression`||r.object.type===`Super`||!ad(r.object,t)?!1:f.exists(S(r),e=>e===`pipe`?c.every(n.arguments,e=>id(e,t)):td(e))}function od(e){let t=e?.typeAnnotation;return t?.type===`TSNumberKeyword`||t?.type===`TSUnionType`&&c.some(t.types,e=>e.type===`TSNumberKeyword`)&&c.every(t.types,e=>nd(e.type))}function sd(e){return f.contains(ds(e),`duration`)}function cd(e){return e.computed?e.key.type===`Literal`&&h.isString(e.key.value)?f.some(e.key.value):f.none():e.key.type===`Identifier`?f.some(e.key.name):f.none()}const ld=m.is(xt);function ud(e){return y.hasProperty(e,`declare`)&&e.declare}function dd(e,t){return f.isSome(Pe(e,ud))||f.exists(Fe(e),n=>Ai(n,t)&&c.some(n.params,t=>Le(t,e)))}function fd(e){let t=e.type===`TSParameterProperty`?e.parameter:e;if(t.type===`Identifier`)return od(t.typeAnnotation)?f.some(t):f.none();if(t.type!==`AssignmentPattern`||t.left.type!==`Identifier`)return f.none();let n=D(t.right);return od(t.left.typeAnnotation)||!t.left.typeAnnotation&&n.type===`Literal`&&y.isNumber(n.value)?f.some(t.left):f.none()}const pd=r.define({name:`prefer-effect-duration-types`,meta:B({type:`suggestion`,description:`Prefer Duration types over plain numbers for millisecond parameters and fields.`,messages:{durationType:`{{name}} holds a duration as a number of milliseconds. Type it as Duration.Input (or Duration.Duration) and convert with Duration.toMillis only where a non-Effect API needs milliseconds.`,durationSchema:`{{name}} decodes a duration as a plain number. Use Schema.DurationFromMillis to keep milliseconds in the encoded data, or Schema.Duration.`},url:`https://www.effect.website/docs/v4/api/effect/Duration`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r=ld(e.filename);function a(n,r,i){return e.report(t.fromId({node:n,messageId:i,data:{name:r}}))}function o(e){return r||!e.body||Ai(e,n)||dd(e,n)?d.void:d.forEach(c.filter(c.getSomes(c.map(e.params,fd)),({name:e})=>sd(e)),e=>a(e,e.name,`durationType`),{concurrency:1,discard:!0})}function l(e){return cd(e).pipe(f.filter(t=>sd(t)&&od(e.typeAnnotation)&&!r&&!dd(e,n)),f.match({onNone:()=>d.void,onSome:t=>a(e.key,t,`durationType`)}))}return s.merge(s.on(`ArrowFunctionExpression`,o),s.on(`FunctionDeclaration`,o),s.on(`FunctionExpression`,o),s.on(`PropertyDefinition`,l),s.on(`TSPropertySignature`,l),s.on(`Property`,e=>e.parent.type===`ObjectExpression`?w(e).pipe(f.filter(t=>sd(t)&&ad(e.value,n)),f.match({onNone:()=>d.void,onSome:t=>a(e.key,t,`durationSchema`)})):d.void))}}),md=m.is(yi),hd={base64:`Base64`,base64url:`Base64Url`,hex:`Hex`};function gd(e,t){return f.flatMap(E(e,t),e=>M(e)&&md(e.value)?f.some(e.value):f.none())}function _d(e){return E(e,1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(T(`alphabet`)),f.exists(({value:e})=>N(e,`base64url`)))}function vd(e){return e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`toString`)?f.map(gd(e,0),e=>({messageId:`encode`,native:`toString('${e}')`,replacement:`${hd[e]}.encode`})):f.flatMap(C(e.callee),t=>{let n=c.join(t,`.`);return n===`Buffer.from`?f.map(gd(e,1),e=>({messageId:`decode`,native:`Buffer.from(…, '${e}')`,replacement:`${hd[e]}.decode`})):n===`Uint8Array.fromHex`?f.some({messageId:`decode`,native:n,replacement:`Hex.decode`}):n===`Uint8Array.fromBase64`?f.some({messageId:`decode`,native:n,replacement:_d(e)?`Base64Url.decode`:`Base64.decode`}):f.none()})}const yd={atob:{messageId:`atob`,native:`atob`,replacement:`Base64.decode`},btoa:{messageId:`btoa`,native:`btoa`,replacement:`Base64.encode`}},bd=m.is(pi),xd=r.define({name:`prefer-effect-encoding`,meta:B({type:`suggestion`,description:`Prefer the Effect v4 Base64, Base64Url, and Hex modules over native binary encoding APIs.`,messages:{atob:`Use Base64.decode from effect/encoding instead of atob: it returns the bytes as a Uint8Array in a Result with an EncodingError, where atob returns a binary string and throws on invalid input. Use Base64.decodeString only for UTF-8 text.`,btoa:`Use Base64.encode from effect/encoding instead of btoa, and pass it the bytes rather than a binary string: btoa throws on characters above U+00FF, and Base64.encode encodes strings as UTF-8.`,decode:`Use {{replacement}} from effect/encoding instead of {{native}}: it returns a Result with an EncodingError instead of throwing on invalid input.`,encode:`Use {{replacement}} from effect/encoding instead of {{native}}: it accepts bytes or UTF-8 text and runs the same in Node.js, browsers, and Workers.`},url:`https://effect.website/docs/v4/api/effect/encoding/Base64`}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};function n(e){let t=e.callee.type===`MemberExpression`&&f.exists(C(e.callee),e=>e.length===2&&f.contains(c.head(e),`globalThis`))?e.callee.object:e.callee,n=C(e.callee).pipe(f.map(c.lastNonEmpty),f.filter(bd));return f.match(n,{onNone:()=>d.succeedNone,onSome:n=>d.map(it(t,t===e.callee?n:`globalThis`),t=>t&&c.isReadonlyArrayNonEmpty(e.arguments)?f.some(yd[n]):f.none())})}return s.on(`CallExpression`,r=>d.flatMap(n(r),n=>n.pipe(f.orElse(()=>vd(r)),f.match({onNone:()=>d.void,onSome:({messageId:n,native:i,replacement:a})=>e.report(t.fromId({node:r,messageId:n,data:{native:i,replacement:a}}))}))))}}),Sd=m.is(Ke),Cd=r.define({name:`prefer-effect-filesystem`,meta:B({type:`suggestion`,description:`Prefer the Effect FileSystem service over direct Node.js filesystem imports in Effect projects.`,messages:{effectFileSystem:`Use the FileSystem service from effect/FileSystem instead of {{source}}.`},url:`https://www.effect.website/docs/v4/api/effect/FileSystem`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.on(`ImportDeclaration`,({source:n})=>Sd(n.value)?e.report(t.fromId({node:n,messageId:`effectFileSystem`,data:{source:n.value}})):d.void):{}}});function wd(e,t,n,r){return e.type===`CallExpression`&&r.isApi(e.callee,`Result`,t)&&f.exists(E(e,0),e=>e.type===`Identifier`&&e.name===n)}const Td=r.define({name:`prefer-effect-filter`,meta:B({type:`suggestion`,description:`Prefer Effect Filter constructors for reusable Result-valued predicates.`,messages:{effectFilter:`Use Filter.fromPredicate for this Result-valued predicate so it composes as a Filter.`},url:`https://www.effect.website/docs/v4/api/effect/Filter`}),*create(){let e=yield*i,n=yield*z;function r(r){return f.exists(Me(r),({name:e})=>f.exists(U(r),t=>t.type===`ConditionalExpression`&&wd(t.consequent,`succeed`,e,n)&&wd(t.alternate,`fail`,e,n)))?e.report(t.fromId({node:r,messageId:`effectFilter`})):d.void}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionExpression`,r))}}),Ed={module:`Yaml`,members:[`load`,`parse`,`parseAllDocuments`,`parseDocument`]},Dd={module:`Toml`,members:[`parse`]},q={module:`Csv`,members:`all`},Od={"@fast-csv/format":q,"@fast-csv/parse":q,"@iarna/toml":Dd,"@streamparser/json":{module:`JsonArray`,members:`all`},"@xmldom/xmldom":{module:`Xml`,members:[`DOMParser`]},"comment-json":{module:`Jsonc`,members:[`parse`]},"csv-parse":q,"csv-parse/sync":q,"csv-parser":q,"csv-stringify":q,"csv-stringify/sync":q,"fast-csv":q,"fast-xml-parser":{module:`Xml`,members:[`XMLParser`]},ini:{module:`Ini`,members:[`decode`,`parse`]},"js-yaml":Ed,json5:{module:`Json5`,members:[`parse`]},"jsonc-parser":{module:`Jsonc`,members:[`parse`]},ndjson:{module:`Ndjson`,members:`all`},papaparse:q,sax:{module:`Xml`,members:`all`},"smol-toml":Dd,"stream-json":{module:`JsonArray`,members:`all`},"strip-json-comments":{module:`Jsonc`,members:`all`},toml:Dd,xml2js:{module:`Xml`,members:[`Parser`,`parseString`,`parseStringPromise`]},yaml:Ed};function kd(e,t){return e.members===`all`||c.contains(e.members,t)}const Ad=r.define({name:`prefer-effect-format-parser`,meta:B({type:`suggestion`,description:`Prefer the effect/encoding modules over third-party YAML, TOML, INI, JSON5, JSONC, CSV, NDJSON, JSON array and XML parsers in Effect files.`,messages:{effectFormat:`Use {{module}} from effect/encoding instead of {{api}}.`},url:`https://www.effect.website/docs/v4/api/effect/encoding`}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};function n(n,r,i){return e.report(t.fromId({node:n,messageId:`effectFormat`,data:{module:r.module,api:i}}))}function r(t,r,i){let a=c.flatMap(e.sourceCode.getDeclaredVariables(t),({references:e})=>c.getSomes(c.map(e,({identifier:e})=>A(e).pipe(f.filter(t=>t.type===`MemberExpression`&&t.object===e),f.flatMap(e=>S(e).pipe(f.filter(e=>kd(r,e)),f.map(t=>[e,`${i} ${t}`])))))));return d.forEach(a,([e,t])=>n(e,r,t),{concurrency:1,discard:!0})}function a(e,t,i){let a=e.source.value;if(t.type===`ImportSpecifier`){let r=Se(t.imported);return!qi(e,t)&&kd(i,r)?n(t,i,`${a} ${r}`):d.void}return i.members===`all`?n(t,i,a):r(t,i,a)}return s.on(`ImportDeclaration`,e=>f.match(l.get(Od,e.source.value),{onNone:()=>d.void,onSome:t=>qi(e)?d.void:d.forEach(e.specifiers,n=>a(e,n,t),{concurrency:1,discard:!0})}))}}),jd=r.define({name:`prefer-effect-headers`,meta:B({type:`suggestion`,description:`Prefer immutable Effect Headers values in Effect projects.`,messages:{effectHeaders:`Use Headers.fromInput to construct normalized, immutable Effect headers.`},url:`https://www.effect.website/docs/v4/api/effect/unstable/http/Headers`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`effectHeaders`})),it(n.callee,`Headers`))):{}}});function Md(e){return f.exists(f.all(e),e=>c.every(e,ae.isHttpMethod)&&new Set(e).size>=6)}const Nd=r.define({name:`prefer-effect-http-method`,meta:B({type:`suggestion`,description:`Prefer the Effect HttpMethod type and guards over hand-written lists of HTTP methods.`,messages:{methodList:`Use HttpMethod.HttpMethod, HttpMethod.all or HttpMethod.isHttpMethod instead of listing HTTP methods by hand. HttpMethod also includes TRACE and QUERY.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpMethod`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.merge(s.on(`ArrayExpression`,n=>Md(c.map(n.elements,e=>y.isNotNull(e)&&M(e)?f.some(e.value):f.none()))?e.report(t.fromId({node:n,messageId:`methodList`})):d.void),s.on(`TSUnionType`,n=>Md(c.map(n.types,e=>e.type===`TSLiteralType`&&M(e.literal)?f.some(e.literal.value):f.none()))?e.report(t.fromId({node:n,messageId:`methodList`})):d.void)):{}}}),Pd=new Map(c.map(l.keys({Continue:!0,SwitchingProtocols:!0,Processing:!0,EarlyHints:!0,OK:!0,Created:!0,Accepted:!0,NonAuthoritativeInformation:!0,NoContent:!0,ResetContent:!0,PartialContent:!0,MultiStatus:!0,AlreadyReported:!0,ImUsed:!0,MultipleChoices:!0,MovedPermanently:!0,Found:!0,SeeOther:!0,NotModified:!0,TemporaryRedirect:!0,PermanentRedirect:!0,BadRequest:!0,Unauthorized:!0,PaymentRequired:!0,Forbidden:!0,NotFound:!0,MethodNotAllowed:!0,NotAcceptable:!0,ProxyAuthenticationRequired:!0,RequestTimeout:!0,Conflict:!0,Gone:!0,LengthRequired:!0,PreconditionFailed:!0,PayloadTooLarge:!0,UriTooLong:!0,UnsupportedMediaType:!0,RangeNotSatisfiable:!0,ExpectationFailed:!0,ImATeapot:!0,MisdirectedRequest:!0,UnprocessableEntity:!0,Locked:!0,FailedDependency:!0,TooEarly:!0,UpgradeRequired:!0,PreconditionRequired:!0,TooManyRequests:!0,RequestHeaderFieldsTooLarge:!0,UnavailableForLegalReasons:!0,InternalServerError:!0,NotImplemented:!0,BadGateway:!0,ServiceUnavailable:!0,GatewayTimeout:!0,HttpVersionNotSupported:!0,VariantAlsoNegotiates:!0,InsufficientStorage:!0,LoopDetected:!0,NotExtended:!0,NetworkAuthenticationRequired:!0}),e=>_.make(oe.fromLiteral(e),e)));function Fd(e,t){return t.isApi(e.callee,`HttpApiSchema`,`status`)?E(e,0).pipe(f.toArray,c.map(e=>_.make(e,`statusName`))):t.isApi(e.callee,`HttpApiSchema`,`Empty`)?E(e,0).pipe(f.toArray,c.map(e=>_.make(e,`httpStatus`))):t.isApi(e.callee,`HttpServerResponse`,`setStatus`)?c.map(c.getSomes([E(e,0),E(e,1)]),e=>_.make(e,`httpStatus`)):f.flatMap(t.member(e.callee,`HttpServerResponse`),t=>E(e,t===`empty`?0:1).pipe(f.filter(e=>e.type===`ObjectExpression`),f.flatMap(T(`status`)))).pipe(f.toArray,c.map(({value:e})=>_.make(e,`httpStatus`)))}const Id=r.define({name:`prefer-effect-http-status`,meta:B({type:`suggestion`,description:`Prefer named HttpStatus literals over status code numbers passed to Effect HTTP APIs.`,messages:{statusName:`Pass the status name: HttpApiSchema.status('{{literal}}') instead of {{code}}.`,httpStatus:`Name the status: use HttpStatus.fromLiteral('{{literal}}') instead of {{code}}.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpStatus`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r(n,r){let i=D(n),a=i.type===`Literal`&&y.isNumber(i.value)?f.fromNullishOr(Pd.get(i.value)):f.none();return f.match(a,{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:i,messageId:r,data:{code:e.sourceCode.getText(i),literal:n}}))})}return s.merge(s.on(`ObjectExpression`,e=>d.forEach(c.filter(c.getSomes(c.map(e.properties,we)),e=>f.contains(w(e),`httpApiStatus`)),e=>r(e.value,`httpStatus`),{concurrency:1,discard:!0})),s.on(`CallExpression`,e=>d.forEach(Fd(e,n),([e,t])=>r(e,t),{concurrency:1,discard:!0})))}}),Ld=m.is(Ye),Rd=m.is(bi);function zd(e){return N(e,`.`)}function Bd(e){return f.exists(j(e,`VariableDeclarator`),({id:e})=>e.type===`ArrayPattern`&&c.some(e.elements,e=>e?.type===`Identifier`&&Rd(e.name)))}const Vd=r.define({name:`prefer-effect-jwt`,meta:B({type:`suggestion`,description:`Prefer Effect Jwt over JWT libraries and tokens split and decoded by hand in Effect projects.`,messages:{jwtLibrary:`Use Jwt from effect/jose instead of {{source}}: it decodes the claims with a Schema and fails with a typed JwtError.`,manualJwt:`Do not split a JWT on '.' by hand. Use Jwt.verify or Jwt.verifyWithKeySet from effect/jose, which check the signature, exp and nbf before decoding the claims with a Schema, and Jwt.decodeUnverified only to choose a key.`},url:`https://effect.website/docs/v4/api/effect/jose/Jwt`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r(e){return n.isApi(e.callee,`String`,`split`)?f.exists(E(e,1),zd)?E(e,0):f.none():e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`split`)&&f.exists(E(e,0),zd)?f.some(e.callee.object):f.none()}return s.merge(s.on(`ImportDeclaration`,({source:n})=>Ld(n.value)?e.report(t.fromId({node:n,messageId:`jwtLibrary`,data:{source:n.value}})):d.void),s.on(`CallExpression`,n=>f.exists(r(n),e=>f.exists(C(e),e=>/jwt|token/iu.test(c.lastNonEmpty(e)))||Bd(n))?e.report(t.fromId({node:n,messageId:`manualJwt`})):d.void))}});function Hd(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&c.isReadonlyArrayEmpty(e.expressions)}function Ud(e,t){return e.type!==`BinaryExpression`||!be(e.operator)?f.none():Hd(e.left)?f.some(t.getText(e.right)):Hd(e.right)?f.some(t.getText(e.left)):f.none()}function Wd(e){return e?.type===`ConditionalExpression`||e?.type===`IfStatement`}function Gd(e,t,n){return f.contains(Ud(e.test,n),t)?Wd(e.alternate)?f.map(Gd(e.alternate,t,n),ne.increment):f.some(1):f.none()}function Kd(e,t){return Ud(e.test,t).pipe(f.flatMap(n=>Gd(e,n,t)),f.exists(e=>e>1))}const qd=r.define({name:`prefer-effect-match`,meta:B({type:`suggestion`,description:`Prefer Effect Match for composable and exhaustive branching in Effect projects.`,messages:{effectMatch:`Use Match.type, Match.value, or Match.tags with Match.exhaustive instead of switch.`,preferMatch:`Use Match from Effect instead of a chained literal ternary.`,ifChain:"Use Match.type, Match.value, or Match.discriminators with Match.exhaustive instead of an `else if` chain comparing the same value against literals."},url:`https://www.effect.website/docs/v4/api/effect/Match`}),*create(){let e=yield*i,n=yield*z,r=s.on(`ConditionalExpression`,n=>n.parent.type!==`ConditionalExpression`&&Kd(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`preferMatch`})):d.void);return n.hasEffectImport?s.merge(r,s.on(`SwitchStatement`,n=>e.report(t.fromId({node:n,messageId:`effectMatch`}))),s.on(`IfStatement`,n=>(n.parent.type!==`IfStatement`||n.parent.alternate!==n)&&Kd(n,e.sourceCode)?e.report(t.fromId({node:n,messageId:`ifChain`})):d.void)):r}}),Jd=m.is(Nt),Yd={"<":`>`,"<=":`>=`,">":`<`,">=":`<=`};function Xd(e){return e.type===`PrivateIdentifier`?e:D(e)}function Zd(e){let t=Xd(e);return t.type===`MemberExpression`&&f.exists(S(t),Jd)}function Qd(e){let t=Xd(e);return t.type===`Literal`&&y.isNumber(t.value)?f.some(t.value):f.none()}function $d(e,t){let n=Xd(e);if(n.type!==`BinaryExpression`||!(n.operator in Yd))return f.none();let[r,i,a]=Zd(n.left)?[n.left,n.right,n.operator]:[n.right,n.left,Yd[n.operator]??n.operator];return Zd(r)?f.flatMap(Qd(i),e=>{let n=t(r);return e===200&&a===`>=`||e===199&&a===`>`?f.some({bound:`lower`,inRange:!0,status:n}):e===200&&a===`<`||e===199&&a===`<=`?f.some({bound:`lower`,inRange:!1,status:n}):e===300&&a===`<`||e===299&&a===`<=`?f.some({bound:`upper`,inRange:!0,status:n}):e===300&&a===`>=`||e===299&&a===`>`?f.some({bound:`upper`,inRange:!1,status:n}):f.none()}):f.none()}const ef=r.define({name:`prefer-effect-match-status`,meta:B({type:`suggestion`,description:`Prefer HttpClientResponse.filterStatusOk or matchStatus over hand-written 2xx status range checks.`,messages:{matchStatus:`Use HttpClientResponse.filterStatusOk, or HttpClientResponse.matchStatus with a '2xx' case, instead of checking the 2xx range by hand. On a native fetch Response, read response.ok.`},url:`https://www.effect.website/docs/v4/api/effect/http/HttpClientResponse`}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};function n(t){return e.sourceCode.getText(t)}return s.on(`LogicalExpression`,r=>{let i=r.operator===`&&`;return r.operator!==`??`&&f.exists(f.all([$d(r.left,n),$d(r.right,n)]),([e,t])=>e.status===t.status&&e.bound!==t.bound&&e.inRange===i&&t.inRange===i)?e.report(t.fromId({node:r,messageId:`matchStatus`})):d.void})}}),tf=r.define({name:`prefer-effect-ndjson`,meta:B({type:`suggestion`,description:`Prefer Effect Ndjson over splitting lines and parsing or stringifying each one as JSON.`,messages:{decode:`Use Ndjson.decodeString or Ndjson.decodeSchemaString from effect/encoding instead of JSON.parse on each line: it handles CRLF, blank lines and lines split across chunks, and fails with an NdjsonError.`,encode:`Use Ndjson.encodeString or Ndjson.encodeSchemaString from effect/encoding instead of joining JSON.stringify results with line breaks.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Ndjson`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r={imports:n,sourceCode:e.sourceCode},a={mapper:t=>_u(t,`stringify`,e.sourceCode),element:t=>t.type===`CallExpression`&&_u(t.callee,`stringify`,e.sourceCode)};function o(t){return _u(t.callee,`parse`,e.sourceCode)&&f.exists(E(t,0),e=>Mu(e,r))}function c(e){return f.exists(gu(e,du,n),t=>Pu(Fu(e,t,n),a,r))}return s.merge(s.on(`CallExpression`,n=>o(n)?e.report(t.fromId({node:n,messageId:`decode`})):c(n)?e.report(t.fromId({node:n,messageId:`encode`})):d.void),s.on(`MemberExpression`,n=>_u(n,`parse`,e.sourceCode)&&ku(n,r)?e.report(t.fromId({node:n,messageId:`decode`})):d.void))}}),nf=m.is(Xe),rf=m.is(xi),af=[`net`,`node:net`],of=m.is(Si),sf=/^(?:(?:0|10|127|169\.254|192\.168|172\.(?:1[6-9]|2\d|3[01])|100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7]))\.|fe80:|::ffff:)$/iu,cf=[/(?:(?:\\d|\[0-9\])(?:\+|\{1,3\})\\\.){3}/u,/\((?:\?:)?(?:\\d|\[0-9\])(?:\+|\{1,3\})\\\.\)\{3\}/u,/^(?=[\s\S]*25\[0-5\])(?=[\s\S]*\\\.)/u,/^\^(?:\(\?:)?(?:0|10|100|127|169\\\.254|172|192\\\.168)(?:\|(?:0|10|100|127|169\\\.254|172|192\\\.168))*\)?\\\./u,/^\^\(?(?:\?:)?(?:fe80|fe\[89ab\]|f\[cd\]|fc\|fd|fd\|fc)/iu,/::ffff:/iu];function lf(e){return f.match(A(e),{onNone:()=>e,onSome:t=>t.type===`Program`?e:lf(t)})}const uf=r.define({name:`prefer-effect-net-address`,meta:B({type:`suggestion`,description:`Prefer Effect NetAddress over IP addresses parsed and classified by hand in Effect projects.`,messages:{ipText:`Parse the address with NetAddress.ipFromString and classify it with NetAddress.isLoopback, isPrivate, isLinkLocal, isUniqueLocal, isUnspecified or isIpv4Mapped, or IpNetwork.contains, instead of matching IP text by hand.`,nodeIpCheck:`Use NetAddress.ipFromString, ipv4FromString or ipv6FromString from effect/net instead of net.{{name}}: they return a typed address to classify.`,library:`Use NetAddress and IpNetwork from effect/net instead of {{source}}.`},url:`https://effect.website/docs/v4/api/effect/net/NetAddress`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r=yield*p.make(b.empty());function a(n){let[i]=lf(n).range;return d.gen(function*(){let a=yield*p.get(r);b.has(a,i)||(yield*p.update(r,b.add(i)),yield*e.report(t.fromId({node:n,messageId:`ipText`})))})}function o(e){return(e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`startsWith`)||n.isApi(e.callee,`String`,`startsWith`))&&f.exists(E(e,0),e=>M(e)&&sf.test(e.value))}return s.merge(s.on(`ImportDeclaration`,({source:n})=>nf(n.value)?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`CallExpression`,n=>ft(e.sourceCode,n.callee,af).pipe(f.filter(rf),f.match({onNone:()=>o(n)?a(n):d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`nodeIpCheck`,data:{name:r}}))}))),s.on(`Literal`,e=>`regex`in e&&c.some(cf,t=>t.test(e.regex.pattern))?a(e):d.void),s.on(`BinaryExpression`,e=>be(e.operator)&&c.some([e.left,e.right],e=>M(e)&&of(e.value))?a(e):d.void))}}),df={num:`Number`,opt:`Option`,order:`Order`},ff=m.is(At),pf=m.is(jt),mf=/* @__PURE__ */ new Set([`increment`,`decrement`,`order`,`between`]),hf=m.is(St);function J(e){let t=D(e);return t.type===`Literal`?f.liftPredicate(t.value,y.isNumber):t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)?f.map(J(t.argument),e=>t.operator===`-`?-e:e):f.none()}function Y(e){return g.value(D(e)).pipe(g.discriminators(`type`)({Identifier:v.constTrue,Literal:v.constTrue,ThisExpression:v.constTrue,UnaryExpression:({operator:e,argument:t})=>e!==`delete`&&Y(t),BinaryExpression:({left:e,right:t})=>e.type!==`PrivateIdentifier`&&Y(e)&&Y(t),MemberExpression:({object:e,computed:t,property:n})=>Y(e)&&(!t||Y(n))}),g.orElse(v.constFalse))}function gf(e,t,n,r){let i=D(e);return i.type!==`CallExpression`||i.optional||i.arguments.length!==r||i.callee.type!==`MemberExpression`||i.callee.optional||!L(t,i.callee.object,`Math`)||!f.contains(S(i.callee),n)?f.none():f.all(c.map(i.arguments,(e,t)=>E(i,t)))}function _f(e,t,n){return f.flatMap(gf(e,t,n,2),([e,t])=>y.isNotUndefined(e)&&y.isNotUndefined(t)?f.some([e,t]):f.none())}function vf(e){return f.isSome(J(e))||C(D(e)).pipe(f.map(c.lastNonEmpty),f.exists(pf))}function yf(e){return c.every(e,Y)||c.countBy(e,e=>f.isNone(J(e)))<=1}function bf(e,t,n){return f.match(J(e),{onSome:e=>f.contains(J(t),e),onNone:()=>n.getText(D(e))===n.getText(D(t))})}function xf(e,t,n){let[r,i]=e;return r?.type===`Identifier`&&i?.type===`Identifier`&&r.name!==i.name&&t.type===`Identifier`&&n.type===`Identifier`&&(t.name===r.name&&n.name===i.name||t.name===i.name&&n.name===r.name)}function Sf(e,t){let n=D(e);if(n.type!==`CallExpression`||n.optional||n.arguments.length!==2)return f.none();let r=n.callee,i=r.type===`MemberExpression`&&!r.optional&&L(t.scope,r.object,`Math`)?S(r):f.filter(t.imports.member(r,`Number`),()=>R(t.sourceCode,r));return f.all([f.filter(i,ff),E(n,0),E(n,1)]).pipe(f.map(([e,t,n])=>[e,[t,n]]))}function Cf(e,t,n){return f.flatMap(Sf(e,n),([e,n])=>e===t?f.some(n):f.none())}function wf(e,t){let{sourceCode:n}=t;return Sf(e,t).pipe(f.flatMap(([e,[r,i]])=>{let a=e===`min`?`max`:`min`;return Cf(i,a,t).pipe(f.map(e=>[r,e]),f.orElse(()=>f.map(Cf(r,a,t),e=>[i,e])),f.flatMap(([t,[r,i]])=>{let a=vf(r)===vf(i),[o,s]=vf(i)&&!vf(r)?[i,r]:[r,i],[c,l]=e===`min`?[o,t]:[t,o];return f.exists(f.all([J(c),J(l)]),([e,t])=>e>t)?f.none():f.some({kind:`clamp`,mode:e===`max`&&a?`report`:yf([t,r,i])?`fix`:`suggest`,replacement:({num:e})=>`${e}.clamp(${V(n,s)}, { minimum: ${V(n,c)}, maximum: ${V(n,l)} })`})}))}))}function Tf(e,t){let n=D(e);if(n.type===`BinaryExpression`&&n.operator===`**`)return f.contains(J(n.left),10)?f.some(n.right):f.none();let r=f.flatMap(_f(n,t,`pow`),([e,t])=>f.contains(J(e),10)?f.some(t):f.none());return f.orElse(r,()=>J(n).pipe(f.map(Math.log10),f.map(Math.round),f.filter(e=>ne.between(e,{minimum:1,maximum:22})&&f.contains(J(n),10**e))))}function Ef(e,t,n){if(e.operator!==`/`)return f.none();let r=e.right;return gf(e.left,t,`round`,1).pipe(f.flatMap(c.head),f.map(D),f.filter(e=>e.type===`BinaryExpression`&&e.operator===`*`),f.flatMap(({left:e,right:t})=>bf(t,r,n)?f.some([e,t,!1]):bf(e,r,n)?f.some([t,e,!0]):f.none()),f.flatMap(([e,r,i])=>f.map(Tf(r,t),t=>{let r=y.isNumber(t)?String(t):V(n,t);return{kind:`round`,mode:y.isNumber(t)||Y(t)&&(!i||Y(e))?`fix`:`report`,replacement:({num:t})=>`${t}.round(${V(n,e)}, ${r})`}})))}function Df(e,t,n){let r=D(e);if(t.isApi(r,`Number`,`sum`)&&R(n,r))return f.some(`+`);if(t.isApi(r,`Number`,`multiply`)&&R(n,r))return f.some(`*`);if(r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`||r.async||r.generator||r.params.length!==2||y.isNull(r.body))return f.none();let i=r.body;return(i.type===`BlockStatement`?f.flatMap(f.liftPredicate(i.body,e=>e.length===1),e=>f.flatMap(c.head(e),e=>e.type===`ReturnStatement`&&y.isNotNullish(e.argument)?f.some(e.argument):f.none())):f.some(i)).pipe(f.map(D),f.filter(e=>e.type===`BinaryExpression`&&(e.operator===`+`||e.operator===`*`)),f.filter(({left:e,right:t})=>xf(r.params,D(e),D(t))),f.map(({operator:e})=>e===`+`?`+`:`*`))}function Of(e,t,n){return{kind:e,mode:e===`sumAll`?`fix`:`suggest`,replacement:({num:r})=>f.match(t,{onNone:()=>`${r}.${e}`,onSome:t=>`${r}.${e}(${V(n,t)})`})}}function kf(e,t){let n=e===`+`?0:1;return f.exists(J(t),e=>Object.is(e,n))?f.some(e===`+`?`sumAll`:`multiplyAll`):f.none()}function Af(e,t,n){if(t.isApi(e.callee,`Array`,`reduce`)&&R(n,e.callee)){if(e.arguments.length!==2&&e.arguments.length!==3)return f.none();let[r,i,a]=e.arguments.length===3?[E(e,0),E(e,1),E(e,2)]:[f.none(),E(e,0),E(e,1)];return f.all([i,a]).pipe(f.flatMap(([e,r])=>f.flatMap(Df(r,t,n),t=>kf(t,e))),f.filter(()=>e.arguments.length===2||f.isSome(r)),f.map(e=>Of(e,r,n)))}let r=e.callee;return e.optional||e.arguments.length!==2||r.type!==`MemberExpression`||r.optional||r.object.type===`Super`||!f.contains(S(r),`reduce`)||f.isSome(t.path(r))?f.none():f.all([E(e,0),E(e,1)]).pipe(f.flatMap(([e,r])=>f.flatMap(Df(e,t,n),e=>kf(e,r))),f.map(e=>Of(e,f.some(r.object),n)))}function jf(e){return e.type===`Identifier`&&(y.isNullish(e.typeAnnotation)||e.typeAnnotation.typeAnnotation.type===`TSNumberKeyword`)}function Mf(e,t){if(e.type!==`ArrowFunctionExpression`||e.async||y.isNotNullish(e.returnType)||y.isNotNullish(e.typeParameters)||e.params.length!==t||e.body.type===`BlockStatement`)return f.none();let n=c.filter(e.params,jf);return n.length===t?f.some([n,D(e.body)]):f.none()}function Nf(e,t){let n=D(e);return n.type===`Identifier`&&n.name===t}function Pf(e,t){return e.type===`BinaryExpression`?Ff(e,t):e.type===`AssignmentExpression`?If(e,t):e.type===`UpdateExpression`&&e.argument.type===`Identifier`&&e.argument.name===t?f.some([e.operator===`++`?`+`:`-`,e.prefix?`new`:`old`]):f.none()}function Ff(e,t){return e.type!==`BinaryExpression`||e.left.type===`PrivateIdentifier`?f.none():(e.operator===`+`||e.operator===`-`)&&Nf(e.left,t)&&f.contains(J(e.right),1)?f.some([e.operator,`new`]):f.none()}function If(e,t){return(e.operator===`+=`||e.operator===`-=`)&&e.left.type===`Identifier`&&e.left.name===t&&f.contains(J(e.right),1)?f.some([e.operator===`+=`?`+`:`-`,`new`]):f.none()}function Lf(e){return Mf(e,1).pipe(f.flatMap(([[e],t])=>y.isUndefined(e)?f.none():f.map(Pf(t,e.name),n=>[n,e,t])),f.map(([[e,t],n,r])=>{let i=e===`+`?`increment`:`decrement`,a=e===`+`&&r.type!==`UpdateExpression`&&y.isNullish(n.typeAnnotation);return t===`new`?{kind:i,mode:a?`suggest`:`fix`,replacement:({num:e})=>`${e}.${i}`}:{kind:`unchangedStep`,mode:`report`,data:{step:e===`+`?`n++`:`n--`,api:`Num.${i}`},replacement:()=>``}}))}function Rf(e,t){let n=e.callee;return t.imports.isApi(n,`Array`,`sort`)&&R(t.sourceCode,n)?e.arguments.length===1||e.arguments.length===2?E(e,e.arguments.length-1):f.none():!e.optional&&e.arguments.length===1&&n.type===`MemberExpression`&&!n.optional&&f.exists(S(n),e=>e===`sort`||e===`toSorted`)&&f.isNone(t.imports.path(n))?E(e,0):f.none()}function zf(e,t){return Rf(e,t).pipe(f.flatMap(e=>Mf(e,2).pipe(f.flatMap(([[t,n],r])=>y.isUndefined(t)||y.isUndefined(n)||t.name===n.name||r.type!==`BinaryExpression`||r.operator!==`-`?f.none():Nf(r.left,t.name)&&Nf(r.right,n.name)?f.some({kind:`order`,mode:`fix`,target:e,data:{order:`Num.Order`},replacement:({num:e})=>`${e}.Order`}):Nf(r.left,n.name)&&Nf(r.right,t.name)?f.some({kind:`order`,mode:`fix`,target:e,data:{order:`Order.flip(Num.Order)`},extra:[`order`],replacement:({num:e,order:t})=>`${t}.flip(${e}.Order)`}):f.none()))))}function Bf(e,t){let n=D(e);if(n.type!==`BinaryExpression`||n.left.type===`PrivateIdentifier`)return f.none();let{operator:r,left:i,right:a}=n;return r===(t?`<`:`<=`)?f.some({small:i,big:a}):r===(t?`>`:`>=`)?f.some({small:a,big:i}):f.none()}function Vf(e,t,n,r){return r.getText(D(e.small))===t?f.some([n?`lower`:`upper`,e.big]):r.getText(D(e.big))===t?f.some([n?`upper`:`lower`,e.small]):f.none()}function Hf(e,t,n,r,i){let a=i.getText(D(e));return f.zipWith(Vf(t,a,r,i),Vf(n,a,r,i),([t,n],[r,i])=>t===r?f.none():f.some(t===`lower`?[e,n,i]:[e,i,n])).pipe(f.flatten)}function Uf(e){let t=D(e);return t.type===`TemplateLiteral`||t.type===`Literal`&&(y.isString(t.value)||y.isBigInt(t.value))}function Wf(e,t){if(e.operator!==`&&`&&e.operator!==`||`)return f.none();let n=e.operator===`||`;return f.all([Bf(e.left,n),Bf(e.right,n)]).pipe(f.flatMap(([e,r])=>c.findFirst(c.filter([e.small,e.big],e=>f.isNone(J(e))),i=>Hf(i,e,r,n,t))),f.filter(e=>!c.some(e,Uf)),f.filter(([,e,t])=>c.every([e,t],vf)),f.map(([e,r,i])=>({kind:`between`,mode:c.every([e,r,i],Y)?!n&&f.isSome(J(r))?`fix`:`suggest`:`report`,replacement:({num:a})=>`${n?`!`:``}${a}.between(${V(t,e)}, { minimum: ${V(t,r)}, maximum: ${V(t,i)} })`})))}function Gf(e){return f.contains(J(e),0)}function Kf(e){let t=D(e);return t.type!==`BinaryExpression`||t.operator!==`===`&&t.operator!==`!==`?f.none():(Gf(t.right)?f.some(t.left):Gf(t.left)?f.some(t.right):f.none()).pipe(f.filter(e=>f.isNone(J(e))),f.map(e=>[e,t.operator===`!==`]))}function qf(e,t){return Kf(e.test).pipe(f.flatMap(([n,r])=>{let[i,a]=r?[e.alternate,e.consequent]:[e.consequent,e.alternate],o=D(a);if(o.type!==`BinaryExpression`||o.operator!==`/`||t.getText(D(o.right))!==t.getText(D(n)))return f.none();let s=o.left,c=D(i).type===`ObjectExpression`?`(${t.getText(i)})`:V(t,i);return f.some({kind:`divide`,mode:Y(s)&&Y(n)&&!O(i,e=>e.type===`AwaitExpression`||e.type===`YieldExpression`)?`fix`:`report`,extra:[`opt`],replacement:({num:e,opt:r})=>`${r}.getOrElse(${e}.divide(${V(t,s)}, ${V(t,n)}), () => ${c})`})}))}function Jf(e,t){let n=e.callee;return e.optional||e.arguments.length!==1||!f.exists(c.head(e.arguments),e=>e.type===`SpreadElement`)||n.type!==`MemberExpression`||n.optional||!L(t.scope,n.object,`Math`)?f.none():S(n).pipe(f.filter(ff),f.map(e=>({kind:`extreme`,mode:`report`,data:{api:`Arr.${e}`,math:`Math.${e}`,empty:e===`max`?`-Infinity`:`Infinity`},replacement:()=>``})))}function Yf(e,t){let n=e.type===`CallExpression`?e:f.getOrNull(f.none());if(y.isNull(n)||n.optional||n.arguments.length!==1||n.callee.type!==`Identifier`)return f.none();let{name:r}=n.callee;return f.liftPredicate(r,e=>(e===`Number`||e===`parseFloat`)&&L(t.getScope(n),n.callee,e))}function Xf(e,t){let n=e.callee;return!e.optional&&e.arguments.length===1&&(L(t.scope,n,`isNaN`)||n.type===`MemberExpression`&&!n.optional&&L(t.scope,n.object,`Number`)&&f.contains(S(n),`isNaN`))?E(e,0).pipe(f.map(D),f.flatMap(e=>e.type===`Identifier`?rt(I(t.sourceCode,e,e.name)).pipe(f.flatMap(({node:e})=>e.type===`VariableDeclarator`&&y.isNotNullish(e.init)&&je(e.parent)?f.some(D(e.init)):f.none())):f.some(e))).pipe(f.flatMap(e=>Yf(e,t.sourceCode)),f.map(e=>({kind:`parse`,mode:`report`,data:{conversion:`${e}(…)`},replacement:()=>``}))):f.none()}const Zf=r.define({name:`prefer-effect-number`,meta:B({type:`suggestion`,description:`Prefer Effect Number helpers over hand-written clamping, rounding, ranges, sums, products, comparators and parsing in Effect files.`,messages:{clamp:`Use Number.clamp from Effect instead of nesting min and max.`,round:`Use Number.round from Effect instead of scaling Math.round by a power of ten.`,sumAll:`Use Number.sumAll from Effect instead of summing with reduce.`,multiplyAll:`Use Number.multiplyAll from Effect instead of multiplying with reduce. It returns 0 at the first 0, even when NaN or Infinity follows.`,increment:`Use Number.increment from Effect instead of (n) => n + 1.`,decrement:`Use Number.decrement from Effect instead of (n) => n - 1.`,unchangedStep:`This callback returns n unchanged, because {{step}} returns the value before the update. Use {{api}} to return the next value.`,order:`Use {{order}} from Effect instead of a comparator that subtracts. It sorts the same, except NaN.`,between:`Use Number.between from Effect instead of comparing with both bounds.`,divide:`Use Number.divide from Effect, which returns none for a zero divisor, instead of checking for 0 first.`,extreme:`Use {{api}} with Number.Order instead of {{math}} over a spread. It needs a non-empty array, where {{math}} of an empty array is {{empty}}, and it skips NaN.`,parse:`Use Number.parse from Effect, which returns an Option, instead of {{conversion}} with a NaN check. Number.parse returns none for '' and '12px'.`,replace:`Replace with Number.{{api}}.`},url:`https://www.effect.website/docs/v4/api/effect/Number`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};let r=hf(e.filename),a=d.fnUntraced(function*(n,i){let{kind:a}=i,o=!r&&i.mode===`fix`&&mf.has(a)?`suggest`:i.mode,s=i.target??n,u=t.fromId({node:s,messageId:a,data:i.data??{}});if(o===`report`||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(s)))return yield*e.report(u);let p=yield*d.forEach([`num`,...i.extra??[]],e=>d.map(Yn(s,`effect/${df[e]}`,Ji(df[e])),t=>[e,t]),{concurrency:1}),m=l.map(df,(e,t)=>f.match(c.findFirst(p,([e])=>e===t),{onNone:()=>Ji(e),onSome:([,e])=>e.name})),h=t.composeFixes(...c.flatMap(p,([,e])=>f.toArray(e.fix)),t.replaceText(s,i.replacement(m)));return yield*e.report(o===`fix`?t.withFix(u,h):t.withSuggestions(u,[{messageId:`replace`,data:{api:a},fix:h}]))});function u(e,t){return f.match(t,{onNone:()=>d.void,onSome:t=>a(e,t)})}function p(t){return d.map(o.getScope(t),t=>({sourceCode:e.sourceCode,imports:n,scope:t}))}return s.merge(s.on(`CallExpression`,t=>d.flatMap(p(t),r=>u(t,wf(t,r).pipe(f.orElse(()=>Af(t,n,e.sourceCode)),f.orElse(()=>zf(t,r)),f.orElse(()=>Jf(t,r)),f.orElse(()=>Xf(t,r)))))),s.on(`BinaryExpression`,t=>d.flatMap(o.getScope(t),n=>u(t,Ef(t,n,e.sourceCode)))),s.on(`ArrowFunctionExpression`,e=>u(e,Lf(e))),s.on(`LogicalExpression`,t=>u(t,Wf(t,e.sourceCode))),s.on(`ConditionalExpression`,t=>u(t,qf(t,e.sourceCode))))}}),Qf=m.is(Je),$f=r.define({name:`prefer-effect-path`,meta:B({type:`suggestion`,description:`Prefer the Effect Path service over direct Node.js path imports in Effect projects.`,messages:{effectPath:`Use the Path service from effect/Path instead of {{source}}.`},url:`https://www.effect.website/docs/v4/api/effect/Path`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.on(`ImportDeclaration`,({source:n})=>Qf(n.value)?e.report(t.fromId({node:n,messageId:`effectPath`,data:{source:n.value}})):d.void):{}}}),ep={Arr:`effect/Array`,P:`effect/Predicate`},tp={bigint:`isBigInt`,boolean:`isBoolean`,function:`isFunction`,number:`isNumber`,object:`isObjectOrArray`,string:`isString`,symbol:`isSymbol`,undefined:`isUndefined`},np={"!=":`isNotNullish`,"!==":`isNotNull`,"==":`isNullish`,"===":`isNull`},rp={"!=":`isNotNullish`,"!==":`isNotUndefined`,"==":`isNullish`,"===":`isUndefined`},ip={Array:[`Arr`,`isArray`,`similar`],BigInt:[`P`,`isBigInt`,`different`],Boolean:[`P`,`isBoolean`,`different`],Date:[`P`,`isDate`,`exact`],Error:[`P`,`isError`,`exact`],Function:[`P`,`isFunction`,`similar`],Map:[`P`,`isMap`,`similar`],Number:[`P`,`isNumber`,`different`],Promise:[`P`,`isPromise`,`similar`],RegExp:[`P`,`isRegExp`,`exact`],Set:[`P`,`isSet`,`similar`],String:[`P`,`isString`,`different`],Symbol:[`P`,`isSymbol`,`different`],Uint8Array:[`P`,`isUint8Array`,`exact`]},ap=m.is(ge);function op(e){return e.type===`ArrowFunctionExpression`||e.type===`FunctionDeclaration`||e.type===`FunctionExpression`}function sp(e,t,n,r){return(n.type===`Literal`&&y.isNull(n.value)?f.some(np):f.liftPredicate(rp,()=>L(r,n,`undefined`))).pipe(f.flatMap(l.get(e.operator)),f.map(e=>({namespace:`P`,member:e,subject:t,negated:!1,equivalence:`exact`})))}function cp(e,t,n,r){if(t.type!==`UnaryExpression`||t.operator!==`typeof`||!M(n))return f.none();let i=D(t.argument);return i.type===`Identifier`&&L(r,i,i.name)?f.none():f.map(l.get(tp,n.value),r=>{let i=n.value===`undefined`&&ap(e.operator);return{namespace:`P`,member:i?`isNotUndefined`:r,subject:t.argument,negated:ap(e.operator)&&!i,equivalence:n.value===`object`?`similar`:`exact`}})}function lp(e,t){if(!be(e.operator))return f.none();let n=D(e.left),r=D(e.right);return cp(e,n,r,t).pipe(f.orElse(()=>cp(e,r,n,t)),f.orElse(()=>sp(e,e.left,r,t)),f.orElse(()=>sp(e,e.right,n,t)))}function up(e,t){let n=D(e.right);return n.type===`Identifier`&&L(t,n,n.name)?f.map(l.get(ip,n.name),([t,n,r])=>({namespace:t,member:n,subject:e.left,negated:!1,equivalence:r})):f.none()}function dp(e){return f.exists(Pe(e,op),e=>e.returnType?.typeAnnotation.type===`TSTypePredicate`)}const fp=r.define({name:`prefer-effect-predicate`,meta:B({type:`suggestion`,description:`Prefer Effect Predicate guards over typeof, instanceof, and nullish comparisons in Effect files.`,messages:{predicate:`Use {{predicate}} from Effect instead of this check. Decode unknown input with Schema.is or a Schema decoder instead of narrowing it by hand.`,objectPredicate:`Use {{predicate}} from Effect instead of this check. Unlike typeof x === 'object', it treats null as not an object.`,boxedInstance:"`instanceof {{constructor}}` only matches boxed objects such as `new {{constructor}}(…)`, never primitive values. To check for the primitive, use {{predicate}}.",replace:`Replace with {{predicate}}.`},url:`https://www.effect.website/docs/v4/api/effect/Predicate`,fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};let n=d.fnUntraced(function*(n,r){let{namespace:i,member:a,negated:o,equivalence:s}=r,l=o?`!`:``,u=`${l}${i}.${a}`,d=t.fromId(s===`different`?{node:n,messageId:`boxedInstance`,data:{constructor:e.sourceCode.getText(n.right),predicate:u}}:{node:n,messageId:a===`isObjectOrArray`?`objectPredicate`:`predicate`,data:{predicate:u}});if(s===`different`||c.isReadonlyArrayNonEmpty(e.sourceCode.getCommentsInside(n)))return yield*e.report(d);let f=yield*Xn(n,ep[i],i,t=>`${l}${t}.${a}(${V(e.sourceCode,r.subject)})`);return yield*e.report(s===`exact`?t.withFix(d,f):t.withSuggestions(d,[{messageId:`replace`,data:{predicate:u},fix:f}]))});return s.on(`BinaryExpression`,e=>d.flatMap(o.getScope(e),t=>(e.operator===`instanceof`?up(e,t):lp(e,t)).pipe(f.filter(()=>!dp(e)),f.match({onNone:()=>d.void,onSome:t=>n(e,t)}))))}}),pp=m.is(Ze),mp=r.define({name:`prefer-effect-sse`,meta:B({type:`suggestion`,description:"Prefer Effect Sse over Server-Sent Events libraries and `EventSource` in Effect projects.",messages:{library:`Use Sse from effect/encoding instead of {{source}}: Sse.decode, Sse.decodeSchema or Sse.makeParser parse event streams, and Sse.encode or HttpApiSchema.StreamSse write them.`,eventSource:`Read the event stream with HttpClient and Sse.decode or Sse.decodeSchema, so events are schema-decoded and the stream is interruptible.`},url:`https://www.effect.website/docs/v4/api/effect/encoding/Sse`}),*create(){let e=yield*i;return(yield*z).hasEffectImport?s.merge(Al(n=>pp(Ol(n.value))?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`eventSource`})),it(n.callee,`EventSource`)))):{}}}),hp=m.is(di),gp=r.define({name:`prefer-effect-url`,meta:B({type:`suggestion`,description:`Prefer Effect Url helpers for safe URL parsing in Effect projects.`,messages:{effectUrl:`Use Url.fromString or Url.make so invalid URLs are represented as Result failures.`},url:`https://www.effect.website/docs/v4/api/effect/unstable/http/Url`}),*create(){let e=yield*i,n=yield*z;function r(n,r){return d.when(e.report(t.fromId({node:n,messageId:`effectUrl`})),it(r,`URL`))}return n.hasEffectImport?s.merge(s.on(`NewExpression`,e=>r(e,e.callee)),s.on(`CallExpression`,e=>f.exists(C(e.callee),e=>e.length===2&&e[0]===`URL`&&hp(e[1]))&&e.callee.type===`MemberExpression`?r(e,e.callee.object):d.void)):{}}}),_p=/[?&][\w.%[\]-]+=$/u;function vp(e){return _p.test(e)}function yp(e){return c.some(c.take(e.quasis,e.expressions.length),e=>vp(e.value.cooked??e.value.raw))}function bp(e){return f.match(c.head(e.arguments),{onNone:()=>!0,onSome:e=>e.type===`ObjectExpression`||e.type===`ArrayExpression`})}const xp=r.define({name:`prefer-effect-url-params`,meta:B({type:`suggestion`,description:`Prefer Effect UrlParams over URLSearchParams and hand-built query strings in Effect projects.`,messages:{urlSearchParams:`Use UrlParams.fromInput for immutable query parameters, and HttpClientRequest.setUrlParams or UrlParams.toString to apply them.`,manualQuery:`Build query strings with UrlParams.fromInput and UrlParams.toString, or HttpClientRequest.setUrlParams, which encode every value.`},url:`https://www.effect.website/docs/v4/api/effect/http/UrlParams`}),*create(){let e=yield*i;return!(yield*z).hasEffectImport||Mo(e.filename)?{}:s.merge(s.on(`NewExpression`,n=>d.when(e.report(t.fromId({node:n,messageId:`urlSearchParams`})),d.map(it(n.callee,`URLSearchParams`),e=>e&&bp(n)))),s.on(`TemplateLiteral`,n=>yp(n)&&n.parent.type!==`TaggedTemplateExpression`?e.report(t.fromId({node:n,messageId:`manualQuery`})):d.void),s.on(`BinaryExpression`,n=>{let r=n.left.type===`BinaryExpression`&&n.left.operator===`+`?n.left.right:n.left;return n.operator===`+`&&M(r)&&vp(r.value)?e.report(t.fromId({node:n,messageId:`manualQuery`})):d.void}))}}),Sp=m.is(Qe),Cp=m.is(Ci),wp=[`node:os`,`os`],Tp=r.define({name:`prefer-effect-user-directories`,meta:B({type:`suggestion`,description:`Prefer the Effect UserDirectories service over home directories and XDG paths resolved by hand in Effect projects.`,messages:{homedir:`Use the UserDirectories service from effect/persistence instead of os.homedir(): dirs.config, dirs.data, dirs.cache and dirs.state resolve the platform directory, and dirs.home the home directory.`,variable:`Use the UserDirectories service from effect/persistence instead of reading {{name}}: it applies the XDG, macOS and Windows conventions and reads the environment through the ConfigProvider.`,library:`Use the UserDirectories service from effect/persistence instead of {{source}}.`},url:`https://effect.website/docs/v4/api/effect/persistence/UserDirectories`}),*create(){let e=yield*i,n=yield*z;if(!n.hasEffectImport)return{};function r(n,r){return e.report(t.fromId({node:n,messageId:`variable`,data:{name:r}}))}return s.merge(s.on(`ImportDeclaration`,({source:n})=>Sp(n.value)?e.report(t.fromId({node:n,messageId:`library`,data:{source:n.value}})):d.void),s.on(`CallExpression`,i=>{if(f.contains(ft(e.sourceCode,i.callee,wp),`homedir`))return e.report(t.fromId({node:i,messageId:`homedir`}));let a=n.isApi(i.callee,`Config`,[`String`,`NonEmptyString`,`Redacted`])&&R(e.sourceCode,i.callee)?E(i,0).pipe(f.filter(M),f.map(({value:e})=>e),f.filter(Cp)):f.none();return f.match(a,{onNone:()=>d.void,onSome:e=>r(i,e)})}),s.on(`MemberExpression`,e=>{let t=e.parent.type===`AssignmentExpression`&&e.parent.left===e||!f.exists(C(e.object),e=>c.join(e,`.`)===`process.env`)?f.none():f.filter(S(e),Cp);return f.match(t,{onNone:()=>d.void,onSome:t=>e.object.type===`MemberExpression`?d.when(r(e,t),it(e.object.object,`process`)):d.void})}))}}),Ep={"&&":[`===`,`==`],"||":[`!==`,`!=`],"??":[]};function Dp(e,t){let n=D(e);return n.type===`LogicalExpression`&&n.operator===t?[...Dp(n.left,t),...Dp(n.right,t)]:[n]}function Op(e,t,n){if(e.type!==`BinaryExpression`||!c.contains(t,e.operator)||e.left.type===`PrivateIdentifier`)return f.none();let r=D(e.left),i=D(e.right);if(r.type!==`MemberExpression`||i.type!==`MemberExpression`)return f.none();let a=n.getText(r.object),o=n.getText(i.object);return f.flatMap(S(r),e=>a===o||!f.contains(S(i),e)?f.none():f.some(a<o?`${a} and ${o}`:`${o} and ${a}`))}function kp(e,t){return Fe(e).pipe(f.flatMap(e=>Oi(e,t)),f.exists(e=>e.length===2&&e[0]===`Equivalence`&&e[1]===`make`))}const Ap=r.define({name:`prefer-equal`,meta:B({type:`suggestion`,description:`Prefer Equal.equals or an Equivalence over field-by-field comparisons in Effect files.`,messages:{preferEqual:`Compare {{pair}} with Equal.equals (Data and Schema classes implement Equal) or an Equivalence such as Equivalence.Struct instead of field by field.`},url:`https://www.effect.website/docs/v4/api/effect/Equal`}),*create(){let e=yield*i,n=yield*z;return n.hasEffectImport?s.on(`LogicalExpression`,r=>{let i=Ep[r.operator],a=r.parent;if(c.isReadonlyArrayEmpty(i)||a.type===`LogicalExpression`&&a.operator===r.operator)return d.void;let o=c.getSomes(c.map(Dp(r,r.operator),t=>Op(t,i,e.sourceCode)));return c.findFirst(o,(e,t)=>c.contains(c.take(o,t),e)).pipe(f.filter(()=>!kp(r,n)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:`preferEqual`,data:{pair:n}}))}))}):{}}});function jp(e,t){return f.exists(e,e=>{let n=D(e);return n.type===`Identifier`&&n.name===t})}function Mp(e,t,n){return e?.type===`CallExpression`&&e.arguments.length===1&&n.isApi(e.callee,`Match`,`value`)&&jp(E(e,0),t)}function Np(e,t,n){return e.callee.type===`MemberExpression`&&f.contains(S(e.callee),`pipe`)?Mp(e.callee.object,t,n):(n.isApiPath(e.callee,[`pipe`])||n.isApiPath(e.callee,[`Function`,`pipe`]))&&f.exists(E(e,0),e=>Mp(e,t,n))}function Pp(e,t,n){if(n.isApi(e.callee,`Match`,`valueTags`))return e.arguments.length===2&&jp(E(e,0),t)?c.get(e.arguments,1):f.none();let r=e.callee;return r.type===`CallExpression`&&n.isApi(r.callee,`Match`,`valueTags`)&&r.arguments.length===1&&e.arguments.length===1&&jp(E(e,0),t)?c.head(r.arguments):f.none()}function Fp(e){return e.type!==`ArrowFunctionExpression`&&y.isNotNull(e.id)||e.parent.type===`VariableDeclarator`&&e.parent.init===e}function Ip(e){let[t]=e.params;return e.params.length===1&&t?.type===`Identifier`&&!e.typeParameters&&!e.async&&!e.generator?f.some(t):f.none()}function Lp(e,t,n){return U(e).pipe(f.filter(e=>e.type===`CallExpression`&&!O(e,e=>e.type===`ThisExpression`)),f.flatMap(r=>Np(r,t,n)?f.some(`value`):f.exists(Pp(r,t,n),n=>!Fp(e)||Ae(n,t))?f.some(`valueTags`):f.none()))}const Rp=r.define({name:`prefer-hoisted-match`,meta:B({type:`suggestion`,description:`Hoist Effect matchers with Match.type or Match.typeTags instead of wrapping Match.value or Match.valueTags in a function.`,messages:{value:"Replace this function with a hoisted `Match.type<…>().pipe(…)` matcher instead of calling `Match.value({{parameter}})` on every call. Case handlers already receive the narrowed value.",valueTags:"Replace this function with a hoisted `Match.typeTags<…>()({…})` or `Match.type<…>().pipe(Match.tagsExhaustive({…}))` matcher instead of calling `Match.valueTags` with `{{parameter}}`. Case handlers already receive the narrowed value."},url:`https://www.effect.website/docs/v4/api/effect/Match`}),*create(){let e=yield*i,n=yield*z;function r(r){return f.match(Ip(r),{onNone:()=>d.void,onSome:({name:i})=>f.match(Lp(r,i,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:n,data:{parameter:i}}))})})}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionDeclaration`,r),s.on(`FunctionExpression`,r))}});function zp(e){return e.type===`SpreadElement`}function Bp(e){if(!zp(e))return!1;let t=D(e.argument);return t.type!==`ConditionalExpression`&&t.type!==`LogicalExpression`&&t.type!==`ObjectExpression`&&(t.type!==`MemberExpression`||!f.contains(S(t),`fields`))}function Vp(e){return k(e)&&c.some(e.params,e=>e.type!==`AssignmentPattern`&&e.type!==`TSParameterProperty`&&!e.typeAnnotation)}function Hp(e){return y.isNull(e)||e.type===`SpreadElement`?!1:g.value(D(e)).pipe(g.when({type:`Literal`},({value:e})=>y.isString(e)||y.isNumber(e)||y.isBoolean(e)),g.when({type:`TemplateLiteral`},({expressions:e})=>c.isReadonlyArrayEmpty(e)),g.when({type:`UnaryExpression`,operator:`-`},({argument:e})=>Hp(e)),g.when({type:`ArrayExpression`},({elements:e})=>c.some(e,Hp)),g.when({type:`ObjectExpression`},({properties:e})=>c.some(e,e=>e.type===`Property`&&Hp(e.value))),g.orElse(v.constFalse))}function Up(e){return Vp(e)||e.type===`CallExpression`&&c.some(e.arguments,Vp)}const Wp=g.type().pipe(g.when({type:`Property`,kind:`init`,method:!1},e=>{let t=D(e.value);return!Up(t)&&!Hp(t)}),g.orElse(v.constFalse));function Gp(e){let[t,...n]=e.properties;return y.isUndefined(t)||!Bp(t)||c.isReadonlyArrayEmpty(n)?f.none():c.every(n,Bp)?f.some(`merge`):c.every(n,Wp)?f.some(`copy`):f.none()}function Kp(e,t){let[n,...r]=e.properties;if(!n||!zp(n)||!c.isReadonlyArrayNonEmpty(r))return f.none();let i=V(t,n.argument),a=c.headNonEmpty(r);if(!c.every(r,zp)){let e=h.slice(_.get(a.range,0),_.get(c.lastNonEmpty(r).range,1))(t.text);return f.some(`${i}, { ${e} }`)}return r.length===1&&zp(a)?f.some(`${i}, ${V(t,a.argument)}`):f.none()}const qp=r.define({name:`prefer-struct-assign`,meta:B({type:`suggestion`,description:`Prefer Struct.assign over object spread merges and copies in Effect files.`,messages:{merge:`Use Struct.assign(a, b) instead of merging objects with spreads.`,copy:`Use Struct.assign(value, { … }) instead of copying an object with spread overrides. Spreading a class instance drops its prototype; rebuild Schema and Data class instances with their constructor.`,assign:`Replace with Struct.assign.`},url:`https://www.effect.website/docs/v4/api/effect/Struct#assign`,hasSuggestions:!0}),*create(){let e=yield*i;if(!(yield*z).hasEffectImport)return{};let n=d.fnUntraced(function*(n,r){let i=t.fromId({node:n,messageId:r}),a=f.filter(Kp(n,e.sourceCode),()=>c.isReadonlyArrayEmpty(e.sourceCode.getCommentsInside(n)));if(f.isNone(a))return yield*e.report(i);let o=yield*Xn(n,`effect/Struct`,`Struct`,e=>`${e}.assign(${a.value})`);return yield*e.report(t.withSuggestions(i,[{messageId:`assign`,fix:o}]))});return s.on(`ObjectExpression`,e=>f.match(Gp(e),{onNone:()=>d.void,onSome:t=>n(e,t)}))}}),Jp=`isTagged`;function Yp(e,t){return e.isApi(t,`Predicate`,Jp)||f.contains(f.flatMap(C(t),Ce(`Predicate`)),Jp)}function Xp(e,t){let{callee:n}=t,r=Yp(e,n)&&t.arguments.length===2,i=n.type===`CallExpression`&&Yp(e,n.callee)&&n.arguments.length===1&&t.arguments.length===1;return r||i?c.head(t.arguments):f.none()}const Zp=r.define({name:`prefer-tagged-error-handling`,meta:B({type:`problem`,description:"Use Effect tagged error handlers instead of `Predicate.isTagged` checks in a broad catch handler.",messages:{taggedError:"Use Effect.catchTag or Effect.catchTags instead of checking the error with `Predicate.isTagged` in a broad Effect catch handler.",taggedReason:"Use Effect.catchReason or Effect.catchReasons instead of checking the error `reason` with `Predicate.isTagged` in a broad Effect catch handler."},url:`https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/prefer-tagged-error-handling.ts`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>Xp(n,r).pipe(f.filter(()=>no(r)),f.match({onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:r,messageId:ro(n)?`taggedReason`:`taggedError`}))})))}}),Qp={interruptibleMask:`interruptible`,uninterruptibleMask:`uninterruptible`},$p=r.define({name:`prefer-uninterruptible`,meta:B({type:`suggestion`,description:`Prefer the non-mask interruptibility API when the restore callback is unused.`,messages:{unusedRestore:`The mask callback never uses restore, so the mask is equivalent to {{replacement}} and misleadingly suggests a restored region.`},url:`https://github.com/Effect-TS/tsgo/issues/659`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>{let i=f.flatMap(n.member(r.callee,`Effect`),e=>l.get(Qp,e));return f.isSome(i)&&f.exists(E(r,0),e=>k(e)&&!Ne(e))?e.report(t.fromId({node:r,messageId:`unusedRestore`,data:{replacement:`Effect.${i.value}`}})):d.void})}}),em=r.define({name:`prefer-with-span`,meta:B({type:`suggestion`,description:`Prefer Effect.withSpan when the callback does not use the span handle.`,messages:{unusedSpan:`The useSpan callback ignores its span. Use Effect.withSpan so nested spans are parented beneath this span.`},url:`https://github.com/Effect-TS/tsgo/issues/663`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`useSpan`)&&f.exists(E(r,r.arguments.length-1),e=>k(e)&&!Ne(e))?e.report(t.fromId({node:r,messageId:`unusedSpan`})):d.void)}}),tm=m.is(Ho);function nm(e,t){let n=D(e);return N(n,0)||t.isApi(n,`Duration`,`zero`)?!0:M(n)?tm(n.value):n.type===`CallExpression`&&f.exists(t.path(n.callee),e=>f.contains(c.head(e),`Duration`))&&f.exists(E(n,0),N(0))}const rm=r.define({name:`prefer-yield-now`,meta:B({type:`suggestion`,description:`Prefer scheduler yielding to a zero-duration Clock sleep.`,messages:{zeroSleep:`Effect.sleep(0) uses Clock and interacts with TestClock. Use Effect.yieldNow for a cooperative scheduler yield.`},url:`https://github.com/Effect-TS/tsgo/issues/661`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`sleep`)&&f.exists(E(r,0),e=>nm(e,n))?e.report(t.fromId({node:r,messageId:`zeroSleep`})):d.void)}}),im=m.is(Zt),am=[`tapCause`,`tapErrorCause`],om=[...am,`tapError`],sm=[`as`,`asSome`,`asVoid`,`map`,`withSpan`],cm=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],lm=[`debug`,`error`,`info`,`log`,`trace`,`warn`];function um(e,t){return f.exists(Oi(e,t),([e,t])=>e===`Effect`&&im(t))||f.exists(Di(e,`catch`),e=>t.isApi(e.callee,`Effect`,[`try`,`tryPromise`]))}function dm(e,t){return t.isApi(e,`Effect`,cm)||t.isApi(e,`Console`,lm)}function fm(e){let t=e.body;return t?.type===`BlockStatement`?c.matchRight(t.body,{onEmpty:()=>f.none(),onNonEmpty:(e,t)=>t.type===`ReturnStatement`&&y.isNotNullish(t.argument)&&c.every(e,e=>e.type===`VariableDeclaration`)?f.some(D(t.argument)):f.none()}):U(e)}function pm(e,t){let n=D(e);return k(n)?f.exists(Me(n),({name:e})=>f.exists(fm(n),n=>n.type===`CallExpression`&&dm(n.callee,t)&&Ae(n,e))):dm(n,t)}function mm(e,t,n){return e.type===`CallExpression`&&n.isApi(e.callee,`Effect`,t)&&f.exists(c.last(e.arguments),e=>e.type!==`SpreadElement`&&pm(e,n))}function hm(e){return e.type===`MemberExpression`&&f.contains(S(e),`pipe`)}function gm(e,t){return t.isApiPath(e,[`pipe`])||t.isApiPath(e,[`Function`,`pipe`])}function _m(e,t){if(e.type!==`CallExpression`)return[e];let n=D(e.callee);return hm(n)?[..._m(n.object,t),...e.arguments]:gm(n,t)?c.match(e.arguments,{onEmpty:()=>[e],onNonEmpty:([e,...n])=>[..._m(e,t),...n]}):[e]}function vm(e,t){if(e.arguments.length>1)return f.match(c.head(e.arguments),{onNone:()=>[],onSome:e=>_m(e,t)});let n=e.parent;if(n.type!==`CallExpression`||!P(n.arguments,e))return[];let r=D(n.callee),i=c.takeWhile(n.arguments,t=>t!==e);return hm(r)?[..._m(r.object,t),...i]:gm(r,t)?c.match(i,{onEmpty:()=>[],onNonEmpty:([e,...n])=>[..._m(e,t),...n]}):i}function ym(e,t){return f.exists(Ie(e),e=>f.exists(c.findLast(vm(e,t),e=>!t.isApi(e.type===`CallExpression`?e.callee:e,`Effect`,sm)),n=>mm(n,t.isApi(e.callee,`Effect`,`catchCause`)?am:om,t)))}function bm(e){if(e.type===`NewExpression`)return f.some(e.callee);let t=e.type===`CallExpression`?D(e.callee):void 0;return t?.type===`MemberExpression`&&f.contains(S(t),`make`)?f.some(t.object):f.none()}function xm(e){return f.match(f.filter(A(e),e=>ye(e.type)),{onNone:()=>e,onSome:xm})}function Sm(e,t,n){let r=xm(e);return t.body===r||f.exists(A(r),e=>e.type===`ReturnStatement`&&F(Fe(e),t)||e.type===`YieldExpression`&&e.delegate||e.type===`CallExpression`&&n.isApi(e.callee,`Effect`,`fail`)&&F(c.head(e.arguments),r))}function Cm(e,t,n){return f.exists(bm(e),r=>f.exists(f.flatMap(C(r),c.last),i=>h.endsWith(`Error`)(i)||/^\p{Lu}/u.test(i)&&f.isNone(n.path(r))&&Sm(e,t,n)))}const wm=r.define({name:`preserve-caught-error`,meta:B({type:`suggestion`,description:`Preserve the underlying cause when wrapping an Effect failure.`,messages:{droppedCause:"This handler constructs a new error but drops the caught failure. Accept it as a parameter and attach it as cause, or log it first with `Effect.tapError(Effect.logError)`."},url:`https://github.com/Effect-TS/tsgo/issues/490`}),*create(){let e=yield*i,n=yield*z;function r(r){let i=Me(r);return y.isNotNullish(r.body)&&um(r,n)&&O(r.body,e=>Cm(e,r,n)&&!f.exists(i,({name:t})=>Ae(e,t)))&&!ym(r,n)?e.report(t.fromId({node:r,messageId:`droppedCause`})):d.void}return s.merge(s.on(`ArrowFunctionExpression`,r),s.on(`FunctionExpression`,r))}}),Tm=m.is(St),Em=r.define({name:`require-dual-type-arguments`,meta:B({type:`problem`,description:`Require Function.dual calls to pass their data-last and data-first signatures as type arguments.`,messages:{missingTypeArguments:`Function.dual without type arguments does not type-check its implementation or its data-last form. Write Fn.dual<DataLast, DataFirst>(...) instead of annotating the constant.`}}),*create(){let e=yield*i,n=yield*z;return Tm(e.filename)?s.on(`CallExpression`,r=>n.isApi(r.callee,`Function`,`dual`)&&R(e.sourceCode,r.callee)&&y.isNullish(r.typeArguments)?e.report(t.fromId({node:r.callee,messageId:`missingTypeArguments`})):d.void):{}}}),Dm=r.define({name:`require-schema-class-brand`,meta:B({type:`problem`,description:`Require Schema.Class declarations to carry a nominal brand.`,messages:{missingBrand:`Schema.Class without a second type parameter is structural. Add a unique brand so plain objects cannot masquerade as instances.`},url:`https://github.com/Effect-TS/tsgo/issues/468`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Schema`,`Class`)&&(r.typeArguments?.params.length??0)<2?e.report(t.fromId({node:r,messageId:`missingBrand`})):d.void)}}),Om=r.define({name:`require-try-promise-abort-signal`,meta:B({type:`suggestion`,description:`Require Effect.tryPromise thunks to accept and use their AbortSignal for interruption.`,messages:{missingSignal:"Accept the AbortSignal parameter and pass it to the Promise API. Name it `_signal` only when cancellation is unsupported.",unusedSignal:"Pass this AbortSignal to the Promise API, or rename it to `_signal` to explicitly acknowledge that cancellation is unsupported."},url:`https://www.effect.website/docs/v4/api/effect/Effect#tryPromise`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>n.isApi(r.callee,`Effect`,`tryPromise`)?f.match(Pi(E(r,0)),{onNone:()=>d.void,onSome:n=>f.match(Me(n),{onNone:()=>e.report(t.fromId({node:n,messageId:`missingSignal`})),onSome:r=>h.startsWith(`_`)(r.name)||Ne(n)?d.void:e.report(t.fromId({node:r,messageId:`unusedSignal`}))})}):d.void)}}),km=[`fn`,`fnUntraced`,`gen`],Am=[`fn`,`fnUntraced`],jm=[`try`,`tryPromise`];function Mm(e,t){return g.value(e.parent).pipe(g.when({type:`CallExpression`},n=>F(E(n,0),e)&&t.isApi(n.callee,`Effect`,jm)),g.when({type:`Property`,computed:!1,key:{type:`Identifier`,name:`try`},parent:{type:`ObjectExpression`,parent:{type:`CallExpression`}}},e=>t.isApi(e.parent.parent.callee,`Effect`,jm)),g.orElse(()=>!1))}function Nm(e,t){return f.exists(Ie(e),({callee:e})=>t.isApi(e,`Effect`,km)||e.type===`CallExpression`&&t.isApi(e.callee,`Effect`,Am))}const Pm=r.define({name:`throw-in-effect-gen`,meta:B({type:`problem`,description:`Disallow throw in Effect generator APIs because it creates an untyped defect.`,messages:{throwInGen:`Use yield* Effect.fail(...) instead of throw so the failure stays in the typed error channel.`}}),*create(){let e=yield*i,n=yield*z;return s.on(`ThrowStatement`,r=>f.exists(Fe(r),e=>!Mm(e,n)&&Nm(e,n))?e.report(t.fromId({node:r,messageId:`throwInGen`})):d.void)}}),Fm=m.is(an),Im=m.is(on),Lm=m.is(sn),Rm=/^run|unsafe/iu;function zm(e,t){return rt(I(t.sourceCode,e,e.name))}function Bm(e,t){let n=e.callee,r=f.getOrElse(t.imports.path(n),()=>[]),i=f.exists(c.head(r),Fm)&&!c.some(r,e=>Rm.test(e)),a=n.type===`MemberExpression`&&!n.computed&&f.contains(S(n),`pipe`)&&n.object.type===`CallExpression`&&Bm(n.object,t)||n.type===`CallExpression`&&Bm(n,t),o=f.exists(c.head(r),Im)||f.exists(c.get(r,1),Lm);return!e.optional&&(i||a)&&c.every(e.arguments,e=>e.type!==`SpreadElement`&&X(e,t)&&(!o||!Vm(e,t)))}function Vm(e,t){return e.type===`Identifier`?f.exists(zm(e,t),e=>e.type===`FunctionName`||e.type===`ImportBinding`||e.type===`Variable`&&e.node.type===`VariableDeclarator`&&y.isNotNull(e.node.init)&&k(e.node.init)):k(e)}function X(e,t){return g.value(e).pipe(g.discriminators(`type`)({Literal:e=>!(`regex`in e),ArrowFunctionExpression:v.constTrue,FunctionExpression:v.constTrue,Identifier:e=>!f.exists(zm(e,t),e=>e.type===`Variable`&&e.parent?.type===`VariableDeclaration`&&!je(e.parent)),TemplateLiteral:({expressions:e})=>c.every(e,e=>X(e,t)),ParenthesizedExpression:({expression:e})=>X(e,t),TSAsExpression:({expression:e})=>X(e,t),TSSatisfiesExpression:({expression:e})=>X(e,t),TSNonNullExpression:({expression:e})=>X(e,t),MemberExpression:e=>f.isSome(t.imports.path(e))||e.object.type===`CallExpression`&&Bm(e.object,t)&&(!e.computed||X(e.property,t)),UnaryExpression:({argument:e,operator:n})=>n!==`delete`&&X(e,t),BinaryExpression:({left:e,right:n})=>X(e,t)&&X(n,t),LogicalExpression:({left:e,right:n})=>X(e,t)&&X(n,t),ConditionalExpression:({alternate:e,consequent:n,test:r})=>X(r,t)&&X(n,t)&&X(e,t),ArrayExpression:({elements:e})=>c.every(e,e=>y.isNull(e)||X(e,t)),ObjectExpression:({properties:e})=>c.every(e,e=>e.type===`SpreadElement`?X(e.argument,t):(!e.computed||X(e.key,t))&&X(e.value,t)),CallExpression:e=>Bm(e,t)}),g.orElse(v.constFalse))}function Hm(e,t){return e.type===`ObjectExpression`||e.type===`ArrayExpression`||k(e)||e.type===`Identifier`&&f.exists(zm(e,t),({type:e})=>e===`FunctionName`)}function Um(e,t){return c.isReadonlyArrayEmpty(e.params)&&!e.async&&!e.generator&&!e.typeParameters&&f.exists(U(e),e=>!Hm(e,t)&&X(e,t))}function Wm(e,t,n){return f.exists(c.findFirst(e.getDeclaredVariables(t),e=>e.name===n),({references:e})=>c.some(e,({identifier:e,init:t})=>{let n=e.parent;return!t&&(n.type!==`CallExpression`||n.callee!==e)}))}function Gm(e){return(e.parent?.type===`ExportNamedDeclaration`?e.parent:e).parent?.type===`Program`}const Km=r.define({name:`no-constant-thunk`,meta:B({type:`suggestion`,description:`Disallow top-level functions without parameters that always return the same value.`,messages:{constantThunk:"`{{name}}` takes no parameters and always returns the same value. Make it a constant, or a static on its class."}}),*create(){let e=yield*i,n={sourceCode:e.sourceCode,imports:yield*z};function r(r,i,a){return Um(i,n)&&!Wm(e.sourceCode,r,a.name)?e.report(t.fromId({node:a,messageId:`constantThunk`,data:{name:a.name}})):d.void}return s.merge(s.on(`FunctionDeclaration`,e=>e.id&&e.body&&Gm(e)?r(e,e,e.id):d.void),s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&k(e.init)&&Gm(e.parent)?r(e,e.init,e.id):d.void))}}),qm=m.is(cn),Jm=m.is(ln),Ym=m.is(un);function Xm(e,t){return t.type===`Identifier`&&f.exists(I(e,t,t.name),({defs:e})=>{let[t]=e;if(!t||e.length!==1)return!1;if(t.type===`FunctionName`)return t.node.type===`FunctionDeclaration`;let n=t.node;return t.type===`Variable`&&n.type===`VariableDeclarator`&&n.id.type===`Identifier`&&!n.id.typeAnnotation&&y.isNotNull(n.init)&&k(n.init)})}function Zm(e){return!!e.returnType||c.some(e.params,e=>e.type===`Identifier`&&!!e.typeAnnotation)}const Qm=r.define({name:`no-forwarding-lambda`,meta:B({type:`suggestion`,description:`Disallow Effect callbacks that only forward their parameters to another function.`,messages:{forwardingLambda:`This callback only passes its parameters to {{callee}}. Pass {{callee}} directly.`,passCallee:`Pass {{callee}} directly.`},fixable:`code`,hasSuggestions:!0}),*create(){let e=yield*i,n=yield*z,{sourceCode:r}=e,a=d.fnUntraced(function*(n,i){let a=r.getText(i.callee),o=h.includes(`
|
|
5
|
+
`)(a)?`the callee`:`\`${a}\``,s=t.fromId({node:n,messageId:`forwardingLambda`,data:{callee:o}});if(c.isReadonlyArrayNonEmpty(r.getCommentsInside(n))||!kc(r,i.callee,n))return yield*e.report(s);let l=t.replaceText(n,V(r,i.callee));return yield*e.report(Xm(r,i.callee)&&!Zm(n)?t.withFix(s,l):t.withSuggestions(s,[{messageId:`passCallee`,data:{callee:o},fix:l}]))});function o(e){return Ie(e).pipe(f.flatMap(e=>n.path(e.callee)),f.filter(e=>e.length===2&&!f.exists(c.head(e),e=>qm(e)||Ym(e))&&!Jm(c.join(e,`.`))),f.flatMap(()=>Cc(e)),f.filter(({exact:t,call:r})=>t&&Ec(r.callee,n)&&(!wc(e)||Tc(r.callee,n))),f.match({onNone:()=>d.void,onSome:({call:t})=>a(e,t)}))}return s.merge(s.on(`ArrowFunctionExpression`,o),s.on(`FunctionExpression`,o))}}),$m=[`Effect`,`fn`],eh=m.is(wt);function th(e,t){let n=D(e);return k(n)||n.type===`CallExpression`&&(t.isApiPath(n.callee,$m)||n.callee.type===`CallExpression`&&t.isApiPath(n.callee.callee,$m))}function nh(e,t){return e.type===`FunctionDeclaration`&&e.id&&e.body?[{declaration:e,typed:wc(e)||!!e.typeParameters,name:e.id}]:e.type===`VariableDeclaration`?c.flatMap(e.declarations,e=>{if(e.id.type!==`Identifier`||!e.init||!th(e.init,t))return[];let n=D(e.init);return[{declaration:e,typed:k(n)&&(wc(n)||!!n.typeParameters),name:e.id}]}):[]}const rh=r.define({name:`no-single-use-private-function`,meta:B({type:`suggestion`,description:`Disallow short non-exported top-level functions that are used only once.`,messages:{singleUse:"`{{name}}` is only used once and not exported. Inline it where it is used instead of keeping a one-off helper."},schema:[{type:`object`,properties:{maxLines:{type:`integer`,minimum:1}},additionalProperties:!1}]}),options:ko,*create(e){let n=yield*i,r=yield*z;if(h.endsWith(`.d.ts`)(n.filename))return{};let{sourceCode:a}=n,o=e?.maxLines??3;function l(e,t){let{declaration:n,typed:r,name:i}=e,s=a.getText(n);if(r||c.contains(t,i.name)||eh(i.name)||h.split(s,`
|
|
6
|
+
`).length>o||s.length>o*120)return!1;let l=c.findFirst(a.getDeclaredVariables(n),e=>e.name===i.name).pipe(f.match({onSome:e=>c.filter(e.references,e=>!e.init),onNone:c.empty}));return l.length===1&&!c.some(l,e=>Le(n,e.identifier))}return s.on(`Program`,e=>{let i=c.flatMap(e.body,e=>e.type===`ExportNamedDeclaration`&&!e.source?c.map(e.specifiers,e=>Se(e.local)):e.type===`ExportDefaultDeclaration`&&e.declaration.type===`Identifier`?[e.declaration.name]:[]);return d.forEach(c.filter(c.flatMap(e.body,e=>nh(e,r)),e=>l(e,i)),({name:e})=>n.report(t.fromId({node:e,messageId:`singleUse`,data:{name:e.name}})),{concurrency:1,discard:!0})})}});function ih(e,t){let n=h.replaceAll(/\s+/gu,` `)(t.getText(e.callee));return n.length>60?`${h.slice(0,59)(n)}…`:n}function ah(e,t,n){return wc(e)&&(!Tc(t,n)||c.some(e.params,e=>e.type===`Identifier`&&y.isNotNullish(e.typeAnnotation)&&e.typeAnnotation.typeAnnotation.type!==`TSUnknownKeyword`))}const oh=r.define({name:`no-trivial-wrapper`,meta:B({type:`suggestion`,description:`Disallow named functions that only forward their parameters to another call.`,messages:{forwardsParameters:"`{{name}}` only passes its parameters to `{{callee}}`. Call `{{callee}}` directly, or assign it to a constant instead of wrapping it.",forwardsWithArguments:"`{{name}}` only passes its parameters to `{{callee}}` with fixed arguments. Call it inline, or hoist a constant built from those arguments, such as `Match.typeTags` or `Schema.is(Schema)`."}}),*create(){let e=yield*i,n=yield*z;function r(r,i){return Cc(r).pipe(f.filter(({call:e,exact:t})=>!ah(r,e.callee,n)&&Ec(e.callee,n)&&(t||n.isApi(e.callee,`Match`,`valueTags`)||n.isApi(e.callee,`Function`,`pipe`)&&e.arguments.length===2)),f.match({onNone:()=>d.void,onSome:({call:n,exact:r})=>e.report(t.fromId({node:i,messageId:r?`forwardsParameters`:`forwardsWithArguments`,data:{name:i.name,callee:ih(n,e.sourceCode)}}))}))}return s.merge(s.on(`FunctionDeclaration`,e=>e.id&&e.body?r(e,e.id):d.void),s.on(`VariableDeclarator`,e=>e.id.type===`Identifier`&&e.init&&k(e.init)?r(e.init,e.id):d.void))}}),sh=m.is(ii),ch=[`replace`,`replaceAll`,`slice`,`split`,`substring`,`takeLeft`,`takeRight`],lh=[`split`,`takeLeft`,`takeRight`],uh=[`flow`,`pipe`];function dh(e){let t=D(e);return t.type===`ChainExpression`?t.expression:t}function fh(e,t){return t.isApi(dh(e),`DateTime`,`formatIso`)}function ph(e,t){let n=dh(e);if(n.type!==`CallExpression`)return!1;let r=dh(n.callee);return r.type===`MemberExpression`&&f.contains(S(r),`toISOString`)&&c.isReadonlyArrayEmpty(n.arguments)||fh(r,t)}function mh(e,t){let n=dh(e);return n.type===`CallExpression`&&t.isApi(n.callee,`String`,ch)}function hh(e,t){return t.isApi(e,`Function`,uh)||t.isApiPath(e,[`pipe`])||t.isApiPath(e,[`flow`])}function gh(e,t){let n=dh(e.callee),r=c.filter(e.arguments,e=>e.type!==`SpreadElement`);return r.length===e.arguments.length?n.type===`MemberExpression`&&n.object.type!==`Super`&&f.contains(S(n),`pipe`)?f.some([n.object,...r]):hh(n,t)?f.some(r):f.none():f.none()}function _h(e,t){let n=dh(e.callee),r=f.exists(E(e,0),e=>ph(e,t));return n.type===`MemberExpression`&&f.exists(S(n),sh)&&ph(n.object,t)||e.arguments.length===2&&t.isApi(n,`String`,lh)&&r||e.arguments.length===1&&mh(n,t)&&r}function vh(e,t){return _h(e,t)?f.some(e):gh(e,t).pipe(f.flatMap(e=>c.findFirst(c.zip(e,c.drop(e,1)),([e,n])=>mh(n,t)&&(ph(e,t)||fh(e,t)))),f.map(([,e])=>e))}const yh=r.define({name:`no-utc-iso-slicing`,meta:B({type:`problem`,description:`Disallow slicing or rewriting a UTC ISO string to get a local date or time.`,messages:{utcIsoSlicing:`toISOString() and DateTime.formatIso give UTC, so slicing or rewriting them gives the UTC date and time: in Europe/Amsterdam the previous day between 00:00 and 02:00, and +00:00 instead of +01:00/+02:00. Format in an explicit zone instead: DateTime.setZone with DateTime.formatIsoDate, formatIsoOffset or formatIsoZoned, or Intl.DateTimeFormat with timeZone.`},url:`https://www.effect.website/docs/v4/api/effect/DateTime`}),*create(){let e=yield*i,n=yield*z;return s.on(`CallExpression`,r=>f.match(vh(r,n),{onNone:()=>d.void,onSome:n=>e.report(t.fromId({node:n,messageId:`utcIsoSlicing`}))}))}}),bh=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,xh=String.raw`[^\S\r\n\u2028\u2029]*`,Sh=RegExp(`^(${xh}${bh})(?:${xh}${bh})+(${xh};?)$`,`u`),Ch=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,wh=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),Th=/* @__PURE__ */ new Set([`any`,`never`,`always`]),Eh=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),Dh=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),Oh=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function kh(e){return e.type===`Punctuator`&&e.value===`;`}function Ah(e,t){return e.loc.end.line===t.loc.start.line}function jh(e){return e.loc.start.line===e.loc.end.line}function Mh(e){return wh.has(e.type)}function Nh(e){return e.type===`ChainExpression`?e.expression:e}function Z(e,t){let n=new Set(c.ensure(e));return(e,r)=>r.getFirstToken(e)?.value===t&&n.has(e.type)}function Ph(e){return t=>t.type===e}function Q(e,t){return(n,r)=>e(n,r)&&jh(n)===(t===`singleline`)}function Fh(e){if(e.type!==`ExpressionStatement`)return!1;let t=Nh(e.expression);if(t.type===`UnaryExpression`&&(t=Nh(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;)n=f.getOrThrowWith(c.last(n.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return Mh(n)}function Ih(e){if(e.type!==`VariableDeclaration`)return!1;let t=f.getOrUndefined(c.head(e.declarations))?.init;if(y.isNullish(t))return!1;for(;t.type===`MemberExpression`;)t=t.object;return t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`require`}function Lh(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||Fh(e))return!0;let n=t.getLastToken(e,e=>!kh(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(_.get(n.range,0)):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Rh(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Mh(e.parent.parent))&&e.expression.type===`Literal`&&y.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function zh(e,t){if(!Rh(e,t)||!e.parent||!(`body`in e.parent)||!c.isArray(e.parent.body))return!1;let n=e.parent.body;return v.pipe(n,c.takeWhile(t=>t!==e),c.every(e=>Rh(e,t)))}function Bh(e){if(e.type!==`ExpressionStatement`||e.expression.type!==`AssignmentExpression`)return!1;let t=e.expression.left;if(t.type!==`MemberExpression`)return!1;for(;t.object.type===`MemberExpression`;)t=t.object;return t.object.type===`Identifier`&&(t.object.name===`exports`||t.object.name===`module`&&t.property.type===`Identifier`&&t.property.name===`exports`)}function Vh(e,t){let n=f.fromNullOr(t.getLastToken(e)).pipe(f.getOrThrowWith(()=>/* @__PURE__ */ Error(`Padding rule invariant: statement has no token`))),r=t.getTokenBefore(n),i=t.getTokenAfter(n);return r&&i&&_.get(r.range,0)>=_.get(e.range,0)&&kh(n)&&!Ah(r,n)&&Ah(n,i)?r:n}function Hh(e,t){if(jh(e))return e.loc;let n=e.loc.start.line,r=f.getOrThrowWith(c.get(t.lines,n-1),()=>/* @__PURE__ */ Error(`Padding rule invariant: statement source line is missing`));return{start:e.loc.start,end:{line:n,column:r.length}}}const Uh=g.type().pipe(g.when({type:`VariableDeclaration`,kind:g.is(`using`,`await using`)},v.constTrue),g.orElse(v.constFalse)),$={"block-like":Lh,expression:(e,t)=>e.type===`ExpressionStatement`&&!zh(e,t),return:Z(`ReturnStatement`,`return`),export:Z([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:Z(`VariableDeclaration`,`var`),let:Z(`VariableDeclaration`,`let`),const:Z(`VariableDeclaration`,`const`),using:Uh,type:Z(`TSTypeAliasDeclaration`,`type`)},Wh={"*":()=>!0,exports:Bh,require:Ih,directive:zh,iife:Fh,block:Ph(`BlockStatement`),empty:Ph(`EmptyStatement`),function:Ph(`FunctionDeclaration`),"ts-method":Ph(`TSMethodSignature`),break:Z(`BreakStatement`,`break`),case:Z(`SwitchCase`,`case`),class:Z(`ClassDeclaration`,`class`),continue:Z(`ContinueStatement`,`continue`),debugger:Z(`DebuggerStatement`,`debugger`),default:Z([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:Z(`DoWhileStatement`,`do`),for:Z([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:Z(`IfStatement`,`if`),import:Z(`ImportDeclaration`,`import`),switch:Z(`SwitchStatement`,`switch`),throw:Z(`ThrowStatement`,`throw`),try:Z(`TryStatement`,`try`),while:Z([`WhileStatement`,`DoWhileStatement`],`while`),with:Z(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&Ch.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&f.exists(c.head(e.declarations),({init:e})=>y.isNotNullish(e)&&h.startsWith(`require(`)(t.getText(e))),enum:Z(`TSEnumDeclaration`,`enum`),interface:Z(`TSInterfaceDeclaration`,`interface`),"function-overload":Ph(`TSDeclareFunction`),...$,"singleline-block-like":Q($[`block-like`],`singleline`),"multiline-block-like":Q($[`block-like`],`multiline`),"singleline-expression":Q($.expression,`singleline`),"multiline-expression":Q($.expression,`multiline`),"singleline-return":Q($.return,`singleline`),"multiline-return":Q($.return,`multiline`),"singleline-export":Q($.export,`singleline`),"multiline-export":Q($.export,`multiline`),"singleline-var":Q($.var,`singleline`),"multiline-var":Q($.var,`multiline`),"singleline-let":Q($.let,`singleline`),"multiline-let":Q($.let,`multiline`),"singleline-const":Q($.const,`singleline`),"multiline-const":Q($.const,`multiline`),"singleline-using":Q($.using,`singleline`),"multiline-using":Q($.using,`multiline`),"singleline-type":Q($.type,`singleline`),"multiline-type":Q($.type,`multiline`)};function Gh(e){return Eh.has(e)}function Kh(e){return Th.has(e)}function qh(e){return y.isString(e)&&l.has(Wh,e)}function Jh(e){return c.isArray(e)}function Yh(e){if(qh(e))return e;if(y.isObject(e)&&y.isString(e.selector)&&c.every(l.keys(e),e=>Oh.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(Gh(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function Xh(e){if(!c.isArray(e))return Yh(e);let t=e;if(!c.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return c.map(t,e=>Yh(e))}function Zh(e){return c.map(e,e=>{if(!y.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||c.some(l.keys(e),e=>!Dh.has(e))||!Kh(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:Xh(e.prev),next:Xh(e.next)}})}function Qh(e,t,n){let r=[],i=Vh(e,n);if(t.loc.start.line-i.loc.end.line>=2)do{let e=f.fromNullOr(n.getTokenAfter(i,{includeComments:!0})).pipe(f.getOrThrowWith(()=>/* @__PURE__ */ Error(`Padding rule invariant: next statement token is missing`)));e.loc.start.line-i.loc.end.line>=2&&r.push([i,e]),i=e}while(_.get(i.range,0)<_.get(t.range,0));return r}function $h(e,t,n){return d.gen(function*(){if(n===`any`)return yield*d.void;let r=yield*i,a=r.sourceCode,o=Qh(e,t,a);return n===`never`?c.isArrayNonEmpty(o)?yield*r.report({node:t,messageId:`unexpectedBlankLine`,loc:Hh(t,a),fix(e){if(o.length>=2)return null;let t=c.headNonEmpty(o),n=_.get(t[0].range,1),r=_.get(t[1].range,0);return e.replaceTextRange([n,r],v.pipe(a.text,h.slice(n,r),h.replace(Sh,`$1$2`)))}}):yield*d.void:c.isArrayNonEmpty(o)?yield*d.void:yield*r.report({node:t,messageId:`expectedBlankLine`,loc:Hh(t,a),fix(n){let r=Vh(e,a),i=a.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!Ah(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,Ah(r,i)?`
|
|
7
7
|
|
|
8
8
|
`:`
|
|
9
|
-
`)}})})}function*ym(e,t){let n=e.sourceCode,r=g.pipe(t,c.flatMap(e=>[...c.ensure(e.prev),...c.ensure(e.next)]),c.flatMap(e=>b.isString(e)?[]:[e.selector]),c.dedupe),i=yield*p.make(new Map(c.map(r,e=>[e,/* @__PURE__ */ new Set]))),a=yield*p.make(c.empty()),o=yield*p.make(f.none());function l(){return p.update(o,e=>f.some({upper:e,prevNode:f.none()}))}function u(){return p.update(o,f.flatMap(e=>e.upper))}function m(e,t,r){let i=e;for(;i.type===`LabeledStatement`;)i=i.body;return pm(t)?c.some(t,e=>m(i,e,r)):b.isString(t)?lm[t](i,n):r.get(t.selector)?.has(i)===!0&&(t.lineMode===`singleline`?Xp(i):t.lineMode!==`multiline`||!Xp(i))}function h(e,n,r){return g.pipe(c.findLast(t,t=>m(e,t.prev,r)&&m(n,t.next,r)),f.match({onNone:()=>`any`,onSome:e=>e.blankLine}))}let v=_.type().pipe(_.when({parent:_.null},g.constant(d.void)),_.not({parent:{type:_.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},g.constant(d.void)),_.orElse(e=>d.gen(function*(){let t=yield*p.get(o);if(f.isNone(t))return yield*d.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(f.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*p.update(a,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*p.set(o,f.some({upper:t.value.upper,prevNode:f.some(e)}))})));function y(e){return d.andThen(v(e),l())}let x={Program:l,"Program:exit":d.fn(`'Program:exit'`)(function*(){let e=yield*p.get(i);yield*p.get(a).pipe(d.flatMap(t=>d.all(c.map(t,({prevNode:t,nextNode:n})=>vm(t,n,h(t,n,e))),{concurrency:1}))),yield*u()}),BlockStatement:l,"BlockStatement:exit":u,SwitchStatement:l,"SwitchStatement:exit":u,SwitchCase:y,"SwitchCase:exit":u,StaticBlock:l,"StaticBlock:exit":u,TSInterfaceBody:l,"TSInterfaceBody:exit":u,TSModuleBlock:l,"TSModuleBlock:exit":u,TSTypeLiteral:l,"TSTypeLiteral:exit":u,TSDeclareFunction:y,"TSDeclareFunction:exit":u,TSMethodSignature:y,"TSMethodSignature:exit":u,":statement":v};return s.merge(x,...c.map(r,e=>s.on(e,t=>p.update(i,n=>(n.get(e)?.add(t),n)))))}const bm=r.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:l.keys(lm)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*i;return yield*ym(e,gm(e.options))}}),xm=m.Literals([`document`,`localStorage`,`navigator`,`sessionStorage`,`window`]),Sm=m.is(xm),Cm=/\b(?:document|localStorage|navigator|sessionStorage|window)\b/u,wm=m.is(m.Literals([`every`,`filter`,`find`,`findIndex`,`findLast`,`findLastIndex`,`flatMap`,`forEach`,`map`,`reduce`,`reduceRight`,`some`,`sort`,`toSorted`])),Tm={useMemo:0,useReducer:2,useState:0},Em=m.is(m.Literals([`forwardRef`,`memo`])),Dm=m.String.check(m.isPattern(/^use[A-Z0-9]/u)),Om=m.is(Dm),km=m.String.check(m.isPattern(/^_?[A-Z]/u)),Am=m.is(km),jm=r.define({name:`no-browser-api-in-render`,meta:V({type:`problem`,description:`Disallow reading browser-only APIs while a React component or hook renders.`,messages:{browserApiInRender:"Reading `{{name}}` during render makes the server and client render differ, even behind a `typeof window` check. Read it in `useEffect` or subscribe with `useSyncExternalStore`."},url:`https://react.dev/reference/react-dom/client/hydrateRoot#handling-different-client-and-server-content`}),*create(){let e=yield*i;return Cm.test(e.sourceCode.text)?s.onExit(`Program`,()=>{let n=c.filter(c.getSomes(c.map(Mm(e.sourceCode.scopeManager.globalScope),({identifier:e})=>Nm(e))),({node:e})=>Pm(e));return d.forEach(n,({name:n,node:r})=>e.report(t.fromId({node:r,messageId:`browserApiInRender`,data:{name:n}})),{concurrency:1,discard:!0})}):{}}});function Mm(e){return f.fromNullishOr(e).pipe(f.match({onNone:()=>[],onSome:e=>c.dedupeWith([...a.throughReferences(e),...c.flatMap(c.filter(a.variables(e),({defs:e})=>c.isReadonlyArrayEmpty(e)),a.getReferences)],y.strictEqual())}))}function Nm(e){if(e.type!==`Identifier`)return f.none();let t=e.name===`globalThis`?f.flatMap(M(e,`MemberExpression`),e=>C(e).pipe(f.filter(Sm),f.map(t=>({name:`globalThis.${t}`,node:e})))):f.liftPredicate({name:e.name,node:e},({name:e})=>Sm(e));return f.filter(t,({node:e})=>!f.exists(j(e),e=>e.type===`UnaryExpression`&&e.operator===`typeof`||e.type===`TSTypeQuery`||e.type===`TSQualifiedName`))}function Pm(e){return f.exists(Ce(e,Fm),e=>Im(e)||Bm(e)&&Pm(e))}function Fm(e){return e.type===`ArrowFunctionExpression`||e.type===`FunctionDeclaration`||e.type===`FunctionExpression`}function Im(e){return f.exists(Rm(e),t=>Om(t)||Am(t)&&b.isNotNull(e.body)&&k(e.body,e=>e.type===`JSXElement`||e.type===`JSXFragment`))}function Lm(e){return M(e,`CallExpression`).pipe(f.filter(e=>f.exists(zm(e.callee),Em)),f.match({onNone:()=>e,onSome:Lm}))}function Rm(e){if(e.type!==`ArrowFunctionExpression`&&e.id)return f.some(e.id.name);let{parent:t}=Lm(e);return t?.type===`VariableDeclarator`&&t.id.type===`Identifier`?f.some(t.id.name):f.none()}function zm(e){return e.type===`Identifier`?f.some(e.name):e.type===`MemberExpression`?C(e):f.none()}function Bm(e){let t=e.parent;return t.type===`CallExpression`?t.callee===e||f.exists(zm(t.callee),n=>f.match(l.get(Tm,n),{onSome:n=>I(D(t,n),e),onNone:()=>t.callee.type===`MemberExpression`&&wm(n)&&I(D(t,0),e)})):!1}const Vm=r.define({name:`no-export-all-in-client`,meta:V({type:`problem`,description:"Disallow `export *` in 'use client' modules, which Next.js does not support.",messages:{exportAll:"Next.js does not support `export *` in a 'use client' module. Re-export each name instead."},url:`https://nextjs.org/docs/app/api-reference/directives/use-client`}),*create(){let e=yield*i;return c.some(e.sourceCode.ast.body,e=>e.type===`ExpressionStatement`&&e.directive===`use client`)?s.on(`ExportAllDeclaration`,n=>n.exportKind!==`type`&&n.parent.type===`Program`?e.report(t.fromId({node:n,messageId:`exportAll`})):d.void):{}}}),Hm=m.is(m.String.check(m.isPattern(/^\s*use[\s_-]*(?:client|server|cache)\b/iu))),Um=m.is(m.String.check(m.isPattern(/^use (?:client|server|cache(?:: [\w-]+)?)$/u))),Wm={"alchemy-domain-block-file-name":it,"alchemy-domain-pure-decide":ut,"alchemy-domain-pure-imports":gt,"alchemy-domain-require-view-version":vt,"alchemy-domain-total-handlers":St,"alchemy-no-cloudflare-init-finalizer":At,"alchemy-no-deprecated-docker-constraints":Rt,"alchemy-no-deprecated-resource":Bt,"alchemy-no-plaintext-github-secret":Ht,"alchemy-no-removed-config-api":Wt,"alchemy-no-reserved-eventbridge-default-name":Gt,"alchemy-no-runtime-config":Kt,"alchemy-no-v1-import":Jt,"alchemy-no-v1-worker-properties":Xt,"avoid-data-tagged-error":Zt,"ban-error-string":on,"consistent-schema-pipe":Rn,"cors-credentials-with-wildcard":Hn,"dual-numeric-arity-with-optional-parameter":Wn,"effect-promise-vs-trypromise":Gn,"no-already-started-promise":tr,"no-async-effect-try":nr,"no-browser-api-in-render":jm,"no-constant-thunk":up,"no-discarded-run-promise":rr,"no-discarded-schema-checks":cr,"no-effect-as-on-log":Lr,"no-empty-effect-callback":Rr,"no-empty-schema-struct":zr,"no-encoding-get-or-throw":Kr,"no-export-all-in-client":Vm,"no-effect-alchemy-barrel-imports":Dr,"no-forwarding-lambda":gp,"no-function-config-default":Yr,"no-hash-as-identity":$r,"no-inline-schema-compile":_i,"no-logging-in-catch":wi,"no-manual-effect-error-tag":Ii,"no-manual-encoding":Qi,"no-manual-sse":aa,"no-manual-tag-comparison":sa,"no-manual-tagged-construction":ca,"no-millis-arithmetic":Va,"no-multi-shot-effect-callback":Ka,"no-non-json-schema-annotation":ro,"no-option-of-service":so,"no-overwritten-discriminant":co,"no-service-option-get-or-throw":_o,"no-single-use-private-function":Sp,"no-service-constructor-imports":po,"no-throw-in-effect-callback":bo,"no-trivial-wrapper":Tp,"no-uppercase-http-api-header":ko,"no-utc-iso-slicing":Rp,"no-zero-retry-times":Ao,"padding-line-between-statements":bm,"prefer-data-match":Io,"prefer-direct-effect-combinators":Gs,"prefer-effect-alchemy-namespace-imports":Ks,"prefer-effect-archive":ec,"prefer-effect-array-ops":uc,"prefer-effect-array-sort":dc,"prefer-effect-cookies":Ac,"prefer-effect-csv":al,"prefer-effect-datetime":cl,"prefer-effect-duration":ll,"prefer-effect-duration-constants":xl,"prefer-effect-duration-types":Rl,"prefer-effect-encoding":Jl,"prefer-effect-filesystem":Zl,"prefer-effect-filter":$l,"prefer-effect-format-parser":iu,"prefer-effect-headers":au,"prefer-effect-http-method":su,"prefer-effect-http-status":uu,"prefer-effect-jwt":_u,"prefer-effect-match":Cu,"prefer-effect-match-status":ju,"prefer-effect-ndjson":Mu,"prefer-effect-net-address":Uu,"prefer-effect-number":Ad,"prefer-effect-path":Nd,"prefer-effect-predicate":qd,"prefer-effect-sse":Xd,"prefer-effect-url":$d,"prefer-effect-url-params":af,"prefer-effect-user-directories":df,"prefer-hoisted-match":wf,"prefer-equal":gf,"prefer-struct-assign":Nf,"prefer-uninterruptible":Ff,"prefer-with-span":If,"prefer-yield-now":Bf,"preserve-caught-error":Wf,"require-schema-class-brand":Gf,"require-try-promise-abort-signal":Kf,"throw-in-effect-gen":Qf,"valid-directive":r.define({name:`valid-directive`,meta:V({type:`problem`,description:`Disallow misspelled 'use client', 'use server' and 'use cache' directives, which do nothing.`,messages:{invalidDirective:`'{{directive}}' is not a valid directive, so it does nothing. Directives are case- and whitespace-sensitive: write 'use client', 'use server' or 'use cache'.`},url:`https://react.dev/reference/rsc/directives`}),*create(){let e=yield*i;return s.on(`ExpressionStatement`,n=>f.liftPredicate(n.directive,h.isString).pipe(f.filter(e=>!Um(e)&&Hm(e)),f.match({onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`invalidDirective`,data:{directive:r}}))})))}})},Gm=[`prefer-effect-filesystem`,`prefer-effect-path`],Km=[`prefer-effect-http-status`],qm=c.filter(l.keys(Wm),e=>!c.contains(Gm,e)),Jm=l.fromEntries(c.map(qm,e=>[`2digits/${e}`,c.contains(Km,e)?`warn`:`error`])),Ym=`@2digits/oxlint-plugin`,Xm=n.define({name:Ym,rules:Wm,recommended:{rules:qm}}),Zm=n.define({name:Ym,rules:Wm,recommended:{rules:Km,severity:`warn`}}),Qm=u.assign(Xm,{configs:u.assign(Xm.configs,{recommended:u.assign(Xm.configs.recommended,{rules:u.assign(Xm.configs.recommended.rules,Zm.configs.recommended.rules)})})});export{Qm as default,Jm as recommendedRules,Wm as rules};
|
|
9
|
+
`)}})})}function*eg(e,t){let n=e.sourceCode,r=v.pipe(t,c.flatMap(e=>[...c.ensure(e.prev),...c.ensure(e.next)]),c.flatMap(e=>y.isString(e)?[]:[e.selector]),c.dedupe),i=yield*p.make(new Map(c.map(r,e=>[e,/* @__PURE__ */ new Set]))),a=yield*p.make(c.empty()),o=yield*p.make(f.none());function l(){return p.update(o,e=>f.some({upper:e,prevNode:f.none()}))}function u(){return p.update(o,f.flatMap(e=>e.upper))}function m(e,t,r){let i=e;for(;i.type===`LabeledStatement`;)i=i.body;return Jh(t)?c.some(t,e=>m(i,e,r)):y.isString(t)?Wh[t](i,n):r.get(t.selector)?.has(i)===!0&&(t.lineMode===`singleline`?jh(i):t.lineMode!==`multiline`||!jh(i))}function h(e,n,r){return v.pipe(c.findLast(t,t=>m(e,t.prev,r)&&m(n,t.next,r)),f.match({onNone:()=>`any`,onSome:e=>e.blankLine}))}let _=g.type().pipe(g.when({parent:g.null},v.constant(d.void)),g.not({parent:{type:g.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},v.constant(d.void)),g.orElse(e=>d.gen(function*(){let t=yield*p.get(o);if(f.isNone(t))return yield*d.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(f.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*p.update(a,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*p.set(o,f.some({upper:t.value.upper,prevNode:f.some(e)}))})));function ee(e){return d.andThen(_(e),l())}let b={Program:l,"Program:exit":d.fn(`'Program:exit'`)(function*(){let e=yield*p.get(i);yield*p.get(a).pipe(d.flatMap(t=>d.all(c.map(t,({prevNode:t,nextNode:n})=>$h(t,n,h(t,n,e))),{concurrency:1}))),yield*u()}),BlockStatement:l,"BlockStatement:exit":u,SwitchStatement:l,"SwitchStatement:exit":u,SwitchCase:ee,"SwitchCase:exit":u,StaticBlock:l,"StaticBlock:exit":u,TSInterfaceBody:l,"TSInterfaceBody:exit":u,TSModuleBlock:l,"TSModuleBlock:exit":u,TSTypeLiteral:l,"TSTypeLiteral:exit":u,TSDeclareFunction:ee,"TSDeclareFunction:exit":u,TSMethodSignature:ee,"TSMethodSignature:exit":u,":statement":_};return s.merge(b,...c.map(r,e=>s.on(e,t=>p.update(i,n=>(n.get(e)?.add(t),n)))))}const tg=r.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:l.keys(Wh)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*i;return yield*eg(e,Zh(e.options))}}),ng=m.is(fi),rg=/\b(?:document|localStorage|navigator|sessionStorage|window)\b/u,ig=m.is(ci),ag={useMemo:0,useReducer:2,useState:0},og=m.is(wi),sg=m.is(Et),cg=m.is(Tt),lg=r.define({name:`no-browser-api-in-render`,meta:B({type:`problem`,description:`Disallow reading browser-only APIs while a React component or hook renders.`,messages:{browserApiInRender:"Reading `{{name}}` during render makes the server and client render differ, even behind a `typeof window` check. Read it in `useEffect` or subscribe with `useSyncExternalStore`."},url:`https://react.dev/reference/react-dom/client/hydrateRoot#handling-different-client-and-server-content`}),*create(){let e=yield*i;return rg.test(e.sourceCode.text)?s.onExit(`Program`,()=>{let n=c.filter(c.getSomes(c.map(ug(e.sourceCode.scopeManager.globalScope),({identifier:e})=>dg(e))),({node:e})=>fg(e));return d.forEach(n,({name:n,node:r})=>e.report(t.fromId({node:r,messageId:`browserApiInRender`,data:{name:n}})),{concurrency:1,discard:!0})}):{}}});function ug(e){return f.fromNullishOr(e).pipe(f.match({onNone:()=>[],onSome:e=>c.dedupeWith([...a.throughReferences(e),...c.flatMap(c.filter(a.variables(e),({defs:e})=>c.isReadonlyArrayEmpty(e)),a.getReferences)],ee.strictEqual())}))}function dg(e){if(e.type!==`Identifier`)return f.none();let t=e.name===`globalThis`?f.flatMap(j(e,`MemberExpression`),e=>S(e).pipe(f.filter(ng),f.map(t=>({name:`globalThis.${t}`,node:e})))):f.liftPredicate({name:e.name,node:e},({name:e})=>ng(e));return f.filter(t,({node:e})=>!f.exists(A(e),e=>e.type===`UnaryExpression`&&e.operator===`typeof`||e.type===`TSTypeQuery`||e.type===`TSQualifiedName`))}function fg(e){return f.exists(Pe(e,pg),e=>mg(e)||vg(e)&&fg(e))}function pg(e){return e.type===`ArrowFunctionExpression`||e.type===`FunctionDeclaration`||e.type===`FunctionExpression`}function mg(e){return f.exists(gg(e),t=>sg(t)||cg(t)&&y.isNotNull(e.body)&&O(e.body,e=>e.type===`JSXElement`||e.type===`JSXFragment`))}function hg(e){return j(e,`CallExpression`).pipe(f.filter(e=>f.exists(_g(e.callee),og)),f.match({onNone:()=>e,onSome:hg}))}function gg(e){if(e.type!==`ArrowFunctionExpression`&&e.id)return f.some(e.id.name);let{parent:t}=hg(e);return t?.type===`VariableDeclarator`&&t.id.type===`Identifier`?f.some(t.id.name):f.none()}function _g(e){return e.type===`Identifier`?f.some(e.name):e.type===`MemberExpression`?S(e):f.none()}function vg(e){let t=e.parent;return t.type===`CallExpression`?t.callee===e||f.exists(_g(t.callee),n=>f.match(l.get(ag,n),{onSome:n=>F(E(t,n),e),onNone:()=>t.callee.type===`MemberExpression`&&ig(n)&&F(E(t,0),e)})):!1}const yg=r.define({name:`no-export-all-in-client`,meta:B({type:`problem`,description:"Disallow `export *` in 'use client' modules, which Next.js does not support.",messages:{exportAll:"Next.js does not support `export *` in a 'use client' module. Re-export each name instead."},url:`https://nextjs.org/docs/app/api-reference/directives/use-client`}),*create(){let e=yield*i;return c.some(e.sourceCode.ast.body,e=>e.type===`ExpressionStatement`&&e.directive===`use client`)?s.on(`ExportAllDeclaration`,n=>n.exportKind!==`type`&&n.parent.type===`Program`?e.report(t.fromId({node:n,messageId:`exportAll`})):d.void):{}}}),bg=m.is(Ti),xg=m.is(Ei),Sg={"alchemy-domain-block-file-name":Jt,"alchemy-domain-pure-decide":Dn,"alchemy-domain-pure-imports":Mn,"alchemy-domain-require-view-version":Pn,"alchemy-domain-total-handlers":Rn,"alchemy-no-cloudflare-init-finalizer":Gn,"alchemy-no-deprecated-docker-constraints":$n,"alchemy-no-deprecated-resource":tr,"alchemy-no-plaintext-github-secret":rr,"alchemy-no-removed-config-api":ar,"alchemy-no-reserved-eventbridge-default-name":or,"alchemy-no-runtime-config":sr,"alchemy-no-v1-import":lr,"alchemy-no-v1-worker-properties":dr,"avoid-data-tagged-error":fr,"ban-error-string":yr,"consistent-schema-pipe":Xr,"cors-credentials-with-wildcard":ei,"dual-numeric-arity-with-optional-parameter":ni,"effect-promise-vs-trypromise":ri,"no-already-started-promise":Fi,"no-async-effect-try":Ii,"no-browser-api-in-render":lg,"no-constant-thunk":Km,"no-discarded-run-promise":Li,"no-discarded-schema-checks":Vi,"no-effect-as-on-log":fa,"no-empty-effect-callback":pa,"no-empty-schema-struct":ma,"no-encoding-get-or-throw":xa,"no-export-all-in-client":yg,"no-effect-alchemy-barrel-imports":na,"no-forwarding-lambda":Qm,"no-function-config-default":wa,"no-hash-as-identity":Da,"no-inline-schema-compile":Wa,"no-logging-in-catch":Ya,"no-manual-effect-error-tag":oo,"no-manual-encoding":So,"no-manual-sse":Do,"no-manual-tag-comparison":Ao,"no-manual-tagged-construction":jo,"no-manual-tagged-type":zo,"no-millis-arithmetic":Os,"no-multi-shot-effect-callback":Ns,"no-non-json-schema-annotation":Hs,"no-option-of-service":Ks,"no-overwritten-discriminant":qs,"no-service-option-get-or-throw":ec,"no-single-use-private-function":rh,"no-service-constructor-imports":Xs,"no-throw-in-effect-callback":nc,"no-trivial-wrapper":oh,"no-uppercase-http-api-header":uc,"no-utc-iso-slicing":yh,"no-zero-retry-times":dc,"padding-line-between-statements":tg,"prefer-data-match":_c,"prefer-direct-effect-combinators":El,"prefer-effect-alchemy-namespace-imports":Dl,"prefer-effect-archive":Pl,"prefer-effect-array-ops":Wl,"prefer-effect-array-sort":Gl,"prefer-effect-cookies":su,"prefer-effect-csv":Iu,"prefer-effect-datetime":Ru,"prefer-effect-duration":zu,"prefer-effect-duration-constants":Zu,"prefer-effect-duration-types":pd,"prefer-effect-encoding":xd,"prefer-effect-filesystem":Cd,"prefer-effect-filter":Td,"prefer-effect-format-parser":Ad,"prefer-effect-headers":jd,"prefer-effect-http-method":Nd,"prefer-effect-http-status":Id,"prefer-effect-jwt":Vd,"prefer-effect-match":qd,"prefer-effect-match-status":ef,"prefer-effect-ndjson":tf,"prefer-effect-net-address":uf,"prefer-effect-number":Zf,"prefer-effect-path":$f,"prefer-effect-predicate":fp,"prefer-effect-sse":mp,"prefer-effect-url":gp,"prefer-effect-url-params":xp,"prefer-effect-user-directories":Tp,"prefer-hoisted-match":Rp,"prefer-equal":Ap,"prefer-struct-assign":qp,"prefer-tagged-error-handling":Zp,"prefer-uninterruptible":$p,"prefer-with-span":em,"prefer-yield-now":rm,"preserve-caught-error":wm,"require-dual-type-arguments":Em,"require-schema-class-brand":Dm,"require-try-promise-abort-signal":Om,"throw-in-effect-gen":Pm,"valid-directive":r.define({name:`valid-directive`,meta:B({type:`problem`,description:`Disallow misspelled 'use client', 'use server' and 'use cache' directives, which do nothing.`,messages:{invalidDirective:`'{{directive}}' is not a valid directive, so it does nothing. Directives are case- and whitespace-sensitive: write 'use client', 'use server' or 'use cache'.`},url:`https://react.dev/reference/rsc/directives`}),*create(){let e=yield*i;return s.on(`ExpressionStatement`,n=>f.liftPredicate(n.directive,h.isString).pipe(f.filter(e=>!xg(e)&&bg(e)),f.match({onNone:()=>d.void,onSome:r=>e.report(t.fromId({node:n,messageId:`invalidDirective`,data:{directive:r}}))})))}})},Cg=[`prefer-effect-filesystem`,`prefer-effect-path`],wg=[`prefer-effect-http-status`],Tg=c.filter(l.keys(Sg),e=>!c.contains(Cg,e)),Eg=l.fromEntries(c.map(Tg,e=>[`2digits/${e}`,c.contains(wg,e)?`warn`:`error`])),Dg=`@2digits/oxlint-plugin`,Og=n.define({name:Dg,rules:Sg,recommended:{rules:Tg}}),kg=n.define({name:Dg,rules:Sg,recommended:{rules:wg,severity:`warn`}}),Ag=u.assign(Og,{configs:u.assign(Og.configs,{recommended:u.assign(Og.configs.recommended,{rules:u.assign(Og.configs.recommended.rules,kg.configs.recommended.rules)})})});export{Ag as default,Eg as recommendedRules,Sg as rules};
|