var __defProp = Object.defineProperty;
var __typeError = (msg) => {
  throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);

// src/decisions/schema.ts
import { z as z2 } from "zod";

// ../sdk-contracts/dist/schemas.js
import { z } from "zod";
var AnchorIdZ = z.object({
  selector: z.string(),
  route: z.union([z.string(), z.array(z.string())])
}).strict();
var PageUrlConditionZ = z.object({
  type: z.literal("page_url"),
  url: z.string()
});
var RouteConditionZ = z.object({
  type: z.literal("route"),
  routeId: z.string()
});
var AnchorVisibleConditionZ = z.object({
  type: z.literal("anchor_visible"),
  anchorId: z.string(),
  state: z.enum(["visible", "present", "absent"])
});
var EventOccurredConditionZ = z.object({
  type: z.literal("event_occurred"),
  eventName: z.string(),
  withinMs: z.number().optional()
});
var StateEqualsConditionZ = z.object({
  type: z.literal("state_equals"),
  key: z.string(),
  value: z.unknown()
});
var ViewportConditionZ = z.object({
  type: z.literal("viewport"),
  minWidth: z.number().optional(),
  maxWidth: z.number().optional(),
  minHeight: z.number().optional(),
  maxHeight: z.number().optional()
});
var SessionMetricConditionZ = z.object({
  type: z.literal("session_metric"),
  key: z.string(),
  operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
  threshold: z.number()
});
var DismissedConditionZ = z.object({
  type: z.literal("dismissed"),
  key: z.string(),
  inverted: z.boolean().optional()
});
var CooldownActiveConditionZ = z.object({
  type: z.literal("cooldown_active"),
  key: z.string(),
  inverted: z.boolean().optional()
});
var FrequencyLimitConditionZ = z.object({
  type: z.literal("frequency_limit"),
  key: z.string(),
  limit: z.number(),
  inverted: z.boolean().optional()
});
var MatchOpZ = z.object({
  equals: z.union([z.string(), z.number(), z.boolean()]).optional(),
  contains: z.string().optional()
});
var CounterDefZ = z.object({
  events: z.array(z.string()).min(1),
  match: z.record(z.string(), MatchOpZ).optional()
});
var EventCountConditionZ = z.object({
  type: z.literal("event_count"),
  key: z.string(),
  operator: z.enum(["gte", "lte", "eq", "gt", "lt"]),
  count: z.number().int().min(0),
  withinMs: z.number().positive().optional(),
  counter: CounterDefZ.optional()
});
var ConditionZ = z.discriminatedUnion("type", [
  PageUrlConditionZ,
  RouteConditionZ,
  AnchorVisibleConditionZ,
  EventOccurredConditionZ,
  StateEqualsConditionZ,
  ViewportConditionZ,
  SessionMetricConditionZ,
  DismissedConditionZ,
  CooldownActiveConditionZ,
  FrequencyLimitConditionZ,
  EventCountConditionZ
]);
var RuleZ = z.object({
  conditions: z.array(ConditionZ),
  value: z.unknown()
});
var RuleStrategyZ = z.object({
  type: z.literal("rules"),
  rules: z.array(RuleZ),
  default: z.unknown()
});
var ScoreStrategyZ = z.object({
  type: z.literal("score"),
  field: z.string(),
  threshold: z.number(),
  above: z.unknown(),
  below: z.unknown()
});
var ModelStrategyZ = z.object({
  type: z.literal("model"),
  modelId: z.string(),
  inputs: z.array(z.string()),
  outputMapping: z.record(z.string(), z.unknown()),
  default: z.unknown()
});
var ExternalStrategyZ = z.object({
  type: z.literal("external"),
  endpoint: z.string(),
  method: z.enum(["GET", "POST"]).optional(),
  default: z.unknown(),
  timeoutMs: z.number().optional()
});
var DecisionStrategyZ = z.discriminatedUnion("type", [
  RuleStrategyZ,
  ScoreStrategyZ,
  ModelStrategyZ,
  ExternalStrategyZ
]);
var TriggerWhenZ = DecisionStrategyZ.nullable().optional();
var EventScopeZ = z.object({
  events: z.array(z.string()),
  urlContains: z.string().optional(),
  props: z.record(z.union([z.string(), z.number(), z.boolean()])).optional()
});
var NotifyZ = z.object({
  title: z.string().optional(),
  body: z.string().optional(),
  icon: z.string().optional()
}).nullable().optional();

// src/decisions/schema.ts
var RouteFilterZ = z2.object({
  include: z2.array(z2.string()).optional().describe(
    "URL patterns where this tile appears. Supports *, **, :param wildcards. Use sparingly \u2014 mostly to isolate to specific webapp functionality. Omit to appear on all routes."
  ),
  exclude: z2.array(z2.string()).optional().describe("URL patterns where this tile should NOT appear. Evaluated before include.")
});
var ActivationConfigZ = z2.object({
  routes: RouteFilterZ,
  onlyIfPopulated: z2.boolean().optional().describe(
    "When true, tile is hidden if none of its props.actions[] have an active triggerWhen. Useful for tiles with all-deferred FAQ questions or nav tips. Default: false."
  )
});
function validateCondition(data) {
  return ConditionZ.safeParse(data);
}
function validateStrategy(data) {
  return DecisionStrategyZ.safeParse(data);
}
function validateActivationConfig(data) {
  return ActivationConfigZ.safeParse(data);
}
var decisionSchemas = [
  { defName: "matchOp", schema: MatchOpZ },
  { defName: "counterDef", schema: CounterDefZ },
  { defName: "activationConfig", schema: ActivationConfigZ },
  { defName: "routeFilter", schema: RouteFilterZ },
  { defName: "ruleStrategy", schema: RuleStrategyZ },
  { defName: "scoreStrategy", schema: ScoreStrategyZ },
  { defName: "modelStrategy", schema: ModelStrategyZ },
  { defName: "externalStrategy", schema: ExternalStrategyZ },
  { defName: "rule", schema: RuleZ },
  { defName: "condition", schema: ConditionZ }
];

export {
  __publicField,
  __privateGet,
  __privateAdd,
  __privateSet,
  PageUrlConditionZ,
  RouteConditionZ,
  AnchorVisibleConditionZ,
  EventOccurredConditionZ,
  StateEqualsConditionZ,
  ViewportConditionZ,
  SessionMetricConditionZ,
  DismissedConditionZ,
  CooldownActiveConditionZ,
  FrequencyLimitConditionZ,
  MatchOpZ,
  CounterDefZ,
  EventCountConditionZ,
  ConditionZ,
  RuleZ,
  RuleStrategyZ,
  ScoreStrategyZ,
  ModelStrategyZ,
  ExternalStrategyZ,
  DecisionStrategyZ,
  TriggerWhenZ,
  RouteFilterZ,
  ActivationConfigZ,
  validateCondition,
  validateStrategy,
  validateActivationConfig,
  decisionSchemas
};
//# sourceMappingURL=chunk-BU4Z6PD7.js.map
