@smart-tools/t3-code-pixso-mcp-assistant 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PixsoAssistantService-BWdD4LmW.d.mts +170 -0
- package/dist/PixsoAssistantService-DE6ZFSfz.mjs +113 -0
- package/dist/chunk-CbfVNrr-.mjs +1 -0
- package/dist/constants-C3TxS7N-.mjs +1 -0
- package/dist/contracts/index.d.mts +952 -0
- package/dist/contracts/index.mjs +1 -0
- package/dist/errors-CzFjWbus.d.mts +10 -0
- package/dist/localization-C6n18NsP.d.mts +3 -0
- package/dist/panel-DWzV5ian.mjs +1 -0
- package/dist/renderPreview-BNqmGtPz.mjs +1 -0
- package/dist/scan-CjlRisOD.d.mts +906 -0
- package/dist/server/index.d.mts +3 -0
- package/dist/server/index.mjs +1 -0
- package/dist/server/testing.d.mts +2 -0
- package/dist/server/testing.mjs +1 -0
- package/dist/synthetic/index.d.mts +31 -0
- package/dist/synthetic/index.mjs +1 -0
- package/dist/web/index.d.mts +66 -0
- package/dist/web/index.mjs +10 -0
- package/package.json +50 -0
- package/src/styles.css +13 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { E as CatalogSnapshot, b as GroupsMutateOp, f as ScanReportData, l as ReparseResult, n as LatestScanReport, o as ProbeResult, t as CheckResult, u as ScanJobState, v as CardSummary, w as CardDetail, x as PanelSnapshot } from "./scan-CjlRisOD.mjs";
|
|
2
|
+
import { t as PixsoAssistantError } from "./errors-CzFjWbus.mjs";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as FileSystem from "effect/FileSystem";
|
|
7
|
+
import * as Path from "effect/Path";
|
|
8
|
+
import * as Stream from "effect/Stream";
|
|
9
|
+
|
|
10
|
+
interface PixsoAssistantConfigShape {
|
|
11
|
+
readonly rootDir: string;
|
|
12
|
+
}
|
|
13
|
+
declare const PixsoAssistantConfig_base: Context.ServiceClass<PixsoAssistantConfig, "@smart-tools/t3-code-pixso-mcp-assistant/server/ports/PixsoAssistantConfig", PixsoAssistantConfigShape>;
|
|
14
|
+
declare class PixsoAssistantConfig extends PixsoAssistantConfig_base {}
|
|
15
|
+
interface PersistScanInput {
|
|
16
|
+
readonly dslRaw: string;
|
|
17
|
+
readonly catalogRaw: string | null;
|
|
18
|
+
readonly capturedAtIso: string;
|
|
19
|
+
readonly card: Omit<CardDetail, "id" | "importedAtIso" | "catalogHash">;
|
|
20
|
+
readonly summary: Omit<CardSummary, "id" | "importedAtIso">;
|
|
21
|
+
readonly report: ScanReportData;
|
|
22
|
+
}
|
|
23
|
+
interface PersistScanResult {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly duplicate: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface ReparseRebuildInput {
|
|
28
|
+
readonly dslRaw: string;
|
|
29
|
+
readonly catalogRaw: string | null;
|
|
30
|
+
}
|
|
31
|
+
type ReparseRebuild = (input: ReparseRebuildInput) => {
|
|
32
|
+
readonly card: PersistScanInput["card"];
|
|
33
|
+
readonly summary: PersistScanInput["summary"];
|
|
34
|
+
} | null;
|
|
35
|
+
interface ScanStoreShape {
|
|
36
|
+
readonly getSnapshot: () => Effect.Effect<PanelSnapshot, PixsoAssistantError>;
|
|
37
|
+
readonly getCard: (id: string) => Effect.Effect<CardDetail, PixsoAssistantError>;
|
|
38
|
+
readonly getCardRaw: (id: string) => Effect.Effect<string, PixsoAssistantError>;
|
|
39
|
+
readonly getCatalogRaw: (catalogHash: string) => Effect.Effect<{
|
|
40
|
+
readonly raw: string;
|
|
41
|
+
readonly capturedAtIso: string;
|
|
42
|
+
}, PixsoAssistantError>;
|
|
43
|
+
readonly findScanByNodeId: (nodeId: string) => Effect.Effect<string | null, PixsoAssistantError>;
|
|
44
|
+
readonly removeCard: (id: string) => Effect.Effect<void, PixsoAssistantError>;
|
|
45
|
+
readonly mutateGallery: (mutation: GroupsMutateOp) => Effect.Effect<void, PixsoAssistantError>;
|
|
46
|
+
readonly getLatestReport: () => Effect.Effect<LatestScanReport | null, PixsoAssistantError>;
|
|
47
|
+
readonly persistScan: (input: PersistScanInput, onPublished?: (result: PersistScanResult) => Effect.Effect<void>) => Effect.Effect<PersistScanResult, PixsoAssistantError>;
|
|
48
|
+
readonly recordReport: (report: LatestScanReport) => Effect.Effect<void, PixsoAssistantError>;
|
|
49
|
+
readonly recordCheck: (check: CheckResult) => Effect.Effect<void, PixsoAssistantError>;
|
|
50
|
+
readonly recordProbe: (probe: ProbeResult) => Effect.Effect<void, PixsoAssistantError>;
|
|
51
|
+
readonly reparseScans: (rebuild: ReparseRebuild) => Effect.Effect<ReparseResult, PixsoAssistantError>;
|
|
52
|
+
readonly diagnosticsDir: string;
|
|
53
|
+
}
|
|
54
|
+
declare const ScanStore_base: Context.ServiceClass<ScanStore, "@smart-tools/t3-code-pixso-mcp-assistant/server/store/ScanStore", ScanStoreShape>;
|
|
55
|
+
declare class ScanStore extends ScanStore_base {}
|
|
56
|
+
declare const ScanStoreLive: Layer.Layer<ScanStore, never, FileSystem.FileSystem | Path.Path | PixsoAssistantConfig>;
|
|
57
|
+
declare const RAW_DSL_KEEP = 40;
|
|
58
|
+
declare const RAW_CATALOG_KEEP = 20;
|
|
59
|
+
declare const sameGeneration: (left: CardSummary, right: CardSummary) => boolean;
|
|
60
|
+
type ContractStatus = "consumed" | "recorded" | "not-modelled";
|
|
61
|
+
interface ContractManifestEntry {
|
|
62
|
+
readonly status: ContractStatus;
|
|
63
|
+
readonly reason?: string;
|
|
64
|
+
readonly unobserved?: boolean;
|
|
65
|
+
}
|
|
66
|
+
declare const DSL_CONTRACT_MANIFEST: ReadonlyMap<string, ContractManifestEntry>;
|
|
67
|
+
declare function normalizeContractPath(line: string): string | null;
|
|
68
|
+
declare function normalizeCatalogContractPath(line: string): string | null;
|
|
69
|
+
declare const CATALOG_CONTRACT_MANIFEST: ReadonlyMap<string, ContractManifestEntry>;
|
|
70
|
+
interface PixsoWireTool {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly description: string;
|
|
73
|
+
readonly params: ReadonlyArray<{
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly type: string;
|
|
76
|
+
readonly required: boolean;
|
|
77
|
+
readonly description?: string;
|
|
78
|
+
readonly enumValues?: ReadonlyArray<string>;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
interface PixsoRawTool extends PixsoWireTool {
|
|
82
|
+
readonly inputSchema: unknown;
|
|
83
|
+
}
|
|
84
|
+
type PixsoListResult = {
|
|
85
|
+
readonly ok: true;
|
|
86
|
+
readonly tools: ReadonlyArray<PixsoWireTool>;
|
|
87
|
+
readonly ms: number;
|
|
88
|
+
} | PixsoFailure;
|
|
89
|
+
type PixsoRawListResult = {
|
|
90
|
+
readonly ok: true;
|
|
91
|
+
readonly tools: ReadonlyArray<PixsoRawTool>;
|
|
92
|
+
readonly ms: number;
|
|
93
|
+
} | PixsoFailure;
|
|
94
|
+
type PixsoCallResult = {
|
|
95
|
+
readonly ok: true;
|
|
96
|
+
readonly texts: ReadonlyArray<string>;
|
|
97
|
+
readonly ms: number;
|
|
98
|
+
} | PixsoFailure;
|
|
99
|
+
type PixsoRawCallResult = {
|
|
100
|
+
readonly ok: true;
|
|
101
|
+
readonly result: unknown;
|
|
102
|
+
readonly texts: ReadonlyArray<string>;
|
|
103
|
+
readonly isError: boolean;
|
|
104
|
+
readonly ms: number;
|
|
105
|
+
} | PixsoFailure;
|
|
106
|
+
interface PixsoFailure {
|
|
107
|
+
readonly ok: false;
|
|
108
|
+
readonly timedOut: boolean;
|
|
109
|
+
readonly origin: "transport" | "tool";
|
|
110
|
+
readonly message: string;
|
|
111
|
+
readonly ms: number;
|
|
112
|
+
}
|
|
113
|
+
interface PixsoMcpShape {
|
|
114
|
+
readonly endpoint: string;
|
|
115
|
+
readonly callTimeoutMs: number;
|
|
116
|
+
readonly listTools: () => Effect.Effect<PixsoListResult>;
|
|
117
|
+
readonly listToolsRaw: () => Effect.Effect<PixsoRawListResult>;
|
|
118
|
+
readonly callTool: (tool: string, args: Readonly<Record<string, unknown>>, timeoutMs?: number) => Effect.Effect<PixsoCallResult>;
|
|
119
|
+
readonly callToolRaw: (tool: string, args: Readonly<Record<string, unknown>>, timeoutMs?: number) => Effect.Effect<PixsoRawCallResult>;
|
|
120
|
+
}
|
|
121
|
+
declare const PixsoMcp_base: Context.ServiceClass<PixsoMcp, "@smart-tools/t3-code-pixso-mcp-assistant/server/mcp/PixsoMcp", PixsoMcpShape>;
|
|
122
|
+
declare class PixsoMcp extends PixsoMcp_base {}
|
|
123
|
+
declare const makePixsoMcp: (endpoint: string, timeoutMs?: number) => PixsoMcpShape;
|
|
124
|
+
declare const PixsoMcpLive: Layer.Layer<PixsoMcp, never, never>;
|
|
125
|
+
interface ScanJobShape {
|
|
126
|
+
readonly state: Effect.Effect<ScanJobState>;
|
|
127
|
+
readonly changes: Stream.Stream<ScanJobState>;
|
|
128
|
+
readonly start: () => Effect.Effect<ScanJobState, PixsoAssistantError>;
|
|
129
|
+
readonly check: () => Effect.Effect<CheckResult, PixsoAssistantError>;
|
|
130
|
+
readonly rescanDebug: () => Effect.Effect<LatestScanReport, PixsoAssistantError>;
|
|
131
|
+
readonly reparseStored: () => Effect.Effect<ReparseResult, PixsoAssistantError>;
|
|
132
|
+
}
|
|
133
|
+
declare const ScanJob_base: Context.ServiceClass<ScanJob, "@smart-tools/t3-code-pixso-mcp-assistant/server/scan/ScanJobService/ScanJob", ScanJobShape>;
|
|
134
|
+
declare class ScanJob extends ScanJob_base {}
|
|
135
|
+
declare const ScanJobLive: Layer.Layer<ScanJob, never, ScanStore | PixsoMcp>;
|
|
136
|
+
interface SettleLatchState {
|
|
137
|
+
readonly currentSeq: number;
|
|
138
|
+
readonly settledSeq: number | null;
|
|
139
|
+
}
|
|
140
|
+
declare const initialSettleLatch: SettleLatchState;
|
|
141
|
+
declare const settleWins: (state: SettleLatchState, seq: number) => boolean;
|
|
142
|
+
interface ProbeShape {
|
|
143
|
+
readonly run: () => Effect.Effect<ProbeResult, PixsoAssistantError>;
|
|
144
|
+
}
|
|
145
|
+
declare const Probe_base: Context.ServiceClass<Probe, "@smart-tools/t3-code-pixso-mcp-assistant/server/probe/ProbeService/Probe", ProbeShape>;
|
|
146
|
+
declare class Probe extends Probe_base {}
|
|
147
|
+
declare const ProbeLive: Layer.Layer<Probe, never, FileSystem.FileSystem | Path.Path | ScanStore | PixsoMcp | PixsoAssistantConfig>;
|
|
148
|
+
declare function summaryFromCard(card: CardDetail): CardSummary;
|
|
149
|
+
declare const isStagedName: (entryName: string) => boolean;
|
|
150
|
+
interface PixsoAssistantShape {
|
|
151
|
+
readonly getSnapshot: () => Effect.Effect<PanelSnapshot, PixsoAssistantError>;
|
|
152
|
+
readonly getCard: (id: string) => Effect.Effect<CardDetail, PixsoAssistantError>;
|
|
153
|
+
readonly getCardRaw: (id: string) => Effect.Effect<{
|
|
154
|
+
readonly raw: string;
|
|
155
|
+
}, PixsoAssistantError>;
|
|
156
|
+
readonly removeCard: (id: string) => Effect.Effect<void, PixsoAssistantError>;
|
|
157
|
+
readonly mutateGallery: (mutation: GroupsMutateOp) => Effect.Effect<void, PixsoAssistantError>;
|
|
158
|
+
readonly getLatestReport: () => Effect.Effect<LatestScanReport | null, PixsoAssistantError>;
|
|
159
|
+
readonly getCatalog: (catalogHash: string) => Effect.Effect<CatalogSnapshot, PixsoAssistantError>;
|
|
160
|
+
readonly scanStart: () => Effect.Effect<ScanJobState, PixsoAssistantError>;
|
|
161
|
+
readonly scanStates: () => Stream.Stream<ScanJobState>;
|
|
162
|
+
readonly check: () => Effect.Effect<CheckResult, PixsoAssistantError>;
|
|
163
|
+
readonly probe: () => Effect.Effect<ProbeResult, PixsoAssistantError>;
|
|
164
|
+
readonly rescanDebug: () => Effect.Effect<LatestScanReport, PixsoAssistantError>;
|
|
165
|
+
readonly reparseStored: () => Effect.Effect<ReparseResult, PixsoAssistantError>;
|
|
166
|
+
}
|
|
167
|
+
declare const PixsoAssistant_base: Context.ServiceClass<PixsoAssistant, "@smart-tools/t3-code-pixso-mcp-assistant/server/PixsoAssistantService/PixsoAssistant", PixsoAssistantShape>;
|
|
168
|
+
declare class PixsoAssistant extends PixsoAssistant_base {}
|
|
169
|
+
declare const PixsoAssistantLive: Layer.Layer<PixsoAssistant, never, FileSystem.FileSystem | Path.Path | PixsoMcp | PixsoAssistantConfig>;
|
|
170
|
+
export { ScanStore as A, normalizeContractPath as C, PersistScanInput as D, sameGeneration as E, ScanStoreShape as M, PixsoAssistantConfig as N, PersistScanResult as O, PixsoAssistantConfigShape as P, normalizeCatalogContractPath as S, RAW_DSL_KEEP as T, PixsoMcpShape as _, summaryFromCard as a, ContractManifestEntry as b, ProbeShape as c, settleWins as d, ScanJob as f, PixsoMcpLive as g, PixsoMcp as h, isStagedName as i, ScanStoreLive as j, ReparseRebuild as k, SettleLatchState as l, ScanJobShape as m, PixsoAssistantLive as n, Probe as o, ScanJobLive as p, PixsoAssistantShape as r, ProbeLive as s, PixsoAssistant as t, initialSettleLatch as u, makePixsoMcp as v, RAW_CATALOG_KEEP as w, DSL_CONTRACT_MANIFEST as x, CATALOG_CONTRACT_MANIFEST as y };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import{T as e,c as t,l as n,n as r,p as i,w as a}from"./panel-DWzV5ian.mjs";import{t as o}from"./constants-C3TxS7N-.mjs";import{a as s,b as c,g as l,o as u,t as d,v as f,x as p,y as m}from"./renderPreview-BNqmGtPz.mjs";import*as h from"effect/Schema";import*as g from"effect/Context";import*as _ from"effect/Effect";import*as v from"effect/Layer";import*as y from"effect/Ref";import*as b from"node:buffer";import*as x from"effect/Clock";import*as S from"effect/Deferred";import*as C from"effect/FileSystem";import*as w from"effect/Path";import*as T from"effect/Semaphore";import{Client as E}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as ee}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import*as D from"effect/Option";import*as O from"effect/unstable/sql/SqlClient";import*as k from"effect/PlatformError";import*as te from"node:process";import*as A from"node:crypto";import*as ne from"effect/Duration";import*as j from"effect/SubscriptionRef";function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e,t){let n=e[t];return typeof n==`string`?n:null}function P(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function F(e,t){let n=e[t];return typeof n==`boolean`?n:null}function I(e,t){let n=e[t];return Array.isArray(n)?n:[]}function L(e,t){let n=e[t];return M(n)?n:null}function re(e,t,n){let r=P(e,t);return r===null?n:Math.min(1,Math.max(0,r))}function ie(e){return typeof e!=`number`||!Number.isFinite(e)?null:Math.min(255,Math.max(0,Math.round(e)))}function ae(e){let t=ie(e.r),n=ie(e.g),r=ie(e.b);if(t===null||n===null||r===null)return null;let i=e=>e.toString(16).padStart(2,`0`);return`#${i(t)}${i(n)}${i(r)}`.toUpperCase()}function oe(e,t,n){return e==null?`unknown`:e===`RESIZE_TO_FIT`?`hug`:e===`FIXED`||e===0?`fixed`:(n.push({severity:`info`,code:`unknown-sizing-value`,message:`Unverified sizing value ${JSON.stringify(e)}`,path:t}),`unknown`)}const se=new Set(`stackMode.stackPrimarySizing.stackCounterSizing.stackChildPrimarySizing.stackChildCounterSizing.autoLayoutDirection.autoLayoutItemSpacing.autoLayoutCounterItemSpacing.autoLayoutItemReverseDraw.autoLayoutPrimaryAlign.autoLayoutCounterAlign.autoLayoutAlignType.autoLayoutItemHoriAlign.autoLayoutItemVertAlign.autoLayoutPaddingTop.autoLayoutPaddingBottom.autoLayoutPaddingLeft.autoLayoutPaddingRight.autoLayoutIncludeBorders.autoLayoutItemAbsolutePos.autoLayoutWidthResize.autoLayoutHeightResize.minWidth.minHeight.maxWidth.maxHeight`.split(`.`));function ce(e,t,n){let r=N(e,`stackMode`);if(!(r!==null||P(e,`autoLayoutItemSpacing`)!==null||P(e,`autoLayoutPaddingTop`)!==null))return null;let i;r===`HORIZONTAL`?i=`horizontal`:r===`VERTICAL`?i=`vertical`:(i=`unknown`,n.push({severity:`info`,code:`unknown-stack-mode`,message:`Unverified stackMode ${JSON.stringify(r)}`,path:t}));let a=P(e,`autoLayoutPaddingTop`),o=P(e,`autoLayoutPaddingRight`),s=P(e,`autoLayoutPaddingBottom`),c=P(e,`autoLayoutPaddingLeft`),l=a!==null||o!==null||s!==null||c!==null;return{mode:i,gap:P(e,`autoLayoutItemSpacing`),counterGap:P(e,`autoLayoutCounterItemSpacing`),padding:l?{top:a??0,right:o??0,bottom:s??0,left:c??0}:null,primaryAlign:N(e,`autoLayoutPrimaryAlign`),counterAlign:N(e,`autoLayoutCounterAlign`),alignType:N(e,`autoLayoutAlignType`),primarySizing:oe(e.stackPrimarySizing,t,n),counterSizing:oe(e.stackCounterSizing,t,n),minWidth:P(e,`minWidth`),maxWidth:P(e,`maxWidth`),minHeight:P(e,`minHeight`),maxHeight:P(e,`maxHeight`),reverse:F(e,`autoLayoutItemReverseDraw`)}}function le(e,t,n,r){return!(e.stackChildPrimarySizing!==void 0||e.stackChildCounterSizing!==void 0||e.autoLayoutWidthResize!==void 0||e.autoLayoutItemAbsolutePos!==void 0)&&t===null?null:{inFlow:t,absoluteInFlow:F(e,`autoLayoutItemAbsolutePos`),primarySizing:oe(e.stackChildPrimarySizing??e.autoLayoutWidthResize,n,r),counterSizing:oe(e.stackChildCounterSizing??e.autoLayoutHeightResize,n,r)}}function ue(e){let t=P(e,`rectangleTopLeftCornerRadius`),n=P(e,`rectangleTopRightCornerRadius`),r=P(e,`rectangleBottomRightCornerRadius`),i=P(e,`rectangleBottomLeftCornerRadius`);return t===null&&n===null&&r===null&&i===null?null:{topLeft:t??0,topRight:n??0,bottomRight:r??0,bottomLeft:i??0}}function R(e,t,n,r){for(let i of Object.keys(e))t.has(i)||r.push(`${n}${i}`)}const de=`!reshaped`,fe=new Set([`r`,`g`,`b`,`a`]),pe=new Set([`x`,`y`]),me=new Set([`type`,`visible`,`spread`,`radius`,`color`,`offset`,`blendMode`,`saturation`,`showShadowBehindNode`]),he={DROP_SHADOW:`drop-shadow`,BACKGROUND_BLUR:`background-blur`,FOREGROUND_BLUR:`foreground-blur`};function ge(e,t,n,r){let i=[];for(let a of I(e,`effects`)){if(!M(a))continue;R(a,me,`effects[].`,r);let e=L(a,`color`);e!==null&&R(e,fe,`effects[].color.`,r);let o=L(a,`offset`);o!==null&&R(o,pe,`effects[].offset.`,r);let s=N(a,`type`)??``,c=he[s];if(c===void 0){n.push({severity:`info`,code:`unknown-effect-type`,message:`Unverified effect type "${s}" — skipped`,path:t});continue}i.push({kind:c,color:e===null?null:ae(e),colorAlpha:e===null?1:re(e,`a`,1),offsetX:o===null?null:P(o,`x`),offsetY:o===null?null:P(o,`y`),spread:P(a,`spread`),radius:P(a,`radius`),visible:F(a,`visible`)??!0})}return i}const _e=new Set([`type`,`blendMode`,`opacity`,`visible`,`color`,`stops`,`startPt`,`endPt`,`leftPt`,`transform`]),ve=new Set([`position`,`color`]),ye=new Set([`m00`,`m01`,`m02`,`m10`,`m11`,`m12`]);function be(e,t,n,r){let i=L(e,t);if(i===null)return null;R(i,pe,`${n}${t}.`,r);let a=P(i,`x`),o=P(i,`y`);return a===null||o===null?null:{x:a,y:o}}function xe(e,t,n){let r=[];for(let i of I(e,`stops`)){if(!M(i))continue;R(i,ve,`${t}stops[].`,n);let e=L(i,`color`);e!==null&&R(e,fe,`${t}stops[].color.`,n);let a=P(i,`position`);a!==null&&r.push({position:a,hex:e===null?null:ae(e),alpha:e===null?1:re(e,`a`,1)})}return r}function Se(e,t,n){if(!M(e))return null;R(e,_e,t,n);let r=N(e,`type`)??``,i=L(e,`color`);i!==null&&R(i,fe,`${t}color.`,n);let a=L(e,`transform`);a!==null&&R(a,ye,`${t}transform.`,n);let o=xe(e,t,n),s=r===`GRADIENT_LINEAR`&&o.length>0;return{kind:r===`SOLID`?`solid`:s?`gradient-linear`:`unknown`,hex:i===null?null:ae(i),alpha:i===null?1:re(i,`a`,1),opacity:re(e,`opacity`,1),blendMode:N(e,`blendMode`),visible:F(e,`visible`)??!0,rawType:r,stops:o,startPt:be(e,`startPt`,t,n),endPt:be(e,`endPt`,t,n),leftPt:be(e,`leftPt`,t,n)}}function Ce(e,t,n,r,i,a=t){let o=[];for(let s of I(e,t)){let e=Se(s,`${a}[].`,i);if(e===null){r.push({severity:`warning`,code:`malformed-paint`,message:`Unreadable ${t} entry`,path:n});continue}e.kind===`unknown`&&r.push({severity:`info`,code:`unknown-paint-type`,message:`Paint type "${e.rawType}" is not verified; colour data preserved best-effort`,path:n}),o.push(e)}return o}function we(e,t,n,r){return t===null||t===`none`||t===`origin`?{display:e,normalized:`none`}:t===`allUpper`?{display:e.toUpperCase(),normalized:`upper`}:(r.push({severity:`info`,code:`unknown-text-case`,message:`Unverified textCase "${t}" — display text left as stored`,path:n}),{display:e,normalized:`unknown`})}function Te(e,t,n){let r=N(e,`nodeText`);if(r===null)return null;let i=we(r,N(e,`textCase`),t,n),a=N(e,`textAutoResize`),o=a===`WIDTH_AND_HEIGHT`?`widthAndHeight`:a===`HEIGHT`?`height`:a===`NONE`?`none`:`unknown`;return{raw:r,display:i.display,fontFamily:N(e,`fontFamily`),fontStyle:N(e,`fontStyle`),fontSize:P(e,`fontSize`),textCase:i.normalized,autoResize:o,alignHorizontal:N(e,`textAlignHorizontal`),lineHeightPx:N(e,`lineHeightUnit`)===`PIXELS`?P(e,`lineHeightNumber`):null,letterSpacingPx:N(e,`letterSpacingUnit`)===`PIXELS`?P(e,`letterSpacingNumber`):null,letterSpacing:De(e),decoration:Ee(e)}}function Ee(e){let t=N(e,`textDecoration`);return t===null||t.toLowerCase()===`none`?null:t}function De(e){let t=P(e,`letterSpacingNumber`);if(t===null)return null;let n=N(e,`letterSpacingUnit`);return n===`PIXELS`?{value:t,unit:`px`}:n===`PERCENT`?{value:t,unit:`%`}:null}const Oe={FRAME:`frame`,GROUP:`group`,RECTANGLE:`rect`,ELLIPSE:`ellipse`,PARAGRAPH:`text`,SPAN:`text`,TEXT:`text`,VECTOR:`vector`,INSTANCE:`instance`,SYMBOL:`symbol`,LINE:`line`,MASK:`mask`},ke=new Set(`name.guid.parentGuid.parentGuids.type.visible.angle.opacity.flipVertically.flipHorizontally.width.height.top.left.bottom.right.globalLeft.globalTop.internalOnly.frameMaskDisabled.position.autoLayout.autoLayoutByParent.fillPaints.strokePaints.strokeWeight.strokeAlign.strokeJoin.strokePaddingPath.isShowStroke.cornerRadius.rectangleTopLeftCornerRadius.rectangleTopRightCornerRadius.rectangleBottomLeftCornerRadius.rectangleBottomRightCornerRadius.fontFamily.fontStyle.fontSize.fontWeight.textAutoResize.textAlignHorizontal.textCase.nodeText.toggledOnOTFeatures.toggledOffOTFeatures.lineHeightUnit.lineHeightNumber.letterSpacingUnit.letterSpacingNumber.layerType.description.componentKey.overrideKey.publishID.publishFile.publishable.version.componentNormName.isFromComponent.propDefMap.propAssignMap.mask.scrollBehavior.url.dashPattern.inheritFillStyleID.inheritTextStyleID.effects.mainComponent.mainStateGroup.instanceByFrame.props.borderTopWeight.borderRightWeight.borderBottomWeight.borderLeftWeight.horizontalConstraint.verticalConstraint.scrollDirection.descriptionRich.blendMode.links.textDecoration.margin.instanceOverriddenList`.split(`.`)),Ae=new Set([`fontHash`,`hasNewline`,`fontVariations`,`overlayBackgroundAppearance`,`overlayBackgroundInteraction`,`overlayPositionType`,`propRefMap`]),je=new Set([`0:0`,`4294967295:4294967295`]);function Me(e,t){let n=N(e,t);return n===null||je.has(n)?null:n}function Ne(e){if(typeof e==`string`){let t=e.length>40?`${e.slice(0,40)}…`:e;return JSON.stringify(t)}return typeof e==`number`||typeof e==`boolean`||e===null?String(e):Array.isArray(e)?`[…${e.length}]`:typeof e==`object`?`{…${Object.keys(e).length} keys}`:typeof e}const Pe=/^(text|visible)_\d+_\d+$/;function Fe(e){return typeof e==`string`?e:typeof e==`boolean`||typeof e==`number`?String(e):null}function Ie(e,t){let n=N(e,`type`);if(n===`text`||n===`visible`)return n;let r=Pe.exec(t);return r===null?null:r[1]===`text`?`text`:`visible`}const Le=new Set([`key`,`name`,`type`,`defaultValue`,`value`]),Re=new Set([`text`,`visible`]),ze=e=>e.startsWith(`text`)?`text_{*}`:`visible_{*}`;function Be(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e);n.set(e,{propKey:e,kind:t,name:r.name??i?.name??null,defaultValue:r.defaultValue??i?.defaultValue??null,value:r.value??i?.value??null})};for(let[n,i]of Object.entries(e)){if(!Pe.test(n)||!M(i))continue;R(i,Le,`${ze(n)}.`,t);let e=Ie(i,n);e!==null&&r(n,e,{name:N(i,`name`),defaultValue:Fe(i.defaultValue),value:`value`in i?Fe(i.value):null})}let i=L(e,`propDefMap`);if(i!==null)for(let[e,n]of Object.entries(i)){if(!M(n))continue;R(n,Le,`propDefMap{*}.`,t);let i=Ie(n,e);i!==null&&r(N(n,`key`)??e,i,{name:N(n,`name`),defaultValue:Fe(n.defaultValue)})}let a=L(e,`propAssignMap`);if(a!==null)for(let[e,n]of Object.entries(a)){if(!M(n))continue;R(n,Le,`propAssignMap{*}.`,t);let i=Ie(n,e);i!==null&&r(e,i,{name:N(n,`name`),value:Fe(n.value)})}let o=L(e,`propRefMap`);if(o!==null){R(o,Re,`propRefMap.`,t);for(let[e,n]of Object.entries(o))!Re.has(e)||!M(n)||R(n,Le,`propRefMap.${e}.`,t)}return[...n.values()]}function Ve(e){let t=e.split(`,`).map(e=>e.trim()),n=[];for(let e of t){let t=e.indexOf(`=`);if(t<=0||t===e.length-1)return null;n.push([e.slice(0,t).trim(),e.slice(t+1).trim()])}return n.length>0?Object.fromEntries(n):null}function He(e,t){let n=N(e,`componentKey`),r=N(e,`layerType`),i=N(e,`mainComponent`);if(n===null&&i===null&&r!==`COMPONENT`)return null;let a=N(e,`mainStateGroup`);return{componentKey:n,publishId:N(e,`publishID`),publishFile:N(e,`publishFile`),version:N(e,`version`),normName:N(e,`componentNormName`),description:N(e,`description`)??``,variantProps:Ve(t),mainComponentId:i,mainStateGroup:a===null||a===``?null:a,instanceByFrame:F(e,`instanceByFrame`)??!1}}function Ue(e){let t=P(e,`borderTopWeight`),n=P(e,`borderRightWeight`),r=P(e,`borderBottomWeight`),i=P(e,`borderLeftWeight`);return t===null&&n===null&&r===null&&i===null?null:{top:t,right:n,bottom:r,left:i}}function We(e){let t=N(e,`horizontalConstraint`),n=N(e,`verticalConstraint`);return t===null&&n===null?null:{horizontal:t,vertical:n}}const Ge=new Set([`top`,`right`,`bottom`,`left`]);function Ke(e,t){let n=L(e,`margin`);if(n===null)return null;R(n,Ge,`margin.`,t);let r=P(n,`top`),i=P(n,`right`),a=P(n,`bottom`),o=P(n,`left`);return r===null&&i===null&&a===null&&o===null?null:{top:r,right:i,bottom:a,left:o}}function qe(e,t,n,r){let i=[];for(let a of I(e,`instanceOverriddenList`)){if(!M(a))continue;let e=et(a,n);if(e!==null)for(let t of e.unknownKeys)r.push(`instanceOverriddenList[].${t}`);if(e===null){n.push({severity:`info`,code:`overridden-snapshot-without-guid`,message:`instanceOverriddenList entry has no guid — skipped (unaddressable)`,path:t});continue}i.push({...e,presentKeys:Object.keys(a).sort()})}return i}const Je=new Set([`url`]);function Ye(e,t){let n=null;for(let r of I(e,`links`)){if(!M(r))continue;R(r,Je,`links[].`,t);let e=N(r,`url`);e!==null&&n===null&&(n=e)}return n}const Xe=new Set([`pathString`,`componentId`,`type`,`name`,`nodeText`,`inheritTextStyleID`,`inheritFillStyleID`,`left`,`top`,`width`,`height`,`cornerRadius`,`fillPaints`]);function Ze(e,t,n,r){let i=[];for(let a of I(e,`props`)){if(!M(a))continue;let e=N(a,`pathString`);if(e===null||e===``)continue;let o=e.split(`/`).filter(e=>e!==``),s=o[o.length-1];if(s===void 0)continue;let c=Object.keys(a).sort(),l=c.filter(e=>!Xe.has(e));i.push({path:o,targetGuid:s,componentId:N(a,`componentId`),rawType:N(a,`type`),name:N(a,`name`),text:N(a,`nodeText`),textStyleId:Me(a,`inheritTextStyleID`),fillStyleId:Me(a,`inheritFillStyleID`),left:P(a,`left`),top:P(a,`top`),width:P(a,`width`),height:P(a,`height`),cornerRadius:P(a,`cornerRadius`),fills:Ce(a,`fillPaints`,`${t}/${s}`,n,r,`props[].fillPaints`),changedKeys:c}),l.length>0&&n.push({severity:`info`,code:`instance-override-extra-keys`,message:`Instance override on ${s} carries unmodelled keys: ${l.join(`, `)}`,path:t})}return i}const Qe=[[`autoLayout`,`record`],[`fillPaints`,`array`],[`strokePaints`,`array`],[`effects`,`array`],[`instanceOverriddenList`,`array`],[`parentGuids`,`array`],[`props`,`array`],[`links`,`array`],[`dashPattern`,`array`],[`propDefMap`,`record`],[`propAssignMap`,`record`],[`propRefMap`,`record`],[`margin`,`record`]];function $e(e,t){for(let[n,r]of Qe){let i=e[n];i!=null&&((r===`array`?Array.isArray(i):M(i))||t.push(`${n}${de}`))}}function et(e,t){let n=N(e,`guid`);if(n===null)return null;let r=N(e,`type`)??``,i=Oe[r]??`unknown`;i===`unknown`&&t.push({severity:`warning`,code:`unknown-node-type`,message:`Unverified node type "${r}" — geometry parsed, semantics unknown`,path:n});let a=N(e,`name`)??n,o=L(e,`autoLayout`)??{},s=I(e,`parentGuids`).filter(e=>typeof e==`string`),c=[];$e(e,c),R(o,se,`autoLayout.`,c);let l=Ce(e,`fillPaints`,n,t,c),u=Ce(e,`strokePaints`,n,t,c),d=ge(e,n,t,c),f=Be(e,c),p=Ze(e,n,t,c),m=qe(e,n,t,c),h=Ke(e,c),g=N(e,`url`)??Ye(e,c),_=Object.keys(e).filter(e=>!ke.has(e)&&!Ae.has(e)&&!Pe.test(e)),v=[..._,...c];return v.length>0&&t.push({severity:`info`,code:`unknown-node-keys`,message:`Unrecognized node keys: ${v.join(`, `)}`,path:n}),{guid:n,name:a,kind:i,rawType:r,visible:F(e,`visible`)??!0,opacity:re(e,`opacity`,1),rotation:P(e,`angle`)??0,width:P(e,`width`)??0,height:P(e,`height`)??0,absoluteX:P(e,`globalLeft`),absoluteY:P(e,`globalTop`),cornerRadius:P(e,`cornerRadius`),cornerRadii:ue(e),fills:l,strokes:u,strokeWeight:P(e,`strokeWeight`),strokeAlign:N(e,`strokeAlign`),borders:Ue(e),strokeDashed:I(e,`dashPattern`).length>0,autoLayout:ce(o,n,t),childLayout:le(o,F(e,`autoLayoutByParent`),n,t),text:Te(e,n,t),component:He(e,a),isMask:i===`mask`||(F(e,`mask`)??!1),sticky:N(e,`scrollBehavior`)===`FIXED_WHEN_CHILD_OF_SCROLLING_FRAME`,url:g,fillStyleId:Me(e,`inheritFillStyleID`),textStyleId:Me(e,`inheritTextStyleID`),effects:d,componentProps:f,instanceOverrides:p,overriddenList:m,margin:h,constraints:We(e),scrollDirection:N(e,`scrollDirection`),descriptionRich:N(e,`descriptionRich`),blendMode:N(e,`blendMode`),unknownKeys:v,unknownKeySamples:Object.fromEntries(_.map(t=>[t,Ne(e[t])])),parentGuid:N(e,`parentGuid`),parentGuids:s,left:P(e,`left`)??0,top:P(e,`top`)??0}}function tt(e,t){return t===null?{x:0,y:0}:e.absoluteX!==null&&e.absoluteY!==null&&t.absoluteX!==null&&t.absoluteY!==null?{x:e.absoluteX-t.absoluteX,y:e.absoluteY-t.absoluteY}:{x:e.left,y:e.top}}function nt(e){let t=[],n=new Map;for(let r of e){if(n.has(r.guid)){t.push({severity:`warning`,code:`duplicate-guid`,message:`Duplicate node guid — the later entry was ignored`,path:r.guid});continue}n.set(r.guid,r)}let r=new Map,i=[];for(let e of n.values()){let a=e.parentGuid===null?void 0:n.get(e.parentGuid);if(a===void 0||a.guid===e.guid){a!==void 0&&t.push({severity:`warning`,code:`parent-cycle`,message:`Cyclic parent chain broken`,path:e.guid}),i.push(e);continue}let o=r.get(a.guid)??[];o.push(e),r.set(a.guid,o)}let a=new Set,o=(e,n)=>{a.add(e.guid);let i=tt(e,n),s=(r.get(e.guid)??[]).filter(e=>a.has(e.guid)?(t.push({severity:`warning`,code:`parent-cycle`,message:`Cyclic parent chain broken`,path:e.guid}),!1):!0).map(t=>o(t,e)),{parentGuid:c,parentGuids:l,left:u,top:d,...f}=e;return{...f,x:i.x,y:i.y,children:s}},s=i.map(e=>o(e,null));for(let e of n.values())a.has(e.guid)||t.push({severity:`warning`,code:`orphan-cycle-node`,message:`Node unreachable from any root (cyclic island) — dropped`,path:e.guid});return{roots:s,diagnostics:t}}const rt=new Set([`dslVersion`,`converterVersion`,`sourceMapByUrl`,`pixDslNodes`,`pixComponentNodes`,`variableMap`,`variableSetMap`,`localStyleMap`,`isContainFixed`,`specialNode`,`NameGenerator`]),it={dslVersion:null,converterVersion:null,fonts:[],root:null,detachedNodes:[],components:[],pageGuid:null,unknownEnvelopeKeys:[]};function at(e,t){let n=e;for(let e=0;e<4;e+=1){if(typeof n==`string`)try{n=JSON.parse(n);continue}catch{return t.push({severity:`warning`,code:`invalid-json`,message:`Input string is not valid JSON (truncated dump?) — nothing to parse`}),null}if(!M(n))return t.push({severity:`warning`,code:`unsupported-input`,message:`Unsupported input of type ${Array.isArray(n)?`array`:typeof n}`}),null;if(`pixDslNodes`in n||`dslVersion`in n)return n;let e=I(n,`content`).find(e=>M(e)&&e.type===`text`&&typeof e.text==`string`);if(e!==void 0&&M(e)){n=e.text;continue}let r=N(n,`output`);if(r!==null){n=r;continue}return`roots`in n||`refsIndex`in n?(t.push({severity:`warning`,code:`unsupported-dialect`,message:`Modern Pixso DSL dialect detected (roots/refsIndex) — this assistant targets the legacy pixDslNodes contract`}),null):(t.push({severity:`warning`,code:`unrecognized-envelope`,message:`Object has neither DSL keys nor a known wrapper shape`}),null)}return t.push({severity:`warning`,code:`envelope-too-deep`,message:`Gave up unwrapping after 4 nested envelopes`}),null}function ot(e,t){let n=L(e,`sourceMapByUrl`);if(n===null)return[];let r=[],i=new Set;for(let[e,a]of Object.entries(n)){if(!M(a)||a.type!==`font`)continue;let n=L(a,`fontKey`),o=n===null?null:N(n,`family`),s=n===null?null:N(n,`style`);if(o===null||s===null){t.push({severity:`warning`,code:`malformed-font-entry`,message:`sourceMapByUrl["${e}"] has no readable fontKey`});continue}let c=`${o}|${s}`;i.has(c)||(i.add(c),r.push({family:o,style:s}))}return r}function st(e,t,n){let r={push:e=>n.push(e)},i=[];for(let[a,o]of I(e,t).entries()){if(!M(o)){n.push({severity:`warning`,code:`malformed-node`,message:`${t}[${a}] is not an object — skipped`});continue}let e=et(o,r);if(e===null){n.push({severity:`warning`,code:`node-without-guid`,message:`${t}[${a}] has no guid — skipped (unaddressable)`});continue}i.push(e)}let a=nt(i);return n.push(...a.diagnostics),a.roots}function ct(e,t){for(let n of[`variableMap`,`variableSetMap`,`localStyleMap`]){let r=L(e,n);r!==null&&Object.keys(r).length>0&&t.push({severity:`info`,code:`unverified-map-populated`,message:`${n} is populated — its shape is unverified; raw data preserved upstream`,path:n})}}function lt(e){let t=[],n=at(e,t);if(n===null)return{...it,ok:!1,diagnostics:t};let r=Object.keys(n).filter(e=>!rt.has(e));r.length>0&&t.push({severity:`info`,code:`unknown-envelope-keys`,message:`Unrecognized envelope keys: ${r.join(`, `)}`}),ct(n,t);let i=ot(n,t),a=st(n,`pixDslNodes`,t),o=st(n,`pixComponentNodes`,t),[s=null,...c]=a;c.length>0&&t.push({severity:`warning`,code:`multiple-roots`,message:`pixDslNodes produced ${a.length} roots; the first one is treated as THE node`});let l=I(n,`pixDslNodes`).find(M),u=l===void 0?[]:I(l,`parentGuids`),d=typeof u[0]==`string`?u[0]:null,f=s!==null||o.length>0||i.length>0;return f||t.push({severity:`warning`,code:`empty-dsl`,message:`Envelope parsed but contained no nodes, components or fonts`}),{ok:f,dslVersion:N(n,`dslVersion`),converterVersion:N(n,`converterVersion`),fonts:i,root:s,detachedNodes:c,components:o,pageGuid:d,unknownEnvelopeKeys:r,diagnostics:t}}function ut(e){try{return lt(e)}catch(e){return{...it,ok:!1,diagnostics:[{severity:`warning`,code:`internal-error`,message:`Parser bug guard: ${e instanceof Error?e.message:String(e)}`}]}}}function z(e){let t=[],n=[e];for(;n.length>0;){let e=n.pop();t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}return t}const dt={fixed:`fixed`,hug:`hug`,fill:`fill`,unknown:`?`};function ft(e){let t=[e.mode];if(t.push(`${dt[e.primarySizing]??`?`}×${dt[e.counterSizing]??`?`}`),e.gap!==null&&t.push(`gap ${e.gap}`),e.padding!==null){let{top:n,right:r,bottom:i,left:a}=e.padding;t.push(`padding ${n}/${r}/${i}/${a}`)}return e.alignType!==null&&t.push(e.alignType),t.join(` · `)}const pt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),B=(e,t)=>typeof e[t]==`string`?e[t]:null,mt=(e,t)=>typeof e[t]==`number`&&Number.isFinite(e[t])?e[t]:null;function ht(e){let t=[],n;try{n=JSON.parse(e)}catch{return{entries:[],diagnostics:[{severity:`warning`,code:`catalog-invalid-json`,message:`get_all_components payload is not valid JSON — catalog skipped`}]}}let r=Array.isArray(n)?n:pt(n)&&Array.isArray(n.components)?n.components:null;if(r===null)return{entries:[],diagnostics:[{severity:`warning`,code:`catalog-unrecognized-shape`,message:`get_all_components payload is neither an array nor {components: []}`}]};let i=[];for(let[e,n]of r.entries()){if(!pt(n)){t.push({severity:`warning`,code:`catalog-malformed-entry`,message:`components[${e}] is not an object — skipped`});continue}let r=B(n,`component_key`);if(r===null){t.push({severity:`warning`,code:`catalog-entry-without-key`,message:`components[${e}] has no component_key — skipped (unjoinable)`});continue}let a=pt(n.containing_frame)?n.containing_frame:{},o=pt(a.containingStateGroup)?a.containingStateGroup:null;i.push({component_key:r,name:B(n,`name`)??r,description:B(n,`description`)??``,file_key:B(n,`file_key`)??``,node_id:B(n,`node_id`)??``,containing_frame:{pageId:B(a,`pageId`)??``,pageName:B(a,`pageName`)??``,...o===null?{}:{containingStateGroup:{name:B(o,`name`)??``,nodeId:B(o,`nodeId`)??``}}},content_hash:B(n,`content_hash`)??``,updated_at:B(n,`updated_at`),min_node_width:mt(n,`min_node_width`)??0,min_node_height:mt(n,`min_node_height`)??0,thumbnail_url:B(n,`thumbnail_url`)??``})}return{entries:i,diagnostics:t}}function gt(e,t){return{capturedAtIso:e,libraryNames:{},entries:t}}const _t=/(deprecated|❌)/i;function vt(e){let t=new Map;for(let n of e)for(let e of z(n))for(let n of e.componentProps)t.has(n.propKey)||t.set(n.propKey,n);return t}function yt(e,t){return e.componentProps.map(e=>{let n=t.get(e.propKey),r=n?.defaultValue??e.defaultValue??``,i=e.value??r;return{name:e.name??n?.name??e.propKey,kind:e.kind,value:i,defaultValue:r,overridden:e.value!==null&&e.value!==r}})}function bt(e,t,n){let r=new Map(n.map(e=>[e.component_key,e])),i=vt(t),a=new Map;for(let t of z(e)){let e=t.component?.componentKey??null;if(e===null||t.kind!==`instance`)continue;let n=a.get(e);n===void 0?a.set(e,{first:t,count:1}):n.count+=1}return[...a.entries()].map(([e,{first:t,count:n}])=>{let a=r.get(e),o=a?.containing_frame.containingStateGroup?.name??t.component?.mainStateGroup??null,s=a?.name??t.component?.normName??t.name;return{key:e,name:s,variantGroup:o,library:null,libraryFileKey:a?.file_key??t.component?.publishFile??null,pageName:a?.containing_frame.pageName??null,description:a!==void 0&&a.description!==``?a.description:t.component!==null&&t.component.description!==``?t.component.description:null,updatedAt:a?.updated_at??null,deprecated:_t.test(s)||o!==null&&_t.test(o),resolved:a!==void 0,count:n,props:yt(t,i)}})}const xt=[{name:`get_node_dsl`,description:`DSL of a node (structure + fonts + colors).`,write:!1,params:[{name:`itemId`,type:`string`,required:!1,description:`node id; omit → current selection`},{name:`clientFrameworks`,type:`enum(react|vue|html|arkui|flutter)`,required:!1,description:`logging hint`}]},{name:`get_image`,description:`Preview image of a node.`,write:!1,params:[{name:`itemId`,type:`string`,required:!1},{name:`clientFrameworks`,type:`enum(arkui|flutter|html|react|vue)`,required:!1}]},{name:`get_export_image`,description:`Export a node as an image file.`,write:!1,params:[{name:`itemId`,type:`string`,required:!1},{name:`exportSettings`,type:`object`,required:!0,description:`constraint + imageType`}]},{name:`get_variants`,description:`Variants of a component set.`,write:!1,params:[{name:`itemId`,type:`string`,required:!1}]},{name:`get_variables`,description:`Variables of a set (all if omitted).`,write:!1,params:[{name:`variableSetId`,type:`string`,required:!1}]},{name:`get_variable_sets`,description:`All variable sets.`,write:!1,params:[]},{name:`get_local_styles`,description:`All local styles.`,write:!1,params:[]},{name:`get_remote_styles`,description:`All remote/library styles.`,write:!1,params:[]},{name:`get_all_components`,description:`All components in the file.`,write:!1,params:[]},{name:`design_to_code`,description:`Generate UI code (dead on 2.4).`,write:!1,params:[{name:`itemId`,type:`string`,required:!1},{name:`clientFrameworks`,type:`enum(arkui|flutter|html|react|vue)`,required:!1}]},{name:`create_instance`,description:`Create a component instance.`,write:!0,params:[{name:`componentKey`,type:`string`,required:!0}]},{name:`set_fill_style`,description:`Set a node fill style.`,write:!0,params:[{name:`itemId`,type:`string`,required:!1},{name:`styleKey`,type:`string`,required:!0}]},{name:`set_stroke_style`,description:`Set a node stroke style.`,write:!0,params:[{name:`itemId`,type:`string`,required:!1},{name:`styleKey`,type:`string`,required:!0}]},{name:`set_text_style`,description:`Set a text style.`,write:!0,params:[{name:`itemId`,type:`string`,required:!1},{name:`styleKey`,type:`string`,required:!0}]},{name:`set_grid_style`,description:`Set a grid style.`,write:!0,params:[{name:`itemId`,type:`string`,required:!1},{name:`styleKey`,type:`string`,required:!0}]},{name:`set_bound_variables`,description:`Bind variables to attributes.`,write:!0,params:[{name:`bindings`,type:`array`,required:!0}]},{name:`code_to_design`,description:`Convert HTML/ZIP into Pixso nodes.`,write:!0,params:[{name:`htmlStr`,type:`string`,required:!1},{name:`htmlBuffer`,type:`array`,required:!1}]}],St=new Map(xt.map(e=>[e.name,e]));function Ct(e){let t=St.get(e);return t!==void 0&&t.write}function wt(e){let t=St.get(e);return t!==void 0&&!t.write}const Tt=15e3;var Et=class extends Error{constructor(e){super(`Истекло время ожидания ответа MCP-сервера (${Math.round(e/1e3)}с)`),this.name=`PixsoTimeoutError`}};function Dt(e){return`type`in e&&typeof e.type==`string`?e.type:void 0}function Ot(e){return`description`in e&&typeof e.description==`string`?e.description:``}function kt(e){if(!(`enum`in e)||!Array.isArray(e.enum))return;let t=e.enum;if(t.every(e=>typeof e==`string`))return[...t].sort()}function At(e){let t=Dt(e)??`any`;if(t!==`array`||!(`items`in e))return t;let n=e.items;if(typeof n==`object`&&n){let e=Dt(n);if(e!==void 0)return`${e}[]`}return`array`}function jt(e){let t=e.properties;if(t===void 0)return[];let n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>{let r=Ot(t),i=kt(t);return{name:e,type:At(t),required:n.has(e),...r===``?{}:{description:r},...i===void 0?{}:{enumValues:i}}})}var Mt=class extends Error{cause;constructor(e){super(e instanceof Error?e.message:String(e)),this.name=`PixsoToolPhaseError`,this.cause=e}};async function Nt(e,t,n){let r=new E({name:`ru-code-pixso-assistant`,version:`0.0.0`}),i=new ee(new URL(e)),a,o=new Promise((e,n)=>{a=setTimeout(()=>n(new Et(t)),2*t+5e3)}),s=(async()=>{await r.connect(i,{timeout:t});try{return await n(r)}catch(e){throw new Mt(e)}})();try{return await Promise.race([s,o])}finally{a!==void 0&&clearTimeout(a),await r.close().catch(()=>void 0),s.catch(()=>void 0)}}function Pt(e){return e instanceof Et?!0:e instanceof Error?/timeout|timed out|abort/i.test(e.message)||e.name===`TimeoutError`:!1}function Ft(e){return!(e instanceof Mt)||Pt(e.cause)?`transport`:`tool`}function It(e){return e instanceof Mt?e.cause:e}function Lt(e,t,n=`transport`){let r=Pt(e);return{ok:!1,timedOut:r,origin:r?`transport`:n,message:e instanceof Error?e.message:String(e),ms:Math.round(performance.now()-t)}}async function Rt(e,t=Tt){let n=performance.now();try{return{ok:!0,tools:await Nt(e,t,async e=>(await e.listTools(void 0,{timeout:t})).tools.map(e=>({name:e.name,description:e.description??``,params:jt(e.inputSchema),inputSchema:e.inputSchema}))),ms:Math.round(performance.now()-n)}}catch(e){return Lt(It(e),n,Ft(e))}}async function zt(e,t=Tt){let n=await Rt(e,t);return n.ok?{ok:!0,tools:n.tools.map(({inputSchema:e,...t})=>t),ms:n.ms}:n}function Bt(e){return Array.isArray(e)?e.flatMap(e=>typeof e==`object`&&e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`?[e.text]:[]):[]}async function Vt(e,t,n,r=Tt){let i=performance.now();try{return{ok:!0,...await Nt(e,r,async e=>{let i=await e.callTool({name:t,arguments:{...n}},void 0,{timeout:r});return{result:i,texts:Bt(i.content),isError:i.isError===!0}}),ms:Math.round(performance.now()-i)}}catch(e){return Lt(It(e),i,Ft(e))}}async function Ht(e,t,n,r=Tt){let i=await Vt(e,t,n,r);return i.ok?i.isError?{ok:!1,timedOut:!1,origin:`tool`,message:i.texts[0]??`Инструмент ${t} вернул ошибку`,ms:i.ms}:{ok:!0,texts:i.texts,ms:i.ms}:i}var Ut=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/mcp/PixsoMcp`){};const Wt=(e,t)=>({endpoint:e,callTimeoutMs:t??Tt,listTools:()=>_.promise(()=>zt(e,t)),listToolsRaw:()=>_.promise(()=>Rt(e,t)),callTool:(n,r,i)=>_.promise(()=>Ht(e,n,r,i??t)),callToolRaw:(n,r,i)=>_.promise(()=>Vt(e,n,r,i??t))}),Gt=v.succeed(Ut,Wt(o));var Kt=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/ports/PixsoAssistantConfig`){},qt=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/ports/PixsoIndexSql`){};const Jt=e=>e.includes(`.staged-`),Yt=(e,t)=>e.startsWith(`${t}.`)&&e.length>t.length+1,Xt=e=>te.platform===`win32`?_.logDebug(`[pixso] store: directory sync unavailable on Windows`,{dirPath:e}):_.scoped(_.gen(function*(){yield*(yield*(yield*C.FileSystem).open(e,{flag:`r`})).sync})),Zt=e=>_.forEach([...new Set(e)],Xt,{discard:!0}),Qt=e=>_.gen(function*(){let t=yield*C.FileSystem,n=yield*w.Path,r=[],i=e;for(;!(yield*t.exists(i));){r.push(i);let e=n.dirname(i);if(e===i)break;i=e}r.length!==0&&(yield*t.makeDirectory(e,{recursive:!0}),yield*Zt(r.map(e=>n.dirname(e))))}),$t=e=>_.scoped(_.gen(function*(){let t=yield*C.FileSystem,n=yield*w.Path,r=n.dirname(e.filePath);yield*Qt(r);let i=yield*t.makeTempDirectoryScoped({directory:r,prefix:`${n.basename(e.filePath)}.`}),a=n.join(i,`contents.tmp`);yield*_.scoped(_.gen(function*(){let n=yield*t.open(a,{flag:`w`});yield*n.writeAll(new TextEncoder().encode(e.contents)),yield*n.sync})),yield*t.rename(a,e.filePath),yield*Xt(r)})),en=/^[0-9a-f]{64}$/,V=e=>en.test(e)?_.void:_.fail(k.badArgument({module:`FileSystem`,method:`validateHash`,description:`invalid content hash: ${e}`})),tn=e=>e.pipe(_.catch(e=>e.reason._tag===`NotFound`?_.succeed(null):_.fail(e))),nn=(e,t)=>{let n=e.join(t,`scans`),r=e.join(t,`catalogs`);return{rootDir:t,scansDir:n,catalogsDir:r,quarantineDir:e.join(t,`_quarantine`),diagnosticsDir:e.join(t,`_diagnostics`),scanDir:t=>e.join(n,t),scanDsl:t=>e.join(n,t,`dsl.raw`),scanCard:t=>e.join(n,t,`card.json`),scanSummary:t=>e.join(n,t,`summary.json`),scanPreview:t=>e.join(n,t,`preview.svg`),catalogBlob:t=>e.join(r,`${t}.json`)}},rn=e=>{let t=(e,t)=>V(e).pipe(_.andThen(_.gen(function*(){return yield*(yield*C.FileSystem).readFileString(t)}))),n=n=>t(n,e.scanCard(n)),r=e=>tn(n(e)),i=n=>t(n,e.scanDsl(n)),a=e=>tn(i(e)),o=n=>t(n,e.scanSummary(n)),s=e=>tn(o(e)),c=t=>V(t).pipe(_.andThen(_.gen(function*(){return yield*(yield*C.FileSystem).readFileString(e.catalogBlob(t))})));return{readCard:n,readCardOrNull:r,readDsl:i,readDslOrNull:a,readSummary:o,readSummaryOrNull:s,readCatalog:c,readCatalogOrNull:e=>tn(c(e)),dslExists:t=>V(t).pipe(_.andThen(_.gen(function*(){return yield*(yield*C.FileSystem).exists(e.scanDsl(t))}))),scanDirExists:t=>V(t).pipe(_.andThen(_.gen(function*(){return yield*(yield*C.FileSystem).exists(e.scanDir(t))}))),writeDsl:(t,n)=>V(t).pipe(_.andThen($t({filePath:e.scanDsl(t),contents:n}))),writeCard:(t,n)=>V(t).pipe(_.andThen($t({filePath:e.scanCard(t),contents:n}))),writeSummary:(t,n)=>V(t).pipe(_.andThen($t({filePath:e.scanSummary(t),contents:n}))),writeCatalog:(t,n)=>V(t).pipe(_.andThen(_.gen(function*(){(yield*(yield*C.FileSystem).exists(e.catalogBlob(t)))||(yield*$t({filePath:e.catalogBlob(t),contents:n}))}))),removeDsl:t=>V(t).pipe(_.andThen(_.gen(function*(){yield*(yield*C.FileSystem).remove(e.scanDsl(t),{force:!0})}))),removeCatalog:t=>V(t).pipe(_.andThen(_.gen(function*(){yield*(yield*C.FileSystem).remove(e.catalogBlob(t),{force:!0})}))),removeScanDir:t=>V(t).pipe(_.andThen(_.gen(function*(){yield*(yield*C.FileSystem).remove(e.scanDir(t),{recursive:!0,force:!0})}))),quarantineScanDir:(t,n)=>V(t).pipe(_.andThen(_.gen(function*(){let r=yield*C.FileSystem;yield*r.makeDirectory(e.quarantineDir,{recursive:!0});let i=`${n}-${t}`;yield*r.rename(e.scanDir(t),e.quarantineDir+`/`+i)}))),listScanDirs:()=>_.gen(function*(){return yield*(yield*C.FileSystem).readDirectory(e.scansDir).pipe(_.orElseSucceed(()=>[]))}),listScanDirEntries:t=>V(t).pipe(_.andThen(_.gen(function*(){return yield*(yield*C.FileSystem).readDirectory(e.scanDir(t)).pipe(_.orElseSucceed(()=>[]))}))),listCatalogEntries:()=>_.gen(function*(){return yield*(yield*C.FileSystem).readDirectory(e.catalogsDir).pipe(_.orElseSucceed(()=>[]))}),listQuarantineEntries:()=>_.gen(function*(){return yield*(yield*C.FileSystem).readDirectory(e.quarantineDir).pipe(_.orElseSucceed(()=>[]))}),removeQuarantineEntry:t=>_.gen(function*(){let n=yield*C.FileSystem,r=yield*w.Path;yield*n.remove(r.join(e.quarantineDir,t),{recursive:!0,force:!0})}),statScanDir:t=>V(t).pipe(_.andThen(_.gen(function*(){return yield*tn((yield*C.FileSystem).stat(e.scanDir(t)))}))),ensureScanDir:t=>V(t).pipe(_.andThen(Qt(e.scanDir(t)))),paths:e}},an=e=>A.createHash(`sha256`).update(e,`utf8`).digest(`hex`),on=`unsortedPinned`,sn=`unsortedCollapsed`,H=`lastReport`,cn=`lastProbe`,ln=`lastCheck`,U=e=>typeof e==`string`?e:String(e),W=e=>typeof e==`number`?e:Number(e),un=e=>W(e)===1,dn=e=>e==null?null:U(e),fn=e=>{let t=()=>e`SELECT * FROM scans WHERE deleted = 0 ORDER BY ordinal ASC`.pipe(_.map(e=>e.map(pn)),_.orDie),n=t=>e`SELECT * FROM scans WHERE dsl_hash = ${t} AND deleted = 0`.pipe(_.map(e=>e[0]===void 0?null:pn(e[0])),_.orDie),r=()=>e`SELECT COUNT(*) AS n FROM scans WHERE deleted = 0`.pipe(_.map(e=>W(e[0]?.n??0)),_.orDie),i=t=>e`
|
|
2
|
+
SELECT dsl_hash FROM scans
|
|
3
|
+
WHERE node_id = ${t} AND deleted = 0
|
|
4
|
+
ORDER BY imported_at DESC LIMIT 1
|
|
5
|
+
`.pipe(_.map(e=>e[0]===void 0?null:U(e[0].dsl_hash)),_.orDie),a=t=>e`UPDATE scans SET deleted = 1 WHERE dsl_hash = ${t}`,o=()=>e`SELECT dsl_hash FROM scans WHERE deleted = 1`.pipe(_.map(e=>e.map(e=>U(e.dsl_hash))),_.orDie),s=t=>_.gen(function*(){yield*e`DELETE FROM scans WHERE dsl_hash = ${t}`,yield*e`DELETE FROM group_by_card WHERE card_id = ${t}`,yield*e`DELETE FROM recents WHERE card_id = ${t}`}),c=()=>_.gen(function*(){let t=yield*e`SELECT * FROM groups ORDER BY ordinal ASC`,n=yield*e`SELECT card_id, group_id FROM group_by_card`,r=yield*e`SELECT card_id FROM recents ORDER BY ordinal ASC`,i=yield*e`SELECT k, v FROM panel`,a=new Map(i.map(e=>[U(e.k),U(e.v)]));return{groups:t.map(e=>({id:U(e.id),name:U(e.name),pinned:un(e.pinned),collapsed:un(e.collapsed)})),groupByCardId:Object.fromEntries(n.map(e=>[U(e.card_id),U(e.group_id)])),unsortedPinned:a.get(on)!==`0`,unsortedCollapsed:a.get(sn)===`1`,recents:r.map(e=>U(e.card_id))}}).pipe(_.orDie),l=t=>e`SELECT v FROM panel WHERE k = ${t}`.pipe(_.map(e=>e[0]===void 0?null:U(e[0].v)),_.orDie),u=t=>e`SELECT 1 FROM scans WHERE catalog_hash = ${t} LIMIT 1`.pipe(_.map(e=>e.length>0),_.orDie),d=(t,n)=>e`
|
|
6
|
+
SELECT dsl_hash FROM scans
|
|
7
|
+
WHERE dsl_hash IS NOT ${n}
|
|
8
|
+
ORDER BY imported_at DESC, dsl_hash DESC
|
|
9
|
+
LIMIT -1 OFFSET ${t}
|
|
10
|
+
`.pipe(_.map(e=>e.map(e=>U(e.dsl_hash))),_.orDie),f=(t,n)=>e`
|
|
11
|
+
SELECT catalog_hash, MAX(imported_at) AS newest FROM scans
|
|
12
|
+
WHERE catalog_hash IS NOT NULL AND catalog_hash IS NOT ${n}
|
|
13
|
+
GROUP BY catalog_hash
|
|
14
|
+
ORDER BY newest DESC, catalog_hash DESC
|
|
15
|
+
LIMIT -1 OFFSET ${t}
|
|
16
|
+
`.pipe(_.map(e=>e.map(e=>U(e.catalog_hash))),_.orDie),p=t=>{let n=t.summary;return e`
|
|
17
|
+
INSERT INTO scans (
|
|
18
|
+
dsl_hash, ordinal, node_id, name, imported_at, catalog_hash,
|
|
19
|
+
node_type, width, height, layer_count, complexity_band, complexity_fill,
|
|
20
|
+
colors_json, instance_total, deprecated_used, identity_json
|
|
21
|
+
) VALUES (
|
|
22
|
+
${n.id},
|
|
23
|
+
(SELECT COALESCE(MAX(ordinal), 0) + 1 FROM scans),
|
|
24
|
+
${n.nodeId}, ${n.name}, ${n.importedAtIso}, ${t.catalogHash},
|
|
25
|
+
${n.nodeType}, ${n.width}, ${n.height}, ${n.layerCount},
|
|
26
|
+
${n.complexityBand}, ${n.complexityFilled},
|
|
27
|
+
${JSON.stringify(n.colors)}, ${n.instanceTotal}, ${n.deprecatedUsed},
|
|
28
|
+
${JSON.stringify(n.identity)}
|
|
29
|
+
)
|
|
30
|
+
`},m=t=>{let n=t.summary;return e`
|
|
31
|
+
UPDATE scans SET
|
|
32
|
+
node_id = ${n.nodeId}, name = ${n.name}, catalog_hash = ${t.catalogHash},
|
|
33
|
+
node_type = ${n.nodeType}, width = ${n.width}, height = ${n.height},
|
|
34
|
+
layer_count = ${n.layerCount}, complexity_band = ${n.complexityBand},
|
|
35
|
+
complexity_fill = ${n.complexityFilled}, colors_json = ${JSON.stringify(n.colors)},
|
|
36
|
+
instance_total = ${n.instanceTotal}, deprecated_used = ${n.deprecatedUsed},
|
|
37
|
+
identity_json = ${JSON.stringify(n.identity)}
|
|
38
|
+
WHERE dsl_hash = ${n.id}
|
|
39
|
+
`},h=t=>_.gen(function*(){yield*e`DELETE FROM scans WHERE dsl_hash = ${t}`,yield*e`DELETE FROM group_by_card WHERE card_id = ${t}`,yield*e`DELETE FROM recents WHERE card_id = ${t}`}),g=t=>_.gen(function*(){yield*e`DELETE FROM recents`;for(let[n,r]of t.entries())yield*e`INSERT INTO recents (card_id, ordinal) VALUES (${r}, ${n})`}),v=(t,n)=>e`
|
|
40
|
+
INSERT INTO panel (k, v) VALUES (${t}, ${n})
|
|
41
|
+
ON CONFLICT(k) DO UPDATE SET v = excluded.v
|
|
42
|
+
`,y=(e,t)=>v(e,t?`1`:`0`);return{listScans:t,getScan:n,scanCount:r,findByNodeId:i,readGalleryState:c,readPanelJson:l,catalogIsReferenced:u,rawEvictionCandidates:d,catalogEvictionCandidates:f,newestCatalogImport:t=>e`
|
|
43
|
+
SELECT imported_at FROM scans
|
|
44
|
+
WHERE catalog_hash = ${t} AND deleted = 0
|
|
45
|
+
ORDER BY imported_at DESC LIMIT 1
|
|
46
|
+
`.pipe(_.map(e=>e[0]===void 0?null:U(e[0].imported_at)),_.orDie),insertScan:p,updateScanSummary:m,deleteScan:h,markDeleted:a,listDeleted:o,hardDeleteScan:s,setRecents:g,setPanelJson:v,writeGalleryState:(t,n)=>_.gen(function*(){yield*e`DELETE FROM groups`;for(let[t,r]of n.groups.entries())yield*e`
|
|
47
|
+
INSERT INTO groups (id, name, ordinal, pinned, collapsed)
|
|
48
|
+
VALUES (${r.id}, ${r.name}, ${t},
|
|
49
|
+
${r.pinned?1:0}, ${r.collapsed?1:0})
|
|
50
|
+
`;for(let r of Object.keys(t.groupByCardId))n.groupByCardId[r]===void 0&&(yield*e`DELETE FROM group_by_card WHERE card_id = ${r}`);for(let[r,i]of Object.entries(n.groupByCardId))t.groupByCardId[r]!==i&&(yield*e`
|
|
51
|
+
INSERT INTO group_by_card (card_id, group_id) VALUES (${r}, ${i})
|
|
52
|
+
ON CONFLICT(card_id) DO UPDATE SET group_id = excluded.group_id
|
|
53
|
+
`);t.unsortedPinned!==n.unsortedPinned&&(yield*y(on,n.unsortedPinned)),t.unsortedCollapsed!==n.unsortedCollapsed&&(yield*y(sn,n.unsortedCollapsed)),t.recents.join(`\0`)!==n.recents.join(`\0`)&&(yield*g(n.recents))}),transaction:e.withTransaction}},pn=e=>({catalogHash:dn(e.catalog_hash),summary:{id:U(e.dsl_hash),nodeId:U(e.node_id),name:U(e.name),importedAtIso:U(e.imported_at),nodeType:U(e.node_type),width:W(e.width),height:W(e.height),layerCount:W(e.layer_count),complexityBand:U(e.complexity_band),complexityFilled:W(e.complexity_fill),colors:JSON.parse(U(e.colors_json)),instanceTotal:W(e.instance_total),deprecatedUsed:W(e.deprecated_used),identity:JSON.parse(U(e.identity_json)),previewSvg:``}}),mn={frame:`frame`,group:`group`,rect:`rect`,ellipse:`ellipse`,text:`text`,vector:`vector`,instance:`instance`,symbol:`symbol`,line:`line`,mask:`mask`,unknown:`vector`},hn={INSIDE:`inside`,CENTER:`center`,OUTSIDE:`outside`},gn=new Set([`flex-start`,`center`,`flex-end`]),_n={center:`center`,right:`right`,justify:`justify`,justified:`justify`},vn=e=>e===null?void 0:_n[e.toLowerCase()],G=e=>e.hex===null?null:l(e.hex,f(e.alpha,e.opacity)),yn=e=>e===`fixed`||e===`hug`||e===`fill`?e:null,bn=e=>e!==null&&gn.has(e)?e:void 0;function xn(e){return e.filter(e=>e.visible).map(e=>({kind:e.kind,...e.color===null?{}:{color:l(e.color,e.colorAlpha)},...e.offsetX===null?{}:{offsetX:e.offsetX},...e.offsetY===null?{}:{offsetY:e.offsetY},...e.spread===null?{}:{spread:e.spread},...e.radius===null?{}:{radius:e.radius}}))}function Sn(e,t,n){if(e.kind!==`gradient-linear`)return;let r=e.startPt,i=e.endPt;if(r===null||i===null||t<=0||n<=0)return;let a=e.stops.filter(e=>e.hex!==null).map(t=>({position:t.position,color:t.hex,alpha:f(t.alpha,e.opacity)}));if(a.length===0)return;let o=i.x-r.x,s=i.y-r.y,c=(Math.atan2(o,-s)*180/Math.PI+360)%360;return{kind:`linear`,angle:Math.round(c*100)/100,x1:r.x/t,y1:r.y/n,x2:i.x/t,y2:i.y/n,stops:a}}const Cn=e=>e.topLeft===e.topRight&&e.topRight===e.bottomRight&&e.bottomRight===e.bottomLeft;function wn(e,t){if(e===null)return;let n=e=>e!==null&&e>0?e:null,r=n(e.top),i=n(e.right),a=n(e.bottom),o=n(e.left);if(!(r===null&&i===null&&a===null&&o===null))return{...r===null?{}:{top:r},...i===null?{}:{right:i},...a===null?{}:{bottom:a},...o===null?{}:{left:o},...t===null?{}:{color:t}}}const Tn=new Set([`guid`,`parentGuid`,`parentGuids`,`type`,`pathString`,`position`,`internalOnly`,`frameMaskDisabled`,`bottom`,`right`,`overlayBackgroundAppearance`,`overlayBackgroundInteraction`,`overlayPositionType`]);function En(e){let t=e.fills.find(e=>e.visible&&e.hex!==null)??null;return{path:e.path,targetId:e.targetGuid,...e.componentId===null?{}:{componentId:e.componentId},...e.rawType===null?{}:{nodeType:e.rawType},...e.name===null?{}:{name:e.name},...e.text===null?{}:{text:e.text},...e.textStyleId===null?{}:{textToken:e.textStyleId},...e.fillStyleId===null?{}:{fillToken:e.fillStyleId},...e.left===null?{}:{x:e.left},...e.top===null?{}:{y:e.top},...e.width===null?{}:{width:e.width},...e.height===null?{}:{height:e.height},...e.cornerRadius===null?{}:{radius:e.cornerRadius},...t===null?{}:{fill:G(t)},changed:e.changedKeys.filter(e=>!Tn.has(e))}}function Dn(e){let t=e.fills.find(e=>e.visible&&e.hex!==null)??null;return{path:[e.guid],targetId:e.guid,...e.component?.mainComponentId==null?{}:{componentId:e.component.mainComponentId},nodeType:e.rawType,name:e.name,...e.text===null?{}:{text:e.text.display},...e.textStyleId===null?{}:{textToken:e.textStyleId},...e.fillStyleId===null?{}:{fillToken:e.fillStyleId},x:e.left,y:e.top,width:e.width,height:e.height,...e.cornerRadius===null?{}:{radius:e.cornerRadius},...t===null?{}:{fill:G(t)},changed:[]}}function On(e,t){let n=new Map;for(let t of e){let e=En(t),r=n.get(e.targetId);n.set(e.targetId,r===void 0?e:kn(r,e))}for(let e of t){let t=Dn(e),r=n.get(t.targetId);n.set(t.targetId,r===void 0?t:kn(r,t))}return[...n.values()]}function kn(e,t){return{...t,...e,path:e.path,changed:[...new Set([...e.changed,...t.changed])].sort()}}function An(e,t,n){let r=yn(t),i=yn(n);if(!(r===null||i===null||e===`unknown`))return e===`horizontal`?{w:r,h:i}:{w:i,h:r}}function jn(e,t=0,n=0){let r=t+e.x,i=n+e.y,a=e.kind===`text`,o=e.fills.find(e=>e.visible&&e.hex!==null)??null,s=o===null?void 0:Sn(o,e.width,e.height),c=e.strokes.find(e=>e.visible&&e.hex!==null)??null,l=c===null?null:G(c),u=e.autoLayout===null?void 0:An(e.autoLayout.mode,e.autoLayout.primarySizing,e.autoLayout.counterSizing);return{id:e.guid,name:e.name,type:mn[e.kind],x:r,y:i,width:e.width,height:e.height,...e.cornerRadius!==null&&e.cornerRadius>0?{radius:e.cornerRadius}:{},...!a&&o!==null?{fill:G(o)}:{},...a&&e.text!==null?{text:e.text.display,...o===null?{}:{textColor:G(o)},...e.text.fontFamily!==null||e.text.fontStyle!==null||e.text.fontSize!==null?{font:{...e.text.fontFamily===null?{}:{family:e.text.fontFamily},...e.text.fontStyle===null?{}:{style:e.text.fontStyle},...e.text.fontSize===null?{}:{size:e.text.fontSize}}}:{},textMeta:{lineHeightPx:e.text.lineHeightPx,letterSpacingPx:e.text.letterSpacingPx,upperCase:e.text.textCase===`upper`,...e.text.letterSpacing===null?{}:{letterSpacing:e.text.letterSpacing},...e.text.autoResize===`widthAndHeight`?{autoResize:`width-and-height`}:e.text.autoResize===`height`?{autoResize:`height`}:{},...e.text.decoration===null?{}:{decoration:e.text.decoration},...vn(e.text.alignHorizontal)===void 0?{}:{textAlign:vn(e.text.alignHorizontal)}}}:{},...c!==null&&e.strokeWeight!==null?{stroke:{color:G(c),weight:e.strokeWeight,...e.strokeAlign!==null&&hn[e.strokeAlign]!==void 0?{align:hn[e.strokeAlign]}:{},...e.strokeDashed?{dashed:!0}:{}}}:{},...e.autoLayout===null?{}:{layout:{mode:e.autoLayout.mode,gap:e.autoLayout.gap,...e.autoLayout.counterGap!==null&&e.autoLayout.counterGap!==e.autoLayout.gap?{counterGap:e.autoLayout.counterGap}:{},...e.autoLayout.minWidth===null?{}:{minWidth:e.autoLayout.minWidth},...e.autoLayout.maxWidth===null?{}:{maxWidth:e.autoLayout.maxWidth},...e.autoLayout.minHeight===null?{}:{minHeight:e.autoLayout.minHeight},...e.autoLayout.maxHeight===null?{}:{maxHeight:e.autoLayout.maxHeight},padding:e.autoLayout.padding,...bn(e.autoLayout.primaryAlign)===void 0?{}:{primaryAlign:bn(e.autoLayout.primaryAlign)},...bn(e.autoLayout.counterAlign)===void 0?{}:{counterAlign:bn(e.autoLayout.counterAlign)},...u===void 0?{}:{sizing:u},...e.autoLayout.reverse===!0?{reverse:!0}:{},summary:ft(e.autoLayout)}},...e.opacity===1?{}:{opacity:e.opacity},...e.visible?{}:{hidden:!0},...e.isMask?{mask:!0}:{},...e.sticky?{sticky:!0}:{},...e.url===null?{}:{url:e.url},...e.fillStyleId===null?{}:{fillToken:e.fillStyleId},...e.textStyleId===null?{}:{textToken:e.textStyleId},...e.blendMode===`MULTIPLY`||o!==null&&o.blendMode===`MULTIPLY`?{blendMode:`multiply`}:{},...e.rotation===0?{}:{rotation:e.rotation},...e.cornerRadii!==null&&!Cn(e.cornerRadii)?{radii:e.cornerRadii}:{},...s===void 0?{}:{gradient:s},...wn(e.borders,l)===void 0?{}:{borders:wn(e.borders,l)},...e.constraints!==null&&(e.constraints.horizontal!==null||e.constraints.vertical!==null)?{constraints:{...e.constraints.horizontal===null?{}:{horizontal:e.constraints.horizontal},...e.constraints.vertical===null?{}:{vertical:e.constraints.vertical}}}:{},...e.scrollDirection===null?{}:{scrollDirection:e.scrollDirection},...e.descriptionRich===null?{}:{descriptionRich:e.descriptionRich},...e.margin===null?{}:{margin:{...e.margin.top===null?{}:{top:e.margin.top},...e.margin.right===null?{}:{right:e.margin.right},...e.margin.bottom===null?{}:{bottom:e.margin.bottom},...e.margin.left===null?{}:{left:e.margin.left}}},...e.instanceOverrides.length>0||e.overriddenList.length>0?{overrides:On(e.instanceOverrides,e.overriddenList)}:{},...e.effects.length>0&&xn(e.effects).length>0?{effects:xn(e.effects)}:{},...e.component?.componentKey==null?{}:{componentRef:e.component.componentKey},...e.children.length>0?{children:e.children.map(e=>jn(e,r,i))}:{}}}function Mn(e){return e.component===null?null:{componentKey:e.component.componentKey,libraryFile:e.component.publishFile,version:e.component.version,variants:e.component.variantProps,...e.component.mainComponentId===null?{}:{mainComponent:e.component.mainComponentId},...e.component.mainStateGroup===null?{}:{stateGroup:e.component.mainStateGroup},...e.component.instanceByFrame?{instanceByFrame:!0}:{},...e.component.publishId===null?{}:{publishId:e.component.publishId}}}function Nn(e,t,n){let r=jn(t),i=bt(t,e.components,n),a=s(r),o=u(r),c=Rn(r.type,r.componentRef,i);return{card:{nodeId:t.guid,name:t.name,nodeType:r.type,dslVersion:e.dslVersion,pagePath:[],root:r,component:Mn(t),componentsUsed:i,parserVersion:1},summary:{nodeId:t.guid,name:t.name,nodeType:r.type,width:r.width,height:r.height,layerCount:z(t).length,complexityBand:a.band,complexityFilled:a.filled,colors:o.map(e=>e.color),instanceTotal:i.reduce((e,t)=>e+t.count,0),deprecatedUsed:i.filter(e=>e.deprecated).length,identity:c,previewSvg:d(r)},hasWarnings:e.diagnostics.some(e=>e.severity===`warning`)||i.some(e=>!e.resolved)}}function Pn(e){let t=s(e.root);return{id:e.id,nodeId:e.nodeId,name:e.name,nodeType:e.nodeType,width:e.root.width,height:e.root.height,layerCount:Fn(e.root),complexityBand:t.band,complexityFilled:t.filled,colors:u(e.root).map(e=>e.color),instanceTotal:e.componentsUsed.reduce((e,t)=>e+t.count,0),deprecatedUsed:e.componentsUsed.filter(e=>e.deprecated).length,identity:Rn(e.nodeType,e.root.componentRef,e.componentsUsed),importedAtIso:e.importedAtIso,previewSvg:d(e.root)}}function Fn(e){return 1+(e.children??[]).reduce((e,t)=>e+Fn(t),0)}function In(e){let t=e.children??[];if(t.length===0)return 1;let n=0;for(let e of t){let t=In(e);t>n&&(n=t)}return 1+n}function Ln(e){let t=In(e);return t>380?`Tree depth ${t} exceeds the 380-level decode ceiling`:null}function Rn(e,t,n){if(e===`instance`&&t!==void 0){let e=n.find(e=>e.key===t);if(e!==void 0&&e.resolved)return{componentName:e.name,library:e.library,deprecated:e.deprecated}}return{componentName:null,library:null,deprecated:!1}}const zn={"unknown-sizing-value":`sizing`,"unknown-stack-mode":`stackMode`,"unknown-text-case":`textCase`,"unknown-paint-type":`paint.type`,"unknown-effect-type":`effect.type`,"unknown-node-type":`node.type`};function K(e){let{parsed:t,root:n}=e,r=n===null?[]:z(n),i=t===null?[]:t.components.flatMap(e=>z(e)),a=[...r,...i],o=Bn(a),s=[...t?.diagnostics??[],...e.catalogDiagnostics],c=Vn(s),l=Hn(e.componentsUsed),u=new Set(a.map(e=>e.guid)),d=new Set(s.flatMap(e=>e.severity===`warning`&&e.path!==void 0&&u.has(e.path)?[e.path]:[]));return{outcome:e.outcome,failedStep:e.failedStep,nodeId:n?.guid??null,cardName:n?.name??null,dslVersion:t?.dslVersion??null,converterVersion:t?.converterVersion??null,nodesParsed:a.length,nodesWithIssues:d.size,rootGuids:t===null?[]:[...t.root===null?[]:[t.root.guid],...t.detachedNodes.map(e=>e.guid)],toolTimings:e.toolTimings,unknownKeys:o,unknownEnums:c,unresolvedLibraries:l,diagnostics:s.filter(e=>e.severity===`warning`),catalogStatus:e.catalogStatus,duplicate:e.duplicate,excerpts:Un(a),byteDiff:e.byteDiff}}function Bn(e){let t=new Map;for(let n of e)for(let e of n.unknownKeys){let r=t.get(e);if(r!==void 0){r.count+=1;continue}t.set(e,{sample:n.unknownKeySamples[e]??``,count:1,exampleGuid:n.guid})}return[...t.entries()].map(([e,t])=>({key:e,sample:t.sample,count:t.count,exampleGuid:t.exampleGuid}))}function Vn(e){let t=new Map;for(let n of e){let e=zn[n.code];if(e===void 0)continue;let r=t.get(n.message);if(r!==void 0){r.count+=1;continue}t.set(n.message,{field:e,count:1,exampleGuid:n.path??null})}return[...t.entries()].map(([e,t])=>({field:t.field,value:e,count:t.count,exampleGuid:t.exampleGuid}))}function Hn(e){let t=new Map;for(let n of e){if(n.resolved)continue;let e=n.libraryFileKey??`(unknown library)`,r=t.get(e);if(r!==void 0){r.count+=n.count;continue}t.set(e,{count:n.count,exampleGuid:n.key})}return[...t.entries()].map(([e,t])=>({fileKey:e,count:t.count,exampleGuid:t.exampleGuid}))}function Un(e){let t=[];for(let n of e){if(n.unknownKeys.length===0)continue;let e=n.unknownKeys.map(e=>`"${e}": ${n.unknownKeySamples[e]??`""`}`).join(`, `);if(t.push(`{ "guid": "${n.guid}", ${e} }`),t.length>=8)break}return t}const Wn=h.decodeEffect(h.fromJsonString(r)),Gn=h.decodeEffect(h.fromJsonString(e)),Kn=h.encodeEffect(h.fromJsonString(r)),qn=/^[0-9a-f]{64}$/,Jn=/-[0-9a-f]{64}$/,Yn=/^[0-9a-f]{64}\.json$/,Xn=[`dsl.raw`,`card.json`,`summary.json`,`preview.svg`],Zn=40,Qn=20,$n=(e,t)=>e.id===t.id&&e.nodeId===t.nodeId&&e.name===t.name&&e.nodeType===t.nodeType&&e.importedAtIso===t.importedAtIso&&e.instanceTotal===t.instanceTotal&&e.deprecatedUsed===t.deprecatedUsed&&e.identity.componentName===t.identity.componentName&&e.identity.library===t.identity.library&&e.identity.deprecated===t.identity.deprecated,er=(e,t)=>_.gen(function*(){let n=yield*C.FileSystem,r=yield*w.Path,i=yield*x.currentTimeMillis,a=!1,o=0,s=(e,s)=>_.gen(function*(){yield*n.makeDirectory(t.paths.quarantineDir,{recursive:!0}).pipe(_.andThen(n.rename(r.join(t.paths.scansDir,e),r.join(t.paths.quarantineDir,`${i}-${e}`))),_.orElseSucceed(()=>void 0)),a=!0,o+=1,yield*_.logError(`[pixso] store: scan dir quarantined — this card is NOT in the gallery any more`,{dirName:e,reason:s})}),c=yield*e.listScans(),l=e=>_.gen(function*(){let n=e.summary.id,r=yield*t.readSummary(n).pipe(_.orElseSucceed(()=>null));if(r!==null){let e=yield*Wn(r).pipe(_.orElseSucceed(()=>null));if(e!==null&&e.id===n)return!0}let i=yield*t.readCardOrNull(n);if(i===null)return(yield*t.scanDirExists(n))&&(yield*s(n,`indexed dir has no card.json`)),!1;let a=yield*Gn(i).pipe(_.orElseSucceed(()=>null));return a===null||a.id!==n?(yield*s(n,a===null?`card.json does not decode`:`card.json carries a foreign id`),!1):(yield*Kn(Pn(a)).pipe(_.flatMap(e=>t.writeSummary(n,e)),_.orElseSucceed(()=>void 0)),!0)}),u=[];for(let e of c)(yield*l(e))||u.push(e.summary.id);u.length>0&&(yield*e.transaction(_.forEach(u,t=>e.deleteScan(t),{discard:!0})));let d=yield*t.listScanDirs(),f=new Set((yield*e.listScans()).map(e=>e.summary.id)),p=new Set(yield*e.listDeleted()),m=[];for(let e of d){if(f.has(e)||p.has(e))continue;if(!qn.test(e)){yield*s(e,`unindexed entry name is not a content hash`);continue}let n=yield*t.statScanDir(e);if(n===null)continue;if(n.type!==`Directory`){yield*s(e,`scan entry is not a directory`);continue}let r=yield*t.readCardOrNull(e);if(r===null){yield*s(e,`unindexed dir has no card.json`);continue}let i=yield*Gn(r).pipe(_.orElseSucceed(()=>null));if(i===null||i.id!==e){yield*s(e,i===null?`card.json does not decode`:`card.json carries a foreign id`);continue}let a=yield*t.readSummaryOrNull(e).pipe(_.flatMap(t=>t===null?_.succeed(null):Wn(t).pipe(_.flatMap(t=>t.id===e?_.succeed(t):_.succeed(null)),_.orElseSucceed(()=>null)))),o=a??Pn(i);a===null&&(yield*Kn(o).pipe(_.flatMap(n=>t.writeSummary(e,n)),_.orElseSucceed(()=>void 0))),m.push({card:i,summary:o})}m.length>0&&(m.sort((e,t)=>e.card.importedAtIso.localeCompare(t.card.importedAtIso)),yield*e.transaction(_.forEach(m,({card:t,summary:n})=>e.insertScan({summary:{...n,previewSvg:``},catalogHash:t.catalogHash}),{discard:!0}))),o>0&&(yield*_.logError(`[pixso] store: cards were quarantined — the gallery is SHORTER than the store was`,{quarantined:o,served:yield*e.scanCount()})),yield*or(e,t),a?yield*_.logError(`[pixso] store: the load could not describe everything on disk — EVERY destructive pass skipped`,{served:yield*e.scanCount()}):(yield*tr(e,t),yield*nr(t),yield*ar(t),yield*sr(e,t)),yield*_.logDebug(`[pixso] store loaded`,{scans:yield*e.scanCount(),dropped:u.length,adopted:m.length,quarantined:o})}),tr=(e,t)=>_.gen(function*(){let n=yield*C.FileSystem,r=yield*w.Path,i=yield*e.listScans(),a=new Set(i.flatMap(e=>e.catalogHash===null?[]:[e.catalogHash])),o=yield*t.listCatalogEntries();for(let e of o)Yn.test(e)&&a.has(e.slice(0,-5))||(yield*n.remove(r.join(t.paths.catalogsDir,e),{recursive:!0,force:!0}).pipe(_.orElseSucceed(()=>void 0)))}),nr=e=>_.gen(function*(){let t=yield*C.FileSystem,n=yield*w.Path,r=e=>t.stat(e).pipe(_.map(e=>e.type===`Directory`),_.orElseSucceed(()=>!1)),i=yield*e.listScanDirs();for(let a of i){if(!qn.test(a))continue;let i=yield*e.listScanDirEntries(a);for(let o of i){if(!Xn.some(e=>Yt(o,e)))continue;let i=n.join(e.paths.scanDir(a),o);(yield*r(i))&&(yield*t.remove(i,{recursive:!0,force:!0}).pipe(_.orElseSucceed(()=>void 0)))}}}),rr=e=>{let t=/^(\d+)-/.exec(e);return t===null?0:Number(t[1])},ir=e=>Jn.test(e),ar=e=>_.gen(function*(){let t=yield*e.listQuarantineEntries();if(t.length<=10)return;let n=[...t].sort((e,t)=>{let n=rr(e)-rr(t);if(n!==0)return n;let r=ir(e);return r===ir(t)?e.localeCompare(t):r?1:-1}).slice(0,t.length-10);for(let t of n)yield*e.removeQuarantineEntry(t)}),or=(e,t)=>_.gen(function*(){let n=yield*e.listDeleted();for(let r of n)(yield*t.removeScanDir(r).pipe(_.as(!0),_.orElseSucceed(()=>!1)))&&(yield*e.transaction(e.hardDeleteScan(r)))}),sr=(e,t)=>_.gen(function*(){let n=yield*e.rawEvictionCandidates(40,null);for(let e of n)yield*t.removeDsl(e).pipe(_.catch(t=>_.logDebug(`[pixso] store: evicted raw could not be removed`,{hash:e,cause:String(t)})))}),cr=_.gen(function*(){let e=yield*O.SqlClient;yield*e`
|
|
54
|
+
CREATE TABLE IF NOT EXISTS scans (
|
|
55
|
+
dsl_hash TEXT PRIMARY KEY,
|
|
56
|
+
ordinal INTEGER NOT NULL,
|
|
57
|
+
node_id TEXT NOT NULL,
|
|
58
|
+
name TEXT NOT NULL,
|
|
59
|
+
imported_at TEXT NOT NULL,
|
|
60
|
+
catalog_hash TEXT,
|
|
61
|
+
node_type TEXT NOT NULL,
|
|
62
|
+
width REAL NOT NULL,
|
|
63
|
+
height REAL NOT NULL,
|
|
64
|
+
layer_count INTEGER NOT NULL,
|
|
65
|
+
complexity_band TEXT NOT NULL,
|
|
66
|
+
complexity_fill REAL NOT NULL,
|
|
67
|
+
colors_json TEXT NOT NULL,
|
|
68
|
+
instance_total INTEGER NOT NULL,
|
|
69
|
+
deprecated_used INTEGER NOT NULL,
|
|
70
|
+
identity_json TEXT NOT NULL
|
|
71
|
+
)
|
|
72
|
+
`,yield*e`CREATE UNIQUE INDEX IF NOT EXISTS scans_ordinal ON scans(ordinal)`,yield*e`CREATE INDEX IF NOT EXISTS scans_node_id ON scans(node_id, imported_at)`,yield*e`CREATE INDEX IF NOT EXISTS scans_catalog ON scans(catalog_hash)`,yield*e`
|
|
73
|
+
CREATE TABLE IF NOT EXISTS groups (
|
|
74
|
+
id TEXT PRIMARY KEY,
|
|
75
|
+
name TEXT NOT NULL,
|
|
76
|
+
ordinal INTEGER NOT NULL,
|
|
77
|
+
pinned INTEGER NOT NULL,
|
|
78
|
+
collapsed INTEGER NOT NULL
|
|
79
|
+
)
|
|
80
|
+
`,yield*e`CREATE UNIQUE INDEX IF NOT EXISTS groups_ordinal ON groups(ordinal)`,yield*e`
|
|
81
|
+
CREATE TABLE IF NOT EXISTS group_by_card (
|
|
82
|
+
card_id TEXT PRIMARY KEY,
|
|
83
|
+
group_id TEXT NOT NULL
|
|
84
|
+
)
|
|
85
|
+
`,yield*e`
|
|
86
|
+
CREATE TABLE IF NOT EXISTS recents (
|
|
87
|
+
card_id TEXT PRIMARY KEY,
|
|
88
|
+
ordinal INTEGER NOT NULL
|
|
89
|
+
)
|
|
90
|
+
`,yield*e`
|
|
91
|
+
CREATE TABLE IF NOT EXISTS panel (
|
|
92
|
+
k TEXT PRIMARY KEY,
|
|
93
|
+
v TEXT NOT NULL
|
|
94
|
+
)
|
|
95
|
+
`}),lr=_.gen(function*(){let e=yield*O.SqlClient;(yield*e`PRAGMA table_info(scans)`).some(e=>e.name===`deleted`)||(yield*e`ALTER TABLE scans ADD COLUMN deleted INTEGER NOT NULL DEFAULT 0`)}),ur=[[1,`IndexTables`,cr],[2,`SoftDelete`,lr]],dr=h.encodeEffect(h.fromJsonString(e)),fr=h.encodeEffect(h.fromJsonString(r)),pr=h.is(a),mr=e=>new a({detail:`${c(`Scan store operation failed`,`Операция хранилища сканов не удалась`)}: ${e}`}),q=e=>t=>t.pipe(_.tapError(t=>pr(t)?_.void:_.logError(`[pixso] store operation failed`,{operation:e,cause:String(t)})),_.mapError(t=>pr(t)?t:mr(e))),J=e=>e.pipe(_.tapError(e=>_.logError(`[pixso] store encode failed`,{cause:String(e)})),_.mapError(()=>new a({detail:c(`Storage encode failed — see the server log.`,`Ошибка кодирования хранилища — смотрите лог сервера.`)}))),hr=(e,t)=>[t,...e.filter(e=>e!==t)].slice(0,2);var gr=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/store/ScanStore`){};const _r=_.gen(function*(){let r=yield*Kt,o=yield*_.serviceOption(qt).pipe(_.map(D.getOrUndefined)),s=yield*C.FileSystem,l=yield*w.Path,u=nn(l,r.rootDir),d=e=>e.pipe(_.provideService(C.FileSystem,s),_.provideService(w.Path,l)),f=yield*T.make(1),p=yield*T.make(1),g=yield*y.make(D.none()),v=()=>o===void 0?_.gen(function*(){let{DatabaseSync:e}=yield*_.promise(()=>import(`node:sqlite`)),t=new e(l.join(r.rootDir,`index.db`)),n=yield*_.promise(()=>import(`effect/unstable/reactivity/Reactivity`)),i=yield*_.promise(()=>import(`effect/unstable/sql/Statement`)),a=yield*T.make(1),o={execute:(e,n,r)=>{let i=t.prepare(e),a=i.columns().length>0?i.all(...n):(i.run(...n),[]);return _.succeed(r?r(a):a)},executeRaw:(e,n)=>{let r=t.prepare(e),i=r.columns().length>0;return _.succeed(i?r.all(...n):r.run(...n))},executeUnprepared:(e,n,r)=>{let i=t.prepare(e),a=i.columns().length>0?i.all(...n):(i.run(...n),[]);return _.succeed(r?r(a):a)},executeValues:(e,n)=>{let r=t.prepare(e);return r.columns().length?(r.setReturnArrays(!0),_.succeed(r.all(...n))):(r.run(...n),_.succeed([]))},executeStream:()=>{throw Error(`executeStream not supported`)}},s=a.withPermits(1)(_.succeed(o)),c=a.withPermits(1)(_.succeed(o));return yield*O.make({acquirer:s,transactionAcquirer:c,compiler:i.makeCompilerSqlite(),spanAttributes:[]}).pipe(_.provide(n.layer))}).pipe(q(`open database`)):_.succeed(o),b=()=>{let e=p.withPermits(1)(y.get(g).pipe(_.flatMap(D.match({onNone:()=>_.gen(function*(){let e=yield*v(),t=fn(e);for(let[,,t]of ur)yield*t.pipe(_.provideService(O.SqlClient,e),_.orDie);let n=rn(u);yield*d(er(t,n)).pipe(q(`load`));let r=new Map,i=yield*t.listScans();yield*_.forEach(i,e=>d(n.readSummaryOrNull(e.summary.id)).pipe(_.map(t=>{if(t!==null)try{let n=JSON.parse(t);typeof n.previewSvg==`string`&&n.previewSvg!==``&&r.set(e.summary.id,n.previewSvg)}catch{}}),_.orElseSucceed(()=>void 0)),{concurrency:16});let a={indexDb:t,blobs:n,previews:r};return yield*y.set(g,D.some(a)),a}),onSome:_.succeed}))));return y.get(g).pipe(_.flatMap(D.match({onNone:()=>e,onSome:_.succeed})))},x=h.decodeEffect(h.fromJsonString(e)),S=h.decodeEffect(h.fromJsonString(n)),E=h.decodeEffect(h.fromJsonString(t)),ee=h.decodeEffect(h.fromJsonString(i)),k=h.encodeEffect(h.fromJsonString(n)),te=h.encodeEffect(h.fromJsonString(t)),A=h.encodeEffect(h.fromJsonString(i));return{getSnapshot:()=>_.gen(function*(){let{indexDb:e,previews:t}=yield*b(),n=yield*e.listScans(),r=yield*e.readGalleryState(),i=yield*e.readPanelJson(H),a=yield*e.readPanelJson(cn),o=yield*e.readPanelJson(ln),s=n.map(e=>({...e.summary,previewSvg:t.get(e.summary.id)??``})),c=i===null?null:yield*S(i),l=o===null?null:yield*E(o),u=a===null?null:yield*ee(a);return{cards:s,groups:r.groups,groupByCardId:r.groupByCardId,unsortedPinned:r.unsortedPinned,unsortedCollapsed:r.unsortedCollapsed,recents:r.recents,lastCheck:l,lastProbe:u,lastScanAtIso:c?.atIso??null,supportsReparse:!0}}).pipe(q(`get snapshot`)),getCard:e=>_.gen(function*(){let{indexDb:t,blobs:n}=yield*b(),r=yield*t.getScan(e);return r===null?yield*new a({detail:c(`The card was not found.`,`Карточка не найдена.`)}):{...yield*x(yield*d(n.readCard(e))),importedAtIso:r.summary.importedAtIso,catalogHash:r.catalogHash}}).pipe(q(`read card`)),getCardRaw:e=>_.gen(function*(){let{indexDb:t,blobs:n}=yield*b();return(yield*t.getScan(e))===null?yield*new a({detail:c(`The card was not found.`,`Карточка не найдена.`)}):(yield*d(n.dslExists(e)))?yield*d(n.readDsl(e)):yield*new a({detail:c(`The raw DSL of this card was rotated out by storage retention.`,`Сырой DSL этой карточки вытеснен ротацией хранилища.`)})}).pipe(q(`read dsl`)),getCatalogRaw:e=>_.gen(function*(){let{indexDb:t,blobs:n}=yield*b(),r=yield*t.newestCatalogImport(e);if(r===null)return yield*new a({detail:c(`The catalog was not found.`,`Каталог не найден.`)});let i=yield*d(n.readCatalogOrNull(e));return i===null?yield*new a({detail:c(`The catalog snapshot was rotated out by storage retention.`,`Снимок каталога вытеснен ротацией хранилища.`)}):{raw:i,capturedAtIso:r}}).pipe(q(`read catalog`)),findScanByNodeId:e=>_.gen(function*(){let{indexDb:t}=yield*b();return yield*t.findByNodeId(e)}).pipe(q(`find scan by node id`)),removeCard:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t,blobs:n,previews:r}=yield*b(),i=yield*t.getScan(e);if(i===null)return yield*new a({detail:c(`The card was not found.`,`Карточка не найдена.`)});let o=i.catalogHash;yield*t.transaction(t.markDeleted(e)),r.delete(e),(yield*d(n.removeScanDir(e)).pipe(_.as(!0),_.orElseSucceed(()=>!1)))&&(yield*t.transaction(t.hardDeleteScan(e))),o!==null&&((yield*t.catalogIsReferenced(o))||(yield*d(n.removeCatalog(o)).pipe(_.orElseSucceed(()=>void 0))))}).pipe(q(`remove card`))),mutateGallery:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t,blobs:n,previews:r}=yield*b(),i=yield*t.readGalleryState(),a=m({groups:i.groups,groupByCardId:i.groupByCardId,unsortedPinned:i.unsortedPinned,unsortedCollapsed:i.unsortedCollapsed},e),o=i,s={...a.state,recents:i.recents};yield*t.transaction(_.gen(function*(){yield*t.writeGalleryState(o,s);for(let e of a.removedCardIds)yield*t.deleteScan(e)}));for(let e of a.removedCardIds)r.delete(e),yield*d(n.removeScanDir(e)).pipe(_.orElseSucceed(()=>void 0));if(a.removedCardIds.length>0){let e=yield*t.listScans();new Set(e.flatMap(e=>e.catalogHash===null?[]:[e.catalogHash]))}}).pipe(q(`mutate gallery`))),getLatestReport:()=>_.gen(function*(){let{indexDb:e}=yield*b(),t=yield*e.readPanelJson(H);return t===null?null:yield*S(t)}).pipe(q(`get latest report`)),persistScan:(e,t)=>f.withPermits(1)(_.gen(function*(){let{indexDb:n,blobs:r,previews:i}=yield*b(),a=an(e.dslRaw),o=e.catalogRaw===null?null:an(e.catalogRaw),s=yield*n.getScan(a);if(s!==null){let c=s.summary.importedAtIso;(yield*d(r.dslExists(a)))||(yield*d(r.writeDsl(a,e.dslRaw))),e.catalogRaw!==null&&o!==null&&(yield*d(r.writeCatalog(o,e.catalogRaw)));let l=o===null||o===s.catalogHash?null:{catalogHash:o,card:{...e.card,id:a,importedAtIso:c,catalogHash:o},summary:{...e.summary,id:a,importedAtIso:c}};l!==null&&(yield*d(r.writeCard(a,yield*J(dr(l.card)))),yield*d(r.writeSummary(a,yield*J(fr(l.summary)))));let u=hr(yield*n.readGalleryState().pipe(_.map(e=>e.recents)),a),f=s.catalogHash;yield*n.transaction(_.gen(function*(){l!==null&&(yield*n.updateScanSummary({summary:l.summary,catalogHash:l.catalogHash})),yield*n.setRecents(u),yield*n.setPanelJson(H,yield*k({atIso:e.capturedAtIso,data:{...e.report,outcome:`reimport`,duplicate:!0}}))})),l!==null&&l.summary.previewSvg&&i.set(a,l.summary.previewSvg),t!==void 0&&(yield*t({id:a,duplicate:!0}));let p=yield*n.rawEvictionCandidates(40,a);for(let e of p)yield*d(r.removeDsl(e)).pipe(_.orElseSucceed(()=>void 0));l!==null&&f!==null&&f!==l.catalogHash&&((yield*n.catalogIsReferenced(f))||(yield*d(r.removeCatalog(f)).pipe(_.orElseSucceed(()=>void 0))));let m=yield*n.catalogEvictionCandidates(20,o);for(let e of m)yield*d(r.removeCatalog(e)).pipe(_.orElseSucceed(()=>void 0));return{id:a,duplicate:!0}}let c={...e.card,id:a,importedAtIso:e.capturedAtIso,catalogHash:o},l={...e.summary,id:a,importedAtIso:e.capturedAtIso};yield*d(r.ensureScanDir(a)),yield*d(r.writeDsl(a,e.dslRaw)),yield*d(r.writeCard(a,yield*J(dr(c)))),yield*d(r.writeSummary(a,yield*J(fr(l)))),e.catalogRaw!==null&&o!==null&&(yield*d(r.writeCatalog(o,e.catalogRaw)));let u=hr(yield*n.readGalleryState().pipe(_.map(e=>e.recents)),a),f={summary:l,catalogHash:o};yield*n.transaction(_.gen(function*(){yield*n.insertScan(f),yield*n.setRecents(u),yield*n.setPanelJson(H,yield*k({atIso:e.capturedAtIso,data:e.report}))})),l.previewSvg&&i.set(a,l.previewSvg),t!==void 0&&(yield*t({id:a,duplicate:!1}));let p=yield*n.rawEvictionCandidates(40,a);for(let e of p)yield*d(r.removeDsl(e)).pipe(_.orElseSucceed(()=>void 0));let m=yield*n.catalogEvictionCandidates(20,o);for(let e of m)yield*d(r.removeCatalog(e)).pipe(_.orElseSucceed(()=>void 0));return{id:a,duplicate:!1}}).pipe(q(`persist scan`))),recordReport:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t}=yield*b(),n=yield*k(e);yield*t.transaction(t.setPanelJson(H,n))}).pipe(q(`record report`))),recordCheck:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t}=yield*b(),n=yield*te(e);yield*t.transaction(t.setPanelJson(ln,n))}).pipe(q(`record check`))),recordProbe:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t}=yield*b(),n=yield*A(e);yield*t.transaction(t.setPanelJson(cn,n))}).pipe(q(`record probe`))),reparseScans:e=>f.withPermits(1)(_.gen(function*(){let{indexDb:t,blobs:n}=yield*b(),r=(yield*t.listScans()).map(e=>e.summary.id),i=0,a=0,o=0,s=0;for(let c of r){let r=yield*t.getScan(c);if(r===null)continue;let l=yield*d(n.readDslOrNull(c));if(l===null){a+=1;continue}let u=r.catalogHash===null?null:yield*d(n.readCatalogOrNull(r.catalogHash));if(r.catalogHash!==null&&u===null){o+=1;continue}let f=e({dslRaw:l,catalogRaw:u});if(f===null){s+=1;continue}let p={...f.card,id:c,importedAtIso:r.summary.importedAtIso,catalogHash:r.catalogHash},m={...f.summary,id:c,importedAtIso:r.summary.importedAtIso};yield*d(n.writeCard(c,yield*J(dr(p)))),yield*d(n.writeSummary(c,yield*J(fr(m)))),yield*t.transaction(t.updateScanSummary({summary:m,catalogHash:r.catalogHash})),i+=1}return{total:r.length,reparsed:i,skippedNoRaw:a,skippedNoCatalog:o,failed:s}}).pipe(q(`reparse`))),diagnosticsDir:u.diagnosticsDir}}),vr=v.effect(gr,_r),yr=/guid|item|node|parent/i,br={get_export_image:{exportSettings:{constraint:{type:1,value:1},imageType:1}}};function xr(e,t){if(!(t in e))return null;let n=Object.entries(e).find(([e])=>e===t)?.[1];return typeof n==`string`?n:null}function Sr(e){return`enum`in e&&Array.isArray(e.enum)?e.enum:[]}function Cr(e){if(typeof e!=`object`||!e)return[];let t=new Set(`required`in e&&Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[]);if(!(`properties`in e))return[];let n=e.properties;return typeof n!=`object`||!n?[]:Object.entries(n).flatMap(([e,n])=>{if(typeof n!=`object`||!n)return[];let r=`items`in n&&typeof n.items==`object`&&n.items!==null?n.items:null;return[{name:e,required:t.has(e),type:xr(n,`type`),enumValues:Sr(n),itemType:r===null?null:xr(r,`type`),itemEnumValues:r===null?[]:Sr(r)}]})}function wr(e,t){if(t.length>0)return t[0];switch(e){case`boolean`:return!1;case`number`:case`integer`:return 1;case`string`:return``;case`object`:return{};case`array`:return[];default:return null}}function Tr(e,t,n){let r=br[e]??{},i=Cr(t),a={};for(let e of i){let t=r[e.name];if(t!==void 0){a[e.name]=t;continue}let i=yr.test(e.name);if(i&&(e.type===`string`||e.type===null)){n!==null&&(a[e.name]=n);continue}if(i&&e.type===`array`&&(e.itemType??`string`)===`string`){n!==null&&(a[e.name]=[n]);continue}if(e.required){if(e.type===`array`){a[e.name]=e.itemEnumValues.length>0?[e.itemEnumValues[0]]:[];continue}a[e.name]=wr(e.type,e.enumValues)}}return{args:a,requiredNames:i.filter(e=>e.required).map(e=>e.name)}}const Er=2e4;function Y(){return{seen:0,kinds:{}}}function Dr(e){let t=Object.keys(e);return t.length===0?!1:t.filter(e=>/^\d+:\d+$/.test(e)).length/t.length>=.5}function Or(e){return`__encodedJson`in e&&e.__encodedJson===!0?{marked:!0,inner:`value`in e?e.value:void 0}:{marked:!1,inner:void 0}}function X(e,t){e.seen++;let n=t=>{e.kinds[t]=(e.kinds[t]??0)+1};if(t==null){n(`null`);return}if(Array.isArray(t)){n(`array`);let r=e.arr??={items:Y(),minLen:1/0,maxLen:0,totalItems:0};r.minLen=Math.min(r.minLen,t.length),r.maxLen=Math.max(r.maxLen,t.length),r.totalItems+=t.length;for(let e of t)X(r.items,e);return}if(typeof t==`object`){let r=Or(t);if(r.marked){n(`json-string`),X(e.json??=Y(),r.inner);return}if(n(`object`),Dr(t)){let n=Object.keys(t),r=e.map??={seen:0,totalEntries:0,minKeys:1/0,maxKeys:0,keyShape:Y(),entries:Y()};r.seen++,r.totalEntries+=n.length,r.minKeys=Math.min(r.minKeys,n.length),r.maxKeys=Math.max(r.maxKeys,n.length);for(let[e,n]of Object.entries(t))X(r.keyShape,e),X(r.entries,n);return}let i=e.obj??={seen:0,keys:{}};i.seen++;for(let[e,n]of Object.entries(t)){let t=i.keys[e]??={seen:0,shape:Y()};t.seen++,X(t.shape,n)}return}if(typeof t==`string`&&t.startsWith(`<stripped:`)){n(`binary-stripped`);return}n(typeof t);let r=e.scalar??={distinct:new Map,overflow:0};if(typeof t==`number`){let e=r.num??={min:t,max:t,allInt:!0};e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),Number.isInteger(t)||(e.allInt=!1)}if(typeof t==`string`){let e=r.strLen??={min:t.length,max:t.length};e.min=Math.min(e.min,t.length),e.max=Math.max(e.max,t.length)}let i=String(t).slice(0,80),a=r.distinct.get(i);a===void 0?r.distinct.size<64?r.distinct.set(i,1):r.overflow++:r.distinct.set(i,a+1)}function kr(e,t,n,r){if(n.length>Er)return;let i=Object.entries(e.kinds).map(([t,n])=>n===e.seen?t:`${t}×${n}`).join(` | `),a=`${t===``?`$`:t} : ${i} (seen ${e.seen}${r!==null&&r!==e.seen?` of ${r}`:``})`;if(e.scalar!==void 0){let{distinct:t,overflow:n,num:r,strLen:i}=e.scalar,o=[...t.keys()];n===0&&o.every(e=>e.length<=48)?a+=` values: ${[...t.entries()].map(([e,t])=>t>1?`${JSON.stringify(e)}×${t}`:JSON.stringify(e)).join(`, `)}`:(a+=` distinct≥${t.size+n}, examples: ${o.slice(0,5).map(e=>JSON.stringify(e)).join(`, `)}`,r!==void 0&&(a+=` range ${r.min}…${r.max}${r.allInt?` int`:``}`),i!==void 0&&(a+=` len ${i.min}…${i.max}`))}if(n.push(a),e.map!==void 0){let{totalEntries:r,minKeys:i,maxKeys:a}=e.map,o=e.map.keyShape.scalar,s=o===void 0?``:[...o.distinct.keys()].slice(0,6).map(e=>JSON.stringify(e)).join(`, `);n.push(`${t}{*} : map of ${i===a?i:`${i}…${a}`} data-keyed entries (${r} total; keys e.g. ${s})`),kr(e.map.entries,`${t}{*}`,n,r)}if(e.json!==void 0&&kr(e.json,`${t}→`,n,e.seen),e.arr!==void 0){let{minLen:r,maxLen:i,totalItems:a}=e.arr;n.push(`${t}[] : length ${r===i?r:`${r}…${i}`} (${a} items total)`),kr(e.arr.items,`${t}[]`,n,a)}if(e.obj!==void 0)for(let r of Object.keys(e.obj.keys).sort()){let i=e.obj.keys[r];if(i===void 0)continue;let a=/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;kr(i.shape,`${t}${a}`,n,e.obj.seen)}}function Ar(e){let t=Y();X(t,e);let n=[];return kr(t,`$`,n,null),{shape:t,paths:n,pathCount:n.length,truncated:n.length>Er}}function jr(e,t,n,r=`$`){if(n.length>=20)return;let i=t=>{(e.kinds[t]??0)===0&&n.push(`${r}: kind "${t}" not recorded`)};if(t==null){i(`null`);return}if(Array.isArray(t)){if(i(`array`),e.arr===void 0){n.push(`${r}: array branch missing`);return}for(let i of t)jr(e.arr.items,i,n,`${r}[]`);return}if(typeof t==`object`){let a=Or(t);if(a.marked){if(i(`json-string`),e.json===void 0){n.push(`${r}: json-string branch missing`);return}jr(e.json,a.inner,n,`${r}→`);return}if(i(`object`),Dr(t)){if(e.map===void 0){n.push(`${r}: map branch missing`);return}for(let i of Object.values(t))jr(e.map.entries,i,n,`${r}{*}`);return}if(e.obj===void 0){n.push(`${r}: object branch missing`);return}for(let[i,a]of Object.entries(t)){let t=e.obj.keys[i];if(t===void 0){n.push(`${r}.${i}: key not recorded`);continue}jr(t.shape,a,n,`${r}.${i}`)}return}if(typeof t==`string`&&t.startsWith(`<stripped:`)){i(`binary-stripped`);return}i(typeof t)}const Mr=/^\d+:\d+$/;function Nr(e){if(!(`guid`in e)||typeof e.guid!=`string`||!Mr.test(e.guid))return null;let t=`parentGuids`in e&&Array.isArray(e.parentGuids)?e.parentGuids.filter(e=>typeof e==`string`):[];return{guid:e.guid,parentGuids:t}}function Pr(e,t,n,r){if(r>300||typeof e!=`object`||!e)return;if(Array.isArray(e)){for(let i of e)Pr(i,t,n,r+1);return}let i=Nr(e);i!==null&&t.push({...i,inDslSection:n});for(let[i,a]of Object.entries(e))Pr(a,t,n||i===`pixDslNodes`,r+1)}function Fr(e,t){if(t>300||typeof e!=`object`||!e)return[];if(Array.isArray(e)){for(let n of e){let e=Fr(n,t+1);if(e.length>0)return e}return[]}if(`roots`in e&&Array.isArray(e.roots)){let t=e.roots.flatMap(e=>typeof e==`object`&&e&&`id`in e&&typeof e.id==`string`&&Mr.test(e.id)?[e.id]:[]);if(t.length>0)return t}for(let n of Object.values(e)){let e=Fr(n,t+1);if(e.length>0)return e}return[]}function Ir(e){let t=[];if(Pr(e,t,!1,0),t.length===0){let t=[...new Set(Fr(e,0))];return t.length===1?{guid:t[0]??null,pageGuid:null,reason:`single modern-dialect root by roots[].id`}:t.length>1?{guid:null,pageGuid:null,reason:`ambiguous modern-dialect roots (${t.length}): ${t.slice(0,5).join(`, `)}`}:{guid:null,pageGuid:null,reason:`no guid records found`}}let n=t.filter(e=>e.inDslSection),r=n.length>0?n:t,i=n.length>0?`pixDslNodes section`:`all sections`,a=new Set(r.map(e=>e.guid)),o=r.filter(e=>!e.parentGuids.some(t=>t!==e.guid&&a.has(t))),s=[...new Set(o.map(e=>e.guid))],c=o[0];return s.length===1&&c!==void 0?{guid:c.guid,pageGuid:c.parentGuids[0]??null,reason:`single root by parentGuids in ${i} (${r.length} records)`}:{guid:null,pageGuid:null,reason:`ambiguous roots (${s.length} of ${r.length} records) in ${i}: ${s.slice(0,5).join(`, `)}${s.length>5?`…`:``}`}}const Lr=/data:([a-z0-9.+-]+\/[a-z0-9.+-]+);base64,([A-Za-z0-9+/=]{64,})/gi,Rr=/^[A-Za-z0-9+/=\r\n]{512,}$/;function zr(e){return e.length>=24&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?{width:e.readUInt32BE(16),height:e.readUInt32BE(20)}:null}function Br(e,t,n,r){let i=e.replaceAll(/\s+/g,``),a=null;try{a=b.Buffer.from(i,`base64`)}catch{}let o=a===null?Math.floor(i.length*3/4):a.length,s=A.createHash(`sha256`).update(a??i).digest(`hex`).slice(0,16),c=a===null?null:zr(a);return n.push({path:r,mime:t??`unknown`,bytes:o,base64Chars:i.length,sha256_16:s,head:i.slice(0,24),dims:c}),`<stripped:base64 mime=${t??`unknown`} bytes=${o} sha256=${s}${c===null?``:` dims=${c.width}x${c.height}`} head=${i.slice(0,24)}>`}function Vr(e,t,n,r){if(r>300)return`<max-depth-exceeded>`;if(typeof e==`string`){let i=e.trim();if((i.startsWith(`{`)||i.startsWith(`[`))&&i.length>1)try{let e=JSON.parse(i);if(typeof e==`object`&&e)return{__encodedJson:!0,value:Vr(e,t,`${n}→`,r+1)}}catch{}return Rr.test(e)?Br(e,null,t,n):e.length>=90&&/data:[a-z0-9.+-]+\//i.test(e)?e.replaceAll(Lr,(e,r,i)=>Br(i,r,t,n)):e}if(Array.isArray(e))return e.map((e,i)=>Vr(e,t,`${n}[${i}]`,r+1));if(typeof e==`object`&&e){let i={};for(let[a,o]of Object.entries(e))i[a]=Vr(o,t,`${n}.${a}`,r+1);return i}return e}function Hr(e){let t=[];return{payload:Vr(e,t,`$`,0),blobs:t}}const Ur=`name,guid,parentGuid,parentGuids,parentGuids[],type,visible,angle,opacity,flipVertically,flipHorizontally,width,height,top,left,bottom,right,globalLeft,globalTop,internalOnly,frameMaskDisabled,position,layerType,description,isFromComponent,mask,scrollBehavior,url,dashPattern,componentKey,overrideKey,publishID,publishFile,publishable,version,componentNormName,inheritFillStyleID,inheritTextStyleID,cornerRadius,rectangleTopLeftCornerRadius,rectangleTopRightCornerRadius,rectangleBottomLeftCornerRadius,rectangleBottomRightCornerRadius,strokeWeight,strokeAlign,strokeJoin,strokePaddingPath,isShowStroke,fontFamily,fontStyle,fontSize,fontWeight,textAutoResize,textAlignHorizontal,textCase,nodeText,toggledOnOTFeatures,toggledOffOTFeatures,lineHeightUnit,lineHeightNumber,letterSpacingUnit,letterSpacingNumber,mainComponent,mainStateGroup,instanceByFrame,borderTopWeight,borderRightWeight,borderBottomWeight,borderLeftWeight,horizontalConstraint,verticalConstraint,scrollDirection,descriptionRich,blendMode,links,links[],links[].url`.split(`,`),Wr=`pathString.componentId.type.name.nodeText.componentNormName.inheritTextStyleID.inheritFillStyleID.inheritStrokeStyleID.left.top.width.height.cornerRadius.rectangleTopLeftCornerRadius.rectangleTopRightCornerRadius.rectangleBottomLeftCornerRadius.rectangleBottomRightCornerRadius.rectangleCornerToolIndependent.autoLayoutByParent.strokeWeight.textCase.textDecoration.paragraphIndent.fontFamily.fontStyle.fontSize.fontVariations.fontVariations[].lineHeightUnit.lineHeightNumber.letterSpacingUnit.letterSpacingNumber.stackPaddingTop.stackPaddingBottom.stackPaddingLeft.stackPaddingRight.stackCounterSizing.exportImageQuality.exportKeepNameGroup.exportNameByVariantProp.vectorPaints.vectorPaints[].vectorStyles.vectorStyles[]`.split(`.`),Gr=`stackMode.stackPrimarySizing.stackCounterSizing.stackChildPrimarySizing.stackChildCounterSizing.autoLayoutDirection.autoLayoutItemSpacing.autoLayoutCounterItemSpacing.autoLayoutItemReverseDraw.autoLayoutPrimaryAlign.autoLayoutCounterAlign.autoLayoutAlignType.autoLayoutItemHoriAlign.autoLayoutItemVertAlign.autoLayoutPaddingTop.autoLayoutPaddingBottom.autoLayoutPaddingLeft.autoLayoutPaddingRight.autoLayoutIncludeBorders.autoLayoutItemAbsolutePos.autoLayoutWidthResize.autoLayoutHeightResize.minWidth.minHeight.maxWidth.maxHeight`.split(`.`),Kr=`type,blendMode,opacity,visible,color,color.r,color.g,color.b,color.a,stops,stops[],stops[].position,stops[].color,stops[].color.r,stops[].color.g,stops[].color.b,stops[].color.a,startPt,startPt.x,startPt.y,endPt,endPt.x,endPt.y,leftPt,leftPt.x,leftPt.y,transform,transform.m00,transform.m01,transform.m02,transform.m10,transform.m11,transform.m12`.split(`,`),qr=[`type`,`visible`,`spread`,`color`,`color.r`,`color.g`,`color.b`,`color.a`,`offset`,`offset.x`,`offset.y`],Jr=[`key`,`name`,`type`,`defaultValue`,`value`],Yr=`mirrored node vocabulary — override entries are partial node records; combination not observed live yet`,Z={bottom:{status:`not-modelled`,reason:`redundant with left/top + width/height`},right:{status:`not-modelled`,reason:`redundant with left/top + width/height`},position:{status:`not-modelled`,reason:`canvas z/position marker; semantics unknown (probe §7)`},internalOnly:{status:`not-modelled`,reason:`converter-internal flag`},frameMaskDisabled:{status:`not-modelled`,reason:`converter-internal flag`},flipVertically:{status:`not-modelled`,reason:`flip transform; observed true ×1 (example3); mirrored render not implemented`},flipHorizontally:{status:`not-modelled`,reason:`flip transform; observed false on every capture; mirrored render not implemented`},overrideKey:{status:`not-modelled`,reason:`alternate component identity; componentKey/mainComponent are the used carriers`},publishable:{status:`not-modelled`,reason:`publish flag; no product meaning here`},isShowStroke:{status:`not-modelled`,reason:`stroke visibility flag; strokePaints[].visible is the observed carrier`},strokeJoin:{status:`not-modelled`,reason:`vector join style; the preview draws no joins`},strokePaddingPath:{status:`not-modelled`,reason:`vector path geometry; the preview draws no vector paths (revisit with a vector renderer)`},toggledOnOTFeatures:{status:`not-modelled`,reason:`OpenType feature toggles; typography renders family/style/size only`},toggledOffOTFeatures:{status:`not-modelled`,reason:`OpenType feature toggles; typography renders family/style/size only`},fontWeight:{status:`not-modelled`,reason:`the renderer derives weight from fontStyle names; the raw number is unread`},isFromComponent:{status:`not-modelled`,reason:`instance-provenance flag: true throughout the component section, false on the imported tree in every capture. Recognized so it never reads as drift; componentKey/mainComponent are the identity carriers`},blendMode:{status:`consumed`,reason:`node blend mode; MULTIPLY is the only value mapped to CSS mix-blend-mode — any other value is parsed and carried but deliberately not rendered (no verified analogue)`},publishID:{status:`recorded`,reason:`publication id of the master, carried into PixsoComponentInfo.publishId; recorded identity — no surface shows it yet`},textAlignHorizontal:{status:`consumed`,reason:`horizontal text alignment → CSS text-align + SVG text-anchor; only "center" observed, left is the unstated default`},borderRightWeight:{status:`consumed`,unobserved:!0,reason:`modelled with its three observed siblings — a right-only border must render`},url:{status:`consumed`,unobserved:!0,reason:`bare url appears in NO capture; links[].url is the live carrier — kept for older converters`},inheritFillStyleID:{status:`consumed`,unobserved:!0,reason:`style ref observed so far only inside props[] overrides (none-sentinel 4294967295:4294967295)`},fontHash:{status:`not-modelled`,reason:`font content hash; the font itself arrives via sourceMapByUrl`},hasNewline:{status:`not-modelled`,reason:`derivable from nodeText content`},fontVariations:{status:`not-modelled`,reason:`variable-font axes; typography renders family/style/size only`},"fontVariations[]":{status:`not-modelled`,reason:`variable-font axes; typography renders family/style/size only`}},Q=`parsed into ParsedNode.childLayout and retained; the numeric enum (-1/0/1) has no verified CSS mapping (D11), so no align-self/flex is emitted from it`,Xr={autoLayoutItemReverseDraw:{status:`consumed`,reason:`consumed — SVG paint order only; not a flex-direction reversal (true on 98.8% of corpus auto-layout containers = the default draw order)`},autoLayoutDirection:{status:`not-modelled`,reason:`numeric duplicate of stackMode (1/2 ⇄ HORIZONTAL/VERTICAL); stackMode is the carrier`},autoLayoutItemHoriAlign:{status:`not-modelled`,reason:`numeric alignment enum (0/1 observed) whose meaning no capture verifies; autoLayoutPrimaryAlign/CounterAlign carry the CSS vocabulary the renderer uses`},autoLayoutItemVertAlign:{status:`not-modelled`,reason:`numeric alignment enum (0/1/2 observed) whose meaning no capture verifies; autoLayoutPrimaryAlign/CounterAlign carry the CSS vocabulary the renderer uses`},autoLayoutIncludeBorders:{status:`not-modelled`,reason:`box-model flag (false in every observation); no consumer — box-sizing follows stroke align`},stackChildPrimarySizing:{status:`recorded`,reason:Q},stackChildCounterSizing:{status:`recorded`,reason:Q},autoLayoutWidthResize:{status:`recorded`,reason:Q},autoLayoutHeightResize:{status:`recorded`,reason:Q},autoLayoutItemAbsolutePos:{status:`recorded`,reason:Q},minWidth:{status:`consumed`,reason:`min/max box constraint → CSS min-width; every node-level observation is null (a number appears only inside props[] overrides), so the declaration is emitted only when the DSL gives one`},maxWidth:{status:`consumed`,reason:`min/max box constraint → CSS max-width; every node-level observation is null (a number appears only inside props[] overrides), so the declaration is emitted only when the DSL gives one`},minHeight:{status:`consumed`,reason:`min/max box constraint → CSS min-height; every node-level observation is null (a number appears only inside props[] overrides), so the declaration is emitted only when the DSL gives one`},maxHeight:{status:`consumed`,reason:`min/max box constraint → CSS max-height; every node-level observation is null (a number appears only inside props[] overrides), so the declaration is emitted only when the DSL gives one`}},Zr={status:`recorded`,reason:`redundant with startPt/endPt for a LINEAR gradient in every capture; kept so a future disagreement is visible`},Qr={status:`recorded`,reason:`gradient strokes are flattened to the paint's own approximate colour — CSS/SVG here draw a flat border, so the stops and their geometry are read but never drawn`},$r=(e,t)=>t.startsWith(`leftPt`)||t.startsWith(`transform`)?Zr:e===`strokePaints`?t===`blendMode`?{status:`recorded`,reason:`only the FILL blend mode reaches the view model; a stroke blend has no border analogue`}:t.startsWith(`stops`)||t.startsWith(`startPt`)||t.startsWith(`endPt`)?Qr:{status:`consumed`}:{status:`consumed`},ei={blendMode:{status:`not-modelled`,reason:`only NORMAL observed; a non-normal effect blend has no CSS analogue in the preview`},saturation:{status:`not-modelled`,reason:`background-blur saturation; no CSS filter emitted for it`},showShadowBehindNode:{status:`not-modelled`,reason:`canvas z-order hint; the preview stacks by tree order`}},ti=()=>{let e=new Map,t=(t,n={status:`consumed`})=>{e.set(t,n)},n={status:`consumed`,unobserved:!0,reason:Yr},r={status:`recorded`,unobserved:!0,reason:Yr};t(`dslVersion`),t(`converterVersion`);for(let e of[`variableMap`,`variableSetMap`,`localStyleMap`])t(e,{status:`recorded`,reason:`read only to flag a POPULATED map as unverified (parse.ts flagUnverifiedMaps); populated shape never observed`});t(`isContainFixed`,{status:`not-modelled`,reason:`envelope flag with no consumer; recognized so it never reads as drift`});let i={status:`not-modelled`,reason:`envelope metadata (id/type pairs); type semantics unknown (probe §7)`};for(let e of[`specialNode`,`specialNode[]`,`specialNode[].id`,`specialNode[].type`])t(e,i);let a={status:`not-modelled`,reason:`converter-internal name-counter state; no product meaning`};for(let e of[`NameGenerator`,`NameGenerator.counter`,`NameGenerator.enableSemantic`])t(e,a);t(`NameGenerator.counter{*}`,{...a,unobserved:!0,reason:`${a.reason} (the counter is empty in every capture; its populated form is a data-keyed map)`}),t(`pixDslNodes`),t(`pixComponentNodes`);for(let e of[``,`{*}`,`{*}.type`,`{*}.fontKey`,`{*}.fontKey.family`,`{*}.fontKey.style`])t(`sourceMapByUrl${e}`);t(`sourceMapByUrl{*}.content`,{status:`not-modelled`,reason:`font payload reference; only family/style are joined into the card`});for(let e of[`pixDslNodes`,`pixComponentNodes`]){t(`${e}[]`);for(let n of Ur)t(`${e}[].${n}`,Z[n]??{status:`consumed`});for(let n of[`[]`,`[].pxTag`,`[].windingRule`,`[].path`,`[].path[]`])t(`${e}[].strokePaddingPath${n}`,{status:`not-modelled`,reason:Z.strokePaddingPath.reason});t(`${e}[].dashPattern[]`);for(let n of[`toggledOnOTFeatures`,`toggledOffOTFeatures`])t(`${e}[].${n}[]`,Z[n]);for(let n of Gr)t(`${e}[].autoLayout.${n}`,Xr[n]??{status:`consumed`});t(`${e}[].autoLayout`),t(`${e}[].autoLayoutByParent`,{status:`recorded`,reason:Q});for(let n of[`fillPaints`,`strokePaints`]){t(`${e}[].${n}`),t(`${e}[].${n}[]`);for(let r of Kr)t(`${e}[].${n}[].${r}`,$r(n,r))}t(`${e}[].effects`),t(`${e}[].effects[]`);for(let n of qr)t(`${e}[].effects[].${n}`);for(let[n,r]of Object.entries(ei))t(`${e}[].effects[].${n}`,r);t(`${e}[].effects[].radius`,{status:`consumed`,reason:`shadow/blur radius (observed 3…160) — rendered as the blur length`}),t(`${e}[].effects[].type`,{status:`consumed`,reason:`effect kind — all three observed values render: DROP_SHADOW → box-shadow, BACKGROUND_BLUR → backdrop-filter, FOREGROUND_BLUR → filter: blur() (example1 ×2)`}),t(`${e}[].effects[].color.a`,{status:`consumed`,reason:`effect colour alpha (0.1 / 0.2 / 0.25 observed) — the effect colour becomes rgba(); dropping it drew every shadow fully opaque`});let i={status:`consumed`,unobserved:!0,reason:`modelled symmetrically across propDefMap/propAssignMap; this carrier not observed`};for(let n of[`propDefMap`,`propAssignMap`]){t(`${e}[].${n}`),t(`${e}[].${n}{*}`);for(let r of Jr)t(`${e}[].${n}{*}.${r}`)}let a={status:`consumed`,unobserved:!0,reason:`flat node-level component-prop carrier read by parseComponentProps; every capture uses propDefMap/propAssignMap instead`};for(let n of[`text`,`visible`]){t(`${e}[].${n}_{*}`,a);for(let r of Jr)t(`${e}[].${n}_{*}.${r}`,a)}t(`${e}[].propDefMap{*}.value`,i),t(`${e}[].propAssignMap{*}.key`,i),t(`${e}[].propAssignMap{*}.defaultValue`,i);let o={status:`not-modelled`,reason:`prop→layer binding without a value; deliberately excluded from parseComponentProps`};t(`${e}[].propRefMap`,o);for(let n of[`text`,`visible`])for(let r of[``,`.key`,`.name`,`.type`])t(`${e}[].propRefMap.${n}${r}`,o);let s={status:`not-modelled`,unobserved:!0,reason:`Pixso prototyping (overlay) config; meaningless in a static preview`};for(let n of[`${e}[]`,`${e}[].instanceOverriddenList[]`])for(let e of[`overlayBackgroundAppearance`,`overlayBackgroundInteraction`,`overlayPositionType`]){t(`${n}.${e}`,s);for(let r of[`.backgroundColor`,`.backgroundColor.r`,`.backgroundColor.g`,`.backgroundColor.b`,`.backgroundColor.a`,`.backgroundOpacity`,`.backgroundBlur`,`.backgroundType`])t(`${n}.${e}${r}`,s)}t(`${e}[].props`),t(`${e}[].props[]`);for(let n of Wr)t(`${e}[].props[].${n}`,ni.has(n)?{status:`consumed`,unobserved:!0,reason:Yr}:{status:`recorded`,unobserved:!0,reason:`recorded by name in changedKeys; the value itself is not modelled`});for(let n of Gr)t(`${e}[].props[].autoLayout.${n}`,r);t(`${e}[].props[].autoLayout`,r);let c={status:`recorded`,reason:`recorded by name in changedKeys; the value itself is not modelled`};t(`${e}[].props[].inheritEffectStyleID`,c),t(`${e}[].props[].visible`,c);for(let n of[``,`.entries`,`.entries[]`])t(`${e}[].props[].variableModeBySetMap${n}`,{status:`recorded`,reason:`variable-mode assignment; the variables system has never been observed populated`});for(let i of[`fillPaints`,`strokePaints`]){let a=i===`fillPaints`?n:r;t(`${e}[].props[].${i}`,a),t(`${e}[].props[].${i}[]`,a);for(let n of Kr)t(`${e}[].props[].${i}[].${n}`,a)}t(`${e}[].props[].effects`,r),t(`${e}[].props[].effects[]`,r);for(let n of qr)t(`${e}[].props[].effects[].${n}`,r);let l=`${e}[].instanceOverriddenList`;t(l,n),t(`${l}[]`,n);for(let e of Ur)t(`${l}[].${e}`,n);for(let e of Gr)t(`${l}[].autoLayout.${e}`,n);t(`${l}[].autoLayout`,n);for(let e of[`fillPaints`,`strokePaints`]){t(`${l}[].${e}`,n),t(`${l}[].${e}[]`,n);for(let r of Kr)t(`${l}[].${e}[].${r}`,n)}t(`${l}[].effects`,n),t(`${l}[].effects[]`,n);for(let e of qr)t(`${l}[].effects[].${e}`,n);t(`${l}[].props`,r),t(`${l}[].props[]`,r);for(let e of Wr)t(`${l}[].props[].${e}`,r);t(`${e}[].textDecoration`),t(`${e}[].margin`),t(`${e}[].margin.top`);for(let n of[`right`,`bottom`,`left`])t(`${e}[].margin.${n}`,{status:`consumed`,unobserved:!0,reason:`margin box; only margin.top observed so far — sides modelled together`});t(`${e}[].fontHash`,Z.fontHash),t(`${e}[].hasNewline`,Z.hasNewline),t(`${e}[].fontVariations`,Z.fontVariations),t(`${e}[].fontVariations[]`,Z[`fontVariations[]`])}return e},ni=new Set([`pathString`,`componentId`,`type`,`name`,`nodeText`,`inheritTextStyleID`,`inheritFillStyleID`,`left`,`top`,`width`,`height`,`cornerRadius`,`fillPaints`]),ri=ti(),ii=new Set(ri.keys()),ai=/^(text|visible)_\d+_\d+$/,oi=new Set([`propDefMap`,`propAssignMap`,`propRefMap`]);function si(e){let t=e.split(` : `)[0]?.trim()??``;if(!t.startsWith(`$`))return null;let n=t.replace(/^\$\.?/,``),r=n.startsWith(`content[].text→.`)?n.slice(16):n;if(r===``||r===`content`||r.startsWith(`content[]`))return null;let i=r.replaceAll(/\["(?:[^"\\]|\\.)*"\]/g,`{*}`).split(`.`);return i.map((e,t)=>{if(!ai.test(e))return e;let n=i[t-1]??``;return oi.has(n)?`{*}`:`${e.startsWith(`text`)?`text`:`visible`}_{*}`}).join(`.`).replaceAll(`.{*}`,`{*}`)}function ci(e){let t=e.split(` : `)[0]?.trim()??``;if(!t.startsWith(`$.content[].text→[]`))return null;let n=t.slice(19).replace(/^\./,``);return n===``?null:n}const li=new Map([[`component_key`,{status:`consumed`}],[`name`,{status:`consumed`}],[`description`,{status:`consumed`}],[`file_key`,{status:`consumed`}],[`node_id`,{status:`consumed`}],[`containing_frame`,{status:`consumed`}],[`containing_frame.pageId`,{status:`consumed`}],[`containing_frame.pageName`,{status:`consumed`}],[`containing_frame.containingStateGroup`,{status:`consumed`}],[`containing_frame.containingStateGroup.name`,{status:`consumed`}],[`containing_frame.containingStateGroup.nodeId`,{status:`consumed`}],[`content_hash`,{status:`consumed`}],[`updated_at`,{status:`consumed`}],[`min_node_width`,{status:`consumed`}],[`min_node_height`,{status:`consumed`}],[`thumbnail_url`,{status:`consumed`}],[`type`,{status:`not-modelled`,reason:`entry kind marker; every entry joins by component_key`}],[`aliasName`,{status:`not-modelled`,reason:`local-entry alias (2 of 4648); candidate library display name if local entries ever matter`}],[`canvas_url`,{status:`not-modelled`,reason:`canvas preview URL; thumbnail_url is the used carrier`}],[`description_rtf`,{status:`not-modelled`,reason:`rich-text duplicate of description`}],[`created_at`,{status:`not-modelled`,reason:`publication metadata; updated_at is the surfaced time`}],[`unpublished_at`,{status:`not-modelled`,reason:`publication metadata (null in every observation)`}],[`user_id`,{status:`not-modelled`,reason:`publisher id; no product meaning here`}],[`status`,{status:`not-modelled`,reason:`local-entry publish status (2 of 4648)`}],[`defs`,{status:`not-modelled`,reason:`local-entry field (null in every observation)`}],[`deletedFromSceneGraph`,{status:`not-modelled`,reason:`local-entry flag (2 of 4648, different shape)`}],[`isLocal`,{status:`not-modelled`,reason:`local-entry flag (2 of 4648)`}],[`isPublishable`,{status:`not-modelled`,reason:`local-entry flag (2 of 4648)`}],[`isVariant`,{status:`not-modelled`,reason:`local-entry flag (2 of 4648)`}],[`is_unflattened`,{status:`not-modelled`,reason:`converter flag; no product meaning`}],[`containing_frame.name`,{status:`not-modelled`,reason:`frame identity beyond page/state-group; unused by the join`}],[`containing_frame.nodeId`,{status:`not-modelled`,reason:`frame identity beyond page/state-group; unused by the join`}],[`containing_frame.backgroundColor`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}],[`containing_frame.color`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}],[`containing_frame.color.r`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}],[`containing_frame.color.g`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}],[`containing_frame.color.b`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}],[`containing_frame.color.a`,{status:`not-modelled`,reason:`canvas backdrop of the containing frame`}]]);function ui(e){let t=new Set,n=[];for(let r of e){let e=si(r);e===null||t.has(e)||ii.has(e)||(t.add(e),n.push({path:e,line:r.trim()}))}return n}function di(e){let t=new Set,n=[];for(let r of e){let e=ci(r);e===null||t.has(e)||li.has(e)||(t.add(e),n.push({path:e,line:r.trim()}))}return n}const fi=e=>{let t=e.replaceAll(/[^a-zA-Z0-9._-]+/g,`-`).replaceAll(/^-|-$/g,``);if(t===e)return t;let n=A.createHash(`sha256`).update(e).digest(`hex`).slice(0,8);return t===``?n:`${t}-${n}`};function pi(e){let t=[`# live tool catalog — ${e.length} tools`,``];for(let n of e){let e=St.get(n.name),r=e===void 0?`!! NEW — not in baseline`:e.write?`known, MUTATING (never called)`:`known, read`;t.push(`${n.name} [${r}]`),n.params.length===0&&t.push(` (no params)`);for(let e of n.params)t.push(` ${e.required?`REQUIRED`:`optional`} ${e.name} : ${e.type}`);t.push(``)}return t.join(`
|
|
96
|
+
`)}function mi(e){let t=[`# CATALOG DRIFT + CALL ERRORS — review before trusting contracts`,``];e.deviations.length===0?t.push(`(no catalog drift vs the pinned baseline)`):t.push(...e.deviations);let n=e.records.filter(e=>e.errorText!==null);if(n.length>0){t.push(``,`## Full call errors`,``);for(let e of n)t.push(`### ${e.tool} (status: ${e.status}, args: ${JSON.stringify(e.args)})`,e.errorText??``,``)}return`${t.join(`
|
|
97
|
+
`)}\n`}function hi(e){let t=e.find(e=>e.tool===`get_node_dsl`),n=ui(t?.contract?.paths??[]),r=[`# DSL fields present in THIS capture that the parser does not map yet.`,`# Hand this file over to extend the parser; each mapped field also joins`,`# src/shared/dslContractBaseline.ts, so it stops appearing here.`,`#`,`# A baseline field ABSENT from this capture is NOT reported — one selection never`,`# exercises the whole contract, so only 'present and unmapped' is actionable.`,`# Types and example values below are COVERAGE, not semantics.`,``];return t===void 0||t.contract===null?`${r.join(`
|
|
98
|
+
`)}(get_node_dsl produced no contract in this run — nothing to diff)\n`:n.length===0?`${r.join(`
|
|
99
|
+
`)}(nothing new — every field in this capture is already mapped)\n`:`${r.join(`
|
|
100
|
+
`)}${n.length} new path(s):\n\n${n.map(e=>e.line).join(`
|
|
101
|
+
`)}\n`}function gi(e){let t=e.find(e=>e.tool===`get_all_components`),n=di(t?.contract?.paths??[]),r=[`# get_all_components fields present in THIS capture that carry no decision yet.`,`# Each mapped/decided field joins CATALOG_CONTRACT_MANIFEST, so it stops appearing.`,``];return t===void 0||t.contract===null?`${r.join(`
|
|
102
|
+
`)}(get_all_components produced no contract in this run — nothing to diff)\n`:n.length===0?`${r.join(`
|
|
103
|
+
`)}(nothing new — every field in this capture is already decided)\n`:`${r.join(`
|
|
104
|
+
`)}${n.length} new path(s):\n\n${n.map(e=>e.line).join(`
|
|
105
|
+
`)}\n`}const _i=e=>{let t=e.split(` : `)[0]?.trim()??``;return t.startsWith(`$`)?t:null};function vi(e){if(e.previous===null)return`# First recorded run — nothing to diff against.
|
|
106
|
+
`;let t=[`# Contract movement vs the previous run (${e.previous.dirName}).`,"# Exact per-tool diff: `+` a path this capture ADDED, `-` one it no longer carries,","# `~ before`/`~ after` a path both runs carry whose contract line moved (type,",`# seen counts, enum values, range, length). Absence can be selection-dependent —`,`# treat removals as hints, additions and changes as findings.`,``],n=0;for(let r of e.records){if(r.contract===null)continue;let i=e.previous.contractsByTool.get(r.tool);if(i===void 0)continue;let a=new Map(r.contract.paths.flatMap(e=>{let t=_i(e);return t===null?[]:[[t,e]]})),o=new Map(i.flatMap(e=>{let t=_i(e);return t===null?[]:[[t,e]]})),s=[...a.keys()].filter(e=>!o.has(e)).sort(),c=[...o.keys()].filter(e=>!a.has(e)).sort(),l=[...a.keys()].filter(e=>o.has(e)&&a.get(e)!==o.get(e)).sort();if(!(s.length===0&&c.length===0&&l.length===0)){n+=s.length+c.length+l.length,t.push(`## ${r.tool}`,``);for(let e of s)t.push(`+ ${a.get(e)??e}`);for(let e of c)t.push(`- ${o.get(e)??e}`);for(let e of l)t.push(`~ before ${o.get(e)??e}`),t.push(`~ after ${a.get(e)??e}`);t.push(``)}}return n===0&&t.push(`(no contract movement — contract lines identical per tool)`),`${t.join(`
|
|
107
|
+
`)}\n`}const yi=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function bi(e){if(!yi(e))return null;let t=e.content;if(!Array.isArray(t))return null;for(let e of t){if(!yi(e))continue;let t=e.text;if(!yi(t)||t.__encodedJson!==!0)continue;let n=t.value;if(yi(n)&&(`pixDslNodes`in n||`dslVersion`in n))return n}return null}function xi(e){let t=e.find(e=>e.tool===`get_node_dsl`),n=t===void 0?null:bi(t.payload),r=[`# Key-set signatures: which keys CO-OCCUR on one node, grouped by node type.`,`# Per-field aggregation cannot answer this; one line here = one observed key set.`,``];if(n===null)return`${r.join(`
|
|
108
|
+
`)}(no DSL envelope in this run — nothing to sign)\n`;let i=[...r];for(let e of[`pixDslNodes`,`pixComponentNodes`]){let t=n[e];if(!Array.isArray(t))continue;let r=new Map;for(let e of t){if(!yi(e))continue;let t=typeof e.type==`string`?e.type:`(untyped)`,n=Object.keys(e).sort().join(` `),i=r.get(t)??new Map;i.set(n,(i.get(n)??0)+1),r.set(t,i)}i.push(`## ${e}`,``);for(let e of[...r.keys()].sort()){let t=r.get(e);i.push(`### ${e} — ${t.size} distinct key set(s)`);let n=[...t.entries()].sort((e,t)=>t[1]-e[1]);for(let[e,t]of n.slice(0,40))i.push(` ×${t} ${e}`);n.length>40&&i.push(` … ${n.length-40} more key set(s) truncated`),i.push(``)}}return`${i.join(`
|
|
109
|
+
`)}\n`}function Si(e){return[`# To hand these results over for contract/parser analysis, copy:`,` summary.json`,` tools.contract.txt`,` ALARMS.txt`,` contract-new-paths.txt`,` catalog-new-paths.txt`,` diff-vs-previous.txt`,` key-signatures.txt`,`# …plus the contract files of the data tools (at minimum get_node_dsl and`,`# get_all_components when present):`,...e.filter(e=>e.contract!==null).map(e=>` contracts/${fi(e.tool)}.contract.txt`),`# raw/ stays local — request specific raw files only when the contracts are not enough.`,``].join(`
|
|
110
|
+
`)}function Ci(e){return JSON.stringify({meta:{script:`pixso-assistant diagnostics probe (probe-v4 port)`,generatedAt:e.atIso,endpoint:e.endpoint},target:e.target,catalog:{toolCount:e.tools.length,deviations:e.deviations},calls:e.records.map(e=>({label:e.tool,args:e.args,status:e.status.toUpperCase(),ms:e.ms,rawBytes:e.rawBytes,blobsStripped:e.blobs.length,contract:e.contract===null?null:{pathCount:e.contract.pathCount,verified:e.contractMisses.length===0},contractMisses:e.contractMisses,error:e.errorText})),skippedTools:e.skippedTools},null,2)}function wi(e){return JSON.stringify(e,null,1)}function Ti(e){return JSON.stringify({tool:e.tool,args:e.args,status:e.status,ms:e.ms,rawBytes:e.rawBytes,error:e.errorText,strippedBlobs:e.blobs,payload:e.payload},null,1)}function Ei(e){let t=e.contract;return t===null?``:[`# ${e.tool}`,`# tool: ${e.tool} args: ${JSON.stringify(e.args)}`,`# status: ${e.status.toUpperCase()} ms: ${e.ms} rawBytes: ${e.rawBytes} blobsStripped: ${e.blobs.length}`,`# selfVerified: ${e.contractMisses.length===0}${t.truncated?` !! PATH LIST TRUNCATED AT ${Er}`:``}`,``].concat(t.paths).join(`
|
|
111
|
+
`)}function Di(e,t){return _.gen(function*(){let n=(n,r)=>$t({filePath:t.join(e.dumpDir,n),contents:r});yield*n(`summary.json`,Ci(e)),yield*n(`tools.json`,wi(e.tools)),yield*n(`tools.contract.txt`,pi(e.tools)),yield*n(`ALARMS.txt`,mi(e)),yield*n(`HANDOFF.txt`,Si(e.records)),yield*n(`contract-new-paths.txt`,hi(e.records)),yield*n(`catalog-new-paths.txt`,gi(e.records)),yield*n(`diff-vs-previous.txt`,vi(e)),yield*n(`key-signatures.txt`,xi(e.records));for(let t of e.records){let e=fi(t.tool);yield*n(`raw/${e}.raw.json`,Ti(t)),t.contract!==null&&(yield*n(`contracts/${e}.contract.txt`,Ei(t)))}})}var Oi=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/probe/ProbeService/Probe`){};const ki=/-32602|input validation|invalid arguments|invalid_type|missing required/i,Ai=/requires|missing required|unsupported|not found|invalid/i,ji=/^\s*(unsupported|missing required|error:)/i,Mi=/requires|missing required/i,Ni=e=>e.startsWith(`enum`)?`string`:e.endsWith(`[]`)?`array`:e,Pi=e=>{let t=/^enum\((.+)\)$/.exec(e);return t===null?null:t[1].split(`|`).sort()},Fi=e=>e===null?`—`:e.join(`|`);function Ii(e){let t=[],n=new Map(e.map(e=>[e.name,e]));for(let e of xt){let r=n.get(e.name);if(r===void 0){t.push(p(`{0}: tool vanished from tools/list`,`{0}: инструмент исчез из tools/list`,[e.name]));continue}let i=new Map(r.params.map(e=>[e.name,e]));for(let n of e.params){let r=i.get(n.name);if(r===void 0){t.push(p(`{0}: param {1} vanished`,`{0}: параметр {1} исчез`,[e.name,n.name]));continue}Ni(r.type)!==Ni(n.type)&&t.push(p(`{0}: {1} — type {2} → {3}`,`{0}: {1} — тип {2} → {3}`,[e.name,n.name,n.type,r.type])),r.required!==n.required&&t.push(p(`{0}: {1} — required {2} → {3}`,`{0}: {1} — required {2} → {3}`,[e.name,n.name,String(n.required),String(r.required)]));let a=Pi(n.type),o=r.enumValues===void 0?null:[...r.enumValues].sort();Fi(a)!==Fi(o)&&t.push(`${e.name}: ${n.name} — enum [${Fi(a)}] → [${Fi(o)}]`)}for(let n of r.params)e.params.some(e=>e.name===n.name)||t.push(p(`{0}: new param {1} ({2}) — not in contract`,`{0}: новый параметр {1} ({2}) — не в контракте`,[e.name,n.name,n.type]))}for(let n of e)xt.some(e=>e.name===n.name)||t.push(p(`{0}: new tool — not in contract`,`{0}: новый инструмент — не в контракте`,[n.name]));return t}const Li=e=>`${(e/1024).toFixed(1)} ${c(`KB`,`КБ`)}`;function Ri(e){let t=Ar(e),n=[];return jr(t.shape,e,n),{contract:t,misses:n}}function zi(e){try{return JSON.parse(e)}catch{return}}function Bi(e,t,n,r){let i=n.length>0?p(`requires: {0}`,`требует: {0}`,[n.join(`, `)]):c(`args out of contract`,`аргументы вне контракта`);if(!r.ok){let n=!r.timedOut&&ki.test(r.message);return{tool:e.name,args:t,status:n?`needs-args`:`dead`,ms:r.ms,rawBytes:0,detail:r.timedOut?p(`timeout {0}s`,`таймаут {0}с`,[Math.round(r.ms/1e3)]):n?i:c(`error · see the report`,`ошибка · см. отчёт`),errorText:r.message,payload:null,blobs:[],contract:null,contractMisses:[]}}let a=r.texts.join(`
|
|
112
|
+
`),{payload:o,blobs:s}=Hr(r.result),l=b.Buffer.byteLength(a,`utf8`);if(r.isError){let n=ki.test(a);return{tool:e.name,args:t,status:n?`needs-args`:`dead`,ms:r.ms,rawBytes:l,detail:n?i:c(`tool error · see the report`,`ошибка инструмента · см. отчёт`),errorText:a,payload:o,blobs:s,contract:null,contractMisses:[]}}let u=r.texts[0]??``,d=zi(u),f=typeof d==`object`&&d&&`message`in d&&typeof d.message==`string`?d.message:null;if(typeof d==`object`&&d&&`success`in d&&d.success===!1||f!==null&&Ai.test(f)||ji.test(u)){let n=Mi.test(f??u);return{tool:e.name,args:t,status:n?`needs-args`:`dead`,ms:r.ms,rawBytes:l,detail:n?i:c(`tool error · see the report`,`ошибка инструмента · см. отчёт`),errorText:a,payload:o,blobs:s,contract:null,contractMisses:[]}}let{contract:m,misses:h}=Ri(o);return{tool:e.name,args:t,status:b.Buffer.byteLength(a.trim(),`utf8`)<=64?`empty`:`ok`,ms:r.ms,rawBytes:l,detail:`${r.ms} ${c(`ms`,`мс`)} · ${Li(l)}`,errorText:null,payload:o,blobs:s,contract:m,contractMisses:h}}const Vi=e=>({tool:e.tool,args:JSON.stringify(e.args),status:e.status,detail:e.detail}),Hi=_.gen(function*(){let e=yield*Ut,t=yield*gr,n=yield*Kt,r=yield*C.FileSystem,i=yield*w.Path,o=yield*T.make(1),s=yield*y.make(null),l=(t,n,r)=>_.gen(function*(){let{args:i,requiredNames:a}=Tr(t.name,t.inputSchema,n),o=Bi(t,i,a,yield*e.callToolRaw(t.name,i));return yield*y.update(r,e=>new Map(e).set(t.name,o)),o}),u=()=>_.gen(function*(){let o=yield*e.listToolsRaw();if(!o.ok)return yield*new a({detail:`${c(`Probe failed: Pixso MCP is unreachable`,`Проба не удалась: Pixso MCP недоступен`)}: ${o.message}`});let s=yield*x.currentTimeMillis,u=new Date(s).toISOString(),d=i.join(t.diagnosticsDir,u.replaceAll(/[:.]/g,`-`)),f=Ii(o.tools),m=o.tools.filter(e=>wt(e.name)),h=o.tools.filter(e=>!wt(e.name)),g=m.find(e=>e.name===`get_node_dsl`),v=m.filter(e=>e.name!==`get_node_dsl`),b=yield*y.make(new Map),S=yield*y.make({guid:null,pageGuid:null,reason:`probe deadline exceeded before target derivation`}),C=6*e.callTimeoutMs,w=yield*_.gen(function*(){let e=g===void 0?null:yield*l(g,null,b);yield*_.yieldNow;let t=e===null?{guid:null,pageGuid:null,reason:`get_node_dsl absent from tools/list`}:e.status===`ok`?Ir(e.payload):{guid:null,pageGuid:null,reason:`get_node_dsl ${e.status} — staying in selection mode`};return yield*y.set(S,t),yield*_.forEach(v,e=>l(e,t.guid,b),{concurrency:4}),!0}).pipe(_.timeoutOrElse({duration:C,orElse:()=>_.succeed(!1)})),T=yield*y.get(b),E=yield*y.get(S),ee=e=>({tool:e.name,args:Tr(e.name,e.inputSchema,e.name===`get_node_dsl`?null:E.guid).args,status:`dead`,ms:C,rawBytes:0,detail:p(`probe timeout {0}s`,`таймаут пробы {0}с`,[Math.round(C/1e3)]),errorText:`probe deadline exceeded`,payload:null,blobs:[],contract:null,contractMisses:[]}),D=[...g===void 0?[]:[g],...v].map(e=>T.get(e.name)??ee(e)),O=w?f:[...f,p(`probe aborted by the overall timeout ({0}s)`,`проба прервана по общему таймауту ({0}с)`,[Math.round(C/1e3)])],k=yield*_.gen(function*(){let e=[...yield*r.readDirectory(t.diagnosticsDir).pipe(_.orElseSucceed(()=>[]))].filter(e=>e!==i.basename(d)).sort().at(-1);if(e===void 0)return null;let n=new Map;for(let a of D){let o=i.join(t.diagnosticsDir,e,`contracts`,`${fi(a.tool)}.contract.txt`),s=yield*r.readFileString(o).pipe(_.map(e=>e.split(`
|
|
113
|
+
`)),_.orElseSucceed(()=>null));s!==null&&n.set(a.tool,s)}return n.size===0?null:{dirName:e,contractsByTool:n}}),te=yield*Di({dumpDir:d,atIso:u,endpoint:e.endpoint,target:E,tools:o.tools,deviations:O,records:D,skippedTools:h.map(e=>e.name),previous:k},i).pipe(_.as(!0),_.catchCause(e=>_.logError(`[pixso] probe report write failed`,{cause:String(e)}).pipe(_.as(!1)))),A=te?O:[...O,c(`report not saved — see the log`,`отчёт не сохранён — см. лог`)];yield*r.readDirectory(t.diagnosticsDir).pipe(_.orElseSucceed(()=>[]),_.flatMap(e=>_.forEach([...e].sort().slice(0,Math.max(0,e.length-10)),e=>r.remove(i.join(t.diagnosticsDir,e),{recursive:!0,force:!0}).pipe(_.orElseSucceed(()=>void 0)))));let ne={atIso:u,rows:D.map(Vi),deviations:A,savedTo:te?i.relative(n.rootDir,d):``};return yield*t.recordProbe(ne),yield*_.logDebug(`[pixso] probe`,{tools:D.length,ok:D.filter(e=>e.status===`ok`).length,dead:D.filter(e=>e.status===`dead`).length,needsArgs:D.filter(e=>e.status===`needs-args`).length,deviations:A.length,finishedInTime:w,savedTo:te?d:``}),ne}).pipe(_.provideService(C.FileSystem,r),_.provideService(w.Path,i)),d=o.withPermits(1)(_.gen(function*(){let e=yield*y.get(s);if(e!==null)return{leads:!1,deferred:e};let t=yield*S.make();return yield*y.set(s,t),{leads:!0,deferred:t}}));return{run:()=>_.gen(function*(){let e=yield*d;return e.leads?yield*u().pipe(_.onExit(t=>y.set(s,null).pipe(_.andThen(S.done(e.deferred,t))))):yield*S.await(e.deferred)})}}),Ui=v.effect(Oi,Hi);function Wi(e){return!(e.entries.length===0&&e.diagnostics.length>0)}function Gi(e){return e.timedOut?{outcome:`tool-timeout`,failedStep:1}:e.origin===`transport`?{outcome:`mcp-down`,failedStep:0}:{outcome:`dsl-error`,failedStep:1}}function Ki(e){return e.detachedNodes.length>0?{outcome:`multi-selection`,failedStep:3}:e.root===null&&e.diagnostics.some(e=>e.code===`empty-dsl`)?{outcome:`empty-selection`,failedStep:1}:{outcome:`parse-error`,failedStep:3}}const qi=new Set([`2.1.15`]),Ji=new Set([`2.2.13`]);function Yi(e,t){let n=e.dslVersion!==null&&qi.has(e.dslVersion),r=e.converterVersion!==null&&Ji.has(e.converterVersion);if(n&&r)return{verdict:`verified`,detail:null};let i=`dslVersion ${e.dslVersion??`—`} / converterVersion ${e.converterVersion??`—`}`;if(t===null)return{verdict:`incompatible`,detail:i};let a=z(t),o=a.length>0&&(t.width>0||t.height>0),s=new Set([...a.flatMap(e=>e.unknownKeys),...e.unknownEnvelopeKeys]),c=s.size,l=[...s].some(e=>e.endsWith(de));return o&&!l&&c<=12?{verdict:`compatible`,detail:i}:{verdict:`incompatible`,detail:i}}function Xi(){return c(`Unsupported Pixso format — contact the developer.`,`Неподдерживаемый формат Pixso — обратитесь к разработчику.`)}function Zi(e,t){if(t===`multi-selection`){let t=(e.root===null?0:1)+e.detachedNodes.length;return`pixDslNodes: ${String(t)} ${c(`root nodes in the response — expected 1`,`корневых узлов в ответе — ожидался 1`)}`}let n=e.diagnostics.find(e=>e.severity===`warning`);if(n===void 0)return null;let r=e.diagnostics.filter(e=>e.severity===`warning`).length;return`parser: ${n.message}${r>1?` · ${String(r)} diagnostics`:``}`}function Qi(e){if(e.unresolvedLibraries.length>0){let t=e.unresolvedLibraries.reduce((e,t)=>e+t.count,0),n=e.unresolvedLibraries[0];return`${c(`library`,`библиотека`)} ${n.fileKey} ${c(`is not in the catalog`,`отсутствует в каталоге`)} — ${String(t)} ${c(`components unresolved`,`экземпляров без привязки`)}`}let t=e.diagnostics[0];return t===void 0?null:`parser: ${t.message}`}function $i(e,t){if(e===t)return{identical:!0,note:c(`byte-for-byte identical`,`байт-в-байт идентичен`)};let n=b.Buffer.from(e,`utf8`),r=b.Buffer.from(t,`utf8`),i=0,a=Math.min(n.length,r.length);for(;i<a&&n[i]===r[i];)i+=1;return{identical:!1,note:`${c(`differs`,`отличается`)}: ${c(`length`,`длина`)} ${String(n.length)} → ${String(r.length)}, ${c(`first divergence at byte`,`первое расхождение — байт`)} №${String(i+1)}`}}const $={parsed:null,root:null,componentsUsed:[],catalogStatus:`skipped`,catalogDiagnostics:[],duplicate:!1,byteDiff:null},ea=new Set([`mcp-down`,`tool-timeout`,`dsl-error`,`parse-error`,`components-error`,`internal-error`]),ta=e=>ea.has(e),na=(e,t)=>{let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?null:r-n},ra=(e,t)=>{let n=na(e.startedAtIso,e.settledAtIso),r=t.toolTimings.reduce((e,t)=>e+t.ms,0);return{outcome:e.outcome,ms:n,mcpMs:r,localMs:n===null?null:n-r,failedStep:e.failedStep,cardId:e.cardId,nodeId:t.nodeId,nodes:t.nodesParsed,nodeIssues:t.nodesWithIssues,unknownKeys:t.unknownKeys.length,unknownEnums:t.unknownEnums.length,unresolvedLibraries:t.unresolvedLibraries.length,warnings:t.diagnostics.filter(e=>e.severity===`warning`).length,catalog:t.catalogStatus,duplicate:t.duplicate,detail:e.detail}},ia=e=>({outcome:e.outcome,ms:e.toolTimings.reduce((e,t)=>e+t.ms,0),nodeId:e.nodeId,nodes:e.nodesParsed,unknownKeys:e.unknownKeys.length,unknownEnums:e.unknownEnums.length,byteIdentical:e.byteDiff===null?null:e.byteDiff.identical,byteNote:e.byteDiff===null?null:e.byteDiff.note}),aa={currentSeq:0,settledSeq:null},oa=(e,t)=>t>0&&t===e.currentSeq&&e.settledSeq!==t,sa=e=>y.modify(e,e=>{let t=e.currentSeq+1;return[t,{currentSeq:t,settledSeq:null}]}),ca=(e,t)=>y.modify(e,e=>oa(e,t)?[!0,{...e,settledSeq:t}]:[!1,e]),la=(e,t)=>y.get(e).pipe(_.map(e=>e.currentSeq===t)),ua=ne.seconds(60),da=2e3,fa=25e6;var pa=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/scan/ScanJobService/ScanJob`){};const ma=_.gen(function*(){let e=yield*Ut,t=yield*gr,n=yield*j.make({phase:`idle`}),r=yield*T.make(1),i=yield*y.make(aa),o=(e,t)=>{let n=ra(e,t);return ta(e.outcome)?_.logError(`[pixso] scan failed`,n):_.logDebug(`[pixso] scan settled`,n)},s=(e,t)=>la(i,e).pipe(_.flatMap(e=>e?j.set(n,t):_.void)),l=_.map(x.currentTimeMillis,e=>new Date(e).toISOString()),u=e=>_.uninterruptible(_.gen(function*(){if(!(yield*ca(i,e.seq))){yield*_.logDebug(`[pixso] scan settle dropped — run already settled or superseded`,{seq:e.seq,outcome:e.outcome});return}e.cardId===null&&(yield*t.recordReport({atIso:e.settledAtIso,data:e.report}).pipe(_.orElseSucceed(()=>void 0)));let r={phase:`settled`,outcome:e.outcome,failedStep:e.failedStep,cardId:e.cardId,detail:e.detail,startedAtIso:e.startedAtIso,settledAtIso:e.settledAtIso};yield*j.set(n,r),yield*o(r,e.report)})),d=(e,t,n,r,i,a,o=null)=>l.pipe(_.flatMap(s=>u({seq:e,startedAtIso:t,settledAtIso:s,outcome:n,failedStep:r,cardId:i,report:a,detail:o}))),f=(n,r)=>_.gen(function*(){let i=yield*y.make([]),a=yield*y.make(1),o=e=>y.update(i,t=>[...t,e]);return yield*_.gen(function*(){let f=yield*e.callTool(`get_node_dsl`,{});if(!f.ok){yield*o({tool:`get_node_dsl`,ms:f.ms,ok:!1,detail:f.message});let{outcome:e,failedStep:t}=Gi(f),a=yield*y.get(i);yield*d(r,n,e,t,null,K({...$,outcome:e,failedStep:t,toolTimings:a}),`get_node_dsl: ${f.message}`);return}if(f.texts.length>1){let e=yield*y.get(i);yield*_.logError(`[pixso] get_node_dsl returned multiple text items`,{items:f.texts.length,sizes:f.texts.map(e=>e.length)}),yield*d(r,n,`dsl-error`,1,null,K({...$,outcome:`dsl-error`,failedStep:1,toolTimings:e}),`get_node_dsl: ${String(f.texts.length)} ${c(`text items in the response — expected 1`,`текстовых частей в ответе — ожидалась 1`)}`);return}let p=f.texts[0]??``;if(yield*o({tool:`get_node_dsl`,ms:f.ms,ok:!0,detail:null}),b.Buffer.byteLength(p,`utf8`)>fa){let e=yield*y.get(i);yield*d(r,n,`dsl-error`,1,null,K({...$,outcome:`dsl-error`,failedStep:1,toolTimings:e}),c(`The selection is too large to read — pick a smaller frame.`,`Выделение слишком велико для чтения — выберите фрейм поменьше.`));return}let m=ut(p),h=m.detachedNodes.length===0?m.root:null;if(!m.ok||h===null){let{outcome:e,failedStep:t}=Ki(m),a=yield*y.get(i);yield*d(r,n,e,t,null,K({...$,outcome:e,failedStep:t,parsed:m,root:m.root,toolTimings:a}),Zi(m,e));return}let g=Yi(m,h);if(g.verdict===`incompatible`){let e=yield*y.get(i);yield*_.logError(`[pixso] unsupported DSL version rejected`,{detail:g.detail}),yield*d(r,n,`parse-error`,3,null,K({...$,outcome:`parse-error`,failedStep:3,parsed:m,root:h,toolTimings:e}),Xi());return}yield*y.set(a,2),yield*s(r,{phase:`running`,step:2,startedAtIso:n});let v=yield*e.callTool(`get_all_components`,{});v.ok&&v.texts.length>1&&(yield*_.logDebug(`[pixso] get_all_components extra text items`,{items:v.texts.length,extraSizes:v.texts.slice(1).map(e=>e.length)}));let x=v.ok?v.texts[0]??``:null;yield*o({tool:`get_all_components`,ms:v.ms,ok:v.ok,detail:v.ok?null:v.message}),yield*y.set(a,3),yield*s(r,{phase:`running`,step:3,startedAtIso:n});let S=v.ok?ht(x??``):null;if(S===null||!Wi(S)){let e=yield*y.get(i);yield*d(r,n,`components-error`,2,null,K({outcome:`components-error`,failedStep:2,parsed:m,root:h,componentsUsed:[],catalogStatus:`failed`,catalogDiagnostics:S?.diagnostics??[],toolTimings:e,duplicate:!1,byteDiff:null}),v.ok?`get_all_components: ${S?.diagnostics[0]?.message??`invalid catalog`}`:`get_all_components: ${v.message}`);return}let C=Ln(h);if(C!==null){let e=yield*y.get(i);yield*d(r,n,`internal-error`,3,null,K({...$,outcome:`internal-error`,failedStep:3,parsed:m,root:h,toolTimings:e,catalogStatus:v.ok?`ok`:`failed`}),C);return}let w=Nn(m,h,S.entries),T=g.verdict===`compatible`,E=w.hasWarnings||T?`success-warnings`:`success`,ee=yield*y.get(i),D=K({outcome:E,failedStep:null,parsed:m,root:h,componentsUsed:w.card.componentsUsed,catalogStatus:`ok`,catalogDiagnostics:S.diagnostics,toolTimings:ee,duplicate:!1,byteDiff:null}),O=T?{...D,diagnostics:[{severity:`warning`,code:`version-unverified`,message:`${c(`Format version outside the supported list — accepted by the structural compatibility check`,`Версия формата вне поддерживаемого списка — принята проверкой структурной совместимости`)} (${g.detail??``})`},...D.diagnostics]}:D,k=yield*l;yield*t.persistScan({dslRaw:p,catalogRaw:x,capturedAtIso:k,card:T?{...w.card,versionUnverified:!0}:w.card,summary:w.summary,report:O},e=>u({seq:r,startedAtIso:n,settledAtIso:k,outcome:e.duplicate?`reimport`:E,failedStep:null,cardId:e.id,detail:e.duplicate||E!==`success-warnings`?null:Qi(O),report:{...O,duplicate:e.duplicate}}))}).pipe(_.timeoutOrElse({duration:ua,orElse:()=>_.gen(function*(){let e=yield*y.get(i),t=yield*y.get(a);yield*d(r,n,`tool-timeout`,t,null,K({...$,outcome:`tool-timeout`,failedStep:t,toolTimings:e}))})}),_.catchCause(e=>_.gen(function*(){let t=String(e);yield*_.logError(`[pixso] scan pipeline defect`,{cause:t});let o=yield*y.get(i),s=yield*y.get(a),c=t.length>da?`${t.slice(0,da)}…`:t;yield*d(r,n,`dsl-error`,s,null,K({...$,outcome:`dsl-error`,failedStep:s,toolTimings:[...o,{tool:`pipeline`,ms:0,ok:!1,detail:c}]}))})))}),p=()=>r.withPermits(1)(_.gen(function*(){let e=yield*j.get(n);if(e.phase===`running`)return e;let t=yield*l,r={phase:`running`,step:0,startedAtIso:t},a=yield*sa(i);return yield*j.set(n,r),yield*_.logDebug(`[pixso] scan start`,{startedAtIso:t,seq:a}),yield*_.forkDetach(f(t,a)),r})),m=()=>_.gen(function*(){if((yield*j.get(n)).phase===`running`)return yield*new a({detail:c(`A scan is already running — wait for it to finish.`,`Скан уже выполняется — дождитесь его завершения.`)});let r=yield*e.listTools();if(!r.ok)return yield*_.logError(`[pixso] check failed`,{ms:r.ms,timedOut:r.timedOut,origin:r.origin,message:r.message}),yield*new a({detail:`${c(`Failed to connect to Pixso MCP`,`Не удалось подключиться к Pixso MCP`)}: ${r.message}`});let i={atIso:yield*l,tools:r.tools.map(e=>({name:e.name,description:e.description,write:Ct(e.name),params:e.params.map(e=>({name:e.name,type:e.type,required:e.required,...e.description===void 0?{}:{description:e.description}}))}))};return yield*t.recordCheck(i),yield*_.logDebug(`[pixso] check ok`,{ms:r.ms,tools:i.tools.length,write:i.tools.filter(e=>e.write).length}),i}),h=()=>_.gen(function*(){if((yield*j.get(n)).phase===`running`)return yield*new a({detail:c(`A scan is already running — wait for it to finish.`,`Скан уже выполняется — дождитесь его завершения.`)});let r=[],i=yield*e.callTool(`get_node_dsl`,{}),o=yield*l;if(!i.ok){r.push({tool:`get_node_dsl`,ms:i.ms,ok:!1,detail:i.message});let{outcome:e,failedStep:n}=Gi(i),a={atIso:o,data:K({...$,outcome:e,failedStep:n,toolTimings:r})};return yield*t.recordReport(a),a}let s=i.texts[0]??``;if(r.push({tool:`get_node_dsl`,ms:i.ms,ok:!0,detail:null}),b.Buffer.byteLength(s,`utf8`)>fa){let e={atIso:o,data:K({...$,outcome:`dsl-error`,failedStep:1,toolTimings:r})};return yield*t.recordReport(e),e}let u=ut(s),d=u.detachedNodes.length===0?u.root:null,f=null;if(d!==null){let e=yield*t.findScanByNodeId(d.guid);if(e!==null){let n=yield*t.getCardRaw(e).pipe(_.orElseSucceed(()=>null));n!==null&&(f=$i(n,s))}}if(!u.ok||d===null){let{outcome:e,failedStep:n}=Ki(u),i={atIso:o,data:K({...$,outcome:e,failedStep:n,parsed:u,root:u.root,toolTimings:r,byteDiff:f})};return yield*t.recordReport(i),i}if(Yi(u,d).verdict===`incompatible`){let e={atIso:o,data:K({...$,outcome:`parse-error`,failedStep:3,parsed:u,root:d,toolTimings:r,byteDiff:f})};return yield*t.recordReport(e),e}let p={atIso:o,data:K({outcome:u.diagnostics.some(e=>e.severity===`warning`)?`success-warnings`:`success`,failedStep:null,parsed:u,root:d,componentsUsed:[],catalogStatus:`skipped`,catalogDiagnostics:[],toolTimings:r,duplicate:!1,byteDiff:f})};return yield*t.recordReport(p),p});return{state:j.get(n),changes:j.changes(n),start:p,check:m,rescanDebug:()=>h().pipe(_.tap(e=>_.logDebug(`[pixso] rescan`,ia(e.data)))),reparseStored:()=>_.gen(function*(){if((yield*j.get(n)).phase===`running`)return yield*new a({detail:c(`A scan is already running — wait for it to finish.`,`Скан уже выполняется — дождитесь его завершения.`)});let e=yield*t.reparseScans(({dslRaw:e,catalogRaw:t})=>{let n=ut(e),r=n.detachedNodes.length===0?n.root:null;if(!n.ok||r===null)return null;let i=Yi(n,r);if(i.verdict===`incompatible`)return null;let a=t===null?null:ht(t),o=Nn(n,r,a!==null&&Wi(a)?a.entries:[]);return{card:i.verdict===`compatible`?{...o.card,versionUnverified:!0}:o.card,summary:o.summary}});return yield*_.logDebug(`[pixso] reparse`,{...e}),e})}}),ha=v.effect(pa,ma);var ga=class extends g.Service()(`@smart-tools/t3-code-pixso-mcp-assistant/server/PixsoAssistantService/PixsoAssistant`){};const _a=_.gen(function*(){let e=yield*gr,t=yield*pa,n=yield*Oi,r=yield*y.make(new Map);return{getSnapshot:()=>e.getSnapshot(),getCard:t=>e.getCard(t),getCardRaw:t=>e.getCardRaw(t).pipe(_.map(e=>({raw:e}))),removeCard:t=>e.removeCard(t),mutateGallery:t=>e.mutateGallery(t),getLatestReport:()=>e.getLatestReport(),getCatalog:t=>_.gen(function*(){let n=(yield*y.get(r)).get(t);if(n!==void 0)return n;let{raw:i,capturedAtIso:a}=yield*e.getCatalogRaw(t),o=gt(a,ht(i).entries);return yield*y.update(r,e=>{let n=new Map(e);if(n.size>=2&&!n.has(t)){let e=n.keys().next().value;e!==void 0&&n.delete(e)}return n.set(t,o),n}),o}),scanStart:()=>t.start(),scanStates:()=>t.changes,check:()=>t.check(),probe:()=>n.run(),rescanDebug:()=>t.rescanDebug(),reparseStored:()=>t.reparseStored()}}),va=v.effect(ga,_a).pipe(v.provide(ha),v.provide(Ui),v.provide(vr));export{Wt as C,Gt as S,$n as _,aa as a,Kt as b,Ui as c,ci as d,si as f,Zn as g,Qn as h,ha as i,li as l,vr as m,va as n,oa as o,gr as p,pa as r,Oi as s,ga as t,ri as u,Pn as v,Ut as x,Jt as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!r.call(i,d)&&d!==o&&e(i,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return i},o=(e,t,n)=>(a(e,t,`default`),n&&a(n,t,`default`));export{o as n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`http://127.0.0.1:3667/mcp`;export{e as t};
|